You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46582 lines
1.3 MiB

  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, {
  40. /******/ configurable: false,
  41. /******/ enumerable: true,
  42. /******/ get: getter
  43. /******/ });
  44. /******/ }
  45. /******/ };
  46. /******/
  47. /******/ // getDefaultExport function for compatibility with non-harmony modules
  48. /******/ __webpack_require__.n = function(module) {
  49. /******/ var getter = module && module.__esModule ?
  50. /******/ function getDefault() { return module['default']; } :
  51. /******/ function getModuleExports() { return module; };
  52. /******/ __webpack_require__.d(getter, 'a', getter);
  53. /******/ return getter;
  54. /******/ };
  55. /******/
  56. /******/ // Object.prototype.hasOwnProperty.call
  57. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  58. /******/
  59. /******/ // __webpack_public_path__
  60. /******/ __webpack_require__.p = "";
  61. /******/
  62. /******/ // Load entry module and return exports
  63. /******/ return __webpack_require__(__webpack_require__.s = 9);
  64. /******/ })
  65. /************************************************************************/
  66. /******/ ([
  67. /* 0 */
  68. /***/ (function(module, exports, __webpack_require__) {
  69. "use strict";
  70. var bind = __webpack_require__(3);
  71. var isBuffer = __webpack_require__(18);
  72. /*global toString:true*/
  73. // utils is a library of generic helper functions non-specific to axios
  74. var toString = Object.prototype.toString;
  75. /**
  76. * Determine if a value is an Array
  77. *
  78. * @param {Object} val The value to test
  79. * @returns {boolean} True if value is an Array, otherwise false
  80. */
  81. function isArray(val) {
  82. return toString.call(val) === '[object Array]';
  83. }
  84. /**
  85. * Determine if a value is an ArrayBuffer
  86. *
  87. * @param {Object} val The value to test
  88. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  89. */
  90. function isArrayBuffer(val) {
  91. return toString.call(val) === '[object ArrayBuffer]';
  92. }
  93. /**
  94. * Determine if a value is a FormData
  95. *
  96. * @param {Object} val The value to test
  97. * @returns {boolean} True if value is an FormData, otherwise false
  98. */
  99. function isFormData(val) {
  100. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  101. }
  102. /**
  103. * Determine if a value is a view on an ArrayBuffer
  104. *
  105. * @param {Object} val The value to test
  106. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  107. */
  108. function isArrayBufferView(val) {
  109. var result;
  110. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  111. result = ArrayBuffer.isView(val);
  112. } else {
  113. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  114. }
  115. return result;
  116. }
  117. /**
  118. * Determine if a value is a String
  119. *
  120. * @param {Object} val The value to test
  121. * @returns {boolean} True if value is a String, otherwise false
  122. */
  123. function isString(val) {
  124. return typeof val === 'string';
  125. }
  126. /**
  127. * Determine if a value is a Number
  128. *
  129. * @param {Object} val The value to test
  130. * @returns {boolean} True if value is a Number, otherwise false
  131. */
  132. function isNumber(val) {
  133. return typeof val === 'number';
  134. }
  135. /**
  136. * Determine if a value is undefined
  137. *
  138. * @param {Object} val The value to test
  139. * @returns {boolean} True if the value is undefined, otherwise false
  140. */
  141. function isUndefined(val) {
  142. return typeof val === 'undefined';
  143. }
  144. /**
  145. * Determine if a value is an Object
  146. *
  147. * @param {Object} val The value to test
  148. * @returns {boolean} True if value is an Object, otherwise false
  149. */
  150. function isObject(val) {
  151. return val !== null && typeof val === 'object';
  152. }
  153. /**
  154. * Determine if a value is a Date
  155. *
  156. * @param {Object} val The value to test
  157. * @returns {boolean} True if value is a Date, otherwise false
  158. */
  159. function isDate(val) {
  160. return toString.call(val) === '[object Date]';
  161. }
  162. /**
  163. * Determine if a value is a File
  164. *
  165. * @param {Object} val The value to test
  166. * @returns {boolean} True if value is a File, otherwise false
  167. */
  168. function isFile(val) {
  169. return toString.call(val) === '[object File]';
  170. }
  171. /**
  172. * Determine if a value is a Blob
  173. *
  174. * @param {Object} val The value to test
  175. * @returns {boolean} True if value is a Blob, otherwise false
  176. */
  177. function isBlob(val) {
  178. return toString.call(val) === '[object Blob]';
  179. }
  180. /**
  181. * Determine if a value is a Function
  182. *
  183. * @param {Object} val The value to test
  184. * @returns {boolean} True if value is a Function, otherwise false
  185. */
  186. function isFunction(val) {
  187. return toString.call(val) === '[object Function]';
  188. }
  189. /**
  190. * Determine if a value is a Stream
  191. *
  192. * @param {Object} val The value to test
  193. * @returns {boolean} True if value is a Stream, otherwise false
  194. */
  195. function isStream(val) {
  196. return isObject(val) && isFunction(val.pipe);
  197. }
  198. /**
  199. * Determine if a value is a URLSearchParams object
  200. *
  201. * @param {Object} val The value to test
  202. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  203. */
  204. function isURLSearchParams(val) {
  205. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  206. }
  207. /**
  208. * Trim excess whitespace off the beginning and end of a string
  209. *
  210. * @param {String} str The String to trim
  211. * @returns {String} The String freed of excess whitespace
  212. */
  213. function trim(str) {
  214. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  215. }
  216. /**
  217. * Determine if we're running in a standard browser environment
  218. *
  219. * This allows axios to run in a web worker, and react-native.
  220. * Both environments support XMLHttpRequest, but not fully standard globals.
  221. *
  222. * web workers:
  223. * typeof window -> undefined
  224. * typeof document -> undefined
  225. *
  226. * react-native:
  227. * navigator.product -> 'ReactNative'
  228. */
  229. function isStandardBrowserEnv() {
  230. if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
  231. return false;
  232. }
  233. return (
  234. typeof window !== 'undefined' &&
  235. typeof document !== 'undefined'
  236. );
  237. }
  238. /**
  239. * Iterate over an Array or an Object invoking a function for each item.
  240. *
  241. * If `obj` is an Array callback will be called passing
  242. * the value, index, and complete array for each item.
  243. *
  244. * If 'obj' is an Object callback will be called passing
  245. * the value, key, and complete object for each property.
  246. *
  247. * @param {Object|Array} obj The object to iterate
  248. * @param {Function} fn The callback to invoke for each item
  249. */
  250. function forEach(obj, fn) {
  251. // Don't bother if no value provided
  252. if (obj === null || typeof obj === 'undefined') {
  253. return;
  254. }
  255. // Force an array if not already something iterable
  256. if (typeof obj !== 'object' && !isArray(obj)) {
  257. /*eslint no-param-reassign:0*/
  258. obj = [obj];
  259. }
  260. if (isArray(obj)) {
  261. // Iterate over array values
  262. for (var i = 0, l = obj.length; i < l; i++) {
  263. fn.call(null, obj[i], i, obj);
  264. }
  265. } else {
  266. // Iterate over object keys
  267. for (var key in obj) {
  268. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  269. fn.call(null, obj[key], key, obj);
  270. }
  271. }
  272. }
  273. }
  274. /**
  275. * Accepts varargs expecting each argument to be an object, then
  276. * immutably merges the properties of each object and returns result.
  277. *
  278. * When multiple objects contain the same key the later object in
  279. * the arguments list will take precedence.
  280. *
  281. * Example:
  282. *
  283. * ```js
  284. * var result = merge({foo: 123}, {foo: 456});
  285. * console.log(result.foo); // outputs 456
  286. * ```
  287. *
  288. * @param {Object} obj1 Object to merge
  289. * @returns {Object} Result of all merge properties
  290. */
  291. function merge(/* obj1, obj2, obj3, ... */) {
  292. var result = {};
  293. function assignValue(val, key) {
  294. if (typeof result[key] === 'object' && typeof val === 'object') {
  295. result[key] = merge(result[key], val);
  296. } else {
  297. result[key] = val;
  298. }
  299. }
  300. for (var i = 0, l = arguments.length; i < l; i++) {
  301. forEach(arguments[i], assignValue);
  302. }
  303. return result;
  304. }
  305. /**
  306. * Extends object a by mutably adding to it the properties of object b.
  307. *
  308. * @param {Object} a The object to be extended
  309. * @param {Object} b The object to copy properties from
  310. * @param {Object} thisArg The object to bind function to
  311. * @return {Object} The resulting value of object a
  312. */
  313. function extend(a, b, thisArg) {
  314. forEach(b, function assignValue(val, key) {
  315. if (thisArg && typeof val === 'function') {
  316. a[key] = bind(val, thisArg);
  317. } else {
  318. a[key] = val;
  319. }
  320. });
  321. return a;
  322. }
  323. module.exports = {
  324. isArray: isArray,
  325. isArrayBuffer: isArrayBuffer,
  326. isBuffer: isBuffer,
  327. isFormData: isFormData,
  328. isArrayBufferView: isArrayBufferView,
  329. isString: isString,
  330. isNumber: isNumber,
  331. isObject: isObject,
  332. isUndefined: isUndefined,
  333. isDate: isDate,
  334. isFile: isFile,
  335. isBlob: isBlob,
  336. isFunction: isFunction,
  337. isStream: isStream,
  338. isURLSearchParams: isURLSearchParams,
  339. isStandardBrowserEnv: isStandardBrowserEnv,
  340. forEach: forEach,
  341. merge: merge,
  342. extend: extend,
  343. trim: trim
  344. };
  345. /***/ }),
  346. /* 1 */
  347. /***/ (function(module, exports, __webpack_require__) {
  348. "use strict";
  349. /* WEBPACK VAR INJECTION */(function(process) {
  350. var utils = __webpack_require__(0);
  351. var normalizeHeaderName = __webpack_require__(21);
  352. var DEFAULT_CONTENT_TYPE = {
  353. 'Content-Type': 'application/x-www-form-urlencoded'
  354. };
  355. function setContentTypeIfUnset(headers, value) {
  356. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  357. headers['Content-Type'] = value;
  358. }
  359. }
  360. function getDefaultAdapter() {
  361. var adapter;
  362. if (typeof XMLHttpRequest !== 'undefined') {
  363. // For browsers use XHR adapter
  364. adapter = __webpack_require__(4);
  365. } else if (typeof process !== 'undefined') {
  366. // For node use HTTP adapter
  367. adapter = __webpack_require__(4);
  368. }
  369. return adapter;
  370. }
  371. var defaults = {
  372. adapter: getDefaultAdapter(),
  373. transformRequest: [function transformRequest(data, headers) {
  374. normalizeHeaderName(headers, 'Content-Type');
  375. if (utils.isFormData(data) ||
  376. utils.isArrayBuffer(data) ||
  377. utils.isBuffer(data) ||
  378. utils.isStream(data) ||
  379. utils.isFile(data) ||
  380. utils.isBlob(data)
  381. ) {
  382. return data;
  383. }
  384. if (utils.isArrayBufferView(data)) {
  385. return data.buffer;
  386. }
  387. if (utils.isURLSearchParams(data)) {
  388. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  389. return data.toString();
  390. }
  391. if (utils.isObject(data)) {
  392. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  393. return JSON.stringify(data);
  394. }
  395. return data;
  396. }],
  397. transformResponse: [function transformResponse(data) {
  398. /*eslint no-param-reassign:0*/
  399. if (typeof data === 'string') {
  400. try {
  401. data = JSON.parse(data);
  402. } catch (e) { /* Ignore */ }
  403. }
  404. return data;
  405. }],
  406. timeout: 0,
  407. xsrfCookieName: 'XSRF-TOKEN',
  408. xsrfHeaderName: 'X-XSRF-TOKEN',
  409. maxContentLength: -1,
  410. validateStatus: function validateStatus(status) {
  411. return status >= 200 && status < 300;
  412. }
  413. };
  414. defaults.headers = {
  415. common: {
  416. 'Accept': 'application/json, text/plain, */*'
  417. }
  418. };
  419. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  420. defaults.headers[method] = {};
  421. });
  422. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  423. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  424. });
  425. module.exports = defaults;
  426. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(20)))
  427. /***/ }),
  428. /* 2 */
  429. /***/ (function(module, exports) {
  430. var g;
  431. // This works in non-strict mode
  432. g = (function() {
  433. return this;
  434. })();
  435. try {
  436. // This works if eval is allowed (see CSP)
  437. g = g || Function("return this")() || (1,eval)("this");
  438. } catch(e) {
  439. // This works if the window reference is available
  440. if(typeof window === "object")
  441. g = window;
  442. }
  443. // g can still be undefined, but nothing to do about it...
  444. // We return undefined, instead of nothing here, so it's
  445. // easier to handle this case. if(!global) { ...}
  446. module.exports = g;
  447. /***/ }),
  448. /* 3 */
  449. /***/ (function(module, exports, __webpack_require__) {
  450. "use strict";
  451. module.exports = function bind(fn, thisArg) {
  452. return function wrap() {
  453. var args = new Array(arguments.length);
  454. for (var i = 0; i < args.length; i++) {
  455. args[i] = arguments[i];
  456. }
  457. return fn.apply(thisArg, args);
  458. };
  459. };
  460. /***/ }),
  461. /* 4 */
  462. /***/ (function(module, exports, __webpack_require__) {
  463. "use strict";
  464. var utils = __webpack_require__(0);
  465. var settle = __webpack_require__(22);
  466. var buildURL = __webpack_require__(24);
  467. var parseHeaders = __webpack_require__(25);
  468. var isURLSameOrigin = __webpack_require__(26);
  469. var createError = __webpack_require__(5);
  470. var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(27);
  471. module.exports = function xhrAdapter(config) {
  472. return new Promise(function dispatchXhrRequest(resolve, reject) {
  473. var requestData = config.data;
  474. var requestHeaders = config.headers;
  475. if (utils.isFormData(requestData)) {
  476. delete requestHeaders['Content-Type']; // Let the browser set it
  477. }
  478. var request = new XMLHttpRequest();
  479. var loadEvent = 'onreadystatechange';
  480. var xDomain = false;
  481. // For IE 8/9 CORS support
  482. // Only supports POST and GET calls and doesn't returns the response headers.
  483. // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
  484. if ("development" !== 'test' &&
  485. typeof window !== 'undefined' &&
  486. window.XDomainRequest && !('withCredentials' in request) &&
  487. !isURLSameOrigin(config.url)) {
  488. request = new window.XDomainRequest();
  489. loadEvent = 'onload';
  490. xDomain = true;
  491. request.onprogress = function handleProgress() {};
  492. request.ontimeout = function handleTimeout() {};
  493. }
  494. // HTTP basic authentication
  495. if (config.auth) {
  496. var username = config.auth.username || '';
  497. var password = config.auth.password || '';
  498. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  499. }
  500. request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
  501. // Set the request timeout in MS
  502. request.timeout = config.timeout;
  503. // Listen for ready state
  504. request[loadEvent] = function handleLoad() {
  505. if (!request || (request.readyState !== 4 && !xDomain)) {
  506. return;
  507. }
  508. // The request errored out and we didn't get a response, this will be
  509. // handled by onerror instead
  510. // With one exception: request that using file: protocol, most browsers
  511. // will return status as 0 even though it's a successful request
  512. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  513. return;
  514. }
  515. // Prepare the response
  516. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  517. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  518. var response = {
  519. data: responseData,
  520. // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)
  521. status: request.status === 1223 ? 204 : request.status,
  522. statusText: request.status === 1223 ? 'No Content' : request.statusText,
  523. headers: responseHeaders,
  524. config: config,
  525. request: request
  526. };
  527. settle(resolve, reject, response);
  528. // Clean up request
  529. request = null;
  530. };
  531. // Handle low level network errors
  532. request.onerror = function handleError() {
  533. // Real errors are hidden from us by the browser
  534. // onerror should only fire if it's a network error
  535. reject(createError('Network Error', config, null, request));
  536. // Clean up request
  537. request = null;
  538. };
  539. // Handle timeout
  540. request.ontimeout = function handleTimeout() {
  541. reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
  542. request));
  543. // Clean up request
  544. request = null;
  545. };
  546. // Add xsrf header
  547. // This is only done if running in a standard browser environment.
  548. // Specifically not if we're in a web worker, or react-native.
  549. if (utils.isStandardBrowserEnv()) {
  550. var cookies = __webpack_require__(28);
  551. // Add xsrf header
  552. var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
  553. cookies.read(config.xsrfCookieName) :
  554. undefined;
  555. if (xsrfValue) {
  556. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  557. }
  558. }
  559. // Add headers to the request
  560. if ('setRequestHeader' in request) {
  561. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  562. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  563. // Remove Content-Type if data is undefined
  564. delete requestHeaders[key];
  565. } else {
  566. // Otherwise add header to the request
  567. request.setRequestHeader(key, val);
  568. }
  569. });
  570. }
  571. // Add withCredentials to request if needed
  572. if (config.withCredentials) {
  573. request.withCredentials = true;
  574. }
  575. // Add responseType to request if needed
  576. if (config.responseType) {
  577. try {
  578. request.responseType = config.responseType;
  579. } catch (e) {
  580. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  581. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  582. if (config.responseType !== 'json') {
  583. throw e;
  584. }
  585. }
  586. }
  587. // Handle progress if needed
  588. if (typeof config.onDownloadProgress === 'function') {
  589. request.addEventListener('progress', config.onDownloadProgress);
  590. }
  591. // Not all browsers support upload events
  592. if (typeof config.onUploadProgress === 'function' && request.upload) {
  593. request.upload.addEventListener('progress', config.onUploadProgress);
  594. }
  595. if (config.cancelToken) {
  596. // Handle cancellation
  597. config.cancelToken.promise.then(function onCanceled(cancel) {
  598. if (!request) {
  599. return;
  600. }
  601. request.abort();
  602. reject(cancel);
  603. // Clean up request
  604. request = null;
  605. });
  606. }
  607. if (requestData === undefined) {
  608. requestData = null;
  609. }
  610. // Send the request
  611. request.send(requestData);
  612. });
  613. };
  614. /***/ }),
  615. /* 5 */
  616. /***/ (function(module, exports, __webpack_require__) {
  617. "use strict";
  618. var enhanceError = __webpack_require__(23);
  619. /**
  620. * Create an Error with the specified message, config, error code, request and response.
  621. *
  622. * @param {string} message The error message.
  623. * @param {Object} config The config.
  624. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  625. * @param {Object} [request] The request.
  626. * @param {Object} [response] The response.
  627. * @returns {Error} The created error.
  628. */
  629. module.exports = function createError(message, config, code, request, response) {
  630. var error = new Error(message);
  631. return enhanceError(error, config, code, request, response);
  632. };
  633. /***/ }),
  634. /* 6 */
  635. /***/ (function(module, exports, __webpack_require__) {
  636. "use strict";
  637. module.exports = function isCancel(value) {
  638. return !!(value && value.__CANCEL__);
  639. };
  640. /***/ }),
  641. /* 7 */
  642. /***/ (function(module, exports, __webpack_require__) {
  643. "use strict";
  644. /**
  645. * A `Cancel` is an object that is thrown when an operation is canceled.
  646. *
  647. * @class
  648. * @param {string=} message The message.
  649. */
  650. function Cancel(message) {
  651. this.message = message;
  652. }
  653. Cancel.prototype.toString = function toString() {
  654. return 'Cancel' + (this.message ? ': ' + this.message : '');
  655. };
  656. Cancel.prototype.__CANCEL__ = true;
  657. module.exports = Cancel;
  658. /***/ }),
  659. /* 8 */
  660. /***/ (function(module, exports) {
  661. /* globals __VUE_SSR_CONTEXT__ */
  662. // this module is a runtime utility for cleaner component module output and will
  663. // be included in the final webpack user bundle
  664. module.exports = function normalizeComponent (
  665. rawScriptExports,
  666. compiledTemplate,
  667. injectStyles,
  668. scopeId,
  669. moduleIdentifier /* server only */
  670. ) {
  671. var esModule
  672. var scriptExports = rawScriptExports = rawScriptExports || {}
  673. // ES6 modules interop
  674. var type = typeof rawScriptExports.default
  675. if (type === 'object' || type === 'function') {
  676. esModule = rawScriptExports
  677. scriptExports = rawScriptExports.default
  678. }
  679. // Vue.extend constructor export interop
  680. var options = typeof scriptExports === 'function'
  681. ? scriptExports.options
  682. : scriptExports
  683. // render functions
  684. if (compiledTemplate) {
  685. options.render = compiledTemplate.render
  686. options.staticRenderFns = compiledTemplate.staticRenderFns
  687. }
  688. // scopedId
  689. if (scopeId) {
  690. options._scopeId = scopeId
  691. }
  692. var hook
  693. if (moduleIdentifier) { // server build
  694. hook = function (context) {
  695. // 2.3 injection
  696. context =
  697. context || // cached call
  698. (this.$vnode && this.$vnode.ssrContext) || // stateful
  699. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  700. // 2.2 with runInNewContext: true
  701. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  702. context = __VUE_SSR_CONTEXT__
  703. }
  704. // inject component styles
  705. if (injectStyles) {
  706. injectStyles.call(this, context)
  707. }
  708. // register component module identifier for async chunk inferrence
  709. if (context && context._registeredComponents) {
  710. context._registeredComponents.add(moduleIdentifier)
  711. }
  712. }
  713. // used by ssr in case component is cached and beforeCreate
  714. // never gets called
  715. options._ssrRegister = hook
  716. } else if (injectStyles) {
  717. hook = injectStyles
  718. }
  719. if (hook) {
  720. var functional = options.functional
  721. var existing = functional
  722. ? options.render
  723. : options.beforeCreate
  724. if (!functional) {
  725. // inject component registration as beforeCreate hook
  726. options.beforeCreate = existing
  727. ? [].concat(existing, hook)
  728. : [hook]
  729. } else {
  730. // register for functioal component in vue file
  731. options.render = function renderWithStyleInjection (h, context) {
  732. hook.call(context)
  733. return existing(h, context)
  734. }
  735. }
  736. }
  737. return {
  738. esModule: esModule,
  739. exports: scriptExports,
  740. options: options
  741. }
  742. }
  743. /***/ }),
  744. /* 9 */
  745. /***/ (function(module, exports, __webpack_require__) {
  746. __webpack_require__(10);
  747. module.exports = __webpack_require__(45);
  748. /***/ }),
  749. /* 10 */
  750. /***/ (function(module, exports, __webpack_require__) {
  751. /**
  752. * First we will load all of this project's JavaScript dependencies which
  753. * includes Vue and other libraries. It is a great starting point when
  754. * building robust, powerful web applications using Vue and Laravel.
  755. */
  756. __webpack_require__(11);
  757. window.Vue = __webpack_require__(38);
  758. /**
  759. * Next, we will create a fresh Vue application instance and attach it to
  760. * the page. Then, you may begin adding components to this application
  761. * or customize the JavaScript scaffolding to fit your unique needs.
  762. */
  763. Vue.component('example', __webpack_require__(39));
  764. Vue.component('team-list', __webpack_require__(42));
  765. var app = new Vue({
  766. el: '#app'
  767. });
  768. $.ajaxSetup({
  769. headers: {
  770. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  771. }
  772. });
  773. /***/ }),
  774. /* 11 */
  775. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  776. "use strict";
  777. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  778. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_laravel_echo__ = __webpack_require__(36);
  779. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_laravel_echo___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_laravel_echo__);
  780. window._ = __webpack_require__(12);
  781. /**
  782. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  783. * for JavaScript based Bootstrap features such as modals and tabs. This
  784. * code may be modified to fit the specific needs of your application.
  785. */
  786. try {
  787. window.$ = window.jQuery = __webpack_require__(14);
  788. __webpack_require__(15);
  789. } catch (e) {}
  790. /**
  791. * We'll load the axios HTTP library which allows us to easily issue requests
  792. * to our Laravel back-end. This library automatically handles sending the
  793. * CSRF token as a header based on the value of the "XSRF" token cookie.
  794. */
  795. window.axios = __webpack_require__(16);
  796. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  797. /**
  798. * Next we will register the CSRF Token as a common header with Axios so that
  799. * all outgoing HTTP requests automatically have it attached. This is just
  800. * a simple convenience so we don't have to attach every token manually.
  801. */
  802. var token = document.head.querySelector('meta[name="csrf-token"]');
  803. if (token) {
  804. window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
  805. } else {
  806. console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
  807. }
  808. /**
  809. * Echo exposes an expressive API for subscribing to channels and listening
  810. * for events that are broadcast by Laravel. Echo and event broadcasting
  811. * allows your team to easily build robust real-time web applications.
  812. */
  813. window.Pusher = __webpack_require__(37);
  814. window.Echo = new __WEBPACK_IMPORTED_MODULE_0_laravel_echo___default.a({
  815. broadcaster: 'pusher',
  816. key: '2083afa65322501623f3',
  817. cluster: 'us2',
  818. encrypted: true
  819. });
  820. /***/ }),
  821. /* 12 */
  822. /***/ (function(module, exports, __webpack_require__) {
  823. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  824. * @license
  825. * Lodash <https://lodash.com/>
  826. * Copyright JS Foundation and other contributors <https://js.foundation/>
  827. * Released under MIT license <https://lodash.com/license>
  828. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  829. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  830. */
  831. ;(function() {
  832. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  833. var undefined;
  834. /** Used as the semantic version number. */
  835. var VERSION = '4.17.4';
  836. /** Used as the size to enable large array optimizations. */
  837. var LARGE_ARRAY_SIZE = 200;
  838. /** Error message constants. */
  839. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  840. FUNC_ERROR_TEXT = 'Expected a function';
  841. /** Used to stand-in for `undefined` hash values. */
  842. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  843. /** Used as the maximum memoize cache size. */
  844. var MAX_MEMOIZE_SIZE = 500;
  845. /** Used as the internal argument placeholder. */
  846. var PLACEHOLDER = '__lodash_placeholder__';
  847. /** Used to compose bitmasks for cloning. */
  848. var CLONE_DEEP_FLAG = 1,
  849. CLONE_FLAT_FLAG = 2,
  850. CLONE_SYMBOLS_FLAG = 4;
  851. /** Used to compose bitmasks for value comparisons. */
  852. var COMPARE_PARTIAL_FLAG = 1,
  853. COMPARE_UNORDERED_FLAG = 2;
  854. /** Used to compose bitmasks for function metadata. */
  855. var WRAP_BIND_FLAG = 1,
  856. WRAP_BIND_KEY_FLAG = 2,
  857. WRAP_CURRY_BOUND_FLAG = 4,
  858. WRAP_CURRY_FLAG = 8,
  859. WRAP_CURRY_RIGHT_FLAG = 16,
  860. WRAP_PARTIAL_FLAG = 32,
  861. WRAP_PARTIAL_RIGHT_FLAG = 64,
  862. WRAP_ARY_FLAG = 128,
  863. WRAP_REARG_FLAG = 256,
  864. WRAP_FLIP_FLAG = 512;
  865. /** Used as default options for `_.truncate`. */
  866. var DEFAULT_TRUNC_LENGTH = 30,
  867. DEFAULT_TRUNC_OMISSION = '...';
  868. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  869. var HOT_COUNT = 800,
  870. HOT_SPAN = 16;
  871. /** Used to indicate the type of lazy iteratees. */
  872. var LAZY_FILTER_FLAG = 1,
  873. LAZY_MAP_FLAG = 2,
  874. LAZY_WHILE_FLAG = 3;
  875. /** Used as references for various `Number` constants. */
  876. var INFINITY = 1 / 0,
  877. MAX_SAFE_INTEGER = 9007199254740991,
  878. MAX_INTEGER = 1.7976931348623157e+308,
  879. NAN = 0 / 0;
  880. /** Used as references for the maximum length and index of an array. */
  881. var MAX_ARRAY_LENGTH = 4294967295,
  882. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  883. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  884. /** Used to associate wrap methods with their bit flags. */
  885. var wrapFlags = [
  886. ['ary', WRAP_ARY_FLAG],
  887. ['bind', WRAP_BIND_FLAG],
  888. ['bindKey', WRAP_BIND_KEY_FLAG],
  889. ['curry', WRAP_CURRY_FLAG],
  890. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  891. ['flip', WRAP_FLIP_FLAG],
  892. ['partial', WRAP_PARTIAL_FLAG],
  893. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  894. ['rearg', WRAP_REARG_FLAG]
  895. ];
  896. /** `Object#toString` result references. */
  897. var argsTag = '[object Arguments]',
  898. arrayTag = '[object Array]',
  899. asyncTag = '[object AsyncFunction]',
  900. boolTag = '[object Boolean]',
  901. dateTag = '[object Date]',
  902. domExcTag = '[object DOMException]',
  903. errorTag = '[object Error]',
  904. funcTag = '[object Function]',
  905. genTag = '[object GeneratorFunction]',
  906. mapTag = '[object Map]',
  907. numberTag = '[object Number]',
  908. nullTag = '[object Null]',
  909. objectTag = '[object Object]',
  910. promiseTag = '[object Promise]',
  911. proxyTag = '[object Proxy]',
  912. regexpTag = '[object RegExp]',
  913. setTag = '[object Set]',
  914. stringTag = '[object String]',
  915. symbolTag = '[object Symbol]',
  916. undefinedTag = '[object Undefined]',
  917. weakMapTag = '[object WeakMap]',
  918. weakSetTag = '[object WeakSet]';
  919. var arrayBufferTag = '[object ArrayBuffer]',
  920. dataViewTag = '[object DataView]',
  921. float32Tag = '[object Float32Array]',
  922. float64Tag = '[object Float64Array]',
  923. int8Tag = '[object Int8Array]',
  924. int16Tag = '[object Int16Array]',
  925. int32Tag = '[object Int32Array]',
  926. uint8Tag = '[object Uint8Array]',
  927. uint8ClampedTag = '[object Uint8ClampedArray]',
  928. uint16Tag = '[object Uint16Array]',
  929. uint32Tag = '[object Uint32Array]';
  930. /** Used to match empty string literals in compiled template source. */
  931. var reEmptyStringLeading = /\b__p \+= '';/g,
  932. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  933. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  934. /** Used to match HTML entities and HTML characters. */
  935. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  936. reUnescapedHtml = /[&<>"']/g,
  937. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  938. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  939. /** Used to match template delimiters. */
  940. var reEscape = /<%-([\s\S]+?)%>/g,
  941. reEvaluate = /<%([\s\S]+?)%>/g,
  942. reInterpolate = /<%=([\s\S]+?)%>/g;
  943. /** Used to match property names within property paths. */
  944. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  945. reIsPlainProp = /^\w*$/,
  946. reLeadingDot = /^\./,
  947. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  948. /**
  949. * Used to match `RegExp`
  950. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  951. */
  952. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  953. reHasRegExpChar = RegExp(reRegExpChar.source);
  954. /** Used to match leading and trailing whitespace. */
  955. var reTrim = /^\s+|\s+$/g,
  956. reTrimStart = /^\s+/,
  957. reTrimEnd = /\s+$/;
  958. /** Used to match wrap detail comments. */
  959. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  960. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  961. reSplitDetails = /,? & /;
  962. /** Used to match words composed of alphanumeric characters. */
  963. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  964. /** Used to match backslashes in property paths. */
  965. var reEscapeChar = /\\(\\)?/g;
  966. /**
  967. * Used to match
  968. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  969. */
  970. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  971. /** Used to match `RegExp` flags from their coerced string values. */
  972. var reFlags = /\w*$/;
  973. /** Used to detect bad signed hexadecimal string values. */
  974. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  975. /** Used to detect binary string values. */
  976. var reIsBinary = /^0b[01]+$/i;
  977. /** Used to detect host constructors (Safari). */
  978. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  979. /** Used to detect octal string values. */
  980. var reIsOctal = /^0o[0-7]+$/i;
  981. /** Used to detect unsigned integer values. */
  982. var reIsUint = /^(?:0|[1-9]\d*)$/;
  983. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  984. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  985. /** Used to ensure capturing order of template delimiters. */
  986. var reNoMatch = /($^)/;
  987. /** Used to match unescaped characters in compiled string literals. */
  988. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  989. /** Used to compose unicode character classes. */
  990. var rsAstralRange = '\\ud800-\\udfff',
  991. rsComboMarksRange = '\\u0300-\\u036f',
  992. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  993. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  994. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  995. rsDingbatRange = '\\u2700-\\u27bf',
  996. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  997. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  998. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  999. rsPunctuationRange = '\\u2000-\\u206f',
  1000. 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',
  1001. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  1002. rsVarRange = '\\ufe0e\\ufe0f',
  1003. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  1004. /** Used to compose unicode capture groups. */
  1005. var rsApos = "['\u2019]",
  1006. rsAstral = '[' + rsAstralRange + ']',
  1007. rsBreak = '[' + rsBreakRange + ']',
  1008. rsCombo = '[' + rsComboRange + ']',
  1009. rsDigits = '\\d+',
  1010. rsDingbat = '[' + rsDingbatRange + ']',
  1011. rsLower = '[' + rsLowerRange + ']',
  1012. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  1013. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  1014. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  1015. rsNonAstral = '[^' + rsAstralRange + ']',
  1016. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  1017. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  1018. rsUpper = '[' + rsUpperRange + ']',
  1019. rsZWJ = '\\u200d';
  1020. /** Used to compose unicode regexes. */
  1021. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  1022. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  1023. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  1024. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  1025. reOptMod = rsModifier + '?',
  1026. rsOptVar = '[' + rsVarRange + ']?',
  1027. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  1028. rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
  1029. rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
  1030. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  1031. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  1032. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  1033. /** Used to match apostrophes. */
  1034. var reApos = RegExp(rsApos, 'g');
  1035. /**
  1036. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  1037. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  1038. */
  1039. var reComboMark = RegExp(rsCombo, 'g');
  1040. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  1041. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  1042. /** Used to match complex or compound words. */
  1043. var reUnicodeWord = RegExp([
  1044. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  1045. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  1046. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  1047. rsUpper + '+' + rsOptContrUpper,
  1048. rsOrdUpper,
  1049. rsOrdLower,
  1050. rsDigits,
  1051. rsEmoji
  1052. ].join('|'), 'g');
  1053. /** 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/). */
  1054. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  1055. /** Used to detect strings that need a more robust regexp to match words. */
  1056. 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 ]/;
  1057. /** Used to assign default `context` object properties. */
  1058. var contextProps = [
  1059. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  1060. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  1061. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  1062. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  1063. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  1064. ];
  1065. /** Used to make template sourceURLs easier to identify. */
  1066. var templateCounter = -1;
  1067. /** Used to identify `toStringTag` values of typed arrays. */
  1068. var typedArrayTags = {};
  1069. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1070. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1071. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1072. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1073. typedArrayTags[uint32Tag] = true;
  1074. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1075. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1076. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  1077. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  1078. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  1079. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  1080. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  1081. typedArrayTags[weakMapTag] = false;
  1082. /** Used to identify `toStringTag` values supported by `_.clone`. */
  1083. var cloneableTags = {};
  1084. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1085. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  1086. cloneableTags[boolTag] = cloneableTags[dateTag] =
  1087. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  1088. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  1089. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  1090. cloneableTags[numberTag] = cloneableTags[objectTag] =
  1091. cloneableTags[regexpTag] = cloneableTags[setTag] =
  1092. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  1093. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  1094. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  1095. cloneableTags[errorTag] = cloneableTags[funcTag] =
  1096. cloneableTags[weakMapTag] = false;
  1097. /** Used to map Latin Unicode letters to basic Latin letters. */
  1098. var deburredLetters = {
  1099. // Latin-1 Supplement block.
  1100. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  1101. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  1102. '\xc7': 'C', '\xe7': 'c',
  1103. '\xd0': 'D', '\xf0': 'd',
  1104. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  1105. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  1106. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  1107. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  1108. '\xd1': 'N', '\xf1': 'n',
  1109. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  1110. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  1111. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  1112. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  1113. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  1114. '\xc6': 'Ae', '\xe6': 'ae',
  1115. '\xde': 'Th', '\xfe': 'th',
  1116. '\xdf': 'ss',
  1117. // Latin Extended-A block.
  1118. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  1119. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  1120. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  1121. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  1122. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  1123. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  1124. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  1125. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  1126. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  1127. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  1128. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  1129. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  1130. '\u0134': 'J', '\u0135': 'j',
  1131. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  1132. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  1133. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  1134. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  1135. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  1136. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  1137. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  1138. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  1139. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  1140. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  1141. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  1142. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  1143. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  1144. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  1145. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  1146. '\u0174': 'W', '\u0175': 'w',
  1147. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  1148. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  1149. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  1150. '\u0132': 'IJ', '\u0133': 'ij',
  1151. '\u0152': 'Oe', '\u0153': 'oe',
  1152. '\u0149': "'n", '\u017f': 's'
  1153. };
  1154. /** Used to map characters to HTML entities. */
  1155. var htmlEscapes = {
  1156. '&': '&amp;',
  1157. '<': '&lt;',
  1158. '>': '&gt;',
  1159. '"': '&quot;',
  1160. "'": '&#39;'
  1161. };
  1162. /** Used to map HTML entities to characters. */
  1163. var htmlUnescapes = {
  1164. '&amp;': '&',
  1165. '&lt;': '<',
  1166. '&gt;': '>',
  1167. '&quot;': '"',
  1168. '&#39;': "'"
  1169. };
  1170. /** Used to escape characters for inclusion in compiled string literals. */
  1171. var stringEscapes = {
  1172. '\\': '\\',
  1173. "'": "'",
  1174. '\n': 'n',
  1175. '\r': 'r',
  1176. '\u2028': 'u2028',
  1177. '\u2029': 'u2029'
  1178. };
  1179. /** Built-in method references without a dependency on `root`. */
  1180. var freeParseFloat = parseFloat,
  1181. freeParseInt = parseInt;
  1182. /** Detect free variable `global` from Node.js. */
  1183. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  1184. /** Detect free variable `self`. */
  1185. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1186. /** Used as a reference to the global object. */
  1187. var root = freeGlobal || freeSelf || Function('return this')();
  1188. /** Detect free variable `exports`. */
  1189. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  1190. /** Detect free variable `module`. */
  1191. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  1192. /** Detect the popular CommonJS extension `module.exports`. */
  1193. var moduleExports = freeModule && freeModule.exports === freeExports;
  1194. /** Detect free variable `process` from Node.js. */
  1195. var freeProcess = moduleExports && freeGlobal.process;
  1196. /** Used to access faster Node.js helpers. */
  1197. var nodeUtil = (function() {
  1198. try {
  1199. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  1200. } catch (e) {}
  1201. }());
  1202. /* Node.js helper references. */
  1203. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  1204. nodeIsDate = nodeUtil && nodeUtil.isDate,
  1205. nodeIsMap = nodeUtil && nodeUtil.isMap,
  1206. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  1207. nodeIsSet = nodeUtil && nodeUtil.isSet,
  1208. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  1209. /*--------------------------------------------------------------------------*/
  1210. /**
  1211. * Adds the key-value `pair` to `map`.
  1212. *
  1213. * @private
  1214. * @param {Object} map The map to modify.
  1215. * @param {Array} pair The key-value pair to add.
  1216. * @returns {Object} Returns `map`.
  1217. */
  1218. function addMapEntry(map, pair) {
  1219. // Don't return `map.set` because it's not chainable in IE 11.
  1220. map.set(pair[0], pair[1]);
  1221. return map;
  1222. }
  1223. /**
  1224. * Adds `value` to `set`.
  1225. *
  1226. * @private
  1227. * @param {Object} set The set to modify.
  1228. * @param {*} value The value to add.
  1229. * @returns {Object} Returns `set`.
  1230. */
  1231. function addSetEntry(set, value) {
  1232. // Don't return `set.add` because it's not chainable in IE 11.
  1233. set.add(value);
  1234. return set;
  1235. }
  1236. /**
  1237. * A faster alternative to `Function#apply`, this function invokes `func`
  1238. * with the `this` binding of `thisArg` and the arguments of `args`.
  1239. *
  1240. * @private
  1241. * @param {Function} func The function to invoke.
  1242. * @param {*} thisArg The `this` binding of `func`.
  1243. * @param {Array} args The arguments to invoke `func` with.
  1244. * @returns {*} Returns the result of `func`.
  1245. */
  1246. function apply(func, thisArg, args) {
  1247. switch (args.length) {
  1248. case 0: return func.call(thisArg);
  1249. case 1: return func.call(thisArg, args[0]);
  1250. case 2: return func.call(thisArg, args[0], args[1]);
  1251. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  1252. }
  1253. return func.apply(thisArg, args);
  1254. }
  1255. /**
  1256. * A specialized version of `baseAggregator` for arrays.
  1257. *
  1258. * @private
  1259. * @param {Array} [array] The array to iterate over.
  1260. * @param {Function} setter The function to set `accumulator` values.
  1261. * @param {Function} iteratee The iteratee to transform keys.
  1262. * @param {Object} accumulator The initial aggregated object.
  1263. * @returns {Function} Returns `accumulator`.
  1264. */
  1265. function arrayAggregator(array, setter, iteratee, accumulator) {
  1266. var index = -1,
  1267. length = array == null ? 0 : array.length;
  1268. while (++index < length) {
  1269. var value = array[index];
  1270. setter(accumulator, value, iteratee(value), array);
  1271. }
  1272. return accumulator;
  1273. }
  1274. /**
  1275. * A specialized version of `_.forEach` for arrays without support for
  1276. * iteratee shorthands.
  1277. *
  1278. * @private
  1279. * @param {Array} [array] The array to iterate over.
  1280. * @param {Function} iteratee The function invoked per iteration.
  1281. * @returns {Array} Returns `array`.
  1282. */
  1283. function arrayEach(array, iteratee) {
  1284. var index = -1,
  1285. length = array == null ? 0 : array.length;
  1286. while (++index < length) {
  1287. if (iteratee(array[index], index, array) === false) {
  1288. break;
  1289. }
  1290. }
  1291. return array;
  1292. }
  1293. /**
  1294. * A specialized version of `_.forEachRight` for arrays without support for
  1295. * iteratee shorthands.
  1296. *
  1297. * @private
  1298. * @param {Array} [array] The array to iterate over.
  1299. * @param {Function} iteratee The function invoked per iteration.
  1300. * @returns {Array} Returns `array`.
  1301. */
  1302. function arrayEachRight(array, iteratee) {
  1303. var length = array == null ? 0 : array.length;
  1304. while (length--) {
  1305. if (iteratee(array[length], length, array) === false) {
  1306. break;
  1307. }
  1308. }
  1309. return array;
  1310. }
  1311. /**
  1312. * A specialized version of `_.every` for arrays without support for
  1313. * iteratee shorthands.
  1314. *
  1315. * @private
  1316. * @param {Array} [array] The array to iterate over.
  1317. * @param {Function} predicate The function invoked per iteration.
  1318. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  1319. * else `false`.
  1320. */
  1321. function arrayEvery(array, predicate) {
  1322. var index = -1,
  1323. length = array == null ? 0 : array.length;
  1324. while (++index < length) {
  1325. if (!predicate(array[index], index, array)) {
  1326. return false;
  1327. }
  1328. }
  1329. return true;
  1330. }
  1331. /**
  1332. * A specialized version of `_.filter` for arrays without support for
  1333. * iteratee shorthands.
  1334. *
  1335. * @private
  1336. * @param {Array} [array] The array to iterate over.
  1337. * @param {Function} predicate The function invoked per iteration.
  1338. * @returns {Array} Returns the new filtered array.
  1339. */
  1340. function arrayFilter(array, predicate) {
  1341. var index = -1,
  1342. length = array == null ? 0 : array.length,
  1343. resIndex = 0,
  1344. result = [];
  1345. while (++index < length) {
  1346. var value = array[index];
  1347. if (predicate(value, index, array)) {
  1348. result[resIndex++] = value;
  1349. }
  1350. }
  1351. return result;
  1352. }
  1353. /**
  1354. * A specialized version of `_.includes` for arrays without support for
  1355. * specifying an index to search from.
  1356. *
  1357. * @private
  1358. * @param {Array} [array] The array to inspect.
  1359. * @param {*} target The value to search for.
  1360. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  1361. */
  1362. function arrayIncludes(array, value) {
  1363. var length = array == null ? 0 : array.length;
  1364. return !!length && baseIndexOf(array, value, 0) > -1;
  1365. }
  1366. /**
  1367. * This function is like `arrayIncludes` except that it accepts a comparator.
  1368. *
  1369. * @private
  1370. * @param {Array} [array] The array to inspect.
  1371. * @param {*} target The value to search for.
  1372. * @param {Function} comparator The comparator invoked per element.
  1373. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  1374. */
  1375. function arrayIncludesWith(array, value, comparator) {
  1376. var index = -1,
  1377. length = array == null ? 0 : array.length;
  1378. while (++index < length) {
  1379. if (comparator(value, array[index])) {
  1380. return true;
  1381. }
  1382. }
  1383. return false;
  1384. }
  1385. /**
  1386. * A specialized version of `_.map` for arrays without support for iteratee
  1387. * shorthands.
  1388. *
  1389. * @private
  1390. * @param {Array} [array] The array to iterate over.
  1391. * @param {Function} iteratee The function invoked per iteration.
  1392. * @returns {Array} Returns the new mapped array.
  1393. */
  1394. function arrayMap(array, iteratee) {
  1395. var index = -1,
  1396. length = array == null ? 0 : array.length,
  1397. result = Array(length);
  1398. while (++index < length) {
  1399. result[index] = iteratee(array[index], index, array);
  1400. }
  1401. return result;
  1402. }
  1403. /**
  1404. * Appends the elements of `values` to `array`.
  1405. *
  1406. * @private
  1407. * @param {Array} array The array to modify.
  1408. * @param {Array} values The values to append.
  1409. * @returns {Array} Returns `array`.
  1410. */
  1411. function arrayPush(array, values) {
  1412. var index = -1,
  1413. length = values.length,
  1414. offset = array.length;
  1415. while (++index < length) {
  1416. array[offset + index] = values[index];
  1417. }
  1418. return array;
  1419. }
  1420. /**
  1421. * A specialized version of `_.reduce` for arrays without support for
  1422. * iteratee shorthands.
  1423. *
  1424. * @private
  1425. * @param {Array} [array] The array to iterate over.
  1426. * @param {Function} iteratee The function invoked per iteration.
  1427. * @param {*} [accumulator] The initial value.
  1428. * @param {boolean} [initAccum] Specify using the first element of `array` as
  1429. * the initial value.
  1430. * @returns {*} Returns the accumulated value.
  1431. */
  1432. function arrayReduce(array, iteratee, accumulator, initAccum) {
  1433. var index = -1,
  1434. length = array == null ? 0 : array.length;
  1435. if (initAccum && length) {
  1436. accumulator = array[++index];
  1437. }
  1438. while (++index < length) {
  1439. accumulator = iteratee(accumulator, array[index], index, array);
  1440. }
  1441. return accumulator;
  1442. }
  1443. /**
  1444. * A specialized version of `_.reduceRight` for arrays without support for
  1445. * iteratee shorthands.
  1446. *
  1447. * @private
  1448. * @param {Array} [array] The array to iterate over.
  1449. * @param {Function} iteratee The function invoked per iteration.
  1450. * @param {*} [accumulator] The initial value.
  1451. * @param {boolean} [initAccum] Specify using the last element of `array` as
  1452. * the initial value.
  1453. * @returns {*} Returns the accumulated value.
  1454. */
  1455. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  1456. var length = array == null ? 0 : array.length;
  1457. if (initAccum && length) {
  1458. accumulator = array[--length];
  1459. }
  1460. while (length--) {
  1461. accumulator = iteratee(accumulator, array[length], length, array);
  1462. }
  1463. return accumulator;
  1464. }
  1465. /**
  1466. * A specialized version of `_.some` for arrays without support for iteratee
  1467. * shorthands.
  1468. *
  1469. * @private
  1470. * @param {Array} [array] The array to iterate over.
  1471. * @param {Function} predicate The function invoked per iteration.
  1472. * @returns {boolean} Returns `true` if any element passes the predicate check,
  1473. * else `false`.
  1474. */
  1475. function arraySome(array, predicate) {
  1476. var index = -1,
  1477. length = array == null ? 0 : array.length;
  1478. while (++index < length) {
  1479. if (predicate(array[index], index, array)) {
  1480. return true;
  1481. }
  1482. }
  1483. return false;
  1484. }
  1485. /**
  1486. * Gets the size of an ASCII `string`.
  1487. *
  1488. * @private
  1489. * @param {string} string The string inspect.
  1490. * @returns {number} Returns the string size.
  1491. */
  1492. var asciiSize = baseProperty('length');
  1493. /**
  1494. * Converts an ASCII `string` to an array.
  1495. *
  1496. * @private
  1497. * @param {string} string The string to convert.
  1498. * @returns {Array} Returns the converted array.
  1499. */
  1500. function asciiToArray(string) {
  1501. return string.split('');
  1502. }
  1503. /**
  1504. * Splits an ASCII `string` into an array of its words.
  1505. *
  1506. * @private
  1507. * @param {string} The string to inspect.
  1508. * @returns {Array} Returns the words of `string`.
  1509. */
  1510. function asciiWords(string) {
  1511. return string.match(reAsciiWord) || [];
  1512. }
  1513. /**
  1514. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  1515. * without support for iteratee shorthands, which iterates over `collection`
  1516. * using `eachFunc`.
  1517. *
  1518. * @private
  1519. * @param {Array|Object} collection The collection to inspect.
  1520. * @param {Function} predicate The function invoked per iteration.
  1521. * @param {Function} eachFunc The function to iterate over `collection`.
  1522. * @returns {*} Returns the found element or its key, else `undefined`.
  1523. */
  1524. function baseFindKey(collection, predicate, eachFunc) {
  1525. var result;
  1526. eachFunc(collection, function(value, key, collection) {
  1527. if (predicate(value, key, collection)) {
  1528. result = key;
  1529. return false;
  1530. }
  1531. });
  1532. return result;
  1533. }
  1534. /**
  1535. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  1536. * support for iteratee shorthands.
  1537. *
  1538. * @private
  1539. * @param {Array} array The array to inspect.
  1540. * @param {Function} predicate The function invoked per iteration.
  1541. * @param {number} fromIndex The index to search from.
  1542. * @param {boolean} [fromRight] Specify iterating from right to left.
  1543. * @returns {number} Returns the index of the matched value, else `-1`.
  1544. */
  1545. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  1546. var length = array.length,
  1547. index = fromIndex + (fromRight ? 1 : -1);
  1548. while ((fromRight ? index-- : ++index < length)) {
  1549. if (predicate(array[index], index, array)) {
  1550. return index;
  1551. }
  1552. }
  1553. return -1;
  1554. }
  1555. /**
  1556. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  1557. *
  1558. * @private
  1559. * @param {Array} array The array to inspect.
  1560. * @param {*} value The value to search for.
  1561. * @param {number} fromIndex The index to search from.
  1562. * @returns {number} Returns the index of the matched value, else `-1`.
  1563. */
  1564. function baseIndexOf(array, value, fromIndex) {
  1565. return value === value
  1566. ? strictIndexOf(array, value, fromIndex)
  1567. : baseFindIndex(array, baseIsNaN, fromIndex);
  1568. }
  1569. /**
  1570. * This function is like `baseIndexOf` except that it accepts a comparator.
  1571. *
  1572. * @private
  1573. * @param {Array} array The array to inspect.
  1574. * @param {*} value The value to search for.
  1575. * @param {number} fromIndex The index to search from.
  1576. * @param {Function} comparator The comparator invoked per element.
  1577. * @returns {number} Returns the index of the matched value, else `-1`.
  1578. */
  1579. function baseIndexOfWith(array, value, fromIndex, comparator) {
  1580. var index = fromIndex - 1,
  1581. length = array.length;
  1582. while (++index < length) {
  1583. if (comparator(array[index], value)) {
  1584. return index;
  1585. }
  1586. }
  1587. return -1;
  1588. }
  1589. /**
  1590. * The base implementation of `_.isNaN` without support for number objects.
  1591. *
  1592. * @private
  1593. * @param {*} value The value to check.
  1594. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  1595. */
  1596. function baseIsNaN(value) {
  1597. return value !== value;
  1598. }
  1599. /**
  1600. * The base implementation of `_.mean` and `_.meanBy` without support for
  1601. * iteratee shorthands.
  1602. *
  1603. * @private
  1604. * @param {Array} array The array to iterate over.
  1605. * @param {Function} iteratee The function invoked per iteration.
  1606. * @returns {number} Returns the mean.
  1607. */
  1608. function baseMean(array, iteratee) {
  1609. var length = array == null ? 0 : array.length;
  1610. return length ? (baseSum(array, iteratee) / length) : NAN;
  1611. }
  1612. /**
  1613. * The base implementation of `_.property` without support for deep paths.
  1614. *
  1615. * @private
  1616. * @param {string} key The key of the property to get.
  1617. * @returns {Function} Returns the new accessor function.
  1618. */
  1619. function baseProperty(key) {
  1620. return function(object) {
  1621. return object == null ? undefined : object[key];
  1622. };
  1623. }
  1624. /**
  1625. * The base implementation of `_.propertyOf` without support for deep paths.
  1626. *
  1627. * @private
  1628. * @param {Object} object The object to query.
  1629. * @returns {Function} Returns the new accessor function.
  1630. */
  1631. function basePropertyOf(object) {
  1632. return function(key) {
  1633. return object == null ? undefined : object[key];
  1634. };
  1635. }
  1636. /**
  1637. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  1638. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  1639. *
  1640. * @private
  1641. * @param {Array|Object} collection The collection to iterate over.
  1642. * @param {Function} iteratee The function invoked per iteration.
  1643. * @param {*} accumulator The initial value.
  1644. * @param {boolean} initAccum Specify using the first or last element of
  1645. * `collection` as the initial value.
  1646. * @param {Function} eachFunc The function to iterate over `collection`.
  1647. * @returns {*} Returns the accumulated value.
  1648. */
  1649. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  1650. eachFunc(collection, function(value, index, collection) {
  1651. accumulator = initAccum
  1652. ? (initAccum = false, value)
  1653. : iteratee(accumulator, value, index, collection);
  1654. });
  1655. return accumulator;
  1656. }
  1657. /**
  1658. * The base implementation of `_.sortBy` which uses `comparer` to define the
  1659. * sort order of `array` and replaces criteria objects with their corresponding
  1660. * values.
  1661. *
  1662. * @private
  1663. * @param {Array} array The array to sort.
  1664. * @param {Function} comparer The function to define sort order.
  1665. * @returns {Array} Returns `array`.
  1666. */
  1667. function baseSortBy(array, comparer) {
  1668. var length = array.length;
  1669. array.sort(comparer);
  1670. while (length--) {
  1671. array[length] = array[length].value;
  1672. }
  1673. return array;
  1674. }
  1675. /**
  1676. * The base implementation of `_.sum` and `_.sumBy` without support for
  1677. * iteratee shorthands.
  1678. *
  1679. * @private
  1680. * @param {Array} array The array to iterate over.
  1681. * @param {Function} iteratee The function invoked per iteration.
  1682. * @returns {number} Returns the sum.
  1683. */
  1684. function baseSum(array, iteratee) {
  1685. var result,
  1686. index = -1,
  1687. length = array.length;
  1688. while (++index < length) {
  1689. var current = iteratee(array[index]);
  1690. if (current !== undefined) {
  1691. result = result === undefined ? current : (result + current);
  1692. }
  1693. }
  1694. return result;
  1695. }
  1696. /**
  1697. * The base implementation of `_.times` without support for iteratee shorthands
  1698. * or max array length checks.
  1699. *
  1700. * @private
  1701. * @param {number} n The number of times to invoke `iteratee`.
  1702. * @param {Function} iteratee The function invoked per iteration.
  1703. * @returns {Array} Returns the array of results.
  1704. */
  1705. function baseTimes(n, iteratee) {
  1706. var index = -1,
  1707. result = Array(n);
  1708. while (++index < n) {
  1709. result[index] = iteratee(index);
  1710. }
  1711. return result;
  1712. }
  1713. /**
  1714. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  1715. * of key-value pairs for `object` corresponding to the property names of `props`.
  1716. *
  1717. * @private
  1718. * @param {Object} object The object to query.
  1719. * @param {Array} props The property names to get values for.
  1720. * @returns {Object} Returns the key-value pairs.
  1721. */
  1722. function baseToPairs(object, props) {
  1723. return arrayMap(props, function(key) {
  1724. return [key, object[key]];
  1725. });
  1726. }
  1727. /**
  1728. * The base implementation of `_.unary` without support for storing metadata.
  1729. *
  1730. * @private
  1731. * @param {Function} func The function to cap arguments for.
  1732. * @returns {Function} Returns the new capped function.
  1733. */
  1734. function baseUnary(func) {
  1735. return function(value) {
  1736. return func(value);
  1737. };
  1738. }
  1739. /**
  1740. * The base implementation of `_.values` and `_.valuesIn` which creates an
  1741. * array of `object` property values corresponding to the property names
  1742. * of `props`.
  1743. *
  1744. * @private
  1745. * @param {Object} object The object to query.
  1746. * @param {Array} props The property names to get values for.
  1747. * @returns {Object} Returns the array of property values.
  1748. */
  1749. function baseValues(object, props) {
  1750. return arrayMap(props, function(key) {
  1751. return object[key];
  1752. });
  1753. }
  1754. /**
  1755. * Checks if a `cache` value for `key` exists.
  1756. *
  1757. * @private
  1758. * @param {Object} cache The cache to query.
  1759. * @param {string} key The key of the entry to check.
  1760. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1761. */
  1762. function cacheHas(cache, key) {
  1763. return cache.has(key);
  1764. }
  1765. /**
  1766. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  1767. * that is not found in the character symbols.
  1768. *
  1769. * @private
  1770. * @param {Array} strSymbols The string symbols to inspect.
  1771. * @param {Array} chrSymbols The character symbols to find.
  1772. * @returns {number} Returns the index of the first unmatched string symbol.
  1773. */
  1774. function charsStartIndex(strSymbols, chrSymbols) {
  1775. var index = -1,
  1776. length = strSymbols.length;
  1777. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  1778. return index;
  1779. }
  1780. /**
  1781. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  1782. * that is not found in the character symbols.
  1783. *
  1784. * @private
  1785. * @param {Array} strSymbols The string symbols to inspect.
  1786. * @param {Array} chrSymbols The character symbols to find.
  1787. * @returns {number} Returns the index of the last unmatched string symbol.
  1788. */
  1789. function charsEndIndex(strSymbols, chrSymbols) {
  1790. var index = strSymbols.length;
  1791. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  1792. return index;
  1793. }
  1794. /**
  1795. * Gets the number of `placeholder` occurrences in `array`.
  1796. *
  1797. * @private
  1798. * @param {Array} array The array to inspect.
  1799. * @param {*} placeholder The placeholder to search for.
  1800. * @returns {number} Returns the placeholder count.
  1801. */
  1802. function countHolders(array, placeholder) {
  1803. var length = array.length,
  1804. result = 0;
  1805. while (length--) {
  1806. if (array[length] === placeholder) {
  1807. ++result;
  1808. }
  1809. }
  1810. return result;
  1811. }
  1812. /**
  1813. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  1814. * letters to basic Latin letters.
  1815. *
  1816. * @private
  1817. * @param {string} letter The matched letter to deburr.
  1818. * @returns {string} Returns the deburred letter.
  1819. */
  1820. var deburrLetter = basePropertyOf(deburredLetters);
  1821. /**
  1822. * Used by `_.escape` to convert characters to HTML entities.
  1823. *
  1824. * @private
  1825. * @param {string} chr The matched character to escape.
  1826. * @returns {string} Returns the escaped character.
  1827. */
  1828. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  1829. /**
  1830. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  1831. *
  1832. * @private
  1833. * @param {string} chr The matched character to escape.
  1834. * @returns {string} Returns the escaped character.
  1835. */
  1836. function escapeStringChar(chr) {
  1837. return '\\' + stringEscapes[chr];
  1838. }
  1839. /**
  1840. * Gets the value at `key` of `object`.
  1841. *
  1842. * @private
  1843. * @param {Object} [object] The object to query.
  1844. * @param {string} key The key of the property to get.
  1845. * @returns {*} Returns the property value.
  1846. */
  1847. function getValue(object, key) {
  1848. return object == null ? undefined : object[key];
  1849. }
  1850. /**
  1851. * Checks if `string` contains Unicode symbols.
  1852. *
  1853. * @private
  1854. * @param {string} string The string to inspect.
  1855. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  1856. */
  1857. function hasUnicode(string) {
  1858. return reHasUnicode.test(string);
  1859. }
  1860. /**
  1861. * Checks if `string` contains a word composed of Unicode symbols.
  1862. *
  1863. * @private
  1864. * @param {string} string The string to inspect.
  1865. * @returns {boolean} Returns `true` if a word is found, else `false`.
  1866. */
  1867. function hasUnicodeWord(string) {
  1868. return reHasUnicodeWord.test(string);
  1869. }
  1870. /**
  1871. * Converts `iterator` to an array.
  1872. *
  1873. * @private
  1874. * @param {Object} iterator The iterator to convert.
  1875. * @returns {Array} Returns the converted array.
  1876. */
  1877. function iteratorToArray(iterator) {
  1878. var data,
  1879. result = [];
  1880. while (!(data = iterator.next()).done) {
  1881. result.push(data.value);
  1882. }
  1883. return result;
  1884. }
  1885. /**
  1886. * Converts `map` to its key-value pairs.
  1887. *
  1888. * @private
  1889. * @param {Object} map The map to convert.
  1890. * @returns {Array} Returns the key-value pairs.
  1891. */
  1892. function mapToArray(map) {
  1893. var index = -1,
  1894. result = Array(map.size);
  1895. map.forEach(function(value, key) {
  1896. result[++index] = [key, value];
  1897. });
  1898. return result;
  1899. }
  1900. /**
  1901. * Creates a unary function that invokes `func` with its argument transformed.
  1902. *
  1903. * @private
  1904. * @param {Function} func The function to wrap.
  1905. * @param {Function} transform The argument transform.
  1906. * @returns {Function} Returns the new function.
  1907. */
  1908. function overArg(func, transform) {
  1909. return function(arg) {
  1910. return func(transform(arg));
  1911. };
  1912. }
  1913. /**
  1914. * Replaces all `placeholder` elements in `array` with an internal placeholder
  1915. * and returns an array of their indexes.
  1916. *
  1917. * @private
  1918. * @param {Array} array The array to modify.
  1919. * @param {*} placeholder The placeholder to replace.
  1920. * @returns {Array} Returns the new array of placeholder indexes.
  1921. */
  1922. function replaceHolders(array, placeholder) {
  1923. var index = -1,
  1924. length = array.length,
  1925. resIndex = 0,
  1926. result = [];
  1927. while (++index < length) {
  1928. var value = array[index];
  1929. if (value === placeholder || value === PLACEHOLDER) {
  1930. array[index] = PLACEHOLDER;
  1931. result[resIndex++] = index;
  1932. }
  1933. }
  1934. return result;
  1935. }
  1936. /**
  1937. * Converts `set` to an array of its values.
  1938. *
  1939. * @private
  1940. * @param {Object} set The set to convert.
  1941. * @returns {Array} Returns the values.
  1942. */
  1943. function setToArray(set) {
  1944. var index = -1,
  1945. result = Array(set.size);
  1946. set.forEach(function(value) {
  1947. result[++index] = value;
  1948. });
  1949. return result;
  1950. }
  1951. /**
  1952. * Converts `set` to its value-value pairs.
  1953. *
  1954. * @private
  1955. * @param {Object} set The set to convert.
  1956. * @returns {Array} Returns the value-value pairs.
  1957. */
  1958. function setToPairs(set) {
  1959. var index = -1,
  1960. result = Array(set.size);
  1961. set.forEach(function(value) {
  1962. result[++index] = [value, value];
  1963. });
  1964. return result;
  1965. }
  1966. /**
  1967. * A specialized version of `_.indexOf` which performs strict equality
  1968. * comparisons of values, i.e. `===`.
  1969. *
  1970. * @private
  1971. * @param {Array} array The array to inspect.
  1972. * @param {*} value The value to search for.
  1973. * @param {number} fromIndex The index to search from.
  1974. * @returns {number} Returns the index of the matched value, else `-1`.
  1975. */
  1976. function strictIndexOf(array, value, fromIndex) {
  1977. var index = fromIndex - 1,
  1978. length = array.length;
  1979. while (++index < length) {
  1980. if (array[index] === value) {
  1981. return index;
  1982. }
  1983. }
  1984. return -1;
  1985. }
  1986. /**
  1987. * A specialized version of `_.lastIndexOf` which performs strict equality
  1988. * comparisons of values, i.e. `===`.
  1989. *
  1990. * @private
  1991. * @param {Array} array The array to inspect.
  1992. * @param {*} value The value to search for.
  1993. * @param {number} fromIndex The index to search from.
  1994. * @returns {number} Returns the index of the matched value, else `-1`.
  1995. */
  1996. function strictLastIndexOf(array, value, fromIndex) {
  1997. var index = fromIndex + 1;
  1998. while (index--) {
  1999. if (array[index] === value) {
  2000. return index;
  2001. }
  2002. }
  2003. return index;
  2004. }
  2005. /**
  2006. * Gets the number of symbols in `string`.
  2007. *
  2008. * @private
  2009. * @param {string} string The string to inspect.
  2010. * @returns {number} Returns the string size.
  2011. */
  2012. function stringSize(string) {
  2013. return hasUnicode(string)
  2014. ? unicodeSize(string)
  2015. : asciiSize(string);
  2016. }
  2017. /**
  2018. * Converts `string` to an array.
  2019. *
  2020. * @private
  2021. * @param {string} string The string to convert.
  2022. * @returns {Array} Returns the converted array.
  2023. */
  2024. function stringToArray(string) {
  2025. return hasUnicode(string)
  2026. ? unicodeToArray(string)
  2027. : asciiToArray(string);
  2028. }
  2029. /**
  2030. * Used by `_.unescape` to convert HTML entities to characters.
  2031. *
  2032. * @private
  2033. * @param {string} chr The matched character to unescape.
  2034. * @returns {string} Returns the unescaped character.
  2035. */
  2036. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  2037. /**
  2038. * Gets the size of a Unicode `string`.
  2039. *
  2040. * @private
  2041. * @param {string} string The string inspect.
  2042. * @returns {number} Returns the string size.
  2043. */
  2044. function unicodeSize(string) {
  2045. var result = reUnicode.lastIndex = 0;
  2046. while (reUnicode.test(string)) {
  2047. ++result;
  2048. }
  2049. return result;
  2050. }
  2051. /**
  2052. * Converts a Unicode `string` to an array.
  2053. *
  2054. * @private
  2055. * @param {string} string The string to convert.
  2056. * @returns {Array} Returns the converted array.
  2057. */
  2058. function unicodeToArray(string) {
  2059. return string.match(reUnicode) || [];
  2060. }
  2061. /**
  2062. * Splits a Unicode `string` into an array of its words.
  2063. *
  2064. * @private
  2065. * @param {string} The string to inspect.
  2066. * @returns {Array} Returns the words of `string`.
  2067. */
  2068. function unicodeWords(string) {
  2069. return string.match(reUnicodeWord) || [];
  2070. }
  2071. /*--------------------------------------------------------------------------*/
  2072. /**
  2073. * Create a new pristine `lodash` function using the `context` object.
  2074. *
  2075. * @static
  2076. * @memberOf _
  2077. * @since 1.1.0
  2078. * @category Util
  2079. * @param {Object} [context=root] The context object.
  2080. * @returns {Function} Returns a new `lodash` function.
  2081. * @example
  2082. *
  2083. * _.mixin({ 'foo': _.constant('foo') });
  2084. *
  2085. * var lodash = _.runInContext();
  2086. * lodash.mixin({ 'bar': lodash.constant('bar') });
  2087. *
  2088. * _.isFunction(_.foo);
  2089. * // => true
  2090. * _.isFunction(_.bar);
  2091. * // => false
  2092. *
  2093. * lodash.isFunction(lodash.foo);
  2094. * // => false
  2095. * lodash.isFunction(lodash.bar);
  2096. * // => true
  2097. *
  2098. * // Create a suped-up `defer` in Node.js.
  2099. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  2100. */
  2101. var runInContext = (function runInContext(context) {
  2102. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  2103. /** Built-in constructor references. */
  2104. var Array = context.Array,
  2105. Date = context.Date,
  2106. Error = context.Error,
  2107. Function = context.Function,
  2108. Math = context.Math,
  2109. Object = context.Object,
  2110. RegExp = context.RegExp,
  2111. String = context.String,
  2112. TypeError = context.TypeError;
  2113. /** Used for built-in method references. */
  2114. var arrayProto = Array.prototype,
  2115. funcProto = Function.prototype,
  2116. objectProto = Object.prototype;
  2117. /** Used to detect overreaching core-js shims. */
  2118. var coreJsData = context['__core-js_shared__'];
  2119. /** Used to resolve the decompiled source of functions. */
  2120. var funcToString = funcProto.toString;
  2121. /** Used to check objects for own properties. */
  2122. var hasOwnProperty = objectProto.hasOwnProperty;
  2123. /** Used to generate unique IDs. */
  2124. var idCounter = 0;
  2125. /** Used to detect methods masquerading as native. */
  2126. var maskSrcKey = (function() {
  2127. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2128. return uid ? ('Symbol(src)_1.' + uid) : '';
  2129. }());
  2130. /**
  2131. * Used to resolve the
  2132. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2133. * of values.
  2134. */
  2135. var nativeObjectToString = objectProto.toString;
  2136. /** Used to infer the `Object` constructor. */
  2137. var objectCtorString = funcToString.call(Object);
  2138. /** Used to restore the original `_` reference in `_.noConflict`. */
  2139. var oldDash = root._;
  2140. /** Used to detect if a method is native. */
  2141. var reIsNative = RegExp('^' +
  2142. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2143. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2144. );
  2145. /** Built-in value references. */
  2146. var Buffer = moduleExports ? context.Buffer : undefined,
  2147. Symbol = context.Symbol,
  2148. Uint8Array = context.Uint8Array,
  2149. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  2150. getPrototype = overArg(Object.getPrototypeOf, Object),
  2151. objectCreate = Object.create,
  2152. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2153. splice = arrayProto.splice,
  2154. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  2155. symIterator = Symbol ? Symbol.iterator : undefined,
  2156. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  2157. var defineProperty = (function() {
  2158. try {
  2159. var func = getNative(Object, 'defineProperty');
  2160. func({}, '', {});
  2161. return func;
  2162. } catch (e) {}
  2163. }());
  2164. /** Mocked built-ins. */
  2165. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  2166. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  2167. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  2168. /* Built-in method references for those with the same name as other `lodash` methods. */
  2169. var nativeCeil = Math.ceil,
  2170. nativeFloor = Math.floor,
  2171. nativeGetSymbols = Object.getOwnPropertySymbols,
  2172. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  2173. nativeIsFinite = context.isFinite,
  2174. nativeJoin = arrayProto.join,
  2175. nativeKeys = overArg(Object.keys, Object),
  2176. nativeMax = Math.max,
  2177. nativeMin = Math.min,
  2178. nativeNow = Date.now,
  2179. nativeParseInt = context.parseInt,
  2180. nativeRandom = Math.random,
  2181. nativeReverse = arrayProto.reverse;
  2182. /* Built-in method references that are verified to be native. */
  2183. var DataView = getNative(context, 'DataView'),
  2184. Map = getNative(context, 'Map'),
  2185. Promise = getNative(context, 'Promise'),
  2186. Set = getNative(context, 'Set'),
  2187. WeakMap = getNative(context, 'WeakMap'),
  2188. nativeCreate = getNative(Object, 'create');
  2189. /** Used to store function metadata. */
  2190. var metaMap = WeakMap && new WeakMap;
  2191. /** Used to lookup unminified function names. */
  2192. var realNames = {};
  2193. /** Used to detect maps, sets, and weakmaps. */
  2194. var dataViewCtorString = toSource(DataView),
  2195. mapCtorString = toSource(Map),
  2196. promiseCtorString = toSource(Promise),
  2197. setCtorString = toSource(Set),
  2198. weakMapCtorString = toSource(WeakMap);
  2199. /** Used to convert symbols to primitives and strings. */
  2200. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2201. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2202. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2203. /*------------------------------------------------------------------------*/
  2204. /**
  2205. * Creates a `lodash` object which wraps `value` to enable implicit method
  2206. * chain sequences. Methods that operate on and return arrays, collections,
  2207. * and functions can be chained together. Methods that retrieve a single value
  2208. * or may return a primitive value will automatically end the chain sequence
  2209. * and return the unwrapped value. Otherwise, the value must be unwrapped
  2210. * with `_#value`.
  2211. *
  2212. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  2213. * enabled using `_.chain`.
  2214. *
  2215. * The execution of chained methods is lazy, that is, it's deferred until
  2216. * `_#value` is implicitly or explicitly called.
  2217. *
  2218. * Lazy evaluation allows several methods to support shortcut fusion.
  2219. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  2220. * the creation of intermediate arrays and can greatly reduce the number of
  2221. * iteratee executions. Sections of a chain sequence qualify for shortcut
  2222. * fusion if the section is applied to an array and iteratees accept only
  2223. * one argument. The heuristic for whether a section qualifies for shortcut
  2224. * fusion is subject to change.
  2225. *
  2226. * Chaining is supported in custom builds as long as the `_#value` method is
  2227. * directly or indirectly included in the build.
  2228. *
  2229. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  2230. *
  2231. * The wrapper `Array` methods are:
  2232. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  2233. *
  2234. * The wrapper `String` methods are:
  2235. * `replace` and `split`
  2236. *
  2237. * The wrapper methods that support shortcut fusion are:
  2238. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  2239. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  2240. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  2241. *
  2242. * The chainable wrapper methods are:
  2243. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  2244. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  2245. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  2246. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  2247. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  2248. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  2249. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  2250. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  2251. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  2252. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  2253. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  2254. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  2255. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  2256. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  2257. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  2258. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  2259. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  2260. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  2261. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  2262. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  2263. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  2264. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  2265. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  2266. * `zipObject`, `zipObjectDeep`, and `zipWith`
  2267. *
  2268. * The wrapper methods that are **not** chainable by default are:
  2269. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  2270. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  2271. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  2272. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  2273. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  2274. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  2275. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  2276. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  2277. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  2278. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  2279. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  2280. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  2281. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  2282. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  2283. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  2284. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  2285. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  2286. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  2287. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  2288. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  2289. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  2290. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  2291. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  2292. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  2293. * `upperFirst`, `value`, and `words`
  2294. *
  2295. * @name _
  2296. * @constructor
  2297. * @category Seq
  2298. * @param {*} value The value to wrap in a `lodash` instance.
  2299. * @returns {Object} Returns the new `lodash` wrapper instance.
  2300. * @example
  2301. *
  2302. * function square(n) {
  2303. * return n * n;
  2304. * }
  2305. *
  2306. * var wrapped = _([1, 2, 3]);
  2307. *
  2308. * // Returns an unwrapped value.
  2309. * wrapped.reduce(_.add);
  2310. * // => 6
  2311. *
  2312. * // Returns a wrapped value.
  2313. * var squares = wrapped.map(square);
  2314. *
  2315. * _.isArray(squares);
  2316. * // => false
  2317. *
  2318. * _.isArray(squares.value());
  2319. * // => true
  2320. */
  2321. function lodash(value) {
  2322. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  2323. if (value instanceof LodashWrapper) {
  2324. return value;
  2325. }
  2326. if (hasOwnProperty.call(value, '__wrapped__')) {
  2327. return wrapperClone(value);
  2328. }
  2329. }
  2330. return new LodashWrapper(value);
  2331. }
  2332. /**
  2333. * The base implementation of `_.create` without support for assigning
  2334. * properties to the created object.
  2335. *
  2336. * @private
  2337. * @param {Object} proto The object to inherit from.
  2338. * @returns {Object} Returns the new object.
  2339. */
  2340. var baseCreate = (function() {
  2341. function object() {}
  2342. return function(proto) {
  2343. if (!isObject(proto)) {
  2344. return {};
  2345. }
  2346. if (objectCreate) {
  2347. return objectCreate(proto);
  2348. }
  2349. object.prototype = proto;
  2350. var result = new object;
  2351. object.prototype = undefined;
  2352. return result;
  2353. };
  2354. }());
  2355. /**
  2356. * The function whose prototype chain sequence wrappers inherit from.
  2357. *
  2358. * @private
  2359. */
  2360. function baseLodash() {
  2361. // No operation performed.
  2362. }
  2363. /**
  2364. * The base constructor for creating `lodash` wrapper objects.
  2365. *
  2366. * @private
  2367. * @param {*} value The value to wrap.
  2368. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  2369. */
  2370. function LodashWrapper(value, chainAll) {
  2371. this.__wrapped__ = value;
  2372. this.__actions__ = [];
  2373. this.__chain__ = !!chainAll;
  2374. this.__index__ = 0;
  2375. this.__values__ = undefined;
  2376. }
  2377. /**
  2378. * By default, the template delimiters used by lodash are like those in
  2379. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  2380. * following template settings to use alternative delimiters.
  2381. *
  2382. * @static
  2383. * @memberOf _
  2384. * @type {Object}
  2385. */
  2386. lodash.templateSettings = {
  2387. /**
  2388. * Used to detect `data` property values to be HTML-escaped.
  2389. *
  2390. * @memberOf _.templateSettings
  2391. * @type {RegExp}
  2392. */
  2393. 'escape': reEscape,
  2394. /**
  2395. * Used to detect code to be evaluated.
  2396. *
  2397. * @memberOf _.templateSettings
  2398. * @type {RegExp}
  2399. */
  2400. 'evaluate': reEvaluate,
  2401. /**
  2402. * Used to detect `data` property values to inject.
  2403. *
  2404. * @memberOf _.templateSettings
  2405. * @type {RegExp}
  2406. */
  2407. 'interpolate': reInterpolate,
  2408. /**
  2409. * Used to reference the data object in the template text.
  2410. *
  2411. * @memberOf _.templateSettings
  2412. * @type {string}
  2413. */
  2414. 'variable': '',
  2415. /**
  2416. * Used to import variables into the compiled template.
  2417. *
  2418. * @memberOf _.templateSettings
  2419. * @type {Object}
  2420. */
  2421. 'imports': {
  2422. /**
  2423. * A reference to the `lodash` function.
  2424. *
  2425. * @memberOf _.templateSettings.imports
  2426. * @type {Function}
  2427. */
  2428. '_': lodash
  2429. }
  2430. };
  2431. // Ensure wrappers are instances of `baseLodash`.
  2432. lodash.prototype = baseLodash.prototype;
  2433. lodash.prototype.constructor = lodash;
  2434. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  2435. LodashWrapper.prototype.constructor = LodashWrapper;
  2436. /*------------------------------------------------------------------------*/
  2437. /**
  2438. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  2439. *
  2440. * @private
  2441. * @constructor
  2442. * @param {*} value The value to wrap.
  2443. */
  2444. function LazyWrapper(value) {
  2445. this.__wrapped__ = value;
  2446. this.__actions__ = [];
  2447. this.__dir__ = 1;
  2448. this.__filtered__ = false;
  2449. this.__iteratees__ = [];
  2450. this.__takeCount__ = MAX_ARRAY_LENGTH;
  2451. this.__views__ = [];
  2452. }
  2453. /**
  2454. * Creates a clone of the lazy wrapper object.
  2455. *
  2456. * @private
  2457. * @name clone
  2458. * @memberOf LazyWrapper
  2459. * @returns {Object} Returns the cloned `LazyWrapper` object.
  2460. */
  2461. function lazyClone() {
  2462. var result = new LazyWrapper(this.__wrapped__);
  2463. result.__actions__ = copyArray(this.__actions__);
  2464. result.__dir__ = this.__dir__;
  2465. result.__filtered__ = this.__filtered__;
  2466. result.__iteratees__ = copyArray(this.__iteratees__);
  2467. result.__takeCount__ = this.__takeCount__;
  2468. result.__views__ = copyArray(this.__views__);
  2469. return result;
  2470. }
  2471. /**
  2472. * Reverses the direction of lazy iteration.
  2473. *
  2474. * @private
  2475. * @name reverse
  2476. * @memberOf LazyWrapper
  2477. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  2478. */
  2479. function lazyReverse() {
  2480. if (this.__filtered__) {
  2481. var result = new LazyWrapper(this);
  2482. result.__dir__ = -1;
  2483. result.__filtered__ = true;
  2484. } else {
  2485. result = this.clone();
  2486. result.__dir__ *= -1;
  2487. }
  2488. return result;
  2489. }
  2490. /**
  2491. * Extracts the unwrapped value from its lazy wrapper.
  2492. *
  2493. * @private
  2494. * @name value
  2495. * @memberOf LazyWrapper
  2496. * @returns {*} Returns the unwrapped value.
  2497. */
  2498. function lazyValue() {
  2499. var array = this.__wrapped__.value(),
  2500. dir = this.__dir__,
  2501. isArr = isArray(array),
  2502. isRight = dir < 0,
  2503. arrLength = isArr ? array.length : 0,
  2504. view = getView(0, arrLength, this.__views__),
  2505. start = view.start,
  2506. end = view.end,
  2507. length = end - start,
  2508. index = isRight ? end : (start - 1),
  2509. iteratees = this.__iteratees__,
  2510. iterLength = iteratees.length,
  2511. resIndex = 0,
  2512. takeCount = nativeMin(length, this.__takeCount__);
  2513. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  2514. return baseWrapperValue(array, this.__actions__);
  2515. }
  2516. var result = [];
  2517. outer:
  2518. while (length-- && resIndex < takeCount) {
  2519. index += dir;
  2520. var iterIndex = -1,
  2521. value = array[index];
  2522. while (++iterIndex < iterLength) {
  2523. var data = iteratees[iterIndex],
  2524. iteratee = data.iteratee,
  2525. type = data.type,
  2526. computed = iteratee(value);
  2527. if (type == LAZY_MAP_FLAG) {
  2528. value = computed;
  2529. } else if (!computed) {
  2530. if (type == LAZY_FILTER_FLAG) {
  2531. continue outer;
  2532. } else {
  2533. break outer;
  2534. }
  2535. }
  2536. }
  2537. result[resIndex++] = value;
  2538. }
  2539. return result;
  2540. }
  2541. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  2542. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  2543. LazyWrapper.prototype.constructor = LazyWrapper;
  2544. /*------------------------------------------------------------------------*/
  2545. /**
  2546. * Creates a hash object.
  2547. *
  2548. * @private
  2549. * @constructor
  2550. * @param {Array} [entries] The key-value pairs to cache.
  2551. */
  2552. function Hash(entries) {
  2553. var index = -1,
  2554. length = entries == null ? 0 : entries.length;
  2555. this.clear();
  2556. while (++index < length) {
  2557. var entry = entries[index];
  2558. this.set(entry[0], entry[1]);
  2559. }
  2560. }
  2561. /**
  2562. * Removes all key-value entries from the hash.
  2563. *
  2564. * @private
  2565. * @name clear
  2566. * @memberOf Hash
  2567. */
  2568. function hashClear() {
  2569. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  2570. this.size = 0;
  2571. }
  2572. /**
  2573. * Removes `key` and its value from the hash.
  2574. *
  2575. * @private
  2576. * @name delete
  2577. * @memberOf Hash
  2578. * @param {Object} hash The hash to modify.
  2579. * @param {string} key The key of the value to remove.
  2580. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2581. */
  2582. function hashDelete(key) {
  2583. var result = this.has(key) && delete this.__data__[key];
  2584. this.size -= result ? 1 : 0;
  2585. return result;
  2586. }
  2587. /**
  2588. * Gets the hash value for `key`.
  2589. *
  2590. * @private
  2591. * @name get
  2592. * @memberOf Hash
  2593. * @param {string} key The key of the value to get.
  2594. * @returns {*} Returns the entry value.
  2595. */
  2596. function hashGet(key) {
  2597. var data = this.__data__;
  2598. if (nativeCreate) {
  2599. var result = data[key];
  2600. return result === HASH_UNDEFINED ? undefined : result;
  2601. }
  2602. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  2603. }
  2604. /**
  2605. * Checks if a hash value for `key` exists.
  2606. *
  2607. * @private
  2608. * @name has
  2609. * @memberOf Hash
  2610. * @param {string} key The key of the entry to check.
  2611. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2612. */
  2613. function hashHas(key) {
  2614. var data = this.__data__;
  2615. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  2616. }
  2617. /**
  2618. * Sets the hash `key` to `value`.
  2619. *
  2620. * @private
  2621. * @name set
  2622. * @memberOf Hash
  2623. * @param {string} key The key of the value to set.
  2624. * @param {*} value The value to set.
  2625. * @returns {Object} Returns the hash instance.
  2626. */
  2627. function hashSet(key, value) {
  2628. var data = this.__data__;
  2629. this.size += this.has(key) ? 0 : 1;
  2630. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  2631. return this;
  2632. }
  2633. // Add methods to `Hash`.
  2634. Hash.prototype.clear = hashClear;
  2635. Hash.prototype['delete'] = hashDelete;
  2636. Hash.prototype.get = hashGet;
  2637. Hash.prototype.has = hashHas;
  2638. Hash.prototype.set = hashSet;
  2639. /*------------------------------------------------------------------------*/
  2640. /**
  2641. * Creates an list cache object.
  2642. *
  2643. * @private
  2644. * @constructor
  2645. * @param {Array} [entries] The key-value pairs to cache.
  2646. */
  2647. function ListCache(entries) {
  2648. var index = -1,
  2649. length = entries == null ? 0 : entries.length;
  2650. this.clear();
  2651. while (++index < length) {
  2652. var entry = entries[index];
  2653. this.set(entry[0], entry[1]);
  2654. }
  2655. }
  2656. /**
  2657. * Removes all key-value entries from the list cache.
  2658. *
  2659. * @private
  2660. * @name clear
  2661. * @memberOf ListCache
  2662. */
  2663. function listCacheClear() {
  2664. this.__data__ = [];
  2665. this.size = 0;
  2666. }
  2667. /**
  2668. * Removes `key` and its value from the list cache.
  2669. *
  2670. * @private
  2671. * @name delete
  2672. * @memberOf ListCache
  2673. * @param {string} key The key of the value to remove.
  2674. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2675. */
  2676. function listCacheDelete(key) {
  2677. var data = this.__data__,
  2678. index = assocIndexOf(data, key);
  2679. if (index < 0) {
  2680. return false;
  2681. }
  2682. var lastIndex = data.length - 1;
  2683. if (index == lastIndex) {
  2684. data.pop();
  2685. } else {
  2686. splice.call(data, index, 1);
  2687. }
  2688. --this.size;
  2689. return true;
  2690. }
  2691. /**
  2692. * Gets the list cache value for `key`.
  2693. *
  2694. * @private
  2695. * @name get
  2696. * @memberOf ListCache
  2697. * @param {string} key The key of the value to get.
  2698. * @returns {*} Returns the entry value.
  2699. */
  2700. function listCacheGet(key) {
  2701. var data = this.__data__,
  2702. index = assocIndexOf(data, key);
  2703. return index < 0 ? undefined : data[index][1];
  2704. }
  2705. /**
  2706. * Checks if a list cache value for `key` exists.
  2707. *
  2708. * @private
  2709. * @name has
  2710. * @memberOf ListCache
  2711. * @param {string} key The key of the entry to check.
  2712. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2713. */
  2714. function listCacheHas(key) {
  2715. return assocIndexOf(this.__data__, key) > -1;
  2716. }
  2717. /**
  2718. * Sets the list cache `key` to `value`.
  2719. *
  2720. * @private
  2721. * @name set
  2722. * @memberOf ListCache
  2723. * @param {string} key The key of the value to set.
  2724. * @param {*} value The value to set.
  2725. * @returns {Object} Returns the list cache instance.
  2726. */
  2727. function listCacheSet(key, value) {
  2728. var data = this.__data__,
  2729. index = assocIndexOf(data, key);
  2730. if (index < 0) {
  2731. ++this.size;
  2732. data.push([key, value]);
  2733. } else {
  2734. data[index][1] = value;
  2735. }
  2736. return this;
  2737. }
  2738. // Add methods to `ListCache`.
  2739. ListCache.prototype.clear = listCacheClear;
  2740. ListCache.prototype['delete'] = listCacheDelete;
  2741. ListCache.prototype.get = listCacheGet;
  2742. ListCache.prototype.has = listCacheHas;
  2743. ListCache.prototype.set = listCacheSet;
  2744. /*------------------------------------------------------------------------*/
  2745. /**
  2746. * Creates a map cache object to store key-value pairs.
  2747. *
  2748. * @private
  2749. * @constructor
  2750. * @param {Array} [entries] The key-value pairs to cache.
  2751. */
  2752. function MapCache(entries) {
  2753. var index = -1,
  2754. length = entries == null ? 0 : entries.length;
  2755. this.clear();
  2756. while (++index < length) {
  2757. var entry = entries[index];
  2758. this.set(entry[0], entry[1]);
  2759. }
  2760. }
  2761. /**
  2762. * Removes all key-value entries from the map.
  2763. *
  2764. * @private
  2765. * @name clear
  2766. * @memberOf MapCache
  2767. */
  2768. function mapCacheClear() {
  2769. this.size = 0;
  2770. this.__data__ = {
  2771. 'hash': new Hash,
  2772. 'map': new (Map || ListCache),
  2773. 'string': new Hash
  2774. };
  2775. }
  2776. /**
  2777. * Removes `key` and its value from the map.
  2778. *
  2779. * @private
  2780. * @name delete
  2781. * @memberOf MapCache
  2782. * @param {string} key The key of the value to remove.
  2783. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2784. */
  2785. function mapCacheDelete(key) {
  2786. var result = getMapData(this, key)['delete'](key);
  2787. this.size -= result ? 1 : 0;
  2788. return result;
  2789. }
  2790. /**
  2791. * Gets the map value for `key`.
  2792. *
  2793. * @private
  2794. * @name get
  2795. * @memberOf MapCache
  2796. * @param {string} key The key of the value to get.
  2797. * @returns {*} Returns the entry value.
  2798. */
  2799. function mapCacheGet(key) {
  2800. return getMapData(this, key).get(key);
  2801. }
  2802. /**
  2803. * Checks if a map value for `key` exists.
  2804. *
  2805. * @private
  2806. * @name has
  2807. * @memberOf MapCache
  2808. * @param {string} key The key of the entry to check.
  2809. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2810. */
  2811. function mapCacheHas(key) {
  2812. return getMapData(this, key).has(key);
  2813. }
  2814. /**
  2815. * Sets the map `key` to `value`.
  2816. *
  2817. * @private
  2818. * @name set
  2819. * @memberOf MapCache
  2820. * @param {string} key The key of the value to set.
  2821. * @param {*} value The value to set.
  2822. * @returns {Object} Returns the map cache instance.
  2823. */
  2824. function mapCacheSet(key, value) {
  2825. var data = getMapData(this, key),
  2826. size = data.size;
  2827. data.set(key, value);
  2828. this.size += data.size == size ? 0 : 1;
  2829. return this;
  2830. }
  2831. // Add methods to `MapCache`.
  2832. MapCache.prototype.clear = mapCacheClear;
  2833. MapCache.prototype['delete'] = mapCacheDelete;
  2834. MapCache.prototype.get = mapCacheGet;
  2835. MapCache.prototype.has = mapCacheHas;
  2836. MapCache.prototype.set = mapCacheSet;
  2837. /*------------------------------------------------------------------------*/
  2838. /**
  2839. *
  2840. * Creates an array cache object to store unique values.
  2841. *
  2842. * @private
  2843. * @constructor
  2844. * @param {Array} [values] The values to cache.
  2845. */
  2846. function SetCache(values) {
  2847. var index = -1,
  2848. length = values == null ? 0 : values.length;
  2849. this.__data__ = new MapCache;
  2850. while (++index < length) {
  2851. this.add(values[index]);
  2852. }
  2853. }
  2854. /**
  2855. * Adds `value` to the array cache.
  2856. *
  2857. * @private
  2858. * @name add
  2859. * @memberOf SetCache
  2860. * @alias push
  2861. * @param {*} value The value to cache.
  2862. * @returns {Object} Returns the cache instance.
  2863. */
  2864. function setCacheAdd(value) {
  2865. this.__data__.set(value, HASH_UNDEFINED);
  2866. return this;
  2867. }
  2868. /**
  2869. * Checks if `value` is in the array cache.
  2870. *
  2871. * @private
  2872. * @name has
  2873. * @memberOf SetCache
  2874. * @param {*} value The value to search for.
  2875. * @returns {number} Returns `true` if `value` is found, else `false`.
  2876. */
  2877. function setCacheHas(value) {
  2878. return this.__data__.has(value);
  2879. }
  2880. // Add methods to `SetCache`.
  2881. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  2882. SetCache.prototype.has = setCacheHas;
  2883. /*------------------------------------------------------------------------*/
  2884. /**
  2885. * Creates a stack cache object to store key-value pairs.
  2886. *
  2887. * @private
  2888. * @constructor
  2889. * @param {Array} [entries] The key-value pairs to cache.
  2890. */
  2891. function Stack(entries) {
  2892. var data = this.__data__ = new ListCache(entries);
  2893. this.size = data.size;
  2894. }
  2895. /**
  2896. * Removes all key-value entries from the stack.
  2897. *
  2898. * @private
  2899. * @name clear
  2900. * @memberOf Stack
  2901. */
  2902. function stackClear() {
  2903. this.__data__ = new ListCache;
  2904. this.size = 0;
  2905. }
  2906. /**
  2907. * Removes `key` and its value from the stack.
  2908. *
  2909. * @private
  2910. * @name delete
  2911. * @memberOf Stack
  2912. * @param {string} key The key of the value to remove.
  2913. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2914. */
  2915. function stackDelete(key) {
  2916. var data = this.__data__,
  2917. result = data['delete'](key);
  2918. this.size = data.size;
  2919. return result;
  2920. }
  2921. /**
  2922. * Gets the stack value for `key`.
  2923. *
  2924. * @private
  2925. * @name get
  2926. * @memberOf Stack
  2927. * @param {string} key The key of the value to get.
  2928. * @returns {*} Returns the entry value.
  2929. */
  2930. function stackGet(key) {
  2931. return this.__data__.get(key);
  2932. }
  2933. /**
  2934. * Checks if a stack value for `key` exists.
  2935. *
  2936. * @private
  2937. * @name has
  2938. * @memberOf Stack
  2939. * @param {string} key The key of the entry to check.
  2940. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2941. */
  2942. function stackHas(key) {
  2943. return this.__data__.has(key);
  2944. }
  2945. /**
  2946. * Sets the stack `key` to `value`.
  2947. *
  2948. * @private
  2949. * @name set
  2950. * @memberOf Stack
  2951. * @param {string} key The key of the value to set.
  2952. * @param {*} value The value to set.
  2953. * @returns {Object} Returns the stack cache instance.
  2954. */
  2955. function stackSet(key, value) {
  2956. var data = this.__data__;
  2957. if (data instanceof ListCache) {
  2958. var pairs = data.__data__;
  2959. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  2960. pairs.push([key, value]);
  2961. this.size = ++data.size;
  2962. return this;
  2963. }
  2964. data = this.__data__ = new MapCache(pairs);
  2965. }
  2966. data.set(key, value);
  2967. this.size = data.size;
  2968. return this;
  2969. }
  2970. // Add methods to `Stack`.
  2971. Stack.prototype.clear = stackClear;
  2972. Stack.prototype['delete'] = stackDelete;
  2973. Stack.prototype.get = stackGet;
  2974. Stack.prototype.has = stackHas;
  2975. Stack.prototype.set = stackSet;
  2976. /*------------------------------------------------------------------------*/
  2977. /**
  2978. * Creates an array of the enumerable property names of the array-like `value`.
  2979. *
  2980. * @private
  2981. * @param {*} value The value to query.
  2982. * @param {boolean} inherited Specify returning inherited property names.
  2983. * @returns {Array} Returns the array of property names.
  2984. */
  2985. function arrayLikeKeys(value, inherited) {
  2986. var isArr = isArray(value),
  2987. isArg = !isArr && isArguments(value),
  2988. isBuff = !isArr && !isArg && isBuffer(value),
  2989. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  2990. skipIndexes = isArr || isArg || isBuff || isType,
  2991. result = skipIndexes ? baseTimes(value.length, String) : [],
  2992. length = result.length;
  2993. for (var key in value) {
  2994. if ((inherited || hasOwnProperty.call(value, key)) &&
  2995. !(skipIndexes && (
  2996. // Safari 9 has enumerable `arguments.length` in strict mode.
  2997. key == 'length' ||
  2998. // Node.js 0.10 has enumerable non-index properties on buffers.
  2999. (isBuff && (key == 'offset' || key == 'parent')) ||
  3000. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3001. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  3002. // Skip index properties.
  3003. isIndex(key, length)
  3004. ))) {
  3005. result.push(key);
  3006. }
  3007. }
  3008. return result;
  3009. }
  3010. /**
  3011. * A specialized version of `_.sample` for arrays.
  3012. *
  3013. * @private
  3014. * @param {Array} array The array to sample.
  3015. * @returns {*} Returns the random element.
  3016. */
  3017. function arraySample(array) {
  3018. var length = array.length;
  3019. return length ? array[baseRandom(0, length - 1)] : undefined;
  3020. }
  3021. /**
  3022. * A specialized version of `_.sampleSize` for arrays.
  3023. *
  3024. * @private
  3025. * @param {Array} array The array to sample.
  3026. * @param {number} n The number of elements to sample.
  3027. * @returns {Array} Returns the random elements.
  3028. */
  3029. function arraySampleSize(array, n) {
  3030. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  3031. }
  3032. /**
  3033. * A specialized version of `_.shuffle` for arrays.
  3034. *
  3035. * @private
  3036. * @param {Array} array The array to shuffle.
  3037. * @returns {Array} Returns the new shuffled array.
  3038. */
  3039. function arrayShuffle(array) {
  3040. return shuffleSelf(copyArray(array));
  3041. }
  3042. /**
  3043. * This function is like `assignValue` except that it doesn't assign
  3044. * `undefined` values.
  3045. *
  3046. * @private
  3047. * @param {Object} object The object to modify.
  3048. * @param {string} key The key of the property to assign.
  3049. * @param {*} value The value to assign.
  3050. */
  3051. function assignMergeValue(object, key, value) {
  3052. if ((value !== undefined && !eq(object[key], value)) ||
  3053. (value === undefined && !(key in object))) {
  3054. baseAssignValue(object, key, value);
  3055. }
  3056. }
  3057. /**
  3058. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  3059. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3060. * for equality comparisons.
  3061. *
  3062. * @private
  3063. * @param {Object} object The object to modify.
  3064. * @param {string} key The key of the property to assign.
  3065. * @param {*} value The value to assign.
  3066. */
  3067. function assignValue(object, key, value) {
  3068. var objValue = object[key];
  3069. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  3070. (value === undefined && !(key in object))) {
  3071. baseAssignValue(object, key, value);
  3072. }
  3073. }
  3074. /**
  3075. * Gets the index at which the `key` is found in `array` of key-value pairs.
  3076. *
  3077. * @private
  3078. * @param {Array} array The array to inspect.
  3079. * @param {*} key The key to search for.
  3080. * @returns {number} Returns the index of the matched value, else `-1`.
  3081. */
  3082. function assocIndexOf(array, key) {
  3083. var length = array.length;
  3084. while (length--) {
  3085. if (eq(array[length][0], key)) {
  3086. return length;
  3087. }
  3088. }
  3089. return -1;
  3090. }
  3091. /**
  3092. * Aggregates elements of `collection` on `accumulator` with keys transformed
  3093. * by `iteratee` and values set by `setter`.
  3094. *
  3095. * @private
  3096. * @param {Array|Object} collection The collection to iterate over.
  3097. * @param {Function} setter The function to set `accumulator` values.
  3098. * @param {Function} iteratee The iteratee to transform keys.
  3099. * @param {Object} accumulator The initial aggregated object.
  3100. * @returns {Function} Returns `accumulator`.
  3101. */
  3102. function baseAggregator(collection, setter, iteratee, accumulator) {
  3103. baseEach(collection, function(value, key, collection) {
  3104. setter(accumulator, value, iteratee(value), collection);
  3105. });
  3106. return accumulator;
  3107. }
  3108. /**
  3109. * The base implementation of `_.assign` without support for multiple sources
  3110. * or `customizer` functions.
  3111. *
  3112. * @private
  3113. * @param {Object} object The destination object.
  3114. * @param {Object} source The source object.
  3115. * @returns {Object} Returns `object`.
  3116. */
  3117. function baseAssign(object, source) {
  3118. return object && copyObject(source, keys(source), object);
  3119. }
  3120. /**
  3121. * The base implementation of `_.assignIn` without support for multiple sources
  3122. * or `customizer` functions.
  3123. *
  3124. * @private
  3125. * @param {Object} object The destination object.
  3126. * @param {Object} source The source object.
  3127. * @returns {Object} Returns `object`.
  3128. */
  3129. function baseAssignIn(object, source) {
  3130. return object && copyObject(source, keysIn(source), object);
  3131. }
  3132. /**
  3133. * The base implementation of `assignValue` and `assignMergeValue` without
  3134. * value checks.
  3135. *
  3136. * @private
  3137. * @param {Object} object The object to modify.
  3138. * @param {string} key The key of the property to assign.
  3139. * @param {*} value The value to assign.
  3140. */
  3141. function baseAssignValue(object, key, value) {
  3142. if (key == '__proto__' && defineProperty) {
  3143. defineProperty(object, key, {
  3144. 'configurable': true,
  3145. 'enumerable': true,
  3146. 'value': value,
  3147. 'writable': true
  3148. });
  3149. } else {
  3150. object[key] = value;
  3151. }
  3152. }
  3153. /**
  3154. * The base implementation of `_.at` without support for individual paths.
  3155. *
  3156. * @private
  3157. * @param {Object} object The object to iterate over.
  3158. * @param {string[]} paths The property paths to pick.
  3159. * @returns {Array} Returns the picked elements.
  3160. */
  3161. function baseAt(object, paths) {
  3162. var index = -1,
  3163. length = paths.length,
  3164. result = Array(length),
  3165. skip = object == null;
  3166. while (++index < length) {
  3167. result[index] = skip ? undefined : get(object, paths[index]);
  3168. }
  3169. return result;
  3170. }
  3171. /**
  3172. * The base implementation of `_.clamp` which doesn't coerce arguments.
  3173. *
  3174. * @private
  3175. * @param {number} number The number to clamp.
  3176. * @param {number} [lower] The lower bound.
  3177. * @param {number} upper The upper bound.
  3178. * @returns {number} Returns the clamped number.
  3179. */
  3180. function baseClamp(number, lower, upper) {
  3181. if (number === number) {
  3182. if (upper !== undefined) {
  3183. number = number <= upper ? number : upper;
  3184. }
  3185. if (lower !== undefined) {
  3186. number = number >= lower ? number : lower;
  3187. }
  3188. }
  3189. return number;
  3190. }
  3191. /**
  3192. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  3193. * traversed objects.
  3194. *
  3195. * @private
  3196. * @param {*} value The value to clone.
  3197. * @param {boolean} bitmask The bitmask flags.
  3198. * 1 - Deep clone
  3199. * 2 - Flatten inherited properties
  3200. * 4 - Clone symbols
  3201. * @param {Function} [customizer] The function to customize cloning.
  3202. * @param {string} [key] The key of `value`.
  3203. * @param {Object} [object] The parent object of `value`.
  3204. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  3205. * @returns {*} Returns the cloned value.
  3206. */
  3207. function baseClone(value, bitmask, customizer, key, object, stack) {
  3208. var result,
  3209. isDeep = bitmask & CLONE_DEEP_FLAG,
  3210. isFlat = bitmask & CLONE_FLAT_FLAG,
  3211. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  3212. if (customizer) {
  3213. result = object ? customizer(value, key, object, stack) : customizer(value);
  3214. }
  3215. if (result !== undefined) {
  3216. return result;
  3217. }
  3218. if (!isObject(value)) {
  3219. return value;
  3220. }
  3221. var isArr = isArray(value);
  3222. if (isArr) {
  3223. result = initCloneArray(value);
  3224. if (!isDeep) {
  3225. return copyArray(value, result);
  3226. }
  3227. } else {
  3228. var tag = getTag(value),
  3229. isFunc = tag == funcTag || tag == genTag;
  3230. if (isBuffer(value)) {
  3231. return cloneBuffer(value, isDeep);
  3232. }
  3233. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  3234. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  3235. if (!isDeep) {
  3236. return isFlat
  3237. ? copySymbolsIn(value, baseAssignIn(result, value))
  3238. : copySymbols(value, baseAssign(result, value));
  3239. }
  3240. } else {
  3241. if (!cloneableTags[tag]) {
  3242. return object ? value : {};
  3243. }
  3244. result = initCloneByTag(value, tag, baseClone, isDeep);
  3245. }
  3246. }
  3247. // Check for circular references and return its corresponding clone.
  3248. stack || (stack = new Stack);
  3249. var stacked = stack.get(value);
  3250. if (stacked) {
  3251. return stacked;
  3252. }
  3253. stack.set(value, result);
  3254. var keysFunc = isFull
  3255. ? (isFlat ? getAllKeysIn : getAllKeys)
  3256. : (isFlat ? keysIn : keys);
  3257. var props = isArr ? undefined : keysFunc(value);
  3258. arrayEach(props || value, function(subValue, key) {
  3259. if (props) {
  3260. key = subValue;
  3261. subValue = value[key];
  3262. }
  3263. // Recursively populate clone (susceptible to call stack limits).
  3264. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  3265. });
  3266. return result;
  3267. }
  3268. /**
  3269. * The base implementation of `_.conforms` which doesn't clone `source`.
  3270. *
  3271. * @private
  3272. * @param {Object} source The object of property predicates to conform to.
  3273. * @returns {Function} Returns the new spec function.
  3274. */
  3275. function baseConforms(source) {
  3276. var props = keys(source);
  3277. return function(object) {
  3278. return baseConformsTo(object, source, props);
  3279. };
  3280. }
  3281. /**
  3282. * The base implementation of `_.conformsTo` which accepts `props` to check.
  3283. *
  3284. * @private
  3285. * @param {Object} object The object to inspect.
  3286. * @param {Object} source The object of property predicates to conform to.
  3287. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  3288. */
  3289. function baseConformsTo(object, source, props) {
  3290. var length = props.length;
  3291. if (object == null) {
  3292. return !length;
  3293. }
  3294. object = Object(object);
  3295. while (length--) {
  3296. var key = props[length],
  3297. predicate = source[key],
  3298. value = object[key];
  3299. if ((value === undefined && !(key in object)) || !predicate(value)) {
  3300. return false;
  3301. }
  3302. }
  3303. return true;
  3304. }
  3305. /**
  3306. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  3307. * to provide to `func`.
  3308. *
  3309. * @private
  3310. * @param {Function} func The function to delay.
  3311. * @param {number} wait The number of milliseconds to delay invocation.
  3312. * @param {Array} args The arguments to provide to `func`.
  3313. * @returns {number|Object} Returns the timer id or timeout object.
  3314. */
  3315. function baseDelay(func, wait, args) {
  3316. if (typeof func != 'function') {
  3317. throw new TypeError(FUNC_ERROR_TEXT);
  3318. }
  3319. return setTimeout(function() { func.apply(undefined, args); }, wait);
  3320. }
  3321. /**
  3322. * The base implementation of methods like `_.difference` without support
  3323. * for excluding multiple arrays or iteratee shorthands.
  3324. *
  3325. * @private
  3326. * @param {Array} array The array to inspect.
  3327. * @param {Array} values The values to exclude.
  3328. * @param {Function} [iteratee] The iteratee invoked per element.
  3329. * @param {Function} [comparator] The comparator invoked per element.
  3330. * @returns {Array} Returns the new array of filtered values.
  3331. */
  3332. function baseDifference(array, values, iteratee, comparator) {
  3333. var index = -1,
  3334. includes = arrayIncludes,
  3335. isCommon = true,
  3336. length = array.length,
  3337. result = [],
  3338. valuesLength = values.length;
  3339. if (!length) {
  3340. return result;
  3341. }
  3342. if (iteratee) {
  3343. values = arrayMap(values, baseUnary(iteratee));
  3344. }
  3345. if (comparator) {
  3346. includes = arrayIncludesWith;
  3347. isCommon = false;
  3348. }
  3349. else if (values.length >= LARGE_ARRAY_SIZE) {
  3350. includes = cacheHas;
  3351. isCommon = false;
  3352. values = new SetCache(values);
  3353. }
  3354. outer:
  3355. while (++index < length) {
  3356. var value = array[index],
  3357. computed = iteratee == null ? value : iteratee(value);
  3358. value = (comparator || value !== 0) ? value : 0;
  3359. if (isCommon && computed === computed) {
  3360. var valuesIndex = valuesLength;
  3361. while (valuesIndex--) {
  3362. if (values[valuesIndex] === computed) {
  3363. continue outer;
  3364. }
  3365. }
  3366. result.push(value);
  3367. }
  3368. else if (!includes(values, computed, comparator)) {
  3369. result.push(value);
  3370. }
  3371. }
  3372. return result;
  3373. }
  3374. /**
  3375. * The base implementation of `_.forEach` without support for iteratee shorthands.
  3376. *
  3377. * @private
  3378. * @param {Array|Object} collection The collection to iterate over.
  3379. * @param {Function} iteratee The function invoked per iteration.
  3380. * @returns {Array|Object} Returns `collection`.
  3381. */
  3382. var baseEach = createBaseEach(baseForOwn);
  3383. /**
  3384. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  3385. *
  3386. * @private
  3387. * @param {Array|Object} collection The collection to iterate over.
  3388. * @param {Function} iteratee The function invoked per iteration.
  3389. * @returns {Array|Object} Returns `collection`.
  3390. */
  3391. var baseEachRight = createBaseEach(baseForOwnRight, true);
  3392. /**
  3393. * The base implementation of `_.every` without support for iteratee shorthands.
  3394. *
  3395. * @private
  3396. * @param {Array|Object} collection The collection to iterate over.
  3397. * @param {Function} predicate The function invoked per iteration.
  3398. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  3399. * else `false`
  3400. */
  3401. function baseEvery(collection, predicate) {
  3402. var result = true;
  3403. baseEach(collection, function(value, index, collection) {
  3404. result = !!predicate(value, index, collection);
  3405. return result;
  3406. });
  3407. return result;
  3408. }
  3409. /**
  3410. * The base implementation of methods like `_.max` and `_.min` which accepts a
  3411. * `comparator` to determine the extremum value.
  3412. *
  3413. * @private
  3414. * @param {Array} array The array to iterate over.
  3415. * @param {Function} iteratee The iteratee invoked per iteration.
  3416. * @param {Function} comparator The comparator used to compare values.
  3417. * @returns {*} Returns the extremum value.
  3418. */
  3419. function baseExtremum(array, iteratee, comparator) {
  3420. var index = -1,
  3421. length = array.length;
  3422. while (++index < length) {
  3423. var value = array[index],
  3424. current = iteratee(value);
  3425. if (current != null && (computed === undefined
  3426. ? (current === current && !isSymbol(current))
  3427. : comparator(current, computed)
  3428. )) {
  3429. var computed = current,
  3430. result = value;
  3431. }
  3432. }
  3433. return result;
  3434. }
  3435. /**
  3436. * The base implementation of `_.fill` without an iteratee call guard.
  3437. *
  3438. * @private
  3439. * @param {Array} array The array to fill.
  3440. * @param {*} value The value to fill `array` with.
  3441. * @param {number} [start=0] The start position.
  3442. * @param {number} [end=array.length] The end position.
  3443. * @returns {Array} Returns `array`.
  3444. */
  3445. function baseFill(array, value, start, end) {
  3446. var length = array.length;
  3447. start = toInteger(start);
  3448. if (start < 0) {
  3449. start = -start > length ? 0 : (length + start);
  3450. }
  3451. end = (end === undefined || end > length) ? length : toInteger(end);
  3452. if (end < 0) {
  3453. end += length;
  3454. }
  3455. end = start > end ? 0 : toLength(end);
  3456. while (start < end) {
  3457. array[start++] = value;
  3458. }
  3459. return array;
  3460. }
  3461. /**
  3462. * The base implementation of `_.filter` without support for iteratee shorthands.
  3463. *
  3464. * @private
  3465. * @param {Array|Object} collection The collection to iterate over.
  3466. * @param {Function} predicate The function invoked per iteration.
  3467. * @returns {Array} Returns the new filtered array.
  3468. */
  3469. function baseFilter(collection, predicate) {
  3470. var result = [];
  3471. baseEach(collection, function(value, index, collection) {
  3472. if (predicate(value, index, collection)) {
  3473. result.push(value);
  3474. }
  3475. });
  3476. return result;
  3477. }
  3478. /**
  3479. * The base implementation of `_.flatten` with support for restricting flattening.
  3480. *
  3481. * @private
  3482. * @param {Array} array The array to flatten.
  3483. * @param {number} depth The maximum recursion depth.
  3484. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  3485. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  3486. * @param {Array} [result=[]] The initial result value.
  3487. * @returns {Array} Returns the new flattened array.
  3488. */
  3489. function baseFlatten(array, depth, predicate, isStrict, result) {
  3490. var index = -1,
  3491. length = array.length;
  3492. predicate || (predicate = isFlattenable);
  3493. result || (result = []);
  3494. while (++index < length) {
  3495. var value = array[index];
  3496. if (depth > 0 && predicate(value)) {
  3497. if (depth > 1) {
  3498. // Recursively flatten arrays (susceptible to call stack limits).
  3499. baseFlatten(value, depth - 1, predicate, isStrict, result);
  3500. } else {
  3501. arrayPush(result, value);
  3502. }
  3503. } else if (!isStrict) {
  3504. result[result.length] = value;
  3505. }
  3506. }
  3507. return result;
  3508. }
  3509. /**
  3510. * The base implementation of `baseForOwn` which iterates over `object`
  3511. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  3512. * Iteratee functions may exit iteration early by explicitly returning `false`.
  3513. *
  3514. * @private
  3515. * @param {Object} object The object to iterate over.
  3516. * @param {Function} iteratee The function invoked per iteration.
  3517. * @param {Function} keysFunc The function to get the keys of `object`.
  3518. * @returns {Object} Returns `object`.
  3519. */
  3520. var baseFor = createBaseFor();
  3521. /**
  3522. * This function is like `baseFor` except that it iterates over properties
  3523. * in the opposite order.
  3524. *
  3525. * @private
  3526. * @param {Object} object The object to iterate over.
  3527. * @param {Function} iteratee The function invoked per iteration.
  3528. * @param {Function} keysFunc The function to get the keys of `object`.
  3529. * @returns {Object} Returns `object`.
  3530. */
  3531. var baseForRight = createBaseFor(true);
  3532. /**
  3533. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  3534. *
  3535. * @private
  3536. * @param {Object} object The object to iterate over.
  3537. * @param {Function} iteratee The function invoked per iteration.
  3538. * @returns {Object} Returns `object`.
  3539. */
  3540. function baseForOwn(object, iteratee) {
  3541. return object && baseFor(object, iteratee, keys);
  3542. }
  3543. /**
  3544. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  3545. *
  3546. * @private
  3547. * @param {Object} object The object to iterate over.
  3548. * @param {Function} iteratee The function invoked per iteration.
  3549. * @returns {Object} Returns `object`.
  3550. */
  3551. function baseForOwnRight(object, iteratee) {
  3552. return object && baseForRight(object, iteratee, keys);
  3553. }
  3554. /**
  3555. * The base implementation of `_.functions` which creates an array of
  3556. * `object` function property names filtered from `props`.
  3557. *
  3558. * @private
  3559. * @param {Object} object The object to inspect.
  3560. * @param {Array} props The property names to filter.
  3561. * @returns {Array} Returns the function names.
  3562. */
  3563. function baseFunctions(object, props) {
  3564. return arrayFilter(props, function(key) {
  3565. return isFunction(object[key]);
  3566. });
  3567. }
  3568. /**
  3569. * The base implementation of `_.get` without support for default values.
  3570. *
  3571. * @private
  3572. * @param {Object} object The object to query.
  3573. * @param {Array|string} path The path of the property to get.
  3574. * @returns {*} Returns the resolved value.
  3575. */
  3576. function baseGet(object, path) {
  3577. path = castPath(path, object);
  3578. var index = 0,
  3579. length = path.length;
  3580. while (object != null && index < length) {
  3581. object = object[toKey(path[index++])];
  3582. }
  3583. return (index && index == length) ? object : undefined;
  3584. }
  3585. /**
  3586. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  3587. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  3588. * symbols of `object`.
  3589. *
  3590. * @private
  3591. * @param {Object} object The object to query.
  3592. * @param {Function} keysFunc The function to get the keys of `object`.
  3593. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  3594. * @returns {Array} Returns the array of property names and symbols.
  3595. */
  3596. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  3597. var result = keysFunc(object);
  3598. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  3599. }
  3600. /**
  3601. * The base implementation of `getTag` without fallbacks for buggy environments.
  3602. *
  3603. * @private
  3604. * @param {*} value The value to query.
  3605. * @returns {string} Returns the `toStringTag`.
  3606. */
  3607. function baseGetTag(value) {
  3608. if (value == null) {
  3609. return value === undefined ? undefinedTag : nullTag;
  3610. }
  3611. return (symToStringTag && symToStringTag in Object(value))
  3612. ? getRawTag(value)
  3613. : objectToString(value);
  3614. }
  3615. /**
  3616. * The base implementation of `_.gt` which doesn't coerce arguments.
  3617. *
  3618. * @private
  3619. * @param {*} value The value to compare.
  3620. * @param {*} other The other value to compare.
  3621. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  3622. * else `false`.
  3623. */
  3624. function baseGt(value, other) {
  3625. return value > other;
  3626. }
  3627. /**
  3628. * The base implementation of `_.has` without support for deep paths.
  3629. *
  3630. * @private
  3631. * @param {Object} [object] The object to query.
  3632. * @param {Array|string} key The key to check.
  3633. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3634. */
  3635. function baseHas(object, key) {
  3636. return object != null && hasOwnProperty.call(object, key);
  3637. }
  3638. /**
  3639. * The base implementation of `_.hasIn` without support for deep paths.
  3640. *
  3641. * @private
  3642. * @param {Object} [object] The object to query.
  3643. * @param {Array|string} key The key to check.
  3644. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3645. */
  3646. function baseHasIn(object, key) {
  3647. return object != null && key in Object(object);
  3648. }
  3649. /**
  3650. * The base implementation of `_.inRange` which doesn't coerce arguments.
  3651. *
  3652. * @private
  3653. * @param {number} number The number to check.
  3654. * @param {number} start The start of the range.
  3655. * @param {number} end The end of the range.
  3656. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  3657. */
  3658. function baseInRange(number, start, end) {
  3659. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  3660. }
  3661. /**
  3662. * The base implementation of methods like `_.intersection`, without support
  3663. * for iteratee shorthands, that accepts an array of arrays to inspect.
  3664. *
  3665. * @private
  3666. * @param {Array} arrays The arrays to inspect.
  3667. * @param {Function} [iteratee] The iteratee invoked per element.
  3668. * @param {Function} [comparator] The comparator invoked per element.
  3669. * @returns {Array} Returns the new array of shared values.
  3670. */
  3671. function baseIntersection(arrays, iteratee, comparator) {
  3672. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  3673. length = arrays[0].length,
  3674. othLength = arrays.length,
  3675. othIndex = othLength,
  3676. caches = Array(othLength),
  3677. maxLength = Infinity,
  3678. result = [];
  3679. while (othIndex--) {
  3680. var array = arrays[othIndex];
  3681. if (othIndex && iteratee) {
  3682. array = arrayMap(array, baseUnary(iteratee));
  3683. }
  3684. maxLength = nativeMin(array.length, maxLength);
  3685. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  3686. ? new SetCache(othIndex && array)
  3687. : undefined;
  3688. }
  3689. array = arrays[0];
  3690. var index = -1,
  3691. seen = caches[0];
  3692. outer:
  3693. while (++index < length && result.length < maxLength) {
  3694. var value = array[index],
  3695. computed = iteratee ? iteratee(value) : value;
  3696. value = (comparator || value !== 0) ? value : 0;
  3697. if (!(seen
  3698. ? cacheHas(seen, computed)
  3699. : includes(result, computed, comparator)
  3700. )) {
  3701. othIndex = othLength;
  3702. while (--othIndex) {
  3703. var cache = caches[othIndex];
  3704. if (!(cache
  3705. ? cacheHas(cache, computed)
  3706. : includes(arrays[othIndex], computed, comparator))
  3707. ) {
  3708. continue outer;
  3709. }
  3710. }
  3711. if (seen) {
  3712. seen.push(computed);
  3713. }
  3714. result.push(value);
  3715. }
  3716. }
  3717. return result;
  3718. }
  3719. /**
  3720. * The base implementation of `_.invert` and `_.invertBy` which inverts
  3721. * `object` with values transformed by `iteratee` and set by `setter`.
  3722. *
  3723. * @private
  3724. * @param {Object} object The object to iterate over.
  3725. * @param {Function} setter The function to set `accumulator` values.
  3726. * @param {Function} iteratee The iteratee to transform values.
  3727. * @param {Object} accumulator The initial inverted object.
  3728. * @returns {Function} Returns `accumulator`.
  3729. */
  3730. function baseInverter(object, setter, iteratee, accumulator) {
  3731. baseForOwn(object, function(value, key, object) {
  3732. setter(accumulator, iteratee(value), key, object);
  3733. });
  3734. return accumulator;
  3735. }
  3736. /**
  3737. * The base implementation of `_.invoke` without support for individual
  3738. * method arguments.
  3739. *
  3740. * @private
  3741. * @param {Object} object The object to query.
  3742. * @param {Array|string} path The path of the method to invoke.
  3743. * @param {Array} args The arguments to invoke the method with.
  3744. * @returns {*} Returns the result of the invoked method.
  3745. */
  3746. function baseInvoke(object, path, args) {
  3747. path = castPath(path, object);
  3748. object = parent(object, path);
  3749. var func = object == null ? object : object[toKey(last(path))];
  3750. return func == null ? undefined : apply(func, object, args);
  3751. }
  3752. /**
  3753. * The base implementation of `_.isArguments`.
  3754. *
  3755. * @private
  3756. * @param {*} value The value to check.
  3757. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  3758. */
  3759. function baseIsArguments(value) {
  3760. return isObjectLike(value) && baseGetTag(value) == argsTag;
  3761. }
  3762. /**
  3763. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  3764. *
  3765. * @private
  3766. * @param {*} value The value to check.
  3767. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  3768. */
  3769. function baseIsArrayBuffer(value) {
  3770. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  3771. }
  3772. /**
  3773. * The base implementation of `_.isDate` without Node.js optimizations.
  3774. *
  3775. * @private
  3776. * @param {*} value The value to check.
  3777. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  3778. */
  3779. function baseIsDate(value) {
  3780. return isObjectLike(value) && baseGetTag(value) == dateTag;
  3781. }
  3782. /**
  3783. * The base implementation of `_.isEqual` which supports partial comparisons
  3784. * and tracks traversed objects.
  3785. *
  3786. * @private
  3787. * @param {*} value The value to compare.
  3788. * @param {*} other The other value to compare.
  3789. * @param {boolean} bitmask The bitmask flags.
  3790. * 1 - Unordered comparison
  3791. * 2 - Partial comparison
  3792. * @param {Function} [customizer] The function to customize comparisons.
  3793. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  3794. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3795. */
  3796. function baseIsEqual(value, other, bitmask, customizer, stack) {
  3797. if (value === other) {
  3798. return true;
  3799. }
  3800. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  3801. return value !== value && other !== other;
  3802. }
  3803. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  3804. }
  3805. /**
  3806. * A specialized version of `baseIsEqual` for arrays and objects which performs
  3807. * deep comparisons and tracks traversed objects enabling objects with circular
  3808. * references to be compared.
  3809. *
  3810. * @private
  3811. * @param {Object} object The object to compare.
  3812. * @param {Object} other The other object to compare.
  3813. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  3814. * @param {Function} customizer The function to customize comparisons.
  3815. * @param {Function} equalFunc The function to determine equivalents of values.
  3816. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  3817. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3818. */
  3819. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  3820. var objIsArr = isArray(object),
  3821. othIsArr = isArray(other),
  3822. objTag = objIsArr ? arrayTag : getTag(object),
  3823. othTag = othIsArr ? arrayTag : getTag(other);
  3824. objTag = objTag == argsTag ? objectTag : objTag;
  3825. othTag = othTag == argsTag ? objectTag : othTag;
  3826. var objIsObj = objTag == objectTag,
  3827. othIsObj = othTag == objectTag,
  3828. isSameTag = objTag == othTag;
  3829. if (isSameTag && isBuffer(object)) {
  3830. if (!isBuffer(other)) {
  3831. return false;
  3832. }
  3833. objIsArr = true;
  3834. objIsObj = false;
  3835. }
  3836. if (isSameTag && !objIsObj) {
  3837. stack || (stack = new Stack);
  3838. return (objIsArr || isTypedArray(object))
  3839. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  3840. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  3841. }
  3842. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  3843. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  3844. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  3845. if (objIsWrapped || othIsWrapped) {
  3846. var objUnwrapped = objIsWrapped ? object.value() : object,
  3847. othUnwrapped = othIsWrapped ? other.value() : other;
  3848. stack || (stack = new Stack);
  3849. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  3850. }
  3851. }
  3852. if (!isSameTag) {
  3853. return false;
  3854. }
  3855. stack || (stack = new Stack);
  3856. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  3857. }
  3858. /**
  3859. * The base implementation of `_.isMap` without Node.js optimizations.
  3860. *
  3861. * @private
  3862. * @param {*} value The value to check.
  3863. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  3864. */
  3865. function baseIsMap(value) {
  3866. return isObjectLike(value) && getTag(value) == mapTag;
  3867. }
  3868. /**
  3869. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  3870. *
  3871. * @private
  3872. * @param {Object} object The object to inspect.
  3873. * @param {Object} source The object of property values to match.
  3874. * @param {Array} matchData The property names, values, and compare flags to match.
  3875. * @param {Function} [customizer] The function to customize comparisons.
  3876. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  3877. */
  3878. function baseIsMatch(object, source, matchData, customizer) {
  3879. var index = matchData.length,
  3880. length = index,
  3881. noCustomizer = !customizer;
  3882. if (object == null) {
  3883. return !length;
  3884. }
  3885. object = Object(object);
  3886. while (index--) {
  3887. var data = matchData[index];
  3888. if ((noCustomizer && data[2])
  3889. ? data[1] !== object[data[0]]
  3890. : !(data[0] in object)
  3891. ) {
  3892. return false;
  3893. }
  3894. }
  3895. while (++index < length) {
  3896. data = matchData[index];
  3897. var key = data[0],
  3898. objValue = object[key],
  3899. srcValue = data[1];
  3900. if (noCustomizer && data[2]) {
  3901. if (objValue === undefined && !(key in object)) {
  3902. return false;
  3903. }
  3904. } else {
  3905. var stack = new Stack;
  3906. if (customizer) {
  3907. var result = customizer(objValue, srcValue, key, object, source, stack);
  3908. }
  3909. if (!(result === undefined
  3910. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  3911. : result
  3912. )) {
  3913. return false;
  3914. }
  3915. }
  3916. }
  3917. return true;
  3918. }
  3919. /**
  3920. * The base implementation of `_.isNative` without bad shim checks.
  3921. *
  3922. * @private
  3923. * @param {*} value The value to check.
  3924. * @returns {boolean} Returns `true` if `value` is a native function,
  3925. * else `false`.
  3926. */
  3927. function baseIsNative(value) {
  3928. if (!isObject(value) || isMasked(value)) {
  3929. return false;
  3930. }
  3931. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  3932. return pattern.test(toSource(value));
  3933. }
  3934. /**
  3935. * The base implementation of `_.isRegExp` without Node.js optimizations.
  3936. *
  3937. * @private
  3938. * @param {*} value The value to check.
  3939. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  3940. */
  3941. function baseIsRegExp(value) {
  3942. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  3943. }
  3944. /**
  3945. * The base implementation of `_.isSet` without Node.js optimizations.
  3946. *
  3947. * @private
  3948. * @param {*} value The value to check.
  3949. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  3950. */
  3951. function baseIsSet(value) {
  3952. return isObjectLike(value) && getTag(value) == setTag;
  3953. }
  3954. /**
  3955. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  3956. *
  3957. * @private
  3958. * @param {*} value The value to check.
  3959. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3960. */
  3961. function baseIsTypedArray(value) {
  3962. return isObjectLike(value) &&
  3963. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  3964. }
  3965. /**
  3966. * The base implementation of `_.iteratee`.
  3967. *
  3968. * @private
  3969. * @param {*} [value=_.identity] The value to convert to an iteratee.
  3970. * @returns {Function} Returns the iteratee.
  3971. */
  3972. function baseIteratee(value) {
  3973. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  3974. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  3975. if (typeof value == 'function') {
  3976. return value;
  3977. }
  3978. if (value == null) {
  3979. return identity;
  3980. }
  3981. if (typeof value == 'object') {
  3982. return isArray(value)
  3983. ? baseMatchesProperty(value[0], value[1])
  3984. : baseMatches(value);
  3985. }
  3986. return property(value);
  3987. }
  3988. /**
  3989. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  3990. *
  3991. * @private
  3992. * @param {Object} object The object to query.
  3993. * @returns {Array} Returns the array of property names.
  3994. */
  3995. function baseKeys(object) {
  3996. if (!isPrototype(object)) {
  3997. return nativeKeys(object);
  3998. }
  3999. var result = [];
  4000. for (var key in Object(object)) {
  4001. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  4002. result.push(key);
  4003. }
  4004. }
  4005. return result;
  4006. }
  4007. /**
  4008. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  4009. *
  4010. * @private
  4011. * @param {Object} object The object to query.
  4012. * @returns {Array} Returns the array of property names.
  4013. */
  4014. function baseKeysIn(object) {
  4015. if (!isObject(object)) {
  4016. return nativeKeysIn(object);
  4017. }
  4018. var isProto = isPrototype(object),
  4019. result = [];
  4020. for (var key in object) {
  4021. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  4022. result.push(key);
  4023. }
  4024. }
  4025. return result;
  4026. }
  4027. /**
  4028. * The base implementation of `_.lt` which doesn't coerce arguments.
  4029. *
  4030. * @private
  4031. * @param {*} value The value to compare.
  4032. * @param {*} other The other value to compare.
  4033. * @returns {boolean} Returns `true` if `value` is less than `other`,
  4034. * else `false`.
  4035. */
  4036. function baseLt(value, other) {
  4037. return value < other;
  4038. }
  4039. /**
  4040. * The base implementation of `_.map` without support for iteratee shorthands.
  4041. *
  4042. * @private
  4043. * @param {Array|Object} collection The collection to iterate over.
  4044. * @param {Function} iteratee The function invoked per iteration.
  4045. * @returns {Array} Returns the new mapped array.
  4046. */
  4047. function baseMap(collection, iteratee) {
  4048. var index = -1,
  4049. result = isArrayLike(collection) ? Array(collection.length) : [];
  4050. baseEach(collection, function(value, key, collection) {
  4051. result[++index] = iteratee(value, key, collection);
  4052. });
  4053. return result;
  4054. }
  4055. /**
  4056. * The base implementation of `_.matches` which doesn't clone `source`.
  4057. *
  4058. * @private
  4059. * @param {Object} source The object of property values to match.
  4060. * @returns {Function} Returns the new spec function.
  4061. */
  4062. function baseMatches(source) {
  4063. var matchData = getMatchData(source);
  4064. if (matchData.length == 1 && matchData[0][2]) {
  4065. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  4066. }
  4067. return function(object) {
  4068. return object === source || baseIsMatch(object, source, matchData);
  4069. };
  4070. }
  4071. /**
  4072. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  4073. *
  4074. * @private
  4075. * @param {string} path The path of the property to get.
  4076. * @param {*} srcValue The value to match.
  4077. * @returns {Function} Returns the new spec function.
  4078. */
  4079. function baseMatchesProperty(path, srcValue) {
  4080. if (isKey(path) && isStrictComparable(srcValue)) {
  4081. return matchesStrictComparable(toKey(path), srcValue);
  4082. }
  4083. return function(object) {
  4084. var objValue = get(object, path);
  4085. return (objValue === undefined && objValue === srcValue)
  4086. ? hasIn(object, path)
  4087. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  4088. };
  4089. }
  4090. /**
  4091. * The base implementation of `_.merge` without support for multiple sources.
  4092. *
  4093. * @private
  4094. * @param {Object} object The destination object.
  4095. * @param {Object} source The source object.
  4096. * @param {number} srcIndex The index of `source`.
  4097. * @param {Function} [customizer] The function to customize merged values.
  4098. * @param {Object} [stack] Tracks traversed source values and their merged
  4099. * counterparts.
  4100. */
  4101. function baseMerge(object, source, srcIndex, customizer, stack) {
  4102. if (object === source) {
  4103. return;
  4104. }
  4105. baseFor(source, function(srcValue, key) {
  4106. if (isObject(srcValue)) {
  4107. stack || (stack = new Stack);
  4108. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  4109. }
  4110. else {
  4111. var newValue = customizer
  4112. ? customizer(object[key], srcValue, (key + ''), object, source, stack)
  4113. : undefined;
  4114. if (newValue === undefined) {
  4115. newValue = srcValue;
  4116. }
  4117. assignMergeValue(object, key, newValue);
  4118. }
  4119. }, keysIn);
  4120. }
  4121. /**
  4122. * A specialized version of `baseMerge` for arrays and objects which performs
  4123. * deep merges and tracks traversed objects enabling objects with circular
  4124. * references to be merged.
  4125. *
  4126. * @private
  4127. * @param {Object} object The destination object.
  4128. * @param {Object} source The source object.
  4129. * @param {string} key The key of the value to merge.
  4130. * @param {number} srcIndex The index of `source`.
  4131. * @param {Function} mergeFunc The function to merge values.
  4132. * @param {Function} [customizer] The function to customize assigned values.
  4133. * @param {Object} [stack] Tracks traversed source values and their merged
  4134. * counterparts.
  4135. */
  4136. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  4137. var objValue = object[key],
  4138. srcValue = source[key],
  4139. stacked = stack.get(srcValue);
  4140. if (stacked) {
  4141. assignMergeValue(object, key, stacked);
  4142. return;
  4143. }
  4144. var newValue = customizer
  4145. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  4146. : undefined;
  4147. var isCommon = newValue === undefined;
  4148. if (isCommon) {
  4149. var isArr = isArray(srcValue),
  4150. isBuff = !isArr && isBuffer(srcValue),
  4151. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  4152. newValue = srcValue;
  4153. if (isArr || isBuff || isTyped) {
  4154. if (isArray(objValue)) {
  4155. newValue = objValue;
  4156. }
  4157. else if (isArrayLikeObject(objValue)) {
  4158. newValue = copyArray(objValue);
  4159. }
  4160. else if (isBuff) {
  4161. isCommon = false;
  4162. newValue = cloneBuffer(srcValue, true);
  4163. }
  4164. else if (isTyped) {
  4165. isCommon = false;
  4166. newValue = cloneTypedArray(srcValue, true);
  4167. }
  4168. else {
  4169. newValue = [];
  4170. }
  4171. }
  4172. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  4173. newValue = objValue;
  4174. if (isArguments(objValue)) {
  4175. newValue = toPlainObject(objValue);
  4176. }
  4177. else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
  4178. newValue = initCloneObject(srcValue);
  4179. }
  4180. }
  4181. else {
  4182. isCommon = false;
  4183. }
  4184. }
  4185. if (isCommon) {
  4186. // Recursively merge objects and arrays (susceptible to call stack limits).
  4187. stack.set(srcValue, newValue);
  4188. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  4189. stack['delete'](srcValue);
  4190. }
  4191. assignMergeValue(object, key, newValue);
  4192. }
  4193. /**
  4194. * The base implementation of `_.nth` which doesn't coerce arguments.
  4195. *
  4196. * @private
  4197. * @param {Array} array The array to query.
  4198. * @param {number} n The index of the element to return.
  4199. * @returns {*} Returns the nth element of `array`.
  4200. */
  4201. function baseNth(array, n) {
  4202. var length = array.length;
  4203. if (!length) {
  4204. return;
  4205. }
  4206. n += n < 0 ? length : 0;
  4207. return isIndex(n, length) ? array[n] : undefined;
  4208. }
  4209. /**
  4210. * The base implementation of `_.orderBy` without param guards.
  4211. *
  4212. * @private
  4213. * @param {Array|Object} collection The collection to iterate over.
  4214. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  4215. * @param {string[]} orders The sort orders of `iteratees`.
  4216. * @returns {Array} Returns the new sorted array.
  4217. */
  4218. function baseOrderBy(collection, iteratees, orders) {
  4219. var index = -1;
  4220. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  4221. var result = baseMap(collection, function(value, key, collection) {
  4222. var criteria = arrayMap(iteratees, function(iteratee) {
  4223. return iteratee(value);
  4224. });
  4225. return { 'criteria': criteria, 'index': ++index, 'value': value };
  4226. });
  4227. return baseSortBy(result, function(object, other) {
  4228. return compareMultiple(object, other, orders);
  4229. });
  4230. }
  4231. /**
  4232. * The base implementation of `_.pick` without support for individual
  4233. * property identifiers.
  4234. *
  4235. * @private
  4236. * @param {Object} object The source object.
  4237. * @param {string[]} paths The property paths to pick.
  4238. * @returns {Object} Returns the new object.
  4239. */
  4240. function basePick(object, paths) {
  4241. return basePickBy(object, paths, function(value, path) {
  4242. return hasIn(object, path);
  4243. });
  4244. }
  4245. /**
  4246. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  4247. *
  4248. * @private
  4249. * @param {Object} object The source object.
  4250. * @param {string[]} paths The property paths to pick.
  4251. * @param {Function} predicate The function invoked per property.
  4252. * @returns {Object} Returns the new object.
  4253. */
  4254. function basePickBy(object, paths, predicate) {
  4255. var index = -1,
  4256. length = paths.length,
  4257. result = {};
  4258. while (++index < length) {
  4259. var path = paths[index],
  4260. value = baseGet(object, path);
  4261. if (predicate(value, path)) {
  4262. baseSet(result, castPath(path, object), value);
  4263. }
  4264. }
  4265. return result;
  4266. }
  4267. /**
  4268. * A specialized version of `baseProperty` which supports deep paths.
  4269. *
  4270. * @private
  4271. * @param {Array|string} path The path of the property to get.
  4272. * @returns {Function} Returns the new accessor function.
  4273. */
  4274. function basePropertyDeep(path) {
  4275. return function(object) {
  4276. return baseGet(object, path);
  4277. };
  4278. }
  4279. /**
  4280. * The base implementation of `_.pullAllBy` without support for iteratee
  4281. * shorthands.
  4282. *
  4283. * @private
  4284. * @param {Array} array The array to modify.
  4285. * @param {Array} values The values to remove.
  4286. * @param {Function} [iteratee] The iteratee invoked per element.
  4287. * @param {Function} [comparator] The comparator invoked per element.
  4288. * @returns {Array} Returns `array`.
  4289. */
  4290. function basePullAll(array, values, iteratee, comparator) {
  4291. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  4292. index = -1,
  4293. length = values.length,
  4294. seen = array;
  4295. if (array === values) {
  4296. values = copyArray(values);
  4297. }
  4298. if (iteratee) {
  4299. seen = arrayMap(array, baseUnary(iteratee));
  4300. }
  4301. while (++index < length) {
  4302. var fromIndex = 0,
  4303. value = values[index],
  4304. computed = iteratee ? iteratee(value) : value;
  4305. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  4306. if (seen !== array) {
  4307. splice.call(seen, fromIndex, 1);
  4308. }
  4309. splice.call(array, fromIndex, 1);
  4310. }
  4311. }
  4312. return array;
  4313. }
  4314. /**
  4315. * The base implementation of `_.pullAt` without support for individual
  4316. * indexes or capturing the removed elements.
  4317. *
  4318. * @private
  4319. * @param {Array} array The array to modify.
  4320. * @param {number[]} indexes The indexes of elements to remove.
  4321. * @returns {Array} Returns `array`.
  4322. */
  4323. function basePullAt(array, indexes) {
  4324. var length = array ? indexes.length : 0,
  4325. lastIndex = length - 1;
  4326. while (length--) {
  4327. var index = indexes[length];
  4328. if (length == lastIndex || index !== previous) {
  4329. var previous = index;
  4330. if (isIndex(index)) {
  4331. splice.call(array, index, 1);
  4332. } else {
  4333. baseUnset(array, index);
  4334. }
  4335. }
  4336. }
  4337. return array;
  4338. }
  4339. /**
  4340. * The base implementation of `_.random` without support for returning
  4341. * floating-point numbers.
  4342. *
  4343. * @private
  4344. * @param {number} lower The lower bound.
  4345. * @param {number} upper The upper bound.
  4346. * @returns {number} Returns the random number.
  4347. */
  4348. function baseRandom(lower, upper) {
  4349. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  4350. }
  4351. /**
  4352. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  4353. * coerce arguments.
  4354. *
  4355. * @private
  4356. * @param {number} start The start of the range.
  4357. * @param {number} end The end of the range.
  4358. * @param {number} step The value to increment or decrement by.
  4359. * @param {boolean} [fromRight] Specify iterating from right to left.
  4360. * @returns {Array} Returns the range of numbers.
  4361. */
  4362. function baseRange(start, end, step, fromRight) {
  4363. var index = -1,
  4364. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  4365. result = Array(length);
  4366. while (length--) {
  4367. result[fromRight ? length : ++index] = start;
  4368. start += step;
  4369. }
  4370. return result;
  4371. }
  4372. /**
  4373. * The base implementation of `_.repeat` which doesn't coerce arguments.
  4374. *
  4375. * @private
  4376. * @param {string} string The string to repeat.
  4377. * @param {number} n The number of times to repeat the string.
  4378. * @returns {string} Returns the repeated string.
  4379. */
  4380. function baseRepeat(string, n) {
  4381. var result = '';
  4382. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  4383. return result;
  4384. }
  4385. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  4386. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  4387. do {
  4388. if (n % 2) {
  4389. result += string;
  4390. }
  4391. n = nativeFloor(n / 2);
  4392. if (n) {
  4393. string += string;
  4394. }
  4395. } while (n);
  4396. return result;
  4397. }
  4398. /**
  4399. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  4400. *
  4401. * @private
  4402. * @param {Function} func The function to apply a rest parameter to.
  4403. * @param {number} [start=func.length-1] The start position of the rest parameter.
  4404. * @returns {Function} Returns the new function.
  4405. */
  4406. function baseRest(func, start) {
  4407. return setToString(overRest(func, start, identity), func + '');
  4408. }
  4409. /**
  4410. * The base implementation of `_.sample`.
  4411. *
  4412. * @private
  4413. * @param {Array|Object} collection The collection to sample.
  4414. * @returns {*} Returns the random element.
  4415. */
  4416. function baseSample(collection) {
  4417. return arraySample(values(collection));
  4418. }
  4419. /**
  4420. * The base implementation of `_.sampleSize` without param guards.
  4421. *
  4422. * @private
  4423. * @param {Array|Object} collection The collection to sample.
  4424. * @param {number} n The number of elements to sample.
  4425. * @returns {Array} Returns the random elements.
  4426. */
  4427. function baseSampleSize(collection, n) {
  4428. var array = values(collection);
  4429. return shuffleSelf(array, baseClamp(n, 0, array.length));
  4430. }
  4431. /**
  4432. * The base implementation of `_.set`.
  4433. *
  4434. * @private
  4435. * @param {Object} object The object to modify.
  4436. * @param {Array|string} path The path of the property to set.
  4437. * @param {*} value The value to set.
  4438. * @param {Function} [customizer] The function to customize path creation.
  4439. * @returns {Object} Returns `object`.
  4440. */
  4441. function baseSet(object, path, value, customizer) {
  4442. if (!isObject(object)) {
  4443. return object;
  4444. }
  4445. path = castPath(path, object);
  4446. var index = -1,
  4447. length = path.length,
  4448. lastIndex = length - 1,
  4449. nested = object;
  4450. while (nested != null && ++index < length) {
  4451. var key = toKey(path[index]),
  4452. newValue = value;
  4453. if (index != lastIndex) {
  4454. var objValue = nested[key];
  4455. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  4456. if (newValue === undefined) {
  4457. newValue = isObject(objValue)
  4458. ? objValue
  4459. : (isIndex(path[index + 1]) ? [] : {});
  4460. }
  4461. }
  4462. assignValue(nested, key, newValue);
  4463. nested = nested[key];
  4464. }
  4465. return object;
  4466. }
  4467. /**
  4468. * The base implementation of `setData` without support for hot loop shorting.
  4469. *
  4470. * @private
  4471. * @param {Function} func The function to associate metadata with.
  4472. * @param {*} data The metadata.
  4473. * @returns {Function} Returns `func`.
  4474. */
  4475. var baseSetData = !metaMap ? identity : function(func, data) {
  4476. metaMap.set(func, data);
  4477. return func;
  4478. };
  4479. /**
  4480. * The base implementation of `setToString` without support for hot loop shorting.
  4481. *
  4482. * @private
  4483. * @param {Function} func The function to modify.
  4484. * @param {Function} string The `toString` result.
  4485. * @returns {Function} Returns `func`.
  4486. */
  4487. var baseSetToString = !defineProperty ? identity : function(func, string) {
  4488. return defineProperty(func, 'toString', {
  4489. 'configurable': true,
  4490. 'enumerable': false,
  4491. 'value': constant(string),
  4492. 'writable': true
  4493. });
  4494. };
  4495. /**
  4496. * The base implementation of `_.shuffle`.
  4497. *
  4498. * @private
  4499. * @param {Array|Object} collection The collection to shuffle.
  4500. * @returns {Array} Returns the new shuffled array.
  4501. */
  4502. function baseShuffle(collection) {
  4503. return shuffleSelf(values(collection));
  4504. }
  4505. /**
  4506. * The base implementation of `_.slice` without an iteratee call guard.
  4507. *
  4508. * @private
  4509. * @param {Array} array The array to slice.
  4510. * @param {number} [start=0] The start position.
  4511. * @param {number} [end=array.length] The end position.
  4512. * @returns {Array} Returns the slice of `array`.
  4513. */
  4514. function baseSlice(array, start, end) {
  4515. var index = -1,
  4516. length = array.length;
  4517. if (start < 0) {
  4518. start = -start > length ? 0 : (length + start);
  4519. }
  4520. end = end > length ? length : end;
  4521. if (end < 0) {
  4522. end += length;
  4523. }
  4524. length = start > end ? 0 : ((end - start) >>> 0);
  4525. start >>>= 0;
  4526. var result = Array(length);
  4527. while (++index < length) {
  4528. result[index] = array[index + start];
  4529. }
  4530. return result;
  4531. }
  4532. /**
  4533. * The base implementation of `_.some` without support for iteratee shorthands.
  4534. *
  4535. * @private
  4536. * @param {Array|Object} collection The collection to iterate over.
  4537. * @param {Function} predicate The function invoked per iteration.
  4538. * @returns {boolean} Returns `true` if any element passes the predicate check,
  4539. * else `false`.
  4540. */
  4541. function baseSome(collection, predicate) {
  4542. var result;
  4543. baseEach(collection, function(value, index, collection) {
  4544. result = predicate(value, index, collection);
  4545. return !result;
  4546. });
  4547. return !!result;
  4548. }
  4549. /**
  4550. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  4551. * performs a binary search of `array` to determine the index at which `value`
  4552. * should be inserted into `array` in order to maintain its sort order.
  4553. *
  4554. * @private
  4555. * @param {Array} array The sorted array to inspect.
  4556. * @param {*} value The value to evaluate.
  4557. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  4558. * @returns {number} Returns the index at which `value` should be inserted
  4559. * into `array`.
  4560. */
  4561. function baseSortedIndex(array, value, retHighest) {
  4562. var low = 0,
  4563. high = array == null ? low : array.length;
  4564. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  4565. while (low < high) {
  4566. var mid = (low + high) >>> 1,
  4567. computed = array[mid];
  4568. if (computed !== null && !isSymbol(computed) &&
  4569. (retHighest ? (computed <= value) : (computed < value))) {
  4570. low = mid + 1;
  4571. } else {
  4572. high = mid;
  4573. }
  4574. }
  4575. return high;
  4576. }
  4577. return baseSortedIndexBy(array, value, identity, retHighest);
  4578. }
  4579. /**
  4580. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  4581. * which invokes `iteratee` for `value` and each element of `array` to compute
  4582. * their sort ranking. The iteratee is invoked with one argument; (value).
  4583. *
  4584. * @private
  4585. * @param {Array} array The sorted array to inspect.
  4586. * @param {*} value The value to evaluate.
  4587. * @param {Function} iteratee The iteratee invoked per element.
  4588. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  4589. * @returns {number} Returns the index at which `value` should be inserted
  4590. * into `array`.
  4591. */
  4592. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  4593. value = iteratee(value);
  4594. var low = 0,
  4595. high = array == null ? 0 : array.length,
  4596. valIsNaN = value !== value,
  4597. valIsNull = value === null,
  4598. valIsSymbol = isSymbol(value),
  4599. valIsUndefined = value === undefined;
  4600. while (low < high) {
  4601. var mid = nativeFloor((low + high) / 2),
  4602. computed = iteratee(array[mid]),
  4603. othIsDefined = computed !== undefined,
  4604. othIsNull = computed === null,
  4605. othIsReflexive = computed === computed,
  4606. othIsSymbol = isSymbol(computed);
  4607. if (valIsNaN) {
  4608. var setLow = retHighest || othIsReflexive;
  4609. } else if (valIsUndefined) {
  4610. setLow = othIsReflexive && (retHighest || othIsDefined);
  4611. } else if (valIsNull) {
  4612. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  4613. } else if (valIsSymbol) {
  4614. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  4615. } else if (othIsNull || othIsSymbol) {
  4616. setLow = false;
  4617. } else {
  4618. setLow = retHighest ? (computed <= value) : (computed < value);
  4619. }
  4620. if (setLow) {
  4621. low = mid + 1;
  4622. } else {
  4623. high = mid;
  4624. }
  4625. }
  4626. return nativeMin(high, MAX_ARRAY_INDEX);
  4627. }
  4628. /**
  4629. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  4630. * support for iteratee shorthands.
  4631. *
  4632. * @private
  4633. * @param {Array} array The array to inspect.
  4634. * @param {Function} [iteratee] The iteratee invoked per element.
  4635. * @returns {Array} Returns the new duplicate free array.
  4636. */
  4637. function baseSortedUniq(array, iteratee) {
  4638. var index = -1,
  4639. length = array.length,
  4640. resIndex = 0,
  4641. result = [];
  4642. while (++index < length) {
  4643. var value = array[index],
  4644. computed = iteratee ? iteratee(value) : value;
  4645. if (!index || !eq(computed, seen)) {
  4646. var seen = computed;
  4647. result[resIndex++] = value === 0 ? 0 : value;
  4648. }
  4649. }
  4650. return result;
  4651. }
  4652. /**
  4653. * The base implementation of `_.toNumber` which doesn't ensure correct
  4654. * conversions of binary, hexadecimal, or octal string values.
  4655. *
  4656. * @private
  4657. * @param {*} value The value to process.
  4658. * @returns {number} Returns the number.
  4659. */
  4660. function baseToNumber(value) {
  4661. if (typeof value == 'number') {
  4662. return value;
  4663. }
  4664. if (isSymbol(value)) {
  4665. return NAN;
  4666. }
  4667. return +value;
  4668. }
  4669. /**
  4670. * The base implementation of `_.toString` which doesn't convert nullish
  4671. * values to empty strings.
  4672. *
  4673. * @private
  4674. * @param {*} value The value to process.
  4675. * @returns {string} Returns the string.
  4676. */
  4677. function baseToString(value) {
  4678. // Exit early for strings to avoid a performance hit in some environments.
  4679. if (typeof value == 'string') {
  4680. return value;
  4681. }
  4682. if (isArray(value)) {
  4683. // Recursively convert values (susceptible to call stack limits).
  4684. return arrayMap(value, baseToString) + '';
  4685. }
  4686. if (isSymbol(value)) {
  4687. return symbolToString ? symbolToString.call(value) : '';
  4688. }
  4689. var result = (value + '');
  4690. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  4691. }
  4692. /**
  4693. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  4694. *
  4695. * @private
  4696. * @param {Array} array The array to inspect.
  4697. * @param {Function} [iteratee] The iteratee invoked per element.
  4698. * @param {Function} [comparator] The comparator invoked per element.
  4699. * @returns {Array} Returns the new duplicate free array.
  4700. */
  4701. function baseUniq(array, iteratee, comparator) {
  4702. var index = -1,
  4703. includes = arrayIncludes,
  4704. length = array.length,
  4705. isCommon = true,
  4706. result = [],
  4707. seen = result;
  4708. if (comparator) {
  4709. isCommon = false;
  4710. includes = arrayIncludesWith;
  4711. }
  4712. else if (length >= LARGE_ARRAY_SIZE) {
  4713. var set = iteratee ? null : createSet(array);
  4714. if (set) {
  4715. return setToArray(set);
  4716. }
  4717. isCommon = false;
  4718. includes = cacheHas;
  4719. seen = new SetCache;
  4720. }
  4721. else {
  4722. seen = iteratee ? [] : result;
  4723. }
  4724. outer:
  4725. while (++index < length) {
  4726. var value = array[index],
  4727. computed = iteratee ? iteratee(value) : value;
  4728. value = (comparator || value !== 0) ? value : 0;
  4729. if (isCommon && computed === computed) {
  4730. var seenIndex = seen.length;
  4731. while (seenIndex--) {
  4732. if (seen[seenIndex] === computed) {
  4733. continue outer;
  4734. }
  4735. }
  4736. if (iteratee) {
  4737. seen.push(computed);
  4738. }
  4739. result.push(value);
  4740. }
  4741. else if (!includes(seen, computed, comparator)) {
  4742. if (seen !== result) {
  4743. seen.push(computed);
  4744. }
  4745. result.push(value);
  4746. }
  4747. }
  4748. return result;
  4749. }
  4750. /**
  4751. * The base implementation of `_.unset`.
  4752. *
  4753. * @private
  4754. * @param {Object} object The object to modify.
  4755. * @param {Array|string} path The property path to unset.
  4756. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  4757. */
  4758. function baseUnset(object, path) {
  4759. path = castPath(path, object);
  4760. object = parent(object, path);
  4761. return object == null || delete object[toKey(last(path))];
  4762. }
  4763. /**
  4764. * The base implementation of `_.update`.
  4765. *
  4766. * @private
  4767. * @param {Object} object The object to modify.
  4768. * @param {Array|string} path The path of the property to update.
  4769. * @param {Function} updater The function to produce the updated value.
  4770. * @param {Function} [customizer] The function to customize path creation.
  4771. * @returns {Object} Returns `object`.
  4772. */
  4773. function baseUpdate(object, path, updater, customizer) {
  4774. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  4775. }
  4776. /**
  4777. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  4778. * without support for iteratee shorthands.
  4779. *
  4780. * @private
  4781. * @param {Array} array The array to query.
  4782. * @param {Function} predicate The function invoked per iteration.
  4783. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  4784. * @param {boolean} [fromRight] Specify iterating from right to left.
  4785. * @returns {Array} Returns the slice of `array`.
  4786. */
  4787. function baseWhile(array, predicate, isDrop, fromRight) {
  4788. var length = array.length,
  4789. index = fromRight ? length : -1;
  4790. while ((fromRight ? index-- : ++index < length) &&
  4791. predicate(array[index], index, array)) {}
  4792. return isDrop
  4793. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  4794. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  4795. }
  4796. /**
  4797. * The base implementation of `wrapperValue` which returns the result of
  4798. * performing a sequence of actions on the unwrapped `value`, where each
  4799. * successive action is supplied the return value of the previous.
  4800. *
  4801. * @private
  4802. * @param {*} value The unwrapped value.
  4803. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  4804. * @returns {*} Returns the resolved value.
  4805. */
  4806. function baseWrapperValue(value, actions) {
  4807. var result = value;
  4808. if (result instanceof LazyWrapper) {
  4809. result = result.value();
  4810. }
  4811. return arrayReduce(actions, function(result, action) {
  4812. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  4813. }, result);
  4814. }
  4815. /**
  4816. * The base implementation of methods like `_.xor`, without support for
  4817. * iteratee shorthands, that accepts an array of arrays to inspect.
  4818. *
  4819. * @private
  4820. * @param {Array} arrays The arrays to inspect.
  4821. * @param {Function} [iteratee] The iteratee invoked per element.
  4822. * @param {Function} [comparator] The comparator invoked per element.
  4823. * @returns {Array} Returns the new array of values.
  4824. */
  4825. function baseXor(arrays, iteratee, comparator) {
  4826. var length = arrays.length;
  4827. if (length < 2) {
  4828. return length ? baseUniq(arrays[0]) : [];
  4829. }
  4830. var index = -1,
  4831. result = Array(length);
  4832. while (++index < length) {
  4833. var array = arrays[index],
  4834. othIndex = -1;
  4835. while (++othIndex < length) {
  4836. if (othIndex != index) {
  4837. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  4838. }
  4839. }
  4840. }
  4841. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  4842. }
  4843. /**
  4844. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  4845. *
  4846. * @private
  4847. * @param {Array} props The property identifiers.
  4848. * @param {Array} values The property values.
  4849. * @param {Function} assignFunc The function to assign values.
  4850. * @returns {Object} Returns the new object.
  4851. */
  4852. function baseZipObject(props, values, assignFunc) {
  4853. var index = -1,
  4854. length = props.length,
  4855. valsLength = values.length,
  4856. result = {};
  4857. while (++index < length) {
  4858. var value = index < valsLength ? values[index] : undefined;
  4859. assignFunc(result, props[index], value);
  4860. }
  4861. return result;
  4862. }
  4863. /**
  4864. * Casts `value` to an empty array if it's not an array like object.
  4865. *
  4866. * @private
  4867. * @param {*} value The value to inspect.
  4868. * @returns {Array|Object} Returns the cast array-like object.
  4869. */
  4870. function castArrayLikeObject(value) {
  4871. return isArrayLikeObject(value) ? value : [];
  4872. }
  4873. /**
  4874. * Casts `value` to `identity` if it's not a function.
  4875. *
  4876. * @private
  4877. * @param {*} value The value to inspect.
  4878. * @returns {Function} Returns cast function.
  4879. */
  4880. function castFunction(value) {
  4881. return typeof value == 'function' ? value : identity;
  4882. }
  4883. /**
  4884. * Casts `value` to a path array if it's not one.
  4885. *
  4886. * @private
  4887. * @param {*} value The value to inspect.
  4888. * @param {Object} [object] The object to query keys on.
  4889. * @returns {Array} Returns the cast property path array.
  4890. */
  4891. function castPath(value, object) {
  4892. if (isArray(value)) {
  4893. return value;
  4894. }
  4895. return isKey(value, object) ? [value] : stringToPath(toString(value));
  4896. }
  4897. /**
  4898. * A `baseRest` alias which can be replaced with `identity` by module
  4899. * replacement plugins.
  4900. *
  4901. * @private
  4902. * @type {Function}
  4903. * @param {Function} func The function to apply a rest parameter to.
  4904. * @returns {Function} Returns the new function.
  4905. */
  4906. var castRest = baseRest;
  4907. /**
  4908. * Casts `array` to a slice if it's needed.
  4909. *
  4910. * @private
  4911. * @param {Array} array The array to inspect.
  4912. * @param {number} start The start position.
  4913. * @param {number} [end=array.length] The end position.
  4914. * @returns {Array} Returns the cast slice.
  4915. */
  4916. function castSlice(array, start, end) {
  4917. var length = array.length;
  4918. end = end === undefined ? length : end;
  4919. return (!start && end >= length) ? array : baseSlice(array, start, end);
  4920. }
  4921. /**
  4922. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  4923. *
  4924. * @private
  4925. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  4926. */
  4927. var clearTimeout = ctxClearTimeout || function(id) {
  4928. return root.clearTimeout(id);
  4929. };
  4930. /**
  4931. * Creates a clone of `buffer`.
  4932. *
  4933. * @private
  4934. * @param {Buffer} buffer The buffer to clone.
  4935. * @param {boolean} [isDeep] Specify a deep clone.
  4936. * @returns {Buffer} Returns the cloned buffer.
  4937. */
  4938. function cloneBuffer(buffer, isDeep) {
  4939. if (isDeep) {
  4940. return buffer.slice();
  4941. }
  4942. var length = buffer.length,
  4943. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  4944. buffer.copy(result);
  4945. return result;
  4946. }
  4947. /**
  4948. * Creates a clone of `arrayBuffer`.
  4949. *
  4950. * @private
  4951. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  4952. * @returns {ArrayBuffer} Returns the cloned array buffer.
  4953. */
  4954. function cloneArrayBuffer(arrayBuffer) {
  4955. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  4956. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  4957. return result;
  4958. }
  4959. /**
  4960. * Creates a clone of `dataView`.
  4961. *
  4962. * @private
  4963. * @param {Object} dataView The data view to clone.
  4964. * @param {boolean} [isDeep] Specify a deep clone.
  4965. * @returns {Object} Returns the cloned data view.
  4966. */
  4967. function cloneDataView(dataView, isDeep) {
  4968. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  4969. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  4970. }
  4971. /**
  4972. * Creates a clone of `map`.
  4973. *
  4974. * @private
  4975. * @param {Object} map The map to clone.
  4976. * @param {Function} cloneFunc The function to clone values.
  4977. * @param {boolean} [isDeep] Specify a deep clone.
  4978. * @returns {Object} Returns the cloned map.
  4979. */
  4980. function cloneMap(map, isDeep, cloneFunc) {
  4981. var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
  4982. return arrayReduce(array, addMapEntry, new map.constructor);
  4983. }
  4984. /**
  4985. * Creates a clone of `regexp`.
  4986. *
  4987. * @private
  4988. * @param {Object} regexp The regexp to clone.
  4989. * @returns {Object} Returns the cloned regexp.
  4990. */
  4991. function cloneRegExp(regexp) {
  4992. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  4993. result.lastIndex = regexp.lastIndex;
  4994. return result;
  4995. }
  4996. /**
  4997. * Creates a clone of `set`.
  4998. *
  4999. * @private
  5000. * @param {Object} set The set to clone.
  5001. * @param {Function} cloneFunc The function to clone values.
  5002. * @param {boolean} [isDeep] Specify a deep clone.
  5003. * @returns {Object} Returns the cloned set.
  5004. */
  5005. function cloneSet(set, isDeep, cloneFunc) {
  5006. var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
  5007. return arrayReduce(array, addSetEntry, new set.constructor);
  5008. }
  5009. /**
  5010. * Creates a clone of the `symbol` object.
  5011. *
  5012. * @private
  5013. * @param {Object} symbol The symbol object to clone.
  5014. * @returns {Object} Returns the cloned symbol object.
  5015. */
  5016. function cloneSymbol(symbol) {
  5017. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  5018. }
  5019. /**
  5020. * Creates a clone of `typedArray`.
  5021. *
  5022. * @private
  5023. * @param {Object} typedArray The typed array to clone.
  5024. * @param {boolean} [isDeep] Specify a deep clone.
  5025. * @returns {Object} Returns the cloned typed array.
  5026. */
  5027. function cloneTypedArray(typedArray, isDeep) {
  5028. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  5029. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  5030. }
  5031. /**
  5032. * Compares values to sort them in ascending order.
  5033. *
  5034. * @private
  5035. * @param {*} value The value to compare.
  5036. * @param {*} other The other value to compare.
  5037. * @returns {number} Returns the sort order indicator for `value`.
  5038. */
  5039. function compareAscending(value, other) {
  5040. if (value !== other) {
  5041. var valIsDefined = value !== undefined,
  5042. valIsNull = value === null,
  5043. valIsReflexive = value === value,
  5044. valIsSymbol = isSymbol(value);
  5045. var othIsDefined = other !== undefined,
  5046. othIsNull = other === null,
  5047. othIsReflexive = other === other,
  5048. othIsSymbol = isSymbol(other);
  5049. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  5050. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  5051. (valIsNull && othIsDefined && othIsReflexive) ||
  5052. (!valIsDefined && othIsReflexive) ||
  5053. !valIsReflexive) {
  5054. return 1;
  5055. }
  5056. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  5057. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  5058. (othIsNull && valIsDefined && valIsReflexive) ||
  5059. (!othIsDefined && valIsReflexive) ||
  5060. !othIsReflexive) {
  5061. return -1;
  5062. }
  5063. }
  5064. return 0;
  5065. }
  5066. /**
  5067. * Used by `_.orderBy` to compare multiple properties of a value to another
  5068. * and stable sort them.
  5069. *
  5070. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  5071. * specify an order of "desc" for descending or "asc" for ascending sort order
  5072. * of corresponding values.
  5073. *
  5074. * @private
  5075. * @param {Object} object The object to compare.
  5076. * @param {Object} other The other object to compare.
  5077. * @param {boolean[]|string[]} orders The order to sort by for each property.
  5078. * @returns {number} Returns the sort order indicator for `object`.
  5079. */
  5080. function compareMultiple(object, other, orders) {
  5081. var index = -1,
  5082. objCriteria = object.criteria,
  5083. othCriteria = other.criteria,
  5084. length = objCriteria.length,
  5085. ordersLength = orders.length;
  5086. while (++index < length) {
  5087. var result = compareAscending(objCriteria[index], othCriteria[index]);
  5088. if (result) {
  5089. if (index >= ordersLength) {
  5090. return result;
  5091. }
  5092. var order = orders[index];
  5093. return result * (order == 'desc' ? -1 : 1);
  5094. }
  5095. }
  5096. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  5097. // that causes it, under certain circumstances, to provide the same value for
  5098. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  5099. // for more details.
  5100. //
  5101. // This also ensures a stable sort in V8 and other engines.
  5102. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  5103. return object.index - other.index;
  5104. }
  5105. /**
  5106. * Creates an array that is the composition of partially applied arguments,
  5107. * placeholders, and provided arguments into a single array of arguments.
  5108. *
  5109. * @private
  5110. * @param {Array} args The provided arguments.
  5111. * @param {Array} partials The arguments to prepend to those provided.
  5112. * @param {Array} holders The `partials` placeholder indexes.
  5113. * @params {boolean} [isCurried] Specify composing for a curried function.
  5114. * @returns {Array} Returns the new array of composed arguments.
  5115. */
  5116. function composeArgs(args, partials, holders, isCurried) {
  5117. var argsIndex = -1,
  5118. argsLength = args.length,
  5119. holdersLength = holders.length,
  5120. leftIndex = -1,
  5121. leftLength = partials.length,
  5122. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5123. result = Array(leftLength + rangeLength),
  5124. isUncurried = !isCurried;
  5125. while (++leftIndex < leftLength) {
  5126. result[leftIndex] = partials[leftIndex];
  5127. }
  5128. while (++argsIndex < holdersLength) {
  5129. if (isUncurried || argsIndex < argsLength) {
  5130. result[holders[argsIndex]] = args[argsIndex];
  5131. }
  5132. }
  5133. while (rangeLength--) {
  5134. result[leftIndex++] = args[argsIndex++];
  5135. }
  5136. return result;
  5137. }
  5138. /**
  5139. * This function is like `composeArgs` except that the arguments composition
  5140. * is tailored for `_.partialRight`.
  5141. *
  5142. * @private
  5143. * @param {Array} args The provided arguments.
  5144. * @param {Array} partials The arguments to append to those provided.
  5145. * @param {Array} holders The `partials` placeholder indexes.
  5146. * @params {boolean} [isCurried] Specify composing for a curried function.
  5147. * @returns {Array} Returns the new array of composed arguments.
  5148. */
  5149. function composeArgsRight(args, partials, holders, isCurried) {
  5150. var argsIndex = -1,
  5151. argsLength = args.length,
  5152. holdersIndex = -1,
  5153. holdersLength = holders.length,
  5154. rightIndex = -1,
  5155. rightLength = partials.length,
  5156. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5157. result = Array(rangeLength + rightLength),
  5158. isUncurried = !isCurried;
  5159. while (++argsIndex < rangeLength) {
  5160. result[argsIndex] = args[argsIndex];
  5161. }
  5162. var offset = argsIndex;
  5163. while (++rightIndex < rightLength) {
  5164. result[offset + rightIndex] = partials[rightIndex];
  5165. }
  5166. while (++holdersIndex < holdersLength) {
  5167. if (isUncurried || argsIndex < argsLength) {
  5168. result[offset + holders[holdersIndex]] = args[argsIndex++];
  5169. }
  5170. }
  5171. return result;
  5172. }
  5173. /**
  5174. * Copies the values of `source` to `array`.
  5175. *
  5176. * @private
  5177. * @param {Array} source The array to copy values from.
  5178. * @param {Array} [array=[]] The array to copy values to.
  5179. * @returns {Array} Returns `array`.
  5180. */
  5181. function copyArray(source, array) {
  5182. var index = -1,
  5183. length = source.length;
  5184. array || (array = Array(length));
  5185. while (++index < length) {
  5186. array[index] = source[index];
  5187. }
  5188. return array;
  5189. }
  5190. /**
  5191. * Copies properties of `source` to `object`.
  5192. *
  5193. * @private
  5194. * @param {Object} source The object to copy properties from.
  5195. * @param {Array} props The property identifiers to copy.
  5196. * @param {Object} [object={}] The object to copy properties to.
  5197. * @param {Function} [customizer] The function to customize copied values.
  5198. * @returns {Object} Returns `object`.
  5199. */
  5200. function copyObject(source, props, object, customizer) {
  5201. var isNew = !object;
  5202. object || (object = {});
  5203. var index = -1,
  5204. length = props.length;
  5205. while (++index < length) {
  5206. var key = props[index];
  5207. var newValue = customizer
  5208. ? customizer(object[key], source[key], key, object, source)
  5209. : undefined;
  5210. if (newValue === undefined) {
  5211. newValue = source[key];
  5212. }
  5213. if (isNew) {
  5214. baseAssignValue(object, key, newValue);
  5215. } else {
  5216. assignValue(object, key, newValue);
  5217. }
  5218. }
  5219. return object;
  5220. }
  5221. /**
  5222. * Copies own symbols of `source` to `object`.
  5223. *
  5224. * @private
  5225. * @param {Object} source The object to copy symbols from.
  5226. * @param {Object} [object={}] The object to copy symbols to.
  5227. * @returns {Object} Returns `object`.
  5228. */
  5229. function copySymbols(source, object) {
  5230. return copyObject(source, getSymbols(source), object);
  5231. }
  5232. /**
  5233. * Copies own and inherited symbols of `source` to `object`.
  5234. *
  5235. * @private
  5236. * @param {Object} source The object to copy symbols from.
  5237. * @param {Object} [object={}] The object to copy symbols to.
  5238. * @returns {Object} Returns `object`.
  5239. */
  5240. function copySymbolsIn(source, object) {
  5241. return copyObject(source, getSymbolsIn(source), object);
  5242. }
  5243. /**
  5244. * Creates a function like `_.groupBy`.
  5245. *
  5246. * @private
  5247. * @param {Function} setter The function to set accumulator values.
  5248. * @param {Function} [initializer] The accumulator object initializer.
  5249. * @returns {Function} Returns the new aggregator function.
  5250. */
  5251. function createAggregator(setter, initializer) {
  5252. return function(collection, iteratee) {
  5253. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  5254. accumulator = initializer ? initializer() : {};
  5255. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  5256. };
  5257. }
  5258. /**
  5259. * Creates a function like `_.assign`.
  5260. *
  5261. * @private
  5262. * @param {Function} assigner The function to assign values.
  5263. * @returns {Function} Returns the new assigner function.
  5264. */
  5265. function createAssigner(assigner) {
  5266. return baseRest(function(object, sources) {
  5267. var index = -1,
  5268. length = sources.length,
  5269. customizer = length > 1 ? sources[length - 1] : undefined,
  5270. guard = length > 2 ? sources[2] : undefined;
  5271. customizer = (assigner.length > 3 && typeof customizer == 'function')
  5272. ? (length--, customizer)
  5273. : undefined;
  5274. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  5275. customizer = length < 3 ? undefined : customizer;
  5276. length = 1;
  5277. }
  5278. object = Object(object);
  5279. while (++index < length) {
  5280. var source = sources[index];
  5281. if (source) {
  5282. assigner(object, source, index, customizer);
  5283. }
  5284. }
  5285. return object;
  5286. });
  5287. }
  5288. /**
  5289. * Creates a `baseEach` or `baseEachRight` function.
  5290. *
  5291. * @private
  5292. * @param {Function} eachFunc The function to iterate over a collection.
  5293. * @param {boolean} [fromRight] Specify iterating from right to left.
  5294. * @returns {Function} Returns the new base function.
  5295. */
  5296. function createBaseEach(eachFunc, fromRight) {
  5297. return function(collection, iteratee) {
  5298. if (collection == null) {
  5299. return collection;
  5300. }
  5301. if (!isArrayLike(collection)) {
  5302. return eachFunc(collection, iteratee);
  5303. }
  5304. var length = collection.length,
  5305. index = fromRight ? length : -1,
  5306. iterable = Object(collection);
  5307. while ((fromRight ? index-- : ++index < length)) {
  5308. if (iteratee(iterable[index], index, iterable) === false) {
  5309. break;
  5310. }
  5311. }
  5312. return collection;
  5313. };
  5314. }
  5315. /**
  5316. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  5317. *
  5318. * @private
  5319. * @param {boolean} [fromRight] Specify iterating from right to left.
  5320. * @returns {Function} Returns the new base function.
  5321. */
  5322. function createBaseFor(fromRight) {
  5323. return function(object, iteratee, keysFunc) {
  5324. var index = -1,
  5325. iterable = Object(object),
  5326. props = keysFunc(object),
  5327. length = props.length;
  5328. while (length--) {
  5329. var key = props[fromRight ? length : ++index];
  5330. if (iteratee(iterable[key], key, iterable) === false) {
  5331. break;
  5332. }
  5333. }
  5334. return object;
  5335. };
  5336. }
  5337. /**
  5338. * Creates a function that wraps `func` to invoke it with the optional `this`
  5339. * binding of `thisArg`.
  5340. *
  5341. * @private
  5342. * @param {Function} func The function to wrap.
  5343. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5344. * @param {*} [thisArg] The `this` binding of `func`.
  5345. * @returns {Function} Returns the new wrapped function.
  5346. */
  5347. function createBind(func, bitmask, thisArg) {
  5348. var isBind = bitmask & WRAP_BIND_FLAG,
  5349. Ctor = createCtor(func);
  5350. function wrapper() {
  5351. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5352. return fn.apply(isBind ? thisArg : this, arguments);
  5353. }
  5354. return wrapper;
  5355. }
  5356. /**
  5357. * Creates a function like `_.lowerFirst`.
  5358. *
  5359. * @private
  5360. * @param {string} methodName The name of the `String` case method to use.
  5361. * @returns {Function} Returns the new case function.
  5362. */
  5363. function createCaseFirst(methodName) {
  5364. return function(string) {
  5365. string = toString(string);
  5366. var strSymbols = hasUnicode(string)
  5367. ? stringToArray(string)
  5368. : undefined;
  5369. var chr = strSymbols
  5370. ? strSymbols[0]
  5371. : string.charAt(0);
  5372. var trailing = strSymbols
  5373. ? castSlice(strSymbols, 1).join('')
  5374. : string.slice(1);
  5375. return chr[methodName]() + trailing;
  5376. };
  5377. }
  5378. /**
  5379. * Creates a function like `_.camelCase`.
  5380. *
  5381. * @private
  5382. * @param {Function} callback The function to combine each word.
  5383. * @returns {Function} Returns the new compounder function.
  5384. */
  5385. function createCompounder(callback) {
  5386. return function(string) {
  5387. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  5388. };
  5389. }
  5390. /**
  5391. * Creates a function that produces an instance of `Ctor` regardless of
  5392. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  5393. *
  5394. * @private
  5395. * @param {Function} Ctor The constructor to wrap.
  5396. * @returns {Function} Returns the new wrapped function.
  5397. */
  5398. function createCtor(Ctor) {
  5399. return function() {
  5400. // Use a `switch` statement to work with class constructors. See
  5401. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  5402. // for more details.
  5403. var args = arguments;
  5404. switch (args.length) {
  5405. case 0: return new Ctor;
  5406. case 1: return new Ctor(args[0]);
  5407. case 2: return new Ctor(args[0], args[1]);
  5408. case 3: return new Ctor(args[0], args[1], args[2]);
  5409. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  5410. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  5411. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  5412. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  5413. }
  5414. var thisBinding = baseCreate(Ctor.prototype),
  5415. result = Ctor.apply(thisBinding, args);
  5416. // Mimic the constructor's `return` behavior.
  5417. // See https://es5.github.io/#x13.2.2 for more details.
  5418. return isObject(result) ? result : thisBinding;
  5419. };
  5420. }
  5421. /**
  5422. * Creates a function that wraps `func` to enable currying.
  5423. *
  5424. * @private
  5425. * @param {Function} func The function to wrap.
  5426. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5427. * @param {number} arity The arity of `func`.
  5428. * @returns {Function} Returns the new wrapped function.
  5429. */
  5430. function createCurry(func, bitmask, arity) {
  5431. var Ctor = createCtor(func);
  5432. function wrapper() {
  5433. var length = arguments.length,
  5434. args = Array(length),
  5435. index = length,
  5436. placeholder = getHolder(wrapper);
  5437. while (index--) {
  5438. args[index] = arguments[index];
  5439. }
  5440. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  5441. ? []
  5442. : replaceHolders(args, placeholder);
  5443. length -= holders.length;
  5444. if (length < arity) {
  5445. return createRecurry(
  5446. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  5447. args, holders, undefined, undefined, arity - length);
  5448. }
  5449. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5450. return apply(fn, this, args);
  5451. }
  5452. return wrapper;
  5453. }
  5454. /**
  5455. * Creates a `_.find` or `_.findLast` function.
  5456. *
  5457. * @private
  5458. * @param {Function} findIndexFunc The function to find the collection index.
  5459. * @returns {Function} Returns the new find function.
  5460. */
  5461. function createFind(findIndexFunc) {
  5462. return function(collection, predicate, fromIndex) {
  5463. var iterable = Object(collection);
  5464. if (!isArrayLike(collection)) {
  5465. var iteratee = getIteratee(predicate, 3);
  5466. collection = keys(collection);
  5467. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  5468. }
  5469. var index = findIndexFunc(collection, predicate, fromIndex);
  5470. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  5471. };
  5472. }
  5473. /**
  5474. * Creates a `_.flow` or `_.flowRight` function.
  5475. *
  5476. * @private
  5477. * @param {boolean} [fromRight] Specify iterating from right to left.
  5478. * @returns {Function} Returns the new flow function.
  5479. */
  5480. function createFlow(fromRight) {
  5481. return flatRest(function(funcs) {
  5482. var length = funcs.length,
  5483. index = length,
  5484. prereq = LodashWrapper.prototype.thru;
  5485. if (fromRight) {
  5486. funcs.reverse();
  5487. }
  5488. while (index--) {
  5489. var func = funcs[index];
  5490. if (typeof func != 'function') {
  5491. throw new TypeError(FUNC_ERROR_TEXT);
  5492. }
  5493. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  5494. var wrapper = new LodashWrapper([], true);
  5495. }
  5496. }
  5497. index = wrapper ? index : length;
  5498. while (++index < length) {
  5499. func = funcs[index];
  5500. var funcName = getFuncName(func),
  5501. data = funcName == 'wrapper' ? getData(func) : undefined;
  5502. if (data && isLaziable(data[0]) &&
  5503. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  5504. !data[4].length && data[9] == 1
  5505. ) {
  5506. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  5507. } else {
  5508. wrapper = (func.length == 1 && isLaziable(func))
  5509. ? wrapper[funcName]()
  5510. : wrapper.thru(func);
  5511. }
  5512. }
  5513. return function() {
  5514. var args = arguments,
  5515. value = args[0];
  5516. if (wrapper && args.length == 1 && isArray(value)) {
  5517. return wrapper.plant(value).value();
  5518. }
  5519. var index = 0,
  5520. result = length ? funcs[index].apply(this, args) : value;
  5521. while (++index < length) {
  5522. result = funcs[index].call(this, result);
  5523. }
  5524. return result;
  5525. };
  5526. });
  5527. }
  5528. /**
  5529. * Creates a function that wraps `func` to invoke it with optional `this`
  5530. * binding of `thisArg`, partial application, and currying.
  5531. *
  5532. * @private
  5533. * @param {Function|string} func The function or method name to wrap.
  5534. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5535. * @param {*} [thisArg] The `this` binding of `func`.
  5536. * @param {Array} [partials] The arguments to prepend to those provided to
  5537. * the new function.
  5538. * @param {Array} [holders] The `partials` placeholder indexes.
  5539. * @param {Array} [partialsRight] The arguments to append to those provided
  5540. * to the new function.
  5541. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  5542. * @param {Array} [argPos] The argument positions of the new function.
  5543. * @param {number} [ary] The arity cap of `func`.
  5544. * @param {number} [arity] The arity of `func`.
  5545. * @returns {Function} Returns the new wrapped function.
  5546. */
  5547. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  5548. var isAry = bitmask & WRAP_ARY_FLAG,
  5549. isBind = bitmask & WRAP_BIND_FLAG,
  5550. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  5551. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  5552. isFlip = bitmask & WRAP_FLIP_FLAG,
  5553. Ctor = isBindKey ? undefined : createCtor(func);
  5554. function wrapper() {
  5555. var length = arguments.length,
  5556. args = Array(length),
  5557. index = length;
  5558. while (index--) {
  5559. args[index] = arguments[index];
  5560. }
  5561. if (isCurried) {
  5562. var placeholder = getHolder(wrapper),
  5563. holdersCount = countHolders(args, placeholder);
  5564. }
  5565. if (partials) {
  5566. args = composeArgs(args, partials, holders, isCurried);
  5567. }
  5568. if (partialsRight) {
  5569. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  5570. }
  5571. length -= holdersCount;
  5572. if (isCurried && length < arity) {
  5573. var newHolders = replaceHolders(args, placeholder);
  5574. return createRecurry(
  5575. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  5576. args, newHolders, argPos, ary, arity - length
  5577. );
  5578. }
  5579. var thisBinding = isBind ? thisArg : this,
  5580. fn = isBindKey ? thisBinding[func] : func;
  5581. length = args.length;
  5582. if (argPos) {
  5583. args = reorder(args, argPos);
  5584. } else if (isFlip && length > 1) {
  5585. args.reverse();
  5586. }
  5587. if (isAry && ary < length) {
  5588. args.length = ary;
  5589. }
  5590. if (this && this !== root && this instanceof wrapper) {
  5591. fn = Ctor || createCtor(fn);
  5592. }
  5593. return fn.apply(thisBinding, args);
  5594. }
  5595. return wrapper;
  5596. }
  5597. /**
  5598. * Creates a function like `_.invertBy`.
  5599. *
  5600. * @private
  5601. * @param {Function} setter The function to set accumulator values.
  5602. * @param {Function} toIteratee The function to resolve iteratees.
  5603. * @returns {Function} Returns the new inverter function.
  5604. */
  5605. function createInverter(setter, toIteratee) {
  5606. return function(object, iteratee) {
  5607. return baseInverter(object, setter, toIteratee(iteratee), {});
  5608. };
  5609. }
  5610. /**
  5611. * Creates a function that performs a mathematical operation on two values.
  5612. *
  5613. * @private
  5614. * @param {Function} operator The function to perform the operation.
  5615. * @param {number} [defaultValue] The value used for `undefined` arguments.
  5616. * @returns {Function} Returns the new mathematical operation function.
  5617. */
  5618. function createMathOperation(operator, defaultValue) {
  5619. return function(value, other) {
  5620. var result;
  5621. if (value === undefined && other === undefined) {
  5622. return defaultValue;
  5623. }
  5624. if (value !== undefined) {
  5625. result = value;
  5626. }
  5627. if (other !== undefined) {
  5628. if (result === undefined) {
  5629. return other;
  5630. }
  5631. if (typeof value == 'string' || typeof other == 'string') {
  5632. value = baseToString(value);
  5633. other = baseToString(other);
  5634. } else {
  5635. value = baseToNumber(value);
  5636. other = baseToNumber(other);
  5637. }
  5638. result = operator(value, other);
  5639. }
  5640. return result;
  5641. };
  5642. }
  5643. /**
  5644. * Creates a function like `_.over`.
  5645. *
  5646. * @private
  5647. * @param {Function} arrayFunc The function to iterate over iteratees.
  5648. * @returns {Function} Returns the new over function.
  5649. */
  5650. function createOver(arrayFunc) {
  5651. return flatRest(function(iteratees) {
  5652. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  5653. return baseRest(function(args) {
  5654. var thisArg = this;
  5655. return arrayFunc(iteratees, function(iteratee) {
  5656. return apply(iteratee, thisArg, args);
  5657. });
  5658. });
  5659. });
  5660. }
  5661. /**
  5662. * Creates the padding for `string` based on `length`. The `chars` string
  5663. * is truncated if the number of characters exceeds `length`.
  5664. *
  5665. * @private
  5666. * @param {number} length The padding length.
  5667. * @param {string} [chars=' '] The string used as padding.
  5668. * @returns {string} Returns the padding for `string`.
  5669. */
  5670. function createPadding(length, chars) {
  5671. chars = chars === undefined ? ' ' : baseToString(chars);
  5672. var charsLength = chars.length;
  5673. if (charsLength < 2) {
  5674. return charsLength ? baseRepeat(chars, length) : chars;
  5675. }
  5676. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  5677. return hasUnicode(chars)
  5678. ? castSlice(stringToArray(result), 0, length).join('')
  5679. : result.slice(0, length);
  5680. }
  5681. /**
  5682. * Creates a function that wraps `func` to invoke it with the `this` binding
  5683. * of `thisArg` and `partials` prepended to the arguments it receives.
  5684. *
  5685. * @private
  5686. * @param {Function} func The function to wrap.
  5687. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5688. * @param {*} thisArg The `this` binding of `func`.
  5689. * @param {Array} partials The arguments to prepend to those provided to
  5690. * the new function.
  5691. * @returns {Function} Returns the new wrapped function.
  5692. */
  5693. function createPartial(func, bitmask, thisArg, partials) {
  5694. var isBind = bitmask & WRAP_BIND_FLAG,
  5695. Ctor = createCtor(func);
  5696. function wrapper() {
  5697. var argsIndex = -1,
  5698. argsLength = arguments.length,
  5699. leftIndex = -1,
  5700. leftLength = partials.length,
  5701. args = Array(leftLength + argsLength),
  5702. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5703. while (++leftIndex < leftLength) {
  5704. args[leftIndex] = partials[leftIndex];
  5705. }
  5706. while (argsLength--) {
  5707. args[leftIndex++] = arguments[++argsIndex];
  5708. }
  5709. return apply(fn, isBind ? thisArg : this, args);
  5710. }
  5711. return wrapper;
  5712. }
  5713. /**
  5714. * Creates a `_.range` or `_.rangeRight` function.
  5715. *
  5716. * @private
  5717. * @param {boolean} [fromRight] Specify iterating from right to left.
  5718. * @returns {Function} Returns the new range function.
  5719. */
  5720. function createRange(fromRight) {
  5721. return function(start, end, step) {
  5722. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  5723. end = step = undefined;
  5724. }
  5725. // Ensure the sign of `-0` is preserved.
  5726. start = toFinite(start);
  5727. if (end === undefined) {
  5728. end = start;
  5729. start = 0;
  5730. } else {
  5731. end = toFinite(end);
  5732. }
  5733. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  5734. return baseRange(start, end, step, fromRight);
  5735. };
  5736. }
  5737. /**
  5738. * Creates a function that performs a relational operation on two values.
  5739. *
  5740. * @private
  5741. * @param {Function} operator The function to perform the operation.
  5742. * @returns {Function} Returns the new relational operation function.
  5743. */
  5744. function createRelationalOperation(operator) {
  5745. return function(value, other) {
  5746. if (!(typeof value == 'string' && typeof other == 'string')) {
  5747. value = toNumber(value);
  5748. other = toNumber(other);
  5749. }
  5750. return operator(value, other);
  5751. };
  5752. }
  5753. /**
  5754. * Creates a function that wraps `func` to continue currying.
  5755. *
  5756. * @private
  5757. * @param {Function} func The function to wrap.
  5758. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5759. * @param {Function} wrapFunc The function to create the `func` wrapper.
  5760. * @param {*} placeholder The placeholder value.
  5761. * @param {*} [thisArg] The `this` binding of `func`.
  5762. * @param {Array} [partials] The arguments to prepend to those provided to
  5763. * the new function.
  5764. * @param {Array} [holders] The `partials` placeholder indexes.
  5765. * @param {Array} [argPos] The argument positions of the new function.
  5766. * @param {number} [ary] The arity cap of `func`.
  5767. * @param {number} [arity] The arity of `func`.
  5768. * @returns {Function} Returns the new wrapped function.
  5769. */
  5770. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  5771. var isCurry = bitmask & WRAP_CURRY_FLAG,
  5772. newHolders = isCurry ? holders : undefined,
  5773. newHoldersRight = isCurry ? undefined : holders,
  5774. newPartials = isCurry ? partials : undefined,
  5775. newPartialsRight = isCurry ? undefined : partials;
  5776. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  5777. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  5778. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  5779. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  5780. }
  5781. var newData = [
  5782. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  5783. newHoldersRight, argPos, ary, arity
  5784. ];
  5785. var result = wrapFunc.apply(undefined, newData);
  5786. if (isLaziable(func)) {
  5787. setData(result, newData);
  5788. }
  5789. result.placeholder = placeholder;
  5790. return setWrapToString(result, func, bitmask);
  5791. }
  5792. /**
  5793. * Creates a function like `_.round`.
  5794. *
  5795. * @private
  5796. * @param {string} methodName The name of the `Math` method to use when rounding.
  5797. * @returns {Function} Returns the new round function.
  5798. */
  5799. function createRound(methodName) {
  5800. var func = Math[methodName];
  5801. return function(number, precision) {
  5802. number = toNumber(number);
  5803. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  5804. if (precision) {
  5805. // Shift with exponential notation to avoid floating-point issues.
  5806. // See [MDN](https://mdn.io/round#Examples) for more details.
  5807. var pair = (toString(number) + 'e').split('e'),
  5808. value = func(pair[0] + 'e' + (+pair[1] + precision));
  5809. pair = (toString(value) + 'e').split('e');
  5810. return +(pair[0] + 'e' + (+pair[1] - precision));
  5811. }
  5812. return func(number);
  5813. };
  5814. }
  5815. /**
  5816. * Creates a set object of `values`.
  5817. *
  5818. * @private
  5819. * @param {Array} values The values to add to the set.
  5820. * @returns {Object} Returns the new set.
  5821. */
  5822. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  5823. return new Set(values);
  5824. };
  5825. /**
  5826. * Creates a `_.toPairs` or `_.toPairsIn` function.
  5827. *
  5828. * @private
  5829. * @param {Function} keysFunc The function to get the keys of a given object.
  5830. * @returns {Function} Returns the new pairs function.
  5831. */
  5832. function createToPairs(keysFunc) {
  5833. return function(object) {
  5834. var tag = getTag(object);
  5835. if (tag == mapTag) {
  5836. return mapToArray(object);
  5837. }
  5838. if (tag == setTag) {
  5839. return setToPairs(object);
  5840. }
  5841. return baseToPairs(object, keysFunc(object));
  5842. };
  5843. }
  5844. /**
  5845. * Creates a function that either curries or invokes `func` with optional
  5846. * `this` binding and partially applied arguments.
  5847. *
  5848. * @private
  5849. * @param {Function|string} func The function or method name to wrap.
  5850. * @param {number} bitmask The bitmask flags.
  5851. * 1 - `_.bind`
  5852. * 2 - `_.bindKey`
  5853. * 4 - `_.curry` or `_.curryRight` of a bound function
  5854. * 8 - `_.curry`
  5855. * 16 - `_.curryRight`
  5856. * 32 - `_.partial`
  5857. * 64 - `_.partialRight`
  5858. * 128 - `_.rearg`
  5859. * 256 - `_.ary`
  5860. * 512 - `_.flip`
  5861. * @param {*} [thisArg] The `this` binding of `func`.
  5862. * @param {Array} [partials] The arguments to be partially applied.
  5863. * @param {Array} [holders] The `partials` placeholder indexes.
  5864. * @param {Array} [argPos] The argument positions of the new function.
  5865. * @param {number} [ary] The arity cap of `func`.
  5866. * @param {number} [arity] The arity of `func`.
  5867. * @returns {Function} Returns the new wrapped function.
  5868. */
  5869. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  5870. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  5871. if (!isBindKey && typeof func != 'function') {
  5872. throw new TypeError(FUNC_ERROR_TEXT);
  5873. }
  5874. var length = partials ? partials.length : 0;
  5875. if (!length) {
  5876. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  5877. partials = holders = undefined;
  5878. }
  5879. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  5880. arity = arity === undefined ? arity : toInteger(arity);
  5881. length -= holders ? holders.length : 0;
  5882. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  5883. var partialsRight = partials,
  5884. holdersRight = holders;
  5885. partials = holders = undefined;
  5886. }
  5887. var data = isBindKey ? undefined : getData(func);
  5888. var newData = [
  5889. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  5890. argPos, ary, arity
  5891. ];
  5892. if (data) {
  5893. mergeData(newData, data);
  5894. }
  5895. func = newData[0];
  5896. bitmask = newData[1];
  5897. thisArg = newData[2];
  5898. partials = newData[3];
  5899. holders = newData[4];
  5900. arity = newData[9] = newData[9] === undefined
  5901. ? (isBindKey ? 0 : func.length)
  5902. : nativeMax(newData[9] - length, 0);
  5903. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  5904. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  5905. }
  5906. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  5907. var result = createBind(func, bitmask, thisArg);
  5908. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  5909. result = createCurry(func, bitmask, arity);
  5910. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  5911. result = createPartial(func, bitmask, thisArg, partials);
  5912. } else {
  5913. result = createHybrid.apply(undefined, newData);
  5914. }
  5915. var setter = data ? baseSetData : setData;
  5916. return setWrapToString(setter(result, newData), func, bitmask);
  5917. }
  5918. /**
  5919. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  5920. * of source objects to the destination object for all destination properties
  5921. * that resolve to `undefined`.
  5922. *
  5923. * @private
  5924. * @param {*} objValue The destination value.
  5925. * @param {*} srcValue The source value.
  5926. * @param {string} key The key of the property to assign.
  5927. * @param {Object} object The parent object of `objValue`.
  5928. * @returns {*} Returns the value to assign.
  5929. */
  5930. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  5931. if (objValue === undefined ||
  5932. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  5933. return srcValue;
  5934. }
  5935. return objValue;
  5936. }
  5937. /**
  5938. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  5939. * objects into destination objects that are passed thru.
  5940. *
  5941. * @private
  5942. * @param {*} objValue The destination value.
  5943. * @param {*} srcValue The source value.
  5944. * @param {string} key The key of the property to merge.
  5945. * @param {Object} object The parent object of `objValue`.
  5946. * @param {Object} source The parent object of `srcValue`.
  5947. * @param {Object} [stack] Tracks traversed source values and their merged
  5948. * counterparts.
  5949. * @returns {*} Returns the value to assign.
  5950. */
  5951. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  5952. if (isObject(objValue) && isObject(srcValue)) {
  5953. // Recursively merge objects and arrays (susceptible to call stack limits).
  5954. stack.set(srcValue, objValue);
  5955. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  5956. stack['delete'](srcValue);
  5957. }
  5958. return objValue;
  5959. }
  5960. /**
  5961. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  5962. * objects.
  5963. *
  5964. * @private
  5965. * @param {*} value The value to inspect.
  5966. * @param {string} key The key of the property to inspect.
  5967. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  5968. */
  5969. function customOmitClone(value) {
  5970. return isPlainObject(value) ? undefined : value;
  5971. }
  5972. /**
  5973. * A specialized version of `baseIsEqualDeep` for arrays with support for
  5974. * partial deep comparisons.
  5975. *
  5976. * @private
  5977. * @param {Array} array The array to compare.
  5978. * @param {Array} other The other array to compare.
  5979. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  5980. * @param {Function} customizer The function to customize comparisons.
  5981. * @param {Function} equalFunc The function to determine equivalents of values.
  5982. * @param {Object} stack Tracks traversed `array` and `other` objects.
  5983. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  5984. */
  5985. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  5986. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  5987. arrLength = array.length,
  5988. othLength = other.length;
  5989. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  5990. return false;
  5991. }
  5992. // Assume cyclic values are equal.
  5993. var stacked = stack.get(array);
  5994. if (stacked && stack.get(other)) {
  5995. return stacked == other;
  5996. }
  5997. var index = -1,
  5998. result = true,
  5999. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  6000. stack.set(array, other);
  6001. stack.set(other, array);
  6002. // Ignore non-index properties.
  6003. while (++index < arrLength) {
  6004. var arrValue = array[index],
  6005. othValue = other[index];
  6006. if (customizer) {
  6007. var compared = isPartial
  6008. ? customizer(othValue, arrValue, index, other, array, stack)
  6009. : customizer(arrValue, othValue, index, array, other, stack);
  6010. }
  6011. if (compared !== undefined) {
  6012. if (compared) {
  6013. continue;
  6014. }
  6015. result = false;
  6016. break;
  6017. }
  6018. // Recursively compare arrays (susceptible to call stack limits).
  6019. if (seen) {
  6020. if (!arraySome(other, function(othValue, othIndex) {
  6021. if (!cacheHas(seen, othIndex) &&
  6022. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  6023. return seen.push(othIndex);
  6024. }
  6025. })) {
  6026. result = false;
  6027. break;
  6028. }
  6029. } else if (!(
  6030. arrValue === othValue ||
  6031. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  6032. )) {
  6033. result = false;
  6034. break;
  6035. }
  6036. }
  6037. stack['delete'](array);
  6038. stack['delete'](other);
  6039. return result;
  6040. }
  6041. /**
  6042. * A specialized version of `baseIsEqualDeep` for comparing objects of
  6043. * the same `toStringTag`.
  6044. *
  6045. * **Note:** This function only supports comparing values with tags of
  6046. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6047. *
  6048. * @private
  6049. * @param {Object} object The object to compare.
  6050. * @param {Object} other The other object to compare.
  6051. * @param {string} tag The `toStringTag` of the objects to compare.
  6052. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6053. * @param {Function} customizer The function to customize comparisons.
  6054. * @param {Function} equalFunc The function to determine equivalents of values.
  6055. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6056. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6057. */
  6058. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  6059. switch (tag) {
  6060. case dataViewTag:
  6061. if ((object.byteLength != other.byteLength) ||
  6062. (object.byteOffset != other.byteOffset)) {
  6063. return false;
  6064. }
  6065. object = object.buffer;
  6066. other = other.buffer;
  6067. case arrayBufferTag:
  6068. if ((object.byteLength != other.byteLength) ||
  6069. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  6070. return false;
  6071. }
  6072. return true;
  6073. case boolTag:
  6074. case dateTag:
  6075. case numberTag:
  6076. // Coerce booleans to `1` or `0` and dates to milliseconds.
  6077. // Invalid dates are coerced to `NaN`.
  6078. return eq(+object, +other);
  6079. case errorTag:
  6080. return object.name == other.name && object.message == other.message;
  6081. case regexpTag:
  6082. case stringTag:
  6083. // Coerce regexes to strings and treat strings, primitives and objects,
  6084. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  6085. // for more details.
  6086. return object == (other + '');
  6087. case mapTag:
  6088. var convert = mapToArray;
  6089. case setTag:
  6090. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  6091. convert || (convert = setToArray);
  6092. if (object.size != other.size && !isPartial) {
  6093. return false;
  6094. }
  6095. // Assume cyclic values are equal.
  6096. var stacked = stack.get(object);
  6097. if (stacked) {
  6098. return stacked == other;
  6099. }
  6100. bitmask |= COMPARE_UNORDERED_FLAG;
  6101. // Recursively compare objects (susceptible to call stack limits).
  6102. stack.set(object, other);
  6103. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  6104. stack['delete'](object);
  6105. return result;
  6106. case symbolTag:
  6107. if (symbolValueOf) {
  6108. return symbolValueOf.call(object) == symbolValueOf.call(other);
  6109. }
  6110. }
  6111. return false;
  6112. }
  6113. /**
  6114. * A specialized version of `baseIsEqualDeep` for objects with support for
  6115. * partial deep comparisons.
  6116. *
  6117. * @private
  6118. * @param {Object} object The object to compare.
  6119. * @param {Object} other The other object to compare.
  6120. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6121. * @param {Function} customizer The function to customize comparisons.
  6122. * @param {Function} equalFunc The function to determine equivalents of values.
  6123. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6124. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6125. */
  6126. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  6127. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6128. objProps = getAllKeys(object),
  6129. objLength = objProps.length,
  6130. othProps = getAllKeys(other),
  6131. othLength = othProps.length;
  6132. if (objLength != othLength && !isPartial) {
  6133. return false;
  6134. }
  6135. var index = objLength;
  6136. while (index--) {
  6137. var key = objProps[index];
  6138. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  6139. return false;
  6140. }
  6141. }
  6142. // Assume cyclic values are equal.
  6143. var stacked = stack.get(object);
  6144. if (stacked && stack.get(other)) {
  6145. return stacked == other;
  6146. }
  6147. var result = true;
  6148. stack.set(object, other);
  6149. stack.set(other, object);
  6150. var skipCtor = isPartial;
  6151. while (++index < objLength) {
  6152. key = objProps[index];
  6153. var objValue = object[key],
  6154. othValue = other[key];
  6155. if (customizer) {
  6156. var compared = isPartial
  6157. ? customizer(othValue, objValue, key, other, object, stack)
  6158. : customizer(objValue, othValue, key, object, other, stack);
  6159. }
  6160. // Recursively compare objects (susceptible to call stack limits).
  6161. if (!(compared === undefined
  6162. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  6163. : compared
  6164. )) {
  6165. result = false;
  6166. break;
  6167. }
  6168. skipCtor || (skipCtor = key == 'constructor');
  6169. }
  6170. if (result && !skipCtor) {
  6171. var objCtor = object.constructor,
  6172. othCtor = other.constructor;
  6173. // Non `Object` object instances with different constructors are not equal.
  6174. if (objCtor != othCtor &&
  6175. ('constructor' in object && 'constructor' in other) &&
  6176. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  6177. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  6178. result = false;
  6179. }
  6180. }
  6181. stack['delete'](object);
  6182. stack['delete'](other);
  6183. return result;
  6184. }
  6185. /**
  6186. * A specialized version of `baseRest` which flattens the rest array.
  6187. *
  6188. * @private
  6189. * @param {Function} func The function to apply a rest parameter to.
  6190. * @returns {Function} Returns the new function.
  6191. */
  6192. function flatRest(func) {
  6193. return setToString(overRest(func, undefined, flatten), func + '');
  6194. }
  6195. /**
  6196. * Creates an array of own enumerable property names and symbols of `object`.
  6197. *
  6198. * @private
  6199. * @param {Object} object The object to query.
  6200. * @returns {Array} Returns the array of property names and symbols.
  6201. */
  6202. function getAllKeys(object) {
  6203. return baseGetAllKeys(object, keys, getSymbols);
  6204. }
  6205. /**
  6206. * Creates an array of own and inherited enumerable property names and
  6207. * symbols of `object`.
  6208. *
  6209. * @private
  6210. * @param {Object} object The object to query.
  6211. * @returns {Array} Returns the array of property names and symbols.
  6212. */
  6213. function getAllKeysIn(object) {
  6214. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  6215. }
  6216. /**
  6217. * Gets metadata for `func`.
  6218. *
  6219. * @private
  6220. * @param {Function} func The function to query.
  6221. * @returns {*} Returns the metadata for `func`.
  6222. */
  6223. var getData = !metaMap ? noop : function(func) {
  6224. return metaMap.get(func);
  6225. };
  6226. /**
  6227. * Gets the name of `func`.
  6228. *
  6229. * @private
  6230. * @param {Function} func The function to query.
  6231. * @returns {string} Returns the function name.
  6232. */
  6233. function getFuncName(func) {
  6234. var result = (func.name + ''),
  6235. array = realNames[result],
  6236. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  6237. while (length--) {
  6238. var data = array[length],
  6239. otherFunc = data.func;
  6240. if (otherFunc == null || otherFunc == func) {
  6241. return data.name;
  6242. }
  6243. }
  6244. return result;
  6245. }
  6246. /**
  6247. * Gets the argument placeholder value for `func`.
  6248. *
  6249. * @private
  6250. * @param {Function} func The function to inspect.
  6251. * @returns {*} Returns the placeholder value.
  6252. */
  6253. function getHolder(func) {
  6254. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  6255. return object.placeholder;
  6256. }
  6257. /**
  6258. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  6259. * this function returns the custom method, otherwise it returns `baseIteratee`.
  6260. * If arguments are provided, the chosen function is invoked with them and
  6261. * its result is returned.
  6262. *
  6263. * @private
  6264. * @param {*} [value] The value to convert to an iteratee.
  6265. * @param {number} [arity] The arity of the created iteratee.
  6266. * @returns {Function} Returns the chosen function or its result.
  6267. */
  6268. function getIteratee() {
  6269. var result = lodash.iteratee || iteratee;
  6270. result = result === iteratee ? baseIteratee : result;
  6271. return arguments.length ? result(arguments[0], arguments[1]) : result;
  6272. }
  6273. /**
  6274. * Gets the data for `map`.
  6275. *
  6276. * @private
  6277. * @param {Object} map The map to query.
  6278. * @param {string} key The reference key.
  6279. * @returns {*} Returns the map data.
  6280. */
  6281. function getMapData(map, key) {
  6282. var data = map.__data__;
  6283. return isKeyable(key)
  6284. ? data[typeof key == 'string' ? 'string' : 'hash']
  6285. : data.map;
  6286. }
  6287. /**
  6288. * Gets the property names, values, and compare flags of `object`.
  6289. *
  6290. * @private
  6291. * @param {Object} object The object to query.
  6292. * @returns {Array} Returns the match data of `object`.
  6293. */
  6294. function getMatchData(object) {
  6295. var result = keys(object),
  6296. length = result.length;
  6297. while (length--) {
  6298. var key = result[length],
  6299. value = object[key];
  6300. result[length] = [key, value, isStrictComparable(value)];
  6301. }
  6302. return result;
  6303. }
  6304. /**
  6305. * Gets the native function at `key` of `object`.
  6306. *
  6307. * @private
  6308. * @param {Object} object The object to query.
  6309. * @param {string} key The key of the method to get.
  6310. * @returns {*} Returns the function if it's native, else `undefined`.
  6311. */
  6312. function getNative(object, key) {
  6313. var value = getValue(object, key);
  6314. return baseIsNative(value) ? value : undefined;
  6315. }
  6316. /**
  6317. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  6318. *
  6319. * @private
  6320. * @param {*} value The value to query.
  6321. * @returns {string} Returns the raw `toStringTag`.
  6322. */
  6323. function getRawTag(value) {
  6324. var isOwn = hasOwnProperty.call(value, symToStringTag),
  6325. tag = value[symToStringTag];
  6326. try {
  6327. value[symToStringTag] = undefined;
  6328. var unmasked = true;
  6329. } catch (e) {}
  6330. var result = nativeObjectToString.call(value);
  6331. if (unmasked) {
  6332. if (isOwn) {
  6333. value[symToStringTag] = tag;
  6334. } else {
  6335. delete value[symToStringTag];
  6336. }
  6337. }
  6338. return result;
  6339. }
  6340. /**
  6341. * Creates an array of the own enumerable symbols of `object`.
  6342. *
  6343. * @private
  6344. * @param {Object} object The object to query.
  6345. * @returns {Array} Returns the array of symbols.
  6346. */
  6347. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  6348. if (object == null) {
  6349. return [];
  6350. }
  6351. object = Object(object);
  6352. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  6353. return propertyIsEnumerable.call(object, symbol);
  6354. });
  6355. };
  6356. /**
  6357. * Creates an array of the own and inherited enumerable symbols of `object`.
  6358. *
  6359. * @private
  6360. * @param {Object} object The object to query.
  6361. * @returns {Array} Returns the array of symbols.
  6362. */
  6363. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  6364. var result = [];
  6365. while (object) {
  6366. arrayPush(result, getSymbols(object));
  6367. object = getPrototype(object);
  6368. }
  6369. return result;
  6370. };
  6371. /**
  6372. * Gets the `toStringTag` of `value`.
  6373. *
  6374. * @private
  6375. * @param {*} value The value to query.
  6376. * @returns {string} Returns the `toStringTag`.
  6377. */
  6378. var getTag = baseGetTag;
  6379. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  6380. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  6381. (Map && getTag(new Map) != mapTag) ||
  6382. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  6383. (Set && getTag(new Set) != setTag) ||
  6384. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  6385. getTag = function(value) {
  6386. var result = baseGetTag(value),
  6387. Ctor = result == objectTag ? value.constructor : undefined,
  6388. ctorString = Ctor ? toSource(Ctor) : '';
  6389. if (ctorString) {
  6390. switch (ctorString) {
  6391. case dataViewCtorString: return dataViewTag;
  6392. case mapCtorString: return mapTag;
  6393. case promiseCtorString: return promiseTag;
  6394. case setCtorString: return setTag;
  6395. case weakMapCtorString: return weakMapTag;
  6396. }
  6397. }
  6398. return result;
  6399. };
  6400. }
  6401. /**
  6402. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  6403. *
  6404. * @private
  6405. * @param {number} start The start of the view.
  6406. * @param {number} end The end of the view.
  6407. * @param {Array} transforms The transformations to apply to the view.
  6408. * @returns {Object} Returns an object containing the `start` and `end`
  6409. * positions of the view.
  6410. */
  6411. function getView(start, end, transforms) {
  6412. var index = -1,
  6413. length = transforms.length;
  6414. while (++index < length) {
  6415. var data = transforms[index],
  6416. size = data.size;
  6417. switch (data.type) {
  6418. case 'drop': start += size; break;
  6419. case 'dropRight': end -= size; break;
  6420. case 'take': end = nativeMin(end, start + size); break;
  6421. case 'takeRight': start = nativeMax(start, end - size); break;
  6422. }
  6423. }
  6424. return { 'start': start, 'end': end };
  6425. }
  6426. /**
  6427. * Extracts wrapper details from the `source` body comment.
  6428. *
  6429. * @private
  6430. * @param {string} source The source to inspect.
  6431. * @returns {Array} Returns the wrapper details.
  6432. */
  6433. function getWrapDetails(source) {
  6434. var match = source.match(reWrapDetails);
  6435. return match ? match[1].split(reSplitDetails) : [];
  6436. }
  6437. /**
  6438. * Checks if `path` exists on `object`.
  6439. *
  6440. * @private
  6441. * @param {Object} object The object to query.
  6442. * @param {Array|string} path The path to check.
  6443. * @param {Function} hasFunc The function to check properties.
  6444. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  6445. */
  6446. function hasPath(object, path, hasFunc) {
  6447. path = castPath(path, object);
  6448. var index = -1,
  6449. length = path.length,
  6450. result = false;
  6451. while (++index < length) {
  6452. var key = toKey(path[index]);
  6453. if (!(result = object != null && hasFunc(object, key))) {
  6454. break;
  6455. }
  6456. object = object[key];
  6457. }
  6458. if (result || ++index != length) {
  6459. return result;
  6460. }
  6461. length = object == null ? 0 : object.length;
  6462. return !!length && isLength(length) && isIndex(key, length) &&
  6463. (isArray(object) || isArguments(object));
  6464. }
  6465. /**
  6466. * Initializes an array clone.
  6467. *
  6468. * @private
  6469. * @param {Array} array The array to clone.
  6470. * @returns {Array} Returns the initialized clone.
  6471. */
  6472. function initCloneArray(array) {
  6473. var length = array.length,
  6474. result = array.constructor(length);
  6475. // Add properties assigned by `RegExp#exec`.
  6476. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  6477. result.index = array.index;
  6478. result.input = array.input;
  6479. }
  6480. return result;
  6481. }
  6482. /**
  6483. * Initializes an object clone.
  6484. *
  6485. * @private
  6486. * @param {Object} object The object to clone.
  6487. * @returns {Object} Returns the initialized clone.
  6488. */
  6489. function initCloneObject(object) {
  6490. return (typeof object.constructor == 'function' && !isPrototype(object))
  6491. ? baseCreate(getPrototype(object))
  6492. : {};
  6493. }
  6494. /**
  6495. * Initializes an object clone based on its `toStringTag`.
  6496. *
  6497. * **Note:** This function only supports cloning values with tags of
  6498. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6499. *
  6500. * @private
  6501. * @param {Object} object The object to clone.
  6502. * @param {string} tag The `toStringTag` of the object to clone.
  6503. * @param {Function} cloneFunc The function to clone values.
  6504. * @param {boolean} [isDeep] Specify a deep clone.
  6505. * @returns {Object} Returns the initialized clone.
  6506. */
  6507. function initCloneByTag(object, tag, cloneFunc, isDeep) {
  6508. var Ctor = object.constructor;
  6509. switch (tag) {
  6510. case arrayBufferTag:
  6511. return cloneArrayBuffer(object);
  6512. case boolTag:
  6513. case dateTag:
  6514. return new Ctor(+object);
  6515. case dataViewTag:
  6516. return cloneDataView(object, isDeep);
  6517. case float32Tag: case float64Tag:
  6518. case int8Tag: case int16Tag: case int32Tag:
  6519. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  6520. return cloneTypedArray(object, isDeep);
  6521. case mapTag:
  6522. return cloneMap(object, isDeep, cloneFunc);
  6523. case numberTag:
  6524. case stringTag:
  6525. return new Ctor(object);
  6526. case regexpTag:
  6527. return cloneRegExp(object);
  6528. case setTag:
  6529. return cloneSet(object, isDeep, cloneFunc);
  6530. case symbolTag:
  6531. return cloneSymbol(object);
  6532. }
  6533. }
  6534. /**
  6535. * Inserts wrapper `details` in a comment at the top of the `source` body.
  6536. *
  6537. * @private
  6538. * @param {string} source The source to modify.
  6539. * @returns {Array} details The details to insert.
  6540. * @returns {string} Returns the modified source.
  6541. */
  6542. function insertWrapDetails(source, details) {
  6543. var length = details.length;
  6544. if (!length) {
  6545. return source;
  6546. }
  6547. var lastIndex = length - 1;
  6548. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  6549. details = details.join(length > 2 ? ', ' : ' ');
  6550. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  6551. }
  6552. /**
  6553. * Checks if `value` is a flattenable `arguments` object or array.
  6554. *
  6555. * @private
  6556. * @param {*} value The value to check.
  6557. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  6558. */
  6559. function isFlattenable(value) {
  6560. return isArray(value) || isArguments(value) ||
  6561. !!(spreadableSymbol && value && value[spreadableSymbol]);
  6562. }
  6563. /**
  6564. * Checks if `value` is a valid array-like index.
  6565. *
  6566. * @private
  6567. * @param {*} value The value to check.
  6568. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  6569. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  6570. */
  6571. function isIndex(value, length) {
  6572. length = length == null ? MAX_SAFE_INTEGER : length;
  6573. return !!length &&
  6574. (typeof value == 'number' || reIsUint.test(value)) &&
  6575. (value > -1 && value % 1 == 0 && value < length);
  6576. }
  6577. /**
  6578. * Checks if the given arguments are from an iteratee call.
  6579. *
  6580. * @private
  6581. * @param {*} value The potential iteratee value argument.
  6582. * @param {*} index The potential iteratee index or key argument.
  6583. * @param {*} object The potential iteratee object argument.
  6584. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  6585. * else `false`.
  6586. */
  6587. function isIterateeCall(value, index, object) {
  6588. if (!isObject(object)) {
  6589. return false;
  6590. }
  6591. var type = typeof index;
  6592. if (type == 'number'
  6593. ? (isArrayLike(object) && isIndex(index, object.length))
  6594. : (type == 'string' && index in object)
  6595. ) {
  6596. return eq(object[index], value);
  6597. }
  6598. return false;
  6599. }
  6600. /**
  6601. * Checks if `value` is a property name and not a property path.
  6602. *
  6603. * @private
  6604. * @param {*} value The value to check.
  6605. * @param {Object} [object] The object to query keys on.
  6606. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  6607. */
  6608. function isKey(value, object) {
  6609. if (isArray(value)) {
  6610. return false;
  6611. }
  6612. var type = typeof value;
  6613. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  6614. value == null || isSymbol(value)) {
  6615. return true;
  6616. }
  6617. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  6618. (object != null && value in Object(object));
  6619. }
  6620. /**
  6621. * Checks if `value` is suitable for use as unique object key.
  6622. *
  6623. * @private
  6624. * @param {*} value The value to check.
  6625. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  6626. */
  6627. function isKeyable(value) {
  6628. var type = typeof value;
  6629. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  6630. ? (value !== '__proto__')
  6631. : (value === null);
  6632. }
  6633. /**
  6634. * Checks if `func` has a lazy counterpart.
  6635. *
  6636. * @private
  6637. * @param {Function} func The function to check.
  6638. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  6639. * else `false`.
  6640. */
  6641. function isLaziable(func) {
  6642. var funcName = getFuncName(func),
  6643. other = lodash[funcName];
  6644. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  6645. return false;
  6646. }
  6647. if (func === other) {
  6648. return true;
  6649. }
  6650. var data = getData(other);
  6651. return !!data && func === data[0];
  6652. }
  6653. /**
  6654. * Checks if `func` has its source masked.
  6655. *
  6656. * @private
  6657. * @param {Function} func The function to check.
  6658. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  6659. */
  6660. function isMasked(func) {
  6661. return !!maskSrcKey && (maskSrcKey in func);
  6662. }
  6663. /**
  6664. * Checks if `func` is capable of being masked.
  6665. *
  6666. * @private
  6667. * @param {*} value The value to check.
  6668. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  6669. */
  6670. var isMaskable = coreJsData ? isFunction : stubFalse;
  6671. /**
  6672. * Checks if `value` is likely a prototype object.
  6673. *
  6674. * @private
  6675. * @param {*} value The value to check.
  6676. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  6677. */
  6678. function isPrototype(value) {
  6679. var Ctor = value && value.constructor,
  6680. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  6681. return value === proto;
  6682. }
  6683. /**
  6684. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  6685. *
  6686. * @private
  6687. * @param {*} value The value to check.
  6688. * @returns {boolean} Returns `true` if `value` if suitable for strict
  6689. * equality comparisons, else `false`.
  6690. */
  6691. function isStrictComparable(value) {
  6692. return value === value && !isObject(value);
  6693. }
  6694. /**
  6695. * A specialized version of `matchesProperty` for source values suitable
  6696. * for strict equality comparisons, i.e. `===`.
  6697. *
  6698. * @private
  6699. * @param {string} key The key of the property to get.
  6700. * @param {*} srcValue The value to match.
  6701. * @returns {Function} Returns the new spec function.
  6702. */
  6703. function matchesStrictComparable(key, srcValue) {
  6704. return function(object) {
  6705. if (object == null) {
  6706. return false;
  6707. }
  6708. return object[key] === srcValue &&
  6709. (srcValue !== undefined || (key in Object(object)));
  6710. };
  6711. }
  6712. /**
  6713. * A specialized version of `_.memoize` which clears the memoized function's
  6714. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  6715. *
  6716. * @private
  6717. * @param {Function} func The function to have its output memoized.
  6718. * @returns {Function} Returns the new memoized function.
  6719. */
  6720. function memoizeCapped(func) {
  6721. var result = memoize(func, function(key) {
  6722. if (cache.size === MAX_MEMOIZE_SIZE) {
  6723. cache.clear();
  6724. }
  6725. return key;
  6726. });
  6727. var cache = result.cache;
  6728. return result;
  6729. }
  6730. /**
  6731. * Merges the function metadata of `source` into `data`.
  6732. *
  6733. * Merging metadata reduces the number of wrappers used to invoke a function.
  6734. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  6735. * may be applied regardless of execution order. Methods like `_.ary` and
  6736. * `_.rearg` modify function arguments, making the order in which they are
  6737. * executed important, preventing the merging of metadata. However, we make
  6738. * an exception for a safe combined case where curried functions have `_.ary`
  6739. * and or `_.rearg` applied.
  6740. *
  6741. * @private
  6742. * @param {Array} data The destination metadata.
  6743. * @param {Array} source The source metadata.
  6744. * @returns {Array} Returns `data`.
  6745. */
  6746. function mergeData(data, source) {
  6747. var bitmask = data[1],
  6748. srcBitmask = source[1],
  6749. newBitmask = bitmask | srcBitmask,
  6750. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  6751. var isCombo =
  6752. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  6753. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  6754. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  6755. // Exit early if metadata can't be merged.
  6756. if (!(isCommon || isCombo)) {
  6757. return data;
  6758. }
  6759. // Use source `thisArg` if available.
  6760. if (srcBitmask & WRAP_BIND_FLAG) {
  6761. data[2] = source[2];
  6762. // Set when currying a bound function.
  6763. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  6764. }
  6765. // Compose partial arguments.
  6766. var value = source[3];
  6767. if (value) {
  6768. var partials = data[3];
  6769. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  6770. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  6771. }
  6772. // Compose partial right arguments.
  6773. value = source[5];
  6774. if (value) {
  6775. partials = data[5];
  6776. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  6777. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  6778. }
  6779. // Use source `argPos` if available.
  6780. value = source[7];
  6781. if (value) {
  6782. data[7] = value;
  6783. }
  6784. // Use source `ary` if it's smaller.
  6785. if (srcBitmask & WRAP_ARY_FLAG) {
  6786. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  6787. }
  6788. // Use source `arity` if one is not provided.
  6789. if (data[9] == null) {
  6790. data[9] = source[9];
  6791. }
  6792. // Use source `func` and merge bitmasks.
  6793. data[0] = source[0];
  6794. data[1] = newBitmask;
  6795. return data;
  6796. }
  6797. /**
  6798. * This function is like
  6799. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  6800. * except that it includes inherited enumerable properties.
  6801. *
  6802. * @private
  6803. * @param {Object} object The object to query.
  6804. * @returns {Array} Returns the array of property names.
  6805. */
  6806. function nativeKeysIn(object) {
  6807. var result = [];
  6808. if (object != null) {
  6809. for (var key in Object(object)) {
  6810. result.push(key);
  6811. }
  6812. }
  6813. return result;
  6814. }
  6815. /**
  6816. * Converts `value` to a string using `Object.prototype.toString`.
  6817. *
  6818. * @private
  6819. * @param {*} value The value to convert.
  6820. * @returns {string} Returns the converted string.
  6821. */
  6822. function objectToString(value) {
  6823. return nativeObjectToString.call(value);
  6824. }
  6825. /**
  6826. * A specialized version of `baseRest` which transforms the rest array.
  6827. *
  6828. * @private
  6829. * @param {Function} func The function to apply a rest parameter to.
  6830. * @param {number} [start=func.length-1] The start position of the rest parameter.
  6831. * @param {Function} transform The rest array transform.
  6832. * @returns {Function} Returns the new function.
  6833. */
  6834. function overRest(func, start, transform) {
  6835. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  6836. return function() {
  6837. var args = arguments,
  6838. index = -1,
  6839. length = nativeMax(args.length - start, 0),
  6840. array = Array(length);
  6841. while (++index < length) {
  6842. array[index] = args[start + index];
  6843. }
  6844. index = -1;
  6845. var otherArgs = Array(start + 1);
  6846. while (++index < start) {
  6847. otherArgs[index] = args[index];
  6848. }
  6849. otherArgs[start] = transform(array);
  6850. return apply(func, this, otherArgs);
  6851. };
  6852. }
  6853. /**
  6854. * Gets the parent value at `path` of `object`.
  6855. *
  6856. * @private
  6857. * @param {Object} object The object to query.
  6858. * @param {Array} path The path to get the parent value of.
  6859. * @returns {*} Returns the parent value.
  6860. */
  6861. function parent(object, path) {
  6862. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  6863. }
  6864. /**
  6865. * Reorder `array` according to the specified indexes where the element at
  6866. * the first index is assigned as the first element, the element at
  6867. * the second index is assigned as the second element, and so on.
  6868. *
  6869. * @private
  6870. * @param {Array} array The array to reorder.
  6871. * @param {Array} indexes The arranged array indexes.
  6872. * @returns {Array} Returns `array`.
  6873. */
  6874. function reorder(array, indexes) {
  6875. var arrLength = array.length,
  6876. length = nativeMin(indexes.length, arrLength),
  6877. oldArray = copyArray(array);
  6878. while (length--) {
  6879. var index = indexes[length];
  6880. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  6881. }
  6882. return array;
  6883. }
  6884. /**
  6885. * Sets metadata for `func`.
  6886. *
  6887. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  6888. * period of time, it will trip its breaker and transition to an identity
  6889. * function to avoid garbage collection pauses in V8. See
  6890. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  6891. * for more details.
  6892. *
  6893. * @private
  6894. * @param {Function} func The function to associate metadata with.
  6895. * @param {*} data The metadata.
  6896. * @returns {Function} Returns `func`.
  6897. */
  6898. var setData = shortOut(baseSetData);
  6899. /**
  6900. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  6901. *
  6902. * @private
  6903. * @param {Function} func The function to delay.
  6904. * @param {number} wait The number of milliseconds to delay invocation.
  6905. * @returns {number|Object} Returns the timer id or timeout object.
  6906. */
  6907. var setTimeout = ctxSetTimeout || function(func, wait) {
  6908. return root.setTimeout(func, wait);
  6909. };
  6910. /**
  6911. * Sets the `toString` method of `func` to return `string`.
  6912. *
  6913. * @private
  6914. * @param {Function} func The function to modify.
  6915. * @param {Function} string The `toString` result.
  6916. * @returns {Function} Returns `func`.
  6917. */
  6918. var setToString = shortOut(baseSetToString);
  6919. /**
  6920. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  6921. * with wrapper details in a comment at the top of the source body.
  6922. *
  6923. * @private
  6924. * @param {Function} wrapper The function to modify.
  6925. * @param {Function} reference The reference function.
  6926. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6927. * @returns {Function} Returns `wrapper`.
  6928. */
  6929. function setWrapToString(wrapper, reference, bitmask) {
  6930. var source = (reference + '');
  6931. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  6932. }
  6933. /**
  6934. * Creates a function that'll short out and invoke `identity` instead
  6935. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  6936. * milliseconds.
  6937. *
  6938. * @private
  6939. * @param {Function} func The function to restrict.
  6940. * @returns {Function} Returns the new shortable function.
  6941. */
  6942. function shortOut(func) {
  6943. var count = 0,
  6944. lastCalled = 0;
  6945. return function() {
  6946. var stamp = nativeNow(),
  6947. remaining = HOT_SPAN - (stamp - lastCalled);
  6948. lastCalled = stamp;
  6949. if (remaining > 0) {
  6950. if (++count >= HOT_COUNT) {
  6951. return arguments[0];
  6952. }
  6953. } else {
  6954. count = 0;
  6955. }
  6956. return func.apply(undefined, arguments);
  6957. };
  6958. }
  6959. /**
  6960. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  6961. *
  6962. * @private
  6963. * @param {Array} array The array to shuffle.
  6964. * @param {number} [size=array.length] The size of `array`.
  6965. * @returns {Array} Returns `array`.
  6966. */
  6967. function shuffleSelf(array, size) {
  6968. var index = -1,
  6969. length = array.length,
  6970. lastIndex = length - 1;
  6971. size = size === undefined ? length : size;
  6972. while (++index < size) {
  6973. var rand = baseRandom(index, lastIndex),
  6974. value = array[rand];
  6975. array[rand] = array[index];
  6976. array[index] = value;
  6977. }
  6978. array.length = size;
  6979. return array;
  6980. }
  6981. /**
  6982. * Converts `string` to a property path array.
  6983. *
  6984. * @private
  6985. * @param {string} string The string to convert.
  6986. * @returns {Array} Returns the property path array.
  6987. */
  6988. var stringToPath = memoizeCapped(function(string) {
  6989. var result = [];
  6990. if (reLeadingDot.test(string)) {
  6991. result.push('');
  6992. }
  6993. string.replace(rePropName, function(match, number, quote, string) {
  6994. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  6995. });
  6996. return result;
  6997. });
  6998. /**
  6999. * Converts `value` to a string key if it's not a string or symbol.
  7000. *
  7001. * @private
  7002. * @param {*} value The value to inspect.
  7003. * @returns {string|symbol} Returns the key.
  7004. */
  7005. function toKey(value) {
  7006. if (typeof value == 'string' || isSymbol(value)) {
  7007. return value;
  7008. }
  7009. var result = (value + '');
  7010. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  7011. }
  7012. /**
  7013. * Converts `func` to its source code.
  7014. *
  7015. * @private
  7016. * @param {Function} func The function to convert.
  7017. * @returns {string} Returns the source code.
  7018. */
  7019. function toSource(func) {
  7020. if (func != null) {
  7021. try {
  7022. return funcToString.call(func);
  7023. } catch (e) {}
  7024. try {
  7025. return (func + '');
  7026. } catch (e) {}
  7027. }
  7028. return '';
  7029. }
  7030. /**
  7031. * Updates wrapper `details` based on `bitmask` flags.
  7032. *
  7033. * @private
  7034. * @returns {Array} details The details to modify.
  7035. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7036. * @returns {Array} Returns `details`.
  7037. */
  7038. function updateWrapDetails(details, bitmask) {
  7039. arrayEach(wrapFlags, function(pair) {
  7040. var value = '_.' + pair[0];
  7041. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  7042. details.push(value);
  7043. }
  7044. });
  7045. return details.sort();
  7046. }
  7047. /**
  7048. * Creates a clone of `wrapper`.
  7049. *
  7050. * @private
  7051. * @param {Object} wrapper The wrapper to clone.
  7052. * @returns {Object} Returns the cloned wrapper.
  7053. */
  7054. function wrapperClone(wrapper) {
  7055. if (wrapper instanceof LazyWrapper) {
  7056. return wrapper.clone();
  7057. }
  7058. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  7059. result.__actions__ = copyArray(wrapper.__actions__);
  7060. result.__index__ = wrapper.__index__;
  7061. result.__values__ = wrapper.__values__;
  7062. return result;
  7063. }
  7064. /*------------------------------------------------------------------------*/
  7065. /**
  7066. * Creates an array of elements split into groups the length of `size`.
  7067. * If `array` can't be split evenly, the final chunk will be the remaining
  7068. * elements.
  7069. *
  7070. * @static
  7071. * @memberOf _
  7072. * @since 3.0.0
  7073. * @category Array
  7074. * @param {Array} array The array to process.
  7075. * @param {number} [size=1] The length of each chunk
  7076. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7077. * @returns {Array} Returns the new array of chunks.
  7078. * @example
  7079. *
  7080. * _.chunk(['a', 'b', 'c', 'd'], 2);
  7081. * // => [['a', 'b'], ['c', 'd']]
  7082. *
  7083. * _.chunk(['a', 'b', 'c', 'd'], 3);
  7084. * // => [['a', 'b', 'c'], ['d']]
  7085. */
  7086. function chunk(array, size, guard) {
  7087. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  7088. size = 1;
  7089. } else {
  7090. size = nativeMax(toInteger(size), 0);
  7091. }
  7092. var length = array == null ? 0 : array.length;
  7093. if (!length || size < 1) {
  7094. return [];
  7095. }
  7096. var index = 0,
  7097. resIndex = 0,
  7098. result = Array(nativeCeil(length / size));
  7099. while (index < length) {
  7100. result[resIndex++] = baseSlice(array, index, (index += size));
  7101. }
  7102. return result;
  7103. }
  7104. /**
  7105. * Creates an array with all falsey values removed. The values `false`, `null`,
  7106. * `0`, `""`, `undefined`, and `NaN` are falsey.
  7107. *
  7108. * @static
  7109. * @memberOf _
  7110. * @since 0.1.0
  7111. * @category Array
  7112. * @param {Array} array The array to compact.
  7113. * @returns {Array} Returns the new array of filtered values.
  7114. * @example
  7115. *
  7116. * _.compact([0, 1, false, 2, '', 3]);
  7117. * // => [1, 2, 3]
  7118. */
  7119. function compact(array) {
  7120. var index = -1,
  7121. length = array == null ? 0 : array.length,
  7122. resIndex = 0,
  7123. result = [];
  7124. while (++index < length) {
  7125. var value = array[index];
  7126. if (value) {
  7127. result[resIndex++] = value;
  7128. }
  7129. }
  7130. return result;
  7131. }
  7132. /**
  7133. * Creates a new array concatenating `array` with any additional arrays
  7134. * and/or values.
  7135. *
  7136. * @static
  7137. * @memberOf _
  7138. * @since 4.0.0
  7139. * @category Array
  7140. * @param {Array} array The array to concatenate.
  7141. * @param {...*} [values] The values to concatenate.
  7142. * @returns {Array} Returns the new concatenated array.
  7143. * @example
  7144. *
  7145. * var array = [1];
  7146. * var other = _.concat(array, 2, [3], [[4]]);
  7147. *
  7148. * console.log(other);
  7149. * // => [1, 2, 3, [4]]
  7150. *
  7151. * console.log(array);
  7152. * // => [1]
  7153. */
  7154. function concat() {
  7155. var length = arguments.length;
  7156. if (!length) {
  7157. return [];
  7158. }
  7159. var args = Array(length - 1),
  7160. array = arguments[0],
  7161. index = length;
  7162. while (index--) {
  7163. args[index - 1] = arguments[index];
  7164. }
  7165. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  7166. }
  7167. /**
  7168. * Creates an array of `array` values not included in the other given arrays
  7169. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7170. * for equality comparisons. The order and references of result values are
  7171. * determined by the first array.
  7172. *
  7173. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  7174. *
  7175. * @static
  7176. * @memberOf _
  7177. * @since 0.1.0
  7178. * @category Array
  7179. * @param {Array} array The array to inspect.
  7180. * @param {...Array} [values] The values to exclude.
  7181. * @returns {Array} Returns the new array of filtered values.
  7182. * @see _.without, _.xor
  7183. * @example
  7184. *
  7185. * _.difference([2, 1], [2, 3]);
  7186. * // => [1]
  7187. */
  7188. var difference = baseRest(function(array, values) {
  7189. return isArrayLikeObject(array)
  7190. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  7191. : [];
  7192. });
  7193. /**
  7194. * This method is like `_.difference` except that it accepts `iteratee` which
  7195. * is invoked for each element of `array` and `values` to generate the criterion
  7196. * by which they're compared. The order and references of result values are
  7197. * determined by the first array. The iteratee is invoked with one argument:
  7198. * (value).
  7199. *
  7200. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  7201. *
  7202. * @static
  7203. * @memberOf _
  7204. * @since 4.0.0
  7205. * @category Array
  7206. * @param {Array} array The array to inspect.
  7207. * @param {...Array} [values] The values to exclude.
  7208. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7209. * @returns {Array} Returns the new array of filtered values.
  7210. * @example
  7211. *
  7212. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  7213. * // => [1.2]
  7214. *
  7215. * // The `_.property` iteratee shorthand.
  7216. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  7217. * // => [{ 'x': 2 }]
  7218. */
  7219. var differenceBy = baseRest(function(array, values) {
  7220. var iteratee = last(values);
  7221. if (isArrayLikeObject(iteratee)) {
  7222. iteratee = undefined;
  7223. }
  7224. return isArrayLikeObject(array)
  7225. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  7226. : [];
  7227. });
  7228. /**
  7229. * This method is like `_.difference` except that it accepts `comparator`
  7230. * which is invoked to compare elements of `array` to `values`. The order and
  7231. * references of result values are determined by the first array. The comparator
  7232. * is invoked with two arguments: (arrVal, othVal).
  7233. *
  7234. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  7235. *
  7236. * @static
  7237. * @memberOf _
  7238. * @since 4.0.0
  7239. * @category Array
  7240. * @param {Array} array The array to inspect.
  7241. * @param {...Array} [values] The values to exclude.
  7242. * @param {Function} [comparator] The comparator invoked per element.
  7243. * @returns {Array} Returns the new array of filtered values.
  7244. * @example
  7245. *
  7246. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  7247. *
  7248. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  7249. * // => [{ 'x': 2, 'y': 1 }]
  7250. */
  7251. var differenceWith = baseRest(function(array, values) {
  7252. var comparator = last(values);
  7253. if (isArrayLikeObject(comparator)) {
  7254. comparator = undefined;
  7255. }
  7256. return isArrayLikeObject(array)
  7257. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  7258. : [];
  7259. });
  7260. /**
  7261. * Creates a slice of `array` with `n` elements dropped from the beginning.
  7262. *
  7263. * @static
  7264. * @memberOf _
  7265. * @since 0.5.0
  7266. * @category Array
  7267. * @param {Array} array The array to query.
  7268. * @param {number} [n=1] The number of elements to drop.
  7269. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7270. * @returns {Array} Returns the slice of `array`.
  7271. * @example
  7272. *
  7273. * _.drop([1, 2, 3]);
  7274. * // => [2, 3]
  7275. *
  7276. * _.drop([1, 2, 3], 2);
  7277. * // => [3]
  7278. *
  7279. * _.drop([1, 2, 3], 5);
  7280. * // => []
  7281. *
  7282. * _.drop([1, 2, 3], 0);
  7283. * // => [1, 2, 3]
  7284. */
  7285. function drop(array, n, guard) {
  7286. var length = array == null ? 0 : array.length;
  7287. if (!length) {
  7288. return [];
  7289. }
  7290. n = (guard || n === undefined) ? 1 : toInteger(n);
  7291. return baseSlice(array, n < 0 ? 0 : n, length);
  7292. }
  7293. /**
  7294. * Creates a slice of `array` with `n` elements dropped from the end.
  7295. *
  7296. * @static
  7297. * @memberOf _
  7298. * @since 3.0.0
  7299. * @category Array
  7300. * @param {Array} array The array to query.
  7301. * @param {number} [n=1] The number of elements to drop.
  7302. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7303. * @returns {Array} Returns the slice of `array`.
  7304. * @example
  7305. *
  7306. * _.dropRight([1, 2, 3]);
  7307. * // => [1, 2]
  7308. *
  7309. * _.dropRight([1, 2, 3], 2);
  7310. * // => [1]
  7311. *
  7312. * _.dropRight([1, 2, 3], 5);
  7313. * // => []
  7314. *
  7315. * _.dropRight([1, 2, 3], 0);
  7316. * // => [1, 2, 3]
  7317. */
  7318. function dropRight(array, n, guard) {
  7319. var length = array == null ? 0 : array.length;
  7320. if (!length) {
  7321. return [];
  7322. }
  7323. n = (guard || n === undefined) ? 1 : toInteger(n);
  7324. n = length - n;
  7325. return baseSlice(array, 0, n < 0 ? 0 : n);
  7326. }
  7327. /**
  7328. * Creates a slice of `array` excluding elements dropped from the end.
  7329. * Elements are dropped until `predicate` returns falsey. The predicate is
  7330. * invoked with three arguments: (value, index, array).
  7331. *
  7332. * @static
  7333. * @memberOf _
  7334. * @since 3.0.0
  7335. * @category Array
  7336. * @param {Array} array The array to query.
  7337. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7338. * @returns {Array} Returns the slice of `array`.
  7339. * @example
  7340. *
  7341. * var users = [
  7342. * { 'user': 'barney', 'active': true },
  7343. * { 'user': 'fred', 'active': false },
  7344. * { 'user': 'pebbles', 'active': false }
  7345. * ];
  7346. *
  7347. * _.dropRightWhile(users, function(o) { return !o.active; });
  7348. * // => objects for ['barney']
  7349. *
  7350. * // The `_.matches` iteratee shorthand.
  7351. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  7352. * // => objects for ['barney', 'fred']
  7353. *
  7354. * // The `_.matchesProperty` iteratee shorthand.
  7355. * _.dropRightWhile(users, ['active', false]);
  7356. * // => objects for ['barney']
  7357. *
  7358. * // The `_.property` iteratee shorthand.
  7359. * _.dropRightWhile(users, 'active');
  7360. * // => objects for ['barney', 'fred', 'pebbles']
  7361. */
  7362. function dropRightWhile(array, predicate) {
  7363. return (array && array.length)
  7364. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  7365. : [];
  7366. }
  7367. /**
  7368. * Creates a slice of `array` excluding elements dropped from the beginning.
  7369. * Elements are dropped until `predicate` returns falsey. The predicate is
  7370. * invoked with three arguments: (value, index, array).
  7371. *
  7372. * @static
  7373. * @memberOf _
  7374. * @since 3.0.0
  7375. * @category Array
  7376. * @param {Array} array The array to query.
  7377. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7378. * @returns {Array} Returns the slice of `array`.
  7379. * @example
  7380. *
  7381. * var users = [
  7382. * { 'user': 'barney', 'active': false },
  7383. * { 'user': 'fred', 'active': false },
  7384. * { 'user': 'pebbles', 'active': true }
  7385. * ];
  7386. *
  7387. * _.dropWhile(users, function(o) { return !o.active; });
  7388. * // => objects for ['pebbles']
  7389. *
  7390. * // The `_.matches` iteratee shorthand.
  7391. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  7392. * // => objects for ['fred', 'pebbles']
  7393. *
  7394. * // The `_.matchesProperty` iteratee shorthand.
  7395. * _.dropWhile(users, ['active', false]);
  7396. * // => objects for ['pebbles']
  7397. *
  7398. * // The `_.property` iteratee shorthand.
  7399. * _.dropWhile(users, 'active');
  7400. * // => objects for ['barney', 'fred', 'pebbles']
  7401. */
  7402. function dropWhile(array, predicate) {
  7403. return (array && array.length)
  7404. ? baseWhile(array, getIteratee(predicate, 3), true)
  7405. : [];
  7406. }
  7407. /**
  7408. * Fills elements of `array` with `value` from `start` up to, but not
  7409. * including, `end`.
  7410. *
  7411. * **Note:** This method mutates `array`.
  7412. *
  7413. * @static
  7414. * @memberOf _
  7415. * @since 3.2.0
  7416. * @category Array
  7417. * @param {Array} array The array to fill.
  7418. * @param {*} value The value to fill `array` with.
  7419. * @param {number} [start=0] The start position.
  7420. * @param {number} [end=array.length] The end position.
  7421. * @returns {Array} Returns `array`.
  7422. * @example
  7423. *
  7424. * var array = [1, 2, 3];
  7425. *
  7426. * _.fill(array, 'a');
  7427. * console.log(array);
  7428. * // => ['a', 'a', 'a']
  7429. *
  7430. * _.fill(Array(3), 2);
  7431. * // => [2, 2, 2]
  7432. *
  7433. * _.fill([4, 6, 8, 10], '*', 1, 3);
  7434. * // => [4, '*', '*', 10]
  7435. */
  7436. function fill(array, value, start, end) {
  7437. var length = array == null ? 0 : array.length;
  7438. if (!length) {
  7439. return [];
  7440. }
  7441. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  7442. start = 0;
  7443. end = length;
  7444. }
  7445. return baseFill(array, value, start, end);
  7446. }
  7447. /**
  7448. * This method is like `_.find` except that it returns the index of the first
  7449. * element `predicate` returns truthy for instead of the element itself.
  7450. *
  7451. * @static
  7452. * @memberOf _
  7453. * @since 1.1.0
  7454. * @category Array
  7455. * @param {Array} array The array to inspect.
  7456. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7457. * @param {number} [fromIndex=0] The index to search from.
  7458. * @returns {number} Returns the index of the found element, else `-1`.
  7459. * @example
  7460. *
  7461. * var users = [
  7462. * { 'user': 'barney', 'active': false },
  7463. * { 'user': 'fred', 'active': false },
  7464. * { 'user': 'pebbles', 'active': true }
  7465. * ];
  7466. *
  7467. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  7468. * // => 0
  7469. *
  7470. * // The `_.matches` iteratee shorthand.
  7471. * _.findIndex(users, { 'user': 'fred', 'active': false });
  7472. * // => 1
  7473. *
  7474. * // The `_.matchesProperty` iteratee shorthand.
  7475. * _.findIndex(users, ['active', false]);
  7476. * // => 0
  7477. *
  7478. * // The `_.property` iteratee shorthand.
  7479. * _.findIndex(users, 'active');
  7480. * // => 2
  7481. */
  7482. function findIndex(array, predicate, fromIndex) {
  7483. var length = array == null ? 0 : array.length;
  7484. if (!length) {
  7485. return -1;
  7486. }
  7487. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  7488. if (index < 0) {
  7489. index = nativeMax(length + index, 0);
  7490. }
  7491. return baseFindIndex(array, getIteratee(predicate, 3), index);
  7492. }
  7493. /**
  7494. * This method is like `_.findIndex` except that it iterates over elements
  7495. * of `collection` from right to left.
  7496. *
  7497. * @static
  7498. * @memberOf _
  7499. * @since 2.0.0
  7500. * @category Array
  7501. * @param {Array} array The array to inspect.
  7502. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7503. * @param {number} [fromIndex=array.length-1] The index to search from.
  7504. * @returns {number} Returns the index of the found element, else `-1`.
  7505. * @example
  7506. *
  7507. * var users = [
  7508. * { 'user': 'barney', 'active': true },
  7509. * { 'user': 'fred', 'active': false },
  7510. * { 'user': 'pebbles', 'active': false }
  7511. * ];
  7512. *
  7513. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  7514. * // => 2
  7515. *
  7516. * // The `_.matches` iteratee shorthand.
  7517. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  7518. * // => 0
  7519. *
  7520. * // The `_.matchesProperty` iteratee shorthand.
  7521. * _.findLastIndex(users, ['active', false]);
  7522. * // => 2
  7523. *
  7524. * // The `_.property` iteratee shorthand.
  7525. * _.findLastIndex(users, 'active');
  7526. * // => 0
  7527. */
  7528. function findLastIndex(array, predicate, fromIndex) {
  7529. var length = array == null ? 0 : array.length;
  7530. if (!length) {
  7531. return -1;
  7532. }
  7533. var index = length - 1;
  7534. if (fromIndex !== undefined) {
  7535. index = toInteger(fromIndex);
  7536. index = fromIndex < 0
  7537. ? nativeMax(length + index, 0)
  7538. : nativeMin(index, length - 1);
  7539. }
  7540. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  7541. }
  7542. /**
  7543. * Flattens `array` a single level deep.
  7544. *
  7545. * @static
  7546. * @memberOf _
  7547. * @since 0.1.0
  7548. * @category Array
  7549. * @param {Array} array The array to flatten.
  7550. * @returns {Array} Returns the new flattened array.
  7551. * @example
  7552. *
  7553. * _.flatten([1, [2, [3, [4]], 5]]);
  7554. * // => [1, 2, [3, [4]], 5]
  7555. */
  7556. function flatten(array) {
  7557. var length = array == null ? 0 : array.length;
  7558. return length ? baseFlatten(array, 1) : [];
  7559. }
  7560. /**
  7561. * Recursively flattens `array`.
  7562. *
  7563. * @static
  7564. * @memberOf _
  7565. * @since 3.0.0
  7566. * @category Array
  7567. * @param {Array} array The array to flatten.
  7568. * @returns {Array} Returns the new flattened array.
  7569. * @example
  7570. *
  7571. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  7572. * // => [1, 2, 3, 4, 5]
  7573. */
  7574. function flattenDeep(array) {
  7575. var length = array == null ? 0 : array.length;
  7576. return length ? baseFlatten(array, INFINITY) : [];
  7577. }
  7578. /**
  7579. * Recursively flatten `array` up to `depth` times.
  7580. *
  7581. * @static
  7582. * @memberOf _
  7583. * @since 4.4.0
  7584. * @category Array
  7585. * @param {Array} array The array to flatten.
  7586. * @param {number} [depth=1] The maximum recursion depth.
  7587. * @returns {Array} Returns the new flattened array.
  7588. * @example
  7589. *
  7590. * var array = [1, [2, [3, [4]], 5]];
  7591. *
  7592. * _.flattenDepth(array, 1);
  7593. * // => [1, 2, [3, [4]], 5]
  7594. *
  7595. * _.flattenDepth(array, 2);
  7596. * // => [1, 2, 3, [4], 5]
  7597. */
  7598. function flattenDepth(array, depth) {
  7599. var length = array == null ? 0 : array.length;
  7600. if (!length) {
  7601. return [];
  7602. }
  7603. depth = depth === undefined ? 1 : toInteger(depth);
  7604. return baseFlatten(array, depth);
  7605. }
  7606. /**
  7607. * The inverse of `_.toPairs`; this method returns an object composed
  7608. * from key-value `pairs`.
  7609. *
  7610. * @static
  7611. * @memberOf _
  7612. * @since 4.0.0
  7613. * @category Array
  7614. * @param {Array} pairs The key-value pairs.
  7615. * @returns {Object} Returns the new object.
  7616. * @example
  7617. *
  7618. * _.fromPairs([['a', 1], ['b', 2]]);
  7619. * // => { 'a': 1, 'b': 2 }
  7620. */
  7621. function fromPairs(pairs) {
  7622. var index = -1,
  7623. length = pairs == null ? 0 : pairs.length,
  7624. result = {};
  7625. while (++index < length) {
  7626. var pair = pairs[index];
  7627. result[pair[0]] = pair[1];
  7628. }
  7629. return result;
  7630. }
  7631. /**
  7632. * Gets the first element of `array`.
  7633. *
  7634. * @static
  7635. * @memberOf _
  7636. * @since 0.1.0
  7637. * @alias first
  7638. * @category Array
  7639. * @param {Array} array The array to query.
  7640. * @returns {*} Returns the first element of `array`.
  7641. * @example
  7642. *
  7643. * _.head([1, 2, 3]);
  7644. * // => 1
  7645. *
  7646. * _.head([]);
  7647. * // => undefined
  7648. */
  7649. function head(array) {
  7650. return (array && array.length) ? array[0] : undefined;
  7651. }
  7652. /**
  7653. * Gets the index at which the first occurrence of `value` is found in `array`
  7654. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7655. * for equality comparisons. If `fromIndex` is negative, it's used as the
  7656. * offset from the end of `array`.
  7657. *
  7658. * @static
  7659. * @memberOf _
  7660. * @since 0.1.0
  7661. * @category Array
  7662. * @param {Array} array The array to inspect.
  7663. * @param {*} value The value to search for.
  7664. * @param {number} [fromIndex=0] The index to search from.
  7665. * @returns {number} Returns the index of the matched value, else `-1`.
  7666. * @example
  7667. *
  7668. * _.indexOf([1, 2, 1, 2], 2);
  7669. * // => 1
  7670. *
  7671. * // Search from the `fromIndex`.
  7672. * _.indexOf([1, 2, 1, 2], 2, 2);
  7673. * // => 3
  7674. */
  7675. function indexOf(array, value, fromIndex) {
  7676. var length = array == null ? 0 : array.length;
  7677. if (!length) {
  7678. return -1;
  7679. }
  7680. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  7681. if (index < 0) {
  7682. index = nativeMax(length + index, 0);
  7683. }
  7684. return baseIndexOf(array, value, index);
  7685. }
  7686. /**
  7687. * Gets all but the last element of `array`.
  7688. *
  7689. * @static
  7690. * @memberOf _
  7691. * @since 0.1.0
  7692. * @category Array
  7693. * @param {Array} array The array to query.
  7694. * @returns {Array} Returns the slice of `array`.
  7695. * @example
  7696. *
  7697. * _.initial([1, 2, 3]);
  7698. * // => [1, 2]
  7699. */
  7700. function initial(array) {
  7701. var length = array == null ? 0 : array.length;
  7702. return length ? baseSlice(array, 0, -1) : [];
  7703. }
  7704. /**
  7705. * Creates an array of unique values that are included in all given arrays
  7706. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7707. * for equality comparisons. The order and references of result values are
  7708. * determined by the first array.
  7709. *
  7710. * @static
  7711. * @memberOf _
  7712. * @since 0.1.0
  7713. * @category Array
  7714. * @param {...Array} [arrays] The arrays to inspect.
  7715. * @returns {Array} Returns the new array of intersecting values.
  7716. * @example
  7717. *
  7718. * _.intersection([2, 1], [2, 3]);
  7719. * // => [2]
  7720. */
  7721. var intersection = baseRest(function(arrays) {
  7722. var mapped = arrayMap(arrays, castArrayLikeObject);
  7723. return (mapped.length && mapped[0] === arrays[0])
  7724. ? baseIntersection(mapped)
  7725. : [];
  7726. });
  7727. /**
  7728. * This method is like `_.intersection` except that it accepts `iteratee`
  7729. * which is invoked for each element of each `arrays` to generate the criterion
  7730. * by which they're compared. The order and references of result values are
  7731. * determined by the first array. The iteratee is invoked with one argument:
  7732. * (value).
  7733. *
  7734. * @static
  7735. * @memberOf _
  7736. * @since 4.0.0
  7737. * @category Array
  7738. * @param {...Array} [arrays] The arrays to inspect.
  7739. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7740. * @returns {Array} Returns the new array of intersecting values.
  7741. * @example
  7742. *
  7743. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  7744. * // => [2.1]
  7745. *
  7746. * // The `_.property` iteratee shorthand.
  7747. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  7748. * // => [{ 'x': 1 }]
  7749. */
  7750. var intersectionBy = baseRest(function(arrays) {
  7751. var iteratee = last(arrays),
  7752. mapped = arrayMap(arrays, castArrayLikeObject);
  7753. if (iteratee === last(mapped)) {
  7754. iteratee = undefined;
  7755. } else {
  7756. mapped.pop();
  7757. }
  7758. return (mapped.length && mapped[0] === arrays[0])
  7759. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  7760. : [];
  7761. });
  7762. /**
  7763. * This method is like `_.intersection` except that it accepts `comparator`
  7764. * which is invoked to compare elements of `arrays`. The order and references
  7765. * of result values are determined by the first array. The comparator is
  7766. * invoked with two arguments: (arrVal, othVal).
  7767. *
  7768. * @static
  7769. * @memberOf _
  7770. * @since 4.0.0
  7771. * @category Array
  7772. * @param {...Array} [arrays] The arrays to inspect.
  7773. * @param {Function} [comparator] The comparator invoked per element.
  7774. * @returns {Array} Returns the new array of intersecting values.
  7775. * @example
  7776. *
  7777. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  7778. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  7779. *
  7780. * _.intersectionWith(objects, others, _.isEqual);
  7781. * // => [{ 'x': 1, 'y': 2 }]
  7782. */
  7783. var intersectionWith = baseRest(function(arrays) {
  7784. var comparator = last(arrays),
  7785. mapped = arrayMap(arrays, castArrayLikeObject);
  7786. comparator = typeof comparator == 'function' ? comparator : undefined;
  7787. if (comparator) {
  7788. mapped.pop();
  7789. }
  7790. return (mapped.length && mapped[0] === arrays[0])
  7791. ? baseIntersection(mapped, undefined, comparator)
  7792. : [];
  7793. });
  7794. /**
  7795. * Converts all elements in `array` into a string separated by `separator`.
  7796. *
  7797. * @static
  7798. * @memberOf _
  7799. * @since 4.0.0
  7800. * @category Array
  7801. * @param {Array} array The array to convert.
  7802. * @param {string} [separator=','] The element separator.
  7803. * @returns {string} Returns the joined string.
  7804. * @example
  7805. *
  7806. * _.join(['a', 'b', 'c'], '~');
  7807. * // => 'a~b~c'
  7808. */
  7809. function join(array, separator) {
  7810. return array == null ? '' : nativeJoin.call(array, separator);
  7811. }
  7812. /**
  7813. * Gets the last element of `array`.
  7814. *
  7815. * @static
  7816. * @memberOf _
  7817. * @since 0.1.0
  7818. * @category Array
  7819. * @param {Array} array The array to query.
  7820. * @returns {*} Returns the last element of `array`.
  7821. * @example
  7822. *
  7823. * _.last([1, 2, 3]);
  7824. * // => 3
  7825. */
  7826. function last(array) {
  7827. var length = array == null ? 0 : array.length;
  7828. return length ? array[length - 1] : undefined;
  7829. }
  7830. /**
  7831. * This method is like `_.indexOf` except that it iterates over elements of
  7832. * `array` from right to left.
  7833. *
  7834. * @static
  7835. * @memberOf _
  7836. * @since 0.1.0
  7837. * @category Array
  7838. * @param {Array} array The array to inspect.
  7839. * @param {*} value The value to search for.
  7840. * @param {number} [fromIndex=array.length-1] The index to search from.
  7841. * @returns {number} Returns the index of the matched value, else `-1`.
  7842. * @example
  7843. *
  7844. * _.lastIndexOf([1, 2, 1, 2], 2);
  7845. * // => 3
  7846. *
  7847. * // Search from the `fromIndex`.
  7848. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  7849. * // => 1
  7850. */
  7851. function lastIndexOf(array, value, fromIndex) {
  7852. var length = array == null ? 0 : array.length;
  7853. if (!length) {
  7854. return -1;
  7855. }
  7856. var index = length;
  7857. if (fromIndex !== undefined) {
  7858. index = toInteger(fromIndex);
  7859. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  7860. }
  7861. return value === value
  7862. ? strictLastIndexOf(array, value, index)
  7863. : baseFindIndex(array, baseIsNaN, index, true);
  7864. }
  7865. /**
  7866. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  7867. * element from the end is returned.
  7868. *
  7869. * @static
  7870. * @memberOf _
  7871. * @since 4.11.0
  7872. * @category Array
  7873. * @param {Array} array The array to query.
  7874. * @param {number} [n=0] The index of the element to return.
  7875. * @returns {*} Returns the nth element of `array`.
  7876. * @example
  7877. *
  7878. * var array = ['a', 'b', 'c', 'd'];
  7879. *
  7880. * _.nth(array, 1);
  7881. * // => 'b'
  7882. *
  7883. * _.nth(array, -2);
  7884. * // => 'c';
  7885. */
  7886. function nth(array, n) {
  7887. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  7888. }
  7889. /**
  7890. * Removes all given values from `array` using
  7891. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7892. * for equality comparisons.
  7893. *
  7894. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  7895. * to remove elements from an array by predicate.
  7896. *
  7897. * @static
  7898. * @memberOf _
  7899. * @since 2.0.0
  7900. * @category Array
  7901. * @param {Array} array The array to modify.
  7902. * @param {...*} [values] The values to remove.
  7903. * @returns {Array} Returns `array`.
  7904. * @example
  7905. *
  7906. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  7907. *
  7908. * _.pull(array, 'a', 'c');
  7909. * console.log(array);
  7910. * // => ['b', 'b']
  7911. */
  7912. var pull = baseRest(pullAll);
  7913. /**
  7914. * This method is like `_.pull` except that it accepts an array of values to remove.
  7915. *
  7916. * **Note:** Unlike `_.difference`, this method mutates `array`.
  7917. *
  7918. * @static
  7919. * @memberOf _
  7920. * @since 4.0.0
  7921. * @category Array
  7922. * @param {Array} array The array to modify.
  7923. * @param {Array} values The values to remove.
  7924. * @returns {Array} Returns `array`.
  7925. * @example
  7926. *
  7927. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  7928. *
  7929. * _.pullAll(array, ['a', 'c']);
  7930. * console.log(array);
  7931. * // => ['b', 'b']
  7932. */
  7933. function pullAll(array, values) {
  7934. return (array && array.length && values && values.length)
  7935. ? basePullAll(array, values)
  7936. : array;
  7937. }
  7938. /**
  7939. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  7940. * invoked for each element of `array` and `values` to generate the criterion
  7941. * by which they're compared. The iteratee is invoked with one argument: (value).
  7942. *
  7943. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  7944. *
  7945. * @static
  7946. * @memberOf _
  7947. * @since 4.0.0
  7948. * @category Array
  7949. * @param {Array} array The array to modify.
  7950. * @param {Array} values The values to remove.
  7951. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7952. * @returns {Array} Returns `array`.
  7953. * @example
  7954. *
  7955. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  7956. *
  7957. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  7958. * console.log(array);
  7959. * // => [{ 'x': 2 }]
  7960. */
  7961. function pullAllBy(array, values, iteratee) {
  7962. return (array && array.length && values && values.length)
  7963. ? basePullAll(array, values, getIteratee(iteratee, 2))
  7964. : array;
  7965. }
  7966. /**
  7967. * This method is like `_.pullAll` except that it accepts `comparator` which
  7968. * is invoked to compare elements of `array` to `values`. The comparator is
  7969. * invoked with two arguments: (arrVal, othVal).
  7970. *
  7971. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  7972. *
  7973. * @static
  7974. * @memberOf _
  7975. * @since 4.6.0
  7976. * @category Array
  7977. * @param {Array} array The array to modify.
  7978. * @param {Array} values The values to remove.
  7979. * @param {Function} [comparator] The comparator invoked per element.
  7980. * @returns {Array} Returns `array`.
  7981. * @example
  7982. *
  7983. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  7984. *
  7985. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  7986. * console.log(array);
  7987. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  7988. */
  7989. function pullAllWith(array, values, comparator) {
  7990. return (array && array.length && values && values.length)
  7991. ? basePullAll(array, values, undefined, comparator)
  7992. : array;
  7993. }
  7994. /**
  7995. * Removes elements from `array` corresponding to `indexes` and returns an
  7996. * array of removed elements.
  7997. *
  7998. * **Note:** Unlike `_.at`, this method mutates `array`.
  7999. *
  8000. * @static
  8001. * @memberOf _
  8002. * @since 3.0.0
  8003. * @category Array
  8004. * @param {Array} array The array to modify.
  8005. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  8006. * @returns {Array} Returns the new array of removed elements.
  8007. * @example
  8008. *
  8009. * var array = ['a', 'b', 'c', 'd'];
  8010. * var pulled = _.pullAt(array, [1, 3]);
  8011. *
  8012. * console.log(array);
  8013. * // => ['a', 'c']
  8014. *
  8015. * console.log(pulled);
  8016. * // => ['b', 'd']
  8017. */
  8018. var pullAt = flatRest(function(array, indexes) {
  8019. var length = array == null ? 0 : array.length,
  8020. result = baseAt(array, indexes);
  8021. basePullAt(array, arrayMap(indexes, function(index) {
  8022. return isIndex(index, length) ? +index : index;
  8023. }).sort(compareAscending));
  8024. return result;
  8025. });
  8026. /**
  8027. * Removes all elements from `array` that `predicate` returns truthy for
  8028. * and returns an array of the removed elements. The predicate is invoked
  8029. * with three arguments: (value, index, array).
  8030. *
  8031. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  8032. * to pull elements from an array by value.
  8033. *
  8034. * @static
  8035. * @memberOf _
  8036. * @since 2.0.0
  8037. * @category Array
  8038. * @param {Array} array The array to modify.
  8039. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8040. * @returns {Array} Returns the new array of removed elements.
  8041. * @example
  8042. *
  8043. * var array = [1, 2, 3, 4];
  8044. * var evens = _.remove(array, function(n) {
  8045. * return n % 2 == 0;
  8046. * });
  8047. *
  8048. * console.log(array);
  8049. * // => [1, 3]
  8050. *
  8051. * console.log(evens);
  8052. * // => [2, 4]
  8053. */
  8054. function remove(array, predicate) {
  8055. var result = [];
  8056. if (!(array && array.length)) {
  8057. return result;
  8058. }
  8059. var index = -1,
  8060. indexes = [],
  8061. length = array.length;
  8062. predicate = getIteratee(predicate, 3);
  8063. while (++index < length) {
  8064. var value = array[index];
  8065. if (predicate(value, index, array)) {
  8066. result.push(value);
  8067. indexes.push(index);
  8068. }
  8069. }
  8070. basePullAt(array, indexes);
  8071. return result;
  8072. }
  8073. /**
  8074. * Reverses `array` so that the first element becomes the last, the second
  8075. * element becomes the second to last, and so on.
  8076. *
  8077. * **Note:** This method mutates `array` and is based on
  8078. * [`Array#reverse`](https://mdn.io/Array/reverse).
  8079. *
  8080. * @static
  8081. * @memberOf _
  8082. * @since 4.0.0
  8083. * @category Array
  8084. * @param {Array} array The array to modify.
  8085. * @returns {Array} Returns `array`.
  8086. * @example
  8087. *
  8088. * var array = [1, 2, 3];
  8089. *
  8090. * _.reverse(array);
  8091. * // => [3, 2, 1]
  8092. *
  8093. * console.log(array);
  8094. * // => [3, 2, 1]
  8095. */
  8096. function reverse(array) {
  8097. return array == null ? array : nativeReverse.call(array);
  8098. }
  8099. /**
  8100. * Creates a slice of `array` from `start` up to, but not including, `end`.
  8101. *
  8102. * **Note:** This method is used instead of
  8103. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  8104. * returned.
  8105. *
  8106. * @static
  8107. * @memberOf _
  8108. * @since 3.0.0
  8109. * @category Array
  8110. * @param {Array} array The array to slice.
  8111. * @param {number} [start=0] The start position.
  8112. * @param {number} [end=array.length] The end position.
  8113. * @returns {Array} Returns the slice of `array`.
  8114. */
  8115. function slice(array, start, end) {
  8116. var length = array == null ? 0 : array.length;
  8117. if (!length) {
  8118. return [];
  8119. }
  8120. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  8121. start = 0;
  8122. end = length;
  8123. }
  8124. else {
  8125. start = start == null ? 0 : toInteger(start);
  8126. end = end === undefined ? length : toInteger(end);
  8127. }
  8128. return baseSlice(array, start, end);
  8129. }
  8130. /**
  8131. * Uses a binary search to determine the lowest index at which `value`
  8132. * should be inserted into `array` in order to maintain its sort order.
  8133. *
  8134. * @static
  8135. * @memberOf _
  8136. * @since 0.1.0
  8137. * @category Array
  8138. * @param {Array} array The sorted array to inspect.
  8139. * @param {*} value The value to evaluate.
  8140. * @returns {number} Returns the index at which `value` should be inserted
  8141. * into `array`.
  8142. * @example
  8143. *
  8144. * _.sortedIndex([30, 50], 40);
  8145. * // => 1
  8146. */
  8147. function sortedIndex(array, value) {
  8148. return baseSortedIndex(array, value);
  8149. }
  8150. /**
  8151. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  8152. * which is invoked for `value` and each element of `array` to compute their
  8153. * sort ranking. The iteratee is invoked with one argument: (value).
  8154. *
  8155. * @static
  8156. * @memberOf _
  8157. * @since 4.0.0
  8158. * @category Array
  8159. * @param {Array} array The sorted array to inspect.
  8160. * @param {*} value The value to evaluate.
  8161. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8162. * @returns {number} Returns the index at which `value` should be inserted
  8163. * into `array`.
  8164. * @example
  8165. *
  8166. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8167. *
  8168. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8169. * // => 0
  8170. *
  8171. * // The `_.property` iteratee shorthand.
  8172. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  8173. * // => 0
  8174. */
  8175. function sortedIndexBy(array, value, iteratee) {
  8176. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  8177. }
  8178. /**
  8179. * This method is like `_.indexOf` except that it performs a binary
  8180. * search on a sorted `array`.
  8181. *
  8182. * @static
  8183. * @memberOf _
  8184. * @since 4.0.0
  8185. * @category Array
  8186. * @param {Array} array The array to inspect.
  8187. * @param {*} value The value to search for.
  8188. * @returns {number} Returns the index of the matched value, else `-1`.
  8189. * @example
  8190. *
  8191. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  8192. * // => 1
  8193. */
  8194. function sortedIndexOf(array, value) {
  8195. var length = array == null ? 0 : array.length;
  8196. if (length) {
  8197. var index = baseSortedIndex(array, value);
  8198. if (index < length && eq(array[index], value)) {
  8199. return index;
  8200. }
  8201. }
  8202. return -1;
  8203. }
  8204. /**
  8205. * This method is like `_.sortedIndex` except that it returns the highest
  8206. * index at which `value` should be inserted into `array` in order to
  8207. * maintain its sort order.
  8208. *
  8209. * @static
  8210. * @memberOf _
  8211. * @since 3.0.0
  8212. * @category Array
  8213. * @param {Array} array The sorted array to inspect.
  8214. * @param {*} value The value to evaluate.
  8215. * @returns {number} Returns the index at which `value` should be inserted
  8216. * into `array`.
  8217. * @example
  8218. *
  8219. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  8220. * // => 4
  8221. */
  8222. function sortedLastIndex(array, value) {
  8223. return baseSortedIndex(array, value, true);
  8224. }
  8225. /**
  8226. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  8227. * which is invoked for `value` and each element of `array` to compute their
  8228. * sort ranking. The iteratee is invoked with one argument: (value).
  8229. *
  8230. * @static
  8231. * @memberOf _
  8232. * @since 4.0.0
  8233. * @category Array
  8234. * @param {Array} array The sorted array to inspect.
  8235. * @param {*} value The value to evaluate.
  8236. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8237. * @returns {number} Returns the index at which `value` should be inserted
  8238. * into `array`.
  8239. * @example
  8240. *
  8241. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8242. *
  8243. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8244. * // => 1
  8245. *
  8246. * // The `_.property` iteratee shorthand.
  8247. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  8248. * // => 1
  8249. */
  8250. function sortedLastIndexBy(array, value, iteratee) {
  8251. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  8252. }
  8253. /**
  8254. * This method is like `_.lastIndexOf` except that it performs a binary
  8255. * search on a sorted `array`.
  8256. *
  8257. * @static
  8258. * @memberOf _
  8259. * @since 4.0.0
  8260. * @category Array
  8261. * @param {Array} array The array to inspect.
  8262. * @param {*} value The value to search for.
  8263. * @returns {number} Returns the index of the matched value, else `-1`.
  8264. * @example
  8265. *
  8266. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  8267. * // => 3
  8268. */
  8269. function sortedLastIndexOf(array, value) {
  8270. var length = array == null ? 0 : array.length;
  8271. if (length) {
  8272. var index = baseSortedIndex(array, value, true) - 1;
  8273. if (eq(array[index], value)) {
  8274. return index;
  8275. }
  8276. }
  8277. return -1;
  8278. }
  8279. /**
  8280. * This method is like `_.uniq` except that it's designed and optimized
  8281. * for sorted arrays.
  8282. *
  8283. * @static
  8284. * @memberOf _
  8285. * @since 4.0.0
  8286. * @category Array
  8287. * @param {Array} array The array to inspect.
  8288. * @returns {Array} Returns the new duplicate free array.
  8289. * @example
  8290. *
  8291. * _.sortedUniq([1, 1, 2]);
  8292. * // => [1, 2]
  8293. */
  8294. function sortedUniq(array) {
  8295. return (array && array.length)
  8296. ? baseSortedUniq(array)
  8297. : [];
  8298. }
  8299. /**
  8300. * This method is like `_.uniqBy` except that it's designed and optimized
  8301. * for sorted arrays.
  8302. *
  8303. * @static
  8304. * @memberOf _
  8305. * @since 4.0.0
  8306. * @category Array
  8307. * @param {Array} array The array to inspect.
  8308. * @param {Function} [iteratee] The iteratee invoked per element.
  8309. * @returns {Array} Returns the new duplicate free array.
  8310. * @example
  8311. *
  8312. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  8313. * // => [1.1, 2.3]
  8314. */
  8315. function sortedUniqBy(array, iteratee) {
  8316. return (array && array.length)
  8317. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  8318. : [];
  8319. }
  8320. /**
  8321. * Gets all but the first element of `array`.
  8322. *
  8323. * @static
  8324. * @memberOf _
  8325. * @since 4.0.0
  8326. * @category Array
  8327. * @param {Array} array The array to query.
  8328. * @returns {Array} Returns the slice of `array`.
  8329. * @example
  8330. *
  8331. * _.tail([1, 2, 3]);
  8332. * // => [2, 3]
  8333. */
  8334. function tail(array) {
  8335. var length = array == null ? 0 : array.length;
  8336. return length ? baseSlice(array, 1, length) : [];
  8337. }
  8338. /**
  8339. * Creates a slice of `array` with `n` elements taken from the beginning.
  8340. *
  8341. * @static
  8342. * @memberOf _
  8343. * @since 0.1.0
  8344. * @category Array
  8345. * @param {Array} array The array to query.
  8346. * @param {number} [n=1] The number of elements to take.
  8347. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8348. * @returns {Array} Returns the slice of `array`.
  8349. * @example
  8350. *
  8351. * _.take([1, 2, 3]);
  8352. * // => [1]
  8353. *
  8354. * _.take([1, 2, 3], 2);
  8355. * // => [1, 2]
  8356. *
  8357. * _.take([1, 2, 3], 5);
  8358. * // => [1, 2, 3]
  8359. *
  8360. * _.take([1, 2, 3], 0);
  8361. * // => []
  8362. */
  8363. function take(array, n, guard) {
  8364. if (!(array && array.length)) {
  8365. return [];
  8366. }
  8367. n = (guard || n === undefined) ? 1 : toInteger(n);
  8368. return baseSlice(array, 0, n < 0 ? 0 : n);
  8369. }
  8370. /**
  8371. * Creates a slice of `array` with `n` elements taken from the end.
  8372. *
  8373. * @static
  8374. * @memberOf _
  8375. * @since 3.0.0
  8376. * @category Array
  8377. * @param {Array} array The array to query.
  8378. * @param {number} [n=1] The number of elements to take.
  8379. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8380. * @returns {Array} Returns the slice of `array`.
  8381. * @example
  8382. *
  8383. * _.takeRight([1, 2, 3]);
  8384. * // => [3]
  8385. *
  8386. * _.takeRight([1, 2, 3], 2);
  8387. * // => [2, 3]
  8388. *
  8389. * _.takeRight([1, 2, 3], 5);
  8390. * // => [1, 2, 3]
  8391. *
  8392. * _.takeRight([1, 2, 3], 0);
  8393. * // => []
  8394. */
  8395. function takeRight(array, n, guard) {
  8396. var length = array == null ? 0 : array.length;
  8397. if (!length) {
  8398. return [];
  8399. }
  8400. n = (guard || n === undefined) ? 1 : toInteger(n);
  8401. n = length - n;
  8402. return baseSlice(array, n < 0 ? 0 : n, length);
  8403. }
  8404. /**
  8405. * Creates a slice of `array` with elements taken from the end. Elements are
  8406. * taken until `predicate` returns falsey. The predicate is invoked with
  8407. * three arguments: (value, index, array).
  8408. *
  8409. * @static
  8410. * @memberOf _
  8411. * @since 3.0.0
  8412. * @category Array
  8413. * @param {Array} array The array to query.
  8414. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8415. * @returns {Array} Returns the slice of `array`.
  8416. * @example
  8417. *
  8418. * var users = [
  8419. * { 'user': 'barney', 'active': true },
  8420. * { 'user': 'fred', 'active': false },
  8421. * { 'user': 'pebbles', 'active': false }
  8422. * ];
  8423. *
  8424. * _.takeRightWhile(users, function(o) { return !o.active; });
  8425. * // => objects for ['fred', 'pebbles']
  8426. *
  8427. * // The `_.matches` iteratee shorthand.
  8428. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  8429. * // => objects for ['pebbles']
  8430. *
  8431. * // The `_.matchesProperty` iteratee shorthand.
  8432. * _.takeRightWhile(users, ['active', false]);
  8433. * // => objects for ['fred', 'pebbles']
  8434. *
  8435. * // The `_.property` iteratee shorthand.
  8436. * _.takeRightWhile(users, 'active');
  8437. * // => []
  8438. */
  8439. function takeRightWhile(array, predicate) {
  8440. return (array && array.length)
  8441. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  8442. : [];
  8443. }
  8444. /**
  8445. * Creates a slice of `array` with elements taken from the beginning. Elements
  8446. * are taken until `predicate` returns falsey. The predicate is invoked with
  8447. * three arguments: (value, index, array).
  8448. *
  8449. * @static
  8450. * @memberOf _
  8451. * @since 3.0.0
  8452. * @category Array
  8453. * @param {Array} array The array to query.
  8454. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8455. * @returns {Array} Returns the slice of `array`.
  8456. * @example
  8457. *
  8458. * var users = [
  8459. * { 'user': 'barney', 'active': false },
  8460. * { 'user': 'fred', 'active': false },
  8461. * { 'user': 'pebbles', 'active': true }
  8462. * ];
  8463. *
  8464. * _.takeWhile(users, function(o) { return !o.active; });
  8465. * // => objects for ['barney', 'fred']
  8466. *
  8467. * // The `_.matches` iteratee shorthand.
  8468. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  8469. * // => objects for ['barney']
  8470. *
  8471. * // The `_.matchesProperty` iteratee shorthand.
  8472. * _.takeWhile(users, ['active', false]);
  8473. * // => objects for ['barney', 'fred']
  8474. *
  8475. * // The `_.property` iteratee shorthand.
  8476. * _.takeWhile(users, 'active');
  8477. * // => []
  8478. */
  8479. function takeWhile(array, predicate) {
  8480. return (array && array.length)
  8481. ? baseWhile(array, getIteratee(predicate, 3))
  8482. : [];
  8483. }
  8484. /**
  8485. * Creates an array of unique values, in order, from all given arrays using
  8486. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8487. * for equality comparisons.
  8488. *
  8489. * @static
  8490. * @memberOf _
  8491. * @since 0.1.0
  8492. * @category Array
  8493. * @param {...Array} [arrays] The arrays to inspect.
  8494. * @returns {Array} Returns the new array of combined values.
  8495. * @example
  8496. *
  8497. * _.union([2], [1, 2]);
  8498. * // => [2, 1]
  8499. */
  8500. var union = baseRest(function(arrays) {
  8501. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  8502. });
  8503. /**
  8504. * This method is like `_.union` except that it accepts `iteratee` which is
  8505. * invoked for each element of each `arrays` to generate the criterion by
  8506. * which uniqueness is computed. Result values are chosen from the first
  8507. * array in which the value occurs. The iteratee is invoked with one argument:
  8508. * (value).
  8509. *
  8510. * @static
  8511. * @memberOf _
  8512. * @since 4.0.0
  8513. * @category Array
  8514. * @param {...Array} [arrays] The arrays to inspect.
  8515. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8516. * @returns {Array} Returns the new array of combined values.
  8517. * @example
  8518. *
  8519. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  8520. * // => [2.1, 1.2]
  8521. *
  8522. * // The `_.property` iteratee shorthand.
  8523. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8524. * // => [{ 'x': 1 }, { 'x': 2 }]
  8525. */
  8526. var unionBy = baseRest(function(arrays) {
  8527. var iteratee = last(arrays);
  8528. if (isArrayLikeObject(iteratee)) {
  8529. iteratee = undefined;
  8530. }
  8531. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  8532. });
  8533. /**
  8534. * This method is like `_.union` except that it accepts `comparator` which
  8535. * is invoked to compare elements of `arrays`. Result values are chosen from
  8536. * the first array in which the value occurs. The comparator is invoked
  8537. * with two arguments: (arrVal, othVal).
  8538. *
  8539. * @static
  8540. * @memberOf _
  8541. * @since 4.0.0
  8542. * @category Array
  8543. * @param {...Array} [arrays] The arrays to inspect.
  8544. * @param {Function} [comparator] The comparator invoked per element.
  8545. * @returns {Array} Returns the new array of combined values.
  8546. * @example
  8547. *
  8548. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8549. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8550. *
  8551. * _.unionWith(objects, others, _.isEqual);
  8552. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  8553. */
  8554. var unionWith = baseRest(function(arrays) {
  8555. var comparator = last(arrays);
  8556. comparator = typeof comparator == 'function' ? comparator : undefined;
  8557. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  8558. });
  8559. /**
  8560. * Creates a duplicate-free version of an array, using
  8561. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8562. * for equality comparisons, in which only the first occurrence of each element
  8563. * is kept. The order of result values is determined by the order they occur
  8564. * in the array.
  8565. *
  8566. * @static
  8567. * @memberOf _
  8568. * @since 0.1.0
  8569. * @category Array
  8570. * @param {Array} array The array to inspect.
  8571. * @returns {Array} Returns the new duplicate free array.
  8572. * @example
  8573. *
  8574. * _.uniq([2, 1, 2]);
  8575. * // => [2, 1]
  8576. */
  8577. function uniq(array) {
  8578. return (array && array.length) ? baseUniq(array) : [];
  8579. }
  8580. /**
  8581. * This method is like `_.uniq` except that it accepts `iteratee` which is
  8582. * invoked for each element in `array` to generate the criterion by which
  8583. * uniqueness is computed. The order of result values is determined by the
  8584. * order they occur in the array. The iteratee is invoked with one argument:
  8585. * (value).
  8586. *
  8587. * @static
  8588. * @memberOf _
  8589. * @since 4.0.0
  8590. * @category Array
  8591. * @param {Array} array The array to inspect.
  8592. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8593. * @returns {Array} Returns the new duplicate free array.
  8594. * @example
  8595. *
  8596. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  8597. * // => [2.1, 1.2]
  8598. *
  8599. * // The `_.property` iteratee shorthand.
  8600. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  8601. * // => [{ 'x': 1 }, { 'x': 2 }]
  8602. */
  8603. function uniqBy(array, iteratee) {
  8604. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  8605. }
  8606. /**
  8607. * This method is like `_.uniq` except that it accepts `comparator` which
  8608. * is invoked to compare elements of `array`. The order of result values is
  8609. * determined by the order they occur in the array.The comparator is invoked
  8610. * with two arguments: (arrVal, othVal).
  8611. *
  8612. * @static
  8613. * @memberOf _
  8614. * @since 4.0.0
  8615. * @category Array
  8616. * @param {Array} array The array to inspect.
  8617. * @param {Function} [comparator] The comparator invoked per element.
  8618. * @returns {Array} Returns the new duplicate free array.
  8619. * @example
  8620. *
  8621. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8622. *
  8623. * _.uniqWith(objects, _.isEqual);
  8624. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  8625. */
  8626. function uniqWith(array, comparator) {
  8627. comparator = typeof comparator == 'function' ? comparator : undefined;
  8628. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  8629. }
  8630. /**
  8631. * This method is like `_.zip` except that it accepts an array of grouped
  8632. * elements and creates an array regrouping the elements to their pre-zip
  8633. * configuration.
  8634. *
  8635. * @static
  8636. * @memberOf _
  8637. * @since 1.2.0
  8638. * @category Array
  8639. * @param {Array} array The array of grouped elements to process.
  8640. * @returns {Array} Returns the new array of regrouped elements.
  8641. * @example
  8642. *
  8643. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  8644. * // => [['a', 1, true], ['b', 2, false]]
  8645. *
  8646. * _.unzip(zipped);
  8647. * // => [['a', 'b'], [1, 2], [true, false]]
  8648. */
  8649. function unzip(array) {
  8650. if (!(array && array.length)) {
  8651. return [];
  8652. }
  8653. var length = 0;
  8654. array = arrayFilter(array, function(group) {
  8655. if (isArrayLikeObject(group)) {
  8656. length = nativeMax(group.length, length);
  8657. return true;
  8658. }
  8659. });
  8660. return baseTimes(length, function(index) {
  8661. return arrayMap(array, baseProperty(index));
  8662. });
  8663. }
  8664. /**
  8665. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  8666. * how regrouped values should be combined. The iteratee is invoked with the
  8667. * elements of each group: (...group).
  8668. *
  8669. * @static
  8670. * @memberOf _
  8671. * @since 3.8.0
  8672. * @category Array
  8673. * @param {Array} array The array of grouped elements to process.
  8674. * @param {Function} [iteratee=_.identity] The function to combine
  8675. * regrouped values.
  8676. * @returns {Array} Returns the new array of regrouped elements.
  8677. * @example
  8678. *
  8679. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  8680. * // => [[1, 10, 100], [2, 20, 200]]
  8681. *
  8682. * _.unzipWith(zipped, _.add);
  8683. * // => [3, 30, 300]
  8684. */
  8685. function unzipWith(array, iteratee) {
  8686. if (!(array && array.length)) {
  8687. return [];
  8688. }
  8689. var result = unzip(array);
  8690. if (iteratee == null) {
  8691. return result;
  8692. }
  8693. return arrayMap(result, function(group) {
  8694. return apply(iteratee, undefined, group);
  8695. });
  8696. }
  8697. /**
  8698. * Creates an array excluding all given values using
  8699. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8700. * for equality comparisons.
  8701. *
  8702. * **Note:** Unlike `_.pull`, this method returns a new array.
  8703. *
  8704. * @static
  8705. * @memberOf _
  8706. * @since 0.1.0
  8707. * @category Array
  8708. * @param {Array} array The array to inspect.
  8709. * @param {...*} [values] The values to exclude.
  8710. * @returns {Array} Returns the new array of filtered values.
  8711. * @see _.difference, _.xor
  8712. * @example
  8713. *
  8714. * _.without([2, 1, 2, 3], 1, 2);
  8715. * // => [3]
  8716. */
  8717. var without = baseRest(function(array, values) {
  8718. return isArrayLikeObject(array)
  8719. ? baseDifference(array, values)
  8720. : [];
  8721. });
  8722. /**
  8723. * Creates an array of unique values that is the
  8724. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  8725. * of the given arrays. The order of result values is determined by the order
  8726. * they occur in the arrays.
  8727. *
  8728. * @static
  8729. * @memberOf _
  8730. * @since 2.4.0
  8731. * @category Array
  8732. * @param {...Array} [arrays] The arrays to inspect.
  8733. * @returns {Array} Returns the new array of filtered values.
  8734. * @see _.difference, _.without
  8735. * @example
  8736. *
  8737. * _.xor([2, 1], [2, 3]);
  8738. * // => [1, 3]
  8739. */
  8740. var xor = baseRest(function(arrays) {
  8741. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  8742. });
  8743. /**
  8744. * This method is like `_.xor` except that it accepts `iteratee` which is
  8745. * invoked for each element of each `arrays` to generate the criterion by
  8746. * which by which they're compared. The order of result values is determined
  8747. * by the order they occur in the arrays. The iteratee is invoked with one
  8748. * argument: (value).
  8749. *
  8750. * @static
  8751. * @memberOf _
  8752. * @since 4.0.0
  8753. * @category Array
  8754. * @param {...Array} [arrays] The arrays to inspect.
  8755. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8756. * @returns {Array} Returns the new array of filtered values.
  8757. * @example
  8758. *
  8759. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8760. * // => [1.2, 3.4]
  8761. *
  8762. * // The `_.property` iteratee shorthand.
  8763. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8764. * // => [{ 'x': 2 }]
  8765. */
  8766. var xorBy = baseRest(function(arrays) {
  8767. var iteratee = last(arrays);
  8768. if (isArrayLikeObject(iteratee)) {
  8769. iteratee = undefined;
  8770. }
  8771. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  8772. });
  8773. /**
  8774. * This method is like `_.xor` except that it accepts `comparator` which is
  8775. * invoked to compare elements of `arrays`. The order of result values is
  8776. * determined by the order they occur in the arrays. The comparator is invoked
  8777. * with two arguments: (arrVal, othVal).
  8778. *
  8779. * @static
  8780. * @memberOf _
  8781. * @since 4.0.0
  8782. * @category Array
  8783. * @param {...Array} [arrays] The arrays to inspect.
  8784. * @param {Function} [comparator] The comparator invoked per element.
  8785. * @returns {Array} Returns the new array of filtered values.
  8786. * @example
  8787. *
  8788. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8789. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8790. *
  8791. * _.xorWith(objects, others, _.isEqual);
  8792. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  8793. */
  8794. var xorWith = baseRest(function(arrays) {
  8795. var comparator = last(arrays);
  8796. comparator = typeof comparator == 'function' ? comparator : undefined;
  8797. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  8798. });
  8799. /**
  8800. * Creates an array of grouped elements, the first of which contains the
  8801. * first elements of the given arrays, the second of which contains the
  8802. * second elements of the given arrays, and so on.
  8803. *
  8804. * @static
  8805. * @memberOf _
  8806. * @since 0.1.0
  8807. * @category Array
  8808. * @param {...Array} [arrays] The arrays to process.
  8809. * @returns {Array} Returns the new array of grouped elements.
  8810. * @example
  8811. *
  8812. * _.zip(['a', 'b'], [1, 2], [true, false]);
  8813. * // => [['a', 1, true], ['b', 2, false]]
  8814. */
  8815. var zip = baseRest(unzip);
  8816. /**
  8817. * This method is like `_.fromPairs` except that it accepts two arrays,
  8818. * one of property identifiers and one of corresponding values.
  8819. *
  8820. * @static
  8821. * @memberOf _
  8822. * @since 0.4.0
  8823. * @category Array
  8824. * @param {Array} [props=[]] The property identifiers.
  8825. * @param {Array} [values=[]] The property values.
  8826. * @returns {Object} Returns the new object.
  8827. * @example
  8828. *
  8829. * _.zipObject(['a', 'b'], [1, 2]);
  8830. * // => { 'a': 1, 'b': 2 }
  8831. */
  8832. function zipObject(props, values) {
  8833. return baseZipObject(props || [], values || [], assignValue);
  8834. }
  8835. /**
  8836. * This method is like `_.zipObject` except that it supports property paths.
  8837. *
  8838. * @static
  8839. * @memberOf _
  8840. * @since 4.1.0
  8841. * @category Array
  8842. * @param {Array} [props=[]] The property identifiers.
  8843. * @param {Array} [values=[]] The property values.
  8844. * @returns {Object} Returns the new object.
  8845. * @example
  8846. *
  8847. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  8848. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  8849. */
  8850. function zipObjectDeep(props, values) {
  8851. return baseZipObject(props || [], values || [], baseSet);
  8852. }
  8853. /**
  8854. * This method is like `_.zip` except that it accepts `iteratee` to specify
  8855. * how grouped values should be combined. The iteratee is invoked with the
  8856. * elements of each group: (...group).
  8857. *
  8858. * @static
  8859. * @memberOf _
  8860. * @since 3.8.0
  8861. * @category Array
  8862. * @param {...Array} [arrays] The arrays to process.
  8863. * @param {Function} [iteratee=_.identity] The function to combine
  8864. * grouped values.
  8865. * @returns {Array} Returns the new array of grouped elements.
  8866. * @example
  8867. *
  8868. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  8869. * return a + b + c;
  8870. * });
  8871. * // => [111, 222]
  8872. */
  8873. var zipWith = baseRest(function(arrays) {
  8874. var length = arrays.length,
  8875. iteratee = length > 1 ? arrays[length - 1] : undefined;
  8876. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  8877. return unzipWith(arrays, iteratee);
  8878. });
  8879. /*------------------------------------------------------------------------*/
  8880. /**
  8881. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  8882. * chain sequences enabled. The result of such sequences must be unwrapped
  8883. * with `_#value`.
  8884. *
  8885. * @static
  8886. * @memberOf _
  8887. * @since 1.3.0
  8888. * @category Seq
  8889. * @param {*} value The value to wrap.
  8890. * @returns {Object} Returns the new `lodash` wrapper instance.
  8891. * @example
  8892. *
  8893. * var users = [
  8894. * { 'user': 'barney', 'age': 36 },
  8895. * { 'user': 'fred', 'age': 40 },
  8896. * { 'user': 'pebbles', 'age': 1 }
  8897. * ];
  8898. *
  8899. * var youngest = _
  8900. * .chain(users)
  8901. * .sortBy('age')
  8902. * .map(function(o) {
  8903. * return o.user + ' is ' + o.age;
  8904. * })
  8905. * .head()
  8906. * .value();
  8907. * // => 'pebbles is 1'
  8908. */
  8909. function chain(value) {
  8910. var result = lodash(value);
  8911. result.__chain__ = true;
  8912. return result;
  8913. }
  8914. /**
  8915. * This method invokes `interceptor` and returns `value`. The interceptor
  8916. * is invoked with one argument; (value). The purpose of this method is to
  8917. * "tap into" a method chain sequence in order to modify intermediate results.
  8918. *
  8919. * @static
  8920. * @memberOf _
  8921. * @since 0.1.0
  8922. * @category Seq
  8923. * @param {*} value The value to provide to `interceptor`.
  8924. * @param {Function} interceptor The function to invoke.
  8925. * @returns {*} Returns `value`.
  8926. * @example
  8927. *
  8928. * _([1, 2, 3])
  8929. * .tap(function(array) {
  8930. * // Mutate input array.
  8931. * array.pop();
  8932. * })
  8933. * .reverse()
  8934. * .value();
  8935. * // => [2, 1]
  8936. */
  8937. function tap(value, interceptor) {
  8938. interceptor(value);
  8939. return value;
  8940. }
  8941. /**
  8942. * This method is like `_.tap` except that it returns the result of `interceptor`.
  8943. * The purpose of this method is to "pass thru" values replacing intermediate
  8944. * results in a method chain sequence.
  8945. *
  8946. * @static
  8947. * @memberOf _
  8948. * @since 3.0.0
  8949. * @category Seq
  8950. * @param {*} value The value to provide to `interceptor`.
  8951. * @param {Function} interceptor The function to invoke.
  8952. * @returns {*} Returns the result of `interceptor`.
  8953. * @example
  8954. *
  8955. * _(' abc ')
  8956. * .chain()
  8957. * .trim()
  8958. * .thru(function(value) {
  8959. * return [value];
  8960. * })
  8961. * .value();
  8962. * // => ['abc']
  8963. */
  8964. function thru(value, interceptor) {
  8965. return interceptor(value);
  8966. }
  8967. /**
  8968. * This method is the wrapper version of `_.at`.
  8969. *
  8970. * @name at
  8971. * @memberOf _
  8972. * @since 1.0.0
  8973. * @category Seq
  8974. * @param {...(string|string[])} [paths] The property paths to pick.
  8975. * @returns {Object} Returns the new `lodash` wrapper instance.
  8976. * @example
  8977. *
  8978. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  8979. *
  8980. * _(object).at(['a[0].b.c', 'a[1]']).value();
  8981. * // => [3, 4]
  8982. */
  8983. var wrapperAt = flatRest(function(paths) {
  8984. var length = paths.length,
  8985. start = length ? paths[0] : 0,
  8986. value = this.__wrapped__,
  8987. interceptor = function(object) { return baseAt(object, paths); };
  8988. if (length > 1 || this.__actions__.length ||
  8989. !(value instanceof LazyWrapper) || !isIndex(start)) {
  8990. return this.thru(interceptor);
  8991. }
  8992. value = value.slice(start, +start + (length ? 1 : 0));
  8993. value.__actions__.push({
  8994. 'func': thru,
  8995. 'args': [interceptor],
  8996. 'thisArg': undefined
  8997. });
  8998. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  8999. if (length && !array.length) {
  9000. array.push(undefined);
  9001. }
  9002. return array;
  9003. });
  9004. });
  9005. /**
  9006. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  9007. *
  9008. * @name chain
  9009. * @memberOf _
  9010. * @since 0.1.0
  9011. * @category Seq
  9012. * @returns {Object} Returns the new `lodash` wrapper instance.
  9013. * @example
  9014. *
  9015. * var users = [
  9016. * { 'user': 'barney', 'age': 36 },
  9017. * { 'user': 'fred', 'age': 40 }
  9018. * ];
  9019. *
  9020. * // A sequence without explicit chaining.
  9021. * _(users).head();
  9022. * // => { 'user': 'barney', 'age': 36 }
  9023. *
  9024. * // A sequence with explicit chaining.
  9025. * _(users)
  9026. * .chain()
  9027. * .head()
  9028. * .pick('user')
  9029. * .value();
  9030. * // => { 'user': 'barney' }
  9031. */
  9032. function wrapperChain() {
  9033. return chain(this);
  9034. }
  9035. /**
  9036. * Executes the chain sequence and returns the wrapped result.
  9037. *
  9038. * @name commit
  9039. * @memberOf _
  9040. * @since 3.2.0
  9041. * @category Seq
  9042. * @returns {Object} Returns the new `lodash` wrapper instance.
  9043. * @example
  9044. *
  9045. * var array = [1, 2];
  9046. * var wrapped = _(array).push(3);
  9047. *
  9048. * console.log(array);
  9049. * // => [1, 2]
  9050. *
  9051. * wrapped = wrapped.commit();
  9052. * console.log(array);
  9053. * // => [1, 2, 3]
  9054. *
  9055. * wrapped.last();
  9056. * // => 3
  9057. *
  9058. * console.log(array);
  9059. * // => [1, 2, 3]
  9060. */
  9061. function wrapperCommit() {
  9062. return new LodashWrapper(this.value(), this.__chain__);
  9063. }
  9064. /**
  9065. * Gets the next value on a wrapped object following the
  9066. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  9067. *
  9068. * @name next
  9069. * @memberOf _
  9070. * @since 4.0.0
  9071. * @category Seq
  9072. * @returns {Object} Returns the next iterator value.
  9073. * @example
  9074. *
  9075. * var wrapped = _([1, 2]);
  9076. *
  9077. * wrapped.next();
  9078. * // => { 'done': false, 'value': 1 }
  9079. *
  9080. * wrapped.next();
  9081. * // => { 'done': false, 'value': 2 }
  9082. *
  9083. * wrapped.next();
  9084. * // => { 'done': true, 'value': undefined }
  9085. */
  9086. function wrapperNext() {
  9087. if (this.__values__ === undefined) {
  9088. this.__values__ = toArray(this.value());
  9089. }
  9090. var done = this.__index__ >= this.__values__.length,
  9091. value = done ? undefined : this.__values__[this.__index__++];
  9092. return { 'done': done, 'value': value };
  9093. }
  9094. /**
  9095. * Enables the wrapper to be iterable.
  9096. *
  9097. * @name Symbol.iterator
  9098. * @memberOf _
  9099. * @since 4.0.0
  9100. * @category Seq
  9101. * @returns {Object} Returns the wrapper object.
  9102. * @example
  9103. *
  9104. * var wrapped = _([1, 2]);
  9105. *
  9106. * wrapped[Symbol.iterator]() === wrapped;
  9107. * // => true
  9108. *
  9109. * Array.from(wrapped);
  9110. * // => [1, 2]
  9111. */
  9112. function wrapperToIterator() {
  9113. return this;
  9114. }
  9115. /**
  9116. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  9117. *
  9118. * @name plant
  9119. * @memberOf _
  9120. * @since 3.2.0
  9121. * @category Seq
  9122. * @param {*} value The value to plant.
  9123. * @returns {Object} Returns the new `lodash` wrapper instance.
  9124. * @example
  9125. *
  9126. * function square(n) {
  9127. * return n * n;
  9128. * }
  9129. *
  9130. * var wrapped = _([1, 2]).map(square);
  9131. * var other = wrapped.plant([3, 4]);
  9132. *
  9133. * other.value();
  9134. * // => [9, 16]
  9135. *
  9136. * wrapped.value();
  9137. * // => [1, 4]
  9138. */
  9139. function wrapperPlant(value) {
  9140. var result,
  9141. parent = this;
  9142. while (parent instanceof baseLodash) {
  9143. var clone = wrapperClone(parent);
  9144. clone.__index__ = 0;
  9145. clone.__values__ = undefined;
  9146. if (result) {
  9147. previous.__wrapped__ = clone;
  9148. } else {
  9149. result = clone;
  9150. }
  9151. var previous = clone;
  9152. parent = parent.__wrapped__;
  9153. }
  9154. previous.__wrapped__ = value;
  9155. return result;
  9156. }
  9157. /**
  9158. * This method is the wrapper version of `_.reverse`.
  9159. *
  9160. * **Note:** This method mutates the wrapped array.
  9161. *
  9162. * @name reverse
  9163. * @memberOf _
  9164. * @since 0.1.0
  9165. * @category Seq
  9166. * @returns {Object} Returns the new `lodash` wrapper instance.
  9167. * @example
  9168. *
  9169. * var array = [1, 2, 3];
  9170. *
  9171. * _(array).reverse().value()
  9172. * // => [3, 2, 1]
  9173. *
  9174. * console.log(array);
  9175. * // => [3, 2, 1]
  9176. */
  9177. function wrapperReverse() {
  9178. var value = this.__wrapped__;
  9179. if (value instanceof LazyWrapper) {
  9180. var wrapped = value;
  9181. if (this.__actions__.length) {
  9182. wrapped = new LazyWrapper(this);
  9183. }
  9184. wrapped = wrapped.reverse();
  9185. wrapped.__actions__.push({
  9186. 'func': thru,
  9187. 'args': [reverse],
  9188. 'thisArg': undefined
  9189. });
  9190. return new LodashWrapper(wrapped, this.__chain__);
  9191. }
  9192. return this.thru(reverse);
  9193. }
  9194. /**
  9195. * Executes the chain sequence to resolve the unwrapped value.
  9196. *
  9197. * @name value
  9198. * @memberOf _
  9199. * @since 0.1.0
  9200. * @alias toJSON, valueOf
  9201. * @category Seq
  9202. * @returns {*} Returns the resolved unwrapped value.
  9203. * @example
  9204. *
  9205. * _([1, 2, 3]).value();
  9206. * // => [1, 2, 3]
  9207. */
  9208. function wrapperValue() {
  9209. return baseWrapperValue(this.__wrapped__, this.__actions__);
  9210. }
  9211. /*------------------------------------------------------------------------*/
  9212. /**
  9213. * Creates an object composed of keys generated from the results of running
  9214. * each element of `collection` thru `iteratee`. The corresponding value of
  9215. * each key is the number of times the key was returned by `iteratee`. The
  9216. * iteratee is invoked with one argument: (value).
  9217. *
  9218. * @static
  9219. * @memberOf _
  9220. * @since 0.5.0
  9221. * @category Collection
  9222. * @param {Array|Object} collection The collection to iterate over.
  9223. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9224. * @returns {Object} Returns the composed aggregate object.
  9225. * @example
  9226. *
  9227. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  9228. * // => { '4': 1, '6': 2 }
  9229. *
  9230. * // The `_.property` iteratee shorthand.
  9231. * _.countBy(['one', 'two', 'three'], 'length');
  9232. * // => { '3': 2, '5': 1 }
  9233. */
  9234. var countBy = createAggregator(function(result, value, key) {
  9235. if (hasOwnProperty.call(result, key)) {
  9236. ++result[key];
  9237. } else {
  9238. baseAssignValue(result, key, 1);
  9239. }
  9240. });
  9241. /**
  9242. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  9243. * Iteration is stopped once `predicate` returns falsey. The predicate is
  9244. * invoked with three arguments: (value, index|key, collection).
  9245. *
  9246. * **Note:** This method returns `true` for
  9247. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  9248. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  9249. * elements of empty collections.
  9250. *
  9251. * @static
  9252. * @memberOf _
  9253. * @since 0.1.0
  9254. * @category Collection
  9255. * @param {Array|Object} collection The collection to iterate over.
  9256. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9257. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9258. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  9259. * else `false`.
  9260. * @example
  9261. *
  9262. * _.every([true, 1, null, 'yes'], Boolean);
  9263. * // => false
  9264. *
  9265. * var users = [
  9266. * { 'user': 'barney', 'age': 36, 'active': false },
  9267. * { 'user': 'fred', 'age': 40, 'active': false }
  9268. * ];
  9269. *
  9270. * // The `_.matches` iteratee shorthand.
  9271. * _.every(users, { 'user': 'barney', 'active': false });
  9272. * // => false
  9273. *
  9274. * // The `_.matchesProperty` iteratee shorthand.
  9275. * _.every(users, ['active', false]);
  9276. * // => true
  9277. *
  9278. * // The `_.property` iteratee shorthand.
  9279. * _.every(users, 'active');
  9280. * // => false
  9281. */
  9282. function every(collection, predicate, guard) {
  9283. var func = isArray(collection) ? arrayEvery : baseEvery;
  9284. if (guard && isIterateeCall(collection, predicate, guard)) {
  9285. predicate = undefined;
  9286. }
  9287. return func(collection, getIteratee(predicate, 3));
  9288. }
  9289. /**
  9290. * Iterates over elements of `collection`, returning an array of all elements
  9291. * `predicate` returns truthy for. The predicate is invoked with three
  9292. * arguments: (value, index|key, collection).
  9293. *
  9294. * **Note:** Unlike `_.remove`, this method returns a new array.
  9295. *
  9296. * @static
  9297. * @memberOf _
  9298. * @since 0.1.0
  9299. * @category Collection
  9300. * @param {Array|Object} collection The collection to iterate over.
  9301. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9302. * @returns {Array} Returns the new filtered array.
  9303. * @see _.reject
  9304. * @example
  9305. *
  9306. * var users = [
  9307. * { 'user': 'barney', 'age': 36, 'active': true },
  9308. * { 'user': 'fred', 'age': 40, 'active': false }
  9309. * ];
  9310. *
  9311. * _.filter(users, function(o) { return !o.active; });
  9312. * // => objects for ['fred']
  9313. *
  9314. * // The `_.matches` iteratee shorthand.
  9315. * _.filter(users, { 'age': 36, 'active': true });
  9316. * // => objects for ['barney']
  9317. *
  9318. * // The `_.matchesProperty` iteratee shorthand.
  9319. * _.filter(users, ['active', false]);
  9320. * // => objects for ['fred']
  9321. *
  9322. * // The `_.property` iteratee shorthand.
  9323. * _.filter(users, 'active');
  9324. * // => objects for ['barney']
  9325. */
  9326. function filter(collection, predicate) {
  9327. var func = isArray(collection) ? arrayFilter : baseFilter;
  9328. return func(collection, getIteratee(predicate, 3));
  9329. }
  9330. /**
  9331. * Iterates over elements of `collection`, returning the first element
  9332. * `predicate` returns truthy for. The predicate is invoked with three
  9333. * arguments: (value, index|key, collection).
  9334. *
  9335. * @static
  9336. * @memberOf _
  9337. * @since 0.1.0
  9338. * @category Collection
  9339. * @param {Array|Object} collection The collection to inspect.
  9340. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9341. * @param {number} [fromIndex=0] The index to search from.
  9342. * @returns {*} Returns the matched element, else `undefined`.
  9343. * @example
  9344. *
  9345. * var users = [
  9346. * { 'user': 'barney', 'age': 36, 'active': true },
  9347. * { 'user': 'fred', 'age': 40, 'active': false },
  9348. * { 'user': 'pebbles', 'age': 1, 'active': true }
  9349. * ];
  9350. *
  9351. * _.find(users, function(o) { return o.age < 40; });
  9352. * // => object for 'barney'
  9353. *
  9354. * // The `_.matches` iteratee shorthand.
  9355. * _.find(users, { 'age': 1, 'active': true });
  9356. * // => object for 'pebbles'
  9357. *
  9358. * // The `_.matchesProperty` iteratee shorthand.
  9359. * _.find(users, ['active', false]);
  9360. * // => object for 'fred'
  9361. *
  9362. * // The `_.property` iteratee shorthand.
  9363. * _.find(users, 'active');
  9364. * // => object for 'barney'
  9365. */
  9366. var find = createFind(findIndex);
  9367. /**
  9368. * This method is like `_.find` except that it iterates over elements of
  9369. * `collection` from right to left.
  9370. *
  9371. * @static
  9372. * @memberOf _
  9373. * @since 2.0.0
  9374. * @category Collection
  9375. * @param {Array|Object} collection The collection to inspect.
  9376. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9377. * @param {number} [fromIndex=collection.length-1] The index to search from.
  9378. * @returns {*} Returns the matched element, else `undefined`.
  9379. * @example
  9380. *
  9381. * _.findLast([1, 2, 3, 4], function(n) {
  9382. * return n % 2 == 1;
  9383. * });
  9384. * // => 3
  9385. */
  9386. var findLast = createFind(findLastIndex);
  9387. /**
  9388. * Creates a flattened array of values by running each element in `collection`
  9389. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  9390. * with three arguments: (value, index|key, collection).
  9391. *
  9392. * @static
  9393. * @memberOf _
  9394. * @since 4.0.0
  9395. * @category Collection
  9396. * @param {Array|Object} collection The collection to iterate over.
  9397. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9398. * @returns {Array} Returns the new flattened array.
  9399. * @example
  9400. *
  9401. * function duplicate(n) {
  9402. * return [n, n];
  9403. * }
  9404. *
  9405. * _.flatMap([1, 2], duplicate);
  9406. * // => [1, 1, 2, 2]
  9407. */
  9408. function flatMap(collection, iteratee) {
  9409. return baseFlatten(map(collection, iteratee), 1);
  9410. }
  9411. /**
  9412. * This method is like `_.flatMap` except that it recursively flattens the
  9413. * mapped results.
  9414. *
  9415. * @static
  9416. * @memberOf _
  9417. * @since 4.7.0
  9418. * @category Collection
  9419. * @param {Array|Object} collection The collection to iterate over.
  9420. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9421. * @returns {Array} Returns the new flattened array.
  9422. * @example
  9423. *
  9424. * function duplicate(n) {
  9425. * return [[[n, n]]];
  9426. * }
  9427. *
  9428. * _.flatMapDeep([1, 2], duplicate);
  9429. * // => [1, 1, 2, 2]
  9430. */
  9431. function flatMapDeep(collection, iteratee) {
  9432. return baseFlatten(map(collection, iteratee), INFINITY);
  9433. }
  9434. /**
  9435. * This method is like `_.flatMap` except that it recursively flattens the
  9436. * mapped results up to `depth` times.
  9437. *
  9438. * @static
  9439. * @memberOf _
  9440. * @since 4.7.0
  9441. * @category Collection
  9442. * @param {Array|Object} collection The collection to iterate over.
  9443. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9444. * @param {number} [depth=1] The maximum recursion depth.
  9445. * @returns {Array} Returns the new flattened array.
  9446. * @example
  9447. *
  9448. * function duplicate(n) {
  9449. * return [[[n, n]]];
  9450. * }
  9451. *
  9452. * _.flatMapDepth([1, 2], duplicate, 2);
  9453. * // => [[1, 1], [2, 2]]
  9454. */
  9455. function flatMapDepth(collection, iteratee, depth) {
  9456. depth = depth === undefined ? 1 : toInteger(depth);
  9457. return baseFlatten(map(collection, iteratee), depth);
  9458. }
  9459. /**
  9460. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  9461. * The iteratee is invoked with three arguments: (value, index|key, collection).
  9462. * Iteratee functions may exit iteration early by explicitly returning `false`.
  9463. *
  9464. * **Note:** As with other "Collections" methods, objects with a "length"
  9465. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  9466. * or `_.forOwn` for object iteration.
  9467. *
  9468. * @static
  9469. * @memberOf _
  9470. * @since 0.1.0
  9471. * @alias each
  9472. * @category Collection
  9473. * @param {Array|Object} collection The collection to iterate over.
  9474. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9475. * @returns {Array|Object} Returns `collection`.
  9476. * @see _.forEachRight
  9477. * @example
  9478. *
  9479. * _.forEach([1, 2], function(value) {
  9480. * console.log(value);
  9481. * });
  9482. * // => Logs `1` then `2`.
  9483. *
  9484. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  9485. * console.log(key);
  9486. * });
  9487. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  9488. */
  9489. function forEach(collection, iteratee) {
  9490. var func = isArray(collection) ? arrayEach : baseEach;
  9491. return func(collection, getIteratee(iteratee, 3));
  9492. }
  9493. /**
  9494. * This method is like `_.forEach` except that it iterates over elements of
  9495. * `collection` from right to left.
  9496. *
  9497. * @static
  9498. * @memberOf _
  9499. * @since 2.0.0
  9500. * @alias eachRight
  9501. * @category Collection
  9502. * @param {Array|Object} collection The collection to iterate over.
  9503. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9504. * @returns {Array|Object} Returns `collection`.
  9505. * @see _.forEach
  9506. * @example
  9507. *
  9508. * _.forEachRight([1, 2], function(value) {
  9509. * console.log(value);
  9510. * });
  9511. * // => Logs `2` then `1`.
  9512. */
  9513. function forEachRight(collection, iteratee) {
  9514. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  9515. return func(collection, getIteratee(iteratee, 3));
  9516. }
  9517. /**
  9518. * Creates an object composed of keys generated from the results of running
  9519. * each element of `collection` thru `iteratee`. The order of grouped values
  9520. * is determined by the order they occur in `collection`. The corresponding
  9521. * value of each key is an array of elements responsible for generating the
  9522. * key. The iteratee is invoked with one argument: (value).
  9523. *
  9524. * @static
  9525. * @memberOf _
  9526. * @since 0.1.0
  9527. * @category Collection
  9528. * @param {Array|Object} collection The collection to iterate over.
  9529. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9530. * @returns {Object} Returns the composed aggregate object.
  9531. * @example
  9532. *
  9533. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  9534. * // => { '4': [4.2], '6': [6.1, 6.3] }
  9535. *
  9536. * // The `_.property` iteratee shorthand.
  9537. * _.groupBy(['one', 'two', 'three'], 'length');
  9538. * // => { '3': ['one', 'two'], '5': ['three'] }
  9539. */
  9540. var groupBy = createAggregator(function(result, value, key) {
  9541. if (hasOwnProperty.call(result, key)) {
  9542. result[key].push(value);
  9543. } else {
  9544. baseAssignValue(result, key, [value]);
  9545. }
  9546. });
  9547. /**
  9548. * Checks if `value` is in `collection`. If `collection` is a string, it's
  9549. * checked for a substring of `value`, otherwise
  9550. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9551. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  9552. * the offset from the end of `collection`.
  9553. *
  9554. * @static
  9555. * @memberOf _
  9556. * @since 0.1.0
  9557. * @category Collection
  9558. * @param {Array|Object|string} collection The collection to inspect.
  9559. * @param {*} value The value to search for.
  9560. * @param {number} [fromIndex=0] The index to search from.
  9561. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  9562. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  9563. * @example
  9564. *
  9565. * _.includes([1, 2, 3], 1);
  9566. * // => true
  9567. *
  9568. * _.includes([1, 2, 3], 1, 2);
  9569. * // => false
  9570. *
  9571. * _.includes({ 'a': 1, 'b': 2 }, 1);
  9572. * // => true
  9573. *
  9574. * _.includes('abcd', 'bc');
  9575. * // => true
  9576. */
  9577. function includes(collection, value, fromIndex, guard) {
  9578. collection = isArrayLike(collection) ? collection : values(collection);
  9579. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  9580. var length = collection.length;
  9581. if (fromIndex < 0) {
  9582. fromIndex = nativeMax(length + fromIndex, 0);
  9583. }
  9584. return isString(collection)
  9585. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  9586. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  9587. }
  9588. /**
  9589. * Invokes the method at `path` of each element in `collection`, returning
  9590. * an array of the results of each invoked method. Any additional arguments
  9591. * are provided to each invoked method. If `path` is a function, it's invoked
  9592. * for, and `this` bound to, each element in `collection`.
  9593. *
  9594. * @static
  9595. * @memberOf _
  9596. * @since 4.0.0
  9597. * @category Collection
  9598. * @param {Array|Object} collection The collection to iterate over.
  9599. * @param {Array|Function|string} path The path of the method to invoke or
  9600. * the function invoked per iteration.
  9601. * @param {...*} [args] The arguments to invoke each method with.
  9602. * @returns {Array} Returns the array of results.
  9603. * @example
  9604. *
  9605. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  9606. * // => [[1, 5, 7], [1, 2, 3]]
  9607. *
  9608. * _.invokeMap([123, 456], String.prototype.split, '');
  9609. * // => [['1', '2', '3'], ['4', '5', '6']]
  9610. */
  9611. var invokeMap = baseRest(function(collection, path, args) {
  9612. var index = -1,
  9613. isFunc = typeof path == 'function',
  9614. result = isArrayLike(collection) ? Array(collection.length) : [];
  9615. baseEach(collection, function(value) {
  9616. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  9617. });
  9618. return result;
  9619. });
  9620. /**
  9621. * Creates an object composed of keys generated from the results of running
  9622. * each element of `collection` thru `iteratee`. The corresponding value of
  9623. * each key is the last element responsible for generating the key. The
  9624. * iteratee is invoked with one argument: (value).
  9625. *
  9626. * @static
  9627. * @memberOf _
  9628. * @since 4.0.0
  9629. * @category Collection
  9630. * @param {Array|Object} collection The collection to iterate over.
  9631. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9632. * @returns {Object} Returns the composed aggregate object.
  9633. * @example
  9634. *
  9635. * var array = [
  9636. * { 'dir': 'left', 'code': 97 },
  9637. * { 'dir': 'right', 'code': 100 }
  9638. * ];
  9639. *
  9640. * _.keyBy(array, function(o) {
  9641. * return String.fromCharCode(o.code);
  9642. * });
  9643. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  9644. *
  9645. * _.keyBy(array, 'dir');
  9646. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  9647. */
  9648. var keyBy = createAggregator(function(result, value, key) {
  9649. baseAssignValue(result, key, value);
  9650. });
  9651. /**
  9652. * Creates an array of values by running each element in `collection` thru
  9653. * `iteratee`. The iteratee is invoked with three arguments:
  9654. * (value, index|key, collection).
  9655. *
  9656. * Many lodash methods are guarded to work as iteratees for methods like
  9657. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  9658. *
  9659. * The guarded methods are:
  9660. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  9661. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  9662. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  9663. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  9664. *
  9665. * @static
  9666. * @memberOf _
  9667. * @since 0.1.0
  9668. * @category Collection
  9669. * @param {Array|Object} collection The collection to iterate over.
  9670. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9671. * @returns {Array} Returns the new mapped array.
  9672. * @example
  9673. *
  9674. * function square(n) {
  9675. * return n * n;
  9676. * }
  9677. *
  9678. * _.map([4, 8], square);
  9679. * // => [16, 64]
  9680. *
  9681. * _.map({ 'a': 4, 'b': 8 }, square);
  9682. * // => [16, 64] (iteration order is not guaranteed)
  9683. *
  9684. * var users = [
  9685. * { 'user': 'barney' },
  9686. * { 'user': 'fred' }
  9687. * ];
  9688. *
  9689. * // The `_.property` iteratee shorthand.
  9690. * _.map(users, 'user');
  9691. * // => ['barney', 'fred']
  9692. */
  9693. function map(collection, iteratee) {
  9694. var func = isArray(collection) ? arrayMap : baseMap;
  9695. return func(collection, getIteratee(iteratee, 3));
  9696. }
  9697. /**
  9698. * This method is like `_.sortBy` except that it allows specifying the sort
  9699. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  9700. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  9701. * descending or "asc" for ascending sort order of corresponding values.
  9702. *
  9703. * @static
  9704. * @memberOf _
  9705. * @since 4.0.0
  9706. * @category Collection
  9707. * @param {Array|Object} collection The collection to iterate over.
  9708. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  9709. * The iteratees to sort by.
  9710. * @param {string[]} [orders] The sort orders of `iteratees`.
  9711. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  9712. * @returns {Array} Returns the new sorted array.
  9713. * @example
  9714. *
  9715. * var users = [
  9716. * { 'user': 'fred', 'age': 48 },
  9717. * { 'user': 'barney', 'age': 34 },
  9718. * { 'user': 'fred', 'age': 40 },
  9719. * { 'user': 'barney', 'age': 36 }
  9720. * ];
  9721. *
  9722. * // Sort by `user` in ascending order and by `age` in descending order.
  9723. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  9724. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  9725. */
  9726. function orderBy(collection, iteratees, orders, guard) {
  9727. if (collection == null) {
  9728. return [];
  9729. }
  9730. if (!isArray(iteratees)) {
  9731. iteratees = iteratees == null ? [] : [iteratees];
  9732. }
  9733. orders = guard ? undefined : orders;
  9734. if (!isArray(orders)) {
  9735. orders = orders == null ? [] : [orders];
  9736. }
  9737. return baseOrderBy(collection, iteratees, orders);
  9738. }
  9739. /**
  9740. * Creates an array of elements split into two groups, the first of which
  9741. * contains elements `predicate` returns truthy for, the second of which
  9742. * contains elements `predicate` returns falsey for. The predicate is
  9743. * invoked with one argument: (value).
  9744. *
  9745. * @static
  9746. * @memberOf _
  9747. * @since 3.0.0
  9748. * @category Collection
  9749. * @param {Array|Object} collection The collection to iterate over.
  9750. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9751. * @returns {Array} Returns the array of grouped elements.
  9752. * @example
  9753. *
  9754. * var users = [
  9755. * { 'user': 'barney', 'age': 36, 'active': false },
  9756. * { 'user': 'fred', 'age': 40, 'active': true },
  9757. * { 'user': 'pebbles', 'age': 1, 'active': false }
  9758. * ];
  9759. *
  9760. * _.partition(users, function(o) { return o.active; });
  9761. * // => objects for [['fred'], ['barney', 'pebbles']]
  9762. *
  9763. * // The `_.matches` iteratee shorthand.
  9764. * _.partition(users, { 'age': 1, 'active': false });
  9765. * // => objects for [['pebbles'], ['barney', 'fred']]
  9766. *
  9767. * // The `_.matchesProperty` iteratee shorthand.
  9768. * _.partition(users, ['active', false]);
  9769. * // => objects for [['barney', 'pebbles'], ['fred']]
  9770. *
  9771. * // The `_.property` iteratee shorthand.
  9772. * _.partition(users, 'active');
  9773. * // => objects for [['fred'], ['barney', 'pebbles']]
  9774. */
  9775. var partition = createAggregator(function(result, value, key) {
  9776. result[key ? 0 : 1].push(value);
  9777. }, function() { return [[], []]; });
  9778. /**
  9779. * Reduces `collection` to a value which is the accumulated result of running
  9780. * each element in `collection` thru `iteratee`, where each successive
  9781. * invocation is supplied the return value of the previous. If `accumulator`
  9782. * is not given, the first element of `collection` is used as the initial
  9783. * value. The iteratee is invoked with four arguments:
  9784. * (accumulator, value, index|key, collection).
  9785. *
  9786. * Many lodash methods are guarded to work as iteratees for methods like
  9787. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  9788. *
  9789. * The guarded methods are:
  9790. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  9791. * and `sortBy`
  9792. *
  9793. * @static
  9794. * @memberOf _
  9795. * @since 0.1.0
  9796. * @category Collection
  9797. * @param {Array|Object} collection The collection to iterate over.
  9798. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9799. * @param {*} [accumulator] The initial value.
  9800. * @returns {*} Returns the accumulated value.
  9801. * @see _.reduceRight
  9802. * @example
  9803. *
  9804. * _.reduce([1, 2], function(sum, n) {
  9805. * return sum + n;
  9806. * }, 0);
  9807. * // => 3
  9808. *
  9809. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  9810. * (result[value] || (result[value] = [])).push(key);
  9811. * return result;
  9812. * }, {});
  9813. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  9814. */
  9815. function reduce(collection, iteratee, accumulator) {
  9816. var func = isArray(collection) ? arrayReduce : baseReduce,
  9817. initAccum = arguments.length < 3;
  9818. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  9819. }
  9820. /**
  9821. * This method is like `_.reduce` except that it iterates over elements of
  9822. * `collection` from right to left.
  9823. *
  9824. * @static
  9825. * @memberOf _
  9826. * @since 0.1.0
  9827. * @category Collection
  9828. * @param {Array|Object} collection The collection to iterate over.
  9829. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9830. * @param {*} [accumulator] The initial value.
  9831. * @returns {*} Returns the accumulated value.
  9832. * @see _.reduce
  9833. * @example
  9834. *
  9835. * var array = [[0, 1], [2, 3], [4, 5]];
  9836. *
  9837. * _.reduceRight(array, function(flattened, other) {
  9838. * return flattened.concat(other);
  9839. * }, []);
  9840. * // => [4, 5, 2, 3, 0, 1]
  9841. */
  9842. function reduceRight(collection, iteratee, accumulator) {
  9843. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  9844. initAccum = arguments.length < 3;
  9845. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  9846. }
  9847. /**
  9848. * The opposite of `_.filter`; this method returns the elements of `collection`
  9849. * that `predicate` does **not** return truthy for.
  9850. *
  9851. * @static
  9852. * @memberOf _
  9853. * @since 0.1.0
  9854. * @category Collection
  9855. * @param {Array|Object} collection The collection to iterate over.
  9856. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9857. * @returns {Array} Returns the new filtered array.
  9858. * @see _.filter
  9859. * @example
  9860. *
  9861. * var users = [
  9862. * { 'user': 'barney', 'age': 36, 'active': false },
  9863. * { 'user': 'fred', 'age': 40, 'active': true }
  9864. * ];
  9865. *
  9866. * _.reject(users, function(o) { return !o.active; });
  9867. * // => objects for ['fred']
  9868. *
  9869. * // The `_.matches` iteratee shorthand.
  9870. * _.reject(users, { 'age': 40, 'active': true });
  9871. * // => objects for ['barney']
  9872. *
  9873. * // The `_.matchesProperty` iteratee shorthand.
  9874. * _.reject(users, ['active', false]);
  9875. * // => objects for ['fred']
  9876. *
  9877. * // The `_.property` iteratee shorthand.
  9878. * _.reject(users, 'active');
  9879. * // => objects for ['barney']
  9880. */
  9881. function reject(collection, predicate) {
  9882. var func = isArray(collection) ? arrayFilter : baseFilter;
  9883. return func(collection, negate(getIteratee(predicate, 3)));
  9884. }
  9885. /**
  9886. * Gets a random element from `collection`.
  9887. *
  9888. * @static
  9889. * @memberOf _
  9890. * @since 2.0.0
  9891. * @category Collection
  9892. * @param {Array|Object} collection The collection to sample.
  9893. * @returns {*} Returns the random element.
  9894. * @example
  9895. *
  9896. * _.sample([1, 2, 3, 4]);
  9897. * // => 2
  9898. */
  9899. function sample(collection) {
  9900. var func = isArray(collection) ? arraySample : baseSample;
  9901. return func(collection);
  9902. }
  9903. /**
  9904. * Gets `n` random elements at unique keys from `collection` up to the
  9905. * size of `collection`.
  9906. *
  9907. * @static
  9908. * @memberOf _
  9909. * @since 4.0.0
  9910. * @category Collection
  9911. * @param {Array|Object} collection The collection to sample.
  9912. * @param {number} [n=1] The number of elements to sample.
  9913. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9914. * @returns {Array} Returns the random elements.
  9915. * @example
  9916. *
  9917. * _.sampleSize([1, 2, 3], 2);
  9918. * // => [3, 1]
  9919. *
  9920. * _.sampleSize([1, 2, 3], 4);
  9921. * // => [2, 3, 1]
  9922. */
  9923. function sampleSize(collection, n, guard) {
  9924. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  9925. n = 1;
  9926. } else {
  9927. n = toInteger(n);
  9928. }
  9929. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  9930. return func(collection, n);
  9931. }
  9932. /**
  9933. * Creates an array of shuffled values, using a version of the
  9934. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  9935. *
  9936. * @static
  9937. * @memberOf _
  9938. * @since 0.1.0
  9939. * @category Collection
  9940. * @param {Array|Object} collection The collection to shuffle.
  9941. * @returns {Array} Returns the new shuffled array.
  9942. * @example
  9943. *
  9944. * _.shuffle([1, 2, 3, 4]);
  9945. * // => [4, 1, 3, 2]
  9946. */
  9947. function shuffle(collection) {
  9948. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  9949. return func(collection);
  9950. }
  9951. /**
  9952. * Gets the size of `collection` by returning its length for array-like
  9953. * values or the number of own enumerable string keyed properties for objects.
  9954. *
  9955. * @static
  9956. * @memberOf _
  9957. * @since 0.1.0
  9958. * @category Collection
  9959. * @param {Array|Object|string} collection The collection to inspect.
  9960. * @returns {number} Returns the collection size.
  9961. * @example
  9962. *
  9963. * _.size([1, 2, 3]);
  9964. * // => 3
  9965. *
  9966. * _.size({ 'a': 1, 'b': 2 });
  9967. * // => 2
  9968. *
  9969. * _.size('pebbles');
  9970. * // => 7
  9971. */
  9972. function size(collection) {
  9973. if (collection == null) {
  9974. return 0;
  9975. }
  9976. if (isArrayLike(collection)) {
  9977. return isString(collection) ? stringSize(collection) : collection.length;
  9978. }
  9979. var tag = getTag(collection);
  9980. if (tag == mapTag || tag == setTag) {
  9981. return collection.size;
  9982. }
  9983. return baseKeys(collection).length;
  9984. }
  9985. /**
  9986. * Checks if `predicate` returns truthy for **any** element of `collection`.
  9987. * Iteration is stopped once `predicate` returns truthy. The predicate is
  9988. * invoked with three arguments: (value, index|key, collection).
  9989. *
  9990. * @static
  9991. * @memberOf _
  9992. * @since 0.1.0
  9993. * @category Collection
  9994. * @param {Array|Object} collection The collection to iterate over.
  9995. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9996. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9997. * @returns {boolean} Returns `true` if any element passes the predicate check,
  9998. * else `false`.
  9999. * @example
  10000. *
  10001. * _.some([null, 0, 'yes', false], Boolean);
  10002. * // => true
  10003. *
  10004. * var users = [
  10005. * { 'user': 'barney', 'active': true },
  10006. * { 'user': 'fred', 'active': false }
  10007. * ];
  10008. *
  10009. * // The `_.matches` iteratee shorthand.
  10010. * _.some(users, { 'user': 'barney', 'active': false });
  10011. * // => false
  10012. *
  10013. * // The `_.matchesProperty` iteratee shorthand.
  10014. * _.some(users, ['active', false]);
  10015. * // => true
  10016. *
  10017. * // The `_.property` iteratee shorthand.
  10018. * _.some(users, 'active');
  10019. * // => true
  10020. */
  10021. function some(collection, predicate, guard) {
  10022. var func = isArray(collection) ? arraySome : baseSome;
  10023. if (guard && isIterateeCall(collection, predicate, guard)) {
  10024. predicate = undefined;
  10025. }
  10026. return func(collection, getIteratee(predicate, 3));
  10027. }
  10028. /**
  10029. * Creates an array of elements, sorted in ascending order by the results of
  10030. * running each element in a collection thru each iteratee. This method
  10031. * performs a stable sort, that is, it preserves the original sort order of
  10032. * equal elements. The iteratees are invoked with one argument: (value).
  10033. *
  10034. * @static
  10035. * @memberOf _
  10036. * @since 0.1.0
  10037. * @category Collection
  10038. * @param {Array|Object} collection The collection to iterate over.
  10039. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  10040. * The iteratees to sort by.
  10041. * @returns {Array} Returns the new sorted array.
  10042. * @example
  10043. *
  10044. * var users = [
  10045. * { 'user': 'fred', 'age': 48 },
  10046. * { 'user': 'barney', 'age': 36 },
  10047. * { 'user': 'fred', 'age': 40 },
  10048. * { 'user': 'barney', 'age': 34 }
  10049. * ];
  10050. *
  10051. * _.sortBy(users, [function(o) { return o.user; }]);
  10052. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  10053. *
  10054. * _.sortBy(users, ['user', 'age']);
  10055. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  10056. */
  10057. var sortBy = baseRest(function(collection, iteratees) {
  10058. if (collection == null) {
  10059. return [];
  10060. }
  10061. var length = iteratees.length;
  10062. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  10063. iteratees = [];
  10064. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  10065. iteratees = [iteratees[0]];
  10066. }
  10067. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  10068. });
  10069. /*------------------------------------------------------------------------*/
  10070. /**
  10071. * Gets the timestamp of the number of milliseconds that have elapsed since
  10072. * the Unix epoch (1 January 1970 00:00:00 UTC).
  10073. *
  10074. * @static
  10075. * @memberOf _
  10076. * @since 2.4.0
  10077. * @category Date
  10078. * @returns {number} Returns the timestamp.
  10079. * @example
  10080. *
  10081. * _.defer(function(stamp) {
  10082. * console.log(_.now() - stamp);
  10083. * }, _.now());
  10084. * // => Logs the number of milliseconds it took for the deferred invocation.
  10085. */
  10086. var now = ctxNow || function() {
  10087. return root.Date.now();
  10088. };
  10089. /*------------------------------------------------------------------------*/
  10090. /**
  10091. * The opposite of `_.before`; this method creates a function that invokes
  10092. * `func` once it's called `n` or more times.
  10093. *
  10094. * @static
  10095. * @memberOf _
  10096. * @since 0.1.0
  10097. * @category Function
  10098. * @param {number} n The number of calls before `func` is invoked.
  10099. * @param {Function} func The function to restrict.
  10100. * @returns {Function} Returns the new restricted function.
  10101. * @example
  10102. *
  10103. * var saves = ['profile', 'settings'];
  10104. *
  10105. * var done = _.after(saves.length, function() {
  10106. * console.log('done saving!');
  10107. * });
  10108. *
  10109. * _.forEach(saves, function(type) {
  10110. * asyncSave({ 'type': type, 'complete': done });
  10111. * });
  10112. * // => Logs 'done saving!' after the two async saves have completed.
  10113. */
  10114. function after(n, func) {
  10115. if (typeof func != 'function') {
  10116. throw new TypeError(FUNC_ERROR_TEXT);
  10117. }
  10118. n = toInteger(n);
  10119. return function() {
  10120. if (--n < 1) {
  10121. return func.apply(this, arguments);
  10122. }
  10123. };
  10124. }
  10125. /**
  10126. * Creates a function that invokes `func`, with up to `n` arguments,
  10127. * ignoring any additional arguments.
  10128. *
  10129. * @static
  10130. * @memberOf _
  10131. * @since 3.0.0
  10132. * @category Function
  10133. * @param {Function} func The function to cap arguments for.
  10134. * @param {number} [n=func.length] The arity cap.
  10135. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10136. * @returns {Function} Returns the new capped function.
  10137. * @example
  10138. *
  10139. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  10140. * // => [6, 8, 10]
  10141. */
  10142. function ary(func, n, guard) {
  10143. n = guard ? undefined : n;
  10144. n = (func && n == null) ? func.length : n;
  10145. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  10146. }
  10147. /**
  10148. * Creates a function that invokes `func`, with the `this` binding and arguments
  10149. * of the created function, while it's called less than `n` times. Subsequent
  10150. * calls to the created function return the result of the last `func` invocation.
  10151. *
  10152. * @static
  10153. * @memberOf _
  10154. * @since 3.0.0
  10155. * @category Function
  10156. * @param {number} n The number of calls at which `func` is no longer invoked.
  10157. * @param {Function} func The function to restrict.
  10158. * @returns {Function} Returns the new restricted function.
  10159. * @example
  10160. *
  10161. * jQuery(element).on('click', _.before(5, addContactToList));
  10162. * // => Allows adding up to 4 contacts to the list.
  10163. */
  10164. function before(n, func) {
  10165. var result;
  10166. if (typeof func != 'function') {
  10167. throw new TypeError(FUNC_ERROR_TEXT);
  10168. }
  10169. n = toInteger(n);
  10170. return function() {
  10171. if (--n > 0) {
  10172. result = func.apply(this, arguments);
  10173. }
  10174. if (n <= 1) {
  10175. func = undefined;
  10176. }
  10177. return result;
  10178. };
  10179. }
  10180. /**
  10181. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  10182. * and `partials` prepended to the arguments it receives.
  10183. *
  10184. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  10185. * may be used as a placeholder for partially applied arguments.
  10186. *
  10187. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  10188. * property of bound functions.
  10189. *
  10190. * @static
  10191. * @memberOf _
  10192. * @since 0.1.0
  10193. * @category Function
  10194. * @param {Function} func The function to bind.
  10195. * @param {*} thisArg The `this` binding of `func`.
  10196. * @param {...*} [partials] The arguments to be partially applied.
  10197. * @returns {Function} Returns the new bound function.
  10198. * @example
  10199. *
  10200. * function greet(greeting, punctuation) {
  10201. * return greeting + ' ' + this.user + punctuation;
  10202. * }
  10203. *
  10204. * var object = { 'user': 'fred' };
  10205. *
  10206. * var bound = _.bind(greet, object, 'hi');
  10207. * bound('!');
  10208. * // => 'hi fred!'
  10209. *
  10210. * // Bound with placeholders.
  10211. * var bound = _.bind(greet, object, _, '!');
  10212. * bound('hi');
  10213. * // => 'hi fred!'
  10214. */
  10215. var bind = baseRest(function(func, thisArg, partials) {
  10216. var bitmask = WRAP_BIND_FLAG;
  10217. if (partials.length) {
  10218. var holders = replaceHolders(partials, getHolder(bind));
  10219. bitmask |= WRAP_PARTIAL_FLAG;
  10220. }
  10221. return createWrap(func, bitmask, thisArg, partials, holders);
  10222. });
  10223. /**
  10224. * Creates a function that invokes the method at `object[key]` with `partials`
  10225. * prepended to the arguments it receives.
  10226. *
  10227. * This method differs from `_.bind` by allowing bound functions to reference
  10228. * methods that may be redefined or don't yet exist. See
  10229. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  10230. * for more details.
  10231. *
  10232. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  10233. * builds, may be used as a placeholder for partially applied arguments.
  10234. *
  10235. * @static
  10236. * @memberOf _
  10237. * @since 0.10.0
  10238. * @category Function
  10239. * @param {Object} object The object to invoke the method on.
  10240. * @param {string} key The key of the method.
  10241. * @param {...*} [partials] The arguments to be partially applied.
  10242. * @returns {Function} Returns the new bound function.
  10243. * @example
  10244. *
  10245. * var object = {
  10246. * 'user': 'fred',
  10247. * 'greet': function(greeting, punctuation) {
  10248. * return greeting + ' ' + this.user + punctuation;
  10249. * }
  10250. * };
  10251. *
  10252. * var bound = _.bindKey(object, 'greet', 'hi');
  10253. * bound('!');
  10254. * // => 'hi fred!'
  10255. *
  10256. * object.greet = function(greeting, punctuation) {
  10257. * return greeting + 'ya ' + this.user + punctuation;
  10258. * };
  10259. *
  10260. * bound('!');
  10261. * // => 'hiya fred!'
  10262. *
  10263. * // Bound with placeholders.
  10264. * var bound = _.bindKey(object, 'greet', _, '!');
  10265. * bound('hi');
  10266. * // => 'hiya fred!'
  10267. */
  10268. var bindKey = baseRest(function(object, key, partials) {
  10269. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  10270. if (partials.length) {
  10271. var holders = replaceHolders(partials, getHolder(bindKey));
  10272. bitmask |= WRAP_PARTIAL_FLAG;
  10273. }
  10274. return createWrap(key, bitmask, object, partials, holders);
  10275. });
  10276. /**
  10277. * Creates a function that accepts arguments of `func` and either invokes
  10278. * `func` returning its result, if at least `arity` number of arguments have
  10279. * been provided, or returns a function that accepts the remaining `func`
  10280. * arguments, and so on. The arity of `func` may be specified if `func.length`
  10281. * is not sufficient.
  10282. *
  10283. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  10284. * may be used as a placeholder for provided arguments.
  10285. *
  10286. * **Note:** This method doesn't set the "length" property of curried functions.
  10287. *
  10288. * @static
  10289. * @memberOf _
  10290. * @since 2.0.0
  10291. * @category Function
  10292. * @param {Function} func The function to curry.
  10293. * @param {number} [arity=func.length] The arity of `func`.
  10294. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10295. * @returns {Function} Returns the new curried function.
  10296. * @example
  10297. *
  10298. * var abc = function(a, b, c) {
  10299. * return [a, b, c];
  10300. * };
  10301. *
  10302. * var curried = _.curry(abc);
  10303. *
  10304. * curried(1)(2)(3);
  10305. * // => [1, 2, 3]
  10306. *
  10307. * curried(1, 2)(3);
  10308. * // => [1, 2, 3]
  10309. *
  10310. * curried(1, 2, 3);
  10311. * // => [1, 2, 3]
  10312. *
  10313. * // Curried with placeholders.
  10314. * curried(1)(_, 3)(2);
  10315. * // => [1, 2, 3]
  10316. */
  10317. function curry(func, arity, guard) {
  10318. arity = guard ? undefined : arity;
  10319. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  10320. result.placeholder = curry.placeholder;
  10321. return result;
  10322. }
  10323. /**
  10324. * This method is like `_.curry` except that arguments are applied to `func`
  10325. * in the manner of `_.partialRight` instead of `_.partial`.
  10326. *
  10327. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  10328. * builds, may be used as a placeholder for provided arguments.
  10329. *
  10330. * **Note:** This method doesn't set the "length" property of curried functions.
  10331. *
  10332. * @static
  10333. * @memberOf _
  10334. * @since 3.0.0
  10335. * @category Function
  10336. * @param {Function} func The function to curry.
  10337. * @param {number} [arity=func.length] The arity of `func`.
  10338. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10339. * @returns {Function} Returns the new curried function.
  10340. * @example
  10341. *
  10342. * var abc = function(a, b, c) {
  10343. * return [a, b, c];
  10344. * };
  10345. *
  10346. * var curried = _.curryRight(abc);
  10347. *
  10348. * curried(3)(2)(1);
  10349. * // => [1, 2, 3]
  10350. *
  10351. * curried(2, 3)(1);
  10352. * // => [1, 2, 3]
  10353. *
  10354. * curried(1, 2, 3);
  10355. * // => [1, 2, 3]
  10356. *
  10357. * // Curried with placeholders.
  10358. * curried(3)(1, _)(2);
  10359. * // => [1, 2, 3]
  10360. */
  10361. function curryRight(func, arity, guard) {
  10362. arity = guard ? undefined : arity;
  10363. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  10364. result.placeholder = curryRight.placeholder;
  10365. return result;
  10366. }
  10367. /**
  10368. * Creates a debounced function that delays invoking `func` until after `wait`
  10369. * milliseconds have elapsed since the last time the debounced function was
  10370. * invoked. The debounced function comes with a `cancel` method to cancel
  10371. * delayed `func` invocations and a `flush` method to immediately invoke them.
  10372. * Provide `options` to indicate whether `func` should be invoked on the
  10373. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  10374. * with the last arguments provided to the debounced function. Subsequent
  10375. * calls to the debounced function return the result of the last `func`
  10376. * invocation.
  10377. *
  10378. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  10379. * invoked on the trailing edge of the timeout only if the debounced function
  10380. * is invoked more than once during the `wait` timeout.
  10381. *
  10382. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  10383. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  10384. *
  10385. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  10386. * for details over the differences between `_.debounce` and `_.throttle`.
  10387. *
  10388. * @static
  10389. * @memberOf _
  10390. * @since 0.1.0
  10391. * @category Function
  10392. * @param {Function} func The function to debounce.
  10393. * @param {number} [wait=0] The number of milliseconds to delay.
  10394. * @param {Object} [options={}] The options object.
  10395. * @param {boolean} [options.leading=false]
  10396. * Specify invoking on the leading edge of the timeout.
  10397. * @param {number} [options.maxWait]
  10398. * The maximum time `func` is allowed to be delayed before it's invoked.
  10399. * @param {boolean} [options.trailing=true]
  10400. * Specify invoking on the trailing edge of the timeout.
  10401. * @returns {Function} Returns the new debounced function.
  10402. * @example
  10403. *
  10404. * // Avoid costly calculations while the window size is in flux.
  10405. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  10406. *
  10407. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  10408. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  10409. * 'leading': true,
  10410. * 'trailing': false
  10411. * }));
  10412. *
  10413. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  10414. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  10415. * var source = new EventSource('/stream');
  10416. * jQuery(source).on('message', debounced);
  10417. *
  10418. * // Cancel the trailing debounced invocation.
  10419. * jQuery(window).on('popstate', debounced.cancel);
  10420. */
  10421. function debounce(func, wait, options) {
  10422. var lastArgs,
  10423. lastThis,
  10424. maxWait,
  10425. result,
  10426. timerId,
  10427. lastCallTime,
  10428. lastInvokeTime = 0,
  10429. leading = false,
  10430. maxing = false,
  10431. trailing = true;
  10432. if (typeof func != 'function') {
  10433. throw new TypeError(FUNC_ERROR_TEXT);
  10434. }
  10435. wait = toNumber(wait) || 0;
  10436. if (isObject(options)) {
  10437. leading = !!options.leading;
  10438. maxing = 'maxWait' in options;
  10439. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  10440. trailing = 'trailing' in options ? !!options.trailing : trailing;
  10441. }
  10442. function invokeFunc(time) {
  10443. var args = lastArgs,
  10444. thisArg = lastThis;
  10445. lastArgs = lastThis = undefined;
  10446. lastInvokeTime = time;
  10447. result = func.apply(thisArg, args);
  10448. return result;
  10449. }
  10450. function leadingEdge(time) {
  10451. // Reset any `maxWait` timer.
  10452. lastInvokeTime = time;
  10453. // Start the timer for the trailing edge.
  10454. timerId = setTimeout(timerExpired, wait);
  10455. // Invoke the leading edge.
  10456. return leading ? invokeFunc(time) : result;
  10457. }
  10458. function remainingWait(time) {
  10459. var timeSinceLastCall = time - lastCallTime,
  10460. timeSinceLastInvoke = time - lastInvokeTime,
  10461. result = wait - timeSinceLastCall;
  10462. return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
  10463. }
  10464. function shouldInvoke(time) {
  10465. var timeSinceLastCall = time - lastCallTime,
  10466. timeSinceLastInvoke = time - lastInvokeTime;
  10467. // Either this is the first call, activity has stopped and we're at the
  10468. // trailing edge, the system time has gone backwards and we're treating
  10469. // it as the trailing edge, or we've hit the `maxWait` limit.
  10470. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  10471. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  10472. }
  10473. function timerExpired() {
  10474. var time = now();
  10475. if (shouldInvoke(time)) {
  10476. return trailingEdge(time);
  10477. }
  10478. // Restart the timer.
  10479. timerId = setTimeout(timerExpired, remainingWait(time));
  10480. }
  10481. function trailingEdge(time) {
  10482. timerId = undefined;
  10483. // Only invoke if we have `lastArgs` which means `func` has been
  10484. // debounced at least once.
  10485. if (trailing && lastArgs) {
  10486. return invokeFunc(time);
  10487. }
  10488. lastArgs = lastThis = undefined;
  10489. return result;
  10490. }
  10491. function cancel() {
  10492. if (timerId !== undefined) {
  10493. clearTimeout(timerId);
  10494. }
  10495. lastInvokeTime = 0;
  10496. lastArgs = lastCallTime = lastThis = timerId = undefined;
  10497. }
  10498. function flush() {
  10499. return timerId === undefined ? result : trailingEdge(now());
  10500. }
  10501. function debounced() {
  10502. var time = now(),
  10503. isInvoking = shouldInvoke(time);
  10504. lastArgs = arguments;
  10505. lastThis = this;
  10506. lastCallTime = time;
  10507. if (isInvoking) {
  10508. if (timerId === undefined) {
  10509. return leadingEdge(lastCallTime);
  10510. }
  10511. if (maxing) {
  10512. // Handle invocations in a tight loop.
  10513. timerId = setTimeout(timerExpired, wait);
  10514. return invokeFunc(lastCallTime);
  10515. }
  10516. }
  10517. if (timerId === undefined) {
  10518. timerId = setTimeout(timerExpired, wait);
  10519. }
  10520. return result;
  10521. }
  10522. debounced.cancel = cancel;
  10523. debounced.flush = flush;
  10524. return debounced;
  10525. }
  10526. /**
  10527. * Defers invoking the `func` until the current call stack has cleared. Any
  10528. * additional arguments are provided to `func` when it's invoked.
  10529. *
  10530. * @static
  10531. * @memberOf _
  10532. * @since 0.1.0
  10533. * @category Function
  10534. * @param {Function} func The function to defer.
  10535. * @param {...*} [args] The arguments to invoke `func` with.
  10536. * @returns {number} Returns the timer id.
  10537. * @example
  10538. *
  10539. * _.defer(function(text) {
  10540. * console.log(text);
  10541. * }, 'deferred');
  10542. * // => Logs 'deferred' after one millisecond.
  10543. */
  10544. var defer = baseRest(function(func, args) {
  10545. return baseDelay(func, 1, args);
  10546. });
  10547. /**
  10548. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  10549. * provided to `func` when it's invoked.
  10550. *
  10551. * @static
  10552. * @memberOf _
  10553. * @since 0.1.0
  10554. * @category Function
  10555. * @param {Function} func The function to delay.
  10556. * @param {number} wait The number of milliseconds to delay invocation.
  10557. * @param {...*} [args] The arguments to invoke `func` with.
  10558. * @returns {number} Returns the timer id.
  10559. * @example
  10560. *
  10561. * _.delay(function(text) {
  10562. * console.log(text);
  10563. * }, 1000, 'later');
  10564. * // => Logs 'later' after one second.
  10565. */
  10566. var delay = baseRest(function(func, wait, args) {
  10567. return baseDelay(func, toNumber(wait) || 0, args);
  10568. });
  10569. /**
  10570. * Creates a function that invokes `func` with arguments reversed.
  10571. *
  10572. * @static
  10573. * @memberOf _
  10574. * @since 4.0.0
  10575. * @category Function
  10576. * @param {Function} func The function to flip arguments for.
  10577. * @returns {Function} Returns the new flipped function.
  10578. * @example
  10579. *
  10580. * var flipped = _.flip(function() {
  10581. * return _.toArray(arguments);
  10582. * });
  10583. *
  10584. * flipped('a', 'b', 'c', 'd');
  10585. * // => ['d', 'c', 'b', 'a']
  10586. */
  10587. function flip(func) {
  10588. return createWrap(func, WRAP_FLIP_FLAG);
  10589. }
  10590. /**
  10591. * Creates a function that memoizes the result of `func`. If `resolver` is
  10592. * provided, it determines the cache key for storing the result based on the
  10593. * arguments provided to the memoized function. By default, the first argument
  10594. * provided to the memoized function is used as the map cache key. The `func`
  10595. * is invoked with the `this` binding of the memoized function.
  10596. *
  10597. * **Note:** The cache is exposed as the `cache` property on the memoized
  10598. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  10599. * constructor with one whose instances implement the
  10600. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  10601. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  10602. *
  10603. * @static
  10604. * @memberOf _
  10605. * @since 0.1.0
  10606. * @category Function
  10607. * @param {Function} func The function to have its output memoized.
  10608. * @param {Function} [resolver] The function to resolve the cache key.
  10609. * @returns {Function} Returns the new memoized function.
  10610. * @example
  10611. *
  10612. * var object = { 'a': 1, 'b': 2 };
  10613. * var other = { 'c': 3, 'd': 4 };
  10614. *
  10615. * var values = _.memoize(_.values);
  10616. * values(object);
  10617. * // => [1, 2]
  10618. *
  10619. * values(other);
  10620. * // => [3, 4]
  10621. *
  10622. * object.a = 2;
  10623. * values(object);
  10624. * // => [1, 2]
  10625. *
  10626. * // Modify the result cache.
  10627. * values.cache.set(object, ['a', 'b']);
  10628. * values(object);
  10629. * // => ['a', 'b']
  10630. *
  10631. * // Replace `_.memoize.Cache`.
  10632. * _.memoize.Cache = WeakMap;
  10633. */
  10634. function memoize(func, resolver) {
  10635. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  10636. throw new TypeError(FUNC_ERROR_TEXT);
  10637. }
  10638. var memoized = function() {
  10639. var args = arguments,
  10640. key = resolver ? resolver.apply(this, args) : args[0],
  10641. cache = memoized.cache;
  10642. if (cache.has(key)) {
  10643. return cache.get(key);
  10644. }
  10645. var result = func.apply(this, args);
  10646. memoized.cache = cache.set(key, result) || cache;
  10647. return result;
  10648. };
  10649. memoized.cache = new (memoize.Cache || MapCache);
  10650. return memoized;
  10651. }
  10652. // Expose `MapCache`.
  10653. memoize.Cache = MapCache;
  10654. /**
  10655. * Creates a function that negates the result of the predicate `func`. The
  10656. * `func` predicate is invoked with the `this` binding and arguments of the
  10657. * created function.
  10658. *
  10659. * @static
  10660. * @memberOf _
  10661. * @since 3.0.0
  10662. * @category Function
  10663. * @param {Function} predicate The predicate to negate.
  10664. * @returns {Function} Returns the new negated function.
  10665. * @example
  10666. *
  10667. * function isEven(n) {
  10668. * return n % 2 == 0;
  10669. * }
  10670. *
  10671. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  10672. * // => [1, 3, 5]
  10673. */
  10674. function negate(predicate) {
  10675. if (typeof predicate != 'function') {
  10676. throw new TypeError(FUNC_ERROR_TEXT);
  10677. }
  10678. return function() {
  10679. var args = arguments;
  10680. switch (args.length) {
  10681. case 0: return !predicate.call(this);
  10682. case 1: return !predicate.call(this, args[0]);
  10683. case 2: return !predicate.call(this, args[0], args[1]);
  10684. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  10685. }
  10686. return !predicate.apply(this, args);
  10687. };
  10688. }
  10689. /**
  10690. * Creates a function that is restricted to invoking `func` once. Repeat calls
  10691. * to the function return the value of the first invocation. The `func` is
  10692. * invoked with the `this` binding and arguments of the created function.
  10693. *
  10694. * @static
  10695. * @memberOf _
  10696. * @since 0.1.0
  10697. * @category Function
  10698. * @param {Function} func The function to restrict.
  10699. * @returns {Function} Returns the new restricted function.
  10700. * @example
  10701. *
  10702. * var initialize = _.once(createApplication);
  10703. * initialize();
  10704. * initialize();
  10705. * // => `createApplication` is invoked once
  10706. */
  10707. function once(func) {
  10708. return before(2, func);
  10709. }
  10710. /**
  10711. * Creates a function that invokes `func` with its arguments transformed.
  10712. *
  10713. * @static
  10714. * @since 4.0.0
  10715. * @memberOf _
  10716. * @category Function
  10717. * @param {Function} func The function to wrap.
  10718. * @param {...(Function|Function[])} [transforms=[_.identity]]
  10719. * The argument transforms.
  10720. * @returns {Function} Returns the new function.
  10721. * @example
  10722. *
  10723. * function doubled(n) {
  10724. * return n * 2;
  10725. * }
  10726. *
  10727. * function square(n) {
  10728. * return n * n;
  10729. * }
  10730. *
  10731. * var func = _.overArgs(function(x, y) {
  10732. * return [x, y];
  10733. * }, [square, doubled]);
  10734. *
  10735. * func(9, 3);
  10736. * // => [81, 6]
  10737. *
  10738. * func(10, 5);
  10739. * // => [100, 10]
  10740. */
  10741. var overArgs = castRest(function(func, transforms) {
  10742. transforms = (transforms.length == 1 && isArray(transforms[0]))
  10743. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  10744. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  10745. var funcsLength = transforms.length;
  10746. return baseRest(function(args) {
  10747. var index = -1,
  10748. length = nativeMin(args.length, funcsLength);
  10749. while (++index < length) {
  10750. args[index] = transforms[index].call(this, args[index]);
  10751. }
  10752. return apply(func, this, args);
  10753. });
  10754. });
  10755. /**
  10756. * Creates a function that invokes `func` with `partials` prepended to the
  10757. * arguments it receives. This method is like `_.bind` except it does **not**
  10758. * alter the `this` binding.
  10759. *
  10760. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  10761. * builds, may be used as a placeholder for partially applied arguments.
  10762. *
  10763. * **Note:** This method doesn't set the "length" property of partially
  10764. * applied functions.
  10765. *
  10766. * @static
  10767. * @memberOf _
  10768. * @since 0.2.0
  10769. * @category Function
  10770. * @param {Function} func The function to partially apply arguments to.
  10771. * @param {...*} [partials] The arguments to be partially applied.
  10772. * @returns {Function} Returns the new partially applied function.
  10773. * @example
  10774. *
  10775. * function greet(greeting, name) {
  10776. * return greeting + ' ' + name;
  10777. * }
  10778. *
  10779. * var sayHelloTo = _.partial(greet, 'hello');
  10780. * sayHelloTo('fred');
  10781. * // => 'hello fred'
  10782. *
  10783. * // Partially applied with placeholders.
  10784. * var greetFred = _.partial(greet, _, 'fred');
  10785. * greetFred('hi');
  10786. * // => 'hi fred'
  10787. */
  10788. var partial = baseRest(function(func, partials) {
  10789. var holders = replaceHolders(partials, getHolder(partial));
  10790. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  10791. });
  10792. /**
  10793. * This method is like `_.partial` except that partially applied arguments
  10794. * are appended to the arguments it receives.
  10795. *
  10796. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  10797. * builds, may be used as a placeholder for partially applied arguments.
  10798. *
  10799. * **Note:** This method doesn't set the "length" property of partially
  10800. * applied functions.
  10801. *
  10802. * @static
  10803. * @memberOf _
  10804. * @since 1.0.0
  10805. * @category Function
  10806. * @param {Function} func The function to partially apply arguments to.
  10807. * @param {...*} [partials] The arguments to be partially applied.
  10808. * @returns {Function} Returns the new partially applied function.
  10809. * @example
  10810. *
  10811. * function greet(greeting, name) {
  10812. * return greeting + ' ' + name;
  10813. * }
  10814. *
  10815. * var greetFred = _.partialRight(greet, 'fred');
  10816. * greetFred('hi');
  10817. * // => 'hi fred'
  10818. *
  10819. * // Partially applied with placeholders.
  10820. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  10821. * sayHelloTo('fred');
  10822. * // => 'hello fred'
  10823. */
  10824. var partialRight = baseRest(function(func, partials) {
  10825. var holders = replaceHolders(partials, getHolder(partialRight));
  10826. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  10827. });
  10828. /**
  10829. * Creates a function that invokes `func` with arguments arranged according
  10830. * to the specified `indexes` where the argument value at the first index is
  10831. * provided as the first argument, the argument value at the second index is
  10832. * provided as the second argument, and so on.
  10833. *
  10834. * @static
  10835. * @memberOf _
  10836. * @since 3.0.0
  10837. * @category Function
  10838. * @param {Function} func The function to rearrange arguments for.
  10839. * @param {...(number|number[])} indexes The arranged argument indexes.
  10840. * @returns {Function} Returns the new function.
  10841. * @example
  10842. *
  10843. * var rearged = _.rearg(function(a, b, c) {
  10844. * return [a, b, c];
  10845. * }, [2, 0, 1]);
  10846. *
  10847. * rearged('b', 'c', 'a')
  10848. * // => ['a', 'b', 'c']
  10849. */
  10850. var rearg = flatRest(function(func, indexes) {
  10851. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  10852. });
  10853. /**
  10854. * Creates a function that invokes `func` with the `this` binding of the
  10855. * created function and arguments from `start` and beyond provided as
  10856. * an array.
  10857. *
  10858. * **Note:** This method is based on the
  10859. * [rest parameter](https://mdn.io/rest_parameters).
  10860. *
  10861. * @static
  10862. * @memberOf _
  10863. * @since 4.0.0
  10864. * @category Function
  10865. * @param {Function} func The function to apply a rest parameter to.
  10866. * @param {number} [start=func.length-1] The start position of the rest parameter.
  10867. * @returns {Function} Returns the new function.
  10868. * @example
  10869. *
  10870. * var say = _.rest(function(what, names) {
  10871. * return what + ' ' + _.initial(names).join(', ') +
  10872. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  10873. * });
  10874. *
  10875. * say('hello', 'fred', 'barney', 'pebbles');
  10876. * // => 'hello fred, barney, & pebbles'
  10877. */
  10878. function rest(func, start) {
  10879. if (typeof func != 'function') {
  10880. throw new TypeError(FUNC_ERROR_TEXT);
  10881. }
  10882. start = start === undefined ? start : toInteger(start);
  10883. return baseRest(func, start);
  10884. }
  10885. /**
  10886. * Creates a function that invokes `func` with the `this` binding of the
  10887. * create function and an array of arguments much like
  10888. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  10889. *
  10890. * **Note:** This method is based on the
  10891. * [spread operator](https://mdn.io/spread_operator).
  10892. *
  10893. * @static
  10894. * @memberOf _
  10895. * @since 3.2.0
  10896. * @category Function
  10897. * @param {Function} func The function to spread arguments over.
  10898. * @param {number} [start=0] The start position of the spread.
  10899. * @returns {Function} Returns the new function.
  10900. * @example
  10901. *
  10902. * var say = _.spread(function(who, what) {
  10903. * return who + ' says ' + what;
  10904. * });
  10905. *
  10906. * say(['fred', 'hello']);
  10907. * // => 'fred says hello'
  10908. *
  10909. * var numbers = Promise.all([
  10910. * Promise.resolve(40),
  10911. * Promise.resolve(36)
  10912. * ]);
  10913. *
  10914. * numbers.then(_.spread(function(x, y) {
  10915. * return x + y;
  10916. * }));
  10917. * // => a Promise of 76
  10918. */
  10919. function spread(func, start) {
  10920. if (typeof func != 'function') {
  10921. throw new TypeError(FUNC_ERROR_TEXT);
  10922. }
  10923. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  10924. return baseRest(function(args) {
  10925. var array = args[start],
  10926. otherArgs = castSlice(args, 0, start);
  10927. if (array) {
  10928. arrayPush(otherArgs, array);
  10929. }
  10930. return apply(func, this, otherArgs);
  10931. });
  10932. }
  10933. /**
  10934. * Creates a throttled function that only invokes `func` at most once per
  10935. * every `wait` milliseconds. The throttled function comes with a `cancel`
  10936. * method to cancel delayed `func` invocations and a `flush` method to
  10937. * immediately invoke them. Provide `options` to indicate whether `func`
  10938. * should be invoked on the leading and/or trailing edge of the `wait`
  10939. * timeout. The `func` is invoked with the last arguments provided to the
  10940. * throttled function. Subsequent calls to the throttled function return the
  10941. * result of the last `func` invocation.
  10942. *
  10943. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  10944. * invoked on the trailing edge of the timeout only if the throttled function
  10945. * is invoked more than once during the `wait` timeout.
  10946. *
  10947. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  10948. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  10949. *
  10950. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  10951. * for details over the differences between `_.throttle` and `_.debounce`.
  10952. *
  10953. * @static
  10954. * @memberOf _
  10955. * @since 0.1.0
  10956. * @category Function
  10957. * @param {Function} func The function to throttle.
  10958. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  10959. * @param {Object} [options={}] The options object.
  10960. * @param {boolean} [options.leading=true]
  10961. * Specify invoking on the leading edge of the timeout.
  10962. * @param {boolean} [options.trailing=true]
  10963. * Specify invoking on the trailing edge of the timeout.
  10964. * @returns {Function} Returns the new throttled function.
  10965. * @example
  10966. *
  10967. * // Avoid excessively updating the position while scrolling.
  10968. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  10969. *
  10970. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  10971. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  10972. * jQuery(element).on('click', throttled);
  10973. *
  10974. * // Cancel the trailing throttled invocation.
  10975. * jQuery(window).on('popstate', throttled.cancel);
  10976. */
  10977. function throttle(func, wait, options) {
  10978. var leading = true,
  10979. trailing = true;
  10980. if (typeof func != 'function') {
  10981. throw new TypeError(FUNC_ERROR_TEXT);
  10982. }
  10983. if (isObject(options)) {
  10984. leading = 'leading' in options ? !!options.leading : leading;
  10985. trailing = 'trailing' in options ? !!options.trailing : trailing;
  10986. }
  10987. return debounce(func, wait, {
  10988. 'leading': leading,
  10989. 'maxWait': wait,
  10990. 'trailing': trailing
  10991. });
  10992. }
  10993. /**
  10994. * Creates a function that accepts up to one argument, ignoring any
  10995. * additional arguments.
  10996. *
  10997. * @static
  10998. * @memberOf _
  10999. * @since 4.0.0
  11000. * @category Function
  11001. * @param {Function} func The function to cap arguments for.
  11002. * @returns {Function} Returns the new capped function.
  11003. * @example
  11004. *
  11005. * _.map(['6', '8', '10'], _.unary(parseInt));
  11006. * // => [6, 8, 10]
  11007. */
  11008. function unary(func) {
  11009. return ary(func, 1);
  11010. }
  11011. /**
  11012. * Creates a function that provides `value` to `wrapper` as its first
  11013. * argument. Any additional arguments provided to the function are appended
  11014. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  11015. * binding of the created function.
  11016. *
  11017. * @static
  11018. * @memberOf _
  11019. * @since 0.1.0
  11020. * @category Function
  11021. * @param {*} value The value to wrap.
  11022. * @param {Function} [wrapper=identity] The wrapper function.
  11023. * @returns {Function} Returns the new function.
  11024. * @example
  11025. *
  11026. * var p = _.wrap(_.escape, function(func, text) {
  11027. * return '<p>' + func(text) + '</p>';
  11028. * });
  11029. *
  11030. * p('fred, barney, & pebbles');
  11031. * // => '<p>fred, barney, &amp; pebbles</p>'
  11032. */
  11033. function wrap(value, wrapper) {
  11034. return partial(castFunction(wrapper), value);
  11035. }
  11036. /*------------------------------------------------------------------------*/
  11037. /**
  11038. * Casts `value` as an array if it's not one.
  11039. *
  11040. * @static
  11041. * @memberOf _
  11042. * @since 4.4.0
  11043. * @category Lang
  11044. * @param {*} value The value to inspect.
  11045. * @returns {Array} Returns the cast array.
  11046. * @example
  11047. *
  11048. * _.castArray(1);
  11049. * // => [1]
  11050. *
  11051. * _.castArray({ 'a': 1 });
  11052. * // => [{ 'a': 1 }]
  11053. *
  11054. * _.castArray('abc');
  11055. * // => ['abc']
  11056. *
  11057. * _.castArray(null);
  11058. * // => [null]
  11059. *
  11060. * _.castArray(undefined);
  11061. * // => [undefined]
  11062. *
  11063. * _.castArray();
  11064. * // => []
  11065. *
  11066. * var array = [1, 2, 3];
  11067. * console.log(_.castArray(array) === array);
  11068. * // => true
  11069. */
  11070. function castArray() {
  11071. if (!arguments.length) {
  11072. return [];
  11073. }
  11074. var value = arguments[0];
  11075. return isArray(value) ? value : [value];
  11076. }
  11077. /**
  11078. * Creates a shallow clone of `value`.
  11079. *
  11080. * **Note:** This method is loosely based on the
  11081. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  11082. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  11083. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  11084. * arrays. The own enumerable properties of `arguments` objects are cloned
  11085. * as plain objects. An empty object is returned for uncloneable values such
  11086. * as error objects, functions, DOM nodes, and WeakMaps.
  11087. *
  11088. * @static
  11089. * @memberOf _
  11090. * @since 0.1.0
  11091. * @category Lang
  11092. * @param {*} value The value to clone.
  11093. * @returns {*} Returns the cloned value.
  11094. * @see _.cloneDeep
  11095. * @example
  11096. *
  11097. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11098. *
  11099. * var shallow = _.clone(objects);
  11100. * console.log(shallow[0] === objects[0]);
  11101. * // => true
  11102. */
  11103. function clone(value) {
  11104. return baseClone(value, CLONE_SYMBOLS_FLAG);
  11105. }
  11106. /**
  11107. * This method is like `_.clone` except that it accepts `customizer` which
  11108. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  11109. * cloning is handled by the method instead. The `customizer` is invoked with
  11110. * up to four arguments; (value [, index|key, object, stack]).
  11111. *
  11112. * @static
  11113. * @memberOf _
  11114. * @since 4.0.0
  11115. * @category Lang
  11116. * @param {*} value The value to clone.
  11117. * @param {Function} [customizer] The function to customize cloning.
  11118. * @returns {*} Returns the cloned value.
  11119. * @see _.cloneDeepWith
  11120. * @example
  11121. *
  11122. * function customizer(value) {
  11123. * if (_.isElement(value)) {
  11124. * return value.cloneNode(false);
  11125. * }
  11126. * }
  11127. *
  11128. * var el = _.cloneWith(document.body, customizer);
  11129. *
  11130. * console.log(el === document.body);
  11131. * // => false
  11132. * console.log(el.nodeName);
  11133. * // => 'BODY'
  11134. * console.log(el.childNodes.length);
  11135. * // => 0
  11136. */
  11137. function cloneWith(value, customizer) {
  11138. customizer = typeof customizer == 'function' ? customizer : undefined;
  11139. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  11140. }
  11141. /**
  11142. * This method is like `_.clone` except that it recursively clones `value`.
  11143. *
  11144. * @static
  11145. * @memberOf _
  11146. * @since 1.0.0
  11147. * @category Lang
  11148. * @param {*} value The value to recursively clone.
  11149. * @returns {*} Returns the deep cloned value.
  11150. * @see _.clone
  11151. * @example
  11152. *
  11153. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11154. *
  11155. * var deep = _.cloneDeep(objects);
  11156. * console.log(deep[0] === objects[0]);
  11157. * // => false
  11158. */
  11159. function cloneDeep(value) {
  11160. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  11161. }
  11162. /**
  11163. * This method is like `_.cloneWith` except that it recursively clones `value`.
  11164. *
  11165. * @static
  11166. * @memberOf _
  11167. * @since 4.0.0
  11168. * @category Lang
  11169. * @param {*} value The value to recursively clone.
  11170. * @param {Function} [customizer] The function to customize cloning.
  11171. * @returns {*} Returns the deep cloned value.
  11172. * @see _.cloneWith
  11173. * @example
  11174. *
  11175. * function customizer(value) {
  11176. * if (_.isElement(value)) {
  11177. * return value.cloneNode(true);
  11178. * }
  11179. * }
  11180. *
  11181. * var el = _.cloneDeepWith(document.body, customizer);
  11182. *
  11183. * console.log(el === document.body);
  11184. * // => false
  11185. * console.log(el.nodeName);
  11186. * // => 'BODY'
  11187. * console.log(el.childNodes.length);
  11188. * // => 20
  11189. */
  11190. function cloneDeepWith(value, customizer) {
  11191. customizer = typeof customizer == 'function' ? customizer : undefined;
  11192. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  11193. }
  11194. /**
  11195. * Checks if `object` conforms to `source` by invoking the predicate
  11196. * properties of `source` with the corresponding property values of `object`.
  11197. *
  11198. * **Note:** This method is equivalent to `_.conforms` when `source` is
  11199. * partially applied.
  11200. *
  11201. * @static
  11202. * @memberOf _
  11203. * @since 4.14.0
  11204. * @category Lang
  11205. * @param {Object} object The object to inspect.
  11206. * @param {Object} source The object of property predicates to conform to.
  11207. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  11208. * @example
  11209. *
  11210. * var object = { 'a': 1, 'b': 2 };
  11211. *
  11212. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  11213. * // => true
  11214. *
  11215. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  11216. * // => false
  11217. */
  11218. function conformsTo(object, source) {
  11219. return source == null || baseConformsTo(object, source, keys(source));
  11220. }
  11221. /**
  11222. * Performs a
  11223. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11224. * comparison between two values to determine if they are equivalent.
  11225. *
  11226. * @static
  11227. * @memberOf _
  11228. * @since 4.0.0
  11229. * @category Lang
  11230. * @param {*} value The value to compare.
  11231. * @param {*} other The other value to compare.
  11232. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11233. * @example
  11234. *
  11235. * var object = { 'a': 1 };
  11236. * var other = { 'a': 1 };
  11237. *
  11238. * _.eq(object, object);
  11239. * // => true
  11240. *
  11241. * _.eq(object, other);
  11242. * // => false
  11243. *
  11244. * _.eq('a', 'a');
  11245. * // => true
  11246. *
  11247. * _.eq('a', Object('a'));
  11248. * // => false
  11249. *
  11250. * _.eq(NaN, NaN);
  11251. * // => true
  11252. */
  11253. function eq(value, other) {
  11254. return value === other || (value !== value && other !== other);
  11255. }
  11256. /**
  11257. * Checks if `value` is greater than `other`.
  11258. *
  11259. * @static
  11260. * @memberOf _
  11261. * @since 3.9.0
  11262. * @category Lang
  11263. * @param {*} value The value to compare.
  11264. * @param {*} other The other value to compare.
  11265. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  11266. * else `false`.
  11267. * @see _.lt
  11268. * @example
  11269. *
  11270. * _.gt(3, 1);
  11271. * // => true
  11272. *
  11273. * _.gt(3, 3);
  11274. * // => false
  11275. *
  11276. * _.gt(1, 3);
  11277. * // => false
  11278. */
  11279. var gt = createRelationalOperation(baseGt);
  11280. /**
  11281. * Checks if `value` is greater than or equal to `other`.
  11282. *
  11283. * @static
  11284. * @memberOf _
  11285. * @since 3.9.0
  11286. * @category Lang
  11287. * @param {*} value The value to compare.
  11288. * @param {*} other The other value to compare.
  11289. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  11290. * `other`, else `false`.
  11291. * @see _.lte
  11292. * @example
  11293. *
  11294. * _.gte(3, 1);
  11295. * // => true
  11296. *
  11297. * _.gte(3, 3);
  11298. * // => true
  11299. *
  11300. * _.gte(1, 3);
  11301. * // => false
  11302. */
  11303. var gte = createRelationalOperation(function(value, other) {
  11304. return value >= other;
  11305. });
  11306. /**
  11307. * Checks if `value` is likely an `arguments` object.
  11308. *
  11309. * @static
  11310. * @memberOf _
  11311. * @since 0.1.0
  11312. * @category Lang
  11313. * @param {*} value The value to check.
  11314. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  11315. * else `false`.
  11316. * @example
  11317. *
  11318. * _.isArguments(function() { return arguments; }());
  11319. * // => true
  11320. *
  11321. * _.isArguments([1, 2, 3]);
  11322. * // => false
  11323. */
  11324. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  11325. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  11326. !propertyIsEnumerable.call(value, 'callee');
  11327. };
  11328. /**
  11329. * Checks if `value` is classified as an `Array` object.
  11330. *
  11331. * @static
  11332. * @memberOf _
  11333. * @since 0.1.0
  11334. * @category Lang
  11335. * @param {*} value The value to check.
  11336. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  11337. * @example
  11338. *
  11339. * _.isArray([1, 2, 3]);
  11340. * // => true
  11341. *
  11342. * _.isArray(document.body.children);
  11343. * // => false
  11344. *
  11345. * _.isArray('abc');
  11346. * // => false
  11347. *
  11348. * _.isArray(_.noop);
  11349. * // => false
  11350. */
  11351. var isArray = Array.isArray;
  11352. /**
  11353. * Checks if `value` is classified as an `ArrayBuffer` object.
  11354. *
  11355. * @static
  11356. * @memberOf _
  11357. * @since 4.3.0
  11358. * @category Lang
  11359. * @param {*} value The value to check.
  11360. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  11361. * @example
  11362. *
  11363. * _.isArrayBuffer(new ArrayBuffer(2));
  11364. * // => true
  11365. *
  11366. * _.isArrayBuffer(new Array(2));
  11367. * // => false
  11368. */
  11369. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  11370. /**
  11371. * Checks if `value` is array-like. A value is considered array-like if it's
  11372. * not a function and has a `value.length` that's an integer greater than or
  11373. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  11374. *
  11375. * @static
  11376. * @memberOf _
  11377. * @since 4.0.0
  11378. * @category Lang
  11379. * @param {*} value The value to check.
  11380. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  11381. * @example
  11382. *
  11383. * _.isArrayLike([1, 2, 3]);
  11384. * // => true
  11385. *
  11386. * _.isArrayLike(document.body.children);
  11387. * // => true
  11388. *
  11389. * _.isArrayLike('abc');
  11390. * // => true
  11391. *
  11392. * _.isArrayLike(_.noop);
  11393. * // => false
  11394. */
  11395. function isArrayLike(value) {
  11396. return value != null && isLength(value.length) && !isFunction(value);
  11397. }
  11398. /**
  11399. * This method is like `_.isArrayLike` except that it also checks if `value`
  11400. * is an object.
  11401. *
  11402. * @static
  11403. * @memberOf _
  11404. * @since 4.0.0
  11405. * @category Lang
  11406. * @param {*} value The value to check.
  11407. * @returns {boolean} Returns `true` if `value` is an array-like object,
  11408. * else `false`.
  11409. * @example
  11410. *
  11411. * _.isArrayLikeObject([1, 2, 3]);
  11412. * // => true
  11413. *
  11414. * _.isArrayLikeObject(document.body.children);
  11415. * // => true
  11416. *
  11417. * _.isArrayLikeObject('abc');
  11418. * // => false
  11419. *
  11420. * _.isArrayLikeObject(_.noop);
  11421. * // => false
  11422. */
  11423. function isArrayLikeObject(value) {
  11424. return isObjectLike(value) && isArrayLike(value);
  11425. }
  11426. /**
  11427. * Checks if `value` is classified as a boolean primitive or object.
  11428. *
  11429. * @static
  11430. * @memberOf _
  11431. * @since 0.1.0
  11432. * @category Lang
  11433. * @param {*} value The value to check.
  11434. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  11435. * @example
  11436. *
  11437. * _.isBoolean(false);
  11438. * // => true
  11439. *
  11440. * _.isBoolean(null);
  11441. * // => false
  11442. */
  11443. function isBoolean(value) {
  11444. return value === true || value === false ||
  11445. (isObjectLike(value) && baseGetTag(value) == boolTag);
  11446. }
  11447. /**
  11448. * Checks if `value` is a buffer.
  11449. *
  11450. * @static
  11451. * @memberOf _
  11452. * @since 4.3.0
  11453. * @category Lang
  11454. * @param {*} value The value to check.
  11455. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  11456. * @example
  11457. *
  11458. * _.isBuffer(new Buffer(2));
  11459. * // => true
  11460. *
  11461. * _.isBuffer(new Uint8Array(2));
  11462. * // => false
  11463. */
  11464. var isBuffer = nativeIsBuffer || stubFalse;
  11465. /**
  11466. * Checks if `value` is classified as a `Date` object.
  11467. *
  11468. * @static
  11469. * @memberOf _
  11470. * @since 0.1.0
  11471. * @category Lang
  11472. * @param {*} value The value to check.
  11473. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  11474. * @example
  11475. *
  11476. * _.isDate(new Date);
  11477. * // => true
  11478. *
  11479. * _.isDate('Mon April 23 2012');
  11480. * // => false
  11481. */
  11482. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  11483. /**
  11484. * Checks if `value` is likely a DOM element.
  11485. *
  11486. * @static
  11487. * @memberOf _
  11488. * @since 0.1.0
  11489. * @category Lang
  11490. * @param {*} value The value to check.
  11491. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  11492. * @example
  11493. *
  11494. * _.isElement(document.body);
  11495. * // => true
  11496. *
  11497. * _.isElement('<body>');
  11498. * // => false
  11499. */
  11500. function isElement(value) {
  11501. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  11502. }
  11503. /**
  11504. * Checks if `value` is an empty object, collection, map, or set.
  11505. *
  11506. * Objects are considered empty if they have no own enumerable string keyed
  11507. * properties.
  11508. *
  11509. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  11510. * jQuery-like collections are considered empty if they have a `length` of `0`.
  11511. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  11512. *
  11513. * @static
  11514. * @memberOf _
  11515. * @since 0.1.0
  11516. * @category Lang
  11517. * @param {*} value The value to check.
  11518. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  11519. * @example
  11520. *
  11521. * _.isEmpty(null);
  11522. * // => true
  11523. *
  11524. * _.isEmpty(true);
  11525. * // => true
  11526. *
  11527. * _.isEmpty(1);
  11528. * // => true
  11529. *
  11530. * _.isEmpty([1, 2, 3]);
  11531. * // => false
  11532. *
  11533. * _.isEmpty({ 'a': 1 });
  11534. * // => false
  11535. */
  11536. function isEmpty(value) {
  11537. if (value == null) {
  11538. return true;
  11539. }
  11540. if (isArrayLike(value) &&
  11541. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  11542. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  11543. return !value.length;
  11544. }
  11545. var tag = getTag(value);
  11546. if (tag == mapTag || tag == setTag) {
  11547. return !value.size;
  11548. }
  11549. if (isPrototype(value)) {
  11550. return !baseKeys(value).length;
  11551. }
  11552. for (var key in value) {
  11553. if (hasOwnProperty.call(value, key)) {
  11554. return false;
  11555. }
  11556. }
  11557. return true;
  11558. }
  11559. /**
  11560. * Performs a deep comparison between two values to determine if they are
  11561. * equivalent.
  11562. *
  11563. * **Note:** This method supports comparing arrays, array buffers, booleans,
  11564. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  11565. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  11566. * by their own, not inherited, enumerable properties. Functions and DOM
  11567. * nodes are compared by strict equality, i.e. `===`.
  11568. *
  11569. * @static
  11570. * @memberOf _
  11571. * @since 0.1.0
  11572. * @category Lang
  11573. * @param {*} value The value to compare.
  11574. * @param {*} other The other value to compare.
  11575. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11576. * @example
  11577. *
  11578. * var object = { 'a': 1 };
  11579. * var other = { 'a': 1 };
  11580. *
  11581. * _.isEqual(object, other);
  11582. * // => true
  11583. *
  11584. * object === other;
  11585. * // => false
  11586. */
  11587. function isEqual(value, other) {
  11588. return baseIsEqual(value, other);
  11589. }
  11590. /**
  11591. * This method is like `_.isEqual` except that it accepts `customizer` which
  11592. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  11593. * are handled by the method instead. The `customizer` is invoked with up to
  11594. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  11595. *
  11596. * @static
  11597. * @memberOf _
  11598. * @since 4.0.0
  11599. * @category Lang
  11600. * @param {*} value The value to compare.
  11601. * @param {*} other The other value to compare.
  11602. * @param {Function} [customizer] The function to customize comparisons.
  11603. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11604. * @example
  11605. *
  11606. * function isGreeting(value) {
  11607. * return /^h(?:i|ello)$/.test(value);
  11608. * }
  11609. *
  11610. * function customizer(objValue, othValue) {
  11611. * if (isGreeting(objValue) && isGreeting(othValue)) {
  11612. * return true;
  11613. * }
  11614. * }
  11615. *
  11616. * var array = ['hello', 'goodbye'];
  11617. * var other = ['hi', 'goodbye'];
  11618. *
  11619. * _.isEqualWith(array, other, customizer);
  11620. * // => true
  11621. */
  11622. function isEqualWith(value, other, customizer) {
  11623. customizer = typeof customizer == 'function' ? customizer : undefined;
  11624. var result = customizer ? customizer(value, other) : undefined;
  11625. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  11626. }
  11627. /**
  11628. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  11629. * `SyntaxError`, `TypeError`, or `URIError` object.
  11630. *
  11631. * @static
  11632. * @memberOf _
  11633. * @since 3.0.0
  11634. * @category Lang
  11635. * @param {*} value The value to check.
  11636. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  11637. * @example
  11638. *
  11639. * _.isError(new Error);
  11640. * // => true
  11641. *
  11642. * _.isError(Error);
  11643. * // => false
  11644. */
  11645. function isError(value) {
  11646. if (!isObjectLike(value)) {
  11647. return false;
  11648. }
  11649. var tag = baseGetTag(value);
  11650. return tag == errorTag || tag == domExcTag ||
  11651. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  11652. }
  11653. /**
  11654. * Checks if `value` is a finite primitive number.
  11655. *
  11656. * **Note:** This method is based on
  11657. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  11658. *
  11659. * @static
  11660. * @memberOf _
  11661. * @since 0.1.0
  11662. * @category Lang
  11663. * @param {*} value The value to check.
  11664. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  11665. * @example
  11666. *
  11667. * _.isFinite(3);
  11668. * // => true
  11669. *
  11670. * _.isFinite(Number.MIN_VALUE);
  11671. * // => true
  11672. *
  11673. * _.isFinite(Infinity);
  11674. * // => false
  11675. *
  11676. * _.isFinite('3');
  11677. * // => false
  11678. */
  11679. function isFinite(value) {
  11680. return typeof value == 'number' && nativeIsFinite(value);
  11681. }
  11682. /**
  11683. * Checks if `value` is classified as a `Function` object.
  11684. *
  11685. * @static
  11686. * @memberOf _
  11687. * @since 0.1.0
  11688. * @category Lang
  11689. * @param {*} value The value to check.
  11690. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  11691. * @example
  11692. *
  11693. * _.isFunction(_);
  11694. * // => true
  11695. *
  11696. * _.isFunction(/abc/);
  11697. * // => false
  11698. */
  11699. function isFunction(value) {
  11700. if (!isObject(value)) {
  11701. return false;
  11702. }
  11703. // The use of `Object#toString` avoids issues with the `typeof` operator
  11704. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  11705. var tag = baseGetTag(value);
  11706. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  11707. }
  11708. /**
  11709. * Checks if `value` is an integer.
  11710. *
  11711. * **Note:** This method is based on
  11712. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  11713. *
  11714. * @static
  11715. * @memberOf _
  11716. * @since 4.0.0
  11717. * @category Lang
  11718. * @param {*} value The value to check.
  11719. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  11720. * @example
  11721. *
  11722. * _.isInteger(3);
  11723. * // => true
  11724. *
  11725. * _.isInteger(Number.MIN_VALUE);
  11726. * // => false
  11727. *
  11728. * _.isInteger(Infinity);
  11729. * // => false
  11730. *
  11731. * _.isInteger('3');
  11732. * // => false
  11733. */
  11734. function isInteger(value) {
  11735. return typeof value == 'number' && value == toInteger(value);
  11736. }
  11737. /**
  11738. * Checks if `value` is a valid array-like length.
  11739. *
  11740. * **Note:** This method is loosely based on
  11741. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  11742. *
  11743. * @static
  11744. * @memberOf _
  11745. * @since 4.0.0
  11746. * @category Lang
  11747. * @param {*} value The value to check.
  11748. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  11749. * @example
  11750. *
  11751. * _.isLength(3);
  11752. * // => true
  11753. *
  11754. * _.isLength(Number.MIN_VALUE);
  11755. * // => false
  11756. *
  11757. * _.isLength(Infinity);
  11758. * // => false
  11759. *
  11760. * _.isLength('3');
  11761. * // => false
  11762. */
  11763. function isLength(value) {
  11764. return typeof value == 'number' &&
  11765. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  11766. }
  11767. /**
  11768. * Checks if `value` is the
  11769. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  11770. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  11771. *
  11772. * @static
  11773. * @memberOf _
  11774. * @since 0.1.0
  11775. * @category Lang
  11776. * @param {*} value The value to check.
  11777. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  11778. * @example
  11779. *
  11780. * _.isObject({});
  11781. * // => true
  11782. *
  11783. * _.isObject([1, 2, 3]);
  11784. * // => true
  11785. *
  11786. * _.isObject(_.noop);
  11787. * // => true
  11788. *
  11789. * _.isObject(null);
  11790. * // => false
  11791. */
  11792. function isObject(value) {
  11793. var type = typeof value;
  11794. return value != null && (type == 'object' || type == 'function');
  11795. }
  11796. /**
  11797. * Checks if `value` is object-like. A value is object-like if it's not `null`
  11798. * and has a `typeof` result of "object".
  11799. *
  11800. * @static
  11801. * @memberOf _
  11802. * @since 4.0.0
  11803. * @category Lang
  11804. * @param {*} value The value to check.
  11805. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  11806. * @example
  11807. *
  11808. * _.isObjectLike({});
  11809. * // => true
  11810. *
  11811. * _.isObjectLike([1, 2, 3]);
  11812. * // => true
  11813. *
  11814. * _.isObjectLike(_.noop);
  11815. * // => false
  11816. *
  11817. * _.isObjectLike(null);
  11818. * // => false
  11819. */
  11820. function isObjectLike(value) {
  11821. return value != null && typeof value == 'object';
  11822. }
  11823. /**
  11824. * Checks if `value` is classified as a `Map` object.
  11825. *
  11826. * @static
  11827. * @memberOf _
  11828. * @since 4.3.0
  11829. * @category Lang
  11830. * @param {*} value The value to check.
  11831. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11832. * @example
  11833. *
  11834. * _.isMap(new Map);
  11835. * // => true
  11836. *
  11837. * _.isMap(new WeakMap);
  11838. * // => false
  11839. */
  11840. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  11841. /**
  11842. * Performs a partial deep comparison between `object` and `source` to
  11843. * determine if `object` contains equivalent property values.
  11844. *
  11845. * **Note:** This method is equivalent to `_.matches` when `source` is
  11846. * partially applied.
  11847. *
  11848. * Partial comparisons will match empty array and empty object `source`
  11849. * values against any array or object value, respectively. See `_.isEqual`
  11850. * for a list of supported value comparisons.
  11851. *
  11852. * @static
  11853. * @memberOf _
  11854. * @since 3.0.0
  11855. * @category Lang
  11856. * @param {Object} object The object to inspect.
  11857. * @param {Object} source The object of property values to match.
  11858. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  11859. * @example
  11860. *
  11861. * var object = { 'a': 1, 'b': 2 };
  11862. *
  11863. * _.isMatch(object, { 'b': 2 });
  11864. * // => true
  11865. *
  11866. * _.isMatch(object, { 'b': 1 });
  11867. * // => false
  11868. */
  11869. function isMatch(object, source) {
  11870. return object === source || baseIsMatch(object, source, getMatchData(source));
  11871. }
  11872. /**
  11873. * This method is like `_.isMatch` except that it accepts `customizer` which
  11874. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  11875. * are handled by the method instead. The `customizer` is invoked with five
  11876. * arguments: (objValue, srcValue, index|key, object, source).
  11877. *
  11878. * @static
  11879. * @memberOf _
  11880. * @since 4.0.0
  11881. * @category Lang
  11882. * @param {Object} object The object to inspect.
  11883. * @param {Object} source The object of property values to match.
  11884. * @param {Function} [customizer] The function to customize comparisons.
  11885. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  11886. * @example
  11887. *
  11888. * function isGreeting(value) {
  11889. * return /^h(?:i|ello)$/.test(value);
  11890. * }
  11891. *
  11892. * function customizer(objValue, srcValue) {
  11893. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  11894. * return true;
  11895. * }
  11896. * }
  11897. *
  11898. * var object = { 'greeting': 'hello' };
  11899. * var source = { 'greeting': 'hi' };
  11900. *
  11901. * _.isMatchWith(object, source, customizer);
  11902. * // => true
  11903. */
  11904. function isMatchWith(object, source, customizer) {
  11905. customizer = typeof customizer == 'function' ? customizer : undefined;
  11906. return baseIsMatch(object, source, getMatchData(source), customizer);
  11907. }
  11908. /**
  11909. * Checks if `value` is `NaN`.
  11910. *
  11911. * **Note:** This method is based on
  11912. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  11913. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  11914. * `undefined` and other non-number values.
  11915. *
  11916. * @static
  11917. * @memberOf _
  11918. * @since 0.1.0
  11919. * @category Lang
  11920. * @param {*} value The value to check.
  11921. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  11922. * @example
  11923. *
  11924. * _.isNaN(NaN);
  11925. * // => true
  11926. *
  11927. * _.isNaN(new Number(NaN));
  11928. * // => true
  11929. *
  11930. * isNaN(undefined);
  11931. * // => true
  11932. *
  11933. * _.isNaN(undefined);
  11934. * // => false
  11935. */
  11936. function isNaN(value) {
  11937. // An `NaN` primitive is the only value that is not equal to itself.
  11938. // Perform the `toStringTag` check first to avoid errors with some
  11939. // ActiveX objects in IE.
  11940. return isNumber(value) && value != +value;
  11941. }
  11942. /**
  11943. * Checks if `value` is a pristine native function.
  11944. *
  11945. * **Note:** This method can't reliably detect native functions in the presence
  11946. * of the core-js package because core-js circumvents this kind of detection.
  11947. * Despite multiple requests, the core-js maintainer has made it clear: any
  11948. * attempt to fix the detection will be obstructed. As a result, we're left
  11949. * with little choice but to throw an error. Unfortunately, this also affects
  11950. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  11951. * which rely on core-js.
  11952. *
  11953. * @static
  11954. * @memberOf _
  11955. * @since 3.0.0
  11956. * @category Lang
  11957. * @param {*} value The value to check.
  11958. * @returns {boolean} Returns `true` if `value` is a native function,
  11959. * else `false`.
  11960. * @example
  11961. *
  11962. * _.isNative(Array.prototype.push);
  11963. * // => true
  11964. *
  11965. * _.isNative(_);
  11966. * // => false
  11967. */
  11968. function isNative(value) {
  11969. if (isMaskable(value)) {
  11970. throw new Error(CORE_ERROR_TEXT);
  11971. }
  11972. return baseIsNative(value);
  11973. }
  11974. /**
  11975. * Checks if `value` is `null`.
  11976. *
  11977. * @static
  11978. * @memberOf _
  11979. * @since 0.1.0
  11980. * @category Lang
  11981. * @param {*} value The value to check.
  11982. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  11983. * @example
  11984. *
  11985. * _.isNull(null);
  11986. * // => true
  11987. *
  11988. * _.isNull(void 0);
  11989. * // => false
  11990. */
  11991. function isNull(value) {
  11992. return value === null;
  11993. }
  11994. /**
  11995. * Checks if `value` is `null` or `undefined`.
  11996. *
  11997. * @static
  11998. * @memberOf _
  11999. * @since 4.0.0
  12000. * @category Lang
  12001. * @param {*} value The value to check.
  12002. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  12003. * @example
  12004. *
  12005. * _.isNil(null);
  12006. * // => true
  12007. *
  12008. * _.isNil(void 0);
  12009. * // => true
  12010. *
  12011. * _.isNil(NaN);
  12012. * // => false
  12013. */
  12014. function isNil(value) {
  12015. return value == null;
  12016. }
  12017. /**
  12018. * Checks if `value` is classified as a `Number` primitive or object.
  12019. *
  12020. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  12021. * classified as numbers, use the `_.isFinite` method.
  12022. *
  12023. * @static
  12024. * @memberOf _
  12025. * @since 0.1.0
  12026. * @category Lang
  12027. * @param {*} value The value to check.
  12028. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  12029. * @example
  12030. *
  12031. * _.isNumber(3);
  12032. * // => true
  12033. *
  12034. * _.isNumber(Number.MIN_VALUE);
  12035. * // => true
  12036. *
  12037. * _.isNumber(Infinity);
  12038. * // => true
  12039. *
  12040. * _.isNumber('3');
  12041. * // => false
  12042. */
  12043. function isNumber(value) {
  12044. return typeof value == 'number' ||
  12045. (isObjectLike(value) && baseGetTag(value) == numberTag);
  12046. }
  12047. /**
  12048. * Checks if `value` is a plain object, that is, an object created by the
  12049. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  12050. *
  12051. * @static
  12052. * @memberOf _
  12053. * @since 0.8.0
  12054. * @category Lang
  12055. * @param {*} value The value to check.
  12056. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  12057. * @example
  12058. *
  12059. * function Foo() {
  12060. * this.a = 1;
  12061. * }
  12062. *
  12063. * _.isPlainObject(new Foo);
  12064. * // => false
  12065. *
  12066. * _.isPlainObject([1, 2, 3]);
  12067. * // => false
  12068. *
  12069. * _.isPlainObject({ 'x': 0, 'y': 0 });
  12070. * // => true
  12071. *
  12072. * _.isPlainObject(Object.create(null));
  12073. * // => true
  12074. */
  12075. function isPlainObject(value) {
  12076. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  12077. return false;
  12078. }
  12079. var proto = getPrototype(value);
  12080. if (proto === null) {
  12081. return true;
  12082. }
  12083. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  12084. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  12085. funcToString.call(Ctor) == objectCtorString;
  12086. }
  12087. /**
  12088. * Checks if `value` is classified as a `RegExp` object.
  12089. *
  12090. * @static
  12091. * @memberOf _
  12092. * @since 0.1.0
  12093. * @category Lang
  12094. * @param {*} value The value to check.
  12095. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  12096. * @example
  12097. *
  12098. * _.isRegExp(/abc/);
  12099. * // => true
  12100. *
  12101. * _.isRegExp('/abc/');
  12102. * // => false
  12103. */
  12104. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  12105. /**
  12106. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  12107. * double precision number which isn't the result of a rounded unsafe integer.
  12108. *
  12109. * **Note:** This method is based on
  12110. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  12111. *
  12112. * @static
  12113. * @memberOf _
  12114. * @since 4.0.0
  12115. * @category Lang
  12116. * @param {*} value The value to check.
  12117. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  12118. * @example
  12119. *
  12120. * _.isSafeInteger(3);
  12121. * // => true
  12122. *
  12123. * _.isSafeInteger(Number.MIN_VALUE);
  12124. * // => false
  12125. *
  12126. * _.isSafeInteger(Infinity);
  12127. * // => false
  12128. *
  12129. * _.isSafeInteger('3');
  12130. * // => false
  12131. */
  12132. function isSafeInteger(value) {
  12133. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  12134. }
  12135. /**
  12136. * Checks if `value` is classified as a `Set` object.
  12137. *
  12138. * @static
  12139. * @memberOf _
  12140. * @since 4.3.0
  12141. * @category Lang
  12142. * @param {*} value The value to check.
  12143. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  12144. * @example
  12145. *
  12146. * _.isSet(new Set);
  12147. * // => true
  12148. *
  12149. * _.isSet(new WeakSet);
  12150. * // => false
  12151. */
  12152. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  12153. /**
  12154. * Checks if `value` is classified as a `String` primitive or object.
  12155. *
  12156. * @static
  12157. * @since 0.1.0
  12158. * @memberOf _
  12159. * @category Lang
  12160. * @param {*} value The value to check.
  12161. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  12162. * @example
  12163. *
  12164. * _.isString('abc');
  12165. * // => true
  12166. *
  12167. * _.isString(1);
  12168. * // => false
  12169. */
  12170. function isString(value) {
  12171. return typeof value == 'string' ||
  12172. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  12173. }
  12174. /**
  12175. * Checks if `value` is classified as a `Symbol` primitive or object.
  12176. *
  12177. * @static
  12178. * @memberOf _
  12179. * @since 4.0.0
  12180. * @category Lang
  12181. * @param {*} value The value to check.
  12182. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  12183. * @example
  12184. *
  12185. * _.isSymbol(Symbol.iterator);
  12186. * // => true
  12187. *
  12188. * _.isSymbol('abc');
  12189. * // => false
  12190. */
  12191. function isSymbol(value) {
  12192. return typeof value == 'symbol' ||
  12193. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  12194. }
  12195. /**
  12196. * Checks if `value` is classified as a typed array.
  12197. *
  12198. * @static
  12199. * @memberOf _
  12200. * @since 3.0.0
  12201. * @category Lang
  12202. * @param {*} value The value to check.
  12203. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  12204. * @example
  12205. *
  12206. * _.isTypedArray(new Uint8Array);
  12207. * // => true
  12208. *
  12209. * _.isTypedArray([]);
  12210. * // => false
  12211. */
  12212. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  12213. /**
  12214. * Checks if `value` is `undefined`.
  12215. *
  12216. * @static
  12217. * @since 0.1.0
  12218. * @memberOf _
  12219. * @category Lang
  12220. * @param {*} value The value to check.
  12221. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  12222. * @example
  12223. *
  12224. * _.isUndefined(void 0);
  12225. * // => true
  12226. *
  12227. * _.isUndefined(null);
  12228. * // => false
  12229. */
  12230. function isUndefined(value) {
  12231. return value === undefined;
  12232. }
  12233. /**
  12234. * Checks if `value` is classified as a `WeakMap` object.
  12235. *
  12236. * @static
  12237. * @memberOf _
  12238. * @since 4.3.0
  12239. * @category Lang
  12240. * @param {*} value The value to check.
  12241. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  12242. * @example
  12243. *
  12244. * _.isWeakMap(new WeakMap);
  12245. * // => true
  12246. *
  12247. * _.isWeakMap(new Map);
  12248. * // => false
  12249. */
  12250. function isWeakMap(value) {
  12251. return isObjectLike(value) && getTag(value) == weakMapTag;
  12252. }
  12253. /**
  12254. * Checks if `value` is classified as a `WeakSet` object.
  12255. *
  12256. * @static
  12257. * @memberOf _
  12258. * @since 4.3.0
  12259. * @category Lang
  12260. * @param {*} value The value to check.
  12261. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  12262. * @example
  12263. *
  12264. * _.isWeakSet(new WeakSet);
  12265. * // => true
  12266. *
  12267. * _.isWeakSet(new Set);
  12268. * // => false
  12269. */
  12270. function isWeakSet(value) {
  12271. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  12272. }
  12273. /**
  12274. * Checks if `value` is less than `other`.
  12275. *
  12276. * @static
  12277. * @memberOf _
  12278. * @since 3.9.0
  12279. * @category Lang
  12280. * @param {*} value The value to compare.
  12281. * @param {*} other The other value to compare.
  12282. * @returns {boolean} Returns `true` if `value` is less than `other`,
  12283. * else `false`.
  12284. * @see _.gt
  12285. * @example
  12286. *
  12287. * _.lt(1, 3);
  12288. * // => true
  12289. *
  12290. * _.lt(3, 3);
  12291. * // => false
  12292. *
  12293. * _.lt(3, 1);
  12294. * // => false
  12295. */
  12296. var lt = createRelationalOperation(baseLt);
  12297. /**
  12298. * Checks if `value` is less than or equal to `other`.
  12299. *
  12300. * @static
  12301. * @memberOf _
  12302. * @since 3.9.0
  12303. * @category Lang
  12304. * @param {*} value The value to compare.
  12305. * @param {*} other The other value to compare.
  12306. * @returns {boolean} Returns `true` if `value` is less than or equal to
  12307. * `other`, else `false`.
  12308. * @see _.gte
  12309. * @example
  12310. *
  12311. * _.lte(1, 3);
  12312. * // => true
  12313. *
  12314. * _.lte(3, 3);
  12315. * // => true
  12316. *
  12317. * _.lte(3, 1);
  12318. * // => false
  12319. */
  12320. var lte = createRelationalOperation(function(value, other) {
  12321. return value <= other;
  12322. });
  12323. /**
  12324. * Converts `value` to an array.
  12325. *
  12326. * @static
  12327. * @since 0.1.0
  12328. * @memberOf _
  12329. * @category Lang
  12330. * @param {*} value The value to convert.
  12331. * @returns {Array} Returns the converted array.
  12332. * @example
  12333. *
  12334. * _.toArray({ 'a': 1, 'b': 2 });
  12335. * // => [1, 2]
  12336. *
  12337. * _.toArray('abc');
  12338. * // => ['a', 'b', 'c']
  12339. *
  12340. * _.toArray(1);
  12341. * // => []
  12342. *
  12343. * _.toArray(null);
  12344. * // => []
  12345. */
  12346. function toArray(value) {
  12347. if (!value) {
  12348. return [];
  12349. }
  12350. if (isArrayLike(value)) {
  12351. return isString(value) ? stringToArray(value) : copyArray(value);
  12352. }
  12353. if (symIterator && value[symIterator]) {
  12354. return iteratorToArray(value[symIterator]());
  12355. }
  12356. var tag = getTag(value),
  12357. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  12358. return func(value);
  12359. }
  12360. /**
  12361. * Converts `value` to a finite number.
  12362. *
  12363. * @static
  12364. * @memberOf _
  12365. * @since 4.12.0
  12366. * @category Lang
  12367. * @param {*} value The value to convert.
  12368. * @returns {number} Returns the converted number.
  12369. * @example
  12370. *
  12371. * _.toFinite(3.2);
  12372. * // => 3.2
  12373. *
  12374. * _.toFinite(Number.MIN_VALUE);
  12375. * // => 5e-324
  12376. *
  12377. * _.toFinite(Infinity);
  12378. * // => 1.7976931348623157e+308
  12379. *
  12380. * _.toFinite('3.2');
  12381. * // => 3.2
  12382. */
  12383. function toFinite(value) {
  12384. if (!value) {
  12385. return value === 0 ? value : 0;
  12386. }
  12387. value = toNumber(value);
  12388. if (value === INFINITY || value === -INFINITY) {
  12389. var sign = (value < 0 ? -1 : 1);
  12390. return sign * MAX_INTEGER;
  12391. }
  12392. return value === value ? value : 0;
  12393. }
  12394. /**
  12395. * Converts `value` to an integer.
  12396. *
  12397. * **Note:** This method is loosely based on
  12398. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  12399. *
  12400. * @static
  12401. * @memberOf _
  12402. * @since 4.0.0
  12403. * @category Lang
  12404. * @param {*} value The value to convert.
  12405. * @returns {number} Returns the converted integer.
  12406. * @example
  12407. *
  12408. * _.toInteger(3.2);
  12409. * // => 3
  12410. *
  12411. * _.toInteger(Number.MIN_VALUE);
  12412. * // => 0
  12413. *
  12414. * _.toInteger(Infinity);
  12415. * // => 1.7976931348623157e+308
  12416. *
  12417. * _.toInteger('3.2');
  12418. * // => 3
  12419. */
  12420. function toInteger(value) {
  12421. var result = toFinite(value),
  12422. remainder = result % 1;
  12423. return result === result ? (remainder ? result - remainder : result) : 0;
  12424. }
  12425. /**
  12426. * Converts `value` to an integer suitable for use as the length of an
  12427. * array-like object.
  12428. *
  12429. * **Note:** This method is based on
  12430. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  12431. *
  12432. * @static
  12433. * @memberOf _
  12434. * @since 4.0.0
  12435. * @category Lang
  12436. * @param {*} value The value to convert.
  12437. * @returns {number} Returns the converted integer.
  12438. * @example
  12439. *
  12440. * _.toLength(3.2);
  12441. * // => 3
  12442. *
  12443. * _.toLength(Number.MIN_VALUE);
  12444. * // => 0
  12445. *
  12446. * _.toLength(Infinity);
  12447. * // => 4294967295
  12448. *
  12449. * _.toLength('3.2');
  12450. * // => 3
  12451. */
  12452. function toLength(value) {
  12453. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  12454. }
  12455. /**
  12456. * Converts `value` to a number.
  12457. *
  12458. * @static
  12459. * @memberOf _
  12460. * @since 4.0.0
  12461. * @category Lang
  12462. * @param {*} value The value to process.
  12463. * @returns {number} Returns the number.
  12464. * @example
  12465. *
  12466. * _.toNumber(3.2);
  12467. * // => 3.2
  12468. *
  12469. * _.toNumber(Number.MIN_VALUE);
  12470. * // => 5e-324
  12471. *
  12472. * _.toNumber(Infinity);
  12473. * // => Infinity
  12474. *
  12475. * _.toNumber('3.2');
  12476. * // => 3.2
  12477. */
  12478. function toNumber(value) {
  12479. if (typeof value == 'number') {
  12480. return value;
  12481. }
  12482. if (isSymbol(value)) {
  12483. return NAN;
  12484. }
  12485. if (isObject(value)) {
  12486. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  12487. value = isObject(other) ? (other + '') : other;
  12488. }
  12489. if (typeof value != 'string') {
  12490. return value === 0 ? value : +value;
  12491. }
  12492. value = value.replace(reTrim, '');
  12493. var isBinary = reIsBinary.test(value);
  12494. return (isBinary || reIsOctal.test(value))
  12495. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  12496. : (reIsBadHex.test(value) ? NAN : +value);
  12497. }
  12498. /**
  12499. * Converts `value` to a plain object flattening inherited enumerable string
  12500. * keyed properties of `value` to own properties of the plain object.
  12501. *
  12502. * @static
  12503. * @memberOf _
  12504. * @since 3.0.0
  12505. * @category Lang
  12506. * @param {*} value The value to convert.
  12507. * @returns {Object} Returns the converted plain object.
  12508. * @example
  12509. *
  12510. * function Foo() {
  12511. * this.b = 2;
  12512. * }
  12513. *
  12514. * Foo.prototype.c = 3;
  12515. *
  12516. * _.assign({ 'a': 1 }, new Foo);
  12517. * // => { 'a': 1, 'b': 2 }
  12518. *
  12519. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  12520. * // => { 'a': 1, 'b': 2, 'c': 3 }
  12521. */
  12522. function toPlainObject(value) {
  12523. return copyObject(value, keysIn(value));
  12524. }
  12525. /**
  12526. * Converts `value` to a safe integer. A safe integer can be compared and
  12527. * represented correctly.
  12528. *
  12529. * @static
  12530. * @memberOf _
  12531. * @since 4.0.0
  12532. * @category Lang
  12533. * @param {*} value The value to convert.
  12534. * @returns {number} Returns the converted integer.
  12535. * @example
  12536. *
  12537. * _.toSafeInteger(3.2);
  12538. * // => 3
  12539. *
  12540. * _.toSafeInteger(Number.MIN_VALUE);
  12541. * // => 0
  12542. *
  12543. * _.toSafeInteger(Infinity);
  12544. * // => 9007199254740991
  12545. *
  12546. * _.toSafeInteger('3.2');
  12547. * // => 3
  12548. */
  12549. function toSafeInteger(value) {
  12550. return value
  12551. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  12552. : (value === 0 ? value : 0);
  12553. }
  12554. /**
  12555. * Converts `value` to a string. An empty string is returned for `null`
  12556. * and `undefined` values. The sign of `-0` is preserved.
  12557. *
  12558. * @static
  12559. * @memberOf _
  12560. * @since 4.0.0
  12561. * @category Lang
  12562. * @param {*} value The value to convert.
  12563. * @returns {string} Returns the converted string.
  12564. * @example
  12565. *
  12566. * _.toString(null);
  12567. * // => ''
  12568. *
  12569. * _.toString(-0);
  12570. * // => '-0'
  12571. *
  12572. * _.toString([1, 2, 3]);
  12573. * // => '1,2,3'
  12574. */
  12575. function toString(value) {
  12576. return value == null ? '' : baseToString(value);
  12577. }
  12578. /*------------------------------------------------------------------------*/
  12579. /**
  12580. * Assigns own enumerable string keyed properties of source objects to the
  12581. * destination object. Source objects are applied from left to right.
  12582. * Subsequent sources overwrite property assignments of previous sources.
  12583. *
  12584. * **Note:** This method mutates `object` and is loosely based on
  12585. * [`Object.assign`](https://mdn.io/Object/assign).
  12586. *
  12587. * @static
  12588. * @memberOf _
  12589. * @since 0.10.0
  12590. * @category Object
  12591. * @param {Object} object The destination object.
  12592. * @param {...Object} [sources] The source objects.
  12593. * @returns {Object} Returns `object`.
  12594. * @see _.assignIn
  12595. * @example
  12596. *
  12597. * function Foo() {
  12598. * this.a = 1;
  12599. * }
  12600. *
  12601. * function Bar() {
  12602. * this.c = 3;
  12603. * }
  12604. *
  12605. * Foo.prototype.b = 2;
  12606. * Bar.prototype.d = 4;
  12607. *
  12608. * _.assign({ 'a': 0 }, new Foo, new Bar);
  12609. * // => { 'a': 1, 'c': 3 }
  12610. */
  12611. var assign = createAssigner(function(object, source) {
  12612. if (isPrototype(source) || isArrayLike(source)) {
  12613. copyObject(source, keys(source), object);
  12614. return;
  12615. }
  12616. for (var key in source) {
  12617. if (hasOwnProperty.call(source, key)) {
  12618. assignValue(object, key, source[key]);
  12619. }
  12620. }
  12621. });
  12622. /**
  12623. * This method is like `_.assign` except that it iterates over own and
  12624. * inherited source properties.
  12625. *
  12626. * **Note:** This method mutates `object`.
  12627. *
  12628. * @static
  12629. * @memberOf _
  12630. * @since 4.0.0
  12631. * @alias extend
  12632. * @category Object
  12633. * @param {Object} object The destination object.
  12634. * @param {...Object} [sources] The source objects.
  12635. * @returns {Object} Returns `object`.
  12636. * @see _.assign
  12637. * @example
  12638. *
  12639. * function Foo() {
  12640. * this.a = 1;
  12641. * }
  12642. *
  12643. * function Bar() {
  12644. * this.c = 3;
  12645. * }
  12646. *
  12647. * Foo.prototype.b = 2;
  12648. * Bar.prototype.d = 4;
  12649. *
  12650. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  12651. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  12652. */
  12653. var assignIn = createAssigner(function(object, source) {
  12654. copyObject(source, keysIn(source), object);
  12655. });
  12656. /**
  12657. * This method is like `_.assignIn` except that it accepts `customizer`
  12658. * which is invoked to produce the assigned values. If `customizer` returns
  12659. * `undefined`, assignment is handled by the method instead. The `customizer`
  12660. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  12661. *
  12662. * **Note:** This method mutates `object`.
  12663. *
  12664. * @static
  12665. * @memberOf _
  12666. * @since 4.0.0
  12667. * @alias extendWith
  12668. * @category Object
  12669. * @param {Object} object The destination object.
  12670. * @param {...Object} sources The source objects.
  12671. * @param {Function} [customizer] The function to customize assigned values.
  12672. * @returns {Object} Returns `object`.
  12673. * @see _.assignWith
  12674. * @example
  12675. *
  12676. * function customizer(objValue, srcValue) {
  12677. * return _.isUndefined(objValue) ? srcValue : objValue;
  12678. * }
  12679. *
  12680. * var defaults = _.partialRight(_.assignInWith, customizer);
  12681. *
  12682. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12683. * // => { 'a': 1, 'b': 2 }
  12684. */
  12685. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  12686. copyObject(source, keysIn(source), object, customizer);
  12687. });
  12688. /**
  12689. * This method is like `_.assign` except that it accepts `customizer`
  12690. * which is invoked to produce the assigned values. If `customizer` returns
  12691. * `undefined`, assignment is handled by the method instead. The `customizer`
  12692. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  12693. *
  12694. * **Note:** This method mutates `object`.
  12695. *
  12696. * @static
  12697. * @memberOf _
  12698. * @since 4.0.0
  12699. * @category Object
  12700. * @param {Object} object The destination object.
  12701. * @param {...Object} sources The source objects.
  12702. * @param {Function} [customizer] The function to customize assigned values.
  12703. * @returns {Object} Returns `object`.
  12704. * @see _.assignInWith
  12705. * @example
  12706. *
  12707. * function customizer(objValue, srcValue) {
  12708. * return _.isUndefined(objValue) ? srcValue : objValue;
  12709. * }
  12710. *
  12711. * var defaults = _.partialRight(_.assignWith, customizer);
  12712. *
  12713. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12714. * // => { 'a': 1, 'b': 2 }
  12715. */
  12716. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  12717. copyObject(source, keys(source), object, customizer);
  12718. });
  12719. /**
  12720. * Creates an array of values corresponding to `paths` of `object`.
  12721. *
  12722. * @static
  12723. * @memberOf _
  12724. * @since 1.0.0
  12725. * @category Object
  12726. * @param {Object} object The object to iterate over.
  12727. * @param {...(string|string[])} [paths] The property paths to pick.
  12728. * @returns {Array} Returns the picked values.
  12729. * @example
  12730. *
  12731. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  12732. *
  12733. * _.at(object, ['a[0].b.c', 'a[1]']);
  12734. * // => [3, 4]
  12735. */
  12736. var at = flatRest(baseAt);
  12737. /**
  12738. * Creates an object that inherits from the `prototype` object. If a
  12739. * `properties` object is given, its own enumerable string keyed properties
  12740. * are assigned to the created object.
  12741. *
  12742. * @static
  12743. * @memberOf _
  12744. * @since 2.3.0
  12745. * @category Object
  12746. * @param {Object} prototype The object to inherit from.
  12747. * @param {Object} [properties] The properties to assign to the object.
  12748. * @returns {Object} Returns the new object.
  12749. * @example
  12750. *
  12751. * function Shape() {
  12752. * this.x = 0;
  12753. * this.y = 0;
  12754. * }
  12755. *
  12756. * function Circle() {
  12757. * Shape.call(this);
  12758. * }
  12759. *
  12760. * Circle.prototype = _.create(Shape.prototype, {
  12761. * 'constructor': Circle
  12762. * });
  12763. *
  12764. * var circle = new Circle;
  12765. * circle instanceof Circle;
  12766. * // => true
  12767. *
  12768. * circle instanceof Shape;
  12769. * // => true
  12770. */
  12771. function create(prototype, properties) {
  12772. var result = baseCreate(prototype);
  12773. return properties == null ? result : baseAssign(result, properties);
  12774. }
  12775. /**
  12776. * Assigns own and inherited enumerable string keyed properties of source
  12777. * objects to the destination object for all destination properties that
  12778. * resolve to `undefined`. Source objects are applied from left to right.
  12779. * Once a property is set, additional values of the same property are ignored.
  12780. *
  12781. * **Note:** This method mutates `object`.
  12782. *
  12783. * @static
  12784. * @since 0.1.0
  12785. * @memberOf _
  12786. * @category Object
  12787. * @param {Object} object The destination object.
  12788. * @param {...Object} [sources] The source objects.
  12789. * @returns {Object} Returns `object`.
  12790. * @see _.defaultsDeep
  12791. * @example
  12792. *
  12793. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12794. * // => { 'a': 1, 'b': 2 }
  12795. */
  12796. var defaults = baseRest(function(args) {
  12797. args.push(undefined, customDefaultsAssignIn);
  12798. return apply(assignInWith, undefined, args);
  12799. });
  12800. /**
  12801. * This method is like `_.defaults` except that it recursively assigns
  12802. * default properties.
  12803. *
  12804. * **Note:** This method mutates `object`.
  12805. *
  12806. * @static
  12807. * @memberOf _
  12808. * @since 3.10.0
  12809. * @category Object
  12810. * @param {Object} object The destination object.
  12811. * @param {...Object} [sources] The source objects.
  12812. * @returns {Object} Returns `object`.
  12813. * @see _.defaults
  12814. * @example
  12815. *
  12816. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  12817. * // => { 'a': { 'b': 2, 'c': 3 } }
  12818. */
  12819. var defaultsDeep = baseRest(function(args) {
  12820. args.push(undefined, customDefaultsMerge);
  12821. return apply(mergeWith, undefined, args);
  12822. });
  12823. /**
  12824. * This method is like `_.find` except that it returns the key of the first
  12825. * element `predicate` returns truthy for instead of the element itself.
  12826. *
  12827. * @static
  12828. * @memberOf _
  12829. * @since 1.1.0
  12830. * @category Object
  12831. * @param {Object} object The object to inspect.
  12832. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12833. * @returns {string|undefined} Returns the key of the matched element,
  12834. * else `undefined`.
  12835. * @example
  12836. *
  12837. * var users = {
  12838. * 'barney': { 'age': 36, 'active': true },
  12839. * 'fred': { 'age': 40, 'active': false },
  12840. * 'pebbles': { 'age': 1, 'active': true }
  12841. * };
  12842. *
  12843. * _.findKey(users, function(o) { return o.age < 40; });
  12844. * // => 'barney' (iteration order is not guaranteed)
  12845. *
  12846. * // The `_.matches` iteratee shorthand.
  12847. * _.findKey(users, { 'age': 1, 'active': true });
  12848. * // => 'pebbles'
  12849. *
  12850. * // The `_.matchesProperty` iteratee shorthand.
  12851. * _.findKey(users, ['active', false]);
  12852. * // => 'fred'
  12853. *
  12854. * // The `_.property` iteratee shorthand.
  12855. * _.findKey(users, 'active');
  12856. * // => 'barney'
  12857. */
  12858. function findKey(object, predicate) {
  12859. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  12860. }
  12861. /**
  12862. * This method is like `_.findKey` except that it iterates over elements of
  12863. * a collection in the opposite order.
  12864. *
  12865. * @static
  12866. * @memberOf _
  12867. * @since 2.0.0
  12868. * @category Object
  12869. * @param {Object} object The object to inspect.
  12870. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12871. * @returns {string|undefined} Returns the key of the matched element,
  12872. * else `undefined`.
  12873. * @example
  12874. *
  12875. * var users = {
  12876. * 'barney': { 'age': 36, 'active': true },
  12877. * 'fred': { 'age': 40, 'active': false },
  12878. * 'pebbles': { 'age': 1, 'active': true }
  12879. * };
  12880. *
  12881. * _.findLastKey(users, function(o) { return o.age < 40; });
  12882. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  12883. *
  12884. * // The `_.matches` iteratee shorthand.
  12885. * _.findLastKey(users, { 'age': 36, 'active': true });
  12886. * // => 'barney'
  12887. *
  12888. * // The `_.matchesProperty` iteratee shorthand.
  12889. * _.findLastKey(users, ['active', false]);
  12890. * // => 'fred'
  12891. *
  12892. * // The `_.property` iteratee shorthand.
  12893. * _.findLastKey(users, 'active');
  12894. * // => 'pebbles'
  12895. */
  12896. function findLastKey(object, predicate) {
  12897. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  12898. }
  12899. /**
  12900. * Iterates over own and inherited enumerable string keyed properties of an
  12901. * object and invokes `iteratee` for each property. The iteratee is invoked
  12902. * with three arguments: (value, key, object). Iteratee functions may exit
  12903. * iteration early by explicitly returning `false`.
  12904. *
  12905. * @static
  12906. * @memberOf _
  12907. * @since 0.3.0
  12908. * @category Object
  12909. * @param {Object} object The object to iterate over.
  12910. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12911. * @returns {Object} Returns `object`.
  12912. * @see _.forInRight
  12913. * @example
  12914. *
  12915. * function Foo() {
  12916. * this.a = 1;
  12917. * this.b = 2;
  12918. * }
  12919. *
  12920. * Foo.prototype.c = 3;
  12921. *
  12922. * _.forIn(new Foo, function(value, key) {
  12923. * console.log(key);
  12924. * });
  12925. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  12926. */
  12927. function forIn(object, iteratee) {
  12928. return object == null
  12929. ? object
  12930. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  12931. }
  12932. /**
  12933. * This method is like `_.forIn` except that it iterates over properties of
  12934. * `object` in the opposite order.
  12935. *
  12936. * @static
  12937. * @memberOf _
  12938. * @since 2.0.0
  12939. * @category Object
  12940. * @param {Object} object The object to iterate over.
  12941. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12942. * @returns {Object} Returns `object`.
  12943. * @see _.forIn
  12944. * @example
  12945. *
  12946. * function Foo() {
  12947. * this.a = 1;
  12948. * this.b = 2;
  12949. * }
  12950. *
  12951. * Foo.prototype.c = 3;
  12952. *
  12953. * _.forInRight(new Foo, function(value, key) {
  12954. * console.log(key);
  12955. * });
  12956. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  12957. */
  12958. function forInRight(object, iteratee) {
  12959. return object == null
  12960. ? object
  12961. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  12962. }
  12963. /**
  12964. * Iterates over own enumerable string keyed properties of an object and
  12965. * invokes `iteratee` for each property. The iteratee is invoked with three
  12966. * arguments: (value, key, object). Iteratee functions may exit iteration
  12967. * early by explicitly returning `false`.
  12968. *
  12969. * @static
  12970. * @memberOf _
  12971. * @since 0.3.0
  12972. * @category Object
  12973. * @param {Object} object The object to iterate over.
  12974. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12975. * @returns {Object} Returns `object`.
  12976. * @see _.forOwnRight
  12977. * @example
  12978. *
  12979. * function Foo() {
  12980. * this.a = 1;
  12981. * this.b = 2;
  12982. * }
  12983. *
  12984. * Foo.prototype.c = 3;
  12985. *
  12986. * _.forOwn(new Foo, function(value, key) {
  12987. * console.log(key);
  12988. * });
  12989. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  12990. */
  12991. function forOwn(object, iteratee) {
  12992. return object && baseForOwn(object, getIteratee(iteratee, 3));
  12993. }
  12994. /**
  12995. * This method is like `_.forOwn` except that it iterates over properties of
  12996. * `object` in the opposite order.
  12997. *
  12998. * @static
  12999. * @memberOf _
  13000. * @since 2.0.0
  13001. * @category Object
  13002. * @param {Object} object The object to iterate over.
  13003. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13004. * @returns {Object} Returns `object`.
  13005. * @see _.forOwn
  13006. * @example
  13007. *
  13008. * function Foo() {
  13009. * this.a = 1;
  13010. * this.b = 2;
  13011. * }
  13012. *
  13013. * Foo.prototype.c = 3;
  13014. *
  13015. * _.forOwnRight(new Foo, function(value, key) {
  13016. * console.log(key);
  13017. * });
  13018. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  13019. */
  13020. function forOwnRight(object, iteratee) {
  13021. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  13022. }
  13023. /**
  13024. * Creates an array of function property names from own enumerable properties
  13025. * of `object`.
  13026. *
  13027. * @static
  13028. * @since 0.1.0
  13029. * @memberOf _
  13030. * @category Object
  13031. * @param {Object} object The object to inspect.
  13032. * @returns {Array} Returns the function names.
  13033. * @see _.functionsIn
  13034. * @example
  13035. *
  13036. * function Foo() {
  13037. * this.a = _.constant('a');
  13038. * this.b = _.constant('b');
  13039. * }
  13040. *
  13041. * Foo.prototype.c = _.constant('c');
  13042. *
  13043. * _.functions(new Foo);
  13044. * // => ['a', 'b']
  13045. */
  13046. function functions(object) {
  13047. return object == null ? [] : baseFunctions(object, keys(object));
  13048. }
  13049. /**
  13050. * Creates an array of function property names from own and inherited
  13051. * enumerable properties of `object`.
  13052. *
  13053. * @static
  13054. * @memberOf _
  13055. * @since 4.0.0
  13056. * @category Object
  13057. * @param {Object} object The object to inspect.
  13058. * @returns {Array} Returns the function names.
  13059. * @see _.functions
  13060. * @example
  13061. *
  13062. * function Foo() {
  13063. * this.a = _.constant('a');
  13064. * this.b = _.constant('b');
  13065. * }
  13066. *
  13067. * Foo.prototype.c = _.constant('c');
  13068. *
  13069. * _.functionsIn(new Foo);
  13070. * // => ['a', 'b', 'c']
  13071. */
  13072. function functionsIn(object) {
  13073. return object == null ? [] : baseFunctions(object, keysIn(object));
  13074. }
  13075. /**
  13076. * Gets the value at `path` of `object`. If the resolved value is
  13077. * `undefined`, the `defaultValue` is returned in its place.
  13078. *
  13079. * @static
  13080. * @memberOf _
  13081. * @since 3.7.0
  13082. * @category Object
  13083. * @param {Object} object The object to query.
  13084. * @param {Array|string} path The path of the property to get.
  13085. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13086. * @returns {*} Returns the resolved value.
  13087. * @example
  13088. *
  13089. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13090. *
  13091. * _.get(object, 'a[0].b.c');
  13092. * // => 3
  13093. *
  13094. * _.get(object, ['a', '0', 'b', 'c']);
  13095. * // => 3
  13096. *
  13097. * _.get(object, 'a.b.c', 'default');
  13098. * // => 'default'
  13099. */
  13100. function get(object, path, defaultValue) {
  13101. var result = object == null ? undefined : baseGet(object, path);
  13102. return result === undefined ? defaultValue : result;
  13103. }
  13104. /**
  13105. * Checks if `path` is a direct property of `object`.
  13106. *
  13107. * @static
  13108. * @since 0.1.0
  13109. * @memberOf _
  13110. * @category Object
  13111. * @param {Object} object The object to query.
  13112. * @param {Array|string} path The path to check.
  13113. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13114. * @example
  13115. *
  13116. * var object = { 'a': { 'b': 2 } };
  13117. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  13118. *
  13119. * _.has(object, 'a');
  13120. * // => true
  13121. *
  13122. * _.has(object, 'a.b');
  13123. * // => true
  13124. *
  13125. * _.has(object, ['a', 'b']);
  13126. * // => true
  13127. *
  13128. * _.has(other, 'a');
  13129. * // => false
  13130. */
  13131. function has(object, path) {
  13132. return object != null && hasPath(object, path, baseHas);
  13133. }
  13134. /**
  13135. * Checks if `path` is a direct or inherited property of `object`.
  13136. *
  13137. * @static
  13138. * @memberOf _
  13139. * @since 4.0.0
  13140. * @category Object
  13141. * @param {Object} object The object to query.
  13142. * @param {Array|string} path The path to check.
  13143. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13144. * @example
  13145. *
  13146. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  13147. *
  13148. * _.hasIn(object, 'a');
  13149. * // => true
  13150. *
  13151. * _.hasIn(object, 'a.b');
  13152. * // => true
  13153. *
  13154. * _.hasIn(object, ['a', 'b']);
  13155. * // => true
  13156. *
  13157. * _.hasIn(object, 'b');
  13158. * // => false
  13159. */
  13160. function hasIn(object, path) {
  13161. return object != null && hasPath(object, path, baseHasIn);
  13162. }
  13163. /**
  13164. * Creates an object composed of the inverted keys and values of `object`.
  13165. * If `object` contains duplicate values, subsequent values overwrite
  13166. * property assignments of previous values.
  13167. *
  13168. * @static
  13169. * @memberOf _
  13170. * @since 0.7.0
  13171. * @category Object
  13172. * @param {Object} object The object to invert.
  13173. * @returns {Object} Returns the new inverted object.
  13174. * @example
  13175. *
  13176. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13177. *
  13178. * _.invert(object);
  13179. * // => { '1': 'c', '2': 'b' }
  13180. */
  13181. var invert = createInverter(function(result, value, key) {
  13182. result[value] = key;
  13183. }, constant(identity));
  13184. /**
  13185. * This method is like `_.invert` except that the inverted object is generated
  13186. * from the results of running each element of `object` thru `iteratee`. The
  13187. * corresponding inverted value of each inverted key is an array of keys
  13188. * responsible for generating the inverted value. The iteratee is invoked
  13189. * with one argument: (value).
  13190. *
  13191. * @static
  13192. * @memberOf _
  13193. * @since 4.1.0
  13194. * @category Object
  13195. * @param {Object} object The object to invert.
  13196. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13197. * @returns {Object} Returns the new inverted object.
  13198. * @example
  13199. *
  13200. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13201. *
  13202. * _.invertBy(object);
  13203. * // => { '1': ['a', 'c'], '2': ['b'] }
  13204. *
  13205. * _.invertBy(object, function(value) {
  13206. * return 'group' + value;
  13207. * });
  13208. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  13209. */
  13210. var invertBy = createInverter(function(result, value, key) {
  13211. if (hasOwnProperty.call(result, value)) {
  13212. result[value].push(key);
  13213. } else {
  13214. result[value] = [key];
  13215. }
  13216. }, getIteratee);
  13217. /**
  13218. * Invokes the method at `path` of `object`.
  13219. *
  13220. * @static
  13221. * @memberOf _
  13222. * @since 4.0.0
  13223. * @category Object
  13224. * @param {Object} object The object to query.
  13225. * @param {Array|string} path The path of the method to invoke.
  13226. * @param {...*} [args] The arguments to invoke the method with.
  13227. * @returns {*} Returns the result of the invoked method.
  13228. * @example
  13229. *
  13230. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  13231. *
  13232. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  13233. * // => [2, 3]
  13234. */
  13235. var invoke = baseRest(baseInvoke);
  13236. /**
  13237. * Creates an array of the own enumerable property names of `object`.
  13238. *
  13239. * **Note:** Non-object values are coerced to objects. See the
  13240. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  13241. * for more details.
  13242. *
  13243. * @static
  13244. * @since 0.1.0
  13245. * @memberOf _
  13246. * @category Object
  13247. * @param {Object} object The object to query.
  13248. * @returns {Array} Returns the array of property names.
  13249. * @example
  13250. *
  13251. * function Foo() {
  13252. * this.a = 1;
  13253. * this.b = 2;
  13254. * }
  13255. *
  13256. * Foo.prototype.c = 3;
  13257. *
  13258. * _.keys(new Foo);
  13259. * // => ['a', 'b'] (iteration order is not guaranteed)
  13260. *
  13261. * _.keys('hi');
  13262. * // => ['0', '1']
  13263. */
  13264. function keys(object) {
  13265. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  13266. }
  13267. /**
  13268. * Creates an array of the own and inherited enumerable property names of `object`.
  13269. *
  13270. * **Note:** Non-object values are coerced to objects.
  13271. *
  13272. * @static
  13273. * @memberOf _
  13274. * @since 3.0.0
  13275. * @category Object
  13276. * @param {Object} object The object to query.
  13277. * @returns {Array} Returns the array of property names.
  13278. * @example
  13279. *
  13280. * function Foo() {
  13281. * this.a = 1;
  13282. * this.b = 2;
  13283. * }
  13284. *
  13285. * Foo.prototype.c = 3;
  13286. *
  13287. * _.keysIn(new Foo);
  13288. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  13289. */
  13290. function keysIn(object) {
  13291. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  13292. }
  13293. /**
  13294. * The opposite of `_.mapValues`; this method creates an object with the
  13295. * same values as `object` and keys generated by running each own enumerable
  13296. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  13297. * with three arguments: (value, key, object).
  13298. *
  13299. * @static
  13300. * @memberOf _
  13301. * @since 3.8.0
  13302. * @category Object
  13303. * @param {Object} object The object to iterate over.
  13304. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13305. * @returns {Object} Returns the new mapped object.
  13306. * @see _.mapValues
  13307. * @example
  13308. *
  13309. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  13310. * return key + value;
  13311. * });
  13312. * // => { 'a1': 1, 'b2': 2 }
  13313. */
  13314. function mapKeys(object, iteratee) {
  13315. var result = {};
  13316. iteratee = getIteratee(iteratee, 3);
  13317. baseForOwn(object, function(value, key, object) {
  13318. baseAssignValue(result, iteratee(value, key, object), value);
  13319. });
  13320. return result;
  13321. }
  13322. /**
  13323. * Creates an object with the same keys as `object` and values generated
  13324. * by running each own enumerable string keyed property of `object` thru
  13325. * `iteratee`. The iteratee is invoked with three arguments:
  13326. * (value, key, object).
  13327. *
  13328. * @static
  13329. * @memberOf _
  13330. * @since 2.4.0
  13331. * @category Object
  13332. * @param {Object} object The object to iterate over.
  13333. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13334. * @returns {Object} Returns the new mapped object.
  13335. * @see _.mapKeys
  13336. * @example
  13337. *
  13338. * var users = {
  13339. * 'fred': { 'user': 'fred', 'age': 40 },
  13340. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  13341. * };
  13342. *
  13343. * _.mapValues(users, function(o) { return o.age; });
  13344. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  13345. *
  13346. * // The `_.property` iteratee shorthand.
  13347. * _.mapValues(users, 'age');
  13348. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  13349. */
  13350. function mapValues(object, iteratee) {
  13351. var result = {};
  13352. iteratee = getIteratee(iteratee, 3);
  13353. baseForOwn(object, function(value, key, object) {
  13354. baseAssignValue(result, key, iteratee(value, key, object));
  13355. });
  13356. return result;
  13357. }
  13358. /**
  13359. * This method is like `_.assign` except that it recursively merges own and
  13360. * inherited enumerable string keyed properties of source objects into the
  13361. * destination object. Source properties that resolve to `undefined` are
  13362. * skipped if a destination value exists. Array and plain object properties
  13363. * are merged recursively. Other objects and value types are overridden by
  13364. * assignment. Source objects are applied from left to right. Subsequent
  13365. * sources overwrite property assignments of previous sources.
  13366. *
  13367. * **Note:** This method mutates `object`.
  13368. *
  13369. * @static
  13370. * @memberOf _
  13371. * @since 0.5.0
  13372. * @category Object
  13373. * @param {Object} object The destination object.
  13374. * @param {...Object} [sources] The source objects.
  13375. * @returns {Object} Returns `object`.
  13376. * @example
  13377. *
  13378. * var object = {
  13379. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  13380. * };
  13381. *
  13382. * var other = {
  13383. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  13384. * };
  13385. *
  13386. * _.merge(object, other);
  13387. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  13388. */
  13389. var merge = createAssigner(function(object, source, srcIndex) {
  13390. baseMerge(object, source, srcIndex);
  13391. });
  13392. /**
  13393. * This method is like `_.merge` except that it accepts `customizer` which
  13394. * is invoked to produce the merged values of the destination and source
  13395. * properties. If `customizer` returns `undefined`, merging is handled by the
  13396. * method instead. The `customizer` is invoked with six arguments:
  13397. * (objValue, srcValue, key, object, source, stack).
  13398. *
  13399. * **Note:** This method mutates `object`.
  13400. *
  13401. * @static
  13402. * @memberOf _
  13403. * @since 4.0.0
  13404. * @category Object
  13405. * @param {Object} object The destination object.
  13406. * @param {...Object} sources The source objects.
  13407. * @param {Function} customizer The function to customize assigned values.
  13408. * @returns {Object} Returns `object`.
  13409. * @example
  13410. *
  13411. * function customizer(objValue, srcValue) {
  13412. * if (_.isArray(objValue)) {
  13413. * return objValue.concat(srcValue);
  13414. * }
  13415. * }
  13416. *
  13417. * var object = { 'a': [1], 'b': [2] };
  13418. * var other = { 'a': [3], 'b': [4] };
  13419. *
  13420. * _.mergeWith(object, other, customizer);
  13421. * // => { 'a': [1, 3], 'b': [2, 4] }
  13422. */
  13423. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  13424. baseMerge(object, source, srcIndex, customizer);
  13425. });
  13426. /**
  13427. * The opposite of `_.pick`; this method creates an object composed of the
  13428. * own and inherited enumerable property paths of `object` that are not omitted.
  13429. *
  13430. * **Note:** This method is considerably slower than `_.pick`.
  13431. *
  13432. * @static
  13433. * @since 0.1.0
  13434. * @memberOf _
  13435. * @category Object
  13436. * @param {Object} object The source object.
  13437. * @param {...(string|string[])} [paths] The property paths to omit.
  13438. * @returns {Object} Returns the new object.
  13439. * @example
  13440. *
  13441. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13442. *
  13443. * _.omit(object, ['a', 'c']);
  13444. * // => { 'b': '2' }
  13445. */
  13446. var omit = flatRest(function(object, paths) {
  13447. var result = {};
  13448. if (object == null) {
  13449. return result;
  13450. }
  13451. var isDeep = false;
  13452. paths = arrayMap(paths, function(path) {
  13453. path = castPath(path, object);
  13454. isDeep || (isDeep = path.length > 1);
  13455. return path;
  13456. });
  13457. copyObject(object, getAllKeysIn(object), result);
  13458. if (isDeep) {
  13459. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  13460. }
  13461. var length = paths.length;
  13462. while (length--) {
  13463. baseUnset(result, paths[length]);
  13464. }
  13465. return result;
  13466. });
  13467. /**
  13468. * The opposite of `_.pickBy`; this method creates an object composed of
  13469. * the own and inherited enumerable string keyed properties of `object` that
  13470. * `predicate` doesn't return truthy for. The predicate is invoked with two
  13471. * arguments: (value, key).
  13472. *
  13473. * @static
  13474. * @memberOf _
  13475. * @since 4.0.0
  13476. * @category Object
  13477. * @param {Object} object The source object.
  13478. * @param {Function} [predicate=_.identity] The function invoked per property.
  13479. * @returns {Object} Returns the new object.
  13480. * @example
  13481. *
  13482. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13483. *
  13484. * _.omitBy(object, _.isNumber);
  13485. * // => { 'b': '2' }
  13486. */
  13487. function omitBy(object, predicate) {
  13488. return pickBy(object, negate(getIteratee(predicate)));
  13489. }
  13490. /**
  13491. * Creates an object composed of the picked `object` properties.
  13492. *
  13493. * @static
  13494. * @since 0.1.0
  13495. * @memberOf _
  13496. * @category Object
  13497. * @param {Object} object The source object.
  13498. * @param {...(string|string[])} [paths] The property paths to pick.
  13499. * @returns {Object} Returns the new object.
  13500. * @example
  13501. *
  13502. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13503. *
  13504. * _.pick(object, ['a', 'c']);
  13505. * // => { 'a': 1, 'c': 3 }
  13506. */
  13507. var pick = flatRest(function(object, paths) {
  13508. return object == null ? {} : basePick(object, paths);
  13509. });
  13510. /**
  13511. * Creates an object composed of the `object` properties `predicate` returns
  13512. * truthy for. The predicate is invoked with two arguments: (value, key).
  13513. *
  13514. * @static
  13515. * @memberOf _
  13516. * @since 4.0.0
  13517. * @category Object
  13518. * @param {Object} object The source object.
  13519. * @param {Function} [predicate=_.identity] The function invoked per property.
  13520. * @returns {Object} Returns the new object.
  13521. * @example
  13522. *
  13523. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13524. *
  13525. * _.pickBy(object, _.isNumber);
  13526. * // => { 'a': 1, 'c': 3 }
  13527. */
  13528. function pickBy(object, predicate) {
  13529. if (object == null) {
  13530. return {};
  13531. }
  13532. var props = arrayMap(getAllKeysIn(object), function(prop) {
  13533. return [prop];
  13534. });
  13535. predicate = getIteratee(predicate);
  13536. return basePickBy(object, props, function(value, path) {
  13537. return predicate(value, path[0]);
  13538. });
  13539. }
  13540. /**
  13541. * This method is like `_.get` except that if the resolved value is a
  13542. * function it's invoked with the `this` binding of its parent object and
  13543. * its result is returned.
  13544. *
  13545. * @static
  13546. * @since 0.1.0
  13547. * @memberOf _
  13548. * @category Object
  13549. * @param {Object} object The object to query.
  13550. * @param {Array|string} path The path of the property to resolve.
  13551. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13552. * @returns {*} Returns the resolved value.
  13553. * @example
  13554. *
  13555. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  13556. *
  13557. * _.result(object, 'a[0].b.c1');
  13558. * // => 3
  13559. *
  13560. * _.result(object, 'a[0].b.c2');
  13561. * // => 4
  13562. *
  13563. * _.result(object, 'a[0].b.c3', 'default');
  13564. * // => 'default'
  13565. *
  13566. * _.result(object, 'a[0].b.c3', _.constant('default'));
  13567. * // => 'default'
  13568. */
  13569. function result(object, path, defaultValue) {
  13570. path = castPath(path, object);
  13571. var index = -1,
  13572. length = path.length;
  13573. // Ensure the loop is entered when path is empty.
  13574. if (!length) {
  13575. length = 1;
  13576. object = undefined;
  13577. }
  13578. while (++index < length) {
  13579. var value = object == null ? undefined : object[toKey(path[index])];
  13580. if (value === undefined) {
  13581. index = length;
  13582. value = defaultValue;
  13583. }
  13584. object = isFunction(value) ? value.call(object) : value;
  13585. }
  13586. return object;
  13587. }
  13588. /**
  13589. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  13590. * it's created. Arrays are created for missing index properties while objects
  13591. * are created for all other missing properties. Use `_.setWith` to customize
  13592. * `path` creation.
  13593. *
  13594. * **Note:** This method mutates `object`.
  13595. *
  13596. * @static
  13597. * @memberOf _
  13598. * @since 3.7.0
  13599. * @category Object
  13600. * @param {Object} object The object to modify.
  13601. * @param {Array|string} path The path of the property to set.
  13602. * @param {*} value The value to set.
  13603. * @returns {Object} Returns `object`.
  13604. * @example
  13605. *
  13606. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13607. *
  13608. * _.set(object, 'a[0].b.c', 4);
  13609. * console.log(object.a[0].b.c);
  13610. * // => 4
  13611. *
  13612. * _.set(object, ['x', '0', 'y', 'z'], 5);
  13613. * console.log(object.x[0].y.z);
  13614. * // => 5
  13615. */
  13616. function set(object, path, value) {
  13617. return object == null ? object : baseSet(object, path, value);
  13618. }
  13619. /**
  13620. * This method is like `_.set` except that it accepts `customizer` which is
  13621. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  13622. * path creation is handled by the method instead. The `customizer` is invoked
  13623. * with three arguments: (nsValue, key, nsObject).
  13624. *
  13625. * **Note:** This method mutates `object`.
  13626. *
  13627. * @static
  13628. * @memberOf _
  13629. * @since 4.0.0
  13630. * @category Object
  13631. * @param {Object} object The object to modify.
  13632. * @param {Array|string} path The path of the property to set.
  13633. * @param {*} value The value to set.
  13634. * @param {Function} [customizer] The function to customize assigned values.
  13635. * @returns {Object} Returns `object`.
  13636. * @example
  13637. *
  13638. * var object = {};
  13639. *
  13640. * _.setWith(object, '[0][1]', 'a', Object);
  13641. * // => { '0': { '1': 'a' } }
  13642. */
  13643. function setWith(object, path, value, customizer) {
  13644. customizer = typeof customizer == 'function' ? customizer : undefined;
  13645. return object == null ? object : baseSet(object, path, value, customizer);
  13646. }
  13647. /**
  13648. * Creates an array of own enumerable string keyed-value pairs for `object`
  13649. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  13650. * entries are returned.
  13651. *
  13652. * @static
  13653. * @memberOf _
  13654. * @since 4.0.0
  13655. * @alias entries
  13656. * @category Object
  13657. * @param {Object} object The object to query.
  13658. * @returns {Array} Returns the key-value pairs.
  13659. * @example
  13660. *
  13661. * function Foo() {
  13662. * this.a = 1;
  13663. * this.b = 2;
  13664. * }
  13665. *
  13666. * Foo.prototype.c = 3;
  13667. *
  13668. * _.toPairs(new Foo);
  13669. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  13670. */
  13671. var toPairs = createToPairs(keys);
  13672. /**
  13673. * Creates an array of own and inherited enumerable string keyed-value pairs
  13674. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  13675. * or set, its entries are returned.
  13676. *
  13677. * @static
  13678. * @memberOf _
  13679. * @since 4.0.0
  13680. * @alias entriesIn
  13681. * @category Object
  13682. * @param {Object} object The object to query.
  13683. * @returns {Array} Returns the key-value pairs.
  13684. * @example
  13685. *
  13686. * function Foo() {
  13687. * this.a = 1;
  13688. * this.b = 2;
  13689. * }
  13690. *
  13691. * Foo.prototype.c = 3;
  13692. *
  13693. * _.toPairsIn(new Foo);
  13694. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  13695. */
  13696. var toPairsIn = createToPairs(keysIn);
  13697. /**
  13698. * An alternative to `_.reduce`; this method transforms `object` to a new
  13699. * `accumulator` object which is the result of running each of its own
  13700. * enumerable string keyed properties thru `iteratee`, with each invocation
  13701. * potentially mutating the `accumulator` object. If `accumulator` is not
  13702. * provided, a new object with the same `[[Prototype]]` will be used. The
  13703. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  13704. * Iteratee functions may exit iteration early by explicitly returning `false`.
  13705. *
  13706. * @static
  13707. * @memberOf _
  13708. * @since 1.3.0
  13709. * @category Object
  13710. * @param {Object} object The object to iterate over.
  13711. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13712. * @param {*} [accumulator] The custom accumulator value.
  13713. * @returns {*} Returns the accumulated value.
  13714. * @example
  13715. *
  13716. * _.transform([2, 3, 4], function(result, n) {
  13717. * result.push(n *= n);
  13718. * return n % 2 == 0;
  13719. * }, []);
  13720. * // => [4, 9]
  13721. *
  13722. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  13723. * (result[value] || (result[value] = [])).push(key);
  13724. * }, {});
  13725. * // => { '1': ['a', 'c'], '2': ['b'] }
  13726. */
  13727. function transform(object, iteratee, accumulator) {
  13728. var isArr = isArray(object),
  13729. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  13730. iteratee = getIteratee(iteratee, 4);
  13731. if (accumulator == null) {
  13732. var Ctor = object && object.constructor;
  13733. if (isArrLike) {
  13734. accumulator = isArr ? new Ctor : [];
  13735. }
  13736. else if (isObject(object)) {
  13737. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  13738. }
  13739. else {
  13740. accumulator = {};
  13741. }
  13742. }
  13743. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  13744. return iteratee(accumulator, value, index, object);
  13745. });
  13746. return accumulator;
  13747. }
  13748. /**
  13749. * Removes the property at `path` of `object`.
  13750. *
  13751. * **Note:** This method mutates `object`.
  13752. *
  13753. * @static
  13754. * @memberOf _
  13755. * @since 4.0.0
  13756. * @category Object
  13757. * @param {Object} object The object to modify.
  13758. * @param {Array|string} path The path of the property to unset.
  13759. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  13760. * @example
  13761. *
  13762. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  13763. * _.unset(object, 'a[0].b.c');
  13764. * // => true
  13765. *
  13766. * console.log(object);
  13767. * // => { 'a': [{ 'b': {} }] };
  13768. *
  13769. * _.unset(object, ['a', '0', 'b', 'c']);
  13770. * // => true
  13771. *
  13772. * console.log(object);
  13773. * // => { 'a': [{ 'b': {} }] };
  13774. */
  13775. function unset(object, path) {
  13776. return object == null ? true : baseUnset(object, path);
  13777. }
  13778. /**
  13779. * This method is like `_.set` except that accepts `updater` to produce the
  13780. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  13781. * is invoked with one argument: (value).
  13782. *
  13783. * **Note:** This method mutates `object`.
  13784. *
  13785. * @static
  13786. * @memberOf _
  13787. * @since 4.6.0
  13788. * @category Object
  13789. * @param {Object} object The object to modify.
  13790. * @param {Array|string} path The path of the property to set.
  13791. * @param {Function} updater The function to produce the updated value.
  13792. * @returns {Object} Returns `object`.
  13793. * @example
  13794. *
  13795. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13796. *
  13797. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  13798. * console.log(object.a[0].b.c);
  13799. * // => 9
  13800. *
  13801. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  13802. * console.log(object.x[0].y.z);
  13803. * // => 0
  13804. */
  13805. function update(object, path, updater) {
  13806. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  13807. }
  13808. /**
  13809. * This method is like `_.update` except that it accepts `customizer` which is
  13810. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  13811. * path creation is handled by the method instead. The `customizer` is invoked
  13812. * with three arguments: (nsValue, key, nsObject).
  13813. *
  13814. * **Note:** This method mutates `object`.
  13815. *
  13816. * @static
  13817. * @memberOf _
  13818. * @since 4.6.0
  13819. * @category Object
  13820. * @param {Object} object The object to modify.
  13821. * @param {Array|string} path The path of the property to set.
  13822. * @param {Function} updater The function to produce the updated value.
  13823. * @param {Function} [customizer] The function to customize assigned values.
  13824. * @returns {Object} Returns `object`.
  13825. * @example
  13826. *
  13827. * var object = {};
  13828. *
  13829. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  13830. * // => { '0': { '1': 'a' } }
  13831. */
  13832. function updateWith(object, path, updater, customizer) {
  13833. customizer = typeof customizer == 'function' ? customizer : undefined;
  13834. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  13835. }
  13836. /**
  13837. * Creates an array of the own enumerable string keyed property values of `object`.
  13838. *
  13839. * **Note:** Non-object values are coerced to objects.
  13840. *
  13841. * @static
  13842. * @since 0.1.0
  13843. * @memberOf _
  13844. * @category Object
  13845. * @param {Object} object The object to query.
  13846. * @returns {Array} Returns the array of property values.
  13847. * @example
  13848. *
  13849. * function Foo() {
  13850. * this.a = 1;
  13851. * this.b = 2;
  13852. * }
  13853. *
  13854. * Foo.prototype.c = 3;
  13855. *
  13856. * _.values(new Foo);
  13857. * // => [1, 2] (iteration order is not guaranteed)
  13858. *
  13859. * _.values('hi');
  13860. * // => ['h', 'i']
  13861. */
  13862. function values(object) {
  13863. return object == null ? [] : baseValues(object, keys(object));
  13864. }
  13865. /**
  13866. * Creates an array of the own and inherited enumerable string keyed property
  13867. * values of `object`.
  13868. *
  13869. * **Note:** Non-object values are coerced to objects.
  13870. *
  13871. * @static
  13872. * @memberOf _
  13873. * @since 3.0.0
  13874. * @category Object
  13875. * @param {Object} object The object to query.
  13876. * @returns {Array} Returns the array of property values.
  13877. * @example
  13878. *
  13879. * function Foo() {
  13880. * this.a = 1;
  13881. * this.b = 2;
  13882. * }
  13883. *
  13884. * Foo.prototype.c = 3;
  13885. *
  13886. * _.valuesIn(new Foo);
  13887. * // => [1, 2, 3] (iteration order is not guaranteed)
  13888. */
  13889. function valuesIn(object) {
  13890. return object == null ? [] : baseValues(object, keysIn(object));
  13891. }
  13892. /*------------------------------------------------------------------------*/
  13893. /**
  13894. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  13895. *
  13896. * @static
  13897. * @memberOf _
  13898. * @since 4.0.0
  13899. * @category Number
  13900. * @param {number} number The number to clamp.
  13901. * @param {number} [lower] The lower bound.
  13902. * @param {number} upper The upper bound.
  13903. * @returns {number} Returns the clamped number.
  13904. * @example
  13905. *
  13906. * _.clamp(-10, -5, 5);
  13907. * // => -5
  13908. *
  13909. * _.clamp(10, -5, 5);
  13910. * // => 5
  13911. */
  13912. function clamp(number, lower, upper) {
  13913. if (upper === undefined) {
  13914. upper = lower;
  13915. lower = undefined;
  13916. }
  13917. if (upper !== undefined) {
  13918. upper = toNumber(upper);
  13919. upper = upper === upper ? upper : 0;
  13920. }
  13921. if (lower !== undefined) {
  13922. lower = toNumber(lower);
  13923. lower = lower === lower ? lower : 0;
  13924. }
  13925. return baseClamp(toNumber(number), lower, upper);
  13926. }
  13927. /**
  13928. * Checks if `n` is between `start` and up to, but not including, `end`. If
  13929. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  13930. * If `start` is greater than `end` the params are swapped to support
  13931. * negative ranges.
  13932. *
  13933. * @static
  13934. * @memberOf _
  13935. * @since 3.3.0
  13936. * @category Number
  13937. * @param {number} number The number to check.
  13938. * @param {number} [start=0] The start of the range.
  13939. * @param {number} end The end of the range.
  13940. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  13941. * @see _.range, _.rangeRight
  13942. * @example
  13943. *
  13944. * _.inRange(3, 2, 4);
  13945. * // => true
  13946. *
  13947. * _.inRange(4, 8);
  13948. * // => true
  13949. *
  13950. * _.inRange(4, 2);
  13951. * // => false
  13952. *
  13953. * _.inRange(2, 2);
  13954. * // => false
  13955. *
  13956. * _.inRange(1.2, 2);
  13957. * // => true
  13958. *
  13959. * _.inRange(5.2, 4);
  13960. * // => false
  13961. *
  13962. * _.inRange(-3, -2, -6);
  13963. * // => true
  13964. */
  13965. function inRange(number, start, end) {
  13966. start = toFinite(start);
  13967. if (end === undefined) {
  13968. end = start;
  13969. start = 0;
  13970. } else {
  13971. end = toFinite(end);
  13972. }
  13973. number = toNumber(number);
  13974. return baseInRange(number, start, end);
  13975. }
  13976. /**
  13977. * Produces a random number between the inclusive `lower` and `upper` bounds.
  13978. * If only one argument is provided a number between `0` and the given number
  13979. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  13980. * floats, a floating-point number is returned instead of an integer.
  13981. *
  13982. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  13983. * floating-point values which can produce unexpected results.
  13984. *
  13985. * @static
  13986. * @memberOf _
  13987. * @since 0.7.0
  13988. * @category Number
  13989. * @param {number} [lower=0] The lower bound.
  13990. * @param {number} [upper=1] The upper bound.
  13991. * @param {boolean} [floating] Specify returning a floating-point number.
  13992. * @returns {number} Returns the random number.
  13993. * @example
  13994. *
  13995. * _.random(0, 5);
  13996. * // => an integer between 0 and 5
  13997. *
  13998. * _.random(5);
  13999. * // => also an integer between 0 and 5
  14000. *
  14001. * _.random(5, true);
  14002. * // => a floating-point number between 0 and 5
  14003. *
  14004. * _.random(1.2, 5.2);
  14005. * // => a floating-point number between 1.2 and 5.2
  14006. */
  14007. function random(lower, upper, floating) {
  14008. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  14009. upper = floating = undefined;
  14010. }
  14011. if (floating === undefined) {
  14012. if (typeof upper == 'boolean') {
  14013. floating = upper;
  14014. upper = undefined;
  14015. }
  14016. else if (typeof lower == 'boolean') {
  14017. floating = lower;
  14018. lower = undefined;
  14019. }
  14020. }
  14021. if (lower === undefined && upper === undefined) {
  14022. lower = 0;
  14023. upper = 1;
  14024. }
  14025. else {
  14026. lower = toFinite(lower);
  14027. if (upper === undefined) {
  14028. upper = lower;
  14029. lower = 0;
  14030. } else {
  14031. upper = toFinite(upper);
  14032. }
  14033. }
  14034. if (lower > upper) {
  14035. var temp = lower;
  14036. lower = upper;
  14037. upper = temp;
  14038. }
  14039. if (floating || lower % 1 || upper % 1) {
  14040. var rand = nativeRandom();
  14041. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  14042. }
  14043. return baseRandom(lower, upper);
  14044. }
  14045. /*------------------------------------------------------------------------*/
  14046. /**
  14047. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  14048. *
  14049. * @static
  14050. * @memberOf _
  14051. * @since 3.0.0
  14052. * @category String
  14053. * @param {string} [string=''] The string to convert.
  14054. * @returns {string} Returns the camel cased string.
  14055. * @example
  14056. *
  14057. * _.camelCase('Foo Bar');
  14058. * // => 'fooBar'
  14059. *
  14060. * _.camelCase('--foo-bar--');
  14061. * // => 'fooBar'
  14062. *
  14063. * _.camelCase('__FOO_BAR__');
  14064. * // => 'fooBar'
  14065. */
  14066. var camelCase = createCompounder(function(result, word, index) {
  14067. word = word.toLowerCase();
  14068. return result + (index ? capitalize(word) : word);
  14069. });
  14070. /**
  14071. * Converts the first character of `string` to upper case and the remaining
  14072. * to lower case.
  14073. *
  14074. * @static
  14075. * @memberOf _
  14076. * @since 3.0.0
  14077. * @category String
  14078. * @param {string} [string=''] The string to capitalize.
  14079. * @returns {string} Returns the capitalized string.
  14080. * @example
  14081. *
  14082. * _.capitalize('FRED');
  14083. * // => 'Fred'
  14084. */
  14085. function capitalize(string) {
  14086. return upperFirst(toString(string).toLowerCase());
  14087. }
  14088. /**
  14089. * Deburrs `string` by converting
  14090. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  14091. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  14092. * letters to basic Latin letters and removing
  14093. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  14094. *
  14095. * @static
  14096. * @memberOf _
  14097. * @since 3.0.0
  14098. * @category String
  14099. * @param {string} [string=''] The string to deburr.
  14100. * @returns {string} Returns the deburred string.
  14101. * @example
  14102. *
  14103. * _.deburr('déjà vu');
  14104. * // => 'deja vu'
  14105. */
  14106. function deburr(string) {
  14107. string = toString(string);
  14108. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  14109. }
  14110. /**
  14111. * Checks if `string` ends with the given target string.
  14112. *
  14113. * @static
  14114. * @memberOf _
  14115. * @since 3.0.0
  14116. * @category String
  14117. * @param {string} [string=''] The string to inspect.
  14118. * @param {string} [target] The string to search for.
  14119. * @param {number} [position=string.length] The position to search up to.
  14120. * @returns {boolean} Returns `true` if `string` ends with `target`,
  14121. * else `false`.
  14122. * @example
  14123. *
  14124. * _.endsWith('abc', 'c');
  14125. * // => true
  14126. *
  14127. * _.endsWith('abc', 'b');
  14128. * // => false
  14129. *
  14130. * _.endsWith('abc', 'b', 2);
  14131. * // => true
  14132. */
  14133. function endsWith(string, target, position) {
  14134. string = toString(string);
  14135. target = baseToString(target);
  14136. var length = string.length;
  14137. position = position === undefined
  14138. ? length
  14139. : baseClamp(toInteger(position), 0, length);
  14140. var end = position;
  14141. position -= target.length;
  14142. return position >= 0 && string.slice(position, end) == target;
  14143. }
  14144. /**
  14145. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  14146. * corresponding HTML entities.
  14147. *
  14148. * **Note:** No other characters are escaped. To escape additional
  14149. * characters use a third-party library like [_he_](https://mths.be/he).
  14150. *
  14151. * Though the ">" character is escaped for symmetry, characters like
  14152. * ">" and "/" don't need escaping in HTML and have no special meaning
  14153. * unless they're part of a tag or unquoted attribute value. See
  14154. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  14155. * (under "semi-related fun fact") for more details.
  14156. *
  14157. * When working with HTML you should always
  14158. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  14159. * XSS vectors.
  14160. *
  14161. * @static
  14162. * @since 0.1.0
  14163. * @memberOf _
  14164. * @category String
  14165. * @param {string} [string=''] The string to escape.
  14166. * @returns {string} Returns the escaped string.
  14167. * @example
  14168. *
  14169. * _.escape('fred, barney, & pebbles');
  14170. * // => 'fred, barney, &amp; pebbles'
  14171. */
  14172. function escape(string) {
  14173. string = toString(string);
  14174. return (string && reHasUnescapedHtml.test(string))
  14175. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  14176. : string;
  14177. }
  14178. /**
  14179. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  14180. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  14181. *
  14182. * @static
  14183. * @memberOf _
  14184. * @since 3.0.0
  14185. * @category String
  14186. * @param {string} [string=''] The string to escape.
  14187. * @returns {string} Returns the escaped string.
  14188. * @example
  14189. *
  14190. * _.escapeRegExp('[lodash](https://lodash.com/)');
  14191. * // => '\[lodash\]\(https://lodash\.com/\)'
  14192. */
  14193. function escapeRegExp(string) {
  14194. string = toString(string);
  14195. return (string && reHasRegExpChar.test(string))
  14196. ? string.replace(reRegExpChar, '\\$&')
  14197. : string;
  14198. }
  14199. /**
  14200. * Converts `string` to
  14201. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  14202. *
  14203. * @static
  14204. * @memberOf _
  14205. * @since 3.0.0
  14206. * @category String
  14207. * @param {string} [string=''] The string to convert.
  14208. * @returns {string} Returns the kebab cased string.
  14209. * @example
  14210. *
  14211. * _.kebabCase('Foo Bar');
  14212. * // => 'foo-bar'
  14213. *
  14214. * _.kebabCase('fooBar');
  14215. * // => 'foo-bar'
  14216. *
  14217. * _.kebabCase('__FOO_BAR__');
  14218. * // => 'foo-bar'
  14219. */
  14220. var kebabCase = createCompounder(function(result, word, index) {
  14221. return result + (index ? '-' : '') + word.toLowerCase();
  14222. });
  14223. /**
  14224. * Converts `string`, as space separated words, to lower case.
  14225. *
  14226. * @static
  14227. * @memberOf _
  14228. * @since 4.0.0
  14229. * @category String
  14230. * @param {string} [string=''] The string to convert.
  14231. * @returns {string} Returns the lower cased string.
  14232. * @example
  14233. *
  14234. * _.lowerCase('--Foo-Bar--');
  14235. * // => 'foo bar'
  14236. *
  14237. * _.lowerCase('fooBar');
  14238. * // => 'foo bar'
  14239. *
  14240. * _.lowerCase('__FOO_BAR__');
  14241. * // => 'foo bar'
  14242. */
  14243. var lowerCase = createCompounder(function(result, word, index) {
  14244. return result + (index ? ' ' : '') + word.toLowerCase();
  14245. });
  14246. /**
  14247. * Converts the first character of `string` to lower case.
  14248. *
  14249. * @static
  14250. * @memberOf _
  14251. * @since 4.0.0
  14252. * @category String
  14253. * @param {string} [string=''] The string to convert.
  14254. * @returns {string} Returns the converted string.
  14255. * @example
  14256. *
  14257. * _.lowerFirst('Fred');
  14258. * // => 'fred'
  14259. *
  14260. * _.lowerFirst('FRED');
  14261. * // => 'fRED'
  14262. */
  14263. var lowerFirst = createCaseFirst('toLowerCase');
  14264. /**
  14265. * Pads `string` on the left and right sides if it's shorter than `length`.
  14266. * Padding characters are truncated if they can't be evenly divided by `length`.
  14267. *
  14268. * @static
  14269. * @memberOf _
  14270. * @since 3.0.0
  14271. * @category String
  14272. * @param {string} [string=''] The string to pad.
  14273. * @param {number} [length=0] The padding length.
  14274. * @param {string} [chars=' '] The string used as padding.
  14275. * @returns {string} Returns the padded string.
  14276. * @example
  14277. *
  14278. * _.pad('abc', 8);
  14279. * // => ' abc '
  14280. *
  14281. * _.pad('abc', 8, '_-');
  14282. * // => '_-abc_-_'
  14283. *
  14284. * _.pad('abc', 3);
  14285. * // => 'abc'
  14286. */
  14287. function pad(string, length, chars) {
  14288. string = toString(string);
  14289. length = toInteger(length);
  14290. var strLength = length ? stringSize(string) : 0;
  14291. if (!length || strLength >= length) {
  14292. return string;
  14293. }
  14294. var mid = (length - strLength) / 2;
  14295. return (
  14296. createPadding(nativeFloor(mid), chars) +
  14297. string +
  14298. createPadding(nativeCeil(mid), chars)
  14299. );
  14300. }
  14301. /**
  14302. * Pads `string` on the right side if it's shorter than `length`. Padding
  14303. * characters are truncated if they exceed `length`.
  14304. *
  14305. * @static
  14306. * @memberOf _
  14307. * @since 4.0.0
  14308. * @category String
  14309. * @param {string} [string=''] The string to pad.
  14310. * @param {number} [length=0] The padding length.
  14311. * @param {string} [chars=' '] The string used as padding.
  14312. * @returns {string} Returns the padded string.
  14313. * @example
  14314. *
  14315. * _.padEnd('abc', 6);
  14316. * // => 'abc '
  14317. *
  14318. * _.padEnd('abc', 6, '_-');
  14319. * // => 'abc_-_'
  14320. *
  14321. * _.padEnd('abc', 3);
  14322. * // => 'abc'
  14323. */
  14324. function padEnd(string, length, chars) {
  14325. string = toString(string);
  14326. length = toInteger(length);
  14327. var strLength = length ? stringSize(string) : 0;
  14328. return (length && strLength < length)
  14329. ? (string + createPadding(length - strLength, chars))
  14330. : string;
  14331. }
  14332. /**
  14333. * Pads `string` on the left side if it's shorter than `length`. Padding
  14334. * characters are truncated if they exceed `length`.
  14335. *
  14336. * @static
  14337. * @memberOf _
  14338. * @since 4.0.0
  14339. * @category String
  14340. * @param {string} [string=''] The string to pad.
  14341. * @param {number} [length=0] The padding length.
  14342. * @param {string} [chars=' '] The string used as padding.
  14343. * @returns {string} Returns the padded string.
  14344. * @example
  14345. *
  14346. * _.padStart('abc', 6);
  14347. * // => ' abc'
  14348. *
  14349. * _.padStart('abc', 6, '_-');
  14350. * // => '_-_abc'
  14351. *
  14352. * _.padStart('abc', 3);
  14353. * // => 'abc'
  14354. */
  14355. function padStart(string, length, chars) {
  14356. string = toString(string);
  14357. length = toInteger(length);
  14358. var strLength = length ? stringSize(string) : 0;
  14359. return (length && strLength < length)
  14360. ? (createPadding(length - strLength, chars) + string)
  14361. : string;
  14362. }
  14363. /**
  14364. * Converts `string` to an integer of the specified radix. If `radix` is
  14365. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  14366. * hexadecimal, in which case a `radix` of `16` is used.
  14367. *
  14368. * **Note:** This method aligns with the
  14369. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  14370. *
  14371. * @static
  14372. * @memberOf _
  14373. * @since 1.1.0
  14374. * @category String
  14375. * @param {string} string The string to convert.
  14376. * @param {number} [radix=10] The radix to interpret `value` by.
  14377. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14378. * @returns {number} Returns the converted integer.
  14379. * @example
  14380. *
  14381. * _.parseInt('08');
  14382. * // => 8
  14383. *
  14384. * _.map(['6', '08', '10'], _.parseInt);
  14385. * // => [6, 8, 10]
  14386. */
  14387. function parseInt(string, radix, guard) {
  14388. if (guard || radix == null) {
  14389. radix = 0;
  14390. } else if (radix) {
  14391. radix = +radix;
  14392. }
  14393. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  14394. }
  14395. /**
  14396. * Repeats the given string `n` times.
  14397. *
  14398. * @static
  14399. * @memberOf _
  14400. * @since 3.0.0
  14401. * @category String
  14402. * @param {string} [string=''] The string to repeat.
  14403. * @param {number} [n=1] The number of times to repeat the string.
  14404. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14405. * @returns {string} Returns the repeated string.
  14406. * @example
  14407. *
  14408. * _.repeat('*', 3);
  14409. * // => '***'
  14410. *
  14411. * _.repeat('abc', 2);
  14412. * // => 'abcabc'
  14413. *
  14414. * _.repeat('abc', 0);
  14415. * // => ''
  14416. */
  14417. function repeat(string, n, guard) {
  14418. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  14419. n = 1;
  14420. } else {
  14421. n = toInteger(n);
  14422. }
  14423. return baseRepeat(toString(string), n);
  14424. }
  14425. /**
  14426. * Replaces matches for `pattern` in `string` with `replacement`.
  14427. *
  14428. * **Note:** This method is based on
  14429. * [`String#replace`](https://mdn.io/String/replace).
  14430. *
  14431. * @static
  14432. * @memberOf _
  14433. * @since 4.0.0
  14434. * @category String
  14435. * @param {string} [string=''] The string to modify.
  14436. * @param {RegExp|string} pattern The pattern to replace.
  14437. * @param {Function|string} replacement The match replacement.
  14438. * @returns {string} Returns the modified string.
  14439. * @example
  14440. *
  14441. * _.replace('Hi Fred', 'Fred', 'Barney');
  14442. * // => 'Hi Barney'
  14443. */
  14444. function replace() {
  14445. var args = arguments,
  14446. string = toString(args[0]);
  14447. return args.length < 3 ? string : string.replace(args[1], args[2]);
  14448. }
  14449. /**
  14450. * Converts `string` to
  14451. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  14452. *
  14453. * @static
  14454. * @memberOf _
  14455. * @since 3.0.0
  14456. * @category String
  14457. * @param {string} [string=''] The string to convert.
  14458. * @returns {string} Returns the snake cased string.
  14459. * @example
  14460. *
  14461. * _.snakeCase('Foo Bar');
  14462. * // => 'foo_bar'
  14463. *
  14464. * _.snakeCase('fooBar');
  14465. * // => 'foo_bar'
  14466. *
  14467. * _.snakeCase('--FOO-BAR--');
  14468. * // => 'foo_bar'
  14469. */
  14470. var snakeCase = createCompounder(function(result, word, index) {
  14471. return result + (index ? '_' : '') + word.toLowerCase();
  14472. });
  14473. /**
  14474. * Splits `string` by `separator`.
  14475. *
  14476. * **Note:** This method is based on
  14477. * [`String#split`](https://mdn.io/String/split).
  14478. *
  14479. * @static
  14480. * @memberOf _
  14481. * @since 4.0.0
  14482. * @category String
  14483. * @param {string} [string=''] The string to split.
  14484. * @param {RegExp|string} separator The separator pattern to split by.
  14485. * @param {number} [limit] The length to truncate results to.
  14486. * @returns {Array} Returns the string segments.
  14487. * @example
  14488. *
  14489. * _.split('a-b-c', '-', 2);
  14490. * // => ['a', 'b']
  14491. */
  14492. function split(string, separator, limit) {
  14493. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  14494. separator = limit = undefined;
  14495. }
  14496. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  14497. if (!limit) {
  14498. return [];
  14499. }
  14500. string = toString(string);
  14501. if (string && (
  14502. typeof separator == 'string' ||
  14503. (separator != null && !isRegExp(separator))
  14504. )) {
  14505. separator = baseToString(separator);
  14506. if (!separator && hasUnicode(string)) {
  14507. return castSlice(stringToArray(string), 0, limit);
  14508. }
  14509. }
  14510. return string.split(separator, limit);
  14511. }
  14512. /**
  14513. * Converts `string` to
  14514. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  14515. *
  14516. * @static
  14517. * @memberOf _
  14518. * @since 3.1.0
  14519. * @category String
  14520. * @param {string} [string=''] The string to convert.
  14521. * @returns {string} Returns the start cased string.
  14522. * @example
  14523. *
  14524. * _.startCase('--foo-bar--');
  14525. * // => 'Foo Bar'
  14526. *
  14527. * _.startCase('fooBar');
  14528. * // => 'Foo Bar'
  14529. *
  14530. * _.startCase('__FOO_BAR__');
  14531. * // => 'FOO BAR'
  14532. */
  14533. var startCase = createCompounder(function(result, word, index) {
  14534. return result + (index ? ' ' : '') + upperFirst(word);
  14535. });
  14536. /**
  14537. * Checks if `string` starts with the given target string.
  14538. *
  14539. * @static
  14540. * @memberOf _
  14541. * @since 3.0.0
  14542. * @category String
  14543. * @param {string} [string=''] The string to inspect.
  14544. * @param {string} [target] The string to search for.
  14545. * @param {number} [position=0] The position to search from.
  14546. * @returns {boolean} Returns `true` if `string` starts with `target`,
  14547. * else `false`.
  14548. * @example
  14549. *
  14550. * _.startsWith('abc', 'a');
  14551. * // => true
  14552. *
  14553. * _.startsWith('abc', 'b');
  14554. * // => false
  14555. *
  14556. * _.startsWith('abc', 'b', 1);
  14557. * // => true
  14558. */
  14559. function startsWith(string, target, position) {
  14560. string = toString(string);
  14561. position = position == null
  14562. ? 0
  14563. : baseClamp(toInteger(position), 0, string.length);
  14564. target = baseToString(target);
  14565. return string.slice(position, position + target.length) == target;
  14566. }
  14567. /**
  14568. * Creates a compiled template function that can interpolate data properties
  14569. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  14570. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  14571. * properties may be accessed as free variables in the template. If a setting
  14572. * object is given, it takes precedence over `_.templateSettings` values.
  14573. *
  14574. * **Note:** In the development build `_.template` utilizes
  14575. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  14576. * for easier debugging.
  14577. *
  14578. * For more information on precompiling templates see
  14579. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  14580. *
  14581. * For more information on Chrome extension sandboxes see
  14582. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  14583. *
  14584. * @static
  14585. * @since 0.1.0
  14586. * @memberOf _
  14587. * @category String
  14588. * @param {string} [string=''] The template string.
  14589. * @param {Object} [options={}] The options object.
  14590. * @param {RegExp} [options.escape=_.templateSettings.escape]
  14591. * The HTML "escape" delimiter.
  14592. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  14593. * The "evaluate" delimiter.
  14594. * @param {Object} [options.imports=_.templateSettings.imports]
  14595. * An object to import into the template as free variables.
  14596. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  14597. * The "interpolate" delimiter.
  14598. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  14599. * The sourceURL of the compiled template.
  14600. * @param {string} [options.variable='obj']
  14601. * The data object variable name.
  14602. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14603. * @returns {Function} Returns the compiled template function.
  14604. * @example
  14605. *
  14606. * // Use the "interpolate" delimiter to create a compiled template.
  14607. * var compiled = _.template('hello <%= user %>!');
  14608. * compiled({ 'user': 'fred' });
  14609. * // => 'hello fred!'
  14610. *
  14611. * // Use the HTML "escape" delimiter to escape data property values.
  14612. * var compiled = _.template('<b><%- value %></b>');
  14613. * compiled({ 'value': '<script>' });
  14614. * // => '<b>&lt;script&gt;</b>'
  14615. *
  14616. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  14617. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  14618. * compiled({ 'users': ['fred', 'barney'] });
  14619. * // => '<li>fred</li><li>barney</li>'
  14620. *
  14621. * // Use the internal `print` function in "evaluate" delimiters.
  14622. * var compiled = _.template('<% print("hello " + user); %>!');
  14623. * compiled({ 'user': 'barney' });
  14624. * // => 'hello barney!'
  14625. *
  14626. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  14627. * // Disable support by replacing the "interpolate" delimiter.
  14628. * var compiled = _.template('hello ${ user }!');
  14629. * compiled({ 'user': 'pebbles' });
  14630. * // => 'hello pebbles!'
  14631. *
  14632. * // Use backslashes to treat delimiters as plain text.
  14633. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  14634. * compiled({ 'value': 'ignored' });
  14635. * // => '<%- value %>'
  14636. *
  14637. * // Use the `imports` option to import `jQuery` as `jq`.
  14638. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  14639. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  14640. * compiled({ 'users': ['fred', 'barney'] });
  14641. * // => '<li>fred</li><li>barney</li>'
  14642. *
  14643. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  14644. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  14645. * compiled(data);
  14646. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  14647. *
  14648. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  14649. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  14650. * compiled.source;
  14651. * // => function(data) {
  14652. * // var __t, __p = '';
  14653. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  14654. * // return __p;
  14655. * // }
  14656. *
  14657. * // Use custom template delimiters.
  14658. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  14659. * var compiled = _.template('hello {{ user }}!');
  14660. * compiled({ 'user': 'mustache' });
  14661. * // => 'hello mustache!'
  14662. *
  14663. * // Use the `source` property to inline compiled templates for meaningful
  14664. * // line numbers in error messages and stack traces.
  14665. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  14666. * var JST = {\
  14667. * "main": ' + _.template(mainText).source + '\
  14668. * };\
  14669. * ');
  14670. */
  14671. function template(string, options, guard) {
  14672. // Based on John Resig's `tmpl` implementation
  14673. // (http://ejohn.org/blog/javascript-micro-templating/)
  14674. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  14675. var settings = lodash.templateSettings;
  14676. if (guard && isIterateeCall(string, options, guard)) {
  14677. options = undefined;
  14678. }
  14679. string = toString(string);
  14680. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  14681. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  14682. importsKeys = keys(imports),
  14683. importsValues = baseValues(imports, importsKeys);
  14684. var isEscaping,
  14685. isEvaluating,
  14686. index = 0,
  14687. interpolate = options.interpolate || reNoMatch,
  14688. source = "__p += '";
  14689. // Compile the regexp to match each delimiter.
  14690. var reDelimiters = RegExp(
  14691. (options.escape || reNoMatch).source + '|' +
  14692. interpolate.source + '|' +
  14693. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  14694. (options.evaluate || reNoMatch).source + '|$'
  14695. , 'g');
  14696. // Use a sourceURL for easier debugging.
  14697. var sourceURL = '//# sourceURL=' +
  14698. ('sourceURL' in options
  14699. ? options.sourceURL
  14700. : ('lodash.templateSources[' + (++templateCounter) + ']')
  14701. ) + '\n';
  14702. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  14703. interpolateValue || (interpolateValue = esTemplateValue);
  14704. // Escape characters that can't be included in string literals.
  14705. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  14706. // Replace delimiters with snippets.
  14707. if (escapeValue) {
  14708. isEscaping = true;
  14709. source += "' +\n__e(" + escapeValue + ") +\n'";
  14710. }
  14711. if (evaluateValue) {
  14712. isEvaluating = true;
  14713. source += "';\n" + evaluateValue + ";\n__p += '";
  14714. }
  14715. if (interpolateValue) {
  14716. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  14717. }
  14718. index = offset + match.length;
  14719. // The JS engine embedded in Adobe products needs `match` returned in
  14720. // order to produce the correct `offset` value.
  14721. return match;
  14722. });
  14723. source += "';\n";
  14724. // If `variable` is not specified wrap a with-statement around the generated
  14725. // code to add the data object to the top of the scope chain.
  14726. var variable = options.variable;
  14727. if (!variable) {
  14728. source = 'with (obj) {\n' + source + '\n}\n';
  14729. }
  14730. // Cleanup code by stripping empty strings.
  14731. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  14732. .replace(reEmptyStringMiddle, '$1')
  14733. .replace(reEmptyStringTrailing, '$1;');
  14734. // Frame code as the function body.
  14735. source = 'function(' + (variable || 'obj') + ') {\n' +
  14736. (variable
  14737. ? ''
  14738. : 'obj || (obj = {});\n'
  14739. ) +
  14740. "var __t, __p = ''" +
  14741. (isEscaping
  14742. ? ', __e = _.escape'
  14743. : ''
  14744. ) +
  14745. (isEvaluating
  14746. ? ', __j = Array.prototype.join;\n' +
  14747. "function print() { __p += __j.call(arguments, '') }\n"
  14748. : ';\n'
  14749. ) +
  14750. source +
  14751. 'return __p\n}';
  14752. var result = attempt(function() {
  14753. return Function(importsKeys, sourceURL + 'return ' + source)
  14754. .apply(undefined, importsValues);
  14755. });
  14756. // Provide the compiled function's source by its `toString` method or
  14757. // the `source` property as a convenience for inlining compiled templates.
  14758. result.source = source;
  14759. if (isError(result)) {
  14760. throw result;
  14761. }
  14762. return result;
  14763. }
  14764. /**
  14765. * Converts `string`, as a whole, to lower case just like
  14766. * [String#toLowerCase](https://mdn.io/toLowerCase).
  14767. *
  14768. * @static
  14769. * @memberOf _
  14770. * @since 4.0.0
  14771. * @category String
  14772. * @param {string} [string=''] The string to convert.
  14773. * @returns {string} Returns the lower cased string.
  14774. * @example
  14775. *
  14776. * _.toLower('--Foo-Bar--');
  14777. * // => '--foo-bar--'
  14778. *
  14779. * _.toLower('fooBar');
  14780. * // => 'foobar'
  14781. *
  14782. * _.toLower('__FOO_BAR__');
  14783. * // => '__foo_bar__'
  14784. */
  14785. function toLower(value) {
  14786. return toString(value).toLowerCase();
  14787. }
  14788. /**
  14789. * Converts `string`, as a whole, to upper case just like
  14790. * [String#toUpperCase](https://mdn.io/toUpperCase).
  14791. *
  14792. * @static
  14793. * @memberOf _
  14794. * @since 4.0.0
  14795. * @category String
  14796. * @param {string} [string=''] The string to convert.
  14797. * @returns {string} Returns the upper cased string.
  14798. * @example
  14799. *
  14800. * _.toUpper('--foo-bar--');
  14801. * // => '--FOO-BAR--'
  14802. *
  14803. * _.toUpper('fooBar');
  14804. * // => 'FOOBAR'
  14805. *
  14806. * _.toUpper('__foo_bar__');
  14807. * // => '__FOO_BAR__'
  14808. */
  14809. function toUpper(value) {
  14810. return toString(value).toUpperCase();
  14811. }
  14812. /**
  14813. * Removes leading and trailing whitespace or specified characters from `string`.
  14814. *
  14815. * @static
  14816. * @memberOf _
  14817. * @since 3.0.0
  14818. * @category String
  14819. * @param {string} [string=''] The string to trim.
  14820. * @param {string} [chars=whitespace] The characters to trim.
  14821. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14822. * @returns {string} Returns the trimmed string.
  14823. * @example
  14824. *
  14825. * _.trim(' abc ');
  14826. * // => 'abc'
  14827. *
  14828. * _.trim('-_-abc-_-', '_-');
  14829. * // => 'abc'
  14830. *
  14831. * _.map([' foo ', ' bar '], _.trim);
  14832. * // => ['foo', 'bar']
  14833. */
  14834. function trim(string, chars, guard) {
  14835. string = toString(string);
  14836. if (string && (guard || chars === undefined)) {
  14837. return string.replace(reTrim, '');
  14838. }
  14839. if (!string || !(chars = baseToString(chars))) {
  14840. return string;
  14841. }
  14842. var strSymbols = stringToArray(string),
  14843. chrSymbols = stringToArray(chars),
  14844. start = charsStartIndex(strSymbols, chrSymbols),
  14845. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  14846. return castSlice(strSymbols, start, end).join('');
  14847. }
  14848. /**
  14849. * Removes trailing whitespace or specified characters from `string`.
  14850. *
  14851. * @static
  14852. * @memberOf _
  14853. * @since 4.0.0
  14854. * @category String
  14855. * @param {string} [string=''] The string to trim.
  14856. * @param {string} [chars=whitespace] The characters to trim.
  14857. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14858. * @returns {string} Returns the trimmed string.
  14859. * @example
  14860. *
  14861. * _.trimEnd(' abc ');
  14862. * // => ' abc'
  14863. *
  14864. * _.trimEnd('-_-abc-_-', '_-');
  14865. * // => '-_-abc'
  14866. */
  14867. function trimEnd(string, chars, guard) {
  14868. string = toString(string);
  14869. if (string && (guard || chars === undefined)) {
  14870. return string.replace(reTrimEnd, '');
  14871. }
  14872. if (!string || !(chars = baseToString(chars))) {
  14873. return string;
  14874. }
  14875. var strSymbols = stringToArray(string),
  14876. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  14877. return castSlice(strSymbols, 0, end).join('');
  14878. }
  14879. /**
  14880. * Removes leading whitespace or specified characters from `string`.
  14881. *
  14882. * @static
  14883. * @memberOf _
  14884. * @since 4.0.0
  14885. * @category String
  14886. * @param {string} [string=''] The string to trim.
  14887. * @param {string} [chars=whitespace] The characters to trim.
  14888. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14889. * @returns {string} Returns the trimmed string.
  14890. * @example
  14891. *
  14892. * _.trimStart(' abc ');
  14893. * // => 'abc '
  14894. *
  14895. * _.trimStart('-_-abc-_-', '_-');
  14896. * // => 'abc-_-'
  14897. */
  14898. function trimStart(string, chars, guard) {
  14899. string = toString(string);
  14900. if (string && (guard || chars === undefined)) {
  14901. return string.replace(reTrimStart, '');
  14902. }
  14903. if (!string || !(chars = baseToString(chars))) {
  14904. return string;
  14905. }
  14906. var strSymbols = stringToArray(string),
  14907. start = charsStartIndex(strSymbols, stringToArray(chars));
  14908. return castSlice(strSymbols, start).join('');
  14909. }
  14910. /**
  14911. * Truncates `string` if it's longer than the given maximum string length.
  14912. * The last characters of the truncated string are replaced with the omission
  14913. * string which defaults to "...".
  14914. *
  14915. * @static
  14916. * @memberOf _
  14917. * @since 4.0.0
  14918. * @category String
  14919. * @param {string} [string=''] The string to truncate.
  14920. * @param {Object} [options={}] The options object.
  14921. * @param {number} [options.length=30] The maximum string length.
  14922. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  14923. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  14924. * @returns {string} Returns the truncated string.
  14925. * @example
  14926. *
  14927. * _.truncate('hi-diddly-ho there, neighborino');
  14928. * // => 'hi-diddly-ho there, neighbo...'
  14929. *
  14930. * _.truncate('hi-diddly-ho there, neighborino', {
  14931. * 'length': 24,
  14932. * 'separator': ' '
  14933. * });
  14934. * // => 'hi-diddly-ho there,...'
  14935. *
  14936. * _.truncate('hi-diddly-ho there, neighborino', {
  14937. * 'length': 24,
  14938. * 'separator': /,? +/
  14939. * });
  14940. * // => 'hi-diddly-ho there...'
  14941. *
  14942. * _.truncate('hi-diddly-ho there, neighborino', {
  14943. * 'omission': ' [...]'
  14944. * });
  14945. * // => 'hi-diddly-ho there, neig [...]'
  14946. */
  14947. function truncate(string, options) {
  14948. var length = DEFAULT_TRUNC_LENGTH,
  14949. omission = DEFAULT_TRUNC_OMISSION;
  14950. if (isObject(options)) {
  14951. var separator = 'separator' in options ? options.separator : separator;
  14952. length = 'length' in options ? toInteger(options.length) : length;
  14953. omission = 'omission' in options ? baseToString(options.omission) : omission;
  14954. }
  14955. string = toString(string);
  14956. var strLength = string.length;
  14957. if (hasUnicode(string)) {
  14958. var strSymbols = stringToArray(string);
  14959. strLength = strSymbols.length;
  14960. }
  14961. if (length >= strLength) {
  14962. return string;
  14963. }
  14964. var end = length - stringSize(omission);
  14965. if (end < 1) {
  14966. return omission;
  14967. }
  14968. var result = strSymbols
  14969. ? castSlice(strSymbols, 0, end).join('')
  14970. : string.slice(0, end);
  14971. if (separator === undefined) {
  14972. return result + omission;
  14973. }
  14974. if (strSymbols) {
  14975. end += (result.length - end);
  14976. }
  14977. if (isRegExp(separator)) {
  14978. if (string.slice(end).search(separator)) {
  14979. var match,
  14980. substring = result;
  14981. if (!separator.global) {
  14982. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  14983. }
  14984. separator.lastIndex = 0;
  14985. while ((match = separator.exec(substring))) {
  14986. var newEnd = match.index;
  14987. }
  14988. result = result.slice(0, newEnd === undefined ? end : newEnd);
  14989. }
  14990. } else if (string.indexOf(baseToString(separator), end) != end) {
  14991. var index = result.lastIndexOf(separator);
  14992. if (index > -1) {
  14993. result = result.slice(0, index);
  14994. }
  14995. }
  14996. return result + omission;
  14997. }
  14998. /**
  14999. * The inverse of `_.escape`; this method converts the HTML entities
  15000. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  15001. * their corresponding characters.
  15002. *
  15003. * **Note:** No other HTML entities are unescaped. To unescape additional
  15004. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  15005. *
  15006. * @static
  15007. * @memberOf _
  15008. * @since 0.6.0
  15009. * @category String
  15010. * @param {string} [string=''] The string to unescape.
  15011. * @returns {string} Returns the unescaped string.
  15012. * @example
  15013. *
  15014. * _.unescape('fred, barney, &amp; pebbles');
  15015. * // => 'fred, barney, & pebbles'
  15016. */
  15017. function unescape(string) {
  15018. string = toString(string);
  15019. return (string && reHasEscapedHtml.test(string))
  15020. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  15021. : string;
  15022. }
  15023. /**
  15024. * Converts `string`, as space separated words, to upper case.
  15025. *
  15026. * @static
  15027. * @memberOf _
  15028. * @since 4.0.0
  15029. * @category String
  15030. * @param {string} [string=''] The string to convert.
  15031. * @returns {string} Returns the upper cased string.
  15032. * @example
  15033. *
  15034. * _.upperCase('--foo-bar');
  15035. * // => 'FOO BAR'
  15036. *
  15037. * _.upperCase('fooBar');
  15038. * // => 'FOO BAR'
  15039. *
  15040. * _.upperCase('__foo_bar__');
  15041. * // => 'FOO BAR'
  15042. */
  15043. var upperCase = createCompounder(function(result, word, index) {
  15044. return result + (index ? ' ' : '') + word.toUpperCase();
  15045. });
  15046. /**
  15047. * Converts the first character of `string` to upper case.
  15048. *
  15049. * @static
  15050. * @memberOf _
  15051. * @since 4.0.0
  15052. * @category String
  15053. * @param {string} [string=''] The string to convert.
  15054. * @returns {string} Returns the converted string.
  15055. * @example
  15056. *
  15057. * _.upperFirst('fred');
  15058. * // => 'Fred'
  15059. *
  15060. * _.upperFirst('FRED');
  15061. * // => 'FRED'
  15062. */
  15063. var upperFirst = createCaseFirst('toUpperCase');
  15064. /**
  15065. * Splits `string` into an array of its words.
  15066. *
  15067. * @static
  15068. * @memberOf _
  15069. * @since 3.0.0
  15070. * @category String
  15071. * @param {string} [string=''] The string to inspect.
  15072. * @param {RegExp|string} [pattern] The pattern to match words.
  15073. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15074. * @returns {Array} Returns the words of `string`.
  15075. * @example
  15076. *
  15077. * _.words('fred, barney, & pebbles');
  15078. * // => ['fred', 'barney', 'pebbles']
  15079. *
  15080. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  15081. * // => ['fred', 'barney', '&', 'pebbles']
  15082. */
  15083. function words(string, pattern, guard) {
  15084. string = toString(string);
  15085. pattern = guard ? undefined : pattern;
  15086. if (pattern === undefined) {
  15087. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  15088. }
  15089. return string.match(pattern) || [];
  15090. }
  15091. /*------------------------------------------------------------------------*/
  15092. /**
  15093. * Attempts to invoke `func`, returning either the result or the caught error
  15094. * object. Any additional arguments are provided to `func` when it's invoked.
  15095. *
  15096. * @static
  15097. * @memberOf _
  15098. * @since 3.0.0
  15099. * @category Util
  15100. * @param {Function} func The function to attempt.
  15101. * @param {...*} [args] The arguments to invoke `func` with.
  15102. * @returns {*} Returns the `func` result or error object.
  15103. * @example
  15104. *
  15105. * // Avoid throwing errors for invalid selectors.
  15106. * var elements = _.attempt(function(selector) {
  15107. * return document.querySelectorAll(selector);
  15108. * }, '>_>');
  15109. *
  15110. * if (_.isError(elements)) {
  15111. * elements = [];
  15112. * }
  15113. */
  15114. var attempt = baseRest(function(func, args) {
  15115. try {
  15116. return apply(func, undefined, args);
  15117. } catch (e) {
  15118. return isError(e) ? e : new Error(e);
  15119. }
  15120. });
  15121. /**
  15122. * Binds methods of an object to the object itself, overwriting the existing
  15123. * method.
  15124. *
  15125. * **Note:** This method doesn't set the "length" property of bound functions.
  15126. *
  15127. * @static
  15128. * @since 0.1.0
  15129. * @memberOf _
  15130. * @category Util
  15131. * @param {Object} object The object to bind and assign the bound methods to.
  15132. * @param {...(string|string[])} methodNames The object method names to bind.
  15133. * @returns {Object} Returns `object`.
  15134. * @example
  15135. *
  15136. * var view = {
  15137. * 'label': 'docs',
  15138. * 'click': function() {
  15139. * console.log('clicked ' + this.label);
  15140. * }
  15141. * };
  15142. *
  15143. * _.bindAll(view, ['click']);
  15144. * jQuery(element).on('click', view.click);
  15145. * // => Logs 'clicked docs' when clicked.
  15146. */
  15147. var bindAll = flatRest(function(object, methodNames) {
  15148. arrayEach(methodNames, function(key) {
  15149. key = toKey(key);
  15150. baseAssignValue(object, key, bind(object[key], object));
  15151. });
  15152. return object;
  15153. });
  15154. /**
  15155. * Creates a function that iterates over `pairs` and invokes the corresponding
  15156. * function of the first predicate to return truthy. The predicate-function
  15157. * pairs are invoked with the `this` binding and arguments of the created
  15158. * function.
  15159. *
  15160. * @static
  15161. * @memberOf _
  15162. * @since 4.0.0
  15163. * @category Util
  15164. * @param {Array} pairs The predicate-function pairs.
  15165. * @returns {Function} Returns the new composite function.
  15166. * @example
  15167. *
  15168. * var func = _.cond([
  15169. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  15170. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  15171. * [_.stubTrue, _.constant('no match')]
  15172. * ]);
  15173. *
  15174. * func({ 'a': 1, 'b': 2 });
  15175. * // => 'matches A'
  15176. *
  15177. * func({ 'a': 0, 'b': 1 });
  15178. * // => 'matches B'
  15179. *
  15180. * func({ 'a': '1', 'b': '2' });
  15181. * // => 'no match'
  15182. */
  15183. function cond(pairs) {
  15184. var length = pairs == null ? 0 : pairs.length,
  15185. toIteratee = getIteratee();
  15186. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  15187. if (typeof pair[1] != 'function') {
  15188. throw new TypeError(FUNC_ERROR_TEXT);
  15189. }
  15190. return [toIteratee(pair[0]), pair[1]];
  15191. });
  15192. return baseRest(function(args) {
  15193. var index = -1;
  15194. while (++index < length) {
  15195. var pair = pairs[index];
  15196. if (apply(pair[0], this, args)) {
  15197. return apply(pair[1], this, args);
  15198. }
  15199. }
  15200. });
  15201. }
  15202. /**
  15203. * Creates a function that invokes the predicate properties of `source` with
  15204. * the corresponding property values of a given object, returning `true` if
  15205. * all predicates return truthy, else `false`.
  15206. *
  15207. * **Note:** The created function is equivalent to `_.conformsTo` with
  15208. * `source` partially applied.
  15209. *
  15210. * @static
  15211. * @memberOf _
  15212. * @since 4.0.0
  15213. * @category Util
  15214. * @param {Object} source The object of property predicates to conform to.
  15215. * @returns {Function} Returns the new spec function.
  15216. * @example
  15217. *
  15218. * var objects = [
  15219. * { 'a': 2, 'b': 1 },
  15220. * { 'a': 1, 'b': 2 }
  15221. * ];
  15222. *
  15223. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  15224. * // => [{ 'a': 1, 'b': 2 }]
  15225. */
  15226. function conforms(source) {
  15227. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  15228. }
  15229. /**
  15230. * Creates a function that returns `value`.
  15231. *
  15232. * @static
  15233. * @memberOf _
  15234. * @since 2.4.0
  15235. * @category Util
  15236. * @param {*} value The value to return from the new function.
  15237. * @returns {Function} Returns the new constant function.
  15238. * @example
  15239. *
  15240. * var objects = _.times(2, _.constant({ 'a': 1 }));
  15241. *
  15242. * console.log(objects);
  15243. * // => [{ 'a': 1 }, { 'a': 1 }]
  15244. *
  15245. * console.log(objects[0] === objects[1]);
  15246. * // => true
  15247. */
  15248. function constant(value) {
  15249. return function() {
  15250. return value;
  15251. };
  15252. }
  15253. /**
  15254. * Checks `value` to determine whether a default value should be returned in
  15255. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  15256. * or `undefined`.
  15257. *
  15258. * @static
  15259. * @memberOf _
  15260. * @since 4.14.0
  15261. * @category Util
  15262. * @param {*} value The value to check.
  15263. * @param {*} defaultValue The default value.
  15264. * @returns {*} Returns the resolved value.
  15265. * @example
  15266. *
  15267. * _.defaultTo(1, 10);
  15268. * // => 1
  15269. *
  15270. * _.defaultTo(undefined, 10);
  15271. * // => 10
  15272. */
  15273. function defaultTo(value, defaultValue) {
  15274. return (value == null || value !== value) ? defaultValue : value;
  15275. }
  15276. /**
  15277. * Creates a function that returns the result of invoking the given functions
  15278. * with the `this` binding of the created function, where each successive
  15279. * invocation is supplied the return value of the previous.
  15280. *
  15281. * @static
  15282. * @memberOf _
  15283. * @since 3.0.0
  15284. * @category Util
  15285. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  15286. * @returns {Function} Returns the new composite function.
  15287. * @see _.flowRight
  15288. * @example
  15289. *
  15290. * function square(n) {
  15291. * return n * n;
  15292. * }
  15293. *
  15294. * var addSquare = _.flow([_.add, square]);
  15295. * addSquare(1, 2);
  15296. * // => 9
  15297. */
  15298. var flow = createFlow();
  15299. /**
  15300. * This method is like `_.flow` except that it creates a function that
  15301. * invokes the given functions from right to left.
  15302. *
  15303. * @static
  15304. * @since 3.0.0
  15305. * @memberOf _
  15306. * @category Util
  15307. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  15308. * @returns {Function} Returns the new composite function.
  15309. * @see _.flow
  15310. * @example
  15311. *
  15312. * function square(n) {
  15313. * return n * n;
  15314. * }
  15315. *
  15316. * var addSquare = _.flowRight([square, _.add]);
  15317. * addSquare(1, 2);
  15318. * // => 9
  15319. */
  15320. var flowRight = createFlow(true);
  15321. /**
  15322. * This method returns the first argument it receives.
  15323. *
  15324. * @static
  15325. * @since 0.1.0
  15326. * @memberOf _
  15327. * @category Util
  15328. * @param {*} value Any value.
  15329. * @returns {*} Returns `value`.
  15330. * @example
  15331. *
  15332. * var object = { 'a': 1 };
  15333. *
  15334. * console.log(_.identity(object) === object);
  15335. * // => true
  15336. */
  15337. function identity(value) {
  15338. return value;
  15339. }
  15340. /**
  15341. * Creates a function that invokes `func` with the arguments of the created
  15342. * function. If `func` is a property name, the created function returns the
  15343. * property value for a given element. If `func` is an array or object, the
  15344. * created function returns `true` for elements that contain the equivalent
  15345. * source properties, otherwise it returns `false`.
  15346. *
  15347. * @static
  15348. * @since 4.0.0
  15349. * @memberOf _
  15350. * @category Util
  15351. * @param {*} [func=_.identity] The value to convert to a callback.
  15352. * @returns {Function} Returns the callback.
  15353. * @example
  15354. *
  15355. * var users = [
  15356. * { 'user': 'barney', 'age': 36, 'active': true },
  15357. * { 'user': 'fred', 'age': 40, 'active': false }
  15358. * ];
  15359. *
  15360. * // The `_.matches` iteratee shorthand.
  15361. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  15362. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  15363. *
  15364. * // The `_.matchesProperty` iteratee shorthand.
  15365. * _.filter(users, _.iteratee(['user', 'fred']));
  15366. * // => [{ 'user': 'fred', 'age': 40 }]
  15367. *
  15368. * // The `_.property` iteratee shorthand.
  15369. * _.map(users, _.iteratee('user'));
  15370. * // => ['barney', 'fred']
  15371. *
  15372. * // Create custom iteratee shorthands.
  15373. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  15374. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  15375. * return func.test(string);
  15376. * };
  15377. * });
  15378. *
  15379. * _.filter(['abc', 'def'], /ef/);
  15380. * // => ['def']
  15381. */
  15382. function iteratee(func) {
  15383. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  15384. }
  15385. /**
  15386. * Creates a function that performs a partial deep comparison between a given
  15387. * object and `source`, returning `true` if the given object has equivalent
  15388. * property values, else `false`.
  15389. *
  15390. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  15391. * partially applied.
  15392. *
  15393. * Partial comparisons will match empty array and empty object `source`
  15394. * values against any array or object value, respectively. See `_.isEqual`
  15395. * for a list of supported value comparisons.
  15396. *
  15397. * @static
  15398. * @memberOf _
  15399. * @since 3.0.0
  15400. * @category Util
  15401. * @param {Object} source The object of property values to match.
  15402. * @returns {Function} Returns the new spec function.
  15403. * @example
  15404. *
  15405. * var objects = [
  15406. * { 'a': 1, 'b': 2, 'c': 3 },
  15407. * { 'a': 4, 'b': 5, 'c': 6 }
  15408. * ];
  15409. *
  15410. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  15411. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  15412. */
  15413. function matches(source) {
  15414. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  15415. }
  15416. /**
  15417. * Creates a function that performs a partial deep comparison between the
  15418. * value at `path` of a given object to `srcValue`, returning `true` if the
  15419. * object value is equivalent, else `false`.
  15420. *
  15421. * **Note:** Partial comparisons will match empty array and empty object
  15422. * `srcValue` values against any array or object value, respectively. See
  15423. * `_.isEqual` for a list of supported value comparisons.
  15424. *
  15425. * @static
  15426. * @memberOf _
  15427. * @since 3.2.0
  15428. * @category Util
  15429. * @param {Array|string} path The path of the property to get.
  15430. * @param {*} srcValue The value to match.
  15431. * @returns {Function} Returns the new spec function.
  15432. * @example
  15433. *
  15434. * var objects = [
  15435. * { 'a': 1, 'b': 2, 'c': 3 },
  15436. * { 'a': 4, 'b': 5, 'c': 6 }
  15437. * ];
  15438. *
  15439. * _.find(objects, _.matchesProperty('a', 4));
  15440. * // => { 'a': 4, 'b': 5, 'c': 6 }
  15441. */
  15442. function matchesProperty(path, srcValue) {
  15443. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  15444. }
  15445. /**
  15446. * Creates a function that invokes the method at `path` of a given object.
  15447. * Any additional arguments are provided to the invoked method.
  15448. *
  15449. * @static
  15450. * @memberOf _
  15451. * @since 3.7.0
  15452. * @category Util
  15453. * @param {Array|string} path The path of the method to invoke.
  15454. * @param {...*} [args] The arguments to invoke the method with.
  15455. * @returns {Function} Returns the new invoker function.
  15456. * @example
  15457. *
  15458. * var objects = [
  15459. * { 'a': { 'b': _.constant(2) } },
  15460. * { 'a': { 'b': _.constant(1) } }
  15461. * ];
  15462. *
  15463. * _.map(objects, _.method('a.b'));
  15464. * // => [2, 1]
  15465. *
  15466. * _.map(objects, _.method(['a', 'b']));
  15467. * // => [2, 1]
  15468. */
  15469. var method = baseRest(function(path, args) {
  15470. return function(object) {
  15471. return baseInvoke(object, path, args);
  15472. };
  15473. });
  15474. /**
  15475. * The opposite of `_.method`; this method creates a function that invokes
  15476. * the method at a given path of `object`. Any additional arguments are
  15477. * provided to the invoked method.
  15478. *
  15479. * @static
  15480. * @memberOf _
  15481. * @since 3.7.0
  15482. * @category Util
  15483. * @param {Object} object The object to query.
  15484. * @param {...*} [args] The arguments to invoke the method with.
  15485. * @returns {Function} Returns the new invoker function.
  15486. * @example
  15487. *
  15488. * var array = _.times(3, _.constant),
  15489. * object = { 'a': array, 'b': array, 'c': array };
  15490. *
  15491. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  15492. * // => [2, 0]
  15493. *
  15494. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  15495. * // => [2, 0]
  15496. */
  15497. var methodOf = baseRest(function(object, args) {
  15498. return function(path) {
  15499. return baseInvoke(object, path, args);
  15500. };
  15501. });
  15502. /**
  15503. * Adds all own enumerable string keyed function properties of a source
  15504. * object to the destination object. If `object` is a function, then methods
  15505. * are added to its prototype as well.
  15506. *
  15507. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  15508. * avoid conflicts caused by modifying the original.
  15509. *
  15510. * @static
  15511. * @since 0.1.0
  15512. * @memberOf _
  15513. * @category Util
  15514. * @param {Function|Object} [object=lodash] The destination object.
  15515. * @param {Object} source The object of functions to add.
  15516. * @param {Object} [options={}] The options object.
  15517. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  15518. * @returns {Function|Object} Returns `object`.
  15519. * @example
  15520. *
  15521. * function vowels(string) {
  15522. * return _.filter(string, function(v) {
  15523. * return /[aeiou]/i.test(v);
  15524. * });
  15525. * }
  15526. *
  15527. * _.mixin({ 'vowels': vowels });
  15528. * _.vowels('fred');
  15529. * // => ['e']
  15530. *
  15531. * _('fred').vowels().value();
  15532. * // => ['e']
  15533. *
  15534. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  15535. * _('fred').vowels();
  15536. * // => ['e']
  15537. */
  15538. function mixin(object, source, options) {
  15539. var props = keys(source),
  15540. methodNames = baseFunctions(source, props);
  15541. if (options == null &&
  15542. !(isObject(source) && (methodNames.length || !props.length))) {
  15543. options = source;
  15544. source = object;
  15545. object = this;
  15546. methodNames = baseFunctions(source, keys(source));
  15547. }
  15548. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  15549. isFunc = isFunction(object);
  15550. arrayEach(methodNames, function(methodName) {
  15551. var func = source[methodName];
  15552. object[methodName] = func;
  15553. if (isFunc) {
  15554. object.prototype[methodName] = function() {
  15555. var chainAll = this.__chain__;
  15556. if (chain || chainAll) {
  15557. var result = object(this.__wrapped__),
  15558. actions = result.__actions__ = copyArray(this.__actions__);
  15559. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  15560. result.__chain__ = chainAll;
  15561. return result;
  15562. }
  15563. return func.apply(object, arrayPush([this.value()], arguments));
  15564. };
  15565. }
  15566. });
  15567. return object;
  15568. }
  15569. /**
  15570. * Reverts the `_` variable to its previous value and returns a reference to
  15571. * the `lodash` function.
  15572. *
  15573. * @static
  15574. * @since 0.1.0
  15575. * @memberOf _
  15576. * @category Util
  15577. * @returns {Function} Returns the `lodash` function.
  15578. * @example
  15579. *
  15580. * var lodash = _.noConflict();
  15581. */
  15582. function noConflict() {
  15583. if (root._ === this) {
  15584. root._ = oldDash;
  15585. }
  15586. return this;
  15587. }
  15588. /**
  15589. * This method returns `undefined`.
  15590. *
  15591. * @static
  15592. * @memberOf _
  15593. * @since 2.3.0
  15594. * @category Util
  15595. * @example
  15596. *
  15597. * _.times(2, _.noop);
  15598. * // => [undefined, undefined]
  15599. */
  15600. function noop() {
  15601. // No operation performed.
  15602. }
  15603. /**
  15604. * Creates a function that gets the argument at index `n`. If `n` is negative,
  15605. * the nth argument from the end is returned.
  15606. *
  15607. * @static
  15608. * @memberOf _
  15609. * @since 4.0.0
  15610. * @category Util
  15611. * @param {number} [n=0] The index of the argument to return.
  15612. * @returns {Function} Returns the new pass-thru function.
  15613. * @example
  15614. *
  15615. * var func = _.nthArg(1);
  15616. * func('a', 'b', 'c', 'd');
  15617. * // => 'b'
  15618. *
  15619. * var func = _.nthArg(-2);
  15620. * func('a', 'b', 'c', 'd');
  15621. * // => 'c'
  15622. */
  15623. function nthArg(n) {
  15624. n = toInteger(n);
  15625. return baseRest(function(args) {
  15626. return baseNth(args, n);
  15627. });
  15628. }
  15629. /**
  15630. * Creates a function that invokes `iteratees` with the arguments it receives
  15631. * and returns their results.
  15632. *
  15633. * @static
  15634. * @memberOf _
  15635. * @since 4.0.0
  15636. * @category Util
  15637. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  15638. * The iteratees to invoke.
  15639. * @returns {Function} Returns the new function.
  15640. * @example
  15641. *
  15642. * var func = _.over([Math.max, Math.min]);
  15643. *
  15644. * func(1, 2, 3, 4);
  15645. * // => [4, 1]
  15646. */
  15647. var over = createOver(arrayMap);
  15648. /**
  15649. * Creates a function that checks if **all** of the `predicates` return
  15650. * truthy when invoked with the arguments it receives.
  15651. *
  15652. * @static
  15653. * @memberOf _
  15654. * @since 4.0.0
  15655. * @category Util
  15656. * @param {...(Function|Function[])} [predicates=[_.identity]]
  15657. * The predicates to check.
  15658. * @returns {Function} Returns the new function.
  15659. * @example
  15660. *
  15661. * var func = _.overEvery([Boolean, isFinite]);
  15662. *
  15663. * func('1');
  15664. * // => true
  15665. *
  15666. * func(null);
  15667. * // => false
  15668. *
  15669. * func(NaN);
  15670. * // => false
  15671. */
  15672. var overEvery = createOver(arrayEvery);
  15673. /**
  15674. * Creates a function that checks if **any** of the `predicates` return
  15675. * truthy when invoked with the arguments it receives.
  15676. *
  15677. * @static
  15678. * @memberOf _
  15679. * @since 4.0.0
  15680. * @category Util
  15681. * @param {...(Function|Function[])} [predicates=[_.identity]]
  15682. * The predicates to check.
  15683. * @returns {Function} Returns the new function.
  15684. * @example
  15685. *
  15686. * var func = _.overSome([Boolean, isFinite]);
  15687. *
  15688. * func('1');
  15689. * // => true
  15690. *
  15691. * func(null);
  15692. * // => true
  15693. *
  15694. * func(NaN);
  15695. * // => false
  15696. */
  15697. var overSome = createOver(arraySome);
  15698. /**
  15699. * Creates a function that returns the value at `path` of a given object.
  15700. *
  15701. * @static
  15702. * @memberOf _
  15703. * @since 2.4.0
  15704. * @category Util
  15705. * @param {Array|string} path The path of the property to get.
  15706. * @returns {Function} Returns the new accessor function.
  15707. * @example
  15708. *
  15709. * var objects = [
  15710. * { 'a': { 'b': 2 } },
  15711. * { 'a': { 'b': 1 } }
  15712. * ];
  15713. *
  15714. * _.map(objects, _.property('a.b'));
  15715. * // => [2, 1]
  15716. *
  15717. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  15718. * // => [1, 2]
  15719. */
  15720. function property(path) {
  15721. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  15722. }
  15723. /**
  15724. * The opposite of `_.property`; this method creates a function that returns
  15725. * the value at a given path of `object`.
  15726. *
  15727. * @static
  15728. * @memberOf _
  15729. * @since 3.0.0
  15730. * @category Util
  15731. * @param {Object} object The object to query.
  15732. * @returns {Function} Returns the new accessor function.
  15733. * @example
  15734. *
  15735. * var array = [0, 1, 2],
  15736. * object = { 'a': array, 'b': array, 'c': array };
  15737. *
  15738. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  15739. * // => [2, 0]
  15740. *
  15741. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  15742. * // => [2, 0]
  15743. */
  15744. function propertyOf(object) {
  15745. return function(path) {
  15746. return object == null ? undefined : baseGet(object, path);
  15747. };
  15748. }
  15749. /**
  15750. * Creates an array of numbers (positive and/or negative) progressing from
  15751. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  15752. * `start` is specified without an `end` or `step`. If `end` is not specified,
  15753. * it's set to `start` with `start` then set to `0`.
  15754. *
  15755. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  15756. * floating-point values which can produce unexpected results.
  15757. *
  15758. * @static
  15759. * @since 0.1.0
  15760. * @memberOf _
  15761. * @category Util
  15762. * @param {number} [start=0] The start of the range.
  15763. * @param {number} end The end of the range.
  15764. * @param {number} [step=1] The value to increment or decrement by.
  15765. * @returns {Array} Returns the range of numbers.
  15766. * @see _.inRange, _.rangeRight
  15767. * @example
  15768. *
  15769. * _.range(4);
  15770. * // => [0, 1, 2, 3]
  15771. *
  15772. * _.range(-4);
  15773. * // => [0, -1, -2, -3]
  15774. *
  15775. * _.range(1, 5);
  15776. * // => [1, 2, 3, 4]
  15777. *
  15778. * _.range(0, 20, 5);
  15779. * // => [0, 5, 10, 15]
  15780. *
  15781. * _.range(0, -4, -1);
  15782. * // => [0, -1, -2, -3]
  15783. *
  15784. * _.range(1, 4, 0);
  15785. * // => [1, 1, 1]
  15786. *
  15787. * _.range(0);
  15788. * // => []
  15789. */
  15790. var range = createRange();
  15791. /**
  15792. * This method is like `_.range` except that it populates values in
  15793. * descending order.
  15794. *
  15795. * @static
  15796. * @memberOf _
  15797. * @since 4.0.0
  15798. * @category Util
  15799. * @param {number} [start=0] The start of the range.
  15800. * @param {number} end The end of the range.
  15801. * @param {number} [step=1] The value to increment or decrement by.
  15802. * @returns {Array} Returns the range of numbers.
  15803. * @see _.inRange, _.range
  15804. * @example
  15805. *
  15806. * _.rangeRight(4);
  15807. * // => [3, 2, 1, 0]
  15808. *
  15809. * _.rangeRight(-4);
  15810. * // => [-3, -2, -1, 0]
  15811. *
  15812. * _.rangeRight(1, 5);
  15813. * // => [4, 3, 2, 1]
  15814. *
  15815. * _.rangeRight(0, 20, 5);
  15816. * // => [15, 10, 5, 0]
  15817. *
  15818. * _.rangeRight(0, -4, -1);
  15819. * // => [-3, -2, -1, 0]
  15820. *
  15821. * _.rangeRight(1, 4, 0);
  15822. * // => [1, 1, 1]
  15823. *
  15824. * _.rangeRight(0);
  15825. * // => []
  15826. */
  15827. var rangeRight = createRange(true);
  15828. /**
  15829. * This method returns a new empty array.
  15830. *
  15831. * @static
  15832. * @memberOf _
  15833. * @since 4.13.0
  15834. * @category Util
  15835. * @returns {Array} Returns the new empty array.
  15836. * @example
  15837. *
  15838. * var arrays = _.times(2, _.stubArray);
  15839. *
  15840. * console.log(arrays);
  15841. * // => [[], []]
  15842. *
  15843. * console.log(arrays[0] === arrays[1]);
  15844. * // => false
  15845. */
  15846. function stubArray() {
  15847. return [];
  15848. }
  15849. /**
  15850. * This method returns `false`.
  15851. *
  15852. * @static
  15853. * @memberOf _
  15854. * @since 4.13.0
  15855. * @category Util
  15856. * @returns {boolean} Returns `false`.
  15857. * @example
  15858. *
  15859. * _.times(2, _.stubFalse);
  15860. * // => [false, false]
  15861. */
  15862. function stubFalse() {
  15863. return false;
  15864. }
  15865. /**
  15866. * This method returns a new empty object.
  15867. *
  15868. * @static
  15869. * @memberOf _
  15870. * @since 4.13.0
  15871. * @category Util
  15872. * @returns {Object} Returns the new empty object.
  15873. * @example
  15874. *
  15875. * var objects = _.times(2, _.stubObject);
  15876. *
  15877. * console.log(objects);
  15878. * // => [{}, {}]
  15879. *
  15880. * console.log(objects[0] === objects[1]);
  15881. * // => false
  15882. */
  15883. function stubObject() {
  15884. return {};
  15885. }
  15886. /**
  15887. * This method returns an empty string.
  15888. *
  15889. * @static
  15890. * @memberOf _
  15891. * @since 4.13.0
  15892. * @category Util
  15893. * @returns {string} Returns the empty string.
  15894. * @example
  15895. *
  15896. * _.times(2, _.stubString);
  15897. * // => ['', '']
  15898. */
  15899. function stubString() {
  15900. return '';
  15901. }
  15902. /**
  15903. * This method returns `true`.
  15904. *
  15905. * @static
  15906. * @memberOf _
  15907. * @since 4.13.0
  15908. * @category Util
  15909. * @returns {boolean} Returns `true`.
  15910. * @example
  15911. *
  15912. * _.times(2, _.stubTrue);
  15913. * // => [true, true]
  15914. */
  15915. function stubTrue() {
  15916. return true;
  15917. }
  15918. /**
  15919. * Invokes the iteratee `n` times, returning an array of the results of
  15920. * each invocation. The iteratee is invoked with one argument; (index).
  15921. *
  15922. * @static
  15923. * @since 0.1.0
  15924. * @memberOf _
  15925. * @category Util
  15926. * @param {number} n The number of times to invoke `iteratee`.
  15927. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  15928. * @returns {Array} Returns the array of results.
  15929. * @example
  15930. *
  15931. * _.times(3, String);
  15932. * // => ['0', '1', '2']
  15933. *
  15934. * _.times(4, _.constant(0));
  15935. * // => [0, 0, 0, 0]
  15936. */
  15937. function times(n, iteratee) {
  15938. n = toInteger(n);
  15939. if (n < 1 || n > MAX_SAFE_INTEGER) {
  15940. return [];
  15941. }
  15942. var index = MAX_ARRAY_LENGTH,
  15943. length = nativeMin(n, MAX_ARRAY_LENGTH);
  15944. iteratee = getIteratee(iteratee);
  15945. n -= MAX_ARRAY_LENGTH;
  15946. var result = baseTimes(length, iteratee);
  15947. while (++index < n) {
  15948. iteratee(index);
  15949. }
  15950. return result;
  15951. }
  15952. /**
  15953. * Converts `value` to a property path array.
  15954. *
  15955. * @static
  15956. * @memberOf _
  15957. * @since 4.0.0
  15958. * @category Util
  15959. * @param {*} value The value to convert.
  15960. * @returns {Array} Returns the new property path array.
  15961. * @example
  15962. *
  15963. * _.toPath('a.b.c');
  15964. * // => ['a', 'b', 'c']
  15965. *
  15966. * _.toPath('a[0].b.c');
  15967. * // => ['a', '0', 'b', 'c']
  15968. */
  15969. function toPath(value) {
  15970. if (isArray(value)) {
  15971. return arrayMap(value, toKey);
  15972. }
  15973. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  15974. }
  15975. /**
  15976. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  15977. *
  15978. * @static
  15979. * @since 0.1.0
  15980. * @memberOf _
  15981. * @category Util
  15982. * @param {string} [prefix=''] The value to prefix the ID with.
  15983. * @returns {string} Returns the unique ID.
  15984. * @example
  15985. *
  15986. * _.uniqueId('contact_');
  15987. * // => 'contact_104'
  15988. *
  15989. * _.uniqueId();
  15990. * // => '105'
  15991. */
  15992. function uniqueId(prefix) {
  15993. var id = ++idCounter;
  15994. return toString(prefix) + id;
  15995. }
  15996. /*------------------------------------------------------------------------*/
  15997. /**
  15998. * Adds two numbers.
  15999. *
  16000. * @static
  16001. * @memberOf _
  16002. * @since 3.4.0
  16003. * @category Math
  16004. * @param {number} augend The first number in an addition.
  16005. * @param {number} addend The second number in an addition.
  16006. * @returns {number} Returns the total.
  16007. * @example
  16008. *
  16009. * _.add(6, 4);
  16010. * // => 10
  16011. */
  16012. var add = createMathOperation(function(augend, addend) {
  16013. return augend + addend;
  16014. }, 0);
  16015. /**
  16016. * Computes `number` rounded up to `precision`.
  16017. *
  16018. * @static
  16019. * @memberOf _
  16020. * @since 3.10.0
  16021. * @category Math
  16022. * @param {number} number The number to round up.
  16023. * @param {number} [precision=0] The precision to round up to.
  16024. * @returns {number} Returns the rounded up number.
  16025. * @example
  16026. *
  16027. * _.ceil(4.006);
  16028. * // => 5
  16029. *
  16030. * _.ceil(6.004, 2);
  16031. * // => 6.01
  16032. *
  16033. * _.ceil(6040, -2);
  16034. * // => 6100
  16035. */
  16036. var ceil = createRound('ceil');
  16037. /**
  16038. * Divide two numbers.
  16039. *
  16040. * @static
  16041. * @memberOf _
  16042. * @since 4.7.0
  16043. * @category Math
  16044. * @param {number} dividend The first number in a division.
  16045. * @param {number} divisor The second number in a division.
  16046. * @returns {number} Returns the quotient.
  16047. * @example
  16048. *
  16049. * _.divide(6, 4);
  16050. * // => 1.5
  16051. */
  16052. var divide = createMathOperation(function(dividend, divisor) {
  16053. return dividend / divisor;
  16054. }, 1);
  16055. /**
  16056. * Computes `number` rounded down to `precision`.
  16057. *
  16058. * @static
  16059. * @memberOf _
  16060. * @since 3.10.0
  16061. * @category Math
  16062. * @param {number} number The number to round down.
  16063. * @param {number} [precision=0] The precision to round down to.
  16064. * @returns {number} Returns the rounded down number.
  16065. * @example
  16066. *
  16067. * _.floor(4.006);
  16068. * // => 4
  16069. *
  16070. * _.floor(0.046, 2);
  16071. * // => 0.04
  16072. *
  16073. * _.floor(4060, -2);
  16074. * // => 4000
  16075. */
  16076. var floor = createRound('floor');
  16077. /**
  16078. * Computes the maximum value of `array`. If `array` is empty or falsey,
  16079. * `undefined` is returned.
  16080. *
  16081. * @static
  16082. * @since 0.1.0
  16083. * @memberOf _
  16084. * @category Math
  16085. * @param {Array} array The array to iterate over.
  16086. * @returns {*} Returns the maximum value.
  16087. * @example
  16088. *
  16089. * _.max([4, 2, 8, 6]);
  16090. * // => 8
  16091. *
  16092. * _.max([]);
  16093. * // => undefined
  16094. */
  16095. function max(array) {
  16096. return (array && array.length)
  16097. ? baseExtremum(array, identity, baseGt)
  16098. : undefined;
  16099. }
  16100. /**
  16101. * This method is like `_.max` except that it accepts `iteratee` which is
  16102. * invoked for each element in `array` to generate the criterion by which
  16103. * the value is ranked. The iteratee is invoked with one argument: (value).
  16104. *
  16105. * @static
  16106. * @memberOf _
  16107. * @since 4.0.0
  16108. * @category Math
  16109. * @param {Array} array The array to iterate over.
  16110. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16111. * @returns {*} Returns the maximum value.
  16112. * @example
  16113. *
  16114. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16115. *
  16116. * _.maxBy(objects, function(o) { return o.n; });
  16117. * // => { 'n': 2 }
  16118. *
  16119. * // The `_.property` iteratee shorthand.
  16120. * _.maxBy(objects, 'n');
  16121. * // => { 'n': 2 }
  16122. */
  16123. function maxBy(array, iteratee) {
  16124. return (array && array.length)
  16125. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  16126. : undefined;
  16127. }
  16128. /**
  16129. * Computes the mean of the values in `array`.
  16130. *
  16131. * @static
  16132. * @memberOf _
  16133. * @since 4.0.0
  16134. * @category Math
  16135. * @param {Array} array The array to iterate over.
  16136. * @returns {number} Returns the mean.
  16137. * @example
  16138. *
  16139. * _.mean([4, 2, 8, 6]);
  16140. * // => 5
  16141. */
  16142. function mean(array) {
  16143. return baseMean(array, identity);
  16144. }
  16145. /**
  16146. * This method is like `_.mean` except that it accepts `iteratee` which is
  16147. * invoked for each element in `array` to generate the value to be averaged.
  16148. * The iteratee is invoked with one argument: (value).
  16149. *
  16150. * @static
  16151. * @memberOf _
  16152. * @since 4.7.0
  16153. * @category Math
  16154. * @param {Array} array The array to iterate over.
  16155. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16156. * @returns {number} Returns the mean.
  16157. * @example
  16158. *
  16159. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16160. *
  16161. * _.meanBy(objects, function(o) { return o.n; });
  16162. * // => 5
  16163. *
  16164. * // The `_.property` iteratee shorthand.
  16165. * _.meanBy(objects, 'n');
  16166. * // => 5
  16167. */
  16168. function meanBy(array, iteratee) {
  16169. return baseMean(array, getIteratee(iteratee, 2));
  16170. }
  16171. /**
  16172. * Computes the minimum value of `array`. If `array` is empty or falsey,
  16173. * `undefined` is returned.
  16174. *
  16175. * @static
  16176. * @since 0.1.0
  16177. * @memberOf _
  16178. * @category Math
  16179. * @param {Array} array The array to iterate over.
  16180. * @returns {*} Returns the minimum value.
  16181. * @example
  16182. *
  16183. * _.min([4, 2, 8, 6]);
  16184. * // => 2
  16185. *
  16186. * _.min([]);
  16187. * // => undefined
  16188. */
  16189. function min(array) {
  16190. return (array && array.length)
  16191. ? baseExtremum(array, identity, baseLt)
  16192. : undefined;
  16193. }
  16194. /**
  16195. * This method is like `_.min` except that it accepts `iteratee` which is
  16196. * invoked for each element in `array` to generate the criterion by which
  16197. * the value is ranked. The iteratee is invoked with one argument: (value).
  16198. *
  16199. * @static
  16200. * @memberOf _
  16201. * @since 4.0.0
  16202. * @category Math
  16203. * @param {Array} array The array to iterate over.
  16204. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16205. * @returns {*} Returns the minimum value.
  16206. * @example
  16207. *
  16208. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16209. *
  16210. * _.minBy(objects, function(o) { return o.n; });
  16211. * // => { 'n': 1 }
  16212. *
  16213. * // The `_.property` iteratee shorthand.
  16214. * _.minBy(objects, 'n');
  16215. * // => { 'n': 1 }
  16216. */
  16217. function minBy(array, iteratee) {
  16218. return (array && array.length)
  16219. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  16220. : undefined;
  16221. }
  16222. /**
  16223. * Multiply two numbers.
  16224. *
  16225. * @static
  16226. * @memberOf _
  16227. * @since 4.7.0
  16228. * @category Math
  16229. * @param {number} multiplier The first number in a multiplication.
  16230. * @param {number} multiplicand The second number in a multiplication.
  16231. * @returns {number} Returns the product.
  16232. * @example
  16233. *
  16234. * _.multiply(6, 4);
  16235. * // => 24
  16236. */
  16237. var multiply = createMathOperation(function(multiplier, multiplicand) {
  16238. return multiplier * multiplicand;
  16239. }, 1);
  16240. /**
  16241. * Computes `number` rounded to `precision`.
  16242. *
  16243. * @static
  16244. * @memberOf _
  16245. * @since 3.10.0
  16246. * @category Math
  16247. * @param {number} number The number to round.
  16248. * @param {number} [precision=0] The precision to round to.
  16249. * @returns {number} Returns the rounded number.
  16250. * @example
  16251. *
  16252. * _.round(4.006);
  16253. * // => 4
  16254. *
  16255. * _.round(4.006, 2);
  16256. * // => 4.01
  16257. *
  16258. * _.round(4060, -2);
  16259. * // => 4100
  16260. */
  16261. var round = createRound('round');
  16262. /**
  16263. * Subtract two numbers.
  16264. *
  16265. * @static
  16266. * @memberOf _
  16267. * @since 4.0.0
  16268. * @category Math
  16269. * @param {number} minuend The first number in a subtraction.
  16270. * @param {number} subtrahend The second number in a subtraction.
  16271. * @returns {number} Returns the difference.
  16272. * @example
  16273. *
  16274. * _.subtract(6, 4);
  16275. * // => 2
  16276. */
  16277. var subtract = createMathOperation(function(minuend, subtrahend) {
  16278. return minuend - subtrahend;
  16279. }, 0);
  16280. /**
  16281. * Computes the sum of the values in `array`.
  16282. *
  16283. * @static
  16284. * @memberOf _
  16285. * @since 3.4.0
  16286. * @category Math
  16287. * @param {Array} array The array to iterate over.
  16288. * @returns {number} Returns the sum.
  16289. * @example
  16290. *
  16291. * _.sum([4, 2, 8, 6]);
  16292. * // => 20
  16293. */
  16294. function sum(array) {
  16295. return (array && array.length)
  16296. ? baseSum(array, identity)
  16297. : 0;
  16298. }
  16299. /**
  16300. * This method is like `_.sum` except that it accepts `iteratee` which is
  16301. * invoked for each element in `array` to generate the value to be summed.
  16302. * The iteratee is invoked with one argument: (value).
  16303. *
  16304. * @static
  16305. * @memberOf _
  16306. * @since 4.0.0
  16307. * @category Math
  16308. * @param {Array} array The array to iterate over.
  16309. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16310. * @returns {number} Returns the sum.
  16311. * @example
  16312. *
  16313. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16314. *
  16315. * _.sumBy(objects, function(o) { return o.n; });
  16316. * // => 20
  16317. *
  16318. * // The `_.property` iteratee shorthand.
  16319. * _.sumBy(objects, 'n');
  16320. * // => 20
  16321. */
  16322. function sumBy(array, iteratee) {
  16323. return (array && array.length)
  16324. ? baseSum(array, getIteratee(iteratee, 2))
  16325. : 0;
  16326. }
  16327. /*------------------------------------------------------------------------*/
  16328. // Add methods that return wrapped values in chain sequences.
  16329. lodash.after = after;
  16330. lodash.ary = ary;
  16331. lodash.assign = assign;
  16332. lodash.assignIn = assignIn;
  16333. lodash.assignInWith = assignInWith;
  16334. lodash.assignWith = assignWith;
  16335. lodash.at = at;
  16336. lodash.before = before;
  16337. lodash.bind = bind;
  16338. lodash.bindAll = bindAll;
  16339. lodash.bindKey = bindKey;
  16340. lodash.castArray = castArray;
  16341. lodash.chain = chain;
  16342. lodash.chunk = chunk;
  16343. lodash.compact = compact;
  16344. lodash.concat = concat;
  16345. lodash.cond = cond;
  16346. lodash.conforms = conforms;
  16347. lodash.constant = constant;
  16348. lodash.countBy = countBy;
  16349. lodash.create = create;
  16350. lodash.curry = curry;
  16351. lodash.curryRight = curryRight;
  16352. lodash.debounce = debounce;
  16353. lodash.defaults = defaults;
  16354. lodash.defaultsDeep = defaultsDeep;
  16355. lodash.defer = defer;
  16356. lodash.delay = delay;
  16357. lodash.difference = difference;
  16358. lodash.differenceBy = differenceBy;
  16359. lodash.differenceWith = differenceWith;
  16360. lodash.drop = drop;
  16361. lodash.dropRight = dropRight;
  16362. lodash.dropRightWhile = dropRightWhile;
  16363. lodash.dropWhile = dropWhile;
  16364. lodash.fill = fill;
  16365. lodash.filter = filter;
  16366. lodash.flatMap = flatMap;
  16367. lodash.flatMapDeep = flatMapDeep;
  16368. lodash.flatMapDepth = flatMapDepth;
  16369. lodash.flatten = flatten;
  16370. lodash.flattenDeep = flattenDeep;
  16371. lodash.flattenDepth = flattenDepth;
  16372. lodash.flip = flip;
  16373. lodash.flow = flow;
  16374. lodash.flowRight = flowRight;
  16375. lodash.fromPairs = fromPairs;
  16376. lodash.functions = functions;
  16377. lodash.functionsIn = functionsIn;
  16378. lodash.groupBy = groupBy;
  16379. lodash.initial = initial;
  16380. lodash.intersection = intersection;
  16381. lodash.intersectionBy = intersectionBy;
  16382. lodash.intersectionWith = intersectionWith;
  16383. lodash.invert = invert;
  16384. lodash.invertBy = invertBy;
  16385. lodash.invokeMap = invokeMap;
  16386. lodash.iteratee = iteratee;
  16387. lodash.keyBy = keyBy;
  16388. lodash.keys = keys;
  16389. lodash.keysIn = keysIn;
  16390. lodash.map = map;
  16391. lodash.mapKeys = mapKeys;
  16392. lodash.mapValues = mapValues;
  16393. lodash.matches = matches;
  16394. lodash.matchesProperty = matchesProperty;
  16395. lodash.memoize = memoize;
  16396. lodash.merge = merge;
  16397. lodash.mergeWith = mergeWith;
  16398. lodash.method = method;
  16399. lodash.methodOf = methodOf;
  16400. lodash.mixin = mixin;
  16401. lodash.negate = negate;
  16402. lodash.nthArg = nthArg;
  16403. lodash.omit = omit;
  16404. lodash.omitBy = omitBy;
  16405. lodash.once = once;
  16406. lodash.orderBy = orderBy;
  16407. lodash.over = over;
  16408. lodash.overArgs = overArgs;
  16409. lodash.overEvery = overEvery;
  16410. lodash.overSome = overSome;
  16411. lodash.partial = partial;
  16412. lodash.partialRight = partialRight;
  16413. lodash.partition = partition;
  16414. lodash.pick = pick;
  16415. lodash.pickBy = pickBy;
  16416. lodash.property = property;
  16417. lodash.propertyOf = propertyOf;
  16418. lodash.pull = pull;
  16419. lodash.pullAll = pullAll;
  16420. lodash.pullAllBy = pullAllBy;
  16421. lodash.pullAllWith = pullAllWith;
  16422. lodash.pullAt = pullAt;
  16423. lodash.range = range;
  16424. lodash.rangeRight = rangeRight;
  16425. lodash.rearg = rearg;
  16426. lodash.reject = reject;
  16427. lodash.remove = remove;
  16428. lodash.rest = rest;
  16429. lodash.reverse = reverse;
  16430. lodash.sampleSize = sampleSize;
  16431. lodash.set = set;
  16432. lodash.setWith = setWith;
  16433. lodash.shuffle = shuffle;
  16434. lodash.slice = slice;
  16435. lodash.sortBy = sortBy;
  16436. lodash.sortedUniq = sortedUniq;
  16437. lodash.sortedUniqBy = sortedUniqBy;
  16438. lodash.split = split;
  16439. lodash.spread = spread;
  16440. lodash.tail = tail;
  16441. lodash.take = take;
  16442. lodash.takeRight = takeRight;
  16443. lodash.takeRightWhile = takeRightWhile;
  16444. lodash.takeWhile = takeWhile;
  16445. lodash.tap = tap;
  16446. lodash.throttle = throttle;
  16447. lodash.thru = thru;
  16448. lodash.toArray = toArray;
  16449. lodash.toPairs = toPairs;
  16450. lodash.toPairsIn = toPairsIn;
  16451. lodash.toPath = toPath;
  16452. lodash.toPlainObject = toPlainObject;
  16453. lodash.transform = transform;
  16454. lodash.unary = unary;
  16455. lodash.union = union;
  16456. lodash.unionBy = unionBy;
  16457. lodash.unionWith = unionWith;
  16458. lodash.uniq = uniq;
  16459. lodash.uniqBy = uniqBy;
  16460. lodash.uniqWith = uniqWith;
  16461. lodash.unset = unset;
  16462. lodash.unzip = unzip;
  16463. lodash.unzipWith = unzipWith;
  16464. lodash.update = update;
  16465. lodash.updateWith = updateWith;
  16466. lodash.values = values;
  16467. lodash.valuesIn = valuesIn;
  16468. lodash.without = without;
  16469. lodash.words = words;
  16470. lodash.wrap = wrap;
  16471. lodash.xor = xor;
  16472. lodash.xorBy = xorBy;
  16473. lodash.xorWith = xorWith;
  16474. lodash.zip = zip;
  16475. lodash.zipObject = zipObject;
  16476. lodash.zipObjectDeep = zipObjectDeep;
  16477. lodash.zipWith = zipWith;
  16478. // Add aliases.
  16479. lodash.entries = toPairs;
  16480. lodash.entriesIn = toPairsIn;
  16481. lodash.extend = assignIn;
  16482. lodash.extendWith = assignInWith;
  16483. // Add methods to `lodash.prototype`.
  16484. mixin(lodash, lodash);
  16485. /*------------------------------------------------------------------------*/
  16486. // Add methods that return unwrapped values in chain sequences.
  16487. lodash.add = add;
  16488. lodash.attempt = attempt;
  16489. lodash.camelCase = camelCase;
  16490. lodash.capitalize = capitalize;
  16491. lodash.ceil = ceil;
  16492. lodash.clamp = clamp;
  16493. lodash.clone = clone;
  16494. lodash.cloneDeep = cloneDeep;
  16495. lodash.cloneDeepWith = cloneDeepWith;
  16496. lodash.cloneWith = cloneWith;
  16497. lodash.conformsTo = conformsTo;
  16498. lodash.deburr = deburr;
  16499. lodash.defaultTo = defaultTo;
  16500. lodash.divide = divide;
  16501. lodash.endsWith = endsWith;
  16502. lodash.eq = eq;
  16503. lodash.escape = escape;
  16504. lodash.escapeRegExp = escapeRegExp;
  16505. lodash.every = every;
  16506. lodash.find = find;
  16507. lodash.findIndex = findIndex;
  16508. lodash.findKey = findKey;
  16509. lodash.findLast = findLast;
  16510. lodash.findLastIndex = findLastIndex;
  16511. lodash.findLastKey = findLastKey;
  16512. lodash.floor = floor;
  16513. lodash.forEach = forEach;
  16514. lodash.forEachRight = forEachRight;
  16515. lodash.forIn = forIn;
  16516. lodash.forInRight = forInRight;
  16517. lodash.forOwn = forOwn;
  16518. lodash.forOwnRight = forOwnRight;
  16519. lodash.get = get;
  16520. lodash.gt = gt;
  16521. lodash.gte = gte;
  16522. lodash.has = has;
  16523. lodash.hasIn = hasIn;
  16524. lodash.head = head;
  16525. lodash.identity = identity;
  16526. lodash.includes = includes;
  16527. lodash.indexOf = indexOf;
  16528. lodash.inRange = inRange;
  16529. lodash.invoke = invoke;
  16530. lodash.isArguments = isArguments;
  16531. lodash.isArray = isArray;
  16532. lodash.isArrayBuffer = isArrayBuffer;
  16533. lodash.isArrayLike = isArrayLike;
  16534. lodash.isArrayLikeObject = isArrayLikeObject;
  16535. lodash.isBoolean = isBoolean;
  16536. lodash.isBuffer = isBuffer;
  16537. lodash.isDate = isDate;
  16538. lodash.isElement = isElement;
  16539. lodash.isEmpty = isEmpty;
  16540. lodash.isEqual = isEqual;
  16541. lodash.isEqualWith = isEqualWith;
  16542. lodash.isError = isError;
  16543. lodash.isFinite = isFinite;
  16544. lodash.isFunction = isFunction;
  16545. lodash.isInteger = isInteger;
  16546. lodash.isLength = isLength;
  16547. lodash.isMap = isMap;
  16548. lodash.isMatch = isMatch;
  16549. lodash.isMatchWith = isMatchWith;
  16550. lodash.isNaN = isNaN;
  16551. lodash.isNative = isNative;
  16552. lodash.isNil = isNil;
  16553. lodash.isNull = isNull;
  16554. lodash.isNumber = isNumber;
  16555. lodash.isObject = isObject;
  16556. lodash.isObjectLike = isObjectLike;
  16557. lodash.isPlainObject = isPlainObject;
  16558. lodash.isRegExp = isRegExp;
  16559. lodash.isSafeInteger = isSafeInteger;
  16560. lodash.isSet = isSet;
  16561. lodash.isString = isString;
  16562. lodash.isSymbol = isSymbol;
  16563. lodash.isTypedArray = isTypedArray;
  16564. lodash.isUndefined = isUndefined;
  16565. lodash.isWeakMap = isWeakMap;
  16566. lodash.isWeakSet = isWeakSet;
  16567. lodash.join = join;
  16568. lodash.kebabCase = kebabCase;
  16569. lodash.last = last;
  16570. lodash.lastIndexOf = lastIndexOf;
  16571. lodash.lowerCase = lowerCase;
  16572. lodash.lowerFirst = lowerFirst;
  16573. lodash.lt = lt;
  16574. lodash.lte = lte;
  16575. lodash.max = max;
  16576. lodash.maxBy = maxBy;
  16577. lodash.mean = mean;
  16578. lodash.meanBy = meanBy;
  16579. lodash.min = min;
  16580. lodash.minBy = minBy;
  16581. lodash.stubArray = stubArray;
  16582. lodash.stubFalse = stubFalse;
  16583. lodash.stubObject = stubObject;
  16584. lodash.stubString = stubString;
  16585. lodash.stubTrue = stubTrue;
  16586. lodash.multiply = multiply;
  16587. lodash.nth = nth;
  16588. lodash.noConflict = noConflict;
  16589. lodash.noop = noop;
  16590. lodash.now = now;
  16591. lodash.pad = pad;
  16592. lodash.padEnd = padEnd;
  16593. lodash.padStart = padStart;
  16594. lodash.parseInt = parseInt;
  16595. lodash.random = random;
  16596. lodash.reduce = reduce;
  16597. lodash.reduceRight = reduceRight;
  16598. lodash.repeat = repeat;
  16599. lodash.replace = replace;
  16600. lodash.result = result;
  16601. lodash.round = round;
  16602. lodash.runInContext = runInContext;
  16603. lodash.sample = sample;
  16604. lodash.size = size;
  16605. lodash.snakeCase = snakeCase;
  16606. lodash.some = some;
  16607. lodash.sortedIndex = sortedIndex;
  16608. lodash.sortedIndexBy = sortedIndexBy;
  16609. lodash.sortedIndexOf = sortedIndexOf;
  16610. lodash.sortedLastIndex = sortedLastIndex;
  16611. lodash.sortedLastIndexBy = sortedLastIndexBy;
  16612. lodash.sortedLastIndexOf = sortedLastIndexOf;
  16613. lodash.startCase = startCase;
  16614. lodash.startsWith = startsWith;
  16615. lodash.subtract = subtract;
  16616. lodash.sum = sum;
  16617. lodash.sumBy = sumBy;
  16618. lodash.template = template;
  16619. lodash.times = times;
  16620. lodash.toFinite = toFinite;
  16621. lodash.toInteger = toInteger;
  16622. lodash.toLength = toLength;
  16623. lodash.toLower = toLower;
  16624. lodash.toNumber = toNumber;
  16625. lodash.toSafeInteger = toSafeInteger;
  16626. lodash.toString = toString;
  16627. lodash.toUpper = toUpper;
  16628. lodash.trim = trim;
  16629. lodash.trimEnd = trimEnd;
  16630. lodash.trimStart = trimStart;
  16631. lodash.truncate = truncate;
  16632. lodash.unescape = unescape;
  16633. lodash.uniqueId = uniqueId;
  16634. lodash.upperCase = upperCase;
  16635. lodash.upperFirst = upperFirst;
  16636. // Add aliases.
  16637. lodash.each = forEach;
  16638. lodash.eachRight = forEachRight;
  16639. lodash.first = head;
  16640. mixin(lodash, (function() {
  16641. var source = {};
  16642. baseForOwn(lodash, function(func, methodName) {
  16643. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  16644. source[methodName] = func;
  16645. }
  16646. });
  16647. return source;
  16648. }()), { 'chain': false });
  16649. /*------------------------------------------------------------------------*/
  16650. /**
  16651. * The semantic version number.
  16652. *
  16653. * @static
  16654. * @memberOf _
  16655. * @type {string}
  16656. */
  16657. lodash.VERSION = VERSION;
  16658. // Assign default placeholders.
  16659. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  16660. lodash[methodName].placeholder = lodash;
  16661. });
  16662. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  16663. arrayEach(['drop', 'take'], function(methodName, index) {
  16664. LazyWrapper.prototype[methodName] = function(n) {
  16665. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  16666. var result = (this.__filtered__ && !index)
  16667. ? new LazyWrapper(this)
  16668. : this.clone();
  16669. if (result.__filtered__) {
  16670. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  16671. } else {
  16672. result.__views__.push({
  16673. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  16674. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  16675. });
  16676. }
  16677. return result;
  16678. };
  16679. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  16680. return this.reverse()[methodName](n).reverse();
  16681. };
  16682. });
  16683. // Add `LazyWrapper` methods that accept an `iteratee` value.
  16684. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  16685. var type = index + 1,
  16686. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  16687. LazyWrapper.prototype[methodName] = function(iteratee) {
  16688. var result = this.clone();
  16689. result.__iteratees__.push({
  16690. 'iteratee': getIteratee(iteratee, 3),
  16691. 'type': type
  16692. });
  16693. result.__filtered__ = result.__filtered__ || isFilter;
  16694. return result;
  16695. };
  16696. });
  16697. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  16698. arrayEach(['head', 'last'], function(methodName, index) {
  16699. var takeName = 'take' + (index ? 'Right' : '');
  16700. LazyWrapper.prototype[methodName] = function() {
  16701. return this[takeName](1).value()[0];
  16702. };
  16703. });
  16704. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  16705. arrayEach(['initial', 'tail'], function(methodName, index) {
  16706. var dropName = 'drop' + (index ? '' : 'Right');
  16707. LazyWrapper.prototype[methodName] = function() {
  16708. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  16709. };
  16710. });
  16711. LazyWrapper.prototype.compact = function() {
  16712. return this.filter(identity);
  16713. };
  16714. LazyWrapper.prototype.find = function(predicate) {
  16715. return this.filter(predicate).head();
  16716. };
  16717. LazyWrapper.prototype.findLast = function(predicate) {
  16718. return this.reverse().find(predicate);
  16719. };
  16720. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  16721. if (typeof path == 'function') {
  16722. return new LazyWrapper(this);
  16723. }
  16724. return this.map(function(value) {
  16725. return baseInvoke(value, path, args);
  16726. });
  16727. });
  16728. LazyWrapper.prototype.reject = function(predicate) {
  16729. return this.filter(negate(getIteratee(predicate)));
  16730. };
  16731. LazyWrapper.prototype.slice = function(start, end) {
  16732. start = toInteger(start);
  16733. var result = this;
  16734. if (result.__filtered__ && (start > 0 || end < 0)) {
  16735. return new LazyWrapper(result);
  16736. }
  16737. if (start < 0) {
  16738. result = result.takeRight(-start);
  16739. } else if (start) {
  16740. result = result.drop(start);
  16741. }
  16742. if (end !== undefined) {
  16743. end = toInteger(end);
  16744. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  16745. }
  16746. return result;
  16747. };
  16748. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  16749. return this.reverse().takeWhile(predicate).reverse();
  16750. };
  16751. LazyWrapper.prototype.toArray = function() {
  16752. return this.take(MAX_ARRAY_LENGTH);
  16753. };
  16754. // Add `LazyWrapper` methods to `lodash.prototype`.
  16755. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  16756. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  16757. isTaker = /^(?:head|last)$/.test(methodName),
  16758. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  16759. retUnwrapped = isTaker || /^find/.test(methodName);
  16760. if (!lodashFunc) {
  16761. return;
  16762. }
  16763. lodash.prototype[methodName] = function() {
  16764. var value = this.__wrapped__,
  16765. args = isTaker ? [1] : arguments,
  16766. isLazy = value instanceof LazyWrapper,
  16767. iteratee = args[0],
  16768. useLazy = isLazy || isArray(value);
  16769. var interceptor = function(value) {
  16770. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  16771. return (isTaker && chainAll) ? result[0] : result;
  16772. };
  16773. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  16774. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  16775. isLazy = useLazy = false;
  16776. }
  16777. var chainAll = this.__chain__,
  16778. isHybrid = !!this.__actions__.length,
  16779. isUnwrapped = retUnwrapped && !chainAll,
  16780. onlyLazy = isLazy && !isHybrid;
  16781. if (!retUnwrapped && useLazy) {
  16782. value = onlyLazy ? value : new LazyWrapper(this);
  16783. var result = func.apply(value, args);
  16784. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  16785. return new LodashWrapper(result, chainAll);
  16786. }
  16787. if (isUnwrapped && onlyLazy) {
  16788. return func.apply(this, args);
  16789. }
  16790. result = this.thru(interceptor);
  16791. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  16792. };
  16793. });
  16794. // Add `Array` methods to `lodash.prototype`.
  16795. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  16796. var func = arrayProto[methodName],
  16797. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  16798. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  16799. lodash.prototype[methodName] = function() {
  16800. var args = arguments;
  16801. if (retUnwrapped && !this.__chain__) {
  16802. var value = this.value();
  16803. return func.apply(isArray(value) ? value : [], args);
  16804. }
  16805. return this[chainName](function(value) {
  16806. return func.apply(isArray(value) ? value : [], args);
  16807. });
  16808. };
  16809. });
  16810. // Map minified method names to their real names.
  16811. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  16812. var lodashFunc = lodash[methodName];
  16813. if (lodashFunc) {
  16814. var key = (lodashFunc.name + ''),
  16815. names = realNames[key] || (realNames[key] = []);
  16816. names.push({ 'name': methodName, 'func': lodashFunc });
  16817. }
  16818. });
  16819. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  16820. 'name': 'wrapper',
  16821. 'func': undefined
  16822. }];
  16823. // Add methods to `LazyWrapper`.
  16824. LazyWrapper.prototype.clone = lazyClone;
  16825. LazyWrapper.prototype.reverse = lazyReverse;
  16826. LazyWrapper.prototype.value = lazyValue;
  16827. // Add chain sequence methods to the `lodash` wrapper.
  16828. lodash.prototype.at = wrapperAt;
  16829. lodash.prototype.chain = wrapperChain;
  16830. lodash.prototype.commit = wrapperCommit;
  16831. lodash.prototype.next = wrapperNext;
  16832. lodash.prototype.plant = wrapperPlant;
  16833. lodash.prototype.reverse = wrapperReverse;
  16834. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  16835. // Add lazy aliases.
  16836. lodash.prototype.first = lodash.prototype.head;
  16837. if (symIterator) {
  16838. lodash.prototype[symIterator] = wrapperToIterator;
  16839. }
  16840. return lodash;
  16841. });
  16842. /*--------------------------------------------------------------------------*/
  16843. // Export lodash.
  16844. var _ = runInContext();
  16845. // Some AMD build optimizers, like r.js, check for condition patterns like:
  16846. if (true) {
  16847. // Expose Lodash on the global object to prevent errors when Lodash is
  16848. // loaded by a script tag in the presence of an AMD loader.
  16849. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  16850. // Use `_.noConflict` to remove Lodash from the global object.
  16851. root._ = _;
  16852. // Define as an anonymous module so, through path mapping, it can be
  16853. // referenced as the "underscore" module.
  16854. !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
  16855. return _;
  16856. }.call(exports, __webpack_require__, exports, module),
  16857. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16858. }
  16859. // Check for `exports` after `define` in case a build optimizer adds it.
  16860. else if (freeModule) {
  16861. // Export for Node.js.
  16862. (freeModule.exports = _)._ = _;
  16863. // Export for CommonJS support.
  16864. freeExports._ = _;
  16865. }
  16866. else {
  16867. // Export to the global object.
  16868. root._ = _;
  16869. }
  16870. }.call(this));
  16871. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(13)(module)))
  16872. /***/ }),
  16873. /* 13 */
  16874. /***/ (function(module, exports) {
  16875. module.exports = function(module) {
  16876. if(!module.webpackPolyfill) {
  16877. module.deprecate = function() {};
  16878. module.paths = [];
  16879. // module.parent = undefined by default
  16880. if(!module.children) module.children = [];
  16881. Object.defineProperty(module, "loaded", {
  16882. enumerable: true,
  16883. get: function() {
  16884. return module.l;
  16885. }
  16886. });
  16887. Object.defineProperty(module, "id", {
  16888. enumerable: true,
  16889. get: function() {
  16890. return module.i;
  16891. }
  16892. });
  16893. module.webpackPolyfill = 1;
  16894. }
  16895. return module;
  16896. };
  16897. /***/ }),
  16898. /* 14 */
  16899. /***/ (function(module, exports, __webpack_require__) {
  16900. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  16901. * jQuery JavaScript Library v3.2.1
  16902. * https://jquery.com/
  16903. *
  16904. * Includes Sizzle.js
  16905. * https://sizzlejs.com/
  16906. *
  16907. * Copyright JS Foundation and other contributors
  16908. * Released under the MIT license
  16909. * https://jquery.org/license
  16910. *
  16911. * Date: 2017-03-20T18:59Z
  16912. */
  16913. ( function( global, factory ) {
  16914. "use strict";
  16915. if ( typeof module === "object" && typeof module.exports === "object" ) {
  16916. // For CommonJS and CommonJS-like environments where a proper `window`
  16917. // is present, execute the factory and get jQuery.
  16918. // For environments that do not have a `window` with a `document`
  16919. // (such as Node.js), expose a factory as module.exports.
  16920. // This accentuates the need for the creation of a real `window`.
  16921. // e.g. var jQuery = require("jquery")(window);
  16922. // See ticket #14549 for more info.
  16923. module.exports = global.document ?
  16924. factory( global, true ) :
  16925. function( w ) {
  16926. if ( !w.document ) {
  16927. throw new Error( "jQuery requires a window with a document" );
  16928. }
  16929. return factory( w );
  16930. };
  16931. } else {
  16932. factory( global );
  16933. }
  16934. // Pass this if window is not defined yet
  16935. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  16936. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  16937. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  16938. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  16939. // enough that all such attempts are guarded in a try block.
  16940. "use strict";
  16941. var arr = [];
  16942. var document = window.document;
  16943. var getProto = Object.getPrototypeOf;
  16944. var slice = arr.slice;
  16945. var concat = arr.concat;
  16946. var push = arr.push;
  16947. var indexOf = arr.indexOf;
  16948. var class2type = {};
  16949. var toString = class2type.toString;
  16950. var hasOwn = class2type.hasOwnProperty;
  16951. var fnToString = hasOwn.toString;
  16952. var ObjectFunctionString = fnToString.call( Object );
  16953. var support = {};
  16954. function DOMEval( code, doc ) {
  16955. doc = doc || document;
  16956. var script = doc.createElement( "script" );
  16957. script.text = code;
  16958. doc.head.appendChild( script ).parentNode.removeChild( script );
  16959. }
  16960. /* global Symbol */
  16961. // Defining this global in .eslintrc.json would create a danger of using the global
  16962. // unguarded in another place, it seems safer to define global only for this module
  16963. var
  16964. version = "3.2.1",
  16965. // Define a local copy of jQuery
  16966. jQuery = function( selector, context ) {
  16967. // The jQuery object is actually just the init constructor 'enhanced'
  16968. // Need init if jQuery is called (just allow error to be thrown if not included)
  16969. return new jQuery.fn.init( selector, context );
  16970. },
  16971. // Support: Android <=4.0 only
  16972. // Make sure we trim BOM and NBSP
  16973. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  16974. // Matches dashed string for camelizing
  16975. rmsPrefix = /^-ms-/,
  16976. rdashAlpha = /-([a-z])/g,
  16977. // Used by jQuery.camelCase as callback to replace()
  16978. fcamelCase = function( all, letter ) {
  16979. return letter.toUpperCase();
  16980. };
  16981. jQuery.fn = jQuery.prototype = {
  16982. // The current version of jQuery being used
  16983. jquery: version,
  16984. constructor: jQuery,
  16985. // The default length of a jQuery object is 0
  16986. length: 0,
  16987. toArray: function() {
  16988. return slice.call( this );
  16989. },
  16990. // Get the Nth element in the matched element set OR
  16991. // Get the whole matched element set as a clean array
  16992. get: function( num ) {
  16993. // Return all the elements in a clean array
  16994. if ( num == null ) {
  16995. return slice.call( this );
  16996. }
  16997. // Return just the one element from the set
  16998. return num < 0 ? this[ num + this.length ] : this[ num ];
  16999. },
  17000. // Take an array of elements and push it onto the stack
  17001. // (returning the new matched element set)
  17002. pushStack: function( elems ) {
  17003. // Build a new jQuery matched element set
  17004. var ret = jQuery.merge( this.constructor(), elems );
  17005. // Add the old object onto the stack (as a reference)
  17006. ret.prevObject = this;
  17007. // Return the newly-formed element set
  17008. return ret;
  17009. },
  17010. // Execute a callback for every element in the matched set.
  17011. each: function( callback ) {
  17012. return jQuery.each( this, callback );
  17013. },
  17014. map: function( callback ) {
  17015. return this.pushStack( jQuery.map( this, function( elem, i ) {
  17016. return callback.call( elem, i, elem );
  17017. } ) );
  17018. },
  17019. slice: function() {
  17020. return this.pushStack( slice.apply( this, arguments ) );
  17021. },
  17022. first: function() {
  17023. return this.eq( 0 );
  17024. },
  17025. last: function() {
  17026. return this.eq( -1 );
  17027. },
  17028. eq: function( i ) {
  17029. var len = this.length,
  17030. j = +i + ( i < 0 ? len : 0 );
  17031. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  17032. },
  17033. end: function() {
  17034. return this.prevObject || this.constructor();
  17035. },
  17036. // For internal use only.
  17037. // Behaves like an Array's method, not like a jQuery method.
  17038. push: push,
  17039. sort: arr.sort,
  17040. splice: arr.splice
  17041. };
  17042. jQuery.extend = jQuery.fn.extend = function() {
  17043. var options, name, src, copy, copyIsArray, clone,
  17044. target = arguments[ 0 ] || {},
  17045. i = 1,
  17046. length = arguments.length,
  17047. deep = false;
  17048. // Handle a deep copy situation
  17049. if ( typeof target === "boolean" ) {
  17050. deep = target;
  17051. // Skip the boolean and the target
  17052. target = arguments[ i ] || {};
  17053. i++;
  17054. }
  17055. // Handle case when target is a string or something (possible in deep copy)
  17056. if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
  17057. target = {};
  17058. }
  17059. // Extend jQuery itself if only one argument is passed
  17060. if ( i === length ) {
  17061. target = this;
  17062. i--;
  17063. }
  17064. for ( ; i < length; i++ ) {
  17065. // Only deal with non-null/undefined values
  17066. if ( ( options = arguments[ i ] ) != null ) {
  17067. // Extend the base object
  17068. for ( name in options ) {
  17069. src = target[ name ];
  17070. copy = options[ name ];
  17071. // Prevent never-ending loop
  17072. if ( target === copy ) {
  17073. continue;
  17074. }
  17075. // Recurse if we're merging plain objects or arrays
  17076. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  17077. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  17078. if ( copyIsArray ) {
  17079. copyIsArray = false;
  17080. clone = src && Array.isArray( src ) ? src : [];
  17081. } else {
  17082. clone = src && jQuery.isPlainObject( src ) ? src : {};
  17083. }
  17084. // Never move original objects, clone them
  17085. target[ name ] = jQuery.extend( deep, clone, copy );
  17086. // Don't bring in undefined values
  17087. } else if ( copy !== undefined ) {
  17088. target[ name ] = copy;
  17089. }
  17090. }
  17091. }
  17092. }
  17093. // Return the modified object
  17094. return target;
  17095. };
  17096. jQuery.extend( {
  17097. // Unique for each copy of jQuery on the page
  17098. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  17099. // Assume jQuery is ready without the ready module
  17100. isReady: true,
  17101. error: function( msg ) {
  17102. throw new Error( msg );
  17103. },
  17104. noop: function() {},
  17105. isFunction: function( obj ) {
  17106. return jQuery.type( obj ) === "function";
  17107. },
  17108. isWindow: function( obj ) {
  17109. return obj != null && obj === obj.window;
  17110. },
  17111. isNumeric: function( obj ) {
  17112. // As of jQuery 3.0, isNumeric is limited to
  17113. // strings and numbers (primitives or objects)
  17114. // that can be coerced to finite numbers (gh-2662)
  17115. var type = jQuery.type( obj );
  17116. return ( type === "number" || type === "string" ) &&
  17117. // parseFloat NaNs numeric-cast false positives ("")
  17118. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  17119. // subtraction forces infinities to NaN
  17120. !isNaN( obj - parseFloat( obj ) );
  17121. },
  17122. isPlainObject: function( obj ) {
  17123. var proto, Ctor;
  17124. // Detect obvious negatives
  17125. // Use toString instead of jQuery.type to catch host objects
  17126. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  17127. return false;
  17128. }
  17129. proto = getProto( obj );
  17130. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  17131. if ( !proto ) {
  17132. return true;
  17133. }
  17134. // Objects with prototype are plain iff they were constructed by a global Object function
  17135. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  17136. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  17137. },
  17138. isEmptyObject: function( obj ) {
  17139. /* eslint-disable no-unused-vars */
  17140. // See https://github.com/eslint/eslint/issues/6125
  17141. var name;
  17142. for ( name in obj ) {
  17143. return false;
  17144. }
  17145. return true;
  17146. },
  17147. type: function( obj ) {
  17148. if ( obj == null ) {
  17149. return obj + "";
  17150. }
  17151. // Support: Android <=2.3 only (functionish RegExp)
  17152. return typeof obj === "object" || typeof obj === "function" ?
  17153. class2type[ toString.call( obj ) ] || "object" :
  17154. typeof obj;
  17155. },
  17156. // Evaluates a script in a global context
  17157. globalEval: function( code ) {
  17158. DOMEval( code );
  17159. },
  17160. // Convert dashed to camelCase; used by the css and data modules
  17161. // Support: IE <=9 - 11, Edge 12 - 13
  17162. // Microsoft forgot to hump their vendor prefix (#9572)
  17163. camelCase: function( string ) {
  17164. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  17165. },
  17166. each: function( obj, callback ) {
  17167. var length, i = 0;
  17168. if ( isArrayLike( obj ) ) {
  17169. length = obj.length;
  17170. for ( ; i < length; i++ ) {
  17171. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  17172. break;
  17173. }
  17174. }
  17175. } else {
  17176. for ( i in obj ) {
  17177. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  17178. break;
  17179. }
  17180. }
  17181. }
  17182. return obj;
  17183. },
  17184. // Support: Android <=4.0 only
  17185. trim: function( text ) {
  17186. return text == null ?
  17187. "" :
  17188. ( text + "" ).replace( rtrim, "" );
  17189. },
  17190. // results is for internal usage only
  17191. makeArray: function( arr, results ) {
  17192. var ret = results || [];
  17193. if ( arr != null ) {
  17194. if ( isArrayLike( Object( arr ) ) ) {
  17195. jQuery.merge( ret,
  17196. typeof arr === "string" ?
  17197. [ arr ] : arr
  17198. );
  17199. } else {
  17200. push.call( ret, arr );
  17201. }
  17202. }
  17203. return ret;
  17204. },
  17205. inArray: function( elem, arr, i ) {
  17206. return arr == null ? -1 : indexOf.call( arr, elem, i );
  17207. },
  17208. // Support: Android <=4.0 only, PhantomJS 1 only
  17209. // push.apply(_, arraylike) throws on ancient WebKit
  17210. merge: function( first, second ) {
  17211. var len = +second.length,
  17212. j = 0,
  17213. i = first.length;
  17214. for ( ; j < len; j++ ) {
  17215. first[ i++ ] = second[ j ];
  17216. }
  17217. first.length = i;
  17218. return first;
  17219. },
  17220. grep: function( elems, callback, invert ) {
  17221. var callbackInverse,
  17222. matches = [],
  17223. i = 0,
  17224. length = elems.length,
  17225. callbackExpect = !invert;
  17226. // Go through the array, only saving the items
  17227. // that pass the validator function
  17228. for ( ; i < length; i++ ) {
  17229. callbackInverse = !callback( elems[ i ], i );
  17230. if ( callbackInverse !== callbackExpect ) {
  17231. matches.push( elems[ i ] );
  17232. }
  17233. }
  17234. return matches;
  17235. },
  17236. // arg is for internal usage only
  17237. map: function( elems, callback, arg ) {
  17238. var length, value,
  17239. i = 0,
  17240. ret = [];
  17241. // Go through the array, translating each of the items to their new values
  17242. if ( isArrayLike( elems ) ) {
  17243. length = elems.length;
  17244. for ( ; i < length; i++ ) {
  17245. value = callback( elems[ i ], i, arg );
  17246. if ( value != null ) {
  17247. ret.push( value );
  17248. }
  17249. }
  17250. // Go through every key on the object,
  17251. } else {
  17252. for ( i in elems ) {
  17253. value = callback( elems[ i ], i, arg );
  17254. if ( value != null ) {
  17255. ret.push( value );
  17256. }
  17257. }
  17258. }
  17259. // Flatten any nested arrays
  17260. return concat.apply( [], ret );
  17261. },
  17262. // A global GUID counter for objects
  17263. guid: 1,
  17264. // Bind a function to a context, optionally partially applying any
  17265. // arguments.
  17266. proxy: function( fn, context ) {
  17267. var tmp, args, proxy;
  17268. if ( typeof context === "string" ) {
  17269. tmp = fn[ context ];
  17270. context = fn;
  17271. fn = tmp;
  17272. }
  17273. // Quick check to determine if target is callable, in the spec
  17274. // this throws a TypeError, but we will just return undefined.
  17275. if ( !jQuery.isFunction( fn ) ) {
  17276. return undefined;
  17277. }
  17278. // Simulated bind
  17279. args = slice.call( arguments, 2 );
  17280. proxy = function() {
  17281. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  17282. };
  17283. // Set the guid of unique handler to the same of original handler, so it can be removed
  17284. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  17285. return proxy;
  17286. },
  17287. now: Date.now,
  17288. // jQuery.support is not used in Core but other projects attach their
  17289. // properties to it so it needs to exist.
  17290. support: support
  17291. } );
  17292. if ( typeof Symbol === "function" ) {
  17293. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  17294. }
  17295. // Populate the class2type map
  17296. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  17297. function( i, name ) {
  17298. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  17299. } );
  17300. function isArrayLike( obj ) {
  17301. // Support: real iOS 8.2 only (not reproducible in simulator)
  17302. // `in` check used to prevent JIT error (gh-2145)
  17303. // hasOwn isn't used here due to false negatives
  17304. // regarding Nodelist length in IE
  17305. var length = !!obj && "length" in obj && obj.length,
  17306. type = jQuery.type( obj );
  17307. if ( type === "function" || jQuery.isWindow( obj ) ) {
  17308. return false;
  17309. }
  17310. return type === "array" || length === 0 ||
  17311. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  17312. }
  17313. var Sizzle =
  17314. /*!
  17315. * Sizzle CSS Selector Engine v2.3.3
  17316. * https://sizzlejs.com/
  17317. *
  17318. * Copyright jQuery Foundation and other contributors
  17319. * Released under the MIT license
  17320. * http://jquery.org/license
  17321. *
  17322. * Date: 2016-08-08
  17323. */
  17324. (function( window ) {
  17325. var i,
  17326. support,
  17327. Expr,
  17328. getText,
  17329. isXML,
  17330. tokenize,
  17331. compile,
  17332. select,
  17333. outermostContext,
  17334. sortInput,
  17335. hasDuplicate,
  17336. // Local document vars
  17337. setDocument,
  17338. document,
  17339. docElem,
  17340. documentIsHTML,
  17341. rbuggyQSA,
  17342. rbuggyMatches,
  17343. matches,
  17344. contains,
  17345. // Instance-specific data
  17346. expando = "sizzle" + 1 * new Date(),
  17347. preferredDoc = window.document,
  17348. dirruns = 0,
  17349. done = 0,
  17350. classCache = createCache(),
  17351. tokenCache = createCache(),
  17352. compilerCache = createCache(),
  17353. sortOrder = function( a, b ) {
  17354. if ( a === b ) {
  17355. hasDuplicate = true;
  17356. }
  17357. return 0;
  17358. },
  17359. // Instance methods
  17360. hasOwn = ({}).hasOwnProperty,
  17361. arr = [],
  17362. pop = arr.pop,
  17363. push_native = arr.push,
  17364. push = arr.push,
  17365. slice = arr.slice,
  17366. // Use a stripped-down indexOf as it's faster than native
  17367. // https://jsperf.com/thor-indexof-vs-for/5
  17368. indexOf = function( list, elem ) {
  17369. var i = 0,
  17370. len = list.length;
  17371. for ( ; i < len; i++ ) {
  17372. if ( list[i] === elem ) {
  17373. return i;
  17374. }
  17375. }
  17376. return -1;
  17377. },
  17378. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  17379. // Regular expressions
  17380. // http://www.w3.org/TR/css3-selectors/#whitespace
  17381. whitespace = "[\\x20\\t\\r\\n\\f]",
  17382. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  17383. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  17384. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  17385. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  17386. // Operator (capture 2)
  17387. "*([*^$|!~]?=)" + whitespace +
  17388. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  17389. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  17390. "*\\]",
  17391. pseudos = ":(" + identifier + ")(?:\\((" +
  17392. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  17393. // 1. quoted (capture 3; capture 4 or capture 5)
  17394. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  17395. // 2. simple (capture 6)
  17396. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  17397. // 3. anything else (capture 2)
  17398. ".*" +
  17399. ")\\)|)",
  17400. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  17401. rwhitespace = new RegExp( whitespace + "+", "g" ),
  17402. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  17403. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  17404. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  17405. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  17406. rpseudo = new RegExp( pseudos ),
  17407. ridentifier = new RegExp( "^" + identifier + "$" ),
  17408. matchExpr = {
  17409. "ID": new RegExp( "^#(" + identifier + ")" ),
  17410. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  17411. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  17412. "ATTR": new RegExp( "^" + attributes ),
  17413. "PSEUDO": new RegExp( "^" + pseudos ),
  17414. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  17415. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  17416. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  17417. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  17418. // For use in libraries implementing .is()
  17419. // We use this for POS matching in `select`
  17420. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  17421. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  17422. },
  17423. rinputs = /^(?:input|select|textarea|button)$/i,
  17424. rheader = /^h\d$/i,
  17425. rnative = /^[^{]+\{\s*\[native \w/,
  17426. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  17427. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  17428. rsibling = /[+~]/,
  17429. // CSS escapes
  17430. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  17431. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  17432. funescape = function( _, escaped, escapedWhitespace ) {
  17433. var high = "0x" + escaped - 0x10000;
  17434. // NaN means non-codepoint
  17435. // Support: Firefox<24
  17436. // Workaround erroneous numeric interpretation of +"0x"
  17437. return high !== high || escapedWhitespace ?
  17438. escaped :
  17439. high < 0 ?
  17440. // BMP codepoint
  17441. String.fromCharCode( high + 0x10000 ) :
  17442. // Supplemental Plane codepoint (surrogate pair)
  17443. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  17444. },
  17445. // CSS string/identifier serialization
  17446. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  17447. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  17448. fcssescape = function( ch, asCodePoint ) {
  17449. if ( asCodePoint ) {
  17450. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  17451. if ( ch === "\0" ) {
  17452. return "\uFFFD";
  17453. }
  17454. // Control characters and (dependent upon position) numbers get escaped as code points
  17455. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  17456. }
  17457. // Other potentially-special ASCII characters get backslash-escaped
  17458. return "\\" + ch;
  17459. },
  17460. // Used for iframes
  17461. // See setDocument()
  17462. // Removing the function wrapper causes a "Permission Denied"
  17463. // error in IE
  17464. unloadHandler = function() {
  17465. setDocument();
  17466. },
  17467. disabledAncestor = addCombinator(
  17468. function( elem ) {
  17469. return elem.disabled === true && ("form" in elem || "label" in elem);
  17470. },
  17471. { dir: "parentNode", next: "legend" }
  17472. );
  17473. // Optimize for push.apply( _, NodeList )
  17474. try {
  17475. push.apply(
  17476. (arr = slice.call( preferredDoc.childNodes )),
  17477. preferredDoc.childNodes
  17478. );
  17479. // Support: Android<4.0
  17480. // Detect silently failing push.apply
  17481. arr[ preferredDoc.childNodes.length ].nodeType;
  17482. } catch ( e ) {
  17483. push = { apply: arr.length ?
  17484. // Leverage slice if possible
  17485. function( target, els ) {
  17486. push_native.apply( target, slice.call(els) );
  17487. } :
  17488. // Support: IE<9
  17489. // Otherwise append directly
  17490. function( target, els ) {
  17491. var j = target.length,
  17492. i = 0;
  17493. // Can't trust NodeList.length
  17494. while ( (target[j++] = els[i++]) ) {}
  17495. target.length = j - 1;
  17496. }
  17497. };
  17498. }
  17499. function Sizzle( selector, context, results, seed ) {
  17500. var m, i, elem, nid, match, groups, newSelector,
  17501. newContext = context && context.ownerDocument,
  17502. // nodeType defaults to 9, since context defaults to document
  17503. nodeType = context ? context.nodeType : 9;
  17504. results = results || [];
  17505. // Return early from calls with invalid selector or context
  17506. if ( typeof selector !== "string" || !selector ||
  17507. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  17508. return results;
  17509. }
  17510. // Try to shortcut find operations (as opposed to filters) in HTML documents
  17511. if ( !seed ) {
  17512. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  17513. setDocument( context );
  17514. }
  17515. context = context || document;
  17516. if ( documentIsHTML ) {
  17517. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  17518. // (excepting DocumentFragment context, where the methods don't exist)
  17519. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  17520. // ID selector
  17521. if ( (m = match[1]) ) {
  17522. // Document context
  17523. if ( nodeType === 9 ) {
  17524. if ( (elem = context.getElementById( m )) ) {
  17525. // Support: IE, Opera, Webkit
  17526. // TODO: identify versions
  17527. // getElementById can match elements by name instead of ID
  17528. if ( elem.id === m ) {
  17529. results.push( elem );
  17530. return results;
  17531. }
  17532. } else {
  17533. return results;
  17534. }
  17535. // Element context
  17536. } else {
  17537. // Support: IE, Opera, Webkit
  17538. // TODO: identify versions
  17539. // getElementById can match elements by name instead of ID
  17540. if ( newContext && (elem = newContext.getElementById( m )) &&
  17541. contains( context, elem ) &&
  17542. elem.id === m ) {
  17543. results.push( elem );
  17544. return results;
  17545. }
  17546. }
  17547. // Type selector
  17548. } else if ( match[2] ) {
  17549. push.apply( results, context.getElementsByTagName( selector ) );
  17550. return results;
  17551. // Class selector
  17552. } else if ( (m = match[3]) && support.getElementsByClassName &&
  17553. context.getElementsByClassName ) {
  17554. push.apply( results, context.getElementsByClassName( m ) );
  17555. return results;
  17556. }
  17557. }
  17558. // Take advantage of querySelectorAll
  17559. if ( support.qsa &&
  17560. !compilerCache[ selector + " " ] &&
  17561. (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  17562. if ( nodeType !== 1 ) {
  17563. newContext = context;
  17564. newSelector = selector;
  17565. // qSA looks outside Element context, which is not what we want
  17566. // Thanks to Andrew Dupont for this workaround technique
  17567. // Support: IE <=8
  17568. // Exclude object elements
  17569. } else if ( context.nodeName.toLowerCase() !== "object" ) {
  17570. // Capture the context ID, setting it first if necessary
  17571. if ( (nid = context.getAttribute( "id" )) ) {
  17572. nid = nid.replace( rcssescape, fcssescape );
  17573. } else {
  17574. context.setAttribute( "id", (nid = expando) );
  17575. }
  17576. // Prefix every selector in the list
  17577. groups = tokenize( selector );
  17578. i = groups.length;
  17579. while ( i-- ) {
  17580. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  17581. }
  17582. newSelector = groups.join( "," );
  17583. // Expand context for sibling selectors
  17584. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  17585. context;
  17586. }
  17587. if ( newSelector ) {
  17588. try {
  17589. push.apply( results,
  17590. newContext.querySelectorAll( newSelector )
  17591. );
  17592. return results;
  17593. } catch ( qsaError ) {
  17594. } finally {
  17595. if ( nid === expando ) {
  17596. context.removeAttribute( "id" );
  17597. }
  17598. }
  17599. }
  17600. }
  17601. }
  17602. }
  17603. // All others
  17604. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  17605. }
  17606. /**
  17607. * Create key-value caches of limited size
  17608. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  17609. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  17610. * deleting the oldest entry
  17611. */
  17612. function createCache() {
  17613. var keys = [];
  17614. function cache( key, value ) {
  17615. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  17616. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  17617. // Only keep the most recent entries
  17618. delete cache[ keys.shift() ];
  17619. }
  17620. return (cache[ key + " " ] = value);
  17621. }
  17622. return cache;
  17623. }
  17624. /**
  17625. * Mark a function for special use by Sizzle
  17626. * @param {Function} fn The function to mark
  17627. */
  17628. function markFunction( fn ) {
  17629. fn[ expando ] = true;
  17630. return fn;
  17631. }
  17632. /**
  17633. * Support testing using an element
  17634. * @param {Function} fn Passed the created element and returns a boolean result
  17635. */
  17636. function assert( fn ) {
  17637. var el = document.createElement("fieldset");
  17638. try {
  17639. return !!fn( el );
  17640. } catch (e) {
  17641. return false;
  17642. } finally {
  17643. // Remove from its parent by default
  17644. if ( el.parentNode ) {
  17645. el.parentNode.removeChild( el );
  17646. }
  17647. // release memory in IE
  17648. el = null;
  17649. }
  17650. }
  17651. /**
  17652. * Adds the same handler for all of the specified attrs
  17653. * @param {String} attrs Pipe-separated list of attributes
  17654. * @param {Function} handler The method that will be applied
  17655. */
  17656. function addHandle( attrs, handler ) {
  17657. var arr = attrs.split("|"),
  17658. i = arr.length;
  17659. while ( i-- ) {
  17660. Expr.attrHandle[ arr[i] ] = handler;
  17661. }
  17662. }
  17663. /**
  17664. * Checks document order of two siblings
  17665. * @param {Element} a
  17666. * @param {Element} b
  17667. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  17668. */
  17669. function siblingCheck( a, b ) {
  17670. var cur = b && a,
  17671. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  17672. a.sourceIndex - b.sourceIndex;
  17673. // Use IE sourceIndex if available on both nodes
  17674. if ( diff ) {
  17675. return diff;
  17676. }
  17677. // Check if b follows a
  17678. if ( cur ) {
  17679. while ( (cur = cur.nextSibling) ) {
  17680. if ( cur === b ) {
  17681. return -1;
  17682. }
  17683. }
  17684. }
  17685. return a ? 1 : -1;
  17686. }
  17687. /**
  17688. * Returns a function to use in pseudos for input types
  17689. * @param {String} type
  17690. */
  17691. function createInputPseudo( type ) {
  17692. return function( elem ) {
  17693. var name = elem.nodeName.toLowerCase();
  17694. return name === "input" && elem.type === type;
  17695. };
  17696. }
  17697. /**
  17698. * Returns a function to use in pseudos for buttons
  17699. * @param {String} type
  17700. */
  17701. function createButtonPseudo( type ) {
  17702. return function( elem ) {
  17703. var name = elem.nodeName.toLowerCase();
  17704. return (name === "input" || name === "button") && elem.type === type;
  17705. };
  17706. }
  17707. /**
  17708. * Returns a function to use in pseudos for :enabled/:disabled
  17709. * @param {Boolean} disabled true for :disabled; false for :enabled
  17710. */
  17711. function createDisabledPseudo( disabled ) {
  17712. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  17713. return function( elem ) {
  17714. // Only certain elements can match :enabled or :disabled
  17715. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  17716. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  17717. if ( "form" in elem ) {
  17718. // Check for inherited disabledness on relevant non-disabled elements:
  17719. // * listed form-associated elements in a disabled fieldset
  17720. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  17721. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  17722. // * option elements in a disabled optgroup
  17723. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  17724. // All such elements have a "form" property.
  17725. if ( elem.parentNode && elem.disabled === false ) {
  17726. // Option elements defer to a parent optgroup if present
  17727. if ( "label" in elem ) {
  17728. if ( "label" in elem.parentNode ) {
  17729. return elem.parentNode.disabled === disabled;
  17730. } else {
  17731. return elem.disabled === disabled;
  17732. }
  17733. }
  17734. // Support: IE 6 - 11
  17735. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  17736. return elem.isDisabled === disabled ||
  17737. // Where there is no isDisabled, check manually
  17738. /* jshint -W018 */
  17739. elem.isDisabled !== !disabled &&
  17740. disabledAncestor( elem ) === disabled;
  17741. }
  17742. return elem.disabled === disabled;
  17743. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  17744. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  17745. // even exist on them, let alone have a boolean value.
  17746. } else if ( "label" in elem ) {
  17747. return elem.disabled === disabled;
  17748. }
  17749. // Remaining elements are neither :enabled nor :disabled
  17750. return false;
  17751. };
  17752. }
  17753. /**
  17754. * Returns a function to use in pseudos for positionals
  17755. * @param {Function} fn
  17756. */
  17757. function createPositionalPseudo( fn ) {
  17758. return markFunction(function( argument ) {
  17759. argument = +argument;
  17760. return markFunction(function( seed, matches ) {
  17761. var j,
  17762. matchIndexes = fn( [], seed.length, argument ),
  17763. i = matchIndexes.length;
  17764. // Match elements found at the specified indexes
  17765. while ( i-- ) {
  17766. if ( seed[ (j = matchIndexes[i]) ] ) {
  17767. seed[j] = !(matches[j] = seed[j]);
  17768. }
  17769. }
  17770. });
  17771. });
  17772. }
  17773. /**
  17774. * Checks a node for validity as a Sizzle context
  17775. * @param {Element|Object=} context
  17776. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  17777. */
  17778. function testContext( context ) {
  17779. return context && typeof context.getElementsByTagName !== "undefined" && context;
  17780. }
  17781. // Expose support vars for convenience
  17782. support = Sizzle.support = {};
  17783. /**
  17784. * Detects XML nodes
  17785. * @param {Element|Object} elem An element or a document
  17786. * @returns {Boolean} True iff elem is a non-HTML XML node
  17787. */
  17788. isXML = Sizzle.isXML = function( elem ) {
  17789. // documentElement is verified for cases where it doesn't yet exist
  17790. // (such as loading iframes in IE - #4833)
  17791. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  17792. return documentElement ? documentElement.nodeName !== "HTML" : false;
  17793. };
  17794. /**
  17795. * Sets document-related variables once based on the current document
  17796. * @param {Element|Object} [doc] An element or document object to use to set the document
  17797. * @returns {Object} Returns the current document
  17798. */
  17799. setDocument = Sizzle.setDocument = function( node ) {
  17800. var hasCompare, subWindow,
  17801. doc = node ? node.ownerDocument || node : preferredDoc;
  17802. // Return early if doc is invalid or already selected
  17803. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  17804. return document;
  17805. }
  17806. // Update global variables
  17807. document = doc;
  17808. docElem = document.documentElement;
  17809. documentIsHTML = !isXML( document );
  17810. // Support: IE 9-11, Edge
  17811. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  17812. if ( preferredDoc !== document &&
  17813. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  17814. // Support: IE 11, Edge
  17815. if ( subWindow.addEventListener ) {
  17816. subWindow.addEventListener( "unload", unloadHandler, false );
  17817. // Support: IE 9 - 10 only
  17818. } else if ( subWindow.attachEvent ) {
  17819. subWindow.attachEvent( "onunload", unloadHandler );
  17820. }
  17821. }
  17822. /* Attributes
  17823. ---------------------------------------------------------------------- */
  17824. // Support: IE<8
  17825. // Verify that getAttribute really returns attributes and not properties
  17826. // (excepting IE8 booleans)
  17827. support.attributes = assert(function( el ) {
  17828. el.className = "i";
  17829. return !el.getAttribute("className");
  17830. });
  17831. /* getElement(s)By*
  17832. ---------------------------------------------------------------------- */
  17833. // Check if getElementsByTagName("*") returns only elements
  17834. support.getElementsByTagName = assert(function( el ) {
  17835. el.appendChild( document.createComment("") );
  17836. return !el.getElementsByTagName("*").length;
  17837. });
  17838. // Support: IE<9
  17839. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  17840. // Support: IE<10
  17841. // Check if getElementById returns elements by name
  17842. // The broken getElementById methods don't pick up programmatically-set names,
  17843. // so use a roundabout getElementsByName test
  17844. support.getById = assert(function( el ) {
  17845. docElem.appendChild( el ).id = expando;
  17846. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  17847. });
  17848. // ID filter and find
  17849. if ( support.getById ) {
  17850. Expr.filter["ID"] = function( id ) {
  17851. var attrId = id.replace( runescape, funescape );
  17852. return function( elem ) {
  17853. return elem.getAttribute("id") === attrId;
  17854. };
  17855. };
  17856. Expr.find["ID"] = function( id, context ) {
  17857. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  17858. var elem = context.getElementById( id );
  17859. return elem ? [ elem ] : [];
  17860. }
  17861. };
  17862. } else {
  17863. Expr.filter["ID"] = function( id ) {
  17864. var attrId = id.replace( runescape, funescape );
  17865. return function( elem ) {
  17866. var node = typeof elem.getAttributeNode !== "undefined" &&
  17867. elem.getAttributeNode("id");
  17868. return node && node.value === attrId;
  17869. };
  17870. };
  17871. // Support: IE 6 - 7 only
  17872. // getElementById is not reliable as a find shortcut
  17873. Expr.find["ID"] = function( id, context ) {
  17874. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  17875. var node, i, elems,
  17876. elem = context.getElementById( id );
  17877. if ( elem ) {
  17878. // Verify the id attribute
  17879. node = elem.getAttributeNode("id");
  17880. if ( node && node.value === id ) {
  17881. return [ elem ];
  17882. }
  17883. // Fall back on getElementsByName
  17884. elems = context.getElementsByName( id );
  17885. i = 0;
  17886. while ( (elem = elems[i++]) ) {
  17887. node = elem.getAttributeNode("id");
  17888. if ( node && node.value === id ) {
  17889. return [ elem ];
  17890. }
  17891. }
  17892. }
  17893. return [];
  17894. }
  17895. };
  17896. }
  17897. // Tag
  17898. Expr.find["TAG"] = support.getElementsByTagName ?
  17899. function( tag, context ) {
  17900. if ( typeof context.getElementsByTagName !== "undefined" ) {
  17901. return context.getElementsByTagName( tag );
  17902. // DocumentFragment nodes don't have gEBTN
  17903. } else if ( support.qsa ) {
  17904. return context.querySelectorAll( tag );
  17905. }
  17906. } :
  17907. function( tag, context ) {
  17908. var elem,
  17909. tmp = [],
  17910. i = 0,
  17911. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  17912. results = context.getElementsByTagName( tag );
  17913. // Filter out possible comments
  17914. if ( tag === "*" ) {
  17915. while ( (elem = results[i++]) ) {
  17916. if ( elem.nodeType === 1 ) {
  17917. tmp.push( elem );
  17918. }
  17919. }
  17920. return tmp;
  17921. }
  17922. return results;
  17923. };
  17924. // Class
  17925. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  17926. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  17927. return context.getElementsByClassName( className );
  17928. }
  17929. };
  17930. /* QSA/matchesSelector
  17931. ---------------------------------------------------------------------- */
  17932. // QSA and matchesSelector support
  17933. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  17934. rbuggyMatches = [];
  17935. // qSa(:focus) reports false when true (Chrome 21)
  17936. // We allow this because of a bug in IE8/9 that throws an error
  17937. // whenever `document.activeElement` is accessed on an iframe
  17938. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  17939. // See https://bugs.jquery.com/ticket/13378
  17940. rbuggyQSA = [];
  17941. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  17942. // Build QSA regex
  17943. // Regex strategy adopted from Diego Perini
  17944. assert(function( el ) {
  17945. // Select is set to empty string on purpose
  17946. // This is to test IE's treatment of not explicitly
  17947. // setting a boolean content attribute,
  17948. // since its presence should be enough
  17949. // https://bugs.jquery.com/ticket/12359
  17950. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  17951. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  17952. "<option selected=''></option></select>";
  17953. // Support: IE8, Opera 11-12.16
  17954. // Nothing should be selected when empty strings follow ^= or $= or *=
  17955. // The test attribute must be unknown in Opera but "safe" for WinRT
  17956. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  17957. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  17958. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  17959. }
  17960. // Support: IE8
  17961. // Boolean attributes and "value" are not treated correctly
  17962. if ( !el.querySelectorAll("[selected]").length ) {
  17963. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  17964. }
  17965. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  17966. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  17967. rbuggyQSA.push("~=");
  17968. }
  17969. // Webkit/Opera - :checked should return selected option elements
  17970. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  17971. // IE8 throws error here and will not see later tests
  17972. if ( !el.querySelectorAll(":checked").length ) {
  17973. rbuggyQSA.push(":checked");
  17974. }
  17975. // Support: Safari 8+, iOS 8+
  17976. // https://bugs.webkit.org/show_bug.cgi?id=136851
  17977. // In-page `selector#id sibling-combinator selector` fails
  17978. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  17979. rbuggyQSA.push(".#.+[+~]");
  17980. }
  17981. });
  17982. assert(function( el ) {
  17983. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  17984. "<select disabled='disabled'><option/></select>";
  17985. // Support: Windows 8 Native Apps
  17986. // The type and name attributes are restricted during .innerHTML assignment
  17987. var input = document.createElement("input");
  17988. input.setAttribute( "type", "hidden" );
  17989. el.appendChild( input ).setAttribute( "name", "D" );
  17990. // Support: IE8
  17991. // Enforce case-sensitivity of name attribute
  17992. if ( el.querySelectorAll("[name=d]").length ) {
  17993. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  17994. }
  17995. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  17996. // IE8 throws error here and will not see later tests
  17997. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  17998. rbuggyQSA.push( ":enabled", ":disabled" );
  17999. }
  18000. // Support: IE9-11+
  18001. // IE's :disabled selector does not pick up the children of disabled fieldsets
  18002. docElem.appendChild( el ).disabled = true;
  18003. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  18004. rbuggyQSA.push( ":enabled", ":disabled" );
  18005. }
  18006. // Opera 10-11 does not throw on post-comma invalid pseudos
  18007. el.querySelectorAll("*,:x");
  18008. rbuggyQSA.push(",.*:");
  18009. });
  18010. }
  18011. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  18012. docElem.webkitMatchesSelector ||
  18013. docElem.mozMatchesSelector ||
  18014. docElem.oMatchesSelector ||
  18015. docElem.msMatchesSelector) )) ) {
  18016. assert(function( el ) {
  18017. // Check to see if it's possible to do matchesSelector
  18018. // on a disconnected node (IE 9)
  18019. support.disconnectedMatch = matches.call( el, "*" );
  18020. // This should fail with an exception
  18021. // Gecko does not error, returns false instead
  18022. matches.call( el, "[s!='']:x" );
  18023. rbuggyMatches.push( "!=", pseudos );
  18024. });
  18025. }
  18026. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  18027. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  18028. /* Contains
  18029. ---------------------------------------------------------------------- */
  18030. hasCompare = rnative.test( docElem.compareDocumentPosition );
  18031. // Element contains another
  18032. // Purposefully self-exclusive
  18033. // As in, an element does not contain itself
  18034. contains = hasCompare || rnative.test( docElem.contains ) ?
  18035. function( a, b ) {
  18036. var adown = a.nodeType === 9 ? a.documentElement : a,
  18037. bup = b && b.parentNode;
  18038. return a === bup || !!( bup && bup.nodeType === 1 && (
  18039. adown.contains ?
  18040. adown.contains( bup ) :
  18041. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  18042. ));
  18043. } :
  18044. function( a, b ) {
  18045. if ( b ) {
  18046. while ( (b = b.parentNode) ) {
  18047. if ( b === a ) {
  18048. return true;
  18049. }
  18050. }
  18051. }
  18052. return false;
  18053. };
  18054. /* Sorting
  18055. ---------------------------------------------------------------------- */
  18056. // Document order sorting
  18057. sortOrder = hasCompare ?
  18058. function( a, b ) {
  18059. // Flag for duplicate removal
  18060. if ( a === b ) {
  18061. hasDuplicate = true;
  18062. return 0;
  18063. }
  18064. // Sort on method existence if only one input has compareDocumentPosition
  18065. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  18066. if ( compare ) {
  18067. return compare;
  18068. }
  18069. // Calculate position if both inputs belong to the same document
  18070. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  18071. a.compareDocumentPosition( b ) :
  18072. // Otherwise we know they are disconnected
  18073. 1;
  18074. // Disconnected nodes
  18075. if ( compare & 1 ||
  18076. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  18077. // Choose the first element that is related to our preferred document
  18078. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  18079. return -1;
  18080. }
  18081. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  18082. return 1;
  18083. }
  18084. // Maintain original order
  18085. return sortInput ?
  18086. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  18087. 0;
  18088. }
  18089. return compare & 4 ? -1 : 1;
  18090. } :
  18091. function( a, b ) {
  18092. // Exit early if the nodes are identical
  18093. if ( a === b ) {
  18094. hasDuplicate = true;
  18095. return 0;
  18096. }
  18097. var cur,
  18098. i = 0,
  18099. aup = a.parentNode,
  18100. bup = b.parentNode,
  18101. ap = [ a ],
  18102. bp = [ b ];
  18103. // Parentless nodes are either documents or disconnected
  18104. if ( !aup || !bup ) {
  18105. return a === document ? -1 :
  18106. b === document ? 1 :
  18107. aup ? -1 :
  18108. bup ? 1 :
  18109. sortInput ?
  18110. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  18111. 0;
  18112. // If the nodes are siblings, we can do a quick check
  18113. } else if ( aup === bup ) {
  18114. return siblingCheck( a, b );
  18115. }
  18116. // Otherwise we need full lists of their ancestors for comparison
  18117. cur = a;
  18118. while ( (cur = cur.parentNode) ) {
  18119. ap.unshift( cur );
  18120. }
  18121. cur = b;
  18122. while ( (cur = cur.parentNode) ) {
  18123. bp.unshift( cur );
  18124. }
  18125. // Walk down the tree looking for a discrepancy
  18126. while ( ap[i] === bp[i] ) {
  18127. i++;
  18128. }
  18129. return i ?
  18130. // Do a sibling check if the nodes have a common ancestor
  18131. siblingCheck( ap[i], bp[i] ) :
  18132. // Otherwise nodes in our document sort first
  18133. ap[i] === preferredDoc ? -1 :
  18134. bp[i] === preferredDoc ? 1 :
  18135. 0;
  18136. };
  18137. return document;
  18138. };
  18139. Sizzle.matches = function( expr, elements ) {
  18140. return Sizzle( expr, null, null, elements );
  18141. };
  18142. Sizzle.matchesSelector = function( elem, expr ) {
  18143. // Set document vars if needed
  18144. if ( ( elem.ownerDocument || elem ) !== document ) {
  18145. setDocument( elem );
  18146. }
  18147. // Make sure that attribute selectors are quoted
  18148. expr = expr.replace( rattributeQuotes, "='$1']" );
  18149. if ( support.matchesSelector && documentIsHTML &&
  18150. !compilerCache[ expr + " " ] &&
  18151. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  18152. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  18153. try {
  18154. var ret = matches.call( elem, expr );
  18155. // IE 9's matchesSelector returns false on disconnected nodes
  18156. if ( ret || support.disconnectedMatch ||
  18157. // As well, disconnected nodes are said to be in a document
  18158. // fragment in IE 9
  18159. elem.document && elem.document.nodeType !== 11 ) {
  18160. return ret;
  18161. }
  18162. } catch (e) {}
  18163. }
  18164. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  18165. };
  18166. Sizzle.contains = function( context, elem ) {
  18167. // Set document vars if needed
  18168. if ( ( context.ownerDocument || context ) !== document ) {
  18169. setDocument( context );
  18170. }
  18171. return contains( context, elem );
  18172. };
  18173. Sizzle.attr = function( elem, name ) {
  18174. // Set document vars if needed
  18175. if ( ( elem.ownerDocument || elem ) !== document ) {
  18176. setDocument( elem );
  18177. }
  18178. var fn = Expr.attrHandle[ name.toLowerCase() ],
  18179. // Don't get fooled by Object.prototype properties (jQuery #13807)
  18180. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  18181. fn( elem, name, !documentIsHTML ) :
  18182. undefined;
  18183. return val !== undefined ?
  18184. val :
  18185. support.attributes || !documentIsHTML ?
  18186. elem.getAttribute( name ) :
  18187. (val = elem.getAttributeNode(name)) && val.specified ?
  18188. val.value :
  18189. null;
  18190. };
  18191. Sizzle.escape = function( sel ) {
  18192. return (sel + "").replace( rcssescape, fcssescape );
  18193. };
  18194. Sizzle.error = function( msg ) {
  18195. throw new Error( "Syntax error, unrecognized expression: " + msg );
  18196. };
  18197. /**
  18198. * Document sorting and removing duplicates
  18199. * @param {ArrayLike} results
  18200. */
  18201. Sizzle.uniqueSort = function( results ) {
  18202. var elem,
  18203. duplicates = [],
  18204. j = 0,
  18205. i = 0;
  18206. // Unless we *know* we can detect duplicates, assume their presence
  18207. hasDuplicate = !support.detectDuplicates;
  18208. sortInput = !support.sortStable && results.slice( 0 );
  18209. results.sort( sortOrder );
  18210. if ( hasDuplicate ) {
  18211. while ( (elem = results[i++]) ) {
  18212. if ( elem === results[ i ] ) {
  18213. j = duplicates.push( i );
  18214. }
  18215. }
  18216. while ( j-- ) {
  18217. results.splice( duplicates[ j ], 1 );
  18218. }
  18219. }
  18220. // Clear input after sorting to release objects
  18221. // See https://github.com/jquery/sizzle/pull/225
  18222. sortInput = null;
  18223. return results;
  18224. };
  18225. /**
  18226. * Utility function for retrieving the text value of an array of DOM nodes
  18227. * @param {Array|Element} elem
  18228. */
  18229. getText = Sizzle.getText = function( elem ) {
  18230. var node,
  18231. ret = "",
  18232. i = 0,
  18233. nodeType = elem.nodeType;
  18234. if ( !nodeType ) {
  18235. // If no nodeType, this is expected to be an array
  18236. while ( (node = elem[i++]) ) {
  18237. // Do not traverse comment nodes
  18238. ret += getText( node );
  18239. }
  18240. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  18241. // Use textContent for elements
  18242. // innerText usage removed for consistency of new lines (jQuery #11153)
  18243. if ( typeof elem.textContent === "string" ) {
  18244. return elem.textContent;
  18245. } else {
  18246. // Traverse its children
  18247. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  18248. ret += getText( elem );
  18249. }
  18250. }
  18251. } else if ( nodeType === 3 || nodeType === 4 ) {
  18252. return elem.nodeValue;
  18253. }
  18254. // Do not include comment or processing instruction nodes
  18255. return ret;
  18256. };
  18257. Expr = Sizzle.selectors = {
  18258. // Can be adjusted by the user
  18259. cacheLength: 50,
  18260. createPseudo: markFunction,
  18261. match: matchExpr,
  18262. attrHandle: {},
  18263. find: {},
  18264. relative: {
  18265. ">": { dir: "parentNode", first: true },
  18266. " ": { dir: "parentNode" },
  18267. "+": { dir: "previousSibling", first: true },
  18268. "~": { dir: "previousSibling" }
  18269. },
  18270. preFilter: {
  18271. "ATTR": function( match ) {
  18272. match[1] = match[1].replace( runescape, funescape );
  18273. // Move the given value to match[3] whether quoted or unquoted
  18274. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  18275. if ( match[2] === "~=" ) {
  18276. match[3] = " " + match[3] + " ";
  18277. }
  18278. return match.slice( 0, 4 );
  18279. },
  18280. "CHILD": function( match ) {
  18281. /* matches from matchExpr["CHILD"]
  18282. 1 type (only|nth|...)
  18283. 2 what (child|of-type)
  18284. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  18285. 4 xn-component of xn+y argument ([+-]?\d*n|)
  18286. 5 sign of xn-component
  18287. 6 x of xn-component
  18288. 7 sign of y-component
  18289. 8 y of y-component
  18290. */
  18291. match[1] = match[1].toLowerCase();
  18292. if ( match[1].slice( 0, 3 ) === "nth" ) {
  18293. // nth-* requires argument
  18294. if ( !match[3] ) {
  18295. Sizzle.error( match[0] );
  18296. }
  18297. // numeric x and y parameters for Expr.filter.CHILD
  18298. // remember that false/true cast respectively to 0/1
  18299. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  18300. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  18301. // other types prohibit arguments
  18302. } else if ( match[3] ) {
  18303. Sizzle.error( match[0] );
  18304. }
  18305. return match;
  18306. },
  18307. "PSEUDO": function( match ) {
  18308. var excess,
  18309. unquoted = !match[6] && match[2];
  18310. if ( matchExpr["CHILD"].test( match[0] ) ) {
  18311. return null;
  18312. }
  18313. // Accept quoted arguments as-is
  18314. if ( match[3] ) {
  18315. match[2] = match[4] || match[5] || "";
  18316. // Strip excess characters from unquoted arguments
  18317. } else if ( unquoted && rpseudo.test( unquoted ) &&
  18318. // Get excess from tokenize (recursively)
  18319. (excess = tokenize( unquoted, true )) &&
  18320. // advance to the next closing parenthesis
  18321. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  18322. // excess is a negative index
  18323. match[0] = match[0].slice( 0, excess );
  18324. match[2] = unquoted.slice( 0, excess );
  18325. }
  18326. // Return only captures needed by the pseudo filter method (type and argument)
  18327. return match.slice( 0, 3 );
  18328. }
  18329. },
  18330. filter: {
  18331. "TAG": function( nodeNameSelector ) {
  18332. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  18333. return nodeNameSelector === "*" ?
  18334. function() { return true; } :
  18335. function( elem ) {
  18336. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  18337. };
  18338. },
  18339. "CLASS": function( className ) {
  18340. var pattern = classCache[ className + " " ];
  18341. return pattern ||
  18342. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  18343. classCache( className, function( elem ) {
  18344. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  18345. });
  18346. },
  18347. "ATTR": function( name, operator, check ) {
  18348. return function( elem ) {
  18349. var result = Sizzle.attr( elem, name );
  18350. if ( result == null ) {
  18351. return operator === "!=";
  18352. }
  18353. if ( !operator ) {
  18354. return true;
  18355. }
  18356. result += "";
  18357. return operator === "=" ? result === check :
  18358. operator === "!=" ? result !== check :
  18359. operator === "^=" ? check && result.indexOf( check ) === 0 :
  18360. operator === "*=" ? check && result.indexOf( check ) > -1 :
  18361. operator === "$=" ? check && result.slice( -check.length ) === check :
  18362. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  18363. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  18364. false;
  18365. };
  18366. },
  18367. "CHILD": function( type, what, argument, first, last ) {
  18368. var simple = type.slice( 0, 3 ) !== "nth",
  18369. forward = type.slice( -4 ) !== "last",
  18370. ofType = what === "of-type";
  18371. return first === 1 && last === 0 ?
  18372. // Shortcut for :nth-*(n)
  18373. function( elem ) {
  18374. return !!elem.parentNode;
  18375. } :
  18376. function( elem, context, xml ) {
  18377. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  18378. dir = simple !== forward ? "nextSibling" : "previousSibling",
  18379. parent = elem.parentNode,
  18380. name = ofType && elem.nodeName.toLowerCase(),
  18381. useCache = !xml && !ofType,
  18382. diff = false;
  18383. if ( parent ) {
  18384. // :(first|last|only)-(child|of-type)
  18385. if ( simple ) {
  18386. while ( dir ) {
  18387. node = elem;
  18388. while ( (node = node[ dir ]) ) {
  18389. if ( ofType ?
  18390. node.nodeName.toLowerCase() === name :
  18391. node.nodeType === 1 ) {
  18392. return false;
  18393. }
  18394. }
  18395. // Reverse direction for :only-* (if we haven't yet done so)
  18396. start = dir = type === "only" && !start && "nextSibling";
  18397. }
  18398. return true;
  18399. }
  18400. start = [ forward ? parent.firstChild : parent.lastChild ];
  18401. // non-xml :nth-child(...) stores cache data on `parent`
  18402. if ( forward && useCache ) {
  18403. // Seek `elem` from a previously-cached index
  18404. // ...in a gzip-friendly way
  18405. node = parent;
  18406. outerCache = node[ expando ] || (node[ expando ] = {});
  18407. // Support: IE <9 only
  18408. // Defend against cloned attroperties (jQuery gh-1709)
  18409. uniqueCache = outerCache[ node.uniqueID ] ||
  18410. (outerCache[ node.uniqueID ] = {});
  18411. cache = uniqueCache[ type ] || [];
  18412. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  18413. diff = nodeIndex && cache[ 2 ];
  18414. node = nodeIndex && parent.childNodes[ nodeIndex ];
  18415. while ( (node = ++nodeIndex && node && node[ dir ] ||
  18416. // Fallback to seeking `elem` from the start
  18417. (diff = nodeIndex = 0) || start.pop()) ) {
  18418. // When found, cache indexes on `parent` and break
  18419. if ( node.nodeType === 1 && ++diff && node === elem ) {
  18420. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  18421. break;
  18422. }
  18423. }
  18424. } else {
  18425. // Use previously-cached element index if available
  18426. if ( useCache ) {
  18427. // ...in a gzip-friendly way
  18428. node = elem;
  18429. outerCache = node[ expando ] || (node[ expando ] = {});
  18430. // Support: IE <9 only
  18431. // Defend against cloned attroperties (jQuery gh-1709)
  18432. uniqueCache = outerCache[ node.uniqueID ] ||
  18433. (outerCache[ node.uniqueID ] = {});
  18434. cache = uniqueCache[ type ] || [];
  18435. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  18436. diff = nodeIndex;
  18437. }
  18438. // xml :nth-child(...)
  18439. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  18440. if ( diff === false ) {
  18441. // Use the same loop as above to seek `elem` from the start
  18442. while ( (node = ++nodeIndex && node && node[ dir ] ||
  18443. (diff = nodeIndex = 0) || start.pop()) ) {
  18444. if ( ( ofType ?
  18445. node.nodeName.toLowerCase() === name :
  18446. node.nodeType === 1 ) &&
  18447. ++diff ) {
  18448. // Cache the index of each encountered element
  18449. if ( useCache ) {
  18450. outerCache = node[ expando ] || (node[ expando ] = {});
  18451. // Support: IE <9 only
  18452. // Defend against cloned attroperties (jQuery gh-1709)
  18453. uniqueCache = outerCache[ node.uniqueID ] ||
  18454. (outerCache[ node.uniqueID ] = {});
  18455. uniqueCache[ type ] = [ dirruns, diff ];
  18456. }
  18457. if ( node === elem ) {
  18458. break;
  18459. }
  18460. }
  18461. }
  18462. }
  18463. }
  18464. // Incorporate the offset, then check against cycle size
  18465. diff -= last;
  18466. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  18467. }
  18468. };
  18469. },
  18470. "PSEUDO": function( pseudo, argument ) {
  18471. // pseudo-class names are case-insensitive
  18472. // http://www.w3.org/TR/selectors/#pseudo-classes
  18473. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  18474. // Remember that setFilters inherits from pseudos
  18475. var args,
  18476. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  18477. Sizzle.error( "unsupported pseudo: " + pseudo );
  18478. // The user may use createPseudo to indicate that
  18479. // arguments are needed to create the filter function
  18480. // just as Sizzle does
  18481. if ( fn[ expando ] ) {
  18482. return fn( argument );
  18483. }
  18484. // But maintain support for old signatures
  18485. if ( fn.length > 1 ) {
  18486. args = [ pseudo, pseudo, "", argument ];
  18487. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  18488. markFunction(function( seed, matches ) {
  18489. var idx,
  18490. matched = fn( seed, argument ),
  18491. i = matched.length;
  18492. while ( i-- ) {
  18493. idx = indexOf( seed, matched[i] );
  18494. seed[ idx ] = !( matches[ idx ] = matched[i] );
  18495. }
  18496. }) :
  18497. function( elem ) {
  18498. return fn( elem, 0, args );
  18499. };
  18500. }
  18501. return fn;
  18502. }
  18503. },
  18504. pseudos: {
  18505. // Potentially complex pseudos
  18506. "not": markFunction(function( selector ) {
  18507. // Trim the selector passed to compile
  18508. // to avoid treating leading and trailing
  18509. // spaces as combinators
  18510. var input = [],
  18511. results = [],
  18512. matcher = compile( selector.replace( rtrim, "$1" ) );
  18513. return matcher[ expando ] ?
  18514. markFunction(function( seed, matches, context, xml ) {
  18515. var elem,
  18516. unmatched = matcher( seed, null, xml, [] ),
  18517. i = seed.length;
  18518. // Match elements unmatched by `matcher`
  18519. while ( i-- ) {
  18520. if ( (elem = unmatched[i]) ) {
  18521. seed[i] = !(matches[i] = elem);
  18522. }
  18523. }
  18524. }) :
  18525. function( elem, context, xml ) {
  18526. input[0] = elem;
  18527. matcher( input, null, xml, results );
  18528. // Don't keep the element (issue #299)
  18529. input[0] = null;
  18530. return !results.pop();
  18531. };
  18532. }),
  18533. "has": markFunction(function( selector ) {
  18534. return function( elem ) {
  18535. return Sizzle( selector, elem ).length > 0;
  18536. };
  18537. }),
  18538. "contains": markFunction(function( text ) {
  18539. text = text.replace( runescape, funescape );
  18540. return function( elem ) {
  18541. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  18542. };
  18543. }),
  18544. // "Whether an element is represented by a :lang() selector
  18545. // is based solely on the element's language value
  18546. // being equal to the identifier C,
  18547. // or beginning with the identifier C immediately followed by "-".
  18548. // The matching of C against the element's language value is performed case-insensitively.
  18549. // The identifier C does not have to be a valid language name."
  18550. // http://www.w3.org/TR/selectors/#lang-pseudo
  18551. "lang": markFunction( function( lang ) {
  18552. // lang value must be a valid identifier
  18553. if ( !ridentifier.test(lang || "") ) {
  18554. Sizzle.error( "unsupported lang: " + lang );
  18555. }
  18556. lang = lang.replace( runescape, funescape ).toLowerCase();
  18557. return function( elem ) {
  18558. var elemLang;
  18559. do {
  18560. if ( (elemLang = documentIsHTML ?
  18561. elem.lang :
  18562. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  18563. elemLang = elemLang.toLowerCase();
  18564. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  18565. }
  18566. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  18567. return false;
  18568. };
  18569. }),
  18570. // Miscellaneous
  18571. "target": function( elem ) {
  18572. var hash = window.location && window.location.hash;
  18573. return hash && hash.slice( 1 ) === elem.id;
  18574. },
  18575. "root": function( elem ) {
  18576. return elem === docElem;
  18577. },
  18578. "focus": function( elem ) {
  18579. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  18580. },
  18581. // Boolean properties
  18582. "enabled": createDisabledPseudo( false ),
  18583. "disabled": createDisabledPseudo( true ),
  18584. "checked": function( elem ) {
  18585. // In CSS3, :checked should return both checked and selected elements
  18586. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  18587. var nodeName = elem.nodeName.toLowerCase();
  18588. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  18589. },
  18590. "selected": function( elem ) {
  18591. // Accessing this property makes selected-by-default
  18592. // options in Safari work properly
  18593. if ( elem.parentNode ) {
  18594. elem.parentNode.selectedIndex;
  18595. }
  18596. return elem.selected === true;
  18597. },
  18598. // Contents
  18599. "empty": function( elem ) {
  18600. // http://www.w3.org/TR/selectors/#empty-pseudo
  18601. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  18602. // but not by others (comment: 8; processing instruction: 7; etc.)
  18603. // nodeType < 6 works because attributes (2) do not appear as children
  18604. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  18605. if ( elem.nodeType < 6 ) {
  18606. return false;
  18607. }
  18608. }
  18609. return true;
  18610. },
  18611. "parent": function( elem ) {
  18612. return !Expr.pseudos["empty"]( elem );
  18613. },
  18614. // Element/input types
  18615. "header": function( elem ) {
  18616. return rheader.test( elem.nodeName );
  18617. },
  18618. "input": function( elem ) {
  18619. return rinputs.test( elem.nodeName );
  18620. },
  18621. "button": function( elem ) {
  18622. var name = elem.nodeName.toLowerCase();
  18623. return name === "input" && elem.type === "button" || name === "button";
  18624. },
  18625. "text": function( elem ) {
  18626. var attr;
  18627. return elem.nodeName.toLowerCase() === "input" &&
  18628. elem.type === "text" &&
  18629. // Support: IE<8
  18630. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  18631. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  18632. },
  18633. // Position-in-collection
  18634. "first": createPositionalPseudo(function() {
  18635. return [ 0 ];
  18636. }),
  18637. "last": createPositionalPseudo(function( matchIndexes, length ) {
  18638. return [ length - 1 ];
  18639. }),
  18640. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18641. return [ argument < 0 ? argument + length : argument ];
  18642. }),
  18643. "even": createPositionalPseudo(function( matchIndexes, length ) {
  18644. var i = 0;
  18645. for ( ; i < length; i += 2 ) {
  18646. matchIndexes.push( i );
  18647. }
  18648. return matchIndexes;
  18649. }),
  18650. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  18651. var i = 1;
  18652. for ( ; i < length; i += 2 ) {
  18653. matchIndexes.push( i );
  18654. }
  18655. return matchIndexes;
  18656. }),
  18657. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18658. var i = argument < 0 ? argument + length : argument;
  18659. for ( ; --i >= 0; ) {
  18660. matchIndexes.push( i );
  18661. }
  18662. return matchIndexes;
  18663. }),
  18664. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18665. var i = argument < 0 ? argument + length : argument;
  18666. for ( ; ++i < length; ) {
  18667. matchIndexes.push( i );
  18668. }
  18669. return matchIndexes;
  18670. })
  18671. }
  18672. };
  18673. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  18674. // Add button/input type pseudos
  18675. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  18676. Expr.pseudos[ i ] = createInputPseudo( i );
  18677. }
  18678. for ( i in { submit: true, reset: true } ) {
  18679. Expr.pseudos[ i ] = createButtonPseudo( i );
  18680. }
  18681. // Easy API for creating new setFilters
  18682. function setFilters() {}
  18683. setFilters.prototype = Expr.filters = Expr.pseudos;
  18684. Expr.setFilters = new setFilters();
  18685. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  18686. var matched, match, tokens, type,
  18687. soFar, groups, preFilters,
  18688. cached = tokenCache[ selector + " " ];
  18689. if ( cached ) {
  18690. return parseOnly ? 0 : cached.slice( 0 );
  18691. }
  18692. soFar = selector;
  18693. groups = [];
  18694. preFilters = Expr.preFilter;
  18695. while ( soFar ) {
  18696. // Comma and first run
  18697. if ( !matched || (match = rcomma.exec( soFar )) ) {
  18698. if ( match ) {
  18699. // Don't consume trailing commas as valid
  18700. soFar = soFar.slice( match[0].length ) || soFar;
  18701. }
  18702. groups.push( (tokens = []) );
  18703. }
  18704. matched = false;
  18705. // Combinators
  18706. if ( (match = rcombinators.exec( soFar )) ) {
  18707. matched = match.shift();
  18708. tokens.push({
  18709. value: matched,
  18710. // Cast descendant combinators to space
  18711. type: match[0].replace( rtrim, " " )
  18712. });
  18713. soFar = soFar.slice( matched.length );
  18714. }
  18715. // Filters
  18716. for ( type in Expr.filter ) {
  18717. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  18718. (match = preFilters[ type ]( match ))) ) {
  18719. matched = match.shift();
  18720. tokens.push({
  18721. value: matched,
  18722. type: type,
  18723. matches: match
  18724. });
  18725. soFar = soFar.slice( matched.length );
  18726. }
  18727. }
  18728. if ( !matched ) {
  18729. break;
  18730. }
  18731. }
  18732. // Return the length of the invalid excess
  18733. // if we're just parsing
  18734. // Otherwise, throw an error or return tokens
  18735. return parseOnly ?
  18736. soFar.length :
  18737. soFar ?
  18738. Sizzle.error( selector ) :
  18739. // Cache the tokens
  18740. tokenCache( selector, groups ).slice( 0 );
  18741. };
  18742. function toSelector( tokens ) {
  18743. var i = 0,
  18744. len = tokens.length,
  18745. selector = "";
  18746. for ( ; i < len; i++ ) {
  18747. selector += tokens[i].value;
  18748. }
  18749. return selector;
  18750. }
  18751. function addCombinator( matcher, combinator, base ) {
  18752. var dir = combinator.dir,
  18753. skip = combinator.next,
  18754. key = skip || dir,
  18755. checkNonElements = base && key === "parentNode",
  18756. doneName = done++;
  18757. return combinator.first ?
  18758. // Check against closest ancestor/preceding element
  18759. function( elem, context, xml ) {
  18760. while ( (elem = elem[ dir ]) ) {
  18761. if ( elem.nodeType === 1 || checkNonElements ) {
  18762. return matcher( elem, context, xml );
  18763. }
  18764. }
  18765. return false;
  18766. } :
  18767. // Check against all ancestor/preceding elements
  18768. function( elem, context, xml ) {
  18769. var oldCache, uniqueCache, outerCache,
  18770. newCache = [ dirruns, doneName ];
  18771. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  18772. if ( xml ) {
  18773. while ( (elem = elem[ dir ]) ) {
  18774. if ( elem.nodeType === 1 || checkNonElements ) {
  18775. if ( matcher( elem, context, xml ) ) {
  18776. return true;
  18777. }
  18778. }
  18779. }
  18780. } else {
  18781. while ( (elem = elem[ dir ]) ) {
  18782. if ( elem.nodeType === 1 || checkNonElements ) {
  18783. outerCache = elem[ expando ] || (elem[ expando ] = {});
  18784. // Support: IE <9 only
  18785. // Defend against cloned attroperties (jQuery gh-1709)
  18786. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  18787. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  18788. elem = elem[ dir ] || elem;
  18789. } else if ( (oldCache = uniqueCache[ key ]) &&
  18790. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  18791. // Assign to newCache so results back-propagate to previous elements
  18792. return (newCache[ 2 ] = oldCache[ 2 ]);
  18793. } else {
  18794. // Reuse newcache so results back-propagate to previous elements
  18795. uniqueCache[ key ] = newCache;
  18796. // A match means we're done; a fail means we have to keep checking
  18797. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  18798. return true;
  18799. }
  18800. }
  18801. }
  18802. }
  18803. }
  18804. return false;
  18805. };
  18806. }
  18807. function elementMatcher( matchers ) {
  18808. return matchers.length > 1 ?
  18809. function( elem, context, xml ) {
  18810. var i = matchers.length;
  18811. while ( i-- ) {
  18812. if ( !matchers[i]( elem, context, xml ) ) {
  18813. return false;
  18814. }
  18815. }
  18816. return true;
  18817. } :
  18818. matchers[0];
  18819. }
  18820. function multipleContexts( selector, contexts, results ) {
  18821. var i = 0,
  18822. len = contexts.length;
  18823. for ( ; i < len; i++ ) {
  18824. Sizzle( selector, contexts[i], results );
  18825. }
  18826. return results;
  18827. }
  18828. function condense( unmatched, map, filter, context, xml ) {
  18829. var elem,
  18830. newUnmatched = [],
  18831. i = 0,
  18832. len = unmatched.length,
  18833. mapped = map != null;
  18834. for ( ; i < len; i++ ) {
  18835. if ( (elem = unmatched[i]) ) {
  18836. if ( !filter || filter( elem, context, xml ) ) {
  18837. newUnmatched.push( elem );
  18838. if ( mapped ) {
  18839. map.push( i );
  18840. }
  18841. }
  18842. }
  18843. }
  18844. return newUnmatched;
  18845. }
  18846. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  18847. if ( postFilter && !postFilter[ expando ] ) {
  18848. postFilter = setMatcher( postFilter );
  18849. }
  18850. if ( postFinder && !postFinder[ expando ] ) {
  18851. postFinder = setMatcher( postFinder, postSelector );
  18852. }
  18853. return markFunction(function( seed, results, context, xml ) {
  18854. var temp, i, elem,
  18855. preMap = [],
  18856. postMap = [],
  18857. preexisting = results.length,
  18858. // Get initial elements from seed or context
  18859. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  18860. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  18861. matcherIn = preFilter && ( seed || !selector ) ?
  18862. condense( elems, preMap, preFilter, context, xml ) :
  18863. elems,
  18864. matcherOut = matcher ?
  18865. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  18866. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  18867. // ...intermediate processing is necessary
  18868. [] :
  18869. // ...otherwise use results directly
  18870. results :
  18871. matcherIn;
  18872. // Find primary matches
  18873. if ( matcher ) {
  18874. matcher( matcherIn, matcherOut, context, xml );
  18875. }
  18876. // Apply postFilter
  18877. if ( postFilter ) {
  18878. temp = condense( matcherOut, postMap );
  18879. postFilter( temp, [], context, xml );
  18880. // Un-match failing elements by moving them back to matcherIn
  18881. i = temp.length;
  18882. while ( i-- ) {
  18883. if ( (elem = temp[i]) ) {
  18884. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  18885. }
  18886. }
  18887. }
  18888. if ( seed ) {
  18889. if ( postFinder || preFilter ) {
  18890. if ( postFinder ) {
  18891. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  18892. temp = [];
  18893. i = matcherOut.length;
  18894. while ( i-- ) {
  18895. if ( (elem = matcherOut[i]) ) {
  18896. // Restore matcherIn since elem is not yet a final match
  18897. temp.push( (matcherIn[i] = elem) );
  18898. }
  18899. }
  18900. postFinder( null, (matcherOut = []), temp, xml );
  18901. }
  18902. // Move matched elements from seed to results to keep them synchronized
  18903. i = matcherOut.length;
  18904. while ( i-- ) {
  18905. if ( (elem = matcherOut[i]) &&
  18906. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  18907. seed[temp] = !(results[temp] = elem);
  18908. }
  18909. }
  18910. }
  18911. // Add elements to results, through postFinder if defined
  18912. } else {
  18913. matcherOut = condense(
  18914. matcherOut === results ?
  18915. matcherOut.splice( preexisting, matcherOut.length ) :
  18916. matcherOut
  18917. );
  18918. if ( postFinder ) {
  18919. postFinder( null, results, matcherOut, xml );
  18920. } else {
  18921. push.apply( results, matcherOut );
  18922. }
  18923. }
  18924. });
  18925. }
  18926. function matcherFromTokens( tokens ) {
  18927. var checkContext, matcher, j,
  18928. len = tokens.length,
  18929. leadingRelative = Expr.relative[ tokens[0].type ],
  18930. implicitRelative = leadingRelative || Expr.relative[" "],
  18931. i = leadingRelative ? 1 : 0,
  18932. // The foundational matcher ensures that elements are reachable from top-level context(s)
  18933. matchContext = addCombinator( function( elem ) {
  18934. return elem === checkContext;
  18935. }, implicitRelative, true ),
  18936. matchAnyContext = addCombinator( function( elem ) {
  18937. return indexOf( checkContext, elem ) > -1;
  18938. }, implicitRelative, true ),
  18939. matchers = [ function( elem, context, xml ) {
  18940. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  18941. (checkContext = context).nodeType ?
  18942. matchContext( elem, context, xml ) :
  18943. matchAnyContext( elem, context, xml ) );
  18944. // Avoid hanging onto element (issue #299)
  18945. checkContext = null;
  18946. return ret;
  18947. } ];
  18948. for ( ; i < len; i++ ) {
  18949. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  18950. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  18951. } else {
  18952. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  18953. // Return special upon seeing a positional matcher
  18954. if ( matcher[ expando ] ) {
  18955. // Find the next relative operator (if any) for proper handling
  18956. j = ++i;
  18957. for ( ; j < len; j++ ) {
  18958. if ( Expr.relative[ tokens[j].type ] ) {
  18959. break;
  18960. }
  18961. }
  18962. return setMatcher(
  18963. i > 1 && elementMatcher( matchers ),
  18964. i > 1 && toSelector(
  18965. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  18966. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  18967. ).replace( rtrim, "$1" ),
  18968. matcher,
  18969. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  18970. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  18971. j < len && toSelector( tokens )
  18972. );
  18973. }
  18974. matchers.push( matcher );
  18975. }
  18976. }
  18977. return elementMatcher( matchers );
  18978. }
  18979. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  18980. var bySet = setMatchers.length > 0,
  18981. byElement = elementMatchers.length > 0,
  18982. superMatcher = function( seed, context, xml, results, outermost ) {
  18983. var elem, j, matcher,
  18984. matchedCount = 0,
  18985. i = "0",
  18986. unmatched = seed && [],
  18987. setMatched = [],
  18988. contextBackup = outermostContext,
  18989. // We must always have either seed elements or outermost context
  18990. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  18991. // Use integer dirruns iff this is the outermost matcher
  18992. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  18993. len = elems.length;
  18994. if ( outermost ) {
  18995. outermostContext = context === document || context || outermost;
  18996. }
  18997. // Add elements passing elementMatchers directly to results
  18998. // Support: IE<9, Safari
  18999. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  19000. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  19001. if ( byElement && elem ) {
  19002. j = 0;
  19003. if ( !context && elem.ownerDocument !== document ) {
  19004. setDocument( elem );
  19005. xml = !documentIsHTML;
  19006. }
  19007. while ( (matcher = elementMatchers[j++]) ) {
  19008. if ( matcher( elem, context || document, xml) ) {
  19009. results.push( elem );
  19010. break;
  19011. }
  19012. }
  19013. if ( outermost ) {
  19014. dirruns = dirrunsUnique;
  19015. }
  19016. }
  19017. // Track unmatched elements for set filters
  19018. if ( bySet ) {
  19019. // They will have gone through all possible matchers
  19020. if ( (elem = !matcher && elem) ) {
  19021. matchedCount--;
  19022. }
  19023. // Lengthen the array for every element, matched or not
  19024. if ( seed ) {
  19025. unmatched.push( elem );
  19026. }
  19027. }
  19028. }
  19029. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  19030. // makes the latter nonnegative.
  19031. matchedCount += i;
  19032. // Apply set filters to unmatched elements
  19033. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  19034. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  19035. // no element matchers and no seed.
  19036. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  19037. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  19038. // numerically zero.
  19039. if ( bySet && i !== matchedCount ) {
  19040. j = 0;
  19041. while ( (matcher = setMatchers[j++]) ) {
  19042. matcher( unmatched, setMatched, context, xml );
  19043. }
  19044. if ( seed ) {
  19045. // Reintegrate element matches to eliminate the need for sorting
  19046. if ( matchedCount > 0 ) {
  19047. while ( i-- ) {
  19048. if ( !(unmatched[i] || setMatched[i]) ) {
  19049. setMatched[i] = pop.call( results );
  19050. }
  19051. }
  19052. }
  19053. // Discard index placeholder values to get only actual matches
  19054. setMatched = condense( setMatched );
  19055. }
  19056. // Add matches to results
  19057. push.apply( results, setMatched );
  19058. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  19059. if ( outermost && !seed && setMatched.length > 0 &&
  19060. ( matchedCount + setMatchers.length ) > 1 ) {
  19061. Sizzle.uniqueSort( results );
  19062. }
  19063. }
  19064. // Override manipulation of globals by nested matchers
  19065. if ( outermost ) {
  19066. dirruns = dirrunsUnique;
  19067. outermostContext = contextBackup;
  19068. }
  19069. return unmatched;
  19070. };
  19071. return bySet ?
  19072. markFunction( superMatcher ) :
  19073. superMatcher;
  19074. }
  19075. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  19076. var i,
  19077. setMatchers = [],
  19078. elementMatchers = [],
  19079. cached = compilerCache[ selector + " " ];
  19080. if ( !cached ) {
  19081. // Generate a function of recursive functions that can be used to check each element
  19082. if ( !match ) {
  19083. match = tokenize( selector );
  19084. }
  19085. i = match.length;
  19086. while ( i-- ) {
  19087. cached = matcherFromTokens( match[i] );
  19088. if ( cached[ expando ] ) {
  19089. setMatchers.push( cached );
  19090. } else {
  19091. elementMatchers.push( cached );
  19092. }
  19093. }
  19094. // Cache the compiled function
  19095. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  19096. // Save selector and tokenization
  19097. cached.selector = selector;
  19098. }
  19099. return cached;
  19100. };
  19101. /**
  19102. * A low-level selection function that works with Sizzle's compiled
  19103. * selector functions
  19104. * @param {String|Function} selector A selector or a pre-compiled
  19105. * selector function built with Sizzle.compile
  19106. * @param {Element} context
  19107. * @param {Array} [results]
  19108. * @param {Array} [seed] A set of elements to match against
  19109. */
  19110. select = Sizzle.select = function( selector, context, results, seed ) {
  19111. var i, tokens, token, type, find,
  19112. compiled = typeof selector === "function" && selector,
  19113. match = !seed && tokenize( (selector = compiled.selector || selector) );
  19114. results = results || [];
  19115. // Try to minimize operations if there is only one selector in the list and no seed
  19116. // (the latter of which guarantees us context)
  19117. if ( match.length === 1 ) {
  19118. // Reduce context if the leading compound selector is an ID
  19119. tokens = match[0] = match[0].slice( 0 );
  19120. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  19121. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  19122. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  19123. if ( !context ) {
  19124. return results;
  19125. // Precompiled matchers will still verify ancestry, so step up a level
  19126. } else if ( compiled ) {
  19127. context = context.parentNode;
  19128. }
  19129. selector = selector.slice( tokens.shift().value.length );
  19130. }
  19131. // Fetch a seed set for right-to-left matching
  19132. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  19133. while ( i-- ) {
  19134. token = tokens[i];
  19135. // Abort if we hit a combinator
  19136. if ( Expr.relative[ (type = token.type) ] ) {
  19137. break;
  19138. }
  19139. if ( (find = Expr.find[ type ]) ) {
  19140. // Search, expanding context for leading sibling combinators
  19141. if ( (seed = find(
  19142. token.matches[0].replace( runescape, funescape ),
  19143. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  19144. )) ) {
  19145. // If seed is empty or no tokens remain, we can return early
  19146. tokens.splice( i, 1 );
  19147. selector = seed.length && toSelector( tokens );
  19148. if ( !selector ) {
  19149. push.apply( results, seed );
  19150. return results;
  19151. }
  19152. break;
  19153. }
  19154. }
  19155. }
  19156. }
  19157. // Compile and execute a filtering function if one is not provided
  19158. // Provide `match` to avoid retokenization if we modified the selector above
  19159. ( compiled || compile( selector, match ) )(
  19160. seed,
  19161. context,
  19162. !documentIsHTML,
  19163. results,
  19164. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  19165. );
  19166. return results;
  19167. };
  19168. // One-time assignments
  19169. // Sort stability
  19170. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  19171. // Support: Chrome 14-35+
  19172. // Always assume duplicates if they aren't passed to the comparison function
  19173. support.detectDuplicates = !!hasDuplicate;
  19174. // Initialize against the default document
  19175. setDocument();
  19176. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  19177. // Detached nodes confoundingly follow *each other*
  19178. support.sortDetached = assert(function( el ) {
  19179. // Should return 1, but returns 4 (following)
  19180. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  19181. });
  19182. // Support: IE<8
  19183. // Prevent attribute/property "interpolation"
  19184. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  19185. if ( !assert(function( el ) {
  19186. el.innerHTML = "<a href='#'></a>";
  19187. return el.firstChild.getAttribute("href") === "#" ;
  19188. }) ) {
  19189. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  19190. if ( !isXML ) {
  19191. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  19192. }
  19193. });
  19194. }
  19195. // Support: IE<9
  19196. // Use defaultValue in place of getAttribute("value")
  19197. if ( !support.attributes || !assert(function( el ) {
  19198. el.innerHTML = "<input/>";
  19199. el.firstChild.setAttribute( "value", "" );
  19200. return el.firstChild.getAttribute( "value" ) === "";
  19201. }) ) {
  19202. addHandle( "value", function( elem, name, isXML ) {
  19203. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  19204. return elem.defaultValue;
  19205. }
  19206. });
  19207. }
  19208. // Support: IE<9
  19209. // Use getAttributeNode to fetch booleans when getAttribute lies
  19210. if ( !assert(function( el ) {
  19211. return el.getAttribute("disabled") == null;
  19212. }) ) {
  19213. addHandle( booleans, function( elem, name, isXML ) {
  19214. var val;
  19215. if ( !isXML ) {
  19216. return elem[ name ] === true ? name.toLowerCase() :
  19217. (val = elem.getAttributeNode( name )) && val.specified ?
  19218. val.value :
  19219. null;
  19220. }
  19221. });
  19222. }
  19223. return Sizzle;
  19224. })( window );
  19225. jQuery.find = Sizzle;
  19226. jQuery.expr = Sizzle.selectors;
  19227. // Deprecated
  19228. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  19229. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  19230. jQuery.text = Sizzle.getText;
  19231. jQuery.isXMLDoc = Sizzle.isXML;
  19232. jQuery.contains = Sizzle.contains;
  19233. jQuery.escapeSelector = Sizzle.escape;
  19234. var dir = function( elem, dir, until ) {
  19235. var matched = [],
  19236. truncate = until !== undefined;
  19237. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  19238. if ( elem.nodeType === 1 ) {
  19239. if ( truncate && jQuery( elem ).is( until ) ) {
  19240. break;
  19241. }
  19242. matched.push( elem );
  19243. }
  19244. }
  19245. return matched;
  19246. };
  19247. var siblings = function( n, elem ) {
  19248. var matched = [];
  19249. for ( ; n; n = n.nextSibling ) {
  19250. if ( n.nodeType === 1 && n !== elem ) {
  19251. matched.push( n );
  19252. }
  19253. }
  19254. return matched;
  19255. };
  19256. var rneedsContext = jQuery.expr.match.needsContext;
  19257. function nodeName( elem, name ) {
  19258. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  19259. };
  19260. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  19261. var risSimple = /^.[^:#\[\.,]*$/;
  19262. // Implement the identical functionality for filter and not
  19263. function winnow( elements, qualifier, not ) {
  19264. if ( jQuery.isFunction( qualifier ) ) {
  19265. return jQuery.grep( elements, function( elem, i ) {
  19266. return !!qualifier.call( elem, i, elem ) !== not;
  19267. } );
  19268. }
  19269. // Single element
  19270. if ( qualifier.nodeType ) {
  19271. return jQuery.grep( elements, function( elem ) {
  19272. return ( elem === qualifier ) !== not;
  19273. } );
  19274. }
  19275. // Arraylike of elements (jQuery, arguments, Array)
  19276. if ( typeof qualifier !== "string" ) {
  19277. return jQuery.grep( elements, function( elem ) {
  19278. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  19279. } );
  19280. }
  19281. // Simple selector that can be filtered directly, removing non-Elements
  19282. if ( risSimple.test( qualifier ) ) {
  19283. return jQuery.filter( qualifier, elements, not );
  19284. }
  19285. // Complex selector, compare the two sets, removing non-Elements
  19286. qualifier = jQuery.filter( qualifier, elements );
  19287. return jQuery.grep( elements, function( elem ) {
  19288. return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
  19289. } );
  19290. }
  19291. jQuery.filter = function( expr, elems, not ) {
  19292. var elem = elems[ 0 ];
  19293. if ( not ) {
  19294. expr = ":not(" + expr + ")";
  19295. }
  19296. if ( elems.length === 1 && elem.nodeType === 1 ) {
  19297. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  19298. }
  19299. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  19300. return elem.nodeType === 1;
  19301. } ) );
  19302. };
  19303. jQuery.fn.extend( {
  19304. find: function( selector ) {
  19305. var i, ret,
  19306. len = this.length,
  19307. self = this;
  19308. if ( typeof selector !== "string" ) {
  19309. return this.pushStack( jQuery( selector ).filter( function() {
  19310. for ( i = 0; i < len; i++ ) {
  19311. if ( jQuery.contains( self[ i ], this ) ) {
  19312. return true;
  19313. }
  19314. }
  19315. } ) );
  19316. }
  19317. ret = this.pushStack( [] );
  19318. for ( i = 0; i < len; i++ ) {
  19319. jQuery.find( selector, self[ i ], ret );
  19320. }
  19321. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  19322. },
  19323. filter: function( selector ) {
  19324. return this.pushStack( winnow( this, selector || [], false ) );
  19325. },
  19326. not: function( selector ) {
  19327. return this.pushStack( winnow( this, selector || [], true ) );
  19328. },
  19329. is: function( selector ) {
  19330. return !!winnow(
  19331. this,
  19332. // If this is a positional/relative selector, check membership in the returned set
  19333. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  19334. typeof selector === "string" && rneedsContext.test( selector ) ?
  19335. jQuery( selector ) :
  19336. selector || [],
  19337. false
  19338. ).length;
  19339. }
  19340. } );
  19341. // Initialize a jQuery object
  19342. // A central reference to the root jQuery(document)
  19343. var rootjQuery,
  19344. // A simple way to check for HTML strings
  19345. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  19346. // Strict HTML recognition (#11290: must start with <)
  19347. // Shortcut simple #id case for speed
  19348. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  19349. init = jQuery.fn.init = function( selector, context, root ) {
  19350. var match, elem;
  19351. // HANDLE: $(""), $(null), $(undefined), $(false)
  19352. if ( !selector ) {
  19353. return this;
  19354. }
  19355. // Method init() accepts an alternate rootjQuery
  19356. // so migrate can support jQuery.sub (gh-2101)
  19357. root = root || rootjQuery;
  19358. // Handle HTML strings
  19359. if ( typeof selector === "string" ) {
  19360. if ( selector[ 0 ] === "<" &&
  19361. selector[ selector.length - 1 ] === ">" &&
  19362. selector.length >= 3 ) {
  19363. // Assume that strings that start and end with <> are HTML and skip the regex check
  19364. match = [ null, selector, null ];
  19365. } else {
  19366. match = rquickExpr.exec( selector );
  19367. }
  19368. // Match html or make sure no context is specified for #id
  19369. if ( match && ( match[ 1 ] || !context ) ) {
  19370. // HANDLE: $(html) -> $(array)
  19371. if ( match[ 1 ] ) {
  19372. context = context instanceof jQuery ? context[ 0 ] : context;
  19373. // Option to run scripts is true for back-compat
  19374. // Intentionally let the error be thrown if parseHTML is not present
  19375. jQuery.merge( this, jQuery.parseHTML(
  19376. match[ 1 ],
  19377. context && context.nodeType ? context.ownerDocument || context : document,
  19378. true
  19379. ) );
  19380. // HANDLE: $(html, props)
  19381. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  19382. for ( match in context ) {
  19383. // Properties of context are called as methods if possible
  19384. if ( jQuery.isFunction( this[ match ] ) ) {
  19385. this[ match ]( context[ match ] );
  19386. // ...and otherwise set as attributes
  19387. } else {
  19388. this.attr( match, context[ match ] );
  19389. }
  19390. }
  19391. }
  19392. return this;
  19393. // HANDLE: $(#id)
  19394. } else {
  19395. elem = document.getElementById( match[ 2 ] );
  19396. if ( elem ) {
  19397. // Inject the element directly into the jQuery object
  19398. this[ 0 ] = elem;
  19399. this.length = 1;
  19400. }
  19401. return this;
  19402. }
  19403. // HANDLE: $(expr, $(...))
  19404. } else if ( !context || context.jquery ) {
  19405. return ( context || root ).find( selector );
  19406. // HANDLE: $(expr, context)
  19407. // (which is just equivalent to: $(context).find(expr)
  19408. } else {
  19409. return this.constructor( context ).find( selector );
  19410. }
  19411. // HANDLE: $(DOMElement)
  19412. } else if ( selector.nodeType ) {
  19413. this[ 0 ] = selector;
  19414. this.length = 1;
  19415. return this;
  19416. // HANDLE: $(function)
  19417. // Shortcut for document ready
  19418. } else if ( jQuery.isFunction( selector ) ) {
  19419. return root.ready !== undefined ?
  19420. root.ready( selector ) :
  19421. // Execute immediately if ready is not present
  19422. selector( jQuery );
  19423. }
  19424. return jQuery.makeArray( selector, this );
  19425. };
  19426. // Give the init function the jQuery prototype for later instantiation
  19427. init.prototype = jQuery.fn;
  19428. // Initialize central reference
  19429. rootjQuery = jQuery( document );
  19430. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  19431. // Methods guaranteed to produce a unique set when starting from a unique set
  19432. guaranteedUnique = {
  19433. children: true,
  19434. contents: true,
  19435. next: true,
  19436. prev: true
  19437. };
  19438. jQuery.fn.extend( {
  19439. has: function( target ) {
  19440. var targets = jQuery( target, this ),
  19441. l = targets.length;
  19442. return this.filter( function() {
  19443. var i = 0;
  19444. for ( ; i < l; i++ ) {
  19445. if ( jQuery.contains( this, targets[ i ] ) ) {
  19446. return true;
  19447. }
  19448. }
  19449. } );
  19450. },
  19451. closest: function( selectors, context ) {
  19452. var cur,
  19453. i = 0,
  19454. l = this.length,
  19455. matched = [],
  19456. targets = typeof selectors !== "string" && jQuery( selectors );
  19457. // Positional selectors never match, since there's no _selection_ context
  19458. if ( !rneedsContext.test( selectors ) ) {
  19459. for ( ; i < l; i++ ) {
  19460. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  19461. // Always skip document fragments
  19462. if ( cur.nodeType < 11 && ( targets ?
  19463. targets.index( cur ) > -1 :
  19464. // Don't pass non-elements to Sizzle
  19465. cur.nodeType === 1 &&
  19466. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  19467. matched.push( cur );
  19468. break;
  19469. }
  19470. }
  19471. }
  19472. }
  19473. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  19474. },
  19475. // Determine the position of an element within the set
  19476. index: function( elem ) {
  19477. // No argument, return index in parent
  19478. if ( !elem ) {
  19479. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  19480. }
  19481. // Index in selector
  19482. if ( typeof elem === "string" ) {
  19483. return indexOf.call( jQuery( elem ), this[ 0 ] );
  19484. }
  19485. // Locate the position of the desired element
  19486. return indexOf.call( this,
  19487. // If it receives a jQuery object, the first element is used
  19488. elem.jquery ? elem[ 0 ] : elem
  19489. );
  19490. },
  19491. add: function( selector, context ) {
  19492. return this.pushStack(
  19493. jQuery.uniqueSort(
  19494. jQuery.merge( this.get(), jQuery( selector, context ) )
  19495. )
  19496. );
  19497. },
  19498. addBack: function( selector ) {
  19499. return this.add( selector == null ?
  19500. this.prevObject : this.prevObject.filter( selector )
  19501. );
  19502. }
  19503. } );
  19504. function sibling( cur, dir ) {
  19505. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  19506. return cur;
  19507. }
  19508. jQuery.each( {
  19509. parent: function( elem ) {
  19510. var parent = elem.parentNode;
  19511. return parent && parent.nodeType !== 11 ? parent : null;
  19512. },
  19513. parents: function( elem ) {
  19514. return dir( elem, "parentNode" );
  19515. },
  19516. parentsUntil: function( elem, i, until ) {
  19517. return dir( elem, "parentNode", until );
  19518. },
  19519. next: function( elem ) {
  19520. return sibling( elem, "nextSibling" );
  19521. },
  19522. prev: function( elem ) {
  19523. return sibling( elem, "previousSibling" );
  19524. },
  19525. nextAll: function( elem ) {
  19526. return dir( elem, "nextSibling" );
  19527. },
  19528. prevAll: function( elem ) {
  19529. return dir( elem, "previousSibling" );
  19530. },
  19531. nextUntil: function( elem, i, until ) {
  19532. return dir( elem, "nextSibling", until );
  19533. },
  19534. prevUntil: function( elem, i, until ) {
  19535. return dir( elem, "previousSibling", until );
  19536. },
  19537. siblings: function( elem ) {
  19538. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  19539. },
  19540. children: function( elem ) {
  19541. return siblings( elem.firstChild );
  19542. },
  19543. contents: function( elem ) {
  19544. if ( nodeName( elem, "iframe" ) ) {
  19545. return elem.contentDocument;
  19546. }
  19547. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  19548. // Treat the template element as a regular one in browsers that
  19549. // don't support it.
  19550. if ( nodeName( elem, "template" ) ) {
  19551. elem = elem.content || elem;
  19552. }
  19553. return jQuery.merge( [], elem.childNodes );
  19554. }
  19555. }, function( name, fn ) {
  19556. jQuery.fn[ name ] = function( until, selector ) {
  19557. var matched = jQuery.map( this, fn, until );
  19558. if ( name.slice( -5 ) !== "Until" ) {
  19559. selector = until;
  19560. }
  19561. if ( selector && typeof selector === "string" ) {
  19562. matched = jQuery.filter( selector, matched );
  19563. }
  19564. if ( this.length > 1 ) {
  19565. // Remove duplicates
  19566. if ( !guaranteedUnique[ name ] ) {
  19567. jQuery.uniqueSort( matched );
  19568. }
  19569. // Reverse order for parents* and prev-derivatives
  19570. if ( rparentsprev.test( name ) ) {
  19571. matched.reverse();
  19572. }
  19573. }
  19574. return this.pushStack( matched );
  19575. };
  19576. } );
  19577. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  19578. // Convert String-formatted options into Object-formatted ones
  19579. function createOptions( options ) {
  19580. var object = {};
  19581. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  19582. object[ flag ] = true;
  19583. } );
  19584. return object;
  19585. }
  19586. /*
  19587. * Create a callback list using the following parameters:
  19588. *
  19589. * options: an optional list of space-separated options that will change how
  19590. * the callback list behaves or a more traditional option object
  19591. *
  19592. * By default a callback list will act like an event callback list and can be
  19593. * "fired" multiple times.
  19594. *
  19595. * Possible options:
  19596. *
  19597. * once: will ensure the callback list can only be fired once (like a Deferred)
  19598. *
  19599. * memory: will keep track of previous values and will call any callback added
  19600. * after the list has been fired right away with the latest "memorized"
  19601. * values (like a Deferred)
  19602. *
  19603. * unique: will ensure a callback can only be added once (no duplicate in the list)
  19604. *
  19605. * stopOnFalse: interrupt callings when a callback returns false
  19606. *
  19607. */
  19608. jQuery.Callbacks = function( options ) {
  19609. // Convert options from String-formatted to Object-formatted if needed
  19610. // (we check in cache first)
  19611. options = typeof options === "string" ?
  19612. createOptions( options ) :
  19613. jQuery.extend( {}, options );
  19614. var // Flag to know if list is currently firing
  19615. firing,
  19616. // Last fire value for non-forgettable lists
  19617. memory,
  19618. // Flag to know if list was already fired
  19619. fired,
  19620. // Flag to prevent firing
  19621. locked,
  19622. // Actual callback list
  19623. list = [],
  19624. // Queue of execution data for repeatable lists
  19625. queue = [],
  19626. // Index of currently firing callback (modified by add/remove as needed)
  19627. firingIndex = -1,
  19628. // Fire callbacks
  19629. fire = function() {
  19630. // Enforce single-firing
  19631. locked = locked || options.once;
  19632. // Execute callbacks for all pending executions,
  19633. // respecting firingIndex overrides and runtime changes
  19634. fired = firing = true;
  19635. for ( ; queue.length; firingIndex = -1 ) {
  19636. memory = queue.shift();
  19637. while ( ++firingIndex < list.length ) {
  19638. // Run callback and check for early termination
  19639. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  19640. options.stopOnFalse ) {
  19641. // Jump to end and forget the data so .add doesn't re-fire
  19642. firingIndex = list.length;
  19643. memory = false;
  19644. }
  19645. }
  19646. }
  19647. // Forget the data if we're done with it
  19648. if ( !options.memory ) {
  19649. memory = false;
  19650. }
  19651. firing = false;
  19652. // Clean up if we're done firing for good
  19653. if ( locked ) {
  19654. // Keep an empty list if we have data for future add calls
  19655. if ( memory ) {
  19656. list = [];
  19657. // Otherwise, this object is spent
  19658. } else {
  19659. list = "";
  19660. }
  19661. }
  19662. },
  19663. // Actual Callbacks object
  19664. self = {
  19665. // Add a callback or a collection of callbacks to the list
  19666. add: function() {
  19667. if ( list ) {
  19668. // If we have memory from a past run, we should fire after adding
  19669. if ( memory && !firing ) {
  19670. firingIndex = list.length - 1;
  19671. queue.push( memory );
  19672. }
  19673. ( function add( args ) {
  19674. jQuery.each( args, function( _, arg ) {
  19675. if ( jQuery.isFunction( arg ) ) {
  19676. if ( !options.unique || !self.has( arg ) ) {
  19677. list.push( arg );
  19678. }
  19679. } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
  19680. // Inspect recursively
  19681. add( arg );
  19682. }
  19683. } );
  19684. } )( arguments );
  19685. if ( memory && !firing ) {
  19686. fire();
  19687. }
  19688. }
  19689. return this;
  19690. },
  19691. // Remove a callback from the list
  19692. remove: function() {
  19693. jQuery.each( arguments, function( _, arg ) {
  19694. var index;
  19695. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  19696. list.splice( index, 1 );
  19697. // Handle firing indexes
  19698. if ( index <= firingIndex ) {
  19699. firingIndex--;
  19700. }
  19701. }
  19702. } );
  19703. return this;
  19704. },
  19705. // Check if a given callback is in the list.
  19706. // If no argument is given, return whether or not list has callbacks attached.
  19707. has: function( fn ) {
  19708. return fn ?
  19709. jQuery.inArray( fn, list ) > -1 :
  19710. list.length > 0;
  19711. },
  19712. // Remove all callbacks from the list
  19713. empty: function() {
  19714. if ( list ) {
  19715. list = [];
  19716. }
  19717. return this;
  19718. },
  19719. // Disable .fire and .add
  19720. // Abort any current/pending executions
  19721. // Clear all callbacks and values
  19722. disable: function() {
  19723. locked = queue = [];
  19724. list = memory = "";
  19725. return this;
  19726. },
  19727. disabled: function() {
  19728. return !list;
  19729. },
  19730. // Disable .fire
  19731. // Also disable .add unless we have memory (since it would have no effect)
  19732. // Abort any pending executions
  19733. lock: function() {
  19734. locked = queue = [];
  19735. if ( !memory && !firing ) {
  19736. list = memory = "";
  19737. }
  19738. return this;
  19739. },
  19740. locked: function() {
  19741. return !!locked;
  19742. },
  19743. // Call all callbacks with the given context and arguments
  19744. fireWith: function( context, args ) {
  19745. if ( !locked ) {
  19746. args = args || [];
  19747. args = [ context, args.slice ? args.slice() : args ];
  19748. queue.push( args );
  19749. if ( !firing ) {
  19750. fire();
  19751. }
  19752. }
  19753. return this;
  19754. },
  19755. // Call all the callbacks with the given arguments
  19756. fire: function() {
  19757. self.fireWith( this, arguments );
  19758. return this;
  19759. },
  19760. // To know if the callbacks have already been called at least once
  19761. fired: function() {
  19762. return !!fired;
  19763. }
  19764. };
  19765. return self;
  19766. };
  19767. function Identity( v ) {
  19768. return v;
  19769. }
  19770. function Thrower( ex ) {
  19771. throw ex;
  19772. }
  19773. function adoptValue( value, resolve, reject, noValue ) {
  19774. var method;
  19775. try {
  19776. // Check for promise aspect first to privilege synchronous behavior
  19777. if ( value && jQuery.isFunction( ( method = value.promise ) ) ) {
  19778. method.call( value ).done( resolve ).fail( reject );
  19779. // Other thenables
  19780. } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) {
  19781. method.call( value, resolve, reject );
  19782. // Other non-thenables
  19783. } else {
  19784. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  19785. // * false: [ value ].slice( 0 ) => resolve( value )
  19786. // * true: [ value ].slice( 1 ) => resolve()
  19787. resolve.apply( undefined, [ value ].slice( noValue ) );
  19788. }
  19789. // For Promises/A+, convert exceptions into rejections
  19790. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  19791. // Deferred#then to conditionally suppress rejection.
  19792. } catch ( value ) {
  19793. // Support: Android 4.0 only
  19794. // Strict mode functions invoked without .call/.apply get global-object context
  19795. reject.apply( undefined, [ value ] );
  19796. }
  19797. }
  19798. jQuery.extend( {
  19799. Deferred: function( func ) {
  19800. var tuples = [
  19801. // action, add listener, callbacks,
  19802. // ... .then handlers, argument index, [final state]
  19803. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  19804. jQuery.Callbacks( "memory" ), 2 ],
  19805. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  19806. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  19807. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  19808. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  19809. ],
  19810. state = "pending",
  19811. promise = {
  19812. state: function() {
  19813. return state;
  19814. },
  19815. always: function() {
  19816. deferred.done( arguments ).fail( arguments );
  19817. return this;
  19818. },
  19819. "catch": function( fn ) {
  19820. return promise.then( null, fn );
  19821. },
  19822. // Keep pipe for back-compat
  19823. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  19824. var fns = arguments;
  19825. return jQuery.Deferred( function( newDefer ) {
  19826. jQuery.each( tuples, function( i, tuple ) {
  19827. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  19828. var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  19829. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  19830. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  19831. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  19832. deferred[ tuple[ 1 ] ]( function() {
  19833. var returned = fn && fn.apply( this, arguments );
  19834. if ( returned && jQuery.isFunction( returned.promise ) ) {
  19835. returned.promise()
  19836. .progress( newDefer.notify )
  19837. .done( newDefer.resolve )
  19838. .fail( newDefer.reject );
  19839. } else {
  19840. newDefer[ tuple[ 0 ] + "With" ](
  19841. this,
  19842. fn ? [ returned ] : arguments
  19843. );
  19844. }
  19845. } );
  19846. } );
  19847. fns = null;
  19848. } ).promise();
  19849. },
  19850. then: function( onFulfilled, onRejected, onProgress ) {
  19851. var maxDepth = 0;
  19852. function resolve( depth, deferred, handler, special ) {
  19853. return function() {
  19854. var that = this,
  19855. args = arguments,
  19856. mightThrow = function() {
  19857. var returned, then;
  19858. // Support: Promises/A+ section 2.3.3.3.3
  19859. // https://promisesaplus.com/#point-59
  19860. // Ignore double-resolution attempts
  19861. if ( depth < maxDepth ) {
  19862. return;
  19863. }
  19864. returned = handler.apply( that, args );
  19865. // Support: Promises/A+ section 2.3.1
  19866. // https://promisesaplus.com/#point-48
  19867. if ( returned === deferred.promise() ) {
  19868. throw new TypeError( "Thenable self-resolution" );
  19869. }
  19870. // Support: Promises/A+ sections 2.3.3.1, 3.5
  19871. // https://promisesaplus.com/#point-54
  19872. // https://promisesaplus.com/#point-75
  19873. // Retrieve `then` only once
  19874. then = returned &&
  19875. // Support: Promises/A+ section 2.3.4
  19876. // https://promisesaplus.com/#point-64
  19877. // Only check objects and functions for thenability
  19878. ( typeof returned === "object" ||
  19879. typeof returned === "function" ) &&
  19880. returned.then;
  19881. // Handle a returned thenable
  19882. if ( jQuery.isFunction( then ) ) {
  19883. // Special processors (notify) just wait for resolution
  19884. if ( special ) {
  19885. then.call(
  19886. returned,
  19887. resolve( maxDepth, deferred, Identity, special ),
  19888. resolve( maxDepth, deferred, Thrower, special )
  19889. );
  19890. // Normal processors (resolve) also hook into progress
  19891. } else {
  19892. // ...and disregard older resolution values
  19893. maxDepth++;
  19894. then.call(
  19895. returned,
  19896. resolve( maxDepth, deferred, Identity, special ),
  19897. resolve( maxDepth, deferred, Thrower, special ),
  19898. resolve( maxDepth, deferred, Identity,
  19899. deferred.notifyWith )
  19900. );
  19901. }
  19902. // Handle all other returned values
  19903. } else {
  19904. // Only substitute handlers pass on context
  19905. // and multiple values (non-spec behavior)
  19906. if ( handler !== Identity ) {
  19907. that = undefined;
  19908. args = [ returned ];
  19909. }
  19910. // Process the value(s)
  19911. // Default process is resolve
  19912. ( special || deferred.resolveWith )( that, args );
  19913. }
  19914. },
  19915. // Only normal processors (resolve) catch and reject exceptions
  19916. process = special ?
  19917. mightThrow :
  19918. function() {
  19919. try {
  19920. mightThrow();
  19921. } catch ( e ) {
  19922. if ( jQuery.Deferred.exceptionHook ) {
  19923. jQuery.Deferred.exceptionHook( e,
  19924. process.stackTrace );
  19925. }
  19926. // Support: Promises/A+ section 2.3.3.3.4.1
  19927. // https://promisesaplus.com/#point-61
  19928. // Ignore post-resolution exceptions
  19929. if ( depth + 1 >= maxDepth ) {
  19930. // Only substitute handlers pass on context
  19931. // and multiple values (non-spec behavior)
  19932. if ( handler !== Thrower ) {
  19933. that = undefined;
  19934. args = [ e ];
  19935. }
  19936. deferred.rejectWith( that, args );
  19937. }
  19938. }
  19939. };
  19940. // Support: Promises/A+ section 2.3.3.3.1
  19941. // https://promisesaplus.com/#point-57
  19942. // Re-resolve promises immediately to dodge false rejection from
  19943. // subsequent errors
  19944. if ( depth ) {
  19945. process();
  19946. } else {
  19947. // Call an optional hook to record the stack, in case of exception
  19948. // since it's otherwise lost when execution goes async
  19949. if ( jQuery.Deferred.getStackHook ) {
  19950. process.stackTrace = jQuery.Deferred.getStackHook();
  19951. }
  19952. window.setTimeout( process );
  19953. }
  19954. };
  19955. }
  19956. return jQuery.Deferred( function( newDefer ) {
  19957. // progress_handlers.add( ... )
  19958. tuples[ 0 ][ 3 ].add(
  19959. resolve(
  19960. 0,
  19961. newDefer,
  19962. jQuery.isFunction( onProgress ) ?
  19963. onProgress :
  19964. Identity,
  19965. newDefer.notifyWith
  19966. )
  19967. );
  19968. // fulfilled_handlers.add( ... )
  19969. tuples[ 1 ][ 3 ].add(
  19970. resolve(
  19971. 0,
  19972. newDefer,
  19973. jQuery.isFunction( onFulfilled ) ?
  19974. onFulfilled :
  19975. Identity
  19976. )
  19977. );
  19978. // rejected_handlers.add( ... )
  19979. tuples[ 2 ][ 3 ].add(
  19980. resolve(
  19981. 0,
  19982. newDefer,
  19983. jQuery.isFunction( onRejected ) ?
  19984. onRejected :
  19985. Thrower
  19986. )
  19987. );
  19988. } ).promise();
  19989. },
  19990. // Get a promise for this deferred
  19991. // If obj is provided, the promise aspect is added to the object
  19992. promise: function( obj ) {
  19993. return obj != null ? jQuery.extend( obj, promise ) : promise;
  19994. }
  19995. },
  19996. deferred = {};
  19997. // Add list-specific methods
  19998. jQuery.each( tuples, function( i, tuple ) {
  19999. var list = tuple[ 2 ],
  20000. stateString = tuple[ 5 ];
  20001. // promise.progress = list.add
  20002. // promise.done = list.add
  20003. // promise.fail = list.add
  20004. promise[ tuple[ 1 ] ] = list.add;
  20005. // Handle state
  20006. if ( stateString ) {
  20007. list.add(
  20008. function() {
  20009. // state = "resolved" (i.e., fulfilled)
  20010. // state = "rejected"
  20011. state = stateString;
  20012. },
  20013. // rejected_callbacks.disable
  20014. // fulfilled_callbacks.disable
  20015. tuples[ 3 - i ][ 2 ].disable,
  20016. // progress_callbacks.lock
  20017. tuples[ 0 ][ 2 ].lock
  20018. );
  20019. }
  20020. // progress_handlers.fire
  20021. // fulfilled_handlers.fire
  20022. // rejected_handlers.fire
  20023. list.add( tuple[ 3 ].fire );
  20024. // deferred.notify = function() { deferred.notifyWith(...) }
  20025. // deferred.resolve = function() { deferred.resolveWith(...) }
  20026. // deferred.reject = function() { deferred.rejectWith(...) }
  20027. deferred[ tuple[ 0 ] ] = function() {
  20028. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  20029. return this;
  20030. };
  20031. // deferred.notifyWith = list.fireWith
  20032. // deferred.resolveWith = list.fireWith
  20033. // deferred.rejectWith = list.fireWith
  20034. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  20035. } );
  20036. // Make the deferred a promise
  20037. promise.promise( deferred );
  20038. // Call given func if any
  20039. if ( func ) {
  20040. func.call( deferred, deferred );
  20041. }
  20042. // All done!
  20043. return deferred;
  20044. },
  20045. // Deferred helper
  20046. when: function( singleValue ) {
  20047. var
  20048. // count of uncompleted subordinates
  20049. remaining = arguments.length,
  20050. // count of unprocessed arguments
  20051. i = remaining,
  20052. // subordinate fulfillment data
  20053. resolveContexts = Array( i ),
  20054. resolveValues = slice.call( arguments ),
  20055. // the master Deferred
  20056. master = jQuery.Deferred(),
  20057. // subordinate callback factory
  20058. updateFunc = function( i ) {
  20059. return function( value ) {
  20060. resolveContexts[ i ] = this;
  20061. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  20062. if ( !( --remaining ) ) {
  20063. master.resolveWith( resolveContexts, resolveValues );
  20064. }
  20065. };
  20066. };
  20067. // Single- and empty arguments are adopted like Promise.resolve
  20068. if ( remaining <= 1 ) {
  20069. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  20070. !remaining );
  20071. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  20072. if ( master.state() === "pending" ||
  20073. jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  20074. return master.then();
  20075. }
  20076. }
  20077. // Multiple arguments are aggregated like Promise.all array elements
  20078. while ( i-- ) {
  20079. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  20080. }
  20081. return master.promise();
  20082. }
  20083. } );
  20084. // These usually indicate a programmer mistake during development,
  20085. // warn about them ASAP rather than swallowing them by default.
  20086. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  20087. jQuery.Deferred.exceptionHook = function( error, stack ) {
  20088. // Support: IE 8 - 9 only
  20089. // Console exists when dev tools are open, which can happen at any time
  20090. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  20091. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  20092. }
  20093. };
  20094. jQuery.readyException = function( error ) {
  20095. window.setTimeout( function() {
  20096. throw error;
  20097. } );
  20098. };
  20099. // The deferred used on DOM ready
  20100. var readyList = jQuery.Deferred();
  20101. jQuery.fn.ready = function( fn ) {
  20102. readyList
  20103. .then( fn )
  20104. // Wrap jQuery.readyException in a function so that the lookup
  20105. // happens at the time of error handling instead of callback
  20106. // registration.
  20107. .catch( function( error ) {
  20108. jQuery.readyException( error );
  20109. } );
  20110. return this;
  20111. };
  20112. jQuery.extend( {
  20113. // Is the DOM ready to be used? Set to true once it occurs.
  20114. isReady: false,
  20115. // A counter to track how many items to wait for before
  20116. // the ready event fires. See #6781
  20117. readyWait: 1,
  20118. // Handle when the DOM is ready
  20119. ready: function( wait ) {
  20120. // Abort if there are pending holds or we're already ready
  20121. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  20122. return;
  20123. }
  20124. // Remember that the DOM is ready
  20125. jQuery.isReady = true;
  20126. // If a normal DOM Ready event fired, decrement, and wait if need be
  20127. if ( wait !== true && --jQuery.readyWait > 0 ) {
  20128. return;
  20129. }
  20130. // If there are functions bound, to execute
  20131. readyList.resolveWith( document, [ jQuery ] );
  20132. }
  20133. } );
  20134. jQuery.ready.then = readyList.then;
  20135. // The ready event handler and self cleanup method
  20136. function completed() {
  20137. document.removeEventListener( "DOMContentLoaded", completed );
  20138. window.removeEventListener( "load", completed );
  20139. jQuery.ready();
  20140. }
  20141. // Catch cases where $(document).ready() is called
  20142. // after the browser event has already occurred.
  20143. // Support: IE <=9 - 10 only
  20144. // Older IE sometimes signals "interactive" too soon
  20145. if ( document.readyState === "complete" ||
  20146. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  20147. // Handle it asynchronously to allow scripts the opportunity to delay ready
  20148. window.setTimeout( jQuery.ready );
  20149. } else {
  20150. // Use the handy event callback
  20151. document.addEventListener( "DOMContentLoaded", completed );
  20152. // A fallback to window.onload, that will always work
  20153. window.addEventListener( "load", completed );
  20154. }
  20155. // Multifunctional method to get and set values of a collection
  20156. // The value/s can optionally be executed if it's a function
  20157. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  20158. var i = 0,
  20159. len = elems.length,
  20160. bulk = key == null;
  20161. // Sets many values
  20162. if ( jQuery.type( key ) === "object" ) {
  20163. chainable = true;
  20164. for ( i in key ) {
  20165. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  20166. }
  20167. // Sets one value
  20168. } else if ( value !== undefined ) {
  20169. chainable = true;
  20170. if ( !jQuery.isFunction( value ) ) {
  20171. raw = true;
  20172. }
  20173. if ( bulk ) {
  20174. // Bulk operations run against the entire set
  20175. if ( raw ) {
  20176. fn.call( elems, value );
  20177. fn = null;
  20178. // ...except when executing function values
  20179. } else {
  20180. bulk = fn;
  20181. fn = function( elem, key, value ) {
  20182. return bulk.call( jQuery( elem ), value );
  20183. };
  20184. }
  20185. }
  20186. if ( fn ) {
  20187. for ( ; i < len; i++ ) {
  20188. fn(
  20189. elems[ i ], key, raw ?
  20190. value :
  20191. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  20192. );
  20193. }
  20194. }
  20195. }
  20196. if ( chainable ) {
  20197. return elems;
  20198. }
  20199. // Gets
  20200. if ( bulk ) {
  20201. return fn.call( elems );
  20202. }
  20203. return len ? fn( elems[ 0 ], key ) : emptyGet;
  20204. };
  20205. var acceptData = function( owner ) {
  20206. // Accepts only:
  20207. // - Node
  20208. // - Node.ELEMENT_NODE
  20209. // - Node.DOCUMENT_NODE
  20210. // - Object
  20211. // - Any
  20212. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  20213. };
  20214. function Data() {
  20215. this.expando = jQuery.expando + Data.uid++;
  20216. }
  20217. Data.uid = 1;
  20218. Data.prototype = {
  20219. cache: function( owner ) {
  20220. // Check if the owner object already has a cache
  20221. var value = owner[ this.expando ];
  20222. // If not, create one
  20223. if ( !value ) {
  20224. value = {};
  20225. // We can accept data for non-element nodes in modern browsers,
  20226. // but we should not, see #8335.
  20227. // Always return an empty object.
  20228. if ( acceptData( owner ) ) {
  20229. // If it is a node unlikely to be stringify-ed or looped over
  20230. // use plain assignment
  20231. if ( owner.nodeType ) {
  20232. owner[ this.expando ] = value;
  20233. // Otherwise secure it in a non-enumerable property
  20234. // configurable must be true to allow the property to be
  20235. // deleted when data is removed
  20236. } else {
  20237. Object.defineProperty( owner, this.expando, {
  20238. value: value,
  20239. configurable: true
  20240. } );
  20241. }
  20242. }
  20243. }
  20244. return value;
  20245. },
  20246. set: function( owner, data, value ) {
  20247. var prop,
  20248. cache = this.cache( owner );
  20249. // Handle: [ owner, key, value ] args
  20250. // Always use camelCase key (gh-2257)
  20251. if ( typeof data === "string" ) {
  20252. cache[ jQuery.camelCase( data ) ] = value;
  20253. // Handle: [ owner, { properties } ] args
  20254. } else {
  20255. // Copy the properties one-by-one to the cache object
  20256. for ( prop in data ) {
  20257. cache[ jQuery.camelCase( prop ) ] = data[ prop ];
  20258. }
  20259. }
  20260. return cache;
  20261. },
  20262. get: function( owner, key ) {
  20263. return key === undefined ?
  20264. this.cache( owner ) :
  20265. // Always use camelCase key (gh-2257)
  20266. owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
  20267. },
  20268. access: function( owner, key, value ) {
  20269. // In cases where either:
  20270. //
  20271. // 1. No key was specified
  20272. // 2. A string key was specified, but no value provided
  20273. //
  20274. // Take the "read" path and allow the get method to determine
  20275. // which value to return, respectively either:
  20276. //
  20277. // 1. The entire cache object
  20278. // 2. The data stored at the key
  20279. //
  20280. if ( key === undefined ||
  20281. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  20282. return this.get( owner, key );
  20283. }
  20284. // When the key is not a string, or both a key and value
  20285. // are specified, set or extend (existing objects) with either:
  20286. //
  20287. // 1. An object of properties
  20288. // 2. A key and value
  20289. //
  20290. this.set( owner, key, value );
  20291. // Since the "set" path can have two possible entry points
  20292. // return the expected data based on which path was taken[*]
  20293. return value !== undefined ? value : key;
  20294. },
  20295. remove: function( owner, key ) {
  20296. var i,
  20297. cache = owner[ this.expando ];
  20298. if ( cache === undefined ) {
  20299. return;
  20300. }
  20301. if ( key !== undefined ) {
  20302. // Support array or space separated string of keys
  20303. if ( Array.isArray( key ) ) {
  20304. // If key is an array of keys...
  20305. // We always set camelCase keys, so remove that.
  20306. key = key.map( jQuery.camelCase );
  20307. } else {
  20308. key = jQuery.camelCase( key );
  20309. // If a key with the spaces exists, use it.
  20310. // Otherwise, create an array by matching non-whitespace
  20311. key = key in cache ?
  20312. [ key ] :
  20313. ( key.match( rnothtmlwhite ) || [] );
  20314. }
  20315. i = key.length;
  20316. while ( i-- ) {
  20317. delete cache[ key[ i ] ];
  20318. }
  20319. }
  20320. // Remove the expando if there's no more data
  20321. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  20322. // Support: Chrome <=35 - 45
  20323. // Webkit & Blink performance suffers when deleting properties
  20324. // from DOM nodes, so set to undefined instead
  20325. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  20326. if ( owner.nodeType ) {
  20327. owner[ this.expando ] = undefined;
  20328. } else {
  20329. delete owner[ this.expando ];
  20330. }
  20331. }
  20332. },
  20333. hasData: function( owner ) {
  20334. var cache = owner[ this.expando ];
  20335. return cache !== undefined && !jQuery.isEmptyObject( cache );
  20336. }
  20337. };
  20338. var dataPriv = new Data();
  20339. var dataUser = new Data();
  20340. // Implementation Summary
  20341. //
  20342. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  20343. // 2. Improve the module's maintainability by reducing the storage
  20344. // paths to a single mechanism.
  20345. // 3. Use the same single mechanism to support "private" and "user" data.
  20346. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  20347. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  20348. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  20349. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  20350. rmultiDash = /[A-Z]/g;
  20351. function getData( data ) {
  20352. if ( data === "true" ) {
  20353. return true;
  20354. }
  20355. if ( data === "false" ) {
  20356. return false;
  20357. }
  20358. if ( data === "null" ) {
  20359. return null;
  20360. }
  20361. // Only convert to a number if it doesn't change the string
  20362. if ( data === +data + "" ) {
  20363. return +data;
  20364. }
  20365. if ( rbrace.test( data ) ) {
  20366. return JSON.parse( data );
  20367. }
  20368. return data;
  20369. }
  20370. function dataAttr( elem, key, data ) {
  20371. var name;
  20372. // If nothing was found internally, try to fetch any
  20373. // data from the HTML5 data-* attribute
  20374. if ( data === undefined && elem.nodeType === 1 ) {
  20375. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  20376. data = elem.getAttribute( name );
  20377. if ( typeof data === "string" ) {
  20378. try {
  20379. data = getData( data );
  20380. } catch ( e ) {}
  20381. // Make sure we set the data so it isn't changed later
  20382. dataUser.set( elem, key, data );
  20383. } else {
  20384. data = undefined;
  20385. }
  20386. }
  20387. return data;
  20388. }
  20389. jQuery.extend( {
  20390. hasData: function( elem ) {
  20391. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  20392. },
  20393. data: function( elem, name, data ) {
  20394. return dataUser.access( elem, name, data );
  20395. },
  20396. removeData: function( elem, name ) {
  20397. dataUser.remove( elem, name );
  20398. },
  20399. // TODO: Now that all calls to _data and _removeData have been replaced
  20400. // with direct calls to dataPriv methods, these can be deprecated.
  20401. _data: function( elem, name, data ) {
  20402. return dataPriv.access( elem, name, data );
  20403. },
  20404. _removeData: function( elem, name ) {
  20405. dataPriv.remove( elem, name );
  20406. }
  20407. } );
  20408. jQuery.fn.extend( {
  20409. data: function( key, value ) {
  20410. var i, name, data,
  20411. elem = this[ 0 ],
  20412. attrs = elem && elem.attributes;
  20413. // Gets all values
  20414. if ( key === undefined ) {
  20415. if ( this.length ) {
  20416. data = dataUser.get( elem );
  20417. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  20418. i = attrs.length;
  20419. while ( i-- ) {
  20420. // Support: IE 11 only
  20421. // The attrs elements can be null (#14894)
  20422. if ( attrs[ i ] ) {
  20423. name = attrs[ i ].name;
  20424. if ( name.indexOf( "data-" ) === 0 ) {
  20425. name = jQuery.camelCase( name.slice( 5 ) );
  20426. dataAttr( elem, name, data[ name ] );
  20427. }
  20428. }
  20429. }
  20430. dataPriv.set( elem, "hasDataAttrs", true );
  20431. }
  20432. }
  20433. return data;
  20434. }
  20435. // Sets multiple values
  20436. if ( typeof key === "object" ) {
  20437. return this.each( function() {
  20438. dataUser.set( this, key );
  20439. } );
  20440. }
  20441. return access( this, function( value ) {
  20442. var data;
  20443. // The calling jQuery object (element matches) is not empty
  20444. // (and therefore has an element appears at this[ 0 ]) and the
  20445. // `value` parameter was not undefined. An empty jQuery object
  20446. // will result in `undefined` for elem = this[ 0 ] which will
  20447. // throw an exception if an attempt to read a data cache is made.
  20448. if ( elem && value === undefined ) {
  20449. // Attempt to get data from the cache
  20450. // The key will always be camelCased in Data
  20451. data = dataUser.get( elem, key );
  20452. if ( data !== undefined ) {
  20453. return data;
  20454. }
  20455. // Attempt to "discover" the data in
  20456. // HTML5 custom data-* attrs
  20457. data = dataAttr( elem, key );
  20458. if ( data !== undefined ) {
  20459. return data;
  20460. }
  20461. // We tried really hard, but the data doesn't exist.
  20462. return;
  20463. }
  20464. // Set the data...
  20465. this.each( function() {
  20466. // We always store the camelCased key
  20467. dataUser.set( this, key, value );
  20468. } );
  20469. }, null, value, arguments.length > 1, null, true );
  20470. },
  20471. removeData: function( key ) {
  20472. return this.each( function() {
  20473. dataUser.remove( this, key );
  20474. } );
  20475. }
  20476. } );
  20477. jQuery.extend( {
  20478. queue: function( elem, type, data ) {
  20479. var queue;
  20480. if ( elem ) {
  20481. type = ( type || "fx" ) + "queue";
  20482. queue = dataPriv.get( elem, type );
  20483. // Speed up dequeue by getting out quickly if this is just a lookup
  20484. if ( data ) {
  20485. if ( !queue || Array.isArray( data ) ) {
  20486. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  20487. } else {
  20488. queue.push( data );
  20489. }
  20490. }
  20491. return queue || [];
  20492. }
  20493. },
  20494. dequeue: function( elem, type ) {
  20495. type = type || "fx";
  20496. var queue = jQuery.queue( elem, type ),
  20497. startLength = queue.length,
  20498. fn = queue.shift(),
  20499. hooks = jQuery._queueHooks( elem, type ),
  20500. next = function() {
  20501. jQuery.dequeue( elem, type );
  20502. };
  20503. // If the fx queue is dequeued, always remove the progress sentinel
  20504. if ( fn === "inprogress" ) {
  20505. fn = queue.shift();
  20506. startLength--;
  20507. }
  20508. if ( fn ) {
  20509. // Add a progress sentinel to prevent the fx queue from being
  20510. // automatically dequeued
  20511. if ( type === "fx" ) {
  20512. queue.unshift( "inprogress" );
  20513. }
  20514. // Clear up the last queue stop function
  20515. delete hooks.stop;
  20516. fn.call( elem, next, hooks );
  20517. }
  20518. if ( !startLength && hooks ) {
  20519. hooks.empty.fire();
  20520. }
  20521. },
  20522. // Not public - generate a queueHooks object, or return the current one
  20523. _queueHooks: function( elem, type ) {
  20524. var key = type + "queueHooks";
  20525. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  20526. empty: jQuery.Callbacks( "once memory" ).add( function() {
  20527. dataPriv.remove( elem, [ type + "queue", key ] );
  20528. } )
  20529. } );
  20530. }
  20531. } );
  20532. jQuery.fn.extend( {
  20533. queue: function( type, data ) {
  20534. var setter = 2;
  20535. if ( typeof type !== "string" ) {
  20536. data = type;
  20537. type = "fx";
  20538. setter--;
  20539. }
  20540. if ( arguments.length < setter ) {
  20541. return jQuery.queue( this[ 0 ], type );
  20542. }
  20543. return data === undefined ?
  20544. this :
  20545. this.each( function() {
  20546. var queue = jQuery.queue( this, type, data );
  20547. // Ensure a hooks for this queue
  20548. jQuery._queueHooks( this, type );
  20549. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  20550. jQuery.dequeue( this, type );
  20551. }
  20552. } );
  20553. },
  20554. dequeue: function( type ) {
  20555. return this.each( function() {
  20556. jQuery.dequeue( this, type );
  20557. } );
  20558. },
  20559. clearQueue: function( type ) {
  20560. return this.queue( type || "fx", [] );
  20561. },
  20562. // Get a promise resolved when queues of a certain type
  20563. // are emptied (fx is the type by default)
  20564. promise: function( type, obj ) {
  20565. var tmp,
  20566. count = 1,
  20567. defer = jQuery.Deferred(),
  20568. elements = this,
  20569. i = this.length,
  20570. resolve = function() {
  20571. if ( !( --count ) ) {
  20572. defer.resolveWith( elements, [ elements ] );
  20573. }
  20574. };
  20575. if ( typeof type !== "string" ) {
  20576. obj = type;
  20577. type = undefined;
  20578. }
  20579. type = type || "fx";
  20580. while ( i-- ) {
  20581. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  20582. if ( tmp && tmp.empty ) {
  20583. count++;
  20584. tmp.empty.add( resolve );
  20585. }
  20586. }
  20587. resolve();
  20588. return defer.promise( obj );
  20589. }
  20590. } );
  20591. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  20592. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  20593. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  20594. var isHiddenWithinTree = function( elem, el ) {
  20595. // isHiddenWithinTree might be called from jQuery#filter function;
  20596. // in that case, element will be second argument
  20597. elem = el || elem;
  20598. // Inline style trumps all
  20599. return elem.style.display === "none" ||
  20600. elem.style.display === "" &&
  20601. // Otherwise, check computed style
  20602. // Support: Firefox <=43 - 45
  20603. // Disconnected elements can have computed display: none, so first confirm that elem is
  20604. // in the document.
  20605. jQuery.contains( elem.ownerDocument, elem ) &&
  20606. jQuery.css( elem, "display" ) === "none";
  20607. };
  20608. var swap = function( elem, options, callback, args ) {
  20609. var ret, name,
  20610. old = {};
  20611. // Remember the old values, and insert the new ones
  20612. for ( name in options ) {
  20613. old[ name ] = elem.style[ name ];
  20614. elem.style[ name ] = options[ name ];
  20615. }
  20616. ret = callback.apply( elem, args || [] );
  20617. // Revert the old values
  20618. for ( name in options ) {
  20619. elem.style[ name ] = old[ name ];
  20620. }
  20621. return ret;
  20622. };
  20623. function adjustCSS( elem, prop, valueParts, tween ) {
  20624. var adjusted,
  20625. scale = 1,
  20626. maxIterations = 20,
  20627. currentValue = tween ?
  20628. function() {
  20629. return tween.cur();
  20630. } :
  20631. function() {
  20632. return jQuery.css( elem, prop, "" );
  20633. },
  20634. initial = currentValue(),
  20635. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  20636. // Starting value computation is required for potential unit mismatches
  20637. initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  20638. rcssNum.exec( jQuery.css( elem, prop ) );
  20639. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  20640. // Trust units reported by jQuery.css
  20641. unit = unit || initialInUnit[ 3 ];
  20642. // Make sure we update the tween properties later on
  20643. valueParts = valueParts || [];
  20644. // Iteratively approximate from a nonzero starting point
  20645. initialInUnit = +initial || 1;
  20646. do {
  20647. // If previous iteration zeroed out, double until we get *something*.
  20648. // Use string for doubling so we don't accidentally see scale as unchanged below
  20649. scale = scale || ".5";
  20650. // Adjust and apply
  20651. initialInUnit = initialInUnit / scale;
  20652. jQuery.style( elem, prop, initialInUnit + unit );
  20653. // Update scale, tolerating zero or NaN from tween.cur()
  20654. // Break the loop if scale is unchanged or perfect, or if we've just had enough.
  20655. } while (
  20656. scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
  20657. );
  20658. }
  20659. if ( valueParts ) {
  20660. initialInUnit = +initialInUnit || +initial || 0;
  20661. // Apply relative offset (+=/-=) if specified
  20662. adjusted = valueParts[ 1 ] ?
  20663. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  20664. +valueParts[ 2 ];
  20665. if ( tween ) {
  20666. tween.unit = unit;
  20667. tween.start = initialInUnit;
  20668. tween.end = adjusted;
  20669. }
  20670. }
  20671. return adjusted;
  20672. }
  20673. var defaultDisplayMap = {};
  20674. function getDefaultDisplay( elem ) {
  20675. var temp,
  20676. doc = elem.ownerDocument,
  20677. nodeName = elem.nodeName,
  20678. display = defaultDisplayMap[ nodeName ];
  20679. if ( display ) {
  20680. return display;
  20681. }
  20682. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  20683. display = jQuery.css( temp, "display" );
  20684. temp.parentNode.removeChild( temp );
  20685. if ( display === "none" ) {
  20686. display = "block";
  20687. }
  20688. defaultDisplayMap[ nodeName ] = display;
  20689. return display;
  20690. }
  20691. function showHide( elements, show ) {
  20692. var display, elem,
  20693. values = [],
  20694. index = 0,
  20695. length = elements.length;
  20696. // Determine new display value for elements that need to change
  20697. for ( ; index < length; index++ ) {
  20698. elem = elements[ index ];
  20699. if ( !elem.style ) {
  20700. continue;
  20701. }
  20702. display = elem.style.display;
  20703. if ( show ) {
  20704. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  20705. // check is required in this first loop unless we have a nonempty display value (either
  20706. // inline or about-to-be-restored)
  20707. if ( display === "none" ) {
  20708. values[ index ] = dataPriv.get( elem, "display" ) || null;
  20709. if ( !values[ index ] ) {
  20710. elem.style.display = "";
  20711. }
  20712. }
  20713. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  20714. values[ index ] = getDefaultDisplay( elem );
  20715. }
  20716. } else {
  20717. if ( display !== "none" ) {
  20718. values[ index ] = "none";
  20719. // Remember what we're overwriting
  20720. dataPriv.set( elem, "display", display );
  20721. }
  20722. }
  20723. }
  20724. // Set the display of the elements in a second loop to avoid constant reflow
  20725. for ( index = 0; index < length; index++ ) {
  20726. if ( values[ index ] != null ) {
  20727. elements[ index ].style.display = values[ index ];
  20728. }
  20729. }
  20730. return elements;
  20731. }
  20732. jQuery.fn.extend( {
  20733. show: function() {
  20734. return showHide( this, true );
  20735. },
  20736. hide: function() {
  20737. return showHide( this );
  20738. },
  20739. toggle: function( state ) {
  20740. if ( typeof state === "boolean" ) {
  20741. return state ? this.show() : this.hide();
  20742. }
  20743. return this.each( function() {
  20744. if ( isHiddenWithinTree( this ) ) {
  20745. jQuery( this ).show();
  20746. } else {
  20747. jQuery( this ).hide();
  20748. }
  20749. } );
  20750. }
  20751. } );
  20752. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  20753. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
  20754. var rscriptType = ( /^$|\/(?:java|ecma)script/i );
  20755. // We have to close these tags to support XHTML (#13200)
  20756. var wrapMap = {
  20757. // Support: IE <=9 only
  20758. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  20759. // XHTML parsers do not magically insert elements in the
  20760. // same way that tag soup parsers do. So we cannot shorten
  20761. // this by omitting <tbody> or other required elements.
  20762. thead: [ 1, "<table>", "</table>" ],
  20763. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  20764. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  20765. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  20766. _default: [ 0, "", "" ]
  20767. };
  20768. // Support: IE <=9 only
  20769. wrapMap.optgroup = wrapMap.option;
  20770. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  20771. wrapMap.th = wrapMap.td;
  20772. function getAll( context, tag ) {
  20773. // Support: IE <=9 - 11 only
  20774. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  20775. var ret;
  20776. if ( typeof context.getElementsByTagName !== "undefined" ) {
  20777. ret = context.getElementsByTagName( tag || "*" );
  20778. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  20779. ret = context.querySelectorAll( tag || "*" );
  20780. } else {
  20781. ret = [];
  20782. }
  20783. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  20784. return jQuery.merge( [ context ], ret );
  20785. }
  20786. return ret;
  20787. }
  20788. // Mark scripts as having already been evaluated
  20789. function setGlobalEval( elems, refElements ) {
  20790. var i = 0,
  20791. l = elems.length;
  20792. for ( ; i < l; i++ ) {
  20793. dataPriv.set(
  20794. elems[ i ],
  20795. "globalEval",
  20796. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  20797. );
  20798. }
  20799. }
  20800. var rhtml = /<|&#?\w+;/;
  20801. function buildFragment( elems, context, scripts, selection, ignored ) {
  20802. var elem, tmp, tag, wrap, contains, j,
  20803. fragment = context.createDocumentFragment(),
  20804. nodes = [],
  20805. i = 0,
  20806. l = elems.length;
  20807. for ( ; i < l; i++ ) {
  20808. elem = elems[ i ];
  20809. if ( elem || elem === 0 ) {
  20810. // Add nodes directly
  20811. if ( jQuery.type( elem ) === "object" ) {
  20812. // Support: Android <=4.0 only, PhantomJS 1 only
  20813. // push.apply(_, arraylike) throws on ancient WebKit
  20814. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  20815. // Convert non-html into a text node
  20816. } else if ( !rhtml.test( elem ) ) {
  20817. nodes.push( context.createTextNode( elem ) );
  20818. // Convert html into DOM nodes
  20819. } else {
  20820. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  20821. // Deserialize a standard representation
  20822. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  20823. wrap = wrapMap[ tag ] || wrapMap._default;
  20824. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  20825. // Descend through wrappers to the right content
  20826. j = wrap[ 0 ];
  20827. while ( j-- ) {
  20828. tmp = tmp.lastChild;
  20829. }
  20830. // Support: Android <=4.0 only, PhantomJS 1 only
  20831. // push.apply(_, arraylike) throws on ancient WebKit
  20832. jQuery.merge( nodes, tmp.childNodes );
  20833. // Remember the top-level container
  20834. tmp = fragment.firstChild;
  20835. // Ensure the created nodes are orphaned (#12392)
  20836. tmp.textContent = "";
  20837. }
  20838. }
  20839. }
  20840. // Remove wrapper from fragment
  20841. fragment.textContent = "";
  20842. i = 0;
  20843. while ( ( elem = nodes[ i++ ] ) ) {
  20844. // Skip elements already in the context collection (trac-4087)
  20845. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  20846. if ( ignored ) {
  20847. ignored.push( elem );
  20848. }
  20849. continue;
  20850. }
  20851. contains = jQuery.contains( elem.ownerDocument, elem );
  20852. // Append to fragment
  20853. tmp = getAll( fragment.appendChild( elem ), "script" );
  20854. // Preserve script evaluation history
  20855. if ( contains ) {
  20856. setGlobalEval( tmp );
  20857. }
  20858. // Capture executables
  20859. if ( scripts ) {
  20860. j = 0;
  20861. while ( ( elem = tmp[ j++ ] ) ) {
  20862. if ( rscriptType.test( elem.type || "" ) ) {
  20863. scripts.push( elem );
  20864. }
  20865. }
  20866. }
  20867. }
  20868. return fragment;
  20869. }
  20870. ( function() {
  20871. var fragment = document.createDocumentFragment(),
  20872. div = fragment.appendChild( document.createElement( "div" ) ),
  20873. input = document.createElement( "input" );
  20874. // Support: Android 4.0 - 4.3 only
  20875. // Check state lost if the name is set (#11217)
  20876. // Support: Windows Web Apps (WWA)
  20877. // `name` and `type` must use .setAttribute for WWA (#14901)
  20878. input.setAttribute( "type", "radio" );
  20879. input.setAttribute( "checked", "checked" );
  20880. input.setAttribute( "name", "t" );
  20881. div.appendChild( input );
  20882. // Support: Android <=4.1 only
  20883. // Older WebKit doesn't clone checked state correctly in fragments
  20884. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  20885. // Support: IE <=11 only
  20886. // Make sure textarea (and checkbox) defaultValue is properly cloned
  20887. div.innerHTML = "<textarea>x</textarea>";
  20888. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  20889. } )();
  20890. var documentElement = document.documentElement;
  20891. var
  20892. rkeyEvent = /^key/,
  20893. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  20894. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  20895. function returnTrue() {
  20896. return true;
  20897. }
  20898. function returnFalse() {
  20899. return false;
  20900. }
  20901. // Support: IE <=9 only
  20902. // See #13393 for more info
  20903. function safeActiveElement() {
  20904. try {
  20905. return document.activeElement;
  20906. } catch ( err ) { }
  20907. }
  20908. function on( elem, types, selector, data, fn, one ) {
  20909. var origFn, type;
  20910. // Types can be a map of types/handlers
  20911. if ( typeof types === "object" ) {
  20912. // ( types-Object, selector, data )
  20913. if ( typeof selector !== "string" ) {
  20914. // ( types-Object, data )
  20915. data = data || selector;
  20916. selector = undefined;
  20917. }
  20918. for ( type in types ) {
  20919. on( elem, type, selector, data, types[ type ], one );
  20920. }
  20921. return elem;
  20922. }
  20923. if ( data == null && fn == null ) {
  20924. // ( types, fn )
  20925. fn = selector;
  20926. data = selector = undefined;
  20927. } else if ( fn == null ) {
  20928. if ( typeof selector === "string" ) {
  20929. // ( types, selector, fn )
  20930. fn = data;
  20931. data = undefined;
  20932. } else {
  20933. // ( types, data, fn )
  20934. fn = data;
  20935. data = selector;
  20936. selector = undefined;
  20937. }
  20938. }
  20939. if ( fn === false ) {
  20940. fn = returnFalse;
  20941. } else if ( !fn ) {
  20942. return elem;
  20943. }
  20944. if ( one === 1 ) {
  20945. origFn = fn;
  20946. fn = function( event ) {
  20947. // Can use an empty set, since event contains the info
  20948. jQuery().off( event );
  20949. return origFn.apply( this, arguments );
  20950. };
  20951. // Use same guid so caller can remove using origFn
  20952. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  20953. }
  20954. return elem.each( function() {
  20955. jQuery.event.add( this, types, fn, data, selector );
  20956. } );
  20957. }
  20958. /*
  20959. * Helper functions for managing events -- not part of the public interface.
  20960. * Props to Dean Edwards' addEvent library for many of the ideas.
  20961. */
  20962. jQuery.event = {
  20963. global: {},
  20964. add: function( elem, types, handler, data, selector ) {
  20965. var handleObjIn, eventHandle, tmp,
  20966. events, t, handleObj,
  20967. special, handlers, type, namespaces, origType,
  20968. elemData = dataPriv.get( elem );
  20969. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  20970. if ( !elemData ) {
  20971. return;
  20972. }
  20973. // Caller can pass in an object of custom data in lieu of the handler
  20974. if ( handler.handler ) {
  20975. handleObjIn = handler;
  20976. handler = handleObjIn.handler;
  20977. selector = handleObjIn.selector;
  20978. }
  20979. // Ensure that invalid selectors throw exceptions at attach time
  20980. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  20981. if ( selector ) {
  20982. jQuery.find.matchesSelector( documentElement, selector );
  20983. }
  20984. // Make sure that the handler has a unique ID, used to find/remove it later
  20985. if ( !handler.guid ) {
  20986. handler.guid = jQuery.guid++;
  20987. }
  20988. // Init the element's event structure and main handler, if this is the first
  20989. if ( !( events = elemData.events ) ) {
  20990. events = elemData.events = {};
  20991. }
  20992. if ( !( eventHandle = elemData.handle ) ) {
  20993. eventHandle = elemData.handle = function( e ) {
  20994. // Discard the second event of a jQuery.event.trigger() and
  20995. // when an event is called after a page has unloaded
  20996. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  20997. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  20998. };
  20999. }
  21000. // Handle multiple events separated by a space
  21001. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  21002. t = types.length;
  21003. while ( t-- ) {
  21004. tmp = rtypenamespace.exec( types[ t ] ) || [];
  21005. type = origType = tmp[ 1 ];
  21006. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  21007. // There *must* be a type, no attaching namespace-only handlers
  21008. if ( !type ) {
  21009. continue;
  21010. }
  21011. // If event changes its type, use the special event handlers for the changed type
  21012. special = jQuery.event.special[ type ] || {};
  21013. // If selector defined, determine special event api type, otherwise given type
  21014. type = ( selector ? special.delegateType : special.bindType ) || type;
  21015. // Update special based on newly reset type
  21016. special = jQuery.event.special[ type ] || {};
  21017. // handleObj is passed to all event handlers
  21018. handleObj = jQuery.extend( {
  21019. type: type,
  21020. origType: origType,
  21021. data: data,
  21022. handler: handler,
  21023. guid: handler.guid,
  21024. selector: selector,
  21025. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  21026. namespace: namespaces.join( "." )
  21027. }, handleObjIn );
  21028. // Init the event handler queue if we're the first
  21029. if ( !( handlers = events[ type ] ) ) {
  21030. handlers = events[ type ] = [];
  21031. handlers.delegateCount = 0;
  21032. // Only use addEventListener if the special events handler returns false
  21033. if ( !special.setup ||
  21034. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  21035. if ( elem.addEventListener ) {
  21036. elem.addEventListener( type, eventHandle );
  21037. }
  21038. }
  21039. }
  21040. if ( special.add ) {
  21041. special.add.call( elem, handleObj );
  21042. if ( !handleObj.handler.guid ) {
  21043. handleObj.handler.guid = handler.guid;
  21044. }
  21045. }
  21046. // Add to the element's handler list, delegates in front
  21047. if ( selector ) {
  21048. handlers.splice( handlers.delegateCount++, 0, handleObj );
  21049. } else {
  21050. handlers.push( handleObj );
  21051. }
  21052. // Keep track of which events have ever been used, for event optimization
  21053. jQuery.event.global[ type ] = true;
  21054. }
  21055. },
  21056. // Detach an event or set of events from an element
  21057. remove: function( elem, types, handler, selector, mappedTypes ) {
  21058. var j, origCount, tmp,
  21059. events, t, handleObj,
  21060. special, handlers, type, namespaces, origType,
  21061. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  21062. if ( !elemData || !( events = elemData.events ) ) {
  21063. return;
  21064. }
  21065. // Once for each type.namespace in types; type may be omitted
  21066. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  21067. t = types.length;
  21068. while ( t-- ) {
  21069. tmp = rtypenamespace.exec( types[ t ] ) || [];
  21070. type = origType = tmp[ 1 ];
  21071. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  21072. // Unbind all events (on this namespace, if provided) for the element
  21073. if ( !type ) {
  21074. for ( type in events ) {
  21075. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  21076. }
  21077. continue;
  21078. }
  21079. special = jQuery.event.special[ type ] || {};
  21080. type = ( selector ? special.delegateType : special.bindType ) || type;
  21081. handlers = events[ type ] || [];
  21082. tmp = tmp[ 2 ] &&
  21083. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  21084. // Remove matching events
  21085. origCount = j = handlers.length;
  21086. while ( j-- ) {
  21087. handleObj = handlers[ j ];
  21088. if ( ( mappedTypes || origType === handleObj.origType ) &&
  21089. ( !handler || handler.guid === handleObj.guid ) &&
  21090. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  21091. ( !selector || selector === handleObj.selector ||
  21092. selector === "**" && handleObj.selector ) ) {
  21093. handlers.splice( j, 1 );
  21094. if ( handleObj.selector ) {
  21095. handlers.delegateCount--;
  21096. }
  21097. if ( special.remove ) {
  21098. special.remove.call( elem, handleObj );
  21099. }
  21100. }
  21101. }
  21102. // Remove generic event handler if we removed something and no more handlers exist
  21103. // (avoids potential for endless recursion during removal of special event handlers)
  21104. if ( origCount && !handlers.length ) {
  21105. if ( !special.teardown ||
  21106. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  21107. jQuery.removeEvent( elem, type, elemData.handle );
  21108. }
  21109. delete events[ type ];
  21110. }
  21111. }
  21112. // Remove data and the expando if it's no longer used
  21113. if ( jQuery.isEmptyObject( events ) ) {
  21114. dataPriv.remove( elem, "handle events" );
  21115. }
  21116. },
  21117. dispatch: function( nativeEvent ) {
  21118. // Make a writable jQuery.Event from the native event object
  21119. var event = jQuery.event.fix( nativeEvent );
  21120. var i, j, ret, matched, handleObj, handlerQueue,
  21121. args = new Array( arguments.length ),
  21122. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  21123. special = jQuery.event.special[ event.type ] || {};
  21124. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  21125. args[ 0 ] = event;
  21126. for ( i = 1; i < arguments.length; i++ ) {
  21127. args[ i ] = arguments[ i ];
  21128. }
  21129. event.delegateTarget = this;
  21130. // Call the preDispatch hook for the mapped type, and let it bail if desired
  21131. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  21132. return;
  21133. }
  21134. // Determine handlers
  21135. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  21136. // Run delegates first; they may want to stop propagation beneath us
  21137. i = 0;
  21138. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  21139. event.currentTarget = matched.elem;
  21140. j = 0;
  21141. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  21142. !event.isImmediatePropagationStopped() ) {
  21143. // Triggered event must either 1) have no namespace, or 2) have namespace(s)
  21144. // a subset or equal to those in the bound event (both can have no namespace).
  21145. if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
  21146. event.handleObj = handleObj;
  21147. event.data = handleObj.data;
  21148. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  21149. handleObj.handler ).apply( matched.elem, args );
  21150. if ( ret !== undefined ) {
  21151. if ( ( event.result = ret ) === false ) {
  21152. event.preventDefault();
  21153. event.stopPropagation();
  21154. }
  21155. }
  21156. }
  21157. }
  21158. }
  21159. // Call the postDispatch hook for the mapped type
  21160. if ( special.postDispatch ) {
  21161. special.postDispatch.call( this, event );
  21162. }
  21163. return event.result;
  21164. },
  21165. handlers: function( event, handlers ) {
  21166. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  21167. handlerQueue = [],
  21168. delegateCount = handlers.delegateCount,
  21169. cur = event.target;
  21170. // Find delegate handlers
  21171. if ( delegateCount &&
  21172. // Support: IE <=9
  21173. // Black-hole SVG <use> instance trees (trac-13180)
  21174. cur.nodeType &&
  21175. // Support: Firefox <=42
  21176. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  21177. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  21178. // Support: IE 11 only
  21179. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  21180. !( event.type === "click" && event.button >= 1 ) ) {
  21181. for ( ; cur !== this; cur = cur.parentNode || this ) {
  21182. // Don't check non-elements (#13208)
  21183. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  21184. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  21185. matchedHandlers = [];
  21186. matchedSelectors = {};
  21187. for ( i = 0; i < delegateCount; i++ ) {
  21188. handleObj = handlers[ i ];
  21189. // Don't conflict with Object.prototype properties (#13203)
  21190. sel = handleObj.selector + " ";
  21191. if ( matchedSelectors[ sel ] === undefined ) {
  21192. matchedSelectors[ sel ] = handleObj.needsContext ?
  21193. jQuery( sel, this ).index( cur ) > -1 :
  21194. jQuery.find( sel, this, null, [ cur ] ).length;
  21195. }
  21196. if ( matchedSelectors[ sel ] ) {
  21197. matchedHandlers.push( handleObj );
  21198. }
  21199. }
  21200. if ( matchedHandlers.length ) {
  21201. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  21202. }
  21203. }
  21204. }
  21205. }
  21206. // Add the remaining (directly-bound) handlers
  21207. cur = this;
  21208. if ( delegateCount < handlers.length ) {
  21209. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  21210. }
  21211. return handlerQueue;
  21212. },
  21213. addProp: function( name, hook ) {
  21214. Object.defineProperty( jQuery.Event.prototype, name, {
  21215. enumerable: true,
  21216. configurable: true,
  21217. get: jQuery.isFunction( hook ) ?
  21218. function() {
  21219. if ( this.originalEvent ) {
  21220. return hook( this.originalEvent );
  21221. }
  21222. } :
  21223. function() {
  21224. if ( this.originalEvent ) {
  21225. return this.originalEvent[ name ];
  21226. }
  21227. },
  21228. set: function( value ) {
  21229. Object.defineProperty( this, name, {
  21230. enumerable: true,
  21231. configurable: true,
  21232. writable: true,
  21233. value: value
  21234. } );
  21235. }
  21236. } );
  21237. },
  21238. fix: function( originalEvent ) {
  21239. return originalEvent[ jQuery.expando ] ?
  21240. originalEvent :
  21241. new jQuery.Event( originalEvent );
  21242. },
  21243. special: {
  21244. load: {
  21245. // Prevent triggered image.load events from bubbling to window.load
  21246. noBubble: true
  21247. },
  21248. focus: {
  21249. // Fire native event if possible so blur/focus sequence is correct
  21250. trigger: function() {
  21251. if ( this !== safeActiveElement() && this.focus ) {
  21252. this.focus();
  21253. return false;
  21254. }
  21255. },
  21256. delegateType: "focusin"
  21257. },
  21258. blur: {
  21259. trigger: function() {
  21260. if ( this === safeActiveElement() && this.blur ) {
  21261. this.blur();
  21262. return false;
  21263. }
  21264. },
  21265. delegateType: "focusout"
  21266. },
  21267. click: {
  21268. // For checkbox, fire native event so checked state will be right
  21269. trigger: function() {
  21270. if ( this.type === "checkbox" && this.click && nodeName( this, "input" ) ) {
  21271. this.click();
  21272. return false;
  21273. }
  21274. },
  21275. // For cross-browser consistency, don't fire native .click() on links
  21276. _default: function( event ) {
  21277. return nodeName( event.target, "a" );
  21278. }
  21279. },
  21280. beforeunload: {
  21281. postDispatch: function( event ) {
  21282. // Support: Firefox 20+
  21283. // Firefox doesn't alert if the returnValue field is not set.
  21284. if ( event.result !== undefined && event.originalEvent ) {
  21285. event.originalEvent.returnValue = event.result;
  21286. }
  21287. }
  21288. }
  21289. }
  21290. };
  21291. jQuery.removeEvent = function( elem, type, handle ) {
  21292. // This "if" is needed for plain objects
  21293. if ( elem.removeEventListener ) {
  21294. elem.removeEventListener( type, handle );
  21295. }
  21296. };
  21297. jQuery.Event = function( src, props ) {
  21298. // Allow instantiation without the 'new' keyword
  21299. if ( !( this instanceof jQuery.Event ) ) {
  21300. return new jQuery.Event( src, props );
  21301. }
  21302. // Event object
  21303. if ( src && src.type ) {
  21304. this.originalEvent = src;
  21305. this.type = src.type;
  21306. // Events bubbling up the document may have been marked as prevented
  21307. // by a handler lower down the tree; reflect the correct value.
  21308. this.isDefaultPrevented = src.defaultPrevented ||
  21309. src.defaultPrevented === undefined &&
  21310. // Support: Android <=2.3 only
  21311. src.returnValue === false ?
  21312. returnTrue :
  21313. returnFalse;
  21314. // Create target properties
  21315. // Support: Safari <=6 - 7 only
  21316. // Target should not be a text node (#504, #13143)
  21317. this.target = ( src.target && src.target.nodeType === 3 ) ?
  21318. src.target.parentNode :
  21319. src.target;
  21320. this.currentTarget = src.currentTarget;
  21321. this.relatedTarget = src.relatedTarget;
  21322. // Event type
  21323. } else {
  21324. this.type = src;
  21325. }
  21326. // Put explicitly provided properties onto the event object
  21327. if ( props ) {
  21328. jQuery.extend( this, props );
  21329. }
  21330. // Create a timestamp if incoming event doesn't have one
  21331. this.timeStamp = src && src.timeStamp || jQuery.now();
  21332. // Mark it as fixed
  21333. this[ jQuery.expando ] = true;
  21334. };
  21335. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  21336. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  21337. jQuery.Event.prototype = {
  21338. constructor: jQuery.Event,
  21339. isDefaultPrevented: returnFalse,
  21340. isPropagationStopped: returnFalse,
  21341. isImmediatePropagationStopped: returnFalse,
  21342. isSimulated: false,
  21343. preventDefault: function() {
  21344. var e = this.originalEvent;
  21345. this.isDefaultPrevented = returnTrue;
  21346. if ( e && !this.isSimulated ) {
  21347. e.preventDefault();
  21348. }
  21349. },
  21350. stopPropagation: function() {
  21351. var e = this.originalEvent;
  21352. this.isPropagationStopped = returnTrue;
  21353. if ( e && !this.isSimulated ) {
  21354. e.stopPropagation();
  21355. }
  21356. },
  21357. stopImmediatePropagation: function() {
  21358. var e = this.originalEvent;
  21359. this.isImmediatePropagationStopped = returnTrue;
  21360. if ( e && !this.isSimulated ) {
  21361. e.stopImmediatePropagation();
  21362. }
  21363. this.stopPropagation();
  21364. }
  21365. };
  21366. // Includes all common event props including KeyEvent and MouseEvent specific props
  21367. jQuery.each( {
  21368. altKey: true,
  21369. bubbles: true,
  21370. cancelable: true,
  21371. changedTouches: true,
  21372. ctrlKey: true,
  21373. detail: true,
  21374. eventPhase: true,
  21375. metaKey: true,
  21376. pageX: true,
  21377. pageY: true,
  21378. shiftKey: true,
  21379. view: true,
  21380. "char": true,
  21381. charCode: true,
  21382. key: true,
  21383. keyCode: true,
  21384. button: true,
  21385. buttons: true,
  21386. clientX: true,
  21387. clientY: true,
  21388. offsetX: true,
  21389. offsetY: true,
  21390. pointerId: true,
  21391. pointerType: true,
  21392. screenX: true,
  21393. screenY: true,
  21394. targetTouches: true,
  21395. toElement: true,
  21396. touches: true,
  21397. which: function( event ) {
  21398. var button = event.button;
  21399. // Add which for key events
  21400. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  21401. return event.charCode != null ? event.charCode : event.keyCode;
  21402. }
  21403. // Add which for click: 1 === left; 2 === middle; 3 === right
  21404. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  21405. if ( button & 1 ) {
  21406. return 1;
  21407. }
  21408. if ( button & 2 ) {
  21409. return 3;
  21410. }
  21411. if ( button & 4 ) {
  21412. return 2;
  21413. }
  21414. return 0;
  21415. }
  21416. return event.which;
  21417. }
  21418. }, jQuery.event.addProp );
  21419. // Create mouseenter/leave events using mouseover/out and event-time checks
  21420. // so that event delegation works in jQuery.
  21421. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  21422. //
  21423. // Support: Safari 7 only
  21424. // Safari sends mouseenter too often; see:
  21425. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  21426. // for the description of the bug (it existed in older Chrome versions as well).
  21427. jQuery.each( {
  21428. mouseenter: "mouseover",
  21429. mouseleave: "mouseout",
  21430. pointerenter: "pointerover",
  21431. pointerleave: "pointerout"
  21432. }, function( orig, fix ) {
  21433. jQuery.event.special[ orig ] = {
  21434. delegateType: fix,
  21435. bindType: fix,
  21436. handle: function( event ) {
  21437. var ret,
  21438. target = this,
  21439. related = event.relatedTarget,
  21440. handleObj = event.handleObj;
  21441. // For mouseenter/leave call the handler if related is outside the target.
  21442. // NB: No relatedTarget if the mouse left/entered the browser window
  21443. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  21444. event.type = handleObj.origType;
  21445. ret = handleObj.handler.apply( this, arguments );
  21446. event.type = fix;
  21447. }
  21448. return ret;
  21449. }
  21450. };
  21451. } );
  21452. jQuery.fn.extend( {
  21453. on: function( types, selector, data, fn ) {
  21454. return on( this, types, selector, data, fn );
  21455. },
  21456. one: function( types, selector, data, fn ) {
  21457. return on( this, types, selector, data, fn, 1 );
  21458. },
  21459. off: function( types, selector, fn ) {
  21460. var handleObj, type;
  21461. if ( types && types.preventDefault && types.handleObj ) {
  21462. // ( event ) dispatched jQuery.Event
  21463. handleObj = types.handleObj;
  21464. jQuery( types.delegateTarget ).off(
  21465. handleObj.namespace ?
  21466. handleObj.origType + "." + handleObj.namespace :
  21467. handleObj.origType,
  21468. handleObj.selector,
  21469. handleObj.handler
  21470. );
  21471. return this;
  21472. }
  21473. if ( typeof types === "object" ) {
  21474. // ( types-object [, selector] )
  21475. for ( type in types ) {
  21476. this.off( type, selector, types[ type ] );
  21477. }
  21478. return this;
  21479. }
  21480. if ( selector === false || typeof selector === "function" ) {
  21481. // ( types [, fn] )
  21482. fn = selector;
  21483. selector = undefined;
  21484. }
  21485. if ( fn === false ) {
  21486. fn = returnFalse;
  21487. }
  21488. return this.each( function() {
  21489. jQuery.event.remove( this, types, fn, selector );
  21490. } );
  21491. }
  21492. } );
  21493. var
  21494. /* eslint-disable max-len */
  21495. // See https://github.com/eslint/eslint/issues/3229
  21496. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  21497. /* eslint-enable */
  21498. // Support: IE <=10 - 11, Edge 12 - 13
  21499. // In IE/Edge using regex groups here causes severe slowdowns.
  21500. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  21501. rnoInnerhtml = /<script|<style|<link/i,
  21502. // checked="checked" or checked
  21503. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  21504. rscriptTypeMasked = /^true\/(.*)/,
  21505. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  21506. // Prefer a tbody over its parent table for containing new rows
  21507. function manipulationTarget( elem, content ) {
  21508. if ( nodeName( elem, "table" ) &&
  21509. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  21510. return jQuery( ">tbody", elem )[ 0 ] || elem;
  21511. }
  21512. return elem;
  21513. }
  21514. // Replace/restore the type attribute of script elements for safe DOM manipulation
  21515. function disableScript( elem ) {
  21516. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  21517. return elem;
  21518. }
  21519. function restoreScript( elem ) {
  21520. var match = rscriptTypeMasked.exec( elem.type );
  21521. if ( match ) {
  21522. elem.type = match[ 1 ];
  21523. } else {
  21524. elem.removeAttribute( "type" );
  21525. }
  21526. return elem;
  21527. }
  21528. function cloneCopyEvent( src, dest ) {
  21529. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  21530. if ( dest.nodeType !== 1 ) {
  21531. return;
  21532. }
  21533. // 1. Copy private data: events, handlers, etc.
  21534. if ( dataPriv.hasData( src ) ) {
  21535. pdataOld = dataPriv.access( src );
  21536. pdataCur = dataPriv.set( dest, pdataOld );
  21537. events = pdataOld.events;
  21538. if ( events ) {
  21539. delete pdataCur.handle;
  21540. pdataCur.events = {};
  21541. for ( type in events ) {
  21542. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  21543. jQuery.event.add( dest, type, events[ type ][ i ] );
  21544. }
  21545. }
  21546. }
  21547. }
  21548. // 2. Copy user data
  21549. if ( dataUser.hasData( src ) ) {
  21550. udataOld = dataUser.access( src );
  21551. udataCur = jQuery.extend( {}, udataOld );
  21552. dataUser.set( dest, udataCur );
  21553. }
  21554. }
  21555. // Fix IE bugs, see support tests
  21556. function fixInput( src, dest ) {
  21557. var nodeName = dest.nodeName.toLowerCase();
  21558. // Fails to persist the checked state of a cloned checkbox or radio button.
  21559. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  21560. dest.checked = src.checked;
  21561. // Fails to return the selected option to the default selected state when cloning options
  21562. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  21563. dest.defaultValue = src.defaultValue;
  21564. }
  21565. }
  21566. function domManip( collection, args, callback, ignored ) {
  21567. // Flatten any nested arrays
  21568. args = concat.apply( [], args );
  21569. var fragment, first, scripts, hasScripts, node, doc,
  21570. i = 0,
  21571. l = collection.length,
  21572. iNoClone = l - 1,
  21573. value = args[ 0 ],
  21574. isFunction = jQuery.isFunction( value );
  21575. // We can't cloneNode fragments that contain checked, in WebKit
  21576. if ( isFunction ||
  21577. ( l > 1 && typeof value === "string" &&
  21578. !support.checkClone && rchecked.test( value ) ) ) {
  21579. return collection.each( function( index ) {
  21580. var self = collection.eq( index );
  21581. if ( isFunction ) {
  21582. args[ 0 ] = value.call( this, index, self.html() );
  21583. }
  21584. domManip( self, args, callback, ignored );
  21585. } );
  21586. }
  21587. if ( l ) {
  21588. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  21589. first = fragment.firstChild;
  21590. if ( fragment.childNodes.length === 1 ) {
  21591. fragment = first;
  21592. }
  21593. // Require either new content or an interest in ignored elements to invoke the callback
  21594. if ( first || ignored ) {
  21595. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  21596. hasScripts = scripts.length;
  21597. // Use the original fragment for the last item
  21598. // instead of the first because it can end up
  21599. // being emptied incorrectly in certain situations (#8070).
  21600. for ( ; i < l; i++ ) {
  21601. node = fragment;
  21602. if ( i !== iNoClone ) {
  21603. node = jQuery.clone( node, true, true );
  21604. // Keep references to cloned scripts for later restoration
  21605. if ( hasScripts ) {
  21606. // Support: Android <=4.0 only, PhantomJS 1 only
  21607. // push.apply(_, arraylike) throws on ancient WebKit
  21608. jQuery.merge( scripts, getAll( node, "script" ) );
  21609. }
  21610. }
  21611. callback.call( collection[ i ], node, i );
  21612. }
  21613. if ( hasScripts ) {
  21614. doc = scripts[ scripts.length - 1 ].ownerDocument;
  21615. // Reenable scripts
  21616. jQuery.map( scripts, restoreScript );
  21617. // Evaluate executable scripts on first document insertion
  21618. for ( i = 0; i < hasScripts; i++ ) {
  21619. node = scripts[ i ];
  21620. if ( rscriptType.test( node.type || "" ) &&
  21621. !dataPriv.access( node, "globalEval" ) &&
  21622. jQuery.contains( doc, node ) ) {
  21623. if ( node.src ) {
  21624. // Optional AJAX dependency, but won't run scripts if not present
  21625. if ( jQuery._evalUrl ) {
  21626. jQuery._evalUrl( node.src );
  21627. }
  21628. } else {
  21629. DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
  21630. }
  21631. }
  21632. }
  21633. }
  21634. }
  21635. }
  21636. return collection;
  21637. }
  21638. function remove( elem, selector, keepData ) {
  21639. var node,
  21640. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  21641. i = 0;
  21642. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  21643. if ( !keepData && node.nodeType === 1 ) {
  21644. jQuery.cleanData( getAll( node ) );
  21645. }
  21646. if ( node.parentNode ) {
  21647. if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
  21648. setGlobalEval( getAll( node, "script" ) );
  21649. }
  21650. node.parentNode.removeChild( node );
  21651. }
  21652. }
  21653. return elem;
  21654. }
  21655. jQuery.extend( {
  21656. htmlPrefilter: function( html ) {
  21657. return html.replace( rxhtmlTag, "<$1></$2>" );
  21658. },
  21659. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  21660. var i, l, srcElements, destElements,
  21661. clone = elem.cloneNode( true ),
  21662. inPage = jQuery.contains( elem.ownerDocument, elem );
  21663. // Fix IE cloning issues
  21664. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  21665. !jQuery.isXMLDoc( elem ) ) {
  21666. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  21667. destElements = getAll( clone );
  21668. srcElements = getAll( elem );
  21669. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  21670. fixInput( srcElements[ i ], destElements[ i ] );
  21671. }
  21672. }
  21673. // Copy the events from the original to the clone
  21674. if ( dataAndEvents ) {
  21675. if ( deepDataAndEvents ) {
  21676. srcElements = srcElements || getAll( elem );
  21677. destElements = destElements || getAll( clone );
  21678. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  21679. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  21680. }
  21681. } else {
  21682. cloneCopyEvent( elem, clone );
  21683. }
  21684. }
  21685. // Preserve script evaluation history
  21686. destElements = getAll( clone, "script" );
  21687. if ( destElements.length > 0 ) {
  21688. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  21689. }
  21690. // Return the cloned set
  21691. return clone;
  21692. },
  21693. cleanData: function( elems ) {
  21694. var data, elem, type,
  21695. special = jQuery.event.special,
  21696. i = 0;
  21697. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  21698. if ( acceptData( elem ) ) {
  21699. if ( ( data = elem[ dataPriv.expando ] ) ) {
  21700. if ( data.events ) {
  21701. for ( type in data.events ) {
  21702. if ( special[ type ] ) {
  21703. jQuery.event.remove( elem, type );
  21704. // This is a shortcut to avoid jQuery.event.remove's overhead
  21705. } else {
  21706. jQuery.removeEvent( elem, type, data.handle );
  21707. }
  21708. }
  21709. }
  21710. // Support: Chrome <=35 - 45+
  21711. // Assign undefined instead of using delete, see Data#remove
  21712. elem[ dataPriv.expando ] = undefined;
  21713. }
  21714. if ( elem[ dataUser.expando ] ) {
  21715. // Support: Chrome <=35 - 45+
  21716. // Assign undefined instead of using delete, see Data#remove
  21717. elem[ dataUser.expando ] = undefined;
  21718. }
  21719. }
  21720. }
  21721. }
  21722. } );
  21723. jQuery.fn.extend( {
  21724. detach: function( selector ) {
  21725. return remove( this, selector, true );
  21726. },
  21727. remove: function( selector ) {
  21728. return remove( this, selector );
  21729. },
  21730. text: function( value ) {
  21731. return access( this, function( value ) {
  21732. return value === undefined ?
  21733. jQuery.text( this ) :
  21734. this.empty().each( function() {
  21735. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  21736. this.textContent = value;
  21737. }
  21738. } );
  21739. }, null, value, arguments.length );
  21740. },
  21741. append: function() {
  21742. return domManip( this, arguments, function( elem ) {
  21743. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  21744. var target = manipulationTarget( this, elem );
  21745. target.appendChild( elem );
  21746. }
  21747. } );
  21748. },
  21749. prepend: function() {
  21750. return domManip( this, arguments, function( elem ) {
  21751. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  21752. var target = manipulationTarget( this, elem );
  21753. target.insertBefore( elem, target.firstChild );
  21754. }
  21755. } );
  21756. },
  21757. before: function() {
  21758. return domManip( this, arguments, function( elem ) {
  21759. if ( this.parentNode ) {
  21760. this.parentNode.insertBefore( elem, this );
  21761. }
  21762. } );
  21763. },
  21764. after: function() {
  21765. return domManip( this, arguments, function( elem ) {
  21766. if ( this.parentNode ) {
  21767. this.parentNode.insertBefore( elem, this.nextSibling );
  21768. }
  21769. } );
  21770. },
  21771. empty: function() {
  21772. var elem,
  21773. i = 0;
  21774. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  21775. if ( elem.nodeType === 1 ) {
  21776. // Prevent memory leaks
  21777. jQuery.cleanData( getAll( elem, false ) );
  21778. // Remove any remaining nodes
  21779. elem.textContent = "";
  21780. }
  21781. }
  21782. return this;
  21783. },
  21784. clone: function( dataAndEvents, deepDataAndEvents ) {
  21785. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  21786. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  21787. return this.map( function() {
  21788. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  21789. } );
  21790. },
  21791. html: function( value ) {
  21792. return access( this, function( value ) {
  21793. var elem = this[ 0 ] || {},
  21794. i = 0,
  21795. l = this.length;
  21796. if ( value === undefined && elem.nodeType === 1 ) {
  21797. return elem.innerHTML;
  21798. }
  21799. // See if we can take a shortcut and just use innerHTML
  21800. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  21801. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  21802. value = jQuery.htmlPrefilter( value );
  21803. try {
  21804. for ( ; i < l; i++ ) {
  21805. elem = this[ i ] || {};
  21806. // Remove element nodes and prevent memory leaks
  21807. if ( elem.nodeType === 1 ) {
  21808. jQuery.cleanData( getAll( elem, false ) );
  21809. elem.innerHTML = value;
  21810. }
  21811. }
  21812. elem = 0;
  21813. // If using innerHTML throws an exception, use the fallback method
  21814. } catch ( e ) {}
  21815. }
  21816. if ( elem ) {
  21817. this.empty().append( value );
  21818. }
  21819. }, null, value, arguments.length );
  21820. },
  21821. replaceWith: function() {
  21822. var ignored = [];
  21823. // Make the changes, replacing each non-ignored context element with the new content
  21824. return domManip( this, arguments, function( elem ) {
  21825. var parent = this.parentNode;
  21826. if ( jQuery.inArray( this, ignored ) < 0 ) {
  21827. jQuery.cleanData( getAll( this ) );
  21828. if ( parent ) {
  21829. parent.replaceChild( elem, this );
  21830. }
  21831. }
  21832. // Force callback invocation
  21833. }, ignored );
  21834. }
  21835. } );
  21836. jQuery.each( {
  21837. appendTo: "append",
  21838. prependTo: "prepend",
  21839. insertBefore: "before",
  21840. insertAfter: "after",
  21841. replaceAll: "replaceWith"
  21842. }, function( name, original ) {
  21843. jQuery.fn[ name ] = function( selector ) {
  21844. var elems,
  21845. ret = [],
  21846. insert = jQuery( selector ),
  21847. last = insert.length - 1,
  21848. i = 0;
  21849. for ( ; i <= last; i++ ) {
  21850. elems = i === last ? this : this.clone( true );
  21851. jQuery( insert[ i ] )[ original ]( elems );
  21852. // Support: Android <=4.0 only, PhantomJS 1 only
  21853. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  21854. push.apply( ret, elems.get() );
  21855. }
  21856. return this.pushStack( ret );
  21857. };
  21858. } );
  21859. var rmargin = ( /^margin/ );
  21860. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  21861. var getStyles = function( elem ) {
  21862. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  21863. // IE throws on elements created in popups
  21864. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  21865. var view = elem.ownerDocument.defaultView;
  21866. if ( !view || !view.opener ) {
  21867. view = window;
  21868. }
  21869. return view.getComputedStyle( elem );
  21870. };
  21871. ( function() {
  21872. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  21873. // so they're executed at the same time to save the second computation.
  21874. function computeStyleTests() {
  21875. // This is a singleton, we need to execute it only once
  21876. if ( !div ) {
  21877. return;
  21878. }
  21879. div.style.cssText =
  21880. "box-sizing:border-box;" +
  21881. "position:relative;display:block;" +
  21882. "margin:auto;border:1px;padding:1px;" +
  21883. "top:1%;width:50%";
  21884. div.innerHTML = "";
  21885. documentElement.appendChild( container );
  21886. var divStyle = window.getComputedStyle( div );
  21887. pixelPositionVal = divStyle.top !== "1%";
  21888. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  21889. reliableMarginLeftVal = divStyle.marginLeft === "2px";
  21890. boxSizingReliableVal = divStyle.width === "4px";
  21891. // Support: Android 4.0 - 4.3 only
  21892. // Some styles come back with percentage values, even though they shouldn't
  21893. div.style.marginRight = "50%";
  21894. pixelMarginRightVal = divStyle.marginRight === "4px";
  21895. documentElement.removeChild( container );
  21896. // Nullify the div so it wouldn't be stored in the memory and
  21897. // it will also be a sign that checks already performed
  21898. div = null;
  21899. }
  21900. var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
  21901. container = document.createElement( "div" ),
  21902. div = document.createElement( "div" );
  21903. // Finish early in limited (non-browser) environments
  21904. if ( !div.style ) {
  21905. return;
  21906. }
  21907. // Support: IE <=9 - 11 only
  21908. // Style of cloned element affects source element cloned (#8908)
  21909. div.style.backgroundClip = "content-box";
  21910. div.cloneNode( true ).style.backgroundClip = "";
  21911. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  21912. container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
  21913. "padding:0;margin-top:1px;position:absolute";
  21914. container.appendChild( div );
  21915. jQuery.extend( support, {
  21916. pixelPosition: function() {
  21917. computeStyleTests();
  21918. return pixelPositionVal;
  21919. },
  21920. boxSizingReliable: function() {
  21921. computeStyleTests();
  21922. return boxSizingReliableVal;
  21923. },
  21924. pixelMarginRight: function() {
  21925. computeStyleTests();
  21926. return pixelMarginRightVal;
  21927. },
  21928. reliableMarginLeft: function() {
  21929. computeStyleTests();
  21930. return reliableMarginLeftVal;
  21931. }
  21932. } );
  21933. } )();
  21934. function curCSS( elem, name, computed ) {
  21935. var width, minWidth, maxWidth, ret,
  21936. // Support: Firefox 51+
  21937. // Retrieving style before computed somehow
  21938. // fixes an issue with getting wrong values
  21939. // on detached elements
  21940. style = elem.style;
  21941. computed = computed || getStyles( elem );
  21942. // getPropertyValue is needed for:
  21943. // .css('filter') (IE 9 only, #12537)
  21944. // .css('--customProperty) (#3144)
  21945. if ( computed ) {
  21946. ret = computed.getPropertyValue( name ) || computed[ name ];
  21947. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  21948. ret = jQuery.style( elem, name );
  21949. }
  21950. // A tribute to the "awesome hack by Dean Edwards"
  21951. // Android Browser returns percentage for some values,
  21952. // but width seems to be reliably pixels.
  21953. // This is against the CSSOM draft spec:
  21954. // https://drafts.csswg.org/cssom/#resolved-values
  21955. if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  21956. // Remember the original values
  21957. width = style.width;
  21958. minWidth = style.minWidth;
  21959. maxWidth = style.maxWidth;
  21960. // Put in the new values to get a computed value out
  21961. style.minWidth = style.maxWidth = style.width = ret;
  21962. ret = computed.width;
  21963. // Revert the changed values
  21964. style.width = width;
  21965. style.minWidth = minWidth;
  21966. style.maxWidth = maxWidth;
  21967. }
  21968. }
  21969. return ret !== undefined ?
  21970. // Support: IE <=9 - 11 only
  21971. // IE returns zIndex value as an integer.
  21972. ret + "" :
  21973. ret;
  21974. }
  21975. function addGetHookIf( conditionFn, hookFn ) {
  21976. // Define the hook, we'll check on the first run if it's really needed.
  21977. return {
  21978. get: function() {
  21979. if ( conditionFn() ) {
  21980. // Hook not needed (or it's not possible to use it due
  21981. // to missing dependency), remove it.
  21982. delete this.get;
  21983. return;
  21984. }
  21985. // Hook needed; redefine it so that the support test is not executed again.
  21986. return ( this.get = hookFn ).apply( this, arguments );
  21987. }
  21988. };
  21989. }
  21990. var
  21991. // Swappable if display is none or starts with table
  21992. // except "table", "table-cell", or "table-caption"
  21993. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  21994. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  21995. rcustomProp = /^--/,
  21996. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  21997. cssNormalTransform = {
  21998. letterSpacing: "0",
  21999. fontWeight: "400"
  22000. },
  22001. cssPrefixes = [ "Webkit", "Moz", "ms" ],
  22002. emptyStyle = document.createElement( "div" ).style;
  22003. // Return a css property mapped to a potentially vendor prefixed property
  22004. function vendorPropName( name ) {
  22005. // Shortcut for names that are not vendor prefixed
  22006. if ( name in emptyStyle ) {
  22007. return name;
  22008. }
  22009. // Check for vendor prefixed names
  22010. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  22011. i = cssPrefixes.length;
  22012. while ( i-- ) {
  22013. name = cssPrefixes[ i ] + capName;
  22014. if ( name in emptyStyle ) {
  22015. return name;
  22016. }
  22017. }
  22018. }
  22019. // Return a property mapped along what jQuery.cssProps suggests or to
  22020. // a vendor prefixed property.
  22021. function finalPropName( name ) {
  22022. var ret = jQuery.cssProps[ name ];
  22023. if ( !ret ) {
  22024. ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
  22025. }
  22026. return ret;
  22027. }
  22028. function setPositiveNumber( elem, value, subtract ) {
  22029. // Any relative (+/-) values have already been
  22030. // normalized at this point
  22031. var matches = rcssNum.exec( value );
  22032. return matches ?
  22033. // Guard against undefined "subtract", e.g., when used as in cssHooks
  22034. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  22035. value;
  22036. }
  22037. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  22038. var i,
  22039. val = 0;
  22040. // If we already have the right measurement, avoid augmentation
  22041. if ( extra === ( isBorderBox ? "border" : "content" ) ) {
  22042. i = 4;
  22043. // Otherwise initialize for horizontal or vertical properties
  22044. } else {
  22045. i = name === "width" ? 1 : 0;
  22046. }
  22047. for ( ; i < 4; i += 2 ) {
  22048. // Both box models exclude margin, so add it if we want it
  22049. if ( extra === "margin" ) {
  22050. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  22051. }
  22052. if ( isBorderBox ) {
  22053. // border-box includes padding, so remove it if we want content
  22054. if ( extra === "content" ) {
  22055. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  22056. }
  22057. // At this point, extra isn't border nor margin, so remove border
  22058. if ( extra !== "margin" ) {
  22059. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  22060. }
  22061. } else {
  22062. // At this point, extra isn't content, so add padding
  22063. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  22064. // At this point, extra isn't content nor padding, so add border
  22065. if ( extra !== "padding" ) {
  22066. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  22067. }
  22068. }
  22069. }
  22070. return val;
  22071. }
  22072. function getWidthOrHeight( elem, name, extra ) {
  22073. // Start with computed style
  22074. var valueIsBorderBox,
  22075. styles = getStyles( elem ),
  22076. val = curCSS( elem, name, styles ),
  22077. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  22078. // Computed unit is not pixels. Stop here and return.
  22079. if ( rnumnonpx.test( val ) ) {
  22080. return val;
  22081. }
  22082. // Check for style in case a browser which returns unreliable values
  22083. // for getComputedStyle silently falls back to the reliable elem.style
  22084. valueIsBorderBox = isBorderBox &&
  22085. ( support.boxSizingReliable() || val === elem.style[ name ] );
  22086. // Fall back to offsetWidth/Height when value is "auto"
  22087. // This happens for inline elements with no explicit setting (gh-3571)
  22088. if ( val === "auto" ) {
  22089. val = elem[ "offset" + name[ 0 ].toUpperCase() + name.slice( 1 ) ];
  22090. }
  22091. // Normalize "", auto, and prepare for extra
  22092. val = parseFloat( val ) || 0;
  22093. // Use the active box-sizing model to add/subtract irrelevant styles
  22094. return ( val +
  22095. augmentWidthOrHeight(
  22096. elem,
  22097. name,
  22098. extra || ( isBorderBox ? "border" : "content" ),
  22099. valueIsBorderBox,
  22100. styles
  22101. )
  22102. ) + "px";
  22103. }
  22104. jQuery.extend( {
  22105. // Add in style property hooks for overriding the default
  22106. // behavior of getting and setting a style property
  22107. cssHooks: {
  22108. opacity: {
  22109. get: function( elem, computed ) {
  22110. if ( computed ) {
  22111. // We should always get a number back from opacity
  22112. var ret = curCSS( elem, "opacity" );
  22113. return ret === "" ? "1" : ret;
  22114. }
  22115. }
  22116. }
  22117. },
  22118. // Don't automatically add "px" to these possibly-unitless properties
  22119. cssNumber: {
  22120. "animationIterationCount": true,
  22121. "columnCount": true,
  22122. "fillOpacity": true,
  22123. "flexGrow": true,
  22124. "flexShrink": true,
  22125. "fontWeight": true,
  22126. "lineHeight": true,
  22127. "opacity": true,
  22128. "order": true,
  22129. "orphans": true,
  22130. "widows": true,
  22131. "zIndex": true,
  22132. "zoom": true
  22133. },
  22134. // Add in properties whose names you wish to fix before
  22135. // setting or getting the value
  22136. cssProps: {
  22137. "float": "cssFloat"
  22138. },
  22139. // Get and set the style property on a DOM Node
  22140. style: function( elem, name, value, extra ) {
  22141. // Don't set styles on text and comment nodes
  22142. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  22143. return;
  22144. }
  22145. // Make sure that we're working with the right name
  22146. var ret, type, hooks,
  22147. origName = jQuery.camelCase( name ),
  22148. isCustomProp = rcustomProp.test( name ),
  22149. style = elem.style;
  22150. // Make sure that we're working with the right name. We don't
  22151. // want to query the value if it is a CSS custom property
  22152. // since they are user-defined.
  22153. if ( !isCustomProp ) {
  22154. name = finalPropName( origName );
  22155. }
  22156. // Gets hook for the prefixed version, then unprefixed version
  22157. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  22158. // Check if we're setting a value
  22159. if ( value !== undefined ) {
  22160. type = typeof value;
  22161. // Convert "+=" or "-=" to relative numbers (#7345)
  22162. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  22163. value = adjustCSS( elem, name, ret );
  22164. // Fixes bug #9237
  22165. type = "number";
  22166. }
  22167. // Make sure that null and NaN values aren't set (#7116)
  22168. if ( value == null || value !== value ) {
  22169. return;
  22170. }
  22171. // If a number was passed in, add the unit (except for certain CSS properties)
  22172. if ( type === "number" ) {
  22173. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  22174. }
  22175. // background-* props affect original clone's values
  22176. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  22177. style[ name ] = "inherit";
  22178. }
  22179. // If a hook was provided, use that value, otherwise just set the specified value
  22180. if ( !hooks || !( "set" in hooks ) ||
  22181. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  22182. if ( isCustomProp ) {
  22183. style.setProperty( name, value );
  22184. } else {
  22185. style[ name ] = value;
  22186. }
  22187. }
  22188. } else {
  22189. // If a hook was provided get the non-computed value from there
  22190. if ( hooks && "get" in hooks &&
  22191. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  22192. return ret;
  22193. }
  22194. // Otherwise just get the value from the style object
  22195. return style[ name ];
  22196. }
  22197. },
  22198. css: function( elem, name, extra, styles ) {
  22199. var val, num, hooks,
  22200. origName = jQuery.camelCase( name ),
  22201. isCustomProp = rcustomProp.test( name );
  22202. // Make sure that we're working with the right name. We don't
  22203. // want to modify the value if it is a CSS custom property
  22204. // since they are user-defined.
  22205. if ( !isCustomProp ) {
  22206. name = finalPropName( origName );
  22207. }
  22208. // Try prefixed name followed by the unprefixed name
  22209. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  22210. // If a hook was provided get the computed value from there
  22211. if ( hooks && "get" in hooks ) {
  22212. val = hooks.get( elem, true, extra );
  22213. }
  22214. // Otherwise, if a way to get the computed value exists, use that
  22215. if ( val === undefined ) {
  22216. val = curCSS( elem, name, styles );
  22217. }
  22218. // Convert "normal" to computed value
  22219. if ( val === "normal" && name in cssNormalTransform ) {
  22220. val = cssNormalTransform[ name ];
  22221. }
  22222. // Make numeric if forced or a qualifier was provided and val looks numeric
  22223. if ( extra === "" || extra ) {
  22224. num = parseFloat( val );
  22225. return extra === true || isFinite( num ) ? num || 0 : val;
  22226. }
  22227. return val;
  22228. }
  22229. } );
  22230. jQuery.each( [ "height", "width" ], function( i, name ) {
  22231. jQuery.cssHooks[ name ] = {
  22232. get: function( elem, computed, extra ) {
  22233. if ( computed ) {
  22234. // Certain elements can have dimension info if we invisibly show them
  22235. // but it must have a current display style that would benefit
  22236. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  22237. // Support: Safari 8+
  22238. // Table columns in Safari have non-zero offsetWidth & zero
  22239. // getBoundingClientRect().width unless display is changed.
  22240. // Support: IE <=11 only
  22241. // Running getBoundingClientRect on a disconnected node
  22242. // in IE throws an error.
  22243. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  22244. swap( elem, cssShow, function() {
  22245. return getWidthOrHeight( elem, name, extra );
  22246. } ) :
  22247. getWidthOrHeight( elem, name, extra );
  22248. }
  22249. },
  22250. set: function( elem, value, extra ) {
  22251. var matches,
  22252. styles = extra && getStyles( elem ),
  22253. subtract = extra && augmentWidthOrHeight(
  22254. elem,
  22255. name,
  22256. extra,
  22257. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  22258. styles
  22259. );
  22260. // Convert to pixels if value adjustment is needed
  22261. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  22262. ( matches[ 3 ] || "px" ) !== "px" ) {
  22263. elem.style[ name ] = value;
  22264. value = jQuery.css( elem, name );
  22265. }
  22266. return setPositiveNumber( elem, value, subtract );
  22267. }
  22268. };
  22269. } );
  22270. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  22271. function( elem, computed ) {
  22272. if ( computed ) {
  22273. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  22274. elem.getBoundingClientRect().left -
  22275. swap( elem, { marginLeft: 0 }, function() {
  22276. return elem.getBoundingClientRect().left;
  22277. } )
  22278. ) + "px";
  22279. }
  22280. }
  22281. );
  22282. // These hooks are used by animate to expand properties
  22283. jQuery.each( {
  22284. margin: "",
  22285. padding: "",
  22286. border: "Width"
  22287. }, function( prefix, suffix ) {
  22288. jQuery.cssHooks[ prefix + suffix ] = {
  22289. expand: function( value ) {
  22290. var i = 0,
  22291. expanded = {},
  22292. // Assumes a single number if not a string
  22293. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  22294. for ( ; i < 4; i++ ) {
  22295. expanded[ prefix + cssExpand[ i ] + suffix ] =
  22296. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  22297. }
  22298. return expanded;
  22299. }
  22300. };
  22301. if ( !rmargin.test( prefix ) ) {
  22302. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  22303. }
  22304. } );
  22305. jQuery.fn.extend( {
  22306. css: function( name, value ) {
  22307. return access( this, function( elem, name, value ) {
  22308. var styles, len,
  22309. map = {},
  22310. i = 0;
  22311. if ( Array.isArray( name ) ) {
  22312. styles = getStyles( elem );
  22313. len = name.length;
  22314. for ( ; i < len; i++ ) {
  22315. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  22316. }
  22317. return map;
  22318. }
  22319. return value !== undefined ?
  22320. jQuery.style( elem, name, value ) :
  22321. jQuery.css( elem, name );
  22322. }, name, value, arguments.length > 1 );
  22323. }
  22324. } );
  22325. function Tween( elem, options, prop, end, easing ) {
  22326. return new Tween.prototype.init( elem, options, prop, end, easing );
  22327. }
  22328. jQuery.Tween = Tween;
  22329. Tween.prototype = {
  22330. constructor: Tween,
  22331. init: function( elem, options, prop, end, easing, unit ) {
  22332. this.elem = elem;
  22333. this.prop = prop;
  22334. this.easing = easing || jQuery.easing._default;
  22335. this.options = options;
  22336. this.start = this.now = this.cur();
  22337. this.end = end;
  22338. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  22339. },
  22340. cur: function() {
  22341. var hooks = Tween.propHooks[ this.prop ];
  22342. return hooks && hooks.get ?
  22343. hooks.get( this ) :
  22344. Tween.propHooks._default.get( this );
  22345. },
  22346. run: function( percent ) {
  22347. var eased,
  22348. hooks = Tween.propHooks[ this.prop ];
  22349. if ( this.options.duration ) {
  22350. this.pos = eased = jQuery.easing[ this.easing ](
  22351. percent, this.options.duration * percent, 0, 1, this.options.duration
  22352. );
  22353. } else {
  22354. this.pos = eased = percent;
  22355. }
  22356. this.now = ( this.end - this.start ) * eased + this.start;
  22357. if ( this.options.step ) {
  22358. this.options.step.call( this.elem, this.now, this );
  22359. }
  22360. if ( hooks && hooks.set ) {
  22361. hooks.set( this );
  22362. } else {
  22363. Tween.propHooks._default.set( this );
  22364. }
  22365. return this;
  22366. }
  22367. };
  22368. Tween.prototype.init.prototype = Tween.prototype;
  22369. Tween.propHooks = {
  22370. _default: {
  22371. get: function( tween ) {
  22372. var result;
  22373. // Use a property on the element directly when it is not a DOM element,
  22374. // or when there is no matching style property that exists.
  22375. if ( tween.elem.nodeType !== 1 ||
  22376. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  22377. return tween.elem[ tween.prop ];
  22378. }
  22379. // Passing an empty string as a 3rd parameter to .css will automatically
  22380. // attempt a parseFloat and fallback to a string if the parse fails.
  22381. // Simple values such as "10px" are parsed to Float;
  22382. // complex values such as "rotate(1rad)" are returned as-is.
  22383. result = jQuery.css( tween.elem, tween.prop, "" );
  22384. // Empty strings, null, undefined and "auto" are converted to 0.
  22385. return !result || result === "auto" ? 0 : result;
  22386. },
  22387. set: function( tween ) {
  22388. // Use step hook for back compat.
  22389. // Use cssHook if its there.
  22390. // Use .style if available and use plain properties where available.
  22391. if ( jQuery.fx.step[ tween.prop ] ) {
  22392. jQuery.fx.step[ tween.prop ]( tween );
  22393. } else if ( tween.elem.nodeType === 1 &&
  22394. ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
  22395. jQuery.cssHooks[ tween.prop ] ) ) {
  22396. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  22397. } else {
  22398. tween.elem[ tween.prop ] = tween.now;
  22399. }
  22400. }
  22401. }
  22402. };
  22403. // Support: IE <=9 only
  22404. // Panic based approach to setting things on disconnected nodes
  22405. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  22406. set: function( tween ) {
  22407. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  22408. tween.elem[ tween.prop ] = tween.now;
  22409. }
  22410. }
  22411. };
  22412. jQuery.easing = {
  22413. linear: function( p ) {
  22414. return p;
  22415. },
  22416. swing: function( p ) {
  22417. return 0.5 - Math.cos( p * Math.PI ) / 2;
  22418. },
  22419. _default: "swing"
  22420. };
  22421. jQuery.fx = Tween.prototype.init;
  22422. // Back compat <1.8 extension point
  22423. jQuery.fx.step = {};
  22424. var
  22425. fxNow, inProgress,
  22426. rfxtypes = /^(?:toggle|show|hide)$/,
  22427. rrun = /queueHooks$/;
  22428. function schedule() {
  22429. if ( inProgress ) {
  22430. if ( document.hidden === false && window.requestAnimationFrame ) {
  22431. window.requestAnimationFrame( schedule );
  22432. } else {
  22433. window.setTimeout( schedule, jQuery.fx.interval );
  22434. }
  22435. jQuery.fx.tick();
  22436. }
  22437. }
  22438. // Animations created synchronously will run synchronously
  22439. function createFxNow() {
  22440. window.setTimeout( function() {
  22441. fxNow = undefined;
  22442. } );
  22443. return ( fxNow = jQuery.now() );
  22444. }
  22445. // Generate parameters to create a standard animation
  22446. function genFx( type, includeWidth ) {
  22447. var which,
  22448. i = 0,
  22449. attrs = { height: type };
  22450. // If we include width, step value is 1 to do all cssExpand values,
  22451. // otherwise step value is 2 to skip over Left and Right
  22452. includeWidth = includeWidth ? 1 : 0;
  22453. for ( ; i < 4; i += 2 - includeWidth ) {
  22454. which = cssExpand[ i ];
  22455. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  22456. }
  22457. if ( includeWidth ) {
  22458. attrs.opacity = attrs.width = type;
  22459. }
  22460. return attrs;
  22461. }
  22462. function createTween( value, prop, animation ) {
  22463. var tween,
  22464. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  22465. index = 0,
  22466. length = collection.length;
  22467. for ( ; index < length; index++ ) {
  22468. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  22469. // We're done with this property
  22470. return tween;
  22471. }
  22472. }
  22473. }
  22474. function defaultPrefilter( elem, props, opts ) {
  22475. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  22476. isBox = "width" in props || "height" in props,
  22477. anim = this,
  22478. orig = {},
  22479. style = elem.style,
  22480. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  22481. dataShow = dataPriv.get( elem, "fxshow" );
  22482. // Queue-skipping animations hijack the fx hooks
  22483. if ( !opts.queue ) {
  22484. hooks = jQuery._queueHooks( elem, "fx" );
  22485. if ( hooks.unqueued == null ) {
  22486. hooks.unqueued = 0;
  22487. oldfire = hooks.empty.fire;
  22488. hooks.empty.fire = function() {
  22489. if ( !hooks.unqueued ) {
  22490. oldfire();
  22491. }
  22492. };
  22493. }
  22494. hooks.unqueued++;
  22495. anim.always( function() {
  22496. // Ensure the complete handler is called before this completes
  22497. anim.always( function() {
  22498. hooks.unqueued--;
  22499. if ( !jQuery.queue( elem, "fx" ).length ) {
  22500. hooks.empty.fire();
  22501. }
  22502. } );
  22503. } );
  22504. }
  22505. // Detect show/hide animations
  22506. for ( prop in props ) {
  22507. value = props[ prop ];
  22508. if ( rfxtypes.test( value ) ) {
  22509. delete props[ prop ];
  22510. toggle = toggle || value === "toggle";
  22511. if ( value === ( hidden ? "hide" : "show" ) ) {
  22512. // Pretend to be hidden if this is a "show" and
  22513. // there is still data from a stopped show/hide
  22514. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  22515. hidden = true;
  22516. // Ignore all other no-op show/hide data
  22517. } else {
  22518. continue;
  22519. }
  22520. }
  22521. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  22522. }
  22523. }
  22524. // Bail out if this is a no-op like .hide().hide()
  22525. propTween = !jQuery.isEmptyObject( props );
  22526. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  22527. return;
  22528. }
  22529. // Restrict "overflow" and "display" styles during box animations
  22530. if ( isBox && elem.nodeType === 1 ) {
  22531. // Support: IE <=9 - 11, Edge 12 - 13
  22532. // Record all 3 overflow attributes because IE does not infer the shorthand
  22533. // from identically-valued overflowX and overflowY
  22534. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  22535. // Identify a display type, preferring old show/hide data over the CSS cascade
  22536. restoreDisplay = dataShow && dataShow.display;
  22537. if ( restoreDisplay == null ) {
  22538. restoreDisplay = dataPriv.get( elem, "display" );
  22539. }
  22540. display = jQuery.css( elem, "display" );
  22541. if ( display === "none" ) {
  22542. if ( restoreDisplay ) {
  22543. display = restoreDisplay;
  22544. } else {
  22545. // Get nonempty value(s) by temporarily forcing visibility
  22546. showHide( [ elem ], true );
  22547. restoreDisplay = elem.style.display || restoreDisplay;
  22548. display = jQuery.css( elem, "display" );
  22549. showHide( [ elem ] );
  22550. }
  22551. }
  22552. // Animate inline elements as inline-block
  22553. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  22554. if ( jQuery.css( elem, "float" ) === "none" ) {
  22555. // Restore the original display value at the end of pure show/hide animations
  22556. if ( !propTween ) {
  22557. anim.done( function() {
  22558. style.display = restoreDisplay;
  22559. } );
  22560. if ( restoreDisplay == null ) {
  22561. display = style.display;
  22562. restoreDisplay = display === "none" ? "" : display;
  22563. }
  22564. }
  22565. style.display = "inline-block";
  22566. }
  22567. }
  22568. }
  22569. if ( opts.overflow ) {
  22570. style.overflow = "hidden";
  22571. anim.always( function() {
  22572. style.overflow = opts.overflow[ 0 ];
  22573. style.overflowX = opts.overflow[ 1 ];
  22574. style.overflowY = opts.overflow[ 2 ];
  22575. } );
  22576. }
  22577. // Implement show/hide animations
  22578. propTween = false;
  22579. for ( prop in orig ) {
  22580. // General show/hide setup for this element animation
  22581. if ( !propTween ) {
  22582. if ( dataShow ) {
  22583. if ( "hidden" in dataShow ) {
  22584. hidden = dataShow.hidden;
  22585. }
  22586. } else {
  22587. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  22588. }
  22589. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  22590. if ( toggle ) {
  22591. dataShow.hidden = !hidden;
  22592. }
  22593. // Show elements before animating them
  22594. if ( hidden ) {
  22595. showHide( [ elem ], true );
  22596. }
  22597. /* eslint-disable no-loop-func */
  22598. anim.done( function() {
  22599. /* eslint-enable no-loop-func */
  22600. // The final step of a "hide" animation is actually hiding the element
  22601. if ( !hidden ) {
  22602. showHide( [ elem ] );
  22603. }
  22604. dataPriv.remove( elem, "fxshow" );
  22605. for ( prop in orig ) {
  22606. jQuery.style( elem, prop, orig[ prop ] );
  22607. }
  22608. } );
  22609. }
  22610. // Per-property setup
  22611. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  22612. if ( !( prop in dataShow ) ) {
  22613. dataShow[ prop ] = propTween.start;
  22614. if ( hidden ) {
  22615. propTween.end = propTween.start;
  22616. propTween.start = 0;
  22617. }
  22618. }
  22619. }
  22620. }
  22621. function propFilter( props, specialEasing ) {
  22622. var index, name, easing, value, hooks;
  22623. // camelCase, specialEasing and expand cssHook pass
  22624. for ( index in props ) {
  22625. name = jQuery.camelCase( index );
  22626. easing = specialEasing[ name ];
  22627. value = props[ index ];
  22628. if ( Array.isArray( value ) ) {
  22629. easing = value[ 1 ];
  22630. value = props[ index ] = value[ 0 ];
  22631. }
  22632. if ( index !== name ) {
  22633. props[ name ] = value;
  22634. delete props[ index ];
  22635. }
  22636. hooks = jQuery.cssHooks[ name ];
  22637. if ( hooks && "expand" in hooks ) {
  22638. value = hooks.expand( value );
  22639. delete props[ name ];
  22640. // Not quite $.extend, this won't overwrite existing keys.
  22641. // Reusing 'index' because we have the correct "name"
  22642. for ( index in value ) {
  22643. if ( !( index in props ) ) {
  22644. props[ index ] = value[ index ];
  22645. specialEasing[ index ] = easing;
  22646. }
  22647. }
  22648. } else {
  22649. specialEasing[ name ] = easing;
  22650. }
  22651. }
  22652. }
  22653. function Animation( elem, properties, options ) {
  22654. var result,
  22655. stopped,
  22656. index = 0,
  22657. length = Animation.prefilters.length,
  22658. deferred = jQuery.Deferred().always( function() {
  22659. // Don't match elem in the :animated selector
  22660. delete tick.elem;
  22661. } ),
  22662. tick = function() {
  22663. if ( stopped ) {
  22664. return false;
  22665. }
  22666. var currentTime = fxNow || createFxNow(),
  22667. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  22668. // Support: Android 2.3 only
  22669. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  22670. temp = remaining / animation.duration || 0,
  22671. percent = 1 - temp,
  22672. index = 0,
  22673. length = animation.tweens.length;
  22674. for ( ; index < length; index++ ) {
  22675. animation.tweens[ index ].run( percent );
  22676. }
  22677. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  22678. // If there's more to do, yield
  22679. if ( percent < 1 && length ) {
  22680. return remaining;
  22681. }
  22682. // If this was an empty animation, synthesize a final progress notification
  22683. if ( !length ) {
  22684. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  22685. }
  22686. // Resolve the animation and report its conclusion
  22687. deferred.resolveWith( elem, [ animation ] );
  22688. return false;
  22689. },
  22690. animation = deferred.promise( {
  22691. elem: elem,
  22692. props: jQuery.extend( {}, properties ),
  22693. opts: jQuery.extend( true, {
  22694. specialEasing: {},
  22695. easing: jQuery.easing._default
  22696. }, options ),
  22697. originalProperties: properties,
  22698. originalOptions: options,
  22699. startTime: fxNow || createFxNow(),
  22700. duration: options.duration,
  22701. tweens: [],
  22702. createTween: function( prop, end ) {
  22703. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  22704. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  22705. animation.tweens.push( tween );
  22706. return tween;
  22707. },
  22708. stop: function( gotoEnd ) {
  22709. var index = 0,
  22710. // If we are going to the end, we want to run all the tweens
  22711. // otherwise we skip this part
  22712. length = gotoEnd ? animation.tweens.length : 0;
  22713. if ( stopped ) {
  22714. return this;
  22715. }
  22716. stopped = true;
  22717. for ( ; index < length; index++ ) {
  22718. animation.tweens[ index ].run( 1 );
  22719. }
  22720. // Resolve when we played the last frame; otherwise, reject
  22721. if ( gotoEnd ) {
  22722. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  22723. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  22724. } else {
  22725. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  22726. }
  22727. return this;
  22728. }
  22729. } ),
  22730. props = animation.props;
  22731. propFilter( props, animation.opts.specialEasing );
  22732. for ( ; index < length; index++ ) {
  22733. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  22734. if ( result ) {
  22735. if ( jQuery.isFunction( result.stop ) ) {
  22736. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  22737. jQuery.proxy( result.stop, result );
  22738. }
  22739. return result;
  22740. }
  22741. }
  22742. jQuery.map( props, createTween, animation );
  22743. if ( jQuery.isFunction( animation.opts.start ) ) {
  22744. animation.opts.start.call( elem, animation );
  22745. }
  22746. // Attach callbacks from options
  22747. animation
  22748. .progress( animation.opts.progress )
  22749. .done( animation.opts.done, animation.opts.complete )
  22750. .fail( animation.opts.fail )
  22751. .always( animation.opts.always );
  22752. jQuery.fx.timer(
  22753. jQuery.extend( tick, {
  22754. elem: elem,
  22755. anim: animation,
  22756. queue: animation.opts.queue
  22757. } )
  22758. );
  22759. return animation;
  22760. }
  22761. jQuery.Animation = jQuery.extend( Animation, {
  22762. tweeners: {
  22763. "*": [ function( prop, value ) {
  22764. var tween = this.createTween( prop, value );
  22765. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  22766. return tween;
  22767. } ]
  22768. },
  22769. tweener: function( props, callback ) {
  22770. if ( jQuery.isFunction( props ) ) {
  22771. callback = props;
  22772. props = [ "*" ];
  22773. } else {
  22774. props = props.match( rnothtmlwhite );
  22775. }
  22776. var prop,
  22777. index = 0,
  22778. length = props.length;
  22779. for ( ; index < length; index++ ) {
  22780. prop = props[ index ];
  22781. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  22782. Animation.tweeners[ prop ].unshift( callback );
  22783. }
  22784. },
  22785. prefilters: [ defaultPrefilter ],
  22786. prefilter: function( callback, prepend ) {
  22787. if ( prepend ) {
  22788. Animation.prefilters.unshift( callback );
  22789. } else {
  22790. Animation.prefilters.push( callback );
  22791. }
  22792. }
  22793. } );
  22794. jQuery.speed = function( speed, easing, fn ) {
  22795. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  22796. complete: fn || !fn && easing ||
  22797. jQuery.isFunction( speed ) && speed,
  22798. duration: speed,
  22799. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  22800. };
  22801. // Go to the end state if fx are off
  22802. if ( jQuery.fx.off ) {
  22803. opt.duration = 0;
  22804. } else {
  22805. if ( typeof opt.duration !== "number" ) {
  22806. if ( opt.duration in jQuery.fx.speeds ) {
  22807. opt.duration = jQuery.fx.speeds[ opt.duration ];
  22808. } else {
  22809. opt.duration = jQuery.fx.speeds._default;
  22810. }
  22811. }
  22812. }
  22813. // Normalize opt.queue - true/undefined/null -> "fx"
  22814. if ( opt.queue == null || opt.queue === true ) {
  22815. opt.queue = "fx";
  22816. }
  22817. // Queueing
  22818. opt.old = opt.complete;
  22819. opt.complete = function() {
  22820. if ( jQuery.isFunction( opt.old ) ) {
  22821. opt.old.call( this );
  22822. }
  22823. if ( opt.queue ) {
  22824. jQuery.dequeue( this, opt.queue );
  22825. }
  22826. };
  22827. return opt;
  22828. };
  22829. jQuery.fn.extend( {
  22830. fadeTo: function( speed, to, easing, callback ) {
  22831. // Show any hidden elements after setting opacity to 0
  22832. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  22833. // Animate to the value specified
  22834. .end().animate( { opacity: to }, speed, easing, callback );
  22835. },
  22836. animate: function( prop, speed, easing, callback ) {
  22837. var empty = jQuery.isEmptyObject( prop ),
  22838. optall = jQuery.speed( speed, easing, callback ),
  22839. doAnimation = function() {
  22840. // Operate on a copy of prop so per-property easing won't be lost
  22841. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  22842. // Empty animations, or finishing resolves immediately
  22843. if ( empty || dataPriv.get( this, "finish" ) ) {
  22844. anim.stop( true );
  22845. }
  22846. };
  22847. doAnimation.finish = doAnimation;
  22848. return empty || optall.queue === false ?
  22849. this.each( doAnimation ) :
  22850. this.queue( optall.queue, doAnimation );
  22851. },
  22852. stop: function( type, clearQueue, gotoEnd ) {
  22853. var stopQueue = function( hooks ) {
  22854. var stop = hooks.stop;
  22855. delete hooks.stop;
  22856. stop( gotoEnd );
  22857. };
  22858. if ( typeof type !== "string" ) {
  22859. gotoEnd = clearQueue;
  22860. clearQueue = type;
  22861. type = undefined;
  22862. }
  22863. if ( clearQueue && type !== false ) {
  22864. this.queue( type || "fx", [] );
  22865. }
  22866. return this.each( function() {
  22867. var dequeue = true,
  22868. index = type != null && type + "queueHooks",
  22869. timers = jQuery.timers,
  22870. data = dataPriv.get( this );
  22871. if ( index ) {
  22872. if ( data[ index ] && data[ index ].stop ) {
  22873. stopQueue( data[ index ] );
  22874. }
  22875. } else {
  22876. for ( index in data ) {
  22877. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  22878. stopQueue( data[ index ] );
  22879. }
  22880. }
  22881. }
  22882. for ( index = timers.length; index--; ) {
  22883. if ( timers[ index ].elem === this &&
  22884. ( type == null || timers[ index ].queue === type ) ) {
  22885. timers[ index ].anim.stop( gotoEnd );
  22886. dequeue = false;
  22887. timers.splice( index, 1 );
  22888. }
  22889. }
  22890. // Start the next in the queue if the last step wasn't forced.
  22891. // Timers currently will call their complete callbacks, which
  22892. // will dequeue but only if they were gotoEnd.
  22893. if ( dequeue || !gotoEnd ) {
  22894. jQuery.dequeue( this, type );
  22895. }
  22896. } );
  22897. },
  22898. finish: function( type ) {
  22899. if ( type !== false ) {
  22900. type = type || "fx";
  22901. }
  22902. return this.each( function() {
  22903. var index,
  22904. data = dataPriv.get( this ),
  22905. queue = data[ type + "queue" ],
  22906. hooks = data[ type + "queueHooks" ],
  22907. timers = jQuery.timers,
  22908. length = queue ? queue.length : 0;
  22909. // Enable finishing flag on private data
  22910. data.finish = true;
  22911. // Empty the queue first
  22912. jQuery.queue( this, type, [] );
  22913. if ( hooks && hooks.stop ) {
  22914. hooks.stop.call( this, true );
  22915. }
  22916. // Look for any active animations, and finish them
  22917. for ( index = timers.length; index--; ) {
  22918. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  22919. timers[ index ].anim.stop( true );
  22920. timers.splice( index, 1 );
  22921. }
  22922. }
  22923. // Look for any animations in the old queue and finish them
  22924. for ( index = 0; index < length; index++ ) {
  22925. if ( queue[ index ] && queue[ index ].finish ) {
  22926. queue[ index ].finish.call( this );
  22927. }
  22928. }
  22929. // Turn off finishing flag
  22930. delete data.finish;
  22931. } );
  22932. }
  22933. } );
  22934. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  22935. var cssFn = jQuery.fn[ name ];
  22936. jQuery.fn[ name ] = function( speed, easing, callback ) {
  22937. return speed == null || typeof speed === "boolean" ?
  22938. cssFn.apply( this, arguments ) :
  22939. this.animate( genFx( name, true ), speed, easing, callback );
  22940. };
  22941. } );
  22942. // Generate shortcuts for custom animations
  22943. jQuery.each( {
  22944. slideDown: genFx( "show" ),
  22945. slideUp: genFx( "hide" ),
  22946. slideToggle: genFx( "toggle" ),
  22947. fadeIn: { opacity: "show" },
  22948. fadeOut: { opacity: "hide" },
  22949. fadeToggle: { opacity: "toggle" }
  22950. }, function( name, props ) {
  22951. jQuery.fn[ name ] = function( speed, easing, callback ) {
  22952. return this.animate( props, speed, easing, callback );
  22953. };
  22954. } );
  22955. jQuery.timers = [];
  22956. jQuery.fx.tick = function() {
  22957. var timer,
  22958. i = 0,
  22959. timers = jQuery.timers;
  22960. fxNow = jQuery.now();
  22961. for ( ; i < timers.length; i++ ) {
  22962. timer = timers[ i ];
  22963. // Run the timer and safely remove it when done (allowing for external removal)
  22964. if ( !timer() && timers[ i ] === timer ) {
  22965. timers.splice( i--, 1 );
  22966. }
  22967. }
  22968. if ( !timers.length ) {
  22969. jQuery.fx.stop();
  22970. }
  22971. fxNow = undefined;
  22972. };
  22973. jQuery.fx.timer = function( timer ) {
  22974. jQuery.timers.push( timer );
  22975. jQuery.fx.start();
  22976. };
  22977. jQuery.fx.interval = 13;
  22978. jQuery.fx.start = function() {
  22979. if ( inProgress ) {
  22980. return;
  22981. }
  22982. inProgress = true;
  22983. schedule();
  22984. };
  22985. jQuery.fx.stop = function() {
  22986. inProgress = null;
  22987. };
  22988. jQuery.fx.speeds = {
  22989. slow: 600,
  22990. fast: 200,
  22991. // Default speed
  22992. _default: 400
  22993. };
  22994. // Based off of the plugin by Clint Helfers, with permission.
  22995. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  22996. jQuery.fn.delay = function( time, type ) {
  22997. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  22998. type = type || "fx";
  22999. return this.queue( type, function( next, hooks ) {
  23000. var timeout = window.setTimeout( next, time );
  23001. hooks.stop = function() {
  23002. window.clearTimeout( timeout );
  23003. };
  23004. } );
  23005. };
  23006. ( function() {
  23007. var input = document.createElement( "input" ),
  23008. select = document.createElement( "select" ),
  23009. opt = select.appendChild( document.createElement( "option" ) );
  23010. input.type = "checkbox";
  23011. // Support: Android <=4.3 only
  23012. // Default value for a checkbox should be "on"
  23013. support.checkOn = input.value !== "";
  23014. // Support: IE <=11 only
  23015. // Must access selectedIndex to make default options select
  23016. support.optSelected = opt.selected;
  23017. // Support: IE <=11 only
  23018. // An input loses its value after becoming a radio
  23019. input = document.createElement( "input" );
  23020. input.value = "t";
  23021. input.type = "radio";
  23022. support.radioValue = input.value === "t";
  23023. } )();
  23024. var boolHook,
  23025. attrHandle = jQuery.expr.attrHandle;
  23026. jQuery.fn.extend( {
  23027. attr: function( name, value ) {
  23028. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  23029. },
  23030. removeAttr: function( name ) {
  23031. return this.each( function() {
  23032. jQuery.removeAttr( this, name );
  23033. } );
  23034. }
  23035. } );
  23036. jQuery.extend( {
  23037. attr: function( elem, name, value ) {
  23038. var ret, hooks,
  23039. nType = elem.nodeType;
  23040. // Don't get/set attributes on text, comment and attribute nodes
  23041. if ( nType === 3 || nType === 8 || nType === 2 ) {
  23042. return;
  23043. }
  23044. // Fallback to prop when attributes are not supported
  23045. if ( typeof elem.getAttribute === "undefined" ) {
  23046. return jQuery.prop( elem, name, value );
  23047. }
  23048. // Attribute hooks are determined by the lowercase version
  23049. // Grab necessary hook if one is defined
  23050. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  23051. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  23052. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  23053. }
  23054. if ( value !== undefined ) {
  23055. if ( value === null ) {
  23056. jQuery.removeAttr( elem, name );
  23057. return;
  23058. }
  23059. if ( hooks && "set" in hooks &&
  23060. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  23061. return ret;
  23062. }
  23063. elem.setAttribute( name, value + "" );
  23064. return value;
  23065. }
  23066. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  23067. return ret;
  23068. }
  23069. ret = jQuery.find.attr( elem, name );
  23070. // Non-existent attributes return null, we normalize to undefined
  23071. return ret == null ? undefined : ret;
  23072. },
  23073. attrHooks: {
  23074. type: {
  23075. set: function( elem, value ) {
  23076. if ( !support.radioValue && value === "radio" &&
  23077. nodeName( elem, "input" ) ) {
  23078. var val = elem.value;
  23079. elem.setAttribute( "type", value );
  23080. if ( val ) {
  23081. elem.value = val;
  23082. }
  23083. return value;
  23084. }
  23085. }
  23086. }
  23087. },
  23088. removeAttr: function( elem, value ) {
  23089. var name,
  23090. i = 0,
  23091. // Attribute names can contain non-HTML whitespace characters
  23092. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  23093. attrNames = value && value.match( rnothtmlwhite );
  23094. if ( attrNames && elem.nodeType === 1 ) {
  23095. while ( ( name = attrNames[ i++ ] ) ) {
  23096. elem.removeAttribute( name );
  23097. }
  23098. }
  23099. }
  23100. } );
  23101. // Hooks for boolean attributes
  23102. boolHook = {
  23103. set: function( elem, value, name ) {
  23104. if ( value === false ) {
  23105. // Remove boolean attributes when set to false
  23106. jQuery.removeAttr( elem, name );
  23107. } else {
  23108. elem.setAttribute( name, name );
  23109. }
  23110. return name;
  23111. }
  23112. };
  23113. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  23114. var getter = attrHandle[ name ] || jQuery.find.attr;
  23115. attrHandle[ name ] = function( elem, name, isXML ) {
  23116. var ret, handle,
  23117. lowercaseName = name.toLowerCase();
  23118. if ( !isXML ) {
  23119. // Avoid an infinite loop by temporarily removing this function from the getter
  23120. handle = attrHandle[ lowercaseName ];
  23121. attrHandle[ lowercaseName ] = ret;
  23122. ret = getter( elem, name, isXML ) != null ?
  23123. lowercaseName :
  23124. null;
  23125. attrHandle[ lowercaseName ] = handle;
  23126. }
  23127. return ret;
  23128. };
  23129. } );
  23130. var rfocusable = /^(?:input|select|textarea|button)$/i,
  23131. rclickable = /^(?:a|area)$/i;
  23132. jQuery.fn.extend( {
  23133. prop: function( name, value ) {
  23134. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  23135. },
  23136. removeProp: function( name ) {
  23137. return this.each( function() {
  23138. delete this[ jQuery.propFix[ name ] || name ];
  23139. } );
  23140. }
  23141. } );
  23142. jQuery.extend( {
  23143. prop: function( elem, name, value ) {
  23144. var ret, hooks,
  23145. nType = elem.nodeType;
  23146. // Don't get/set properties on text, comment and attribute nodes
  23147. if ( nType === 3 || nType === 8 || nType === 2 ) {
  23148. return;
  23149. }
  23150. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  23151. // Fix name and attach hooks
  23152. name = jQuery.propFix[ name ] || name;
  23153. hooks = jQuery.propHooks[ name ];
  23154. }
  23155. if ( value !== undefined ) {
  23156. if ( hooks && "set" in hooks &&
  23157. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  23158. return ret;
  23159. }
  23160. return ( elem[ name ] = value );
  23161. }
  23162. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  23163. return ret;
  23164. }
  23165. return elem[ name ];
  23166. },
  23167. propHooks: {
  23168. tabIndex: {
  23169. get: function( elem ) {
  23170. // Support: IE <=9 - 11 only
  23171. // elem.tabIndex doesn't always return the
  23172. // correct value when it hasn't been explicitly set
  23173. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  23174. // Use proper attribute retrieval(#12072)
  23175. var tabindex = jQuery.find.attr( elem, "tabindex" );
  23176. if ( tabindex ) {
  23177. return parseInt( tabindex, 10 );
  23178. }
  23179. if (
  23180. rfocusable.test( elem.nodeName ) ||
  23181. rclickable.test( elem.nodeName ) &&
  23182. elem.href
  23183. ) {
  23184. return 0;
  23185. }
  23186. return -1;
  23187. }
  23188. }
  23189. },
  23190. propFix: {
  23191. "for": "htmlFor",
  23192. "class": "className"
  23193. }
  23194. } );
  23195. // Support: IE <=11 only
  23196. // Accessing the selectedIndex property
  23197. // forces the browser to respect setting selected
  23198. // on the option
  23199. // The getter ensures a default option is selected
  23200. // when in an optgroup
  23201. // eslint rule "no-unused-expressions" is disabled for this code
  23202. // since it considers such accessions noop
  23203. if ( !support.optSelected ) {
  23204. jQuery.propHooks.selected = {
  23205. get: function( elem ) {
  23206. /* eslint no-unused-expressions: "off" */
  23207. var parent = elem.parentNode;
  23208. if ( parent && parent.parentNode ) {
  23209. parent.parentNode.selectedIndex;
  23210. }
  23211. return null;
  23212. },
  23213. set: function( elem ) {
  23214. /* eslint no-unused-expressions: "off" */
  23215. var parent = elem.parentNode;
  23216. if ( parent ) {
  23217. parent.selectedIndex;
  23218. if ( parent.parentNode ) {
  23219. parent.parentNode.selectedIndex;
  23220. }
  23221. }
  23222. }
  23223. };
  23224. }
  23225. jQuery.each( [
  23226. "tabIndex",
  23227. "readOnly",
  23228. "maxLength",
  23229. "cellSpacing",
  23230. "cellPadding",
  23231. "rowSpan",
  23232. "colSpan",
  23233. "useMap",
  23234. "frameBorder",
  23235. "contentEditable"
  23236. ], function() {
  23237. jQuery.propFix[ this.toLowerCase() ] = this;
  23238. } );
  23239. // Strip and collapse whitespace according to HTML spec
  23240. // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
  23241. function stripAndCollapse( value ) {
  23242. var tokens = value.match( rnothtmlwhite ) || [];
  23243. return tokens.join( " " );
  23244. }
  23245. function getClass( elem ) {
  23246. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  23247. }
  23248. jQuery.fn.extend( {
  23249. addClass: function( value ) {
  23250. var classes, elem, cur, curValue, clazz, j, finalValue,
  23251. i = 0;
  23252. if ( jQuery.isFunction( value ) ) {
  23253. return this.each( function( j ) {
  23254. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  23255. } );
  23256. }
  23257. if ( typeof value === "string" && value ) {
  23258. classes = value.match( rnothtmlwhite ) || [];
  23259. while ( ( elem = this[ i++ ] ) ) {
  23260. curValue = getClass( elem );
  23261. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  23262. if ( cur ) {
  23263. j = 0;
  23264. while ( ( clazz = classes[ j++ ] ) ) {
  23265. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  23266. cur += clazz + " ";
  23267. }
  23268. }
  23269. // Only assign if different to avoid unneeded rendering.
  23270. finalValue = stripAndCollapse( cur );
  23271. if ( curValue !== finalValue ) {
  23272. elem.setAttribute( "class", finalValue );
  23273. }
  23274. }
  23275. }
  23276. }
  23277. return this;
  23278. },
  23279. removeClass: function( value ) {
  23280. var classes, elem, cur, curValue, clazz, j, finalValue,
  23281. i = 0;
  23282. if ( jQuery.isFunction( value ) ) {
  23283. return this.each( function( j ) {
  23284. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  23285. } );
  23286. }
  23287. if ( !arguments.length ) {
  23288. return this.attr( "class", "" );
  23289. }
  23290. if ( typeof value === "string" && value ) {
  23291. classes = value.match( rnothtmlwhite ) || [];
  23292. while ( ( elem = this[ i++ ] ) ) {
  23293. curValue = getClass( elem );
  23294. // This expression is here for better compressibility (see addClass)
  23295. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  23296. if ( cur ) {
  23297. j = 0;
  23298. while ( ( clazz = classes[ j++ ] ) ) {
  23299. // Remove *all* instances
  23300. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  23301. cur = cur.replace( " " + clazz + " ", " " );
  23302. }
  23303. }
  23304. // Only assign if different to avoid unneeded rendering.
  23305. finalValue = stripAndCollapse( cur );
  23306. if ( curValue !== finalValue ) {
  23307. elem.setAttribute( "class", finalValue );
  23308. }
  23309. }
  23310. }
  23311. }
  23312. return this;
  23313. },
  23314. toggleClass: function( value, stateVal ) {
  23315. var type = typeof value;
  23316. if ( typeof stateVal === "boolean" && type === "string" ) {
  23317. return stateVal ? this.addClass( value ) : this.removeClass( value );
  23318. }
  23319. if ( jQuery.isFunction( value ) ) {
  23320. return this.each( function( i ) {
  23321. jQuery( this ).toggleClass(
  23322. value.call( this, i, getClass( this ), stateVal ),
  23323. stateVal
  23324. );
  23325. } );
  23326. }
  23327. return this.each( function() {
  23328. var className, i, self, classNames;
  23329. if ( type === "string" ) {
  23330. // Toggle individual class names
  23331. i = 0;
  23332. self = jQuery( this );
  23333. classNames = value.match( rnothtmlwhite ) || [];
  23334. while ( ( className = classNames[ i++ ] ) ) {
  23335. // Check each className given, space separated list
  23336. if ( self.hasClass( className ) ) {
  23337. self.removeClass( className );
  23338. } else {
  23339. self.addClass( className );
  23340. }
  23341. }
  23342. // Toggle whole class name
  23343. } else if ( value === undefined || type === "boolean" ) {
  23344. className = getClass( this );
  23345. if ( className ) {
  23346. // Store className if set
  23347. dataPriv.set( this, "__className__", className );
  23348. }
  23349. // If the element has a class name or if we're passed `false`,
  23350. // then remove the whole classname (if there was one, the above saved it).
  23351. // Otherwise bring back whatever was previously saved (if anything),
  23352. // falling back to the empty string if nothing was stored.
  23353. if ( this.setAttribute ) {
  23354. this.setAttribute( "class",
  23355. className || value === false ?
  23356. "" :
  23357. dataPriv.get( this, "__className__" ) || ""
  23358. );
  23359. }
  23360. }
  23361. } );
  23362. },
  23363. hasClass: function( selector ) {
  23364. var className, elem,
  23365. i = 0;
  23366. className = " " + selector + " ";
  23367. while ( ( elem = this[ i++ ] ) ) {
  23368. if ( elem.nodeType === 1 &&
  23369. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  23370. return true;
  23371. }
  23372. }
  23373. return false;
  23374. }
  23375. } );
  23376. var rreturn = /\r/g;
  23377. jQuery.fn.extend( {
  23378. val: function( value ) {
  23379. var hooks, ret, isFunction,
  23380. elem = this[ 0 ];
  23381. if ( !arguments.length ) {
  23382. if ( elem ) {
  23383. hooks = jQuery.valHooks[ elem.type ] ||
  23384. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  23385. if ( hooks &&
  23386. "get" in hooks &&
  23387. ( ret = hooks.get( elem, "value" ) ) !== undefined
  23388. ) {
  23389. return ret;
  23390. }
  23391. ret = elem.value;
  23392. // Handle most common string cases
  23393. if ( typeof ret === "string" ) {
  23394. return ret.replace( rreturn, "" );
  23395. }
  23396. // Handle cases where value is null/undef or number
  23397. return ret == null ? "" : ret;
  23398. }
  23399. return;
  23400. }
  23401. isFunction = jQuery.isFunction( value );
  23402. return this.each( function( i ) {
  23403. var val;
  23404. if ( this.nodeType !== 1 ) {
  23405. return;
  23406. }
  23407. if ( isFunction ) {
  23408. val = value.call( this, i, jQuery( this ).val() );
  23409. } else {
  23410. val = value;
  23411. }
  23412. // Treat null/undefined as ""; convert numbers to string
  23413. if ( val == null ) {
  23414. val = "";
  23415. } else if ( typeof val === "number" ) {
  23416. val += "";
  23417. } else if ( Array.isArray( val ) ) {
  23418. val = jQuery.map( val, function( value ) {
  23419. return value == null ? "" : value + "";
  23420. } );
  23421. }
  23422. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  23423. // If set returns undefined, fall back to normal setting
  23424. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  23425. this.value = val;
  23426. }
  23427. } );
  23428. }
  23429. } );
  23430. jQuery.extend( {
  23431. valHooks: {
  23432. option: {
  23433. get: function( elem ) {
  23434. var val = jQuery.find.attr( elem, "value" );
  23435. return val != null ?
  23436. val :
  23437. // Support: IE <=10 - 11 only
  23438. // option.text throws exceptions (#14686, #14858)
  23439. // Strip and collapse whitespace
  23440. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  23441. stripAndCollapse( jQuery.text( elem ) );
  23442. }
  23443. },
  23444. select: {
  23445. get: function( elem ) {
  23446. var value, option, i,
  23447. options = elem.options,
  23448. index = elem.selectedIndex,
  23449. one = elem.type === "select-one",
  23450. values = one ? null : [],
  23451. max = one ? index + 1 : options.length;
  23452. if ( index < 0 ) {
  23453. i = max;
  23454. } else {
  23455. i = one ? index : 0;
  23456. }
  23457. // Loop through all the selected options
  23458. for ( ; i < max; i++ ) {
  23459. option = options[ i ];
  23460. // Support: IE <=9 only
  23461. // IE8-9 doesn't update selected after form reset (#2551)
  23462. if ( ( option.selected || i === index ) &&
  23463. // Don't return options that are disabled or in a disabled optgroup
  23464. !option.disabled &&
  23465. ( !option.parentNode.disabled ||
  23466. !nodeName( option.parentNode, "optgroup" ) ) ) {
  23467. // Get the specific value for the option
  23468. value = jQuery( option ).val();
  23469. // We don't need an array for one selects
  23470. if ( one ) {
  23471. return value;
  23472. }
  23473. // Multi-Selects return an array
  23474. values.push( value );
  23475. }
  23476. }
  23477. return values;
  23478. },
  23479. set: function( elem, value ) {
  23480. var optionSet, option,
  23481. options = elem.options,
  23482. values = jQuery.makeArray( value ),
  23483. i = options.length;
  23484. while ( i-- ) {
  23485. option = options[ i ];
  23486. /* eslint-disable no-cond-assign */
  23487. if ( option.selected =
  23488. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  23489. ) {
  23490. optionSet = true;
  23491. }
  23492. /* eslint-enable no-cond-assign */
  23493. }
  23494. // Force browsers to behave consistently when non-matching value is set
  23495. if ( !optionSet ) {
  23496. elem.selectedIndex = -1;
  23497. }
  23498. return values;
  23499. }
  23500. }
  23501. }
  23502. } );
  23503. // Radios and checkboxes getter/setter
  23504. jQuery.each( [ "radio", "checkbox" ], function() {
  23505. jQuery.valHooks[ this ] = {
  23506. set: function( elem, value ) {
  23507. if ( Array.isArray( value ) ) {
  23508. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  23509. }
  23510. }
  23511. };
  23512. if ( !support.checkOn ) {
  23513. jQuery.valHooks[ this ].get = function( elem ) {
  23514. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  23515. };
  23516. }
  23517. } );
  23518. // Return jQuery for attributes-only inclusion
  23519. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
  23520. jQuery.extend( jQuery.event, {
  23521. trigger: function( event, data, elem, onlyHandlers ) {
  23522. var i, cur, tmp, bubbleType, ontype, handle, special,
  23523. eventPath = [ elem || document ],
  23524. type = hasOwn.call( event, "type" ) ? event.type : event,
  23525. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  23526. cur = tmp = elem = elem || document;
  23527. // Don't do events on text and comment nodes
  23528. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  23529. return;
  23530. }
  23531. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  23532. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  23533. return;
  23534. }
  23535. if ( type.indexOf( "." ) > -1 ) {
  23536. // Namespaced trigger; create a regexp to match event type in handle()
  23537. namespaces = type.split( "." );
  23538. type = namespaces.shift();
  23539. namespaces.sort();
  23540. }
  23541. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  23542. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  23543. event = event[ jQuery.expando ] ?
  23544. event :
  23545. new jQuery.Event( type, typeof event === "object" && event );
  23546. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  23547. event.isTrigger = onlyHandlers ? 2 : 3;
  23548. event.namespace = namespaces.join( "." );
  23549. event.rnamespace = event.namespace ?
  23550. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  23551. null;
  23552. // Clean up the event in case it is being reused
  23553. event.result = undefined;
  23554. if ( !event.target ) {
  23555. event.target = elem;
  23556. }
  23557. // Clone any incoming data and prepend the event, creating the handler arg list
  23558. data = data == null ?
  23559. [ event ] :
  23560. jQuery.makeArray( data, [ event ] );
  23561. // Allow special events to draw outside the lines
  23562. special = jQuery.event.special[ type ] || {};
  23563. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  23564. return;
  23565. }
  23566. // Determine event propagation path in advance, per W3C events spec (#9951)
  23567. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  23568. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  23569. bubbleType = special.delegateType || type;
  23570. if ( !rfocusMorph.test( bubbleType + type ) ) {
  23571. cur = cur.parentNode;
  23572. }
  23573. for ( ; cur; cur = cur.parentNode ) {
  23574. eventPath.push( cur );
  23575. tmp = cur;
  23576. }
  23577. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  23578. if ( tmp === ( elem.ownerDocument || document ) ) {
  23579. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  23580. }
  23581. }
  23582. // Fire handlers on the event path
  23583. i = 0;
  23584. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  23585. event.type = i > 1 ?
  23586. bubbleType :
  23587. special.bindType || type;
  23588. // jQuery handler
  23589. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  23590. dataPriv.get( cur, "handle" );
  23591. if ( handle ) {
  23592. handle.apply( cur, data );
  23593. }
  23594. // Native handler
  23595. handle = ontype && cur[ ontype ];
  23596. if ( handle && handle.apply && acceptData( cur ) ) {
  23597. event.result = handle.apply( cur, data );
  23598. if ( event.result === false ) {
  23599. event.preventDefault();
  23600. }
  23601. }
  23602. }
  23603. event.type = type;
  23604. // If nobody prevented the default action, do it now
  23605. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  23606. if ( ( !special._default ||
  23607. special._default.apply( eventPath.pop(), data ) === false ) &&
  23608. acceptData( elem ) ) {
  23609. // Call a native DOM method on the target with the same name as the event.
  23610. // Don't do default actions on window, that's where global variables be (#6170)
  23611. if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
  23612. // Don't re-trigger an onFOO event when we call its FOO() method
  23613. tmp = elem[ ontype ];
  23614. if ( tmp ) {
  23615. elem[ ontype ] = null;
  23616. }
  23617. // Prevent re-triggering of the same event, since we already bubbled it above
  23618. jQuery.event.triggered = type;
  23619. elem[ type ]();
  23620. jQuery.event.triggered = undefined;
  23621. if ( tmp ) {
  23622. elem[ ontype ] = tmp;
  23623. }
  23624. }
  23625. }
  23626. }
  23627. return event.result;
  23628. },
  23629. // Piggyback on a donor event to simulate a different one
  23630. // Used only for `focus(in | out)` events
  23631. simulate: function( type, elem, event ) {
  23632. var e = jQuery.extend(
  23633. new jQuery.Event(),
  23634. event,
  23635. {
  23636. type: type,
  23637. isSimulated: true
  23638. }
  23639. );
  23640. jQuery.event.trigger( e, null, elem );
  23641. }
  23642. } );
  23643. jQuery.fn.extend( {
  23644. trigger: function( type, data ) {
  23645. return this.each( function() {
  23646. jQuery.event.trigger( type, data, this );
  23647. } );
  23648. },
  23649. triggerHandler: function( type, data ) {
  23650. var elem = this[ 0 ];
  23651. if ( elem ) {
  23652. return jQuery.event.trigger( type, data, elem, true );
  23653. }
  23654. }
  23655. } );
  23656. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  23657. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  23658. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  23659. function( i, name ) {
  23660. // Handle event binding
  23661. jQuery.fn[ name ] = function( data, fn ) {
  23662. return arguments.length > 0 ?
  23663. this.on( name, null, data, fn ) :
  23664. this.trigger( name );
  23665. };
  23666. } );
  23667. jQuery.fn.extend( {
  23668. hover: function( fnOver, fnOut ) {
  23669. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  23670. }
  23671. } );
  23672. support.focusin = "onfocusin" in window;
  23673. // Support: Firefox <=44
  23674. // Firefox doesn't have focus(in | out) events
  23675. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  23676. //
  23677. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  23678. // focus(in | out) events fire after focus & blur events,
  23679. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  23680. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  23681. if ( !support.focusin ) {
  23682. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  23683. // Attach a single capturing handler on the document while someone wants focusin/focusout
  23684. var handler = function( event ) {
  23685. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  23686. };
  23687. jQuery.event.special[ fix ] = {
  23688. setup: function() {
  23689. var doc = this.ownerDocument || this,
  23690. attaches = dataPriv.access( doc, fix );
  23691. if ( !attaches ) {
  23692. doc.addEventListener( orig, handler, true );
  23693. }
  23694. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  23695. },
  23696. teardown: function() {
  23697. var doc = this.ownerDocument || this,
  23698. attaches = dataPriv.access( doc, fix ) - 1;
  23699. if ( !attaches ) {
  23700. doc.removeEventListener( orig, handler, true );
  23701. dataPriv.remove( doc, fix );
  23702. } else {
  23703. dataPriv.access( doc, fix, attaches );
  23704. }
  23705. }
  23706. };
  23707. } );
  23708. }
  23709. var location = window.location;
  23710. var nonce = jQuery.now();
  23711. var rquery = ( /\?/ );
  23712. // Cross-browser xml parsing
  23713. jQuery.parseXML = function( data ) {
  23714. var xml;
  23715. if ( !data || typeof data !== "string" ) {
  23716. return null;
  23717. }
  23718. // Support: IE 9 - 11 only
  23719. // IE throws on parseFromString with invalid input.
  23720. try {
  23721. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  23722. } catch ( e ) {
  23723. xml = undefined;
  23724. }
  23725. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  23726. jQuery.error( "Invalid XML: " + data );
  23727. }
  23728. return xml;
  23729. };
  23730. var
  23731. rbracket = /\[\]$/,
  23732. rCRLF = /\r?\n/g,
  23733. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  23734. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  23735. function buildParams( prefix, obj, traditional, add ) {
  23736. var name;
  23737. if ( Array.isArray( obj ) ) {
  23738. // Serialize array item.
  23739. jQuery.each( obj, function( i, v ) {
  23740. if ( traditional || rbracket.test( prefix ) ) {
  23741. // Treat each array item as a scalar.
  23742. add( prefix, v );
  23743. } else {
  23744. // Item is non-scalar (array or object), encode its numeric index.
  23745. buildParams(
  23746. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  23747. v,
  23748. traditional,
  23749. add
  23750. );
  23751. }
  23752. } );
  23753. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  23754. // Serialize object item.
  23755. for ( name in obj ) {
  23756. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  23757. }
  23758. } else {
  23759. // Serialize scalar item.
  23760. add( prefix, obj );
  23761. }
  23762. }
  23763. // Serialize an array of form elements or a set of
  23764. // key/values into a query string
  23765. jQuery.param = function( a, traditional ) {
  23766. var prefix,
  23767. s = [],
  23768. add = function( key, valueOrFunction ) {
  23769. // If value is a function, invoke it and use its return value
  23770. var value = jQuery.isFunction( valueOrFunction ) ?
  23771. valueOrFunction() :
  23772. valueOrFunction;
  23773. s[ s.length ] = encodeURIComponent( key ) + "=" +
  23774. encodeURIComponent( value == null ? "" : value );
  23775. };
  23776. // If an array was passed in, assume that it is an array of form elements.
  23777. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  23778. // Serialize the form elements
  23779. jQuery.each( a, function() {
  23780. add( this.name, this.value );
  23781. } );
  23782. } else {
  23783. // If traditional, encode the "old" way (the way 1.3.2 or older
  23784. // did it), otherwise encode params recursively.
  23785. for ( prefix in a ) {
  23786. buildParams( prefix, a[ prefix ], traditional, add );
  23787. }
  23788. }
  23789. // Return the resulting serialization
  23790. return s.join( "&" );
  23791. };
  23792. jQuery.fn.extend( {
  23793. serialize: function() {
  23794. return jQuery.param( this.serializeArray() );
  23795. },
  23796. serializeArray: function() {
  23797. return this.map( function() {
  23798. // Can add propHook for "elements" to filter or add form elements
  23799. var elements = jQuery.prop( this, "elements" );
  23800. return elements ? jQuery.makeArray( elements ) : this;
  23801. } )
  23802. .filter( function() {
  23803. var type = this.type;
  23804. // Use .is( ":disabled" ) so that fieldset[disabled] works
  23805. return this.name && !jQuery( this ).is( ":disabled" ) &&
  23806. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  23807. ( this.checked || !rcheckableType.test( type ) );
  23808. } )
  23809. .map( function( i, elem ) {
  23810. var val = jQuery( this ).val();
  23811. if ( val == null ) {
  23812. return null;
  23813. }
  23814. if ( Array.isArray( val ) ) {
  23815. return jQuery.map( val, function( val ) {
  23816. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  23817. } );
  23818. }
  23819. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  23820. } ).get();
  23821. }
  23822. } );
  23823. var
  23824. r20 = /%20/g,
  23825. rhash = /#.*$/,
  23826. rantiCache = /([?&])_=[^&]*/,
  23827. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  23828. // #7653, #8125, #8152: local protocol detection
  23829. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  23830. rnoContent = /^(?:GET|HEAD)$/,
  23831. rprotocol = /^\/\//,
  23832. /* Prefilters
  23833. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  23834. * 2) These are called:
  23835. * - BEFORE asking for a transport
  23836. * - AFTER param serialization (s.data is a string if s.processData is true)
  23837. * 3) key is the dataType
  23838. * 4) the catchall symbol "*" can be used
  23839. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  23840. */
  23841. prefilters = {},
  23842. /* Transports bindings
  23843. * 1) key is the dataType
  23844. * 2) the catchall symbol "*" can be used
  23845. * 3) selection will start with transport dataType and THEN go to "*" if needed
  23846. */
  23847. transports = {},
  23848. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  23849. allTypes = "*/".concat( "*" ),
  23850. // Anchor tag for parsing the document origin
  23851. originAnchor = document.createElement( "a" );
  23852. originAnchor.href = location.href;
  23853. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  23854. function addToPrefiltersOrTransports( structure ) {
  23855. // dataTypeExpression is optional and defaults to "*"
  23856. return function( dataTypeExpression, func ) {
  23857. if ( typeof dataTypeExpression !== "string" ) {
  23858. func = dataTypeExpression;
  23859. dataTypeExpression = "*";
  23860. }
  23861. var dataType,
  23862. i = 0,
  23863. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  23864. if ( jQuery.isFunction( func ) ) {
  23865. // For each dataType in the dataTypeExpression
  23866. while ( ( dataType = dataTypes[ i++ ] ) ) {
  23867. // Prepend if requested
  23868. if ( dataType[ 0 ] === "+" ) {
  23869. dataType = dataType.slice( 1 ) || "*";
  23870. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  23871. // Otherwise append
  23872. } else {
  23873. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  23874. }
  23875. }
  23876. }
  23877. };
  23878. }
  23879. // Base inspection function for prefilters and transports
  23880. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  23881. var inspected = {},
  23882. seekingTransport = ( structure === transports );
  23883. function inspect( dataType ) {
  23884. var selected;
  23885. inspected[ dataType ] = true;
  23886. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  23887. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  23888. if ( typeof dataTypeOrTransport === "string" &&
  23889. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  23890. options.dataTypes.unshift( dataTypeOrTransport );
  23891. inspect( dataTypeOrTransport );
  23892. return false;
  23893. } else if ( seekingTransport ) {
  23894. return !( selected = dataTypeOrTransport );
  23895. }
  23896. } );
  23897. return selected;
  23898. }
  23899. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  23900. }
  23901. // A special extend for ajax options
  23902. // that takes "flat" options (not to be deep extended)
  23903. // Fixes #9887
  23904. function ajaxExtend( target, src ) {
  23905. var key, deep,
  23906. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  23907. for ( key in src ) {
  23908. if ( src[ key ] !== undefined ) {
  23909. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  23910. }
  23911. }
  23912. if ( deep ) {
  23913. jQuery.extend( true, target, deep );
  23914. }
  23915. return target;
  23916. }
  23917. /* Handles responses to an ajax request:
  23918. * - finds the right dataType (mediates between content-type and expected dataType)
  23919. * - returns the corresponding response
  23920. */
  23921. function ajaxHandleResponses( s, jqXHR, responses ) {
  23922. var ct, type, finalDataType, firstDataType,
  23923. contents = s.contents,
  23924. dataTypes = s.dataTypes;
  23925. // Remove auto dataType and get content-type in the process
  23926. while ( dataTypes[ 0 ] === "*" ) {
  23927. dataTypes.shift();
  23928. if ( ct === undefined ) {
  23929. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  23930. }
  23931. }
  23932. // Check if we're dealing with a known content-type
  23933. if ( ct ) {
  23934. for ( type in contents ) {
  23935. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  23936. dataTypes.unshift( type );
  23937. break;
  23938. }
  23939. }
  23940. }
  23941. // Check to see if we have a response for the expected dataType
  23942. if ( dataTypes[ 0 ] in responses ) {
  23943. finalDataType = dataTypes[ 0 ];
  23944. } else {
  23945. // Try convertible dataTypes
  23946. for ( type in responses ) {
  23947. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  23948. finalDataType = type;
  23949. break;
  23950. }
  23951. if ( !firstDataType ) {
  23952. firstDataType = type;
  23953. }
  23954. }
  23955. // Or just use first one
  23956. finalDataType = finalDataType || firstDataType;
  23957. }
  23958. // If we found a dataType
  23959. // We add the dataType to the list if needed
  23960. // and return the corresponding response
  23961. if ( finalDataType ) {
  23962. if ( finalDataType !== dataTypes[ 0 ] ) {
  23963. dataTypes.unshift( finalDataType );
  23964. }
  23965. return responses[ finalDataType ];
  23966. }
  23967. }
  23968. /* Chain conversions given the request and the original response
  23969. * Also sets the responseXXX fields on the jqXHR instance
  23970. */
  23971. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  23972. var conv2, current, conv, tmp, prev,
  23973. converters = {},
  23974. // Work with a copy of dataTypes in case we need to modify it for conversion
  23975. dataTypes = s.dataTypes.slice();
  23976. // Create converters map with lowercased keys
  23977. if ( dataTypes[ 1 ] ) {
  23978. for ( conv in s.converters ) {
  23979. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  23980. }
  23981. }
  23982. current = dataTypes.shift();
  23983. // Convert to each sequential dataType
  23984. while ( current ) {
  23985. if ( s.responseFields[ current ] ) {
  23986. jqXHR[ s.responseFields[ current ] ] = response;
  23987. }
  23988. // Apply the dataFilter if provided
  23989. if ( !prev && isSuccess && s.dataFilter ) {
  23990. response = s.dataFilter( response, s.dataType );
  23991. }
  23992. prev = current;
  23993. current = dataTypes.shift();
  23994. if ( current ) {
  23995. // There's only work to do if current dataType is non-auto
  23996. if ( current === "*" ) {
  23997. current = prev;
  23998. // Convert response if prev dataType is non-auto and differs from current
  23999. } else if ( prev !== "*" && prev !== current ) {
  24000. // Seek a direct converter
  24001. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  24002. // If none found, seek a pair
  24003. if ( !conv ) {
  24004. for ( conv2 in converters ) {
  24005. // If conv2 outputs current
  24006. tmp = conv2.split( " " );
  24007. if ( tmp[ 1 ] === current ) {
  24008. // If prev can be converted to accepted input
  24009. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  24010. converters[ "* " + tmp[ 0 ] ];
  24011. if ( conv ) {
  24012. // Condense equivalence converters
  24013. if ( conv === true ) {
  24014. conv = converters[ conv2 ];
  24015. // Otherwise, insert the intermediate dataType
  24016. } else if ( converters[ conv2 ] !== true ) {
  24017. current = tmp[ 0 ];
  24018. dataTypes.unshift( tmp[ 1 ] );
  24019. }
  24020. break;
  24021. }
  24022. }
  24023. }
  24024. }
  24025. // Apply converter (if not an equivalence)
  24026. if ( conv !== true ) {
  24027. // Unless errors are allowed to bubble, catch and return them
  24028. if ( conv && s.throws ) {
  24029. response = conv( response );
  24030. } else {
  24031. try {
  24032. response = conv( response );
  24033. } catch ( e ) {
  24034. return {
  24035. state: "parsererror",
  24036. error: conv ? e : "No conversion from " + prev + " to " + current
  24037. };
  24038. }
  24039. }
  24040. }
  24041. }
  24042. }
  24043. }
  24044. return { state: "success", data: response };
  24045. }
  24046. jQuery.extend( {
  24047. // Counter for holding the number of active queries
  24048. active: 0,
  24049. // Last-Modified header cache for next request
  24050. lastModified: {},
  24051. etag: {},
  24052. ajaxSettings: {
  24053. url: location.href,
  24054. type: "GET",
  24055. isLocal: rlocalProtocol.test( location.protocol ),
  24056. global: true,
  24057. processData: true,
  24058. async: true,
  24059. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  24060. /*
  24061. timeout: 0,
  24062. data: null,
  24063. dataType: null,
  24064. username: null,
  24065. password: null,
  24066. cache: null,
  24067. throws: false,
  24068. traditional: false,
  24069. headers: {},
  24070. */
  24071. accepts: {
  24072. "*": allTypes,
  24073. text: "text/plain",
  24074. html: "text/html",
  24075. xml: "application/xml, text/xml",
  24076. json: "application/json, text/javascript"
  24077. },
  24078. contents: {
  24079. xml: /\bxml\b/,
  24080. html: /\bhtml/,
  24081. json: /\bjson\b/
  24082. },
  24083. responseFields: {
  24084. xml: "responseXML",
  24085. text: "responseText",
  24086. json: "responseJSON"
  24087. },
  24088. // Data converters
  24089. // Keys separate source (or catchall "*") and destination types with a single space
  24090. converters: {
  24091. // Convert anything to text
  24092. "* text": String,
  24093. // Text to html (true = no transformation)
  24094. "text html": true,
  24095. // Evaluate text as a json expression
  24096. "text json": JSON.parse,
  24097. // Parse text as xml
  24098. "text xml": jQuery.parseXML
  24099. },
  24100. // For options that shouldn't be deep extended:
  24101. // you can add your own custom options here if
  24102. // and when you create one that shouldn't be
  24103. // deep extended (see ajaxExtend)
  24104. flatOptions: {
  24105. url: true,
  24106. context: true
  24107. }
  24108. },
  24109. // Creates a full fledged settings object into target
  24110. // with both ajaxSettings and settings fields.
  24111. // If target is omitted, writes into ajaxSettings.
  24112. ajaxSetup: function( target, settings ) {
  24113. return settings ?
  24114. // Building a settings object
  24115. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  24116. // Extending ajaxSettings
  24117. ajaxExtend( jQuery.ajaxSettings, target );
  24118. },
  24119. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  24120. ajaxTransport: addToPrefiltersOrTransports( transports ),
  24121. // Main method
  24122. ajax: function( url, options ) {
  24123. // If url is an object, simulate pre-1.5 signature
  24124. if ( typeof url === "object" ) {
  24125. options = url;
  24126. url = undefined;
  24127. }
  24128. // Force options to be an object
  24129. options = options || {};
  24130. var transport,
  24131. // URL without anti-cache param
  24132. cacheURL,
  24133. // Response headers
  24134. responseHeadersString,
  24135. responseHeaders,
  24136. // timeout handle
  24137. timeoutTimer,
  24138. // Url cleanup var
  24139. urlAnchor,
  24140. // Request state (becomes false upon send and true upon completion)
  24141. completed,
  24142. // To know if global events are to be dispatched
  24143. fireGlobals,
  24144. // Loop variable
  24145. i,
  24146. // uncached part of the url
  24147. uncached,
  24148. // Create the final options object
  24149. s = jQuery.ajaxSetup( {}, options ),
  24150. // Callbacks context
  24151. callbackContext = s.context || s,
  24152. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  24153. globalEventContext = s.context &&
  24154. ( callbackContext.nodeType || callbackContext.jquery ) ?
  24155. jQuery( callbackContext ) :
  24156. jQuery.event,
  24157. // Deferreds
  24158. deferred = jQuery.Deferred(),
  24159. completeDeferred = jQuery.Callbacks( "once memory" ),
  24160. // Status-dependent callbacks
  24161. statusCode = s.statusCode || {},
  24162. // Headers (they are sent all at once)
  24163. requestHeaders = {},
  24164. requestHeadersNames = {},
  24165. // Default abort message
  24166. strAbort = "canceled",
  24167. // Fake xhr
  24168. jqXHR = {
  24169. readyState: 0,
  24170. // Builds headers hashtable if needed
  24171. getResponseHeader: function( key ) {
  24172. var match;
  24173. if ( completed ) {
  24174. if ( !responseHeaders ) {
  24175. responseHeaders = {};
  24176. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  24177. responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
  24178. }
  24179. }
  24180. match = responseHeaders[ key.toLowerCase() ];
  24181. }
  24182. return match == null ? null : match;
  24183. },
  24184. // Raw string
  24185. getAllResponseHeaders: function() {
  24186. return completed ? responseHeadersString : null;
  24187. },
  24188. // Caches the header
  24189. setRequestHeader: function( name, value ) {
  24190. if ( completed == null ) {
  24191. name = requestHeadersNames[ name.toLowerCase() ] =
  24192. requestHeadersNames[ name.toLowerCase() ] || name;
  24193. requestHeaders[ name ] = value;
  24194. }
  24195. return this;
  24196. },
  24197. // Overrides response content-type header
  24198. overrideMimeType: function( type ) {
  24199. if ( completed == null ) {
  24200. s.mimeType = type;
  24201. }
  24202. return this;
  24203. },
  24204. // Status-dependent callbacks
  24205. statusCode: function( map ) {
  24206. var code;
  24207. if ( map ) {
  24208. if ( completed ) {
  24209. // Execute the appropriate callbacks
  24210. jqXHR.always( map[ jqXHR.status ] );
  24211. } else {
  24212. // Lazy-add the new callbacks in a way that preserves old ones
  24213. for ( code in map ) {
  24214. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  24215. }
  24216. }
  24217. }
  24218. return this;
  24219. },
  24220. // Cancel the request
  24221. abort: function( statusText ) {
  24222. var finalText = statusText || strAbort;
  24223. if ( transport ) {
  24224. transport.abort( finalText );
  24225. }
  24226. done( 0, finalText );
  24227. return this;
  24228. }
  24229. };
  24230. // Attach deferreds
  24231. deferred.promise( jqXHR );
  24232. // Add protocol if not provided (prefilters might expect it)
  24233. // Handle falsy url in the settings object (#10093: consistency with old signature)
  24234. // We also use the url parameter if available
  24235. s.url = ( ( url || s.url || location.href ) + "" )
  24236. .replace( rprotocol, location.protocol + "//" );
  24237. // Alias method option to type as per ticket #12004
  24238. s.type = options.method || options.type || s.method || s.type;
  24239. // Extract dataTypes list
  24240. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  24241. // A cross-domain request is in order when the origin doesn't match the current origin.
  24242. if ( s.crossDomain == null ) {
  24243. urlAnchor = document.createElement( "a" );
  24244. // Support: IE <=8 - 11, Edge 12 - 13
  24245. // IE throws exception on accessing the href property if url is malformed,
  24246. // e.g. http://example.com:80x/
  24247. try {
  24248. urlAnchor.href = s.url;
  24249. // Support: IE <=8 - 11 only
  24250. // Anchor's host property isn't correctly set when s.url is relative
  24251. urlAnchor.href = urlAnchor.href;
  24252. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  24253. urlAnchor.protocol + "//" + urlAnchor.host;
  24254. } catch ( e ) {
  24255. // If there is an error parsing the URL, assume it is crossDomain,
  24256. // it can be rejected by the transport if it is invalid
  24257. s.crossDomain = true;
  24258. }
  24259. }
  24260. // Convert data if not already a string
  24261. if ( s.data && s.processData && typeof s.data !== "string" ) {
  24262. s.data = jQuery.param( s.data, s.traditional );
  24263. }
  24264. // Apply prefilters
  24265. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  24266. // If request was aborted inside a prefilter, stop there
  24267. if ( completed ) {
  24268. return jqXHR;
  24269. }
  24270. // We can fire global events as of now if asked to
  24271. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  24272. fireGlobals = jQuery.event && s.global;
  24273. // Watch for a new set of requests
  24274. if ( fireGlobals && jQuery.active++ === 0 ) {
  24275. jQuery.event.trigger( "ajaxStart" );
  24276. }
  24277. // Uppercase the type
  24278. s.type = s.type.toUpperCase();
  24279. // Determine if request has content
  24280. s.hasContent = !rnoContent.test( s.type );
  24281. // Save the URL in case we're toying with the If-Modified-Since
  24282. // and/or If-None-Match header later on
  24283. // Remove hash to simplify url manipulation
  24284. cacheURL = s.url.replace( rhash, "" );
  24285. // More options handling for requests with no content
  24286. if ( !s.hasContent ) {
  24287. // Remember the hash so we can put it back
  24288. uncached = s.url.slice( cacheURL.length );
  24289. // If data is available, append data to url
  24290. if ( s.data ) {
  24291. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  24292. // #9682: remove data so that it's not used in an eventual retry
  24293. delete s.data;
  24294. }
  24295. // Add or update anti-cache param if needed
  24296. if ( s.cache === false ) {
  24297. cacheURL = cacheURL.replace( rantiCache, "$1" );
  24298. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  24299. }
  24300. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  24301. s.url = cacheURL + uncached;
  24302. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  24303. } else if ( s.data && s.processData &&
  24304. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  24305. s.data = s.data.replace( r20, "+" );
  24306. }
  24307. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  24308. if ( s.ifModified ) {
  24309. if ( jQuery.lastModified[ cacheURL ] ) {
  24310. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  24311. }
  24312. if ( jQuery.etag[ cacheURL ] ) {
  24313. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  24314. }
  24315. }
  24316. // Set the correct header, if data is being sent
  24317. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  24318. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  24319. }
  24320. // Set the Accepts header for the server, depending on the dataType
  24321. jqXHR.setRequestHeader(
  24322. "Accept",
  24323. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  24324. s.accepts[ s.dataTypes[ 0 ] ] +
  24325. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  24326. s.accepts[ "*" ]
  24327. );
  24328. // Check for headers option
  24329. for ( i in s.headers ) {
  24330. jqXHR.setRequestHeader( i, s.headers[ i ] );
  24331. }
  24332. // Allow custom headers/mimetypes and early abort
  24333. if ( s.beforeSend &&
  24334. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  24335. // Abort if not done already and return
  24336. return jqXHR.abort();
  24337. }
  24338. // Aborting is no longer a cancellation
  24339. strAbort = "abort";
  24340. // Install callbacks on deferreds
  24341. completeDeferred.add( s.complete );
  24342. jqXHR.done( s.success );
  24343. jqXHR.fail( s.error );
  24344. // Get transport
  24345. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  24346. // If no transport, we auto-abort
  24347. if ( !transport ) {
  24348. done( -1, "No Transport" );
  24349. } else {
  24350. jqXHR.readyState = 1;
  24351. // Send global event
  24352. if ( fireGlobals ) {
  24353. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  24354. }
  24355. // If request was aborted inside ajaxSend, stop there
  24356. if ( completed ) {
  24357. return jqXHR;
  24358. }
  24359. // Timeout
  24360. if ( s.async && s.timeout > 0 ) {
  24361. timeoutTimer = window.setTimeout( function() {
  24362. jqXHR.abort( "timeout" );
  24363. }, s.timeout );
  24364. }
  24365. try {
  24366. completed = false;
  24367. transport.send( requestHeaders, done );
  24368. } catch ( e ) {
  24369. // Rethrow post-completion exceptions
  24370. if ( completed ) {
  24371. throw e;
  24372. }
  24373. // Propagate others as results
  24374. done( -1, e );
  24375. }
  24376. }
  24377. // Callback for when everything is done
  24378. function done( status, nativeStatusText, responses, headers ) {
  24379. var isSuccess, success, error, response, modified,
  24380. statusText = nativeStatusText;
  24381. // Ignore repeat invocations
  24382. if ( completed ) {
  24383. return;
  24384. }
  24385. completed = true;
  24386. // Clear timeout if it exists
  24387. if ( timeoutTimer ) {
  24388. window.clearTimeout( timeoutTimer );
  24389. }
  24390. // Dereference transport for early garbage collection
  24391. // (no matter how long the jqXHR object will be used)
  24392. transport = undefined;
  24393. // Cache response headers
  24394. responseHeadersString = headers || "";
  24395. // Set readyState
  24396. jqXHR.readyState = status > 0 ? 4 : 0;
  24397. // Determine if successful
  24398. isSuccess = status >= 200 && status < 300 || status === 304;
  24399. // Get response data
  24400. if ( responses ) {
  24401. response = ajaxHandleResponses( s, jqXHR, responses );
  24402. }
  24403. // Convert no matter what (that way responseXXX fields are always set)
  24404. response = ajaxConvert( s, response, jqXHR, isSuccess );
  24405. // If successful, handle type chaining
  24406. if ( isSuccess ) {
  24407. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  24408. if ( s.ifModified ) {
  24409. modified = jqXHR.getResponseHeader( "Last-Modified" );
  24410. if ( modified ) {
  24411. jQuery.lastModified[ cacheURL ] = modified;
  24412. }
  24413. modified = jqXHR.getResponseHeader( "etag" );
  24414. if ( modified ) {
  24415. jQuery.etag[ cacheURL ] = modified;
  24416. }
  24417. }
  24418. // if no content
  24419. if ( status === 204 || s.type === "HEAD" ) {
  24420. statusText = "nocontent";
  24421. // if not modified
  24422. } else if ( status === 304 ) {
  24423. statusText = "notmodified";
  24424. // If we have data, let's convert it
  24425. } else {
  24426. statusText = response.state;
  24427. success = response.data;
  24428. error = response.error;
  24429. isSuccess = !error;
  24430. }
  24431. } else {
  24432. // Extract error from statusText and normalize for non-aborts
  24433. error = statusText;
  24434. if ( status || !statusText ) {
  24435. statusText = "error";
  24436. if ( status < 0 ) {
  24437. status = 0;
  24438. }
  24439. }
  24440. }
  24441. // Set data for the fake xhr object
  24442. jqXHR.status = status;
  24443. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  24444. // Success/Error
  24445. if ( isSuccess ) {
  24446. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  24447. } else {
  24448. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  24449. }
  24450. // Status-dependent callbacks
  24451. jqXHR.statusCode( statusCode );
  24452. statusCode = undefined;
  24453. if ( fireGlobals ) {
  24454. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  24455. [ jqXHR, s, isSuccess ? success : error ] );
  24456. }
  24457. // Complete
  24458. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  24459. if ( fireGlobals ) {
  24460. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  24461. // Handle the global AJAX counter
  24462. if ( !( --jQuery.active ) ) {
  24463. jQuery.event.trigger( "ajaxStop" );
  24464. }
  24465. }
  24466. }
  24467. return jqXHR;
  24468. },
  24469. getJSON: function( url, data, callback ) {
  24470. return jQuery.get( url, data, callback, "json" );
  24471. },
  24472. getScript: function( url, callback ) {
  24473. return jQuery.get( url, undefined, callback, "script" );
  24474. }
  24475. } );
  24476. jQuery.each( [ "get", "post" ], function( i, method ) {
  24477. jQuery[ method ] = function( url, data, callback, type ) {
  24478. // Shift arguments if data argument was omitted
  24479. if ( jQuery.isFunction( data ) ) {
  24480. type = type || callback;
  24481. callback = data;
  24482. data = undefined;
  24483. }
  24484. // The url can be an options object (which then must have .url)
  24485. return jQuery.ajax( jQuery.extend( {
  24486. url: url,
  24487. type: method,
  24488. dataType: type,
  24489. data: data,
  24490. success: callback
  24491. }, jQuery.isPlainObject( url ) && url ) );
  24492. };
  24493. } );
  24494. jQuery._evalUrl = function( url ) {
  24495. return jQuery.ajax( {
  24496. url: url,
  24497. // Make this explicit, since user can override this through ajaxSetup (#11264)
  24498. type: "GET",
  24499. dataType: "script",
  24500. cache: true,
  24501. async: false,
  24502. global: false,
  24503. "throws": true
  24504. } );
  24505. };
  24506. jQuery.fn.extend( {
  24507. wrapAll: function( html ) {
  24508. var wrap;
  24509. if ( this[ 0 ] ) {
  24510. if ( jQuery.isFunction( html ) ) {
  24511. html = html.call( this[ 0 ] );
  24512. }
  24513. // The elements to wrap the target around
  24514. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  24515. if ( this[ 0 ].parentNode ) {
  24516. wrap.insertBefore( this[ 0 ] );
  24517. }
  24518. wrap.map( function() {
  24519. var elem = this;
  24520. while ( elem.firstElementChild ) {
  24521. elem = elem.firstElementChild;
  24522. }
  24523. return elem;
  24524. } ).append( this );
  24525. }
  24526. return this;
  24527. },
  24528. wrapInner: function( html ) {
  24529. if ( jQuery.isFunction( html ) ) {
  24530. return this.each( function( i ) {
  24531. jQuery( this ).wrapInner( html.call( this, i ) );
  24532. } );
  24533. }
  24534. return this.each( function() {
  24535. var self = jQuery( this ),
  24536. contents = self.contents();
  24537. if ( contents.length ) {
  24538. contents.wrapAll( html );
  24539. } else {
  24540. self.append( html );
  24541. }
  24542. } );
  24543. },
  24544. wrap: function( html ) {
  24545. var isFunction = jQuery.isFunction( html );
  24546. return this.each( function( i ) {
  24547. jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
  24548. } );
  24549. },
  24550. unwrap: function( selector ) {
  24551. this.parent( selector ).not( "body" ).each( function() {
  24552. jQuery( this ).replaceWith( this.childNodes );
  24553. } );
  24554. return this;
  24555. }
  24556. } );
  24557. jQuery.expr.pseudos.hidden = function( elem ) {
  24558. return !jQuery.expr.pseudos.visible( elem );
  24559. };
  24560. jQuery.expr.pseudos.visible = function( elem ) {
  24561. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  24562. };
  24563. jQuery.ajaxSettings.xhr = function() {
  24564. try {
  24565. return new window.XMLHttpRequest();
  24566. } catch ( e ) {}
  24567. };
  24568. var xhrSuccessStatus = {
  24569. // File protocol always yields status code 0, assume 200
  24570. 0: 200,
  24571. // Support: IE <=9 only
  24572. // #1450: sometimes IE returns 1223 when it should be 204
  24573. 1223: 204
  24574. },
  24575. xhrSupported = jQuery.ajaxSettings.xhr();
  24576. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  24577. support.ajax = xhrSupported = !!xhrSupported;
  24578. jQuery.ajaxTransport( function( options ) {
  24579. var callback, errorCallback;
  24580. // Cross domain only allowed if supported through XMLHttpRequest
  24581. if ( support.cors || xhrSupported && !options.crossDomain ) {
  24582. return {
  24583. send: function( headers, complete ) {
  24584. var i,
  24585. xhr = options.xhr();
  24586. xhr.open(
  24587. options.type,
  24588. options.url,
  24589. options.async,
  24590. options.username,
  24591. options.password
  24592. );
  24593. // Apply custom fields if provided
  24594. if ( options.xhrFields ) {
  24595. for ( i in options.xhrFields ) {
  24596. xhr[ i ] = options.xhrFields[ i ];
  24597. }
  24598. }
  24599. // Override mime type if needed
  24600. if ( options.mimeType && xhr.overrideMimeType ) {
  24601. xhr.overrideMimeType( options.mimeType );
  24602. }
  24603. // X-Requested-With header
  24604. // For cross-domain requests, seeing as conditions for a preflight are
  24605. // akin to a jigsaw puzzle, we simply never set it to be sure.
  24606. // (it can always be set on a per-request basis or even using ajaxSetup)
  24607. // For same-domain requests, won't change header if already provided.
  24608. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  24609. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  24610. }
  24611. // Set headers
  24612. for ( i in headers ) {
  24613. xhr.setRequestHeader( i, headers[ i ] );
  24614. }
  24615. // Callback
  24616. callback = function( type ) {
  24617. return function() {
  24618. if ( callback ) {
  24619. callback = errorCallback = xhr.onload =
  24620. xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
  24621. if ( type === "abort" ) {
  24622. xhr.abort();
  24623. } else if ( type === "error" ) {
  24624. // Support: IE <=9 only
  24625. // On a manual native abort, IE9 throws
  24626. // errors on any property access that is not readyState
  24627. if ( typeof xhr.status !== "number" ) {
  24628. complete( 0, "error" );
  24629. } else {
  24630. complete(
  24631. // File: protocol always yields status 0; see #8605, #14207
  24632. xhr.status,
  24633. xhr.statusText
  24634. );
  24635. }
  24636. } else {
  24637. complete(
  24638. xhrSuccessStatus[ xhr.status ] || xhr.status,
  24639. xhr.statusText,
  24640. // Support: IE <=9 only
  24641. // IE9 has no XHR2 but throws on binary (trac-11426)
  24642. // For XHR2 non-text, let the caller handle it (gh-2498)
  24643. ( xhr.responseType || "text" ) !== "text" ||
  24644. typeof xhr.responseText !== "string" ?
  24645. { binary: xhr.response } :
  24646. { text: xhr.responseText },
  24647. xhr.getAllResponseHeaders()
  24648. );
  24649. }
  24650. }
  24651. };
  24652. };
  24653. // Listen to events
  24654. xhr.onload = callback();
  24655. errorCallback = xhr.onerror = callback( "error" );
  24656. // Support: IE 9 only
  24657. // Use onreadystatechange to replace onabort
  24658. // to handle uncaught aborts
  24659. if ( xhr.onabort !== undefined ) {
  24660. xhr.onabort = errorCallback;
  24661. } else {
  24662. xhr.onreadystatechange = function() {
  24663. // Check readyState before timeout as it changes
  24664. if ( xhr.readyState === 4 ) {
  24665. // Allow onerror to be called first,
  24666. // but that will not handle a native abort
  24667. // Also, save errorCallback to a variable
  24668. // as xhr.onerror cannot be accessed
  24669. window.setTimeout( function() {
  24670. if ( callback ) {
  24671. errorCallback();
  24672. }
  24673. } );
  24674. }
  24675. };
  24676. }
  24677. // Create the abort callback
  24678. callback = callback( "abort" );
  24679. try {
  24680. // Do send the request (this may raise an exception)
  24681. xhr.send( options.hasContent && options.data || null );
  24682. } catch ( e ) {
  24683. // #14683: Only rethrow if this hasn't been notified as an error yet
  24684. if ( callback ) {
  24685. throw e;
  24686. }
  24687. }
  24688. },
  24689. abort: function() {
  24690. if ( callback ) {
  24691. callback();
  24692. }
  24693. }
  24694. };
  24695. }
  24696. } );
  24697. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  24698. jQuery.ajaxPrefilter( function( s ) {
  24699. if ( s.crossDomain ) {
  24700. s.contents.script = false;
  24701. }
  24702. } );
  24703. // Install script dataType
  24704. jQuery.ajaxSetup( {
  24705. accepts: {
  24706. script: "text/javascript, application/javascript, " +
  24707. "application/ecmascript, application/x-ecmascript"
  24708. },
  24709. contents: {
  24710. script: /\b(?:java|ecma)script\b/
  24711. },
  24712. converters: {
  24713. "text script": function( text ) {
  24714. jQuery.globalEval( text );
  24715. return text;
  24716. }
  24717. }
  24718. } );
  24719. // Handle cache's special case and crossDomain
  24720. jQuery.ajaxPrefilter( "script", function( s ) {
  24721. if ( s.cache === undefined ) {
  24722. s.cache = false;
  24723. }
  24724. if ( s.crossDomain ) {
  24725. s.type = "GET";
  24726. }
  24727. } );
  24728. // Bind script tag hack transport
  24729. jQuery.ajaxTransport( "script", function( s ) {
  24730. // This transport only deals with cross domain requests
  24731. if ( s.crossDomain ) {
  24732. var script, callback;
  24733. return {
  24734. send: function( _, complete ) {
  24735. script = jQuery( "<script>" ).prop( {
  24736. charset: s.scriptCharset,
  24737. src: s.url
  24738. } ).on(
  24739. "load error",
  24740. callback = function( evt ) {
  24741. script.remove();
  24742. callback = null;
  24743. if ( evt ) {
  24744. complete( evt.type === "error" ? 404 : 200, evt.type );
  24745. }
  24746. }
  24747. );
  24748. // Use native DOM manipulation to avoid our domManip AJAX trickery
  24749. document.head.appendChild( script[ 0 ] );
  24750. },
  24751. abort: function() {
  24752. if ( callback ) {
  24753. callback();
  24754. }
  24755. }
  24756. };
  24757. }
  24758. } );
  24759. var oldCallbacks = [],
  24760. rjsonp = /(=)\?(?=&|$)|\?\?/;
  24761. // Default jsonp settings
  24762. jQuery.ajaxSetup( {
  24763. jsonp: "callback",
  24764. jsonpCallback: function() {
  24765. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  24766. this[ callback ] = true;
  24767. return callback;
  24768. }
  24769. } );
  24770. // Detect, normalize options and install callbacks for jsonp requests
  24771. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  24772. var callbackName, overwritten, responseContainer,
  24773. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  24774. "url" :
  24775. typeof s.data === "string" &&
  24776. ( s.contentType || "" )
  24777. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  24778. rjsonp.test( s.data ) && "data"
  24779. );
  24780. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  24781. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  24782. // Get callback name, remembering preexisting value associated with it
  24783. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  24784. s.jsonpCallback() :
  24785. s.jsonpCallback;
  24786. // Insert callback into url or form data
  24787. if ( jsonProp ) {
  24788. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  24789. } else if ( s.jsonp !== false ) {
  24790. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  24791. }
  24792. // Use data converter to retrieve json after script execution
  24793. s.converters[ "script json" ] = function() {
  24794. if ( !responseContainer ) {
  24795. jQuery.error( callbackName + " was not called" );
  24796. }
  24797. return responseContainer[ 0 ];
  24798. };
  24799. // Force json dataType
  24800. s.dataTypes[ 0 ] = "json";
  24801. // Install callback
  24802. overwritten = window[ callbackName ];
  24803. window[ callbackName ] = function() {
  24804. responseContainer = arguments;
  24805. };
  24806. // Clean-up function (fires after converters)
  24807. jqXHR.always( function() {
  24808. // If previous value didn't exist - remove it
  24809. if ( overwritten === undefined ) {
  24810. jQuery( window ).removeProp( callbackName );
  24811. // Otherwise restore preexisting value
  24812. } else {
  24813. window[ callbackName ] = overwritten;
  24814. }
  24815. // Save back as free
  24816. if ( s[ callbackName ] ) {
  24817. // Make sure that re-using the options doesn't screw things around
  24818. s.jsonpCallback = originalSettings.jsonpCallback;
  24819. // Save the callback name for future use
  24820. oldCallbacks.push( callbackName );
  24821. }
  24822. // Call if it was a function and we have a response
  24823. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  24824. overwritten( responseContainer[ 0 ] );
  24825. }
  24826. responseContainer = overwritten = undefined;
  24827. } );
  24828. // Delegate to script
  24829. return "script";
  24830. }
  24831. } );
  24832. // Support: Safari 8 only
  24833. // In Safari 8 documents created via document.implementation.createHTMLDocument
  24834. // collapse sibling forms: the second one becomes a child of the first one.
  24835. // Because of that, this security measure has to be disabled in Safari 8.
  24836. // https://bugs.webkit.org/show_bug.cgi?id=137337
  24837. support.createHTMLDocument = ( function() {
  24838. var body = document.implementation.createHTMLDocument( "" ).body;
  24839. body.innerHTML = "<form></form><form></form>";
  24840. return body.childNodes.length === 2;
  24841. } )();
  24842. // Argument "data" should be string of html
  24843. // context (optional): If specified, the fragment will be created in this context,
  24844. // defaults to document
  24845. // keepScripts (optional): If true, will include scripts passed in the html string
  24846. jQuery.parseHTML = function( data, context, keepScripts ) {
  24847. if ( typeof data !== "string" ) {
  24848. return [];
  24849. }
  24850. if ( typeof context === "boolean" ) {
  24851. keepScripts = context;
  24852. context = false;
  24853. }
  24854. var base, parsed, scripts;
  24855. if ( !context ) {
  24856. // Stop scripts or inline event handlers from being executed immediately
  24857. // by using document.implementation
  24858. if ( support.createHTMLDocument ) {
  24859. context = document.implementation.createHTMLDocument( "" );
  24860. // Set the base href for the created document
  24861. // so any parsed elements with URLs
  24862. // are based on the document's URL (gh-2965)
  24863. base = context.createElement( "base" );
  24864. base.href = document.location.href;
  24865. context.head.appendChild( base );
  24866. } else {
  24867. context = document;
  24868. }
  24869. }
  24870. parsed = rsingleTag.exec( data );
  24871. scripts = !keepScripts && [];
  24872. // Single tag
  24873. if ( parsed ) {
  24874. return [ context.createElement( parsed[ 1 ] ) ];
  24875. }
  24876. parsed = buildFragment( [ data ], context, scripts );
  24877. if ( scripts && scripts.length ) {
  24878. jQuery( scripts ).remove();
  24879. }
  24880. return jQuery.merge( [], parsed.childNodes );
  24881. };
  24882. /**
  24883. * Load a url into a page
  24884. */
  24885. jQuery.fn.load = function( url, params, callback ) {
  24886. var selector, type, response,
  24887. self = this,
  24888. off = url.indexOf( " " );
  24889. if ( off > -1 ) {
  24890. selector = stripAndCollapse( url.slice( off ) );
  24891. url = url.slice( 0, off );
  24892. }
  24893. // If it's a function
  24894. if ( jQuery.isFunction( params ) ) {
  24895. // We assume that it's the callback
  24896. callback = params;
  24897. params = undefined;
  24898. // Otherwise, build a param string
  24899. } else if ( params && typeof params === "object" ) {
  24900. type = "POST";
  24901. }
  24902. // If we have elements to modify, make the request
  24903. if ( self.length > 0 ) {
  24904. jQuery.ajax( {
  24905. url: url,
  24906. // If "type" variable is undefined, then "GET" method will be used.
  24907. // Make value of this field explicit since
  24908. // user can override it through ajaxSetup method
  24909. type: type || "GET",
  24910. dataType: "html",
  24911. data: params
  24912. } ).done( function( responseText ) {
  24913. // Save response for use in complete callback
  24914. response = arguments;
  24915. self.html( selector ?
  24916. // If a selector was specified, locate the right elements in a dummy div
  24917. // Exclude scripts to avoid IE 'Permission Denied' errors
  24918. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  24919. // Otherwise use the full result
  24920. responseText );
  24921. // If the request succeeds, this function gets "data", "status", "jqXHR"
  24922. // but they are ignored because response was set above.
  24923. // If it fails, this function gets "jqXHR", "status", "error"
  24924. } ).always( callback && function( jqXHR, status ) {
  24925. self.each( function() {
  24926. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  24927. } );
  24928. } );
  24929. }
  24930. return this;
  24931. };
  24932. // Attach a bunch of functions for handling common AJAX events
  24933. jQuery.each( [
  24934. "ajaxStart",
  24935. "ajaxStop",
  24936. "ajaxComplete",
  24937. "ajaxError",
  24938. "ajaxSuccess",
  24939. "ajaxSend"
  24940. ], function( i, type ) {
  24941. jQuery.fn[ type ] = function( fn ) {
  24942. return this.on( type, fn );
  24943. };
  24944. } );
  24945. jQuery.expr.pseudos.animated = function( elem ) {
  24946. return jQuery.grep( jQuery.timers, function( fn ) {
  24947. return elem === fn.elem;
  24948. } ).length;
  24949. };
  24950. jQuery.offset = {
  24951. setOffset: function( elem, options, i ) {
  24952. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  24953. position = jQuery.css( elem, "position" ),
  24954. curElem = jQuery( elem ),
  24955. props = {};
  24956. // Set position first, in-case top/left are set even on static elem
  24957. if ( position === "static" ) {
  24958. elem.style.position = "relative";
  24959. }
  24960. curOffset = curElem.offset();
  24961. curCSSTop = jQuery.css( elem, "top" );
  24962. curCSSLeft = jQuery.css( elem, "left" );
  24963. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  24964. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  24965. // Need to be able to calculate position if either
  24966. // top or left is auto and position is either absolute or fixed
  24967. if ( calculatePosition ) {
  24968. curPosition = curElem.position();
  24969. curTop = curPosition.top;
  24970. curLeft = curPosition.left;
  24971. } else {
  24972. curTop = parseFloat( curCSSTop ) || 0;
  24973. curLeft = parseFloat( curCSSLeft ) || 0;
  24974. }
  24975. if ( jQuery.isFunction( options ) ) {
  24976. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  24977. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  24978. }
  24979. if ( options.top != null ) {
  24980. props.top = ( options.top - curOffset.top ) + curTop;
  24981. }
  24982. if ( options.left != null ) {
  24983. props.left = ( options.left - curOffset.left ) + curLeft;
  24984. }
  24985. if ( "using" in options ) {
  24986. options.using.call( elem, props );
  24987. } else {
  24988. curElem.css( props );
  24989. }
  24990. }
  24991. };
  24992. jQuery.fn.extend( {
  24993. offset: function( options ) {
  24994. // Preserve chaining for setter
  24995. if ( arguments.length ) {
  24996. return options === undefined ?
  24997. this :
  24998. this.each( function( i ) {
  24999. jQuery.offset.setOffset( this, options, i );
  25000. } );
  25001. }
  25002. var doc, docElem, rect, win,
  25003. elem = this[ 0 ];
  25004. if ( !elem ) {
  25005. return;
  25006. }
  25007. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  25008. // Support: IE <=11 only
  25009. // Running getBoundingClientRect on a
  25010. // disconnected node in IE throws an error
  25011. if ( !elem.getClientRects().length ) {
  25012. return { top: 0, left: 0 };
  25013. }
  25014. rect = elem.getBoundingClientRect();
  25015. doc = elem.ownerDocument;
  25016. docElem = doc.documentElement;
  25017. win = doc.defaultView;
  25018. return {
  25019. top: rect.top + win.pageYOffset - docElem.clientTop,
  25020. left: rect.left + win.pageXOffset - docElem.clientLeft
  25021. };
  25022. },
  25023. position: function() {
  25024. if ( !this[ 0 ] ) {
  25025. return;
  25026. }
  25027. var offsetParent, offset,
  25028. elem = this[ 0 ],
  25029. parentOffset = { top: 0, left: 0 };
  25030. // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
  25031. // because it is its only offset parent
  25032. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  25033. // Assume getBoundingClientRect is there when computed position is fixed
  25034. offset = elem.getBoundingClientRect();
  25035. } else {
  25036. // Get *real* offsetParent
  25037. offsetParent = this.offsetParent();
  25038. // Get correct offsets
  25039. offset = this.offset();
  25040. if ( !nodeName( offsetParent[ 0 ], "html" ) ) {
  25041. parentOffset = offsetParent.offset();
  25042. }
  25043. // Add offsetParent borders
  25044. parentOffset = {
  25045. top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ),
  25046. left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true )
  25047. };
  25048. }
  25049. // Subtract parent offsets and element margins
  25050. return {
  25051. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  25052. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  25053. };
  25054. },
  25055. // This method will return documentElement in the following cases:
  25056. // 1) For the element inside the iframe without offsetParent, this method will return
  25057. // documentElement of the parent window
  25058. // 2) For the hidden or detached element
  25059. // 3) For body or html element, i.e. in case of the html node - it will return itself
  25060. //
  25061. // but those exceptions were never presented as a real life use-cases
  25062. // and might be considered as more preferable results.
  25063. //
  25064. // This logic, however, is not guaranteed and can change at any point in the future
  25065. offsetParent: function() {
  25066. return this.map( function() {
  25067. var offsetParent = this.offsetParent;
  25068. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  25069. offsetParent = offsetParent.offsetParent;
  25070. }
  25071. return offsetParent || documentElement;
  25072. } );
  25073. }
  25074. } );
  25075. // Create scrollLeft and scrollTop methods
  25076. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  25077. var top = "pageYOffset" === prop;
  25078. jQuery.fn[ method ] = function( val ) {
  25079. return access( this, function( elem, method, val ) {
  25080. // Coalesce documents and windows
  25081. var win;
  25082. if ( jQuery.isWindow( elem ) ) {
  25083. win = elem;
  25084. } else if ( elem.nodeType === 9 ) {
  25085. win = elem.defaultView;
  25086. }
  25087. if ( val === undefined ) {
  25088. return win ? win[ prop ] : elem[ method ];
  25089. }
  25090. if ( win ) {
  25091. win.scrollTo(
  25092. !top ? val : win.pageXOffset,
  25093. top ? val : win.pageYOffset
  25094. );
  25095. } else {
  25096. elem[ method ] = val;
  25097. }
  25098. }, method, val, arguments.length );
  25099. };
  25100. } );
  25101. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  25102. // Add the top/left cssHooks using jQuery.fn.position
  25103. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  25104. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  25105. // getComputedStyle returns percent when specified for top/left/bottom/right;
  25106. // rather than make the css module depend on the offset module, just check for it here
  25107. jQuery.each( [ "top", "left" ], function( i, prop ) {
  25108. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  25109. function( elem, computed ) {
  25110. if ( computed ) {
  25111. computed = curCSS( elem, prop );
  25112. // If curCSS returns percentage, fallback to offset
  25113. return rnumnonpx.test( computed ) ?
  25114. jQuery( elem ).position()[ prop ] + "px" :
  25115. computed;
  25116. }
  25117. }
  25118. );
  25119. } );
  25120. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  25121. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  25122. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  25123. function( defaultExtra, funcName ) {
  25124. // Margin is only for outerHeight, outerWidth
  25125. jQuery.fn[ funcName ] = function( margin, value ) {
  25126. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  25127. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  25128. return access( this, function( elem, type, value ) {
  25129. var doc;
  25130. if ( jQuery.isWindow( elem ) ) {
  25131. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  25132. return funcName.indexOf( "outer" ) === 0 ?
  25133. elem[ "inner" + name ] :
  25134. elem.document.documentElement[ "client" + name ];
  25135. }
  25136. // Get document width or height
  25137. if ( elem.nodeType === 9 ) {
  25138. doc = elem.documentElement;
  25139. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  25140. // whichever is greatest
  25141. return Math.max(
  25142. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  25143. elem.body[ "offset" + name ], doc[ "offset" + name ],
  25144. doc[ "client" + name ]
  25145. );
  25146. }
  25147. return value === undefined ?
  25148. // Get width or height on the element, requesting but not forcing parseFloat
  25149. jQuery.css( elem, type, extra ) :
  25150. // Set width or height on the element
  25151. jQuery.style( elem, type, value, extra );
  25152. }, type, chainable ? margin : undefined, chainable );
  25153. };
  25154. } );
  25155. } );
  25156. jQuery.fn.extend( {
  25157. bind: function( types, data, fn ) {
  25158. return this.on( types, null, data, fn );
  25159. },
  25160. unbind: function( types, fn ) {
  25161. return this.off( types, null, fn );
  25162. },
  25163. delegate: function( selector, types, data, fn ) {
  25164. return this.on( types, selector, data, fn );
  25165. },
  25166. undelegate: function( selector, types, fn ) {
  25167. // ( namespace ) or ( selector, types [, fn] )
  25168. return arguments.length === 1 ?
  25169. this.off( selector, "**" ) :
  25170. this.off( types, selector || "**", fn );
  25171. }
  25172. } );
  25173. jQuery.holdReady = function( hold ) {
  25174. if ( hold ) {
  25175. jQuery.readyWait++;
  25176. } else {
  25177. jQuery.ready( true );
  25178. }
  25179. };
  25180. jQuery.isArray = Array.isArray;
  25181. jQuery.parseJSON = JSON.parse;
  25182. jQuery.nodeName = nodeName;
  25183. // Register as a named AMD module, since jQuery can be concatenated with other
  25184. // files that may use define, but not via a proper concatenation script that
  25185. // understands anonymous AMD modules. A named AMD is safest and most robust
  25186. // way to register. Lowercase jquery is used because AMD module names are
  25187. // derived from file names, and jQuery is normally delivered in a lowercase
  25188. // file name. Do this after creating the global so that if an AMD module wants
  25189. // to call noConflict to hide this version of jQuery, it will work.
  25190. // Note that for maximum portability, libraries that are not jQuery should
  25191. // declare themselves as anonymous modules, and avoid setting a global if an
  25192. // AMD loader is present. jQuery is a special case. For more information, see
  25193. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  25194. if ( true ) {
  25195. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
  25196. return jQuery;
  25197. }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  25198. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  25199. }
  25200. var
  25201. // Map over jQuery in case of overwrite
  25202. _jQuery = window.jQuery,
  25203. // Map over the $ in case of overwrite
  25204. _$ = window.$;
  25205. jQuery.noConflict = function( deep ) {
  25206. if ( window.$ === jQuery ) {
  25207. window.$ = _$;
  25208. }
  25209. if ( deep && window.jQuery === jQuery ) {
  25210. window.jQuery = _jQuery;
  25211. }
  25212. return jQuery;
  25213. };
  25214. // Expose jQuery and $ identifiers, even in AMD
  25215. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  25216. // and CommonJS for browser emulators (#13566)
  25217. if ( !noGlobal ) {
  25218. window.jQuery = window.$ = jQuery;
  25219. }
  25220. return jQuery;
  25221. } );
  25222. /***/ }),
  25223. /* 15 */
  25224. /***/ (function(module, exports) {
  25225. /*!
  25226. * Bootstrap v3.3.7 (http://getbootstrap.com)
  25227. * Copyright 2011-2016 Twitter, Inc.
  25228. * Licensed under the MIT license
  25229. */
  25230. if (typeof jQuery === 'undefined') {
  25231. throw new Error('Bootstrap\'s JavaScript requires jQuery')
  25232. }
  25233. +function ($) {
  25234. 'use strict';
  25235. var version = $.fn.jquery.split(' ')[0].split('.')
  25236. if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 3)) {
  25237. throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4')
  25238. }
  25239. }(jQuery);
  25240. /* ========================================================================
  25241. * Bootstrap: transition.js v3.3.7
  25242. * http://getbootstrap.com/javascript/#transitions
  25243. * ========================================================================
  25244. * Copyright 2011-2016 Twitter, Inc.
  25245. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25246. * ======================================================================== */
  25247. +function ($) {
  25248. 'use strict';
  25249. // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  25250. // ============================================================
  25251. function transitionEnd() {
  25252. var el = document.createElement('bootstrap')
  25253. var transEndEventNames = {
  25254. WebkitTransition : 'webkitTransitionEnd',
  25255. MozTransition : 'transitionend',
  25256. OTransition : 'oTransitionEnd otransitionend',
  25257. transition : 'transitionend'
  25258. }
  25259. for (var name in transEndEventNames) {
  25260. if (el.style[name] !== undefined) {
  25261. return { end: transEndEventNames[name] }
  25262. }
  25263. }
  25264. return false // explicit for ie8 ( ._.)
  25265. }
  25266. // http://blog.alexmaccaw.com/css-transitions
  25267. $.fn.emulateTransitionEnd = function (duration) {
  25268. var called = false
  25269. var $el = this
  25270. $(this).one('bsTransitionEnd', function () { called = true })
  25271. var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
  25272. setTimeout(callback, duration)
  25273. return this
  25274. }
  25275. $(function () {
  25276. $.support.transition = transitionEnd()
  25277. if (!$.support.transition) return
  25278. $.event.special.bsTransitionEnd = {
  25279. bindType: $.support.transition.end,
  25280. delegateType: $.support.transition.end,
  25281. handle: function (e) {
  25282. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
  25283. }
  25284. }
  25285. })
  25286. }(jQuery);
  25287. /* ========================================================================
  25288. * Bootstrap: alert.js v3.3.7
  25289. * http://getbootstrap.com/javascript/#alerts
  25290. * ========================================================================
  25291. * Copyright 2011-2016 Twitter, Inc.
  25292. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25293. * ======================================================================== */
  25294. +function ($) {
  25295. 'use strict';
  25296. // ALERT CLASS DEFINITION
  25297. // ======================
  25298. var dismiss = '[data-dismiss="alert"]'
  25299. var Alert = function (el) {
  25300. $(el).on('click', dismiss, this.close)
  25301. }
  25302. Alert.VERSION = '3.3.7'
  25303. Alert.TRANSITION_DURATION = 150
  25304. Alert.prototype.close = function (e) {
  25305. var $this = $(this)
  25306. var selector = $this.attr('data-target')
  25307. if (!selector) {
  25308. selector = $this.attr('href')
  25309. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  25310. }
  25311. var $parent = $(selector === '#' ? [] : selector)
  25312. if (e) e.preventDefault()
  25313. if (!$parent.length) {
  25314. $parent = $this.closest('.alert')
  25315. }
  25316. $parent.trigger(e = $.Event('close.bs.alert'))
  25317. if (e.isDefaultPrevented()) return
  25318. $parent.removeClass('in')
  25319. function removeElement() {
  25320. // detach from parent, fire event then clean up data
  25321. $parent.detach().trigger('closed.bs.alert').remove()
  25322. }
  25323. $.support.transition && $parent.hasClass('fade') ?
  25324. $parent
  25325. .one('bsTransitionEnd', removeElement)
  25326. .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
  25327. removeElement()
  25328. }
  25329. // ALERT PLUGIN DEFINITION
  25330. // =======================
  25331. function Plugin(option) {
  25332. return this.each(function () {
  25333. var $this = $(this)
  25334. var data = $this.data('bs.alert')
  25335. if (!data) $this.data('bs.alert', (data = new Alert(this)))
  25336. if (typeof option == 'string') data[option].call($this)
  25337. })
  25338. }
  25339. var old = $.fn.alert
  25340. $.fn.alert = Plugin
  25341. $.fn.alert.Constructor = Alert
  25342. // ALERT NO CONFLICT
  25343. // =================
  25344. $.fn.alert.noConflict = function () {
  25345. $.fn.alert = old
  25346. return this
  25347. }
  25348. // ALERT DATA-API
  25349. // ==============
  25350. $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
  25351. }(jQuery);
  25352. /* ========================================================================
  25353. * Bootstrap: button.js v3.3.7
  25354. * http://getbootstrap.com/javascript/#buttons
  25355. * ========================================================================
  25356. * Copyright 2011-2016 Twitter, Inc.
  25357. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25358. * ======================================================================== */
  25359. +function ($) {
  25360. 'use strict';
  25361. // BUTTON PUBLIC CLASS DEFINITION
  25362. // ==============================
  25363. var Button = function (element, options) {
  25364. this.$element = $(element)
  25365. this.options = $.extend({}, Button.DEFAULTS, options)
  25366. this.isLoading = false
  25367. }
  25368. Button.VERSION = '3.3.7'
  25369. Button.DEFAULTS = {
  25370. loadingText: 'loading...'
  25371. }
  25372. Button.prototype.setState = function (state) {
  25373. var d = 'disabled'
  25374. var $el = this.$element
  25375. var val = $el.is('input') ? 'val' : 'html'
  25376. var data = $el.data()
  25377. state += 'Text'
  25378. if (data.resetText == null) $el.data('resetText', $el[val]())
  25379. // push to event loop to allow forms to submit
  25380. setTimeout($.proxy(function () {
  25381. $el[val](data[state] == null ? this.options[state] : data[state])
  25382. if (state == 'loadingText') {
  25383. this.isLoading = true
  25384. $el.addClass(d).attr(d, d).prop(d, true)
  25385. } else if (this.isLoading) {
  25386. this.isLoading = false
  25387. $el.removeClass(d).removeAttr(d).prop(d, false)
  25388. }
  25389. }, this), 0)
  25390. }
  25391. Button.prototype.toggle = function () {
  25392. var changed = true
  25393. var $parent = this.$element.closest('[data-toggle="buttons"]')
  25394. if ($parent.length) {
  25395. var $input = this.$element.find('input')
  25396. if ($input.prop('type') == 'radio') {
  25397. if ($input.prop('checked')) changed = false
  25398. $parent.find('.active').removeClass('active')
  25399. this.$element.addClass('active')
  25400. } else if ($input.prop('type') == 'checkbox') {
  25401. if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
  25402. this.$element.toggleClass('active')
  25403. }
  25404. $input.prop('checked', this.$element.hasClass('active'))
  25405. if (changed) $input.trigger('change')
  25406. } else {
  25407. this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
  25408. this.$element.toggleClass('active')
  25409. }
  25410. }
  25411. // BUTTON PLUGIN DEFINITION
  25412. // ========================
  25413. function Plugin(option) {
  25414. return this.each(function () {
  25415. var $this = $(this)
  25416. var data = $this.data('bs.button')
  25417. var options = typeof option == 'object' && option
  25418. if (!data) $this.data('bs.button', (data = new Button(this, options)))
  25419. if (option == 'toggle') data.toggle()
  25420. else if (option) data.setState(option)
  25421. })
  25422. }
  25423. var old = $.fn.button
  25424. $.fn.button = Plugin
  25425. $.fn.button.Constructor = Button
  25426. // BUTTON NO CONFLICT
  25427. // ==================
  25428. $.fn.button.noConflict = function () {
  25429. $.fn.button = old
  25430. return this
  25431. }
  25432. // BUTTON DATA-API
  25433. // ===============
  25434. $(document)
  25435. .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
  25436. var $btn = $(e.target).closest('.btn')
  25437. Plugin.call($btn, 'toggle')
  25438. if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) {
  25439. // Prevent double click on radios, and the double selections (so cancellation) on checkboxes
  25440. e.preventDefault()
  25441. // The target component still receive the focus
  25442. if ($btn.is('input,button')) $btn.trigger('focus')
  25443. else $btn.find('input:visible,button:visible').first().trigger('focus')
  25444. }
  25445. })
  25446. .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
  25447. $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
  25448. })
  25449. }(jQuery);
  25450. /* ========================================================================
  25451. * Bootstrap: carousel.js v3.3.7
  25452. * http://getbootstrap.com/javascript/#carousel
  25453. * ========================================================================
  25454. * Copyright 2011-2016 Twitter, Inc.
  25455. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25456. * ======================================================================== */
  25457. +function ($) {
  25458. 'use strict';
  25459. // CAROUSEL CLASS DEFINITION
  25460. // =========================
  25461. var Carousel = function (element, options) {
  25462. this.$element = $(element)
  25463. this.$indicators = this.$element.find('.carousel-indicators')
  25464. this.options = options
  25465. this.paused = null
  25466. this.sliding = null
  25467. this.interval = null
  25468. this.$active = null
  25469. this.$items = null
  25470. this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
  25471. this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
  25472. .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
  25473. .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
  25474. }
  25475. Carousel.VERSION = '3.3.7'
  25476. Carousel.TRANSITION_DURATION = 600
  25477. Carousel.DEFAULTS = {
  25478. interval: 5000,
  25479. pause: 'hover',
  25480. wrap: true,
  25481. keyboard: true
  25482. }
  25483. Carousel.prototype.keydown = function (e) {
  25484. if (/input|textarea/i.test(e.target.tagName)) return
  25485. switch (e.which) {
  25486. case 37: this.prev(); break
  25487. case 39: this.next(); break
  25488. default: return
  25489. }
  25490. e.preventDefault()
  25491. }
  25492. Carousel.prototype.cycle = function (e) {
  25493. e || (this.paused = false)
  25494. this.interval && clearInterval(this.interval)
  25495. this.options.interval
  25496. && !this.paused
  25497. && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
  25498. return this
  25499. }
  25500. Carousel.prototype.getItemIndex = function (item) {
  25501. this.$items = item.parent().children('.item')
  25502. return this.$items.index(item || this.$active)
  25503. }
  25504. Carousel.prototype.getItemForDirection = function (direction, active) {
  25505. var activeIndex = this.getItemIndex(active)
  25506. var willWrap = (direction == 'prev' && activeIndex === 0)
  25507. || (direction == 'next' && activeIndex == (this.$items.length - 1))
  25508. if (willWrap && !this.options.wrap) return active
  25509. var delta = direction == 'prev' ? -1 : 1
  25510. var itemIndex = (activeIndex + delta) % this.$items.length
  25511. return this.$items.eq(itemIndex)
  25512. }
  25513. Carousel.prototype.to = function (pos) {
  25514. var that = this
  25515. var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
  25516. if (pos > (this.$items.length - 1) || pos < 0) return
  25517. if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
  25518. if (activeIndex == pos) return this.pause().cycle()
  25519. return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos))
  25520. }
  25521. Carousel.prototype.pause = function (e) {
  25522. e || (this.paused = true)
  25523. if (this.$element.find('.next, .prev').length && $.support.transition) {
  25524. this.$element.trigger($.support.transition.end)
  25525. this.cycle(true)
  25526. }
  25527. this.interval = clearInterval(this.interval)
  25528. return this
  25529. }
  25530. Carousel.prototype.next = function () {
  25531. if (this.sliding) return
  25532. return this.slide('next')
  25533. }
  25534. Carousel.prototype.prev = function () {
  25535. if (this.sliding) return
  25536. return this.slide('prev')
  25537. }
  25538. Carousel.prototype.slide = function (type, next) {
  25539. var $active = this.$element.find('.item.active')
  25540. var $next = next || this.getItemForDirection(type, $active)
  25541. var isCycling = this.interval
  25542. var direction = type == 'next' ? 'left' : 'right'
  25543. var that = this
  25544. if ($next.hasClass('active')) return (this.sliding = false)
  25545. var relatedTarget = $next[0]
  25546. var slideEvent = $.Event('slide.bs.carousel', {
  25547. relatedTarget: relatedTarget,
  25548. direction: direction
  25549. })
  25550. this.$element.trigger(slideEvent)
  25551. if (slideEvent.isDefaultPrevented()) return
  25552. this.sliding = true
  25553. isCycling && this.pause()
  25554. if (this.$indicators.length) {
  25555. this.$indicators.find('.active').removeClass('active')
  25556. var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
  25557. $nextIndicator && $nextIndicator.addClass('active')
  25558. }
  25559. var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
  25560. if ($.support.transition && this.$element.hasClass('slide')) {
  25561. $next.addClass(type)
  25562. $next[0].offsetWidth // force reflow
  25563. $active.addClass(direction)
  25564. $next.addClass(direction)
  25565. $active
  25566. .one('bsTransitionEnd', function () {
  25567. $next.removeClass([type, direction].join(' ')).addClass('active')
  25568. $active.removeClass(['active', direction].join(' '))
  25569. that.sliding = false
  25570. setTimeout(function () {
  25571. that.$element.trigger(slidEvent)
  25572. }, 0)
  25573. })
  25574. .emulateTransitionEnd(Carousel.TRANSITION_DURATION)
  25575. } else {
  25576. $active.removeClass('active')
  25577. $next.addClass('active')
  25578. this.sliding = false
  25579. this.$element.trigger(slidEvent)
  25580. }
  25581. isCycling && this.cycle()
  25582. return this
  25583. }
  25584. // CAROUSEL PLUGIN DEFINITION
  25585. // ==========================
  25586. function Plugin(option) {
  25587. return this.each(function () {
  25588. var $this = $(this)
  25589. var data = $this.data('bs.carousel')
  25590. var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
  25591. var action = typeof option == 'string' ? option : options.slide
  25592. if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
  25593. if (typeof option == 'number') data.to(option)
  25594. else if (action) data[action]()
  25595. else if (options.interval) data.pause().cycle()
  25596. })
  25597. }
  25598. var old = $.fn.carousel
  25599. $.fn.carousel = Plugin
  25600. $.fn.carousel.Constructor = Carousel
  25601. // CAROUSEL NO CONFLICT
  25602. // ====================
  25603. $.fn.carousel.noConflict = function () {
  25604. $.fn.carousel = old
  25605. return this
  25606. }
  25607. // CAROUSEL DATA-API
  25608. // =================
  25609. var clickHandler = function (e) {
  25610. var href
  25611. var $this = $(this)
  25612. var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
  25613. if (!$target.hasClass('carousel')) return
  25614. var options = $.extend({}, $target.data(), $this.data())
  25615. var slideIndex = $this.attr('data-slide-to')
  25616. if (slideIndex) options.interval = false
  25617. Plugin.call($target, options)
  25618. if (slideIndex) {
  25619. $target.data('bs.carousel').to(slideIndex)
  25620. }
  25621. e.preventDefault()
  25622. }
  25623. $(document)
  25624. .on('click.bs.carousel.data-api', '[data-slide]', clickHandler)
  25625. .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)
  25626. $(window).on('load', function () {
  25627. $('[data-ride="carousel"]').each(function () {
  25628. var $carousel = $(this)
  25629. Plugin.call($carousel, $carousel.data())
  25630. })
  25631. })
  25632. }(jQuery);
  25633. /* ========================================================================
  25634. * Bootstrap: collapse.js v3.3.7
  25635. * http://getbootstrap.com/javascript/#collapse
  25636. * ========================================================================
  25637. * Copyright 2011-2016 Twitter, Inc.
  25638. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25639. * ======================================================================== */
  25640. /* jshint latedef: false */
  25641. +function ($) {
  25642. 'use strict';
  25643. // COLLAPSE PUBLIC CLASS DEFINITION
  25644. // ================================
  25645. var Collapse = function (element, options) {
  25646. this.$element = $(element)
  25647. this.options = $.extend({}, Collapse.DEFAULTS, options)
  25648. this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
  25649. '[data-toggle="collapse"][data-target="#' + element.id + '"]')
  25650. this.transitioning = null
  25651. if (this.options.parent) {
  25652. this.$parent = this.getParent()
  25653. } else {
  25654. this.addAriaAndCollapsedClass(this.$element, this.$trigger)
  25655. }
  25656. if (this.options.toggle) this.toggle()
  25657. }
  25658. Collapse.VERSION = '3.3.7'
  25659. Collapse.TRANSITION_DURATION = 350
  25660. Collapse.DEFAULTS = {
  25661. toggle: true
  25662. }
  25663. Collapse.prototype.dimension = function () {
  25664. var hasWidth = this.$element.hasClass('width')
  25665. return hasWidth ? 'width' : 'height'
  25666. }
  25667. Collapse.prototype.show = function () {
  25668. if (this.transitioning || this.$element.hasClass('in')) return
  25669. var activesData
  25670. var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')
  25671. if (actives && actives.length) {
  25672. activesData = actives.data('bs.collapse')
  25673. if (activesData && activesData.transitioning) return
  25674. }
  25675. var startEvent = $.Event('show.bs.collapse')
  25676. this.$element.trigger(startEvent)
  25677. if (startEvent.isDefaultPrevented()) return
  25678. if (actives && actives.length) {
  25679. Plugin.call(actives, 'hide')
  25680. activesData || actives.data('bs.collapse', null)
  25681. }
  25682. var dimension = this.dimension()
  25683. this.$element
  25684. .removeClass('collapse')
  25685. .addClass('collapsing')[dimension](0)
  25686. .attr('aria-expanded', true)
  25687. this.$trigger
  25688. .removeClass('collapsed')
  25689. .attr('aria-expanded', true)
  25690. this.transitioning = 1
  25691. var complete = function () {
  25692. this.$element
  25693. .removeClass('collapsing')
  25694. .addClass('collapse in')[dimension]('')
  25695. this.transitioning = 0
  25696. this.$element
  25697. .trigger('shown.bs.collapse')
  25698. }
  25699. if (!$.support.transition) return complete.call(this)
  25700. var scrollSize = $.camelCase(['scroll', dimension].join('-'))
  25701. this.$element
  25702. .one('bsTransitionEnd', $.proxy(complete, this))
  25703. .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])
  25704. }
  25705. Collapse.prototype.hide = function () {
  25706. if (this.transitioning || !this.$element.hasClass('in')) return
  25707. var startEvent = $.Event('hide.bs.collapse')
  25708. this.$element.trigger(startEvent)
  25709. if (startEvent.isDefaultPrevented()) return
  25710. var dimension = this.dimension()
  25711. this.$element[dimension](this.$element[dimension]())[0].offsetHeight
  25712. this.$element
  25713. .addClass('collapsing')
  25714. .removeClass('collapse in')
  25715. .attr('aria-expanded', false)
  25716. this.$trigger
  25717. .addClass('collapsed')
  25718. .attr('aria-expanded', false)
  25719. this.transitioning = 1
  25720. var complete = function () {
  25721. this.transitioning = 0
  25722. this.$element
  25723. .removeClass('collapsing')
  25724. .addClass('collapse')
  25725. .trigger('hidden.bs.collapse')
  25726. }
  25727. if (!$.support.transition) return complete.call(this)
  25728. this.$element
  25729. [dimension](0)
  25730. .one('bsTransitionEnd', $.proxy(complete, this))
  25731. .emulateTransitionEnd(Collapse.TRANSITION_DURATION)
  25732. }
  25733. Collapse.prototype.toggle = function () {
  25734. this[this.$element.hasClass('in') ? 'hide' : 'show']()
  25735. }
  25736. Collapse.prototype.getParent = function () {
  25737. return $(this.options.parent)
  25738. .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]')
  25739. .each($.proxy(function (i, element) {
  25740. var $element = $(element)
  25741. this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)
  25742. }, this))
  25743. .end()
  25744. }
  25745. Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
  25746. var isOpen = $element.hasClass('in')
  25747. $element.attr('aria-expanded', isOpen)
  25748. $trigger
  25749. .toggleClass('collapsed', !isOpen)
  25750. .attr('aria-expanded', isOpen)
  25751. }
  25752. function getTargetFromTrigger($trigger) {
  25753. var href
  25754. var target = $trigger.attr('data-target')
  25755. || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
  25756. return $(target)
  25757. }
  25758. // COLLAPSE PLUGIN DEFINITION
  25759. // ==========================
  25760. function Plugin(option) {
  25761. return this.each(function () {
  25762. var $this = $(this)
  25763. var data = $this.data('bs.collapse')
  25764. var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
  25765. if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false
  25766. if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
  25767. if (typeof option == 'string') data[option]()
  25768. })
  25769. }
  25770. var old = $.fn.collapse
  25771. $.fn.collapse = Plugin
  25772. $.fn.collapse.Constructor = Collapse
  25773. // COLLAPSE NO CONFLICT
  25774. // ====================
  25775. $.fn.collapse.noConflict = function () {
  25776. $.fn.collapse = old
  25777. return this
  25778. }
  25779. // COLLAPSE DATA-API
  25780. // =================
  25781. $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
  25782. var $this = $(this)
  25783. if (!$this.attr('data-target')) e.preventDefault()
  25784. var $target = getTargetFromTrigger($this)
  25785. var data = $target.data('bs.collapse')
  25786. var option = data ? 'toggle' : $this.data()
  25787. Plugin.call($target, option)
  25788. })
  25789. }(jQuery);
  25790. /* ========================================================================
  25791. * Bootstrap: dropdown.js v3.3.7
  25792. * http://getbootstrap.com/javascript/#dropdowns
  25793. * ========================================================================
  25794. * Copyright 2011-2016 Twitter, Inc.
  25795. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25796. * ======================================================================== */
  25797. +function ($) {
  25798. 'use strict';
  25799. // DROPDOWN CLASS DEFINITION
  25800. // =========================
  25801. var backdrop = '.dropdown-backdrop'
  25802. var toggle = '[data-toggle="dropdown"]'
  25803. var Dropdown = function (element) {
  25804. $(element).on('click.bs.dropdown', this.toggle)
  25805. }
  25806. Dropdown.VERSION = '3.3.7'
  25807. function getParent($this) {
  25808. var selector = $this.attr('data-target')
  25809. if (!selector) {
  25810. selector = $this.attr('href')
  25811. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  25812. }
  25813. var $parent = selector && $(selector)
  25814. return $parent && $parent.length ? $parent : $this.parent()
  25815. }
  25816. function clearMenus(e) {
  25817. if (e && e.which === 3) return
  25818. $(backdrop).remove()
  25819. $(toggle).each(function () {
  25820. var $this = $(this)
  25821. var $parent = getParent($this)
  25822. var relatedTarget = { relatedTarget: this }
  25823. if (!$parent.hasClass('open')) return
  25824. if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
  25825. $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
  25826. if (e.isDefaultPrevented()) return
  25827. $this.attr('aria-expanded', 'false')
  25828. $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
  25829. })
  25830. }
  25831. Dropdown.prototype.toggle = function (e) {
  25832. var $this = $(this)
  25833. if ($this.is('.disabled, :disabled')) return
  25834. var $parent = getParent($this)
  25835. var isActive = $parent.hasClass('open')
  25836. clearMenus()
  25837. if (!isActive) {
  25838. if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
  25839. // if mobile we use a backdrop because click events don't delegate
  25840. $(document.createElement('div'))
  25841. .addClass('dropdown-backdrop')
  25842. .insertAfter($(this))
  25843. .on('click', clearMenus)
  25844. }
  25845. var relatedTarget = { relatedTarget: this }
  25846. $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
  25847. if (e.isDefaultPrevented()) return
  25848. $this
  25849. .trigger('focus')
  25850. .attr('aria-expanded', 'true')
  25851. $parent
  25852. .toggleClass('open')
  25853. .trigger($.Event('shown.bs.dropdown', relatedTarget))
  25854. }
  25855. return false
  25856. }
  25857. Dropdown.prototype.keydown = function (e) {
  25858. if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
  25859. var $this = $(this)
  25860. e.preventDefault()
  25861. e.stopPropagation()
  25862. if ($this.is('.disabled, :disabled')) return
  25863. var $parent = getParent($this)
  25864. var isActive = $parent.hasClass('open')
  25865. if (!isActive && e.which != 27 || isActive && e.which == 27) {
  25866. if (e.which == 27) $parent.find(toggle).trigger('focus')
  25867. return $this.trigger('click')
  25868. }
  25869. var desc = ' li:not(.disabled):visible a'
  25870. var $items = $parent.find('.dropdown-menu' + desc)
  25871. if (!$items.length) return
  25872. var index = $items.index(e.target)
  25873. if (e.which == 38 && index > 0) index-- // up
  25874. if (e.which == 40 && index < $items.length - 1) index++ // down
  25875. if (!~index) index = 0
  25876. $items.eq(index).trigger('focus')
  25877. }
  25878. // DROPDOWN PLUGIN DEFINITION
  25879. // ==========================
  25880. function Plugin(option) {
  25881. return this.each(function () {
  25882. var $this = $(this)
  25883. var data = $this.data('bs.dropdown')
  25884. if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
  25885. if (typeof option == 'string') data[option].call($this)
  25886. })
  25887. }
  25888. var old = $.fn.dropdown
  25889. $.fn.dropdown = Plugin
  25890. $.fn.dropdown.Constructor = Dropdown
  25891. // DROPDOWN NO CONFLICT
  25892. // ====================
  25893. $.fn.dropdown.noConflict = function () {
  25894. $.fn.dropdown = old
  25895. return this
  25896. }
  25897. // APPLY TO STANDARD DROPDOWN ELEMENTS
  25898. // ===================================
  25899. $(document)
  25900. .on('click.bs.dropdown.data-api', clearMenus)
  25901. .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
  25902. .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
  25903. .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
  25904. .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
  25905. }(jQuery);
  25906. /* ========================================================================
  25907. * Bootstrap: modal.js v3.3.7
  25908. * http://getbootstrap.com/javascript/#modals
  25909. * ========================================================================
  25910. * Copyright 2011-2016 Twitter, Inc.
  25911. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25912. * ======================================================================== */
  25913. +function ($) {
  25914. 'use strict';
  25915. // MODAL CLASS DEFINITION
  25916. // ======================
  25917. var Modal = function (element, options) {
  25918. this.options = options
  25919. this.$body = $(document.body)
  25920. this.$element = $(element)
  25921. this.$dialog = this.$element.find('.modal-dialog')
  25922. this.$backdrop = null
  25923. this.isShown = null
  25924. this.originalBodyPad = null
  25925. this.scrollbarWidth = 0
  25926. this.ignoreBackdropClick = false
  25927. if (this.options.remote) {
  25928. this.$element
  25929. .find('.modal-content')
  25930. .load(this.options.remote, $.proxy(function () {
  25931. this.$element.trigger('loaded.bs.modal')
  25932. }, this))
  25933. }
  25934. }
  25935. Modal.VERSION = '3.3.7'
  25936. Modal.TRANSITION_DURATION = 300
  25937. Modal.BACKDROP_TRANSITION_DURATION = 150
  25938. Modal.DEFAULTS = {
  25939. backdrop: true,
  25940. keyboard: true,
  25941. show: true
  25942. }
  25943. Modal.prototype.toggle = function (_relatedTarget) {
  25944. return this.isShown ? this.hide() : this.show(_relatedTarget)
  25945. }
  25946. Modal.prototype.show = function (_relatedTarget) {
  25947. var that = this
  25948. var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
  25949. this.$element.trigger(e)
  25950. if (this.isShown || e.isDefaultPrevented()) return
  25951. this.isShown = true
  25952. this.checkScrollbar()
  25953. this.setScrollbar()
  25954. this.$body.addClass('modal-open')
  25955. this.escape()
  25956. this.resize()
  25957. this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
  25958. this.$dialog.on('mousedown.dismiss.bs.modal', function () {
  25959. that.$element.one('mouseup.dismiss.bs.modal', function (e) {
  25960. if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
  25961. })
  25962. })
  25963. this.backdrop(function () {
  25964. var transition = $.support.transition && that.$element.hasClass('fade')
  25965. if (!that.$element.parent().length) {
  25966. that.$element.appendTo(that.$body) // don't move modals dom position
  25967. }
  25968. that.$element
  25969. .show()
  25970. .scrollTop(0)
  25971. that.adjustDialog()
  25972. if (transition) {
  25973. that.$element[0].offsetWidth // force reflow
  25974. }
  25975. that.$element.addClass('in')
  25976. that.enforceFocus()
  25977. var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
  25978. transition ?
  25979. that.$dialog // wait for modal to slide in
  25980. .one('bsTransitionEnd', function () {
  25981. that.$element.trigger('focus').trigger(e)
  25982. })
  25983. .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
  25984. that.$element.trigger('focus').trigger(e)
  25985. })
  25986. }
  25987. Modal.prototype.hide = function (e) {
  25988. if (e) e.preventDefault()
  25989. e = $.Event('hide.bs.modal')
  25990. this.$element.trigger(e)
  25991. if (!this.isShown || e.isDefaultPrevented()) return
  25992. this.isShown = false
  25993. this.escape()
  25994. this.resize()
  25995. $(document).off('focusin.bs.modal')
  25996. this.$element
  25997. .removeClass('in')
  25998. .off('click.dismiss.bs.modal')
  25999. .off('mouseup.dismiss.bs.modal')
  26000. this.$dialog.off('mousedown.dismiss.bs.modal')
  26001. $.support.transition && this.$element.hasClass('fade') ?
  26002. this.$element
  26003. .one('bsTransitionEnd', $.proxy(this.hideModal, this))
  26004. .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
  26005. this.hideModal()
  26006. }
  26007. Modal.prototype.enforceFocus = function () {
  26008. $(document)
  26009. .off('focusin.bs.modal') // guard against infinite focus loop
  26010. .on('focusin.bs.modal', $.proxy(function (e) {
  26011. if (document !== e.target &&
  26012. this.$element[0] !== e.target &&
  26013. !this.$element.has(e.target).length) {
  26014. this.$element.trigger('focus')
  26015. }
  26016. }, this))
  26017. }
  26018. Modal.prototype.escape = function () {
  26019. if (this.isShown && this.options.keyboard) {
  26020. this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
  26021. e.which == 27 && this.hide()
  26022. }, this))
  26023. } else if (!this.isShown) {
  26024. this.$element.off('keydown.dismiss.bs.modal')
  26025. }
  26026. }
  26027. Modal.prototype.resize = function () {
  26028. if (this.isShown) {
  26029. $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
  26030. } else {
  26031. $(window).off('resize.bs.modal')
  26032. }
  26033. }
  26034. Modal.prototype.hideModal = function () {
  26035. var that = this
  26036. this.$element.hide()
  26037. this.backdrop(function () {
  26038. that.$body.removeClass('modal-open')
  26039. that.resetAdjustments()
  26040. that.resetScrollbar()
  26041. that.$element.trigger('hidden.bs.modal')
  26042. })
  26043. }
  26044. Modal.prototype.removeBackdrop = function () {
  26045. this.$backdrop && this.$backdrop.remove()
  26046. this.$backdrop = null
  26047. }
  26048. Modal.prototype.backdrop = function (callback) {
  26049. var that = this
  26050. var animate = this.$element.hasClass('fade') ? 'fade' : ''
  26051. if (this.isShown && this.options.backdrop) {
  26052. var doAnimate = $.support.transition && animate
  26053. this.$backdrop = $(document.createElement('div'))
  26054. .addClass('modal-backdrop ' + animate)
  26055. .appendTo(this.$body)
  26056. this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
  26057. if (this.ignoreBackdropClick) {
  26058. this.ignoreBackdropClick = false
  26059. return
  26060. }
  26061. if (e.target !== e.currentTarget) return
  26062. this.options.backdrop == 'static'
  26063. ? this.$element[0].focus()
  26064. : this.hide()
  26065. }, this))
  26066. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  26067. this.$backdrop.addClass('in')
  26068. if (!callback) return
  26069. doAnimate ?
  26070. this.$backdrop
  26071. .one('bsTransitionEnd', callback)
  26072. .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
  26073. callback()
  26074. } else if (!this.isShown && this.$backdrop) {
  26075. this.$backdrop.removeClass('in')
  26076. var callbackRemove = function () {
  26077. that.removeBackdrop()
  26078. callback && callback()
  26079. }
  26080. $.support.transition && this.$element.hasClass('fade') ?
  26081. this.$backdrop
  26082. .one('bsTransitionEnd', callbackRemove)
  26083. .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
  26084. callbackRemove()
  26085. } else if (callback) {
  26086. callback()
  26087. }
  26088. }
  26089. // these following methods are used to handle overflowing modals
  26090. Modal.prototype.handleUpdate = function () {
  26091. this.adjustDialog()
  26092. }
  26093. Modal.prototype.adjustDialog = function () {
  26094. var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
  26095. this.$element.css({
  26096. paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
  26097. paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
  26098. })
  26099. }
  26100. Modal.prototype.resetAdjustments = function () {
  26101. this.$element.css({
  26102. paddingLeft: '',
  26103. paddingRight: ''
  26104. })
  26105. }
  26106. Modal.prototype.checkScrollbar = function () {
  26107. var fullWindowWidth = window.innerWidth
  26108. if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
  26109. var documentElementRect = document.documentElement.getBoundingClientRect()
  26110. fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
  26111. }
  26112. this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
  26113. this.scrollbarWidth = this.measureScrollbar()
  26114. }
  26115. Modal.prototype.setScrollbar = function () {
  26116. var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
  26117. this.originalBodyPad = document.body.style.paddingRight || ''
  26118. if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
  26119. }
  26120. Modal.prototype.resetScrollbar = function () {
  26121. this.$body.css('padding-right', this.originalBodyPad)
  26122. }
  26123. Modal.prototype.measureScrollbar = function () { // thx walsh
  26124. var scrollDiv = document.createElement('div')
  26125. scrollDiv.className = 'modal-scrollbar-measure'
  26126. this.$body.append(scrollDiv)
  26127. var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
  26128. this.$body[0].removeChild(scrollDiv)
  26129. return scrollbarWidth
  26130. }
  26131. // MODAL PLUGIN DEFINITION
  26132. // =======================
  26133. function Plugin(option, _relatedTarget) {
  26134. return this.each(function () {
  26135. var $this = $(this)
  26136. var data = $this.data('bs.modal')
  26137. var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
  26138. if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
  26139. if (typeof option == 'string') data[option](_relatedTarget)
  26140. else if (options.show) data.show(_relatedTarget)
  26141. })
  26142. }
  26143. var old = $.fn.modal
  26144. $.fn.modal = Plugin
  26145. $.fn.modal.Constructor = Modal
  26146. // MODAL NO CONFLICT
  26147. // =================
  26148. $.fn.modal.noConflict = function () {
  26149. $.fn.modal = old
  26150. return this
  26151. }
  26152. // MODAL DATA-API
  26153. // ==============
  26154. $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
  26155. var $this = $(this)
  26156. var href = $this.attr('href')
  26157. var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
  26158. var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
  26159. if ($this.is('a')) e.preventDefault()
  26160. $target.one('show.bs.modal', function (showEvent) {
  26161. if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
  26162. $target.one('hidden.bs.modal', function () {
  26163. $this.is(':visible') && $this.trigger('focus')
  26164. })
  26165. })
  26166. Plugin.call($target, option, this)
  26167. })
  26168. }(jQuery);
  26169. /* ========================================================================
  26170. * Bootstrap: tooltip.js v3.3.7
  26171. * http://getbootstrap.com/javascript/#tooltip
  26172. * Inspired by the original jQuery.tipsy by Jason Frame
  26173. * ========================================================================
  26174. * Copyright 2011-2016 Twitter, Inc.
  26175. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26176. * ======================================================================== */
  26177. +function ($) {
  26178. 'use strict';
  26179. // TOOLTIP PUBLIC CLASS DEFINITION
  26180. // ===============================
  26181. var Tooltip = function (element, options) {
  26182. this.type = null
  26183. this.options = null
  26184. this.enabled = null
  26185. this.timeout = null
  26186. this.hoverState = null
  26187. this.$element = null
  26188. this.inState = null
  26189. this.init('tooltip', element, options)
  26190. }
  26191. Tooltip.VERSION = '3.3.7'
  26192. Tooltip.TRANSITION_DURATION = 150
  26193. Tooltip.DEFAULTS = {
  26194. animation: true,
  26195. placement: 'top',
  26196. selector: false,
  26197. template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  26198. trigger: 'hover focus',
  26199. title: '',
  26200. delay: 0,
  26201. html: false,
  26202. container: false,
  26203. viewport: {
  26204. selector: 'body',
  26205. padding: 0
  26206. }
  26207. }
  26208. Tooltip.prototype.init = function (type, element, options) {
  26209. this.enabled = true
  26210. this.type = type
  26211. this.$element = $(element)
  26212. this.options = this.getOptions(options)
  26213. this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
  26214. this.inState = { click: false, hover: false, focus: false }
  26215. if (this.$element[0] instanceof document.constructor && !this.options.selector) {
  26216. throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
  26217. }
  26218. var triggers = this.options.trigger.split(' ')
  26219. for (var i = triggers.length; i--;) {
  26220. var trigger = triggers[i]
  26221. if (trigger == 'click') {
  26222. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  26223. } else if (trigger != 'manual') {
  26224. var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
  26225. var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
  26226. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  26227. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  26228. }
  26229. }
  26230. this.options.selector ?
  26231. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  26232. this.fixTitle()
  26233. }
  26234. Tooltip.prototype.getDefaults = function () {
  26235. return Tooltip.DEFAULTS
  26236. }
  26237. Tooltip.prototype.getOptions = function (options) {
  26238. options = $.extend({}, this.getDefaults(), this.$element.data(), options)
  26239. if (options.delay && typeof options.delay == 'number') {
  26240. options.delay = {
  26241. show: options.delay,
  26242. hide: options.delay
  26243. }
  26244. }
  26245. return options
  26246. }
  26247. Tooltip.prototype.getDelegateOptions = function () {
  26248. var options = {}
  26249. var defaults = this.getDefaults()
  26250. this._options && $.each(this._options, function (key, value) {
  26251. if (defaults[key] != value) options[key] = value
  26252. })
  26253. return options
  26254. }
  26255. Tooltip.prototype.enter = function (obj) {
  26256. var self = obj instanceof this.constructor ?
  26257. obj : $(obj.currentTarget).data('bs.' + this.type)
  26258. if (!self) {
  26259. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  26260. $(obj.currentTarget).data('bs.' + this.type, self)
  26261. }
  26262. if (obj instanceof $.Event) {
  26263. self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
  26264. }
  26265. if (self.tip().hasClass('in') || self.hoverState == 'in') {
  26266. self.hoverState = 'in'
  26267. return
  26268. }
  26269. clearTimeout(self.timeout)
  26270. self.hoverState = 'in'
  26271. if (!self.options.delay || !self.options.delay.show) return self.show()
  26272. self.timeout = setTimeout(function () {
  26273. if (self.hoverState == 'in') self.show()
  26274. }, self.options.delay.show)
  26275. }
  26276. Tooltip.prototype.isInStateTrue = function () {
  26277. for (var key in this.inState) {
  26278. if (this.inState[key]) return true
  26279. }
  26280. return false
  26281. }
  26282. Tooltip.prototype.leave = function (obj) {
  26283. var self = obj instanceof this.constructor ?
  26284. obj : $(obj.currentTarget).data('bs.' + this.type)
  26285. if (!self) {
  26286. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  26287. $(obj.currentTarget).data('bs.' + this.type, self)
  26288. }
  26289. if (obj instanceof $.Event) {
  26290. self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
  26291. }
  26292. if (self.isInStateTrue()) return
  26293. clearTimeout(self.timeout)
  26294. self.hoverState = 'out'
  26295. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  26296. self.timeout = setTimeout(function () {
  26297. if (self.hoverState == 'out') self.hide()
  26298. }, self.options.delay.hide)
  26299. }
  26300. Tooltip.prototype.show = function () {
  26301. var e = $.Event('show.bs.' + this.type)
  26302. if (this.hasContent() && this.enabled) {
  26303. this.$element.trigger(e)
  26304. var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
  26305. if (e.isDefaultPrevented() || !inDom) return
  26306. var that = this
  26307. var $tip = this.tip()
  26308. var tipId = this.getUID(this.type)
  26309. this.setContent()
  26310. $tip.attr('id', tipId)
  26311. this.$element.attr('aria-describedby', tipId)
  26312. if (this.options.animation) $tip.addClass('fade')
  26313. var placement = typeof this.options.placement == 'function' ?
  26314. this.options.placement.call(this, $tip[0], this.$element[0]) :
  26315. this.options.placement
  26316. var autoToken = /\s?auto?\s?/i
  26317. var autoPlace = autoToken.test(placement)
  26318. if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
  26319. $tip
  26320. .detach()
  26321. .css({ top: 0, left: 0, display: 'block' })
  26322. .addClass(placement)
  26323. .data('bs.' + this.type, this)
  26324. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
  26325. this.$element.trigger('inserted.bs.' + this.type)
  26326. var pos = this.getPosition()
  26327. var actualWidth = $tip[0].offsetWidth
  26328. var actualHeight = $tip[0].offsetHeight
  26329. if (autoPlace) {
  26330. var orgPlacement = placement
  26331. var viewportDim = this.getPosition(this.$viewport)
  26332. placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
  26333. placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
  26334. placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
  26335. placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
  26336. placement
  26337. $tip
  26338. .removeClass(orgPlacement)
  26339. .addClass(placement)
  26340. }
  26341. var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
  26342. this.applyPlacement(calculatedOffset, placement)
  26343. var complete = function () {
  26344. var prevHoverState = that.hoverState
  26345. that.$element.trigger('shown.bs.' + that.type)
  26346. that.hoverState = null
  26347. if (prevHoverState == 'out') that.leave(that)
  26348. }
  26349. $.support.transition && this.$tip.hasClass('fade') ?
  26350. $tip
  26351. .one('bsTransitionEnd', complete)
  26352. .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
  26353. complete()
  26354. }
  26355. }
  26356. Tooltip.prototype.applyPlacement = function (offset, placement) {
  26357. var $tip = this.tip()
  26358. var width = $tip[0].offsetWidth
  26359. var height = $tip[0].offsetHeight
  26360. // manually read margins because getBoundingClientRect includes difference
  26361. var marginTop = parseInt($tip.css('margin-top'), 10)
  26362. var marginLeft = parseInt($tip.css('margin-left'), 10)
  26363. // we must check for NaN for ie 8/9
  26364. if (isNaN(marginTop)) marginTop = 0
  26365. if (isNaN(marginLeft)) marginLeft = 0
  26366. offset.top += marginTop
  26367. offset.left += marginLeft
  26368. // $.fn.offset doesn't round pixel values
  26369. // so we use setOffset directly with our own function B-0
  26370. $.offset.setOffset($tip[0], $.extend({
  26371. using: function (props) {
  26372. $tip.css({
  26373. top: Math.round(props.top),
  26374. left: Math.round(props.left)
  26375. })
  26376. }
  26377. }, offset), 0)
  26378. $tip.addClass('in')
  26379. // check to see if placing tip in new offset caused the tip to resize itself
  26380. var actualWidth = $tip[0].offsetWidth
  26381. var actualHeight = $tip[0].offsetHeight
  26382. if (placement == 'top' && actualHeight != height) {
  26383. offset.top = offset.top + height - actualHeight
  26384. }
  26385. var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
  26386. if (delta.left) offset.left += delta.left
  26387. else offset.top += delta.top
  26388. var isVertical = /top|bottom/.test(placement)
  26389. var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
  26390. var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
  26391. $tip.offset(offset)
  26392. this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
  26393. }
  26394. Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
  26395. this.arrow()
  26396. .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
  26397. .css(isVertical ? 'top' : 'left', '')
  26398. }
  26399. Tooltip.prototype.setContent = function () {
  26400. var $tip = this.tip()
  26401. var title = this.getTitle()
  26402. $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  26403. $tip.removeClass('fade in top bottom left right')
  26404. }
  26405. Tooltip.prototype.hide = function (callback) {
  26406. var that = this
  26407. var $tip = $(this.$tip)
  26408. var e = $.Event('hide.bs.' + this.type)
  26409. function complete() {
  26410. if (that.hoverState != 'in') $tip.detach()
  26411. if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
  26412. that.$element
  26413. .removeAttr('aria-describedby')
  26414. .trigger('hidden.bs.' + that.type)
  26415. }
  26416. callback && callback()
  26417. }
  26418. this.$element.trigger(e)
  26419. if (e.isDefaultPrevented()) return
  26420. $tip.removeClass('in')
  26421. $.support.transition && $tip.hasClass('fade') ?
  26422. $tip
  26423. .one('bsTransitionEnd', complete)
  26424. .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
  26425. complete()
  26426. this.hoverState = null
  26427. return this
  26428. }
  26429. Tooltip.prototype.fixTitle = function () {
  26430. var $e = this.$element
  26431. if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
  26432. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  26433. }
  26434. }
  26435. Tooltip.prototype.hasContent = function () {
  26436. return this.getTitle()
  26437. }
  26438. Tooltip.prototype.getPosition = function ($element) {
  26439. $element = $element || this.$element
  26440. var el = $element[0]
  26441. var isBody = el.tagName == 'BODY'
  26442. var elRect = el.getBoundingClientRect()
  26443. if (elRect.width == null) {
  26444. // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
  26445. elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
  26446. }
  26447. var isSvg = window.SVGElement && el instanceof window.SVGElement
  26448. // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
  26449. // See https://github.com/twbs/bootstrap/issues/20280
  26450. var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
  26451. var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
  26452. var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
  26453. return $.extend({}, elRect, scroll, outerDims, elOffset)
  26454. }
  26455. Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
  26456. return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  26457. placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  26458. placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
  26459. /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
  26460. }
  26461. Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
  26462. var delta = { top: 0, left: 0 }
  26463. if (!this.$viewport) return delta
  26464. var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
  26465. var viewportDimensions = this.getPosition(this.$viewport)
  26466. if (/right|left/.test(placement)) {
  26467. var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
  26468. var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
  26469. if (topEdgeOffset < viewportDimensions.top) { // top overflow
  26470. delta.top = viewportDimensions.top - topEdgeOffset
  26471. } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
  26472. delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
  26473. }
  26474. } else {
  26475. var leftEdgeOffset = pos.left - viewportPadding
  26476. var rightEdgeOffset = pos.left + viewportPadding + actualWidth
  26477. if (leftEdgeOffset < viewportDimensions.left) { // left overflow
  26478. delta.left = viewportDimensions.left - leftEdgeOffset
  26479. } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
  26480. delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
  26481. }
  26482. }
  26483. return delta
  26484. }
  26485. Tooltip.prototype.getTitle = function () {
  26486. var title
  26487. var $e = this.$element
  26488. var o = this.options
  26489. title = $e.attr('data-original-title')
  26490. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  26491. return title
  26492. }
  26493. Tooltip.prototype.getUID = function (prefix) {
  26494. do prefix += ~~(Math.random() * 1000000)
  26495. while (document.getElementById(prefix))
  26496. return prefix
  26497. }
  26498. Tooltip.prototype.tip = function () {
  26499. if (!this.$tip) {
  26500. this.$tip = $(this.options.template)
  26501. if (this.$tip.length != 1) {
  26502. throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
  26503. }
  26504. }
  26505. return this.$tip
  26506. }
  26507. Tooltip.prototype.arrow = function () {
  26508. return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
  26509. }
  26510. Tooltip.prototype.enable = function () {
  26511. this.enabled = true
  26512. }
  26513. Tooltip.prototype.disable = function () {
  26514. this.enabled = false
  26515. }
  26516. Tooltip.prototype.toggleEnabled = function () {
  26517. this.enabled = !this.enabled
  26518. }
  26519. Tooltip.prototype.toggle = function (e) {
  26520. var self = this
  26521. if (e) {
  26522. self = $(e.currentTarget).data('bs.' + this.type)
  26523. if (!self) {
  26524. self = new this.constructor(e.currentTarget, this.getDelegateOptions())
  26525. $(e.currentTarget).data('bs.' + this.type, self)
  26526. }
  26527. }
  26528. if (e) {
  26529. self.inState.click = !self.inState.click
  26530. if (self.isInStateTrue()) self.enter(self)
  26531. else self.leave(self)
  26532. } else {
  26533. self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  26534. }
  26535. }
  26536. Tooltip.prototype.destroy = function () {
  26537. var that = this
  26538. clearTimeout(this.timeout)
  26539. this.hide(function () {
  26540. that.$element.off('.' + that.type).removeData('bs.' + that.type)
  26541. if (that.$tip) {
  26542. that.$tip.detach()
  26543. }
  26544. that.$tip = null
  26545. that.$arrow = null
  26546. that.$viewport = null
  26547. that.$element = null
  26548. })
  26549. }
  26550. // TOOLTIP PLUGIN DEFINITION
  26551. // =========================
  26552. function Plugin(option) {
  26553. return this.each(function () {
  26554. var $this = $(this)
  26555. var data = $this.data('bs.tooltip')
  26556. var options = typeof option == 'object' && option
  26557. if (!data && /destroy|hide/.test(option)) return
  26558. if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
  26559. if (typeof option == 'string') data[option]()
  26560. })
  26561. }
  26562. var old = $.fn.tooltip
  26563. $.fn.tooltip = Plugin
  26564. $.fn.tooltip.Constructor = Tooltip
  26565. // TOOLTIP NO CONFLICT
  26566. // ===================
  26567. $.fn.tooltip.noConflict = function () {
  26568. $.fn.tooltip = old
  26569. return this
  26570. }
  26571. }(jQuery);
  26572. /* ========================================================================
  26573. * Bootstrap: popover.js v3.3.7
  26574. * http://getbootstrap.com/javascript/#popovers
  26575. * ========================================================================
  26576. * Copyright 2011-2016 Twitter, Inc.
  26577. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26578. * ======================================================================== */
  26579. +function ($) {
  26580. 'use strict';
  26581. // POPOVER PUBLIC CLASS DEFINITION
  26582. // ===============================
  26583. var Popover = function (element, options) {
  26584. this.init('popover', element, options)
  26585. }
  26586. if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
  26587. Popover.VERSION = '3.3.7'
  26588. Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
  26589. placement: 'right',
  26590. trigger: 'click',
  26591. content: '',
  26592. template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  26593. })
  26594. // NOTE: POPOVER EXTENDS tooltip.js
  26595. // ================================
  26596. Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
  26597. Popover.prototype.constructor = Popover
  26598. Popover.prototype.getDefaults = function () {
  26599. return Popover.DEFAULTS
  26600. }
  26601. Popover.prototype.setContent = function () {
  26602. var $tip = this.tip()
  26603. var title = this.getTitle()
  26604. var content = this.getContent()
  26605. $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
  26606. $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
  26607. this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
  26608. ](content)
  26609. $tip.removeClass('fade top bottom left right in')
  26610. // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
  26611. // this manually by checking the contents.
  26612. if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
  26613. }
  26614. Popover.prototype.hasContent = function () {
  26615. return this.getTitle() || this.getContent()
  26616. }
  26617. Popover.prototype.getContent = function () {
  26618. var $e = this.$element
  26619. var o = this.options
  26620. return $e.attr('data-content')
  26621. || (typeof o.content == 'function' ?
  26622. o.content.call($e[0]) :
  26623. o.content)
  26624. }
  26625. Popover.prototype.arrow = function () {
  26626. return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  26627. }
  26628. // POPOVER PLUGIN DEFINITION
  26629. // =========================
  26630. function Plugin(option) {
  26631. return this.each(function () {
  26632. var $this = $(this)
  26633. var data = $this.data('bs.popover')
  26634. var options = typeof option == 'object' && option
  26635. if (!data && /destroy|hide/.test(option)) return
  26636. if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
  26637. if (typeof option == 'string') data[option]()
  26638. })
  26639. }
  26640. var old = $.fn.popover
  26641. $.fn.popover = Plugin
  26642. $.fn.popover.Constructor = Popover
  26643. // POPOVER NO CONFLICT
  26644. // ===================
  26645. $.fn.popover.noConflict = function () {
  26646. $.fn.popover = old
  26647. return this
  26648. }
  26649. }(jQuery);
  26650. /* ========================================================================
  26651. * Bootstrap: scrollspy.js v3.3.7
  26652. * http://getbootstrap.com/javascript/#scrollspy
  26653. * ========================================================================
  26654. * Copyright 2011-2016 Twitter, Inc.
  26655. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26656. * ======================================================================== */
  26657. +function ($) {
  26658. 'use strict';
  26659. // SCROLLSPY CLASS DEFINITION
  26660. // ==========================
  26661. function ScrollSpy(element, options) {
  26662. this.$body = $(document.body)
  26663. this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)
  26664. this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
  26665. this.selector = (this.options.target || '') + ' .nav li > a'
  26666. this.offsets = []
  26667. this.targets = []
  26668. this.activeTarget = null
  26669. this.scrollHeight = 0
  26670. this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))
  26671. this.refresh()
  26672. this.process()
  26673. }
  26674. ScrollSpy.VERSION = '3.3.7'
  26675. ScrollSpy.DEFAULTS = {
  26676. offset: 10
  26677. }
  26678. ScrollSpy.prototype.getScrollHeight = function () {
  26679. return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
  26680. }
  26681. ScrollSpy.prototype.refresh = function () {
  26682. var that = this
  26683. var offsetMethod = 'offset'
  26684. var offsetBase = 0
  26685. this.offsets = []
  26686. this.targets = []
  26687. this.scrollHeight = this.getScrollHeight()
  26688. if (!$.isWindow(this.$scrollElement[0])) {
  26689. offsetMethod = 'position'
  26690. offsetBase = this.$scrollElement.scrollTop()
  26691. }
  26692. this.$body
  26693. .find(this.selector)
  26694. .map(function () {
  26695. var $el = $(this)
  26696. var href = $el.data('target') || $el.attr('href')
  26697. var $href = /^#./.test(href) && $(href)
  26698. return ($href
  26699. && $href.length
  26700. && $href.is(':visible')
  26701. && [[$href[offsetMethod]().top + offsetBase, href]]) || null
  26702. })
  26703. .sort(function (a, b) { return a[0] - b[0] })
  26704. .each(function () {
  26705. that.offsets.push(this[0])
  26706. that.targets.push(this[1])
  26707. })
  26708. }
  26709. ScrollSpy.prototype.process = function () {
  26710. var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
  26711. var scrollHeight = this.getScrollHeight()
  26712. var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
  26713. var offsets = this.offsets
  26714. var targets = this.targets
  26715. var activeTarget = this.activeTarget
  26716. var i
  26717. if (this.scrollHeight != scrollHeight) {
  26718. this.refresh()
  26719. }
  26720. if (scrollTop >= maxScroll) {
  26721. return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
  26722. }
  26723. if (activeTarget && scrollTop < offsets[0]) {
  26724. this.activeTarget = null
  26725. return this.clear()
  26726. }
  26727. for (i = offsets.length; i--;) {
  26728. activeTarget != targets[i]
  26729. && scrollTop >= offsets[i]
  26730. && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1])
  26731. && this.activate(targets[i])
  26732. }
  26733. }
  26734. ScrollSpy.prototype.activate = function (target) {
  26735. this.activeTarget = target
  26736. this.clear()
  26737. var selector = this.selector +
  26738. '[data-target="' + target + '"],' +
  26739. this.selector + '[href="' + target + '"]'
  26740. var active = $(selector)
  26741. .parents('li')
  26742. .addClass('active')
  26743. if (active.parent('.dropdown-menu').length) {
  26744. active = active
  26745. .closest('li.dropdown')
  26746. .addClass('active')
  26747. }
  26748. active.trigger('activate.bs.scrollspy')
  26749. }
  26750. ScrollSpy.prototype.clear = function () {
  26751. $(this.selector)
  26752. .parentsUntil(this.options.target, '.active')
  26753. .removeClass('active')
  26754. }
  26755. // SCROLLSPY PLUGIN DEFINITION
  26756. // ===========================
  26757. function Plugin(option) {
  26758. return this.each(function () {
  26759. var $this = $(this)
  26760. var data = $this.data('bs.scrollspy')
  26761. var options = typeof option == 'object' && option
  26762. if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
  26763. if (typeof option == 'string') data[option]()
  26764. })
  26765. }
  26766. var old = $.fn.scrollspy
  26767. $.fn.scrollspy = Plugin
  26768. $.fn.scrollspy.Constructor = ScrollSpy
  26769. // SCROLLSPY NO CONFLICT
  26770. // =====================
  26771. $.fn.scrollspy.noConflict = function () {
  26772. $.fn.scrollspy = old
  26773. return this
  26774. }
  26775. // SCROLLSPY DATA-API
  26776. // ==================
  26777. $(window).on('load.bs.scrollspy.data-api', function () {
  26778. $('[data-spy="scroll"]').each(function () {
  26779. var $spy = $(this)
  26780. Plugin.call($spy, $spy.data())
  26781. })
  26782. })
  26783. }(jQuery);
  26784. /* ========================================================================
  26785. * Bootstrap: tab.js v3.3.7
  26786. * http://getbootstrap.com/javascript/#tabs
  26787. * ========================================================================
  26788. * Copyright 2011-2016 Twitter, Inc.
  26789. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26790. * ======================================================================== */
  26791. +function ($) {
  26792. 'use strict';
  26793. // TAB CLASS DEFINITION
  26794. // ====================
  26795. var Tab = function (element) {
  26796. // jscs:disable requireDollarBeforejQueryAssignment
  26797. this.element = $(element)
  26798. // jscs:enable requireDollarBeforejQueryAssignment
  26799. }
  26800. Tab.VERSION = '3.3.7'
  26801. Tab.TRANSITION_DURATION = 150
  26802. Tab.prototype.show = function () {
  26803. var $this = this.element
  26804. var $ul = $this.closest('ul:not(.dropdown-menu)')
  26805. var selector = $this.data('target')
  26806. if (!selector) {
  26807. selector = $this.attr('href')
  26808. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  26809. }
  26810. if ($this.parent('li').hasClass('active')) return
  26811. var $previous = $ul.find('.active:last a')
  26812. var hideEvent = $.Event('hide.bs.tab', {
  26813. relatedTarget: $this[0]
  26814. })
  26815. var showEvent = $.Event('show.bs.tab', {
  26816. relatedTarget: $previous[0]
  26817. })
  26818. $previous.trigger(hideEvent)
  26819. $this.trigger(showEvent)
  26820. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
  26821. var $target = $(selector)
  26822. this.activate($this.closest('li'), $ul)
  26823. this.activate($target, $target.parent(), function () {
  26824. $previous.trigger({
  26825. type: 'hidden.bs.tab',
  26826. relatedTarget: $this[0]
  26827. })
  26828. $this.trigger({
  26829. type: 'shown.bs.tab',
  26830. relatedTarget: $previous[0]
  26831. })
  26832. })
  26833. }
  26834. Tab.prototype.activate = function (element, container, callback) {
  26835. var $active = container.find('> .active')
  26836. var transition = callback
  26837. && $.support.transition
  26838. && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
  26839. function next() {
  26840. $active
  26841. .removeClass('active')
  26842. .find('> .dropdown-menu > .active')
  26843. .removeClass('active')
  26844. .end()
  26845. .find('[data-toggle="tab"]')
  26846. .attr('aria-expanded', false)
  26847. element
  26848. .addClass('active')
  26849. .find('[data-toggle="tab"]')
  26850. .attr('aria-expanded', true)
  26851. if (transition) {
  26852. element[0].offsetWidth // reflow for transition
  26853. element.addClass('in')
  26854. } else {
  26855. element.removeClass('fade')
  26856. }
  26857. if (element.parent('.dropdown-menu').length) {
  26858. element
  26859. .closest('li.dropdown')
  26860. .addClass('active')
  26861. .end()
  26862. .find('[data-toggle="tab"]')
  26863. .attr('aria-expanded', true)
  26864. }
  26865. callback && callback()
  26866. }
  26867. $active.length && transition ?
  26868. $active
  26869. .one('bsTransitionEnd', next)
  26870. .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
  26871. next()
  26872. $active.removeClass('in')
  26873. }
  26874. // TAB PLUGIN DEFINITION
  26875. // =====================
  26876. function Plugin(option) {
  26877. return this.each(function () {
  26878. var $this = $(this)
  26879. var data = $this.data('bs.tab')
  26880. if (!data) $this.data('bs.tab', (data = new Tab(this)))
  26881. if (typeof option == 'string') data[option]()
  26882. })
  26883. }
  26884. var old = $.fn.tab
  26885. $.fn.tab = Plugin
  26886. $.fn.tab.Constructor = Tab
  26887. // TAB NO CONFLICT
  26888. // ===============
  26889. $.fn.tab.noConflict = function () {
  26890. $.fn.tab = old
  26891. return this
  26892. }
  26893. // TAB DATA-API
  26894. // ============
  26895. var clickHandler = function (e) {
  26896. e.preventDefault()
  26897. Plugin.call($(this), 'show')
  26898. }
  26899. $(document)
  26900. .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
  26901. .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
  26902. }(jQuery);
  26903. /* ========================================================================
  26904. * Bootstrap: affix.js v3.3.7
  26905. * http://getbootstrap.com/javascript/#affix
  26906. * ========================================================================
  26907. * Copyright 2011-2016 Twitter, Inc.
  26908. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26909. * ======================================================================== */
  26910. +function ($) {
  26911. 'use strict';
  26912. // AFFIX CLASS DEFINITION
  26913. // ======================
  26914. var Affix = function (element, options) {
  26915. this.options = $.extend({}, Affix.DEFAULTS, options)
  26916. this.$target = $(this.options.target)
  26917. .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
  26918. .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
  26919. this.$element = $(element)
  26920. this.affixed = null
  26921. this.unpin = null
  26922. this.pinnedOffset = null
  26923. this.checkPosition()
  26924. }
  26925. Affix.VERSION = '3.3.7'
  26926. Affix.RESET = 'affix affix-top affix-bottom'
  26927. Affix.DEFAULTS = {
  26928. offset: 0,
  26929. target: window
  26930. }
  26931. Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
  26932. var scrollTop = this.$target.scrollTop()
  26933. var position = this.$element.offset()
  26934. var targetHeight = this.$target.height()
  26935. if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false
  26936. if (this.affixed == 'bottom') {
  26937. if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
  26938. return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
  26939. }
  26940. var initializing = this.affixed == null
  26941. var colliderTop = initializing ? scrollTop : position.top
  26942. var colliderHeight = initializing ? targetHeight : height
  26943. if (offsetTop != null && scrollTop <= offsetTop) return 'top'
  26944. if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
  26945. return false
  26946. }
  26947. Affix.prototype.getPinnedOffset = function () {
  26948. if (this.pinnedOffset) return this.pinnedOffset
  26949. this.$element.removeClass(Affix.RESET).addClass('affix')
  26950. var scrollTop = this.$target.scrollTop()
  26951. var position = this.$element.offset()
  26952. return (this.pinnedOffset = position.top - scrollTop)
  26953. }
  26954. Affix.prototype.checkPositionWithEventLoop = function () {
  26955. setTimeout($.proxy(this.checkPosition, this), 1)
  26956. }
  26957. Affix.prototype.checkPosition = function () {
  26958. if (!this.$element.is(':visible')) return
  26959. var height = this.$element.height()
  26960. var offset = this.options.offset
  26961. var offsetTop = offset.top
  26962. var offsetBottom = offset.bottom
  26963. var scrollHeight = Math.max($(document).height(), $(document.body).height())
  26964. if (typeof offset != 'object') offsetBottom = offsetTop = offset
  26965. if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
  26966. if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
  26967. var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)
  26968. if (this.affixed != affix) {
  26969. if (this.unpin != null) this.$element.css('top', '')
  26970. var affixType = 'affix' + (affix ? '-' + affix : '')
  26971. var e = $.Event(affixType + '.bs.affix')
  26972. this.$element.trigger(e)
  26973. if (e.isDefaultPrevented()) return
  26974. this.affixed = affix
  26975. this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
  26976. this.$element
  26977. .removeClass(Affix.RESET)
  26978. .addClass(affixType)
  26979. .trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
  26980. }
  26981. if (affix == 'bottom') {
  26982. this.$element.offset({
  26983. top: scrollHeight - height - offsetBottom
  26984. })
  26985. }
  26986. }
  26987. // AFFIX PLUGIN DEFINITION
  26988. // =======================
  26989. function Plugin(option) {
  26990. return this.each(function () {
  26991. var $this = $(this)
  26992. var data = $this.data('bs.affix')
  26993. var options = typeof option == 'object' && option
  26994. if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
  26995. if (typeof option == 'string') data[option]()
  26996. })
  26997. }
  26998. var old = $.fn.affix
  26999. $.fn.affix = Plugin
  27000. $.fn.affix.Constructor = Affix
  27001. // AFFIX NO CONFLICT
  27002. // =================
  27003. $.fn.affix.noConflict = function () {
  27004. $.fn.affix = old
  27005. return this
  27006. }
  27007. // AFFIX DATA-API
  27008. // ==============
  27009. $(window).on('load', function () {
  27010. $('[data-spy="affix"]').each(function () {
  27011. var $spy = $(this)
  27012. var data = $spy.data()
  27013. data.offset = data.offset || {}
  27014. if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
  27015. if (data.offsetTop != null) data.offset.top = data.offsetTop
  27016. Plugin.call($spy, data)
  27017. })
  27018. })
  27019. }(jQuery);
  27020. /***/ }),
  27021. /* 16 */
  27022. /***/ (function(module, exports, __webpack_require__) {
  27023. module.exports = __webpack_require__(17);
  27024. /***/ }),
  27025. /* 17 */
  27026. /***/ (function(module, exports, __webpack_require__) {
  27027. "use strict";
  27028. var utils = __webpack_require__(0);
  27029. var bind = __webpack_require__(3);
  27030. var Axios = __webpack_require__(19);
  27031. var defaults = __webpack_require__(1);
  27032. /**
  27033. * Create an instance of Axios
  27034. *
  27035. * @param {Object} defaultConfig The default config for the instance
  27036. * @return {Axios} A new instance of Axios
  27037. */
  27038. function createInstance(defaultConfig) {
  27039. var context = new Axios(defaultConfig);
  27040. var instance = bind(Axios.prototype.request, context);
  27041. // Copy axios.prototype to instance
  27042. utils.extend(instance, Axios.prototype, context);
  27043. // Copy context to instance
  27044. utils.extend(instance, context);
  27045. return instance;
  27046. }
  27047. // Create the default instance to be exported
  27048. var axios = createInstance(defaults);
  27049. // Expose Axios class to allow class inheritance
  27050. axios.Axios = Axios;
  27051. // Factory for creating new instances
  27052. axios.create = function create(instanceConfig) {
  27053. return createInstance(utils.merge(defaults, instanceConfig));
  27054. };
  27055. // Expose Cancel & CancelToken
  27056. axios.Cancel = __webpack_require__(7);
  27057. axios.CancelToken = __webpack_require__(34);
  27058. axios.isCancel = __webpack_require__(6);
  27059. // Expose all/spread
  27060. axios.all = function all(promises) {
  27061. return Promise.all(promises);
  27062. };
  27063. axios.spread = __webpack_require__(35);
  27064. module.exports = axios;
  27065. // Allow use of default import syntax in TypeScript
  27066. module.exports.default = axios;
  27067. /***/ }),
  27068. /* 18 */
  27069. /***/ (function(module, exports) {
  27070. /*!
  27071. * Determine if an object is a Buffer
  27072. *
  27073. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  27074. * @license MIT
  27075. */
  27076. // The _isBuffer check is for Safari 5-7 support, because it's missing
  27077. // Object.prototype.constructor. Remove this eventually
  27078. module.exports = function (obj) {
  27079. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  27080. }
  27081. function isBuffer (obj) {
  27082. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  27083. }
  27084. // For Node v0.10 support. Remove this eventually.
  27085. function isSlowBuffer (obj) {
  27086. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  27087. }
  27088. /***/ }),
  27089. /* 19 */
  27090. /***/ (function(module, exports, __webpack_require__) {
  27091. "use strict";
  27092. var defaults = __webpack_require__(1);
  27093. var utils = __webpack_require__(0);
  27094. var InterceptorManager = __webpack_require__(29);
  27095. var dispatchRequest = __webpack_require__(30);
  27096. var isAbsoluteURL = __webpack_require__(32);
  27097. var combineURLs = __webpack_require__(33);
  27098. /**
  27099. * Create a new instance of Axios
  27100. *
  27101. * @param {Object} instanceConfig The default config for the instance
  27102. */
  27103. function Axios(instanceConfig) {
  27104. this.defaults = instanceConfig;
  27105. this.interceptors = {
  27106. request: new InterceptorManager(),
  27107. response: new InterceptorManager()
  27108. };
  27109. }
  27110. /**
  27111. * Dispatch a request
  27112. *
  27113. * @param {Object} config The config specific for this request (merged with this.defaults)
  27114. */
  27115. Axios.prototype.request = function request(config) {
  27116. /*eslint no-param-reassign:0*/
  27117. // Allow for axios('example/url'[, config]) a la fetch API
  27118. if (typeof config === 'string') {
  27119. config = utils.merge({
  27120. url: arguments[0]
  27121. }, arguments[1]);
  27122. }
  27123. config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
  27124. config.method = config.method.toLowerCase();
  27125. // Support baseURL config
  27126. if (config.baseURL && !isAbsoluteURL(config.url)) {
  27127. config.url = combineURLs(config.baseURL, config.url);
  27128. }
  27129. // Hook up interceptors middleware
  27130. var chain = [dispatchRequest, undefined];
  27131. var promise = Promise.resolve(config);
  27132. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  27133. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  27134. });
  27135. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  27136. chain.push(interceptor.fulfilled, interceptor.rejected);
  27137. });
  27138. while (chain.length) {
  27139. promise = promise.then(chain.shift(), chain.shift());
  27140. }
  27141. return promise;
  27142. };
  27143. // Provide aliases for supported request methods
  27144. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  27145. /*eslint func-names:0*/
  27146. Axios.prototype[method] = function(url, config) {
  27147. return this.request(utils.merge(config || {}, {
  27148. method: method,
  27149. url: url
  27150. }));
  27151. };
  27152. });
  27153. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  27154. /*eslint func-names:0*/
  27155. Axios.prototype[method] = function(url, data, config) {
  27156. return this.request(utils.merge(config || {}, {
  27157. method: method,
  27158. url: url,
  27159. data: data
  27160. }));
  27161. };
  27162. });
  27163. module.exports = Axios;
  27164. /***/ }),
  27165. /* 20 */
  27166. /***/ (function(module, exports) {
  27167. // shim for using process in browser
  27168. var process = module.exports = {};
  27169. // cached from whatever global is present so that test runners that stub it
  27170. // don't break things. But we need to wrap it in a try catch in case it is
  27171. // wrapped in strict mode code which doesn't define any globals. It's inside a
  27172. // function because try/catches deoptimize in certain engines.
  27173. var cachedSetTimeout;
  27174. var cachedClearTimeout;
  27175. function defaultSetTimout() {
  27176. throw new Error('setTimeout has not been defined');
  27177. }
  27178. function defaultClearTimeout () {
  27179. throw new Error('clearTimeout has not been defined');
  27180. }
  27181. (function () {
  27182. try {
  27183. if (typeof setTimeout === 'function') {
  27184. cachedSetTimeout = setTimeout;
  27185. } else {
  27186. cachedSetTimeout = defaultSetTimout;
  27187. }
  27188. } catch (e) {
  27189. cachedSetTimeout = defaultSetTimout;
  27190. }
  27191. try {
  27192. if (typeof clearTimeout === 'function') {
  27193. cachedClearTimeout = clearTimeout;
  27194. } else {
  27195. cachedClearTimeout = defaultClearTimeout;
  27196. }
  27197. } catch (e) {
  27198. cachedClearTimeout = defaultClearTimeout;
  27199. }
  27200. } ())
  27201. function runTimeout(fun) {
  27202. if (cachedSetTimeout === setTimeout) {
  27203. //normal enviroments in sane situations
  27204. return setTimeout(fun, 0);
  27205. }
  27206. // if setTimeout wasn't available but was latter defined
  27207. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  27208. cachedSetTimeout = setTimeout;
  27209. return setTimeout(fun, 0);
  27210. }
  27211. try {
  27212. // when when somebody has screwed with setTimeout but no I.E. maddness
  27213. return cachedSetTimeout(fun, 0);
  27214. } catch(e){
  27215. try {
  27216. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  27217. return cachedSetTimeout.call(null, fun, 0);
  27218. } catch(e){
  27219. // 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
  27220. return cachedSetTimeout.call(this, fun, 0);
  27221. }
  27222. }
  27223. }
  27224. function runClearTimeout(marker) {
  27225. if (cachedClearTimeout === clearTimeout) {
  27226. //normal enviroments in sane situations
  27227. return clearTimeout(marker);
  27228. }
  27229. // if clearTimeout wasn't available but was latter defined
  27230. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  27231. cachedClearTimeout = clearTimeout;
  27232. return clearTimeout(marker);
  27233. }
  27234. try {
  27235. // when when somebody has screwed with setTimeout but no I.E. maddness
  27236. return cachedClearTimeout(marker);
  27237. } catch (e){
  27238. try {
  27239. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  27240. return cachedClearTimeout.call(null, marker);
  27241. } catch (e){
  27242. // 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.
  27243. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  27244. return cachedClearTimeout.call(this, marker);
  27245. }
  27246. }
  27247. }
  27248. var queue = [];
  27249. var draining = false;
  27250. var currentQueue;
  27251. var queueIndex = -1;
  27252. function cleanUpNextTick() {
  27253. if (!draining || !currentQueue) {
  27254. return;
  27255. }
  27256. draining = false;
  27257. if (currentQueue.length) {
  27258. queue = currentQueue.concat(queue);
  27259. } else {
  27260. queueIndex = -1;
  27261. }
  27262. if (queue.length) {
  27263. drainQueue();
  27264. }
  27265. }
  27266. function drainQueue() {
  27267. if (draining) {
  27268. return;
  27269. }
  27270. var timeout = runTimeout(cleanUpNextTick);
  27271. draining = true;
  27272. var len = queue.length;
  27273. while(len) {
  27274. currentQueue = queue;
  27275. queue = [];
  27276. while (++queueIndex < len) {
  27277. if (currentQueue) {
  27278. currentQueue[queueIndex].run();
  27279. }
  27280. }
  27281. queueIndex = -1;
  27282. len = queue.length;
  27283. }
  27284. currentQueue = null;
  27285. draining = false;
  27286. runClearTimeout(timeout);
  27287. }
  27288. process.nextTick = function (fun) {
  27289. var args = new Array(arguments.length - 1);
  27290. if (arguments.length > 1) {
  27291. for (var i = 1; i < arguments.length; i++) {
  27292. args[i - 1] = arguments[i];
  27293. }
  27294. }
  27295. queue.push(new Item(fun, args));
  27296. if (queue.length === 1 && !draining) {
  27297. runTimeout(drainQueue);
  27298. }
  27299. };
  27300. // v8 likes predictible objects
  27301. function Item(fun, array) {
  27302. this.fun = fun;
  27303. this.array = array;
  27304. }
  27305. Item.prototype.run = function () {
  27306. this.fun.apply(null, this.array);
  27307. };
  27308. process.title = 'browser';
  27309. process.browser = true;
  27310. process.env = {};
  27311. process.argv = [];
  27312. process.version = ''; // empty string to avoid regexp issues
  27313. process.versions = {};
  27314. function noop() {}
  27315. process.on = noop;
  27316. process.addListener = noop;
  27317. process.once = noop;
  27318. process.off = noop;
  27319. process.removeListener = noop;
  27320. process.removeAllListeners = noop;
  27321. process.emit = noop;
  27322. process.prependListener = noop;
  27323. process.prependOnceListener = noop;
  27324. process.listeners = function (name) { return [] }
  27325. process.binding = function (name) {
  27326. throw new Error('process.binding is not supported');
  27327. };
  27328. process.cwd = function () { return '/' };
  27329. process.chdir = function (dir) {
  27330. throw new Error('process.chdir is not supported');
  27331. };
  27332. process.umask = function() { return 0; };
  27333. /***/ }),
  27334. /* 21 */
  27335. /***/ (function(module, exports, __webpack_require__) {
  27336. "use strict";
  27337. var utils = __webpack_require__(0);
  27338. module.exports = function normalizeHeaderName(headers, normalizedName) {
  27339. utils.forEach(headers, function processHeader(value, name) {
  27340. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  27341. headers[normalizedName] = value;
  27342. delete headers[name];
  27343. }
  27344. });
  27345. };
  27346. /***/ }),
  27347. /* 22 */
  27348. /***/ (function(module, exports, __webpack_require__) {
  27349. "use strict";
  27350. var createError = __webpack_require__(5);
  27351. /**
  27352. * Resolve or reject a Promise based on response status.
  27353. *
  27354. * @param {Function} resolve A function that resolves the promise.
  27355. * @param {Function} reject A function that rejects the promise.
  27356. * @param {object} response The response.
  27357. */
  27358. module.exports = function settle(resolve, reject, response) {
  27359. var validateStatus = response.config.validateStatus;
  27360. // Note: status is not exposed by XDomainRequest
  27361. if (!response.status || !validateStatus || validateStatus(response.status)) {
  27362. resolve(response);
  27363. } else {
  27364. reject(createError(
  27365. 'Request failed with status code ' + response.status,
  27366. response.config,
  27367. null,
  27368. response.request,
  27369. response
  27370. ));
  27371. }
  27372. };
  27373. /***/ }),
  27374. /* 23 */
  27375. /***/ (function(module, exports, __webpack_require__) {
  27376. "use strict";
  27377. /**
  27378. * Update an Error with the specified config, error code, and response.
  27379. *
  27380. * @param {Error} error The error to update.
  27381. * @param {Object} config The config.
  27382. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  27383. * @param {Object} [request] The request.
  27384. * @param {Object} [response] The response.
  27385. * @returns {Error} The error.
  27386. */
  27387. module.exports = function enhanceError(error, config, code, request, response) {
  27388. error.config = config;
  27389. if (code) {
  27390. error.code = code;
  27391. }
  27392. error.request = request;
  27393. error.response = response;
  27394. return error;
  27395. };
  27396. /***/ }),
  27397. /* 24 */
  27398. /***/ (function(module, exports, __webpack_require__) {
  27399. "use strict";
  27400. var utils = __webpack_require__(0);
  27401. function encode(val) {
  27402. return encodeURIComponent(val).
  27403. replace(/%40/gi, '@').
  27404. replace(/%3A/gi, ':').
  27405. replace(/%24/g, '$').
  27406. replace(/%2C/gi, ',').
  27407. replace(/%20/g, '+').
  27408. replace(/%5B/gi, '[').
  27409. replace(/%5D/gi, ']');
  27410. }
  27411. /**
  27412. * Build a URL by appending params to the end
  27413. *
  27414. * @param {string} url The base of the url (e.g., http://www.google.com)
  27415. * @param {object} [params] The params to be appended
  27416. * @returns {string} The formatted url
  27417. */
  27418. module.exports = function buildURL(url, params, paramsSerializer) {
  27419. /*eslint no-param-reassign:0*/
  27420. if (!params) {
  27421. return url;
  27422. }
  27423. var serializedParams;
  27424. if (paramsSerializer) {
  27425. serializedParams = paramsSerializer(params);
  27426. } else if (utils.isURLSearchParams(params)) {
  27427. serializedParams = params.toString();
  27428. } else {
  27429. var parts = [];
  27430. utils.forEach(params, function serialize(val, key) {
  27431. if (val === null || typeof val === 'undefined') {
  27432. return;
  27433. }
  27434. if (utils.isArray(val)) {
  27435. key = key + '[]';
  27436. }
  27437. if (!utils.isArray(val)) {
  27438. val = [val];
  27439. }
  27440. utils.forEach(val, function parseValue(v) {
  27441. if (utils.isDate(v)) {
  27442. v = v.toISOString();
  27443. } else if (utils.isObject(v)) {
  27444. v = JSON.stringify(v);
  27445. }
  27446. parts.push(encode(key) + '=' + encode(v));
  27447. });
  27448. });
  27449. serializedParams = parts.join('&');
  27450. }
  27451. if (serializedParams) {
  27452. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  27453. }
  27454. return url;
  27455. };
  27456. /***/ }),
  27457. /* 25 */
  27458. /***/ (function(module, exports, __webpack_require__) {
  27459. "use strict";
  27460. var utils = __webpack_require__(0);
  27461. /**
  27462. * Parse headers into an object
  27463. *
  27464. * ```
  27465. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  27466. * Content-Type: application/json
  27467. * Connection: keep-alive
  27468. * Transfer-Encoding: chunked
  27469. * ```
  27470. *
  27471. * @param {String} headers Headers needing to be parsed
  27472. * @returns {Object} Headers parsed into an object
  27473. */
  27474. module.exports = function parseHeaders(headers) {
  27475. var parsed = {};
  27476. var key;
  27477. var val;
  27478. var i;
  27479. if (!headers) { return parsed; }
  27480. utils.forEach(headers.split('\n'), function parser(line) {
  27481. i = line.indexOf(':');
  27482. key = utils.trim(line.substr(0, i)).toLowerCase();
  27483. val = utils.trim(line.substr(i + 1));
  27484. if (key) {
  27485. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  27486. }
  27487. });
  27488. return parsed;
  27489. };
  27490. /***/ }),
  27491. /* 26 */
  27492. /***/ (function(module, exports, __webpack_require__) {
  27493. "use strict";
  27494. var utils = __webpack_require__(0);
  27495. module.exports = (
  27496. utils.isStandardBrowserEnv() ?
  27497. // Standard browser envs have full support of the APIs needed to test
  27498. // whether the request URL is of the same origin as current location.
  27499. (function standardBrowserEnv() {
  27500. var msie = /(msie|trident)/i.test(navigator.userAgent);
  27501. var urlParsingNode = document.createElement('a');
  27502. var originURL;
  27503. /**
  27504. * Parse a URL to discover it's components
  27505. *
  27506. * @param {String} url The URL to be parsed
  27507. * @returns {Object}
  27508. */
  27509. function resolveURL(url) {
  27510. var href = url;
  27511. if (msie) {
  27512. // IE needs attribute set twice to normalize properties
  27513. urlParsingNode.setAttribute('href', href);
  27514. href = urlParsingNode.href;
  27515. }
  27516. urlParsingNode.setAttribute('href', href);
  27517. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  27518. return {
  27519. href: urlParsingNode.href,
  27520. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  27521. host: urlParsingNode.host,
  27522. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  27523. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  27524. hostname: urlParsingNode.hostname,
  27525. port: urlParsingNode.port,
  27526. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  27527. urlParsingNode.pathname :
  27528. '/' + urlParsingNode.pathname
  27529. };
  27530. }
  27531. originURL = resolveURL(window.location.href);
  27532. /**
  27533. * Determine if a URL shares the same origin as the current location
  27534. *
  27535. * @param {String} requestURL The URL to test
  27536. * @returns {boolean} True if URL shares the same origin, otherwise false
  27537. */
  27538. return function isURLSameOrigin(requestURL) {
  27539. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  27540. return (parsed.protocol === originURL.protocol &&
  27541. parsed.host === originURL.host);
  27542. };
  27543. })() :
  27544. // Non standard browser envs (web workers, react-native) lack needed support.
  27545. (function nonStandardBrowserEnv() {
  27546. return function isURLSameOrigin() {
  27547. return true;
  27548. };
  27549. })()
  27550. );
  27551. /***/ }),
  27552. /* 27 */
  27553. /***/ (function(module, exports, __webpack_require__) {
  27554. "use strict";
  27555. // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
  27556. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  27557. function E() {
  27558. this.message = 'String contains an invalid character';
  27559. }
  27560. E.prototype = new Error;
  27561. E.prototype.code = 5;
  27562. E.prototype.name = 'InvalidCharacterError';
  27563. function btoa(input) {
  27564. var str = String(input);
  27565. var output = '';
  27566. for (
  27567. // initialize result and counter
  27568. var block, charCode, idx = 0, map = chars;
  27569. // if the next str index does not exist:
  27570. // change the mapping table to "="
  27571. // check if d has no fractional digits
  27572. str.charAt(idx | 0) || (map = '=', idx % 1);
  27573. // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
  27574. output += map.charAt(63 & block >> 8 - idx % 1 * 8)
  27575. ) {
  27576. charCode = str.charCodeAt(idx += 3 / 4);
  27577. if (charCode > 0xFF) {
  27578. throw new E();
  27579. }
  27580. block = block << 8 | charCode;
  27581. }
  27582. return output;
  27583. }
  27584. module.exports = btoa;
  27585. /***/ }),
  27586. /* 28 */
  27587. /***/ (function(module, exports, __webpack_require__) {
  27588. "use strict";
  27589. var utils = __webpack_require__(0);
  27590. module.exports = (
  27591. utils.isStandardBrowserEnv() ?
  27592. // Standard browser envs support document.cookie
  27593. (function standardBrowserEnv() {
  27594. return {
  27595. write: function write(name, value, expires, path, domain, secure) {
  27596. var cookie = [];
  27597. cookie.push(name + '=' + encodeURIComponent(value));
  27598. if (utils.isNumber(expires)) {
  27599. cookie.push('expires=' + new Date(expires).toGMTString());
  27600. }
  27601. if (utils.isString(path)) {
  27602. cookie.push('path=' + path);
  27603. }
  27604. if (utils.isString(domain)) {
  27605. cookie.push('domain=' + domain);
  27606. }
  27607. if (secure === true) {
  27608. cookie.push('secure');
  27609. }
  27610. document.cookie = cookie.join('; ');
  27611. },
  27612. read: function read(name) {
  27613. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  27614. return (match ? decodeURIComponent(match[3]) : null);
  27615. },
  27616. remove: function remove(name) {
  27617. this.write(name, '', Date.now() - 86400000);
  27618. }
  27619. };
  27620. })() :
  27621. // Non standard browser env (web workers, react-native) lack needed support.
  27622. (function nonStandardBrowserEnv() {
  27623. return {
  27624. write: function write() {},
  27625. read: function read() { return null; },
  27626. remove: function remove() {}
  27627. };
  27628. })()
  27629. );
  27630. /***/ }),
  27631. /* 29 */
  27632. /***/ (function(module, exports, __webpack_require__) {
  27633. "use strict";
  27634. var utils = __webpack_require__(0);
  27635. function InterceptorManager() {
  27636. this.handlers = [];
  27637. }
  27638. /**
  27639. * Add a new interceptor to the stack
  27640. *
  27641. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  27642. * @param {Function} rejected The function to handle `reject` for a `Promise`
  27643. *
  27644. * @return {Number} An ID used to remove interceptor later
  27645. */
  27646. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  27647. this.handlers.push({
  27648. fulfilled: fulfilled,
  27649. rejected: rejected
  27650. });
  27651. return this.handlers.length - 1;
  27652. };
  27653. /**
  27654. * Remove an interceptor from the stack
  27655. *
  27656. * @param {Number} id The ID that was returned by `use`
  27657. */
  27658. InterceptorManager.prototype.eject = function eject(id) {
  27659. if (this.handlers[id]) {
  27660. this.handlers[id] = null;
  27661. }
  27662. };
  27663. /**
  27664. * Iterate over all the registered interceptors
  27665. *
  27666. * This method is particularly useful for skipping over any
  27667. * interceptors that may have become `null` calling `eject`.
  27668. *
  27669. * @param {Function} fn The function to call for each interceptor
  27670. */
  27671. InterceptorManager.prototype.forEach = function forEach(fn) {
  27672. utils.forEach(this.handlers, function forEachHandler(h) {
  27673. if (h !== null) {
  27674. fn(h);
  27675. }
  27676. });
  27677. };
  27678. module.exports = InterceptorManager;
  27679. /***/ }),
  27680. /* 30 */
  27681. /***/ (function(module, exports, __webpack_require__) {
  27682. "use strict";
  27683. var utils = __webpack_require__(0);
  27684. var transformData = __webpack_require__(31);
  27685. var isCancel = __webpack_require__(6);
  27686. var defaults = __webpack_require__(1);
  27687. /**
  27688. * Throws a `Cancel` if cancellation has been requested.
  27689. */
  27690. function throwIfCancellationRequested(config) {
  27691. if (config.cancelToken) {
  27692. config.cancelToken.throwIfRequested();
  27693. }
  27694. }
  27695. /**
  27696. * Dispatch a request to the server using the configured adapter.
  27697. *
  27698. * @param {object} config The config that is to be used for the request
  27699. * @returns {Promise} The Promise to be fulfilled
  27700. */
  27701. module.exports = function dispatchRequest(config) {
  27702. throwIfCancellationRequested(config);
  27703. // Ensure headers exist
  27704. config.headers = config.headers || {};
  27705. // Transform request data
  27706. config.data = transformData(
  27707. config.data,
  27708. config.headers,
  27709. config.transformRequest
  27710. );
  27711. // Flatten headers
  27712. config.headers = utils.merge(
  27713. config.headers.common || {},
  27714. config.headers[config.method] || {},
  27715. config.headers || {}
  27716. );
  27717. utils.forEach(
  27718. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  27719. function cleanHeaderConfig(method) {
  27720. delete config.headers[method];
  27721. }
  27722. );
  27723. var adapter = config.adapter || defaults.adapter;
  27724. return adapter(config).then(function onAdapterResolution(response) {
  27725. throwIfCancellationRequested(config);
  27726. // Transform response data
  27727. response.data = transformData(
  27728. response.data,
  27729. response.headers,
  27730. config.transformResponse
  27731. );
  27732. return response;
  27733. }, function onAdapterRejection(reason) {
  27734. if (!isCancel(reason)) {
  27735. throwIfCancellationRequested(config);
  27736. // Transform response data
  27737. if (reason && reason.response) {
  27738. reason.response.data = transformData(
  27739. reason.response.data,
  27740. reason.response.headers,
  27741. config.transformResponse
  27742. );
  27743. }
  27744. }
  27745. return Promise.reject(reason);
  27746. });
  27747. };
  27748. /***/ }),
  27749. /* 31 */
  27750. /***/ (function(module, exports, __webpack_require__) {
  27751. "use strict";
  27752. var utils = __webpack_require__(0);
  27753. /**
  27754. * Transform the data for a request or a response
  27755. *
  27756. * @param {Object|String} data The data to be transformed
  27757. * @param {Array} headers The headers for the request or response
  27758. * @param {Array|Function} fns A single function or Array of functions
  27759. * @returns {*} The resulting transformed data
  27760. */
  27761. module.exports = function transformData(data, headers, fns) {
  27762. /*eslint no-param-reassign:0*/
  27763. utils.forEach(fns, function transform(fn) {
  27764. data = fn(data, headers);
  27765. });
  27766. return data;
  27767. };
  27768. /***/ }),
  27769. /* 32 */
  27770. /***/ (function(module, exports, __webpack_require__) {
  27771. "use strict";
  27772. /**
  27773. * Determines whether the specified URL is absolute
  27774. *
  27775. * @param {string} url The URL to test
  27776. * @returns {boolean} True if the specified URL is absolute, otherwise false
  27777. */
  27778. module.exports = function isAbsoluteURL(url) {
  27779. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  27780. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  27781. // by any combination of letters, digits, plus, period, or hyphen.
  27782. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  27783. };
  27784. /***/ }),
  27785. /* 33 */
  27786. /***/ (function(module, exports, __webpack_require__) {
  27787. "use strict";
  27788. /**
  27789. * Creates a new URL by combining the specified URLs
  27790. *
  27791. * @param {string} baseURL The base URL
  27792. * @param {string} relativeURL The relative URL
  27793. * @returns {string} The combined URL
  27794. */
  27795. module.exports = function combineURLs(baseURL, relativeURL) {
  27796. return relativeURL
  27797. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  27798. : baseURL;
  27799. };
  27800. /***/ }),
  27801. /* 34 */
  27802. /***/ (function(module, exports, __webpack_require__) {
  27803. "use strict";
  27804. var Cancel = __webpack_require__(7);
  27805. /**
  27806. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  27807. *
  27808. * @class
  27809. * @param {Function} executor The executor function.
  27810. */
  27811. function CancelToken(executor) {
  27812. if (typeof executor !== 'function') {
  27813. throw new TypeError('executor must be a function.');
  27814. }
  27815. var resolvePromise;
  27816. this.promise = new Promise(function promiseExecutor(resolve) {
  27817. resolvePromise = resolve;
  27818. });
  27819. var token = this;
  27820. executor(function cancel(message) {
  27821. if (token.reason) {
  27822. // Cancellation has already been requested
  27823. return;
  27824. }
  27825. token.reason = new Cancel(message);
  27826. resolvePromise(token.reason);
  27827. });
  27828. }
  27829. /**
  27830. * Throws a `Cancel` if cancellation has been requested.
  27831. */
  27832. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  27833. if (this.reason) {
  27834. throw this.reason;
  27835. }
  27836. };
  27837. /**
  27838. * Returns an object that contains a new `CancelToken` and a function that, when called,
  27839. * cancels the `CancelToken`.
  27840. */
  27841. CancelToken.source = function source() {
  27842. var cancel;
  27843. var token = new CancelToken(function executor(c) {
  27844. cancel = c;
  27845. });
  27846. return {
  27847. token: token,
  27848. cancel: cancel
  27849. };
  27850. };
  27851. module.exports = CancelToken;
  27852. /***/ }),
  27853. /* 35 */
  27854. /***/ (function(module, exports, __webpack_require__) {
  27855. "use strict";
  27856. /**
  27857. * Syntactic sugar for invoking a function and expanding an array for arguments.
  27858. *
  27859. * Common use case would be to use `Function.prototype.apply`.
  27860. *
  27861. * ```js
  27862. * function f(x, y, z) {}
  27863. * var args = [1, 2, 3];
  27864. * f.apply(null, args);
  27865. * ```
  27866. *
  27867. * With `spread` this example can be re-written.
  27868. *
  27869. * ```js
  27870. * spread(function(x, y, z) {})([1, 2, 3]);
  27871. * ```
  27872. *
  27873. * @param {Function} callback
  27874. * @returns {Function}
  27875. */
  27876. module.exports = function spread(callback) {
  27877. return function wrap(arr) {
  27878. return callback.apply(null, arr);
  27879. };
  27880. };
  27881. /***/ }),
  27882. /* 36 */
  27883. /***/ (function(module, exports) {
  27884. var asyncGenerator = function () {
  27885. function AwaitValue(value) {
  27886. this.value = value;
  27887. }
  27888. function AsyncGenerator(gen) {
  27889. var front, back;
  27890. function send(key, arg) {
  27891. return new Promise(function (resolve, reject) {
  27892. var request = {
  27893. key: key,
  27894. arg: arg,
  27895. resolve: resolve,
  27896. reject: reject,
  27897. next: null
  27898. };
  27899. if (back) {
  27900. back = back.next = request;
  27901. } else {
  27902. front = back = request;
  27903. resume(key, arg);
  27904. }
  27905. });
  27906. }
  27907. function resume(key, arg) {
  27908. try {
  27909. var result = gen[key](arg);
  27910. var value = result.value;
  27911. if (value instanceof AwaitValue) {
  27912. Promise.resolve(value.value).then(function (arg) {
  27913. resume("next", arg);
  27914. }, function (arg) {
  27915. resume("throw", arg);
  27916. });
  27917. } else {
  27918. settle(result.done ? "return" : "normal", result.value);
  27919. }
  27920. } catch (err) {
  27921. settle("throw", err);
  27922. }
  27923. }
  27924. function settle(type, value) {
  27925. switch (type) {
  27926. case "return":
  27927. front.resolve({
  27928. value: value,
  27929. done: true
  27930. });
  27931. break;
  27932. case "throw":
  27933. front.reject(value);
  27934. break;
  27935. default:
  27936. front.resolve({
  27937. value: value,
  27938. done: false
  27939. });
  27940. break;
  27941. }
  27942. front = front.next;
  27943. if (front) {
  27944. resume(front.key, front.arg);
  27945. } else {
  27946. back = null;
  27947. }
  27948. }
  27949. this._invoke = send;
  27950. if (typeof gen.return !== "function") {
  27951. this.return = undefined;
  27952. }
  27953. }
  27954. if (typeof Symbol === "function" && Symbol.asyncIterator) {
  27955. AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
  27956. return this;
  27957. };
  27958. }
  27959. AsyncGenerator.prototype.next = function (arg) {
  27960. return this._invoke("next", arg);
  27961. };
  27962. AsyncGenerator.prototype.throw = function (arg) {
  27963. return this._invoke("throw", arg);
  27964. };
  27965. AsyncGenerator.prototype.return = function (arg) {
  27966. return this._invoke("return", arg);
  27967. };
  27968. return {
  27969. wrap: function (fn) {
  27970. return function () {
  27971. return new AsyncGenerator(fn.apply(this, arguments));
  27972. };
  27973. },
  27974. await: function (value) {
  27975. return new AwaitValue(value);
  27976. }
  27977. };
  27978. }();
  27979. var classCallCheck = function (instance, Constructor) {
  27980. if (!(instance instanceof Constructor)) {
  27981. throw new TypeError("Cannot call a class as a function");
  27982. }
  27983. };
  27984. var createClass = function () {
  27985. function defineProperties(target, props) {
  27986. for (var i = 0; i < props.length; i++) {
  27987. var descriptor = props[i];
  27988. descriptor.enumerable = descriptor.enumerable || false;
  27989. descriptor.configurable = true;
  27990. if ("value" in descriptor) descriptor.writable = true;
  27991. Object.defineProperty(target, descriptor.key, descriptor);
  27992. }
  27993. }
  27994. return function (Constructor, protoProps, staticProps) {
  27995. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  27996. if (staticProps) defineProperties(Constructor, staticProps);
  27997. return Constructor;
  27998. };
  27999. }();
  28000. var _extends = Object.assign || function (target) {
  28001. for (var i = 1; i < arguments.length; i++) {
  28002. var source = arguments[i];
  28003. for (var key in source) {
  28004. if (Object.prototype.hasOwnProperty.call(source, key)) {
  28005. target[key] = source[key];
  28006. }
  28007. }
  28008. }
  28009. return target;
  28010. };
  28011. var inherits = function (subClass, superClass) {
  28012. if (typeof superClass !== "function" && superClass !== null) {
  28013. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  28014. }
  28015. subClass.prototype = Object.create(superClass && superClass.prototype, {
  28016. constructor: {
  28017. value: subClass,
  28018. enumerable: false,
  28019. writable: true,
  28020. configurable: true
  28021. }
  28022. });
  28023. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  28024. };
  28025. var possibleConstructorReturn = function (self, call) {
  28026. if (!self) {
  28027. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  28028. }
  28029. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  28030. };
  28031. var Connector = function () {
  28032. function Connector(options) {
  28033. classCallCheck(this, Connector);
  28034. this._defaultOptions = {
  28035. auth: {
  28036. headers: {}
  28037. },
  28038. authEndpoint: '/broadcasting/auth',
  28039. broadcaster: 'pusher',
  28040. csrfToken: null,
  28041. host: null,
  28042. key: null,
  28043. namespace: 'App.Events'
  28044. };
  28045. this.setOptions(options);
  28046. this.connect();
  28047. }
  28048. createClass(Connector, [{
  28049. key: 'setOptions',
  28050. value: function setOptions(options) {
  28051. this.options = _extends(this._defaultOptions, options);
  28052. if (this.csrfToken()) {
  28053. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  28054. }
  28055. return options;
  28056. }
  28057. }, {
  28058. key: 'csrfToken',
  28059. value: function csrfToken() {
  28060. var selector = void 0;
  28061. if (window && window['Laravel'] && window['Laravel'].csrfToken) {
  28062. return window['Laravel'].csrfToken;
  28063. } else if (this.options.csrfToken) {
  28064. return this.options.csrfToken;
  28065. } else if (typeof document !== 'undefined' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  28066. return selector.getAttribute('content');
  28067. }
  28068. return null;
  28069. }
  28070. }]);
  28071. return Connector;
  28072. }();
  28073. var Channel = function () {
  28074. function Channel() {
  28075. classCallCheck(this, Channel);
  28076. }
  28077. createClass(Channel, [{
  28078. key: 'notification',
  28079. value: function notification(callback) {
  28080. return this.listen('.Illuminate.Notifications.Events.BroadcastNotificationCreated', callback);
  28081. }
  28082. }, {
  28083. key: 'listenForWhisper',
  28084. value: function listenForWhisper(event, callback) {
  28085. return this.listen('.client-' + event, callback);
  28086. }
  28087. }]);
  28088. return Channel;
  28089. }();
  28090. var EventFormatter = function () {
  28091. function EventFormatter(namespace) {
  28092. classCallCheck(this, EventFormatter);
  28093. this.setNamespace(namespace);
  28094. }
  28095. createClass(EventFormatter, [{
  28096. key: 'format',
  28097. value: function format(event) {
  28098. if (this.namespace) {
  28099. if (event.charAt(0) != '\\' && event.charAt(0) != '.') {
  28100. event = this.namespace + '.' + event;
  28101. } else {
  28102. event = event.substr(1);
  28103. }
  28104. }
  28105. return event.replace(/\./g, '\\');
  28106. }
  28107. }, {
  28108. key: 'setNamespace',
  28109. value: function setNamespace(value) {
  28110. this.namespace = value;
  28111. }
  28112. }]);
  28113. return EventFormatter;
  28114. }();
  28115. var PusherChannel = function (_Channel) {
  28116. inherits(PusherChannel, _Channel);
  28117. function PusherChannel(pusher, name, options) {
  28118. classCallCheck(this, PusherChannel);
  28119. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  28120. _this.name = name;
  28121. _this.pusher = pusher;
  28122. _this.options = options;
  28123. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  28124. _this.subscribe();
  28125. return _this;
  28126. }
  28127. createClass(PusherChannel, [{
  28128. key: 'subscribe',
  28129. value: function subscribe() {
  28130. this.subscription = this.pusher.subscribe(this.name);
  28131. }
  28132. }, {
  28133. key: 'unsubscribe',
  28134. value: function unsubscribe() {
  28135. this.pusher.unsubscribe(this.name);
  28136. }
  28137. }, {
  28138. key: 'listen',
  28139. value: function listen(event, callback) {
  28140. this.on(this.eventFormatter.format(event), callback);
  28141. return this;
  28142. }
  28143. }, {
  28144. key: 'stopListening',
  28145. value: function stopListening(event) {
  28146. this.subscription.unbind(this.eventFormatter.format(event));
  28147. return this;
  28148. }
  28149. }, {
  28150. key: 'on',
  28151. value: function on(event, callback) {
  28152. this.subscription.bind(event, callback);
  28153. return this;
  28154. }
  28155. }]);
  28156. return PusherChannel;
  28157. }(Channel);
  28158. var PusherPrivateChannel = function (_PusherChannel) {
  28159. inherits(PusherPrivateChannel, _PusherChannel);
  28160. function PusherPrivateChannel() {
  28161. classCallCheck(this, PusherPrivateChannel);
  28162. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  28163. }
  28164. createClass(PusherPrivateChannel, [{
  28165. key: 'whisper',
  28166. value: function whisper(eventName, data) {
  28167. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  28168. return this;
  28169. }
  28170. }]);
  28171. return PusherPrivateChannel;
  28172. }(PusherChannel);
  28173. var PusherPresenceChannel = function (_PusherChannel) {
  28174. inherits(PusherPresenceChannel, _PusherChannel);
  28175. function PusherPresenceChannel() {
  28176. classCallCheck(this, PusherPresenceChannel);
  28177. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  28178. }
  28179. createClass(PusherPresenceChannel, [{
  28180. key: 'here',
  28181. value: function here(callback) {
  28182. this.on('pusher:subscription_succeeded', function (data) {
  28183. callback(Object.keys(data.members).map(function (k) {
  28184. return data.members[k];
  28185. }));
  28186. });
  28187. return this;
  28188. }
  28189. }, {
  28190. key: 'joining',
  28191. value: function joining(callback) {
  28192. this.on('pusher:member_added', function (member) {
  28193. callback(member.info);
  28194. });
  28195. return this;
  28196. }
  28197. }, {
  28198. key: 'leaving',
  28199. value: function leaving(callback) {
  28200. this.on('pusher:member_removed', function (member) {
  28201. callback(member.info);
  28202. });
  28203. return this;
  28204. }
  28205. }, {
  28206. key: 'whisper',
  28207. value: function whisper(eventName, data) {
  28208. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  28209. return this;
  28210. }
  28211. }]);
  28212. return PusherPresenceChannel;
  28213. }(PusherChannel);
  28214. var SocketIoChannel = function (_Channel) {
  28215. inherits(SocketIoChannel, _Channel);
  28216. function SocketIoChannel(socket, name, options) {
  28217. classCallCheck(this, SocketIoChannel);
  28218. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  28219. _this.events = {};
  28220. _this.name = name;
  28221. _this.socket = socket;
  28222. _this.options = options;
  28223. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  28224. _this.subscribe();
  28225. _this.configureReconnector();
  28226. return _this;
  28227. }
  28228. createClass(SocketIoChannel, [{
  28229. key: 'subscribe',
  28230. value: function subscribe() {
  28231. this.socket.emit('subscribe', {
  28232. channel: this.name,
  28233. auth: this.options.auth || {}
  28234. });
  28235. }
  28236. }, {
  28237. key: 'unsubscribe',
  28238. value: function unsubscribe() {
  28239. this.unbind();
  28240. this.socket.emit('unsubscribe', {
  28241. channel: this.name,
  28242. auth: this.options.auth || {}
  28243. });
  28244. }
  28245. }, {
  28246. key: 'listen',
  28247. value: function listen(event, callback) {
  28248. this.on(this.eventFormatter.format(event), callback);
  28249. return this;
  28250. }
  28251. }, {
  28252. key: 'on',
  28253. value: function on(event, callback) {
  28254. var _this2 = this;
  28255. var listener = function listener(channel, data) {
  28256. if (_this2.name == channel) {
  28257. callback(data);
  28258. }
  28259. };
  28260. this.socket.on(event, listener);
  28261. this.bind(event, listener);
  28262. }
  28263. }, {
  28264. key: 'configureReconnector',
  28265. value: function configureReconnector() {
  28266. var _this3 = this;
  28267. var listener = function listener() {
  28268. _this3.subscribe();
  28269. };
  28270. this.socket.on('reconnect', listener);
  28271. this.bind('reconnect', listener);
  28272. }
  28273. }, {
  28274. key: 'bind',
  28275. value: function bind(event, callback) {
  28276. this.events[event] = this.events[event] || [];
  28277. this.events[event].push(callback);
  28278. }
  28279. }, {
  28280. key: 'unbind',
  28281. value: function unbind() {
  28282. var _this4 = this;
  28283. Object.keys(this.events).forEach(function (event) {
  28284. _this4.events[event].forEach(function (callback) {
  28285. _this4.socket.removeListener(event, callback);
  28286. });
  28287. delete _this4.events[event];
  28288. });
  28289. }
  28290. }]);
  28291. return SocketIoChannel;
  28292. }(Channel);
  28293. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  28294. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  28295. function SocketIoPrivateChannel() {
  28296. classCallCheck(this, SocketIoPrivateChannel);
  28297. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  28298. }
  28299. createClass(SocketIoPrivateChannel, [{
  28300. key: 'whisper',
  28301. value: function whisper(eventName, data) {
  28302. this.socket.emit('client event', {
  28303. channel: this.name,
  28304. event: 'client-' + eventName,
  28305. data: data
  28306. });
  28307. return this;
  28308. }
  28309. }]);
  28310. return SocketIoPrivateChannel;
  28311. }(SocketIoChannel);
  28312. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  28313. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  28314. function SocketIoPresenceChannel() {
  28315. classCallCheck(this, SocketIoPresenceChannel);
  28316. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  28317. }
  28318. createClass(SocketIoPresenceChannel, [{
  28319. key: 'here',
  28320. value: function here(callback) {
  28321. this.on('presence:subscribed', function (members) {
  28322. callback(members.map(function (m) {
  28323. return m.user_info;
  28324. }));
  28325. });
  28326. return this;
  28327. }
  28328. }, {
  28329. key: 'joining',
  28330. value: function joining(callback) {
  28331. this.on('presence:joining', function (member) {
  28332. return callback(member.user_info);
  28333. });
  28334. return this;
  28335. }
  28336. }, {
  28337. key: 'leaving',
  28338. value: function leaving(callback) {
  28339. this.on('presence:leaving', function (member) {
  28340. return callback(member.user_info);
  28341. });
  28342. return this;
  28343. }
  28344. }]);
  28345. return SocketIoPresenceChannel;
  28346. }(SocketIoPrivateChannel);
  28347. var PusherConnector = function (_Connector) {
  28348. inherits(PusherConnector, _Connector);
  28349. function PusherConnector() {
  28350. var _ref;
  28351. classCallCheck(this, PusherConnector);
  28352. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  28353. args[_key] = arguments[_key];
  28354. }
  28355. var _this = possibleConstructorReturn(this, (_ref = PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).call.apply(_ref, [this].concat(args)));
  28356. _this.channels = {};
  28357. return _this;
  28358. }
  28359. createClass(PusherConnector, [{
  28360. key: 'connect',
  28361. value: function connect() {
  28362. this.pusher = new Pusher(this.options.key, this.options);
  28363. }
  28364. }, {
  28365. key: 'listen',
  28366. value: function listen(name, event, callback) {
  28367. return this.channel(name).listen(event, callback);
  28368. }
  28369. }, {
  28370. key: 'channel',
  28371. value: function channel(name) {
  28372. if (!this.channels[name]) {
  28373. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  28374. }
  28375. return this.channels[name];
  28376. }
  28377. }, {
  28378. key: 'privateChannel',
  28379. value: function privateChannel(name) {
  28380. if (!this.channels['private-' + name]) {
  28381. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  28382. }
  28383. return this.channels['private-' + name];
  28384. }
  28385. }, {
  28386. key: 'presenceChannel',
  28387. value: function presenceChannel(name) {
  28388. if (!this.channels['presence-' + name]) {
  28389. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  28390. }
  28391. return this.channels['presence-' + name];
  28392. }
  28393. }, {
  28394. key: 'leave',
  28395. value: function leave(name) {
  28396. var _this2 = this;
  28397. var channels = [name, 'private-' + name, 'presence-' + name];
  28398. channels.forEach(function (name, index) {
  28399. if (_this2.channels[name]) {
  28400. _this2.channels[name].unsubscribe();
  28401. delete _this2.channels[name];
  28402. }
  28403. });
  28404. }
  28405. }, {
  28406. key: 'socketId',
  28407. value: function socketId() {
  28408. return this.pusher.connection.socket_id;
  28409. }
  28410. }]);
  28411. return PusherConnector;
  28412. }(Connector);
  28413. var SocketIoConnector = function (_Connector) {
  28414. inherits(SocketIoConnector, _Connector);
  28415. function SocketIoConnector() {
  28416. var _ref;
  28417. classCallCheck(this, SocketIoConnector);
  28418. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  28419. args[_key] = arguments[_key];
  28420. }
  28421. var _this = possibleConstructorReturn(this, (_ref = SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).call.apply(_ref, [this].concat(args)));
  28422. _this.channels = {};
  28423. return _this;
  28424. }
  28425. createClass(SocketIoConnector, [{
  28426. key: 'connect',
  28427. value: function connect() {
  28428. this.socket = io(this.options.host, this.options);
  28429. return this.socket;
  28430. }
  28431. }, {
  28432. key: 'listen',
  28433. value: function listen(name, event, callback) {
  28434. return this.channel(name).listen(event, callback);
  28435. }
  28436. }, {
  28437. key: 'channel',
  28438. value: function channel(name) {
  28439. if (!this.channels[name]) {
  28440. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  28441. }
  28442. return this.channels[name];
  28443. }
  28444. }, {
  28445. key: 'privateChannel',
  28446. value: function privateChannel(name) {
  28447. if (!this.channels['private-' + name]) {
  28448. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  28449. }
  28450. return this.channels['private-' + name];
  28451. }
  28452. }, {
  28453. key: 'presenceChannel',
  28454. value: function presenceChannel(name) {
  28455. if (!this.channels['presence-' + name]) {
  28456. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  28457. }
  28458. return this.channels['presence-' + name];
  28459. }
  28460. }, {
  28461. key: 'leave',
  28462. value: function leave(name) {
  28463. var _this2 = this;
  28464. var channels = [name, 'private-' + name, 'presence-' + name];
  28465. channels.forEach(function (name) {
  28466. if (_this2.channels[name]) {
  28467. _this2.channels[name].unsubscribe();
  28468. delete _this2.channels[name];
  28469. }
  28470. });
  28471. }
  28472. }, {
  28473. key: 'socketId',
  28474. value: function socketId() {
  28475. return this.socket.id;
  28476. }
  28477. }]);
  28478. return SocketIoConnector;
  28479. }(Connector);
  28480. var Echo = function () {
  28481. function Echo(options) {
  28482. classCallCheck(this, Echo);
  28483. this.options = options;
  28484. if (typeof Vue === 'function' && Vue.http) {
  28485. this.registerVueRequestInterceptor();
  28486. }
  28487. if (typeof axios === 'function') {
  28488. this.registerAxiosRequestInterceptor();
  28489. }
  28490. if (typeof jQuery === 'function') {
  28491. this.registerjQueryAjaxSetup();
  28492. }
  28493. if (this.options.broadcaster == 'pusher') {
  28494. this.connector = new PusherConnector(this.options);
  28495. } else if (this.options.broadcaster == 'socket.io') {
  28496. this.connector = new SocketIoConnector(this.options);
  28497. }
  28498. }
  28499. createClass(Echo, [{
  28500. key: 'registerVueRequestInterceptor',
  28501. value: function registerVueRequestInterceptor() {
  28502. var _this = this;
  28503. Vue.http.interceptors.push(function (request, next) {
  28504. if (_this.socketId()) {
  28505. request.headers.set('X-Socket-ID', _this.socketId());
  28506. }
  28507. next();
  28508. });
  28509. }
  28510. }, {
  28511. key: 'registerAxiosRequestInterceptor',
  28512. value: function registerAxiosRequestInterceptor() {
  28513. var _this2 = this;
  28514. axios.interceptors.request.use(function (config) {
  28515. if (_this2.socketId()) {
  28516. config.headers['X-Socket-Id'] = _this2.socketId();
  28517. }
  28518. return config;
  28519. });
  28520. }
  28521. }, {
  28522. key: 'registerjQueryAjaxSetup',
  28523. value: function registerjQueryAjaxSetup() {
  28524. var _this3 = this;
  28525. if (typeof jQuery.ajax != 'undefined') {
  28526. jQuery.ajaxSetup({
  28527. beforeSend: function beforeSend(xhr) {
  28528. if (_this3.socketId()) {
  28529. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  28530. }
  28531. }
  28532. });
  28533. }
  28534. }
  28535. }, {
  28536. key: 'listen',
  28537. value: function listen(channel, event, callback) {
  28538. return this.connector.listen(channel, event, callback);
  28539. }
  28540. }, {
  28541. key: 'channel',
  28542. value: function channel(_channel) {
  28543. return this.connector.channel(_channel);
  28544. }
  28545. }, {
  28546. key: 'private',
  28547. value: function _private(channel) {
  28548. return this.connector.privateChannel(channel);
  28549. }
  28550. }, {
  28551. key: 'join',
  28552. value: function join(channel) {
  28553. return this.connector.presenceChannel(channel);
  28554. }
  28555. }, {
  28556. key: 'leave',
  28557. value: function leave(channel) {
  28558. this.connector.leave(channel);
  28559. }
  28560. }, {
  28561. key: 'socketId',
  28562. value: function socketId() {
  28563. return this.connector.socketId();
  28564. }
  28565. }]);
  28566. return Echo;
  28567. }();
  28568. module.exports = Echo;
  28569. /***/ }),
  28570. /* 37 */
  28571. /***/ (function(module, exports, __webpack_require__) {
  28572. /*!
  28573. * Pusher JavaScript Library v4.1.0
  28574. * https://pusher.com/
  28575. *
  28576. * Copyright 2017, Pusher
  28577. * Released under the MIT licence.
  28578. */
  28579. (function webpackUniversalModuleDefinition(root, factory) {
  28580. if(true)
  28581. module.exports = factory();
  28582. else if(typeof define === 'function' && define.amd)
  28583. define([], factory);
  28584. else if(typeof exports === 'object')
  28585. exports["Pusher"] = factory();
  28586. else
  28587. root["Pusher"] = factory();
  28588. })(this, function() {
  28589. return /******/ (function(modules) { // webpackBootstrap
  28590. /******/ // The module cache
  28591. /******/ var installedModules = {};
  28592. /******/ // The require function
  28593. /******/ function __webpack_require__(moduleId) {
  28594. /******/ // Check if module is in cache
  28595. /******/ if(installedModules[moduleId])
  28596. /******/ return installedModules[moduleId].exports;
  28597. /******/ // Create a new module (and put it into the cache)
  28598. /******/ var module = installedModules[moduleId] = {
  28599. /******/ exports: {},
  28600. /******/ id: moduleId,
  28601. /******/ loaded: false
  28602. /******/ };
  28603. /******/ // Execute the module function
  28604. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  28605. /******/ // Flag the module as loaded
  28606. /******/ module.loaded = true;
  28607. /******/ // Return the exports of the module
  28608. /******/ return module.exports;
  28609. /******/ }
  28610. /******/ // expose the modules object (__webpack_modules__)
  28611. /******/ __webpack_require__.m = modules;
  28612. /******/ // expose the module cache
  28613. /******/ __webpack_require__.c = installedModules;
  28614. /******/ // __webpack_public_path__
  28615. /******/ __webpack_require__.p = "";
  28616. /******/ // Load entry module and return exports
  28617. /******/ return __webpack_require__(0);
  28618. /******/ })
  28619. /************************************************************************/
  28620. /******/ ([
  28621. /* 0 */
  28622. /***/ (function(module, exports, __webpack_require__) {
  28623. "use strict";
  28624. var pusher_1 = __webpack_require__(1);
  28625. module.exports = pusher_1["default"];
  28626. /***/ }),
  28627. /* 1 */
  28628. /***/ (function(module, exports, __webpack_require__) {
  28629. "use strict";
  28630. var runtime_1 = __webpack_require__(2);
  28631. var Collections = __webpack_require__(9);
  28632. var dispatcher_1 = __webpack_require__(23);
  28633. var timeline_1 = __webpack_require__(38);
  28634. var level_1 = __webpack_require__(39);
  28635. var StrategyBuilder = __webpack_require__(40);
  28636. var timers_1 = __webpack_require__(12);
  28637. var defaults_1 = __webpack_require__(5);
  28638. var DefaultConfig = __webpack_require__(62);
  28639. var logger_1 = __webpack_require__(8);
  28640. var factory_1 = __webpack_require__(42);
  28641. var Pusher = (function () {
  28642. function Pusher(app_key, options) {
  28643. var _this = this;
  28644. checkAppKey(app_key);
  28645. options = options || {};
  28646. this.key = app_key;
  28647. this.config = Collections.extend(DefaultConfig.getGlobalConfig(), options.cluster ? DefaultConfig.getClusterConfig(options.cluster) : {}, options);
  28648. this.channels = factory_1["default"].createChannels();
  28649. this.global_emitter = new dispatcher_1["default"]();
  28650. this.sessionID = Math.floor(Math.random() * 1000000000);
  28651. this.timeline = new timeline_1["default"](this.key, this.sessionID, {
  28652. cluster: this.config.cluster,
  28653. features: Pusher.getClientFeatures(),
  28654. params: this.config.timelineParams || {},
  28655. limit: 50,
  28656. level: level_1["default"].INFO,
  28657. version: defaults_1["default"].VERSION
  28658. });
  28659. if (!this.config.disableStats) {
  28660. this.timelineSender = factory_1["default"].createTimelineSender(this.timeline, {
  28661. host: this.config.statsHost,
  28662. path: "/timeline/v2/" + runtime_1["default"].TimelineTransport.name
  28663. });
  28664. }
  28665. var getStrategy = function (options) {
  28666. var config = Collections.extend({}, _this.config, options);
  28667. return StrategyBuilder.build(runtime_1["default"].getDefaultStrategy(config), config);
  28668. };
  28669. this.connection = factory_1["default"].createConnectionManager(this.key, Collections.extend({ getStrategy: getStrategy,
  28670. timeline: this.timeline,
  28671. activityTimeout: this.config.activity_timeout,
  28672. pongTimeout: this.config.pong_timeout,
  28673. unavailableTimeout: this.config.unavailable_timeout
  28674. }, this.config, { encrypted: this.isEncrypted() }));
  28675. this.connection.bind('connected', function () {
  28676. _this.subscribeAll();
  28677. if (_this.timelineSender) {
  28678. _this.timelineSender.send(_this.connection.isEncrypted());
  28679. }
  28680. });
  28681. this.connection.bind('message', function (params) {
  28682. var internal = (params.event.indexOf('pusher_internal:') === 0);
  28683. if (params.channel) {
  28684. var channel = _this.channel(params.channel);
  28685. if (channel) {
  28686. channel.handleEvent(params.event, params.data);
  28687. }
  28688. }
  28689. if (!internal) {
  28690. _this.global_emitter.emit(params.event, params.data);
  28691. }
  28692. });
  28693. this.connection.bind('connecting', function () {
  28694. _this.channels.disconnect();
  28695. });
  28696. this.connection.bind('disconnected', function () {
  28697. _this.channels.disconnect();
  28698. });
  28699. this.connection.bind('error', function (err) {
  28700. logger_1["default"].warn('Error', err);
  28701. });
  28702. Pusher.instances.push(this);
  28703. this.timeline.info({ instances: Pusher.instances.length });
  28704. if (Pusher.isReady) {
  28705. this.connect();
  28706. }
  28707. }
  28708. Pusher.ready = function () {
  28709. Pusher.isReady = true;
  28710. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  28711. Pusher.instances[i].connect();
  28712. }
  28713. };
  28714. Pusher.log = function (message) {
  28715. if (Pusher.logToConsole && (window).console && (window).console.log) {
  28716. (window).console.log(message);
  28717. }
  28718. };
  28719. Pusher.getClientFeatures = function () {
  28720. return Collections.keys(Collections.filterObject({ "ws": runtime_1["default"].Transports.ws }, function (t) { return t.isSupported({}); }));
  28721. };
  28722. Pusher.prototype.channel = function (name) {
  28723. return this.channels.find(name);
  28724. };
  28725. Pusher.prototype.allChannels = function () {
  28726. return this.channels.all();
  28727. };
  28728. Pusher.prototype.connect = function () {
  28729. this.connection.connect();
  28730. if (this.timelineSender) {
  28731. if (!this.timelineSenderTimer) {
  28732. var encrypted = this.connection.isEncrypted();
  28733. var timelineSender = this.timelineSender;
  28734. this.timelineSenderTimer = new timers_1.PeriodicTimer(60000, function () {
  28735. timelineSender.send(encrypted);
  28736. });
  28737. }
  28738. }
  28739. };
  28740. Pusher.prototype.disconnect = function () {
  28741. this.connection.disconnect();
  28742. if (this.timelineSenderTimer) {
  28743. this.timelineSenderTimer.ensureAborted();
  28744. this.timelineSenderTimer = null;
  28745. }
  28746. };
  28747. Pusher.prototype.bind = function (event_name, callback, context) {
  28748. this.global_emitter.bind(event_name, callback, context);
  28749. return this;
  28750. };
  28751. Pusher.prototype.unbind = function (event_name, callback, context) {
  28752. this.global_emitter.unbind(event_name, callback, context);
  28753. return this;
  28754. };
  28755. Pusher.prototype.bind_global = function (callback) {
  28756. this.global_emitter.bind_global(callback);
  28757. return this;
  28758. };
  28759. Pusher.prototype.unbind_global = function (callback) {
  28760. this.global_emitter.unbind_global(callback);
  28761. return this;
  28762. };
  28763. Pusher.prototype.unbind_all = function (callback) {
  28764. this.global_emitter.unbind_all();
  28765. return this;
  28766. };
  28767. Pusher.prototype.subscribeAll = function () {
  28768. var channelName;
  28769. for (channelName in this.channels.channels) {
  28770. if (this.channels.channels.hasOwnProperty(channelName)) {
  28771. this.subscribe(channelName);
  28772. }
  28773. }
  28774. };
  28775. Pusher.prototype.subscribe = function (channel_name) {
  28776. var channel = this.channels.add(channel_name, this);
  28777. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  28778. channel.reinstateSubscription();
  28779. }
  28780. else if (!channel.subscriptionPending && this.connection.state === "connected") {
  28781. channel.subscribe();
  28782. }
  28783. return channel;
  28784. };
  28785. Pusher.prototype.unsubscribe = function (channel_name) {
  28786. var channel = this.channels.find(channel_name);
  28787. if (channel && channel.subscriptionPending) {
  28788. channel.cancelSubscription();
  28789. }
  28790. else {
  28791. channel = this.channels.remove(channel_name);
  28792. if (channel && this.connection.state === "connected") {
  28793. channel.unsubscribe();
  28794. }
  28795. }
  28796. };
  28797. Pusher.prototype.send_event = function (event_name, data, channel) {
  28798. return this.connection.send_event(event_name, data, channel);
  28799. };
  28800. Pusher.prototype.isEncrypted = function () {
  28801. if (runtime_1["default"].getProtocol() === "https:") {
  28802. return true;
  28803. }
  28804. else {
  28805. return Boolean(this.config.encrypted);
  28806. }
  28807. };
  28808. Pusher.instances = [];
  28809. Pusher.isReady = false;
  28810. Pusher.logToConsole = false;
  28811. Pusher.Runtime = runtime_1["default"];
  28812. Pusher.ScriptReceivers = runtime_1["default"].ScriptReceivers;
  28813. Pusher.DependenciesReceivers = runtime_1["default"].DependenciesReceivers;
  28814. Pusher.auth_callbacks = runtime_1["default"].auth_callbacks;
  28815. return Pusher;
  28816. }());
  28817. exports.__esModule = true;
  28818. exports["default"] = Pusher;
  28819. function checkAppKey(key) {
  28820. if (key === null || key === undefined) {
  28821. throw "You must pass your app key when you instantiate Pusher.";
  28822. }
  28823. }
  28824. runtime_1["default"].setup(Pusher);
  28825. /***/ }),
  28826. /* 2 */
  28827. /***/ (function(module, exports, __webpack_require__) {
  28828. "use strict";
  28829. var dependencies_1 = __webpack_require__(3);
  28830. var xhr_auth_1 = __webpack_require__(7);
  28831. var jsonp_auth_1 = __webpack_require__(14);
  28832. var script_request_1 = __webpack_require__(15);
  28833. var jsonp_request_1 = __webpack_require__(16);
  28834. var script_receiver_factory_1 = __webpack_require__(4);
  28835. var jsonp_timeline_1 = __webpack_require__(17);
  28836. var transports_1 = __webpack_require__(18);
  28837. var net_info_1 = __webpack_require__(25);
  28838. var default_strategy_1 = __webpack_require__(26);
  28839. var transport_connection_initializer_1 = __webpack_require__(27);
  28840. var http_1 = __webpack_require__(28);
  28841. var Runtime = {
  28842. nextAuthCallbackID: 1,
  28843. auth_callbacks: {},
  28844. ScriptReceivers: script_receiver_factory_1.ScriptReceivers,
  28845. DependenciesReceivers: dependencies_1.DependenciesReceivers,
  28846. getDefaultStrategy: default_strategy_1["default"],
  28847. Transports: transports_1["default"],
  28848. transportConnectionInitializer: transport_connection_initializer_1["default"],
  28849. HTTPFactory: http_1["default"],
  28850. TimelineTransport: jsonp_timeline_1["default"],
  28851. getXHRAPI: function () {
  28852. return window.XMLHttpRequest;
  28853. },
  28854. getWebSocketAPI: function () {
  28855. return window.WebSocket || window.MozWebSocket;
  28856. },
  28857. setup: function (PusherClass) {
  28858. var _this = this;
  28859. window.Pusher = PusherClass;
  28860. var initializeOnDocumentBody = function () {
  28861. _this.onDocumentBody(PusherClass.ready);
  28862. };
  28863. if (!window.JSON) {
  28864. dependencies_1.Dependencies.load("json2", {}, initializeOnDocumentBody);
  28865. }
  28866. else {
  28867. initializeOnDocumentBody();
  28868. }
  28869. },
  28870. getDocument: function () {
  28871. return document;
  28872. },
  28873. getProtocol: function () {
  28874. return this.getDocument().location.protocol;
  28875. },
  28876. getAuthorizers: function () {
  28877. return { ajax: xhr_auth_1["default"], jsonp: jsonp_auth_1["default"] };
  28878. },
  28879. onDocumentBody: function (callback) {
  28880. var _this = this;
  28881. if (document.body) {
  28882. callback();
  28883. }
  28884. else {
  28885. setTimeout(function () {
  28886. _this.onDocumentBody(callback);
  28887. }, 0);
  28888. }
  28889. },
  28890. createJSONPRequest: function (url, data) {
  28891. return new jsonp_request_1["default"](url, data);
  28892. },
  28893. createScriptRequest: function (src) {
  28894. return new script_request_1["default"](src);
  28895. },
  28896. getLocalStorage: function () {
  28897. try {
  28898. return window.localStorage;
  28899. }
  28900. catch (e) {
  28901. return undefined;
  28902. }
  28903. },
  28904. createXHR: function () {
  28905. if (this.getXHRAPI()) {
  28906. return this.createXMLHttpRequest();
  28907. }
  28908. else {
  28909. return this.createMicrosoftXHR();
  28910. }
  28911. },
  28912. createXMLHttpRequest: function () {
  28913. var Constructor = this.getXHRAPI();
  28914. return new Constructor();
  28915. },
  28916. createMicrosoftXHR: function () {
  28917. return new ActiveXObject("Microsoft.XMLHTTP");
  28918. },
  28919. getNetwork: function () {
  28920. return net_info_1.Network;
  28921. },
  28922. createWebSocket: function (url) {
  28923. var Constructor = this.getWebSocketAPI();
  28924. return new Constructor(url);
  28925. },
  28926. createSocketRequest: function (method, url) {
  28927. if (this.isXHRSupported()) {
  28928. return this.HTTPFactory.createXHR(method, url);
  28929. }
  28930. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  28931. return this.HTTPFactory.createXDR(method, url);
  28932. }
  28933. else {
  28934. throw "Cross-origin HTTP requests are not supported";
  28935. }
  28936. },
  28937. isXHRSupported: function () {
  28938. var Constructor = this.getXHRAPI();
  28939. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  28940. },
  28941. isXDRSupported: function (encrypted) {
  28942. var protocol = encrypted ? "https:" : "http:";
  28943. var documentProtocol = this.getProtocol();
  28944. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  28945. },
  28946. addUnloadListener: function (listener) {
  28947. if (window.addEventListener !== undefined) {
  28948. window.addEventListener("unload", listener, false);
  28949. }
  28950. else if (window.attachEvent !== undefined) {
  28951. window.attachEvent("onunload", listener);
  28952. }
  28953. },
  28954. removeUnloadListener: function (listener) {
  28955. if (window.addEventListener !== undefined) {
  28956. window.removeEventListener("unload", listener, false);
  28957. }
  28958. else if (window.detachEvent !== undefined) {
  28959. window.detachEvent("onunload", listener);
  28960. }
  28961. }
  28962. };
  28963. exports.__esModule = true;
  28964. exports["default"] = Runtime;
  28965. /***/ }),
  28966. /* 3 */
  28967. /***/ (function(module, exports, __webpack_require__) {
  28968. "use strict";
  28969. var script_receiver_factory_1 = __webpack_require__(4);
  28970. var defaults_1 = __webpack_require__(5);
  28971. var dependency_loader_1 = __webpack_require__(6);
  28972. exports.DependenciesReceivers = new script_receiver_factory_1.ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  28973. exports.Dependencies = new dependency_loader_1["default"]({
  28974. cdn_http: defaults_1["default"].cdn_http,
  28975. cdn_https: defaults_1["default"].cdn_https,
  28976. version: defaults_1["default"].VERSION,
  28977. suffix: defaults_1["default"].dependency_suffix,
  28978. receivers: exports.DependenciesReceivers
  28979. });
  28980. /***/ }),
  28981. /* 4 */
  28982. /***/ (function(module, exports) {
  28983. "use strict";
  28984. var ScriptReceiverFactory = (function () {
  28985. function ScriptReceiverFactory(prefix, name) {
  28986. this.lastId = 0;
  28987. this.prefix = prefix;
  28988. this.name = name;
  28989. }
  28990. ScriptReceiverFactory.prototype.create = function (callback) {
  28991. this.lastId++;
  28992. var number = this.lastId;
  28993. var id = this.prefix + number;
  28994. var name = this.name + "[" + number + "]";
  28995. var called = false;
  28996. var callbackWrapper = function () {
  28997. if (!called) {
  28998. callback.apply(null, arguments);
  28999. called = true;
  29000. }
  29001. };
  29002. this[number] = callbackWrapper;
  29003. return { number: number, id: id, name: name, callback: callbackWrapper };
  29004. };
  29005. ScriptReceiverFactory.prototype.remove = function (receiver) {
  29006. delete this[receiver.number];
  29007. };
  29008. return ScriptReceiverFactory;
  29009. }());
  29010. exports.ScriptReceiverFactory = ScriptReceiverFactory;
  29011. exports.ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  29012. /***/ }),
  29013. /* 5 */
  29014. /***/ (function(module, exports) {
  29015. "use strict";
  29016. var Defaults = {
  29017. VERSION: "4.1.0",
  29018. PROTOCOL: 7,
  29019. host: 'ws.pusherapp.com',
  29020. ws_port: 80,
  29021. wss_port: 443,
  29022. sockjs_host: 'sockjs.pusher.com',
  29023. sockjs_http_port: 80,
  29024. sockjs_https_port: 443,
  29025. sockjs_path: "/pusher",
  29026. stats_host: 'stats.pusher.com',
  29027. channel_auth_endpoint: '/pusher/auth',
  29028. channel_auth_transport: 'ajax',
  29029. activity_timeout: 120000,
  29030. pong_timeout: 30000,
  29031. unavailable_timeout: 10000,
  29032. cdn_http: 'http://js.pusher.com',
  29033. cdn_https: 'https://js.pusher.com',
  29034. dependency_suffix: ''
  29035. };
  29036. exports.__esModule = true;
  29037. exports["default"] = Defaults;
  29038. /***/ }),
  29039. /* 6 */
  29040. /***/ (function(module, exports, __webpack_require__) {
  29041. "use strict";
  29042. var script_receiver_factory_1 = __webpack_require__(4);
  29043. var runtime_1 = __webpack_require__(2);
  29044. var DependencyLoader = (function () {
  29045. function DependencyLoader(options) {
  29046. this.options = options;
  29047. this.receivers = options.receivers || script_receiver_factory_1.ScriptReceivers;
  29048. this.loading = {};
  29049. }
  29050. DependencyLoader.prototype.load = function (name, options, callback) {
  29051. var self = this;
  29052. if (self.loading[name] && self.loading[name].length > 0) {
  29053. self.loading[name].push(callback);
  29054. }
  29055. else {
  29056. self.loading[name] = [callback];
  29057. var request = runtime_1["default"].createScriptRequest(self.getPath(name, options));
  29058. var receiver = self.receivers.create(function (error) {
  29059. self.receivers.remove(receiver);
  29060. if (self.loading[name]) {
  29061. var callbacks = self.loading[name];
  29062. delete self.loading[name];
  29063. var successCallback = function (wasSuccessful) {
  29064. if (!wasSuccessful) {
  29065. request.cleanup();
  29066. }
  29067. };
  29068. for (var i = 0; i < callbacks.length; i++) {
  29069. callbacks[i](error, successCallback);
  29070. }
  29071. }
  29072. });
  29073. request.send(receiver);
  29074. }
  29075. };
  29076. DependencyLoader.prototype.getRoot = function (options) {
  29077. var cdn;
  29078. var protocol = runtime_1["default"].getDocument().location.protocol;
  29079. if ((options && options.encrypted) || protocol === "https:") {
  29080. cdn = this.options.cdn_https;
  29081. }
  29082. else {
  29083. cdn = this.options.cdn_http;
  29084. }
  29085. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  29086. };
  29087. DependencyLoader.prototype.getPath = function (name, options) {
  29088. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  29089. };
  29090. ;
  29091. return DependencyLoader;
  29092. }());
  29093. exports.__esModule = true;
  29094. exports["default"] = DependencyLoader;
  29095. /***/ }),
  29096. /* 7 */
  29097. /***/ (function(module, exports, __webpack_require__) {
  29098. "use strict";
  29099. var logger_1 = __webpack_require__(8);
  29100. var runtime_1 = __webpack_require__(2);
  29101. var ajax = function (context, socketId, callback) {
  29102. var self = this, xhr;
  29103. xhr = runtime_1["default"].createXHR();
  29104. xhr.open("POST", self.options.authEndpoint, true);
  29105. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  29106. for (var headerName in this.authOptions.headers) {
  29107. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  29108. }
  29109. xhr.onreadystatechange = function () {
  29110. if (xhr.readyState === 4) {
  29111. if (xhr.status === 200) {
  29112. var data, parsed = false;
  29113. try {
  29114. data = JSON.parse(xhr.responseText);
  29115. parsed = true;
  29116. }
  29117. catch (e) {
  29118. callback(true, 'JSON returned from webapp was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  29119. }
  29120. if (parsed) {
  29121. callback(false, data);
  29122. }
  29123. }
  29124. else {
  29125. logger_1["default"].warn("Couldn't get auth info from your webapp", xhr.status);
  29126. callback(true, xhr.status);
  29127. }
  29128. }
  29129. };
  29130. xhr.send(this.composeQuery(socketId));
  29131. return xhr;
  29132. };
  29133. exports.__esModule = true;
  29134. exports["default"] = ajax;
  29135. /***/ }),
  29136. /* 8 */
  29137. /***/ (function(module, exports, __webpack_require__) {
  29138. "use strict";
  29139. var collections_1 = __webpack_require__(9);
  29140. var pusher_1 = __webpack_require__(1);
  29141. var Logger = {
  29142. debug: function () {
  29143. var args = [];
  29144. for (var _i = 0; _i < arguments.length; _i++) {
  29145. args[_i - 0] = arguments[_i];
  29146. }
  29147. if (!pusher_1["default"].log) {
  29148. return;
  29149. }
  29150. pusher_1["default"].log(collections_1.stringify.apply(this, arguments));
  29151. },
  29152. warn: function () {
  29153. var args = [];
  29154. for (var _i = 0; _i < arguments.length; _i++) {
  29155. args[_i - 0] = arguments[_i];
  29156. }
  29157. var message = collections_1.stringify.apply(this, arguments);
  29158. if ((window).console) {
  29159. if ((window).console.warn) {
  29160. (window).console.warn(message);
  29161. }
  29162. else if ((window).console.log) {
  29163. (window).console.log(message);
  29164. }
  29165. }
  29166. if (pusher_1["default"].log) {
  29167. pusher_1["default"].log(message);
  29168. }
  29169. }
  29170. };
  29171. exports.__esModule = true;
  29172. exports["default"] = Logger;
  29173. /***/ }),
  29174. /* 9 */
  29175. /***/ (function(module, exports, __webpack_require__) {
  29176. "use strict";
  29177. var base64_1 = __webpack_require__(10);
  29178. var util_1 = __webpack_require__(11);
  29179. function extend(target) {
  29180. var sources = [];
  29181. for (var _i = 1; _i < arguments.length; _i++) {
  29182. sources[_i - 1] = arguments[_i];
  29183. }
  29184. for (var i = 0; i < sources.length; i++) {
  29185. var extensions = sources[i];
  29186. for (var property in extensions) {
  29187. if (extensions[property] && extensions[property].constructor &&
  29188. extensions[property].constructor === Object) {
  29189. target[property] = extend(target[property] || {}, extensions[property]);
  29190. }
  29191. else {
  29192. target[property] = extensions[property];
  29193. }
  29194. }
  29195. }
  29196. return target;
  29197. }
  29198. exports.extend = extend;
  29199. function stringify() {
  29200. var m = ["Pusher"];
  29201. for (var i = 0; i < arguments.length; i++) {
  29202. if (typeof arguments[i] === "string") {
  29203. m.push(arguments[i]);
  29204. }
  29205. else {
  29206. m.push(safeJSONStringify(arguments[i]));
  29207. }
  29208. }
  29209. return m.join(" : ");
  29210. }
  29211. exports.stringify = stringify;
  29212. function arrayIndexOf(array, item) {
  29213. var nativeIndexOf = Array.prototype.indexOf;
  29214. if (array === null) {
  29215. return -1;
  29216. }
  29217. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  29218. return array.indexOf(item);
  29219. }
  29220. for (var i = 0, l = array.length; i < l; i++) {
  29221. if (array[i] === item) {
  29222. return i;
  29223. }
  29224. }
  29225. return -1;
  29226. }
  29227. exports.arrayIndexOf = arrayIndexOf;
  29228. function objectApply(object, f) {
  29229. for (var key in object) {
  29230. if (Object.prototype.hasOwnProperty.call(object, key)) {
  29231. f(object[key], key, object);
  29232. }
  29233. }
  29234. }
  29235. exports.objectApply = objectApply;
  29236. function keys(object) {
  29237. var keys = [];
  29238. objectApply(object, function (_, key) {
  29239. keys.push(key);
  29240. });
  29241. return keys;
  29242. }
  29243. exports.keys = keys;
  29244. function values(object) {
  29245. var values = [];
  29246. objectApply(object, function (value) {
  29247. values.push(value);
  29248. });
  29249. return values;
  29250. }
  29251. exports.values = values;
  29252. function apply(array, f, context) {
  29253. for (var i = 0; i < array.length; i++) {
  29254. f.call(context || (window), array[i], i, array);
  29255. }
  29256. }
  29257. exports.apply = apply;
  29258. function map(array, f) {
  29259. var result = [];
  29260. for (var i = 0; i < array.length; i++) {
  29261. result.push(f(array[i], i, array, result));
  29262. }
  29263. return result;
  29264. }
  29265. exports.map = map;
  29266. function mapObject(object, f) {
  29267. var result = {};
  29268. objectApply(object, function (value, key) {
  29269. result[key] = f(value);
  29270. });
  29271. return result;
  29272. }
  29273. exports.mapObject = mapObject;
  29274. function filter(array, test) {
  29275. test = test || function (value) { return !!value; };
  29276. var result = [];
  29277. for (var i = 0; i < array.length; i++) {
  29278. if (test(array[i], i, array, result)) {
  29279. result.push(array[i]);
  29280. }
  29281. }
  29282. return result;
  29283. }
  29284. exports.filter = filter;
  29285. function filterObject(object, test) {
  29286. var result = {};
  29287. objectApply(object, function (value, key) {
  29288. if ((test && test(value, key, object, result)) || Boolean(value)) {
  29289. result[key] = value;
  29290. }
  29291. });
  29292. return result;
  29293. }
  29294. exports.filterObject = filterObject;
  29295. function flatten(object) {
  29296. var result = [];
  29297. objectApply(object, function (value, key) {
  29298. result.push([key, value]);
  29299. });
  29300. return result;
  29301. }
  29302. exports.flatten = flatten;
  29303. function any(array, test) {
  29304. for (var i = 0; i < array.length; i++) {
  29305. if (test(array[i], i, array)) {
  29306. return true;
  29307. }
  29308. }
  29309. return false;
  29310. }
  29311. exports.any = any;
  29312. function all(array, test) {
  29313. for (var i = 0; i < array.length; i++) {
  29314. if (!test(array[i], i, array)) {
  29315. return false;
  29316. }
  29317. }
  29318. return true;
  29319. }
  29320. exports.all = all;
  29321. function encodeParamsObject(data) {
  29322. return mapObject(data, function (value) {
  29323. if (typeof value === "object") {
  29324. value = safeJSONStringify(value);
  29325. }
  29326. return encodeURIComponent(base64_1["default"](value.toString()));
  29327. });
  29328. }
  29329. exports.encodeParamsObject = encodeParamsObject;
  29330. function buildQueryString(data) {
  29331. var params = filterObject(data, function (value) {
  29332. return value !== undefined;
  29333. });
  29334. var query = map(flatten(encodeParamsObject(params)), util_1["default"].method("join", "=")).join("&");
  29335. return query;
  29336. }
  29337. exports.buildQueryString = buildQueryString;
  29338. function decycleObject(object) {
  29339. var objects = [], paths = [];
  29340. return (function derez(value, path) {
  29341. var i, name, nu;
  29342. switch (typeof value) {
  29343. case 'object':
  29344. if (!value) {
  29345. return null;
  29346. }
  29347. for (i = 0; i < objects.length; i += 1) {
  29348. if (objects[i] === value) {
  29349. return { $ref: paths[i] };
  29350. }
  29351. }
  29352. objects.push(value);
  29353. paths.push(path);
  29354. if (Object.prototype.toString.apply(value) === '[object Array]') {
  29355. nu = [];
  29356. for (i = 0; i < value.length; i += 1) {
  29357. nu[i] = derez(value[i], path + '[' + i + ']');
  29358. }
  29359. }
  29360. else {
  29361. nu = {};
  29362. for (name in value) {
  29363. if (Object.prototype.hasOwnProperty.call(value, name)) {
  29364. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  29365. }
  29366. }
  29367. }
  29368. return nu;
  29369. case 'number':
  29370. case 'string':
  29371. case 'boolean':
  29372. return value;
  29373. }
  29374. }(object, '$'));
  29375. }
  29376. exports.decycleObject = decycleObject;
  29377. function safeJSONStringify(source) {
  29378. try {
  29379. return JSON.stringify(source);
  29380. }
  29381. catch (e) {
  29382. return JSON.stringify(decycleObject(source));
  29383. }
  29384. }
  29385. exports.safeJSONStringify = safeJSONStringify;
  29386. /***/ }),
  29387. /* 10 */
  29388. /***/ (function(module, exports, __webpack_require__) {
  29389. "use strict";
  29390. function encode(s) {
  29391. return btoa(utob(s));
  29392. }
  29393. exports.__esModule = true;
  29394. exports["default"] = encode;
  29395. var fromCharCode = String.fromCharCode;
  29396. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  29397. var b64tab = {};
  29398. for (var i = 0, l = b64chars.length; i < l; i++) {
  29399. b64tab[b64chars.charAt(i)] = i;
  29400. }
  29401. var cb_utob = function (c) {
  29402. var cc = c.charCodeAt(0);
  29403. return cc < 0x80 ? c
  29404. : cc < 0x800 ? fromCharCode(0xc0 | (cc >>> 6)) +
  29405. fromCharCode(0x80 | (cc & 0x3f))
  29406. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  29407. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  29408. fromCharCode(0x80 | (cc & 0x3f));
  29409. };
  29410. var utob = function (u) {
  29411. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  29412. };
  29413. var cb_encode = function (ccc) {
  29414. var padlen = [0, 2, 1][ccc.length % 3];
  29415. var ord = ccc.charCodeAt(0) << 16
  29416. | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
  29417. | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0));
  29418. var chars = [
  29419. b64chars.charAt(ord >>> 18),
  29420. b64chars.charAt((ord >>> 12) & 63),
  29421. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  29422. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  29423. ];
  29424. return chars.join('');
  29425. };
  29426. var btoa = (window).btoa || function (b) {
  29427. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  29428. };
  29429. /***/ }),
  29430. /* 11 */
  29431. /***/ (function(module, exports, __webpack_require__) {
  29432. "use strict";
  29433. var timers_1 = __webpack_require__(12);
  29434. var Util = {
  29435. now: function () {
  29436. if (Date.now) {
  29437. return Date.now();
  29438. }
  29439. else {
  29440. return new Date().valueOf();
  29441. }
  29442. },
  29443. defer: function (callback) {
  29444. return new timers_1.OneOffTimer(0, callback);
  29445. },
  29446. method: function (name) {
  29447. var args = [];
  29448. for (var _i = 1; _i < arguments.length; _i++) {
  29449. args[_i - 1] = arguments[_i];
  29450. }
  29451. var boundArguments = Array.prototype.slice.call(arguments, 1);
  29452. return function (object) {
  29453. return object[name].apply(object, boundArguments.concat(arguments));
  29454. };
  29455. }
  29456. };
  29457. exports.__esModule = true;
  29458. exports["default"] = Util;
  29459. /***/ }),
  29460. /* 12 */
  29461. /***/ (function(module, exports, __webpack_require__) {
  29462. "use strict";
  29463. var __extends = (this && this.__extends) || function (d, b) {
  29464. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29465. function __() { this.constructor = d; }
  29466. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29467. };
  29468. var abstract_timer_1 = __webpack_require__(13);
  29469. function clearTimeout(timer) {
  29470. (window).clearTimeout(timer);
  29471. }
  29472. function clearInterval(timer) {
  29473. (window).clearInterval(timer);
  29474. }
  29475. var OneOffTimer = (function (_super) {
  29476. __extends(OneOffTimer, _super);
  29477. function OneOffTimer(delay, callback) {
  29478. _super.call(this, setTimeout, clearTimeout, delay, function (timer) {
  29479. callback();
  29480. return null;
  29481. });
  29482. }
  29483. return OneOffTimer;
  29484. }(abstract_timer_1["default"]));
  29485. exports.OneOffTimer = OneOffTimer;
  29486. var PeriodicTimer = (function (_super) {
  29487. __extends(PeriodicTimer, _super);
  29488. function PeriodicTimer(delay, callback) {
  29489. _super.call(this, setInterval, clearInterval, delay, function (timer) {
  29490. callback();
  29491. return timer;
  29492. });
  29493. }
  29494. return PeriodicTimer;
  29495. }(abstract_timer_1["default"]));
  29496. exports.PeriodicTimer = PeriodicTimer;
  29497. /***/ }),
  29498. /* 13 */
  29499. /***/ (function(module, exports) {
  29500. "use strict";
  29501. var Timer = (function () {
  29502. function Timer(set, clear, delay, callback) {
  29503. var _this = this;
  29504. this.clear = clear;
  29505. this.timer = set(function () {
  29506. if (_this.timer) {
  29507. _this.timer = callback(_this.timer);
  29508. }
  29509. }, delay);
  29510. }
  29511. Timer.prototype.isRunning = function () {
  29512. return this.timer !== null;
  29513. };
  29514. Timer.prototype.ensureAborted = function () {
  29515. if (this.timer) {
  29516. this.clear(this.timer);
  29517. this.timer = null;
  29518. }
  29519. };
  29520. return Timer;
  29521. }());
  29522. exports.__esModule = true;
  29523. exports["default"] = Timer;
  29524. /***/ }),
  29525. /* 14 */
  29526. /***/ (function(module, exports, __webpack_require__) {
  29527. "use strict";
  29528. var logger_1 = __webpack_require__(8);
  29529. var jsonp = function (context, socketId, callback) {
  29530. if (this.authOptions.headers !== undefined) {
  29531. logger_1["default"].warn("Warn", "To send headers with the auth request, you must use AJAX, rather than JSONP.");
  29532. }
  29533. var callbackName = context.nextAuthCallbackID.toString();
  29534. context.nextAuthCallbackID++;
  29535. var document = context.getDocument();
  29536. var script = document.createElement("script");
  29537. context.auth_callbacks[callbackName] = function (data) {
  29538. callback(false, data);
  29539. };
  29540. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  29541. script.src = this.options.authEndpoint +
  29542. '?callback=' +
  29543. encodeURIComponent(callback_name) +
  29544. '&' +
  29545. this.composeQuery(socketId);
  29546. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  29547. head.insertBefore(script, head.firstChild);
  29548. };
  29549. exports.__esModule = true;
  29550. exports["default"] = jsonp;
  29551. /***/ }),
  29552. /* 15 */
  29553. /***/ (function(module, exports) {
  29554. "use strict";
  29555. var ScriptRequest = (function () {
  29556. function ScriptRequest(src) {
  29557. this.src = src;
  29558. }
  29559. ScriptRequest.prototype.send = function (receiver) {
  29560. var self = this;
  29561. var errorString = "Error loading " + self.src;
  29562. self.script = document.createElement("script");
  29563. self.script.id = receiver.id;
  29564. self.script.src = self.src;
  29565. self.script.type = "text/javascript";
  29566. self.script.charset = "UTF-8";
  29567. if (self.script.addEventListener) {
  29568. self.script.onerror = function () {
  29569. receiver.callback(errorString);
  29570. };
  29571. self.script.onload = function () {
  29572. receiver.callback(null);
  29573. };
  29574. }
  29575. else {
  29576. self.script.onreadystatechange = function () {
  29577. if (self.script.readyState === 'loaded' ||
  29578. self.script.readyState === 'complete') {
  29579. receiver.callback(null);
  29580. }
  29581. };
  29582. }
  29583. if (self.script.async === undefined && document.attachEvent &&
  29584. /opera/i.test(navigator.userAgent)) {
  29585. self.errorScript = document.createElement("script");
  29586. self.errorScript.id = receiver.id + "_error";
  29587. self.errorScript.text = receiver.name + "('" + errorString + "');";
  29588. self.script.async = self.errorScript.async = false;
  29589. }
  29590. else {
  29591. self.script.async = true;
  29592. }
  29593. var head = document.getElementsByTagName('head')[0];
  29594. head.insertBefore(self.script, head.firstChild);
  29595. if (self.errorScript) {
  29596. head.insertBefore(self.errorScript, self.script.nextSibling);
  29597. }
  29598. };
  29599. ScriptRequest.prototype.cleanup = function () {
  29600. if (this.script) {
  29601. this.script.onload = this.script.onerror = null;
  29602. this.script.onreadystatechange = null;
  29603. }
  29604. if (this.script && this.script.parentNode) {
  29605. this.script.parentNode.removeChild(this.script);
  29606. }
  29607. if (this.errorScript && this.errorScript.parentNode) {
  29608. this.errorScript.parentNode.removeChild(this.errorScript);
  29609. }
  29610. this.script = null;
  29611. this.errorScript = null;
  29612. };
  29613. return ScriptRequest;
  29614. }());
  29615. exports.__esModule = true;
  29616. exports["default"] = ScriptRequest;
  29617. /***/ }),
  29618. /* 16 */
  29619. /***/ (function(module, exports, __webpack_require__) {
  29620. "use strict";
  29621. var Collections = __webpack_require__(9);
  29622. var runtime_1 = __webpack_require__(2);
  29623. var JSONPRequest = (function () {
  29624. function JSONPRequest(url, data) {
  29625. this.url = url;
  29626. this.data = data;
  29627. }
  29628. JSONPRequest.prototype.send = function (receiver) {
  29629. if (this.request) {
  29630. return;
  29631. }
  29632. var query = Collections.buildQueryString(this.data);
  29633. var url = this.url + "/" + receiver.number + "?" + query;
  29634. this.request = runtime_1["default"].createScriptRequest(url);
  29635. this.request.send(receiver);
  29636. };
  29637. JSONPRequest.prototype.cleanup = function () {
  29638. if (this.request) {
  29639. this.request.cleanup();
  29640. }
  29641. };
  29642. return JSONPRequest;
  29643. }());
  29644. exports.__esModule = true;
  29645. exports["default"] = JSONPRequest;
  29646. /***/ }),
  29647. /* 17 */
  29648. /***/ (function(module, exports, __webpack_require__) {
  29649. "use strict";
  29650. var runtime_1 = __webpack_require__(2);
  29651. var script_receiver_factory_1 = __webpack_require__(4);
  29652. var getAgent = function (sender, encrypted) {
  29653. return function (data, callback) {
  29654. var scheme = "http" + (encrypted ? "s" : "") + "://";
  29655. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  29656. var request = runtime_1["default"].createJSONPRequest(url, data);
  29657. var receiver = runtime_1["default"].ScriptReceivers.create(function (error, result) {
  29658. script_receiver_factory_1.ScriptReceivers.remove(receiver);
  29659. request.cleanup();
  29660. if (result && result.host) {
  29661. sender.host = result.host;
  29662. }
  29663. if (callback) {
  29664. callback(error, result);
  29665. }
  29666. });
  29667. request.send(receiver);
  29668. };
  29669. };
  29670. var jsonp = {
  29671. name: 'jsonp',
  29672. getAgent: getAgent
  29673. };
  29674. exports.__esModule = true;
  29675. exports["default"] = jsonp;
  29676. /***/ }),
  29677. /* 18 */
  29678. /***/ (function(module, exports, __webpack_require__) {
  29679. "use strict";
  29680. var transports_1 = __webpack_require__(19);
  29681. var transport_1 = __webpack_require__(21);
  29682. var URLSchemes = __webpack_require__(20);
  29683. var runtime_1 = __webpack_require__(2);
  29684. var dependencies_1 = __webpack_require__(3);
  29685. var Collections = __webpack_require__(9);
  29686. var SockJSTransport = new transport_1["default"]({
  29687. file: "sockjs",
  29688. urls: URLSchemes.sockjs,
  29689. handlesActivityChecks: true,
  29690. supportsPing: false,
  29691. isSupported: function () {
  29692. return true;
  29693. },
  29694. isInitialized: function () {
  29695. return window.SockJS !== undefined;
  29696. },
  29697. getSocket: function (url, options) {
  29698. return new window.SockJS(url, null, {
  29699. js_path: dependencies_1.Dependencies.getPath("sockjs", {
  29700. encrypted: options.encrypted
  29701. }),
  29702. ignore_null_origin: options.ignoreNullOrigin
  29703. });
  29704. },
  29705. beforeOpen: function (socket, path) {
  29706. socket.send(JSON.stringify({
  29707. path: path
  29708. }));
  29709. }
  29710. });
  29711. var xdrConfiguration = {
  29712. isSupported: function (environment) {
  29713. var yes = runtime_1["default"].isXDRSupported(environment.encrypted);
  29714. return yes;
  29715. }
  29716. };
  29717. var XDRStreamingTransport = new transport_1["default"](Collections.extend({}, transports_1.streamingConfiguration, xdrConfiguration));
  29718. var XDRPollingTransport = new transport_1["default"](Collections.extend({}, transports_1.pollingConfiguration, xdrConfiguration));
  29719. transports_1["default"].xdr_streaming = XDRStreamingTransport;
  29720. transports_1["default"].xdr_polling = XDRPollingTransport;
  29721. transports_1["default"].sockjs = SockJSTransport;
  29722. exports.__esModule = true;
  29723. exports["default"] = transports_1["default"];
  29724. /***/ }),
  29725. /* 19 */
  29726. /***/ (function(module, exports, __webpack_require__) {
  29727. "use strict";
  29728. var URLSchemes = __webpack_require__(20);
  29729. var transport_1 = __webpack_require__(21);
  29730. var Collections = __webpack_require__(9);
  29731. var runtime_1 = __webpack_require__(2);
  29732. var WSTransport = new transport_1["default"]({
  29733. urls: URLSchemes.ws,
  29734. handlesActivityChecks: false,
  29735. supportsPing: false,
  29736. isInitialized: function () {
  29737. return Boolean(runtime_1["default"].getWebSocketAPI());
  29738. },
  29739. isSupported: function () {
  29740. return Boolean(runtime_1["default"].getWebSocketAPI());
  29741. },
  29742. getSocket: function (url) {
  29743. return runtime_1["default"].createWebSocket(url);
  29744. }
  29745. });
  29746. var httpConfiguration = {
  29747. urls: URLSchemes.http,
  29748. handlesActivityChecks: false,
  29749. supportsPing: true,
  29750. isInitialized: function () {
  29751. return true;
  29752. }
  29753. };
  29754. exports.streamingConfiguration = Collections.extend({ getSocket: function (url) {
  29755. return runtime_1["default"].HTTPFactory.createStreamingSocket(url);
  29756. }
  29757. }, httpConfiguration);
  29758. exports.pollingConfiguration = Collections.extend({ getSocket: function (url) {
  29759. return runtime_1["default"].HTTPFactory.createPollingSocket(url);
  29760. }
  29761. }, httpConfiguration);
  29762. var xhrConfiguration = {
  29763. isSupported: function () {
  29764. return runtime_1["default"].isXHRSupported();
  29765. }
  29766. };
  29767. var XHRStreamingTransport = new transport_1["default"](Collections.extend({}, exports.streamingConfiguration, xhrConfiguration));
  29768. var XHRPollingTransport = new transport_1["default"](Collections.extend({}, exports.pollingConfiguration, xhrConfiguration));
  29769. var Transports = {
  29770. ws: WSTransport,
  29771. xhr_streaming: XHRStreamingTransport,
  29772. xhr_polling: XHRPollingTransport
  29773. };
  29774. exports.__esModule = true;
  29775. exports["default"] = Transports;
  29776. /***/ }),
  29777. /* 20 */
  29778. /***/ (function(module, exports, __webpack_require__) {
  29779. "use strict";
  29780. var defaults_1 = __webpack_require__(5);
  29781. function getGenericURL(baseScheme, params, path) {
  29782. var scheme = baseScheme + (params.encrypted ? "s" : "");
  29783. var host = params.encrypted ? params.hostEncrypted : params.hostUnencrypted;
  29784. return scheme + "://" + host + path;
  29785. }
  29786. function getGenericPath(key, queryString) {
  29787. var path = "/app/" + key;
  29788. var query = "?protocol=" + defaults_1["default"].PROTOCOL +
  29789. "&client=js" +
  29790. "&version=" + defaults_1["default"].VERSION +
  29791. (queryString ? ("&" + queryString) : "");
  29792. return path + query;
  29793. }
  29794. exports.ws = {
  29795. getInitial: function (key, params) {
  29796. return getGenericURL("ws", params, getGenericPath(key, "flash=false"));
  29797. }
  29798. };
  29799. exports.http = {
  29800. getInitial: function (key, params) {
  29801. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  29802. return getGenericURL("http", params, path);
  29803. }
  29804. };
  29805. exports.sockjs = {
  29806. getInitial: function (key, params) {
  29807. return getGenericURL("http", params, params.httpPath || "/pusher");
  29808. },
  29809. getPath: function (key, params) {
  29810. return getGenericPath(key);
  29811. }
  29812. };
  29813. /***/ }),
  29814. /* 21 */
  29815. /***/ (function(module, exports, __webpack_require__) {
  29816. "use strict";
  29817. var transport_connection_1 = __webpack_require__(22);
  29818. var Transport = (function () {
  29819. function Transport(hooks) {
  29820. this.hooks = hooks;
  29821. }
  29822. Transport.prototype.isSupported = function (environment) {
  29823. return this.hooks.isSupported(environment);
  29824. };
  29825. Transport.prototype.createConnection = function (name, priority, key, options) {
  29826. return new transport_connection_1["default"](this.hooks, name, priority, key, options);
  29827. };
  29828. return Transport;
  29829. }());
  29830. exports.__esModule = true;
  29831. exports["default"] = Transport;
  29832. /***/ }),
  29833. /* 22 */
  29834. /***/ (function(module, exports, __webpack_require__) {
  29835. "use strict";
  29836. var __extends = (this && this.__extends) || function (d, b) {
  29837. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29838. function __() { this.constructor = d; }
  29839. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29840. };
  29841. var util_1 = __webpack_require__(11);
  29842. var Collections = __webpack_require__(9);
  29843. var dispatcher_1 = __webpack_require__(23);
  29844. var logger_1 = __webpack_require__(8);
  29845. var runtime_1 = __webpack_require__(2);
  29846. var TransportConnection = (function (_super) {
  29847. __extends(TransportConnection, _super);
  29848. function TransportConnection(hooks, name, priority, key, options) {
  29849. _super.call(this);
  29850. this.initialize = runtime_1["default"].transportConnectionInitializer;
  29851. this.hooks = hooks;
  29852. this.name = name;
  29853. this.priority = priority;
  29854. this.key = key;
  29855. this.options = options;
  29856. this.state = "new";
  29857. this.timeline = options.timeline;
  29858. this.activityTimeout = options.activityTimeout;
  29859. this.id = this.timeline.generateUniqueID();
  29860. }
  29861. TransportConnection.prototype.handlesActivityChecks = function () {
  29862. return Boolean(this.hooks.handlesActivityChecks);
  29863. };
  29864. TransportConnection.prototype.supportsPing = function () {
  29865. return Boolean(this.hooks.supportsPing);
  29866. };
  29867. TransportConnection.prototype.connect = function () {
  29868. var _this = this;
  29869. if (this.socket || this.state !== "initialized") {
  29870. return false;
  29871. }
  29872. var url = this.hooks.urls.getInitial(this.key, this.options);
  29873. try {
  29874. this.socket = this.hooks.getSocket(url, this.options);
  29875. }
  29876. catch (e) {
  29877. util_1["default"].defer(function () {
  29878. _this.onError(e);
  29879. _this.changeState("closed");
  29880. });
  29881. return false;
  29882. }
  29883. this.bindListeners();
  29884. logger_1["default"].debug("Connecting", { transport: this.name, url: url });
  29885. this.changeState("connecting");
  29886. return true;
  29887. };
  29888. TransportConnection.prototype.close = function () {
  29889. if (this.socket) {
  29890. this.socket.close();
  29891. return true;
  29892. }
  29893. else {
  29894. return false;
  29895. }
  29896. };
  29897. TransportConnection.prototype.send = function (data) {
  29898. var _this = this;
  29899. if (this.state === "open") {
  29900. util_1["default"].defer(function () {
  29901. if (_this.socket) {
  29902. _this.socket.send(data);
  29903. }
  29904. });
  29905. return true;
  29906. }
  29907. else {
  29908. return false;
  29909. }
  29910. };
  29911. TransportConnection.prototype.ping = function () {
  29912. if (this.state === "open" && this.supportsPing()) {
  29913. this.socket.ping();
  29914. }
  29915. };
  29916. TransportConnection.prototype.onOpen = function () {
  29917. if (this.hooks.beforeOpen) {
  29918. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  29919. }
  29920. this.changeState("open");
  29921. this.socket.onopen = undefined;
  29922. };
  29923. TransportConnection.prototype.onError = function (error) {
  29924. this.emit("error", { type: 'WebSocketError', error: error });
  29925. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  29926. };
  29927. TransportConnection.prototype.onClose = function (closeEvent) {
  29928. if (closeEvent) {
  29929. this.changeState("closed", {
  29930. code: closeEvent.code,
  29931. reason: closeEvent.reason,
  29932. wasClean: closeEvent.wasClean
  29933. });
  29934. }
  29935. else {
  29936. this.changeState("closed");
  29937. }
  29938. this.unbindListeners();
  29939. this.socket = undefined;
  29940. };
  29941. TransportConnection.prototype.onMessage = function (message) {
  29942. this.emit("message", message);
  29943. };
  29944. TransportConnection.prototype.onActivity = function () {
  29945. this.emit("activity");
  29946. };
  29947. TransportConnection.prototype.bindListeners = function () {
  29948. var _this = this;
  29949. this.socket.onopen = function () {
  29950. _this.onOpen();
  29951. };
  29952. this.socket.onerror = function (error) {
  29953. _this.onError(error);
  29954. };
  29955. this.socket.onclose = function (closeEvent) {
  29956. _this.onClose(closeEvent);
  29957. };
  29958. this.socket.onmessage = function (message) {
  29959. _this.onMessage(message);
  29960. };
  29961. if (this.supportsPing()) {
  29962. this.socket.onactivity = function () { _this.onActivity(); };
  29963. }
  29964. };
  29965. TransportConnection.prototype.unbindListeners = function () {
  29966. if (this.socket) {
  29967. this.socket.onopen = undefined;
  29968. this.socket.onerror = undefined;
  29969. this.socket.onclose = undefined;
  29970. this.socket.onmessage = undefined;
  29971. if (this.supportsPing()) {
  29972. this.socket.onactivity = undefined;
  29973. }
  29974. }
  29975. };
  29976. TransportConnection.prototype.changeState = function (state, params) {
  29977. this.state = state;
  29978. this.timeline.info(this.buildTimelineMessage({
  29979. state: state,
  29980. params: params
  29981. }));
  29982. this.emit(state, params);
  29983. };
  29984. TransportConnection.prototype.buildTimelineMessage = function (message) {
  29985. return Collections.extend({ cid: this.id }, message);
  29986. };
  29987. return TransportConnection;
  29988. }(dispatcher_1["default"]));
  29989. exports.__esModule = true;
  29990. exports["default"] = TransportConnection;
  29991. /***/ }),
  29992. /* 23 */
  29993. /***/ (function(module, exports, __webpack_require__) {
  29994. "use strict";
  29995. var Collections = __webpack_require__(9);
  29996. var callback_registry_1 = __webpack_require__(24);
  29997. var Dispatcher = (function () {
  29998. function Dispatcher(failThrough) {
  29999. this.callbacks = new callback_registry_1["default"]();
  30000. this.global_callbacks = [];
  30001. this.failThrough = failThrough;
  30002. }
  30003. Dispatcher.prototype.bind = function (eventName, callback, context) {
  30004. this.callbacks.add(eventName, callback, context);
  30005. return this;
  30006. };
  30007. Dispatcher.prototype.bind_global = function (callback) {
  30008. this.global_callbacks.push(callback);
  30009. return this;
  30010. };
  30011. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  30012. this.callbacks.remove(eventName, callback, context);
  30013. return this;
  30014. };
  30015. Dispatcher.prototype.unbind_global = function (callback) {
  30016. if (!callback) {
  30017. this.global_callbacks = [];
  30018. return this;
  30019. }
  30020. this.global_callbacks = Collections.filter(this.global_callbacks || [], function (c) { return c !== callback; });
  30021. return this;
  30022. };
  30023. Dispatcher.prototype.unbind_all = function () {
  30024. this.unbind();
  30025. this.unbind_global();
  30026. return this;
  30027. };
  30028. Dispatcher.prototype.emit = function (eventName, data) {
  30029. var i;
  30030. for (i = 0; i < this.global_callbacks.length; i++) {
  30031. this.global_callbacks[i](eventName, data);
  30032. }
  30033. var callbacks = this.callbacks.get(eventName);
  30034. if (callbacks && callbacks.length > 0) {
  30035. for (i = 0; i < callbacks.length; i++) {
  30036. callbacks[i].fn.call(callbacks[i].context || (window), data);
  30037. }
  30038. }
  30039. else if (this.failThrough) {
  30040. this.failThrough(eventName, data);
  30041. }
  30042. return this;
  30043. };
  30044. return Dispatcher;
  30045. }());
  30046. exports.__esModule = true;
  30047. exports["default"] = Dispatcher;
  30048. /***/ }),
  30049. /* 24 */
  30050. /***/ (function(module, exports, __webpack_require__) {
  30051. "use strict";
  30052. var Collections = __webpack_require__(9);
  30053. var CallbackRegistry = (function () {
  30054. function CallbackRegistry() {
  30055. this._callbacks = {};
  30056. }
  30057. CallbackRegistry.prototype.get = function (name) {
  30058. return this._callbacks[prefix(name)];
  30059. };
  30060. CallbackRegistry.prototype.add = function (name, callback, context) {
  30061. var prefixedEventName = prefix(name);
  30062. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  30063. this._callbacks[prefixedEventName].push({
  30064. fn: callback,
  30065. context: context
  30066. });
  30067. };
  30068. CallbackRegistry.prototype.remove = function (name, callback, context) {
  30069. if (!name && !callback && !context) {
  30070. this._callbacks = {};
  30071. return;
  30072. }
  30073. var names = name ? [prefix(name)] : Collections.keys(this._callbacks);
  30074. if (callback || context) {
  30075. this.removeCallback(names, callback, context);
  30076. }
  30077. else {
  30078. this.removeAllCallbacks(names);
  30079. }
  30080. };
  30081. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  30082. Collections.apply(names, function (name) {
  30083. this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function (binding) {
  30084. return (callback && callback !== binding.fn) ||
  30085. (context && context !== binding.context);
  30086. });
  30087. if (this._callbacks[name].length === 0) {
  30088. delete this._callbacks[name];
  30089. }
  30090. }, this);
  30091. };
  30092. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  30093. Collections.apply(names, function (name) {
  30094. delete this._callbacks[name];
  30095. }, this);
  30096. };
  30097. return CallbackRegistry;
  30098. }());
  30099. exports.__esModule = true;
  30100. exports["default"] = CallbackRegistry;
  30101. function prefix(name) {
  30102. return "_" + name;
  30103. }
  30104. /***/ }),
  30105. /* 25 */
  30106. /***/ (function(module, exports, __webpack_require__) {
  30107. "use strict";
  30108. var __extends = (this && this.__extends) || function (d, b) {
  30109. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30110. function __() { this.constructor = d; }
  30111. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30112. };
  30113. var dispatcher_1 = __webpack_require__(23);
  30114. var NetInfo = (function (_super) {
  30115. __extends(NetInfo, _super);
  30116. function NetInfo() {
  30117. _super.call(this);
  30118. var self = this;
  30119. if (window.addEventListener !== undefined) {
  30120. window.addEventListener("online", function () {
  30121. self.emit('online');
  30122. }, false);
  30123. window.addEventListener("offline", function () {
  30124. self.emit('offline');
  30125. }, false);
  30126. }
  30127. }
  30128. NetInfo.prototype.isOnline = function () {
  30129. if (window.navigator.onLine === undefined) {
  30130. return true;
  30131. }
  30132. else {
  30133. return window.navigator.onLine;
  30134. }
  30135. };
  30136. return NetInfo;
  30137. }(dispatcher_1["default"]));
  30138. exports.NetInfo = NetInfo;
  30139. exports.Network = new NetInfo();
  30140. /***/ }),
  30141. /* 26 */
  30142. /***/ (function(module, exports) {
  30143. "use strict";
  30144. var getDefaultStrategy = function (config) {
  30145. var wsStrategy;
  30146. if (config.encrypted) {
  30147. wsStrategy = [
  30148. ":best_connected_ever",
  30149. ":ws_loop",
  30150. [":delayed", 2000, [":http_fallback_loop"]]
  30151. ];
  30152. }
  30153. else {
  30154. wsStrategy = [
  30155. ":best_connected_ever",
  30156. ":ws_loop",
  30157. [":delayed", 2000, [":wss_loop"]],
  30158. [":delayed", 5000, [":http_fallback_loop"]]
  30159. ];
  30160. }
  30161. return [
  30162. [":def", "ws_options", {
  30163. hostUnencrypted: config.wsHost + ":" + config.wsPort,
  30164. hostEncrypted: config.wsHost + ":" + config.wssPort
  30165. }],
  30166. [":def", "wss_options", [":extend", ":ws_options", {
  30167. encrypted: true
  30168. }]],
  30169. [":def", "sockjs_options", {
  30170. hostUnencrypted: config.httpHost + ":" + config.httpPort,
  30171. hostEncrypted: config.httpHost + ":" + config.httpsPort,
  30172. httpPath: config.httpPath
  30173. }],
  30174. [":def", "timeouts", {
  30175. loop: true,
  30176. timeout: 15000,
  30177. timeoutLimit: 60000
  30178. }],
  30179. [":def", "ws_manager", [":transport_manager", {
  30180. lives: 2,
  30181. minPingDelay: 10000,
  30182. maxPingDelay: config.activity_timeout
  30183. }]],
  30184. [":def", "streaming_manager", [":transport_manager", {
  30185. lives: 2,
  30186. minPingDelay: 10000,
  30187. maxPingDelay: config.activity_timeout
  30188. }]],
  30189. [":def_transport", "ws", "ws", 3, ":ws_options", ":ws_manager"],
  30190. [":def_transport", "wss", "ws", 3, ":wss_options", ":ws_manager"],
  30191. [":def_transport", "sockjs", "sockjs", 1, ":sockjs_options"],
  30192. [":def_transport", "xhr_streaming", "xhr_streaming", 1, ":sockjs_options", ":streaming_manager"],
  30193. [":def_transport", "xdr_streaming", "xdr_streaming", 1, ":sockjs_options", ":streaming_manager"],
  30194. [":def_transport", "xhr_polling", "xhr_polling", 1, ":sockjs_options"],
  30195. [":def_transport", "xdr_polling", "xdr_polling", 1, ":sockjs_options"],
  30196. [":def", "ws_loop", [":sequential", ":timeouts", ":ws"]],
  30197. [":def", "wss_loop", [":sequential", ":timeouts", ":wss"]],
  30198. [":def", "sockjs_loop", [":sequential", ":timeouts", ":sockjs"]],
  30199. [":def", "streaming_loop", [":sequential", ":timeouts",
  30200. [":if", [":is_supported", ":xhr_streaming"],
  30201. ":xhr_streaming",
  30202. ":xdr_streaming"
  30203. ]
  30204. ]],
  30205. [":def", "polling_loop", [":sequential", ":timeouts",
  30206. [":if", [":is_supported", ":xhr_polling"],
  30207. ":xhr_polling",
  30208. ":xdr_polling"
  30209. ]
  30210. ]],
  30211. [":def", "http_loop", [":if", [":is_supported", ":streaming_loop"], [
  30212. ":best_connected_ever",
  30213. ":streaming_loop",
  30214. [":delayed", 4000, [":polling_loop"]]
  30215. ], [
  30216. ":polling_loop"
  30217. ]]],
  30218. [":def", "http_fallback_loop",
  30219. [":if", [":is_supported", ":http_loop"], [
  30220. ":http_loop"
  30221. ], [
  30222. ":sockjs_loop"
  30223. ]]
  30224. ],
  30225. [":def", "strategy",
  30226. [":cached", 1800000,
  30227. [":first_connected",
  30228. [":if", [":is_supported", ":ws"],
  30229. wsStrategy,
  30230. ":http_fallback_loop"
  30231. ]
  30232. ]
  30233. ]
  30234. ]
  30235. ];
  30236. };
  30237. exports.__esModule = true;
  30238. exports["default"] = getDefaultStrategy;
  30239. /***/ }),
  30240. /* 27 */
  30241. /***/ (function(module, exports, __webpack_require__) {
  30242. "use strict";
  30243. var dependencies_1 = __webpack_require__(3);
  30244. function default_1() {
  30245. var self = this;
  30246. self.timeline.info(self.buildTimelineMessage({
  30247. transport: self.name + (self.options.encrypted ? "s" : "")
  30248. }));
  30249. if (self.hooks.isInitialized()) {
  30250. self.changeState("initialized");
  30251. }
  30252. else if (self.hooks.file) {
  30253. self.changeState("initializing");
  30254. dependencies_1.Dependencies.load(self.hooks.file, { encrypted: self.options.encrypted }, function (error, callback) {
  30255. if (self.hooks.isInitialized()) {
  30256. self.changeState("initialized");
  30257. callback(true);
  30258. }
  30259. else {
  30260. if (error) {
  30261. self.onError(error);
  30262. }
  30263. self.onClose();
  30264. callback(false);
  30265. }
  30266. });
  30267. }
  30268. else {
  30269. self.onClose();
  30270. }
  30271. }
  30272. exports.__esModule = true;
  30273. exports["default"] = default_1;
  30274. /***/ }),
  30275. /* 28 */
  30276. /***/ (function(module, exports, __webpack_require__) {
  30277. "use strict";
  30278. var http_xdomain_request_1 = __webpack_require__(29);
  30279. var http_1 = __webpack_require__(31);
  30280. http_1["default"].createXDR = function (method, url) {
  30281. return this.createRequest(http_xdomain_request_1["default"], method, url);
  30282. };
  30283. exports.__esModule = true;
  30284. exports["default"] = http_1["default"];
  30285. /***/ }),
  30286. /* 29 */
  30287. /***/ (function(module, exports, __webpack_require__) {
  30288. "use strict";
  30289. var Errors = __webpack_require__(30);
  30290. var hooks = {
  30291. getRequest: function (socket) {
  30292. var xdr = new window.XDomainRequest();
  30293. xdr.ontimeout = function () {
  30294. socket.emit("error", new Errors.RequestTimedOut());
  30295. socket.close();
  30296. };
  30297. xdr.onerror = function (e) {
  30298. socket.emit("error", e);
  30299. socket.close();
  30300. };
  30301. xdr.onprogress = function () {
  30302. if (xdr.responseText && xdr.responseText.length > 0) {
  30303. socket.onChunk(200, xdr.responseText);
  30304. }
  30305. };
  30306. xdr.onload = function () {
  30307. if (xdr.responseText && xdr.responseText.length > 0) {
  30308. socket.onChunk(200, xdr.responseText);
  30309. }
  30310. socket.emit("finished", 200);
  30311. socket.close();
  30312. };
  30313. return xdr;
  30314. },
  30315. abortRequest: function (xdr) {
  30316. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  30317. xdr.abort();
  30318. }
  30319. };
  30320. exports.__esModule = true;
  30321. exports["default"] = hooks;
  30322. /***/ }),
  30323. /* 30 */
  30324. /***/ (function(module, exports) {
  30325. "use strict";
  30326. var __extends = (this && this.__extends) || function (d, b) {
  30327. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30328. function __() { this.constructor = d; }
  30329. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30330. };
  30331. var BadEventName = (function (_super) {
  30332. __extends(BadEventName, _super);
  30333. function BadEventName() {
  30334. _super.apply(this, arguments);
  30335. }
  30336. return BadEventName;
  30337. }(Error));
  30338. exports.BadEventName = BadEventName;
  30339. var RequestTimedOut = (function (_super) {
  30340. __extends(RequestTimedOut, _super);
  30341. function RequestTimedOut() {
  30342. _super.apply(this, arguments);
  30343. }
  30344. return RequestTimedOut;
  30345. }(Error));
  30346. exports.RequestTimedOut = RequestTimedOut;
  30347. var TransportPriorityTooLow = (function (_super) {
  30348. __extends(TransportPriorityTooLow, _super);
  30349. function TransportPriorityTooLow() {
  30350. _super.apply(this, arguments);
  30351. }
  30352. return TransportPriorityTooLow;
  30353. }(Error));
  30354. exports.TransportPriorityTooLow = TransportPriorityTooLow;
  30355. var TransportClosed = (function (_super) {
  30356. __extends(TransportClosed, _super);
  30357. function TransportClosed() {
  30358. _super.apply(this, arguments);
  30359. }
  30360. return TransportClosed;
  30361. }(Error));
  30362. exports.TransportClosed = TransportClosed;
  30363. var UnsupportedTransport = (function (_super) {
  30364. __extends(UnsupportedTransport, _super);
  30365. function UnsupportedTransport() {
  30366. _super.apply(this, arguments);
  30367. }
  30368. return UnsupportedTransport;
  30369. }(Error));
  30370. exports.UnsupportedTransport = UnsupportedTransport;
  30371. var UnsupportedStrategy = (function (_super) {
  30372. __extends(UnsupportedStrategy, _super);
  30373. function UnsupportedStrategy() {
  30374. _super.apply(this, arguments);
  30375. }
  30376. return UnsupportedStrategy;
  30377. }(Error));
  30378. exports.UnsupportedStrategy = UnsupportedStrategy;
  30379. /***/ }),
  30380. /* 31 */
  30381. /***/ (function(module, exports, __webpack_require__) {
  30382. "use strict";
  30383. var http_request_1 = __webpack_require__(32);
  30384. var http_socket_1 = __webpack_require__(33);
  30385. var http_streaming_socket_1 = __webpack_require__(35);
  30386. var http_polling_socket_1 = __webpack_require__(36);
  30387. var http_xhr_request_1 = __webpack_require__(37);
  30388. var HTTP = {
  30389. createStreamingSocket: function (url) {
  30390. return this.createSocket(http_streaming_socket_1["default"], url);
  30391. },
  30392. createPollingSocket: function (url) {
  30393. return this.createSocket(http_polling_socket_1["default"], url);
  30394. },
  30395. createSocket: function (hooks, url) {
  30396. return new http_socket_1["default"](hooks, url);
  30397. },
  30398. createXHR: function (method, url) {
  30399. return this.createRequest(http_xhr_request_1["default"], method, url);
  30400. },
  30401. createRequest: function (hooks, method, url) {
  30402. return new http_request_1["default"](hooks, method, url);
  30403. }
  30404. };
  30405. exports.__esModule = true;
  30406. exports["default"] = HTTP;
  30407. /***/ }),
  30408. /* 32 */
  30409. /***/ (function(module, exports, __webpack_require__) {
  30410. "use strict";
  30411. var __extends = (this && this.__extends) || function (d, b) {
  30412. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30413. function __() { this.constructor = d; }
  30414. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30415. };
  30416. var runtime_1 = __webpack_require__(2);
  30417. var dispatcher_1 = __webpack_require__(23);
  30418. var MAX_BUFFER_LENGTH = 256 * 1024;
  30419. var HTTPRequest = (function (_super) {
  30420. __extends(HTTPRequest, _super);
  30421. function HTTPRequest(hooks, method, url) {
  30422. _super.call(this);
  30423. this.hooks = hooks;
  30424. this.method = method;
  30425. this.url = url;
  30426. }
  30427. HTTPRequest.prototype.start = function (payload) {
  30428. var _this = this;
  30429. this.position = 0;
  30430. this.xhr = this.hooks.getRequest(this);
  30431. this.unloader = function () {
  30432. _this.close();
  30433. };
  30434. runtime_1["default"].addUnloadListener(this.unloader);
  30435. this.xhr.open(this.method, this.url, true);
  30436. if (this.xhr.setRequestHeader) {
  30437. this.xhr.setRequestHeader("Content-Type", "application/json");
  30438. }
  30439. this.xhr.send(payload);
  30440. };
  30441. HTTPRequest.prototype.close = function () {
  30442. if (this.unloader) {
  30443. runtime_1["default"].removeUnloadListener(this.unloader);
  30444. this.unloader = null;
  30445. }
  30446. if (this.xhr) {
  30447. this.hooks.abortRequest(this.xhr);
  30448. this.xhr = null;
  30449. }
  30450. };
  30451. HTTPRequest.prototype.onChunk = function (status, data) {
  30452. while (true) {
  30453. var chunk = this.advanceBuffer(data);
  30454. if (chunk) {
  30455. this.emit("chunk", { status: status, data: chunk });
  30456. }
  30457. else {
  30458. break;
  30459. }
  30460. }
  30461. if (this.isBufferTooLong(data)) {
  30462. this.emit("buffer_too_long");
  30463. }
  30464. };
  30465. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  30466. var unreadData = buffer.slice(this.position);
  30467. var endOfLinePosition = unreadData.indexOf("\n");
  30468. if (endOfLinePosition !== -1) {
  30469. this.position += endOfLinePosition + 1;
  30470. return unreadData.slice(0, endOfLinePosition);
  30471. }
  30472. else {
  30473. return null;
  30474. }
  30475. };
  30476. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  30477. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  30478. };
  30479. return HTTPRequest;
  30480. }(dispatcher_1["default"]));
  30481. exports.__esModule = true;
  30482. exports["default"] = HTTPRequest;
  30483. /***/ }),
  30484. /* 33 */
  30485. /***/ (function(module, exports, __webpack_require__) {
  30486. "use strict";
  30487. var state_1 = __webpack_require__(34);
  30488. var util_1 = __webpack_require__(11);
  30489. var runtime_1 = __webpack_require__(2);
  30490. var autoIncrement = 1;
  30491. var HTTPSocket = (function () {
  30492. function HTTPSocket(hooks, url) {
  30493. this.hooks = hooks;
  30494. this.session = randomNumber(1000) + "/" + randomString(8);
  30495. this.location = getLocation(url);
  30496. this.readyState = state_1["default"].CONNECTING;
  30497. this.openStream();
  30498. }
  30499. HTTPSocket.prototype.send = function (payload) {
  30500. return this.sendRaw(JSON.stringify([payload]));
  30501. };
  30502. HTTPSocket.prototype.ping = function () {
  30503. this.hooks.sendHeartbeat(this);
  30504. };
  30505. HTTPSocket.prototype.close = function (code, reason) {
  30506. this.onClose(code, reason, true);
  30507. };
  30508. HTTPSocket.prototype.sendRaw = function (payload) {
  30509. if (this.readyState === state_1["default"].OPEN) {
  30510. try {
  30511. runtime_1["default"].createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  30512. return true;
  30513. }
  30514. catch (e) {
  30515. return false;
  30516. }
  30517. }
  30518. else {
  30519. return false;
  30520. }
  30521. };
  30522. HTTPSocket.prototype.reconnect = function () {
  30523. this.closeStream();
  30524. this.openStream();
  30525. };
  30526. ;
  30527. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  30528. this.closeStream();
  30529. this.readyState = state_1["default"].CLOSED;
  30530. if (this.onclose) {
  30531. this.onclose({
  30532. code: code,
  30533. reason: reason,
  30534. wasClean: wasClean
  30535. });
  30536. }
  30537. };
  30538. HTTPSocket.prototype.onChunk = function (chunk) {
  30539. if (chunk.status !== 200) {
  30540. return;
  30541. }
  30542. if (this.readyState === state_1["default"].OPEN) {
  30543. this.onActivity();
  30544. }
  30545. var payload;
  30546. var type = chunk.data.slice(0, 1);
  30547. switch (type) {
  30548. case 'o':
  30549. payload = JSON.parse(chunk.data.slice(1) || '{}');
  30550. this.onOpen(payload);
  30551. break;
  30552. case 'a':
  30553. payload = JSON.parse(chunk.data.slice(1) || '[]');
  30554. for (var i = 0; i < payload.length; i++) {
  30555. this.onEvent(payload[i]);
  30556. }
  30557. break;
  30558. case 'm':
  30559. payload = JSON.parse(chunk.data.slice(1) || 'null');
  30560. this.onEvent(payload);
  30561. break;
  30562. case 'h':
  30563. this.hooks.onHeartbeat(this);
  30564. break;
  30565. case 'c':
  30566. payload = JSON.parse(chunk.data.slice(1) || '[]');
  30567. this.onClose(payload[0], payload[1], true);
  30568. break;
  30569. }
  30570. };
  30571. HTTPSocket.prototype.onOpen = function (options) {
  30572. if (this.readyState === state_1["default"].CONNECTING) {
  30573. if (options && options.hostname) {
  30574. this.location.base = replaceHost(this.location.base, options.hostname);
  30575. }
  30576. this.readyState = state_1["default"].OPEN;
  30577. if (this.onopen) {
  30578. this.onopen();
  30579. }
  30580. }
  30581. else {
  30582. this.onClose(1006, "Server lost session", true);
  30583. }
  30584. };
  30585. HTTPSocket.prototype.onEvent = function (event) {
  30586. if (this.readyState === state_1["default"].OPEN && this.onmessage) {
  30587. this.onmessage({ data: event });
  30588. }
  30589. };
  30590. HTTPSocket.prototype.onActivity = function () {
  30591. if (this.onactivity) {
  30592. this.onactivity();
  30593. }
  30594. };
  30595. HTTPSocket.prototype.onError = function (error) {
  30596. if (this.onerror) {
  30597. this.onerror(error);
  30598. }
  30599. };
  30600. HTTPSocket.prototype.openStream = function () {
  30601. var _this = this;
  30602. this.stream = runtime_1["default"].createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  30603. this.stream.bind("chunk", function (chunk) {
  30604. _this.onChunk(chunk);
  30605. });
  30606. this.stream.bind("finished", function (status) {
  30607. _this.hooks.onFinished(_this, status);
  30608. });
  30609. this.stream.bind("buffer_too_long", function () {
  30610. _this.reconnect();
  30611. });
  30612. try {
  30613. this.stream.start();
  30614. }
  30615. catch (error) {
  30616. util_1["default"].defer(function () {
  30617. _this.onError(error);
  30618. _this.onClose(1006, "Could not start streaming", false);
  30619. });
  30620. }
  30621. };
  30622. HTTPSocket.prototype.closeStream = function () {
  30623. if (this.stream) {
  30624. this.stream.unbind_all();
  30625. this.stream.close();
  30626. this.stream = null;
  30627. }
  30628. };
  30629. return HTTPSocket;
  30630. }());
  30631. function getLocation(url) {
  30632. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  30633. return {
  30634. base: parts[1],
  30635. queryString: parts[2]
  30636. };
  30637. }
  30638. function getSendURL(url, session) {
  30639. return url.base + "/" + session + "/xhr_send";
  30640. }
  30641. function getUniqueURL(url) {
  30642. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  30643. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  30644. }
  30645. function replaceHost(url, hostname) {
  30646. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  30647. return urlParts[1] + hostname + urlParts[3];
  30648. }
  30649. function randomNumber(max) {
  30650. return Math.floor(Math.random() * max);
  30651. }
  30652. function randomString(length) {
  30653. var result = [];
  30654. for (var i = 0; i < length; i++) {
  30655. result.push(randomNumber(32).toString(32));
  30656. }
  30657. return result.join('');
  30658. }
  30659. exports.__esModule = true;
  30660. exports["default"] = HTTPSocket;
  30661. /***/ }),
  30662. /* 34 */
  30663. /***/ (function(module, exports) {
  30664. "use strict";
  30665. var State;
  30666. (function (State) {
  30667. State[State["CONNECTING"] = 0] = "CONNECTING";
  30668. State[State["OPEN"] = 1] = "OPEN";
  30669. State[State["CLOSED"] = 3] = "CLOSED";
  30670. })(State || (State = {}));
  30671. exports.__esModule = true;
  30672. exports["default"] = State;
  30673. /***/ }),
  30674. /* 35 */
  30675. /***/ (function(module, exports) {
  30676. "use strict";
  30677. var hooks = {
  30678. getReceiveURL: function (url, session) {
  30679. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  30680. },
  30681. onHeartbeat: function (socket) {
  30682. socket.sendRaw("[]");
  30683. },
  30684. sendHeartbeat: function (socket) {
  30685. socket.sendRaw("[]");
  30686. },
  30687. onFinished: function (socket, status) {
  30688. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  30689. }
  30690. };
  30691. exports.__esModule = true;
  30692. exports["default"] = hooks;
  30693. /***/ }),
  30694. /* 36 */
  30695. /***/ (function(module, exports) {
  30696. "use strict";
  30697. var hooks = {
  30698. getReceiveURL: function (url, session) {
  30699. return url.base + "/" + session + "/xhr" + url.queryString;
  30700. },
  30701. onHeartbeat: function () {
  30702. },
  30703. sendHeartbeat: function (socket) {
  30704. socket.sendRaw("[]");
  30705. },
  30706. onFinished: function (socket, status) {
  30707. if (status === 200) {
  30708. socket.reconnect();
  30709. }
  30710. else {
  30711. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  30712. }
  30713. }
  30714. };
  30715. exports.__esModule = true;
  30716. exports["default"] = hooks;
  30717. /***/ }),
  30718. /* 37 */
  30719. /***/ (function(module, exports, __webpack_require__) {
  30720. "use strict";
  30721. var runtime_1 = __webpack_require__(2);
  30722. var hooks = {
  30723. getRequest: function (socket) {
  30724. var Constructor = runtime_1["default"].getXHRAPI();
  30725. var xhr = new Constructor();
  30726. xhr.onreadystatechange = xhr.onprogress = function () {
  30727. switch (xhr.readyState) {
  30728. case 3:
  30729. if (xhr.responseText && xhr.responseText.length > 0) {
  30730. socket.onChunk(xhr.status, xhr.responseText);
  30731. }
  30732. break;
  30733. case 4:
  30734. if (xhr.responseText && xhr.responseText.length > 0) {
  30735. socket.onChunk(xhr.status, xhr.responseText);
  30736. }
  30737. socket.emit("finished", xhr.status);
  30738. socket.close();
  30739. break;
  30740. }
  30741. };
  30742. return xhr;
  30743. },
  30744. abortRequest: function (xhr) {
  30745. xhr.onreadystatechange = null;
  30746. xhr.abort();
  30747. }
  30748. };
  30749. exports.__esModule = true;
  30750. exports["default"] = hooks;
  30751. /***/ }),
  30752. /* 38 */
  30753. /***/ (function(module, exports, __webpack_require__) {
  30754. "use strict";
  30755. var Collections = __webpack_require__(9);
  30756. var util_1 = __webpack_require__(11);
  30757. var level_1 = __webpack_require__(39);
  30758. var Timeline = (function () {
  30759. function Timeline(key, session, options) {
  30760. this.key = key;
  30761. this.session = session;
  30762. this.events = [];
  30763. this.options = options || {};
  30764. this.sent = 0;
  30765. this.uniqueID = 0;
  30766. }
  30767. Timeline.prototype.log = function (level, event) {
  30768. if (level <= this.options.level) {
  30769. this.events.push(Collections.extend({}, event, { timestamp: util_1["default"].now() }));
  30770. if (this.options.limit && this.events.length > this.options.limit) {
  30771. this.events.shift();
  30772. }
  30773. }
  30774. };
  30775. Timeline.prototype.error = function (event) {
  30776. this.log(level_1["default"].ERROR, event);
  30777. };
  30778. Timeline.prototype.info = function (event) {
  30779. this.log(level_1["default"].INFO, event);
  30780. };
  30781. Timeline.prototype.debug = function (event) {
  30782. this.log(level_1["default"].DEBUG, event);
  30783. };
  30784. Timeline.prototype.isEmpty = function () {
  30785. return this.events.length === 0;
  30786. };
  30787. Timeline.prototype.send = function (sendfn, callback) {
  30788. var _this = this;
  30789. var data = Collections.extend({
  30790. session: this.session,
  30791. bundle: this.sent + 1,
  30792. key: this.key,
  30793. lib: "js",
  30794. version: this.options.version,
  30795. cluster: this.options.cluster,
  30796. features: this.options.features,
  30797. timeline: this.events
  30798. }, this.options.params);
  30799. this.events = [];
  30800. sendfn(data, function (error, result) {
  30801. if (!error) {
  30802. _this.sent++;
  30803. }
  30804. if (callback) {
  30805. callback(error, result);
  30806. }
  30807. });
  30808. return true;
  30809. };
  30810. Timeline.prototype.generateUniqueID = function () {
  30811. this.uniqueID++;
  30812. return this.uniqueID;
  30813. };
  30814. return Timeline;
  30815. }());
  30816. exports.__esModule = true;
  30817. exports["default"] = Timeline;
  30818. /***/ }),
  30819. /* 39 */
  30820. /***/ (function(module, exports) {
  30821. "use strict";
  30822. var TimelineLevel;
  30823. (function (TimelineLevel) {
  30824. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  30825. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  30826. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  30827. })(TimelineLevel || (TimelineLevel = {}));
  30828. exports.__esModule = true;
  30829. exports["default"] = TimelineLevel;
  30830. /***/ }),
  30831. /* 40 */
  30832. /***/ (function(module, exports, __webpack_require__) {
  30833. "use strict";
  30834. var Collections = __webpack_require__(9);
  30835. var util_1 = __webpack_require__(11);
  30836. var transport_manager_1 = __webpack_require__(41);
  30837. var Errors = __webpack_require__(30);
  30838. var transport_strategy_1 = __webpack_require__(55);
  30839. var sequential_strategy_1 = __webpack_require__(56);
  30840. var best_connected_ever_strategy_1 = __webpack_require__(57);
  30841. var cached_strategy_1 = __webpack_require__(58);
  30842. var delayed_strategy_1 = __webpack_require__(59);
  30843. var if_strategy_1 = __webpack_require__(60);
  30844. var first_connected_strategy_1 = __webpack_require__(61);
  30845. var runtime_1 = __webpack_require__(2);
  30846. var Transports = runtime_1["default"].Transports;
  30847. exports.build = function (scheme, options) {
  30848. var context = Collections.extend({}, globalContext, options);
  30849. return evaluate(scheme, context)[1].strategy;
  30850. };
  30851. var UnsupportedStrategy = {
  30852. isSupported: function () {
  30853. return false;
  30854. },
  30855. connect: function (_, callback) {
  30856. var deferred = util_1["default"].defer(function () {
  30857. callback(new Errors.UnsupportedStrategy());
  30858. });
  30859. return {
  30860. abort: function () {
  30861. deferred.ensureAborted();
  30862. },
  30863. forceMinPriority: function () { }
  30864. };
  30865. }
  30866. };
  30867. function returnWithOriginalContext(f) {
  30868. return function (context) {
  30869. return [f.apply(this, arguments), context];
  30870. };
  30871. }
  30872. var globalContext = {
  30873. extend: function (context, first, second) {
  30874. return [Collections.extend({}, first, second), context];
  30875. },
  30876. def: function (context, name, value) {
  30877. if (context[name] !== undefined) {
  30878. throw "Redefining symbol " + name;
  30879. }
  30880. context[name] = value;
  30881. return [undefined, context];
  30882. },
  30883. def_transport: function (context, name, type, priority, options, manager) {
  30884. var transportClass = Transports[type];
  30885. if (!transportClass) {
  30886. throw new Errors.UnsupportedTransport(type);
  30887. }
  30888. var enabled = (!context.enabledTransports ||
  30889. Collections.arrayIndexOf(context.enabledTransports, name) !== -1) &&
  30890. (!context.disabledTransports ||
  30891. Collections.arrayIndexOf(context.disabledTransports, name) === -1);
  30892. var transport;
  30893. if (enabled) {
  30894. transport = new transport_strategy_1["default"](name, priority, manager ? manager.getAssistant(transportClass) : transportClass, Collections.extend({
  30895. key: context.key,
  30896. encrypted: context.encrypted,
  30897. timeline: context.timeline,
  30898. ignoreNullOrigin: context.ignoreNullOrigin
  30899. }, options));
  30900. }
  30901. else {
  30902. transport = UnsupportedStrategy;
  30903. }
  30904. var newContext = context.def(context, name, transport)[1];
  30905. newContext.Transports = context.Transports || {};
  30906. newContext.Transports[name] = transport;
  30907. return [undefined, newContext];
  30908. },
  30909. transport_manager: returnWithOriginalContext(function (_, options) {
  30910. return new transport_manager_1["default"](options);
  30911. }),
  30912. sequential: returnWithOriginalContext(function (_, options) {
  30913. var strategies = Array.prototype.slice.call(arguments, 2);
  30914. return new sequential_strategy_1["default"](strategies, options);
  30915. }),
  30916. cached: returnWithOriginalContext(function (context, ttl, strategy) {
  30917. return new cached_strategy_1["default"](strategy, context.Transports, {
  30918. ttl: ttl,
  30919. timeline: context.timeline,
  30920. encrypted: context.encrypted
  30921. });
  30922. }),
  30923. first_connected: returnWithOriginalContext(function (_, strategy) {
  30924. return new first_connected_strategy_1["default"](strategy);
  30925. }),
  30926. best_connected_ever: returnWithOriginalContext(function () {
  30927. var strategies = Array.prototype.slice.call(arguments, 1);
  30928. return new best_connected_ever_strategy_1["default"](strategies);
  30929. }),
  30930. delayed: returnWithOriginalContext(function (_, delay, strategy) {
  30931. return new delayed_strategy_1["default"](strategy, { delay: delay });
  30932. }),
  30933. "if": returnWithOriginalContext(function (_, test, trueBranch, falseBranch) {
  30934. return new if_strategy_1["default"](test, trueBranch, falseBranch);
  30935. }),
  30936. is_supported: returnWithOriginalContext(function (_, strategy) {
  30937. return function () {
  30938. return strategy.isSupported();
  30939. };
  30940. })
  30941. };
  30942. function isSymbol(expression) {
  30943. return (typeof expression === "string") && expression.charAt(0) === ":";
  30944. }
  30945. function getSymbolValue(expression, context) {
  30946. return context[expression.slice(1)];
  30947. }
  30948. function evaluateListOfExpressions(expressions, context) {
  30949. if (expressions.length === 0) {
  30950. return [[], context];
  30951. }
  30952. var head = evaluate(expressions[0], context);
  30953. var tail = evaluateListOfExpressions(expressions.slice(1), head[1]);
  30954. return [[head[0]].concat(tail[0]), tail[1]];
  30955. }
  30956. function evaluateString(expression, context) {
  30957. if (!isSymbol(expression)) {
  30958. return [expression, context];
  30959. }
  30960. var value = getSymbolValue(expression, context);
  30961. if (value === undefined) {
  30962. throw "Undefined symbol " + expression;
  30963. }
  30964. return [value, context];
  30965. }
  30966. function evaluateArray(expression, context) {
  30967. if (isSymbol(expression[0])) {
  30968. var f = getSymbolValue(expression[0], context);
  30969. if (expression.length > 1) {
  30970. if (typeof f !== "function") {
  30971. throw "Calling non-function " + expression[0];
  30972. }
  30973. var args = [Collections.extend({}, context)].concat(Collections.map(expression.slice(1), function (arg) {
  30974. return evaluate(arg, Collections.extend({}, context))[0];
  30975. }));
  30976. return f.apply(this, args);
  30977. }
  30978. else {
  30979. return [f, context];
  30980. }
  30981. }
  30982. else {
  30983. return evaluateListOfExpressions(expression, context);
  30984. }
  30985. }
  30986. function evaluate(expression, context) {
  30987. if (typeof expression === "string") {
  30988. return evaluateString(expression, context);
  30989. }
  30990. else if (typeof expression === "object") {
  30991. if (expression instanceof Array && expression.length > 0) {
  30992. return evaluateArray(expression, context);
  30993. }
  30994. }
  30995. return [expression, context];
  30996. }
  30997. /***/ }),
  30998. /* 41 */
  30999. /***/ (function(module, exports, __webpack_require__) {
  31000. "use strict";
  31001. var factory_1 = __webpack_require__(42);
  31002. var TransportManager = (function () {
  31003. function TransportManager(options) {
  31004. this.options = options || {};
  31005. this.livesLeft = this.options.lives || Infinity;
  31006. }
  31007. TransportManager.prototype.getAssistant = function (transport) {
  31008. return factory_1["default"].createAssistantToTheTransportManager(this, transport, {
  31009. minPingDelay: this.options.minPingDelay,
  31010. maxPingDelay: this.options.maxPingDelay
  31011. });
  31012. };
  31013. TransportManager.prototype.isAlive = function () {
  31014. return this.livesLeft > 0;
  31015. };
  31016. TransportManager.prototype.reportDeath = function () {
  31017. this.livesLeft -= 1;
  31018. };
  31019. return TransportManager;
  31020. }());
  31021. exports.__esModule = true;
  31022. exports["default"] = TransportManager;
  31023. /***/ }),
  31024. /* 42 */
  31025. /***/ (function(module, exports, __webpack_require__) {
  31026. "use strict";
  31027. var assistant_to_the_transport_manager_1 = __webpack_require__(43);
  31028. var handshake_1 = __webpack_require__(44);
  31029. var pusher_authorizer_1 = __webpack_require__(47);
  31030. var timeline_sender_1 = __webpack_require__(48);
  31031. var presence_channel_1 = __webpack_require__(49);
  31032. var private_channel_1 = __webpack_require__(50);
  31033. var channel_1 = __webpack_require__(51);
  31034. var connection_manager_1 = __webpack_require__(53);
  31035. var channels_1 = __webpack_require__(54);
  31036. var Factory = {
  31037. createChannels: function () {
  31038. return new channels_1["default"]();
  31039. },
  31040. createConnectionManager: function (key, options) {
  31041. return new connection_manager_1["default"](key, options);
  31042. },
  31043. createChannel: function (name, pusher) {
  31044. return new channel_1["default"](name, pusher);
  31045. },
  31046. createPrivateChannel: function (name, pusher) {
  31047. return new private_channel_1["default"](name, pusher);
  31048. },
  31049. createPresenceChannel: function (name, pusher) {
  31050. return new presence_channel_1["default"](name, pusher);
  31051. },
  31052. createTimelineSender: function (timeline, options) {
  31053. return new timeline_sender_1["default"](timeline, options);
  31054. },
  31055. createAuthorizer: function (channel, options) {
  31056. if (options.authorizer) {
  31057. return options.authorizer(channel, options);
  31058. }
  31059. return new pusher_authorizer_1["default"](channel, options);
  31060. },
  31061. createHandshake: function (transport, callback) {
  31062. return new handshake_1["default"](transport, callback);
  31063. },
  31064. createAssistantToTheTransportManager: function (manager, transport, options) {
  31065. return new assistant_to_the_transport_manager_1["default"](manager, transport, options);
  31066. }
  31067. };
  31068. exports.__esModule = true;
  31069. exports["default"] = Factory;
  31070. /***/ }),
  31071. /* 43 */
  31072. /***/ (function(module, exports, __webpack_require__) {
  31073. "use strict";
  31074. var util_1 = __webpack_require__(11);
  31075. var Collections = __webpack_require__(9);
  31076. var AssistantToTheTransportManager = (function () {
  31077. function AssistantToTheTransportManager(manager, transport, options) {
  31078. this.manager = manager;
  31079. this.transport = transport;
  31080. this.minPingDelay = options.minPingDelay;
  31081. this.maxPingDelay = options.maxPingDelay;
  31082. this.pingDelay = undefined;
  31083. }
  31084. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  31085. var _this = this;
  31086. options = Collections.extend({}, options, {
  31087. activityTimeout: this.pingDelay
  31088. });
  31089. var connection = this.transport.createConnection(name, priority, key, options);
  31090. var openTimestamp = null;
  31091. var onOpen = function () {
  31092. connection.unbind("open", onOpen);
  31093. connection.bind("closed", onClosed);
  31094. openTimestamp = util_1["default"].now();
  31095. };
  31096. var onClosed = function (closeEvent) {
  31097. connection.unbind("closed", onClosed);
  31098. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  31099. _this.manager.reportDeath();
  31100. }
  31101. else if (!closeEvent.wasClean && openTimestamp) {
  31102. var lifespan = util_1["default"].now() - openTimestamp;
  31103. if (lifespan < 2 * _this.maxPingDelay) {
  31104. _this.manager.reportDeath();
  31105. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  31106. }
  31107. }
  31108. };
  31109. connection.bind("open", onOpen);
  31110. return connection;
  31111. };
  31112. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  31113. return this.manager.isAlive() && this.transport.isSupported(environment);
  31114. };
  31115. return AssistantToTheTransportManager;
  31116. }());
  31117. exports.__esModule = true;
  31118. exports["default"] = AssistantToTheTransportManager;
  31119. /***/ }),
  31120. /* 44 */
  31121. /***/ (function(module, exports, __webpack_require__) {
  31122. "use strict";
  31123. var Collections = __webpack_require__(9);
  31124. var Protocol = __webpack_require__(45);
  31125. var connection_1 = __webpack_require__(46);
  31126. var Handshake = (function () {
  31127. function Handshake(transport, callback) {
  31128. this.transport = transport;
  31129. this.callback = callback;
  31130. this.bindListeners();
  31131. }
  31132. Handshake.prototype.close = function () {
  31133. this.unbindListeners();
  31134. this.transport.close();
  31135. };
  31136. Handshake.prototype.bindListeners = function () {
  31137. var _this = this;
  31138. this.onMessage = function (m) {
  31139. _this.unbindListeners();
  31140. var result;
  31141. try {
  31142. result = Protocol.processHandshake(m);
  31143. }
  31144. catch (e) {
  31145. _this.finish("error", { error: e });
  31146. _this.transport.close();
  31147. return;
  31148. }
  31149. if (result.action === "connected") {
  31150. _this.finish("connected", {
  31151. connection: new connection_1["default"](result.id, _this.transport),
  31152. activityTimeout: result.activityTimeout
  31153. });
  31154. }
  31155. else {
  31156. _this.finish(result.action, { error: result.error });
  31157. _this.transport.close();
  31158. }
  31159. };
  31160. this.onClosed = function (closeEvent) {
  31161. _this.unbindListeners();
  31162. var action = Protocol.getCloseAction(closeEvent) || "backoff";
  31163. var error = Protocol.getCloseError(closeEvent);
  31164. _this.finish(action, { error: error });
  31165. };
  31166. this.transport.bind("message", this.onMessage);
  31167. this.transport.bind("closed", this.onClosed);
  31168. };
  31169. Handshake.prototype.unbindListeners = function () {
  31170. this.transport.unbind("message", this.onMessage);
  31171. this.transport.unbind("closed", this.onClosed);
  31172. };
  31173. Handshake.prototype.finish = function (action, params) {
  31174. this.callback(Collections.extend({ transport: this.transport, action: action }, params));
  31175. };
  31176. return Handshake;
  31177. }());
  31178. exports.__esModule = true;
  31179. exports["default"] = Handshake;
  31180. /***/ }),
  31181. /* 45 */
  31182. /***/ (function(module, exports) {
  31183. "use strict";
  31184. exports.decodeMessage = function (message) {
  31185. try {
  31186. var params = JSON.parse(message.data);
  31187. if (typeof params.data === 'string') {
  31188. try {
  31189. params.data = JSON.parse(params.data);
  31190. }
  31191. catch (e) {
  31192. if (!(e instanceof SyntaxError)) {
  31193. throw e;
  31194. }
  31195. }
  31196. }
  31197. return params;
  31198. }
  31199. catch (e) {
  31200. throw { type: 'MessageParseError', error: e, data: message.data };
  31201. }
  31202. };
  31203. exports.encodeMessage = function (message) {
  31204. return JSON.stringify(message);
  31205. };
  31206. exports.processHandshake = function (message) {
  31207. message = exports.decodeMessage(message);
  31208. if (message.event === "pusher:connection_established") {
  31209. if (!message.data.activity_timeout) {
  31210. throw "No activity timeout specified in handshake";
  31211. }
  31212. return {
  31213. action: "connected",
  31214. id: message.data.socket_id,
  31215. activityTimeout: message.data.activity_timeout * 1000
  31216. };
  31217. }
  31218. else if (message.event === "pusher:error") {
  31219. return {
  31220. action: this.getCloseAction(message.data),
  31221. error: this.getCloseError(message.data)
  31222. };
  31223. }
  31224. else {
  31225. throw "Invalid handshake";
  31226. }
  31227. };
  31228. exports.getCloseAction = function (closeEvent) {
  31229. if (closeEvent.code < 4000) {
  31230. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  31231. return "backoff";
  31232. }
  31233. else {
  31234. return null;
  31235. }
  31236. }
  31237. else if (closeEvent.code === 4000) {
  31238. return "ssl_only";
  31239. }
  31240. else if (closeEvent.code < 4100) {
  31241. return "refused";
  31242. }
  31243. else if (closeEvent.code < 4200) {
  31244. return "backoff";
  31245. }
  31246. else if (closeEvent.code < 4300) {
  31247. return "retry";
  31248. }
  31249. else {
  31250. return "refused";
  31251. }
  31252. };
  31253. exports.getCloseError = function (closeEvent) {
  31254. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  31255. return {
  31256. type: 'PusherError',
  31257. data: {
  31258. code: closeEvent.code,
  31259. message: closeEvent.reason || closeEvent.message
  31260. }
  31261. };
  31262. }
  31263. else {
  31264. return null;
  31265. }
  31266. };
  31267. /***/ }),
  31268. /* 46 */
  31269. /***/ (function(module, exports, __webpack_require__) {
  31270. "use strict";
  31271. var __extends = (this && this.__extends) || function (d, b) {
  31272. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31273. function __() { this.constructor = d; }
  31274. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31275. };
  31276. var Collections = __webpack_require__(9);
  31277. var dispatcher_1 = __webpack_require__(23);
  31278. var Protocol = __webpack_require__(45);
  31279. var logger_1 = __webpack_require__(8);
  31280. var Connection = (function (_super) {
  31281. __extends(Connection, _super);
  31282. function Connection(id, transport) {
  31283. _super.call(this);
  31284. this.id = id;
  31285. this.transport = transport;
  31286. this.activityTimeout = transport.activityTimeout;
  31287. this.bindListeners();
  31288. }
  31289. Connection.prototype.handlesActivityChecks = function () {
  31290. return this.transport.handlesActivityChecks();
  31291. };
  31292. Connection.prototype.send = function (data) {
  31293. return this.transport.send(data);
  31294. };
  31295. Connection.prototype.send_event = function (name, data, channel) {
  31296. var message = { event: name, data: data };
  31297. if (channel) {
  31298. message.channel = channel;
  31299. }
  31300. logger_1["default"].debug('Event sent', message);
  31301. return this.send(Protocol.encodeMessage(message));
  31302. };
  31303. Connection.prototype.ping = function () {
  31304. if (this.transport.supportsPing()) {
  31305. this.transport.ping();
  31306. }
  31307. else {
  31308. this.send_event('pusher:ping', {});
  31309. }
  31310. };
  31311. Connection.prototype.close = function () {
  31312. this.transport.close();
  31313. };
  31314. Connection.prototype.bindListeners = function () {
  31315. var _this = this;
  31316. var listeners = {
  31317. message: function (m) {
  31318. var message;
  31319. try {
  31320. message = Protocol.decodeMessage(m);
  31321. }
  31322. catch (e) {
  31323. _this.emit('error', {
  31324. type: 'MessageParseError',
  31325. error: e,
  31326. data: m.data
  31327. });
  31328. }
  31329. if (message !== undefined) {
  31330. logger_1["default"].debug('Event recd', message);
  31331. switch (message.event) {
  31332. case 'pusher:error':
  31333. _this.emit('error', { type: 'PusherError', data: message.data });
  31334. break;
  31335. case 'pusher:ping':
  31336. _this.emit("ping");
  31337. break;
  31338. case 'pusher:pong':
  31339. _this.emit("pong");
  31340. break;
  31341. }
  31342. _this.emit('message', message);
  31343. }
  31344. },
  31345. activity: function () {
  31346. _this.emit("activity");
  31347. },
  31348. error: function (error) {
  31349. _this.emit("error", { type: "WebSocketError", error: error });
  31350. },
  31351. closed: function (closeEvent) {
  31352. unbindListeners();
  31353. if (closeEvent && closeEvent.code) {
  31354. _this.handleCloseEvent(closeEvent);
  31355. }
  31356. _this.transport = null;
  31357. _this.emit("closed");
  31358. }
  31359. };
  31360. var unbindListeners = function () {
  31361. Collections.objectApply(listeners, function (listener, event) {
  31362. _this.transport.unbind(event, listener);
  31363. });
  31364. };
  31365. Collections.objectApply(listeners, function (listener, event) {
  31366. _this.transport.bind(event, listener);
  31367. });
  31368. };
  31369. Connection.prototype.handleCloseEvent = function (closeEvent) {
  31370. var action = Protocol.getCloseAction(closeEvent);
  31371. var error = Protocol.getCloseError(closeEvent);
  31372. if (error) {
  31373. this.emit('error', error);
  31374. }
  31375. if (action) {
  31376. this.emit(action);
  31377. }
  31378. };
  31379. return Connection;
  31380. }(dispatcher_1["default"]));
  31381. exports.__esModule = true;
  31382. exports["default"] = Connection;
  31383. /***/ }),
  31384. /* 47 */
  31385. /***/ (function(module, exports, __webpack_require__) {
  31386. "use strict";
  31387. var runtime_1 = __webpack_require__(2);
  31388. var PusherAuthorizer = (function () {
  31389. function PusherAuthorizer(channel, options) {
  31390. this.channel = channel;
  31391. var authTransport = options.authTransport;
  31392. if (typeof runtime_1["default"].getAuthorizers()[authTransport] === "undefined") {
  31393. throw "'" + authTransport + "' is not a recognized auth transport";
  31394. }
  31395. this.type = authTransport;
  31396. this.options = options;
  31397. this.authOptions = (options || {}).auth || {};
  31398. }
  31399. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  31400. var query = 'socket_id=' + encodeURIComponent(socketId) +
  31401. '&channel_name=' + encodeURIComponent(this.channel.name);
  31402. for (var i in this.authOptions.params) {
  31403. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  31404. }
  31405. return query;
  31406. };
  31407. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  31408. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime_1["default"].getAuthorizers();
  31409. return PusherAuthorizer.authorizers[this.type].call(this, runtime_1["default"], socketId, callback);
  31410. };
  31411. return PusherAuthorizer;
  31412. }());
  31413. exports.__esModule = true;
  31414. exports["default"] = PusherAuthorizer;
  31415. /***/ }),
  31416. /* 48 */
  31417. /***/ (function(module, exports, __webpack_require__) {
  31418. "use strict";
  31419. var runtime_1 = __webpack_require__(2);
  31420. var TimelineSender = (function () {
  31421. function TimelineSender(timeline, options) {
  31422. this.timeline = timeline;
  31423. this.options = options || {};
  31424. }
  31425. TimelineSender.prototype.send = function (encrypted, callback) {
  31426. if (this.timeline.isEmpty()) {
  31427. return;
  31428. }
  31429. this.timeline.send(runtime_1["default"].TimelineTransport.getAgent(this, encrypted), callback);
  31430. };
  31431. return TimelineSender;
  31432. }());
  31433. exports.__esModule = true;
  31434. exports["default"] = TimelineSender;
  31435. /***/ }),
  31436. /* 49 */
  31437. /***/ (function(module, exports, __webpack_require__) {
  31438. "use strict";
  31439. var __extends = (this && this.__extends) || function (d, b) {
  31440. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31441. function __() { this.constructor = d; }
  31442. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31443. };
  31444. var private_channel_1 = __webpack_require__(50);
  31445. var logger_1 = __webpack_require__(8);
  31446. var members_1 = __webpack_require__(52);
  31447. var PresenceChannel = (function (_super) {
  31448. __extends(PresenceChannel, _super);
  31449. function PresenceChannel(name, pusher) {
  31450. _super.call(this, name, pusher);
  31451. this.members = new members_1["default"]();
  31452. }
  31453. PresenceChannel.prototype.authorize = function (socketId, callback) {
  31454. var _this = this;
  31455. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  31456. if (!error) {
  31457. if (authData.channel_data === undefined) {
  31458. logger_1["default"].warn("Invalid auth response for channel '" +
  31459. _this.name +
  31460. "', expected 'channel_data' field");
  31461. callback("Invalid auth response");
  31462. return;
  31463. }
  31464. var channelData = JSON.parse(authData.channel_data);
  31465. _this.members.setMyID(channelData.user_id);
  31466. }
  31467. callback(error, authData);
  31468. });
  31469. };
  31470. PresenceChannel.prototype.handleEvent = function (event, data) {
  31471. switch (event) {
  31472. case "pusher_internal:subscription_succeeded":
  31473. this.subscriptionPending = false;
  31474. this.subscribed = true;
  31475. if (this.subscriptionCancelled) {
  31476. this.pusher.unsubscribe(this.name);
  31477. }
  31478. else {
  31479. this.members.onSubscription(data);
  31480. this.emit("pusher:subscription_succeeded", this.members);
  31481. }
  31482. break;
  31483. case "pusher_internal:member_added":
  31484. var addedMember = this.members.addMember(data);
  31485. this.emit('pusher:member_added', addedMember);
  31486. break;
  31487. case "pusher_internal:member_removed":
  31488. var removedMember = this.members.removeMember(data);
  31489. if (removedMember) {
  31490. this.emit('pusher:member_removed', removedMember);
  31491. }
  31492. break;
  31493. default:
  31494. private_channel_1["default"].prototype.handleEvent.call(this, event, data);
  31495. }
  31496. };
  31497. PresenceChannel.prototype.disconnect = function () {
  31498. this.members.reset();
  31499. _super.prototype.disconnect.call(this);
  31500. };
  31501. return PresenceChannel;
  31502. }(private_channel_1["default"]));
  31503. exports.__esModule = true;
  31504. exports["default"] = PresenceChannel;
  31505. /***/ }),
  31506. /* 50 */
  31507. /***/ (function(module, exports, __webpack_require__) {
  31508. "use strict";
  31509. var __extends = (this && this.__extends) || function (d, b) {
  31510. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31511. function __() { this.constructor = d; }
  31512. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31513. };
  31514. var factory_1 = __webpack_require__(42);
  31515. var channel_1 = __webpack_require__(51);
  31516. var PrivateChannel = (function (_super) {
  31517. __extends(PrivateChannel, _super);
  31518. function PrivateChannel() {
  31519. _super.apply(this, arguments);
  31520. }
  31521. PrivateChannel.prototype.authorize = function (socketId, callback) {
  31522. var authorizer = factory_1["default"].createAuthorizer(this, this.pusher.config);
  31523. return authorizer.authorize(socketId, callback);
  31524. };
  31525. return PrivateChannel;
  31526. }(channel_1["default"]));
  31527. exports.__esModule = true;
  31528. exports["default"] = PrivateChannel;
  31529. /***/ }),
  31530. /* 51 */
  31531. /***/ (function(module, exports, __webpack_require__) {
  31532. "use strict";
  31533. var __extends = (this && this.__extends) || function (d, b) {
  31534. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31535. function __() { this.constructor = d; }
  31536. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31537. };
  31538. var dispatcher_1 = __webpack_require__(23);
  31539. var Errors = __webpack_require__(30);
  31540. var logger_1 = __webpack_require__(8);
  31541. var Channel = (function (_super) {
  31542. __extends(Channel, _super);
  31543. function Channel(name, pusher) {
  31544. _super.call(this, function (event, data) {
  31545. logger_1["default"].debug('No callbacks on ' + name + ' for ' + event);
  31546. });
  31547. this.name = name;
  31548. this.pusher = pusher;
  31549. this.subscribed = false;
  31550. this.subscriptionPending = false;
  31551. this.subscriptionCancelled = false;
  31552. }
  31553. Channel.prototype.authorize = function (socketId, callback) {
  31554. return callback(false, {});
  31555. };
  31556. Channel.prototype.trigger = function (event, data) {
  31557. if (event.indexOf("client-") !== 0) {
  31558. throw new Errors.BadEventName("Event '" + event + "' does not start with 'client-'");
  31559. }
  31560. return this.pusher.send_event(event, data, this.name);
  31561. };
  31562. Channel.prototype.disconnect = function () {
  31563. this.subscribed = false;
  31564. };
  31565. Channel.prototype.handleEvent = function (event, data) {
  31566. if (event.indexOf("pusher_internal:") === 0) {
  31567. if (event === "pusher_internal:subscription_succeeded") {
  31568. this.subscriptionPending = false;
  31569. this.subscribed = true;
  31570. if (this.subscriptionCancelled) {
  31571. this.pusher.unsubscribe(this.name);
  31572. }
  31573. else {
  31574. this.emit("pusher:subscription_succeeded", data);
  31575. }
  31576. }
  31577. }
  31578. else {
  31579. this.emit(event, data);
  31580. }
  31581. };
  31582. Channel.prototype.subscribe = function () {
  31583. var _this = this;
  31584. if (this.subscribed) {
  31585. return;
  31586. }
  31587. this.subscriptionPending = true;
  31588. this.subscriptionCancelled = false;
  31589. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  31590. if (error) {
  31591. _this.handleEvent('pusher:subscription_error', data);
  31592. }
  31593. else {
  31594. _this.pusher.send_event('pusher:subscribe', {
  31595. auth: data.auth,
  31596. channel_data: data.channel_data,
  31597. channel: _this.name
  31598. });
  31599. }
  31600. });
  31601. };
  31602. Channel.prototype.unsubscribe = function () {
  31603. this.subscribed = false;
  31604. this.pusher.send_event('pusher:unsubscribe', {
  31605. channel: this.name
  31606. });
  31607. };
  31608. Channel.prototype.cancelSubscription = function () {
  31609. this.subscriptionCancelled = true;
  31610. };
  31611. Channel.prototype.reinstateSubscription = function () {
  31612. this.subscriptionCancelled = false;
  31613. };
  31614. return Channel;
  31615. }(dispatcher_1["default"]));
  31616. exports.__esModule = true;
  31617. exports["default"] = Channel;
  31618. /***/ }),
  31619. /* 52 */
  31620. /***/ (function(module, exports, __webpack_require__) {
  31621. "use strict";
  31622. var Collections = __webpack_require__(9);
  31623. var Members = (function () {
  31624. function Members() {
  31625. this.reset();
  31626. }
  31627. Members.prototype.get = function (id) {
  31628. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  31629. return {
  31630. id: id,
  31631. info: this.members[id]
  31632. };
  31633. }
  31634. else {
  31635. return null;
  31636. }
  31637. };
  31638. Members.prototype.each = function (callback) {
  31639. var _this = this;
  31640. Collections.objectApply(this.members, function (member, id) {
  31641. callback(_this.get(id));
  31642. });
  31643. };
  31644. Members.prototype.setMyID = function (id) {
  31645. this.myID = id;
  31646. };
  31647. Members.prototype.onSubscription = function (subscriptionData) {
  31648. this.members = subscriptionData.presence.hash;
  31649. this.count = subscriptionData.presence.count;
  31650. this.me = this.get(this.myID);
  31651. };
  31652. Members.prototype.addMember = function (memberData) {
  31653. if (this.get(memberData.user_id) === null) {
  31654. this.count++;
  31655. }
  31656. this.members[memberData.user_id] = memberData.user_info;
  31657. return this.get(memberData.user_id);
  31658. };
  31659. Members.prototype.removeMember = function (memberData) {
  31660. var member = this.get(memberData.user_id);
  31661. if (member) {
  31662. delete this.members[memberData.user_id];
  31663. this.count--;
  31664. }
  31665. return member;
  31666. };
  31667. Members.prototype.reset = function () {
  31668. this.members = {};
  31669. this.count = 0;
  31670. this.myID = null;
  31671. this.me = null;
  31672. };
  31673. return Members;
  31674. }());
  31675. exports.__esModule = true;
  31676. exports["default"] = Members;
  31677. /***/ }),
  31678. /* 53 */
  31679. /***/ (function(module, exports, __webpack_require__) {
  31680. "use strict";
  31681. var __extends = (this && this.__extends) || function (d, b) {
  31682. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31683. function __() { this.constructor = d; }
  31684. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31685. };
  31686. var dispatcher_1 = __webpack_require__(23);
  31687. var timers_1 = __webpack_require__(12);
  31688. var logger_1 = __webpack_require__(8);
  31689. var Collections = __webpack_require__(9);
  31690. var runtime_1 = __webpack_require__(2);
  31691. var ConnectionManager = (function (_super) {
  31692. __extends(ConnectionManager, _super);
  31693. function ConnectionManager(key, options) {
  31694. var _this = this;
  31695. _super.call(this);
  31696. this.key = key;
  31697. this.options = options || {};
  31698. this.state = "initialized";
  31699. this.connection = null;
  31700. this.encrypted = !!options.encrypted;
  31701. this.timeline = this.options.timeline;
  31702. this.connectionCallbacks = this.buildConnectionCallbacks();
  31703. this.errorCallbacks = this.buildErrorCallbacks();
  31704. this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
  31705. var Network = runtime_1["default"].getNetwork();
  31706. Network.bind("online", function () {
  31707. _this.timeline.info({ netinfo: "online" });
  31708. if (_this.state === "connecting" || _this.state === "unavailable") {
  31709. _this.retryIn(0);
  31710. }
  31711. });
  31712. Network.bind("offline", function () {
  31713. _this.timeline.info({ netinfo: "offline" });
  31714. if (_this.connection) {
  31715. _this.sendActivityCheck();
  31716. }
  31717. });
  31718. this.updateStrategy();
  31719. }
  31720. ConnectionManager.prototype.connect = function () {
  31721. if (this.connection || this.runner) {
  31722. return;
  31723. }
  31724. if (!this.strategy.isSupported()) {
  31725. this.updateState("failed");
  31726. return;
  31727. }
  31728. this.updateState("connecting");
  31729. this.startConnecting();
  31730. this.setUnavailableTimer();
  31731. };
  31732. ;
  31733. ConnectionManager.prototype.send = function (data) {
  31734. if (this.connection) {
  31735. return this.connection.send(data);
  31736. }
  31737. else {
  31738. return false;
  31739. }
  31740. };
  31741. ;
  31742. ConnectionManager.prototype.send_event = function (name, data, channel) {
  31743. if (this.connection) {
  31744. return this.connection.send_event(name, data, channel);
  31745. }
  31746. else {
  31747. return false;
  31748. }
  31749. };
  31750. ;
  31751. ConnectionManager.prototype.disconnect = function () {
  31752. this.disconnectInternally();
  31753. this.updateState("disconnected");
  31754. };
  31755. ;
  31756. ConnectionManager.prototype.isEncrypted = function () {
  31757. return this.encrypted;
  31758. };
  31759. ;
  31760. ConnectionManager.prototype.startConnecting = function () {
  31761. var _this = this;
  31762. var callback = function (error, handshake) {
  31763. if (error) {
  31764. _this.runner = _this.strategy.connect(0, callback);
  31765. }
  31766. else {
  31767. if (handshake.action === "error") {
  31768. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  31769. _this.timeline.error({ handshakeError: handshake.error });
  31770. }
  31771. else {
  31772. _this.abortConnecting();
  31773. _this.handshakeCallbacks[handshake.action](handshake);
  31774. }
  31775. }
  31776. };
  31777. this.runner = this.strategy.connect(0, callback);
  31778. };
  31779. ;
  31780. ConnectionManager.prototype.abortConnecting = function () {
  31781. if (this.runner) {
  31782. this.runner.abort();
  31783. this.runner = null;
  31784. }
  31785. };
  31786. ;
  31787. ConnectionManager.prototype.disconnectInternally = function () {
  31788. this.abortConnecting();
  31789. this.clearRetryTimer();
  31790. this.clearUnavailableTimer();
  31791. if (this.connection) {
  31792. var connection = this.abandonConnection();
  31793. connection.close();
  31794. }
  31795. };
  31796. ;
  31797. ConnectionManager.prototype.updateStrategy = function () {
  31798. this.strategy = this.options.getStrategy({
  31799. key: this.key,
  31800. timeline: this.timeline,
  31801. encrypted: this.encrypted
  31802. });
  31803. };
  31804. ;
  31805. ConnectionManager.prototype.retryIn = function (delay) {
  31806. var _this = this;
  31807. this.timeline.info({ action: "retry", delay: delay });
  31808. if (delay > 0) {
  31809. this.emit("connecting_in", Math.round(delay / 1000));
  31810. }
  31811. this.retryTimer = new timers_1.OneOffTimer(delay || 0, function () {
  31812. _this.disconnectInternally();
  31813. _this.connect();
  31814. });
  31815. };
  31816. ;
  31817. ConnectionManager.prototype.clearRetryTimer = function () {
  31818. if (this.retryTimer) {
  31819. this.retryTimer.ensureAborted();
  31820. this.retryTimer = null;
  31821. }
  31822. };
  31823. ;
  31824. ConnectionManager.prototype.setUnavailableTimer = function () {
  31825. var _this = this;
  31826. this.unavailableTimer = new timers_1.OneOffTimer(this.options.unavailableTimeout, function () {
  31827. _this.updateState("unavailable");
  31828. });
  31829. };
  31830. ;
  31831. ConnectionManager.prototype.clearUnavailableTimer = function () {
  31832. if (this.unavailableTimer) {
  31833. this.unavailableTimer.ensureAborted();
  31834. }
  31835. };
  31836. ;
  31837. ConnectionManager.prototype.sendActivityCheck = function () {
  31838. var _this = this;
  31839. this.stopActivityCheck();
  31840. this.connection.ping();
  31841. this.activityTimer = new timers_1.OneOffTimer(this.options.pongTimeout, function () {
  31842. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  31843. _this.retryIn(0);
  31844. });
  31845. };
  31846. ;
  31847. ConnectionManager.prototype.resetActivityCheck = function () {
  31848. var _this = this;
  31849. this.stopActivityCheck();
  31850. if (!this.connection.handlesActivityChecks()) {
  31851. this.activityTimer = new timers_1.OneOffTimer(this.activityTimeout, function () {
  31852. _this.sendActivityCheck();
  31853. });
  31854. }
  31855. };
  31856. ;
  31857. ConnectionManager.prototype.stopActivityCheck = function () {
  31858. if (this.activityTimer) {
  31859. this.activityTimer.ensureAborted();
  31860. }
  31861. };
  31862. ;
  31863. ConnectionManager.prototype.buildConnectionCallbacks = function () {
  31864. var _this = this;
  31865. return {
  31866. message: function (message) {
  31867. _this.resetActivityCheck();
  31868. _this.emit('message', message);
  31869. },
  31870. ping: function () {
  31871. _this.send_event('pusher:pong', {});
  31872. },
  31873. activity: function () {
  31874. _this.resetActivityCheck();
  31875. },
  31876. error: function (error) {
  31877. _this.emit("error", { type: "WebSocketError", error: error });
  31878. },
  31879. closed: function () {
  31880. _this.abandonConnection();
  31881. if (_this.shouldRetry()) {
  31882. _this.retryIn(1000);
  31883. }
  31884. }
  31885. };
  31886. };
  31887. ;
  31888. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  31889. var _this = this;
  31890. return Collections.extend({}, errorCallbacks, {
  31891. connected: function (handshake) {
  31892. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  31893. _this.clearUnavailableTimer();
  31894. _this.setConnection(handshake.connection);
  31895. _this.socket_id = _this.connection.id;
  31896. _this.updateState("connected", { socket_id: _this.socket_id });
  31897. }
  31898. });
  31899. };
  31900. ;
  31901. ConnectionManager.prototype.buildErrorCallbacks = function () {
  31902. var _this = this;
  31903. var withErrorEmitted = function (callback) {
  31904. return function (result) {
  31905. if (result.error) {
  31906. _this.emit("error", { type: "WebSocketError", error: result.error });
  31907. }
  31908. callback(result);
  31909. };
  31910. };
  31911. return {
  31912. ssl_only: withErrorEmitted(function () {
  31913. _this.encrypted = true;
  31914. _this.updateStrategy();
  31915. _this.retryIn(0);
  31916. }),
  31917. refused: withErrorEmitted(function () {
  31918. _this.disconnect();
  31919. }),
  31920. backoff: withErrorEmitted(function () {
  31921. _this.retryIn(1000);
  31922. }),
  31923. retry: withErrorEmitted(function () {
  31924. _this.retryIn(0);
  31925. })
  31926. };
  31927. };
  31928. ;
  31929. ConnectionManager.prototype.setConnection = function (connection) {
  31930. this.connection = connection;
  31931. for (var event in this.connectionCallbacks) {
  31932. this.connection.bind(event, this.connectionCallbacks[event]);
  31933. }
  31934. this.resetActivityCheck();
  31935. };
  31936. ;
  31937. ConnectionManager.prototype.abandonConnection = function () {
  31938. if (!this.connection) {
  31939. return;
  31940. }
  31941. this.stopActivityCheck();
  31942. for (var event in this.connectionCallbacks) {
  31943. this.connection.unbind(event, this.connectionCallbacks[event]);
  31944. }
  31945. var connection = this.connection;
  31946. this.connection = null;
  31947. return connection;
  31948. };
  31949. ConnectionManager.prototype.updateState = function (newState, data) {
  31950. var previousState = this.state;
  31951. this.state = newState;
  31952. if (previousState !== newState) {
  31953. var newStateDescription = newState;
  31954. if (newStateDescription === "connected") {
  31955. newStateDescription += " with new socket ID " + data.socket_id;
  31956. }
  31957. logger_1["default"].debug('State changed', previousState + ' -> ' + newStateDescription);
  31958. this.timeline.info({ state: newState, params: data });
  31959. this.emit('state_change', { previous: previousState, current: newState });
  31960. this.emit(newState, data);
  31961. }
  31962. };
  31963. ConnectionManager.prototype.shouldRetry = function () {
  31964. return this.state === "connecting" || this.state === "connected";
  31965. };
  31966. return ConnectionManager;
  31967. }(dispatcher_1["default"]));
  31968. exports.__esModule = true;
  31969. exports["default"] = ConnectionManager;
  31970. /***/ }),
  31971. /* 54 */
  31972. /***/ (function(module, exports, __webpack_require__) {
  31973. "use strict";
  31974. var Collections = __webpack_require__(9);
  31975. var factory_1 = __webpack_require__(42);
  31976. var Channels = (function () {
  31977. function Channels() {
  31978. this.channels = {};
  31979. }
  31980. Channels.prototype.add = function (name, pusher) {
  31981. if (!this.channels[name]) {
  31982. this.channels[name] = createChannel(name, pusher);
  31983. }
  31984. return this.channels[name];
  31985. };
  31986. Channels.prototype.all = function () {
  31987. return Collections.values(this.channels);
  31988. };
  31989. Channels.prototype.find = function (name) {
  31990. return this.channels[name];
  31991. };
  31992. Channels.prototype.remove = function (name) {
  31993. var channel = this.channels[name];
  31994. delete this.channels[name];
  31995. return channel;
  31996. };
  31997. Channels.prototype.disconnect = function () {
  31998. Collections.objectApply(this.channels, function (channel) {
  31999. channel.disconnect();
  32000. });
  32001. };
  32002. return Channels;
  32003. }());
  32004. exports.__esModule = true;
  32005. exports["default"] = Channels;
  32006. function createChannel(name, pusher) {
  32007. if (name.indexOf('private-') === 0) {
  32008. return factory_1["default"].createPrivateChannel(name, pusher);
  32009. }
  32010. else if (name.indexOf('presence-') === 0) {
  32011. return factory_1["default"].createPresenceChannel(name, pusher);
  32012. }
  32013. else {
  32014. return factory_1["default"].createChannel(name, pusher);
  32015. }
  32016. }
  32017. /***/ }),
  32018. /* 55 */
  32019. /***/ (function(module, exports, __webpack_require__) {
  32020. "use strict";
  32021. var factory_1 = __webpack_require__(42);
  32022. var util_1 = __webpack_require__(11);
  32023. var Errors = __webpack_require__(30);
  32024. var Collections = __webpack_require__(9);
  32025. var TransportStrategy = (function () {
  32026. function TransportStrategy(name, priority, transport, options) {
  32027. this.name = name;
  32028. this.priority = priority;
  32029. this.transport = transport;
  32030. this.options = options || {};
  32031. }
  32032. TransportStrategy.prototype.isSupported = function () {
  32033. return this.transport.isSupported({
  32034. encrypted: this.options.encrypted
  32035. });
  32036. };
  32037. TransportStrategy.prototype.connect = function (minPriority, callback) {
  32038. var _this = this;
  32039. if (!this.isSupported()) {
  32040. return failAttempt(new Errors.UnsupportedStrategy(), callback);
  32041. }
  32042. else if (this.priority < minPriority) {
  32043. return failAttempt(new Errors.TransportPriorityTooLow(), callback);
  32044. }
  32045. var connected = false;
  32046. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  32047. var handshake = null;
  32048. var onInitialized = function () {
  32049. transport.unbind("initialized", onInitialized);
  32050. transport.connect();
  32051. };
  32052. var onOpen = function () {
  32053. handshake = factory_1["default"].createHandshake(transport, function (result) {
  32054. connected = true;
  32055. unbindListeners();
  32056. callback(null, result);
  32057. });
  32058. };
  32059. var onError = function (error) {
  32060. unbindListeners();
  32061. callback(error);
  32062. };
  32063. var onClosed = function () {
  32064. unbindListeners();
  32065. var serializedTransport;
  32066. serializedTransport = Collections.safeJSONStringify(transport);
  32067. callback(new Errors.TransportClosed(serializedTransport));
  32068. };
  32069. var unbindListeners = function () {
  32070. transport.unbind("initialized", onInitialized);
  32071. transport.unbind("open", onOpen);
  32072. transport.unbind("error", onError);
  32073. transport.unbind("closed", onClosed);
  32074. };
  32075. transport.bind("initialized", onInitialized);
  32076. transport.bind("open", onOpen);
  32077. transport.bind("error", onError);
  32078. transport.bind("closed", onClosed);
  32079. transport.initialize();
  32080. return {
  32081. abort: function () {
  32082. if (connected) {
  32083. return;
  32084. }
  32085. unbindListeners();
  32086. if (handshake) {
  32087. handshake.close();
  32088. }
  32089. else {
  32090. transport.close();
  32091. }
  32092. },
  32093. forceMinPriority: function (p) {
  32094. if (connected) {
  32095. return;
  32096. }
  32097. if (_this.priority < p) {
  32098. if (handshake) {
  32099. handshake.close();
  32100. }
  32101. else {
  32102. transport.close();
  32103. }
  32104. }
  32105. }
  32106. };
  32107. };
  32108. return TransportStrategy;
  32109. }());
  32110. exports.__esModule = true;
  32111. exports["default"] = TransportStrategy;
  32112. function failAttempt(error, callback) {
  32113. util_1["default"].defer(function () {
  32114. callback(error);
  32115. });
  32116. return {
  32117. abort: function () { },
  32118. forceMinPriority: function () { }
  32119. };
  32120. }
  32121. /***/ }),
  32122. /* 56 */
  32123. /***/ (function(module, exports, __webpack_require__) {
  32124. "use strict";
  32125. var Collections = __webpack_require__(9);
  32126. var util_1 = __webpack_require__(11);
  32127. var timers_1 = __webpack_require__(12);
  32128. var SequentialStrategy = (function () {
  32129. function SequentialStrategy(strategies, options) {
  32130. this.strategies = strategies;
  32131. this.loop = Boolean(options.loop);
  32132. this.failFast = Boolean(options.failFast);
  32133. this.timeout = options.timeout;
  32134. this.timeoutLimit = options.timeoutLimit;
  32135. }
  32136. SequentialStrategy.prototype.isSupported = function () {
  32137. return Collections.any(this.strategies, util_1["default"].method("isSupported"));
  32138. };
  32139. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  32140. var _this = this;
  32141. var strategies = this.strategies;
  32142. var current = 0;
  32143. var timeout = this.timeout;
  32144. var runner = null;
  32145. var tryNextStrategy = function (error, handshake) {
  32146. if (handshake) {
  32147. callback(null, handshake);
  32148. }
  32149. else {
  32150. current = current + 1;
  32151. if (_this.loop) {
  32152. current = current % strategies.length;
  32153. }
  32154. if (current < strategies.length) {
  32155. if (timeout) {
  32156. timeout = timeout * 2;
  32157. if (_this.timeoutLimit) {
  32158. timeout = Math.min(timeout, _this.timeoutLimit);
  32159. }
  32160. }
  32161. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  32162. }
  32163. else {
  32164. callback(true);
  32165. }
  32166. }
  32167. };
  32168. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  32169. return {
  32170. abort: function () {
  32171. runner.abort();
  32172. },
  32173. forceMinPriority: function (p) {
  32174. minPriority = p;
  32175. if (runner) {
  32176. runner.forceMinPriority(p);
  32177. }
  32178. }
  32179. };
  32180. };
  32181. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  32182. var timer = null;
  32183. var runner = null;
  32184. if (options.timeout > 0) {
  32185. timer = new timers_1.OneOffTimer(options.timeout, function () {
  32186. runner.abort();
  32187. callback(true);
  32188. });
  32189. }
  32190. runner = strategy.connect(minPriority, function (error, handshake) {
  32191. if (error && timer && timer.isRunning() && !options.failFast) {
  32192. return;
  32193. }
  32194. if (timer) {
  32195. timer.ensureAborted();
  32196. }
  32197. callback(error, handshake);
  32198. });
  32199. return {
  32200. abort: function () {
  32201. if (timer) {
  32202. timer.ensureAborted();
  32203. }
  32204. runner.abort();
  32205. },
  32206. forceMinPriority: function (p) {
  32207. runner.forceMinPriority(p);
  32208. }
  32209. };
  32210. };
  32211. return SequentialStrategy;
  32212. }());
  32213. exports.__esModule = true;
  32214. exports["default"] = SequentialStrategy;
  32215. /***/ }),
  32216. /* 57 */
  32217. /***/ (function(module, exports, __webpack_require__) {
  32218. "use strict";
  32219. var Collections = __webpack_require__(9);
  32220. var util_1 = __webpack_require__(11);
  32221. var BestConnectedEverStrategy = (function () {
  32222. function BestConnectedEverStrategy(strategies) {
  32223. this.strategies = strategies;
  32224. }
  32225. BestConnectedEverStrategy.prototype.isSupported = function () {
  32226. return Collections.any(this.strategies, util_1["default"].method("isSupported"));
  32227. };
  32228. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  32229. return connect(this.strategies, minPriority, function (i, runners) {
  32230. return function (error, handshake) {
  32231. runners[i].error = error;
  32232. if (error) {
  32233. if (allRunnersFailed(runners)) {
  32234. callback(true);
  32235. }
  32236. return;
  32237. }
  32238. Collections.apply(runners, function (runner) {
  32239. runner.forceMinPriority(handshake.transport.priority);
  32240. });
  32241. callback(null, handshake);
  32242. };
  32243. });
  32244. };
  32245. return BestConnectedEverStrategy;
  32246. }());
  32247. exports.__esModule = true;
  32248. exports["default"] = BestConnectedEverStrategy;
  32249. function connect(strategies, minPriority, callbackBuilder) {
  32250. var runners = Collections.map(strategies, function (strategy, i, _, rs) {
  32251. return strategy.connect(minPriority, callbackBuilder(i, rs));
  32252. });
  32253. return {
  32254. abort: function () {
  32255. Collections.apply(runners, abortRunner);
  32256. },
  32257. forceMinPriority: function (p) {
  32258. Collections.apply(runners, function (runner) {
  32259. runner.forceMinPriority(p);
  32260. });
  32261. }
  32262. };
  32263. }
  32264. function allRunnersFailed(runners) {
  32265. return Collections.all(runners, function (runner) {
  32266. return Boolean(runner.error);
  32267. });
  32268. }
  32269. function abortRunner(runner) {
  32270. if (!runner.error && !runner.aborted) {
  32271. runner.abort();
  32272. runner.aborted = true;
  32273. }
  32274. }
  32275. /***/ }),
  32276. /* 58 */
  32277. /***/ (function(module, exports, __webpack_require__) {
  32278. "use strict";
  32279. var util_1 = __webpack_require__(11);
  32280. var runtime_1 = __webpack_require__(2);
  32281. var sequential_strategy_1 = __webpack_require__(56);
  32282. var Collections = __webpack_require__(9);
  32283. var CachedStrategy = (function () {
  32284. function CachedStrategy(strategy, transports, options) {
  32285. this.strategy = strategy;
  32286. this.transports = transports;
  32287. this.ttl = options.ttl || 1800 * 1000;
  32288. this.encrypted = options.encrypted;
  32289. this.timeline = options.timeline;
  32290. }
  32291. CachedStrategy.prototype.isSupported = function () {
  32292. return this.strategy.isSupported();
  32293. };
  32294. CachedStrategy.prototype.connect = function (minPriority, callback) {
  32295. var encrypted = this.encrypted;
  32296. var info = fetchTransportCache(encrypted);
  32297. var strategies = [this.strategy];
  32298. if (info && info.timestamp + this.ttl >= util_1["default"].now()) {
  32299. var transport = this.transports[info.transport];
  32300. if (transport) {
  32301. this.timeline.info({
  32302. cached: true,
  32303. transport: info.transport,
  32304. latency: info.latency
  32305. });
  32306. strategies.push(new sequential_strategy_1["default"]([transport], {
  32307. timeout: info.latency * 2 + 1000,
  32308. failFast: true
  32309. }));
  32310. }
  32311. }
  32312. var startTimestamp = util_1["default"].now();
  32313. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  32314. if (error) {
  32315. flushTransportCache(encrypted);
  32316. if (strategies.length > 0) {
  32317. startTimestamp = util_1["default"].now();
  32318. runner = strategies.pop().connect(minPriority, cb);
  32319. }
  32320. else {
  32321. callback(error);
  32322. }
  32323. }
  32324. else {
  32325. storeTransportCache(encrypted, handshake.transport.name, util_1["default"].now() - startTimestamp);
  32326. callback(null, handshake);
  32327. }
  32328. });
  32329. return {
  32330. abort: function () {
  32331. runner.abort();
  32332. },
  32333. forceMinPriority: function (p) {
  32334. minPriority = p;
  32335. if (runner) {
  32336. runner.forceMinPriority(p);
  32337. }
  32338. }
  32339. };
  32340. };
  32341. return CachedStrategy;
  32342. }());
  32343. exports.__esModule = true;
  32344. exports["default"] = CachedStrategy;
  32345. function getTransportCacheKey(encrypted) {
  32346. return "pusherTransport" + (encrypted ? "Encrypted" : "Unencrypted");
  32347. }
  32348. function fetchTransportCache(encrypted) {
  32349. var storage = runtime_1["default"].getLocalStorage();
  32350. if (storage) {
  32351. try {
  32352. var serializedCache = storage[getTransportCacheKey(encrypted)];
  32353. if (serializedCache) {
  32354. return JSON.parse(serializedCache);
  32355. }
  32356. }
  32357. catch (e) {
  32358. flushTransportCache(encrypted);
  32359. }
  32360. }
  32361. return null;
  32362. }
  32363. function storeTransportCache(encrypted, transport, latency) {
  32364. var storage = runtime_1["default"].getLocalStorage();
  32365. if (storage) {
  32366. try {
  32367. storage[getTransportCacheKey(encrypted)] = Collections.safeJSONStringify({
  32368. timestamp: util_1["default"].now(),
  32369. transport: transport,
  32370. latency: latency
  32371. });
  32372. }
  32373. catch (e) {
  32374. }
  32375. }
  32376. }
  32377. function flushTransportCache(encrypted) {
  32378. var storage = runtime_1["default"].getLocalStorage();
  32379. if (storage) {
  32380. try {
  32381. delete storage[getTransportCacheKey(encrypted)];
  32382. }
  32383. catch (e) {
  32384. }
  32385. }
  32386. }
  32387. /***/ }),
  32388. /* 59 */
  32389. /***/ (function(module, exports, __webpack_require__) {
  32390. "use strict";
  32391. var timers_1 = __webpack_require__(12);
  32392. var DelayedStrategy = (function () {
  32393. function DelayedStrategy(strategy, _a) {
  32394. var number = _a.delay;
  32395. this.strategy = strategy;
  32396. this.options = { delay: number };
  32397. }
  32398. DelayedStrategy.prototype.isSupported = function () {
  32399. return this.strategy.isSupported();
  32400. };
  32401. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  32402. var strategy = this.strategy;
  32403. var runner;
  32404. var timer = new timers_1.OneOffTimer(this.options.delay, function () {
  32405. runner = strategy.connect(minPriority, callback);
  32406. });
  32407. return {
  32408. abort: function () {
  32409. timer.ensureAborted();
  32410. if (runner) {
  32411. runner.abort();
  32412. }
  32413. },
  32414. forceMinPriority: function (p) {
  32415. minPriority = p;
  32416. if (runner) {
  32417. runner.forceMinPriority(p);
  32418. }
  32419. }
  32420. };
  32421. };
  32422. return DelayedStrategy;
  32423. }());
  32424. exports.__esModule = true;
  32425. exports["default"] = DelayedStrategy;
  32426. /***/ }),
  32427. /* 60 */
  32428. /***/ (function(module, exports) {
  32429. "use strict";
  32430. var IfStrategy = (function () {
  32431. function IfStrategy(test, trueBranch, falseBranch) {
  32432. this.test = test;
  32433. this.trueBranch = trueBranch;
  32434. this.falseBranch = falseBranch;
  32435. }
  32436. IfStrategy.prototype.isSupported = function () {
  32437. var branch = this.test() ? this.trueBranch : this.falseBranch;
  32438. return branch.isSupported();
  32439. };
  32440. IfStrategy.prototype.connect = function (minPriority, callback) {
  32441. var branch = this.test() ? this.trueBranch : this.falseBranch;
  32442. return branch.connect(minPriority, callback);
  32443. };
  32444. return IfStrategy;
  32445. }());
  32446. exports.__esModule = true;
  32447. exports["default"] = IfStrategy;
  32448. /***/ }),
  32449. /* 61 */
  32450. /***/ (function(module, exports) {
  32451. "use strict";
  32452. var FirstConnectedStrategy = (function () {
  32453. function FirstConnectedStrategy(strategy) {
  32454. this.strategy = strategy;
  32455. }
  32456. FirstConnectedStrategy.prototype.isSupported = function () {
  32457. return this.strategy.isSupported();
  32458. };
  32459. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  32460. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  32461. if (handshake) {
  32462. runner.abort();
  32463. }
  32464. callback(error, handshake);
  32465. });
  32466. return runner;
  32467. };
  32468. return FirstConnectedStrategy;
  32469. }());
  32470. exports.__esModule = true;
  32471. exports["default"] = FirstConnectedStrategy;
  32472. /***/ }),
  32473. /* 62 */
  32474. /***/ (function(module, exports, __webpack_require__) {
  32475. "use strict";
  32476. var defaults_1 = __webpack_require__(5);
  32477. exports.getGlobalConfig = function () {
  32478. return {
  32479. wsHost: defaults_1["default"].host,
  32480. wsPort: defaults_1["default"].ws_port,
  32481. wssPort: defaults_1["default"].wss_port,
  32482. httpHost: defaults_1["default"].sockjs_host,
  32483. httpPort: defaults_1["default"].sockjs_http_port,
  32484. httpsPort: defaults_1["default"].sockjs_https_port,
  32485. httpPath: defaults_1["default"].sockjs_path,
  32486. statsHost: defaults_1["default"].stats_host,
  32487. authEndpoint: defaults_1["default"].channel_auth_endpoint,
  32488. authTransport: defaults_1["default"].channel_auth_transport,
  32489. activity_timeout: defaults_1["default"].activity_timeout,
  32490. pong_timeout: defaults_1["default"].pong_timeout,
  32491. unavailable_timeout: defaults_1["default"].unavailable_timeout
  32492. };
  32493. };
  32494. exports.getClusterConfig = function (clusterName) {
  32495. return {
  32496. wsHost: "ws-" + clusterName + ".pusher.com",
  32497. httpHost: "sockjs-" + clusterName + ".pusher.com"
  32498. };
  32499. };
  32500. /***/ })
  32501. /******/ ])
  32502. });
  32503. ;
  32504. /***/ }),
  32505. /* 38 */
  32506. /***/ (function(module, exports, __webpack_require__) {
  32507. "use strict";
  32508. /* WEBPACK VAR INJECTION */(function(global) {/*!
  32509. * Vue.js v2.3.4
  32510. * (c) 2014-2017 Evan You
  32511. * Released under the MIT License.
  32512. */
  32513. /* */
  32514. // these helpers produces better vm code in JS engines due to their
  32515. // explicitness and function inlining
  32516. function isUndef (v) {
  32517. return v === undefined || v === null
  32518. }
  32519. function isDef (v) {
  32520. return v !== undefined && v !== null
  32521. }
  32522. function isTrue (v) {
  32523. return v === true
  32524. }
  32525. function isFalse (v) {
  32526. return v === false
  32527. }
  32528. /**
  32529. * Check if value is primitive
  32530. */
  32531. function isPrimitive (value) {
  32532. return typeof value === 'string' || typeof value === 'number'
  32533. }
  32534. /**
  32535. * Quick object check - this is primarily used to tell
  32536. * Objects from primitive values when we know the value
  32537. * is a JSON-compliant type.
  32538. */
  32539. function isObject (obj) {
  32540. return obj !== null && typeof obj === 'object'
  32541. }
  32542. var _toString = Object.prototype.toString;
  32543. /**
  32544. * Strict object type check. Only returns true
  32545. * for plain JavaScript objects.
  32546. */
  32547. function isPlainObject (obj) {
  32548. return _toString.call(obj) === '[object Object]'
  32549. }
  32550. function isRegExp (v) {
  32551. return _toString.call(v) === '[object RegExp]'
  32552. }
  32553. /**
  32554. * Convert a value to a string that is actually rendered.
  32555. */
  32556. function toString (val) {
  32557. return val == null
  32558. ? ''
  32559. : typeof val === 'object'
  32560. ? JSON.stringify(val, null, 2)
  32561. : String(val)
  32562. }
  32563. /**
  32564. * Convert a input value to a number for persistence.
  32565. * If the conversion fails, return original string.
  32566. */
  32567. function toNumber (val) {
  32568. var n = parseFloat(val);
  32569. return isNaN(n) ? val : n
  32570. }
  32571. /**
  32572. * Make a map and return a function for checking if a key
  32573. * is in that map.
  32574. */
  32575. function makeMap (
  32576. str,
  32577. expectsLowerCase
  32578. ) {
  32579. var map = Object.create(null);
  32580. var list = str.split(',');
  32581. for (var i = 0; i < list.length; i++) {
  32582. map[list[i]] = true;
  32583. }
  32584. return expectsLowerCase
  32585. ? function (val) { return map[val.toLowerCase()]; }
  32586. : function (val) { return map[val]; }
  32587. }
  32588. /**
  32589. * Check if a tag is a built-in tag.
  32590. */
  32591. var isBuiltInTag = makeMap('slot,component', true);
  32592. /**
  32593. * Remove an item from an array
  32594. */
  32595. function remove (arr, item) {
  32596. if (arr.length) {
  32597. var index = arr.indexOf(item);
  32598. if (index > -1) {
  32599. return arr.splice(index, 1)
  32600. }
  32601. }
  32602. }
  32603. /**
  32604. * Check whether the object has the property.
  32605. */
  32606. var hasOwnProperty = Object.prototype.hasOwnProperty;
  32607. function hasOwn (obj, key) {
  32608. return hasOwnProperty.call(obj, key)
  32609. }
  32610. /**
  32611. * Create a cached version of a pure function.
  32612. */
  32613. function cached (fn) {
  32614. var cache = Object.create(null);
  32615. return (function cachedFn (str) {
  32616. var hit = cache[str];
  32617. return hit || (cache[str] = fn(str))
  32618. })
  32619. }
  32620. /**
  32621. * Camelize a hyphen-delimited string.
  32622. */
  32623. var camelizeRE = /-(\w)/g;
  32624. var camelize = cached(function (str) {
  32625. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  32626. });
  32627. /**
  32628. * Capitalize a string.
  32629. */
  32630. var capitalize = cached(function (str) {
  32631. return str.charAt(0).toUpperCase() + str.slice(1)
  32632. });
  32633. /**
  32634. * Hyphenate a camelCase string.
  32635. */
  32636. var hyphenateRE = /([^-])([A-Z])/g;
  32637. var hyphenate = cached(function (str) {
  32638. return str
  32639. .replace(hyphenateRE, '$1-$2')
  32640. .replace(hyphenateRE, '$1-$2')
  32641. .toLowerCase()
  32642. });
  32643. /**
  32644. * Simple bind, faster than native
  32645. */
  32646. function bind (fn, ctx) {
  32647. function boundFn (a) {
  32648. var l = arguments.length;
  32649. return l
  32650. ? l > 1
  32651. ? fn.apply(ctx, arguments)
  32652. : fn.call(ctx, a)
  32653. : fn.call(ctx)
  32654. }
  32655. // record original fn length
  32656. boundFn._length = fn.length;
  32657. return boundFn
  32658. }
  32659. /**
  32660. * Convert an Array-like object to a real Array.
  32661. */
  32662. function toArray (list, start) {
  32663. start = start || 0;
  32664. var i = list.length - start;
  32665. var ret = new Array(i);
  32666. while (i--) {
  32667. ret[i] = list[i + start];
  32668. }
  32669. return ret
  32670. }
  32671. /**
  32672. * Mix properties into target object.
  32673. */
  32674. function extend (to, _from) {
  32675. for (var key in _from) {
  32676. to[key] = _from[key];
  32677. }
  32678. return to
  32679. }
  32680. /**
  32681. * Merge an Array of Objects into a single Object.
  32682. */
  32683. function toObject (arr) {
  32684. var res = {};
  32685. for (var i = 0; i < arr.length; i++) {
  32686. if (arr[i]) {
  32687. extend(res, arr[i]);
  32688. }
  32689. }
  32690. return res
  32691. }
  32692. /**
  32693. * Perform no operation.
  32694. */
  32695. function noop () {}
  32696. /**
  32697. * Always return false.
  32698. */
  32699. var no = function () { return false; };
  32700. /**
  32701. * Return same value
  32702. */
  32703. var identity = function (_) { return _; };
  32704. /**
  32705. * Generate a static keys string from compiler modules.
  32706. */
  32707. function genStaticKeys (modules) {
  32708. return modules.reduce(function (keys, m) {
  32709. return keys.concat(m.staticKeys || [])
  32710. }, []).join(',')
  32711. }
  32712. /**
  32713. * Check if two values are loosely equal - that is,
  32714. * if they are plain objects, do they have the same shape?
  32715. */
  32716. function looseEqual (a, b) {
  32717. var isObjectA = isObject(a);
  32718. var isObjectB = isObject(b);
  32719. if (isObjectA && isObjectB) {
  32720. try {
  32721. return JSON.stringify(a) === JSON.stringify(b)
  32722. } catch (e) {
  32723. // possible circular reference
  32724. return a === b
  32725. }
  32726. } else if (!isObjectA && !isObjectB) {
  32727. return String(a) === String(b)
  32728. } else {
  32729. return false
  32730. }
  32731. }
  32732. function looseIndexOf (arr, val) {
  32733. for (var i = 0; i < arr.length; i++) {
  32734. if (looseEqual(arr[i], val)) { return i }
  32735. }
  32736. return -1
  32737. }
  32738. /**
  32739. * Ensure a function is called only once.
  32740. */
  32741. function once (fn) {
  32742. var called = false;
  32743. return function () {
  32744. if (!called) {
  32745. called = true;
  32746. fn.apply(this, arguments);
  32747. }
  32748. }
  32749. }
  32750. var SSR_ATTR = 'data-server-rendered';
  32751. var ASSET_TYPES = [
  32752. 'component',
  32753. 'directive',
  32754. 'filter'
  32755. ];
  32756. var LIFECYCLE_HOOKS = [
  32757. 'beforeCreate',
  32758. 'created',
  32759. 'beforeMount',
  32760. 'mounted',
  32761. 'beforeUpdate',
  32762. 'updated',
  32763. 'beforeDestroy',
  32764. 'destroyed',
  32765. 'activated',
  32766. 'deactivated'
  32767. ];
  32768. /* */
  32769. var config = ({
  32770. /**
  32771. * Option merge strategies (used in core/util/options)
  32772. */
  32773. optionMergeStrategies: Object.create(null),
  32774. /**
  32775. * Whether to suppress warnings.
  32776. */
  32777. silent: false,
  32778. /**
  32779. * Show production mode tip message on boot?
  32780. */
  32781. productionTip: "development" !== 'production',
  32782. /**
  32783. * Whether to enable devtools
  32784. */
  32785. devtools: "development" !== 'production',
  32786. /**
  32787. * Whether to record perf
  32788. */
  32789. performance: false,
  32790. /**
  32791. * Error handler for watcher errors
  32792. */
  32793. errorHandler: null,
  32794. /**
  32795. * Ignore certain custom elements
  32796. */
  32797. ignoredElements: [],
  32798. /**
  32799. * Custom user key aliases for v-on
  32800. */
  32801. keyCodes: Object.create(null),
  32802. /**
  32803. * Check if a tag is reserved so that it cannot be registered as a
  32804. * component. This is platform-dependent and may be overwritten.
  32805. */
  32806. isReservedTag: no,
  32807. /**
  32808. * Check if an attribute is reserved so that it cannot be used as a component
  32809. * prop. This is platform-dependent and may be overwritten.
  32810. */
  32811. isReservedAttr: no,
  32812. /**
  32813. * Check if a tag is an unknown element.
  32814. * Platform-dependent.
  32815. */
  32816. isUnknownElement: no,
  32817. /**
  32818. * Get the namespace of an element
  32819. */
  32820. getTagNamespace: noop,
  32821. /**
  32822. * Parse the real tag name for the specific platform.
  32823. */
  32824. parsePlatformTagName: identity,
  32825. /**
  32826. * Check if an attribute must be bound using property, e.g. value
  32827. * Platform-dependent.
  32828. */
  32829. mustUseProp: no,
  32830. /**
  32831. * Exposed for legacy reasons
  32832. */
  32833. _lifecycleHooks: LIFECYCLE_HOOKS
  32834. });
  32835. /* */
  32836. var emptyObject = Object.freeze({});
  32837. /**
  32838. * Check if a string starts with $ or _
  32839. */
  32840. function isReserved (str) {
  32841. var c = (str + '').charCodeAt(0);
  32842. return c === 0x24 || c === 0x5F
  32843. }
  32844. /**
  32845. * Define a property.
  32846. */
  32847. function def (obj, key, val, enumerable) {
  32848. Object.defineProperty(obj, key, {
  32849. value: val,
  32850. enumerable: !!enumerable,
  32851. writable: true,
  32852. configurable: true
  32853. });
  32854. }
  32855. /**
  32856. * Parse simple path.
  32857. */
  32858. var bailRE = /[^\w.$]/;
  32859. function parsePath (path) {
  32860. if (bailRE.test(path)) {
  32861. return
  32862. }
  32863. var segments = path.split('.');
  32864. return function (obj) {
  32865. for (var i = 0; i < segments.length; i++) {
  32866. if (!obj) { return }
  32867. obj = obj[segments[i]];
  32868. }
  32869. return obj
  32870. }
  32871. }
  32872. /* */
  32873. var warn = noop;
  32874. var tip = noop;
  32875. var formatComponentName = (null); // work around flow check
  32876. if (true) {
  32877. var hasConsole = typeof console !== 'undefined';
  32878. var classifyRE = /(?:^|[-_])(\w)/g;
  32879. var classify = function (str) { return str
  32880. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  32881. .replace(/[-_]/g, ''); };
  32882. warn = function (msg, vm) {
  32883. if (hasConsole && (!config.silent)) {
  32884. console.error("[Vue warn]: " + msg + (
  32885. vm ? generateComponentTrace(vm) : ''
  32886. ));
  32887. }
  32888. };
  32889. tip = function (msg, vm) {
  32890. if (hasConsole && (!config.silent)) {
  32891. console.warn("[Vue tip]: " + msg + (
  32892. vm ? generateComponentTrace(vm) : ''
  32893. ));
  32894. }
  32895. };
  32896. formatComponentName = function (vm, includeFile) {
  32897. if (vm.$root === vm) {
  32898. return '<Root>'
  32899. }
  32900. var name = typeof vm === 'string'
  32901. ? vm
  32902. : typeof vm === 'function' && vm.options
  32903. ? vm.options.name
  32904. : vm._isVue
  32905. ? vm.$options.name || vm.$options._componentTag
  32906. : vm.name;
  32907. var file = vm._isVue && vm.$options.__file;
  32908. if (!name && file) {
  32909. var match = file.match(/([^/\\]+)\.vue$/);
  32910. name = match && match[1];
  32911. }
  32912. return (
  32913. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  32914. (file && includeFile !== false ? (" at " + file) : '')
  32915. )
  32916. };
  32917. var repeat = function (str, n) {
  32918. var res = '';
  32919. while (n) {
  32920. if (n % 2 === 1) { res += str; }
  32921. if (n > 1) { str += str; }
  32922. n >>= 1;
  32923. }
  32924. return res
  32925. };
  32926. var generateComponentTrace = function (vm) {
  32927. if (vm._isVue && vm.$parent) {
  32928. var tree = [];
  32929. var currentRecursiveSequence = 0;
  32930. while (vm) {
  32931. if (tree.length > 0) {
  32932. var last = tree[tree.length - 1];
  32933. if (last.constructor === vm.constructor) {
  32934. currentRecursiveSequence++;
  32935. vm = vm.$parent;
  32936. continue
  32937. } else if (currentRecursiveSequence > 0) {
  32938. tree[tree.length - 1] = [last, currentRecursiveSequence];
  32939. currentRecursiveSequence = 0;
  32940. }
  32941. }
  32942. tree.push(vm);
  32943. vm = vm.$parent;
  32944. }
  32945. return '\n\nfound in\n\n' + tree
  32946. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  32947. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  32948. : formatComponentName(vm))); })
  32949. .join('\n')
  32950. } else {
  32951. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  32952. }
  32953. };
  32954. }
  32955. /* */
  32956. function handleError (err, vm, info) {
  32957. if (config.errorHandler) {
  32958. config.errorHandler.call(null, err, vm, info);
  32959. } else {
  32960. if (true) {
  32961. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  32962. }
  32963. /* istanbul ignore else */
  32964. if (inBrowser && typeof console !== 'undefined') {
  32965. console.error(err);
  32966. } else {
  32967. throw err
  32968. }
  32969. }
  32970. }
  32971. /* */
  32972. /* globals MutationObserver */
  32973. // can we use __proto__?
  32974. var hasProto = '__proto__' in {};
  32975. // Browser environment sniffing
  32976. var inBrowser = typeof window !== 'undefined';
  32977. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  32978. var isIE = UA && /msie|trident/.test(UA);
  32979. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  32980. var isEdge = UA && UA.indexOf('edge/') > 0;
  32981. var isAndroid = UA && UA.indexOf('android') > 0;
  32982. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  32983. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  32984. var supportsPassive = false;
  32985. if (inBrowser) {
  32986. try {
  32987. var opts = {};
  32988. Object.defineProperty(opts, 'passive', ({
  32989. get: function get () {
  32990. /* istanbul ignore next */
  32991. supportsPassive = true;
  32992. }
  32993. } )); // https://github.com/facebook/flow/issues/285
  32994. window.addEventListener('test-passive', null, opts);
  32995. } catch (e) {}
  32996. }
  32997. // this needs to be lazy-evaled because vue may be required before
  32998. // vue-server-renderer can set VUE_ENV
  32999. var _isServer;
  33000. var isServerRendering = function () {
  33001. if (_isServer === undefined) {
  33002. /* istanbul ignore if */
  33003. if (!inBrowser && typeof global !== 'undefined') {
  33004. // detect presence of vue-server-renderer and avoid
  33005. // Webpack shimming the process
  33006. _isServer = global['process'].env.VUE_ENV === 'server';
  33007. } else {
  33008. _isServer = false;
  33009. }
  33010. }
  33011. return _isServer
  33012. };
  33013. // detect devtools
  33014. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  33015. /* istanbul ignore next */
  33016. function isNative (Ctor) {
  33017. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  33018. }
  33019. var hasSymbol =
  33020. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  33021. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  33022. /**
  33023. * Defer a task to execute it asynchronously.
  33024. */
  33025. var nextTick = (function () {
  33026. var callbacks = [];
  33027. var pending = false;
  33028. var timerFunc;
  33029. function nextTickHandler () {
  33030. pending = false;
  33031. var copies = callbacks.slice(0);
  33032. callbacks.length = 0;
  33033. for (var i = 0; i < copies.length; i++) {
  33034. copies[i]();
  33035. }
  33036. }
  33037. // the nextTick behavior leverages the microtask queue, which can be accessed
  33038. // via either native Promise.then or MutationObserver.
  33039. // MutationObserver has wider support, however it is seriously bugged in
  33040. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  33041. // completely stops working after triggering a few times... so, if native
  33042. // Promise is available, we will use it:
  33043. /* istanbul ignore if */
  33044. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  33045. var p = Promise.resolve();
  33046. var logError = function (err) { console.error(err); };
  33047. timerFunc = function () {
  33048. p.then(nextTickHandler).catch(logError);
  33049. // in problematic UIWebViews, Promise.then doesn't completely break, but
  33050. // it can get stuck in a weird state where callbacks are pushed into the
  33051. // microtask queue but the queue isn't being flushed, until the browser
  33052. // needs to do some other work, e.g. handle a timer. Therefore we can
  33053. // "force" the microtask queue to be flushed by adding an empty timer.
  33054. if (isIOS) { setTimeout(noop); }
  33055. };
  33056. } else if (typeof MutationObserver !== 'undefined' && (
  33057. isNative(MutationObserver) ||
  33058. // PhantomJS and iOS 7.x
  33059. MutationObserver.toString() === '[object MutationObserverConstructor]'
  33060. )) {
  33061. // use MutationObserver where native Promise is not available,
  33062. // e.g. PhantomJS IE11, iOS7, Android 4.4
  33063. var counter = 1;
  33064. var observer = new MutationObserver(nextTickHandler);
  33065. var textNode = document.createTextNode(String(counter));
  33066. observer.observe(textNode, {
  33067. characterData: true
  33068. });
  33069. timerFunc = function () {
  33070. counter = (counter + 1) % 2;
  33071. textNode.data = String(counter);
  33072. };
  33073. } else {
  33074. // fallback to setTimeout
  33075. /* istanbul ignore next */
  33076. timerFunc = function () {
  33077. setTimeout(nextTickHandler, 0);
  33078. };
  33079. }
  33080. return function queueNextTick (cb, ctx) {
  33081. var _resolve;
  33082. callbacks.push(function () {
  33083. if (cb) {
  33084. try {
  33085. cb.call(ctx);
  33086. } catch (e) {
  33087. handleError(e, ctx, 'nextTick');
  33088. }
  33089. } else if (_resolve) {
  33090. _resolve(ctx);
  33091. }
  33092. });
  33093. if (!pending) {
  33094. pending = true;
  33095. timerFunc();
  33096. }
  33097. if (!cb && typeof Promise !== 'undefined') {
  33098. return new Promise(function (resolve, reject) {
  33099. _resolve = resolve;
  33100. })
  33101. }
  33102. }
  33103. })();
  33104. var _Set;
  33105. /* istanbul ignore if */
  33106. if (typeof Set !== 'undefined' && isNative(Set)) {
  33107. // use native Set when available.
  33108. _Set = Set;
  33109. } else {
  33110. // a non-standard Set polyfill that only works with primitive keys.
  33111. _Set = (function () {
  33112. function Set () {
  33113. this.set = Object.create(null);
  33114. }
  33115. Set.prototype.has = function has (key) {
  33116. return this.set[key] === true
  33117. };
  33118. Set.prototype.add = function add (key) {
  33119. this.set[key] = true;
  33120. };
  33121. Set.prototype.clear = function clear () {
  33122. this.set = Object.create(null);
  33123. };
  33124. return Set;
  33125. }());
  33126. }
  33127. /* */
  33128. var uid = 0;
  33129. /**
  33130. * A dep is an observable that can have multiple
  33131. * directives subscribing to it.
  33132. */
  33133. var Dep = function Dep () {
  33134. this.id = uid++;
  33135. this.subs = [];
  33136. };
  33137. Dep.prototype.addSub = function addSub (sub) {
  33138. this.subs.push(sub);
  33139. };
  33140. Dep.prototype.removeSub = function removeSub (sub) {
  33141. remove(this.subs, sub);
  33142. };
  33143. Dep.prototype.depend = function depend () {
  33144. if (Dep.target) {
  33145. Dep.target.addDep(this);
  33146. }
  33147. };
  33148. Dep.prototype.notify = function notify () {
  33149. // stabilize the subscriber list first
  33150. var subs = this.subs.slice();
  33151. for (var i = 0, l = subs.length; i < l; i++) {
  33152. subs[i].update();
  33153. }
  33154. };
  33155. // the current target watcher being evaluated.
  33156. // this is globally unique because there could be only one
  33157. // watcher being evaluated at any time.
  33158. Dep.target = null;
  33159. var targetStack = [];
  33160. function pushTarget (_target) {
  33161. if (Dep.target) { targetStack.push(Dep.target); }
  33162. Dep.target = _target;
  33163. }
  33164. function popTarget () {
  33165. Dep.target = targetStack.pop();
  33166. }
  33167. /*
  33168. * not type checking this file because flow doesn't play well with
  33169. * dynamically accessing methods on Array prototype
  33170. */
  33171. var arrayProto = Array.prototype;
  33172. var arrayMethods = Object.create(arrayProto);[
  33173. 'push',
  33174. 'pop',
  33175. 'shift',
  33176. 'unshift',
  33177. 'splice',
  33178. 'sort',
  33179. 'reverse'
  33180. ]
  33181. .forEach(function (method) {
  33182. // cache original method
  33183. var original = arrayProto[method];
  33184. def(arrayMethods, method, function mutator () {
  33185. var arguments$1 = arguments;
  33186. // avoid leaking arguments:
  33187. // http://jsperf.com/closure-with-arguments
  33188. var i = arguments.length;
  33189. var args = new Array(i);
  33190. while (i--) {
  33191. args[i] = arguments$1[i];
  33192. }
  33193. var result = original.apply(this, args);
  33194. var ob = this.__ob__;
  33195. var inserted;
  33196. switch (method) {
  33197. case 'push':
  33198. inserted = args;
  33199. break
  33200. case 'unshift':
  33201. inserted = args;
  33202. break
  33203. case 'splice':
  33204. inserted = args.slice(2);
  33205. break
  33206. }
  33207. if (inserted) { ob.observeArray(inserted); }
  33208. // notify change
  33209. ob.dep.notify();
  33210. return result
  33211. });
  33212. });
  33213. /* */
  33214. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  33215. /**
  33216. * By default, when a reactive property is set, the new value is
  33217. * also converted to become reactive. However when passing down props,
  33218. * we don't want to force conversion because the value may be a nested value
  33219. * under a frozen data structure. Converting it would defeat the optimization.
  33220. */
  33221. var observerState = {
  33222. shouldConvert: true,
  33223. isSettingProps: false
  33224. };
  33225. /**
  33226. * Observer class that are attached to each observed
  33227. * object. Once attached, the observer converts target
  33228. * object's property keys into getter/setters that
  33229. * collect dependencies and dispatches updates.
  33230. */
  33231. var Observer = function Observer (value) {
  33232. this.value = value;
  33233. this.dep = new Dep();
  33234. this.vmCount = 0;
  33235. def(value, '__ob__', this);
  33236. if (Array.isArray(value)) {
  33237. var augment = hasProto
  33238. ? protoAugment
  33239. : copyAugment;
  33240. augment(value, arrayMethods, arrayKeys);
  33241. this.observeArray(value);
  33242. } else {
  33243. this.walk(value);
  33244. }
  33245. };
  33246. /**
  33247. * Walk through each property and convert them into
  33248. * getter/setters. This method should only be called when
  33249. * value type is Object.
  33250. */
  33251. Observer.prototype.walk = function walk (obj) {
  33252. var keys = Object.keys(obj);
  33253. for (var i = 0; i < keys.length; i++) {
  33254. defineReactive$$1(obj, keys[i], obj[keys[i]]);
  33255. }
  33256. };
  33257. /**
  33258. * Observe a list of Array items.
  33259. */
  33260. Observer.prototype.observeArray = function observeArray (items) {
  33261. for (var i = 0, l = items.length; i < l; i++) {
  33262. observe(items[i]);
  33263. }
  33264. };
  33265. // helpers
  33266. /**
  33267. * Augment an target Object or Array by intercepting
  33268. * the prototype chain using __proto__
  33269. */
  33270. function protoAugment (target, src) {
  33271. /* eslint-disable no-proto */
  33272. target.__proto__ = src;
  33273. /* eslint-enable no-proto */
  33274. }
  33275. /**
  33276. * Augment an target Object or Array by defining
  33277. * hidden properties.
  33278. */
  33279. /* istanbul ignore next */
  33280. function copyAugment (target, src, keys) {
  33281. for (var i = 0, l = keys.length; i < l; i++) {
  33282. var key = keys[i];
  33283. def(target, key, src[key]);
  33284. }
  33285. }
  33286. /**
  33287. * Attempt to create an observer instance for a value,
  33288. * returns the new observer if successfully observed,
  33289. * or the existing observer if the value already has one.
  33290. */
  33291. function observe (value, asRootData) {
  33292. if (!isObject(value)) {
  33293. return
  33294. }
  33295. var ob;
  33296. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  33297. ob = value.__ob__;
  33298. } else if (
  33299. observerState.shouldConvert &&
  33300. !isServerRendering() &&
  33301. (Array.isArray(value) || isPlainObject(value)) &&
  33302. Object.isExtensible(value) &&
  33303. !value._isVue
  33304. ) {
  33305. ob = new Observer(value);
  33306. }
  33307. if (asRootData && ob) {
  33308. ob.vmCount++;
  33309. }
  33310. return ob
  33311. }
  33312. /**
  33313. * Define a reactive property on an Object.
  33314. */
  33315. function defineReactive$$1 (
  33316. obj,
  33317. key,
  33318. val,
  33319. customSetter
  33320. ) {
  33321. var dep = new Dep();
  33322. var property = Object.getOwnPropertyDescriptor(obj, key);
  33323. if (property && property.configurable === false) {
  33324. return
  33325. }
  33326. // cater for pre-defined getter/setters
  33327. var getter = property && property.get;
  33328. var setter = property && property.set;
  33329. var childOb = observe(val);
  33330. Object.defineProperty(obj, key, {
  33331. enumerable: true,
  33332. configurable: true,
  33333. get: function reactiveGetter () {
  33334. var value = getter ? getter.call(obj) : val;
  33335. if (Dep.target) {
  33336. dep.depend();
  33337. if (childOb) {
  33338. childOb.dep.depend();
  33339. }
  33340. if (Array.isArray(value)) {
  33341. dependArray(value);
  33342. }
  33343. }
  33344. return value
  33345. },
  33346. set: function reactiveSetter (newVal) {
  33347. var value = getter ? getter.call(obj) : val;
  33348. /* eslint-disable no-self-compare */
  33349. if (newVal === value || (newVal !== newVal && value !== value)) {
  33350. return
  33351. }
  33352. /* eslint-enable no-self-compare */
  33353. if ("development" !== 'production' && customSetter) {
  33354. customSetter();
  33355. }
  33356. if (setter) {
  33357. setter.call(obj, newVal);
  33358. } else {
  33359. val = newVal;
  33360. }
  33361. childOb = observe(newVal);
  33362. dep.notify();
  33363. }
  33364. });
  33365. }
  33366. /**
  33367. * Set a property on an object. Adds the new property and
  33368. * triggers change notification if the property doesn't
  33369. * already exist.
  33370. */
  33371. function set (target, key, val) {
  33372. if (Array.isArray(target) && typeof key === 'number') {
  33373. target.length = Math.max(target.length, key);
  33374. target.splice(key, 1, val);
  33375. return val
  33376. }
  33377. if (hasOwn(target, key)) {
  33378. target[key] = val;
  33379. return val
  33380. }
  33381. var ob = (target ).__ob__;
  33382. if (target._isVue || (ob && ob.vmCount)) {
  33383. "development" !== 'production' && warn(
  33384. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  33385. 'at runtime - declare it upfront in the data option.'
  33386. );
  33387. return val
  33388. }
  33389. if (!ob) {
  33390. target[key] = val;
  33391. return val
  33392. }
  33393. defineReactive$$1(ob.value, key, val);
  33394. ob.dep.notify();
  33395. return val
  33396. }
  33397. /**
  33398. * Delete a property and trigger change if necessary.
  33399. */
  33400. function del (target, key) {
  33401. if (Array.isArray(target) && typeof key === 'number') {
  33402. target.splice(key, 1);
  33403. return
  33404. }
  33405. var ob = (target ).__ob__;
  33406. if (target._isVue || (ob && ob.vmCount)) {
  33407. "development" !== 'production' && warn(
  33408. 'Avoid deleting properties on a Vue instance or its root $data ' +
  33409. '- just set it to null.'
  33410. );
  33411. return
  33412. }
  33413. if (!hasOwn(target, key)) {
  33414. return
  33415. }
  33416. delete target[key];
  33417. if (!ob) {
  33418. return
  33419. }
  33420. ob.dep.notify();
  33421. }
  33422. /**
  33423. * Collect dependencies on array elements when the array is touched, since
  33424. * we cannot intercept array element access like property getters.
  33425. */
  33426. function dependArray (value) {
  33427. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  33428. e = value[i];
  33429. e && e.__ob__ && e.__ob__.dep.depend();
  33430. if (Array.isArray(e)) {
  33431. dependArray(e);
  33432. }
  33433. }
  33434. }
  33435. /* */
  33436. /**
  33437. * Option overwriting strategies are functions that handle
  33438. * how to merge a parent option value and a child option
  33439. * value into the final value.
  33440. */
  33441. var strats = config.optionMergeStrategies;
  33442. /**
  33443. * Options with restrictions
  33444. */
  33445. if (true) {
  33446. strats.el = strats.propsData = function (parent, child, vm, key) {
  33447. if (!vm) {
  33448. warn(
  33449. "option \"" + key + "\" can only be used during instance " +
  33450. 'creation with the `new` keyword.'
  33451. );
  33452. }
  33453. return defaultStrat(parent, child)
  33454. };
  33455. }
  33456. /**
  33457. * Helper that recursively merges two data objects together.
  33458. */
  33459. function mergeData (to, from) {
  33460. if (!from) { return to }
  33461. var key, toVal, fromVal;
  33462. var keys = Object.keys(from);
  33463. for (var i = 0; i < keys.length; i++) {
  33464. key = keys[i];
  33465. toVal = to[key];
  33466. fromVal = from[key];
  33467. if (!hasOwn(to, key)) {
  33468. set(to, key, fromVal);
  33469. } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
  33470. mergeData(toVal, fromVal);
  33471. }
  33472. }
  33473. return to
  33474. }
  33475. /**
  33476. * Data
  33477. */
  33478. strats.data = function (
  33479. parentVal,
  33480. childVal,
  33481. vm
  33482. ) {
  33483. if (!vm) {
  33484. // in a Vue.extend merge, both should be functions
  33485. if (!childVal) {
  33486. return parentVal
  33487. }
  33488. if (typeof childVal !== 'function') {
  33489. "development" !== 'production' && warn(
  33490. 'The "data" option should be a function ' +
  33491. 'that returns a per-instance value in component ' +
  33492. 'definitions.',
  33493. vm
  33494. );
  33495. return parentVal
  33496. }
  33497. if (!parentVal) {
  33498. return childVal
  33499. }
  33500. // when parentVal & childVal are both present,
  33501. // we need to return a function that returns the
  33502. // merged result of both functions... no need to
  33503. // check if parentVal is a function here because
  33504. // it has to be a function to pass previous merges.
  33505. return function mergedDataFn () {
  33506. return mergeData(
  33507. childVal.call(this),
  33508. parentVal.call(this)
  33509. )
  33510. }
  33511. } else if (parentVal || childVal) {
  33512. return function mergedInstanceDataFn () {
  33513. // instance merge
  33514. var instanceData = typeof childVal === 'function'
  33515. ? childVal.call(vm)
  33516. : childVal;
  33517. var defaultData = typeof parentVal === 'function'
  33518. ? parentVal.call(vm)
  33519. : undefined;
  33520. if (instanceData) {
  33521. return mergeData(instanceData, defaultData)
  33522. } else {
  33523. return defaultData
  33524. }
  33525. }
  33526. }
  33527. };
  33528. /**
  33529. * Hooks and props are merged as arrays.
  33530. */
  33531. function mergeHook (
  33532. parentVal,
  33533. childVal
  33534. ) {
  33535. return childVal
  33536. ? parentVal
  33537. ? parentVal.concat(childVal)
  33538. : Array.isArray(childVal)
  33539. ? childVal
  33540. : [childVal]
  33541. : parentVal
  33542. }
  33543. LIFECYCLE_HOOKS.forEach(function (hook) {
  33544. strats[hook] = mergeHook;
  33545. });
  33546. /**
  33547. * Assets
  33548. *
  33549. * When a vm is present (instance creation), we need to do
  33550. * a three-way merge between constructor options, instance
  33551. * options and parent options.
  33552. */
  33553. function mergeAssets (parentVal, childVal) {
  33554. var res = Object.create(parentVal || null);
  33555. return childVal
  33556. ? extend(res, childVal)
  33557. : res
  33558. }
  33559. ASSET_TYPES.forEach(function (type) {
  33560. strats[type + 's'] = mergeAssets;
  33561. });
  33562. /**
  33563. * Watchers.
  33564. *
  33565. * Watchers hashes should not overwrite one
  33566. * another, so we merge them as arrays.
  33567. */
  33568. strats.watch = function (parentVal, childVal) {
  33569. /* istanbul ignore if */
  33570. if (!childVal) { return Object.create(parentVal || null) }
  33571. if (!parentVal) { return childVal }
  33572. var ret = {};
  33573. extend(ret, parentVal);
  33574. for (var key in childVal) {
  33575. var parent = ret[key];
  33576. var child = childVal[key];
  33577. if (parent && !Array.isArray(parent)) {
  33578. parent = [parent];
  33579. }
  33580. ret[key] = parent
  33581. ? parent.concat(child)
  33582. : [child];
  33583. }
  33584. return ret
  33585. };
  33586. /**
  33587. * Other object hashes.
  33588. */
  33589. strats.props =
  33590. strats.methods =
  33591. strats.computed = function (parentVal, childVal) {
  33592. if (!childVal) { return Object.create(parentVal || null) }
  33593. if (!parentVal) { return childVal }
  33594. var ret = Object.create(null);
  33595. extend(ret, parentVal);
  33596. extend(ret, childVal);
  33597. return ret
  33598. };
  33599. /**
  33600. * Default strategy.
  33601. */
  33602. var defaultStrat = function (parentVal, childVal) {
  33603. return childVal === undefined
  33604. ? parentVal
  33605. : childVal
  33606. };
  33607. /**
  33608. * Validate component names
  33609. */
  33610. function checkComponents (options) {
  33611. for (var key in options.components) {
  33612. var lower = key.toLowerCase();
  33613. if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
  33614. warn(
  33615. 'Do not use built-in or reserved HTML elements as component ' +
  33616. 'id: ' + key
  33617. );
  33618. }
  33619. }
  33620. }
  33621. /**
  33622. * Ensure all props option syntax are normalized into the
  33623. * Object-based format.
  33624. */
  33625. function normalizeProps (options) {
  33626. var props = options.props;
  33627. if (!props) { return }
  33628. var res = {};
  33629. var i, val, name;
  33630. if (Array.isArray(props)) {
  33631. i = props.length;
  33632. while (i--) {
  33633. val = props[i];
  33634. if (typeof val === 'string') {
  33635. name = camelize(val);
  33636. res[name] = { type: null };
  33637. } else if (true) {
  33638. warn('props must be strings when using array syntax.');
  33639. }
  33640. }
  33641. } else if (isPlainObject(props)) {
  33642. for (var key in props) {
  33643. val = props[key];
  33644. name = camelize(key);
  33645. res[name] = isPlainObject(val)
  33646. ? val
  33647. : { type: val };
  33648. }
  33649. }
  33650. options.props = res;
  33651. }
  33652. /**
  33653. * Normalize raw function directives into object format.
  33654. */
  33655. function normalizeDirectives (options) {
  33656. var dirs = options.directives;
  33657. if (dirs) {
  33658. for (var key in dirs) {
  33659. var def = dirs[key];
  33660. if (typeof def === 'function') {
  33661. dirs[key] = { bind: def, update: def };
  33662. }
  33663. }
  33664. }
  33665. }
  33666. /**
  33667. * Merge two option objects into a new one.
  33668. * Core utility used in both instantiation and inheritance.
  33669. */
  33670. function mergeOptions (
  33671. parent,
  33672. child,
  33673. vm
  33674. ) {
  33675. if (true) {
  33676. checkComponents(child);
  33677. }
  33678. if (typeof child === 'function') {
  33679. child = child.options;
  33680. }
  33681. normalizeProps(child);
  33682. normalizeDirectives(child);
  33683. var extendsFrom = child.extends;
  33684. if (extendsFrom) {
  33685. parent = mergeOptions(parent, extendsFrom, vm);
  33686. }
  33687. if (child.mixins) {
  33688. for (var i = 0, l = child.mixins.length; i < l; i++) {
  33689. parent = mergeOptions(parent, child.mixins[i], vm);
  33690. }
  33691. }
  33692. var options = {};
  33693. var key;
  33694. for (key in parent) {
  33695. mergeField(key);
  33696. }
  33697. for (key in child) {
  33698. if (!hasOwn(parent, key)) {
  33699. mergeField(key);
  33700. }
  33701. }
  33702. function mergeField (key) {
  33703. var strat = strats[key] || defaultStrat;
  33704. options[key] = strat(parent[key], child[key], vm, key);
  33705. }
  33706. return options
  33707. }
  33708. /**
  33709. * Resolve an asset.
  33710. * This function is used because child instances need access
  33711. * to assets defined in its ancestor chain.
  33712. */
  33713. function resolveAsset (
  33714. options,
  33715. type,
  33716. id,
  33717. warnMissing
  33718. ) {
  33719. /* istanbul ignore if */
  33720. if (typeof id !== 'string') {
  33721. return
  33722. }
  33723. var assets = options[type];
  33724. // check local registration variations first
  33725. if (hasOwn(assets, id)) { return assets[id] }
  33726. var camelizedId = camelize(id);
  33727. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  33728. var PascalCaseId = capitalize(camelizedId);
  33729. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  33730. // fallback to prototype chain
  33731. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  33732. if ("development" !== 'production' && warnMissing && !res) {
  33733. warn(
  33734. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  33735. options
  33736. );
  33737. }
  33738. return res
  33739. }
  33740. /* */
  33741. function validateProp (
  33742. key,
  33743. propOptions,
  33744. propsData,
  33745. vm
  33746. ) {
  33747. var prop = propOptions[key];
  33748. var absent = !hasOwn(propsData, key);
  33749. var value = propsData[key];
  33750. // handle boolean props
  33751. if (isType(Boolean, prop.type)) {
  33752. if (absent && !hasOwn(prop, 'default')) {
  33753. value = false;
  33754. } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
  33755. value = true;
  33756. }
  33757. }
  33758. // check default value
  33759. if (value === undefined) {
  33760. value = getPropDefaultValue(vm, prop, key);
  33761. // since the default value is a fresh copy,
  33762. // make sure to observe it.
  33763. var prevShouldConvert = observerState.shouldConvert;
  33764. observerState.shouldConvert = true;
  33765. observe(value);
  33766. observerState.shouldConvert = prevShouldConvert;
  33767. }
  33768. if (true) {
  33769. assertProp(prop, key, value, vm, absent);
  33770. }
  33771. return value
  33772. }
  33773. /**
  33774. * Get the default value of a prop.
  33775. */
  33776. function getPropDefaultValue (vm, prop, key) {
  33777. // no default, return undefined
  33778. if (!hasOwn(prop, 'default')) {
  33779. return undefined
  33780. }
  33781. var def = prop.default;
  33782. // warn against non-factory defaults for Object & Array
  33783. if ("development" !== 'production' && isObject(def)) {
  33784. warn(
  33785. 'Invalid default value for prop "' + key + '": ' +
  33786. 'Props with type Object/Array must use a factory function ' +
  33787. 'to return the default value.',
  33788. vm
  33789. );
  33790. }
  33791. // the raw prop value was also undefined from previous render,
  33792. // return previous default value to avoid unnecessary watcher trigger
  33793. if (vm && vm.$options.propsData &&
  33794. vm.$options.propsData[key] === undefined &&
  33795. vm._props[key] !== undefined
  33796. ) {
  33797. return vm._props[key]
  33798. }
  33799. // call factory function for non-Function types
  33800. // a value is Function if its prototype is function even across different execution context
  33801. return typeof def === 'function' && getType(prop.type) !== 'Function'
  33802. ? def.call(vm)
  33803. : def
  33804. }
  33805. /**
  33806. * Assert whether a prop is valid.
  33807. */
  33808. function assertProp (
  33809. prop,
  33810. name,
  33811. value,
  33812. vm,
  33813. absent
  33814. ) {
  33815. if (prop.required && absent) {
  33816. warn(
  33817. 'Missing required prop: "' + name + '"',
  33818. vm
  33819. );
  33820. return
  33821. }
  33822. if (value == null && !prop.required) {
  33823. return
  33824. }
  33825. var type = prop.type;
  33826. var valid = !type || type === true;
  33827. var expectedTypes = [];
  33828. if (type) {
  33829. if (!Array.isArray(type)) {
  33830. type = [type];
  33831. }
  33832. for (var i = 0; i < type.length && !valid; i++) {
  33833. var assertedType = assertType(value, type[i]);
  33834. expectedTypes.push(assertedType.expectedType || '');
  33835. valid = assertedType.valid;
  33836. }
  33837. }
  33838. if (!valid) {
  33839. warn(
  33840. 'Invalid prop: type check failed for prop "' + name + '".' +
  33841. ' Expected ' + expectedTypes.map(capitalize).join(', ') +
  33842. ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
  33843. vm
  33844. );
  33845. return
  33846. }
  33847. var validator = prop.validator;
  33848. if (validator) {
  33849. if (!validator(value)) {
  33850. warn(
  33851. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  33852. vm
  33853. );
  33854. }
  33855. }
  33856. }
  33857. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  33858. function assertType (value, type) {
  33859. var valid;
  33860. var expectedType = getType(type);
  33861. if (simpleCheckRE.test(expectedType)) {
  33862. valid = typeof value === expectedType.toLowerCase();
  33863. } else if (expectedType === 'Object') {
  33864. valid = isPlainObject(value);
  33865. } else if (expectedType === 'Array') {
  33866. valid = Array.isArray(value);
  33867. } else {
  33868. valid = value instanceof type;
  33869. }
  33870. return {
  33871. valid: valid,
  33872. expectedType: expectedType
  33873. }
  33874. }
  33875. /**
  33876. * Use function string name to check built-in types,
  33877. * because a simple equality check will fail when running
  33878. * across different vms / iframes.
  33879. */
  33880. function getType (fn) {
  33881. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  33882. return match ? match[1] : ''
  33883. }
  33884. function isType (type, fn) {
  33885. if (!Array.isArray(fn)) {
  33886. return getType(fn) === getType(type)
  33887. }
  33888. for (var i = 0, len = fn.length; i < len; i++) {
  33889. if (getType(fn[i]) === getType(type)) {
  33890. return true
  33891. }
  33892. }
  33893. /* istanbul ignore next */
  33894. return false
  33895. }
  33896. /* */
  33897. var mark;
  33898. var measure;
  33899. if (true) {
  33900. var perf = inBrowser && window.performance;
  33901. /* istanbul ignore if */
  33902. if (
  33903. perf &&
  33904. perf.mark &&
  33905. perf.measure &&
  33906. perf.clearMarks &&
  33907. perf.clearMeasures
  33908. ) {
  33909. mark = function (tag) { return perf.mark(tag); };
  33910. measure = function (name, startTag, endTag) {
  33911. perf.measure(name, startTag, endTag);
  33912. perf.clearMarks(startTag);
  33913. perf.clearMarks(endTag);
  33914. perf.clearMeasures(name);
  33915. };
  33916. }
  33917. }
  33918. /* not type checking this file because flow doesn't play well with Proxy */
  33919. var initProxy;
  33920. if (true) {
  33921. var allowedGlobals = makeMap(
  33922. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  33923. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  33924. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  33925. 'require' // for Webpack/Browserify
  33926. );
  33927. var warnNonPresent = function (target, key) {
  33928. warn(
  33929. "Property or method \"" + key + "\" is not defined on the instance but " +
  33930. "referenced during render. Make sure to declare reactive data " +
  33931. "properties in the data option.",
  33932. target
  33933. );
  33934. };
  33935. var hasProxy =
  33936. typeof Proxy !== 'undefined' &&
  33937. Proxy.toString().match(/native code/);
  33938. if (hasProxy) {
  33939. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta');
  33940. config.keyCodes = new Proxy(config.keyCodes, {
  33941. set: function set (target, key, value) {
  33942. if (isBuiltInModifier(key)) {
  33943. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  33944. return false
  33945. } else {
  33946. target[key] = value;
  33947. return true
  33948. }
  33949. }
  33950. });
  33951. }
  33952. var hasHandler = {
  33953. has: function has (target, key) {
  33954. var has = key in target;
  33955. var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
  33956. if (!has && !isAllowed) {
  33957. warnNonPresent(target, key);
  33958. }
  33959. return has || !isAllowed
  33960. }
  33961. };
  33962. var getHandler = {
  33963. get: function get (target, key) {
  33964. if (typeof key === 'string' && !(key in target)) {
  33965. warnNonPresent(target, key);
  33966. }
  33967. return target[key]
  33968. }
  33969. };
  33970. initProxy = function initProxy (vm) {
  33971. if (hasProxy) {
  33972. // determine which proxy handler to use
  33973. var options = vm.$options;
  33974. var handlers = options.render && options.render._withStripped
  33975. ? getHandler
  33976. : hasHandler;
  33977. vm._renderProxy = new Proxy(vm, handlers);
  33978. } else {
  33979. vm._renderProxy = vm;
  33980. }
  33981. };
  33982. }
  33983. /* */
  33984. var VNode = function VNode (
  33985. tag,
  33986. data,
  33987. children,
  33988. text,
  33989. elm,
  33990. context,
  33991. componentOptions
  33992. ) {
  33993. this.tag = tag;
  33994. this.data = data;
  33995. this.children = children;
  33996. this.text = text;
  33997. this.elm = elm;
  33998. this.ns = undefined;
  33999. this.context = context;
  34000. this.functionalContext = undefined;
  34001. this.key = data && data.key;
  34002. this.componentOptions = componentOptions;
  34003. this.componentInstance = undefined;
  34004. this.parent = undefined;
  34005. this.raw = false;
  34006. this.isStatic = false;
  34007. this.isRootInsert = true;
  34008. this.isComment = false;
  34009. this.isCloned = false;
  34010. this.isOnce = false;
  34011. };
  34012. var prototypeAccessors = { child: {} };
  34013. // DEPRECATED: alias for componentInstance for backwards compat.
  34014. /* istanbul ignore next */
  34015. prototypeAccessors.child.get = function () {
  34016. return this.componentInstance
  34017. };
  34018. Object.defineProperties( VNode.prototype, prototypeAccessors );
  34019. var createEmptyVNode = function () {
  34020. var node = new VNode();
  34021. node.text = '';
  34022. node.isComment = true;
  34023. return node
  34024. };
  34025. function createTextVNode (val) {
  34026. return new VNode(undefined, undefined, undefined, String(val))
  34027. }
  34028. // optimized shallow clone
  34029. // used for static nodes and slot nodes because they may be reused across
  34030. // multiple renders, cloning them avoids errors when DOM manipulations rely
  34031. // on their elm reference.
  34032. function cloneVNode (vnode) {
  34033. var cloned = new VNode(
  34034. vnode.tag,
  34035. vnode.data,
  34036. vnode.children,
  34037. vnode.text,
  34038. vnode.elm,
  34039. vnode.context,
  34040. vnode.componentOptions
  34041. );
  34042. cloned.ns = vnode.ns;
  34043. cloned.isStatic = vnode.isStatic;
  34044. cloned.key = vnode.key;
  34045. cloned.isComment = vnode.isComment;
  34046. cloned.isCloned = true;
  34047. return cloned
  34048. }
  34049. function cloneVNodes (vnodes) {
  34050. var len = vnodes.length;
  34051. var res = new Array(len);
  34052. for (var i = 0; i < len; i++) {
  34053. res[i] = cloneVNode(vnodes[i]);
  34054. }
  34055. return res
  34056. }
  34057. /* */
  34058. var normalizeEvent = cached(function (name) {
  34059. var passive = name.charAt(0) === '&';
  34060. name = passive ? name.slice(1) : name;
  34061. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  34062. name = once$$1 ? name.slice(1) : name;
  34063. var capture = name.charAt(0) === '!';
  34064. name = capture ? name.slice(1) : name;
  34065. return {
  34066. name: name,
  34067. once: once$$1,
  34068. capture: capture,
  34069. passive: passive
  34070. }
  34071. });
  34072. function createFnInvoker (fns) {
  34073. function invoker () {
  34074. var arguments$1 = arguments;
  34075. var fns = invoker.fns;
  34076. if (Array.isArray(fns)) {
  34077. for (var i = 0; i < fns.length; i++) {
  34078. fns[i].apply(null, arguments$1);
  34079. }
  34080. } else {
  34081. // return handler return value for single handlers
  34082. return fns.apply(null, arguments)
  34083. }
  34084. }
  34085. invoker.fns = fns;
  34086. return invoker
  34087. }
  34088. function updateListeners (
  34089. on,
  34090. oldOn,
  34091. add,
  34092. remove$$1,
  34093. vm
  34094. ) {
  34095. var name, cur, old, event;
  34096. for (name in on) {
  34097. cur = on[name];
  34098. old = oldOn[name];
  34099. event = normalizeEvent(name);
  34100. if (isUndef(cur)) {
  34101. "development" !== 'production' && warn(
  34102. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  34103. vm
  34104. );
  34105. } else if (isUndef(old)) {
  34106. if (isUndef(cur.fns)) {
  34107. cur = on[name] = createFnInvoker(cur);
  34108. }
  34109. add(event.name, cur, event.once, event.capture, event.passive);
  34110. } else if (cur !== old) {
  34111. old.fns = cur;
  34112. on[name] = old;
  34113. }
  34114. }
  34115. for (name in oldOn) {
  34116. if (isUndef(on[name])) {
  34117. event = normalizeEvent(name);
  34118. remove$$1(event.name, oldOn[name], event.capture);
  34119. }
  34120. }
  34121. }
  34122. /* */
  34123. function mergeVNodeHook (def, hookKey, hook) {
  34124. var invoker;
  34125. var oldHook = def[hookKey];
  34126. function wrappedHook () {
  34127. hook.apply(this, arguments);
  34128. // important: remove merged hook to ensure it's called only once
  34129. // and prevent memory leak
  34130. remove(invoker.fns, wrappedHook);
  34131. }
  34132. if (isUndef(oldHook)) {
  34133. // no existing hook
  34134. invoker = createFnInvoker([wrappedHook]);
  34135. } else {
  34136. /* istanbul ignore if */
  34137. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  34138. // already a merged invoker
  34139. invoker = oldHook;
  34140. invoker.fns.push(wrappedHook);
  34141. } else {
  34142. // existing plain hook
  34143. invoker = createFnInvoker([oldHook, wrappedHook]);
  34144. }
  34145. }
  34146. invoker.merged = true;
  34147. def[hookKey] = invoker;
  34148. }
  34149. /* */
  34150. function extractPropsFromVNodeData (
  34151. data,
  34152. Ctor,
  34153. tag
  34154. ) {
  34155. // we are only extracting raw values here.
  34156. // validation and default values are handled in the child
  34157. // component itself.
  34158. var propOptions = Ctor.options.props;
  34159. if (isUndef(propOptions)) {
  34160. return
  34161. }
  34162. var res = {};
  34163. var attrs = data.attrs;
  34164. var props = data.props;
  34165. if (isDef(attrs) || isDef(props)) {
  34166. for (var key in propOptions) {
  34167. var altKey = hyphenate(key);
  34168. if (true) {
  34169. var keyInLowerCase = key.toLowerCase();
  34170. if (
  34171. key !== keyInLowerCase &&
  34172. attrs && hasOwn(attrs, keyInLowerCase)
  34173. ) {
  34174. tip(
  34175. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  34176. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  34177. " \"" + key + "\". " +
  34178. "Note that HTML attributes are case-insensitive and camelCased " +
  34179. "props need to use their kebab-case equivalents when using in-DOM " +
  34180. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  34181. );
  34182. }
  34183. }
  34184. checkProp(res, props, key, altKey, true) ||
  34185. checkProp(res, attrs, key, altKey, false);
  34186. }
  34187. }
  34188. return res
  34189. }
  34190. function checkProp (
  34191. res,
  34192. hash,
  34193. key,
  34194. altKey,
  34195. preserve
  34196. ) {
  34197. if (isDef(hash)) {
  34198. if (hasOwn(hash, key)) {
  34199. res[key] = hash[key];
  34200. if (!preserve) {
  34201. delete hash[key];
  34202. }
  34203. return true
  34204. } else if (hasOwn(hash, altKey)) {
  34205. res[key] = hash[altKey];
  34206. if (!preserve) {
  34207. delete hash[altKey];
  34208. }
  34209. return true
  34210. }
  34211. }
  34212. return false
  34213. }
  34214. /* */
  34215. // The template compiler attempts to minimize the need for normalization by
  34216. // statically analyzing the template at compile time.
  34217. //
  34218. // For plain HTML markup, normalization can be completely skipped because the
  34219. // generated render function is guaranteed to return Array<VNode>. There are
  34220. // two cases where extra normalization is needed:
  34221. // 1. When the children contains components - because a functional component
  34222. // may return an Array instead of a single root. In this case, just a simple
  34223. // normalization is needed - if any child is an Array, we flatten the whole
  34224. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  34225. // because functional components already normalize their own children.
  34226. function simpleNormalizeChildren (children) {
  34227. for (var i = 0; i < children.length; i++) {
  34228. if (Array.isArray(children[i])) {
  34229. return Array.prototype.concat.apply([], children)
  34230. }
  34231. }
  34232. return children
  34233. }
  34234. // 2. When the children contains constructs that always generated nested Arrays,
  34235. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  34236. // with hand-written render functions / JSX. In such cases a full normalization
  34237. // is needed to cater to all possible types of children values.
  34238. function normalizeChildren (children) {
  34239. return isPrimitive(children)
  34240. ? [createTextVNode(children)]
  34241. : Array.isArray(children)
  34242. ? normalizeArrayChildren(children)
  34243. : undefined
  34244. }
  34245. function isTextNode (node) {
  34246. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  34247. }
  34248. function normalizeArrayChildren (children, nestedIndex) {
  34249. var res = [];
  34250. var i, c, last;
  34251. for (i = 0; i < children.length; i++) {
  34252. c = children[i];
  34253. if (isUndef(c) || typeof c === 'boolean') { continue }
  34254. last = res[res.length - 1];
  34255. // nested
  34256. if (Array.isArray(c)) {
  34257. res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
  34258. } else if (isPrimitive(c)) {
  34259. if (isTextNode(last)) {
  34260. // merge adjacent text nodes
  34261. // this is necessary for SSR hydration because text nodes are
  34262. // essentially merged when rendered to HTML strings
  34263. (last).text += String(c);
  34264. } else if (c !== '') {
  34265. // convert primitive to vnode
  34266. res.push(createTextVNode(c));
  34267. }
  34268. } else {
  34269. if (isTextNode(c) && isTextNode(last)) {
  34270. // merge adjacent text nodes
  34271. res[res.length - 1] = createTextVNode(last.text + c.text);
  34272. } else {
  34273. // default key for nested array children (likely generated by v-for)
  34274. if (isTrue(children._isVList) &&
  34275. isDef(c.tag) &&
  34276. isUndef(c.key) &&
  34277. isDef(nestedIndex)) {
  34278. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  34279. }
  34280. res.push(c);
  34281. }
  34282. }
  34283. }
  34284. return res
  34285. }
  34286. /* */
  34287. function ensureCtor (comp, base) {
  34288. return isObject(comp)
  34289. ? base.extend(comp)
  34290. : comp
  34291. }
  34292. function resolveAsyncComponent (
  34293. factory,
  34294. baseCtor,
  34295. context
  34296. ) {
  34297. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  34298. return factory.errorComp
  34299. }
  34300. if (isDef(factory.resolved)) {
  34301. return factory.resolved
  34302. }
  34303. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  34304. return factory.loadingComp
  34305. }
  34306. if (isDef(factory.contexts)) {
  34307. // already pending
  34308. factory.contexts.push(context);
  34309. } else {
  34310. var contexts = factory.contexts = [context];
  34311. var sync = true;
  34312. var forceRender = function () {
  34313. for (var i = 0, l = contexts.length; i < l; i++) {
  34314. contexts[i].$forceUpdate();
  34315. }
  34316. };
  34317. var resolve = once(function (res) {
  34318. // cache resolved
  34319. factory.resolved = ensureCtor(res, baseCtor);
  34320. // invoke callbacks only if this is not a synchronous resolve
  34321. // (async resolves are shimmed as synchronous during SSR)
  34322. if (!sync) {
  34323. forceRender();
  34324. }
  34325. });
  34326. var reject = once(function (reason) {
  34327. "development" !== 'production' && warn(
  34328. "Failed to resolve async component: " + (String(factory)) +
  34329. (reason ? ("\nReason: " + reason) : '')
  34330. );
  34331. if (isDef(factory.errorComp)) {
  34332. factory.error = true;
  34333. forceRender();
  34334. }
  34335. });
  34336. var res = factory(resolve, reject);
  34337. if (isObject(res)) {
  34338. if (typeof res.then === 'function') {
  34339. // () => Promise
  34340. if (isUndef(factory.resolved)) {
  34341. res.then(resolve, reject);
  34342. }
  34343. } else if (isDef(res.component) && typeof res.component.then === 'function') {
  34344. res.component.then(resolve, reject);
  34345. if (isDef(res.error)) {
  34346. factory.errorComp = ensureCtor(res.error, baseCtor);
  34347. }
  34348. if (isDef(res.loading)) {
  34349. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  34350. if (res.delay === 0) {
  34351. factory.loading = true;
  34352. } else {
  34353. setTimeout(function () {
  34354. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  34355. factory.loading = true;
  34356. forceRender();
  34357. }
  34358. }, res.delay || 200);
  34359. }
  34360. }
  34361. if (isDef(res.timeout)) {
  34362. setTimeout(function () {
  34363. if (isUndef(factory.resolved)) {
  34364. reject(
  34365. true
  34366. ? ("timeout (" + (res.timeout) + "ms)")
  34367. : null
  34368. );
  34369. }
  34370. }, res.timeout);
  34371. }
  34372. }
  34373. }
  34374. sync = false;
  34375. // return in case resolved synchronously
  34376. return factory.loading
  34377. ? factory.loadingComp
  34378. : factory.resolved
  34379. }
  34380. }
  34381. /* */
  34382. function getFirstComponentChild (children) {
  34383. if (Array.isArray(children)) {
  34384. for (var i = 0; i < children.length; i++) {
  34385. var c = children[i];
  34386. if (isDef(c) && isDef(c.componentOptions)) {
  34387. return c
  34388. }
  34389. }
  34390. }
  34391. }
  34392. /* */
  34393. /* */
  34394. function initEvents (vm) {
  34395. vm._events = Object.create(null);
  34396. vm._hasHookEvent = false;
  34397. // init parent attached events
  34398. var listeners = vm.$options._parentListeners;
  34399. if (listeners) {
  34400. updateComponentListeners(vm, listeners);
  34401. }
  34402. }
  34403. var target;
  34404. function add (event, fn, once$$1) {
  34405. if (once$$1) {
  34406. target.$once(event, fn);
  34407. } else {
  34408. target.$on(event, fn);
  34409. }
  34410. }
  34411. function remove$1 (event, fn) {
  34412. target.$off(event, fn);
  34413. }
  34414. function updateComponentListeners (
  34415. vm,
  34416. listeners,
  34417. oldListeners
  34418. ) {
  34419. target = vm;
  34420. updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
  34421. }
  34422. function eventsMixin (Vue) {
  34423. var hookRE = /^hook:/;
  34424. Vue.prototype.$on = function (event, fn) {
  34425. var this$1 = this;
  34426. var vm = this;
  34427. if (Array.isArray(event)) {
  34428. for (var i = 0, l = event.length; i < l; i++) {
  34429. this$1.$on(event[i], fn);
  34430. }
  34431. } else {
  34432. (vm._events[event] || (vm._events[event] = [])).push(fn);
  34433. // optimize hook:event cost by using a boolean flag marked at registration
  34434. // instead of a hash lookup
  34435. if (hookRE.test(event)) {
  34436. vm._hasHookEvent = true;
  34437. }
  34438. }
  34439. return vm
  34440. };
  34441. Vue.prototype.$once = function (event, fn) {
  34442. var vm = this;
  34443. function on () {
  34444. vm.$off(event, on);
  34445. fn.apply(vm, arguments);
  34446. }
  34447. on.fn = fn;
  34448. vm.$on(event, on);
  34449. return vm
  34450. };
  34451. Vue.prototype.$off = function (event, fn) {
  34452. var this$1 = this;
  34453. var vm = this;
  34454. // all
  34455. if (!arguments.length) {
  34456. vm._events = Object.create(null);
  34457. return vm
  34458. }
  34459. // array of events
  34460. if (Array.isArray(event)) {
  34461. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  34462. this$1.$off(event[i$1], fn);
  34463. }
  34464. return vm
  34465. }
  34466. // specific event
  34467. var cbs = vm._events[event];
  34468. if (!cbs) {
  34469. return vm
  34470. }
  34471. if (arguments.length === 1) {
  34472. vm._events[event] = null;
  34473. return vm
  34474. }
  34475. // specific handler
  34476. var cb;
  34477. var i = cbs.length;
  34478. while (i--) {
  34479. cb = cbs[i];
  34480. if (cb === fn || cb.fn === fn) {
  34481. cbs.splice(i, 1);
  34482. break
  34483. }
  34484. }
  34485. return vm
  34486. };
  34487. Vue.prototype.$emit = function (event) {
  34488. var vm = this;
  34489. if (true) {
  34490. var lowerCaseEvent = event.toLowerCase();
  34491. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  34492. tip(
  34493. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  34494. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  34495. "Note that HTML attributes are case-insensitive and you cannot use " +
  34496. "v-on to listen to camelCase events when using in-DOM templates. " +
  34497. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  34498. );
  34499. }
  34500. }
  34501. var cbs = vm._events[event];
  34502. if (cbs) {
  34503. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  34504. var args = toArray(arguments, 1);
  34505. for (var i = 0, l = cbs.length; i < l; i++) {
  34506. cbs[i].apply(vm, args);
  34507. }
  34508. }
  34509. return vm
  34510. };
  34511. }
  34512. /* */
  34513. /**
  34514. * Runtime helper for resolving raw children VNodes into a slot object.
  34515. */
  34516. function resolveSlots (
  34517. children,
  34518. context
  34519. ) {
  34520. var slots = {};
  34521. if (!children) {
  34522. return slots
  34523. }
  34524. var defaultSlot = [];
  34525. for (var i = 0, l = children.length; i < l; i++) {
  34526. var child = children[i];
  34527. // named slots should only be respected if the vnode was rendered in the
  34528. // same context.
  34529. if ((child.context === context || child.functionalContext === context) &&
  34530. child.data && child.data.slot != null
  34531. ) {
  34532. var name = child.data.slot;
  34533. var slot = (slots[name] || (slots[name] = []));
  34534. if (child.tag === 'template') {
  34535. slot.push.apply(slot, child.children);
  34536. } else {
  34537. slot.push(child);
  34538. }
  34539. } else {
  34540. defaultSlot.push(child);
  34541. }
  34542. }
  34543. // ignore whitespace
  34544. if (!defaultSlot.every(isWhitespace)) {
  34545. slots.default = defaultSlot;
  34546. }
  34547. return slots
  34548. }
  34549. function isWhitespace (node) {
  34550. return node.isComment || node.text === ' '
  34551. }
  34552. function resolveScopedSlots (
  34553. fns, // see flow/vnode
  34554. res
  34555. ) {
  34556. res = res || {};
  34557. for (var i = 0; i < fns.length; i++) {
  34558. if (Array.isArray(fns[i])) {
  34559. resolveScopedSlots(fns[i], res);
  34560. } else {
  34561. res[fns[i].key] = fns[i].fn;
  34562. }
  34563. }
  34564. return res
  34565. }
  34566. /* */
  34567. var activeInstance = null;
  34568. function initLifecycle (vm) {
  34569. var options = vm.$options;
  34570. // locate first non-abstract parent
  34571. var parent = options.parent;
  34572. if (parent && !options.abstract) {
  34573. while (parent.$options.abstract && parent.$parent) {
  34574. parent = parent.$parent;
  34575. }
  34576. parent.$children.push(vm);
  34577. }
  34578. vm.$parent = parent;
  34579. vm.$root = parent ? parent.$root : vm;
  34580. vm.$children = [];
  34581. vm.$refs = {};
  34582. vm._watcher = null;
  34583. vm._inactive = null;
  34584. vm._directInactive = false;
  34585. vm._isMounted = false;
  34586. vm._isDestroyed = false;
  34587. vm._isBeingDestroyed = false;
  34588. }
  34589. function lifecycleMixin (Vue) {
  34590. Vue.prototype._update = function (vnode, hydrating) {
  34591. var vm = this;
  34592. if (vm._isMounted) {
  34593. callHook(vm, 'beforeUpdate');
  34594. }
  34595. var prevEl = vm.$el;
  34596. var prevVnode = vm._vnode;
  34597. var prevActiveInstance = activeInstance;
  34598. activeInstance = vm;
  34599. vm._vnode = vnode;
  34600. // Vue.prototype.__patch__ is injected in entry points
  34601. // based on the rendering backend used.
  34602. if (!prevVnode) {
  34603. // initial render
  34604. vm.$el = vm.__patch__(
  34605. vm.$el, vnode, hydrating, false /* removeOnly */,
  34606. vm.$options._parentElm,
  34607. vm.$options._refElm
  34608. );
  34609. } else {
  34610. // updates
  34611. vm.$el = vm.__patch__(prevVnode, vnode);
  34612. }
  34613. activeInstance = prevActiveInstance;
  34614. // update __vue__ reference
  34615. if (prevEl) {
  34616. prevEl.__vue__ = null;
  34617. }
  34618. if (vm.$el) {
  34619. vm.$el.__vue__ = vm;
  34620. }
  34621. // if parent is an HOC, update its $el as well
  34622. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  34623. vm.$parent.$el = vm.$el;
  34624. }
  34625. // updated hook is called by the scheduler to ensure that children are
  34626. // updated in a parent's updated hook.
  34627. };
  34628. Vue.prototype.$forceUpdate = function () {
  34629. var vm = this;
  34630. if (vm._watcher) {
  34631. vm._watcher.update();
  34632. }
  34633. };
  34634. Vue.prototype.$destroy = function () {
  34635. var vm = this;
  34636. if (vm._isBeingDestroyed) {
  34637. return
  34638. }
  34639. callHook(vm, 'beforeDestroy');
  34640. vm._isBeingDestroyed = true;
  34641. // remove self from parent
  34642. var parent = vm.$parent;
  34643. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  34644. remove(parent.$children, vm);
  34645. }
  34646. // teardown watchers
  34647. if (vm._watcher) {
  34648. vm._watcher.teardown();
  34649. }
  34650. var i = vm._watchers.length;
  34651. while (i--) {
  34652. vm._watchers[i].teardown();
  34653. }
  34654. // remove reference from data ob
  34655. // frozen object may not have observer.
  34656. if (vm._data.__ob__) {
  34657. vm._data.__ob__.vmCount--;
  34658. }
  34659. // call the last hook...
  34660. vm._isDestroyed = true;
  34661. // invoke destroy hooks on current rendered tree
  34662. vm.__patch__(vm._vnode, null);
  34663. // fire destroyed hook
  34664. callHook(vm, 'destroyed');
  34665. // turn off all instance listeners.
  34666. vm.$off();
  34667. // remove __vue__ reference
  34668. if (vm.$el) {
  34669. vm.$el.__vue__ = null;
  34670. }
  34671. // remove reference to DOM nodes (prevents leak)
  34672. vm.$options._parentElm = vm.$options._refElm = null;
  34673. };
  34674. }
  34675. function mountComponent (
  34676. vm,
  34677. el,
  34678. hydrating
  34679. ) {
  34680. vm.$el = el;
  34681. if (!vm.$options.render) {
  34682. vm.$options.render = createEmptyVNode;
  34683. if (true) {
  34684. /* istanbul ignore if */
  34685. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  34686. vm.$options.el || el) {
  34687. warn(
  34688. 'You are using the runtime-only build of Vue where the template ' +
  34689. 'compiler is not available. Either pre-compile the templates into ' +
  34690. 'render functions, or use the compiler-included build.',
  34691. vm
  34692. );
  34693. } else {
  34694. warn(
  34695. 'Failed to mount component: template or render function not defined.',
  34696. vm
  34697. );
  34698. }
  34699. }
  34700. }
  34701. callHook(vm, 'beforeMount');
  34702. var updateComponent;
  34703. /* istanbul ignore if */
  34704. if ("development" !== 'production' && config.performance && mark) {
  34705. updateComponent = function () {
  34706. var name = vm._name;
  34707. var id = vm._uid;
  34708. var startTag = "vue-perf-start:" + id;
  34709. var endTag = "vue-perf-end:" + id;
  34710. mark(startTag);
  34711. var vnode = vm._render();
  34712. mark(endTag);
  34713. measure((name + " render"), startTag, endTag);
  34714. mark(startTag);
  34715. vm._update(vnode, hydrating);
  34716. mark(endTag);
  34717. measure((name + " patch"), startTag, endTag);
  34718. };
  34719. } else {
  34720. updateComponent = function () {
  34721. vm._update(vm._render(), hydrating);
  34722. };
  34723. }
  34724. vm._watcher = new Watcher(vm, updateComponent, noop);
  34725. hydrating = false;
  34726. // manually mounted instance, call mounted on self
  34727. // mounted is called for render-created child components in its inserted hook
  34728. if (vm.$vnode == null) {
  34729. vm._isMounted = true;
  34730. callHook(vm, 'mounted');
  34731. }
  34732. return vm
  34733. }
  34734. function updateChildComponent (
  34735. vm,
  34736. propsData,
  34737. listeners,
  34738. parentVnode,
  34739. renderChildren
  34740. ) {
  34741. // determine whether component has slot children
  34742. // we need to do this before overwriting $options._renderChildren
  34743. var hasChildren = !!(
  34744. renderChildren || // has new static slots
  34745. vm.$options._renderChildren || // has old static slots
  34746. parentVnode.data.scopedSlots || // has new scoped slots
  34747. vm.$scopedSlots !== emptyObject // has old scoped slots
  34748. );
  34749. vm.$options._parentVnode = parentVnode;
  34750. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  34751. if (vm._vnode) { // update child tree's parent
  34752. vm._vnode.parent = parentVnode;
  34753. }
  34754. vm.$options._renderChildren = renderChildren;
  34755. // update props
  34756. if (propsData && vm.$options.props) {
  34757. observerState.shouldConvert = false;
  34758. if (true) {
  34759. observerState.isSettingProps = true;
  34760. }
  34761. var props = vm._props;
  34762. var propKeys = vm.$options._propKeys || [];
  34763. for (var i = 0; i < propKeys.length; i++) {
  34764. var key = propKeys[i];
  34765. props[key] = validateProp(key, vm.$options.props, propsData, vm);
  34766. }
  34767. observerState.shouldConvert = true;
  34768. if (true) {
  34769. observerState.isSettingProps = false;
  34770. }
  34771. // keep a copy of raw propsData
  34772. vm.$options.propsData = propsData;
  34773. }
  34774. // update listeners
  34775. if (listeners) {
  34776. var oldListeners = vm.$options._parentListeners;
  34777. vm.$options._parentListeners = listeners;
  34778. updateComponentListeners(vm, listeners, oldListeners);
  34779. }
  34780. // resolve slots + force update if has children
  34781. if (hasChildren) {
  34782. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  34783. vm.$forceUpdate();
  34784. }
  34785. }
  34786. function isInInactiveTree (vm) {
  34787. while (vm && (vm = vm.$parent)) {
  34788. if (vm._inactive) { return true }
  34789. }
  34790. return false
  34791. }
  34792. function activateChildComponent (vm, direct) {
  34793. if (direct) {
  34794. vm._directInactive = false;
  34795. if (isInInactiveTree(vm)) {
  34796. return
  34797. }
  34798. } else if (vm._directInactive) {
  34799. return
  34800. }
  34801. if (vm._inactive || vm._inactive === null) {
  34802. vm._inactive = false;
  34803. for (var i = 0; i < vm.$children.length; i++) {
  34804. activateChildComponent(vm.$children[i]);
  34805. }
  34806. callHook(vm, 'activated');
  34807. }
  34808. }
  34809. function deactivateChildComponent (vm, direct) {
  34810. if (direct) {
  34811. vm._directInactive = true;
  34812. if (isInInactiveTree(vm)) {
  34813. return
  34814. }
  34815. }
  34816. if (!vm._inactive) {
  34817. vm._inactive = true;
  34818. for (var i = 0; i < vm.$children.length; i++) {
  34819. deactivateChildComponent(vm.$children[i]);
  34820. }
  34821. callHook(vm, 'deactivated');
  34822. }
  34823. }
  34824. function callHook (vm, hook) {
  34825. var handlers = vm.$options[hook];
  34826. if (handlers) {
  34827. for (var i = 0, j = handlers.length; i < j; i++) {
  34828. try {
  34829. handlers[i].call(vm);
  34830. } catch (e) {
  34831. handleError(e, vm, (hook + " hook"));
  34832. }
  34833. }
  34834. }
  34835. if (vm._hasHookEvent) {
  34836. vm.$emit('hook:' + hook);
  34837. }
  34838. }
  34839. /* */
  34840. var MAX_UPDATE_COUNT = 100;
  34841. var queue = [];
  34842. var activatedChildren = [];
  34843. var has = {};
  34844. var circular = {};
  34845. var waiting = false;
  34846. var flushing = false;
  34847. var index = 0;
  34848. /**
  34849. * Reset the scheduler's state.
  34850. */
  34851. function resetSchedulerState () {
  34852. index = queue.length = activatedChildren.length = 0;
  34853. has = {};
  34854. if (true) {
  34855. circular = {};
  34856. }
  34857. waiting = flushing = false;
  34858. }
  34859. /**
  34860. * Flush both queues and run the watchers.
  34861. */
  34862. function flushSchedulerQueue () {
  34863. flushing = true;
  34864. var watcher, id;
  34865. // Sort queue before flush.
  34866. // This ensures that:
  34867. // 1. Components are updated from parent to child. (because parent is always
  34868. // created before the child)
  34869. // 2. A component's user watchers are run before its render watcher (because
  34870. // user watchers are created before the render watcher)
  34871. // 3. If a component is destroyed during a parent component's watcher run,
  34872. // its watchers can be skipped.
  34873. queue.sort(function (a, b) { return a.id - b.id; });
  34874. // do not cache length because more watchers might be pushed
  34875. // as we run existing watchers
  34876. for (index = 0; index < queue.length; index++) {
  34877. watcher = queue[index];
  34878. id = watcher.id;
  34879. has[id] = null;
  34880. watcher.run();
  34881. // in dev build, check and stop circular updates.
  34882. if ("development" !== 'production' && has[id] != null) {
  34883. circular[id] = (circular[id] || 0) + 1;
  34884. if (circular[id] > MAX_UPDATE_COUNT) {
  34885. warn(
  34886. 'You may have an infinite update loop ' + (
  34887. watcher.user
  34888. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  34889. : "in a component render function."
  34890. ),
  34891. watcher.vm
  34892. );
  34893. break
  34894. }
  34895. }
  34896. }
  34897. // keep copies of post queues before resetting state
  34898. var activatedQueue = activatedChildren.slice();
  34899. var updatedQueue = queue.slice();
  34900. resetSchedulerState();
  34901. // call component updated and activated hooks
  34902. callActivatedHooks(activatedQueue);
  34903. callUpdateHooks(updatedQueue);
  34904. // devtool hook
  34905. /* istanbul ignore if */
  34906. if (devtools && config.devtools) {
  34907. devtools.emit('flush');
  34908. }
  34909. }
  34910. function callUpdateHooks (queue) {
  34911. var i = queue.length;
  34912. while (i--) {
  34913. var watcher = queue[i];
  34914. var vm = watcher.vm;
  34915. if (vm._watcher === watcher && vm._isMounted) {
  34916. callHook(vm, 'updated');
  34917. }
  34918. }
  34919. }
  34920. /**
  34921. * Queue a kept-alive component that was activated during patch.
  34922. * The queue will be processed after the entire tree has been patched.
  34923. */
  34924. function queueActivatedComponent (vm) {
  34925. // setting _inactive to false here so that a render function can
  34926. // rely on checking whether it's in an inactive tree (e.g. router-view)
  34927. vm._inactive = false;
  34928. activatedChildren.push(vm);
  34929. }
  34930. function callActivatedHooks (queue) {
  34931. for (var i = 0; i < queue.length; i++) {
  34932. queue[i]._inactive = true;
  34933. activateChildComponent(queue[i], true /* true */);
  34934. }
  34935. }
  34936. /**
  34937. * Push a watcher into the watcher queue.
  34938. * Jobs with duplicate IDs will be skipped unless it's
  34939. * pushed when the queue is being flushed.
  34940. */
  34941. function queueWatcher (watcher) {
  34942. var id = watcher.id;
  34943. if (has[id] == null) {
  34944. has[id] = true;
  34945. if (!flushing) {
  34946. queue.push(watcher);
  34947. } else {
  34948. // if already flushing, splice the watcher based on its id
  34949. // if already past its id, it will be run next immediately.
  34950. var i = queue.length - 1;
  34951. while (i > index && queue[i].id > watcher.id) {
  34952. i--;
  34953. }
  34954. queue.splice(i + 1, 0, watcher);
  34955. }
  34956. // queue the flush
  34957. if (!waiting) {
  34958. waiting = true;
  34959. nextTick(flushSchedulerQueue);
  34960. }
  34961. }
  34962. }
  34963. /* */
  34964. var uid$2 = 0;
  34965. /**
  34966. * A watcher parses an expression, collects dependencies,
  34967. * and fires callback when the expression value changes.
  34968. * This is used for both the $watch() api and directives.
  34969. */
  34970. var Watcher = function Watcher (
  34971. vm,
  34972. expOrFn,
  34973. cb,
  34974. options
  34975. ) {
  34976. this.vm = vm;
  34977. vm._watchers.push(this);
  34978. // options
  34979. if (options) {
  34980. this.deep = !!options.deep;
  34981. this.user = !!options.user;
  34982. this.lazy = !!options.lazy;
  34983. this.sync = !!options.sync;
  34984. } else {
  34985. this.deep = this.user = this.lazy = this.sync = false;
  34986. }
  34987. this.cb = cb;
  34988. this.id = ++uid$2; // uid for batching
  34989. this.active = true;
  34990. this.dirty = this.lazy; // for lazy watchers
  34991. this.deps = [];
  34992. this.newDeps = [];
  34993. this.depIds = new _Set();
  34994. this.newDepIds = new _Set();
  34995. this.expression = true
  34996. ? expOrFn.toString()
  34997. : '';
  34998. // parse expression for getter
  34999. if (typeof expOrFn === 'function') {
  35000. this.getter = expOrFn;
  35001. } else {
  35002. this.getter = parsePath(expOrFn);
  35003. if (!this.getter) {
  35004. this.getter = function () {};
  35005. "development" !== 'production' && warn(
  35006. "Failed watching path: \"" + expOrFn + "\" " +
  35007. 'Watcher only accepts simple dot-delimited paths. ' +
  35008. 'For full control, use a function instead.',
  35009. vm
  35010. );
  35011. }
  35012. }
  35013. this.value = this.lazy
  35014. ? undefined
  35015. : this.get();
  35016. };
  35017. /**
  35018. * Evaluate the getter, and re-collect dependencies.
  35019. */
  35020. Watcher.prototype.get = function get () {
  35021. pushTarget(this);
  35022. var value;
  35023. var vm = this.vm;
  35024. if (this.user) {
  35025. try {
  35026. value = this.getter.call(vm, vm);
  35027. } catch (e) {
  35028. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  35029. }
  35030. } else {
  35031. value = this.getter.call(vm, vm);
  35032. }
  35033. // "touch" every property so they are all tracked as
  35034. // dependencies for deep watching
  35035. if (this.deep) {
  35036. traverse(value);
  35037. }
  35038. popTarget();
  35039. this.cleanupDeps();
  35040. return value
  35041. };
  35042. /**
  35043. * Add a dependency to this directive.
  35044. */
  35045. Watcher.prototype.addDep = function addDep (dep) {
  35046. var id = dep.id;
  35047. if (!this.newDepIds.has(id)) {
  35048. this.newDepIds.add(id);
  35049. this.newDeps.push(dep);
  35050. if (!this.depIds.has(id)) {
  35051. dep.addSub(this);
  35052. }
  35053. }
  35054. };
  35055. /**
  35056. * Clean up for dependency collection.
  35057. */
  35058. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  35059. var this$1 = this;
  35060. var i = this.deps.length;
  35061. while (i--) {
  35062. var dep = this$1.deps[i];
  35063. if (!this$1.newDepIds.has(dep.id)) {
  35064. dep.removeSub(this$1);
  35065. }
  35066. }
  35067. var tmp = this.depIds;
  35068. this.depIds = this.newDepIds;
  35069. this.newDepIds = tmp;
  35070. this.newDepIds.clear();
  35071. tmp = this.deps;
  35072. this.deps = this.newDeps;
  35073. this.newDeps = tmp;
  35074. this.newDeps.length = 0;
  35075. };
  35076. /**
  35077. * Subscriber interface.
  35078. * Will be called when a dependency changes.
  35079. */
  35080. Watcher.prototype.update = function update () {
  35081. /* istanbul ignore else */
  35082. if (this.lazy) {
  35083. this.dirty = true;
  35084. } else if (this.sync) {
  35085. this.run();
  35086. } else {
  35087. queueWatcher(this);
  35088. }
  35089. };
  35090. /**
  35091. * Scheduler job interface.
  35092. * Will be called by the scheduler.
  35093. */
  35094. Watcher.prototype.run = function run () {
  35095. if (this.active) {
  35096. var value = this.get();
  35097. if (
  35098. value !== this.value ||
  35099. // Deep watchers and watchers on Object/Arrays should fire even
  35100. // when the value is the same, because the value may
  35101. // have mutated.
  35102. isObject(value) ||
  35103. this.deep
  35104. ) {
  35105. // set new value
  35106. var oldValue = this.value;
  35107. this.value = value;
  35108. if (this.user) {
  35109. try {
  35110. this.cb.call(this.vm, value, oldValue);
  35111. } catch (e) {
  35112. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  35113. }
  35114. } else {
  35115. this.cb.call(this.vm, value, oldValue);
  35116. }
  35117. }
  35118. }
  35119. };
  35120. /**
  35121. * Evaluate the value of the watcher.
  35122. * This only gets called for lazy watchers.
  35123. */
  35124. Watcher.prototype.evaluate = function evaluate () {
  35125. this.value = this.get();
  35126. this.dirty = false;
  35127. };
  35128. /**
  35129. * Depend on all deps collected by this watcher.
  35130. */
  35131. Watcher.prototype.depend = function depend () {
  35132. var this$1 = this;
  35133. var i = this.deps.length;
  35134. while (i--) {
  35135. this$1.deps[i].depend();
  35136. }
  35137. };
  35138. /**
  35139. * Remove self from all dependencies' subscriber list.
  35140. */
  35141. Watcher.prototype.teardown = function teardown () {
  35142. var this$1 = this;
  35143. if (this.active) {
  35144. // remove self from vm's watcher list
  35145. // this is a somewhat expensive operation so we skip it
  35146. // if the vm is being destroyed.
  35147. if (!this.vm._isBeingDestroyed) {
  35148. remove(this.vm._watchers, this);
  35149. }
  35150. var i = this.deps.length;
  35151. while (i--) {
  35152. this$1.deps[i].removeSub(this$1);
  35153. }
  35154. this.active = false;
  35155. }
  35156. };
  35157. /**
  35158. * Recursively traverse an object to evoke all converted
  35159. * getters, so that every nested property inside the object
  35160. * is collected as a "deep" dependency.
  35161. */
  35162. var seenObjects = new _Set();
  35163. function traverse (val) {
  35164. seenObjects.clear();
  35165. _traverse(val, seenObjects);
  35166. }
  35167. function _traverse (val, seen) {
  35168. var i, keys;
  35169. var isA = Array.isArray(val);
  35170. if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
  35171. return
  35172. }
  35173. if (val.__ob__) {
  35174. var depId = val.__ob__.dep.id;
  35175. if (seen.has(depId)) {
  35176. return
  35177. }
  35178. seen.add(depId);
  35179. }
  35180. if (isA) {
  35181. i = val.length;
  35182. while (i--) { _traverse(val[i], seen); }
  35183. } else {
  35184. keys = Object.keys(val);
  35185. i = keys.length;
  35186. while (i--) { _traverse(val[keys[i]], seen); }
  35187. }
  35188. }
  35189. /* */
  35190. var sharedPropertyDefinition = {
  35191. enumerable: true,
  35192. configurable: true,
  35193. get: noop,
  35194. set: noop
  35195. };
  35196. function proxy (target, sourceKey, key) {
  35197. sharedPropertyDefinition.get = function proxyGetter () {
  35198. return this[sourceKey][key]
  35199. };
  35200. sharedPropertyDefinition.set = function proxySetter (val) {
  35201. this[sourceKey][key] = val;
  35202. };
  35203. Object.defineProperty(target, key, sharedPropertyDefinition);
  35204. }
  35205. function initState (vm) {
  35206. vm._watchers = [];
  35207. var opts = vm.$options;
  35208. if (opts.props) { initProps(vm, opts.props); }
  35209. if (opts.methods) { initMethods(vm, opts.methods); }
  35210. if (opts.data) {
  35211. initData(vm);
  35212. } else {
  35213. observe(vm._data = {}, true /* asRootData */);
  35214. }
  35215. if (opts.computed) { initComputed(vm, opts.computed); }
  35216. if (opts.watch) { initWatch(vm, opts.watch); }
  35217. }
  35218. var isReservedProp = {
  35219. key: 1,
  35220. ref: 1,
  35221. slot: 1
  35222. };
  35223. function initProps (vm, propsOptions) {
  35224. var propsData = vm.$options.propsData || {};
  35225. var props = vm._props = {};
  35226. // cache prop keys so that future props updates can iterate using Array
  35227. // instead of dynamic object key enumeration.
  35228. var keys = vm.$options._propKeys = [];
  35229. var isRoot = !vm.$parent;
  35230. // root instance props should be converted
  35231. observerState.shouldConvert = isRoot;
  35232. var loop = function ( key ) {
  35233. keys.push(key);
  35234. var value = validateProp(key, propsOptions, propsData, vm);
  35235. /* istanbul ignore else */
  35236. if (true) {
  35237. if (isReservedProp[key] || config.isReservedAttr(key)) {
  35238. warn(
  35239. ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
  35240. vm
  35241. );
  35242. }
  35243. defineReactive$$1(props, key, value, function () {
  35244. if (vm.$parent && !observerState.isSettingProps) {
  35245. warn(
  35246. "Avoid mutating a prop directly since the value will be " +
  35247. "overwritten whenever the parent component re-renders. " +
  35248. "Instead, use a data or computed property based on the prop's " +
  35249. "value. Prop being mutated: \"" + key + "\"",
  35250. vm
  35251. );
  35252. }
  35253. });
  35254. } else {
  35255. defineReactive$$1(props, key, value);
  35256. }
  35257. // static props are already proxied on the component's prototype
  35258. // during Vue.extend(). We only need to proxy props defined at
  35259. // instantiation here.
  35260. if (!(key in vm)) {
  35261. proxy(vm, "_props", key);
  35262. }
  35263. };
  35264. for (var key in propsOptions) loop( key );
  35265. observerState.shouldConvert = true;
  35266. }
  35267. function initData (vm) {
  35268. var data = vm.$options.data;
  35269. data = vm._data = typeof data === 'function'
  35270. ? getData(data, vm)
  35271. : data || {};
  35272. if (!isPlainObject(data)) {
  35273. data = {};
  35274. "development" !== 'production' && warn(
  35275. 'data functions should return an object:\n' +
  35276. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  35277. vm
  35278. );
  35279. }
  35280. // proxy data on instance
  35281. var keys = Object.keys(data);
  35282. var props = vm.$options.props;
  35283. var i = keys.length;
  35284. while (i--) {
  35285. if (props && hasOwn(props, keys[i])) {
  35286. "development" !== 'production' && warn(
  35287. "The data property \"" + (keys[i]) + "\" is already declared as a prop. " +
  35288. "Use prop default value instead.",
  35289. vm
  35290. );
  35291. } else if (!isReserved(keys[i])) {
  35292. proxy(vm, "_data", keys[i]);
  35293. }
  35294. }
  35295. // observe data
  35296. observe(data, true /* asRootData */);
  35297. }
  35298. function getData (data, vm) {
  35299. try {
  35300. return data.call(vm)
  35301. } catch (e) {
  35302. handleError(e, vm, "data()");
  35303. return {}
  35304. }
  35305. }
  35306. var computedWatcherOptions = { lazy: true };
  35307. function initComputed (vm, computed) {
  35308. var watchers = vm._computedWatchers = Object.create(null);
  35309. for (var key in computed) {
  35310. var userDef = computed[key];
  35311. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  35312. if (true) {
  35313. if (getter === undefined) {
  35314. warn(
  35315. ("No getter function has been defined for computed property \"" + key + "\"."),
  35316. vm
  35317. );
  35318. getter = noop;
  35319. }
  35320. }
  35321. // create internal watcher for the computed property.
  35322. watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions);
  35323. // component-defined computed properties are already defined on the
  35324. // component prototype. We only need to define computed properties defined
  35325. // at instantiation here.
  35326. if (!(key in vm)) {
  35327. defineComputed(vm, key, userDef);
  35328. } else if (true) {
  35329. if (key in vm.$data) {
  35330. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  35331. } else if (vm.$options.props && key in vm.$options.props) {
  35332. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  35333. }
  35334. }
  35335. }
  35336. }
  35337. function defineComputed (target, key, userDef) {
  35338. if (typeof userDef === 'function') {
  35339. sharedPropertyDefinition.get = createComputedGetter(key);
  35340. sharedPropertyDefinition.set = noop;
  35341. } else {
  35342. sharedPropertyDefinition.get = userDef.get
  35343. ? userDef.cache !== false
  35344. ? createComputedGetter(key)
  35345. : userDef.get
  35346. : noop;
  35347. sharedPropertyDefinition.set = userDef.set
  35348. ? userDef.set
  35349. : noop;
  35350. }
  35351. Object.defineProperty(target, key, sharedPropertyDefinition);
  35352. }
  35353. function createComputedGetter (key) {
  35354. return function computedGetter () {
  35355. var watcher = this._computedWatchers && this._computedWatchers[key];
  35356. if (watcher) {
  35357. if (watcher.dirty) {
  35358. watcher.evaluate();
  35359. }
  35360. if (Dep.target) {
  35361. watcher.depend();
  35362. }
  35363. return watcher.value
  35364. }
  35365. }
  35366. }
  35367. function initMethods (vm, methods) {
  35368. var props = vm.$options.props;
  35369. for (var key in methods) {
  35370. vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
  35371. if (true) {
  35372. if (methods[key] == null) {
  35373. warn(
  35374. "method \"" + key + "\" has an undefined value in the component definition. " +
  35375. "Did you reference the function correctly?",
  35376. vm
  35377. );
  35378. }
  35379. if (props && hasOwn(props, key)) {
  35380. warn(
  35381. ("method \"" + key + "\" has already been defined as a prop."),
  35382. vm
  35383. );
  35384. }
  35385. }
  35386. }
  35387. }
  35388. function initWatch (vm, watch) {
  35389. for (var key in watch) {
  35390. var handler = watch[key];
  35391. if (Array.isArray(handler)) {
  35392. for (var i = 0; i < handler.length; i++) {
  35393. createWatcher(vm, key, handler[i]);
  35394. }
  35395. } else {
  35396. createWatcher(vm, key, handler);
  35397. }
  35398. }
  35399. }
  35400. function createWatcher (vm, key, handler) {
  35401. var options;
  35402. if (isPlainObject(handler)) {
  35403. options = handler;
  35404. handler = handler.handler;
  35405. }
  35406. if (typeof handler === 'string') {
  35407. handler = vm[handler];
  35408. }
  35409. vm.$watch(key, handler, options);
  35410. }
  35411. function stateMixin (Vue) {
  35412. // flow somehow has problems with directly declared definition object
  35413. // when using Object.defineProperty, so we have to procedurally build up
  35414. // the object here.
  35415. var dataDef = {};
  35416. dataDef.get = function () { return this._data };
  35417. var propsDef = {};
  35418. propsDef.get = function () { return this._props };
  35419. if (true) {
  35420. dataDef.set = function (newData) {
  35421. warn(
  35422. 'Avoid replacing instance root $data. ' +
  35423. 'Use nested data properties instead.',
  35424. this
  35425. );
  35426. };
  35427. propsDef.set = function () {
  35428. warn("$props is readonly.", this);
  35429. };
  35430. }
  35431. Object.defineProperty(Vue.prototype, '$data', dataDef);
  35432. Object.defineProperty(Vue.prototype, '$props', propsDef);
  35433. Vue.prototype.$set = set;
  35434. Vue.prototype.$delete = del;
  35435. Vue.prototype.$watch = function (
  35436. expOrFn,
  35437. cb,
  35438. options
  35439. ) {
  35440. var vm = this;
  35441. options = options || {};
  35442. options.user = true;
  35443. var watcher = new Watcher(vm, expOrFn, cb, options);
  35444. if (options.immediate) {
  35445. cb.call(vm, watcher.value);
  35446. }
  35447. return function unwatchFn () {
  35448. watcher.teardown();
  35449. }
  35450. };
  35451. }
  35452. /* */
  35453. function initProvide (vm) {
  35454. var provide = vm.$options.provide;
  35455. if (provide) {
  35456. vm._provided = typeof provide === 'function'
  35457. ? provide.call(vm)
  35458. : provide;
  35459. }
  35460. }
  35461. function initInjections (vm) {
  35462. var result = resolveInject(vm.$options.inject, vm);
  35463. if (result) {
  35464. Object.keys(result).forEach(function (key) {
  35465. /* istanbul ignore else */
  35466. if (true) {
  35467. defineReactive$$1(vm, key, result[key], function () {
  35468. warn(
  35469. "Avoid mutating an injected value directly since the changes will be " +
  35470. "overwritten whenever the provided component re-renders. " +
  35471. "injection being mutated: \"" + key + "\"",
  35472. vm
  35473. );
  35474. });
  35475. } else {
  35476. defineReactive$$1(vm, key, result[key]);
  35477. }
  35478. });
  35479. }
  35480. }
  35481. function resolveInject (inject, vm) {
  35482. if (inject) {
  35483. // inject is :any because flow is not smart enough to figure out cached
  35484. // isArray here
  35485. var isArray = Array.isArray(inject);
  35486. var result = Object.create(null);
  35487. var keys = isArray
  35488. ? inject
  35489. : hasSymbol
  35490. ? Reflect.ownKeys(inject)
  35491. : Object.keys(inject);
  35492. for (var i = 0; i < keys.length; i++) {
  35493. var key = keys[i];
  35494. var provideKey = isArray ? key : inject[key];
  35495. var source = vm;
  35496. while (source) {
  35497. if (source._provided && provideKey in source._provided) {
  35498. result[key] = source._provided[provideKey];
  35499. break
  35500. }
  35501. source = source.$parent;
  35502. }
  35503. }
  35504. return result
  35505. }
  35506. }
  35507. /* */
  35508. function createFunctionalComponent (
  35509. Ctor,
  35510. propsData,
  35511. data,
  35512. context,
  35513. children
  35514. ) {
  35515. var props = {};
  35516. var propOptions = Ctor.options.props;
  35517. if (isDef(propOptions)) {
  35518. for (var key in propOptions) {
  35519. props[key] = validateProp(key, propOptions, propsData || {});
  35520. }
  35521. } else {
  35522. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  35523. if (isDef(data.props)) { mergeProps(props, data.props); }
  35524. }
  35525. // ensure the createElement function in functional components
  35526. // gets a unique context - this is necessary for correct named slot check
  35527. var _context = Object.create(context);
  35528. var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
  35529. var vnode = Ctor.options.render.call(null, h, {
  35530. data: data,
  35531. props: props,
  35532. children: children,
  35533. parent: context,
  35534. listeners: data.on || {},
  35535. injections: resolveInject(Ctor.options.inject, context),
  35536. slots: function () { return resolveSlots(children, context); }
  35537. });
  35538. if (vnode instanceof VNode) {
  35539. vnode.functionalContext = context;
  35540. vnode.functionalOptions = Ctor.options;
  35541. if (data.slot) {
  35542. (vnode.data || (vnode.data = {})).slot = data.slot;
  35543. }
  35544. }
  35545. return vnode
  35546. }
  35547. function mergeProps (to, from) {
  35548. for (var key in from) {
  35549. to[camelize(key)] = from[key];
  35550. }
  35551. }
  35552. /* */
  35553. // hooks to be invoked on component VNodes during patch
  35554. var componentVNodeHooks = {
  35555. init: function init (
  35556. vnode,
  35557. hydrating,
  35558. parentElm,
  35559. refElm
  35560. ) {
  35561. if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
  35562. var child = vnode.componentInstance = createComponentInstanceForVnode(
  35563. vnode,
  35564. activeInstance,
  35565. parentElm,
  35566. refElm
  35567. );
  35568. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  35569. } else if (vnode.data.keepAlive) {
  35570. // kept-alive components, treat as a patch
  35571. var mountedNode = vnode; // work around flow
  35572. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  35573. }
  35574. },
  35575. prepatch: function prepatch (oldVnode, vnode) {
  35576. var options = vnode.componentOptions;
  35577. var child = vnode.componentInstance = oldVnode.componentInstance;
  35578. updateChildComponent(
  35579. child,
  35580. options.propsData, // updated props
  35581. options.listeners, // updated listeners
  35582. vnode, // new parent vnode
  35583. options.children // new children
  35584. );
  35585. },
  35586. insert: function insert (vnode) {
  35587. var context = vnode.context;
  35588. var componentInstance = vnode.componentInstance;
  35589. if (!componentInstance._isMounted) {
  35590. componentInstance._isMounted = true;
  35591. callHook(componentInstance, 'mounted');
  35592. }
  35593. if (vnode.data.keepAlive) {
  35594. if (context._isMounted) {
  35595. // vue-router#1212
  35596. // During updates, a kept-alive component's child components may
  35597. // change, so directly walking the tree here may call activated hooks
  35598. // on incorrect children. Instead we push them into a queue which will
  35599. // be processed after the whole patch process ended.
  35600. queueActivatedComponent(componentInstance);
  35601. } else {
  35602. activateChildComponent(componentInstance, true /* direct */);
  35603. }
  35604. }
  35605. },
  35606. destroy: function destroy (vnode) {
  35607. var componentInstance = vnode.componentInstance;
  35608. if (!componentInstance._isDestroyed) {
  35609. if (!vnode.data.keepAlive) {
  35610. componentInstance.$destroy();
  35611. } else {
  35612. deactivateChildComponent(componentInstance, true /* direct */);
  35613. }
  35614. }
  35615. }
  35616. };
  35617. var hooksToMerge = Object.keys(componentVNodeHooks);
  35618. function createComponent (
  35619. Ctor,
  35620. data,
  35621. context,
  35622. children,
  35623. tag
  35624. ) {
  35625. if (isUndef(Ctor)) {
  35626. return
  35627. }
  35628. var baseCtor = context.$options._base;
  35629. // plain options object: turn it into a constructor
  35630. if (isObject(Ctor)) {
  35631. Ctor = baseCtor.extend(Ctor);
  35632. }
  35633. // if at this stage it's not a constructor or an async component factory,
  35634. // reject.
  35635. if (typeof Ctor !== 'function') {
  35636. if (true) {
  35637. warn(("Invalid Component definition: " + (String(Ctor))), context);
  35638. }
  35639. return
  35640. }
  35641. // async component
  35642. if (isUndef(Ctor.cid)) {
  35643. Ctor = resolveAsyncComponent(Ctor, baseCtor, context);
  35644. if (Ctor === undefined) {
  35645. // return nothing if this is indeed an async component
  35646. // wait for the callback to trigger parent update.
  35647. return
  35648. }
  35649. }
  35650. // resolve constructor options in case global mixins are applied after
  35651. // component constructor creation
  35652. resolveConstructorOptions(Ctor);
  35653. data = data || {};
  35654. // transform component v-model data into props & events
  35655. if (isDef(data.model)) {
  35656. transformModel(Ctor.options, data);
  35657. }
  35658. // extract props
  35659. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  35660. // functional component
  35661. if (isTrue(Ctor.options.functional)) {
  35662. return createFunctionalComponent(Ctor, propsData, data, context, children)
  35663. }
  35664. // extract listeners, since these needs to be treated as
  35665. // child component listeners instead of DOM listeners
  35666. var listeners = data.on;
  35667. // replace with listeners with .native modifier
  35668. data.on = data.nativeOn;
  35669. if (isTrue(Ctor.options.abstract)) {
  35670. // abstract components do not keep anything
  35671. // other than props & listeners
  35672. data = {};
  35673. }
  35674. // merge component management hooks onto the placeholder node
  35675. mergeHooks(data);
  35676. // return a placeholder vnode
  35677. var name = Ctor.options.name || tag;
  35678. var vnode = new VNode(
  35679. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  35680. data, undefined, undefined, undefined, context,
  35681. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }
  35682. );
  35683. return vnode
  35684. }
  35685. function createComponentInstanceForVnode (
  35686. vnode, // we know it's MountedComponentVNode but flow doesn't
  35687. parent, // activeInstance in lifecycle state
  35688. parentElm,
  35689. refElm
  35690. ) {
  35691. var vnodeComponentOptions = vnode.componentOptions;
  35692. var options = {
  35693. _isComponent: true,
  35694. parent: parent,
  35695. propsData: vnodeComponentOptions.propsData,
  35696. _componentTag: vnodeComponentOptions.tag,
  35697. _parentVnode: vnode,
  35698. _parentListeners: vnodeComponentOptions.listeners,
  35699. _renderChildren: vnodeComponentOptions.children,
  35700. _parentElm: parentElm || null,
  35701. _refElm: refElm || null
  35702. };
  35703. // check inline-template render functions
  35704. var inlineTemplate = vnode.data.inlineTemplate;
  35705. if (isDef(inlineTemplate)) {
  35706. options.render = inlineTemplate.render;
  35707. options.staticRenderFns = inlineTemplate.staticRenderFns;
  35708. }
  35709. return new vnodeComponentOptions.Ctor(options)
  35710. }
  35711. function mergeHooks (data) {
  35712. if (!data.hook) {
  35713. data.hook = {};
  35714. }
  35715. for (var i = 0; i < hooksToMerge.length; i++) {
  35716. var key = hooksToMerge[i];
  35717. var fromParent = data.hook[key];
  35718. var ours = componentVNodeHooks[key];
  35719. data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
  35720. }
  35721. }
  35722. function mergeHook$1 (one, two) {
  35723. return function (a, b, c, d) {
  35724. one(a, b, c, d);
  35725. two(a, b, c, d);
  35726. }
  35727. }
  35728. // transform component v-model info (value and callback) into
  35729. // prop and event handler respectively.
  35730. function transformModel (options, data) {
  35731. var prop = (options.model && options.model.prop) || 'value';
  35732. var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
  35733. var on = data.on || (data.on = {});
  35734. if (isDef(on[event])) {
  35735. on[event] = [data.model.callback].concat(on[event]);
  35736. } else {
  35737. on[event] = data.model.callback;
  35738. }
  35739. }
  35740. /* */
  35741. var SIMPLE_NORMALIZE = 1;
  35742. var ALWAYS_NORMALIZE = 2;
  35743. // wrapper function for providing a more flexible interface
  35744. // without getting yelled at by flow
  35745. function createElement (
  35746. context,
  35747. tag,
  35748. data,
  35749. children,
  35750. normalizationType,
  35751. alwaysNormalize
  35752. ) {
  35753. if (Array.isArray(data) || isPrimitive(data)) {
  35754. normalizationType = children;
  35755. children = data;
  35756. data = undefined;
  35757. }
  35758. if (isTrue(alwaysNormalize)) {
  35759. normalizationType = ALWAYS_NORMALIZE;
  35760. }
  35761. return _createElement(context, tag, data, children, normalizationType)
  35762. }
  35763. function _createElement (
  35764. context,
  35765. tag,
  35766. data,
  35767. children,
  35768. normalizationType
  35769. ) {
  35770. if (isDef(data) && isDef((data).__ob__)) {
  35771. "development" !== 'production' && warn(
  35772. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  35773. 'Always create fresh vnode data objects in each render!',
  35774. context
  35775. );
  35776. return createEmptyVNode()
  35777. }
  35778. if (!tag) {
  35779. // in case of component :is set to falsy value
  35780. return createEmptyVNode()
  35781. }
  35782. // support single function children as default scoped slot
  35783. if (Array.isArray(children) &&
  35784. typeof children[0] === 'function'
  35785. ) {
  35786. data = data || {};
  35787. data.scopedSlots = { default: children[0] };
  35788. children.length = 0;
  35789. }
  35790. if (normalizationType === ALWAYS_NORMALIZE) {
  35791. children = normalizeChildren(children);
  35792. } else if (normalizationType === SIMPLE_NORMALIZE) {
  35793. children = simpleNormalizeChildren(children);
  35794. }
  35795. var vnode, ns;
  35796. if (typeof tag === 'string') {
  35797. var Ctor;
  35798. ns = config.getTagNamespace(tag);
  35799. if (config.isReservedTag(tag)) {
  35800. // platform built-in elements
  35801. vnode = new VNode(
  35802. config.parsePlatformTagName(tag), data, children,
  35803. undefined, undefined, context
  35804. );
  35805. } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  35806. // component
  35807. vnode = createComponent(Ctor, data, context, children, tag);
  35808. } else {
  35809. // unknown or unlisted namespaced elements
  35810. // check at runtime because it may get assigned a namespace when its
  35811. // parent normalizes children
  35812. vnode = new VNode(
  35813. tag, data, children,
  35814. undefined, undefined, context
  35815. );
  35816. }
  35817. } else {
  35818. // direct component options / constructor
  35819. vnode = createComponent(tag, data, context, children);
  35820. }
  35821. if (isDef(vnode)) {
  35822. if (ns) { applyNS(vnode, ns); }
  35823. return vnode
  35824. } else {
  35825. return createEmptyVNode()
  35826. }
  35827. }
  35828. function applyNS (vnode, ns) {
  35829. vnode.ns = ns;
  35830. if (vnode.tag === 'foreignObject') {
  35831. // use default namespace inside foreignObject
  35832. return
  35833. }
  35834. if (isDef(vnode.children)) {
  35835. for (var i = 0, l = vnode.children.length; i < l; i++) {
  35836. var child = vnode.children[i];
  35837. if (isDef(child.tag) && isUndef(child.ns)) {
  35838. applyNS(child, ns);
  35839. }
  35840. }
  35841. }
  35842. }
  35843. /* */
  35844. /**
  35845. * Runtime helper for rendering v-for lists.
  35846. */
  35847. function renderList (
  35848. val,
  35849. render
  35850. ) {
  35851. var ret, i, l, keys, key;
  35852. if (Array.isArray(val) || typeof val === 'string') {
  35853. ret = new Array(val.length);
  35854. for (i = 0, l = val.length; i < l; i++) {
  35855. ret[i] = render(val[i], i);
  35856. }
  35857. } else if (typeof val === 'number') {
  35858. ret = new Array(val);
  35859. for (i = 0; i < val; i++) {
  35860. ret[i] = render(i + 1, i);
  35861. }
  35862. } else if (isObject(val)) {
  35863. keys = Object.keys(val);
  35864. ret = new Array(keys.length);
  35865. for (i = 0, l = keys.length; i < l; i++) {
  35866. key = keys[i];
  35867. ret[i] = render(val[key], key, i);
  35868. }
  35869. }
  35870. if (isDef(ret)) {
  35871. (ret)._isVList = true;
  35872. }
  35873. return ret
  35874. }
  35875. /* */
  35876. /**
  35877. * Runtime helper for rendering <slot>
  35878. */
  35879. function renderSlot (
  35880. name,
  35881. fallback,
  35882. props,
  35883. bindObject
  35884. ) {
  35885. var scopedSlotFn = this.$scopedSlots[name];
  35886. if (scopedSlotFn) { // scoped slot
  35887. props = props || {};
  35888. if (bindObject) {
  35889. extend(props, bindObject);
  35890. }
  35891. return scopedSlotFn(props) || fallback
  35892. } else {
  35893. var slotNodes = this.$slots[name];
  35894. // warn duplicate slot usage
  35895. if (slotNodes && "development" !== 'production') {
  35896. slotNodes._rendered && warn(
  35897. "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
  35898. "- this will likely cause render errors.",
  35899. this
  35900. );
  35901. slotNodes._rendered = true;
  35902. }
  35903. return slotNodes || fallback
  35904. }
  35905. }
  35906. /* */
  35907. /**
  35908. * Runtime helper for resolving filters
  35909. */
  35910. function resolveFilter (id) {
  35911. return resolveAsset(this.$options, 'filters', id, true) || identity
  35912. }
  35913. /* */
  35914. /**
  35915. * Runtime helper for checking keyCodes from config.
  35916. */
  35917. function checkKeyCodes (
  35918. eventKeyCode,
  35919. key,
  35920. builtInAlias
  35921. ) {
  35922. var keyCodes = config.keyCodes[key] || builtInAlias;
  35923. if (Array.isArray(keyCodes)) {
  35924. return keyCodes.indexOf(eventKeyCode) === -1
  35925. } else {
  35926. return keyCodes !== eventKeyCode
  35927. }
  35928. }
  35929. /* */
  35930. /**
  35931. * Runtime helper for merging v-bind="object" into a VNode's data.
  35932. */
  35933. function bindObjectProps (
  35934. data,
  35935. tag,
  35936. value,
  35937. asProp
  35938. ) {
  35939. if (value) {
  35940. if (!isObject(value)) {
  35941. "development" !== 'production' && warn(
  35942. 'v-bind without argument expects an Object or Array value',
  35943. this
  35944. );
  35945. } else {
  35946. if (Array.isArray(value)) {
  35947. value = toObject(value);
  35948. }
  35949. var hash;
  35950. for (var key in value) {
  35951. if (key === 'class' || key === 'style') {
  35952. hash = data;
  35953. } else {
  35954. var type = data.attrs && data.attrs.type;
  35955. hash = asProp || config.mustUseProp(tag, type, key)
  35956. ? data.domProps || (data.domProps = {})
  35957. : data.attrs || (data.attrs = {});
  35958. }
  35959. if (!(key in hash)) {
  35960. hash[key] = value[key];
  35961. }
  35962. }
  35963. }
  35964. }
  35965. return data
  35966. }
  35967. /* */
  35968. /**
  35969. * Runtime helper for rendering static trees.
  35970. */
  35971. function renderStatic (
  35972. index,
  35973. isInFor
  35974. ) {
  35975. var tree = this._staticTrees[index];
  35976. // if has already-rendered static tree and not inside v-for,
  35977. // we can reuse the same tree by doing a shallow clone.
  35978. if (tree && !isInFor) {
  35979. return Array.isArray(tree)
  35980. ? cloneVNodes(tree)
  35981. : cloneVNode(tree)
  35982. }
  35983. // otherwise, render a fresh tree.
  35984. tree = this._staticTrees[index] =
  35985. this.$options.staticRenderFns[index].call(this._renderProxy);
  35986. markStatic(tree, ("__static__" + index), false);
  35987. return tree
  35988. }
  35989. /**
  35990. * Runtime helper for v-once.
  35991. * Effectively it means marking the node as static with a unique key.
  35992. */
  35993. function markOnce (
  35994. tree,
  35995. index,
  35996. key
  35997. ) {
  35998. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  35999. return tree
  36000. }
  36001. function markStatic (
  36002. tree,
  36003. key,
  36004. isOnce
  36005. ) {
  36006. if (Array.isArray(tree)) {
  36007. for (var i = 0; i < tree.length; i++) {
  36008. if (tree[i] && typeof tree[i] !== 'string') {
  36009. markStaticNode(tree[i], (key + "_" + i), isOnce);
  36010. }
  36011. }
  36012. } else {
  36013. markStaticNode(tree, key, isOnce);
  36014. }
  36015. }
  36016. function markStaticNode (node, key, isOnce) {
  36017. node.isStatic = true;
  36018. node.key = key;
  36019. node.isOnce = isOnce;
  36020. }
  36021. /* */
  36022. function initRender (vm) {
  36023. vm._vnode = null; // the root of the child tree
  36024. vm._staticTrees = null;
  36025. var parentVnode = vm.$vnode = vm.$options._parentVnode; // the placeholder node in parent tree
  36026. var renderContext = parentVnode && parentVnode.context;
  36027. vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
  36028. vm.$scopedSlots = emptyObject;
  36029. // bind the createElement fn to this instance
  36030. // so that we get proper render context inside it.
  36031. // args order: tag, data, children, normalizationType, alwaysNormalize
  36032. // internal version is used by render functions compiled from templates
  36033. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  36034. // normalization is always applied for the public version, used in
  36035. // user-written render functions.
  36036. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  36037. }
  36038. function renderMixin (Vue) {
  36039. Vue.prototype.$nextTick = function (fn) {
  36040. return nextTick(fn, this)
  36041. };
  36042. Vue.prototype._render = function () {
  36043. var vm = this;
  36044. var ref = vm.$options;
  36045. var render = ref.render;
  36046. var staticRenderFns = ref.staticRenderFns;
  36047. var _parentVnode = ref._parentVnode;
  36048. if (vm._isMounted) {
  36049. // clone slot nodes on re-renders
  36050. for (var key in vm.$slots) {
  36051. vm.$slots[key] = cloneVNodes(vm.$slots[key]);
  36052. }
  36053. }
  36054. vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject;
  36055. if (staticRenderFns && !vm._staticTrees) {
  36056. vm._staticTrees = [];
  36057. }
  36058. // set parent vnode. this allows render functions to have access
  36059. // to the data on the placeholder node.
  36060. vm.$vnode = _parentVnode;
  36061. // render self
  36062. var vnode;
  36063. try {
  36064. vnode = render.call(vm._renderProxy, vm.$createElement);
  36065. } catch (e) {
  36066. handleError(e, vm, "render function");
  36067. // return error render result,
  36068. // or previous vnode to prevent render error causing blank component
  36069. /* istanbul ignore else */
  36070. if (true) {
  36071. vnode = vm.$options.renderError
  36072. ? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)
  36073. : vm._vnode;
  36074. } else {
  36075. vnode = vm._vnode;
  36076. }
  36077. }
  36078. // return empty vnode in case the render function errored out
  36079. if (!(vnode instanceof VNode)) {
  36080. if ("development" !== 'production' && Array.isArray(vnode)) {
  36081. warn(
  36082. 'Multiple root nodes returned from render function. Render function ' +
  36083. 'should return a single root node.',
  36084. vm
  36085. );
  36086. }
  36087. vnode = createEmptyVNode();
  36088. }
  36089. // set parent
  36090. vnode.parent = _parentVnode;
  36091. return vnode
  36092. };
  36093. // internal render helpers.
  36094. // these are exposed on the instance prototype to reduce generated render
  36095. // code size.
  36096. Vue.prototype._o = markOnce;
  36097. Vue.prototype._n = toNumber;
  36098. Vue.prototype._s = toString;
  36099. Vue.prototype._l = renderList;
  36100. Vue.prototype._t = renderSlot;
  36101. Vue.prototype._q = looseEqual;
  36102. Vue.prototype._i = looseIndexOf;
  36103. Vue.prototype._m = renderStatic;
  36104. Vue.prototype._f = resolveFilter;
  36105. Vue.prototype._k = checkKeyCodes;
  36106. Vue.prototype._b = bindObjectProps;
  36107. Vue.prototype._v = createTextVNode;
  36108. Vue.prototype._e = createEmptyVNode;
  36109. Vue.prototype._u = resolveScopedSlots;
  36110. }
  36111. /* */
  36112. var uid$1 = 0;
  36113. function initMixin (Vue) {
  36114. Vue.prototype._init = function (options) {
  36115. var vm = this;
  36116. // a uid
  36117. vm._uid = uid$1++;
  36118. var startTag, endTag;
  36119. /* istanbul ignore if */
  36120. if ("development" !== 'production' && config.performance && mark) {
  36121. startTag = "vue-perf-init:" + (vm._uid);
  36122. endTag = "vue-perf-end:" + (vm._uid);
  36123. mark(startTag);
  36124. }
  36125. // a flag to avoid this being observed
  36126. vm._isVue = true;
  36127. // merge options
  36128. if (options && options._isComponent) {
  36129. // optimize internal component instantiation
  36130. // since dynamic options merging is pretty slow, and none of the
  36131. // internal component options needs special treatment.
  36132. initInternalComponent(vm, options);
  36133. } else {
  36134. vm.$options = mergeOptions(
  36135. resolveConstructorOptions(vm.constructor),
  36136. options || {},
  36137. vm
  36138. );
  36139. }
  36140. /* istanbul ignore else */
  36141. if (true) {
  36142. initProxy(vm);
  36143. } else {
  36144. vm._renderProxy = vm;
  36145. }
  36146. // expose real self
  36147. vm._self = vm;
  36148. initLifecycle(vm);
  36149. initEvents(vm);
  36150. initRender(vm);
  36151. callHook(vm, 'beforeCreate');
  36152. initInjections(vm); // resolve injections before data/props
  36153. initState(vm);
  36154. initProvide(vm); // resolve provide after data/props
  36155. callHook(vm, 'created');
  36156. /* istanbul ignore if */
  36157. if ("development" !== 'production' && config.performance && mark) {
  36158. vm._name = formatComponentName(vm, false);
  36159. mark(endTag);
  36160. measure(((vm._name) + " init"), startTag, endTag);
  36161. }
  36162. if (vm.$options.el) {
  36163. vm.$mount(vm.$options.el);
  36164. }
  36165. };
  36166. }
  36167. function initInternalComponent (vm, options) {
  36168. var opts = vm.$options = Object.create(vm.constructor.options);
  36169. // doing this because it's faster than dynamic enumeration.
  36170. opts.parent = options.parent;
  36171. opts.propsData = options.propsData;
  36172. opts._parentVnode = options._parentVnode;
  36173. opts._parentListeners = options._parentListeners;
  36174. opts._renderChildren = options._renderChildren;
  36175. opts._componentTag = options._componentTag;
  36176. opts._parentElm = options._parentElm;
  36177. opts._refElm = options._refElm;
  36178. if (options.render) {
  36179. opts.render = options.render;
  36180. opts.staticRenderFns = options.staticRenderFns;
  36181. }
  36182. }
  36183. function resolveConstructorOptions (Ctor) {
  36184. var options = Ctor.options;
  36185. if (Ctor.super) {
  36186. var superOptions = resolveConstructorOptions(Ctor.super);
  36187. var cachedSuperOptions = Ctor.superOptions;
  36188. if (superOptions !== cachedSuperOptions) {
  36189. // super option changed,
  36190. // need to resolve new options.
  36191. Ctor.superOptions = superOptions;
  36192. // check if there are any late-modified/attached options (#4976)
  36193. var modifiedOptions = resolveModifiedOptions(Ctor);
  36194. // update base extend options
  36195. if (modifiedOptions) {
  36196. extend(Ctor.extendOptions, modifiedOptions);
  36197. }
  36198. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  36199. if (options.name) {
  36200. options.components[options.name] = Ctor;
  36201. }
  36202. }
  36203. }
  36204. return options
  36205. }
  36206. function resolveModifiedOptions (Ctor) {
  36207. var modified;
  36208. var latest = Ctor.options;
  36209. var extended = Ctor.extendOptions;
  36210. var sealed = Ctor.sealedOptions;
  36211. for (var key in latest) {
  36212. if (latest[key] !== sealed[key]) {
  36213. if (!modified) { modified = {}; }
  36214. modified[key] = dedupe(latest[key], extended[key], sealed[key]);
  36215. }
  36216. }
  36217. return modified
  36218. }
  36219. function dedupe (latest, extended, sealed) {
  36220. // compare latest and sealed to ensure lifecycle hooks won't be duplicated
  36221. // between merges
  36222. if (Array.isArray(latest)) {
  36223. var res = [];
  36224. sealed = Array.isArray(sealed) ? sealed : [sealed];
  36225. extended = Array.isArray(extended) ? extended : [extended];
  36226. for (var i = 0; i < latest.length; i++) {
  36227. // push original options and not sealed options to exclude duplicated options
  36228. if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) {
  36229. res.push(latest[i]);
  36230. }
  36231. }
  36232. return res
  36233. } else {
  36234. return latest
  36235. }
  36236. }
  36237. function Vue$3 (options) {
  36238. if ("development" !== 'production' &&
  36239. !(this instanceof Vue$3)
  36240. ) {
  36241. warn('Vue is a constructor and should be called with the `new` keyword');
  36242. }
  36243. this._init(options);
  36244. }
  36245. initMixin(Vue$3);
  36246. stateMixin(Vue$3);
  36247. eventsMixin(Vue$3);
  36248. lifecycleMixin(Vue$3);
  36249. renderMixin(Vue$3);
  36250. /* */
  36251. function initUse (Vue) {
  36252. Vue.use = function (plugin) {
  36253. /* istanbul ignore if */
  36254. if (plugin.installed) {
  36255. return this
  36256. }
  36257. // additional parameters
  36258. var args = toArray(arguments, 1);
  36259. args.unshift(this);
  36260. if (typeof plugin.install === 'function') {
  36261. plugin.install.apply(plugin, args);
  36262. } else if (typeof plugin === 'function') {
  36263. plugin.apply(null, args);
  36264. }
  36265. plugin.installed = true;
  36266. return this
  36267. };
  36268. }
  36269. /* */
  36270. function initMixin$1 (Vue) {
  36271. Vue.mixin = function (mixin) {
  36272. this.options = mergeOptions(this.options, mixin);
  36273. return this
  36274. };
  36275. }
  36276. /* */
  36277. function initExtend (Vue) {
  36278. /**
  36279. * Each instance constructor, including Vue, has a unique
  36280. * cid. This enables us to create wrapped "child
  36281. * constructors" for prototypal inheritance and cache them.
  36282. */
  36283. Vue.cid = 0;
  36284. var cid = 1;
  36285. /**
  36286. * Class inheritance
  36287. */
  36288. Vue.extend = function (extendOptions) {
  36289. extendOptions = extendOptions || {};
  36290. var Super = this;
  36291. var SuperId = Super.cid;
  36292. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  36293. if (cachedCtors[SuperId]) {
  36294. return cachedCtors[SuperId]
  36295. }
  36296. var name = extendOptions.name || Super.options.name;
  36297. if (true) {
  36298. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  36299. warn(
  36300. 'Invalid component name: "' + name + '". Component names ' +
  36301. 'can only contain alphanumeric characters and the hyphen, ' +
  36302. 'and must start with a letter.'
  36303. );
  36304. }
  36305. }
  36306. var Sub = function VueComponent (options) {
  36307. this._init(options);
  36308. };
  36309. Sub.prototype = Object.create(Super.prototype);
  36310. Sub.prototype.constructor = Sub;
  36311. Sub.cid = cid++;
  36312. Sub.options = mergeOptions(
  36313. Super.options,
  36314. extendOptions
  36315. );
  36316. Sub['super'] = Super;
  36317. // For props and computed properties, we define the proxy getters on
  36318. // the Vue instances at extension time, on the extended prototype. This
  36319. // avoids Object.defineProperty calls for each instance created.
  36320. if (Sub.options.props) {
  36321. initProps$1(Sub);
  36322. }
  36323. if (Sub.options.computed) {
  36324. initComputed$1(Sub);
  36325. }
  36326. // allow further extension/mixin/plugin usage
  36327. Sub.extend = Super.extend;
  36328. Sub.mixin = Super.mixin;
  36329. Sub.use = Super.use;
  36330. // create asset registers, so extended classes
  36331. // can have their private assets too.
  36332. ASSET_TYPES.forEach(function (type) {
  36333. Sub[type] = Super[type];
  36334. });
  36335. // enable recursive self-lookup
  36336. if (name) {
  36337. Sub.options.components[name] = Sub;
  36338. }
  36339. // keep a reference to the super options at extension time.
  36340. // later at instantiation we can check if Super's options have
  36341. // been updated.
  36342. Sub.superOptions = Super.options;
  36343. Sub.extendOptions = extendOptions;
  36344. Sub.sealedOptions = extend({}, Sub.options);
  36345. // cache constructor
  36346. cachedCtors[SuperId] = Sub;
  36347. return Sub
  36348. };
  36349. }
  36350. function initProps$1 (Comp) {
  36351. var props = Comp.options.props;
  36352. for (var key in props) {
  36353. proxy(Comp.prototype, "_props", key);
  36354. }
  36355. }
  36356. function initComputed$1 (Comp) {
  36357. var computed = Comp.options.computed;
  36358. for (var key in computed) {
  36359. defineComputed(Comp.prototype, key, computed[key]);
  36360. }
  36361. }
  36362. /* */
  36363. function initAssetRegisters (Vue) {
  36364. /**
  36365. * Create asset registration methods.
  36366. */
  36367. ASSET_TYPES.forEach(function (type) {
  36368. Vue[type] = function (
  36369. id,
  36370. definition
  36371. ) {
  36372. if (!definition) {
  36373. return this.options[type + 's'][id]
  36374. } else {
  36375. /* istanbul ignore if */
  36376. if (true) {
  36377. if (type === 'component' && config.isReservedTag(id)) {
  36378. warn(
  36379. 'Do not use built-in or reserved HTML elements as component ' +
  36380. 'id: ' + id
  36381. );
  36382. }
  36383. }
  36384. if (type === 'component' && isPlainObject(definition)) {
  36385. definition.name = definition.name || id;
  36386. definition = this.options._base.extend(definition);
  36387. }
  36388. if (type === 'directive' && typeof definition === 'function') {
  36389. definition = { bind: definition, update: definition };
  36390. }
  36391. this.options[type + 's'][id] = definition;
  36392. return definition
  36393. }
  36394. };
  36395. });
  36396. }
  36397. /* */
  36398. var patternTypes = [String, RegExp];
  36399. function getComponentName (opts) {
  36400. return opts && (opts.Ctor.options.name || opts.tag)
  36401. }
  36402. function matches (pattern, name) {
  36403. if (typeof pattern === 'string') {
  36404. return pattern.split(',').indexOf(name) > -1
  36405. } else if (isRegExp(pattern)) {
  36406. return pattern.test(name)
  36407. }
  36408. /* istanbul ignore next */
  36409. return false
  36410. }
  36411. function pruneCache (cache, current, filter) {
  36412. for (var key in cache) {
  36413. var cachedNode = cache[key];
  36414. if (cachedNode) {
  36415. var name = getComponentName(cachedNode.componentOptions);
  36416. if (name && !filter(name)) {
  36417. if (cachedNode !== current) {
  36418. pruneCacheEntry(cachedNode);
  36419. }
  36420. cache[key] = null;
  36421. }
  36422. }
  36423. }
  36424. }
  36425. function pruneCacheEntry (vnode) {
  36426. if (vnode) {
  36427. vnode.componentInstance.$destroy();
  36428. }
  36429. }
  36430. var KeepAlive = {
  36431. name: 'keep-alive',
  36432. abstract: true,
  36433. props: {
  36434. include: patternTypes,
  36435. exclude: patternTypes
  36436. },
  36437. created: function created () {
  36438. this.cache = Object.create(null);
  36439. },
  36440. destroyed: function destroyed () {
  36441. var this$1 = this;
  36442. for (var key in this$1.cache) {
  36443. pruneCacheEntry(this$1.cache[key]);
  36444. }
  36445. },
  36446. watch: {
  36447. include: function include (val) {
  36448. pruneCache(this.cache, this._vnode, function (name) { return matches(val, name); });
  36449. },
  36450. exclude: function exclude (val) {
  36451. pruneCache(this.cache, this._vnode, function (name) { return !matches(val, name); });
  36452. }
  36453. },
  36454. render: function render () {
  36455. var vnode = getFirstComponentChild(this.$slots.default);
  36456. var componentOptions = vnode && vnode.componentOptions;
  36457. if (componentOptions) {
  36458. // check pattern
  36459. var name = getComponentName(componentOptions);
  36460. if (name && (
  36461. (this.include && !matches(this.include, name)) ||
  36462. (this.exclude && matches(this.exclude, name))
  36463. )) {
  36464. return vnode
  36465. }
  36466. var key = vnode.key == null
  36467. // same constructor may get registered as different local components
  36468. // so cid alone is not enough (#3269)
  36469. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  36470. : vnode.key;
  36471. if (this.cache[key]) {
  36472. vnode.componentInstance = this.cache[key].componentInstance;
  36473. } else {
  36474. this.cache[key] = vnode;
  36475. }
  36476. vnode.data.keepAlive = true;
  36477. }
  36478. return vnode
  36479. }
  36480. };
  36481. var builtInComponents = {
  36482. KeepAlive: KeepAlive
  36483. };
  36484. /* */
  36485. function initGlobalAPI (Vue) {
  36486. // config
  36487. var configDef = {};
  36488. configDef.get = function () { return config; };
  36489. if (true) {
  36490. configDef.set = function () {
  36491. warn(
  36492. 'Do not replace the Vue.config object, set individual fields instead.'
  36493. );
  36494. };
  36495. }
  36496. Object.defineProperty(Vue, 'config', configDef);
  36497. // exposed util methods.
  36498. // NOTE: these are not considered part of the public API - avoid relying on
  36499. // them unless you are aware of the risk.
  36500. Vue.util = {
  36501. warn: warn,
  36502. extend: extend,
  36503. mergeOptions: mergeOptions,
  36504. defineReactive: defineReactive$$1
  36505. };
  36506. Vue.set = set;
  36507. Vue.delete = del;
  36508. Vue.nextTick = nextTick;
  36509. Vue.options = Object.create(null);
  36510. ASSET_TYPES.forEach(function (type) {
  36511. Vue.options[type + 's'] = Object.create(null);
  36512. });
  36513. // this is used to identify the "base" constructor to extend all plain-object
  36514. // components with in Weex's multi-instance scenarios.
  36515. Vue.options._base = Vue;
  36516. extend(Vue.options.components, builtInComponents);
  36517. initUse(Vue);
  36518. initMixin$1(Vue);
  36519. initExtend(Vue);
  36520. initAssetRegisters(Vue);
  36521. }
  36522. initGlobalAPI(Vue$3);
  36523. Object.defineProperty(Vue$3.prototype, '$isServer', {
  36524. get: isServerRendering
  36525. });
  36526. Object.defineProperty(Vue$3.prototype, '$ssrContext', {
  36527. get: function get () {
  36528. /* istanbul ignore next */
  36529. return this.$vnode.ssrContext
  36530. }
  36531. });
  36532. Vue$3.version = '2.3.4';
  36533. /* */
  36534. // these are reserved for web because they are directly compiled away
  36535. // during template compilation
  36536. var isReservedAttr = makeMap('style,class');
  36537. // attributes that should be using props for binding
  36538. var acceptValue = makeMap('input,textarea,option,select');
  36539. var mustUseProp = function (tag, type, attr) {
  36540. return (
  36541. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  36542. (attr === 'selected' && tag === 'option') ||
  36543. (attr === 'checked' && tag === 'input') ||
  36544. (attr === 'muted' && tag === 'video')
  36545. )
  36546. };
  36547. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  36548. var isBooleanAttr = makeMap(
  36549. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  36550. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  36551. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  36552. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  36553. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  36554. 'truespeed,typemustmatch,visible'
  36555. );
  36556. var xlinkNS = 'http://www.w3.org/1999/xlink';
  36557. var isXlink = function (name) {
  36558. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  36559. };
  36560. var getXlinkProp = function (name) {
  36561. return isXlink(name) ? name.slice(6, name.length) : ''
  36562. };
  36563. var isFalsyAttrValue = function (val) {
  36564. return val == null || val === false
  36565. };
  36566. /* */
  36567. function genClassForVnode (vnode) {
  36568. var data = vnode.data;
  36569. var parentNode = vnode;
  36570. var childNode = vnode;
  36571. while (isDef(childNode.componentInstance)) {
  36572. childNode = childNode.componentInstance._vnode;
  36573. if (childNode.data) {
  36574. data = mergeClassData(childNode.data, data);
  36575. }
  36576. }
  36577. while (isDef(parentNode = parentNode.parent)) {
  36578. if (parentNode.data) {
  36579. data = mergeClassData(data, parentNode.data);
  36580. }
  36581. }
  36582. return genClassFromData(data)
  36583. }
  36584. function mergeClassData (child, parent) {
  36585. return {
  36586. staticClass: concat(child.staticClass, parent.staticClass),
  36587. class: isDef(child.class)
  36588. ? [child.class, parent.class]
  36589. : parent.class
  36590. }
  36591. }
  36592. function genClassFromData (data) {
  36593. var dynamicClass = data.class;
  36594. var staticClass = data.staticClass;
  36595. if (isDef(staticClass) || isDef(dynamicClass)) {
  36596. return concat(staticClass, stringifyClass(dynamicClass))
  36597. }
  36598. /* istanbul ignore next */
  36599. return ''
  36600. }
  36601. function concat (a, b) {
  36602. return a ? b ? (a + ' ' + b) : a : (b || '')
  36603. }
  36604. function stringifyClass (value) {
  36605. if (isUndef(value)) {
  36606. return ''
  36607. }
  36608. if (typeof value === 'string') {
  36609. return value
  36610. }
  36611. var res = '';
  36612. if (Array.isArray(value)) {
  36613. var stringified;
  36614. for (var i = 0, l = value.length; i < l; i++) {
  36615. if (isDef(value[i])) {
  36616. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  36617. res += stringified + ' ';
  36618. }
  36619. }
  36620. }
  36621. return res.slice(0, -1)
  36622. }
  36623. if (isObject(value)) {
  36624. for (var key in value) {
  36625. if (value[key]) { res += key + ' '; }
  36626. }
  36627. return res.slice(0, -1)
  36628. }
  36629. /* istanbul ignore next */
  36630. return res
  36631. }
  36632. /* */
  36633. var namespaceMap = {
  36634. svg: 'http://www.w3.org/2000/svg',
  36635. math: 'http://www.w3.org/1998/Math/MathML'
  36636. };
  36637. var isHTMLTag = makeMap(
  36638. 'html,body,base,head,link,meta,style,title,' +
  36639. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  36640. 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' +
  36641. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  36642. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  36643. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  36644. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  36645. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  36646. 'output,progress,select,textarea,' +
  36647. 'details,dialog,menu,menuitem,summary,' +
  36648. 'content,element,shadow,template'
  36649. );
  36650. // this map is intentionally selective, only covering SVG elements that may
  36651. // contain child elements.
  36652. var isSVG = makeMap(
  36653. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  36654. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  36655. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  36656. true
  36657. );
  36658. var isPreTag = function (tag) { return tag === 'pre'; };
  36659. var isReservedTag = function (tag) {
  36660. return isHTMLTag(tag) || isSVG(tag)
  36661. };
  36662. function getTagNamespace (tag) {
  36663. if (isSVG(tag)) {
  36664. return 'svg'
  36665. }
  36666. // basic support for MathML
  36667. // note it doesn't support other MathML elements being component roots
  36668. if (tag === 'math') {
  36669. return 'math'
  36670. }
  36671. }
  36672. var unknownElementCache = Object.create(null);
  36673. function isUnknownElement (tag) {
  36674. /* istanbul ignore if */
  36675. if (!inBrowser) {
  36676. return true
  36677. }
  36678. if (isReservedTag(tag)) {
  36679. return false
  36680. }
  36681. tag = tag.toLowerCase();
  36682. /* istanbul ignore if */
  36683. if (unknownElementCache[tag] != null) {
  36684. return unknownElementCache[tag]
  36685. }
  36686. var el = document.createElement(tag);
  36687. if (tag.indexOf('-') > -1) {
  36688. // http://stackoverflow.com/a/28210364/1070244
  36689. return (unknownElementCache[tag] = (
  36690. el.constructor === window.HTMLUnknownElement ||
  36691. el.constructor === window.HTMLElement
  36692. ))
  36693. } else {
  36694. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  36695. }
  36696. }
  36697. /* */
  36698. /**
  36699. * Query an element selector if it's not an element already.
  36700. */
  36701. function query (el) {
  36702. if (typeof el === 'string') {
  36703. var selected = document.querySelector(el);
  36704. if (!selected) {
  36705. "development" !== 'production' && warn(
  36706. 'Cannot find element: ' + el
  36707. );
  36708. return document.createElement('div')
  36709. }
  36710. return selected
  36711. } else {
  36712. return el
  36713. }
  36714. }
  36715. /* */
  36716. function createElement$1 (tagName, vnode) {
  36717. var elm = document.createElement(tagName);
  36718. if (tagName !== 'select') {
  36719. return elm
  36720. }
  36721. // false or null will remove the attribute but undefined will not
  36722. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  36723. elm.setAttribute('multiple', 'multiple');
  36724. }
  36725. return elm
  36726. }
  36727. function createElementNS (namespace, tagName) {
  36728. return document.createElementNS(namespaceMap[namespace], tagName)
  36729. }
  36730. function createTextNode (text) {
  36731. return document.createTextNode(text)
  36732. }
  36733. function createComment (text) {
  36734. return document.createComment(text)
  36735. }
  36736. function insertBefore (parentNode, newNode, referenceNode) {
  36737. parentNode.insertBefore(newNode, referenceNode);
  36738. }
  36739. function removeChild (node, child) {
  36740. node.removeChild(child);
  36741. }
  36742. function appendChild (node, child) {
  36743. node.appendChild(child);
  36744. }
  36745. function parentNode (node) {
  36746. return node.parentNode
  36747. }
  36748. function nextSibling (node) {
  36749. return node.nextSibling
  36750. }
  36751. function tagName (node) {
  36752. return node.tagName
  36753. }
  36754. function setTextContent (node, text) {
  36755. node.textContent = text;
  36756. }
  36757. function setAttribute (node, key, val) {
  36758. node.setAttribute(key, val);
  36759. }
  36760. var nodeOps = Object.freeze({
  36761. createElement: createElement$1,
  36762. createElementNS: createElementNS,
  36763. createTextNode: createTextNode,
  36764. createComment: createComment,
  36765. insertBefore: insertBefore,
  36766. removeChild: removeChild,
  36767. appendChild: appendChild,
  36768. parentNode: parentNode,
  36769. nextSibling: nextSibling,
  36770. tagName: tagName,
  36771. setTextContent: setTextContent,
  36772. setAttribute: setAttribute
  36773. });
  36774. /* */
  36775. var ref = {
  36776. create: function create (_, vnode) {
  36777. registerRef(vnode);
  36778. },
  36779. update: function update (oldVnode, vnode) {
  36780. if (oldVnode.data.ref !== vnode.data.ref) {
  36781. registerRef(oldVnode, true);
  36782. registerRef(vnode);
  36783. }
  36784. },
  36785. destroy: function destroy (vnode) {
  36786. registerRef(vnode, true);
  36787. }
  36788. };
  36789. function registerRef (vnode, isRemoval) {
  36790. var key = vnode.data.ref;
  36791. if (!key) { return }
  36792. var vm = vnode.context;
  36793. var ref = vnode.componentInstance || vnode.elm;
  36794. var refs = vm.$refs;
  36795. if (isRemoval) {
  36796. if (Array.isArray(refs[key])) {
  36797. remove(refs[key], ref);
  36798. } else if (refs[key] === ref) {
  36799. refs[key] = undefined;
  36800. }
  36801. } else {
  36802. if (vnode.data.refInFor) {
  36803. if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) {
  36804. refs[key].push(ref);
  36805. } else {
  36806. refs[key] = [ref];
  36807. }
  36808. } else {
  36809. refs[key] = ref;
  36810. }
  36811. }
  36812. }
  36813. /**
  36814. * Virtual DOM patching algorithm based on Snabbdom by
  36815. * Simon Friis Vindum (@paldepind)
  36816. * Licensed under the MIT License
  36817. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  36818. *
  36819. * modified by Evan You (@yyx990803)
  36820. *
  36821. /*
  36822. * Not type-checking this because this file is perf-critical and the cost
  36823. * of making flow understand it is not worth it.
  36824. */
  36825. var emptyNode = new VNode('', {}, []);
  36826. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  36827. function sameVnode (a, b) {
  36828. return (
  36829. a.key === b.key &&
  36830. a.tag === b.tag &&
  36831. a.isComment === b.isComment &&
  36832. isDef(a.data) === isDef(b.data) &&
  36833. sameInputType(a, b)
  36834. )
  36835. }
  36836. // Some browsers do not support dynamically changing type for <input>
  36837. // so they need to be treated as different nodes
  36838. function sameInputType (a, b) {
  36839. if (a.tag !== 'input') { return true }
  36840. var i;
  36841. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  36842. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  36843. return typeA === typeB
  36844. }
  36845. function createKeyToOldIdx (children, beginIdx, endIdx) {
  36846. var i, key;
  36847. var map = {};
  36848. for (i = beginIdx; i <= endIdx; ++i) {
  36849. key = children[i].key;
  36850. if (isDef(key)) { map[key] = i; }
  36851. }
  36852. return map
  36853. }
  36854. function createPatchFunction (backend) {
  36855. var i, j;
  36856. var cbs = {};
  36857. var modules = backend.modules;
  36858. var nodeOps = backend.nodeOps;
  36859. for (i = 0; i < hooks.length; ++i) {
  36860. cbs[hooks[i]] = [];
  36861. for (j = 0; j < modules.length; ++j) {
  36862. if (isDef(modules[j][hooks[i]])) {
  36863. cbs[hooks[i]].push(modules[j][hooks[i]]);
  36864. }
  36865. }
  36866. }
  36867. function emptyNodeAt (elm) {
  36868. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  36869. }
  36870. function createRmCb (childElm, listeners) {
  36871. function remove$$1 () {
  36872. if (--remove$$1.listeners === 0) {
  36873. removeNode(childElm);
  36874. }
  36875. }
  36876. remove$$1.listeners = listeners;
  36877. return remove$$1
  36878. }
  36879. function removeNode (el) {
  36880. var parent = nodeOps.parentNode(el);
  36881. // element may have already been removed due to v-html / v-text
  36882. if (isDef(parent)) {
  36883. nodeOps.removeChild(parent, el);
  36884. }
  36885. }
  36886. var inPre = 0;
  36887. function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) {
  36888. vnode.isRootInsert = !nested; // for transition enter check
  36889. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  36890. return
  36891. }
  36892. var data = vnode.data;
  36893. var children = vnode.children;
  36894. var tag = vnode.tag;
  36895. if (isDef(tag)) {
  36896. if (true) {
  36897. if (data && data.pre) {
  36898. inPre++;
  36899. }
  36900. if (
  36901. !inPre &&
  36902. !vnode.ns &&
  36903. !(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) &&
  36904. config.isUnknownElement(tag)
  36905. ) {
  36906. warn(
  36907. 'Unknown custom element: <' + tag + '> - did you ' +
  36908. 'register the component correctly? For recursive components, ' +
  36909. 'make sure to provide the "name" option.',
  36910. vnode.context
  36911. );
  36912. }
  36913. }
  36914. vnode.elm = vnode.ns
  36915. ? nodeOps.createElementNS(vnode.ns, tag)
  36916. : nodeOps.createElement(tag, vnode);
  36917. setScope(vnode);
  36918. /* istanbul ignore if */
  36919. {
  36920. createChildren(vnode, children, insertedVnodeQueue);
  36921. if (isDef(data)) {
  36922. invokeCreateHooks(vnode, insertedVnodeQueue);
  36923. }
  36924. insert(parentElm, vnode.elm, refElm);
  36925. }
  36926. if ("development" !== 'production' && data && data.pre) {
  36927. inPre--;
  36928. }
  36929. } else if (isTrue(vnode.isComment)) {
  36930. vnode.elm = nodeOps.createComment(vnode.text);
  36931. insert(parentElm, vnode.elm, refElm);
  36932. } else {
  36933. vnode.elm = nodeOps.createTextNode(vnode.text);
  36934. insert(parentElm, vnode.elm, refElm);
  36935. }
  36936. }
  36937. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  36938. var i = vnode.data;
  36939. if (isDef(i)) {
  36940. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  36941. if (isDef(i = i.hook) && isDef(i = i.init)) {
  36942. i(vnode, false /* hydrating */, parentElm, refElm);
  36943. }
  36944. // after calling the init hook, if the vnode is a child component
  36945. // it should've created a child instance and mounted it. the child
  36946. // component also has set the placeholder vnode's elm.
  36947. // in that case we can just return the element and be done.
  36948. if (isDef(vnode.componentInstance)) {
  36949. initComponent(vnode, insertedVnodeQueue);
  36950. if (isTrue(isReactivated)) {
  36951. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  36952. }
  36953. return true
  36954. }
  36955. }
  36956. }
  36957. function initComponent (vnode, insertedVnodeQueue) {
  36958. if (isDef(vnode.data.pendingInsert)) {
  36959. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  36960. vnode.data.pendingInsert = null;
  36961. }
  36962. vnode.elm = vnode.componentInstance.$el;
  36963. if (isPatchable(vnode)) {
  36964. invokeCreateHooks(vnode, insertedVnodeQueue);
  36965. setScope(vnode);
  36966. } else {
  36967. // empty component root.
  36968. // skip all element-related modules except for ref (#3455)
  36969. registerRef(vnode);
  36970. // make sure to invoke the insert hook
  36971. insertedVnodeQueue.push(vnode);
  36972. }
  36973. }
  36974. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  36975. var i;
  36976. // hack for #4339: a reactivated component with inner transition
  36977. // does not trigger because the inner node's created hooks are not called
  36978. // again. It's not ideal to involve module-specific logic in here but
  36979. // there doesn't seem to be a better way to do it.
  36980. var innerNode = vnode;
  36981. while (innerNode.componentInstance) {
  36982. innerNode = innerNode.componentInstance._vnode;
  36983. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  36984. for (i = 0; i < cbs.activate.length; ++i) {
  36985. cbs.activate[i](emptyNode, innerNode);
  36986. }
  36987. insertedVnodeQueue.push(innerNode);
  36988. break
  36989. }
  36990. }
  36991. // unlike a newly created component,
  36992. // a reactivated keep-alive component doesn't insert itself
  36993. insert(parentElm, vnode.elm, refElm);
  36994. }
  36995. function insert (parent, elm, ref) {
  36996. if (isDef(parent)) {
  36997. if (isDef(ref)) {
  36998. if (ref.parentNode === parent) {
  36999. nodeOps.insertBefore(parent, elm, ref);
  37000. }
  37001. } else {
  37002. nodeOps.appendChild(parent, elm);
  37003. }
  37004. }
  37005. }
  37006. function createChildren (vnode, children, insertedVnodeQueue) {
  37007. if (Array.isArray(children)) {
  37008. for (var i = 0; i < children.length; ++i) {
  37009. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
  37010. }
  37011. } else if (isPrimitive(vnode.text)) {
  37012. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
  37013. }
  37014. }
  37015. function isPatchable (vnode) {
  37016. while (vnode.componentInstance) {
  37017. vnode = vnode.componentInstance._vnode;
  37018. }
  37019. return isDef(vnode.tag)
  37020. }
  37021. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  37022. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  37023. cbs.create[i$1](emptyNode, vnode);
  37024. }
  37025. i = vnode.data.hook; // Reuse variable
  37026. if (isDef(i)) {
  37027. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  37028. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  37029. }
  37030. }
  37031. // set scope id attribute for scoped CSS.
  37032. // this is implemented as a special case to avoid the overhead
  37033. // of going through the normal attribute patching process.
  37034. function setScope (vnode) {
  37035. var i;
  37036. var ancestor = vnode;
  37037. while (ancestor) {
  37038. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  37039. nodeOps.setAttribute(vnode.elm, i, '');
  37040. }
  37041. ancestor = ancestor.parent;
  37042. }
  37043. // for slot content they should also get the scopeId from the host instance.
  37044. if (isDef(i = activeInstance) &&
  37045. i !== vnode.context &&
  37046. isDef(i = i.$options._scopeId)
  37047. ) {
  37048. nodeOps.setAttribute(vnode.elm, i, '');
  37049. }
  37050. }
  37051. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  37052. for (; startIdx <= endIdx; ++startIdx) {
  37053. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm);
  37054. }
  37055. }
  37056. function invokeDestroyHook (vnode) {
  37057. var i, j;
  37058. var data = vnode.data;
  37059. if (isDef(data)) {
  37060. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  37061. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  37062. }
  37063. if (isDef(i = vnode.children)) {
  37064. for (j = 0; j < vnode.children.length; ++j) {
  37065. invokeDestroyHook(vnode.children[j]);
  37066. }
  37067. }
  37068. }
  37069. function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
  37070. for (; startIdx <= endIdx; ++startIdx) {
  37071. var ch = vnodes[startIdx];
  37072. if (isDef(ch)) {
  37073. if (isDef(ch.tag)) {
  37074. removeAndInvokeRemoveHook(ch);
  37075. invokeDestroyHook(ch);
  37076. } else { // Text node
  37077. removeNode(ch.elm);
  37078. }
  37079. }
  37080. }
  37081. }
  37082. function removeAndInvokeRemoveHook (vnode, rm) {
  37083. if (isDef(rm) || isDef(vnode.data)) {
  37084. var i;
  37085. var listeners = cbs.remove.length + 1;
  37086. if (isDef(rm)) {
  37087. // we have a recursively passed down rm callback
  37088. // increase the listeners count
  37089. rm.listeners += listeners;
  37090. } else {
  37091. // directly removing
  37092. rm = createRmCb(vnode.elm, listeners);
  37093. }
  37094. // recursively invoke hooks on child component root node
  37095. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  37096. removeAndInvokeRemoveHook(i, rm);
  37097. }
  37098. for (i = 0; i < cbs.remove.length; ++i) {
  37099. cbs.remove[i](vnode, rm);
  37100. }
  37101. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  37102. i(vnode, rm);
  37103. } else {
  37104. rm();
  37105. }
  37106. } else {
  37107. removeNode(vnode.elm);
  37108. }
  37109. }
  37110. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  37111. var oldStartIdx = 0;
  37112. var newStartIdx = 0;
  37113. var oldEndIdx = oldCh.length - 1;
  37114. var oldStartVnode = oldCh[0];
  37115. var oldEndVnode = oldCh[oldEndIdx];
  37116. var newEndIdx = newCh.length - 1;
  37117. var newStartVnode = newCh[0];
  37118. var newEndVnode = newCh[newEndIdx];
  37119. var oldKeyToIdx, idxInOld, elmToMove, refElm;
  37120. // removeOnly is a special flag used only by <transition-group>
  37121. // to ensure removed elements stay in correct relative positions
  37122. // during leaving transitions
  37123. var canMove = !removeOnly;
  37124. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  37125. if (isUndef(oldStartVnode)) {
  37126. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  37127. } else if (isUndef(oldEndVnode)) {
  37128. oldEndVnode = oldCh[--oldEndIdx];
  37129. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  37130. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
  37131. oldStartVnode = oldCh[++oldStartIdx];
  37132. newStartVnode = newCh[++newStartIdx];
  37133. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  37134. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
  37135. oldEndVnode = oldCh[--oldEndIdx];
  37136. newEndVnode = newCh[--newEndIdx];
  37137. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  37138. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
  37139. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  37140. oldStartVnode = oldCh[++oldStartIdx];
  37141. newEndVnode = newCh[--newEndIdx];
  37142. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  37143. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
  37144. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  37145. oldEndVnode = oldCh[--oldEndIdx];
  37146. newStartVnode = newCh[++newStartIdx];
  37147. } else {
  37148. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  37149. idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
  37150. if (isUndef(idxInOld)) { // New element
  37151. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  37152. newStartVnode = newCh[++newStartIdx];
  37153. } else {
  37154. elmToMove = oldCh[idxInOld];
  37155. /* istanbul ignore if */
  37156. if ("development" !== 'production' && !elmToMove) {
  37157. warn(
  37158. 'It seems there are duplicate keys that is causing an update error. ' +
  37159. 'Make sure each v-for item has a unique key.'
  37160. );
  37161. }
  37162. if (sameVnode(elmToMove, newStartVnode)) {
  37163. patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
  37164. oldCh[idxInOld] = undefined;
  37165. canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm);
  37166. newStartVnode = newCh[++newStartIdx];
  37167. } else {
  37168. // same key but different element. treat as new element
  37169. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  37170. newStartVnode = newCh[++newStartIdx];
  37171. }
  37172. }
  37173. }
  37174. }
  37175. if (oldStartIdx > oldEndIdx) {
  37176. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  37177. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  37178. } else if (newStartIdx > newEndIdx) {
  37179. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  37180. }
  37181. }
  37182. function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
  37183. if (oldVnode === vnode) {
  37184. return
  37185. }
  37186. // reuse element for static trees.
  37187. // note we only do this if the vnode is cloned -
  37188. // if the new node is not cloned it means the render functions have been
  37189. // reset by the hot-reload-api and we need to do a proper re-render.
  37190. if (isTrue(vnode.isStatic) &&
  37191. isTrue(oldVnode.isStatic) &&
  37192. vnode.key === oldVnode.key &&
  37193. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  37194. ) {
  37195. vnode.elm = oldVnode.elm;
  37196. vnode.componentInstance = oldVnode.componentInstance;
  37197. return
  37198. }
  37199. var i;
  37200. var data = vnode.data;
  37201. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  37202. i(oldVnode, vnode);
  37203. }
  37204. var elm = vnode.elm = oldVnode.elm;
  37205. var oldCh = oldVnode.children;
  37206. var ch = vnode.children;
  37207. if (isDef(data) && isPatchable(vnode)) {
  37208. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  37209. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  37210. }
  37211. if (isUndef(vnode.text)) {
  37212. if (isDef(oldCh) && isDef(ch)) {
  37213. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  37214. } else if (isDef(ch)) {
  37215. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  37216. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  37217. } else if (isDef(oldCh)) {
  37218. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  37219. } else if (isDef(oldVnode.text)) {
  37220. nodeOps.setTextContent(elm, '');
  37221. }
  37222. } else if (oldVnode.text !== vnode.text) {
  37223. nodeOps.setTextContent(elm, vnode.text);
  37224. }
  37225. if (isDef(data)) {
  37226. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  37227. }
  37228. }
  37229. function invokeInsertHook (vnode, queue, initial) {
  37230. // delay insert hooks for component root nodes, invoke them after the
  37231. // element is really inserted
  37232. if (isTrue(initial) && isDef(vnode.parent)) {
  37233. vnode.parent.data.pendingInsert = queue;
  37234. } else {
  37235. for (var i = 0; i < queue.length; ++i) {
  37236. queue[i].data.hook.insert(queue[i]);
  37237. }
  37238. }
  37239. }
  37240. var bailed = false;
  37241. // list of modules that can skip create hook during hydration because they
  37242. // are already rendered on the client or has no need for initialization
  37243. var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key');
  37244. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  37245. function hydrate (elm, vnode, insertedVnodeQueue) {
  37246. if (true) {
  37247. if (!assertNodeMatch(elm, vnode)) {
  37248. return false
  37249. }
  37250. }
  37251. vnode.elm = elm;
  37252. var tag = vnode.tag;
  37253. var data = vnode.data;
  37254. var children = vnode.children;
  37255. if (isDef(data)) {
  37256. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  37257. if (isDef(i = vnode.componentInstance)) {
  37258. // child component. it should have hydrated its own tree.
  37259. initComponent(vnode, insertedVnodeQueue);
  37260. return true
  37261. }
  37262. }
  37263. if (isDef(tag)) {
  37264. if (isDef(children)) {
  37265. // empty element, allow client to pick up and populate children
  37266. if (!elm.hasChildNodes()) {
  37267. createChildren(vnode, children, insertedVnodeQueue);
  37268. } else {
  37269. var childrenMatch = true;
  37270. var childNode = elm.firstChild;
  37271. for (var i$1 = 0; i$1 < children.length; i$1++) {
  37272. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
  37273. childrenMatch = false;
  37274. break
  37275. }
  37276. childNode = childNode.nextSibling;
  37277. }
  37278. // if childNode is not null, it means the actual childNodes list is
  37279. // longer than the virtual children list.
  37280. if (!childrenMatch || childNode) {
  37281. if ("development" !== 'production' &&
  37282. typeof console !== 'undefined' &&
  37283. !bailed
  37284. ) {
  37285. bailed = true;
  37286. console.warn('Parent: ', elm);
  37287. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  37288. }
  37289. return false
  37290. }
  37291. }
  37292. }
  37293. if (isDef(data)) {
  37294. for (var key in data) {
  37295. if (!isRenderedModule(key)) {
  37296. invokeCreateHooks(vnode, insertedVnodeQueue);
  37297. break
  37298. }
  37299. }
  37300. }
  37301. } else if (elm.data !== vnode.text) {
  37302. elm.data = vnode.text;
  37303. }
  37304. return true
  37305. }
  37306. function assertNodeMatch (node, vnode) {
  37307. if (isDef(vnode.tag)) {
  37308. return (
  37309. vnode.tag.indexOf('vue-component') === 0 ||
  37310. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  37311. )
  37312. } else {
  37313. return node.nodeType === (vnode.isComment ? 8 : 3)
  37314. }
  37315. }
  37316. return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) {
  37317. if (isUndef(vnode)) {
  37318. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  37319. return
  37320. }
  37321. var isInitialPatch = false;
  37322. var insertedVnodeQueue = [];
  37323. if (isUndef(oldVnode)) {
  37324. // empty mount (likely as component), create new root element
  37325. isInitialPatch = true;
  37326. createElm(vnode, insertedVnodeQueue, parentElm, refElm);
  37327. } else {
  37328. var isRealElement = isDef(oldVnode.nodeType);
  37329. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  37330. // patch existing root node
  37331. patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
  37332. } else {
  37333. if (isRealElement) {
  37334. // mounting to a real element
  37335. // check if this is server-rendered content and if we can perform
  37336. // a successful hydration.
  37337. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  37338. oldVnode.removeAttribute(SSR_ATTR);
  37339. hydrating = true;
  37340. }
  37341. if (isTrue(hydrating)) {
  37342. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  37343. invokeInsertHook(vnode, insertedVnodeQueue, true);
  37344. return oldVnode
  37345. } else if (true) {
  37346. warn(
  37347. 'The client-side rendered virtual DOM tree is not matching ' +
  37348. 'server-rendered content. This is likely caused by incorrect ' +
  37349. 'HTML markup, for example nesting block-level elements inside ' +
  37350. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  37351. 'full client-side render.'
  37352. );
  37353. }
  37354. }
  37355. // either not server-rendered, or hydration failed.
  37356. // create an empty node and replace it
  37357. oldVnode = emptyNodeAt(oldVnode);
  37358. }
  37359. // replacing existing element
  37360. var oldElm = oldVnode.elm;
  37361. var parentElm$1 = nodeOps.parentNode(oldElm);
  37362. createElm(
  37363. vnode,
  37364. insertedVnodeQueue,
  37365. // extremely rare edge case: do not insert if old element is in a
  37366. // leaving transition. Only happens when combining transition +
  37367. // keep-alive + HOCs. (#4590)
  37368. oldElm._leaveCb ? null : parentElm$1,
  37369. nodeOps.nextSibling(oldElm)
  37370. );
  37371. if (isDef(vnode.parent)) {
  37372. // component root element replaced.
  37373. // update parent placeholder node element, recursively
  37374. var ancestor = vnode.parent;
  37375. while (ancestor) {
  37376. ancestor.elm = vnode.elm;
  37377. ancestor = ancestor.parent;
  37378. }
  37379. if (isPatchable(vnode)) {
  37380. for (var i = 0; i < cbs.create.length; ++i) {
  37381. cbs.create[i](emptyNode, vnode.parent);
  37382. }
  37383. }
  37384. }
  37385. if (isDef(parentElm$1)) {
  37386. removeVnodes(parentElm$1, [oldVnode], 0, 0);
  37387. } else if (isDef(oldVnode.tag)) {
  37388. invokeDestroyHook(oldVnode);
  37389. }
  37390. }
  37391. }
  37392. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  37393. return vnode.elm
  37394. }
  37395. }
  37396. /* */
  37397. var directives = {
  37398. create: updateDirectives,
  37399. update: updateDirectives,
  37400. destroy: function unbindDirectives (vnode) {
  37401. updateDirectives(vnode, emptyNode);
  37402. }
  37403. };
  37404. function updateDirectives (oldVnode, vnode) {
  37405. if (oldVnode.data.directives || vnode.data.directives) {
  37406. _update(oldVnode, vnode);
  37407. }
  37408. }
  37409. function _update (oldVnode, vnode) {
  37410. var isCreate = oldVnode === emptyNode;
  37411. var isDestroy = vnode === emptyNode;
  37412. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  37413. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  37414. var dirsWithInsert = [];
  37415. var dirsWithPostpatch = [];
  37416. var key, oldDir, dir;
  37417. for (key in newDirs) {
  37418. oldDir = oldDirs[key];
  37419. dir = newDirs[key];
  37420. if (!oldDir) {
  37421. // new directive, bind
  37422. callHook$1(dir, 'bind', vnode, oldVnode);
  37423. if (dir.def && dir.def.inserted) {
  37424. dirsWithInsert.push(dir);
  37425. }
  37426. } else {
  37427. // existing directive, update
  37428. dir.oldValue = oldDir.value;
  37429. callHook$1(dir, 'update', vnode, oldVnode);
  37430. if (dir.def && dir.def.componentUpdated) {
  37431. dirsWithPostpatch.push(dir);
  37432. }
  37433. }
  37434. }
  37435. if (dirsWithInsert.length) {
  37436. var callInsert = function () {
  37437. for (var i = 0; i < dirsWithInsert.length; i++) {
  37438. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  37439. }
  37440. };
  37441. if (isCreate) {
  37442. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert);
  37443. } else {
  37444. callInsert();
  37445. }
  37446. }
  37447. if (dirsWithPostpatch.length) {
  37448. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () {
  37449. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  37450. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  37451. }
  37452. });
  37453. }
  37454. if (!isCreate) {
  37455. for (key in oldDirs) {
  37456. if (!newDirs[key]) {
  37457. // no longer present, unbind
  37458. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  37459. }
  37460. }
  37461. }
  37462. }
  37463. var emptyModifiers = Object.create(null);
  37464. function normalizeDirectives$1 (
  37465. dirs,
  37466. vm
  37467. ) {
  37468. var res = Object.create(null);
  37469. if (!dirs) {
  37470. return res
  37471. }
  37472. var i, dir;
  37473. for (i = 0; i < dirs.length; i++) {
  37474. dir = dirs[i];
  37475. if (!dir.modifiers) {
  37476. dir.modifiers = emptyModifiers;
  37477. }
  37478. res[getRawDirName(dir)] = dir;
  37479. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  37480. }
  37481. return res
  37482. }
  37483. function getRawDirName (dir) {
  37484. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  37485. }
  37486. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  37487. var fn = dir.def && dir.def[hook];
  37488. if (fn) {
  37489. try {
  37490. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  37491. } catch (e) {
  37492. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  37493. }
  37494. }
  37495. }
  37496. var baseModules = [
  37497. ref,
  37498. directives
  37499. ];
  37500. /* */
  37501. function updateAttrs (oldVnode, vnode) {
  37502. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  37503. return
  37504. }
  37505. var key, cur, old;
  37506. var elm = vnode.elm;
  37507. var oldAttrs = oldVnode.data.attrs || {};
  37508. var attrs = vnode.data.attrs || {};
  37509. // clone observed objects, as the user probably wants to mutate it
  37510. if (isDef(attrs.__ob__)) {
  37511. attrs = vnode.data.attrs = extend({}, attrs);
  37512. }
  37513. for (key in attrs) {
  37514. cur = attrs[key];
  37515. old = oldAttrs[key];
  37516. if (old !== cur) {
  37517. setAttr(elm, key, cur);
  37518. }
  37519. }
  37520. // #4391: in IE9, setting type can reset value for input[type=radio]
  37521. /* istanbul ignore if */
  37522. if (isIE9 && attrs.value !== oldAttrs.value) {
  37523. setAttr(elm, 'value', attrs.value);
  37524. }
  37525. for (key in oldAttrs) {
  37526. if (isUndef(attrs[key])) {
  37527. if (isXlink(key)) {
  37528. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  37529. } else if (!isEnumeratedAttr(key)) {
  37530. elm.removeAttribute(key);
  37531. }
  37532. }
  37533. }
  37534. }
  37535. function setAttr (el, key, value) {
  37536. if (isBooleanAttr(key)) {
  37537. // set attribute for blank value
  37538. // e.g. <option disabled>Select one</option>
  37539. if (isFalsyAttrValue(value)) {
  37540. el.removeAttribute(key);
  37541. } else {
  37542. el.setAttribute(key, key);
  37543. }
  37544. } else if (isEnumeratedAttr(key)) {
  37545. el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
  37546. } else if (isXlink(key)) {
  37547. if (isFalsyAttrValue(value)) {
  37548. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  37549. } else {
  37550. el.setAttributeNS(xlinkNS, key, value);
  37551. }
  37552. } else {
  37553. if (isFalsyAttrValue(value)) {
  37554. el.removeAttribute(key);
  37555. } else {
  37556. el.setAttribute(key, value);
  37557. }
  37558. }
  37559. }
  37560. var attrs = {
  37561. create: updateAttrs,
  37562. update: updateAttrs
  37563. };
  37564. /* */
  37565. function updateClass (oldVnode, vnode) {
  37566. var el = vnode.elm;
  37567. var data = vnode.data;
  37568. var oldData = oldVnode.data;
  37569. if (
  37570. isUndef(data.staticClass) &&
  37571. isUndef(data.class) && (
  37572. isUndef(oldData) || (
  37573. isUndef(oldData.staticClass) &&
  37574. isUndef(oldData.class)
  37575. )
  37576. )
  37577. ) {
  37578. return
  37579. }
  37580. var cls = genClassForVnode(vnode);
  37581. // handle transition classes
  37582. var transitionClass = el._transitionClasses;
  37583. if (isDef(transitionClass)) {
  37584. cls = concat(cls, stringifyClass(transitionClass));
  37585. }
  37586. // set the class
  37587. if (cls !== el._prevClass) {
  37588. el.setAttribute('class', cls);
  37589. el._prevClass = cls;
  37590. }
  37591. }
  37592. var klass = {
  37593. create: updateClass,
  37594. update: updateClass
  37595. };
  37596. /* */
  37597. var validDivisionCharRE = /[\w).+\-_$\]]/;
  37598. function parseFilters (exp) {
  37599. var inSingle = false;
  37600. var inDouble = false;
  37601. var inTemplateString = false;
  37602. var inRegex = false;
  37603. var curly = 0;
  37604. var square = 0;
  37605. var paren = 0;
  37606. var lastFilterIndex = 0;
  37607. var c, prev, i, expression, filters;
  37608. for (i = 0; i < exp.length; i++) {
  37609. prev = c;
  37610. c = exp.charCodeAt(i);
  37611. if (inSingle) {
  37612. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  37613. } else if (inDouble) {
  37614. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  37615. } else if (inTemplateString) {
  37616. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  37617. } else if (inRegex) {
  37618. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  37619. } else if (
  37620. c === 0x7C && // pipe
  37621. exp.charCodeAt(i + 1) !== 0x7C &&
  37622. exp.charCodeAt(i - 1) !== 0x7C &&
  37623. !curly && !square && !paren
  37624. ) {
  37625. if (expression === undefined) {
  37626. // first filter, end of expression
  37627. lastFilterIndex = i + 1;
  37628. expression = exp.slice(0, i).trim();
  37629. } else {
  37630. pushFilter();
  37631. }
  37632. } else {
  37633. switch (c) {
  37634. case 0x22: inDouble = true; break // "
  37635. case 0x27: inSingle = true; break // '
  37636. case 0x60: inTemplateString = true; break // `
  37637. case 0x28: paren++; break // (
  37638. case 0x29: paren--; break // )
  37639. case 0x5B: square++; break // [
  37640. case 0x5D: square--; break // ]
  37641. case 0x7B: curly++; break // {
  37642. case 0x7D: curly--; break // }
  37643. }
  37644. if (c === 0x2f) { // /
  37645. var j = i - 1;
  37646. var p = (void 0);
  37647. // find first non-whitespace prev char
  37648. for (; j >= 0; j--) {
  37649. p = exp.charAt(j);
  37650. if (p !== ' ') { break }
  37651. }
  37652. if (!p || !validDivisionCharRE.test(p)) {
  37653. inRegex = true;
  37654. }
  37655. }
  37656. }
  37657. }
  37658. if (expression === undefined) {
  37659. expression = exp.slice(0, i).trim();
  37660. } else if (lastFilterIndex !== 0) {
  37661. pushFilter();
  37662. }
  37663. function pushFilter () {
  37664. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  37665. lastFilterIndex = i + 1;
  37666. }
  37667. if (filters) {
  37668. for (i = 0; i < filters.length; i++) {
  37669. expression = wrapFilter(expression, filters[i]);
  37670. }
  37671. }
  37672. return expression
  37673. }
  37674. function wrapFilter (exp, filter) {
  37675. var i = filter.indexOf('(');
  37676. if (i < 0) {
  37677. // _f: resolveFilter
  37678. return ("_f(\"" + filter + "\")(" + exp + ")")
  37679. } else {
  37680. var name = filter.slice(0, i);
  37681. var args = filter.slice(i + 1);
  37682. return ("_f(\"" + name + "\")(" + exp + "," + args)
  37683. }
  37684. }
  37685. /* */
  37686. function baseWarn (msg) {
  37687. console.error(("[Vue compiler]: " + msg));
  37688. }
  37689. function pluckModuleFunction (
  37690. modules,
  37691. key
  37692. ) {
  37693. return modules
  37694. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  37695. : []
  37696. }
  37697. function addProp (el, name, value) {
  37698. (el.props || (el.props = [])).push({ name: name, value: value });
  37699. }
  37700. function addAttr (el, name, value) {
  37701. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  37702. }
  37703. function addDirective (
  37704. el,
  37705. name,
  37706. rawName,
  37707. value,
  37708. arg,
  37709. modifiers
  37710. ) {
  37711. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  37712. }
  37713. function addHandler (
  37714. el,
  37715. name,
  37716. value,
  37717. modifiers,
  37718. important,
  37719. warn
  37720. ) {
  37721. // warn prevent and passive modifier
  37722. /* istanbul ignore if */
  37723. if (
  37724. "development" !== 'production' && warn &&
  37725. modifiers && modifiers.prevent && modifiers.passive
  37726. ) {
  37727. warn(
  37728. 'passive and prevent can\'t be used together. ' +
  37729. 'Passive handler can\'t prevent default event.'
  37730. );
  37731. }
  37732. // check capture modifier
  37733. if (modifiers && modifiers.capture) {
  37734. delete modifiers.capture;
  37735. name = '!' + name; // mark the event as captured
  37736. }
  37737. if (modifiers && modifiers.once) {
  37738. delete modifiers.once;
  37739. name = '~' + name; // mark the event as once
  37740. }
  37741. /* istanbul ignore if */
  37742. if (modifiers && modifiers.passive) {
  37743. delete modifiers.passive;
  37744. name = '&' + name; // mark the event as passive
  37745. }
  37746. var events;
  37747. if (modifiers && modifiers.native) {
  37748. delete modifiers.native;
  37749. events = el.nativeEvents || (el.nativeEvents = {});
  37750. } else {
  37751. events = el.events || (el.events = {});
  37752. }
  37753. var newHandler = { value: value, modifiers: modifiers };
  37754. var handlers = events[name];
  37755. /* istanbul ignore if */
  37756. if (Array.isArray(handlers)) {
  37757. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  37758. } else if (handlers) {
  37759. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  37760. } else {
  37761. events[name] = newHandler;
  37762. }
  37763. }
  37764. function getBindingAttr (
  37765. el,
  37766. name,
  37767. getStatic
  37768. ) {
  37769. var dynamicValue =
  37770. getAndRemoveAttr(el, ':' + name) ||
  37771. getAndRemoveAttr(el, 'v-bind:' + name);
  37772. if (dynamicValue != null) {
  37773. return parseFilters(dynamicValue)
  37774. } else if (getStatic !== false) {
  37775. var staticValue = getAndRemoveAttr(el, name);
  37776. if (staticValue != null) {
  37777. return JSON.stringify(staticValue)
  37778. }
  37779. }
  37780. }
  37781. function getAndRemoveAttr (el, name) {
  37782. var val;
  37783. if ((val = el.attrsMap[name]) != null) {
  37784. var list = el.attrsList;
  37785. for (var i = 0, l = list.length; i < l; i++) {
  37786. if (list[i].name === name) {
  37787. list.splice(i, 1);
  37788. break
  37789. }
  37790. }
  37791. }
  37792. return val
  37793. }
  37794. /* */
  37795. /**
  37796. * Cross-platform code generation for component v-model
  37797. */
  37798. function genComponentModel (
  37799. el,
  37800. value,
  37801. modifiers
  37802. ) {
  37803. var ref = modifiers || {};
  37804. var number = ref.number;
  37805. var trim = ref.trim;
  37806. var baseValueExpression = '$$v';
  37807. var valueExpression = baseValueExpression;
  37808. if (trim) {
  37809. valueExpression =
  37810. "(typeof " + baseValueExpression + " === 'string'" +
  37811. "? " + baseValueExpression + ".trim()" +
  37812. ": " + baseValueExpression + ")";
  37813. }
  37814. if (number) {
  37815. valueExpression = "_n(" + valueExpression + ")";
  37816. }
  37817. var assignment = genAssignmentCode(value, valueExpression);
  37818. el.model = {
  37819. value: ("(" + value + ")"),
  37820. expression: ("\"" + value + "\""),
  37821. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  37822. };
  37823. }
  37824. /**
  37825. * Cross-platform codegen helper for generating v-model value assignment code.
  37826. */
  37827. function genAssignmentCode (
  37828. value,
  37829. assignment
  37830. ) {
  37831. var modelRs = parseModel(value);
  37832. if (modelRs.idx === null) {
  37833. return (value + "=" + assignment)
  37834. } else {
  37835. return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" +
  37836. "if (!Array.isArray($$exp)){" +
  37837. value + "=" + assignment + "}" +
  37838. "else{$$exp.splice($$idx, 1, " + assignment + ")}"
  37839. }
  37840. }
  37841. /**
  37842. * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
  37843. *
  37844. * for loop possible cases:
  37845. *
  37846. * - test
  37847. * - test[idx]
  37848. * - test[test1[idx]]
  37849. * - test["a"][idx]
  37850. * - xxx.test[a[a].test1[idx]]
  37851. * - test.xxx.a["asa"][test1[idx]]
  37852. *
  37853. */
  37854. var len;
  37855. var str;
  37856. var chr;
  37857. var index$1;
  37858. var expressionPos;
  37859. var expressionEndPos;
  37860. function parseModel (val) {
  37861. str = val;
  37862. len = str.length;
  37863. index$1 = expressionPos = expressionEndPos = 0;
  37864. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  37865. return {
  37866. exp: val,
  37867. idx: null
  37868. }
  37869. }
  37870. while (!eof()) {
  37871. chr = next();
  37872. /* istanbul ignore if */
  37873. if (isStringStart(chr)) {
  37874. parseString(chr);
  37875. } else if (chr === 0x5B) {
  37876. parseBracket(chr);
  37877. }
  37878. }
  37879. return {
  37880. exp: val.substring(0, expressionPos),
  37881. idx: val.substring(expressionPos + 1, expressionEndPos)
  37882. }
  37883. }
  37884. function next () {
  37885. return str.charCodeAt(++index$1)
  37886. }
  37887. function eof () {
  37888. return index$1 >= len
  37889. }
  37890. function isStringStart (chr) {
  37891. return chr === 0x22 || chr === 0x27
  37892. }
  37893. function parseBracket (chr) {
  37894. var inBracket = 1;
  37895. expressionPos = index$1;
  37896. while (!eof()) {
  37897. chr = next();
  37898. if (isStringStart(chr)) {
  37899. parseString(chr);
  37900. continue
  37901. }
  37902. if (chr === 0x5B) { inBracket++; }
  37903. if (chr === 0x5D) { inBracket--; }
  37904. if (inBracket === 0) {
  37905. expressionEndPos = index$1;
  37906. break
  37907. }
  37908. }
  37909. }
  37910. function parseString (chr) {
  37911. var stringQuote = chr;
  37912. while (!eof()) {
  37913. chr = next();
  37914. if (chr === stringQuote) {
  37915. break
  37916. }
  37917. }
  37918. }
  37919. /* */
  37920. var warn$1;
  37921. // in some cases, the event used has to be determined at runtime
  37922. // so we used some reserved tokens during compile.
  37923. var RANGE_TOKEN = '__r';
  37924. var CHECKBOX_RADIO_TOKEN = '__c';
  37925. function model (
  37926. el,
  37927. dir,
  37928. _warn
  37929. ) {
  37930. warn$1 = _warn;
  37931. var value = dir.value;
  37932. var modifiers = dir.modifiers;
  37933. var tag = el.tag;
  37934. var type = el.attrsMap.type;
  37935. if (true) {
  37936. var dynamicType = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  37937. if (tag === 'input' && dynamicType) {
  37938. warn$1(
  37939. "<input :type=\"" + dynamicType + "\" v-model=\"" + value + "\">:\n" +
  37940. "v-model does not support dynamic input types. Use v-if branches instead."
  37941. );
  37942. }
  37943. // inputs with type="file" are read only and setting the input's
  37944. // value will throw an error.
  37945. if (tag === 'input' && type === 'file') {
  37946. warn$1(
  37947. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  37948. "File inputs are read only. Use a v-on:change listener instead."
  37949. );
  37950. }
  37951. }
  37952. if (tag === 'select') {
  37953. genSelect(el, value, modifiers);
  37954. } else if (tag === 'input' && type === 'checkbox') {
  37955. genCheckboxModel(el, value, modifiers);
  37956. } else if (tag === 'input' && type === 'radio') {
  37957. genRadioModel(el, value, modifiers);
  37958. } else if (tag === 'input' || tag === 'textarea') {
  37959. genDefaultModel(el, value, modifiers);
  37960. } else if (!config.isReservedTag(tag)) {
  37961. genComponentModel(el, value, modifiers);
  37962. // component v-model doesn't need extra runtime
  37963. return false
  37964. } else if (true) {
  37965. warn$1(
  37966. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  37967. "v-model is not supported on this element type. " +
  37968. 'If you are working with contenteditable, it\'s recommended to ' +
  37969. 'wrap a library dedicated for that purpose inside a custom component.'
  37970. );
  37971. }
  37972. // ensure runtime directive metadata
  37973. return true
  37974. }
  37975. function genCheckboxModel (
  37976. el,
  37977. value,
  37978. modifiers
  37979. ) {
  37980. var number = modifiers && modifiers.number;
  37981. var valueBinding = getBindingAttr(el, 'value') || 'null';
  37982. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  37983. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  37984. addProp(el, 'checked',
  37985. "Array.isArray(" + value + ")" +
  37986. "?_i(" + value + "," + valueBinding + ")>-1" + (
  37987. trueValueBinding === 'true'
  37988. ? (":(" + value + ")")
  37989. : (":_q(" + value + "," + trueValueBinding + ")")
  37990. )
  37991. );
  37992. addHandler(el, CHECKBOX_RADIO_TOKEN,
  37993. "var $$a=" + value + "," +
  37994. '$$el=$event.target,' +
  37995. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  37996. 'if(Array.isArray($$a)){' +
  37997. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  37998. '$$i=_i($$a,$$v);' +
  37999. "if($$c){$$i<0&&(" + value + "=$$a.concat($$v))}" +
  38000. "else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
  38001. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  38002. null, true
  38003. );
  38004. }
  38005. function genRadioModel (
  38006. el,
  38007. value,
  38008. modifiers
  38009. ) {
  38010. var number = modifiers && modifiers.number;
  38011. var valueBinding = getBindingAttr(el, 'value') || 'null';
  38012. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  38013. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  38014. addHandler(el, CHECKBOX_RADIO_TOKEN, genAssignmentCode(value, valueBinding), null, true);
  38015. }
  38016. function genSelect (
  38017. el,
  38018. value,
  38019. modifiers
  38020. ) {
  38021. var number = modifiers && modifiers.number;
  38022. var selectedVal = "Array.prototype.filter" +
  38023. ".call($event.target.options,function(o){return o.selected})" +
  38024. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  38025. "return " + (number ? '_n(val)' : 'val') + "})";
  38026. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  38027. var code = "var $$selectedVal = " + selectedVal + ";";
  38028. code = code + " " + (genAssignmentCode(value, assignment));
  38029. addHandler(el, 'change', code, null, true);
  38030. }
  38031. function genDefaultModel (
  38032. el,
  38033. value,
  38034. modifiers
  38035. ) {
  38036. var type = el.attrsMap.type;
  38037. var ref = modifiers || {};
  38038. var lazy = ref.lazy;
  38039. var number = ref.number;
  38040. var trim = ref.trim;
  38041. var needCompositionGuard = !lazy && type !== 'range';
  38042. var event = lazy
  38043. ? 'change'
  38044. : type === 'range'
  38045. ? RANGE_TOKEN
  38046. : 'input';
  38047. var valueExpression = '$event.target.value';
  38048. if (trim) {
  38049. valueExpression = "$event.target.value.trim()";
  38050. }
  38051. if (number) {
  38052. valueExpression = "_n(" + valueExpression + ")";
  38053. }
  38054. var code = genAssignmentCode(value, valueExpression);
  38055. if (needCompositionGuard) {
  38056. code = "if($event.target.composing)return;" + code;
  38057. }
  38058. addProp(el, 'value', ("(" + value + ")"));
  38059. addHandler(el, event, code, null, true);
  38060. if (trim || number || type === 'number') {
  38061. addHandler(el, 'blur', '$forceUpdate()');
  38062. }
  38063. }
  38064. /* */
  38065. // normalize v-model event tokens that can only be determined at runtime.
  38066. // it's important to place the event as the first in the array because
  38067. // the whole point is ensuring the v-model callback gets called before
  38068. // user-attached handlers.
  38069. function normalizeEvents (on) {
  38070. var event;
  38071. /* istanbul ignore if */
  38072. if (isDef(on[RANGE_TOKEN])) {
  38073. // IE input[type=range] only supports `change` event
  38074. event = isIE ? 'change' : 'input';
  38075. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  38076. delete on[RANGE_TOKEN];
  38077. }
  38078. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  38079. // Chrome fires microtasks in between click/change, leads to #4521
  38080. event = isChrome ? 'click' : 'change';
  38081. on[event] = [].concat(on[CHECKBOX_RADIO_TOKEN], on[event] || []);
  38082. delete on[CHECKBOX_RADIO_TOKEN];
  38083. }
  38084. }
  38085. var target$1;
  38086. function add$1 (
  38087. event,
  38088. handler,
  38089. once$$1,
  38090. capture,
  38091. passive
  38092. ) {
  38093. if (once$$1) {
  38094. var oldHandler = handler;
  38095. var _target = target$1; // save current target element in closure
  38096. handler = function (ev) {
  38097. var res = arguments.length === 1
  38098. ? oldHandler(ev)
  38099. : oldHandler.apply(null, arguments);
  38100. if (res !== null) {
  38101. remove$2(event, handler, capture, _target);
  38102. }
  38103. };
  38104. }
  38105. target$1.addEventListener(
  38106. event,
  38107. handler,
  38108. supportsPassive
  38109. ? { capture: capture, passive: passive }
  38110. : capture
  38111. );
  38112. }
  38113. function remove$2 (
  38114. event,
  38115. handler,
  38116. capture,
  38117. _target
  38118. ) {
  38119. (_target || target$1).removeEventListener(event, handler, capture);
  38120. }
  38121. function updateDOMListeners (oldVnode, vnode) {
  38122. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  38123. return
  38124. }
  38125. var on = vnode.data.on || {};
  38126. var oldOn = oldVnode.data.on || {};
  38127. target$1 = vnode.elm;
  38128. normalizeEvents(on);
  38129. updateListeners(on, oldOn, add$1, remove$2, vnode.context);
  38130. }
  38131. var events = {
  38132. create: updateDOMListeners,
  38133. update: updateDOMListeners
  38134. };
  38135. /* */
  38136. function updateDOMProps (oldVnode, vnode) {
  38137. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  38138. return
  38139. }
  38140. var key, cur;
  38141. var elm = vnode.elm;
  38142. var oldProps = oldVnode.data.domProps || {};
  38143. var props = vnode.data.domProps || {};
  38144. // clone observed objects, as the user probably wants to mutate it
  38145. if (isDef(props.__ob__)) {
  38146. props = vnode.data.domProps = extend({}, props);
  38147. }
  38148. for (key in oldProps) {
  38149. if (isUndef(props[key])) {
  38150. elm[key] = '';
  38151. }
  38152. }
  38153. for (key in props) {
  38154. cur = props[key];
  38155. // ignore children if the node has textContent or innerHTML,
  38156. // as these will throw away existing DOM nodes and cause removal errors
  38157. // on subsequent patches (#3360)
  38158. if (key === 'textContent' || key === 'innerHTML') {
  38159. if (vnode.children) { vnode.children.length = 0; }
  38160. if (cur === oldProps[key]) { continue }
  38161. }
  38162. if (key === 'value') {
  38163. // store value as _value as well since
  38164. // non-string values will be stringified
  38165. elm._value = cur;
  38166. // avoid resetting cursor position when value is the same
  38167. var strCur = isUndef(cur) ? '' : String(cur);
  38168. if (shouldUpdateValue(elm, vnode, strCur)) {
  38169. elm.value = strCur;
  38170. }
  38171. } else {
  38172. elm[key] = cur;
  38173. }
  38174. }
  38175. }
  38176. // check platforms/web/util/attrs.js acceptValue
  38177. function shouldUpdateValue (
  38178. elm,
  38179. vnode,
  38180. checkVal
  38181. ) {
  38182. return (!elm.composing && (
  38183. vnode.tag === 'option' ||
  38184. isDirty(elm, checkVal) ||
  38185. isInputChanged(elm, checkVal)
  38186. ))
  38187. }
  38188. function isDirty (elm, checkVal) {
  38189. // return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value
  38190. return document.activeElement !== elm && elm.value !== checkVal
  38191. }
  38192. function isInputChanged (elm, newVal) {
  38193. var value = elm.value;
  38194. var modifiers = elm._vModifiers; // injected by v-model runtime
  38195. if ((isDef(modifiers) && modifiers.number) || elm.type === 'number') {
  38196. return toNumber(value) !== toNumber(newVal)
  38197. }
  38198. if (isDef(modifiers) && modifiers.trim) {
  38199. return value.trim() !== newVal.trim()
  38200. }
  38201. return value !== newVal
  38202. }
  38203. var domProps = {
  38204. create: updateDOMProps,
  38205. update: updateDOMProps
  38206. };
  38207. /* */
  38208. var parseStyleText = cached(function (cssText) {
  38209. var res = {};
  38210. var listDelimiter = /;(?![^(]*\))/g;
  38211. var propertyDelimiter = /:(.+)/;
  38212. cssText.split(listDelimiter).forEach(function (item) {
  38213. if (item) {
  38214. var tmp = item.split(propertyDelimiter);
  38215. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  38216. }
  38217. });
  38218. return res
  38219. });
  38220. // merge static and dynamic style data on the same vnode
  38221. function normalizeStyleData (data) {
  38222. var style = normalizeStyleBinding(data.style);
  38223. // static style is pre-processed into an object during compilation
  38224. // and is always a fresh object, so it's safe to merge into it
  38225. return data.staticStyle
  38226. ? extend(data.staticStyle, style)
  38227. : style
  38228. }
  38229. // normalize possible array / string values into Object
  38230. function normalizeStyleBinding (bindingStyle) {
  38231. if (Array.isArray(bindingStyle)) {
  38232. return toObject(bindingStyle)
  38233. }
  38234. if (typeof bindingStyle === 'string') {
  38235. return parseStyleText(bindingStyle)
  38236. }
  38237. return bindingStyle
  38238. }
  38239. /**
  38240. * parent component style should be after child's
  38241. * so that parent component's style could override it
  38242. */
  38243. function getStyle (vnode, checkChild) {
  38244. var res = {};
  38245. var styleData;
  38246. if (checkChild) {
  38247. var childNode = vnode;
  38248. while (childNode.componentInstance) {
  38249. childNode = childNode.componentInstance._vnode;
  38250. if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
  38251. extend(res, styleData);
  38252. }
  38253. }
  38254. }
  38255. if ((styleData = normalizeStyleData(vnode.data))) {
  38256. extend(res, styleData);
  38257. }
  38258. var parentNode = vnode;
  38259. while ((parentNode = parentNode.parent)) {
  38260. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  38261. extend(res, styleData);
  38262. }
  38263. }
  38264. return res
  38265. }
  38266. /* */
  38267. var cssVarRE = /^--/;
  38268. var importantRE = /\s*!important$/;
  38269. var setProp = function (el, name, val) {
  38270. /* istanbul ignore if */
  38271. if (cssVarRE.test(name)) {
  38272. el.style.setProperty(name, val);
  38273. } else if (importantRE.test(val)) {
  38274. el.style.setProperty(name, val.replace(importantRE, ''), 'important');
  38275. } else {
  38276. var normalizedName = normalize(name);
  38277. if (Array.isArray(val)) {
  38278. // Support values array created by autoprefixer, e.g.
  38279. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  38280. // Set them one by one, and the browser will only set those it can recognize
  38281. for (var i = 0, len = val.length; i < len; i++) {
  38282. el.style[normalizedName] = val[i];
  38283. }
  38284. } else {
  38285. el.style[normalizedName] = val;
  38286. }
  38287. }
  38288. };
  38289. var prefixes = ['Webkit', 'Moz', 'ms'];
  38290. var testEl;
  38291. var normalize = cached(function (prop) {
  38292. testEl = testEl || document.createElement('div');
  38293. prop = camelize(prop);
  38294. if (prop !== 'filter' && (prop in testEl.style)) {
  38295. return prop
  38296. }
  38297. var upper = prop.charAt(0).toUpperCase() + prop.slice(1);
  38298. for (var i = 0; i < prefixes.length; i++) {
  38299. var prefixed = prefixes[i] + upper;
  38300. if (prefixed in testEl.style) {
  38301. return prefixed
  38302. }
  38303. }
  38304. });
  38305. function updateStyle (oldVnode, vnode) {
  38306. var data = vnode.data;
  38307. var oldData = oldVnode.data;
  38308. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  38309. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  38310. ) {
  38311. return
  38312. }
  38313. var cur, name;
  38314. var el = vnode.elm;
  38315. var oldStaticStyle = oldData.staticStyle;
  38316. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  38317. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  38318. var oldStyle = oldStaticStyle || oldStyleBinding;
  38319. var style = normalizeStyleBinding(vnode.data.style) || {};
  38320. // store normalized style under a different key for next diff
  38321. // make sure to clone it if it's reactive, since the user likley wants
  38322. // to mutate it.
  38323. vnode.data.normalizedStyle = isDef(style.__ob__)
  38324. ? extend({}, style)
  38325. : style;
  38326. var newStyle = getStyle(vnode, true);
  38327. for (name in oldStyle) {
  38328. if (isUndef(newStyle[name])) {
  38329. setProp(el, name, '');
  38330. }
  38331. }
  38332. for (name in newStyle) {
  38333. cur = newStyle[name];
  38334. if (cur !== oldStyle[name]) {
  38335. // ie9 setting to null has no effect, must use empty string
  38336. setProp(el, name, cur == null ? '' : cur);
  38337. }
  38338. }
  38339. }
  38340. var style = {
  38341. create: updateStyle,
  38342. update: updateStyle
  38343. };
  38344. /* */
  38345. /**
  38346. * Add class with compatibility for SVG since classList is not supported on
  38347. * SVG elements in IE
  38348. */
  38349. function addClass (el, cls) {
  38350. /* istanbul ignore if */
  38351. if (!cls || !(cls = cls.trim())) {
  38352. return
  38353. }
  38354. /* istanbul ignore else */
  38355. if (el.classList) {
  38356. if (cls.indexOf(' ') > -1) {
  38357. cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); });
  38358. } else {
  38359. el.classList.add(cls);
  38360. }
  38361. } else {
  38362. var cur = " " + (el.getAttribute('class') || '') + " ";
  38363. if (cur.indexOf(' ' + cls + ' ') < 0) {
  38364. el.setAttribute('class', (cur + cls).trim());
  38365. }
  38366. }
  38367. }
  38368. /**
  38369. * Remove class with compatibility for SVG since classList is not supported on
  38370. * SVG elements in IE
  38371. */
  38372. function removeClass (el, cls) {
  38373. /* istanbul ignore if */
  38374. if (!cls || !(cls = cls.trim())) {
  38375. return
  38376. }
  38377. /* istanbul ignore else */
  38378. if (el.classList) {
  38379. if (cls.indexOf(' ') > -1) {
  38380. cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
  38381. } else {
  38382. el.classList.remove(cls);
  38383. }
  38384. } else {
  38385. var cur = " " + (el.getAttribute('class') || '') + " ";
  38386. var tar = ' ' + cls + ' ';
  38387. while (cur.indexOf(tar) >= 0) {
  38388. cur = cur.replace(tar, ' ');
  38389. }
  38390. el.setAttribute('class', cur.trim());
  38391. }
  38392. }
  38393. /* */
  38394. function resolveTransition (def$$1) {
  38395. if (!def$$1) {
  38396. return
  38397. }
  38398. /* istanbul ignore else */
  38399. if (typeof def$$1 === 'object') {
  38400. var res = {};
  38401. if (def$$1.css !== false) {
  38402. extend(res, autoCssTransition(def$$1.name || 'v'));
  38403. }
  38404. extend(res, def$$1);
  38405. return res
  38406. } else if (typeof def$$1 === 'string') {
  38407. return autoCssTransition(def$$1)
  38408. }
  38409. }
  38410. var autoCssTransition = cached(function (name) {
  38411. return {
  38412. enterClass: (name + "-enter"),
  38413. enterToClass: (name + "-enter-to"),
  38414. enterActiveClass: (name + "-enter-active"),
  38415. leaveClass: (name + "-leave"),
  38416. leaveToClass: (name + "-leave-to"),
  38417. leaveActiveClass: (name + "-leave-active")
  38418. }
  38419. });
  38420. var hasTransition = inBrowser && !isIE9;
  38421. var TRANSITION = 'transition';
  38422. var ANIMATION = 'animation';
  38423. // Transition property/event sniffing
  38424. var transitionProp = 'transition';
  38425. var transitionEndEvent = 'transitionend';
  38426. var animationProp = 'animation';
  38427. var animationEndEvent = 'animationend';
  38428. if (hasTransition) {
  38429. /* istanbul ignore if */
  38430. if (window.ontransitionend === undefined &&
  38431. window.onwebkittransitionend !== undefined
  38432. ) {
  38433. transitionProp = 'WebkitTransition';
  38434. transitionEndEvent = 'webkitTransitionEnd';
  38435. }
  38436. if (window.onanimationend === undefined &&
  38437. window.onwebkitanimationend !== undefined
  38438. ) {
  38439. animationProp = 'WebkitAnimation';
  38440. animationEndEvent = 'webkitAnimationEnd';
  38441. }
  38442. }
  38443. // binding to window is necessary to make hot reload work in IE in strict mode
  38444. var raf = inBrowser && window.requestAnimationFrame
  38445. ? window.requestAnimationFrame.bind(window)
  38446. : setTimeout;
  38447. function nextFrame (fn) {
  38448. raf(function () {
  38449. raf(fn);
  38450. });
  38451. }
  38452. function addTransitionClass (el, cls) {
  38453. (el._transitionClasses || (el._transitionClasses = [])).push(cls);
  38454. addClass(el, cls);
  38455. }
  38456. function removeTransitionClass (el, cls) {
  38457. if (el._transitionClasses) {
  38458. remove(el._transitionClasses, cls);
  38459. }
  38460. removeClass(el, cls);
  38461. }
  38462. function whenTransitionEnds (
  38463. el,
  38464. expectedType,
  38465. cb
  38466. ) {
  38467. var ref = getTransitionInfo(el, expectedType);
  38468. var type = ref.type;
  38469. var timeout = ref.timeout;
  38470. var propCount = ref.propCount;
  38471. if (!type) { return cb() }
  38472. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  38473. var ended = 0;
  38474. var end = function () {
  38475. el.removeEventListener(event, onEnd);
  38476. cb();
  38477. };
  38478. var onEnd = function (e) {
  38479. if (e.target === el) {
  38480. if (++ended >= propCount) {
  38481. end();
  38482. }
  38483. }
  38484. };
  38485. setTimeout(function () {
  38486. if (ended < propCount) {
  38487. end();
  38488. }
  38489. }, timeout + 1);
  38490. el.addEventListener(event, onEnd);
  38491. }
  38492. var transformRE = /\b(transform|all)(,|$)/;
  38493. function getTransitionInfo (el, expectedType) {
  38494. var styles = window.getComputedStyle(el);
  38495. var transitionDelays = styles[transitionProp + 'Delay'].split(', ');
  38496. var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
  38497. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  38498. var animationDelays = styles[animationProp + 'Delay'].split(', ');
  38499. var animationDurations = styles[animationProp + 'Duration'].split(', ');
  38500. var animationTimeout = getTimeout(animationDelays, animationDurations);
  38501. var type;
  38502. var timeout = 0;
  38503. var propCount = 0;
  38504. /* istanbul ignore if */
  38505. if (expectedType === TRANSITION) {
  38506. if (transitionTimeout > 0) {
  38507. type = TRANSITION;
  38508. timeout = transitionTimeout;
  38509. propCount = transitionDurations.length;
  38510. }
  38511. } else if (expectedType === ANIMATION) {
  38512. if (animationTimeout > 0) {
  38513. type = ANIMATION;
  38514. timeout = animationTimeout;
  38515. propCount = animationDurations.length;
  38516. }
  38517. } else {
  38518. timeout = Math.max(transitionTimeout, animationTimeout);
  38519. type = timeout > 0
  38520. ? transitionTimeout > animationTimeout
  38521. ? TRANSITION
  38522. : ANIMATION
  38523. : null;
  38524. propCount = type
  38525. ? type === TRANSITION
  38526. ? transitionDurations.length
  38527. : animationDurations.length
  38528. : 0;
  38529. }
  38530. var hasTransform =
  38531. type === TRANSITION &&
  38532. transformRE.test(styles[transitionProp + 'Property']);
  38533. return {
  38534. type: type,
  38535. timeout: timeout,
  38536. propCount: propCount,
  38537. hasTransform: hasTransform
  38538. }
  38539. }
  38540. function getTimeout (delays, durations) {
  38541. /* istanbul ignore next */
  38542. while (delays.length < durations.length) {
  38543. delays = delays.concat(delays);
  38544. }
  38545. return Math.max.apply(null, durations.map(function (d, i) {
  38546. return toMs(d) + toMs(delays[i])
  38547. }))
  38548. }
  38549. function toMs (s) {
  38550. return Number(s.slice(0, -1)) * 1000
  38551. }
  38552. /* */
  38553. function enter (vnode, toggleDisplay) {
  38554. var el = vnode.elm;
  38555. // call leave callback now
  38556. if (isDef(el._leaveCb)) {
  38557. el._leaveCb.cancelled = true;
  38558. el._leaveCb();
  38559. }
  38560. var data = resolveTransition(vnode.data.transition);
  38561. if (isUndef(data)) {
  38562. return
  38563. }
  38564. /* istanbul ignore if */
  38565. if (isDef(el._enterCb) || el.nodeType !== 1) {
  38566. return
  38567. }
  38568. var css = data.css;
  38569. var type = data.type;
  38570. var enterClass = data.enterClass;
  38571. var enterToClass = data.enterToClass;
  38572. var enterActiveClass = data.enterActiveClass;
  38573. var appearClass = data.appearClass;
  38574. var appearToClass = data.appearToClass;
  38575. var appearActiveClass = data.appearActiveClass;
  38576. var beforeEnter = data.beforeEnter;
  38577. var enter = data.enter;
  38578. var afterEnter = data.afterEnter;
  38579. var enterCancelled = data.enterCancelled;
  38580. var beforeAppear = data.beforeAppear;
  38581. var appear = data.appear;
  38582. var afterAppear = data.afterAppear;
  38583. var appearCancelled = data.appearCancelled;
  38584. var duration = data.duration;
  38585. // activeInstance will always be the <transition> component managing this
  38586. // transition. One edge case to check is when the <transition> is placed
  38587. // as the root node of a child component. In that case we need to check
  38588. // <transition>'s parent for appear check.
  38589. var context = activeInstance;
  38590. var transitionNode = activeInstance.$vnode;
  38591. while (transitionNode && transitionNode.parent) {
  38592. transitionNode = transitionNode.parent;
  38593. context = transitionNode.context;
  38594. }
  38595. var isAppear = !context._isMounted || !vnode.isRootInsert;
  38596. if (isAppear && !appear && appear !== '') {
  38597. return
  38598. }
  38599. var startClass = isAppear && appearClass
  38600. ? appearClass
  38601. : enterClass;
  38602. var activeClass = isAppear && appearActiveClass
  38603. ? appearActiveClass
  38604. : enterActiveClass;
  38605. var toClass = isAppear && appearToClass
  38606. ? appearToClass
  38607. : enterToClass;
  38608. var beforeEnterHook = isAppear
  38609. ? (beforeAppear || beforeEnter)
  38610. : beforeEnter;
  38611. var enterHook = isAppear
  38612. ? (typeof appear === 'function' ? appear : enter)
  38613. : enter;
  38614. var afterEnterHook = isAppear
  38615. ? (afterAppear || afterEnter)
  38616. : afterEnter;
  38617. var enterCancelledHook = isAppear
  38618. ? (appearCancelled || enterCancelled)
  38619. : enterCancelled;
  38620. var explicitEnterDuration = toNumber(
  38621. isObject(duration)
  38622. ? duration.enter
  38623. : duration
  38624. );
  38625. if ("development" !== 'production' && explicitEnterDuration != null) {
  38626. checkDuration(explicitEnterDuration, 'enter', vnode);
  38627. }
  38628. var expectsCSS = css !== false && !isIE9;
  38629. var userWantsControl = getHookArgumentsLength(enterHook);
  38630. var cb = el._enterCb = once(function () {
  38631. if (expectsCSS) {
  38632. removeTransitionClass(el, toClass);
  38633. removeTransitionClass(el, activeClass);
  38634. }
  38635. if (cb.cancelled) {
  38636. if (expectsCSS) {
  38637. removeTransitionClass(el, startClass);
  38638. }
  38639. enterCancelledHook && enterCancelledHook(el);
  38640. } else {
  38641. afterEnterHook && afterEnterHook(el);
  38642. }
  38643. el._enterCb = null;
  38644. });
  38645. if (!vnode.data.show) {
  38646. // remove pending leave element on enter by injecting an insert hook
  38647. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
  38648. var parent = el.parentNode;
  38649. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  38650. if (pendingNode &&
  38651. pendingNode.tag === vnode.tag &&
  38652. pendingNode.elm._leaveCb
  38653. ) {
  38654. pendingNode.elm._leaveCb();
  38655. }
  38656. enterHook && enterHook(el, cb);
  38657. });
  38658. }
  38659. // start enter transition
  38660. beforeEnterHook && beforeEnterHook(el);
  38661. if (expectsCSS) {
  38662. addTransitionClass(el, startClass);
  38663. addTransitionClass(el, activeClass);
  38664. nextFrame(function () {
  38665. addTransitionClass(el, toClass);
  38666. removeTransitionClass(el, startClass);
  38667. if (!cb.cancelled && !userWantsControl) {
  38668. if (isValidDuration(explicitEnterDuration)) {
  38669. setTimeout(cb, explicitEnterDuration);
  38670. } else {
  38671. whenTransitionEnds(el, type, cb);
  38672. }
  38673. }
  38674. });
  38675. }
  38676. if (vnode.data.show) {
  38677. toggleDisplay && toggleDisplay();
  38678. enterHook && enterHook(el, cb);
  38679. }
  38680. if (!expectsCSS && !userWantsControl) {
  38681. cb();
  38682. }
  38683. }
  38684. function leave (vnode, rm) {
  38685. var el = vnode.elm;
  38686. // call enter callback now
  38687. if (isDef(el._enterCb)) {
  38688. el._enterCb.cancelled = true;
  38689. el._enterCb();
  38690. }
  38691. var data = resolveTransition(vnode.data.transition);
  38692. if (isUndef(data)) {
  38693. return rm()
  38694. }
  38695. /* istanbul ignore if */
  38696. if (isDef(el._leaveCb) || el.nodeType !== 1) {
  38697. return
  38698. }
  38699. var css = data.css;
  38700. var type = data.type;
  38701. var leaveClass = data.leaveClass;
  38702. var leaveToClass = data.leaveToClass;
  38703. var leaveActiveClass = data.leaveActiveClass;
  38704. var beforeLeave = data.beforeLeave;
  38705. var leave = data.leave;
  38706. var afterLeave = data.afterLeave;
  38707. var leaveCancelled = data.leaveCancelled;
  38708. var delayLeave = data.delayLeave;
  38709. var duration = data.duration;
  38710. var expectsCSS = css !== false && !isIE9;
  38711. var userWantsControl = getHookArgumentsLength(leave);
  38712. var explicitLeaveDuration = toNumber(
  38713. isObject(duration)
  38714. ? duration.leave
  38715. : duration
  38716. );
  38717. if ("development" !== 'production' && isDef(explicitLeaveDuration)) {
  38718. checkDuration(explicitLeaveDuration, 'leave', vnode);
  38719. }
  38720. var cb = el._leaveCb = once(function () {
  38721. if (el.parentNode && el.parentNode._pending) {
  38722. el.parentNode._pending[vnode.key] = null;
  38723. }
  38724. if (expectsCSS) {
  38725. removeTransitionClass(el, leaveToClass);
  38726. removeTransitionClass(el, leaveActiveClass);
  38727. }
  38728. if (cb.cancelled) {
  38729. if (expectsCSS) {
  38730. removeTransitionClass(el, leaveClass);
  38731. }
  38732. leaveCancelled && leaveCancelled(el);
  38733. } else {
  38734. rm();
  38735. afterLeave && afterLeave(el);
  38736. }
  38737. el._leaveCb = null;
  38738. });
  38739. if (delayLeave) {
  38740. delayLeave(performLeave);
  38741. } else {
  38742. performLeave();
  38743. }
  38744. function performLeave () {
  38745. // the delayed leave may have already been cancelled
  38746. if (cb.cancelled) {
  38747. return
  38748. }
  38749. // record leaving element
  38750. if (!vnode.data.show) {
  38751. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  38752. }
  38753. beforeLeave && beforeLeave(el);
  38754. if (expectsCSS) {
  38755. addTransitionClass(el, leaveClass);
  38756. addTransitionClass(el, leaveActiveClass);
  38757. nextFrame(function () {
  38758. addTransitionClass(el, leaveToClass);
  38759. removeTransitionClass(el, leaveClass);
  38760. if (!cb.cancelled && !userWantsControl) {
  38761. if (isValidDuration(explicitLeaveDuration)) {
  38762. setTimeout(cb, explicitLeaveDuration);
  38763. } else {
  38764. whenTransitionEnds(el, type, cb);
  38765. }
  38766. }
  38767. });
  38768. }
  38769. leave && leave(el, cb);
  38770. if (!expectsCSS && !userWantsControl) {
  38771. cb();
  38772. }
  38773. }
  38774. }
  38775. // only used in dev mode
  38776. function checkDuration (val, name, vnode) {
  38777. if (typeof val !== 'number') {
  38778. warn(
  38779. "<transition> explicit " + name + " duration is not a valid number - " +
  38780. "got " + (JSON.stringify(val)) + ".",
  38781. vnode.context
  38782. );
  38783. } else if (isNaN(val)) {
  38784. warn(
  38785. "<transition> explicit " + name + " duration is NaN - " +
  38786. 'the duration expression might be incorrect.',
  38787. vnode.context
  38788. );
  38789. }
  38790. }
  38791. function isValidDuration (val) {
  38792. return typeof val === 'number' && !isNaN(val)
  38793. }
  38794. /**
  38795. * Normalize a transition hook's argument length. The hook may be:
  38796. * - a merged hook (invoker) with the original in .fns
  38797. * - a wrapped component method (check ._length)
  38798. * - a plain function (.length)
  38799. */
  38800. function getHookArgumentsLength (fn) {
  38801. if (isUndef(fn)) {
  38802. return false
  38803. }
  38804. var invokerFns = fn.fns;
  38805. if (isDef(invokerFns)) {
  38806. // invoker
  38807. return getHookArgumentsLength(
  38808. Array.isArray(invokerFns)
  38809. ? invokerFns[0]
  38810. : invokerFns
  38811. )
  38812. } else {
  38813. return (fn._length || fn.length) > 1
  38814. }
  38815. }
  38816. function _enter (_, vnode) {
  38817. if (vnode.data.show !== true) {
  38818. enter(vnode);
  38819. }
  38820. }
  38821. var transition = inBrowser ? {
  38822. create: _enter,
  38823. activate: _enter,
  38824. remove: function remove$$1 (vnode, rm) {
  38825. /* istanbul ignore else */
  38826. if (vnode.data.show !== true) {
  38827. leave(vnode, rm);
  38828. } else {
  38829. rm();
  38830. }
  38831. }
  38832. } : {};
  38833. var platformModules = [
  38834. attrs,
  38835. klass,
  38836. events,
  38837. domProps,
  38838. style,
  38839. transition
  38840. ];
  38841. /* */
  38842. // the directive module should be applied last, after all
  38843. // built-in modules have been applied.
  38844. var modules = platformModules.concat(baseModules);
  38845. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  38846. /**
  38847. * Not type checking this file because flow doesn't like attaching
  38848. * properties to Elements.
  38849. */
  38850. /* istanbul ignore if */
  38851. if (isIE9) {
  38852. // http://www.matts411.com/post/internet-explorer-9-oninput/
  38853. document.addEventListener('selectionchange', function () {
  38854. var el = document.activeElement;
  38855. if (el && el.vmodel) {
  38856. trigger(el, 'input');
  38857. }
  38858. });
  38859. }
  38860. var model$1 = {
  38861. inserted: function inserted (el, binding, vnode) {
  38862. if (vnode.tag === 'select') {
  38863. var cb = function () {
  38864. setSelected(el, binding, vnode.context);
  38865. };
  38866. cb();
  38867. /* istanbul ignore if */
  38868. if (isIE || isEdge) {
  38869. setTimeout(cb, 0);
  38870. }
  38871. } else if (vnode.tag === 'textarea' || el.type === 'text' || el.type === 'password') {
  38872. el._vModifiers = binding.modifiers;
  38873. if (!binding.modifiers.lazy) {
  38874. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  38875. // switching focus before confirming composition choice
  38876. // this also fixes the issue where some browsers e.g. iOS Chrome
  38877. // fires "change" instead of "input" on autocomplete.
  38878. el.addEventListener('change', onCompositionEnd);
  38879. if (!isAndroid) {
  38880. el.addEventListener('compositionstart', onCompositionStart);
  38881. el.addEventListener('compositionend', onCompositionEnd);
  38882. }
  38883. /* istanbul ignore if */
  38884. if (isIE9) {
  38885. el.vmodel = true;
  38886. }
  38887. }
  38888. }
  38889. },
  38890. componentUpdated: function componentUpdated (el, binding, vnode) {
  38891. if (vnode.tag === 'select') {
  38892. setSelected(el, binding, vnode.context);
  38893. // in case the options rendered by v-for have changed,
  38894. // it's possible that the value is out-of-sync with the rendered options.
  38895. // detect such cases and filter out values that no longer has a matching
  38896. // option in the DOM.
  38897. var needReset = el.multiple
  38898. ? binding.value.some(function (v) { return hasNoMatchingOption(v, el.options); })
  38899. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options);
  38900. if (needReset) {
  38901. trigger(el, 'change');
  38902. }
  38903. }
  38904. }
  38905. };
  38906. function setSelected (el, binding, vm) {
  38907. var value = binding.value;
  38908. var isMultiple = el.multiple;
  38909. if (isMultiple && !Array.isArray(value)) {
  38910. "development" !== 'production' && warn(
  38911. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  38912. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  38913. vm
  38914. );
  38915. return
  38916. }
  38917. var selected, option;
  38918. for (var i = 0, l = el.options.length; i < l; i++) {
  38919. option = el.options[i];
  38920. if (isMultiple) {
  38921. selected = looseIndexOf(value, getValue(option)) > -1;
  38922. if (option.selected !== selected) {
  38923. option.selected = selected;
  38924. }
  38925. } else {
  38926. if (looseEqual(getValue(option), value)) {
  38927. if (el.selectedIndex !== i) {
  38928. el.selectedIndex = i;
  38929. }
  38930. return
  38931. }
  38932. }
  38933. }
  38934. if (!isMultiple) {
  38935. el.selectedIndex = -1;
  38936. }
  38937. }
  38938. function hasNoMatchingOption (value, options) {
  38939. for (var i = 0, l = options.length; i < l; i++) {
  38940. if (looseEqual(getValue(options[i]), value)) {
  38941. return false
  38942. }
  38943. }
  38944. return true
  38945. }
  38946. function getValue (option) {
  38947. return '_value' in option
  38948. ? option._value
  38949. : option.value
  38950. }
  38951. function onCompositionStart (e) {
  38952. e.target.composing = true;
  38953. }
  38954. function onCompositionEnd (e) {
  38955. // prevent triggering an input event for no reason
  38956. if (!e.target.composing) { return }
  38957. e.target.composing = false;
  38958. trigger(e.target, 'input');
  38959. }
  38960. function trigger (el, type) {
  38961. var e = document.createEvent('HTMLEvents');
  38962. e.initEvent(type, true, true);
  38963. el.dispatchEvent(e);
  38964. }
  38965. /* */
  38966. // recursively search for possible transition defined inside the component root
  38967. function locateNode (vnode) {
  38968. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  38969. ? locateNode(vnode.componentInstance._vnode)
  38970. : vnode
  38971. }
  38972. var show = {
  38973. bind: function bind (el, ref, vnode) {
  38974. var value = ref.value;
  38975. vnode = locateNode(vnode);
  38976. var transition = vnode.data && vnode.data.transition;
  38977. var originalDisplay = el.__vOriginalDisplay =
  38978. el.style.display === 'none' ? '' : el.style.display;
  38979. if (value && transition && !isIE9) {
  38980. vnode.data.show = true;
  38981. enter(vnode, function () {
  38982. el.style.display = originalDisplay;
  38983. });
  38984. } else {
  38985. el.style.display = value ? originalDisplay : 'none';
  38986. }
  38987. },
  38988. update: function update (el, ref, vnode) {
  38989. var value = ref.value;
  38990. var oldValue = ref.oldValue;
  38991. /* istanbul ignore if */
  38992. if (value === oldValue) { return }
  38993. vnode = locateNode(vnode);
  38994. var transition = vnode.data && vnode.data.transition;
  38995. if (transition && !isIE9) {
  38996. vnode.data.show = true;
  38997. if (value) {
  38998. enter(vnode, function () {
  38999. el.style.display = el.__vOriginalDisplay;
  39000. });
  39001. } else {
  39002. leave(vnode, function () {
  39003. el.style.display = 'none';
  39004. });
  39005. }
  39006. } else {
  39007. el.style.display = value ? el.__vOriginalDisplay : 'none';
  39008. }
  39009. },
  39010. unbind: function unbind (
  39011. el,
  39012. binding,
  39013. vnode,
  39014. oldVnode,
  39015. isDestroy
  39016. ) {
  39017. if (!isDestroy) {
  39018. el.style.display = el.__vOriginalDisplay;
  39019. }
  39020. }
  39021. };
  39022. var platformDirectives = {
  39023. model: model$1,
  39024. show: show
  39025. };
  39026. /* */
  39027. // Provides transition support for a single element/component.
  39028. // supports transition mode (out-in / in-out)
  39029. var transitionProps = {
  39030. name: String,
  39031. appear: Boolean,
  39032. css: Boolean,
  39033. mode: String,
  39034. type: String,
  39035. enterClass: String,
  39036. leaveClass: String,
  39037. enterToClass: String,
  39038. leaveToClass: String,
  39039. enterActiveClass: String,
  39040. leaveActiveClass: String,
  39041. appearClass: String,
  39042. appearActiveClass: String,
  39043. appearToClass: String,
  39044. duration: [Number, String, Object]
  39045. };
  39046. // in case the child is also an abstract component, e.g. <keep-alive>
  39047. // we want to recursively retrieve the real component to be rendered
  39048. function getRealChild (vnode) {
  39049. var compOptions = vnode && vnode.componentOptions;
  39050. if (compOptions && compOptions.Ctor.options.abstract) {
  39051. return getRealChild(getFirstComponentChild(compOptions.children))
  39052. } else {
  39053. return vnode
  39054. }
  39055. }
  39056. function extractTransitionData (comp) {
  39057. var data = {};
  39058. var options = comp.$options;
  39059. // props
  39060. for (var key in options.propsData) {
  39061. data[key] = comp[key];
  39062. }
  39063. // events.
  39064. // extract listeners and pass them directly to the transition methods
  39065. var listeners = options._parentListeners;
  39066. for (var key$1 in listeners) {
  39067. data[camelize(key$1)] = listeners[key$1];
  39068. }
  39069. return data
  39070. }
  39071. function placeholder (h, rawChild) {
  39072. if (/\d-keep-alive$/.test(rawChild.tag)) {
  39073. return h('keep-alive', {
  39074. props: rawChild.componentOptions.propsData
  39075. })
  39076. }
  39077. }
  39078. function hasParentTransition (vnode) {
  39079. while ((vnode = vnode.parent)) {
  39080. if (vnode.data.transition) {
  39081. return true
  39082. }
  39083. }
  39084. }
  39085. function isSameChild (child, oldChild) {
  39086. return oldChild.key === child.key && oldChild.tag === child.tag
  39087. }
  39088. var Transition = {
  39089. name: 'transition',
  39090. props: transitionProps,
  39091. abstract: true,
  39092. render: function render (h) {
  39093. var this$1 = this;
  39094. var children = this.$slots.default;
  39095. if (!children) {
  39096. return
  39097. }
  39098. // filter out text nodes (possible whitespaces)
  39099. children = children.filter(function (c) { return c.tag; });
  39100. /* istanbul ignore if */
  39101. if (!children.length) {
  39102. return
  39103. }
  39104. // warn multiple elements
  39105. if ("development" !== 'production' && children.length > 1) {
  39106. warn(
  39107. '<transition> can only be used on a single element. Use ' +
  39108. '<transition-group> for lists.',
  39109. this.$parent
  39110. );
  39111. }
  39112. var mode = this.mode;
  39113. // warn invalid mode
  39114. if ("development" !== 'production' &&
  39115. mode && mode !== 'in-out' && mode !== 'out-in'
  39116. ) {
  39117. warn(
  39118. 'invalid <transition> mode: ' + mode,
  39119. this.$parent
  39120. );
  39121. }
  39122. var rawChild = children[0];
  39123. // if this is a component root node and the component's
  39124. // parent container node also has transition, skip.
  39125. if (hasParentTransition(this.$vnode)) {
  39126. return rawChild
  39127. }
  39128. // apply transition data to child
  39129. // use getRealChild() to ignore abstract components e.g. keep-alive
  39130. var child = getRealChild(rawChild);
  39131. /* istanbul ignore if */
  39132. if (!child) {
  39133. return rawChild
  39134. }
  39135. if (this._leaving) {
  39136. return placeholder(h, rawChild)
  39137. }
  39138. // ensure a key that is unique to the vnode type and to this transition
  39139. // component instance. This key will be used to remove pending leaving nodes
  39140. // during entering.
  39141. var id = "__transition-" + (this._uid) + "-";
  39142. child.key = child.key == null
  39143. ? id + child.tag
  39144. : isPrimitive(child.key)
  39145. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  39146. : child.key;
  39147. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  39148. var oldRawChild = this._vnode;
  39149. var oldChild = getRealChild(oldRawChild);
  39150. // mark v-show
  39151. // so that the transition module can hand over the control to the directive
  39152. if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
  39153. child.data.show = true;
  39154. }
  39155. if (oldChild && oldChild.data && !isSameChild(child, oldChild)) {
  39156. // replace old child transition data with fresh one
  39157. // important for dynamic transitions!
  39158. var oldData = oldChild && (oldChild.data.transition = extend({}, data));
  39159. // handle transition mode
  39160. if (mode === 'out-in') {
  39161. // return placeholder node and queue update when leave finishes
  39162. this._leaving = true;
  39163. mergeVNodeHook(oldData, 'afterLeave', function () {
  39164. this$1._leaving = false;
  39165. this$1.$forceUpdate();
  39166. });
  39167. return placeholder(h, rawChild)
  39168. } else if (mode === 'in-out') {
  39169. var delayedLeave;
  39170. var performLeave = function () { delayedLeave(); };
  39171. mergeVNodeHook(data, 'afterEnter', performLeave);
  39172. mergeVNodeHook(data, 'enterCancelled', performLeave);
  39173. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  39174. }
  39175. }
  39176. return rawChild
  39177. }
  39178. };
  39179. /* */
  39180. // Provides transition support for list items.
  39181. // supports move transitions using the FLIP technique.
  39182. // Because the vdom's children update algorithm is "unstable" - i.e.
  39183. // it doesn't guarantee the relative positioning of removed elements,
  39184. // we force transition-group to update its children into two passes:
  39185. // in the first pass, we remove all nodes that need to be removed,
  39186. // triggering their leaving transition; in the second pass, we insert/move
  39187. // into the final desired state. This way in the second pass removed
  39188. // nodes will remain where they should be.
  39189. var props = extend({
  39190. tag: String,
  39191. moveClass: String
  39192. }, transitionProps);
  39193. delete props.mode;
  39194. var TransitionGroup = {
  39195. props: props,
  39196. render: function render (h) {
  39197. var tag = this.tag || this.$vnode.data.tag || 'span';
  39198. var map = Object.create(null);
  39199. var prevChildren = this.prevChildren = this.children;
  39200. var rawChildren = this.$slots.default || [];
  39201. var children = this.children = [];
  39202. var transitionData = extractTransitionData(this);
  39203. for (var i = 0; i < rawChildren.length; i++) {
  39204. var c = rawChildren[i];
  39205. if (c.tag) {
  39206. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  39207. children.push(c);
  39208. map[c.key] = c
  39209. ;(c.data || (c.data = {})).transition = transitionData;
  39210. } else if (true) {
  39211. var opts = c.componentOptions;
  39212. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  39213. warn(("<transition-group> children must be keyed: <" + name + ">"));
  39214. }
  39215. }
  39216. }
  39217. if (prevChildren) {
  39218. var kept = [];
  39219. var removed = [];
  39220. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  39221. var c$1 = prevChildren[i$1];
  39222. c$1.data.transition = transitionData;
  39223. c$1.data.pos = c$1.elm.getBoundingClientRect();
  39224. if (map[c$1.key]) {
  39225. kept.push(c$1);
  39226. } else {
  39227. removed.push(c$1);
  39228. }
  39229. }
  39230. this.kept = h(tag, null, kept);
  39231. this.removed = removed;
  39232. }
  39233. return h(tag, null, children)
  39234. },
  39235. beforeUpdate: function beforeUpdate () {
  39236. // force removing pass
  39237. this.__patch__(
  39238. this._vnode,
  39239. this.kept,
  39240. false, // hydrating
  39241. true // removeOnly (!important, avoids unnecessary moves)
  39242. );
  39243. this._vnode = this.kept;
  39244. },
  39245. updated: function updated () {
  39246. var children = this.prevChildren;
  39247. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  39248. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  39249. return
  39250. }
  39251. // we divide the work into three loops to avoid mixing DOM reads and writes
  39252. // in each iteration - which helps prevent layout thrashing.
  39253. children.forEach(callPendingCbs);
  39254. children.forEach(recordPosition);
  39255. children.forEach(applyTranslation);
  39256. // force reflow to put everything in position
  39257. var body = document.body;
  39258. var f = body.offsetHeight; // eslint-disable-line
  39259. children.forEach(function (c) {
  39260. if (c.data.moved) {
  39261. var el = c.elm;
  39262. var s = el.style;
  39263. addTransitionClass(el, moveClass);
  39264. s.transform = s.WebkitTransform = s.transitionDuration = '';
  39265. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  39266. if (!e || /transform$/.test(e.propertyName)) {
  39267. el.removeEventListener(transitionEndEvent, cb);
  39268. el._moveCb = null;
  39269. removeTransitionClass(el, moveClass);
  39270. }
  39271. });
  39272. }
  39273. });
  39274. },
  39275. methods: {
  39276. hasMove: function hasMove (el, moveClass) {
  39277. /* istanbul ignore if */
  39278. if (!hasTransition) {
  39279. return false
  39280. }
  39281. if (this._hasMove != null) {
  39282. return this._hasMove
  39283. }
  39284. // Detect whether an element with the move class applied has
  39285. // CSS transitions. Since the element may be inside an entering
  39286. // transition at this very moment, we make a clone of it and remove
  39287. // all other transition classes applied to ensure only the move class
  39288. // is applied.
  39289. var clone = el.cloneNode();
  39290. if (el._transitionClasses) {
  39291. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  39292. }
  39293. addClass(clone, moveClass);
  39294. clone.style.display = 'none';
  39295. this.$el.appendChild(clone);
  39296. var info = getTransitionInfo(clone);
  39297. this.$el.removeChild(clone);
  39298. return (this._hasMove = info.hasTransform)
  39299. }
  39300. }
  39301. };
  39302. function callPendingCbs (c) {
  39303. /* istanbul ignore if */
  39304. if (c.elm._moveCb) {
  39305. c.elm._moveCb();
  39306. }
  39307. /* istanbul ignore if */
  39308. if (c.elm._enterCb) {
  39309. c.elm._enterCb();
  39310. }
  39311. }
  39312. function recordPosition (c) {
  39313. c.data.newPos = c.elm.getBoundingClientRect();
  39314. }
  39315. function applyTranslation (c) {
  39316. var oldPos = c.data.pos;
  39317. var newPos = c.data.newPos;
  39318. var dx = oldPos.left - newPos.left;
  39319. var dy = oldPos.top - newPos.top;
  39320. if (dx || dy) {
  39321. c.data.moved = true;
  39322. var s = c.elm.style;
  39323. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  39324. s.transitionDuration = '0s';
  39325. }
  39326. }
  39327. var platformComponents = {
  39328. Transition: Transition,
  39329. TransitionGroup: TransitionGroup
  39330. };
  39331. /* */
  39332. // install platform specific utils
  39333. Vue$3.config.mustUseProp = mustUseProp;
  39334. Vue$3.config.isReservedTag = isReservedTag;
  39335. Vue$3.config.isReservedAttr = isReservedAttr;
  39336. Vue$3.config.getTagNamespace = getTagNamespace;
  39337. Vue$3.config.isUnknownElement = isUnknownElement;
  39338. // install platform runtime directives & components
  39339. extend(Vue$3.options.directives, platformDirectives);
  39340. extend(Vue$3.options.components, platformComponents);
  39341. // install platform patch function
  39342. Vue$3.prototype.__patch__ = inBrowser ? patch : noop;
  39343. // public mount method
  39344. Vue$3.prototype.$mount = function (
  39345. el,
  39346. hydrating
  39347. ) {
  39348. el = el && inBrowser ? query(el) : undefined;
  39349. return mountComponent(this, el, hydrating)
  39350. };
  39351. // devtools global hook
  39352. /* istanbul ignore next */
  39353. setTimeout(function () {
  39354. if (config.devtools) {
  39355. if (devtools) {
  39356. devtools.emit('init', Vue$3);
  39357. } else if ("development" !== 'production' && isChrome) {
  39358. console[console.info ? 'info' : 'log'](
  39359. 'Download the Vue Devtools extension for a better development experience:\n' +
  39360. 'https://github.com/vuejs/vue-devtools'
  39361. );
  39362. }
  39363. }
  39364. if ("development" !== 'production' &&
  39365. config.productionTip !== false &&
  39366. inBrowser && typeof console !== 'undefined'
  39367. ) {
  39368. console[console.info ? 'info' : 'log'](
  39369. "You are running Vue in development mode.\n" +
  39370. "Make sure to turn on production mode when deploying for production.\n" +
  39371. "See more tips at https://vuejs.org/guide/deployment.html"
  39372. );
  39373. }
  39374. }, 0);
  39375. /* */
  39376. // check whether current browser encodes a char inside attribute values
  39377. function shouldDecode (content, encoded) {
  39378. var div = document.createElement('div');
  39379. div.innerHTML = "<div a=\"" + content + "\">";
  39380. return div.innerHTML.indexOf(encoded) > 0
  39381. }
  39382. // #3663
  39383. // IE encodes newlines inside attribute values while other browsers don't
  39384. var shouldDecodeNewlines = inBrowser ? shouldDecode('\n', '&#10;') : false;
  39385. /* */
  39386. var isUnaryTag = makeMap(
  39387. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  39388. 'link,meta,param,source,track,wbr'
  39389. );
  39390. // Elements that you can, intentionally, leave open
  39391. // (and which close themselves)
  39392. var canBeLeftOpenTag = makeMap(
  39393. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  39394. );
  39395. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  39396. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  39397. var isNonPhrasingTag = makeMap(
  39398. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  39399. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  39400. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  39401. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  39402. 'title,tr,track'
  39403. );
  39404. /* */
  39405. var decoder;
  39406. function decode (html) {
  39407. decoder = decoder || document.createElement('div');
  39408. decoder.innerHTML = html;
  39409. return decoder.textContent
  39410. }
  39411. /**
  39412. * Not type-checking this file because it's mostly vendor code.
  39413. */
  39414. /*!
  39415. * HTML Parser By John Resig (ejohn.org)
  39416. * Modified by Juriy "kangax" Zaytsev
  39417. * Original code by Erik Arvidsson, Mozilla Public License
  39418. * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
  39419. */
  39420. // Regular Expressions for parsing tags and attributes
  39421. var singleAttrIdentifier = /([^\s"'<>/=]+)/;
  39422. var singleAttrAssign = /(?:=)/;
  39423. var singleAttrValues = [
  39424. // attr value double quotes
  39425. /"([^"]*)"+/.source,
  39426. // attr value, single quotes
  39427. /'([^']*)'+/.source,
  39428. // attr value, no quotes
  39429. /([^\s"'=<>`]+)/.source
  39430. ];
  39431. var attribute = new RegExp(
  39432. '^\\s*' + singleAttrIdentifier.source +
  39433. '(?:\\s*(' + singleAttrAssign.source + ')' +
  39434. '\\s*(?:' + singleAttrValues.join('|') + '))?'
  39435. );
  39436. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  39437. // but for Vue templates we can enforce a simple charset
  39438. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  39439. var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
  39440. var startTagOpen = new RegExp('^<' + qnameCapture);
  39441. var startTagClose = /^\s*(\/?)>/;
  39442. var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
  39443. var doctype = /^<!DOCTYPE [^>]+>/i;
  39444. var comment = /^<!--/;
  39445. var conditionalComment = /^<!\[/;
  39446. var IS_REGEX_CAPTURING_BROKEN = false;
  39447. 'x'.replace(/x(.)?/g, function (m, g) {
  39448. IS_REGEX_CAPTURING_BROKEN = g === '';
  39449. });
  39450. // Special Elements (can contain anything)
  39451. var isPlainTextElement = makeMap('script,style,textarea', true);
  39452. var reCache = {};
  39453. var decodingMap = {
  39454. '&lt;': '<',
  39455. '&gt;': '>',
  39456. '&quot;': '"',
  39457. '&amp;': '&',
  39458. '&#10;': '\n'
  39459. };
  39460. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  39461. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g;
  39462. function decodeAttr (value, shouldDecodeNewlines) {
  39463. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  39464. return value.replace(re, function (match) { return decodingMap[match]; })
  39465. }
  39466. function parseHTML (html, options) {
  39467. var stack = [];
  39468. var expectHTML = options.expectHTML;
  39469. var isUnaryTag$$1 = options.isUnaryTag || no;
  39470. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  39471. var index = 0;
  39472. var last, lastTag;
  39473. while (html) {
  39474. last = html;
  39475. // Make sure we're not in a plaintext content element like script/style
  39476. if (!lastTag || !isPlainTextElement(lastTag)) {
  39477. var textEnd = html.indexOf('<');
  39478. if (textEnd === 0) {
  39479. // Comment:
  39480. if (comment.test(html)) {
  39481. var commentEnd = html.indexOf('-->');
  39482. if (commentEnd >= 0) {
  39483. advance(commentEnd + 3);
  39484. continue
  39485. }
  39486. }
  39487. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  39488. if (conditionalComment.test(html)) {
  39489. var conditionalEnd = html.indexOf(']>');
  39490. if (conditionalEnd >= 0) {
  39491. advance(conditionalEnd + 2);
  39492. continue
  39493. }
  39494. }
  39495. // Doctype:
  39496. var doctypeMatch = html.match(doctype);
  39497. if (doctypeMatch) {
  39498. advance(doctypeMatch[0].length);
  39499. continue
  39500. }
  39501. // End tag:
  39502. var endTagMatch = html.match(endTag);
  39503. if (endTagMatch) {
  39504. var curIndex = index;
  39505. advance(endTagMatch[0].length);
  39506. parseEndTag(endTagMatch[1], curIndex, index);
  39507. continue
  39508. }
  39509. // Start tag:
  39510. var startTagMatch = parseStartTag();
  39511. if (startTagMatch) {
  39512. handleStartTag(startTagMatch);
  39513. continue
  39514. }
  39515. }
  39516. var text = (void 0), rest$1 = (void 0), next = (void 0);
  39517. if (textEnd >= 0) {
  39518. rest$1 = html.slice(textEnd);
  39519. while (
  39520. !endTag.test(rest$1) &&
  39521. !startTagOpen.test(rest$1) &&
  39522. !comment.test(rest$1) &&
  39523. !conditionalComment.test(rest$1)
  39524. ) {
  39525. // < in plain text, be forgiving and treat it as text
  39526. next = rest$1.indexOf('<', 1);
  39527. if (next < 0) { break }
  39528. textEnd += next;
  39529. rest$1 = html.slice(textEnd);
  39530. }
  39531. text = html.substring(0, textEnd);
  39532. advance(textEnd);
  39533. }
  39534. if (textEnd < 0) {
  39535. text = html;
  39536. html = '';
  39537. }
  39538. if (options.chars && text) {
  39539. options.chars(text);
  39540. }
  39541. } else {
  39542. var stackedTag = lastTag.toLowerCase();
  39543. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  39544. var endTagLength = 0;
  39545. var rest = html.replace(reStackedTag, function (all, text, endTag) {
  39546. endTagLength = endTag.length;
  39547. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  39548. text = text
  39549. .replace(/<!--([\s\S]*?)-->/g, '$1')
  39550. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  39551. }
  39552. if (options.chars) {
  39553. options.chars(text);
  39554. }
  39555. return ''
  39556. });
  39557. index += html.length - rest.length;
  39558. html = rest;
  39559. parseEndTag(stackedTag, index - endTagLength, index);
  39560. }
  39561. if (html === last) {
  39562. options.chars && options.chars(html);
  39563. if ("development" !== 'production' && !stack.length && options.warn) {
  39564. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  39565. }
  39566. break
  39567. }
  39568. }
  39569. // Clean up any remaining tags
  39570. parseEndTag();
  39571. function advance (n) {
  39572. index += n;
  39573. html = html.substring(n);
  39574. }
  39575. function parseStartTag () {
  39576. var start = html.match(startTagOpen);
  39577. if (start) {
  39578. var match = {
  39579. tagName: start[1],
  39580. attrs: [],
  39581. start: index
  39582. };
  39583. advance(start[0].length);
  39584. var end, attr;
  39585. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  39586. advance(attr[0].length);
  39587. match.attrs.push(attr);
  39588. }
  39589. if (end) {
  39590. match.unarySlash = end[1];
  39591. advance(end[0].length);
  39592. match.end = index;
  39593. return match
  39594. }
  39595. }
  39596. }
  39597. function handleStartTag (match) {
  39598. var tagName = match.tagName;
  39599. var unarySlash = match.unarySlash;
  39600. if (expectHTML) {
  39601. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  39602. parseEndTag(lastTag);
  39603. }
  39604. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  39605. parseEndTag(tagName);
  39606. }
  39607. }
  39608. var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
  39609. var l = match.attrs.length;
  39610. var attrs = new Array(l);
  39611. for (var i = 0; i < l; i++) {
  39612. var args = match.attrs[i];
  39613. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  39614. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  39615. if (args[3] === '') { delete args[3]; }
  39616. if (args[4] === '') { delete args[4]; }
  39617. if (args[5] === '') { delete args[5]; }
  39618. }
  39619. var value = args[3] || args[4] || args[5] || '';
  39620. attrs[i] = {
  39621. name: args[1],
  39622. value: decodeAttr(
  39623. value,
  39624. options.shouldDecodeNewlines
  39625. )
  39626. };
  39627. }
  39628. if (!unary) {
  39629. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  39630. lastTag = tagName;
  39631. }
  39632. if (options.start) {
  39633. options.start(tagName, attrs, unary, match.start, match.end);
  39634. }
  39635. }
  39636. function parseEndTag (tagName, start, end) {
  39637. var pos, lowerCasedTagName;
  39638. if (start == null) { start = index; }
  39639. if (end == null) { end = index; }
  39640. if (tagName) {
  39641. lowerCasedTagName = tagName.toLowerCase();
  39642. }
  39643. // Find the closest opened tag of the same type
  39644. if (tagName) {
  39645. for (pos = stack.length - 1; pos >= 0; pos--) {
  39646. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  39647. break
  39648. }
  39649. }
  39650. } else {
  39651. // If no tag name is provided, clean shop
  39652. pos = 0;
  39653. }
  39654. if (pos >= 0) {
  39655. // Close all the open elements, up the stack
  39656. for (var i = stack.length - 1; i >= pos; i--) {
  39657. if ("development" !== 'production' &&
  39658. (i > pos || !tagName) &&
  39659. options.warn
  39660. ) {
  39661. options.warn(
  39662. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  39663. );
  39664. }
  39665. if (options.end) {
  39666. options.end(stack[i].tag, start, end);
  39667. }
  39668. }
  39669. // Remove the open elements from the stack
  39670. stack.length = pos;
  39671. lastTag = pos && stack[pos - 1].tag;
  39672. } else if (lowerCasedTagName === 'br') {
  39673. if (options.start) {
  39674. options.start(tagName, [], true, start, end);
  39675. }
  39676. } else if (lowerCasedTagName === 'p') {
  39677. if (options.start) {
  39678. options.start(tagName, [], false, start, end);
  39679. }
  39680. if (options.end) {
  39681. options.end(tagName, start, end);
  39682. }
  39683. }
  39684. }
  39685. }
  39686. /* */
  39687. var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
  39688. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  39689. var buildRegex = cached(function (delimiters) {
  39690. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  39691. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  39692. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  39693. });
  39694. function parseText (
  39695. text,
  39696. delimiters
  39697. ) {
  39698. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  39699. if (!tagRE.test(text)) {
  39700. return
  39701. }
  39702. var tokens = [];
  39703. var lastIndex = tagRE.lastIndex = 0;
  39704. var match, index;
  39705. while ((match = tagRE.exec(text))) {
  39706. index = match.index;
  39707. // push text token
  39708. if (index > lastIndex) {
  39709. tokens.push(JSON.stringify(text.slice(lastIndex, index)));
  39710. }
  39711. // tag token
  39712. var exp = parseFilters(match[1].trim());
  39713. tokens.push(("_s(" + exp + ")"));
  39714. lastIndex = index + match[0].length;
  39715. }
  39716. if (lastIndex < text.length) {
  39717. tokens.push(JSON.stringify(text.slice(lastIndex)));
  39718. }
  39719. return tokens.join('+')
  39720. }
  39721. /* */
  39722. var onRE = /^@|^v-on:/;
  39723. var dirRE = /^v-|^@|^:/;
  39724. var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
  39725. var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
  39726. var argRE = /:(.*)$/;
  39727. var bindRE = /^:|^v-bind:/;
  39728. var modifierRE = /\.[^.]+/g;
  39729. var decodeHTMLCached = cached(decode);
  39730. // configurable state
  39731. var warn$2;
  39732. var delimiters;
  39733. var transforms;
  39734. var preTransforms;
  39735. var postTransforms;
  39736. var platformIsPreTag;
  39737. var platformMustUseProp;
  39738. var platformGetTagNamespace;
  39739. /**
  39740. * Convert HTML string to AST.
  39741. */
  39742. function parse (
  39743. template,
  39744. options
  39745. ) {
  39746. warn$2 = options.warn || baseWarn;
  39747. platformGetTagNamespace = options.getTagNamespace || no;
  39748. platformMustUseProp = options.mustUseProp || no;
  39749. platformIsPreTag = options.isPreTag || no;
  39750. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  39751. transforms = pluckModuleFunction(options.modules, 'transformNode');
  39752. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  39753. delimiters = options.delimiters;
  39754. var stack = [];
  39755. var preserveWhitespace = options.preserveWhitespace !== false;
  39756. var root;
  39757. var currentParent;
  39758. var inVPre = false;
  39759. var inPre = false;
  39760. var warned = false;
  39761. function warnOnce (msg) {
  39762. if (!warned) {
  39763. warned = true;
  39764. warn$2(msg);
  39765. }
  39766. }
  39767. function endPre (element) {
  39768. // check pre state
  39769. if (element.pre) {
  39770. inVPre = false;
  39771. }
  39772. if (platformIsPreTag(element.tag)) {
  39773. inPre = false;
  39774. }
  39775. }
  39776. parseHTML(template, {
  39777. warn: warn$2,
  39778. expectHTML: options.expectHTML,
  39779. isUnaryTag: options.isUnaryTag,
  39780. canBeLeftOpenTag: options.canBeLeftOpenTag,
  39781. shouldDecodeNewlines: options.shouldDecodeNewlines,
  39782. start: function start (tag, attrs, unary) {
  39783. // check namespace.
  39784. // inherit parent ns if there is one
  39785. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  39786. // handle IE svg bug
  39787. /* istanbul ignore if */
  39788. if (isIE && ns === 'svg') {
  39789. attrs = guardIESVGBug(attrs);
  39790. }
  39791. var element = {
  39792. type: 1,
  39793. tag: tag,
  39794. attrsList: attrs,
  39795. attrsMap: makeAttrsMap(attrs),
  39796. parent: currentParent,
  39797. children: []
  39798. };
  39799. if (ns) {
  39800. element.ns = ns;
  39801. }
  39802. if (isForbiddenTag(element) && !isServerRendering()) {
  39803. element.forbidden = true;
  39804. "development" !== 'production' && warn$2(
  39805. 'Templates should only be responsible for mapping the state to the ' +
  39806. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  39807. "<" + tag + ">" + ', as they will not be parsed.'
  39808. );
  39809. }
  39810. // apply pre-transforms
  39811. for (var i = 0; i < preTransforms.length; i++) {
  39812. preTransforms[i](element, options);
  39813. }
  39814. if (!inVPre) {
  39815. processPre(element);
  39816. if (element.pre) {
  39817. inVPre = true;
  39818. }
  39819. }
  39820. if (platformIsPreTag(element.tag)) {
  39821. inPre = true;
  39822. }
  39823. if (inVPre) {
  39824. processRawAttrs(element);
  39825. } else {
  39826. processFor(element);
  39827. processIf(element);
  39828. processOnce(element);
  39829. processKey(element);
  39830. // determine whether this is a plain element after
  39831. // removing structural attributes
  39832. element.plain = !element.key && !attrs.length;
  39833. processRef(element);
  39834. processSlot(element);
  39835. processComponent(element);
  39836. for (var i$1 = 0; i$1 < transforms.length; i$1++) {
  39837. transforms[i$1](element, options);
  39838. }
  39839. processAttrs(element);
  39840. }
  39841. function checkRootConstraints (el) {
  39842. if (true) {
  39843. if (el.tag === 'slot' || el.tag === 'template') {
  39844. warnOnce(
  39845. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  39846. 'contain multiple nodes.'
  39847. );
  39848. }
  39849. if (el.attrsMap.hasOwnProperty('v-for')) {
  39850. warnOnce(
  39851. 'Cannot use v-for on stateful component root element because ' +
  39852. 'it renders multiple elements.'
  39853. );
  39854. }
  39855. }
  39856. }
  39857. // tree management
  39858. if (!root) {
  39859. root = element;
  39860. checkRootConstraints(root);
  39861. } else if (!stack.length) {
  39862. // allow root elements with v-if, v-else-if and v-else
  39863. if (root.if && (element.elseif || element.else)) {
  39864. checkRootConstraints(element);
  39865. addIfCondition(root, {
  39866. exp: element.elseif,
  39867. block: element
  39868. });
  39869. } else if (true) {
  39870. warnOnce(
  39871. "Component template should contain exactly one root element. " +
  39872. "If you are using v-if on multiple elements, " +
  39873. "use v-else-if to chain them instead."
  39874. );
  39875. }
  39876. }
  39877. if (currentParent && !element.forbidden) {
  39878. if (element.elseif || element.else) {
  39879. processIfConditions(element, currentParent);
  39880. } else if (element.slotScope) { // scoped slot
  39881. currentParent.plain = false;
  39882. var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  39883. } else {
  39884. currentParent.children.push(element);
  39885. element.parent = currentParent;
  39886. }
  39887. }
  39888. if (!unary) {
  39889. currentParent = element;
  39890. stack.push(element);
  39891. } else {
  39892. endPre(element);
  39893. }
  39894. // apply post-transforms
  39895. for (var i$2 = 0; i$2 < postTransforms.length; i$2++) {
  39896. postTransforms[i$2](element, options);
  39897. }
  39898. },
  39899. end: function end () {
  39900. // remove trailing whitespace
  39901. var element = stack[stack.length - 1];
  39902. var lastNode = element.children[element.children.length - 1];
  39903. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  39904. element.children.pop();
  39905. }
  39906. // pop stack
  39907. stack.length -= 1;
  39908. currentParent = stack[stack.length - 1];
  39909. endPre(element);
  39910. },
  39911. chars: function chars (text) {
  39912. if (!currentParent) {
  39913. if (true) {
  39914. if (text === template) {
  39915. warnOnce(
  39916. 'Component template requires a root element, rather than just text.'
  39917. );
  39918. } else if ((text = text.trim())) {
  39919. warnOnce(
  39920. ("text \"" + text + "\" outside root element will be ignored.")
  39921. );
  39922. }
  39923. }
  39924. return
  39925. }
  39926. // IE textarea placeholder bug
  39927. /* istanbul ignore if */
  39928. if (isIE &&
  39929. currentParent.tag === 'textarea' &&
  39930. currentParent.attrsMap.placeholder === text
  39931. ) {
  39932. return
  39933. }
  39934. var children = currentParent.children;
  39935. text = inPre || text.trim()
  39936. ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
  39937. // only preserve whitespace if its not right after a starting tag
  39938. : preserveWhitespace && children.length ? ' ' : '';
  39939. if (text) {
  39940. var expression;
  39941. if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
  39942. children.push({
  39943. type: 2,
  39944. expression: expression,
  39945. text: text
  39946. });
  39947. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  39948. children.push({
  39949. type: 3,
  39950. text: text
  39951. });
  39952. }
  39953. }
  39954. }
  39955. });
  39956. return root
  39957. }
  39958. function processPre (el) {
  39959. if (getAndRemoveAttr(el, 'v-pre') != null) {
  39960. el.pre = true;
  39961. }
  39962. }
  39963. function processRawAttrs (el) {
  39964. var l = el.attrsList.length;
  39965. if (l) {
  39966. var attrs = el.attrs = new Array(l);
  39967. for (var i = 0; i < l; i++) {
  39968. attrs[i] = {
  39969. name: el.attrsList[i].name,
  39970. value: JSON.stringify(el.attrsList[i].value)
  39971. };
  39972. }
  39973. } else if (!el.pre) {
  39974. // non root node in pre blocks with no attributes
  39975. el.plain = true;
  39976. }
  39977. }
  39978. function processKey (el) {
  39979. var exp = getBindingAttr(el, 'key');
  39980. if (exp) {
  39981. if ("development" !== 'production' && el.tag === 'template') {
  39982. warn$2("<template> cannot be keyed. Place the key on real elements instead.");
  39983. }
  39984. el.key = exp;
  39985. }
  39986. }
  39987. function processRef (el) {
  39988. var ref = getBindingAttr(el, 'ref');
  39989. if (ref) {
  39990. el.ref = ref;
  39991. el.refInFor = checkInFor(el);
  39992. }
  39993. }
  39994. function processFor (el) {
  39995. var exp;
  39996. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  39997. var inMatch = exp.match(forAliasRE);
  39998. if (!inMatch) {
  39999. "development" !== 'production' && warn$2(
  40000. ("Invalid v-for expression: " + exp)
  40001. );
  40002. return
  40003. }
  40004. el.for = inMatch[2].trim();
  40005. var alias = inMatch[1].trim();
  40006. var iteratorMatch = alias.match(forIteratorRE);
  40007. if (iteratorMatch) {
  40008. el.alias = iteratorMatch[1].trim();
  40009. el.iterator1 = iteratorMatch[2].trim();
  40010. if (iteratorMatch[3]) {
  40011. el.iterator2 = iteratorMatch[3].trim();
  40012. }
  40013. } else {
  40014. el.alias = alias;
  40015. }
  40016. }
  40017. }
  40018. function processIf (el) {
  40019. var exp = getAndRemoveAttr(el, 'v-if');
  40020. if (exp) {
  40021. el.if = exp;
  40022. addIfCondition(el, {
  40023. exp: exp,
  40024. block: el
  40025. });
  40026. } else {
  40027. if (getAndRemoveAttr(el, 'v-else') != null) {
  40028. el.else = true;
  40029. }
  40030. var elseif = getAndRemoveAttr(el, 'v-else-if');
  40031. if (elseif) {
  40032. el.elseif = elseif;
  40033. }
  40034. }
  40035. }
  40036. function processIfConditions (el, parent) {
  40037. var prev = findPrevElement(parent.children);
  40038. if (prev && prev.if) {
  40039. addIfCondition(prev, {
  40040. exp: el.elseif,
  40041. block: el
  40042. });
  40043. } else if (true) {
  40044. warn$2(
  40045. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  40046. "used on element <" + (el.tag) + "> without corresponding v-if."
  40047. );
  40048. }
  40049. }
  40050. function findPrevElement (children) {
  40051. var i = children.length;
  40052. while (i--) {
  40053. if (children[i].type === 1) {
  40054. return children[i]
  40055. } else {
  40056. if ("development" !== 'production' && children[i].text !== ' ') {
  40057. warn$2(
  40058. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  40059. "will be ignored."
  40060. );
  40061. }
  40062. children.pop();
  40063. }
  40064. }
  40065. }
  40066. function addIfCondition (el, condition) {
  40067. if (!el.ifConditions) {
  40068. el.ifConditions = [];
  40069. }
  40070. el.ifConditions.push(condition);
  40071. }
  40072. function processOnce (el) {
  40073. var once$$1 = getAndRemoveAttr(el, 'v-once');
  40074. if (once$$1 != null) {
  40075. el.once = true;
  40076. }
  40077. }
  40078. function processSlot (el) {
  40079. if (el.tag === 'slot') {
  40080. el.slotName = getBindingAttr(el, 'name');
  40081. if ("development" !== 'production' && el.key) {
  40082. warn$2(
  40083. "`key` does not work on <slot> because slots are abstract outlets " +
  40084. "and can possibly expand into multiple elements. " +
  40085. "Use the key on a wrapping element instead."
  40086. );
  40087. }
  40088. } else {
  40089. var slotTarget = getBindingAttr(el, 'slot');
  40090. if (slotTarget) {
  40091. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  40092. }
  40093. if (el.tag === 'template') {
  40094. el.slotScope = getAndRemoveAttr(el, 'scope');
  40095. }
  40096. }
  40097. }
  40098. function processComponent (el) {
  40099. var binding;
  40100. if ((binding = getBindingAttr(el, 'is'))) {
  40101. el.component = binding;
  40102. }
  40103. if (getAndRemoveAttr(el, 'inline-template') != null) {
  40104. el.inlineTemplate = true;
  40105. }
  40106. }
  40107. function processAttrs (el) {
  40108. var list = el.attrsList;
  40109. var i, l, name, rawName, value, modifiers, isProp;
  40110. for (i = 0, l = list.length; i < l; i++) {
  40111. name = rawName = list[i].name;
  40112. value = list[i].value;
  40113. if (dirRE.test(name)) {
  40114. // mark element as dynamic
  40115. el.hasBindings = true;
  40116. // modifiers
  40117. modifiers = parseModifiers(name);
  40118. if (modifiers) {
  40119. name = name.replace(modifierRE, '');
  40120. }
  40121. if (bindRE.test(name)) { // v-bind
  40122. name = name.replace(bindRE, '');
  40123. value = parseFilters(value);
  40124. isProp = false;
  40125. if (modifiers) {
  40126. if (modifiers.prop) {
  40127. isProp = true;
  40128. name = camelize(name);
  40129. if (name === 'innerHtml') { name = 'innerHTML'; }
  40130. }
  40131. if (modifiers.camel) {
  40132. name = camelize(name);
  40133. }
  40134. if (modifiers.sync) {
  40135. addHandler(
  40136. el,
  40137. ("update:" + (camelize(name))),
  40138. genAssignmentCode(value, "$event")
  40139. );
  40140. }
  40141. }
  40142. if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  40143. addProp(el, name, value);
  40144. } else {
  40145. addAttr(el, name, value);
  40146. }
  40147. } else if (onRE.test(name)) { // v-on
  40148. name = name.replace(onRE, '');
  40149. addHandler(el, name, value, modifiers, false, warn$2);
  40150. } else { // normal directives
  40151. name = name.replace(dirRE, '');
  40152. // parse arg
  40153. var argMatch = name.match(argRE);
  40154. var arg = argMatch && argMatch[1];
  40155. if (arg) {
  40156. name = name.slice(0, -(arg.length + 1));
  40157. }
  40158. addDirective(el, name, rawName, value, arg, modifiers);
  40159. if ("development" !== 'production' && name === 'model') {
  40160. checkForAliasModel(el, value);
  40161. }
  40162. }
  40163. } else {
  40164. // literal attribute
  40165. if (true) {
  40166. var expression = parseText(value, delimiters);
  40167. if (expression) {
  40168. warn$2(
  40169. name + "=\"" + value + "\": " +
  40170. 'Interpolation inside attributes has been removed. ' +
  40171. 'Use v-bind or the colon shorthand instead. For example, ' +
  40172. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  40173. );
  40174. }
  40175. }
  40176. addAttr(el, name, JSON.stringify(value));
  40177. }
  40178. }
  40179. }
  40180. function checkInFor (el) {
  40181. var parent = el;
  40182. while (parent) {
  40183. if (parent.for !== undefined) {
  40184. return true
  40185. }
  40186. parent = parent.parent;
  40187. }
  40188. return false
  40189. }
  40190. function parseModifiers (name) {
  40191. var match = name.match(modifierRE);
  40192. if (match) {
  40193. var ret = {};
  40194. match.forEach(function (m) { ret[m.slice(1)] = true; });
  40195. return ret
  40196. }
  40197. }
  40198. function makeAttrsMap (attrs) {
  40199. var map = {};
  40200. for (var i = 0, l = attrs.length; i < l; i++) {
  40201. if (
  40202. "development" !== 'production' &&
  40203. map[attrs[i].name] && !isIE && !isEdge
  40204. ) {
  40205. warn$2('duplicate attribute: ' + attrs[i].name);
  40206. }
  40207. map[attrs[i].name] = attrs[i].value;
  40208. }
  40209. return map
  40210. }
  40211. // for script (e.g. type="x/template") or style, do not decode content
  40212. function isTextTag (el) {
  40213. return el.tag === 'script' || el.tag === 'style'
  40214. }
  40215. function isForbiddenTag (el) {
  40216. return (
  40217. el.tag === 'style' ||
  40218. (el.tag === 'script' && (
  40219. !el.attrsMap.type ||
  40220. el.attrsMap.type === 'text/javascript'
  40221. ))
  40222. )
  40223. }
  40224. var ieNSBug = /^xmlns:NS\d+/;
  40225. var ieNSPrefix = /^NS\d+:/;
  40226. /* istanbul ignore next */
  40227. function guardIESVGBug (attrs) {
  40228. var res = [];
  40229. for (var i = 0; i < attrs.length; i++) {
  40230. var attr = attrs[i];
  40231. if (!ieNSBug.test(attr.name)) {
  40232. attr.name = attr.name.replace(ieNSPrefix, '');
  40233. res.push(attr);
  40234. }
  40235. }
  40236. return res
  40237. }
  40238. function checkForAliasModel (el, value) {
  40239. var _el = el;
  40240. while (_el) {
  40241. if (_el.for && _el.alias === value) {
  40242. warn$2(
  40243. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  40244. "You are binding v-model directly to a v-for iteration alias. " +
  40245. "This will not be able to modify the v-for source array because " +
  40246. "writing to the alias is like modifying a function local variable. " +
  40247. "Consider using an array of objects and use v-model on an object property instead."
  40248. );
  40249. }
  40250. _el = _el.parent;
  40251. }
  40252. }
  40253. /* */
  40254. var isStaticKey;
  40255. var isPlatformReservedTag;
  40256. var genStaticKeysCached = cached(genStaticKeys$1);
  40257. /**
  40258. * Goal of the optimizer: walk the generated template AST tree
  40259. * and detect sub-trees that are purely static, i.e. parts of
  40260. * the DOM that never needs to change.
  40261. *
  40262. * Once we detect these sub-trees, we can:
  40263. *
  40264. * 1. Hoist them into constants, so that we no longer need to
  40265. * create fresh nodes for them on each re-render;
  40266. * 2. Completely skip them in the patching process.
  40267. */
  40268. function optimize (root, options) {
  40269. if (!root) { return }
  40270. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  40271. isPlatformReservedTag = options.isReservedTag || no;
  40272. // first pass: mark all non-static nodes.
  40273. markStatic$1(root);
  40274. // second pass: mark static roots.
  40275. markStaticRoots(root, false);
  40276. }
  40277. function genStaticKeys$1 (keys) {
  40278. return makeMap(
  40279. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  40280. (keys ? ',' + keys : '')
  40281. )
  40282. }
  40283. function markStatic$1 (node) {
  40284. node.static = isStatic(node);
  40285. if (node.type === 1) {
  40286. // do not make component slot content static. this avoids
  40287. // 1. components not able to mutate slot nodes
  40288. // 2. static slot content fails for hot-reloading
  40289. if (
  40290. !isPlatformReservedTag(node.tag) &&
  40291. node.tag !== 'slot' &&
  40292. node.attrsMap['inline-template'] == null
  40293. ) {
  40294. return
  40295. }
  40296. for (var i = 0, l = node.children.length; i < l; i++) {
  40297. var child = node.children[i];
  40298. markStatic$1(child);
  40299. if (!child.static) {
  40300. node.static = false;
  40301. }
  40302. }
  40303. }
  40304. }
  40305. function markStaticRoots (node, isInFor) {
  40306. if (node.type === 1) {
  40307. if (node.static || node.once) {
  40308. node.staticInFor = isInFor;
  40309. }
  40310. // For a node to qualify as a static root, it should have children that
  40311. // are not just static text. Otherwise the cost of hoisting out will
  40312. // outweigh the benefits and it's better off to just always render it fresh.
  40313. if (node.static && node.children.length && !(
  40314. node.children.length === 1 &&
  40315. node.children[0].type === 3
  40316. )) {
  40317. node.staticRoot = true;
  40318. return
  40319. } else {
  40320. node.staticRoot = false;
  40321. }
  40322. if (node.children) {
  40323. for (var i = 0, l = node.children.length; i < l; i++) {
  40324. markStaticRoots(node.children[i], isInFor || !!node.for);
  40325. }
  40326. }
  40327. if (node.ifConditions) {
  40328. walkThroughConditionsBlocks(node.ifConditions, isInFor);
  40329. }
  40330. }
  40331. }
  40332. function walkThroughConditionsBlocks (conditionBlocks, isInFor) {
  40333. for (var i = 1, len = conditionBlocks.length; i < len; i++) {
  40334. markStaticRoots(conditionBlocks[i].block, isInFor);
  40335. }
  40336. }
  40337. function isStatic (node) {
  40338. if (node.type === 2) { // expression
  40339. return false
  40340. }
  40341. if (node.type === 3) { // text
  40342. return true
  40343. }
  40344. return !!(node.pre || (
  40345. !node.hasBindings && // no dynamic bindings
  40346. !node.if && !node.for && // not v-if or v-for or v-else
  40347. !isBuiltInTag(node.tag) && // not a built-in
  40348. isPlatformReservedTag(node.tag) && // not a component
  40349. !isDirectChildOfTemplateFor(node) &&
  40350. Object.keys(node).every(isStaticKey)
  40351. ))
  40352. }
  40353. function isDirectChildOfTemplateFor (node) {
  40354. while (node.parent) {
  40355. node = node.parent;
  40356. if (node.tag !== 'template') {
  40357. return false
  40358. }
  40359. if (node.for) {
  40360. return true
  40361. }
  40362. }
  40363. return false
  40364. }
  40365. /* */
  40366. var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  40367. var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
  40368. // keyCode aliases
  40369. var keyCodes = {
  40370. esc: 27,
  40371. tab: 9,
  40372. enter: 13,
  40373. space: 32,
  40374. up: 38,
  40375. left: 37,
  40376. right: 39,
  40377. down: 40,
  40378. 'delete': [8, 46]
  40379. };
  40380. // #4868: modifiers that prevent the execution of the listener
  40381. // need to explicitly return null so that we can determine whether to remove
  40382. // the listener for .once
  40383. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  40384. var modifierCode = {
  40385. stop: '$event.stopPropagation();',
  40386. prevent: '$event.preventDefault();',
  40387. self: genGuard("$event.target !== $event.currentTarget"),
  40388. ctrl: genGuard("!$event.ctrlKey"),
  40389. shift: genGuard("!$event.shiftKey"),
  40390. alt: genGuard("!$event.altKey"),
  40391. meta: genGuard("!$event.metaKey"),
  40392. left: genGuard("'button' in $event && $event.button !== 0"),
  40393. middle: genGuard("'button' in $event && $event.button !== 1"),
  40394. right: genGuard("'button' in $event && $event.button !== 2")
  40395. };
  40396. function genHandlers (
  40397. events,
  40398. isNative,
  40399. warn
  40400. ) {
  40401. var res = isNative ? 'nativeOn:{' : 'on:{';
  40402. for (var name in events) {
  40403. var handler = events[name];
  40404. // #5330: warn click.right, since right clicks do not actually fire click events.
  40405. if ("development" !== 'production' &&
  40406. name === 'click' &&
  40407. handler && handler.modifiers && handler.modifiers.right
  40408. ) {
  40409. warn(
  40410. "Use \"contextmenu\" instead of \"click.right\" since right clicks " +
  40411. "do not actually fire \"click\" events."
  40412. );
  40413. }
  40414. res += "\"" + name + "\":" + (genHandler(name, handler)) + ",";
  40415. }
  40416. return res.slice(0, -1) + '}'
  40417. }
  40418. function genHandler (
  40419. name,
  40420. handler
  40421. ) {
  40422. if (!handler) {
  40423. return 'function(){}'
  40424. }
  40425. if (Array.isArray(handler)) {
  40426. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  40427. }
  40428. var isMethodPath = simplePathRE.test(handler.value);
  40429. var isFunctionExpression = fnExpRE.test(handler.value);
  40430. if (!handler.modifiers) {
  40431. return isMethodPath || isFunctionExpression
  40432. ? handler.value
  40433. : ("function($event){" + (handler.value) + "}") // inline statement
  40434. } else {
  40435. var code = '';
  40436. var genModifierCode = '';
  40437. var keys = [];
  40438. for (var key in handler.modifiers) {
  40439. if (modifierCode[key]) {
  40440. genModifierCode += modifierCode[key];
  40441. // left/right
  40442. if (keyCodes[key]) {
  40443. keys.push(key);
  40444. }
  40445. } else {
  40446. keys.push(key);
  40447. }
  40448. }
  40449. if (keys.length) {
  40450. code += genKeyFilter(keys);
  40451. }
  40452. // Make sure modifiers like prevent and stop get executed after key filtering
  40453. if (genModifierCode) {
  40454. code += genModifierCode;
  40455. }
  40456. var handlerCode = isMethodPath
  40457. ? handler.value + '($event)'
  40458. : isFunctionExpression
  40459. ? ("(" + (handler.value) + ")($event)")
  40460. : handler.value;
  40461. return ("function($event){" + code + handlerCode + "}")
  40462. }
  40463. }
  40464. function genKeyFilter (keys) {
  40465. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  40466. }
  40467. function genFilterCode (key) {
  40468. var keyVal = parseInt(key, 10);
  40469. if (keyVal) {
  40470. return ("$event.keyCode!==" + keyVal)
  40471. }
  40472. var alias = keyCodes[key];
  40473. return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
  40474. }
  40475. /* */
  40476. function bind$1 (el, dir) {
  40477. el.wrapData = function (code) {
  40478. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")")
  40479. };
  40480. }
  40481. /* */
  40482. var baseDirectives = {
  40483. bind: bind$1,
  40484. cloak: noop
  40485. };
  40486. /* */
  40487. // configurable state
  40488. var warn$3;
  40489. var transforms$1;
  40490. var dataGenFns;
  40491. var platformDirectives$1;
  40492. var isPlatformReservedTag$1;
  40493. var staticRenderFns;
  40494. var onceCount;
  40495. var currentOptions;
  40496. function generate (
  40497. ast,
  40498. options
  40499. ) {
  40500. // save previous staticRenderFns so generate calls can be nested
  40501. var prevStaticRenderFns = staticRenderFns;
  40502. var currentStaticRenderFns = staticRenderFns = [];
  40503. var prevOnceCount = onceCount;
  40504. onceCount = 0;
  40505. currentOptions = options;
  40506. warn$3 = options.warn || baseWarn;
  40507. transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
  40508. dataGenFns = pluckModuleFunction(options.modules, 'genData');
  40509. platformDirectives$1 = options.directives || {};
  40510. isPlatformReservedTag$1 = options.isReservedTag || no;
  40511. var code = ast ? genElement(ast) : '_c("div")';
  40512. staticRenderFns = prevStaticRenderFns;
  40513. onceCount = prevOnceCount;
  40514. return {
  40515. render: ("with(this){return " + code + "}"),
  40516. staticRenderFns: currentStaticRenderFns
  40517. }
  40518. }
  40519. function genElement (el) {
  40520. if (el.staticRoot && !el.staticProcessed) {
  40521. return genStatic(el)
  40522. } else if (el.once && !el.onceProcessed) {
  40523. return genOnce(el)
  40524. } else if (el.for && !el.forProcessed) {
  40525. return genFor(el)
  40526. } else if (el.if && !el.ifProcessed) {
  40527. return genIf(el)
  40528. } else if (el.tag === 'template' && !el.slotTarget) {
  40529. return genChildren(el) || 'void 0'
  40530. } else if (el.tag === 'slot') {
  40531. return genSlot(el)
  40532. } else {
  40533. // component or element
  40534. var code;
  40535. if (el.component) {
  40536. code = genComponent(el.component, el);
  40537. } else {
  40538. var data = el.plain ? undefined : genData(el);
  40539. var children = el.inlineTemplate ? null : genChildren(el, true);
  40540. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  40541. }
  40542. // module transforms
  40543. for (var i = 0; i < transforms$1.length; i++) {
  40544. code = transforms$1[i](el, code);
  40545. }
  40546. return code
  40547. }
  40548. }
  40549. // hoist static sub-trees out
  40550. function genStatic (el) {
  40551. el.staticProcessed = true;
  40552. staticRenderFns.push(("with(this){return " + (genElement(el)) + "}"));
  40553. return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  40554. }
  40555. // v-once
  40556. function genOnce (el) {
  40557. el.onceProcessed = true;
  40558. if (el.if && !el.ifProcessed) {
  40559. return genIf(el)
  40560. } else if (el.staticInFor) {
  40561. var key = '';
  40562. var parent = el.parent;
  40563. while (parent) {
  40564. if (parent.for) {
  40565. key = parent.key;
  40566. break
  40567. }
  40568. parent = parent.parent;
  40569. }
  40570. if (!key) {
  40571. "development" !== 'production' && warn$3(
  40572. "v-once can only be used inside v-for that is keyed. "
  40573. );
  40574. return genElement(el)
  40575. }
  40576. return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")")
  40577. } else {
  40578. return genStatic(el)
  40579. }
  40580. }
  40581. function genIf (el) {
  40582. el.ifProcessed = true; // avoid recursion
  40583. return genIfConditions(el.ifConditions.slice())
  40584. }
  40585. function genIfConditions (conditions) {
  40586. if (!conditions.length) {
  40587. return '_e()'
  40588. }
  40589. var condition = conditions.shift();
  40590. if (condition.exp) {
  40591. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions)))
  40592. } else {
  40593. return ("" + (genTernaryExp(condition.block)))
  40594. }
  40595. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  40596. function genTernaryExp (el) {
  40597. return el.once ? genOnce(el) : genElement(el)
  40598. }
  40599. }
  40600. function genFor (el) {
  40601. var exp = el.for;
  40602. var alias = el.alias;
  40603. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  40604. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  40605. if (
  40606. "development" !== 'production' &&
  40607. maybeComponent(el) && el.tag !== 'slot' && el.tag !== 'template' && !el.key
  40608. ) {
  40609. warn$3(
  40610. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  40611. "v-for should have explicit keys. " +
  40612. "See https://vuejs.org/guide/list.html#key for more info.",
  40613. true /* tip */
  40614. );
  40615. }
  40616. el.forProcessed = true; // avoid recursion
  40617. return "_l((" + exp + ")," +
  40618. "function(" + alias + iterator1 + iterator2 + "){" +
  40619. "return " + (genElement(el)) +
  40620. '})'
  40621. }
  40622. function genData (el) {
  40623. var data = '{';
  40624. // directives first.
  40625. // directives may mutate the el's other properties before they are generated.
  40626. var dirs = genDirectives(el);
  40627. if (dirs) { data += dirs + ','; }
  40628. // key
  40629. if (el.key) {
  40630. data += "key:" + (el.key) + ",";
  40631. }
  40632. // ref
  40633. if (el.ref) {
  40634. data += "ref:" + (el.ref) + ",";
  40635. }
  40636. if (el.refInFor) {
  40637. data += "refInFor:true,";
  40638. }
  40639. // pre
  40640. if (el.pre) {
  40641. data += "pre:true,";
  40642. }
  40643. // record original tag name for components using "is" attribute
  40644. if (el.component) {
  40645. data += "tag:\"" + (el.tag) + "\",";
  40646. }
  40647. // module data generation functions
  40648. for (var i = 0; i < dataGenFns.length; i++) {
  40649. data += dataGenFns[i](el);
  40650. }
  40651. // attributes
  40652. if (el.attrs) {
  40653. data += "attrs:{" + (genProps(el.attrs)) + "},";
  40654. }
  40655. // DOM props
  40656. if (el.props) {
  40657. data += "domProps:{" + (genProps(el.props)) + "},";
  40658. }
  40659. // event handlers
  40660. if (el.events) {
  40661. data += (genHandlers(el.events, false, warn$3)) + ",";
  40662. }
  40663. if (el.nativeEvents) {
  40664. data += (genHandlers(el.nativeEvents, true, warn$3)) + ",";
  40665. }
  40666. // slot target
  40667. if (el.slotTarget) {
  40668. data += "slot:" + (el.slotTarget) + ",";
  40669. }
  40670. // scoped slots
  40671. if (el.scopedSlots) {
  40672. data += (genScopedSlots(el.scopedSlots)) + ",";
  40673. }
  40674. // component v-model
  40675. if (el.model) {
  40676. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  40677. }
  40678. // inline-template
  40679. if (el.inlineTemplate) {
  40680. var inlineTemplate = genInlineTemplate(el);
  40681. if (inlineTemplate) {
  40682. data += inlineTemplate + ",";
  40683. }
  40684. }
  40685. data = data.replace(/,$/, '') + '}';
  40686. // v-bind data wrap
  40687. if (el.wrapData) {
  40688. data = el.wrapData(data);
  40689. }
  40690. return data
  40691. }
  40692. function genDirectives (el) {
  40693. var dirs = el.directives;
  40694. if (!dirs) { return }
  40695. var res = 'directives:[';
  40696. var hasRuntime = false;
  40697. var i, l, dir, needRuntime;
  40698. for (i = 0, l = dirs.length; i < l; i++) {
  40699. dir = dirs[i];
  40700. needRuntime = true;
  40701. var gen = platformDirectives$1[dir.name] || baseDirectives[dir.name];
  40702. if (gen) {
  40703. // compile-time directive that manipulates AST.
  40704. // returns true if it also needs a runtime counterpart.
  40705. needRuntime = !!gen(el, dir, warn$3);
  40706. }
  40707. if (needRuntime) {
  40708. hasRuntime = true;
  40709. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  40710. }
  40711. }
  40712. if (hasRuntime) {
  40713. return res.slice(0, -1) + ']'
  40714. }
  40715. }
  40716. function genInlineTemplate (el) {
  40717. var ast = el.children[0];
  40718. if ("development" !== 'production' && (
  40719. el.children.length > 1 || ast.type !== 1
  40720. )) {
  40721. warn$3('Inline-template components must have exactly one child element.');
  40722. }
  40723. if (ast.type === 1) {
  40724. var inlineRenderFns = generate(ast, currentOptions);
  40725. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  40726. }
  40727. }
  40728. function genScopedSlots (slots) {
  40729. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "])")
  40730. }
  40731. function genScopedSlot (key, el) {
  40732. if (el.for && !el.forProcessed) {
  40733. return genForScopedSlot(key, el)
  40734. }
  40735. return "{key:" + key + ",fn:function(" + (String(el.attrsMap.scope)) + "){" +
  40736. "return " + (el.tag === 'template'
  40737. ? genChildren(el) || 'void 0'
  40738. : genElement(el)) + "}}"
  40739. }
  40740. function genForScopedSlot (key, el) {
  40741. var exp = el.for;
  40742. var alias = el.alias;
  40743. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  40744. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  40745. el.forProcessed = true; // avoid recursion
  40746. return "_l((" + exp + ")," +
  40747. "function(" + alias + iterator1 + iterator2 + "){" +
  40748. "return " + (genScopedSlot(key, el)) +
  40749. '})'
  40750. }
  40751. function genChildren (el, checkSkip) {
  40752. var children = el.children;
  40753. if (children.length) {
  40754. var el$1 = children[0];
  40755. // optimize single v-for
  40756. if (children.length === 1 &&
  40757. el$1.for &&
  40758. el$1.tag !== 'template' &&
  40759. el$1.tag !== 'slot'
  40760. ) {
  40761. return genElement(el$1)
  40762. }
  40763. var normalizationType = checkSkip ? getNormalizationType(children) : 0;
  40764. return ("[" + (children.map(genNode).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
  40765. }
  40766. }
  40767. // determine the normalization needed for the children array.
  40768. // 0: no normalization needed
  40769. // 1: simple normalization needed (possible 1-level deep nested array)
  40770. // 2: full normalization needed
  40771. function getNormalizationType (children) {
  40772. var res = 0;
  40773. for (var i = 0; i < children.length; i++) {
  40774. var el = children[i];
  40775. if (el.type !== 1) {
  40776. continue
  40777. }
  40778. if (needsNormalization(el) ||
  40779. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  40780. res = 2;
  40781. break
  40782. }
  40783. if (maybeComponent(el) ||
  40784. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  40785. res = 1;
  40786. }
  40787. }
  40788. return res
  40789. }
  40790. function needsNormalization (el) {
  40791. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  40792. }
  40793. function maybeComponent (el) {
  40794. return !isPlatformReservedTag$1(el.tag)
  40795. }
  40796. function genNode (node) {
  40797. if (node.type === 1) {
  40798. return genElement(node)
  40799. } else {
  40800. return genText(node)
  40801. }
  40802. }
  40803. function genText (text) {
  40804. return ("_v(" + (text.type === 2
  40805. ? text.expression // no need for () because already wrapped in _s()
  40806. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  40807. }
  40808. function genSlot (el) {
  40809. var slotName = el.slotName || '"default"';
  40810. var children = genChildren(el);
  40811. var res = "_t(" + slotName + (children ? ("," + children) : '');
  40812. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  40813. var bind$$1 = el.attrsMap['v-bind'];
  40814. if ((attrs || bind$$1) && !children) {
  40815. res += ",null";
  40816. }
  40817. if (attrs) {
  40818. res += "," + attrs;
  40819. }
  40820. if (bind$$1) {
  40821. res += (attrs ? '' : ',null') + "," + bind$$1;
  40822. }
  40823. return res + ')'
  40824. }
  40825. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  40826. function genComponent (componentName, el) {
  40827. var children = el.inlineTemplate ? null : genChildren(el, true);
  40828. return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")")
  40829. }
  40830. function genProps (props) {
  40831. var res = '';
  40832. for (var i = 0; i < props.length; i++) {
  40833. var prop = props[i];
  40834. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  40835. }
  40836. return res.slice(0, -1)
  40837. }
  40838. // #3895, #4268
  40839. function transformSpecialNewlines (text) {
  40840. return text
  40841. .replace(/\u2028/g, '\\u2028')
  40842. .replace(/\u2029/g, '\\u2029')
  40843. }
  40844. /* */
  40845. // these keywords should not appear inside expressions, but operators like
  40846. // typeof, instanceof and in are allowed
  40847. var prohibitedKeywordRE = new RegExp('\\b' + (
  40848. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  40849. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  40850. 'extends,finally,continue,debugger,function,arguments'
  40851. ).split(',').join('\\b|\\b') + '\\b');
  40852. // these unary operators should not be used as property/method names
  40853. var unaryOperatorsRE = new RegExp('\\b' + (
  40854. 'delete,typeof,void'
  40855. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  40856. // check valid identifier for v-for
  40857. var identRE = /[A-Za-z_$][\w$]*/;
  40858. // strip strings in expressions
  40859. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  40860. // detect problematic expressions in a template
  40861. function detectErrors (ast) {
  40862. var errors = [];
  40863. if (ast) {
  40864. checkNode(ast, errors);
  40865. }
  40866. return errors
  40867. }
  40868. function checkNode (node, errors) {
  40869. if (node.type === 1) {
  40870. for (var name in node.attrsMap) {
  40871. if (dirRE.test(name)) {
  40872. var value = node.attrsMap[name];
  40873. if (value) {
  40874. if (name === 'v-for') {
  40875. checkFor(node, ("v-for=\"" + value + "\""), errors);
  40876. } else if (onRE.test(name)) {
  40877. checkEvent(value, (name + "=\"" + value + "\""), errors);
  40878. } else {
  40879. checkExpression(value, (name + "=\"" + value + "\""), errors);
  40880. }
  40881. }
  40882. }
  40883. }
  40884. if (node.children) {
  40885. for (var i = 0; i < node.children.length; i++) {
  40886. checkNode(node.children[i], errors);
  40887. }
  40888. }
  40889. } else if (node.type === 2) {
  40890. checkExpression(node.expression, node.text, errors);
  40891. }
  40892. }
  40893. function checkEvent (exp, text, errors) {
  40894. var stipped = exp.replace(stripStringRE, '');
  40895. var keywordMatch = stipped.match(unaryOperatorsRE);
  40896. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  40897. errors.push(
  40898. "avoid using JavaScript unary operator as property name: " +
  40899. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  40900. );
  40901. }
  40902. checkExpression(exp, text, errors);
  40903. }
  40904. function checkFor (node, text, errors) {
  40905. checkExpression(node.for || '', text, errors);
  40906. checkIdentifier(node.alias, 'v-for alias', text, errors);
  40907. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  40908. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  40909. }
  40910. function checkIdentifier (ident, type, text, errors) {
  40911. if (typeof ident === 'string' && !identRE.test(ident)) {
  40912. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  40913. }
  40914. }
  40915. function checkExpression (exp, text, errors) {
  40916. try {
  40917. new Function(("return " + exp));
  40918. } catch (e) {
  40919. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  40920. if (keywordMatch) {
  40921. errors.push(
  40922. "avoid using JavaScript keyword as property name: " +
  40923. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  40924. );
  40925. } else {
  40926. errors.push(("invalid expression: " + (text.trim())));
  40927. }
  40928. }
  40929. }
  40930. /* */
  40931. function baseCompile (
  40932. template,
  40933. options
  40934. ) {
  40935. var ast = parse(template.trim(), options);
  40936. optimize(ast, options);
  40937. var code = generate(ast, options);
  40938. return {
  40939. ast: ast,
  40940. render: code.render,
  40941. staticRenderFns: code.staticRenderFns
  40942. }
  40943. }
  40944. function makeFunction (code, errors) {
  40945. try {
  40946. return new Function(code)
  40947. } catch (err) {
  40948. errors.push({ err: err, code: code });
  40949. return noop
  40950. }
  40951. }
  40952. function createCompiler (baseOptions) {
  40953. var functionCompileCache = Object.create(null);
  40954. function compile (
  40955. template,
  40956. options
  40957. ) {
  40958. var finalOptions = Object.create(baseOptions);
  40959. var errors = [];
  40960. var tips = [];
  40961. finalOptions.warn = function (msg, tip$$1) {
  40962. (tip$$1 ? tips : errors).push(msg);
  40963. };
  40964. if (options) {
  40965. // merge custom modules
  40966. if (options.modules) {
  40967. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  40968. }
  40969. // merge custom directives
  40970. if (options.directives) {
  40971. finalOptions.directives = extend(
  40972. Object.create(baseOptions.directives),
  40973. options.directives
  40974. );
  40975. }
  40976. // copy other options
  40977. for (var key in options) {
  40978. if (key !== 'modules' && key !== 'directives') {
  40979. finalOptions[key] = options[key];
  40980. }
  40981. }
  40982. }
  40983. var compiled = baseCompile(template, finalOptions);
  40984. if (true) {
  40985. errors.push.apply(errors, detectErrors(compiled.ast));
  40986. }
  40987. compiled.errors = errors;
  40988. compiled.tips = tips;
  40989. return compiled
  40990. }
  40991. function compileToFunctions (
  40992. template,
  40993. options,
  40994. vm
  40995. ) {
  40996. options = options || {};
  40997. /* istanbul ignore if */
  40998. if (true) {
  40999. // detect possible CSP restriction
  41000. try {
  41001. new Function('return 1');
  41002. } catch (e) {
  41003. if (e.toString().match(/unsafe-eval|CSP/)) {
  41004. warn(
  41005. 'It seems you are using the standalone build of Vue.js in an ' +
  41006. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  41007. 'The template compiler cannot work in this environment. Consider ' +
  41008. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  41009. 'templates into render functions.'
  41010. );
  41011. }
  41012. }
  41013. }
  41014. // check cache
  41015. var key = options.delimiters
  41016. ? String(options.delimiters) + template
  41017. : template;
  41018. if (functionCompileCache[key]) {
  41019. return functionCompileCache[key]
  41020. }
  41021. // compile
  41022. var compiled = compile(template, options);
  41023. // check compilation errors/tips
  41024. if (true) {
  41025. if (compiled.errors && compiled.errors.length) {
  41026. warn(
  41027. "Error compiling template:\n\n" + template + "\n\n" +
  41028. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  41029. vm
  41030. );
  41031. }
  41032. if (compiled.tips && compiled.tips.length) {
  41033. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  41034. }
  41035. }
  41036. // turn code into functions
  41037. var res = {};
  41038. var fnGenErrors = [];
  41039. res.render = makeFunction(compiled.render, fnGenErrors);
  41040. var l = compiled.staticRenderFns.length;
  41041. res.staticRenderFns = new Array(l);
  41042. for (var i = 0; i < l; i++) {
  41043. res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors);
  41044. }
  41045. // check function generation errors.
  41046. // this should only happen if there is a bug in the compiler itself.
  41047. // mostly for codegen development use
  41048. /* istanbul ignore if */
  41049. if (true) {
  41050. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  41051. warn(
  41052. "Failed to generate render function:\n\n" +
  41053. fnGenErrors.map(function (ref) {
  41054. var err = ref.err;
  41055. var code = ref.code;
  41056. return ((err.toString()) + " in\n\n" + code + "\n");
  41057. }).join('\n'),
  41058. vm
  41059. );
  41060. }
  41061. }
  41062. return (functionCompileCache[key] = res)
  41063. }
  41064. return {
  41065. compile: compile,
  41066. compileToFunctions: compileToFunctions
  41067. }
  41068. }
  41069. /* */
  41070. function transformNode (el, options) {
  41071. var warn = options.warn || baseWarn;
  41072. var staticClass = getAndRemoveAttr(el, 'class');
  41073. if ("development" !== 'production' && staticClass) {
  41074. var expression = parseText(staticClass, options.delimiters);
  41075. if (expression) {
  41076. warn(
  41077. "class=\"" + staticClass + "\": " +
  41078. 'Interpolation inside attributes has been removed. ' +
  41079. 'Use v-bind or the colon shorthand instead. For example, ' +
  41080. 'instead of <div class="{{ val }}">, use <div :class="val">.'
  41081. );
  41082. }
  41083. }
  41084. if (staticClass) {
  41085. el.staticClass = JSON.stringify(staticClass);
  41086. }
  41087. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  41088. if (classBinding) {
  41089. el.classBinding = classBinding;
  41090. }
  41091. }
  41092. function genData$1 (el) {
  41093. var data = '';
  41094. if (el.staticClass) {
  41095. data += "staticClass:" + (el.staticClass) + ",";
  41096. }
  41097. if (el.classBinding) {
  41098. data += "class:" + (el.classBinding) + ",";
  41099. }
  41100. return data
  41101. }
  41102. var klass$1 = {
  41103. staticKeys: ['staticClass'],
  41104. transformNode: transformNode,
  41105. genData: genData$1
  41106. };
  41107. /* */
  41108. function transformNode$1 (el, options) {
  41109. var warn = options.warn || baseWarn;
  41110. var staticStyle = getAndRemoveAttr(el, 'style');
  41111. if (staticStyle) {
  41112. /* istanbul ignore if */
  41113. if (true) {
  41114. var expression = parseText(staticStyle, options.delimiters);
  41115. if (expression) {
  41116. warn(
  41117. "style=\"" + staticStyle + "\": " +
  41118. 'Interpolation inside attributes has been removed. ' +
  41119. 'Use v-bind or the colon shorthand instead. For example, ' +
  41120. 'instead of <div style="{{ val }}">, use <div :style="val">.'
  41121. );
  41122. }
  41123. }
  41124. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  41125. }
  41126. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  41127. if (styleBinding) {
  41128. el.styleBinding = styleBinding;
  41129. }
  41130. }
  41131. function genData$2 (el) {
  41132. var data = '';
  41133. if (el.staticStyle) {
  41134. data += "staticStyle:" + (el.staticStyle) + ",";
  41135. }
  41136. if (el.styleBinding) {
  41137. data += "style:(" + (el.styleBinding) + "),";
  41138. }
  41139. return data
  41140. }
  41141. var style$1 = {
  41142. staticKeys: ['staticStyle'],
  41143. transformNode: transformNode$1,
  41144. genData: genData$2
  41145. };
  41146. var modules$1 = [
  41147. klass$1,
  41148. style$1
  41149. ];
  41150. /* */
  41151. function text (el, dir) {
  41152. if (dir.value) {
  41153. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
  41154. }
  41155. }
  41156. /* */
  41157. function html (el, dir) {
  41158. if (dir.value) {
  41159. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
  41160. }
  41161. }
  41162. var directives$1 = {
  41163. model: model,
  41164. text: text,
  41165. html: html
  41166. };
  41167. /* */
  41168. var baseOptions = {
  41169. expectHTML: true,
  41170. modules: modules$1,
  41171. directives: directives$1,
  41172. isPreTag: isPreTag,
  41173. isUnaryTag: isUnaryTag,
  41174. mustUseProp: mustUseProp,
  41175. canBeLeftOpenTag: canBeLeftOpenTag,
  41176. isReservedTag: isReservedTag,
  41177. getTagNamespace: getTagNamespace,
  41178. staticKeys: genStaticKeys(modules$1)
  41179. };
  41180. var ref$1 = createCompiler(baseOptions);
  41181. var compileToFunctions = ref$1.compileToFunctions;
  41182. /* */
  41183. var idToTemplate = cached(function (id) {
  41184. var el = query(id);
  41185. return el && el.innerHTML
  41186. });
  41187. var mount = Vue$3.prototype.$mount;
  41188. Vue$3.prototype.$mount = function (
  41189. el,
  41190. hydrating
  41191. ) {
  41192. el = el && query(el);
  41193. /* istanbul ignore if */
  41194. if (el === document.body || el === document.documentElement) {
  41195. "development" !== 'production' && warn(
  41196. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  41197. );
  41198. return this
  41199. }
  41200. var options = this.$options;
  41201. // resolve template/el and convert to render function
  41202. if (!options.render) {
  41203. var template = options.template;
  41204. if (template) {
  41205. if (typeof template === 'string') {
  41206. if (template.charAt(0) === '#') {
  41207. template = idToTemplate(template);
  41208. /* istanbul ignore if */
  41209. if ("development" !== 'production' && !template) {
  41210. warn(
  41211. ("Template element not found or is empty: " + (options.template)),
  41212. this
  41213. );
  41214. }
  41215. }
  41216. } else if (template.nodeType) {
  41217. template = template.innerHTML;
  41218. } else {
  41219. if (true) {
  41220. warn('invalid template option:' + template, this);
  41221. }
  41222. return this
  41223. }
  41224. } else if (el) {
  41225. template = getOuterHTML(el);
  41226. }
  41227. if (template) {
  41228. /* istanbul ignore if */
  41229. if ("development" !== 'production' && config.performance && mark) {
  41230. mark('compile');
  41231. }
  41232. var ref = compileToFunctions(template, {
  41233. shouldDecodeNewlines: shouldDecodeNewlines,
  41234. delimiters: options.delimiters
  41235. }, this);
  41236. var render = ref.render;
  41237. var staticRenderFns = ref.staticRenderFns;
  41238. options.render = render;
  41239. options.staticRenderFns = staticRenderFns;
  41240. /* istanbul ignore if */
  41241. if ("development" !== 'production' && config.performance && mark) {
  41242. mark('compile end');
  41243. measure(((this._name) + " compile"), 'compile', 'compile end');
  41244. }
  41245. }
  41246. }
  41247. return mount.call(this, el, hydrating)
  41248. };
  41249. /**
  41250. * Get outerHTML of elements, taking care
  41251. * of SVG elements in IE as well.
  41252. */
  41253. function getOuterHTML (el) {
  41254. if (el.outerHTML) {
  41255. return el.outerHTML
  41256. } else {
  41257. var container = document.createElement('div');
  41258. container.appendChild(el.cloneNode(true));
  41259. return container.innerHTML
  41260. }
  41261. }
  41262. Vue$3.compile = compileToFunctions;
  41263. module.exports = Vue$3;
  41264. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
  41265. /***/ }),
  41266. /* 39 */
  41267. /***/ (function(module, exports, __webpack_require__) {
  41268. var disposed = false
  41269. var Component = __webpack_require__(8)(
  41270. /* script */
  41271. __webpack_require__(40),
  41272. /* template */
  41273. __webpack_require__(41),
  41274. /* styles */
  41275. null,
  41276. /* scopeId */
  41277. null,
  41278. /* moduleIdentifier (server only) */
  41279. null
  41280. )
  41281. Component.options.__file = "/Users/aaronpk/Code/spy30/resources/assets/js/components/Example.vue"
  41282. if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key.substr(0, 2) !== "__"})) {console.error("named exports are not supported in *.vue files.")}
  41283. if (Component.options.functional) {console.error("[vue-loader] Example.vue: functional components are not supported with templates, they should use render functions.")}
  41284. /* hot reload */
  41285. if (false) {(function () {
  41286. var hotAPI = require("vue-hot-reload-api")
  41287. hotAPI.install(require("vue"), false)
  41288. if (!hotAPI.compatible) return
  41289. module.hot.accept()
  41290. if (!module.hot.data) {
  41291. hotAPI.createRecord("data-v-ffb61a8e", Component.options)
  41292. } else {
  41293. hotAPI.reload("data-v-ffb61a8e", Component.options)
  41294. }
  41295. module.hot.dispose(function (data) {
  41296. disposed = true
  41297. })
  41298. })()}
  41299. module.exports = Component.exports
  41300. /***/ }),
  41301. /* 40 */
  41302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41303. "use strict";
  41304. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  41305. //
  41306. //
  41307. //
  41308. //
  41309. //
  41310. //
  41311. //
  41312. //
  41313. //
  41314. //
  41315. //
  41316. //
  41317. //
  41318. //
  41319. //
  41320. //
  41321. /* harmony default export */ __webpack_exports__["default"] = ({
  41322. mounted: function mounted() {
  41323. console.log('Component mounted.');
  41324. }
  41325. });
  41326. /***/ }),
  41327. /* 41 */
  41328. /***/ (function(module, exports, __webpack_require__) {
  41329. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41330. return _vm._m(0)
  41331. },staticRenderFns: [function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41332. return _c('div', {
  41333. staticClass: "container"
  41334. }, [_c('div', {
  41335. staticClass: "row"
  41336. }, [_c('div', {
  41337. staticClass: "col-md-8 col-md-offset-2"
  41338. }, [_c('div', {
  41339. staticClass: "panel panel-default"
  41340. }, [_c('div', {
  41341. staticClass: "panel-heading"
  41342. }, [_vm._v("Example Component")]), _vm._v(" "), _c('div', {
  41343. staticClass: "panel-body"
  41344. }, [_vm._v("\n I'm an example component!\n ")])])])])])
  41345. }]}
  41346. module.exports.render._withStripped = true
  41347. if (false) {
  41348. module.hot.accept()
  41349. if (module.hot.data) {
  41350. require("vue-hot-reload-api").rerender("data-v-ffb61a8e", module.exports)
  41351. }
  41352. }
  41353. /***/ }),
  41354. /* 42 */
  41355. /***/ (function(module, exports, __webpack_require__) {
  41356. var disposed = false
  41357. var Component = __webpack_require__(8)(
  41358. /* script */
  41359. __webpack_require__(43),
  41360. /* template */
  41361. __webpack_require__(44),
  41362. /* styles */
  41363. null,
  41364. /* scopeId */
  41365. null,
  41366. /* moduleIdentifier (server only) */
  41367. null
  41368. )
  41369. Component.options.__file = "/Users/aaronpk/Code/spy30/resources/assets/js/components/TeamList.vue"
  41370. if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key.substr(0, 2) !== "__"})) {console.error("named exports are not supported in *.vue files.")}
  41371. if (Component.options.functional) {console.error("[vue-loader] TeamList.vue: functional components are not supported with templates, they should use render functions.")}
  41372. /* hot reload */
  41373. if (false) {(function () {
  41374. var hotAPI = require("vue-hot-reload-api")
  41375. hotAPI.install(require("vue"), false)
  41376. if (!hotAPI.compatible) return
  41377. module.hot.accept()
  41378. if (!module.hot.data) {
  41379. hotAPI.createRecord("data-v-67ad3e48", Component.options)
  41380. } else {
  41381. hotAPI.reload("data-v-67ad3e48", Component.options)
  41382. }
  41383. module.hot.dispose(function (data) {
  41384. disposed = true
  41385. })
  41386. })()}
  41387. module.exports = Component.exports
  41388. /***/ }),
  41389. /* 43 */
  41390. /***/ (function(module, exports) {
  41391. //
  41392. //
  41393. //
  41394. //
  41395. //
  41396. /***/ }),
  41397. /* 44 */
  41398. /***/ (function(module, exports, __webpack_require__) {
  41399. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41400. return _c('div', {
  41401. staticClass: "team"
  41402. })
  41403. },staticRenderFns: []}
  41404. module.exports.render._withStripped = true
  41405. if (false) {
  41406. module.hot.accept()
  41407. if (module.hot.data) {
  41408. require("vue-hot-reload-api").rerender("data-v-67ad3e48", module.exports)
  41409. }
  41410. }
  41411. /***/ }),
  41412. /* 45 */
  41413. /***/ (function(module, exports) {
  41414. // removed by extract-text-webpack-plugin
  41415. /***/ })
  41416. /******/ ]);