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.

47384 lines
1.3 MiB

7 years ago
7 years ago
  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, __webpack_exports__, __webpack_require__) {
  751. "use strict";
  752. /**
  753. * First we will load all of this project's JavaScript dependencies which
  754. * includes Vue and other libraries. It is a great starting point when
  755. * building robust, powerful web applications using Vue and Laravel.
  756. */
  757. __webpack_require__(11);
  758. $.ajaxSetup({
  759. headers: {
  760. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  761. }
  762. });
  763. window.Vue = __webpack_require__(38);
  764. /**
  765. * Next, we will create a fresh Vue application instance and attach it to
  766. * the page. Then, you may begin adding components to this application
  767. * or customize the JavaScript scaffolding to fit your unique needs.
  768. */
  769. Vue.component('tweet-queue', __webpack_require__(56));
  770. Vue.component('scorecard', __webpack_require__(59));
  771. var data = {
  772. queue: [],
  773. showScorecard: false
  774. };
  775. var app = new Vue({
  776. el: '#app',
  777. data: data
  778. });
  779. /***/ }),
  780. /* 11 */
  781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  782. "use strict";
  783. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  784. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_laravel_echo__ = __webpack_require__(36);
  785. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_laravel_echo___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_laravel_echo__);
  786. window._ = __webpack_require__(12);
  787. /**
  788. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  789. * for JavaScript based Bootstrap features such as modals and tabs. This
  790. * code may be modified to fit the specific needs of your application.
  791. */
  792. try {
  793. window.$ = window.jQuery = __webpack_require__(14);
  794. __webpack_require__(15);
  795. } catch (e) {}
  796. /**
  797. * We'll load the axios HTTP library which allows us to easily issue requests
  798. * to our Laravel back-end. This library automatically handles sending the
  799. * CSRF token as a header based on the value of the "XSRF" token cookie.
  800. */
  801. window.axios = __webpack_require__(16);
  802. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  803. __webpack_require__(64);
  804. $.featherlight.autoBind = false;
  805. /**
  806. * Next we will register the CSRF Token as a common header with Axios so that
  807. * all outgoing HTTP requests automatically have it attached. This is just
  808. * a simple convenience so we don't have to attach every token manually.
  809. */
  810. var token = document.head.querySelector('meta[name="csrf-token"]');
  811. if (token) {
  812. window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
  813. } else {
  814. console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
  815. }
  816. /**
  817. * Echo exposes an expressive API for subscribing to channels and listening
  818. * for events that are broadcast by Laravel. Echo and event broadcasting
  819. * allows your team to easily build robust real-time web applications.
  820. */
  821. window.Pusher = __webpack_require__(37);
  822. window.Echo = new __WEBPACK_IMPORTED_MODULE_0_laravel_echo___default.a({
  823. broadcaster: 'pusher',
  824. key: '2083afa65322501623f3',
  825. cluster: 'us2',
  826. encrypted: true
  827. });
  828. /***/ }),
  829. /* 12 */
  830. /***/ (function(module, exports, __webpack_require__) {
  831. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  832. * @license
  833. * Lodash <https://lodash.com/>
  834. * Copyright JS Foundation and other contributors <https://js.foundation/>
  835. * Released under MIT license <https://lodash.com/license>
  836. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  837. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  838. */
  839. ;(function() {
  840. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  841. var undefined;
  842. /** Used as the semantic version number. */
  843. var VERSION = '4.17.4';
  844. /** Used as the size to enable large array optimizations. */
  845. var LARGE_ARRAY_SIZE = 200;
  846. /** Error message constants. */
  847. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  848. FUNC_ERROR_TEXT = 'Expected a function';
  849. /** Used to stand-in for `undefined` hash values. */
  850. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  851. /** Used as the maximum memoize cache size. */
  852. var MAX_MEMOIZE_SIZE = 500;
  853. /** Used as the internal argument placeholder. */
  854. var PLACEHOLDER = '__lodash_placeholder__';
  855. /** Used to compose bitmasks for cloning. */
  856. var CLONE_DEEP_FLAG = 1,
  857. CLONE_FLAT_FLAG = 2,
  858. CLONE_SYMBOLS_FLAG = 4;
  859. /** Used to compose bitmasks for value comparisons. */
  860. var COMPARE_PARTIAL_FLAG = 1,
  861. COMPARE_UNORDERED_FLAG = 2;
  862. /** Used to compose bitmasks for function metadata. */
  863. var WRAP_BIND_FLAG = 1,
  864. WRAP_BIND_KEY_FLAG = 2,
  865. WRAP_CURRY_BOUND_FLAG = 4,
  866. WRAP_CURRY_FLAG = 8,
  867. WRAP_CURRY_RIGHT_FLAG = 16,
  868. WRAP_PARTIAL_FLAG = 32,
  869. WRAP_PARTIAL_RIGHT_FLAG = 64,
  870. WRAP_ARY_FLAG = 128,
  871. WRAP_REARG_FLAG = 256,
  872. WRAP_FLIP_FLAG = 512;
  873. /** Used as default options for `_.truncate`. */
  874. var DEFAULT_TRUNC_LENGTH = 30,
  875. DEFAULT_TRUNC_OMISSION = '...';
  876. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  877. var HOT_COUNT = 800,
  878. HOT_SPAN = 16;
  879. /** Used to indicate the type of lazy iteratees. */
  880. var LAZY_FILTER_FLAG = 1,
  881. LAZY_MAP_FLAG = 2,
  882. LAZY_WHILE_FLAG = 3;
  883. /** Used as references for various `Number` constants. */
  884. var INFINITY = 1 / 0,
  885. MAX_SAFE_INTEGER = 9007199254740991,
  886. MAX_INTEGER = 1.7976931348623157e+308,
  887. NAN = 0 / 0;
  888. /** Used as references for the maximum length and index of an array. */
  889. var MAX_ARRAY_LENGTH = 4294967295,
  890. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  891. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  892. /** Used to associate wrap methods with their bit flags. */
  893. var wrapFlags = [
  894. ['ary', WRAP_ARY_FLAG],
  895. ['bind', WRAP_BIND_FLAG],
  896. ['bindKey', WRAP_BIND_KEY_FLAG],
  897. ['curry', WRAP_CURRY_FLAG],
  898. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  899. ['flip', WRAP_FLIP_FLAG],
  900. ['partial', WRAP_PARTIAL_FLAG],
  901. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  902. ['rearg', WRAP_REARG_FLAG]
  903. ];
  904. /** `Object#toString` result references. */
  905. var argsTag = '[object Arguments]',
  906. arrayTag = '[object Array]',
  907. asyncTag = '[object AsyncFunction]',
  908. boolTag = '[object Boolean]',
  909. dateTag = '[object Date]',
  910. domExcTag = '[object DOMException]',
  911. errorTag = '[object Error]',
  912. funcTag = '[object Function]',
  913. genTag = '[object GeneratorFunction]',
  914. mapTag = '[object Map]',
  915. numberTag = '[object Number]',
  916. nullTag = '[object Null]',
  917. objectTag = '[object Object]',
  918. promiseTag = '[object Promise]',
  919. proxyTag = '[object Proxy]',
  920. regexpTag = '[object RegExp]',
  921. setTag = '[object Set]',
  922. stringTag = '[object String]',
  923. symbolTag = '[object Symbol]',
  924. undefinedTag = '[object Undefined]',
  925. weakMapTag = '[object WeakMap]',
  926. weakSetTag = '[object WeakSet]';
  927. var arrayBufferTag = '[object ArrayBuffer]',
  928. dataViewTag = '[object DataView]',
  929. float32Tag = '[object Float32Array]',
  930. float64Tag = '[object Float64Array]',
  931. int8Tag = '[object Int8Array]',
  932. int16Tag = '[object Int16Array]',
  933. int32Tag = '[object Int32Array]',
  934. uint8Tag = '[object Uint8Array]',
  935. uint8ClampedTag = '[object Uint8ClampedArray]',
  936. uint16Tag = '[object Uint16Array]',
  937. uint32Tag = '[object Uint32Array]';
  938. /** Used to match empty string literals in compiled template source. */
  939. var reEmptyStringLeading = /\b__p \+= '';/g,
  940. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  941. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  942. /** Used to match HTML entities and HTML characters. */
  943. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  944. reUnescapedHtml = /[&<>"']/g,
  945. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  946. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  947. /** Used to match template delimiters. */
  948. var reEscape = /<%-([\s\S]+?)%>/g,
  949. reEvaluate = /<%([\s\S]+?)%>/g,
  950. reInterpolate = /<%=([\s\S]+?)%>/g;
  951. /** Used to match property names within property paths. */
  952. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  953. reIsPlainProp = /^\w*$/,
  954. reLeadingDot = /^\./,
  955. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  956. /**
  957. * Used to match `RegExp`
  958. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  959. */
  960. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  961. reHasRegExpChar = RegExp(reRegExpChar.source);
  962. /** Used to match leading and trailing whitespace. */
  963. var reTrim = /^\s+|\s+$/g,
  964. reTrimStart = /^\s+/,
  965. reTrimEnd = /\s+$/;
  966. /** Used to match wrap detail comments. */
  967. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  968. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  969. reSplitDetails = /,? & /;
  970. /** Used to match words composed of alphanumeric characters. */
  971. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  972. /** Used to match backslashes in property paths. */
  973. var reEscapeChar = /\\(\\)?/g;
  974. /**
  975. * Used to match
  976. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  977. */
  978. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  979. /** Used to match `RegExp` flags from their coerced string values. */
  980. var reFlags = /\w*$/;
  981. /** Used to detect bad signed hexadecimal string values. */
  982. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  983. /** Used to detect binary string values. */
  984. var reIsBinary = /^0b[01]+$/i;
  985. /** Used to detect host constructors (Safari). */
  986. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  987. /** Used to detect octal string values. */
  988. var reIsOctal = /^0o[0-7]+$/i;
  989. /** Used to detect unsigned integer values. */
  990. var reIsUint = /^(?:0|[1-9]\d*)$/;
  991. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  992. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  993. /** Used to ensure capturing order of template delimiters. */
  994. var reNoMatch = /($^)/;
  995. /** Used to match unescaped characters in compiled string literals. */
  996. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  997. /** Used to compose unicode character classes. */
  998. var rsAstralRange = '\\ud800-\\udfff',
  999. rsComboMarksRange = '\\u0300-\\u036f',
  1000. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  1001. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  1002. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  1003. rsDingbatRange = '\\u2700-\\u27bf',
  1004. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  1005. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  1006. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  1007. rsPunctuationRange = '\\u2000-\\u206f',
  1008. 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',
  1009. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  1010. rsVarRange = '\\ufe0e\\ufe0f',
  1011. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  1012. /** Used to compose unicode capture groups. */
  1013. var rsApos = "['\u2019]",
  1014. rsAstral = '[' + rsAstralRange + ']',
  1015. rsBreak = '[' + rsBreakRange + ']',
  1016. rsCombo = '[' + rsComboRange + ']',
  1017. rsDigits = '\\d+',
  1018. rsDingbat = '[' + rsDingbatRange + ']',
  1019. rsLower = '[' + rsLowerRange + ']',
  1020. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  1021. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  1022. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  1023. rsNonAstral = '[^' + rsAstralRange + ']',
  1024. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  1025. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  1026. rsUpper = '[' + rsUpperRange + ']',
  1027. rsZWJ = '\\u200d';
  1028. /** Used to compose unicode regexes. */
  1029. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  1030. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  1031. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  1032. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  1033. reOptMod = rsModifier + '?',
  1034. rsOptVar = '[' + rsVarRange + ']?',
  1035. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  1036. rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
  1037. rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
  1038. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  1039. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  1040. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  1041. /** Used to match apostrophes. */
  1042. var reApos = RegExp(rsApos, 'g');
  1043. /**
  1044. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  1045. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  1046. */
  1047. var reComboMark = RegExp(rsCombo, 'g');
  1048. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  1049. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  1050. /** Used to match complex or compound words. */
  1051. var reUnicodeWord = RegExp([
  1052. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  1053. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  1054. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  1055. rsUpper + '+' + rsOptContrUpper,
  1056. rsOrdUpper,
  1057. rsOrdLower,
  1058. rsDigits,
  1059. rsEmoji
  1060. ].join('|'), 'g');
  1061. /** 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/). */
  1062. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  1063. /** Used to detect strings that need a more robust regexp to match words. */
  1064. 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 ]/;
  1065. /** Used to assign default `context` object properties. */
  1066. var contextProps = [
  1067. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  1068. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  1069. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  1070. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  1071. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  1072. ];
  1073. /** Used to make template sourceURLs easier to identify. */
  1074. var templateCounter = -1;
  1075. /** Used to identify `toStringTag` values of typed arrays. */
  1076. var typedArrayTags = {};
  1077. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1078. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1079. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1080. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1081. typedArrayTags[uint32Tag] = true;
  1082. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1083. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1084. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  1085. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  1086. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  1087. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  1088. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  1089. typedArrayTags[weakMapTag] = false;
  1090. /** Used to identify `toStringTag` values supported by `_.clone`. */
  1091. var cloneableTags = {};
  1092. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1093. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  1094. cloneableTags[boolTag] = cloneableTags[dateTag] =
  1095. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  1096. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  1097. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  1098. cloneableTags[numberTag] = cloneableTags[objectTag] =
  1099. cloneableTags[regexpTag] = cloneableTags[setTag] =
  1100. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  1101. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  1102. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  1103. cloneableTags[errorTag] = cloneableTags[funcTag] =
  1104. cloneableTags[weakMapTag] = false;
  1105. /** Used to map Latin Unicode letters to basic Latin letters. */
  1106. var deburredLetters = {
  1107. // Latin-1 Supplement block.
  1108. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  1109. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  1110. '\xc7': 'C', '\xe7': 'c',
  1111. '\xd0': 'D', '\xf0': 'd',
  1112. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  1113. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  1114. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  1115. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  1116. '\xd1': 'N', '\xf1': 'n',
  1117. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  1118. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  1119. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  1120. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  1121. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  1122. '\xc6': 'Ae', '\xe6': 'ae',
  1123. '\xde': 'Th', '\xfe': 'th',
  1124. '\xdf': 'ss',
  1125. // Latin Extended-A block.
  1126. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  1127. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  1128. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  1129. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  1130. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  1131. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  1132. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  1133. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  1134. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  1135. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  1136. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  1137. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  1138. '\u0134': 'J', '\u0135': 'j',
  1139. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  1140. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  1141. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  1142. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  1143. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  1144. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  1145. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  1146. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  1147. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  1148. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  1149. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  1150. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  1151. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  1152. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  1153. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  1154. '\u0174': 'W', '\u0175': 'w',
  1155. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  1156. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  1157. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  1158. '\u0132': 'IJ', '\u0133': 'ij',
  1159. '\u0152': 'Oe', '\u0153': 'oe',
  1160. '\u0149': "'n", '\u017f': 's'
  1161. };
  1162. /** Used to map characters to HTML entities. */
  1163. var htmlEscapes = {
  1164. '&': '&amp;',
  1165. '<': '&lt;',
  1166. '>': '&gt;',
  1167. '"': '&quot;',
  1168. "'": '&#39;'
  1169. };
  1170. /** Used to map HTML entities to characters. */
  1171. var htmlUnescapes = {
  1172. '&amp;': '&',
  1173. '&lt;': '<',
  1174. '&gt;': '>',
  1175. '&quot;': '"',
  1176. '&#39;': "'"
  1177. };
  1178. /** Used to escape characters for inclusion in compiled string literals. */
  1179. var stringEscapes = {
  1180. '\\': '\\',
  1181. "'": "'",
  1182. '\n': 'n',
  1183. '\r': 'r',
  1184. '\u2028': 'u2028',
  1185. '\u2029': 'u2029'
  1186. };
  1187. /** Built-in method references without a dependency on `root`. */
  1188. var freeParseFloat = parseFloat,
  1189. freeParseInt = parseInt;
  1190. /** Detect free variable `global` from Node.js. */
  1191. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  1192. /** Detect free variable `self`. */
  1193. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1194. /** Used as a reference to the global object. */
  1195. var root = freeGlobal || freeSelf || Function('return this')();
  1196. /** Detect free variable `exports`. */
  1197. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  1198. /** Detect free variable `module`. */
  1199. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  1200. /** Detect the popular CommonJS extension `module.exports`. */
  1201. var moduleExports = freeModule && freeModule.exports === freeExports;
  1202. /** Detect free variable `process` from Node.js. */
  1203. var freeProcess = moduleExports && freeGlobal.process;
  1204. /** Used to access faster Node.js helpers. */
  1205. var nodeUtil = (function() {
  1206. try {
  1207. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  1208. } catch (e) {}
  1209. }());
  1210. /* Node.js helper references. */
  1211. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  1212. nodeIsDate = nodeUtil && nodeUtil.isDate,
  1213. nodeIsMap = nodeUtil && nodeUtil.isMap,
  1214. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  1215. nodeIsSet = nodeUtil && nodeUtil.isSet,
  1216. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  1217. /*--------------------------------------------------------------------------*/
  1218. /**
  1219. * Adds the key-value `pair` to `map`.
  1220. *
  1221. * @private
  1222. * @param {Object} map The map to modify.
  1223. * @param {Array} pair The key-value pair to add.
  1224. * @returns {Object} Returns `map`.
  1225. */
  1226. function addMapEntry(map, pair) {
  1227. // Don't return `map.set` because it's not chainable in IE 11.
  1228. map.set(pair[0], pair[1]);
  1229. return map;
  1230. }
  1231. /**
  1232. * Adds `value` to `set`.
  1233. *
  1234. * @private
  1235. * @param {Object} set The set to modify.
  1236. * @param {*} value The value to add.
  1237. * @returns {Object} Returns `set`.
  1238. */
  1239. function addSetEntry(set, value) {
  1240. // Don't return `set.add` because it's not chainable in IE 11.
  1241. set.add(value);
  1242. return set;
  1243. }
  1244. /**
  1245. * A faster alternative to `Function#apply`, this function invokes `func`
  1246. * with the `this` binding of `thisArg` and the arguments of `args`.
  1247. *
  1248. * @private
  1249. * @param {Function} func The function to invoke.
  1250. * @param {*} thisArg The `this` binding of `func`.
  1251. * @param {Array} args The arguments to invoke `func` with.
  1252. * @returns {*} Returns the result of `func`.
  1253. */
  1254. function apply(func, thisArg, args) {
  1255. switch (args.length) {
  1256. case 0: return func.call(thisArg);
  1257. case 1: return func.call(thisArg, args[0]);
  1258. case 2: return func.call(thisArg, args[0], args[1]);
  1259. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  1260. }
  1261. return func.apply(thisArg, args);
  1262. }
  1263. /**
  1264. * A specialized version of `baseAggregator` for arrays.
  1265. *
  1266. * @private
  1267. * @param {Array} [array] The array to iterate over.
  1268. * @param {Function} setter The function to set `accumulator` values.
  1269. * @param {Function} iteratee The iteratee to transform keys.
  1270. * @param {Object} accumulator The initial aggregated object.
  1271. * @returns {Function} Returns `accumulator`.
  1272. */
  1273. function arrayAggregator(array, setter, iteratee, accumulator) {
  1274. var index = -1,
  1275. length = array == null ? 0 : array.length;
  1276. while (++index < length) {
  1277. var value = array[index];
  1278. setter(accumulator, value, iteratee(value), array);
  1279. }
  1280. return accumulator;
  1281. }
  1282. /**
  1283. * A specialized version of `_.forEach` for arrays without support for
  1284. * iteratee shorthands.
  1285. *
  1286. * @private
  1287. * @param {Array} [array] The array to iterate over.
  1288. * @param {Function} iteratee The function invoked per iteration.
  1289. * @returns {Array} Returns `array`.
  1290. */
  1291. function arrayEach(array, iteratee) {
  1292. var index = -1,
  1293. length = array == null ? 0 : array.length;
  1294. while (++index < length) {
  1295. if (iteratee(array[index], index, array) === false) {
  1296. break;
  1297. }
  1298. }
  1299. return array;
  1300. }
  1301. /**
  1302. * A specialized version of `_.forEachRight` for arrays without support for
  1303. * iteratee shorthands.
  1304. *
  1305. * @private
  1306. * @param {Array} [array] The array to iterate over.
  1307. * @param {Function} iteratee The function invoked per iteration.
  1308. * @returns {Array} Returns `array`.
  1309. */
  1310. function arrayEachRight(array, iteratee) {
  1311. var length = array == null ? 0 : array.length;
  1312. while (length--) {
  1313. if (iteratee(array[length], length, array) === false) {
  1314. break;
  1315. }
  1316. }
  1317. return array;
  1318. }
  1319. /**
  1320. * A specialized version of `_.every` for arrays without support for
  1321. * iteratee shorthands.
  1322. *
  1323. * @private
  1324. * @param {Array} [array] The array to iterate over.
  1325. * @param {Function} predicate The function invoked per iteration.
  1326. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  1327. * else `false`.
  1328. */
  1329. function arrayEvery(array, predicate) {
  1330. var index = -1,
  1331. length = array == null ? 0 : array.length;
  1332. while (++index < length) {
  1333. if (!predicate(array[index], index, array)) {
  1334. return false;
  1335. }
  1336. }
  1337. return true;
  1338. }
  1339. /**
  1340. * A specialized version of `_.filter` for arrays without support for
  1341. * iteratee shorthands.
  1342. *
  1343. * @private
  1344. * @param {Array} [array] The array to iterate over.
  1345. * @param {Function} predicate The function invoked per iteration.
  1346. * @returns {Array} Returns the new filtered array.
  1347. */
  1348. function arrayFilter(array, predicate) {
  1349. var index = -1,
  1350. length = array == null ? 0 : array.length,
  1351. resIndex = 0,
  1352. result = [];
  1353. while (++index < length) {
  1354. var value = array[index];
  1355. if (predicate(value, index, array)) {
  1356. result[resIndex++] = value;
  1357. }
  1358. }
  1359. return result;
  1360. }
  1361. /**
  1362. * A specialized version of `_.includes` for arrays without support for
  1363. * specifying an index to search from.
  1364. *
  1365. * @private
  1366. * @param {Array} [array] The array to inspect.
  1367. * @param {*} target The value to search for.
  1368. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  1369. */
  1370. function arrayIncludes(array, value) {
  1371. var length = array == null ? 0 : array.length;
  1372. return !!length && baseIndexOf(array, value, 0) > -1;
  1373. }
  1374. /**
  1375. * This function is like `arrayIncludes` except that it accepts a comparator.
  1376. *
  1377. * @private
  1378. * @param {Array} [array] The array to inspect.
  1379. * @param {*} target The value to search for.
  1380. * @param {Function} comparator The comparator invoked per element.
  1381. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  1382. */
  1383. function arrayIncludesWith(array, value, comparator) {
  1384. var index = -1,
  1385. length = array == null ? 0 : array.length;
  1386. while (++index < length) {
  1387. if (comparator(value, array[index])) {
  1388. return true;
  1389. }
  1390. }
  1391. return false;
  1392. }
  1393. /**
  1394. * A specialized version of `_.map` for arrays without support for iteratee
  1395. * shorthands.
  1396. *
  1397. * @private
  1398. * @param {Array} [array] The array to iterate over.
  1399. * @param {Function} iteratee The function invoked per iteration.
  1400. * @returns {Array} Returns the new mapped array.
  1401. */
  1402. function arrayMap(array, iteratee) {
  1403. var index = -1,
  1404. length = array == null ? 0 : array.length,
  1405. result = Array(length);
  1406. while (++index < length) {
  1407. result[index] = iteratee(array[index], index, array);
  1408. }
  1409. return result;
  1410. }
  1411. /**
  1412. * Appends the elements of `values` to `array`.
  1413. *
  1414. * @private
  1415. * @param {Array} array The array to modify.
  1416. * @param {Array} values The values to append.
  1417. * @returns {Array} Returns `array`.
  1418. */
  1419. function arrayPush(array, values) {
  1420. var index = -1,
  1421. length = values.length,
  1422. offset = array.length;
  1423. while (++index < length) {
  1424. array[offset + index] = values[index];
  1425. }
  1426. return array;
  1427. }
  1428. /**
  1429. * A specialized version of `_.reduce` for arrays without support for
  1430. * iteratee shorthands.
  1431. *
  1432. * @private
  1433. * @param {Array} [array] The array to iterate over.
  1434. * @param {Function} iteratee The function invoked per iteration.
  1435. * @param {*} [accumulator] The initial value.
  1436. * @param {boolean} [initAccum] Specify using the first element of `array` as
  1437. * the initial value.
  1438. * @returns {*} Returns the accumulated value.
  1439. */
  1440. function arrayReduce(array, iteratee, accumulator, initAccum) {
  1441. var index = -1,
  1442. length = array == null ? 0 : array.length;
  1443. if (initAccum && length) {
  1444. accumulator = array[++index];
  1445. }
  1446. while (++index < length) {
  1447. accumulator = iteratee(accumulator, array[index], index, array);
  1448. }
  1449. return accumulator;
  1450. }
  1451. /**
  1452. * A specialized version of `_.reduceRight` for arrays without support for
  1453. * iteratee shorthands.
  1454. *
  1455. * @private
  1456. * @param {Array} [array] The array to iterate over.
  1457. * @param {Function} iteratee The function invoked per iteration.
  1458. * @param {*} [accumulator] The initial value.
  1459. * @param {boolean} [initAccum] Specify using the last element of `array` as
  1460. * the initial value.
  1461. * @returns {*} Returns the accumulated value.
  1462. */
  1463. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  1464. var length = array == null ? 0 : array.length;
  1465. if (initAccum && length) {
  1466. accumulator = array[--length];
  1467. }
  1468. while (length--) {
  1469. accumulator = iteratee(accumulator, array[length], length, array);
  1470. }
  1471. return accumulator;
  1472. }
  1473. /**
  1474. * A specialized version of `_.some` for arrays without support for iteratee
  1475. * shorthands.
  1476. *
  1477. * @private
  1478. * @param {Array} [array] The array to iterate over.
  1479. * @param {Function} predicate The function invoked per iteration.
  1480. * @returns {boolean} Returns `true` if any element passes the predicate check,
  1481. * else `false`.
  1482. */
  1483. function arraySome(array, predicate) {
  1484. var index = -1,
  1485. length = array == null ? 0 : array.length;
  1486. while (++index < length) {
  1487. if (predicate(array[index], index, array)) {
  1488. return true;
  1489. }
  1490. }
  1491. return false;
  1492. }
  1493. /**
  1494. * Gets the size of an ASCII `string`.
  1495. *
  1496. * @private
  1497. * @param {string} string The string inspect.
  1498. * @returns {number} Returns the string size.
  1499. */
  1500. var asciiSize = baseProperty('length');
  1501. /**
  1502. * Converts an ASCII `string` to an array.
  1503. *
  1504. * @private
  1505. * @param {string} string The string to convert.
  1506. * @returns {Array} Returns the converted array.
  1507. */
  1508. function asciiToArray(string) {
  1509. return string.split('');
  1510. }
  1511. /**
  1512. * Splits an ASCII `string` into an array of its words.
  1513. *
  1514. * @private
  1515. * @param {string} The string to inspect.
  1516. * @returns {Array} Returns the words of `string`.
  1517. */
  1518. function asciiWords(string) {
  1519. return string.match(reAsciiWord) || [];
  1520. }
  1521. /**
  1522. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  1523. * without support for iteratee shorthands, which iterates over `collection`
  1524. * using `eachFunc`.
  1525. *
  1526. * @private
  1527. * @param {Array|Object} collection The collection to inspect.
  1528. * @param {Function} predicate The function invoked per iteration.
  1529. * @param {Function} eachFunc The function to iterate over `collection`.
  1530. * @returns {*} Returns the found element or its key, else `undefined`.
  1531. */
  1532. function baseFindKey(collection, predicate, eachFunc) {
  1533. var result;
  1534. eachFunc(collection, function(value, key, collection) {
  1535. if (predicate(value, key, collection)) {
  1536. result = key;
  1537. return false;
  1538. }
  1539. });
  1540. return result;
  1541. }
  1542. /**
  1543. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  1544. * support for iteratee shorthands.
  1545. *
  1546. * @private
  1547. * @param {Array} array The array to inspect.
  1548. * @param {Function} predicate The function invoked per iteration.
  1549. * @param {number} fromIndex The index to search from.
  1550. * @param {boolean} [fromRight] Specify iterating from right to left.
  1551. * @returns {number} Returns the index of the matched value, else `-1`.
  1552. */
  1553. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  1554. var length = array.length,
  1555. index = fromIndex + (fromRight ? 1 : -1);
  1556. while ((fromRight ? index-- : ++index < length)) {
  1557. if (predicate(array[index], index, array)) {
  1558. return index;
  1559. }
  1560. }
  1561. return -1;
  1562. }
  1563. /**
  1564. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  1565. *
  1566. * @private
  1567. * @param {Array} array The array to inspect.
  1568. * @param {*} value The value to search for.
  1569. * @param {number} fromIndex The index to search from.
  1570. * @returns {number} Returns the index of the matched value, else `-1`.
  1571. */
  1572. function baseIndexOf(array, value, fromIndex) {
  1573. return value === value
  1574. ? strictIndexOf(array, value, fromIndex)
  1575. : baseFindIndex(array, baseIsNaN, fromIndex);
  1576. }
  1577. /**
  1578. * This function is like `baseIndexOf` except that it accepts a comparator.
  1579. *
  1580. * @private
  1581. * @param {Array} array The array to inspect.
  1582. * @param {*} value The value to search for.
  1583. * @param {number} fromIndex The index to search from.
  1584. * @param {Function} comparator The comparator invoked per element.
  1585. * @returns {number} Returns the index of the matched value, else `-1`.
  1586. */
  1587. function baseIndexOfWith(array, value, fromIndex, comparator) {
  1588. var index = fromIndex - 1,
  1589. length = array.length;
  1590. while (++index < length) {
  1591. if (comparator(array[index], value)) {
  1592. return index;
  1593. }
  1594. }
  1595. return -1;
  1596. }
  1597. /**
  1598. * The base implementation of `_.isNaN` without support for number objects.
  1599. *
  1600. * @private
  1601. * @param {*} value The value to check.
  1602. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  1603. */
  1604. function baseIsNaN(value) {
  1605. return value !== value;
  1606. }
  1607. /**
  1608. * The base implementation of `_.mean` and `_.meanBy` without support for
  1609. * iteratee shorthands.
  1610. *
  1611. * @private
  1612. * @param {Array} array The array to iterate over.
  1613. * @param {Function} iteratee The function invoked per iteration.
  1614. * @returns {number} Returns the mean.
  1615. */
  1616. function baseMean(array, iteratee) {
  1617. var length = array == null ? 0 : array.length;
  1618. return length ? (baseSum(array, iteratee) / length) : NAN;
  1619. }
  1620. /**
  1621. * The base implementation of `_.property` without support for deep paths.
  1622. *
  1623. * @private
  1624. * @param {string} key The key of the property to get.
  1625. * @returns {Function} Returns the new accessor function.
  1626. */
  1627. function baseProperty(key) {
  1628. return function(object) {
  1629. return object == null ? undefined : object[key];
  1630. };
  1631. }
  1632. /**
  1633. * The base implementation of `_.propertyOf` without support for deep paths.
  1634. *
  1635. * @private
  1636. * @param {Object} object The object to query.
  1637. * @returns {Function} Returns the new accessor function.
  1638. */
  1639. function basePropertyOf(object) {
  1640. return function(key) {
  1641. return object == null ? undefined : object[key];
  1642. };
  1643. }
  1644. /**
  1645. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  1646. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  1647. *
  1648. * @private
  1649. * @param {Array|Object} collection The collection to iterate over.
  1650. * @param {Function} iteratee The function invoked per iteration.
  1651. * @param {*} accumulator The initial value.
  1652. * @param {boolean} initAccum Specify using the first or last element of
  1653. * `collection` as the initial value.
  1654. * @param {Function} eachFunc The function to iterate over `collection`.
  1655. * @returns {*} Returns the accumulated value.
  1656. */
  1657. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  1658. eachFunc(collection, function(value, index, collection) {
  1659. accumulator = initAccum
  1660. ? (initAccum = false, value)
  1661. : iteratee(accumulator, value, index, collection);
  1662. });
  1663. return accumulator;
  1664. }
  1665. /**
  1666. * The base implementation of `_.sortBy` which uses `comparer` to define the
  1667. * sort order of `array` and replaces criteria objects with their corresponding
  1668. * values.
  1669. *
  1670. * @private
  1671. * @param {Array} array The array to sort.
  1672. * @param {Function} comparer The function to define sort order.
  1673. * @returns {Array} Returns `array`.
  1674. */
  1675. function baseSortBy(array, comparer) {
  1676. var length = array.length;
  1677. array.sort(comparer);
  1678. while (length--) {
  1679. array[length] = array[length].value;
  1680. }
  1681. return array;
  1682. }
  1683. /**
  1684. * The base implementation of `_.sum` and `_.sumBy` without support for
  1685. * iteratee shorthands.
  1686. *
  1687. * @private
  1688. * @param {Array} array The array to iterate over.
  1689. * @param {Function} iteratee The function invoked per iteration.
  1690. * @returns {number} Returns the sum.
  1691. */
  1692. function baseSum(array, iteratee) {
  1693. var result,
  1694. index = -1,
  1695. length = array.length;
  1696. while (++index < length) {
  1697. var current = iteratee(array[index]);
  1698. if (current !== undefined) {
  1699. result = result === undefined ? current : (result + current);
  1700. }
  1701. }
  1702. return result;
  1703. }
  1704. /**
  1705. * The base implementation of `_.times` without support for iteratee shorthands
  1706. * or max array length checks.
  1707. *
  1708. * @private
  1709. * @param {number} n The number of times to invoke `iteratee`.
  1710. * @param {Function} iteratee The function invoked per iteration.
  1711. * @returns {Array} Returns the array of results.
  1712. */
  1713. function baseTimes(n, iteratee) {
  1714. var index = -1,
  1715. result = Array(n);
  1716. while (++index < n) {
  1717. result[index] = iteratee(index);
  1718. }
  1719. return result;
  1720. }
  1721. /**
  1722. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  1723. * of key-value pairs for `object` corresponding to the property names of `props`.
  1724. *
  1725. * @private
  1726. * @param {Object} object The object to query.
  1727. * @param {Array} props The property names to get values for.
  1728. * @returns {Object} Returns the key-value pairs.
  1729. */
  1730. function baseToPairs(object, props) {
  1731. return arrayMap(props, function(key) {
  1732. return [key, object[key]];
  1733. });
  1734. }
  1735. /**
  1736. * The base implementation of `_.unary` without support for storing metadata.
  1737. *
  1738. * @private
  1739. * @param {Function} func The function to cap arguments for.
  1740. * @returns {Function} Returns the new capped function.
  1741. */
  1742. function baseUnary(func) {
  1743. return function(value) {
  1744. return func(value);
  1745. };
  1746. }
  1747. /**
  1748. * The base implementation of `_.values` and `_.valuesIn` which creates an
  1749. * array of `object` property values corresponding to the property names
  1750. * of `props`.
  1751. *
  1752. * @private
  1753. * @param {Object} object The object to query.
  1754. * @param {Array} props The property names to get values for.
  1755. * @returns {Object} Returns the array of property values.
  1756. */
  1757. function baseValues(object, props) {
  1758. return arrayMap(props, function(key) {
  1759. return object[key];
  1760. });
  1761. }
  1762. /**
  1763. * Checks if a `cache` value for `key` exists.
  1764. *
  1765. * @private
  1766. * @param {Object} cache The cache to query.
  1767. * @param {string} key The key of the entry to check.
  1768. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1769. */
  1770. function cacheHas(cache, key) {
  1771. return cache.has(key);
  1772. }
  1773. /**
  1774. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  1775. * that is not found in the character symbols.
  1776. *
  1777. * @private
  1778. * @param {Array} strSymbols The string symbols to inspect.
  1779. * @param {Array} chrSymbols The character symbols to find.
  1780. * @returns {number} Returns the index of the first unmatched string symbol.
  1781. */
  1782. function charsStartIndex(strSymbols, chrSymbols) {
  1783. var index = -1,
  1784. length = strSymbols.length;
  1785. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  1786. return index;
  1787. }
  1788. /**
  1789. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  1790. * that is not found in the character symbols.
  1791. *
  1792. * @private
  1793. * @param {Array} strSymbols The string symbols to inspect.
  1794. * @param {Array} chrSymbols The character symbols to find.
  1795. * @returns {number} Returns the index of the last unmatched string symbol.
  1796. */
  1797. function charsEndIndex(strSymbols, chrSymbols) {
  1798. var index = strSymbols.length;
  1799. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  1800. return index;
  1801. }
  1802. /**
  1803. * Gets the number of `placeholder` occurrences in `array`.
  1804. *
  1805. * @private
  1806. * @param {Array} array The array to inspect.
  1807. * @param {*} placeholder The placeholder to search for.
  1808. * @returns {number} Returns the placeholder count.
  1809. */
  1810. function countHolders(array, placeholder) {
  1811. var length = array.length,
  1812. result = 0;
  1813. while (length--) {
  1814. if (array[length] === placeholder) {
  1815. ++result;
  1816. }
  1817. }
  1818. return result;
  1819. }
  1820. /**
  1821. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  1822. * letters to basic Latin letters.
  1823. *
  1824. * @private
  1825. * @param {string} letter The matched letter to deburr.
  1826. * @returns {string} Returns the deburred letter.
  1827. */
  1828. var deburrLetter = basePropertyOf(deburredLetters);
  1829. /**
  1830. * Used by `_.escape` to convert characters to HTML entities.
  1831. *
  1832. * @private
  1833. * @param {string} chr The matched character to escape.
  1834. * @returns {string} Returns the escaped character.
  1835. */
  1836. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  1837. /**
  1838. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  1839. *
  1840. * @private
  1841. * @param {string} chr The matched character to escape.
  1842. * @returns {string} Returns the escaped character.
  1843. */
  1844. function escapeStringChar(chr) {
  1845. return '\\' + stringEscapes[chr];
  1846. }
  1847. /**
  1848. * Gets the value at `key` of `object`.
  1849. *
  1850. * @private
  1851. * @param {Object} [object] The object to query.
  1852. * @param {string} key The key of the property to get.
  1853. * @returns {*} Returns the property value.
  1854. */
  1855. function getValue(object, key) {
  1856. return object == null ? undefined : object[key];
  1857. }
  1858. /**
  1859. * Checks if `string` contains Unicode symbols.
  1860. *
  1861. * @private
  1862. * @param {string} string The string to inspect.
  1863. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  1864. */
  1865. function hasUnicode(string) {
  1866. return reHasUnicode.test(string);
  1867. }
  1868. /**
  1869. * Checks if `string` contains a word composed of Unicode symbols.
  1870. *
  1871. * @private
  1872. * @param {string} string The string to inspect.
  1873. * @returns {boolean} Returns `true` if a word is found, else `false`.
  1874. */
  1875. function hasUnicodeWord(string) {
  1876. return reHasUnicodeWord.test(string);
  1877. }
  1878. /**
  1879. * Converts `iterator` to an array.
  1880. *
  1881. * @private
  1882. * @param {Object} iterator The iterator to convert.
  1883. * @returns {Array} Returns the converted array.
  1884. */
  1885. function iteratorToArray(iterator) {
  1886. var data,
  1887. result = [];
  1888. while (!(data = iterator.next()).done) {
  1889. result.push(data.value);
  1890. }
  1891. return result;
  1892. }
  1893. /**
  1894. * Converts `map` to its key-value pairs.
  1895. *
  1896. * @private
  1897. * @param {Object} map The map to convert.
  1898. * @returns {Array} Returns the key-value pairs.
  1899. */
  1900. function mapToArray(map) {
  1901. var index = -1,
  1902. result = Array(map.size);
  1903. map.forEach(function(value, key) {
  1904. result[++index] = [key, value];
  1905. });
  1906. return result;
  1907. }
  1908. /**
  1909. * Creates a unary function that invokes `func` with its argument transformed.
  1910. *
  1911. * @private
  1912. * @param {Function} func The function to wrap.
  1913. * @param {Function} transform The argument transform.
  1914. * @returns {Function} Returns the new function.
  1915. */
  1916. function overArg(func, transform) {
  1917. return function(arg) {
  1918. return func(transform(arg));
  1919. };
  1920. }
  1921. /**
  1922. * Replaces all `placeholder` elements in `array` with an internal placeholder
  1923. * and returns an array of their indexes.
  1924. *
  1925. * @private
  1926. * @param {Array} array The array to modify.
  1927. * @param {*} placeholder The placeholder to replace.
  1928. * @returns {Array} Returns the new array of placeholder indexes.
  1929. */
  1930. function replaceHolders(array, placeholder) {
  1931. var index = -1,
  1932. length = array.length,
  1933. resIndex = 0,
  1934. result = [];
  1935. while (++index < length) {
  1936. var value = array[index];
  1937. if (value === placeholder || value === PLACEHOLDER) {
  1938. array[index] = PLACEHOLDER;
  1939. result[resIndex++] = index;
  1940. }
  1941. }
  1942. return result;
  1943. }
  1944. /**
  1945. * Converts `set` to an array of its values.
  1946. *
  1947. * @private
  1948. * @param {Object} set The set to convert.
  1949. * @returns {Array} Returns the values.
  1950. */
  1951. function setToArray(set) {
  1952. var index = -1,
  1953. result = Array(set.size);
  1954. set.forEach(function(value) {
  1955. result[++index] = value;
  1956. });
  1957. return result;
  1958. }
  1959. /**
  1960. * Converts `set` to its value-value pairs.
  1961. *
  1962. * @private
  1963. * @param {Object} set The set to convert.
  1964. * @returns {Array} Returns the value-value pairs.
  1965. */
  1966. function setToPairs(set) {
  1967. var index = -1,
  1968. result = Array(set.size);
  1969. set.forEach(function(value) {
  1970. result[++index] = [value, value];
  1971. });
  1972. return result;
  1973. }
  1974. /**
  1975. * A specialized version of `_.indexOf` which performs strict equality
  1976. * comparisons of values, i.e. `===`.
  1977. *
  1978. * @private
  1979. * @param {Array} array The array to inspect.
  1980. * @param {*} value The value to search for.
  1981. * @param {number} fromIndex The index to search from.
  1982. * @returns {number} Returns the index of the matched value, else `-1`.
  1983. */
  1984. function strictIndexOf(array, value, fromIndex) {
  1985. var index = fromIndex - 1,
  1986. length = array.length;
  1987. while (++index < length) {
  1988. if (array[index] === value) {
  1989. return index;
  1990. }
  1991. }
  1992. return -1;
  1993. }
  1994. /**
  1995. * A specialized version of `_.lastIndexOf` which performs strict equality
  1996. * comparisons of values, i.e. `===`.
  1997. *
  1998. * @private
  1999. * @param {Array} array The array to inspect.
  2000. * @param {*} value The value to search for.
  2001. * @param {number} fromIndex The index to search from.
  2002. * @returns {number} Returns the index of the matched value, else `-1`.
  2003. */
  2004. function strictLastIndexOf(array, value, fromIndex) {
  2005. var index = fromIndex + 1;
  2006. while (index--) {
  2007. if (array[index] === value) {
  2008. return index;
  2009. }
  2010. }
  2011. return index;
  2012. }
  2013. /**
  2014. * Gets the number of symbols in `string`.
  2015. *
  2016. * @private
  2017. * @param {string} string The string to inspect.
  2018. * @returns {number} Returns the string size.
  2019. */
  2020. function stringSize(string) {
  2021. return hasUnicode(string)
  2022. ? unicodeSize(string)
  2023. : asciiSize(string);
  2024. }
  2025. /**
  2026. * Converts `string` to an array.
  2027. *
  2028. * @private
  2029. * @param {string} string The string to convert.
  2030. * @returns {Array} Returns the converted array.
  2031. */
  2032. function stringToArray(string) {
  2033. return hasUnicode(string)
  2034. ? unicodeToArray(string)
  2035. : asciiToArray(string);
  2036. }
  2037. /**
  2038. * Used by `_.unescape` to convert HTML entities to characters.
  2039. *
  2040. * @private
  2041. * @param {string} chr The matched character to unescape.
  2042. * @returns {string} Returns the unescaped character.
  2043. */
  2044. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  2045. /**
  2046. * Gets the size of a Unicode `string`.
  2047. *
  2048. * @private
  2049. * @param {string} string The string inspect.
  2050. * @returns {number} Returns the string size.
  2051. */
  2052. function unicodeSize(string) {
  2053. var result = reUnicode.lastIndex = 0;
  2054. while (reUnicode.test(string)) {
  2055. ++result;
  2056. }
  2057. return result;
  2058. }
  2059. /**
  2060. * Converts a Unicode `string` to an array.
  2061. *
  2062. * @private
  2063. * @param {string} string The string to convert.
  2064. * @returns {Array} Returns the converted array.
  2065. */
  2066. function unicodeToArray(string) {
  2067. return string.match(reUnicode) || [];
  2068. }
  2069. /**
  2070. * Splits a Unicode `string` into an array of its words.
  2071. *
  2072. * @private
  2073. * @param {string} The string to inspect.
  2074. * @returns {Array} Returns the words of `string`.
  2075. */
  2076. function unicodeWords(string) {
  2077. return string.match(reUnicodeWord) || [];
  2078. }
  2079. /*--------------------------------------------------------------------------*/
  2080. /**
  2081. * Create a new pristine `lodash` function using the `context` object.
  2082. *
  2083. * @static
  2084. * @memberOf _
  2085. * @since 1.1.0
  2086. * @category Util
  2087. * @param {Object} [context=root] The context object.
  2088. * @returns {Function} Returns a new `lodash` function.
  2089. * @example
  2090. *
  2091. * _.mixin({ 'foo': _.constant('foo') });
  2092. *
  2093. * var lodash = _.runInContext();
  2094. * lodash.mixin({ 'bar': lodash.constant('bar') });
  2095. *
  2096. * _.isFunction(_.foo);
  2097. * // => true
  2098. * _.isFunction(_.bar);
  2099. * // => false
  2100. *
  2101. * lodash.isFunction(lodash.foo);
  2102. * // => false
  2103. * lodash.isFunction(lodash.bar);
  2104. * // => true
  2105. *
  2106. * // Create a suped-up `defer` in Node.js.
  2107. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  2108. */
  2109. var runInContext = (function runInContext(context) {
  2110. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  2111. /** Built-in constructor references. */
  2112. var Array = context.Array,
  2113. Date = context.Date,
  2114. Error = context.Error,
  2115. Function = context.Function,
  2116. Math = context.Math,
  2117. Object = context.Object,
  2118. RegExp = context.RegExp,
  2119. String = context.String,
  2120. TypeError = context.TypeError;
  2121. /** Used for built-in method references. */
  2122. var arrayProto = Array.prototype,
  2123. funcProto = Function.prototype,
  2124. objectProto = Object.prototype;
  2125. /** Used to detect overreaching core-js shims. */
  2126. var coreJsData = context['__core-js_shared__'];
  2127. /** Used to resolve the decompiled source of functions. */
  2128. var funcToString = funcProto.toString;
  2129. /** Used to check objects for own properties. */
  2130. var hasOwnProperty = objectProto.hasOwnProperty;
  2131. /** Used to generate unique IDs. */
  2132. var idCounter = 0;
  2133. /** Used to detect methods masquerading as native. */
  2134. var maskSrcKey = (function() {
  2135. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2136. return uid ? ('Symbol(src)_1.' + uid) : '';
  2137. }());
  2138. /**
  2139. * Used to resolve the
  2140. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2141. * of values.
  2142. */
  2143. var nativeObjectToString = objectProto.toString;
  2144. /** Used to infer the `Object` constructor. */
  2145. var objectCtorString = funcToString.call(Object);
  2146. /** Used to restore the original `_` reference in `_.noConflict`. */
  2147. var oldDash = root._;
  2148. /** Used to detect if a method is native. */
  2149. var reIsNative = RegExp('^' +
  2150. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2151. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2152. );
  2153. /** Built-in value references. */
  2154. var Buffer = moduleExports ? context.Buffer : undefined,
  2155. Symbol = context.Symbol,
  2156. Uint8Array = context.Uint8Array,
  2157. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  2158. getPrototype = overArg(Object.getPrototypeOf, Object),
  2159. objectCreate = Object.create,
  2160. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2161. splice = arrayProto.splice,
  2162. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  2163. symIterator = Symbol ? Symbol.iterator : undefined,
  2164. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  2165. var defineProperty = (function() {
  2166. try {
  2167. var func = getNative(Object, 'defineProperty');
  2168. func({}, '', {});
  2169. return func;
  2170. } catch (e) {}
  2171. }());
  2172. /** Mocked built-ins. */
  2173. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  2174. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  2175. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  2176. /* Built-in method references for those with the same name as other `lodash` methods. */
  2177. var nativeCeil = Math.ceil,
  2178. nativeFloor = Math.floor,
  2179. nativeGetSymbols = Object.getOwnPropertySymbols,
  2180. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  2181. nativeIsFinite = context.isFinite,
  2182. nativeJoin = arrayProto.join,
  2183. nativeKeys = overArg(Object.keys, Object),
  2184. nativeMax = Math.max,
  2185. nativeMin = Math.min,
  2186. nativeNow = Date.now,
  2187. nativeParseInt = context.parseInt,
  2188. nativeRandom = Math.random,
  2189. nativeReverse = arrayProto.reverse;
  2190. /* Built-in method references that are verified to be native. */
  2191. var DataView = getNative(context, 'DataView'),
  2192. Map = getNative(context, 'Map'),
  2193. Promise = getNative(context, 'Promise'),
  2194. Set = getNative(context, 'Set'),
  2195. WeakMap = getNative(context, 'WeakMap'),
  2196. nativeCreate = getNative(Object, 'create');
  2197. /** Used to store function metadata. */
  2198. var metaMap = WeakMap && new WeakMap;
  2199. /** Used to lookup unminified function names. */
  2200. var realNames = {};
  2201. /** Used to detect maps, sets, and weakmaps. */
  2202. var dataViewCtorString = toSource(DataView),
  2203. mapCtorString = toSource(Map),
  2204. promiseCtorString = toSource(Promise),
  2205. setCtorString = toSource(Set),
  2206. weakMapCtorString = toSource(WeakMap);
  2207. /** Used to convert symbols to primitives and strings. */
  2208. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2209. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2210. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2211. /*------------------------------------------------------------------------*/
  2212. /**
  2213. * Creates a `lodash` object which wraps `value` to enable implicit method
  2214. * chain sequences. Methods that operate on and return arrays, collections,
  2215. * and functions can be chained together. Methods that retrieve a single value
  2216. * or may return a primitive value will automatically end the chain sequence
  2217. * and return the unwrapped value. Otherwise, the value must be unwrapped
  2218. * with `_#value`.
  2219. *
  2220. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  2221. * enabled using `_.chain`.
  2222. *
  2223. * The execution of chained methods is lazy, that is, it's deferred until
  2224. * `_#value` is implicitly or explicitly called.
  2225. *
  2226. * Lazy evaluation allows several methods to support shortcut fusion.
  2227. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  2228. * the creation of intermediate arrays and can greatly reduce the number of
  2229. * iteratee executions. Sections of a chain sequence qualify for shortcut
  2230. * fusion if the section is applied to an array and iteratees accept only
  2231. * one argument. The heuristic for whether a section qualifies for shortcut
  2232. * fusion is subject to change.
  2233. *
  2234. * Chaining is supported in custom builds as long as the `_#value` method is
  2235. * directly or indirectly included in the build.
  2236. *
  2237. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  2238. *
  2239. * The wrapper `Array` methods are:
  2240. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  2241. *
  2242. * The wrapper `String` methods are:
  2243. * `replace` and `split`
  2244. *
  2245. * The wrapper methods that support shortcut fusion are:
  2246. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  2247. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  2248. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  2249. *
  2250. * The chainable wrapper methods are:
  2251. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  2252. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  2253. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  2254. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  2255. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  2256. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  2257. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  2258. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  2259. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  2260. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  2261. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  2262. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  2263. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  2264. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  2265. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  2266. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  2267. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  2268. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  2269. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  2270. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  2271. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  2272. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  2273. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  2274. * `zipObject`, `zipObjectDeep`, and `zipWith`
  2275. *
  2276. * The wrapper methods that are **not** chainable by default are:
  2277. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  2278. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  2279. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  2280. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  2281. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  2282. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  2283. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  2284. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  2285. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  2286. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  2287. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  2288. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  2289. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  2290. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  2291. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  2292. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  2293. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  2294. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  2295. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  2296. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  2297. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  2298. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  2299. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  2300. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  2301. * `upperFirst`, `value`, and `words`
  2302. *
  2303. * @name _
  2304. * @constructor
  2305. * @category Seq
  2306. * @param {*} value The value to wrap in a `lodash` instance.
  2307. * @returns {Object} Returns the new `lodash` wrapper instance.
  2308. * @example
  2309. *
  2310. * function square(n) {
  2311. * return n * n;
  2312. * }
  2313. *
  2314. * var wrapped = _([1, 2, 3]);
  2315. *
  2316. * // Returns an unwrapped value.
  2317. * wrapped.reduce(_.add);
  2318. * // => 6
  2319. *
  2320. * // Returns a wrapped value.
  2321. * var squares = wrapped.map(square);
  2322. *
  2323. * _.isArray(squares);
  2324. * // => false
  2325. *
  2326. * _.isArray(squares.value());
  2327. * // => true
  2328. */
  2329. function lodash(value) {
  2330. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  2331. if (value instanceof LodashWrapper) {
  2332. return value;
  2333. }
  2334. if (hasOwnProperty.call(value, '__wrapped__')) {
  2335. return wrapperClone(value);
  2336. }
  2337. }
  2338. return new LodashWrapper(value);
  2339. }
  2340. /**
  2341. * The base implementation of `_.create` without support for assigning
  2342. * properties to the created object.
  2343. *
  2344. * @private
  2345. * @param {Object} proto The object to inherit from.
  2346. * @returns {Object} Returns the new object.
  2347. */
  2348. var baseCreate = (function() {
  2349. function object() {}
  2350. return function(proto) {
  2351. if (!isObject(proto)) {
  2352. return {};
  2353. }
  2354. if (objectCreate) {
  2355. return objectCreate(proto);
  2356. }
  2357. object.prototype = proto;
  2358. var result = new object;
  2359. object.prototype = undefined;
  2360. return result;
  2361. };
  2362. }());
  2363. /**
  2364. * The function whose prototype chain sequence wrappers inherit from.
  2365. *
  2366. * @private
  2367. */
  2368. function baseLodash() {
  2369. // No operation performed.
  2370. }
  2371. /**
  2372. * The base constructor for creating `lodash` wrapper objects.
  2373. *
  2374. * @private
  2375. * @param {*} value The value to wrap.
  2376. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  2377. */
  2378. function LodashWrapper(value, chainAll) {
  2379. this.__wrapped__ = value;
  2380. this.__actions__ = [];
  2381. this.__chain__ = !!chainAll;
  2382. this.__index__ = 0;
  2383. this.__values__ = undefined;
  2384. }
  2385. /**
  2386. * By default, the template delimiters used by lodash are like those in
  2387. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  2388. * following template settings to use alternative delimiters.
  2389. *
  2390. * @static
  2391. * @memberOf _
  2392. * @type {Object}
  2393. */
  2394. lodash.templateSettings = {
  2395. /**
  2396. * Used to detect `data` property values to be HTML-escaped.
  2397. *
  2398. * @memberOf _.templateSettings
  2399. * @type {RegExp}
  2400. */
  2401. 'escape': reEscape,
  2402. /**
  2403. * Used to detect code to be evaluated.
  2404. *
  2405. * @memberOf _.templateSettings
  2406. * @type {RegExp}
  2407. */
  2408. 'evaluate': reEvaluate,
  2409. /**
  2410. * Used to detect `data` property values to inject.
  2411. *
  2412. * @memberOf _.templateSettings
  2413. * @type {RegExp}
  2414. */
  2415. 'interpolate': reInterpolate,
  2416. /**
  2417. * Used to reference the data object in the template text.
  2418. *
  2419. * @memberOf _.templateSettings
  2420. * @type {string}
  2421. */
  2422. 'variable': '',
  2423. /**
  2424. * Used to import variables into the compiled template.
  2425. *
  2426. * @memberOf _.templateSettings
  2427. * @type {Object}
  2428. */
  2429. 'imports': {
  2430. /**
  2431. * A reference to the `lodash` function.
  2432. *
  2433. * @memberOf _.templateSettings.imports
  2434. * @type {Function}
  2435. */
  2436. '_': lodash
  2437. }
  2438. };
  2439. // Ensure wrappers are instances of `baseLodash`.
  2440. lodash.prototype = baseLodash.prototype;
  2441. lodash.prototype.constructor = lodash;
  2442. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  2443. LodashWrapper.prototype.constructor = LodashWrapper;
  2444. /*------------------------------------------------------------------------*/
  2445. /**
  2446. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  2447. *
  2448. * @private
  2449. * @constructor
  2450. * @param {*} value The value to wrap.
  2451. */
  2452. function LazyWrapper(value) {
  2453. this.__wrapped__ = value;
  2454. this.__actions__ = [];
  2455. this.__dir__ = 1;
  2456. this.__filtered__ = false;
  2457. this.__iteratees__ = [];
  2458. this.__takeCount__ = MAX_ARRAY_LENGTH;
  2459. this.__views__ = [];
  2460. }
  2461. /**
  2462. * Creates a clone of the lazy wrapper object.
  2463. *
  2464. * @private
  2465. * @name clone
  2466. * @memberOf LazyWrapper
  2467. * @returns {Object} Returns the cloned `LazyWrapper` object.
  2468. */
  2469. function lazyClone() {
  2470. var result = new LazyWrapper(this.__wrapped__);
  2471. result.__actions__ = copyArray(this.__actions__);
  2472. result.__dir__ = this.__dir__;
  2473. result.__filtered__ = this.__filtered__;
  2474. result.__iteratees__ = copyArray(this.__iteratees__);
  2475. result.__takeCount__ = this.__takeCount__;
  2476. result.__views__ = copyArray(this.__views__);
  2477. return result;
  2478. }
  2479. /**
  2480. * Reverses the direction of lazy iteration.
  2481. *
  2482. * @private
  2483. * @name reverse
  2484. * @memberOf LazyWrapper
  2485. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  2486. */
  2487. function lazyReverse() {
  2488. if (this.__filtered__) {
  2489. var result = new LazyWrapper(this);
  2490. result.__dir__ = -1;
  2491. result.__filtered__ = true;
  2492. } else {
  2493. result = this.clone();
  2494. result.__dir__ *= -1;
  2495. }
  2496. return result;
  2497. }
  2498. /**
  2499. * Extracts the unwrapped value from its lazy wrapper.
  2500. *
  2501. * @private
  2502. * @name value
  2503. * @memberOf LazyWrapper
  2504. * @returns {*} Returns the unwrapped value.
  2505. */
  2506. function lazyValue() {
  2507. var array = this.__wrapped__.value(),
  2508. dir = this.__dir__,
  2509. isArr = isArray(array),
  2510. isRight = dir < 0,
  2511. arrLength = isArr ? array.length : 0,
  2512. view = getView(0, arrLength, this.__views__),
  2513. start = view.start,
  2514. end = view.end,
  2515. length = end - start,
  2516. index = isRight ? end : (start - 1),
  2517. iteratees = this.__iteratees__,
  2518. iterLength = iteratees.length,
  2519. resIndex = 0,
  2520. takeCount = nativeMin(length, this.__takeCount__);
  2521. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  2522. return baseWrapperValue(array, this.__actions__);
  2523. }
  2524. var result = [];
  2525. outer:
  2526. while (length-- && resIndex < takeCount) {
  2527. index += dir;
  2528. var iterIndex = -1,
  2529. value = array[index];
  2530. while (++iterIndex < iterLength) {
  2531. var data = iteratees[iterIndex],
  2532. iteratee = data.iteratee,
  2533. type = data.type,
  2534. computed = iteratee(value);
  2535. if (type == LAZY_MAP_FLAG) {
  2536. value = computed;
  2537. } else if (!computed) {
  2538. if (type == LAZY_FILTER_FLAG) {
  2539. continue outer;
  2540. } else {
  2541. break outer;
  2542. }
  2543. }
  2544. }
  2545. result[resIndex++] = value;
  2546. }
  2547. return result;
  2548. }
  2549. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  2550. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  2551. LazyWrapper.prototype.constructor = LazyWrapper;
  2552. /*------------------------------------------------------------------------*/
  2553. /**
  2554. * Creates a hash object.
  2555. *
  2556. * @private
  2557. * @constructor
  2558. * @param {Array} [entries] The key-value pairs to cache.
  2559. */
  2560. function Hash(entries) {
  2561. var index = -1,
  2562. length = entries == null ? 0 : entries.length;
  2563. this.clear();
  2564. while (++index < length) {
  2565. var entry = entries[index];
  2566. this.set(entry[0], entry[1]);
  2567. }
  2568. }
  2569. /**
  2570. * Removes all key-value entries from the hash.
  2571. *
  2572. * @private
  2573. * @name clear
  2574. * @memberOf Hash
  2575. */
  2576. function hashClear() {
  2577. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  2578. this.size = 0;
  2579. }
  2580. /**
  2581. * Removes `key` and its value from the hash.
  2582. *
  2583. * @private
  2584. * @name delete
  2585. * @memberOf Hash
  2586. * @param {Object} hash The hash to modify.
  2587. * @param {string} key The key of the value to remove.
  2588. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2589. */
  2590. function hashDelete(key) {
  2591. var result = this.has(key) && delete this.__data__[key];
  2592. this.size -= result ? 1 : 0;
  2593. return result;
  2594. }
  2595. /**
  2596. * Gets the hash value for `key`.
  2597. *
  2598. * @private
  2599. * @name get
  2600. * @memberOf Hash
  2601. * @param {string} key The key of the value to get.
  2602. * @returns {*} Returns the entry value.
  2603. */
  2604. function hashGet(key) {
  2605. var data = this.__data__;
  2606. if (nativeCreate) {
  2607. var result = data[key];
  2608. return result === HASH_UNDEFINED ? undefined : result;
  2609. }
  2610. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  2611. }
  2612. /**
  2613. * Checks if a hash value for `key` exists.
  2614. *
  2615. * @private
  2616. * @name has
  2617. * @memberOf Hash
  2618. * @param {string} key The key of the entry to check.
  2619. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2620. */
  2621. function hashHas(key) {
  2622. var data = this.__data__;
  2623. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  2624. }
  2625. /**
  2626. * Sets the hash `key` to `value`.
  2627. *
  2628. * @private
  2629. * @name set
  2630. * @memberOf Hash
  2631. * @param {string} key The key of the value to set.
  2632. * @param {*} value The value to set.
  2633. * @returns {Object} Returns the hash instance.
  2634. */
  2635. function hashSet(key, value) {
  2636. var data = this.__data__;
  2637. this.size += this.has(key) ? 0 : 1;
  2638. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  2639. return this;
  2640. }
  2641. // Add methods to `Hash`.
  2642. Hash.prototype.clear = hashClear;
  2643. Hash.prototype['delete'] = hashDelete;
  2644. Hash.prototype.get = hashGet;
  2645. Hash.prototype.has = hashHas;
  2646. Hash.prototype.set = hashSet;
  2647. /*------------------------------------------------------------------------*/
  2648. /**
  2649. * Creates an list cache object.
  2650. *
  2651. * @private
  2652. * @constructor
  2653. * @param {Array} [entries] The key-value pairs to cache.
  2654. */
  2655. function ListCache(entries) {
  2656. var index = -1,
  2657. length = entries == null ? 0 : entries.length;
  2658. this.clear();
  2659. while (++index < length) {
  2660. var entry = entries[index];
  2661. this.set(entry[0], entry[1]);
  2662. }
  2663. }
  2664. /**
  2665. * Removes all key-value entries from the list cache.
  2666. *
  2667. * @private
  2668. * @name clear
  2669. * @memberOf ListCache
  2670. */
  2671. function listCacheClear() {
  2672. this.__data__ = [];
  2673. this.size = 0;
  2674. }
  2675. /**
  2676. * Removes `key` and its value from the list cache.
  2677. *
  2678. * @private
  2679. * @name delete
  2680. * @memberOf ListCache
  2681. * @param {string} key The key of the value to remove.
  2682. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2683. */
  2684. function listCacheDelete(key) {
  2685. var data = this.__data__,
  2686. index = assocIndexOf(data, key);
  2687. if (index < 0) {
  2688. return false;
  2689. }
  2690. var lastIndex = data.length - 1;
  2691. if (index == lastIndex) {
  2692. data.pop();
  2693. } else {
  2694. splice.call(data, index, 1);
  2695. }
  2696. --this.size;
  2697. return true;
  2698. }
  2699. /**
  2700. * Gets the list cache value for `key`.
  2701. *
  2702. * @private
  2703. * @name get
  2704. * @memberOf ListCache
  2705. * @param {string} key The key of the value to get.
  2706. * @returns {*} Returns the entry value.
  2707. */
  2708. function listCacheGet(key) {
  2709. var data = this.__data__,
  2710. index = assocIndexOf(data, key);
  2711. return index < 0 ? undefined : data[index][1];
  2712. }
  2713. /**
  2714. * Checks if a list cache value for `key` exists.
  2715. *
  2716. * @private
  2717. * @name has
  2718. * @memberOf ListCache
  2719. * @param {string} key The key of the entry to check.
  2720. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2721. */
  2722. function listCacheHas(key) {
  2723. return assocIndexOf(this.__data__, key) > -1;
  2724. }
  2725. /**
  2726. * Sets the list cache `key` to `value`.
  2727. *
  2728. * @private
  2729. * @name set
  2730. * @memberOf ListCache
  2731. * @param {string} key The key of the value to set.
  2732. * @param {*} value The value to set.
  2733. * @returns {Object} Returns the list cache instance.
  2734. */
  2735. function listCacheSet(key, value) {
  2736. var data = this.__data__,
  2737. index = assocIndexOf(data, key);
  2738. if (index < 0) {
  2739. ++this.size;
  2740. data.push([key, value]);
  2741. } else {
  2742. data[index][1] = value;
  2743. }
  2744. return this;
  2745. }
  2746. // Add methods to `ListCache`.
  2747. ListCache.prototype.clear = listCacheClear;
  2748. ListCache.prototype['delete'] = listCacheDelete;
  2749. ListCache.prototype.get = listCacheGet;
  2750. ListCache.prototype.has = listCacheHas;
  2751. ListCache.prototype.set = listCacheSet;
  2752. /*------------------------------------------------------------------------*/
  2753. /**
  2754. * Creates a map cache object to store key-value pairs.
  2755. *
  2756. * @private
  2757. * @constructor
  2758. * @param {Array} [entries] The key-value pairs to cache.
  2759. */
  2760. function MapCache(entries) {
  2761. var index = -1,
  2762. length = entries == null ? 0 : entries.length;
  2763. this.clear();
  2764. while (++index < length) {
  2765. var entry = entries[index];
  2766. this.set(entry[0], entry[1]);
  2767. }
  2768. }
  2769. /**
  2770. * Removes all key-value entries from the map.
  2771. *
  2772. * @private
  2773. * @name clear
  2774. * @memberOf MapCache
  2775. */
  2776. function mapCacheClear() {
  2777. this.size = 0;
  2778. this.__data__ = {
  2779. 'hash': new Hash,
  2780. 'map': new (Map || ListCache),
  2781. 'string': new Hash
  2782. };
  2783. }
  2784. /**
  2785. * Removes `key` and its value from the map.
  2786. *
  2787. * @private
  2788. * @name delete
  2789. * @memberOf MapCache
  2790. * @param {string} key The key of the value to remove.
  2791. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2792. */
  2793. function mapCacheDelete(key) {
  2794. var result = getMapData(this, key)['delete'](key);
  2795. this.size -= result ? 1 : 0;
  2796. return result;
  2797. }
  2798. /**
  2799. * Gets the map value for `key`.
  2800. *
  2801. * @private
  2802. * @name get
  2803. * @memberOf MapCache
  2804. * @param {string} key The key of the value to get.
  2805. * @returns {*} Returns the entry value.
  2806. */
  2807. function mapCacheGet(key) {
  2808. return getMapData(this, key).get(key);
  2809. }
  2810. /**
  2811. * Checks if a map value for `key` exists.
  2812. *
  2813. * @private
  2814. * @name has
  2815. * @memberOf MapCache
  2816. * @param {string} key The key of the entry to check.
  2817. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2818. */
  2819. function mapCacheHas(key) {
  2820. return getMapData(this, key).has(key);
  2821. }
  2822. /**
  2823. * Sets the map `key` to `value`.
  2824. *
  2825. * @private
  2826. * @name set
  2827. * @memberOf MapCache
  2828. * @param {string} key The key of the value to set.
  2829. * @param {*} value The value to set.
  2830. * @returns {Object} Returns the map cache instance.
  2831. */
  2832. function mapCacheSet(key, value) {
  2833. var data = getMapData(this, key),
  2834. size = data.size;
  2835. data.set(key, value);
  2836. this.size += data.size == size ? 0 : 1;
  2837. return this;
  2838. }
  2839. // Add methods to `MapCache`.
  2840. MapCache.prototype.clear = mapCacheClear;
  2841. MapCache.prototype['delete'] = mapCacheDelete;
  2842. MapCache.prototype.get = mapCacheGet;
  2843. MapCache.prototype.has = mapCacheHas;
  2844. MapCache.prototype.set = mapCacheSet;
  2845. /*------------------------------------------------------------------------*/
  2846. /**
  2847. *
  2848. * Creates an array cache object to store unique values.
  2849. *
  2850. * @private
  2851. * @constructor
  2852. * @param {Array} [values] The values to cache.
  2853. */
  2854. function SetCache(values) {
  2855. var index = -1,
  2856. length = values == null ? 0 : values.length;
  2857. this.__data__ = new MapCache;
  2858. while (++index < length) {
  2859. this.add(values[index]);
  2860. }
  2861. }
  2862. /**
  2863. * Adds `value` to the array cache.
  2864. *
  2865. * @private
  2866. * @name add
  2867. * @memberOf SetCache
  2868. * @alias push
  2869. * @param {*} value The value to cache.
  2870. * @returns {Object} Returns the cache instance.
  2871. */
  2872. function setCacheAdd(value) {
  2873. this.__data__.set(value, HASH_UNDEFINED);
  2874. return this;
  2875. }
  2876. /**
  2877. * Checks if `value` is in the array cache.
  2878. *
  2879. * @private
  2880. * @name has
  2881. * @memberOf SetCache
  2882. * @param {*} value The value to search for.
  2883. * @returns {number} Returns `true` if `value` is found, else `false`.
  2884. */
  2885. function setCacheHas(value) {
  2886. return this.__data__.has(value);
  2887. }
  2888. // Add methods to `SetCache`.
  2889. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  2890. SetCache.prototype.has = setCacheHas;
  2891. /*------------------------------------------------------------------------*/
  2892. /**
  2893. * Creates a stack cache object to store key-value pairs.
  2894. *
  2895. * @private
  2896. * @constructor
  2897. * @param {Array} [entries] The key-value pairs to cache.
  2898. */
  2899. function Stack(entries) {
  2900. var data = this.__data__ = new ListCache(entries);
  2901. this.size = data.size;
  2902. }
  2903. /**
  2904. * Removes all key-value entries from the stack.
  2905. *
  2906. * @private
  2907. * @name clear
  2908. * @memberOf Stack
  2909. */
  2910. function stackClear() {
  2911. this.__data__ = new ListCache;
  2912. this.size = 0;
  2913. }
  2914. /**
  2915. * Removes `key` and its value from the stack.
  2916. *
  2917. * @private
  2918. * @name delete
  2919. * @memberOf Stack
  2920. * @param {string} key The key of the value to remove.
  2921. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2922. */
  2923. function stackDelete(key) {
  2924. var data = this.__data__,
  2925. result = data['delete'](key);
  2926. this.size = data.size;
  2927. return result;
  2928. }
  2929. /**
  2930. * Gets the stack value for `key`.
  2931. *
  2932. * @private
  2933. * @name get
  2934. * @memberOf Stack
  2935. * @param {string} key The key of the value to get.
  2936. * @returns {*} Returns the entry value.
  2937. */
  2938. function stackGet(key) {
  2939. return this.__data__.get(key);
  2940. }
  2941. /**
  2942. * Checks if a stack value for `key` exists.
  2943. *
  2944. * @private
  2945. * @name has
  2946. * @memberOf Stack
  2947. * @param {string} key The key of the entry to check.
  2948. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2949. */
  2950. function stackHas(key) {
  2951. return this.__data__.has(key);
  2952. }
  2953. /**
  2954. * Sets the stack `key` to `value`.
  2955. *
  2956. * @private
  2957. * @name set
  2958. * @memberOf Stack
  2959. * @param {string} key The key of the value to set.
  2960. * @param {*} value The value to set.
  2961. * @returns {Object} Returns the stack cache instance.
  2962. */
  2963. function stackSet(key, value) {
  2964. var data = this.__data__;
  2965. if (data instanceof ListCache) {
  2966. var pairs = data.__data__;
  2967. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  2968. pairs.push([key, value]);
  2969. this.size = ++data.size;
  2970. return this;
  2971. }
  2972. data = this.__data__ = new MapCache(pairs);
  2973. }
  2974. data.set(key, value);
  2975. this.size = data.size;
  2976. return this;
  2977. }
  2978. // Add methods to `Stack`.
  2979. Stack.prototype.clear = stackClear;
  2980. Stack.prototype['delete'] = stackDelete;
  2981. Stack.prototype.get = stackGet;
  2982. Stack.prototype.has = stackHas;
  2983. Stack.prototype.set = stackSet;
  2984. /*------------------------------------------------------------------------*/
  2985. /**
  2986. * Creates an array of the enumerable property names of the array-like `value`.
  2987. *
  2988. * @private
  2989. * @param {*} value The value to query.
  2990. * @param {boolean} inherited Specify returning inherited property names.
  2991. * @returns {Array} Returns the array of property names.
  2992. */
  2993. function arrayLikeKeys(value, inherited) {
  2994. var isArr = isArray(value),
  2995. isArg = !isArr && isArguments(value),
  2996. isBuff = !isArr && !isArg && isBuffer(value),
  2997. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  2998. skipIndexes = isArr || isArg || isBuff || isType,
  2999. result = skipIndexes ? baseTimes(value.length, String) : [],
  3000. length = result.length;
  3001. for (var key in value) {
  3002. if ((inherited || hasOwnProperty.call(value, key)) &&
  3003. !(skipIndexes && (
  3004. // Safari 9 has enumerable `arguments.length` in strict mode.
  3005. key == 'length' ||
  3006. // Node.js 0.10 has enumerable non-index properties on buffers.
  3007. (isBuff && (key == 'offset' || key == 'parent')) ||
  3008. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3009. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  3010. // Skip index properties.
  3011. isIndex(key, length)
  3012. ))) {
  3013. result.push(key);
  3014. }
  3015. }
  3016. return result;
  3017. }
  3018. /**
  3019. * A specialized version of `_.sample` for arrays.
  3020. *
  3021. * @private
  3022. * @param {Array} array The array to sample.
  3023. * @returns {*} Returns the random element.
  3024. */
  3025. function arraySample(array) {
  3026. var length = array.length;
  3027. return length ? array[baseRandom(0, length - 1)] : undefined;
  3028. }
  3029. /**
  3030. * A specialized version of `_.sampleSize` for arrays.
  3031. *
  3032. * @private
  3033. * @param {Array} array The array to sample.
  3034. * @param {number} n The number of elements to sample.
  3035. * @returns {Array} Returns the random elements.
  3036. */
  3037. function arraySampleSize(array, n) {
  3038. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  3039. }
  3040. /**
  3041. * A specialized version of `_.shuffle` for arrays.
  3042. *
  3043. * @private
  3044. * @param {Array} array The array to shuffle.
  3045. * @returns {Array} Returns the new shuffled array.
  3046. */
  3047. function arrayShuffle(array) {
  3048. return shuffleSelf(copyArray(array));
  3049. }
  3050. /**
  3051. * This function is like `assignValue` except that it doesn't assign
  3052. * `undefined` values.
  3053. *
  3054. * @private
  3055. * @param {Object} object The object to modify.
  3056. * @param {string} key The key of the property to assign.
  3057. * @param {*} value The value to assign.
  3058. */
  3059. function assignMergeValue(object, key, value) {
  3060. if ((value !== undefined && !eq(object[key], value)) ||
  3061. (value === undefined && !(key in object))) {
  3062. baseAssignValue(object, key, value);
  3063. }
  3064. }
  3065. /**
  3066. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  3067. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3068. * for equality comparisons.
  3069. *
  3070. * @private
  3071. * @param {Object} object The object to modify.
  3072. * @param {string} key The key of the property to assign.
  3073. * @param {*} value The value to assign.
  3074. */
  3075. function assignValue(object, key, value) {
  3076. var objValue = object[key];
  3077. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  3078. (value === undefined && !(key in object))) {
  3079. baseAssignValue(object, key, value);
  3080. }
  3081. }
  3082. /**
  3083. * Gets the index at which the `key` is found in `array` of key-value pairs.
  3084. *
  3085. * @private
  3086. * @param {Array} array The array to inspect.
  3087. * @param {*} key The key to search for.
  3088. * @returns {number} Returns the index of the matched value, else `-1`.
  3089. */
  3090. function assocIndexOf(array, key) {
  3091. var length = array.length;
  3092. while (length--) {
  3093. if (eq(array[length][0], key)) {
  3094. return length;
  3095. }
  3096. }
  3097. return -1;
  3098. }
  3099. /**
  3100. * Aggregates elements of `collection` on `accumulator` with keys transformed
  3101. * by `iteratee` and values set by `setter`.
  3102. *
  3103. * @private
  3104. * @param {Array|Object} collection The collection to iterate over.
  3105. * @param {Function} setter The function to set `accumulator` values.
  3106. * @param {Function} iteratee The iteratee to transform keys.
  3107. * @param {Object} accumulator The initial aggregated object.
  3108. * @returns {Function} Returns `accumulator`.
  3109. */
  3110. function baseAggregator(collection, setter, iteratee, accumulator) {
  3111. baseEach(collection, function(value, key, collection) {
  3112. setter(accumulator, value, iteratee(value), collection);
  3113. });
  3114. return accumulator;
  3115. }
  3116. /**
  3117. * The base implementation of `_.assign` without support for multiple sources
  3118. * or `customizer` functions.
  3119. *
  3120. * @private
  3121. * @param {Object} object The destination object.
  3122. * @param {Object} source The source object.
  3123. * @returns {Object} Returns `object`.
  3124. */
  3125. function baseAssign(object, source) {
  3126. return object && copyObject(source, keys(source), object);
  3127. }
  3128. /**
  3129. * The base implementation of `_.assignIn` without support for multiple sources
  3130. * or `customizer` functions.
  3131. *
  3132. * @private
  3133. * @param {Object} object The destination object.
  3134. * @param {Object} source The source object.
  3135. * @returns {Object} Returns `object`.
  3136. */
  3137. function baseAssignIn(object, source) {
  3138. return object && copyObject(source, keysIn(source), object);
  3139. }
  3140. /**
  3141. * The base implementation of `assignValue` and `assignMergeValue` without
  3142. * value checks.
  3143. *
  3144. * @private
  3145. * @param {Object} object The object to modify.
  3146. * @param {string} key The key of the property to assign.
  3147. * @param {*} value The value to assign.
  3148. */
  3149. function baseAssignValue(object, key, value) {
  3150. if (key == '__proto__' && defineProperty) {
  3151. defineProperty(object, key, {
  3152. 'configurable': true,
  3153. 'enumerable': true,
  3154. 'value': value,
  3155. 'writable': true
  3156. });
  3157. } else {
  3158. object[key] = value;
  3159. }
  3160. }
  3161. /**
  3162. * The base implementation of `_.at` without support for individual paths.
  3163. *
  3164. * @private
  3165. * @param {Object} object The object to iterate over.
  3166. * @param {string[]} paths The property paths to pick.
  3167. * @returns {Array} Returns the picked elements.
  3168. */
  3169. function baseAt(object, paths) {
  3170. var index = -1,
  3171. length = paths.length,
  3172. result = Array(length),
  3173. skip = object == null;
  3174. while (++index < length) {
  3175. result[index] = skip ? undefined : get(object, paths[index]);
  3176. }
  3177. return result;
  3178. }
  3179. /**
  3180. * The base implementation of `_.clamp` which doesn't coerce arguments.
  3181. *
  3182. * @private
  3183. * @param {number} number The number to clamp.
  3184. * @param {number} [lower] The lower bound.
  3185. * @param {number} upper The upper bound.
  3186. * @returns {number} Returns the clamped number.
  3187. */
  3188. function baseClamp(number, lower, upper) {
  3189. if (number === number) {
  3190. if (upper !== undefined) {
  3191. number = number <= upper ? number : upper;
  3192. }
  3193. if (lower !== undefined) {
  3194. number = number >= lower ? number : lower;
  3195. }
  3196. }
  3197. return number;
  3198. }
  3199. /**
  3200. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  3201. * traversed objects.
  3202. *
  3203. * @private
  3204. * @param {*} value The value to clone.
  3205. * @param {boolean} bitmask The bitmask flags.
  3206. * 1 - Deep clone
  3207. * 2 - Flatten inherited properties
  3208. * 4 - Clone symbols
  3209. * @param {Function} [customizer] The function to customize cloning.
  3210. * @param {string} [key] The key of `value`.
  3211. * @param {Object} [object] The parent object of `value`.
  3212. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  3213. * @returns {*} Returns the cloned value.
  3214. */
  3215. function baseClone(value, bitmask, customizer, key, object, stack) {
  3216. var result,
  3217. isDeep = bitmask & CLONE_DEEP_FLAG,
  3218. isFlat = bitmask & CLONE_FLAT_FLAG,
  3219. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  3220. if (customizer) {
  3221. result = object ? customizer(value, key, object, stack) : customizer(value);
  3222. }
  3223. if (result !== undefined) {
  3224. return result;
  3225. }
  3226. if (!isObject(value)) {
  3227. return value;
  3228. }
  3229. var isArr = isArray(value);
  3230. if (isArr) {
  3231. result = initCloneArray(value);
  3232. if (!isDeep) {
  3233. return copyArray(value, result);
  3234. }
  3235. } else {
  3236. var tag = getTag(value),
  3237. isFunc = tag == funcTag || tag == genTag;
  3238. if (isBuffer(value)) {
  3239. return cloneBuffer(value, isDeep);
  3240. }
  3241. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  3242. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  3243. if (!isDeep) {
  3244. return isFlat
  3245. ? copySymbolsIn(value, baseAssignIn(result, value))
  3246. : copySymbols(value, baseAssign(result, value));
  3247. }
  3248. } else {
  3249. if (!cloneableTags[tag]) {
  3250. return object ? value : {};
  3251. }
  3252. result = initCloneByTag(value, tag, baseClone, isDeep);
  3253. }
  3254. }
  3255. // Check for circular references and return its corresponding clone.
  3256. stack || (stack = new Stack);
  3257. var stacked = stack.get(value);
  3258. if (stacked) {
  3259. return stacked;
  3260. }
  3261. stack.set(value, result);
  3262. var keysFunc = isFull
  3263. ? (isFlat ? getAllKeysIn : getAllKeys)
  3264. : (isFlat ? keysIn : keys);
  3265. var props = isArr ? undefined : keysFunc(value);
  3266. arrayEach(props || value, function(subValue, key) {
  3267. if (props) {
  3268. key = subValue;
  3269. subValue = value[key];
  3270. }
  3271. // Recursively populate clone (susceptible to call stack limits).
  3272. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  3273. });
  3274. return result;
  3275. }
  3276. /**
  3277. * The base implementation of `_.conforms` which doesn't clone `source`.
  3278. *
  3279. * @private
  3280. * @param {Object} source The object of property predicates to conform to.
  3281. * @returns {Function} Returns the new spec function.
  3282. */
  3283. function baseConforms(source) {
  3284. var props = keys(source);
  3285. return function(object) {
  3286. return baseConformsTo(object, source, props);
  3287. };
  3288. }
  3289. /**
  3290. * The base implementation of `_.conformsTo` which accepts `props` to check.
  3291. *
  3292. * @private
  3293. * @param {Object} object The object to inspect.
  3294. * @param {Object} source The object of property predicates to conform to.
  3295. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  3296. */
  3297. function baseConformsTo(object, source, props) {
  3298. var length = props.length;
  3299. if (object == null) {
  3300. return !length;
  3301. }
  3302. object = Object(object);
  3303. while (length--) {
  3304. var key = props[length],
  3305. predicate = source[key],
  3306. value = object[key];
  3307. if ((value === undefined && !(key in object)) || !predicate(value)) {
  3308. return false;
  3309. }
  3310. }
  3311. return true;
  3312. }
  3313. /**
  3314. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  3315. * to provide to `func`.
  3316. *
  3317. * @private
  3318. * @param {Function} func The function to delay.
  3319. * @param {number} wait The number of milliseconds to delay invocation.
  3320. * @param {Array} args The arguments to provide to `func`.
  3321. * @returns {number|Object} Returns the timer id or timeout object.
  3322. */
  3323. function baseDelay(func, wait, args) {
  3324. if (typeof func != 'function') {
  3325. throw new TypeError(FUNC_ERROR_TEXT);
  3326. }
  3327. return setTimeout(function() { func.apply(undefined, args); }, wait);
  3328. }
  3329. /**
  3330. * The base implementation of methods like `_.difference` without support
  3331. * for excluding multiple arrays or iteratee shorthands.
  3332. *
  3333. * @private
  3334. * @param {Array} array The array to inspect.
  3335. * @param {Array} values The values to exclude.
  3336. * @param {Function} [iteratee] The iteratee invoked per element.
  3337. * @param {Function} [comparator] The comparator invoked per element.
  3338. * @returns {Array} Returns the new array of filtered values.
  3339. */
  3340. function baseDifference(array, values, iteratee, comparator) {
  3341. var index = -1,
  3342. includes = arrayIncludes,
  3343. isCommon = true,
  3344. length = array.length,
  3345. result = [],
  3346. valuesLength = values.length;
  3347. if (!length) {
  3348. return result;
  3349. }
  3350. if (iteratee) {
  3351. values = arrayMap(values, baseUnary(iteratee));
  3352. }
  3353. if (comparator) {
  3354. includes = arrayIncludesWith;
  3355. isCommon = false;
  3356. }
  3357. else if (values.length >= LARGE_ARRAY_SIZE) {
  3358. includes = cacheHas;
  3359. isCommon = false;
  3360. values = new SetCache(values);
  3361. }
  3362. outer:
  3363. while (++index < length) {
  3364. var value = array[index],
  3365. computed = iteratee == null ? value : iteratee(value);
  3366. value = (comparator || value !== 0) ? value : 0;
  3367. if (isCommon && computed === computed) {
  3368. var valuesIndex = valuesLength;
  3369. while (valuesIndex--) {
  3370. if (values[valuesIndex] === computed) {
  3371. continue outer;
  3372. }
  3373. }
  3374. result.push(value);
  3375. }
  3376. else if (!includes(values, computed, comparator)) {
  3377. result.push(value);
  3378. }
  3379. }
  3380. return result;
  3381. }
  3382. /**
  3383. * The base implementation of `_.forEach` without support for iteratee shorthands.
  3384. *
  3385. * @private
  3386. * @param {Array|Object} collection The collection to iterate over.
  3387. * @param {Function} iteratee The function invoked per iteration.
  3388. * @returns {Array|Object} Returns `collection`.
  3389. */
  3390. var baseEach = createBaseEach(baseForOwn);
  3391. /**
  3392. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  3393. *
  3394. * @private
  3395. * @param {Array|Object} collection The collection to iterate over.
  3396. * @param {Function} iteratee The function invoked per iteration.
  3397. * @returns {Array|Object} Returns `collection`.
  3398. */
  3399. var baseEachRight = createBaseEach(baseForOwnRight, true);
  3400. /**
  3401. * The base implementation of `_.every` without support for iteratee shorthands.
  3402. *
  3403. * @private
  3404. * @param {Array|Object} collection The collection to iterate over.
  3405. * @param {Function} predicate The function invoked per iteration.
  3406. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  3407. * else `false`
  3408. */
  3409. function baseEvery(collection, predicate) {
  3410. var result = true;
  3411. baseEach(collection, function(value, index, collection) {
  3412. result = !!predicate(value, index, collection);
  3413. return result;
  3414. });
  3415. return result;
  3416. }
  3417. /**
  3418. * The base implementation of methods like `_.max` and `_.min` which accepts a
  3419. * `comparator` to determine the extremum value.
  3420. *
  3421. * @private
  3422. * @param {Array} array The array to iterate over.
  3423. * @param {Function} iteratee The iteratee invoked per iteration.
  3424. * @param {Function} comparator The comparator used to compare values.
  3425. * @returns {*} Returns the extremum value.
  3426. */
  3427. function baseExtremum(array, iteratee, comparator) {
  3428. var index = -1,
  3429. length = array.length;
  3430. while (++index < length) {
  3431. var value = array[index],
  3432. current = iteratee(value);
  3433. if (current != null && (computed === undefined
  3434. ? (current === current && !isSymbol(current))
  3435. : comparator(current, computed)
  3436. )) {
  3437. var computed = current,
  3438. result = value;
  3439. }
  3440. }
  3441. return result;
  3442. }
  3443. /**
  3444. * The base implementation of `_.fill` without an iteratee call guard.
  3445. *
  3446. * @private
  3447. * @param {Array} array The array to fill.
  3448. * @param {*} value The value to fill `array` with.
  3449. * @param {number} [start=0] The start position.
  3450. * @param {number} [end=array.length] The end position.
  3451. * @returns {Array} Returns `array`.
  3452. */
  3453. function baseFill(array, value, start, end) {
  3454. var length = array.length;
  3455. start = toInteger(start);
  3456. if (start < 0) {
  3457. start = -start > length ? 0 : (length + start);
  3458. }
  3459. end = (end === undefined || end > length) ? length : toInteger(end);
  3460. if (end < 0) {
  3461. end += length;
  3462. }
  3463. end = start > end ? 0 : toLength(end);
  3464. while (start < end) {
  3465. array[start++] = value;
  3466. }
  3467. return array;
  3468. }
  3469. /**
  3470. * The base implementation of `_.filter` without support for iteratee shorthands.
  3471. *
  3472. * @private
  3473. * @param {Array|Object} collection The collection to iterate over.
  3474. * @param {Function} predicate The function invoked per iteration.
  3475. * @returns {Array} Returns the new filtered array.
  3476. */
  3477. function baseFilter(collection, predicate) {
  3478. var result = [];
  3479. baseEach(collection, function(value, index, collection) {
  3480. if (predicate(value, index, collection)) {
  3481. result.push(value);
  3482. }
  3483. });
  3484. return result;
  3485. }
  3486. /**
  3487. * The base implementation of `_.flatten` with support for restricting flattening.
  3488. *
  3489. * @private
  3490. * @param {Array} array The array to flatten.
  3491. * @param {number} depth The maximum recursion depth.
  3492. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  3493. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  3494. * @param {Array} [result=[]] The initial result value.
  3495. * @returns {Array} Returns the new flattened array.
  3496. */
  3497. function baseFlatten(array, depth, predicate, isStrict, result) {
  3498. var index = -1,
  3499. length = array.length;
  3500. predicate || (predicate = isFlattenable);
  3501. result || (result = []);
  3502. while (++index < length) {
  3503. var value = array[index];
  3504. if (depth > 0 && predicate(value)) {
  3505. if (depth > 1) {
  3506. // Recursively flatten arrays (susceptible to call stack limits).
  3507. baseFlatten(value, depth - 1, predicate, isStrict, result);
  3508. } else {
  3509. arrayPush(result, value);
  3510. }
  3511. } else if (!isStrict) {
  3512. result[result.length] = value;
  3513. }
  3514. }
  3515. return result;
  3516. }
  3517. /**
  3518. * The base implementation of `baseForOwn` which iterates over `object`
  3519. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  3520. * Iteratee functions may exit iteration early by explicitly returning `false`.
  3521. *
  3522. * @private
  3523. * @param {Object} object The object to iterate over.
  3524. * @param {Function} iteratee The function invoked per iteration.
  3525. * @param {Function} keysFunc The function to get the keys of `object`.
  3526. * @returns {Object} Returns `object`.
  3527. */
  3528. var baseFor = createBaseFor();
  3529. /**
  3530. * This function is like `baseFor` except that it iterates over properties
  3531. * in the opposite order.
  3532. *
  3533. * @private
  3534. * @param {Object} object The object to iterate over.
  3535. * @param {Function} iteratee The function invoked per iteration.
  3536. * @param {Function} keysFunc The function to get the keys of `object`.
  3537. * @returns {Object} Returns `object`.
  3538. */
  3539. var baseForRight = createBaseFor(true);
  3540. /**
  3541. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  3542. *
  3543. * @private
  3544. * @param {Object} object The object to iterate over.
  3545. * @param {Function} iteratee The function invoked per iteration.
  3546. * @returns {Object} Returns `object`.
  3547. */
  3548. function baseForOwn(object, iteratee) {
  3549. return object && baseFor(object, iteratee, keys);
  3550. }
  3551. /**
  3552. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  3553. *
  3554. * @private
  3555. * @param {Object} object The object to iterate over.
  3556. * @param {Function} iteratee The function invoked per iteration.
  3557. * @returns {Object} Returns `object`.
  3558. */
  3559. function baseForOwnRight(object, iteratee) {
  3560. return object && baseForRight(object, iteratee, keys);
  3561. }
  3562. /**
  3563. * The base implementation of `_.functions` which creates an array of
  3564. * `object` function property names filtered from `props`.
  3565. *
  3566. * @private
  3567. * @param {Object} object The object to inspect.
  3568. * @param {Array} props The property names to filter.
  3569. * @returns {Array} Returns the function names.
  3570. */
  3571. function baseFunctions(object, props) {
  3572. return arrayFilter(props, function(key) {
  3573. return isFunction(object[key]);
  3574. });
  3575. }
  3576. /**
  3577. * The base implementation of `_.get` without support for default values.
  3578. *
  3579. * @private
  3580. * @param {Object} object The object to query.
  3581. * @param {Array|string} path The path of the property to get.
  3582. * @returns {*} Returns the resolved value.
  3583. */
  3584. function baseGet(object, path) {
  3585. path = castPath(path, object);
  3586. var index = 0,
  3587. length = path.length;
  3588. while (object != null && index < length) {
  3589. object = object[toKey(path[index++])];
  3590. }
  3591. return (index && index == length) ? object : undefined;
  3592. }
  3593. /**
  3594. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  3595. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  3596. * symbols of `object`.
  3597. *
  3598. * @private
  3599. * @param {Object} object The object to query.
  3600. * @param {Function} keysFunc The function to get the keys of `object`.
  3601. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  3602. * @returns {Array} Returns the array of property names and symbols.
  3603. */
  3604. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  3605. var result = keysFunc(object);
  3606. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  3607. }
  3608. /**
  3609. * The base implementation of `getTag` without fallbacks for buggy environments.
  3610. *
  3611. * @private
  3612. * @param {*} value The value to query.
  3613. * @returns {string} Returns the `toStringTag`.
  3614. */
  3615. function baseGetTag(value) {
  3616. if (value == null) {
  3617. return value === undefined ? undefinedTag : nullTag;
  3618. }
  3619. return (symToStringTag && symToStringTag in Object(value))
  3620. ? getRawTag(value)
  3621. : objectToString(value);
  3622. }
  3623. /**
  3624. * The base implementation of `_.gt` which doesn't coerce arguments.
  3625. *
  3626. * @private
  3627. * @param {*} value The value to compare.
  3628. * @param {*} other The other value to compare.
  3629. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  3630. * else `false`.
  3631. */
  3632. function baseGt(value, other) {
  3633. return value > other;
  3634. }
  3635. /**
  3636. * The base implementation of `_.has` without support for deep paths.
  3637. *
  3638. * @private
  3639. * @param {Object} [object] The object to query.
  3640. * @param {Array|string} key The key to check.
  3641. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3642. */
  3643. function baseHas(object, key) {
  3644. return object != null && hasOwnProperty.call(object, key);
  3645. }
  3646. /**
  3647. * The base implementation of `_.hasIn` without support for deep paths.
  3648. *
  3649. * @private
  3650. * @param {Object} [object] The object to query.
  3651. * @param {Array|string} key The key to check.
  3652. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3653. */
  3654. function baseHasIn(object, key) {
  3655. return object != null && key in Object(object);
  3656. }
  3657. /**
  3658. * The base implementation of `_.inRange` which doesn't coerce arguments.
  3659. *
  3660. * @private
  3661. * @param {number} number The number to check.
  3662. * @param {number} start The start of the range.
  3663. * @param {number} end The end of the range.
  3664. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  3665. */
  3666. function baseInRange(number, start, end) {
  3667. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  3668. }
  3669. /**
  3670. * The base implementation of methods like `_.intersection`, without support
  3671. * for iteratee shorthands, that accepts an array of arrays to inspect.
  3672. *
  3673. * @private
  3674. * @param {Array} arrays The arrays to inspect.
  3675. * @param {Function} [iteratee] The iteratee invoked per element.
  3676. * @param {Function} [comparator] The comparator invoked per element.
  3677. * @returns {Array} Returns the new array of shared values.
  3678. */
  3679. function baseIntersection(arrays, iteratee, comparator) {
  3680. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  3681. length = arrays[0].length,
  3682. othLength = arrays.length,
  3683. othIndex = othLength,
  3684. caches = Array(othLength),
  3685. maxLength = Infinity,
  3686. result = [];
  3687. while (othIndex--) {
  3688. var array = arrays[othIndex];
  3689. if (othIndex && iteratee) {
  3690. array = arrayMap(array, baseUnary(iteratee));
  3691. }
  3692. maxLength = nativeMin(array.length, maxLength);
  3693. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  3694. ? new SetCache(othIndex && array)
  3695. : undefined;
  3696. }
  3697. array = arrays[0];
  3698. var index = -1,
  3699. seen = caches[0];
  3700. outer:
  3701. while (++index < length && result.length < maxLength) {
  3702. var value = array[index],
  3703. computed = iteratee ? iteratee(value) : value;
  3704. value = (comparator || value !== 0) ? value : 0;
  3705. if (!(seen
  3706. ? cacheHas(seen, computed)
  3707. : includes(result, computed, comparator)
  3708. )) {
  3709. othIndex = othLength;
  3710. while (--othIndex) {
  3711. var cache = caches[othIndex];
  3712. if (!(cache
  3713. ? cacheHas(cache, computed)
  3714. : includes(arrays[othIndex], computed, comparator))
  3715. ) {
  3716. continue outer;
  3717. }
  3718. }
  3719. if (seen) {
  3720. seen.push(computed);
  3721. }
  3722. result.push(value);
  3723. }
  3724. }
  3725. return result;
  3726. }
  3727. /**
  3728. * The base implementation of `_.invert` and `_.invertBy` which inverts
  3729. * `object` with values transformed by `iteratee` and set by `setter`.
  3730. *
  3731. * @private
  3732. * @param {Object} object The object to iterate over.
  3733. * @param {Function} setter The function to set `accumulator` values.
  3734. * @param {Function} iteratee The iteratee to transform values.
  3735. * @param {Object} accumulator The initial inverted object.
  3736. * @returns {Function} Returns `accumulator`.
  3737. */
  3738. function baseInverter(object, setter, iteratee, accumulator) {
  3739. baseForOwn(object, function(value, key, object) {
  3740. setter(accumulator, iteratee(value), key, object);
  3741. });
  3742. return accumulator;
  3743. }
  3744. /**
  3745. * The base implementation of `_.invoke` without support for individual
  3746. * method arguments.
  3747. *
  3748. * @private
  3749. * @param {Object} object The object to query.
  3750. * @param {Array|string} path The path of the method to invoke.
  3751. * @param {Array} args The arguments to invoke the method with.
  3752. * @returns {*} Returns the result of the invoked method.
  3753. */
  3754. function baseInvoke(object, path, args) {
  3755. path = castPath(path, object);
  3756. object = parent(object, path);
  3757. var func = object == null ? object : object[toKey(last(path))];
  3758. return func == null ? undefined : apply(func, object, args);
  3759. }
  3760. /**
  3761. * The base implementation of `_.isArguments`.
  3762. *
  3763. * @private
  3764. * @param {*} value The value to check.
  3765. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  3766. */
  3767. function baseIsArguments(value) {
  3768. return isObjectLike(value) && baseGetTag(value) == argsTag;
  3769. }
  3770. /**
  3771. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  3772. *
  3773. * @private
  3774. * @param {*} value The value to check.
  3775. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  3776. */
  3777. function baseIsArrayBuffer(value) {
  3778. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  3779. }
  3780. /**
  3781. * The base implementation of `_.isDate` without Node.js optimizations.
  3782. *
  3783. * @private
  3784. * @param {*} value The value to check.
  3785. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  3786. */
  3787. function baseIsDate(value) {
  3788. return isObjectLike(value) && baseGetTag(value) == dateTag;
  3789. }
  3790. /**
  3791. * The base implementation of `_.isEqual` which supports partial comparisons
  3792. * and tracks traversed objects.
  3793. *
  3794. * @private
  3795. * @param {*} value The value to compare.
  3796. * @param {*} other The other value to compare.
  3797. * @param {boolean} bitmask The bitmask flags.
  3798. * 1 - Unordered comparison
  3799. * 2 - Partial comparison
  3800. * @param {Function} [customizer] The function to customize comparisons.
  3801. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  3802. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3803. */
  3804. function baseIsEqual(value, other, bitmask, customizer, stack) {
  3805. if (value === other) {
  3806. return true;
  3807. }
  3808. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  3809. return value !== value && other !== other;
  3810. }
  3811. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  3812. }
  3813. /**
  3814. * A specialized version of `baseIsEqual` for arrays and objects which performs
  3815. * deep comparisons and tracks traversed objects enabling objects with circular
  3816. * references to be compared.
  3817. *
  3818. * @private
  3819. * @param {Object} object The object to compare.
  3820. * @param {Object} other The other object to compare.
  3821. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  3822. * @param {Function} customizer The function to customize comparisons.
  3823. * @param {Function} equalFunc The function to determine equivalents of values.
  3824. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  3825. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3826. */
  3827. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  3828. var objIsArr = isArray(object),
  3829. othIsArr = isArray(other),
  3830. objTag = objIsArr ? arrayTag : getTag(object),
  3831. othTag = othIsArr ? arrayTag : getTag(other);
  3832. objTag = objTag == argsTag ? objectTag : objTag;
  3833. othTag = othTag == argsTag ? objectTag : othTag;
  3834. var objIsObj = objTag == objectTag,
  3835. othIsObj = othTag == objectTag,
  3836. isSameTag = objTag == othTag;
  3837. if (isSameTag && isBuffer(object)) {
  3838. if (!isBuffer(other)) {
  3839. return false;
  3840. }
  3841. objIsArr = true;
  3842. objIsObj = false;
  3843. }
  3844. if (isSameTag && !objIsObj) {
  3845. stack || (stack = new Stack);
  3846. return (objIsArr || isTypedArray(object))
  3847. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  3848. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  3849. }
  3850. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  3851. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  3852. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  3853. if (objIsWrapped || othIsWrapped) {
  3854. var objUnwrapped = objIsWrapped ? object.value() : object,
  3855. othUnwrapped = othIsWrapped ? other.value() : other;
  3856. stack || (stack = new Stack);
  3857. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  3858. }
  3859. }
  3860. if (!isSameTag) {
  3861. return false;
  3862. }
  3863. stack || (stack = new Stack);
  3864. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  3865. }
  3866. /**
  3867. * The base implementation of `_.isMap` without Node.js optimizations.
  3868. *
  3869. * @private
  3870. * @param {*} value The value to check.
  3871. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  3872. */
  3873. function baseIsMap(value) {
  3874. return isObjectLike(value) && getTag(value) == mapTag;
  3875. }
  3876. /**
  3877. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  3878. *
  3879. * @private
  3880. * @param {Object} object The object to inspect.
  3881. * @param {Object} source The object of property values to match.
  3882. * @param {Array} matchData The property names, values, and compare flags to match.
  3883. * @param {Function} [customizer] The function to customize comparisons.
  3884. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  3885. */
  3886. function baseIsMatch(object, source, matchData, customizer) {
  3887. var index = matchData.length,
  3888. length = index,
  3889. noCustomizer = !customizer;
  3890. if (object == null) {
  3891. return !length;
  3892. }
  3893. object = Object(object);
  3894. while (index--) {
  3895. var data = matchData[index];
  3896. if ((noCustomizer && data[2])
  3897. ? data[1] !== object[data[0]]
  3898. : !(data[0] in object)
  3899. ) {
  3900. return false;
  3901. }
  3902. }
  3903. while (++index < length) {
  3904. data = matchData[index];
  3905. var key = data[0],
  3906. objValue = object[key],
  3907. srcValue = data[1];
  3908. if (noCustomizer && data[2]) {
  3909. if (objValue === undefined && !(key in object)) {
  3910. return false;
  3911. }
  3912. } else {
  3913. var stack = new Stack;
  3914. if (customizer) {
  3915. var result = customizer(objValue, srcValue, key, object, source, stack);
  3916. }
  3917. if (!(result === undefined
  3918. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  3919. : result
  3920. )) {
  3921. return false;
  3922. }
  3923. }
  3924. }
  3925. return true;
  3926. }
  3927. /**
  3928. * The base implementation of `_.isNative` without bad shim checks.
  3929. *
  3930. * @private
  3931. * @param {*} value The value to check.
  3932. * @returns {boolean} Returns `true` if `value` is a native function,
  3933. * else `false`.
  3934. */
  3935. function baseIsNative(value) {
  3936. if (!isObject(value) || isMasked(value)) {
  3937. return false;
  3938. }
  3939. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  3940. return pattern.test(toSource(value));
  3941. }
  3942. /**
  3943. * The base implementation of `_.isRegExp` without Node.js optimizations.
  3944. *
  3945. * @private
  3946. * @param {*} value The value to check.
  3947. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  3948. */
  3949. function baseIsRegExp(value) {
  3950. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  3951. }
  3952. /**
  3953. * The base implementation of `_.isSet` without Node.js optimizations.
  3954. *
  3955. * @private
  3956. * @param {*} value The value to check.
  3957. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  3958. */
  3959. function baseIsSet(value) {
  3960. return isObjectLike(value) && getTag(value) == setTag;
  3961. }
  3962. /**
  3963. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  3964. *
  3965. * @private
  3966. * @param {*} value The value to check.
  3967. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3968. */
  3969. function baseIsTypedArray(value) {
  3970. return isObjectLike(value) &&
  3971. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  3972. }
  3973. /**
  3974. * The base implementation of `_.iteratee`.
  3975. *
  3976. * @private
  3977. * @param {*} [value=_.identity] The value to convert to an iteratee.
  3978. * @returns {Function} Returns the iteratee.
  3979. */
  3980. function baseIteratee(value) {
  3981. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  3982. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  3983. if (typeof value == 'function') {
  3984. return value;
  3985. }
  3986. if (value == null) {
  3987. return identity;
  3988. }
  3989. if (typeof value == 'object') {
  3990. return isArray(value)
  3991. ? baseMatchesProperty(value[0], value[1])
  3992. : baseMatches(value);
  3993. }
  3994. return property(value);
  3995. }
  3996. /**
  3997. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  3998. *
  3999. * @private
  4000. * @param {Object} object The object to query.
  4001. * @returns {Array} Returns the array of property names.
  4002. */
  4003. function baseKeys(object) {
  4004. if (!isPrototype(object)) {
  4005. return nativeKeys(object);
  4006. }
  4007. var result = [];
  4008. for (var key in Object(object)) {
  4009. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  4010. result.push(key);
  4011. }
  4012. }
  4013. return result;
  4014. }
  4015. /**
  4016. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  4017. *
  4018. * @private
  4019. * @param {Object} object The object to query.
  4020. * @returns {Array} Returns the array of property names.
  4021. */
  4022. function baseKeysIn(object) {
  4023. if (!isObject(object)) {
  4024. return nativeKeysIn(object);
  4025. }
  4026. var isProto = isPrototype(object),
  4027. result = [];
  4028. for (var key in object) {
  4029. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  4030. result.push(key);
  4031. }
  4032. }
  4033. return result;
  4034. }
  4035. /**
  4036. * The base implementation of `_.lt` which doesn't coerce arguments.
  4037. *
  4038. * @private
  4039. * @param {*} value The value to compare.
  4040. * @param {*} other The other value to compare.
  4041. * @returns {boolean} Returns `true` if `value` is less than `other`,
  4042. * else `false`.
  4043. */
  4044. function baseLt(value, other) {
  4045. return value < other;
  4046. }
  4047. /**
  4048. * The base implementation of `_.map` without support for iteratee shorthands.
  4049. *
  4050. * @private
  4051. * @param {Array|Object} collection The collection to iterate over.
  4052. * @param {Function} iteratee The function invoked per iteration.
  4053. * @returns {Array} Returns the new mapped array.
  4054. */
  4055. function baseMap(collection, iteratee) {
  4056. var index = -1,
  4057. result = isArrayLike(collection) ? Array(collection.length) : [];
  4058. baseEach(collection, function(value, key, collection) {
  4059. result[++index] = iteratee(value, key, collection);
  4060. });
  4061. return result;
  4062. }
  4063. /**
  4064. * The base implementation of `_.matches` which doesn't clone `source`.
  4065. *
  4066. * @private
  4067. * @param {Object} source The object of property values to match.
  4068. * @returns {Function} Returns the new spec function.
  4069. */
  4070. function baseMatches(source) {
  4071. var matchData = getMatchData(source);
  4072. if (matchData.length == 1 && matchData[0][2]) {
  4073. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  4074. }
  4075. return function(object) {
  4076. return object === source || baseIsMatch(object, source, matchData);
  4077. };
  4078. }
  4079. /**
  4080. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  4081. *
  4082. * @private
  4083. * @param {string} path The path of the property to get.
  4084. * @param {*} srcValue The value to match.
  4085. * @returns {Function} Returns the new spec function.
  4086. */
  4087. function baseMatchesProperty(path, srcValue) {
  4088. if (isKey(path) && isStrictComparable(srcValue)) {
  4089. return matchesStrictComparable(toKey(path), srcValue);
  4090. }
  4091. return function(object) {
  4092. var objValue = get(object, path);
  4093. return (objValue === undefined && objValue === srcValue)
  4094. ? hasIn(object, path)
  4095. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  4096. };
  4097. }
  4098. /**
  4099. * The base implementation of `_.merge` without support for multiple sources.
  4100. *
  4101. * @private
  4102. * @param {Object} object The destination object.
  4103. * @param {Object} source The source object.
  4104. * @param {number} srcIndex The index of `source`.
  4105. * @param {Function} [customizer] The function to customize merged values.
  4106. * @param {Object} [stack] Tracks traversed source values and their merged
  4107. * counterparts.
  4108. */
  4109. function baseMerge(object, source, srcIndex, customizer, stack) {
  4110. if (object === source) {
  4111. return;
  4112. }
  4113. baseFor(source, function(srcValue, key) {
  4114. if (isObject(srcValue)) {
  4115. stack || (stack = new Stack);
  4116. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  4117. }
  4118. else {
  4119. var newValue = customizer
  4120. ? customizer(object[key], srcValue, (key + ''), object, source, stack)
  4121. : undefined;
  4122. if (newValue === undefined) {
  4123. newValue = srcValue;
  4124. }
  4125. assignMergeValue(object, key, newValue);
  4126. }
  4127. }, keysIn);
  4128. }
  4129. /**
  4130. * A specialized version of `baseMerge` for arrays and objects which performs
  4131. * deep merges and tracks traversed objects enabling objects with circular
  4132. * references to be merged.
  4133. *
  4134. * @private
  4135. * @param {Object} object The destination object.
  4136. * @param {Object} source The source object.
  4137. * @param {string} key The key of the value to merge.
  4138. * @param {number} srcIndex The index of `source`.
  4139. * @param {Function} mergeFunc The function to merge values.
  4140. * @param {Function} [customizer] The function to customize assigned values.
  4141. * @param {Object} [stack] Tracks traversed source values and their merged
  4142. * counterparts.
  4143. */
  4144. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  4145. var objValue = object[key],
  4146. srcValue = source[key],
  4147. stacked = stack.get(srcValue);
  4148. if (stacked) {
  4149. assignMergeValue(object, key, stacked);
  4150. return;
  4151. }
  4152. var newValue = customizer
  4153. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  4154. : undefined;
  4155. var isCommon = newValue === undefined;
  4156. if (isCommon) {
  4157. var isArr = isArray(srcValue),
  4158. isBuff = !isArr && isBuffer(srcValue),
  4159. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  4160. newValue = srcValue;
  4161. if (isArr || isBuff || isTyped) {
  4162. if (isArray(objValue)) {
  4163. newValue = objValue;
  4164. }
  4165. else if (isArrayLikeObject(objValue)) {
  4166. newValue = copyArray(objValue);
  4167. }
  4168. else if (isBuff) {
  4169. isCommon = false;
  4170. newValue = cloneBuffer(srcValue, true);
  4171. }
  4172. else if (isTyped) {
  4173. isCommon = false;
  4174. newValue = cloneTypedArray(srcValue, true);
  4175. }
  4176. else {
  4177. newValue = [];
  4178. }
  4179. }
  4180. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  4181. newValue = objValue;
  4182. if (isArguments(objValue)) {
  4183. newValue = toPlainObject(objValue);
  4184. }
  4185. else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
  4186. newValue = initCloneObject(srcValue);
  4187. }
  4188. }
  4189. else {
  4190. isCommon = false;
  4191. }
  4192. }
  4193. if (isCommon) {
  4194. // Recursively merge objects and arrays (susceptible to call stack limits).
  4195. stack.set(srcValue, newValue);
  4196. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  4197. stack['delete'](srcValue);
  4198. }
  4199. assignMergeValue(object, key, newValue);
  4200. }
  4201. /**
  4202. * The base implementation of `_.nth` which doesn't coerce arguments.
  4203. *
  4204. * @private
  4205. * @param {Array} array The array to query.
  4206. * @param {number} n The index of the element to return.
  4207. * @returns {*} Returns the nth element of `array`.
  4208. */
  4209. function baseNth(array, n) {
  4210. var length = array.length;
  4211. if (!length) {
  4212. return;
  4213. }
  4214. n += n < 0 ? length : 0;
  4215. return isIndex(n, length) ? array[n] : undefined;
  4216. }
  4217. /**
  4218. * The base implementation of `_.orderBy` without param guards.
  4219. *
  4220. * @private
  4221. * @param {Array|Object} collection The collection to iterate over.
  4222. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  4223. * @param {string[]} orders The sort orders of `iteratees`.
  4224. * @returns {Array} Returns the new sorted array.
  4225. */
  4226. function baseOrderBy(collection, iteratees, orders) {
  4227. var index = -1;
  4228. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  4229. var result = baseMap(collection, function(value, key, collection) {
  4230. var criteria = arrayMap(iteratees, function(iteratee) {
  4231. return iteratee(value);
  4232. });
  4233. return { 'criteria': criteria, 'index': ++index, 'value': value };
  4234. });
  4235. return baseSortBy(result, function(object, other) {
  4236. return compareMultiple(object, other, orders);
  4237. });
  4238. }
  4239. /**
  4240. * The base implementation of `_.pick` without support for individual
  4241. * property identifiers.
  4242. *
  4243. * @private
  4244. * @param {Object} object The source object.
  4245. * @param {string[]} paths The property paths to pick.
  4246. * @returns {Object} Returns the new object.
  4247. */
  4248. function basePick(object, paths) {
  4249. return basePickBy(object, paths, function(value, path) {
  4250. return hasIn(object, path);
  4251. });
  4252. }
  4253. /**
  4254. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  4255. *
  4256. * @private
  4257. * @param {Object} object The source object.
  4258. * @param {string[]} paths The property paths to pick.
  4259. * @param {Function} predicate The function invoked per property.
  4260. * @returns {Object} Returns the new object.
  4261. */
  4262. function basePickBy(object, paths, predicate) {
  4263. var index = -1,
  4264. length = paths.length,
  4265. result = {};
  4266. while (++index < length) {
  4267. var path = paths[index],
  4268. value = baseGet(object, path);
  4269. if (predicate(value, path)) {
  4270. baseSet(result, castPath(path, object), value);
  4271. }
  4272. }
  4273. return result;
  4274. }
  4275. /**
  4276. * A specialized version of `baseProperty` which supports deep paths.
  4277. *
  4278. * @private
  4279. * @param {Array|string} path The path of the property to get.
  4280. * @returns {Function} Returns the new accessor function.
  4281. */
  4282. function basePropertyDeep(path) {
  4283. return function(object) {
  4284. return baseGet(object, path);
  4285. };
  4286. }
  4287. /**
  4288. * The base implementation of `_.pullAllBy` without support for iteratee
  4289. * shorthands.
  4290. *
  4291. * @private
  4292. * @param {Array} array The array to modify.
  4293. * @param {Array} values The values to remove.
  4294. * @param {Function} [iteratee] The iteratee invoked per element.
  4295. * @param {Function} [comparator] The comparator invoked per element.
  4296. * @returns {Array} Returns `array`.
  4297. */
  4298. function basePullAll(array, values, iteratee, comparator) {
  4299. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  4300. index = -1,
  4301. length = values.length,
  4302. seen = array;
  4303. if (array === values) {
  4304. values = copyArray(values);
  4305. }
  4306. if (iteratee) {
  4307. seen = arrayMap(array, baseUnary(iteratee));
  4308. }
  4309. while (++index < length) {
  4310. var fromIndex = 0,
  4311. value = values[index],
  4312. computed = iteratee ? iteratee(value) : value;
  4313. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  4314. if (seen !== array) {
  4315. splice.call(seen, fromIndex, 1);
  4316. }
  4317. splice.call(array, fromIndex, 1);
  4318. }
  4319. }
  4320. return array;
  4321. }
  4322. /**
  4323. * The base implementation of `_.pullAt` without support for individual
  4324. * indexes or capturing the removed elements.
  4325. *
  4326. * @private
  4327. * @param {Array} array The array to modify.
  4328. * @param {number[]} indexes The indexes of elements to remove.
  4329. * @returns {Array} Returns `array`.
  4330. */
  4331. function basePullAt(array, indexes) {
  4332. var length = array ? indexes.length : 0,
  4333. lastIndex = length - 1;
  4334. while (length--) {
  4335. var index = indexes[length];
  4336. if (length == lastIndex || index !== previous) {
  4337. var previous = index;
  4338. if (isIndex(index)) {
  4339. splice.call(array, index, 1);
  4340. } else {
  4341. baseUnset(array, index);
  4342. }
  4343. }
  4344. }
  4345. return array;
  4346. }
  4347. /**
  4348. * The base implementation of `_.random` without support for returning
  4349. * floating-point numbers.
  4350. *
  4351. * @private
  4352. * @param {number} lower The lower bound.
  4353. * @param {number} upper The upper bound.
  4354. * @returns {number} Returns the random number.
  4355. */
  4356. function baseRandom(lower, upper) {
  4357. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  4358. }
  4359. /**
  4360. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  4361. * coerce arguments.
  4362. *
  4363. * @private
  4364. * @param {number} start The start of the range.
  4365. * @param {number} end The end of the range.
  4366. * @param {number} step The value to increment or decrement by.
  4367. * @param {boolean} [fromRight] Specify iterating from right to left.
  4368. * @returns {Array} Returns the range of numbers.
  4369. */
  4370. function baseRange(start, end, step, fromRight) {
  4371. var index = -1,
  4372. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  4373. result = Array(length);
  4374. while (length--) {
  4375. result[fromRight ? length : ++index] = start;
  4376. start += step;
  4377. }
  4378. return result;
  4379. }
  4380. /**
  4381. * The base implementation of `_.repeat` which doesn't coerce arguments.
  4382. *
  4383. * @private
  4384. * @param {string} string The string to repeat.
  4385. * @param {number} n The number of times to repeat the string.
  4386. * @returns {string} Returns the repeated string.
  4387. */
  4388. function baseRepeat(string, n) {
  4389. var result = '';
  4390. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  4391. return result;
  4392. }
  4393. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  4394. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  4395. do {
  4396. if (n % 2) {
  4397. result += string;
  4398. }
  4399. n = nativeFloor(n / 2);
  4400. if (n) {
  4401. string += string;
  4402. }
  4403. } while (n);
  4404. return result;
  4405. }
  4406. /**
  4407. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  4408. *
  4409. * @private
  4410. * @param {Function} func The function to apply a rest parameter to.
  4411. * @param {number} [start=func.length-1] The start position of the rest parameter.
  4412. * @returns {Function} Returns the new function.
  4413. */
  4414. function baseRest(func, start) {
  4415. return setToString(overRest(func, start, identity), func + '');
  4416. }
  4417. /**
  4418. * The base implementation of `_.sample`.
  4419. *
  4420. * @private
  4421. * @param {Array|Object} collection The collection to sample.
  4422. * @returns {*} Returns the random element.
  4423. */
  4424. function baseSample(collection) {
  4425. return arraySample(values(collection));
  4426. }
  4427. /**
  4428. * The base implementation of `_.sampleSize` without param guards.
  4429. *
  4430. * @private
  4431. * @param {Array|Object} collection The collection to sample.
  4432. * @param {number} n The number of elements to sample.
  4433. * @returns {Array} Returns the random elements.
  4434. */
  4435. function baseSampleSize(collection, n) {
  4436. var array = values(collection);
  4437. return shuffleSelf(array, baseClamp(n, 0, array.length));
  4438. }
  4439. /**
  4440. * The base implementation of `_.set`.
  4441. *
  4442. * @private
  4443. * @param {Object} object The object to modify.
  4444. * @param {Array|string} path The path of the property to set.
  4445. * @param {*} value The value to set.
  4446. * @param {Function} [customizer] The function to customize path creation.
  4447. * @returns {Object} Returns `object`.
  4448. */
  4449. function baseSet(object, path, value, customizer) {
  4450. if (!isObject(object)) {
  4451. return object;
  4452. }
  4453. path = castPath(path, object);
  4454. var index = -1,
  4455. length = path.length,
  4456. lastIndex = length - 1,
  4457. nested = object;
  4458. while (nested != null && ++index < length) {
  4459. var key = toKey(path[index]),
  4460. newValue = value;
  4461. if (index != lastIndex) {
  4462. var objValue = nested[key];
  4463. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  4464. if (newValue === undefined) {
  4465. newValue = isObject(objValue)
  4466. ? objValue
  4467. : (isIndex(path[index + 1]) ? [] : {});
  4468. }
  4469. }
  4470. assignValue(nested, key, newValue);
  4471. nested = nested[key];
  4472. }
  4473. return object;
  4474. }
  4475. /**
  4476. * The base implementation of `setData` without support for hot loop shorting.
  4477. *
  4478. * @private
  4479. * @param {Function} func The function to associate metadata with.
  4480. * @param {*} data The metadata.
  4481. * @returns {Function} Returns `func`.
  4482. */
  4483. var baseSetData = !metaMap ? identity : function(func, data) {
  4484. metaMap.set(func, data);
  4485. return func;
  4486. };
  4487. /**
  4488. * The base implementation of `setToString` without support for hot loop shorting.
  4489. *
  4490. * @private
  4491. * @param {Function} func The function to modify.
  4492. * @param {Function} string The `toString` result.
  4493. * @returns {Function} Returns `func`.
  4494. */
  4495. var baseSetToString = !defineProperty ? identity : function(func, string) {
  4496. return defineProperty(func, 'toString', {
  4497. 'configurable': true,
  4498. 'enumerable': false,
  4499. 'value': constant(string),
  4500. 'writable': true
  4501. });
  4502. };
  4503. /**
  4504. * The base implementation of `_.shuffle`.
  4505. *
  4506. * @private
  4507. * @param {Array|Object} collection The collection to shuffle.
  4508. * @returns {Array} Returns the new shuffled array.
  4509. */
  4510. function baseShuffle(collection) {
  4511. return shuffleSelf(values(collection));
  4512. }
  4513. /**
  4514. * The base implementation of `_.slice` without an iteratee call guard.
  4515. *
  4516. * @private
  4517. * @param {Array} array The array to slice.
  4518. * @param {number} [start=0] The start position.
  4519. * @param {number} [end=array.length] The end position.
  4520. * @returns {Array} Returns the slice of `array`.
  4521. */
  4522. function baseSlice(array, start, end) {
  4523. var index = -1,
  4524. length = array.length;
  4525. if (start < 0) {
  4526. start = -start > length ? 0 : (length + start);
  4527. }
  4528. end = end > length ? length : end;
  4529. if (end < 0) {
  4530. end += length;
  4531. }
  4532. length = start > end ? 0 : ((end - start) >>> 0);
  4533. start >>>= 0;
  4534. var result = Array(length);
  4535. while (++index < length) {
  4536. result[index] = array[index + start];
  4537. }
  4538. return result;
  4539. }
  4540. /**
  4541. * The base implementation of `_.some` without support for iteratee shorthands.
  4542. *
  4543. * @private
  4544. * @param {Array|Object} collection The collection to iterate over.
  4545. * @param {Function} predicate The function invoked per iteration.
  4546. * @returns {boolean} Returns `true` if any element passes the predicate check,
  4547. * else `false`.
  4548. */
  4549. function baseSome(collection, predicate) {
  4550. var result;
  4551. baseEach(collection, function(value, index, collection) {
  4552. result = predicate(value, index, collection);
  4553. return !result;
  4554. });
  4555. return !!result;
  4556. }
  4557. /**
  4558. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  4559. * performs a binary search of `array` to determine the index at which `value`
  4560. * should be inserted into `array` in order to maintain its sort order.
  4561. *
  4562. * @private
  4563. * @param {Array} array The sorted array to inspect.
  4564. * @param {*} value The value to evaluate.
  4565. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  4566. * @returns {number} Returns the index at which `value` should be inserted
  4567. * into `array`.
  4568. */
  4569. function baseSortedIndex(array, value, retHighest) {
  4570. var low = 0,
  4571. high = array == null ? low : array.length;
  4572. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  4573. while (low < high) {
  4574. var mid = (low + high) >>> 1,
  4575. computed = array[mid];
  4576. if (computed !== null && !isSymbol(computed) &&
  4577. (retHighest ? (computed <= value) : (computed < value))) {
  4578. low = mid + 1;
  4579. } else {
  4580. high = mid;
  4581. }
  4582. }
  4583. return high;
  4584. }
  4585. return baseSortedIndexBy(array, value, identity, retHighest);
  4586. }
  4587. /**
  4588. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  4589. * which invokes `iteratee` for `value` and each element of `array` to compute
  4590. * their sort ranking. The iteratee is invoked with one argument; (value).
  4591. *
  4592. * @private
  4593. * @param {Array} array The sorted array to inspect.
  4594. * @param {*} value The value to evaluate.
  4595. * @param {Function} iteratee The iteratee invoked per element.
  4596. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  4597. * @returns {number} Returns the index at which `value` should be inserted
  4598. * into `array`.
  4599. */
  4600. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  4601. value = iteratee(value);
  4602. var low = 0,
  4603. high = array == null ? 0 : array.length,
  4604. valIsNaN = value !== value,
  4605. valIsNull = value === null,
  4606. valIsSymbol = isSymbol(value),
  4607. valIsUndefined = value === undefined;
  4608. while (low < high) {
  4609. var mid = nativeFloor((low + high) / 2),
  4610. computed = iteratee(array[mid]),
  4611. othIsDefined = computed !== undefined,
  4612. othIsNull = computed === null,
  4613. othIsReflexive = computed === computed,
  4614. othIsSymbol = isSymbol(computed);
  4615. if (valIsNaN) {
  4616. var setLow = retHighest || othIsReflexive;
  4617. } else if (valIsUndefined) {
  4618. setLow = othIsReflexive && (retHighest || othIsDefined);
  4619. } else if (valIsNull) {
  4620. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  4621. } else if (valIsSymbol) {
  4622. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  4623. } else if (othIsNull || othIsSymbol) {
  4624. setLow = false;
  4625. } else {
  4626. setLow = retHighest ? (computed <= value) : (computed < value);
  4627. }
  4628. if (setLow) {
  4629. low = mid + 1;
  4630. } else {
  4631. high = mid;
  4632. }
  4633. }
  4634. return nativeMin(high, MAX_ARRAY_INDEX);
  4635. }
  4636. /**
  4637. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  4638. * support for iteratee shorthands.
  4639. *
  4640. * @private
  4641. * @param {Array} array The array to inspect.
  4642. * @param {Function} [iteratee] The iteratee invoked per element.
  4643. * @returns {Array} Returns the new duplicate free array.
  4644. */
  4645. function baseSortedUniq(array, iteratee) {
  4646. var index = -1,
  4647. length = array.length,
  4648. resIndex = 0,
  4649. result = [];
  4650. while (++index < length) {
  4651. var value = array[index],
  4652. computed = iteratee ? iteratee(value) : value;
  4653. if (!index || !eq(computed, seen)) {
  4654. var seen = computed;
  4655. result[resIndex++] = value === 0 ? 0 : value;
  4656. }
  4657. }
  4658. return result;
  4659. }
  4660. /**
  4661. * The base implementation of `_.toNumber` which doesn't ensure correct
  4662. * conversions of binary, hexadecimal, or octal string values.
  4663. *
  4664. * @private
  4665. * @param {*} value The value to process.
  4666. * @returns {number} Returns the number.
  4667. */
  4668. function baseToNumber(value) {
  4669. if (typeof value == 'number') {
  4670. return value;
  4671. }
  4672. if (isSymbol(value)) {
  4673. return NAN;
  4674. }
  4675. return +value;
  4676. }
  4677. /**
  4678. * The base implementation of `_.toString` which doesn't convert nullish
  4679. * values to empty strings.
  4680. *
  4681. * @private
  4682. * @param {*} value The value to process.
  4683. * @returns {string} Returns the string.
  4684. */
  4685. function baseToString(value) {
  4686. // Exit early for strings to avoid a performance hit in some environments.
  4687. if (typeof value == 'string') {
  4688. return value;
  4689. }
  4690. if (isArray(value)) {
  4691. // Recursively convert values (susceptible to call stack limits).
  4692. return arrayMap(value, baseToString) + '';
  4693. }
  4694. if (isSymbol(value)) {
  4695. return symbolToString ? symbolToString.call(value) : '';
  4696. }
  4697. var result = (value + '');
  4698. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  4699. }
  4700. /**
  4701. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  4702. *
  4703. * @private
  4704. * @param {Array} array The array to inspect.
  4705. * @param {Function} [iteratee] The iteratee invoked per element.
  4706. * @param {Function} [comparator] The comparator invoked per element.
  4707. * @returns {Array} Returns the new duplicate free array.
  4708. */
  4709. function baseUniq(array, iteratee, comparator) {
  4710. var index = -1,
  4711. includes = arrayIncludes,
  4712. length = array.length,
  4713. isCommon = true,
  4714. result = [],
  4715. seen = result;
  4716. if (comparator) {
  4717. isCommon = false;
  4718. includes = arrayIncludesWith;
  4719. }
  4720. else if (length >= LARGE_ARRAY_SIZE) {
  4721. var set = iteratee ? null : createSet(array);
  4722. if (set) {
  4723. return setToArray(set);
  4724. }
  4725. isCommon = false;
  4726. includes = cacheHas;
  4727. seen = new SetCache;
  4728. }
  4729. else {
  4730. seen = iteratee ? [] : result;
  4731. }
  4732. outer:
  4733. while (++index < length) {
  4734. var value = array[index],
  4735. computed = iteratee ? iteratee(value) : value;
  4736. value = (comparator || value !== 0) ? value : 0;
  4737. if (isCommon && computed === computed) {
  4738. var seenIndex = seen.length;
  4739. while (seenIndex--) {
  4740. if (seen[seenIndex] === computed) {
  4741. continue outer;
  4742. }
  4743. }
  4744. if (iteratee) {
  4745. seen.push(computed);
  4746. }
  4747. result.push(value);
  4748. }
  4749. else if (!includes(seen, computed, comparator)) {
  4750. if (seen !== result) {
  4751. seen.push(computed);
  4752. }
  4753. result.push(value);
  4754. }
  4755. }
  4756. return result;
  4757. }
  4758. /**
  4759. * The base implementation of `_.unset`.
  4760. *
  4761. * @private
  4762. * @param {Object} object The object to modify.
  4763. * @param {Array|string} path The property path to unset.
  4764. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  4765. */
  4766. function baseUnset(object, path) {
  4767. path = castPath(path, object);
  4768. object = parent(object, path);
  4769. return object == null || delete object[toKey(last(path))];
  4770. }
  4771. /**
  4772. * The base implementation of `_.update`.
  4773. *
  4774. * @private
  4775. * @param {Object} object The object to modify.
  4776. * @param {Array|string} path The path of the property to update.
  4777. * @param {Function} updater The function to produce the updated value.
  4778. * @param {Function} [customizer] The function to customize path creation.
  4779. * @returns {Object} Returns `object`.
  4780. */
  4781. function baseUpdate(object, path, updater, customizer) {
  4782. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  4783. }
  4784. /**
  4785. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  4786. * without support for iteratee shorthands.
  4787. *
  4788. * @private
  4789. * @param {Array} array The array to query.
  4790. * @param {Function} predicate The function invoked per iteration.
  4791. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  4792. * @param {boolean} [fromRight] Specify iterating from right to left.
  4793. * @returns {Array} Returns the slice of `array`.
  4794. */
  4795. function baseWhile(array, predicate, isDrop, fromRight) {
  4796. var length = array.length,
  4797. index = fromRight ? length : -1;
  4798. while ((fromRight ? index-- : ++index < length) &&
  4799. predicate(array[index], index, array)) {}
  4800. return isDrop
  4801. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  4802. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  4803. }
  4804. /**
  4805. * The base implementation of `wrapperValue` which returns the result of
  4806. * performing a sequence of actions on the unwrapped `value`, where each
  4807. * successive action is supplied the return value of the previous.
  4808. *
  4809. * @private
  4810. * @param {*} value The unwrapped value.
  4811. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  4812. * @returns {*} Returns the resolved value.
  4813. */
  4814. function baseWrapperValue(value, actions) {
  4815. var result = value;
  4816. if (result instanceof LazyWrapper) {
  4817. result = result.value();
  4818. }
  4819. return arrayReduce(actions, function(result, action) {
  4820. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  4821. }, result);
  4822. }
  4823. /**
  4824. * The base implementation of methods like `_.xor`, without support for
  4825. * iteratee shorthands, that accepts an array of arrays to inspect.
  4826. *
  4827. * @private
  4828. * @param {Array} arrays The arrays to inspect.
  4829. * @param {Function} [iteratee] The iteratee invoked per element.
  4830. * @param {Function} [comparator] The comparator invoked per element.
  4831. * @returns {Array} Returns the new array of values.
  4832. */
  4833. function baseXor(arrays, iteratee, comparator) {
  4834. var length = arrays.length;
  4835. if (length < 2) {
  4836. return length ? baseUniq(arrays[0]) : [];
  4837. }
  4838. var index = -1,
  4839. result = Array(length);
  4840. while (++index < length) {
  4841. var array = arrays[index],
  4842. othIndex = -1;
  4843. while (++othIndex < length) {
  4844. if (othIndex != index) {
  4845. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  4846. }
  4847. }
  4848. }
  4849. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  4850. }
  4851. /**
  4852. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  4853. *
  4854. * @private
  4855. * @param {Array} props The property identifiers.
  4856. * @param {Array} values The property values.
  4857. * @param {Function} assignFunc The function to assign values.
  4858. * @returns {Object} Returns the new object.
  4859. */
  4860. function baseZipObject(props, values, assignFunc) {
  4861. var index = -1,
  4862. length = props.length,
  4863. valsLength = values.length,
  4864. result = {};
  4865. while (++index < length) {
  4866. var value = index < valsLength ? values[index] : undefined;
  4867. assignFunc(result, props[index], value);
  4868. }
  4869. return result;
  4870. }
  4871. /**
  4872. * Casts `value` to an empty array if it's not an array like object.
  4873. *
  4874. * @private
  4875. * @param {*} value The value to inspect.
  4876. * @returns {Array|Object} Returns the cast array-like object.
  4877. */
  4878. function castArrayLikeObject(value) {
  4879. return isArrayLikeObject(value) ? value : [];
  4880. }
  4881. /**
  4882. * Casts `value` to `identity` if it's not a function.
  4883. *
  4884. * @private
  4885. * @param {*} value The value to inspect.
  4886. * @returns {Function} Returns cast function.
  4887. */
  4888. function castFunction(value) {
  4889. return typeof value == 'function' ? value : identity;
  4890. }
  4891. /**
  4892. * Casts `value` to a path array if it's not one.
  4893. *
  4894. * @private
  4895. * @param {*} value The value to inspect.
  4896. * @param {Object} [object] The object to query keys on.
  4897. * @returns {Array} Returns the cast property path array.
  4898. */
  4899. function castPath(value, object) {
  4900. if (isArray(value)) {
  4901. return value;
  4902. }
  4903. return isKey(value, object) ? [value] : stringToPath(toString(value));
  4904. }
  4905. /**
  4906. * A `baseRest` alias which can be replaced with `identity` by module
  4907. * replacement plugins.
  4908. *
  4909. * @private
  4910. * @type {Function}
  4911. * @param {Function} func The function to apply a rest parameter to.
  4912. * @returns {Function} Returns the new function.
  4913. */
  4914. var castRest = baseRest;
  4915. /**
  4916. * Casts `array` to a slice if it's needed.
  4917. *
  4918. * @private
  4919. * @param {Array} array The array to inspect.
  4920. * @param {number} start The start position.
  4921. * @param {number} [end=array.length] The end position.
  4922. * @returns {Array} Returns the cast slice.
  4923. */
  4924. function castSlice(array, start, end) {
  4925. var length = array.length;
  4926. end = end === undefined ? length : end;
  4927. return (!start && end >= length) ? array : baseSlice(array, start, end);
  4928. }
  4929. /**
  4930. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  4931. *
  4932. * @private
  4933. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  4934. */
  4935. var clearTimeout = ctxClearTimeout || function(id) {
  4936. return root.clearTimeout(id);
  4937. };
  4938. /**
  4939. * Creates a clone of `buffer`.
  4940. *
  4941. * @private
  4942. * @param {Buffer} buffer The buffer to clone.
  4943. * @param {boolean} [isDeep] Specify a deep clone.
  4944. * @returns {Buffer} Returns the cloned buffer.
  4945. */
  4946. function cloneBuffer(buffer, isDeep) {
  4947. if (isDeep) {
  4948. return buffer.slice();
  4949. }
  4950. var length = buffer.length,
  4951. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  4952. buffer.copy(result);
  4953. return result;
  4954. }
  4955. /**
  4956. * Creates a clone of `arrayBuffer`.
  4957. *
  4958. * @private
  4959. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  4960. * @returns {ArrayBuffer} Returns the cloned array buffer.
  4961. */
  4962. function cloneArrayBuffer(arrayBuffer) {
  4963. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  4964. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  4965. return result;
  4966. }
  4967. /**
  4968. * Creates a clone of `dataView`.
  4969. *
  4970. * @private
  4971. * @param {Object} dataView The data view to clone.
  4972. * @param {boolean} [isDeep] Specify a deep clone.
  4973. * @returns {Object} Returns the cloned data view.
  4974. */
  4975. function cloneDataView(dataView, isDeep) {
  4976. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  4977. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  4978. }
  4979. /**
  4980. * Creates a clone of `map`.
  4981. *
  4982. * @private
  4983. * @param {Object} map The map to clone.
  4984. * @param {Function} cloneFunc The function to clone values.
  4985. * @param {boolean} [isDeep] Specify a deep clone.
  4986. * @returns {Object} Returns the cloned map.
  4987. */
  4988. function cloneMap(map, isDeep, cloneFunc) {
  4989. var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
  4990. return arrayReduce(array, addMapEntry, new map.constructor);
  4991. }
  4992. /**
  4993. * Creates a clone of `regexp`.
  4994. *
  4995. * @private
  4996. * @param {Object} regexp The regexp to clone.
  4997. * @returns {Object} Returns the cloned regexp.
  4998. */
  4999. function cloneRegExp(regexp) {
  5000. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  5001. result.lastIndex = regexp.lastIndex;
  5002. return result;
  5003. }
  5004. /**
  5005. * Creates a clone of `set`.
  5006. *
  5007. * @private
  5008. * @param {Object} set The set to clone.
  5009. * @param {Function} cloneFunc The function to clone values.
  5010. * @param {boolean} [isDeep] Specify a deep clone.
  5011. * @returns {Object} Returns the cloned set.
  5012. */
  5013. function cloneSet(set, isDeep, cloneFunc) {
  5014. var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
  5015. return arrayReduce(array, addSetEntry, new set.constructor);
  5016. }
  5017. /**
  5018. * Creates a clone of the `symbol` object.
  5019. *
  5020. * @private
  5021. * @param {Object} symbol The symbol object to clone.
  5022. * @returns {Object} Returns the cloned symbol object.
  5023. */
  5024. function cloneSymbol(symbol) {
  5025. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  5026. }
  5027. /**
  5028. * Creates a clone of `typedArray`.
  5029. *
  5030. * @private
  5031. * @param {Object} typedArray The typed array to clone.
  5032. * @param {boolean} [isDeep] Specify a deep clone.
  5033. * @returns {Object} Returns the cloned typed array.
  5034. */
  5035. function cloneTypedArray(typedArray, isDeep) {
  5036. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  5037. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  5038. }
  5039. /**
  5040. * Compares values to sort them in ascending order.
  5041. *
  5042. * @private
  5043. * @param {*} value The value to compare.
  5044. * @param {*} other The other value to compare.
  5045. * @returns {number} Returns the sort order indicator for `value`.
  5046. */
  5047. function compareAscending(value, other) {
  5048. if (value !== other) {
  5049. var valIsDefined = value !== undefined,
  5050. valIsNull = value === null,
  5051. valIsReflexive = value === value,
  5052. valIsSymbol = isSymbol(value);
  5053. var othIsDefined = other !== undefined,
  5054. othIsNull = other === null,
  5055. othIsReflexive = other === other,
  5056. othIsSymbol = isSymbol(other);
  5057. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  5058. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  5059. (valIsNull && othIsDefined && othIsReflexive) ||
  5060. (!valIsDefined && othIsReflexive) ||
  5061. !valIsReflexive) {
  5062. return 1;
  5063. }
  5064. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  5065. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  5066. (othIsNull && valIsDefined && valIsReflexive) ||
  5067. (!othIsDefined && valIsReflexive) ||
  5068. !othIsReflexive) {
  5069. return -1;
  5070. }
  5071. }
  5072. return 0;
  5073. }
  5074. /**
  5075. * Used by `_.orderBy` to compare multiple properties of a value to another
  5076. * and stable sort them.
  5077. *
  5078. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  5079. * specify an order of "desc" for descending or "asc" for ascending sort order
  5080. * of corresponding values.
  5081. *
  5082. * @private
  5083. * @param {Object} object The object to compare.
  5084. * @param {Object} other The other object to compare.
  5085. * @param {boolean[]|string[]} orders The order to sort by for each property.
  5086. * @returns {number} Returns the sort order indicator for `object`.
  5087. */
  5088. function compareMultiple(object, other, orders) {
  5089. var index = -1,
  5090. objCriteria = object.criteria,
  5091. othCriteria = other.criteria,
  5092. length = objCriteria.length,
  5093. ordersLength = orders.length;
  5094. while (++index < length) {
  5095. var result = compareAscending(objCriteria[index], othCriteria[index]);
  5096. if (result) {
  5097. if (index >= ordersLength) {
  5098. return result;
  5099. }
  5100. var order = orders[index];
  5101. return result * (order == 'desc' ? -1 : 1);
  5102. }
  5103. }
  5104. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  5105. // that causes it, under certain circumstances, to provide the same value for
  5106. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  5107. // for more details.
  5108. //
  5109. // This also ensures a stable sort in V8 and other engines.
  5110. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  5111. return object.index - other.index;
  5112. }
  5113. /**
  5114. * Creates an array that is the composition of partially applied arguments,
  5115. * placeholders, and provided arguments into a single array of arguments.
  5116. *
  5117. * @private
  5118. * @param {Array} args The provided arguments.
  5119. * @param {Array} partials The arguments to prepend to those provided.
  5120. * @param {Array} holders The `partials` placeholder indexes.
  5121. * @params {boolean} [isCurried] Specify composing for a curried function.
  5122. * @returns {Array} Returns the new array of composed arguments.
  5123. */
  5124. function composeArgs(args, partials, holders, isCurried) {
  5125. var argsIndex = -1,
  5126. argsLength = args.length,
  5127. holdersLength = holders.length,
  5128. leftIndex = -1,
  5129. leftLength = partials.length,
  5130. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5131. result = Array(leftLength + rangeLength),
  5132. isUncurried = !isCurried;
  5133. while (++leftIndex < leftLength) {
  5134. result[leftIndex] = partials[leftIndex];
  5135. }
  5136. while (++argsIndex < holdersLength) {
  5137. if (isUncurried || argsIndex < argsLength) {
  5138. result[holders[argsIndex]] = args[argsIndex];
  5139. }
  5140. }
  5141. while (rangeLength--) {
  5142. result[leftIndex++] = args[argsIndex++];
  5143. }
  5144. return result;
  5145. }
  5146. /**
  5147. * This function is like `composeArgs` except that the arguments composition
  5148. * is tailored for `_.partialRight`.
  5149. *
  5150. * @private
  5151. * @param {Array} args The provided arguments.
  5152. * @param {Array} partials The arguments to append to those provided.
  5153. * @param {Array} holders The `partials` placeholder indexes.
  5154. * @params {boolean} [isCurried] Specify composing for a curried function.
  5155. * @returns {Array} Returns the new array of composed arguments.
  5156. */
  5157. function composeArgsRight(args, partials, holders, isCurried) {
  5158. var argsIndex = -1,
  5159. argsLength = args.length,
  5160. holdersIndex = -1,
  5161. holdersLength = holders.length,
  5162. rightIndex = -1,
  5163. rightLength = partials.length,
  5164. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5165. result = Array(rangeLength + rightLength),
  5166. isUncurried = !isCurried;
  5167. while (++argsIndex < rangeLength) {
  5168. result[argsIndex] = args[argsIndex];
  5169. }
  5170. var offset = argsIndex;
  5171. while (++rightIndex < rightLength) {
  5172. result[offset + rightIndex] = partials[rightIndex];
  5173. }
  5174. while (++holdersIndex < holdersLength) {
  5175. if (isUncurried || argsIndex < argsLength) {
  5176. result[offset + holders[holdersIndex]] = args[argsIndex++];
  5177. }
  5178. }
  5179. return result;
  5180. }
  5181. /**
  5182. * Copies the values of `source` to `array`.
  5183. *
  5184. * @private
  5185. * @param {Array} source The array to copy values from.
  5186. * @param {Array} [array=[]] The array to copy values to.
  5187. * @returns {Array} Returns `array`.
  5188. */
  5189. function copyArray(source, array) {
  5190. var index = -1,
  5191. length = source.length;
  5192. array || (array = Array(length));
  5193. while (++index < length) {
  5194. array[index] = source[index];
  5195. }
  5196. return array;
  5197. }
  5198. /**
  5199. * Copies properties of `source` to `object`.
  5200. *
  5201. * @private
  5202. * @param {Object} source The object to copy properties from.
  5203. * @param {Array} props The property identifiers to copy.
  5204. * @param {Object} [object={}] The object to copy properties to.
  5205. * @param {Function} [customizer] The function to customize copied values.
  5206. * @returns {Object} Returns `object`.
  5207. */
  5208. function copyObject(source, props, object, customizer) {
  5209. var isNew = !object;
  5210. object || (object = {});
  5211. var index = -1,
  5212. length = props.length;
  5213. while (++index < length) {
  5214. var key = props[index];
  5215. var newValue = customizer
  5216. ? customizer(object[key], source[key], key, object, source)
  5217. : undefined;
  5218. if (newValue === undefined) {
  5219. newValue = source[key];
  5220. }
  5221. if (isNew) {
  5222. baseAssignValue(object, key, newValue);
  5223. } else {
  5224. assignValue(object, key, newValue);
  5225. }
  5226. }
  5227. return object;
  5228. }
  5229. /**
  5230. * Copies own symbols of `source` to `object`.
  5231. *
  5232. * @private
  5233. * @param {Object} source The object to copy symbols from.
  5234. * @param {Object} [object={}] The object to copy symbols to.
  5235. * @returns {Object} Returns `object`.
  5236. */
  5237. function copySymbols(source, object) {
  5238. return copyObject(source, getSymbols(source), object);
  5239. }
  5240. /**
  5241. * Copies own and inherited symbols of `source` to `object`.
  5242. *
  5243. * @private
  5244. * @param {Object} source The object to copy symbols from.
  5245. * @param {Object} [object={}] The object to copy symbols to.
  5246. * @returns {Object} Returns `object`.
  5247. */
  5248. function copySymbolsIn(source, object) {
  5249. return copyObject(source, getSymbolsIn(source), object);
  5250. }
  5251. /**
  5252. * Creates a function like `_.groupBy`.
  5253. *
  5254. * @private
  5255. * @param {Function} setter The function to set accumulator values.
  5256. * @param {Function} [initializer] The accumulator object initializer.
  5257. * @returns {Function} Returns the new aggregator function.
  5258. */
  5259. function createAggregator(setter, initializer) {
  5260. return function(collection, iteratee) {
  5261. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  5262. accumulator = initializer ? initializer() : {};
  5263. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  5264. };
  5265. }
  5266. /**
  5267. * Creates a function like `_.assign`.
  5268. *
  5269. * @private
  5270. * @param {Function} assigner The function to assign values.
  5271. * @returns {Function} Returns the new assigner function.
  5272. */
  5273. function createAssigner(assigner) {
  5274. return baseRest(function(object, sources) {
  5275. var index = -1,
  5276. length = sources.length,
  5277. customizer = length > 1 ? sources[length - 1] : undefined,
  5278. guard = length > 2 ? sources[2] : undefined;
  5279. customizer = (assigner.length > 3 && typeof customizer == 'function')
  5280. ? (length--, customizer)
  5281. : undefined;
  5282. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  5283. customizer = length < 3 ? undefined : customizer;
  5284. length = 1;
  5285. }
  5286. object = Object(object);
  5287. while (++index < length) {
  5288. var source = sources[index];
  5289. if (source) {
  5290. assigner(object, source, index, customizer);
  5291. }
  5292. }
  5293. return object;
  5294. });
  5295. }
  5296. /**
  5297. * Creates a `baseEach` or `baseEachRight` function.
  5298. *
  5299. * @private
  5300. * @param {Function} eachFunc The function to iterate over a collection.
  5301. * @param {boolean} [fromRight] Specify iterating from right to left.
  5302. * @returns {Function} Returns the new base function.
  5303. */
  5304. function createBaseEach(eachFunc, fromRight) {
  5305. return function(collection, iteratee) {
  5306. if (collection == null) {
  5307. return collection;
  5308. }
  5309. if (!isArrayLike(collection)) {
  5310. return eachFunc(collection, iteratee);
  5311. }
  5312. var length = collection.length,
  5313. index = fromRight ? length : -1,
  5314. iterable = Object(collection);
  5315. while ((fromRight ? index-- : ++index < length)) {
  5316. if (iteratee(iterable[index], index, iterable) === false) {
  5317. break;
  5318. }
  5319. }
  5320. return collection;
  5321. };
  5322. }
  5323. /**
  5324. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  5325. *
  5326. * @private
  5327. * @param {boolean} [fromRight] Specify iterating from right to left.
  5328. * @returns {Function} Returns the new base function.
  5329. */
  5330. function createBaseFor(fromRight) {
  5331. return function(object, iteratee, keysFunc) {
  5332. var index = -1,
  5333. iterable = Object(object),
  5334. props = keysFunc(object),
  5335. length = props.length;
  5336. while (length--) {
  5337. var key = props[fromRight ? length : ++index];
  5338. if (iteratee(iterable[key], key, iterable) === false) {
  5339. break;
  5340. }
  5341. }
  5342. return object;
  5343. };
  5344. }
  5345. /**
  5346. * Creates a function that wraps `func` to invoke it with the optional `this`
  5347. * binding of `thisArg`.
  5348. *
  5349. * @private
  5350. * @param {Function} func The function to wrap.
  5351. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5352. * @param {*} [thisArg] The `this` binding of `func`.
  5353. * @returns {Function} Returns the new wrapped function.
  5354. */
  5355. function createBind(func, bitmask, thisArg) {
  5356. var isBind = bitmask & WRAP_BIND_FLAG,
  5357. Ctor = createCtor(func);
  5358. function wrapper() {
  5359. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5360. return fn.apply(isBind ? thisArg : this, arguments);
  5361. }
  5362. return wrapper;
  5363. }
  5364. /**
  5365. * Creates a function like `_.lowerFirst`.
  5366. *
  5367. * @private
  5368. * @param {string} methodName The name of the `String` case method to use.
  5369. * @returns {Function} Returns the new case function.
  5370. */
  5371. function createCaseFirst(methodName) {
  5372. return function(string) {
  5373. string = toString(string);
  5374. var strSymbols = hasUnicode(string)
  5375. ? stringToArray(string)
  5376. : undefined;
  5377. var chr = strSymbols
  5378. ? strSymbols[0]
  5379. : string.charAt(0);
  5380. var trailing = strSymbols
  5381. ? castSlice(strSymbols, 1).join('')
  5382. : string.slice(1);
  5383. return chr[methodName]() + trailing;
  5384. };
  5385. }
  5386. /**
  5387. * Creates a function like `_.camelCase`.
  5388. *
  5389. * @private
  5390. * @param {Function} callback The function to combine each word.
  5391. * @returns {Function} Returns the new compounder function.
  5392. */
  5393. function createCompounder(callback) {
  5394. return function(string) {
  5395. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  5396. };
  5397. }
  5398. /**
  5399. * Creates a function that produces an instance of `Ctor` regardless of
  5400. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  5401. *
  5402. * @private
  5403. * @param {Function} Ctor The constructor to wrap.
  5404. * @returns {Function} Returns the new wrapped function.
  5405. */
  5406. function createCtor(Ctor) {
  5407. return function() {
  5408. // Use a `switch` statement to work with class constructors. See
  5409. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  5410. // for more details.
  5411. var args = arguments;
  5412. switch (args.length) {
  5413. case 0: return new Ctor;
  5414. case 1: return new Ctor(args[0]);
  5415. case 2: return new Ctor(args[0], args[1]);
  5416. case 3: return new Ctor(args[0], args[1], args[2]);
  5417. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  5418. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  5419. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  5420. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  5421. }
  5422. var thisBinding = baseCreate(Ctor.prototype),
  5423. result = Ctor.apply(thisBinding, args);
  5424. // Mimic the constructor's `return` behavior.
  5425. // See https://es5.github.io/#x13.2.2 for more details.
  5426. return isObject(result) ? result : thisBinding;
  5427. };
  5428. }
  5429. /**
  5430. * Creates a function that wraps `func` to enable currying.
  5431. *
  5432. * @private
  5433. * @param {Function} func The function to wrap.
  5434. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5435. * @param {number} arity The arity of `func`.
  5436. * @returns {Function} Returns the new wrapped function.
  5437. */
  5438. function createCurry(func, bitmask, arity) {
  5439. var Ctor = createCtor(func);
  5440. function wrapper() {
  5441. var length = arguments.length,
  5442. args = Array(length),
  5443. index = length,
  5444. placeholder = getHolder(wrapper);
  5445. while (index--) {
  5446. args[index] = arguments[index];
  5447. }
  5448. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  5449. ? []
  5450. : replaceHolders(args, placeholder);
  5451. length -= holders.length;
  5452. if (length < arity) {
  5453. return createRecurry(
  5454. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  5455. args, holders, undefined, undefined, arity - length);
  5456. }
  5457. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5458. return apply(fn, this, args);
  5459. }
  5460. return wrapper;
  5461. }
  5462. /**
  5463. * Creates a `_.find` or `_.findLast` function.
  5464. *
  5465. * @private
  5466. * @param {Function} findIndexFunc The function to find the collection index.
  5467. * @returns {Function} Returns the new find function.
  5468. */
  5469. function createFind(findIndexFunc) {
  5470. return function(collection, predicate, fromIndex) {
  5471. var iterable = Object(collection);
  5472. if (!isArrayLike(collection)) {
  5473. var iteratee = getIteratee(predicate, 3);
  5474. collection = keys(collection);
  5475. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  5476. }
  5477. var index = findIndexFunc(collection, predicate, fromIndex);
  5478. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  5479. };
  5480. }
  5481. /**
  5482. * Creates a `_.flow` or `_.flowRight` function.
  5483. *
  5484. * @private
  5485. * @param {boolean} [fromRight] Specify iterating from right to left.
  5486. * @returns {Function} Returns the new flow function.
  5487. */
  5488. function createFlow(fromRight) {
  5489. return flatRest(function(funcs) {
  5490. var length = funcs.length,
  5491. index = length,
  5492. prereq = LodashWrapper.prototype.thru;
  5493. if (fromRight) {
  5494. funcs.reverse();
  5495. }
  5496. while (index--) {
  5497. var func = funcs[index];
  5498. if (typeof func != 'function') {
  5499. throw new TypeError(FUNC_ERROR_TEXT);
  5500. }
  5501. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  5502. var wrapper = new LodashWrapper([], true);
  5503. }
  5504. }
  5505. index = wrapper ? index : length;
  5506. while (++index < length) {
  5507. func = funcs[index];
  5508. var funcName = getFuncName(func),
  5509. data = funcName == 'wrapper' ? getData(func) : undefined;
  5510. if (data && isLaziable(data[0]) &&
  5511. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  5512. !data[4].length && data[9] == 1
  5513. ) {
  5514. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  5515. } else {
  5516. wrapper = (func.length == 1 && isLaziable(func))
  5517. ? wrapper[funcName]()
  5518. : wrapper.thru(func);
  5519. }
  5520. }
  5521. return function() {
  5522. var args = arguments,
  5523. value = args[0];
  5524. if (wrapper && args.length == 1 && isArray(value)) {
  5525. return wrapper.plant(value).value();
  5526. }
  5527. var index = 0,
  5528. result = length ? funcs[index].apply(this, args) : value;
  5529. while (++index < length) {
  5530. result = funcs[index].call(this, result);
  5531. }
  5532. return result;
  5533. };
  5534. });
  5535. }
  5536. /**
  5537. * Creates a function that wraps `func` to invoke it with optional `this`
  5538. * binding of `thisArg`, partial application, and currying.
  5539. *
  5540. * @private
  5541. * @param {Function|string} func The function or method name to wrap.
  5542. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5543. * @param {*} [thisArg] The `this` binding of `func`.
  5544. * @param {Array} [partials] The arguments to prepend to those provided to
  5545. * the new function.
  5546. * @param {Array} [holders] The `partials` placeholder indexes.
  5547. * @param {Array} [partialsRight] The arguments to append to those provided
  5548. * to the new function.
  5549. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  5550. * @param {Array} [argPos] The argument positions of the new function.
  5551. * @param {number} [ary] The arity cap of `func`.
  5552. * @param {number} [arity] The arity of `func`.
  5553. * @returns {Function} Returns the new wrapped function.
  5554. */
  5555. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  5556. var isAry = bitmask & WRAP_ARY_FLAG,
  5557. isBind = bitmask & WRAP_BIND_FLAG,
  5558. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  5559. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  5560. isFlip = bitmask & WRAP_FLIP_FLAG,
  5561. Ctor = isBindKey ? undefined : createCtor(func);
  5562. function wrapper() {
  5563. var length = arguments.length,
  5564. args = Array(length),
  5565. index = length;
  5566. while (index--) {
  5567. args[index] = arguments[index];
  5568. }
  5569. if (isCurried) {
  5570. var placeholder = getHolder(wrapper),
  5571. holdersCount = countHolders(args, placeholder);
  5572. }
  5573. if (partials) {
  5574. args = composeArgs(args, partials, holders, isCurried);
  5575. }
  5576. if (partialsRight) {
  5577. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  5578. }
  5579. length -= holdersCount;
  5580. if (isCurried && length < arity) {
  5581. var newHolders = replaceHolders(args, placeholder);
  5582. return createRecurry(
  5583. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  5584. args, newHolders, argPos, ary, arity - length
  5585. );
  5586. }
  5587. var thisBinding = isBind ? thisArg : this,
  5588. fn = isBindKey ? thisBinding[func] : func;
  5589. length = args.length;
  5590. if (argPos) {
  5591. args = reorder(args, argPos);
  5592. } else if (isFlip && length > 1) {
  5593. args.reverse();
  5594. }
  5595. if (isAry && ary < length) {
  5596. args.length = ary;
  5597. }
  5598. if (this && this !== root && this instanceof wrapper) {
  5599. fn = Ctor || createCtor(fn);
  5600. }
  5601. return fn.apply(thisBinding, args);
  5602. }
  5603. return wrapper;
  5604. }
  5605. /**
  5606. * Creates a function like `_.invertBy`.
  5607. *
  5608. * @private
  5609. * @param {Function} setter The function to set accumulator values.
  5610. * @param {Function} toIteratee The function to resolve iteratees.
  5611. * @returns {Function} Returns the new inverter function.
  5612. */
  5613. function createInverter(setter, toIteratee) {
  5614. return function(object, iteratee) {
  5615. return baseInverter(object, setter, toIteratee(iteratee), {});
  5616. };
  5617. }
  5618. /**
  5619. * Creates a function that performs a mathematical operation on two values.
  5620. *
  5621. * @private
  5622. * @param {Function} operator The function to perform the operation.
  5623. * @param {number} [defaultValue] The value used for `undefined` arguments.
  5624. * @returns {Function} Returns the new mathematical operation function.
  5625. */
  5626. function createMathOperation(operator, defaultValue) {
  5627. return function(value, other) {
  5628. var result;
  5629. if (value === undefined && other === undefined) {
  5630. return defaultValue;
  5631. }
  5632. if (value !== undefined) {
  5633. result = value;
  5634. }
  5635. if (other !== undefined) {
  5636. if (result === undefined) {
  5637. return other;
  5638. }
  5639. if (typeof value == 'string' || typeof other == 'string') {
  5640. value = baseToString(value);
  5641. other = baseToString(other);
  5642. } else {
  5643. value = baseToNumber(value);
  5644. other = baseToNumber(other);
  5645. }
  5646. result = operator(value, other);
  5647. }
  5648. return result;
  5649. };
  5650. }
  5651. /**
  5652. * Creates a function like `_.over`.
  5653. *
  5654. * @private
  5655. * @param {Function} arrayFunc The function to iterate over iteratees.
  5656. * @returns {Function} Returns the new over function.
  5657. */
  5658. function createOver(arrayFunc) {
  5659. return flatRest(function(iteratees) {
  5660. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  5661. return baseRest(function(args) {
  5662. var thisArg = this;
  5663. return arrayFunc(iteratees, function(iteratee) {
  5664. return apply(iteratee, thisArg, args);
  5665. });
  5666. });
  5667. });
  5668. }
  5669. /**
  5670. * Creates the padding for `string` based on `length`. The `chars` string
  5671. * is truncated if the number of characters exceeds `length`.
  5672. *
  5673. * @private
  5674. * @param {number} length The padding length.
  5675. * @param {string} [chars=' '] The string used as padding.
  5676. * @returns {string} Returns the padding for `string`.
  5677. */
  5678. function createPadding(length, chars) {
  5679. chars = chars === undefined ? ' ' : baseToString(chars);
  5680. var charsLength = chars.length;
  5681. if (charsLength < 2) {
  5682. return charsLength ? baseRepeat(chars, length) : chars;
  5683. }
  5684. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  5685. return hasUnicode(chars)
  5686. ? castSlice(stringToArray(result), 0, length).join('')
  5687. : result.slice(0, length);
  5688. }
  5689. /**
  5690. * Creates a function that wraps `func` to invoke it with the `this` binding
  5691. * of `thisArg` and `partials` prepended to the arguments it receives.
  5692. *
  5693. * @private
  5694. * @param {Function} func The function to wrap.
  5695. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5696. * @param {*} thisArg The `this` binding of `func`.
  5697. * @param {Array} partials The arguments to prepend to those provided to
  5698. * the new function.
  5699. * @returns {Function} Returns the new wrapped function.
  5700. */
  5701. function createPartial(func, bitmask, thisArg, partials) {
  5702. var isBind = bitmask & WRAP_BIND_FLAG,
  5703. Ctor = createCtor(func);
  5704. function wrapper() {
  5705. var argsIndex = -1,
  5706. argsLength = arguments.length,
  5707. leftIndex = -1,
  5708. leftLength = partials.length,
  5709. args = Array(leftLength + argsLength),
  5710. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5711. while (++leftIndex < leftLength) {
  5712. args[leftIndex] = partials[leftIndex];
  5713. }
  5714. while (argsLength--) {
  5715. args[leftIndex++] = arguments[++argsIndex];
  5716. }
  5717. return apply(fn, isBind ? thisArg : this, args);
  5718. }
  5719. return wrapper;
  5720. }
  5721. /**
  5722. * Creates a `_.range` or `_.rangeRight` function.
  5723. *
  5724. * @private
  5725. * @param {boolean} [fromRight] Specify iterating from right to left.
  5726. * @returns {Function} Returns the new range function.
  5727. */
  5728. function createRange(fromRight) {
  5729. return function(start, end, step) {
  5730. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  5731. end = step = undefined;
  5732. }
  5733. // Ensure the sign of `-0` is preserved.
  5734. start = toFinite(start);
  5735. if (end === undefined) {
  5736. end = start;
  5737. start = 0;
  5738. } else {
  5739. end = toFinite(end);
  5740. }
  5741. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  5742. return baseRange(start, end, step, fromRight);
  5743. };
  5744. }
  5745. /**
  5746. * Creates a function that performs a relational operation on two values.
  5747. *
  5748. * @private
  5749. * @param {Function} operator The function to perform the operation.
  5750. * @returns {Function} Returns the new relational operation function.
  5751. */
  5752. function createRelationalOperation(operator) {
  5753. return function(value, other) {
  5754. if (!(typeof value == 'string' && typeof other == 'string')) {
  5755. value = toNumber(value);
  5756. other = toNumber(other);
  5757. }
  5758. return operator(value, other);
  5759. };
  5760. }
  5761. /**
  5762. * Creates a function that wraps `func` to continue currying.
  5763. *
  5764. * @private
  5765. * @param {Function} func The function to wrap.
  5766. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5767. * @param {Function} wrapFunc The function to create the `func` wrapper.
  5768. * @param {*} placeholder The placeholder value.
  5769. * @param {*} [thisArg] The `this` binding of `func`.
  5770. * @param {Array} [partials] The arguments to prepend to those provided to
  5771. * the new function.
  5772. * @param {Array} [holders] The `partials` placeholder indexes.
  5773. * @param {Array} [argPos] The argument positions of the new function.
  5774. * @param {number} [ary] The arity cap of `func`.
  5775. * @param {number} [arity] The arity of `func`.
  5776. * @returns {Function} Returns the new wrapped function.
  5777. */
  5778. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  5779. var isCurry = bitmask & WRAP_CURRY_FLAG,
  5780. newHolders = isCurry ? holders : undefined,
  5781. newHoldersRight = isCurry ? undefined : holders,
  5782. newPartials = isCurry ? partials : undefined,
  5783. newPartialsRight = isCurry ? undefined : partials;
  5784. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  5785. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  5786. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  5787. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  5788. }
  5789. var newData = [
  5790. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  5791. newHoldersRight, argPos, ary, arity
  5792. ];
  5793. var result = wrapFunc.apply(undefined, newData);
  5794. if (isLaziable(func)) {
  5795. setData(result, newData);
  5796. }
  5797. result.placeholder = placeholder;
  5798. return setWrapToString(result, func, bitmask);
  5799. }
  5800. /**
  5801. * Creates a function like `_.round`.
  5802. *
  5803. * @private
  5804. * @param {string} methodName The name of the `Math` method to use when rounding.
  5805. * @returns {Function} Returns the new round function.
  5806. */
  5807. function createRound(methodName) {
  5808. var func = Math[methodName];
  5809. return function(number, precision) {
  5810. number = toNumber(number);
  5811. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  5812. if (precision) {
  5813. // Shift with exponential notation to avoid floating-point issues.
  5814. // See [MDN](https://mdn.io/round#Examples) for more details.
  5815. var pair = (toString(number) + 'e').split('e'),
  5816. value = func(pair[0] + 'e' + (+pair[1] + precision));
  5817. pair = (toString(value) + 'e').split('e');
  5818. return +(pair[0] + 'e' + (+pair[1] - precision));
  5819. }
  5820. return func(number);
  5821. };
  5822. }
  5823. /**
  5824. * Creates a set object of `values`.
  5825. *
  5826. * @private
  5827. * @param {Array} values The values to add to the set.
  5828. * @returns {Object} Returns the new set.
  5829. */
  5830. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  5831. return new Set(values);
  5832. };
  5833. /**
  5834. * Creates a `_.toPairs` or `_.toPairsIn` function.
  5835. *
  5836. * @private
  5837. * @param {Function} keysFunc The function to get the keys of a given object.
  5838. * @returns {Function} Returns the new pairs function.
  5839. */
  5840. function createToPairs(keysFunc) {
  5841. return function(object) {
  5842. var tag = getTag(object);
  5843. if (tag == mapTag) {
  5844. return mapToArray(object);
  5845. }
  5846. if (tag == setTag) {
  5847. return setToPairs(object);
  5848. }
  5849. return baseToPairs(object, keysFunc(object));
  5850. };
  5851. }
  5852. /**
  5853. * Creates a function that either curries or invokes `func` with optional
  5854. * `this` binding and partially applied arguments.
  5855. *
  5856. * @private
  5857. * @param {Function|string} func The function or method name to wrap.
  5858. * @param {number} bitmask The bitmask flags.
  5859. * 1 - `_.bind`
  5860. * 2 - `_.bindKey`
  5861. * 4 - `_.curry` or `_.curryRight` of a bound function
  5862. * 8 - `_.curry`
  5863. * 16 - `_.curryRight`
  5864. * 32 - `_.partial`
  5865. * 64 - `_.partialRight`
  5866. * 128 - `_.rearg`
  5867. * 256 - `_.ary`
  5868. * 512 - `_.flip`
  5869. * @param {*} [thisArg] The `this` binding of `func`.
  5870. * @param {Array} [partials] The arguments to be partially applied.
  5871. * @param {Array} [holders] The `partials` placeholder indexes.
  5872. * @param {Array} [argPos] The argument positions of the new function.
  5873. * @param {number} [ary] The arity cap of `func`.
  5874. * @param {number} [arity] The arity of `func`.
  5875. * @returns {Function} Returns the new wrapped function.
  5876. */
  5877. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  5878. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  5879. if (!isBindKey && typeof func != 'function') {
  5880. throw new TypeError(FUNC_ERROR_TEXT);
  5881. }
  5882. var length = partials ? partials.length : 0;
  5883. if (!length) {
  5884. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  5885. partials = holders = undefined;
  5886. }
  5887. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  5888. arity = arity === undefined ? arity : toInteger(arity);
  5889. length -= holders ? holders.length : 0;
  5890. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  5891. var partialsRight = partials,
  5892. holdersRight = holders;
  5893. partials = holders = undefined;
  5894. }
  5895. var data = isBindKey ? undefined : getData(func);
  5896. var newData = [
  5897. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  5898. argPos, ary, arity
  5899. ];
  5900. if (data) {
  5901. mergeData(newData, data);
  5902. }
  5903. func = newData[0];
  5904. bitmask = newData[1];
  5905. thisArg = newData[2];
  5906. partials = newData[3];
  5907. holders = newData[4];
  5908. arity = newData[9] = newData[9] === undefined
  5909. ? (isBindKey ? 0 : func.length)
  5910. : nativeMax(newData[9] - length, 0);
  5911. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  5912. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  5913. }
  5914. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  5915. var result = createBind(func, bitmask, thisArg);
  5916. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  5917. result = createCurry(func, bitmask, arity);
  5918. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  5919. result = createPartial(func, bitmask, thisArg, partials);
  5920. } else {
  5921. result = createHybrid.apply(undefined, newData);
  5922. }
  5923. var setter = data ? baseSetData : setData;
  5924. return setWrapToString(setter(result, newData), func, bitmask);
  5925. }
  5926. /**
  5927. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  5928. * of source objects to the destination object for all destination properties
  5929. * that resolve to `undefined`.
  5930. *
  5931. * @private
  5932. * @param {*} objValue The destination value.
  5933. * @param {*} srcValue The source value.
  5934. * @param {string} key The key of the property to assign.
  5935. * @param {Object} object The parent object of `objValue`.
  5936. * @returns {*} Returns the value to assign.
  5937. */
  5938. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  5939. if (objValue === undefined ||
  5940. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  5941. return srcValue;
  5942. }
  5943. return objValue;
  5944. }
  5945. /**
  5946. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  5947. * objects into destination objects that are passed thru.
  5948. *
  5949. * @private
  5950. * @param {*} objValue The destination value.
  5951. * @param {*} srcValue The source value.
  5952. * @param {string} key The key of the property to merge.
  5953. * @param {Object} object The parent object of `objValue`.
  5954. * @param {Object} source The parent object of `srcValue`.
  5955. * @param {Object} [stack] Tracks traversed source values and their merged
  5956. * counterparts.
  5957. * @returns {*} Returns the value to assign.
  5958. */
  5959. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  5960. if (isObject(objValue) && isObject(srcValue)) {
  5961. // Recursively merge objects and arrays (susceptible to call stack limits).
  5962. stack.set(srcValue, objValue);
  5963. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  5964. stack['delete'](srcValue);
  5965. }
  5966. return objValue;
  5967. }
  5968. /**
  5969. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  5970. * objects.
  5971. *
  5972. * @private
  5973. * @param {*} value The value to inspect.
  5974. * @param {string} key The key of the property to inspect.
  5975. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  5976. */
  5977. function customOmitClone(value) {
  5978. return isPlainObject(value) ? undefined : value;
  5979. }
  5980. /**
  5981. * A specialized version of `baseIsEqualDeep` for arrays with support for
  5982. * partial deep comparisons.
  5983. *
  5984. * @private
  5985. * @param {Array} array The array to compare.
  5986. * @param {Array} other The other array to compare.
  5987. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  5988. * @param {Function} customizer The function to customize comparisons.
  5989. * @param {Function} equalFunc The function to determine equivalents of values.
  5990. * @param {Object} stack Tracks traversed `array` and `other` objects.
  5991. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  5992. */
  5993. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  5994. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  5995. arrLength = array.length,
  5996. othLength = other.length;
  5997. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  5998. return false;
  5999. }
  6000. // Assume cyclic values are equal.
  6001. var stacked = stack.get(array);
  6002. if (stacked && stack.get(other)) {
  6003. return stacked == other;
  6004. }
  6005. var index = -1,
  6006. result = true,
  6007. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  6008. stack.set(array, other);
  6009. stack.set(other, array);
  6010. // Ignore non-index properties.
  6011. while (++index < arrLength) {
  6012. var arrValue = array[index],
  6013. othValue = other[index];
  6014. if (customizer) {
  6015. var compared = isPartial
  6016. ? customizer(othValue, arrValue, index, other, array, stack)
  6017. : customizer(arrValue, othValue, index, array, other, stack);
  6018. }
  6019. if (compared !== undefined) {
  6020. if (compared) {
  6021. continue;
  6022. }
  6023. result = false;
  6024. break;
  6025. }
  6026. // Recursively compare arrays (susceptible to call stack limits).
  6027. if (seen) {
  6028. if (!arraySome(other, function(othValue, othIndex) {
  6029. if (!cacheHas(seen, othIndex) &&
  6030. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  6031. return seen.push(othIndex);
  6032. }
  6033. })) {
  6034. result = false;
  6035. break;
  6036. }
  6037. } else if (!(
  6038. arrValue === othValue ||
  6039. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  6040. )) {
  6041. result = false;
  6042. break;
  6043. }
  6044. }
  6045. stack['delete'](array);
  6046. stack['delete'](other);
  6047. return result;
  6048. }
  6049. /**
  6050. * A specialized version of `baseIsEqualDeep` for comparing objects of
  6051. * the same `toStringTag`.
  6052. *
  6053. * **Note:** This function only supports comparing values with tags of
  6054. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6055. *
  6056. * @private
  6057. * @param {Object} object The object to compare.
  6058. * @param {Object} other The other object to compare.
  6059. * @param {string} tag The `toStringTag` of the objects to compare.
  6060. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6061. * @param {Function} customizer The function to customize comparisons.
  6062. * @param {Function} equalFunc The function to determine equivalents of values.
  6063. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6064. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6065. */
  6066. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  6067. switch (tag) {
  6068. case dataViewTag:
  6069. if ((object.byteLength != other.byteLength) ||
  6070. (object.byteOffset != other.byteOffset)) {
  6071. return false;
  6072. }
  6073. object = object.buffer;
  6074. other = other.buffer;
  6075. case arrayBufferTag:
  6076. if ((object.byteLength != other.byteLength) ||
  6077. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  6078. return false;
  6079. }
  6080. return true;
  6081. case boolTag:
  6082. case dateTag:
  6083. case numberTag:
  6084. // Coerce booleans to `1` or `0` and dates to milliseconds.
  6085. // Invalid dates are coerced to `NaN`.
  6086. return eq(+object, +other);
  6087. case errorTag:
  6088. return object.name == other.name && object.message == other.message;
  6089. case regexpTag:
  6090. case stringTag:
  6091. // Coerce regexes to strings and treat strings, primitives and objects,
  6092. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  6093. // for more details.
  6094. return object == (other + '');
  6095. case mapTag:
  6096. var convert = mapToArray;
  6097. case setTag:
  6098. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  6099. convert || (convert = setToArray);
  6100. if (object.size != other.size && !isPartial) {
  6101. return false;
  6102. }
  6103. // Assume cyclic values are equal.
  6104. var stacked = stack.get(object);
  6105. if (stacked) {
  6106. return stacked == other;
  6107. }
  6108. bitmask |= COMPARE_UNORDERED_FLAG;
  6109. // Recursively compare objects (susceptible to call stack limits).
  6110. stack.set(object, other);
  6111. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  6112. stack['delete'](object);
  6113. return result;
  6114. case symbolTag:
  6115. if (symbolValueOf) {
  6116. return symbolValueOf.call(object) == symbolValueOf.call(other);
  6117. }
  6118. }
  6119. return false;
  6120. }
  6121. /**
  6122. * A specialized version of `baseIsEqualDeep` for objects with support for
  6123. * partial deep comparisons.
  6124. *
  6125. * @private
  6126. * @param {Object} object The object to compare.
  6127. * @param {Object} other The other object to compare.
  6128. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6129. * @param {Function} customizer The function to customize comparisons.
  6130. * @param {Function} equalFunc The function to determine equivalents of values.
  6131. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6132. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6133. */
  6134. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  6135. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6136. objProps = getAllKeys(object),
  6137. objLength = objProps.length,
  6138. othProps = getAllKeys(other),
  6139. othLength = othProps.length;
  6140. if (objLength != othLength && !isPartial) {
  6141. return false;
  6142. }
  6143. var index = objLength;
  6144. while (index--) {
  6145. var key = objProps[index];
  6146. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  6147. return false;
  6148. }
  6149. }
  6150. // Assume cyclic values are equal.
  6151. var stacked = stack.get(object);
  6152. if (stacked && stack.get(other)) {
  6153. return stacked == other;
  6154. }
  6155. var result = true;
  6156. stack.set(object, other);
  6157. stack.set(other, object);
  6158. var skipCtor = isPartial;
  6159. while (++index < objLength) {
  6160. key = objProps[index];
  6161. var objValue = object[key],
  6162. othValue = other[key];
  6163. if (customizer) {
  6164. var compared = isPartial
  6165. ? customizer(othValue, objValue, key, other, object, stack)
  6166. : customizer(objValue, othValue, key, object, other, stack);
  6167. }
  6168. // Recursively compare objects (susceptible to call stack limits).
  6169. if (!(compared === undefined
  6170. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  6171. : compared
  6172. )) {
  6173. result = false;
  6174. break;
  6175. }
  6176. skipCtor || (skipCtor = key == 'constructor');
  6177. }
  6178. if (result && !skipCtor) {
  6179. var objCtor = object.constructor,
  6180. othCtor = other.constructor;
  6181. // Non `Object` object instances with different constructors are not equal.
  6182. if (objCtor != othCtor &&
  6183. ('constructor' in object && 'constructor' in other) &&
  6184. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  6185. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  6186. result = false;
  6187. }
  6188. }
  6189. stack['delete'](object);
  6190. stack['delete'](other);
  6191. return result;
  6192. }
  6193. /**
  6194. * A specialized version of `baseRest` which flattens the rest array.
  6195. *
  6196. * @private
  6197. * @param {Function} func The function to apply a rest parameter to.
  6198. * @returns {Function} Returns the new function.
  6199. */
  6200. function flatRest(func) {
  6201. return setToString(overRest(func, undefined, flatten), func + '');
  6202. }
  6203. /**
  6204. * Creates an array of own enumerable property names and symbols of `object`.
  6205. *
  6206. * @private
  6207. * @param {Object} object The object to query.
  6208. * @returns {Array} Returns the array of property names and symbols.
  6209. */
  6210. function getAllKeys(object) {
  6211. return baseGetAllKeys(object, keys, getSymbols);
  6212. }
  6213. /**
  6214. * Creates an array of own and inherited enumerable property names and
  6215. * symbols of `object`.
  6216. *
  6217. * @private
  6218. * @param {Object} object The object to query.
  6219. * @returns {Array} Returns the array of property names and symbols.
  6220. */
  6221. function getAllKeysIn(object) {
  6222. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  6223. }
  6224. /**
  6225. * Gets metadata for `func`.
  6226. *
  6227. * @private
  6228. * @param {Function} func The function to query.
  6229. * @returns {*} Returns the metadata for `func`.
  6230. */
  6231. var getData = !metaMap ? noop : function(func) {
  6232. return metaMap.get(func);
  6233. };
  6234. /**
  6235. * Gets the name of `func`.
  6236. *
  6237. * @private
  6238. * @param {Function} func The function to query.
  6239. * @returns {string} Returns the function name.
  6240. */
  6241. function getFuncName(func) {
  6242. var result = (func.name + ''),
  6243. array = realNames[result],
  6244. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  6245. while (length--) {
  6246. var data = array[length],
  6247. otherFunc = data.func;
  6248. if (otherFunc == null || otherFunc == func) {
  6249. return data.name;
  6250. }
  6251. }
  6252. return result;
  6253. }
  6254. /**
  6255. * Gets the argument placeholder value for `func`.
  6256. *
  6257. * @private
  6258. * @param {Function} func The function to inspect.
  6259. * @returns {*} Returns the placeholder value.
  6260. */
  6261. function getHolder(func) {
  6262. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  6263. return object.placeholder;
  6264. }
  6265. /**
  6266. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  6267. * this function returns the custom method, otherwise it returns `baseIteratee`.
  6268. * If arguments are provided, the chosen function is invoked with them and
  6269. * its result is returned.
  6270. *
  6271. * @private
  6272. * @param {*} [value] The value to convert to an iteratee.
  6273. * @param {number} [arity] The arity of the created iteratee.
  6274. * @returns {Function} Returns the chosen function or its result.
  6275. */
  6276. function getIteratee() {
  6277. var result = lodash.iteratee || iteratee;
  6278. result = result === iteratee ? baseIteratee : result;
  6279. return arguments.length ? result(arguments[0], arguments[1]) : result;
  6280. }
  6281. /**
  6282. * Gets the data for `map`.
  6283. *
  6284. * @private
  6285. * @param {Object} map The map to query.
  6286. * @param {string} key The reference key.
  6287. * @returns {*} Returns the map data.
  6288. */
  6289. function getMapData(map, key) {
  6290. var data = map.__data__;
  6291. return isKeyable(key)
  6292. ? data[typeof key == 'string' ? 'string' : 'hash']
  6293. : data.map;
  6294. }
  6295. /**
  6296. * Gets the property names, values, and compare flags of `object`.
  6297. *
  6298. * @private
  6299. * @param {Object} object The object to query.
  6300. * @returns {Array} Returns the match data of `object`.
  6301. */
  6302. function getMatchData(object) {
  6303. var result = keys(object),
  6304. length = result.length;
  6305. while (length--) {
  6306. var key = result[length],
  6307. value = object[key];
  6308. result[length] = [key, value, isStrictComparable(value)];
  6309. }
  6310. return result;
  6311. }
  6312. /**
  6313. * Gets the native function at `key` of `object`.
  6314. *
  6315. * @private
  6316. * @param {Object} object The object to query.
  6317. * @param {string} key The key of the method to get.
  6318. * @returns {*} Returns the function if it's native, else `undefined`.
  6319. */
  6320. function getNative(object, key) {
  6321. var value = getValue(object, key);
  6322. return baseIsNative(value) ? value : undefined;
  6323. }
  6324. /**
  6325. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  6326. *
  6327. * @private
  6328. * @param {*} value The value to query.
  6329. * @returns {string} Returns the raw `toStringTag`.
  6330. */
  6331. function getRawTag(value) {
  6332. var isOwn = hasOwnProperty.call(value, symToStringTag),
  6333. tag = value[symToStringTag];
  6334. try {
  6335. value[symToStringTag] = undefined;
  6336. var unmasked = true;
  6337. } catch (e) {}
  6338. var result = nativeObjectToString.call(value);
  6339. if (unmasked) {
  6340. if (isOwn) {
  6341. value[symToStringTag] = tag;
  6342. } else {
  6343. delete value[symToStringTag];
  6344. }
  6345. }
  6346. return result;
  6347. }
  6348. /**
  6349. * Creates an array of the own enumerable symbols of `object`.
  6350. *
  6351. * @private
  6352. * @param {Object} object The object to query.
  6353. * @returns {Array} Returns the array of symbols.
  6354. */
  6355. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  6356. if (object == null) {
  6357. return [];
  6358. }
  6359. object = Object(object);
  6360. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  6361. return propertyIsEnumerable.call(object, symbol);
  6362. });
  6363. };
  6364. /**
  6365. * Creates an array of the own and inherited enumerable symbols of `object`.
  6366. *
  6367. * @private
  6368. * @param {Object} object The object to query.
  6369. * @returns {Array} Returns the array of symbols.
  6370. */
  6371. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  6372. var result = [];
  6373. while (object) {
  6374. arrayPush(result, getSymbols(object));
  6375. object = getPrototype(object);
  6376. }
  6377. return result;
  6378. };
  6379. /**
  6380. * Gets the `toStringTag` of `value`.
  6381. *
  6382. * @private
  6383. * @param {*} value The value to query.
  6384. * @returns {string} Returns the `toStringTag`.
  6385. */
  6386. var getTag = baseGetTag;
  6387. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  6388. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  6389. (Map && getTag(new Map) != mapTag) ||
  6390. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  6391. (Set && getTag(new Set) != setTag) ||
  6392. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  6393. getTag = function(value) {
  6394. var result = baseGetTag(value),
  6395. Ctor = result == objectTag ? value.constructor : undefined,
  6396. ctorString = Ctor ? toSource(Ctor) : '';
  6397. if (ctorString) {
  6398. switch (ctorString) {
  6399. case dataViewCtorString: return dataViewTag;
  6400. case mapCtorString: return mapTag;
  6401. case promiseCtorString: return promiseTag;
  6402. case setCtorString: return setTag;
  6403. case weakMapCtorString: return weakMapTag;
  6404. }
  6405. }
  6406. return result;
  6407. };
  6408. }
  6409. /**
  6410. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  6411. *
  6412. * @private
  6413. * @param {number} start The start of the view.
  6414. * @param {number} end The end of the view.
  6415. * @param {Array} transforms The transformations to apply to the view.
  6416. * @returns {Object} Returns an object containing the `start` and `end`
  6417. * positions of the view.
  6418. */
  6419. function getView(start, end, transforms) {
  6420. var index = -1,
  6421. length = transforms.length;
  6422. while (++index < length) {
  6423. var data = transforms[index],
  6424. size = data.size;
  6425. switch (data.type) {
  6426. case 'drop': start += size; break;
  6427. case 'dropRight': end -= size; break;
  6428. case 'take': end = nativeMin(end, start + size); break;
  6429. case 'takeRight': start = nativeMax(start, end - size); break;
  6430. }
  6431. }
  6432. return { 'start': start, 'end': end };
  6433. }
  6434. /**
  6435. * Extracts wrapper details from the `source` body comment.
  6436. *
  6437. * @private
  6438. * @param {string} source The source to inspect.
  6439. * @returns {Array} Returns the wrapper details.
  6440. */
  6441. function getWrapDetails(source) {
  6442. var match = source.match(reWrapDetails);
  6443. return match ? match[1].split(reSplitDetails) : [];
  6444. }
  6445. /**
  6446. * Checks if `path` exists on `object`.
  6447. *
  6448. * @private
  6449. * @param {Object} object The object to query.
  6450. * @param {Array|string} path The path to check.
  6451. * @param {Function} hasFunc The function to check properties.
  6452. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  6453. */
  6454. function hasPath(object, path, hasFunc) {
  6455. path = castPath(path, object);
  6456. var index = -1,
  6457. length = path.length,
  6458. result = false;
  6459. while (++index < length) {
  6460. var key = toKey(path[index]);
  6461. if (!(result = object != null && hasFunc(object, key))) {
  6462. break;
  6463. }
  6464. object = object[key];
  6465. }
  6466. if (result || ++index != length) {
  6467. return result;
  6468. }
  6469. length = object == null ? 0 : object.length;
  6470. return !!length && isLength(length) && isIndex(key, length) &&
  6471. (isArray(object) || isArguments(object));
  6472. }
  6473. /**
  6474. * Initializes an array clone.
  6475. *
  6476. * @private
  6477. * @param {Array} array The array to clone.
  6478. * @returns {Array} Returns the initialized clone.
  6479. */
  6480. function initCloneArray(array) {
  6481. var length = array.length,
  6482. result = array.constructor(length);
  6483. // Add properties assigned by `RegExp#exec`.
  6484. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  6485. result.index = array.index;
  6486. result.input = array.input;
  6487. }
  6488. return result;
  6489. }
  6490. /**
  6491. * Initializes an object clone.
  6492. *
  6493. * @private
  6494. * @param {Object} object The object to clone.
  6495. * @returns {Object} Returns the initialized clone.
  6496. */
  6497. function initCloneObject(object) {
  6498. return (typeof object.constructor == 'function' && !isPrototype(object))
  6499. ? baseCreate(getPrototype(object))
  6500. : {};
  6501. }
  6502. /**
  6503. * Initializes an object clone based on its `toStringTag`.
  6504. *
  6505. * **Note:** This function only supports cloning values with tags of
  6506. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6507. *
  6508. * @private
  6509. * @param {Object} object The object to clone.
  6510. * @param {string} tag The `toStringTag` of the object to clone.
  6511. * @param {Function} cloneFunc The function to clone values.
  6512. * @param {boolean} [isDeep] Specify a deep clone.
  6513. * @returns {Object} Returns the initialized clone.
  6514. */
  6515. function initCloneByTag(object, tag, cloneFunc, isDeep) {
  6516. var Ctor = object.constructor;
  6517. switch (tag) {
  6518. case arrayBufferTag:
  6519. return cloneArrayBuffer(object);
  6520. case boolTag:
  6521. case dateTag:
  6522. return new Ctor(+object);
  6523. case dataViewTag:
  6524. return cloneDataView(object, isDeep);
  6525. case float32Tag: case float64Tag:
  6526. case int8Tag: case int16Tag: case int32Tag:
  6527. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  6528. return cloneTypedArray(object, isDeep);
  6529. case mapTag:
  6530. return cloneMap(object, isDeep, cloneFunc);
  6531. case numberTag:
  6532. case stringTag:
  6533. return new Ctor(object);
  6534. case regexpTag:
  6535. return cloneRegExp(object);
  6536. case setTag:
  6537. return cloneSet(object, isDeep, cloneFunc);
  6538. case symbolTag:
  6539. return cloneSymbol(object);
  6540. }
  6541. }
  6542. /**
  6543. * Inserts wrapper `details` in a comment at the top of the `source` body.
  6544. *
  6545. * @private
  6546. * @param {string} source The source to modify.
  6547. * @returns {Array} details The details to insert.
  6548. * @returns {string} Returns the modified source.
  6549. */
  6550. function insertWrapDetails(source, details) {
  6551. var length = details.length;
  6552. if (!length) {
  6553. return source;
  6554. }
  6555. var lastIndex = length - 1;
  6556. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  6557. details = details.join(length > 2 ? ', ' : ' ');
  6558. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  6559. }
  6560. /**
  6561. * Checks if `value` is a flattenable `arguments` object or array.
  6562. *
  6563. * @private
  6564. * @param {*} value The value to check.
  6565. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  6566. */
  6567. function isFlattenable(value) {
  6568. return isArray(value) || isArguments(value) ||
  6569. !!(spreadableSymbol && value && value[spreadableSymbol]);
  6570. }
  6571. /**
  6572. * Checks if `value` is a valid array-like index.
  6573. *
  6574. * @private
  6575. * @param {*} value The value to check.
  6576. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  6577. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  6578. */
  6579. function isIndex(value, length) {
  6580. length = length == null ? MAX_SAFE_INTEGER : length;
  6581. return !!length &&
  6582. (typeof value == 'number' || reIsUint.test(value)) &&
  6583. (value > -1 && value % 1 == 0 && value < length);
  6584. }
  6585. /**
  6586. * Checks if the given arguments are from an iteratee call.
  6587. *
  6588. * @private
  6589. * @param {*} value The potential iteratee value argument.
  6590. * @param {*} index The potential iteratee index or key argument.
  6591. * @param {*} object The potential iteratee object argument.
  6592. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  6593. * else `false`.
  6594. */
  6595. function isIterateeCall(value, index, object) {
  6596. if (!isObject(object)) {
  6597. return false;
  6598. }
  6599. var type = typeof index;
  6600. if (type == 'number'
  6601. ? (isArrayLike(object) && isIndex(index, object.length))
  6602. : (type == 'string' && index in object)
  6603. ) {
  6604. return eq(object[index], value);
  6605. }
  6606. return false;
  6607. }
  6608. /**
  6609. * Checks if `value` is a property name and not a property path.
  6610. *
  6611. * @private
  6612. * @param {*} value The value to check.
  6613. * @param {Object} [object] The object to query keys on.
  6614. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  6615. */
  6616. function isKey(value, object) {
  6617. if (isArray(value)) {
  6618. return false;
  6619. }
  6620. var type = typeof value;
  6621. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  6622. value == null || isSymbol(value)) {
  6623. return true;
  6624. }
  6625. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  6626. (object != null && value in Object(object));
  6627. }
  6628. /**
  6629. * Checks if `value` is suitable for use as unique object key.
  6630. *
  6631. * @private
  6632. * @param {*} value The value to check.
  6633. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  6634. */
  6635. function isKeyable(value) {
  6636. var type = typeof value;
  6637. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  6638. ? (value !== '__proto__')
  6639. : (value === null);
  6640. }
  6641. /**
  6642. * Checks if `func` has a lazy counterpart.
  6643. *
  6644. * @private
  6645. * @param {Function} func The function to check.
  6646. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  6647. * else `false`.
  6648. */
  6649. function isLaziable(func) {
  6650. var funcName = getFuncName(func),
  6651. other = lodash[funcName];
  6652. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  6653. return false;
  6654. }
  6655. if (func === other) {
  6656. return true;
  6657. }
  6658. var data = getData(other);
  6659. return !!data && func === data[0];
  6660. }
  6661. /**
  6662. * Checks if `func` has its source masked.
  6663. *
  6664. * @private
  6665. * @param {Function} func The function to check.
  6666. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  6667. */
  6668. function isMasked(func) {
  6669. return !!maskSrcKey && (maskSrcKey in func);
  6670. }
  6671. /**
  6672. * Checks if `func` is capable of being masked.
  6673. *
  6674. * @private
  6675. * @param {*} value The value to check.
  6676. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  6677. */
  6678. var isMaskable = coreJsData ? isFunction : stubFalse;
  6679. /**
  6680. * Checks if `value` is likely a prototype object.
  6681. *
  6682. * @private
  6683. * @param {*} value The value to check.
  6684. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  6685. */
  6686. function isPrototype(value) {
  6687. var Ctor = value && value.constructor,
  6688. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  6689. return value === proto;
  6690. }
  6691. /**
  6692. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  6693. *
  6694. * @private
  6695. * @param {*} value The value to check.
  6696. * @returns {boolean} Returns `true` if `value` if suitable for strict
  6697. * equality comparisons, else `false`.
  6698. */
  6699. function isStrictComparable(value) {
  6700. return value === value && !isObject(value);
  6701. }
  6702. /**
  6703. * A specialized version of `matchesProperty` for source values suitable
  6704. * for strict equality comparisons, i.e. `===`.
  6705. *
  6706. * @private
  6707. * @param {string} key The key of the property to get.
  6708. * @param {*} srcValue The value to match.
  6709. * @returns {Function} Returns the new spec function.
  6710. */
  6711. function matchesStrictComparable(key, srcValue) {
  6712. return function(object) {
  6713. if (object == null) {
  6714. return false;
  6715. }
  6716. return object[key] === srcValue &&
  6717. (srcValue !== undefined || (key in Object(object)));
  6718. };
  6719. }
  6720. /**
  6721. * A specialized version of `_.memoize` which clears the memoized function's
  6722. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  6723. *
  6724. * @private
  6725. * @param {Function} func The function to have its output memoized.
  6726. * @returns {Function} Returns the new memoized function.
  6727. */
  6728. function memoizeCapped(func) {
  6729. var result = memoize(func, function(key) {
  6730. if (cache.size === MAX_MEMOIZE_SIZE) {
  6731. cache.clear();
  6732. }
  6733. return key;
  6734. });
  6735. var cache = result.cache;
  6736. return result;
  6737. }
  6738. /**
  6739. * Merges the function metadata of `source` into `data`.
  6740. *
  6741. * Merging metadata reduces the number of wrappers used to invoke a function.
  6742. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  6743. * may be applied regardless of execution order. Methods like `_.ary` and
  6744. * `_.rearg` modify function arguments, making the order in which they are
  6745. * executed important, preventing the merging of metadata. However, we make
  6746. * an exception for a safe combined case where curried functions have `_.ary`
  6747. * and or `_.rearg` applied.
  6748. *
  6749. * @private
  6750. * @param {Array} data The destination metadata.
  6751. * @param {Array} source The source metadata.
  6752. * @returns {Array} Returns `data`.
  6753. */
  6754. function mergeData(data, source) {
  6755. var bitmask = data[1],
  6756. srcBitmask = source[1],
  6757. newBitmask = bitmask | srcBitmask,
  6758. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  6759. var isCombo =
  6760. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  6761. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  6762. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  6763. // Exit early if metadata can't be merged.
  6764. if (!(isCommon || isCombo)) {
  6765. return data;
  6766. }
  6767. // Use source `thisArg` if available.
  6768. if (srcBitmask & WRAP_BIND_FLAG) {
  6769. data[2] = source[2];
  6770. // Set when currying a bound function.
  6771. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  6772. }
  6773. // Compose partial arguments.
  6774. var value = source[3];
  6775. if (value) {
  6776. var partials = data[3];
  6777. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  6778. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  6779. }
  6780. // Compose partial right arguments.
  6781. value = source[5];
  6782. if (value) {
  6783. partials = data[5];
  6784. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  6785. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  6786. }
  6787. // Use source `argPos` if available.
  6788. value = source[7];
  6789. if (value) {
  6790. data[7] = value;
  6791. }
  6792. // Use source `ary` if it's smaller.
  6793. if (srcBitmask & WRAP_ARY_FLAG) {
  6794. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  6795. }
  6796. // Use source `arity` if one is not provided.
  6797. if (data[9] == null) {
  6798. data[9] = source[9];
  6799. }
  6800. // Use source `func` and merge bitmasks.
  6801. data[0] = source[0];
  6802. data[1] = newBitmask;
  6803. return data;
  6804. }
  6805. /**
  6806. * This function is like
  6807. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  6808. * except that it includes inherited enumerable properties.
  6809. *
  6810. * @private
  6811. * @param {Object} object The object to query.
  6812. * @returns {Array} Returns the array of property names.
  6813. */
  6814. function nativeKeysIn(object) {
  6815. var result = [];
  6816. if (object != null) {
  6817. for (var key in Object(object)) {
  6818. result.push(key);
  6819. }
  6820. }
  6821. return result;
  6822. }
  6823. /**
  6824. * Converts `value` to a string using `Object.prototype.toString`.
  6825. *
  6826. * @private
  6827. * @param {*} value The value to convert.
  6828. * @returns {string} Returns the converted string.
  6829. */
  6830. function objectToString(value) {
  6831. return nativeObjectToString.call(value);
  6832. }
  6833. /**
  6834. * A specialized version of `baseRest` which transforms the rest array.
  6835. *
  6836. * @private
  6837. * @param {Function} func The function to apply a rest parameter to.
  6838. * @param {number} [start=func.length-1] The start position of the rest parameter.
  6839. * @param {Function} transform The rest array transform.
  6840. * @returns {Function} Returns the new function.
  6841. */
  6842. function overRest(func, start, transform) {
  6843. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  6844. return function() {
  6845. var args = arguments,
  6846. index = -1,
  6847. length = nativeMax(args.length - start, 0),
  6848. array = Array(length);
  6849. while (++index < length) {
  6850. array[index] = args[start + index];
  6851. }
  6852. index = -1;
  6853. var otherArgs = Array(start + 1);
  6854. while (++index < start) {
  6855. otherArgs[index] = args[index];
  6856. }
  6857. otherArgs[start] = transform(array);
  6858. return apply(func, this, otherArgs);
  6859. };
  6860. }
  6861. /**
  6862. * Gets the parent value at `path` of `object`.
  6863. *
  6864. * @private
  6865. * @param {Object} object The object to query.
  6866. * @param {Array} path The path to get the parent value of.
  6867. * @returns {*} Returns the parent value.
  6868. */
  6869. function parent(object, path) {
  6870. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  6871. }
  6872. /**
  6873. * Reorder `array` according to the specified indexes where the element at
  6874. * the first index is assigned as the first element, the element at
  6875. * the second index is assigned as the second element, and so on.
  6876. *
  6877. * @private
  6878. * @param {Array} array The array to reorder.
  6879. * @param {Array} indexes The arranged array indexes.
  6880. * @returns {Array} Returns `array`.
  6881. */
  6882. function reorder(array, indexes) {
  6883. var arrLength = array.length,
  6884. length = nativeMin(indexes.length, arrLength),
  6885. oldArray = copyArray(array);
  6886. while (length--) {
  6887. var index = indexes[length];
  6888. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  6889. }
  6890. return array;
  6891. }
  6892. /**
  6893. * Sets metadata for `func`.
  6894. *
  6895. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  6896. * period of time, it will trip its breaker and transition to an identity
  6897. * function to avoid garbage collection pauses in V8. See
  6898. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  6899. * for more details.
  6900. *
  6901. * @private
  6902. * @param {Function} func The function to associate metadata with.
  6903. * @param {*} data The metadata.
  6904. * @returns {Function} Returns `func`.
  6905. */
  6906. var setData = shortOut(baseSetData);
  6907. /**
  6908. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  6909. *
  6910. * @private
  6911. * @param {Function} func The function to delay.
  6912. * @param {number} wait The number of milliseconds to delay invocation.
  6913. * @returns {number|Object} Returns the timer id or timeout object.
  6914. */
  6915. var setTimeout = ctxSetTimeout || function(func, wait) {
  6916. return root.setTimeout(func, wait);
  6917. };
  6918. /**
  6919. * Sets the `toString` method of `func` to return `string`.
  6920. *
  6921. * @private
  6922. * @param {Function} func The function to modify.
  6923. * @param {Function} string The `toString` result.
  6924. * @returns {Function} Returns `func`.
  6925. */
  6926. var setToString = shortOut(baseSetToString);
  6927. /**
  6928. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  6929. * with wrapper details in a comment at the top of the source body.
  6930. *
  6931. * @private
  6932. * @param {Function} wrapper The function to modify.
  6933. * @param {Function} reference The reference function.
  6934. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6935. * @returns {Function} Returns `wrapper`.
  6936. */
  6937. function setWrapToString(wrapper, reference, bitmask) {
  6938. var source = (reference + '');
  6939. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  6940. }
  6941. /**
  6942. * Creates a function that'll short out and invoke `identity` instead
  6943. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  6944. * milliseconds.
  6945. *
  6946. * @private
  6947. * @param {Function} func The function to restrict.
  6948. * @returns {Function} Returns the new shortable function.
  6949. */
  6950. function shortOut(func) {
  6951. var count = 0,
  6952. lastCalled = 0;
  6953. return function() {
  6954. var stamp = nativeNow(),
  6955. remaining = HOT_SPAN - (stamp - lastCalled);
  6956. lastCalled = stamp;
  6957. if (remaining > 0) {
  6958. if (++count >= HOT_COUNT) {
  6959. return arguments[0];
  6960. }
  6961. } else {
  6962. count = 0;
  6963. }
  6964. return func.apply(undefined, arguments);
  6965. };
  6966. }
  6967. /**
  6968. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  6969. *
  6970. * @private
  6971. * @param {Array} array The array to shuffle.
  6972. * @param {number} [size=array.length] The size of `array`.
  6973. * @returns {Array} Returns `array`.
  6974. */
  6975. function shuffleSelf(array, size) {
  6976. var index = -1,
  6977. length = array.length,
  6978. lastIndex = length - 1;
  6979. size = size === undefined ? length : size;
  6980. while (++index < size) {
  6981. var rand = baseRandom(index, lastIndex),
  6982. value = array[rand];
  6983. array[rand] = array[index];
  6984. array[index] = value;
  6985. }
  6986. array.length = size;
  6987. return array;
  6988. }
  6989. /**
  6990. * Converts `string` to a property path array.
  6991. *
  6992. * @private
  6993. * @param {string} string The string to convert.
  6994. * @returns {Array} Returns the property path array.
  6995. */
  6996. var stringToPath = memoizeCapped(function(string) {
  6997. var result = [];
  6998. if (reLeadingDot.test(string)) {
  6999. result.push('');
  7000. }
  7001. string.replace(rePropName, function(match, number, quote, string) {
  7002. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  7003. });
  7004. return result;
  7005. });
  7006. /**
  7007. * Converts `value` to a string key if it's not a string or symbol.
  7008. *
  7009. * @private
  7010. * @param {*} value The value to inspect.
  7011. * @returns {string|symbol} Returns the key.
  7012. */
  7013. function toKey(value) {
  7014. if (typeof value == 'string' || isSymbol(value)) {
  7015. return value;
  7016. }
  7017. var result = (value + '');
  7018. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  7019. }
  7020. /**
  7021. * Converts `func` to its source code.
  7022. *
  7023. * @private
  7024. * @param {Function} func The function to convert.
  7025. * @returns {string} Returns the source code.
  7026. */
  7027. function toSource(func) {
  7028. if (func != null) {
  7029. try {
  7030. return funcToString.call(func);
  7031. } catch (e) {}
  7032. try {
  7033. return (func + '');
  7034. } catch (e) {}
  7035. }
  7036. return '';
  7037. }
  7038. /**
  7039. * Updates wrapper `details` based on `bitmask` flags.
  7040. *
  7041. * @private
  7042. * @returns {Array} details The details to modify.
  7043. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7044. * @returns {Array} Returns `details`.
  7045. */
  7046. function updateWrapDetails(details, bitmask) {
  7047. arrayEach(wrapFlags, function(pair) {
  7048. var value = '_.' + pair[0];
  7049. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  7050. details.push(value);
  7051. }
  7052. });
  7053. return details.sort();
  7054. }
  7055. /**
  7056. * Creates a clone of `wrapper`.
  7057. *
  7058. * @private
  7059. * @param {Object} wrapper The wrapper to clone.
  7060. * @returns {Object} Returns the cloned wrapper.
  7061. */
  7062. function wrapperClone(wrapper) {
  7063. if (wrapper instanceof LazyWrapper) {
  7064. return wrapper.clone();
  7065. }
  7066. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  7067. result.__actions__ = copyArray(wrapper.__actions__);
  7068. result.__index__ = wrapper.__index__;
  7069. result.__values__ = wrapper.__values__;
  7070. return result;
  7071. }
  7072. /*------------------------------------------------------------------------*/
  7073. /**
  7074. * Creates an array of elements split into groups the length of `size`.
  7075. * If `array` can't be split evenly, the final chunk will be the remaining
  7076. * elements.
  7077. *
  7078. * @static
  7079. * @memberOf _
  7080. * @since 3.0.0
  7081. * @category Array
  7082. * @param {Array} array The array to process.
  7083. * @param {number} [size=1] The length of each chunk
  7084. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7085. * @returns {Array} Returns the new array of chunks.
  7086. * @example
  7087. *
  7088. * _.chunk(['a', 'b', 'c', 'd'], 2);
  7089. * // => [['a', 'b'], ['c', 'd']]
  7090. *
  7091. * _.chunk(['a', 'b', 'c', 'd'], 3);
  7092. * // => [['a', 'b', 'c'], ['d']]
  7093. */
  7094. function chunk(array, size, guard) {
  7095. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  7096. size = 1;
  7097. } else {
  7098. size = nativeMax(toInteger(size), 0);
  7099. }
  7100. var length = array == null ? 0 : array.length;
  7101. if (!length || size < 1) {
  7102. return [];
  7103. }
  7104. var index = 0,
  7105. resIndex = 0,
  7106. result = Array(nativeCeil(length / size));
  7107. while (index < length) {
  7108. result[resIndex++] = baseSlice(array, index, (index += size));
  7109. }
  7110. return result;
  7111. }
  7112. /**
  7113. * Creates an array with all falsey values removed. The values `false`, `null`,
  7114. * `0`, `""`, `undefined`, and `NaN` are falsey.
  7115. *
  7116. * @static
  7117. * @memberOf _
  7118. * @since 0.1.0
  7119. * @category Array
  7120. * @param {Array} array The array to compact.
  7121. * @returns {Array} Returns the new array of filtered values.
  7122. * @example
  7123. *
  7124. * _.compact([0, 1, false, 2, '', 3]);
  7125. * // => [1, 2, 3]
  7126. */
  7127. function compact(array) {
  7128. var index = -1,
  7129. length = array == null ? 0 : array.length,
  7130. resIndex = 0,
  7131. result = [];
  7132. while (++index < length) {
  7133. var value = array[index];
  7134. if (value) {
  7135. result[resIndex++] = value;
  7136. }
  7137. }
  7138. return result;
  7139. }
  7140. /**
  7141. * Creates a new array concatenating `array` with any additional arrays
  7142. * and/or values.
  7143. *
  7144. * @static
  7145. * @memberOf _
  7146. * @since 4.0.0
  7147. * @category Array
  7148. * @param {Array} array The array to concatenate.
  7149. * @param {...*} [values] The values to concatenate.
  7150. * @returns {Array} Returns the new concatenated array.
  7151. * @example
  7152. *
  7153. * var array = [1];
  7154. * var other = _.concat(array, 2, [3], [[4]]);
  7155. *
  7156. * console.log(other);
  7157. * // => [1, 2, 3, [4]]
  7158. *
  7159. * console.log(array);
  7160. * // => [1]
  7161. */
  7162. function concat() {
  7163. var length = arguments.length;
  7164. if (!length) {
  7165. return [];
  7166. }
  7167. var args = Array(length - 1),
  7168. array = arguments[0],
  7169. index = length;
  7170. while (index--) {
  7171. args[index - 1] = arguments[index];
  7172. }
  7173. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  7174. }
  7175. /**
  7176. * Creates an array of `array` values not included in the other given arrays
  7177. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7178. * for equality comparisons. The order and references of result values are
  7179. * determined by the first array.
  7180. *
  7181. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  7182. *
  7183. * @static
  7184. * @memberOf _
  7185. * @since 0.1.0
  7186. * @category Array
  7187. * @param {Array} array The array to inspect.
  7188. * @param {...Array} [values] The values to exclude.
  7189. * @returns {Array} Returns the new array of filtered values.
  7190. * @see _.without, _.xor
  7191. * @example
  7192. *
  7193. * _.difference([2, 1], [2, 3]);
  7194. * // => [1]
  7195. */
  7196. var difference = baseRest(function(array, values) {
  7197. return isArrayLikeObject(array)
  7198. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  7199. : [];
  7200. });
  7201. /**
  7202. * This method is like `_.difference` except that it accepts `iteratee` which
  7203. * is invoked for each element of `array` and `values` to generate the criterion
  7204. * by which they're compared. The order and references of result values are
  7205. * determined by the first array. The iteratee is invoked with one argument:
  7206. * (value).
  7207. *
  7208. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  7209. *
  7210. * @static
  7211. * @memberOf _
  7212. * @since 4.0.0
  7213. * @category Array
  7214. * @param {Array} array The array to inspect.
  7215. * @param {...Array} [values] The values to exclude.
  7216. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7217. * @returns {Array} Returns the new array of filtered values.
  7218. * @example
  7219. *
  7220. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  7221. * // => [1.2]
  7222. *
  7223. * // The `_.property` iteratee shorthand.
  7224. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  7225. * // => [{ 'x': 2 }]
  7226. */
  7227. var differenceBy = baseRest(function(array, values) {
  7228. var iteratee = last(values);
  7229. if (isArrayLikeObject(iteratee)) {
  7230. iteratee = undefined;
  7231. }
  7232. return isArrayLikeObject(array)
  7233. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  7234. : [];
  7235. });
  7236. /**
  7237. * This method is like `_.difference` except that it accepts `comparator`
  7238. * which is invoked to compare elements of `array` to `values`. The order and
  7239. * references of result values are determined by the first array. The comparator
  7240. * is invoked with two arguments: (arrVal, othVal).
  7241. *
  7242. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  7243. *
  7244. * @static
  7245. * @memberOf _
  7246. * @since 4.0.0
  7247. * @category Array
  7248. * @param {Array} array The array to inspect.
  7249. * @param {...Array} [values] The values to exclude.
  7250. * @param {Function} [comparator] The comparator invoked per element.
  7251. * @returns {Array} Returns the new array of filtered values.
  7252. * @example
  7253. *
  7254. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  7255. *
  7256. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  7257. * // => [{ 'x': 2, 'y': 1 }]
  7258. */
  7259. var differenceWith = baseRest(function(array, values) {
  7260. var comparator = last(values);
  7261. if (isArrayLikeObject(comparator)) {
  7262. comparator = undefined;
  7263. }
  7264. return isArrayLikeObject(array)
  7265. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  7266. : [];
  7267. });
  7268. /**
  7269. * Creates a slice of `array` with `n` elements dropped from the beginning.
  7270. *
  7271. * @static
  7272. * @memberOf _
  7273. * @since 0.5.0
  7274. * @category Array
  7275. * @param {Array} array The array to query.
  7276. * @param {number} [n=1] The number of elements to drop.
  7277. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7278. * @returns {Array} Returns the slice of `array`.
  7279. * @example
  7280. *
  7281. * _.drop([1, 2, 3]);
  7282. * // => [2, 3]
  7283. *
  7284. * _.drop([1, 2, 3], 2);
  7285. * // => [3]
  7286. *
  7287. * _.drop([1, 2, 3], 5);
  7288. * // => []
  7289. *
  7290. * _.drop([1, 2, 3], 0);
  7291. * // => [1, 2, 3]
  7292. */
  7293. function drop(array, n, guard) {
  7294. var length = array == null ? 0 : array.length;
  7295. if (!length) {
  7296. return [];
  7297. }
  7298. n = (guard || n === undefined) ? 1 : toInteger(n);
  7299. return baseSlice(array, n < 0 ? 0 : n, length);
  7300. }
  7301. /**
  7302. * Creates a slice of `array` with `n` elements dropped from the end.
  7303. *
  7304. * @static
  7305. * @memberOf _
  7306. * @since 3.0.0
  7307. * @category Array
  7308. * @param {Array} array The array to query.
  7309. * @param {number} [n=1] The number of elements to drop.
  7310. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7311. * @returns {Array} Returns the slice of `array`.
  7312. * @example
  7313. *
  7314. * _.dropRight([1, 2, 3]);
  7315. * // => [1, 2]
  7316. *
  7317. * _.dropRight([1, 2, 3], 2);
  7318. * // => [1]
  7319. *
  7320. * _.dropRight([1, 2, 3], 5);
  7321. * // => []
  7322. *
  7323. * _.dropRight([1, 2, 3], 0);
  7324. * // => [1, 2, 3]
  7325. */
  7326. function dropRight(array, n, guard) {
  7327. var length = array == null ? 0 : array.length;
  7328. if (!length) {
  7329. return [];
  7330. }
  7331. n = (guard || n === undefined) ? 1 : toInteger(n);
  7332. n = length - n;
  7333. return baseSlice(array, 0, n < 0 ? 0 : n);
  7334. }
  7335. /**
  7336. * Creates a slice of `array` excluding elements dropped from the end.
  7337. * Elements are dropped until `predicate` returns falsey. The predicate is
  7338. * invoked with three arguments: (value, index, array).
  7339. *
  7340. * @static
  7341. * @memberOf _
  7342. * @since 3.0.0
  7343. * @category Array
  7344. * @param {Array} array The array to query.
  7345. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7346. * @returns {Array} Returns the slice of `array`.
  7347. * @example
  7348. *
  7349. * var users = [
  7350. * { 'user': 'barney', 'active': true },
  7351. * { 'user': 'fred', 'active': false },
  7352. * { 'user': 'pebbles', 'active': false }
  7353. * ];
  7354. *
  7355. * _.dropRightWhile(users, function(o) { return !o.active; });
  7356. * // => objects for ['barney']
  7357. *
  7358. * // The `_.matches` iteratee shorthand.
  7359. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  7360. * // => objects for ['barney', 'fred']
  7361. *
  7362. * // The `_.matchesProperty` iteratee shorthand.
  7363. * _.dropRightWhile(users, ['active', false]);
  7364. * // => objects for ['barney']
  7365. *
  7366. * // The `_.property` iteratee shorthand.
  7367. * _.dropRightWhile(users, 'active');
  7368. * // => objects for ['barney', 'fred', 'pebbles']
  7369. */
  7370. function dropRightWhile(array, predicate) {
  7371. return (array && array.length)
  7372. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  7373. : [];
  7374. }
  7375. /**
  7376. * Creates a slice of `array` excluding elements dropped from the beginning.
  7377. * Elements are dropped until `predicate` returns falsey. The predicate is
  7378. * invoked with three arguments: (value, index, array).
  7379. *
  7380. * @static
  7381. * @memberOf _
  7382. * @since 3.0.0
  7383. * @category Array
  7384. * @param {Array} array The array to query.
  7385. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7386. * @returns {Array} Returns the slice of `array`.
  7387. * @example
  7388. *
  7389. * var users = [
  7390. * { 'user': 'barney', 'active': false },
  7391. * { 'user': 'fred', 'active': false },
  7392. * { 'user': 'pebbles', 'active': true }
  7393. * ];
  7394. *
  7395. * _.dropWhile(users, function(o) { return !o.active; });
  7396. * // => objects for ['pebbles']
  7397. *
  7398. * // The `_.matches` iteratee shorthand.
  7399. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  7400. * // => objects for ['fred', 'pebbles']
  7401. *
  7402. * // The `_.matchesProperty` iteratee shorthand.
  7403. * _.dropWhile(users, ['active', false]);
  7404. * // => objects for ['pebbles']
  7405. *
  7406. * // The `_.property` iteratee shorthand.
  7407. * _.dropWhile(users, 'active');
  7408. * // => objects for ['barney', 'fred', 'pebbles']
  7409. */
  7410. function dropWhile(array, predicate) {
  7411. return (array && array.length)
  7412. ? baseWhile(array, getIteratee(predicate, 3), true)
  7413. : [];
  7414. }
  7415. /**
  7416. * Fills elements of `array` with `value` from `start` up to, but not
  7417. * including, `end`.
  7418. *
  7419. * **Note:** This method mutates `array`.
  7420. *
  7421. * @static
  7422. * @memberOf _
  7423. * @since 3.2.0
  7424. * @category Array
  7425. * @param {Array} array The array to fill.
  7426. * @param {*} value The value to fill `array` with.
  7427. * @param {number} [start=0] The start position.
  7428. * @param {number} [end=array.length] The end position.
  7429. * @returns {Array} Returns `array`.
  7430. * @example
  7431. *
  7432. * var array = [1, 2, 3];
  7433. *
  7434. * _.fill(array, 'a');
  7435. * console.log(array);
  7436. * // => ['a', 'a', 'a']
  7437. *
  7438. * _.fill(Array(3), 2);
  7439. * // => [2, 2, 2]
  7440. *
  7441. * _.fill([4, 6, 8, 10], '*', 1, 3);
  7442. * // => [4, '*', '*', 10]
  7443. */
  7444. function fill(array, value, start, end) {
  7445. var length = array == null ? 0 : array.length;
  7446. if (!length) {
  7447. return [];
  7448. }
  7449. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  7450. start = 0;
  7451. end = length;
  7452. }
  7453. return baseFill(array, value, start, end);
  7454. }
  7455. /**
  7456. * This method is like `_.find` except that it returns the index of the first
  7457. * element `predicate` returns truthy for instead of the element itself.
  7458. *
  7459. * @static
  7460. * @memberOf _
  7461. * @since 1.1.0
  7462. * @category Array
  7463. * @param {Array} array The array to inspect.
  7464. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7465. * @param {number} [fromIndex=0] The index to search from.
  7466. * @returns {number} Returns the index of the found element, else `-1`.
  7467. * @example
  7468. *
  7469. * var users = [
  7470. * { 'user': 'barney', 'active': false },
  7471. * { 'user': 'fred', 'active': false },
  7472. * { 'user': 'pebbles', 'active': true }
  7473. * ];
  7474. *
  7475. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  7476. * // => 0
  7477. *
  7478. * // The `_.matches` iteratee shorthand.
  7479. * _.findIndex(users, { 'user': 'fred', 'active': false });
  7480. * // => 1
  7481. *
  7482. * // The `_.matchesProperty` iteratee shorthand.
  7483. * _.findIndex(users, ['active', false]);
  7484. * // => 0
  7485. *
  7486. * // The `_.property` iteratee shorthand.
  7487. * _.findIndex(users, 'active');
  7488. * // => 2
  7489. */
  7490. function findIndex(array, predicate, fromIndex) {
  7491. var length = array == null ? 0 : array.length;
  7492. if (!length) {
  7493. return -1;
  7494. }
  7495. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  7496. if (index < 0) {
  7497. index = nativeMax(length + index, 0);
  7498. }
  7499. return baseFindIndex(array, getIteratee(predicate, 3), index);
  7500. }
  7501. /**
  7502. * This method is like `_.findIndex` except that it iterates over elements
  7503. * of `collection` from right to left.
  7504. *
  7505. * @static
  7506. * @memberOf _
  7507. * @since 2.0.0
  7508. * @category Array
  7509. * @param {Array} array The array to inspect.
  7510. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7511. * @param {number} [fromIndex=array.length-1] The index to search from.
  7512. * @returns {number} Returns the index of the found element, else `-1`.
  7513. * @example
  7514. *
  7515. * var users = [
  7516. * { 'user': 'barney', 'active': true },
  7517. * { 'user': 'fred', 'active': false },
  7518. * { 'user': 'pebbles', 'active': false }
  7519. * ];
  7520. *
  7521. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  7522. * // => 2
  7523. *
  7524. * // The `_.matches` iteratee shorthand.
  7525. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  7526. * // => 0
  7527. *
  7528. * // The `_.matchesProperty` iteratee shorthand.
  7529. * _.findLastIndex(users, ['active', false]);
  7530. * // => 2
  7531. *
  7532. * // The `_.property` iteratee shorthand.
  7533. * _.findLastIndex(users, 'active');
  7534. * // => 0
  7535. */
  7536. function findLastIndex(array, predicate, fromIndex) {
  7537. var length = array == null ? 0 : array.length;
  7538. if (!length) {
  7539. return -1;
  7540. }
  7541. var index = length - 1;
  7542. if (fromIndex !== undefined) {
  7543. index = toInteger(fromIndex);
  7544. index = fromIndex < 0
  7545. ? nativeMax(length + index, 0)
  7546. : nativeMin(index, length - 1);
  7547. }
  7548. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  7549. }
  7550. /**
  7551. * Flattens `array` a single level deep.
  7552. *
  7553. * @static
  7554. * @memberOf _
  7555. * @since 0.1.0
  7556. * @category Array
  7557. * @param {Array} array The array to flatten.
  7558. * @returns {Array} Returns the new flattened array.
  7559. * @example
  7560. *
  7561. * _.flatten([1, [2, [3, [4]], 5]]);
  7562. * // => [1, 2, [3, [4]], 5]
  7563. */
  7564. function flatten(array) {
  7565. var length = array == null ? 0 : array.length;
  7566. return length ? baseFlatten(array, 1) : [];
  7567. }
  7568. /**
  7569. * Recursively flattens `array`.
  7570. *
  7571. * @static
  7572. * @memberOf _
  7573. * @since 3.0.0
  7574. * @category Array
  7575. * @param {Array} array The array to flatten.
  7576. * @returns {Array} Returns the new flattened array.
  7577. * @example
  7578. *
  7579. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  7580. * // => [1, 2, 3, 4, 5]
  7581. */
  7582. function flattenDeep(array) {
  7583. var length = array == null ? 0 : array.length;
  7584. return length ? baseFlatten(array, INFINITY) : [];
  7585. }
  7586. /**
  7587. * Recursively flatten `array` up to `depth` times.
  7588. *
  7589. * @static
  7590. * @memberOf _
  7591. * @since 4.4.0
  7592. * @category Array
  7593. * @param {Array} array The array to flatten.
  7594. * @param {number} [depth=1] The maximum recursion depth.
  7595. * @returns {Array} Returns the new flattened array.
  7596. * @example
  7597. *
  7598. * var array = [1, [2, [3, [4]], 5]];
  7599. *
  7600. * _.flattenDepth(array, 1);
  7601. * // => [1, 2, [3, [4]], 5]
  7602. *
  7603. * _.flattenDepth(array, 2);
  7604. * // => [1, 2, 3, [4], 5]
  7605. */
  7606. function flattenDepth(array, depth) {
  7607. var length = array == null ? 0 : array.length;
  7608. if (!length) {
  7609. return [];
  7610. }
  7611. depth = depth === undefined ? 1 : toInteger(depth);
  7612. return baseFlatten(array, depth);
  7613. }
  7614. /**
  7615. * The inverse of `_.toPairs`; this method returns an object composed
  7616. * from key-value `pairs`.
  7617. *
  7618. * @static
  7619. * @memberOf _
  7620. * @since 4.0.0
  7621. * @category Array
  7622. * @param {Array} pairs The key-value pairs.
  7623. * @returns {Object} Returns the new object.
  7624. * @example
  7625. *
  7626. * _.fromPairs([['a', 1], ['b', 2]]);
  7627. * // => { 'a': 1, 'b': 2 }
  7628. */
  7629. function fromPairs(pairs) {
  7630. var index = -1,
  7631. length = pairs == null ? 0 : pairs.length,
  7632. result = {};
  7633. while (++index < length) {
  7634. var pair = pairs[index];
  7635. result[pair[0]] = pair[1];
  7636. }
  7637. return result;
  7638. }
  7639. /**
  7640. * Gets the first element of `array`.
  7641. *
  7642. * @static
  7643. * @memberOf _
  7644. * @since 0.1.0
  7645. * @alias first
  7646. * @category Array
  7647. * @param {Array} array The array to query.
  7648. * @returns {*} Returns the first element of `array`.
  7649. * @example
  7650. *
  7651. * _.head([1, 2, 3]);
  7652. * // => 1
  7653. *
  7654. * _.head([]);
  7655. * // => undefined
  7656. */
  7657. function head(array) {
  7658. return (array && array.length) ? array[0] : undefined;
  7659. }
  7660. /**
  7661. * Gets the index at which the first occurrence of `value` is found in `array`
  7662. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7663. * for equality comparisons. If `fromIndex` is negative, it's used as the
  7664. * offset from the end of `array`.
  7665. *
  7666. * @static
  7667. * @memberOf _
  7668. * @since 0.1.0
  7669. * @category Array
  7670. * @param {Array} array The array to inspect.
  7671. * @param {*} value The value to search for.
  7672. * @param {number} [fromIndex=0] The index to search from.
  7673. * @returns {number} Returns the index of the matched value, else `-1`.
  7674. * @example
  7675. *
  7676. * _.indexOf([1, 2, 1, 2], 2);
  7677. * // => 1
  7678. *
  7679. * // Search from the `fromIndex`.
  7680. * _.indexOf([1, 2, 1, 2], 2, 2);
  7681. * // => 3
  7682. */
  7683. function indexOf(array, value, fromIndex) {
  7684. var length = array == null ? 0 : array.length;
  7685. if (!length) {
  7686. return -1;
  7687. }
  7688. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  7689. if (index < 0) {
  7690. index = nativeMax(length + index, 0);
  7691. }
  7692. return baseIndexOf(array, value, index);
  7693. }
  7694. /**
  7695. * Gets all but the last element of `array`.
  7696. *
  7697. * @static
  7698. * @memberOf _
  7699. * @since 0.1.0
  7700. * @category Array
  7701. * @param {Array} array The array to query.
  7702. * @returns {Array} Returns the slice of `array`.
  7703. * @example
  7704. *
  7705. * _.initial([1, 2, 3]);
  7706. * // => [1, 2]
  7707. */
  7708. function initial(array) {
  7709. var length = array == null ? 0 : array.length;
  7710. return length ? baseSlice(array, 0, -1) : [];
  7711. }
  7712. /**
  7713. * Creates an array of unique values that are included in all given arrays
  7714. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7715. * for equality comparisons. The order and references of result values are
  7716. * determined by the first array.
  7717. *
  7718. * @static
  7719. * @memberOf _
  7720. * @since 0.1.0
  7721. * @category Array
  7722. * @param {...Array} [arrays] The arrays to inspect.
  7723. * @returns {Array} Returns the new array of intersecting values.
  7724. * @example
  7725. *
  7726. * _.intersection([2, 1], [2, 3]);
  7727. * // => [2]
  7728. */
  7729. var intersection = baseRest(function(arrays) {
  7730. var mapped = arrayMap(arrays, castArrayLikeObject);
  7731. return (mapped.length && mapped[0] === arrays[0])
  7732. ? baseIntersection(mapped)
  7733. : [];
  7734. });
  7735. /**
  7736. * This method is like `_.intersection` except that it accepts `iteratee`
  7737. * which is invoked for each element of each `arrays` to generate the criterion
  7738. * by which they're compared. The order and references of result values are
  7739. * determined by the first array. The iteratee is invoked with one argument:
  7740. * (value).
  7741. *
  7742. * @static
  7743. * @memberOf _
  7744. * @since 4.0.0
  7745. * @category Array
  7746. * @param {...Array} [arrays] The arrays to inspect.
  7747. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7748. * @returns {Array} Returns the new array of intersecting values.
  7749. * @example
  7750. *
  7751. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  7752. * // => [2.1]
  7753. *
  7754. * // The `_.property` iteratee shorthand.
  7755. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  7756. * // => [{ 'x': 1 }]
  7757. */
  7758. var intersectionBy = baseRest(function(arrays) {
  7759. var iteratee = last(arrays),
  7760. mapped = arrayMap(arrays, castArrayLikeObject);
  7761. if (iteratee === last(mapped)) {
  7762. iteratee = undefined;
  7763. } else {
  7764. mapped.pop();
  7765. }
  7766. return (mapped.length && mapped[0] === arrays[0])
  7767. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  7768. : [];
  7769. });
  7770. /**
  7771. * This method is like `_.intersection` except that it accepts `comparator`
  7772. * which is invoked to compare elements of `arrays`. The order and references
  7773. * of result values are determined by the first array. The comparator is
  7774. * invoked with two arguments: (arrVal, othVal).
  7775. *
  7776. * @static
  7777. * @memberOf _
  7778. * @since 4.0.0
  7779. * @category Array
  7780. * @param {...Array} [arrays] The arrays to inspect.
  7781. * @param {Function} [comparator] The comparator invoked per element.
  7782. * @returns {Array} Returns the new array of intersecting values.
  7783. * @example
  7784. *
  7785. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  7786. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  7787. *
  7788. * _.intersectionWith(objects, others, _.isEqual);
  7789. * // => [{ 'x': 1, 'y': 2 }]
  7790. */
  7791. var intersectionWith = baseRest(function(arrays) {
  7792. var comparator = last(arrays),
  7793. mapped = arrayMap(arrays, castArrayLikeObject);
  7794. comparator = typeof comparator == 'function' ? comparator : undefined;
  7795. if (comparator) {
  7796. mapped.pop();
  7797. }
  7798. return (mapped.length && mapped[0] === arrays[0])
  7799. ? baseIntersection(mapped, undefined, comparator)
  7800. : [];
  7801. });
  7802. /**
  7803. * Converts all elements in `array` into a string separated by `separator`.
  7804. *
  7805. * @static
  7806. * @memberOf _
  7807. * @since 4.0.0
  7808. * @category Array
  7809. * @param {Array} array The array to convert.
  7810. * @param {string} [separator=','] The element separator.
  7811. * @returns {string} Returns the joined string.
  7812. * @example
  7813. *
  7814. * _.join(['a', 'b', 'c'], '~');
  7815. * // => 'a~b~c'
  7816. */
  7817. function join(array, separator) {
  7818. return array == null ? '' : nativeJoin.call(array, separator);
  7819. }
  7820. /**
  7821. * Gets the last element of `array`.
  7822. *
  7823. * @static
  7824. * @memberOf _
  7825. * @since 0.1.0
  7826. * @category Array
  7827. * @param {Array} array The array to query.
  7828. * @returns {*} Returns the last element of `array`.
  7829. * @example
  7830. *
  7831. * _.last([1, 2, 3]);
  7832. * // => 3
  7833. */
  7834. function last(array) {
  7835. var length = array == null ? 0 : array.length;
  7836. return length ? array[length - 1] : undefined;
  7837. }
  7838. /**
  7839. * This method is like `_.indexOf` except that it iterates over elements of
  7840. * `array` from right to left.
  7841. *
  7842. * @static
  7843. * @memberOf _
  7844. * @since 0.1.0
  7845. * @category Array
  7846. * @param {Array} array The array to inspect.
  7847. * @param {*} value The value to search for.
  7848. * @param {number} [fromIndex=array.length-1] The index to search from.
  7849. * @returns {number} Returns the index of the matched value, else `-1`.
  7850. * @example
  7851. *
  7852. * _.lastIndexOf([1, 2, 1, 2], 2);
  7853. * // => 3
  7854. *
  7855. * // Search from the `fromIndex`.
  7856. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  7857. * // => 1
  7858. */
  7859. function lastIndexOf(array, value, fromIndex) {
  7860. var length = array == null ? 0 : array.length;
  7861. if (!length) {
  7862. return -1;
  7863. }
  7864. var index = length;
  7865. if (fromIndex !== undefined) {
  7866. index = toInteger(fromIndex);
  7867. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  7868. }
  7869. return value === value
  7870. ? strictLastIndexOf(array, value, index)
  7871. : baseFindIndex(array, baseIsNaN, index, true);
  7872. }
  7873. /**
  7874. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  7875. * element from the end is returned.
  7876. *
  7877. * @static
  7878. * @memberOf _
  7879. * @since 4.11.0
  7880. * @category Array
  7881. * @param {Array} array The array to query.
  7882. * @param {number} [n=0] The index of the element to return.
  7883. * @returns {*} Returns the nth element of `array`.
  7884. * @example
  7885. *
  7886. * var array = ['a', 'b', 'c', 'd'];
  7887. *
  7888. * _.nth(array, 1);
  7889. * // => 'b'
  7890. *
  7891. * _.nth(array, -2);
  7892. * // => 'c';
  7893. */
  7894. function nth(array, n) {
  7895. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  7896. }
  7897. /**
  7898. * Removes all given values from `array` using
  7899. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7900. * for equality comparisons.
  7901. *
  7902. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  7903. * to remove elements from an array by predicate.
  7904. *
  7905. * @static
  7906. * @memberOf _
  7907. * @since 2.0.0
  7908. * @category Array
  7909. * @param {Array} array The array to modify.
  7910. * @param {...*} [values] The values to remove.
  7911. * @returns {Array} Returns `array`.
  7912. * @example
  7913. *
  7914. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  7915. *
  7916. * _.pull(array, 'a', 'c');
  7917. * console.log(array);
  7918. * // => ['b', 'b']
  7919. */
  7920. var pull = baseRest(pullAll);
  7921. /**
  7922. * This method is like `_.pull` except that it accepts an array of values to remove.
  7923. *
  7924. * **Note:** Unlike `_.difference`, this method mutates `array`.
  7925. *
  7926. * @static
  7927. * @memberOf _
  7928. * @since 4.0.0
  7929. * @category Array
  7930. * @param {Array} array The array to modify.
  7931. * @param {Array} values The values to remove.
  7932. * @returns {Array} Returns `array`.
  7933. * @example
  7934. *
  7935. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  7936. *
  7937. * _.pullAll(array, ['a', 'c']);
  7938. * console.log(array);
  7939. * // => ['b', 'b']
  7940. */
  7941. function pullAll(array, values) {
  7942. return (array && array.length && values && values.length)
  7943. ? basePullAll(array, values)
  7944. : array;
  7945. }
  7946. /**
  7947. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  7948. * invoked for each element of `array` and `values` to generate the criterion
  7949. * by which they're compared. The iteratee is invoked with one argument: (value).
  7950. *
  7951. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  7952. *
  7953. * @static
  7954. * @memberOf _
  7955. * @since 4.0.0
  7956. * @category Array
  7957. * @param {Array} array The array to modify.
  7958. * @param {Array} values The values to remove.
  7959. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7960. * @returns {Array} Returns `array`.
  7961. * @example
  7962. *
  7963. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  7964. *
  7965. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  7966. * console.log(array);
  7967. * // => [{ 'x': 2 }]
  7968. */
  7969. function pullAllBy(array, values, iteratee) {
  7970. return (array && array.length && values && values.length)
  7971. ? basePullAll(array, values, getIteratee(iteratee, 2))
  7972. : array;
  7973. }
  7974. /**
  7975. * This method is like `_.pullAll` except that it accepts `comparator` which
  7976. * is invoked to compare elements of `array` to `values`. The comparator is
  7977. * invoked with two arguments: (arrVal, othVal).
  7978. *
  7979. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  7980. *
  7981. * @static
  7982. * @memberOf _
  7983. * @since 4.6.0
  7984. * @category Array
  7985. * @param {Array} array The array to modify.
  7986. * @param {Array} values The values to remove.
  7987. * @param {Function} [comparator] The comparator invoked per element.
  7988. * @returns {Array} Returns `array`.
  7989. * @example
  7990. *
  7991. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  7992. *
  7993. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  7994. * console.log(array);
  7995. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  7996. */
  7997. function pullAllWith(array, values, comparator) {
  7998. return (array && array.length && values && values.length)
  7999. ? basePullAll(array, values, undefined, comparator)
  8000. : array;
  8001. }
  8002. /**
  8003. * Removes elements from `array` corresponding to `indexes` and returns an
  8004. * array of removed elements.
  8005. *
  8006. * **Note:** Unlike `_.at`, this method mutates `array`.
  8007. *
  8008. * @static
  8009. * @memberOf _
  8010. * @since 3.0.0
  8011. * @category Array
  8012. * @param {Array} array The array to modify.
  8013. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  8014. * @returns {Array} Returns the new array of removed elements.
  8015. * @example
  8016. *
  8017. * var array = ['a', 'b', 'c', 'd'];
  8018. * var pulled = _.pullAt(array, [1, 3]);
  8019. *
  8020. * console.log(array);
  8021. * // => ['a', 'c']
  8022. *
  8023. * console.log(pulled);
  8024. * // => ['b', 'd']
  8025. */
  8026. var pullAt = flatRest(function(array, indexes) {
  8027. var length = array == null ? 0 : array.length,
  8028. result = baseAt(array, indexes);
  8029. basePullAt(array, arrayMap(indexes, function(index) {
  8030. return isIndex(index, length) ? +index : index;
  8031. }).sort(compareAscending));
  8032. return result;
  8033. });
  8034. /**
  8035. * Removes all elements from `array` that `predicate` returns truthy for
  8036. * and returns an array of the removed elements. The predicate is invoked
  8037. * with three arguments: (value, index, array).
  8038. *
  8039. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  8040. * to pull elements from an array by value.
  8041. *
  8042. * @static
  8043. * @memberOf _
  8044. * @since 2.0.0
  8045. * @category Array
  8046. * @param {Array} array The array to modify.
  8047. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8048. * @returns {Array} Returns the new array of removed elements.
  8049. * @example
  8050. *
  8051. * var array = [1, 2, 3, 4];
  8052. * var evens = _.remove(array, function(n) {
  8053. * return n % 2 == 0;
  8054. * });
  8055. *
  8056. * console.log(array);
  8057. * // => [1, 3]
  8058. *
  8059. * console.log(evens);
  8060. * // => [2, 4]
  8061. */
  8062. function remove(array, predicate) {
  8063. var result = [];
  8064. if (!(array && array.length)) {
  8065. return result;
  8066. }
  8067. var index = -1,
  8068. indexes = [],
  8069. length = array.length;
  8070. predicate = getIteratee(predicate, 3);
  8071. while (++index < length) {
  8072. var value = array[index];
  8073. if (predicate(value, index, array)) {
  8074. result.push(value);
  8075. indexes.push(index);
  8076. }
  8077. }
  8078. basePullAt(array, indexes);
  8079. return result;
  8080. }
  8081. /**
  8082. * Reverses `array` so that the first element becomes the last, the second
  8083. * element becomes the second to last, and so on.
  8084. *
  8085. * **Note:** This method mutates `array` and is based on
  8086. * [`Array#reverse`](https://mdn.io/Array/reverse).
  8087. *
  8088. * @static
  8089. * @memberOf _
  8090. * @since 4.0.0
  8091. * @category Array
  8092. * @param {Array} array The array to modify.
  8093. * @returns {Array} Returns `array`.
  8094. * @example
  8095. *
  8096. * var array = [1, 2, 3];
  8097. *
  8098. * _.reverse(array);
  8099. * // => [3, 2, 1]
  8100. *
  8101. * console.log(array);
  8102. * // => [3, 2, 1]
  8103. */
  8104. function reverse(array) {
  8105. return array == null ? array : nativeReverse.call(array);
  8106. }
  8107. /**
  8108. * Creates a slice of `array` from `start` up to, but not including, `end`.
  8109. *
  8110. * **Note:** This method is used instead of
  8111. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  8112. * returned.
  8113. *
  8114. * @static
  8115. * @memberOf _
  8116. * @since 3.0.0
  8117. * @category Array
  8118. * @param {Array} array The array to slice.
  8119. * @param {number} [start=0] The start position.
  8120. * @param {number} [end=array.length] The end position.
  8121. * @returns {Array} Returns the slice of `array`.
  8122. */
  8123. function slice(array, start, end) {
  8124. var length = array == null ? 0 : array.length;
  8125. if (!length) {
  8126. return [];
  8127. }
  8128. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  8129. start = 0;
  8130. end = length;
  8131. }
  8132. else {
  8133. start = start == null ? 0 : toInteger(start);
  8134. end = end === undefined ? length : toInteger(end);
  8135. }
  8136. return baseSlice(array, start, end);
  8137. }
  8138. /**
  8139. * Uses a binary search to determine the lowest index at which `value`
  8140. * should be inserted into `array` in order to maintain its sort order.
  8141. *
  8142. * @static
  8143. * @memberOf _
  8144. * @since 0.1.0
  8145. * @category Array
  8146. * @param {Array} array The sorted array to inspect.
  8147. * @param {*} value The value to evaluate.
  8148. * @returns {number} Returns the index at which `value` should be inserted
  8149. * into `array`.
  8150. * @example
  8151. *
  8152. * _.sortedIndex([30, 50], 40);
  8153. * // => 1
  8154. */
  8155. function sortedIndex(array, value) {
  8156. return baseSortedIndex(array, value);
  8157. }
  8158. /**
  8159. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  8160. * which is invoked for `value` and each element of `array` to compute their
  8161. * sort ranking. The iteratee is invoked with one argument: (value).
  8162. *
  8163. * @static
  8164. * @memberOf _
  8165. * @since 4.0.0
  8166. * @category Array
  8167. * @param {Array} array The sorted array to inspect.
  8168. * @param {*} value The value to evaluate.
  8169. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8170. * @returns {number} Returns the index at which `value` should be inserted
  8171. * into `array`.
  8172. * @example
  8173. *
  8174. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8175. *
  8176. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8177. * // => 0
  8178. *
  8179. * // The `_.property` iteratee shorthand.
  8180. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  8181. * // => 0
  8182. */
  8183. function sortedIndexBy(array, value, iteratee) {
  8184. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  8185. }
  8186. /**
  8187. * This method is like `_.indexOf` except that it performs a binary
  8188. * search on a sorted `array`.
  8189. *
  8190. * @static
  8191. * @memberOf _
  8192. * @since 4.0.0
  8193. * @category Array
  8194. * @param {Array} array The array to inspect.
  8195. * @param {*} value The value to search for.
  8196. * @returns {number} Returns the index of the matched value, else `-1`.
  8197. * @example
  8198. *
  8199. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  8200. * // => 1
  8201. */
  8202. function sortedIndexOf(array, value) {
  8203. var length = array == null ? 0 : array.length;
  8204. if (length) {
  8205. var index = baseSortedIndex(array, value);
  8206. if (index < length && eq(array[index], value)) {
  8207. return index;
  8208. }
  8209. }
  8210. return -1;
  8211. }
  8212. /**
  8213. * This method is like `_.sortedIndex` except that it returns the highest
  8214. * index at which `value` should be inserted into `array` in order to
  8215. * maintain its sort order.
  8216. *
  8217. * @static
  8218. * @memberOf _
  8219. * @since 3.0.0
  8220. * @category Array
  8221. * @param {Array} array The sorted array to inspect.
  8222. * @param {*} value The value to evaluate.
  8223. * @returns {number} Returns the index at which `value` should be inserted
  8224. * into `array`.
  8225. * @example
  8226. *
  8227. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  8228. * // => 4
  8229. */
  8230. function sortedLastIndex(array, value) {
  8231. return baseSortedIndex(array, value, true);
  8232. }
  8233. /**
  8234. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  8235. * which is invoked for `value` and each element of `array` to compute their
  8236. * sort ranking. The iteratee is invoked with one argument: (value).
  8237. *
  8238. * @static
  8239. * @memberOf _
  8240. * @since 4.0.0
  8241. * @category Array
  8242. * @param {Array} array The sorted array to inspect.
  8243. * @param {*} value The value to evaluate.
  8244. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8245. * @returns {number} Returns the index at which `value` should be inserted
  8246. * into `array`.
  8247. * @example
  8248. *
  8249. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8250. *
  8251. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8252. * // => 1
  8253. *
  8254. * // The `_.property` iteratee shorthand.
  8255. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  8256. * // => 1
  8257. */
  8258. function sortedLastIndexBy(array, value, iteratee) {
  8259. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  8260. }
  8261. /**
  8262. * This method is like `_.lastIndexOf` except that it performs a binary
  8263. * search on a sorted `array`.
  8264. *
  8265. * @static
  8266. * @memberOf _
  8267. * @since 4.0.0
  8268. * @category Array
  8269. * @param {Array} array The array to inspect.
  8270. * @param {*} value The value to search for.
  8271. * @returns {number} Returns the index of the matched value, else `-1`.
  8272. * @example
  8273. *
  8274. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  8275. * // => 3
  8276. */
  8277. function sortedLastIndexOf(array, value) {
  8278. var length = array == null ? 0 : array.length;
  8279. if (length) {
  8280. var index = baseSortedIndex(array, value, true) - 1;
  8281. if (eq(array[index], value)) {
  8282. return index;
  8283. }
  8284. }
  8285. return -1;
  8286. }
  8287. /**
  8288. * This method is like `_.uniq` except that it's designed and optimized
  8289. * for sorted arrays.
  8290. *
  8291. * @static
  8292. * @memberOf _
  8293. * @since 4.0.0
  8294. * @category Array
  8295. * @param {Array} array The array to inspect.
  8296. * @returns {Array} Returns the new duplicate free array.
  8297. * @example
  8298. *
  8299. * _.sortedUniq([1, 1, 2]);
  8300. * // => [1, 2]
  8301. */
  8302. function sortedUniq(array) {
  8303. return (array && array.length)
  8304. ? baseSortedUniq(array)
  8305. : [];
  8306. }
  8307. /**
  8308. * This method is like `_.uniqBy` except that it's designed and optimized
  8309. * for sorted arrays.
  8310. *
  8311. * @static
  8312. * @memberOf _
  8313. * @since 4.0.0
  8314. * @category Array
  8315. * @param {Array} array The array to inspect.
  8316. * @param {Function} [iteratee] The iteratee invoked per element.
  8317. * @returns {Array} Returns the new duplicate free array.
  8318. * @example
  8319. *
  8320. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  8321. * // => [1.1, 2.3]
  8322. */
  8323. function sortedUniqBy(array, iteratee) {
  8324. return (array && array.length)
  8325. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  8326. : [];
  8327. }
  8328. /**
  8329. * Gets all but the first element of `array`.
  8330. *
  8331. * @static
  8332. * @memberOf _
  8333. * @since 4.0.0
  8334. * @category Array
  8335. * @param {Array} array The array to query.
  8336. * @returns {Array} Returns the slice of `array`.
  8337. * @example
  8338. *
  8339. * _.tail([1, 2, 3]);
  8340. * // => [2, 3]
  8341. */
  8342. function tail(array) {
  8343. var length = array == null ? 0 : array.length;
  8344. return length ? baseSlice(array, 1, length) : [];
  8345. }
  8346. /**
  8347. * Creates a slice of `array` with `n` elements taken from the beginning.
  8348. *
  8349. * @static
  8350. * @memberOf _
  8351. * @since 0.1.0
  8352. * @category Array
  8353. * @param {Array} array The array to query.
  8354. * @param {number} [n=1] The number of elements to take.
  8355. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8356. * @returns {Array} Returns the slice of `array`.
  8357. * @example
  8358. *
  8359. * _.take([1, 2, 3]);
  8360. * // => [1]
  8361. *
  8362. * _.take([1, 2, 3], 2);
  8363. * // => [1, 2]
  8364. *
  8365. * _.take([1, 2, 3], 5);
  8366. * // => [1, 2, 3]
  8367. *
  8368. * _.take([1, 2, 3], 0);
  8369. * // => []
  8370. */
  8371. function take(array, n, guard) {
  8372. if (!(array && array.length)) {
  8373. return [];
  8374. }
  8375. n = (guard || n === undefined) ? 1 : toInteger(n);
  8376. return baseSlice(array, 0, n < 0 ? 0 : n);
  8377. }
  8378. /**
  8379. * Creates a slice of `array` with `n` elements taken from the end.
  8380. *
  8381. * @static
  8382. * @memberOf _
  8383. * @since 3.0.0
  8384. * @category Array
  8385. * @param {Array} array The array to query.
  8386. * @param {number} [n=1] The number of elements to take.
  8387. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8388. * @returns {Array} Returns the slice of `array`.
  8389. * @example
  8390. *
  8391. * _.takeRight([1, 2, 3]);
  8392. * // => [3]
  8393. *
  8394. * _.takeRight([1, 2, 3], 2);
  8395. * // => [2, 3]
  8396. *
  8397. * _.takeRight([1, 2, 3], 5);
  8398. * // => [1, 2, 3]
  8399. *
  8400. * _.takeRight([1, 2, 3], 0);
  8401. * // => []
  8402. */
  8403. function takeRight(array, n, guard) {
  8404. var length = array == null ? 0 : array.length;
  8405. if (!length) {
  8406. return [];
  8407. }
  8408. n = (guard || n === undefined) ? 1 : toInteger(n);
  8409. n = length - n;
  8410. return baseSlice(array, n < 0 ? 0 : n, length);
  8411. }
  8412. /**
  8413. * Creates a slice of `array` with elements taken from the end. Elements are
  8414. * taken until `predicate` returns falsey. The predicate is invoked with
  8415. * three arguments: (value, index, array).
  8416. *
  8417. * @static
  8418. * @memberOf _
  8419. * @since 3.0.0
  8420. * @category Array
  8421. * @param {Array} array The array to query.
  8422. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8423. * @returns {Array} Returns the slice of `array`.
  8424. * @example
  8425. *
  8426. * var users = [
  8427. * { 'user': 'barney', 'active': true },
  8428. * { 'user': 'fred', 'active': false },
  8429. * { 'user': 'pebbles', 'active': false }
  8430. * ];
  8431. *
  8432. * _.takeRightWhile(users, function(o) { return !o.active; });
  8433. * // => objects for ['fred', 'pebbles']
  8434. *
  8435. * // The `_.matches` iteratee shorthand.
  8436. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  8437. * // => objects for ['pebbles']
  8438. *
  8439. * // The `_.matchesProperty` iteratee shorthand.
  8440. * _.takeRightWhile(users, ['active', false]);
  8441. * // => objects for ['fred', 'pebbles']
  8442. *
  8443. * // The `_.property` iteratee shorthand.
  8444. * _.takeRightWhile(users, 'active');
  8445. * // => []
  8446. */
  8447. function takeRightWhile(array, predicate) {
  8448. return (array && array.length)
  8449. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  8450. : [];
  8451. }
  8452. /**
  8453. * Creates a slice of `array` with elements taken from the beginning. Elements
  8454. * are taken until `predicate` returns falsey. The predicate is invoked with
  8455. * three arguments: (value, index, array).
  8456. *
  8457. * @static
  8458. * @memberOf _
  8459. * @since 3.0.0
  8460. * @category Array
  8461. * @param {Array} array The array to query.
  8462. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8463. * @returns {Array} Returns the slice of `array`.
  8464. * @example
  8465. *
  8466. * var users = [
  8467. * { 'user': 'barney', 'active': false },
  8468. * { 'user': 'fred', 'active': false },
  8469. * { 'user': 'pebbles', 'active': true }
  8470. * ];
  8471. *
  8472. * _.takeWhile(users, function(o) { return !o.active; });
  8473. * // => objects for ['barney', 'fred']
  8474. *
  8475. * // The `_.matches` iteratee shorthand.
  8476. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  8477. * // => objects for ['barney']
  8478. *
  8479. * // The `_.matchesProperty` iteratee shorthand.
  8480. * _.takeWhile(users, ['active', false]);
  8481. * // => objects for ['barney', 'fred']
  8482. *
  8483. * // The `_.property` iteratee shorthand.
  8484. * _.takeWhile(users, 'active');
  8485. * // => []
  8486. */
  8487. function takeWhile(array, predicate) {
  8488. return (array && array.length)
  8489. ? baseWhile(array, getIteratee(predicate, 3))
  8490. : [];
  8491. }
  8492. /**
  8493. * Creates an array of unique values, in order, from all given arrays using
  8494. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8495. * for equality comparisons.
  8496. *
  8497. * @static
  8498. * @memberOf _
  8499. * @since 0.1.0
  8500. * @category Array
  8501. * @param {...Array} [arrays] The arrays to inspect.
  8502. * @returns {Array} Returns the new array of combined values.
  8503. * @example
  8504. *
  8505. * _.union([2], [1, 2]);
  8506. * // => [2, 1]
  8507. */
  8508. var union = baseRest(function(arrays) {
  8509. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  8510. });
  8511. /**
  8512. * This method is like `_.union` except that it accepts `iteratee` which is
  8513. * invoked for each element of each `arrays` to generate the criterion by
  8514. * which uniqueness is computed. Result values are chosen from the first
  8515. * array in which the value occurs. The iteratee is invoked with one argument:
  8516. * (value).
  8517. *
  8518. * @static
  8519. * @memberOf _
  8520. * @since 4.0.0
  8521. * @category Array
  8522. * @param {...Array} [arrays] The arrays to inspect.
  8523. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8524. * @returns {Array} Returns the new array of combined values.
  8525. * @example
  8526. *
  8527. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  8528. * // => [2.1, 1.2]
  8529. *
  8530. * // The `_.property` iteratee shorthand.
  8531. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8532. * // => [{ 'x': 1 }, { 'x': 2 }]
  8533. */
  8534. var unionBy = baseRest(function(arrays) {
  8535. var iteratee = last(arrays);
  8536. if (isArrayLikeObject(iteratee)) {
  8537. iteratee = undefined;
  8538. }
  8539. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  8540. });
  8541. /**
  8542. * This method is like `_.union` except that it accepts `comparator` which
  8543. * is invoked to compare elements of `arrays`. Result values are chosen from
  8544. * the first array in which the value occurs. The comparator is invoked
  8545. * with two arguments: (arrVal, othVal).
  8546. *
  8547. * @static
  8548. * @memberOf _
  8549. * @since 4.0.0
  8550. * @category Array
  8551. * @param {...Array} [arrays] The arrays to inspect.
  8552. * @param {Function} [comparator] The comparator invoked per element.
  8553. * @returns {Array} Returns the new array of combined values.
  8554. * @example
  8555. *
  8556. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8557. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8558. *
  8559. * _.unionWith(objects, others, _.isEqual);
  8560. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  8561. */
  8562. var unionWith = baseRest(function(arrays) {
  8563. var comparator = last(arrays);
  8564. comparator = typeof comparator == 'function' ? comparator : undefined;
  8565. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  8566. });
  8567. /**
  8568. * Creates a duplicate-free version of an array, using
  8569. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8570. * for equality comparisons, in which only the first occurrence of each element
  8571. * is kept. The order of result values is determined by the order they occur
  8572. * in the array.
  8573. *
  8574. * @static
  8575. * @memberOf _
  8576. * @since 0.1.0
  8577. * @category Array
  8578. * @param {Array} array The array to inspect.
  8579. * @returns {Array} Returns the new duplicate free array.
  8580. * @example
  8581. *
  8582. * _.uniq([2, 1, 2]);
  8583. * // => [2, 1]
  8584. */
  8585. function uniq(array) {
  8586. return (array && array.length) ? baseUniq(array) : [];
  8587. }
  8588. /**
  8589. * This method is like `_.uniq` except that it accepts `iteratee` which is
  8590. * invoked for each element in `array` to generate the criterion by which
  8591. * uniqueness is computed. The order of result values is determined by the
  8592. * order they occur in the array. The iteratee is invoked with one argument:
  8593. * (value).
  8594. *
  8595. * @static
  8596. * @memberOf _
  8597. * @since 4.0.0
  8598. * @category Array
  8599. * @param {Array} array The array to inspect.
  8600. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8601. * @returns {Array} Returns the new duplicate free array.
  8602. * @example
  8603. *
  8604. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  8605. * // => [2.1, 1.2]
  8606. *
  8607. * // The `_.property` iteratee shorthand.
  8608. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  8609. * // => [{ 'x': 1 }, { 'x': 2 }]
  8610. */
  8611. function uniqBy(array, iteratee) {
  8612. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  8613. }
  8614. /**
  8615. * This method is like `_.uniq` except that it accepts `comparator` which
  8616. * is invoked to compare elements of `array`. The order of result values is
  8617. * determined by the order they occur in the array.The comparator is invoked
  8618. * with two arguments: (arrVal, othVal).
  8619. *
  8620. * @static
  8621. * @memberOf _
  8622. * @since 4.0.0
  8623. * @category Array
  8624. * @param {Array} array The array to inspect.
  8625. * @param {Function} [comparator] The comparator invoked per element.
  8626. * @returns {Array} Returns the new duplicate free array.
  8627. * @example
  8628. *
  8629. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8630. *
  8631. * _.uniqWith(objects, _.isEqual);
  8632. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  8633. */
  8634. function uniqWith(array, comparator) {
  8635. comparator = typeof comparator == 'function' ? comparator : undefined;
  8636. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  8637. }
  8638. /**
  8639. * This method is like `_.zip` except that it accepts an array of grouped
  8640. * elements and creates an array regrouping the elements to their pre-zip
  8641. * configuration.
  8642. *
  8643. * @static
  8644. * @memberOf _
  8645. * @since 1.2.0
  8646. * @category Array
  8647. * @param {Array} array The array of grouped elements to process.
  8648. * @returns {Array} Returns the new array of regrouped elements.
  8649. * @example
  8650. *
  8651. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  8652. * // => [['a', 1, true], ['b', 2, false]]
  8653. *
  8654. * _.unzip(zipped);
  8655. * // => [['a', 'b'], [1, 2], [true, false]]
  8656. */
  8657. function unzip(array) {
  8658. if (!(array && array.length)) {
  8659. return [];
  8660. }
  8661. var length = 0;
  8662. array = arrayFilter(array, function(group) {
  8663. if (isArrayLikeObject(group)) {
  8664. length = nativeMax(group.length, length);
  8665. return true;
  8666. }
  8667. });
  8668. return baseTimes(length, function(index) {
  8669. return arrayMap(array, baseProperty(index));
  8670. });
  8671. }
  8672. /**
  8673. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  8674. * how regrouped values should be combined. The iteratee is invoked with the
  8675. * elements of each group: (...group).
  8676. *
  8677. * @static
  8678. * @memberOf _
  8679. * @since 3.8.0
  8680. * @category Array
  8681. * @param {Array} array The array of grouped elements to process.
  8682. * @param {Function} [iteratee=_.identity] The function to combine
  8683. * regrouped values.
  8684. * @returns {Array} Returns the new array of regrouped elements.
  8685. * @example
  8686. *
  8687. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  8688. * // => [[1, 10, 100], [2, 20, 200]]
  8689. *
  8690. * _.unzipWith(zipped, _.add);
  8691. * // => [3, 30, 300]
  8692. */
  8693. function unzipWith(array, iteratee) {
  8694. if (!(array && array.length)) {
  8695. return [];
  8696. }
  8697. var result = unzip(array);
  8698. if (iteratee == null) {
  8699. return result;
  8700. }
  8701. return arrayMap(result, function(group) {
  8702. return apply(iteratee, undefined, group);
  8703. });
  8704. }
  8705. /**
  8706. * Creates an array excluding all given values using
  8707. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8708. * for equality comparisons.
  8709. *
  8710. * **Note:** Unlike `_.pull`, this method returns a new array.
  8711. *
  8712. * @static
  8713. * @memberOf _
  8714. * @since 0.1.0
  8715. * @category Array
  8716. * @param {Array} array The array to inspect.
  8717. * @param {...*} [values] The values to exclude.
  8718. * @returns {Array} Returns the new array of filtered values.
  8719. * @see _.difference, _.xor
  8720. * @example
  8721. *
  8722. * _.without([2, 1, 2, 3], 1, 2);
  8723. * // => [3]
  8724. */
  8725. var without = baseRest(function(array, values) {
  8726. return isArrayLikeObject(array)
  8727. ? baseDifference(array, values)
  8728. : [];
  8729. });
  8730. /**
  8731. * Creates an array of unique values that is the
  8732. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  8733. * of the given arrays. The order of result values is determined by the order
  8734. * they occur in the arrays.
  8735. *
  8736. * @static
  8737. * @memberOf _
  8738. * @since 2.4.0
  8739. * @category Array
  8740. * @param {...Array} [arrays] The arrays to inspect.
  8741. * @returns {Array} Returns the new array of filtered values.
  8742. * @see _.difference, _.without
  8743. * @example
  8744. *
  8745. * _.xor([2, 1], [2, 3]);
  8746. * // => [1, 3]
  8747. */
  8748. var xor = baseRest(function(arrays) {
  8749. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  8750. });
  8751. /**
  8752. * This method is like `_.xor` except that it accepts `iteratee` which is
  8753. * invoked for each element of each `arrays` to generate the criterion by
  8754. * which by which they're compared. The order of result values is determined
  8755. * by the order they occur in the arrays. The iteratee is invoked with one
  8756. * argument: (value).
  8757. *
  8758. * @static
  8759. * @memberOf _
  8760. * @since 4.0.0
  8761. * @category Array
  8762. * @param {...Array} [arrays] The arrays to inspect.
  8763. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8764. * @returns {Array} Returns the new array of filtered values.
  8765. * @example
  8766. *
  8767. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8768. * // => [1.2, 3.4]
  8769. *
  8770. * // The `_.property` iteratee shorthand.
  8771. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8772. * // => [{ 'x': 2 }]
  8773. */
  8774. var xorBy = baseRest(function(arrays) {
  8775. var iteratee = last(arrays);
  8776. if (isArrayLikeObject(iteratee)) {
  8777. iteratee = undefined;
  8778. }
  8779. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  8780. });
  8781. /**
  8782. * This method is like `_.xor` except that it accepts `comparator` which is
  8783. * invoked to compare elements of `arrays`. The order of result values is
  8784. * determined by the order they occur in the arrays. The comparator is invoked
  8785. * with two arguments: (arrVal, othVal).
  8786. *
  8787. * @static
  8788. * @memberOf _
  8789. * @since 4.0.0
  8790. * @category Array
  8791. * @param {...Array} [arrays] The arrays to inspect.
  8792. * @param {Function} [comparator] The comparator invoked per element.
  8793. * @returns {Array} Returns the new array of filtered values.
  8794. * @example
  8795. *
  8796. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8797. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8798. *
  8799. * _.xorWith(objects, others, _.isEqual);
  8800. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  8801. */
  8802. var xorWith = baseRest(function(arrays) {
  8803. var comparator = last(arrays);
  8804. comparator = typeof comparator == 'function' ? comparator : undefined;
  8805. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  8806. });
  8807. /**
  8808. * Creates an array of grouped elements, the first of which contains the
  8809. * first elements of the given arrays, the second of which contains the
  8810. * second elements of the given arrays, and so on.
  8811. *
  8812. * @static
  8813. * @memberOf _
  8814. * @since 0.1.0
  8815. * @category Array
  8816. * @param {...Array} [arrays] The arrays to process.
  8817. * @returns {Array} Returns the new array of grouped elements.
  8818. * @example
  8819. *
  8820. * _.zip(['a', 'b'], [1, 2], [true, false]);
  8821. * // => [['a', 1, true], ['b', 2, false]]
  8822. */
  8823. var zip = baseRest(unzip);
  8824. /**
  8825. * This method is like `_.fromPairs` except that it accepts two arrays,
  8826. * one of property identifiers and one of corresponding values.
  8827. *
  8828. * @static
  8829. * @memberOf _
  8830. * @since 0.4.0
  8831. * @category Array
  8832. * @param {Array} [props=[]] The property identifiers.
  8833. * @param {Array} [values=[]] The property values.
  8834. * @returns {Object} Returns the new object.
  8835. * @example
  8836. *
  8837. * _.zipObject(['a', 'b'], [1, 2]);
  8838. * // => { 'a': 1, 'b': 2 }
  8839. */
  8840. function zipObject(props, values) {
  8841. return baseZipObject(props || [], values || [], assignValue);
  8842. }
  8843. /**
  8844. * This method is like `_.zipObject` except that it supports property paths.
  8845. *
  8846. * @static
  8847. * @memberOf _
  8848. * @since 4.1.0
  8849. * @category Array
  8850. * @param {Array} [props=[]] The property identifiers.
  8851. * @param {Array} [values=[]] The property values.
  8852. * @returns {Object} Returns the new object.
  8853. * @example
  8854. *
  8855. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  8856. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  8857. */
  8858. function zipObjectDeep(props, values) {
  8859. return baseZipObject(props || [], values || [], baseSet);
  8860. }
  8861. /**
  8862. * This method is like `_.zip` except that it accepts `iteratee` to specify
  8863. * how grouped values should be combined. The iteratee is invoked with the
  8864. * elements of each group: (...group).
  8865. *
  8866. * @static
  8867. * @memberOf _
  8868. * @since 3.8.0
  8869. * @category Array
  8870. * @param {...Array} [arrays] The arrays to process.
  8871. * @param {Function} [iteratee=_.identity] The function to combine
  8872. * grouped values.
  8873. * @returns {Array} Returns the new array of grouped elements.
  8874. * @example
  8875. *
  8876. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  8877. * return a + b + c;
  8878. * });
  8879. * // => [111, 222]
  8880. */
  8881. var zipWith = baseRest(function(arrays) {
  8882. var length = arrays.length,
  8883. iteratee = length > 1 ? arrays[length - 1] : undefined;
  8884. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  8885. return unzipWith(arrays, iteratee);
  8886. });
  8887. /*------------------------------------------------------------------------*/
  8888. /**
  8889. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  8890. * chain sequences enabled. The result of such sequences must be unwrapped
  8891. * with `_#value`.
  8892. *
  8893. * @static
  8894. * @memberOf _
  8895. * @since 1.3.0
  8896. * @category Seq
  8897. * @param {*} value The value to wrap.
  8898. * @returns {Object} Returns the new `lodash` wrapper instance.
  8899. * @example
  8900. *
  8901. * var users = [
  8902. * { 'user': 'barney', 'age': 36 },
  8903. * { 'user': 'fred', 'age': 40 },
  8904. * { 'user': 'pebbles', 'age': 1 }
  8905. * ];
  8906. *
  8907. * var youngest = _
  8908. * .chain(users)
  8909. * .sortBy('age')
  8910. * .map(function(o) {
  8911. * return o.user + ' is ' + o.age;
  8912. * })
  8913. * .head()
  8914. * .value();
  8915. * // => 'pebbles is 1'
  8916. */
  8917. function chain(value) {
  8918. var result = lodash(value);
  8919. result.__chain__ = true;
  8920. return result;
  8921. }
  8922. /**
  8923. * This method invokes `interceptor` and returns `value`. The interceptor
  8924. * is invoked with one argument; (value). The purpose of this method is to
  8925. * "tap into" a method chain sequence in order to modify intermediate results.
  8926. *
  8927. * @static
  8928. * @memberOf _
  8929. * @since 0.1.0
  8930. * @category Seq
  8931. * @param {*} value The value to provide to `interceptor`.
  8932. * @param {Function} interceptor The function to invoke.
  8933. * @returns {*} Returns `value`.
  8934. * @example
  8935. *
  8936. * _([1, 2, 3])
  8937. * .tap(function(array) {
  8938. * // Mutate input array.
  8939. * array.pop();
  8940. * })
  8941. * .reverse()
  8942. * .value();
  8943. * // => [2, 1]
  8944. */
  8945. function tap(value, interceptor) {
  8946. interceptor(value);
  8947. return value;
  8948. }
  8949. /**
  8950. * This method is like `_.tap` except that it returns the result of `interceptor`.
  8951. * The purpose of this method is to "pass thru" values replacing intermediate
  8952. * results in a method chain sequence.
  8953. *
  8954. * @static
  8955. * @memberOf _
  8956. * @since 3.0.0
  8957. * @category Seq
  8958. * @param {*} value The value to provide to `interceptor`.
  8959. * @param {Function} interceptor The function to invoke.
  8960. * @returns {*} Returns the result of `interceptor`.
  8961. * @example
  8962. *
  8963. * _(' abc ')
  8964. * .chain()
  8965. * .trim()
  8966. * .thru(function(value) {
  8967. * return [value];
  8968. * })
  8969. * .value();
  8970. * // => ['abc']
  8971. */
  8972. function thru(value, interceptor) {
  8973. return interceptor(value);
  8974. }
  8975. /**
  8976. * This method is the wrapper version of `_.at`.
  8977. *
  8978. * @name at
  8979. * @memberOf _
  8980. * @since 1.0.0
  8981. * @category Seq
  8982. * @param {...(string|string[])} [paths] The property paths to pick.
  8983. * @returns {Object} Returns the new `lodash` wrapper instance.
  8984. * @example
  8985. *
  8986. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  8987. *
  8988. * _(object).at(['a[0].b.c', 'a[1]']).value();
  8989. * // => [3, 4]
  8990. */
  8991. var wrapperAt = flatRest(function(paths) {
  8992. var length = paths.length,
  8993. start = length ? paths[0] : 0,
  8994. value = this.__wrapped__,
  8995. interceptor = function(object) { return baseAt(object, paths); };
  8996. if (length > 1 || this.__actions__.length ||
  8997. !(value instanceof LazyWrapper) || !isIndex(start)) {
  8998. return this.thru(interceptor);
  8999. }
  9000. value = value.slice(start, +start + (length ? 1 : 0));
  9001. value.__actions__.push({
  9002. 'func': thru,
  9003. 'args': [interceptor],
  9004. 'thisArg': undefined
  9005. });
  9006. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  9007. if (length && !array.length) {
  9008. array.push(undefined);
  9009. }
  9010. return array;
  9011. });
  9012. });
  9013. /**
  9014. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  9015. *
  9016. * @name chain
  9017. * @memberOf _
  9018. * @since 0.1.0
  9019. * @category Seq
  9020. * @returns {Object} Returns the new `lodash` wrapper instance.
  9021. * @example
  9022. *
  9023. * var users = [
  9024. * { 'user': 'barney', 'age': 36 },
  9025. * { 'user': 'fred', 'age': 40 }
  9026. * ];
  9027. *
  9028. * // A sequence without explicit chaining.
  9029. * _(users).head();
  9030. * // => { 'user': 'barney', 'age': 36 }
  9031. *
  9032. * // A sequence with explicit chaining.
  9033. * _(users)
  9034. * .chain()
  9035. * .head()
  9036. * .pick('user')
  9037. * .value();
  9038. * // => { 'user': 'barney' }
  9039. */
  9040. function wrapperChain() {
  9041. return chain(this);
  9042. }
  9043. /**
  9044. * Executes the chain sequence and returns the wrapped result.
  9045. *
  9046. * @name commit
  9047. * @memberOf _
  9048. * @since 3.2.0
  9049. * @category Seq
  9050. * @returns {Object} Returns the new `lodash` wrapper instance.
  9051. * @example
  9052. *
  9053. * var array = [1, 2];
  9054. * var wrapped = _(array).push(3);
  9055. *
  9056. * console.log(array);
  9057. * // => [1, 2]
  9058. *
  9059. * wrapped = wrapped.commit();
  9060. * console.log(array);
  9061. * // => [1, 2, 3]
  9062. *
  9063. * wrapped.last();
  9064. * // => 3
  9065. *
  9066. * console.log(array);
  9067. * // => [1, 2, 3]
  9068. */
  9069. function wrapperCommit() {
  9070. return new LodashWrapper(this.value(), this.__chain__);
  9071. }
  9072. /**
  9073. * Gets the next value on a wrapped object following the
  9074. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  9075. *
  9076. * @name next
  9077. * @memberOf _
  9078. * @since 4.0.0
  9079. * @category Seq
  9080. * @returns {Object} Returns the next iterator value.
  9081. * @example
  9082. *
  9083. * var wrapped = _([1, 2]);
  9084. *
  9085. * wrapped.next();
  9086. * // => { 'done': false, 'value': 1 }
  9087. *
  9088. * wrapped.next();
  9089. * // => { 'done': false, 'value': 2 }
  9090. *
  9091. * wrapped.next();
  9092. * // => { 'done': true, 'value': undefined }
  9093. */
  9094. function wrapperNext() {
  9095. if (this.__values__ === undefined) {
  9096. this.__values__ = toArray(this.value());
  9097. }
  9098. var done = this.__index__ >= this.__values__.length,
  9099. value = done ? undefined : this.__values__[this.__index__++];
  9100. return { 'done': done, 'value': value };
  9101. }
  9102. /**
  9103. * Enables the wrapper to be iterable.
  9104. *
  9105. * @name Symbol.iterator
  9106. * @memberOf _
  9107. * @since 4.0.0
  9108. * @category Seq
  9109. * @returns {Object} Returns the wrapper object.
  9110. * @example
  9111. *
  9112. * var wrapped = _([1, 2]);
  9113. *
  9114. * wrapped[Symbol.iterator]() === wrapped;
  9115. * // => true
  9116. *
  9117. * Array.from(wrapped);
  9118. * // => [1, 2]
  9119. */
  9120. function wrapperToIterator() {
  9121. return this;
  9122. }
  9123. /**
  9124. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  9125. *
  9126. * @name plant
  9127. * @memberOf _
  9128. * @since 3.2.0
  9129. * @category Seq
  9130. * @param {*} value The value to plant.
  9131. * @returns {Object} Returns the new `lodash` wrapper instance.
  9132. * @example
  9133. *
  9134. * function square(n) {
  9135. * return n * n;
  9136. * }
  9137. *
  9138. * var wrapped = _([1, 2]).map(square);
  9139. * var other = wrapped.plant([3, 4]);
  9140. *
  9141. * other.value();
  9142. * // => [9, 16]
  9143. *
  9144. * wrapped.value();
  9145. * // => [1, 4]
  9146. */
  9147. function wrapperPlant(value) {
  9148. var result,
  9149. parent = this;
  9150. while (parent instanceof baseLodash) {
  9151. var clone = wrapperClone(parent);
  9152. clone.__index__ = 0;
  9153. clone.__values__ = undefined;
  9154. if (result) {
  9155. previous.__wrapped__ = clone;
  9156. } else {
  9157. result = clone;
  9158. }
  9159. var previous = clone;
  9160. parent = parent.__wrapped__;
  9161. }
  9162. previous.__wrapped__ = value;
  9163. return result;
  9164. }
  9165. /**
  9166. * This method is the wrapper version of `_.reverse`.
  9167. *
  9168. * **Note:** This method mutates the wrapped array.
  9169. *
  9170. * @name reverse
  9171. * @memberOf _
  9172. * @since 0.1.0
  9173. * @category Seq
  9174. * @returns {Object} Returns the new `lodash` wrapper instance.
  9175. * @example
  9176. *
  9177. * var array = [1, 2, 3];
  9178. *
  9179. * _(array).reverse().value()
  9180. * // => [3, 2, 1]
  9181. *
  9182. * console.log(array);
  9183. * // => [3, 2, 1]
  9184. */
  9185. function wrapperReverse() {
  9186. var value = this.__wrapped__;
  9187. if (value instanceof LazyWrapper) {
  9188. var wrapped = value;
  9189. if (this.__actions__.length) {
  9190. wrapped = new LazyWrapper(this);
  9191. }
  9192. wrapped = wrapped.reverse();
  9193. wrapped.__actions__.push({
  9194. 'func': thru,
  9195. 'args': [reverse],
  9196. 'thisArg': undefined
  9197. });
  9198. return new LodashWrapper(wrapped, this.__chain__);
  9199. }
  9200. return this.thru(reverse);
  9201. }
  9202. /**
  9203. * Executes the chain sequence to resolve the unwrapped value.
  9204. *
  9205. * @name value
  9206. * @memberOf _
  9207. * @since 0.1.0
  9208. * @alias toJSON, valueOf
  9209. * @category Seq
  9210. * @returns {*} Returns the resolved unwrapped value.
  9211. * @example
  9212. *
  9213. * _([1, 2, 3]).value();
  9214. * // => [1, 2, 3]
  9215. */
  9216. function wrapperValue() {
  9217. return baseWrapperValue(this.__wrapped__, this.__actions__);
  9218. }
  9219. /*------------------------------------------------------------------------*/
  9220. /**
  9221. * Creates an object composed of keys generated from the results of running
  9222. * each element of `collection` thru `iteratee`. The corresponding value of
  9223. * each key is the number of times the key was returned by `iteratee`. The
  9224. * iteratee is invoked with one argument: (value).
  9225. *
  9226. * @static
  9227. * @memberOf _
  9228. * @since 0.5.0
  9229. * @category Collection
  9230. * @param {Array|Object} collection The collection to iterate over.
  9231. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9232. * @returns {Object} Returns the composed aggregate object.
  9233. * @example
  9234. *
  9235. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  9236. * // => { '4': 1, '6': 2 }
  9237. *
  9238. * // The `_.property` iteratee shorthand.
  9239. * _.countBy(['one', 'two', 'three'], 'length');
  9240. * // => { '3': 2, '5': 1 }
  9241. */
  9242. var countBy = createAggregator(function(result, value, key) {
  9243. if (hasOwnProperty.call(result, key)) {
  9244. ++result[key];
  9245. } else {
  9246. baseAssignValue(result, key, 1);
  9247. }
  9248. });
  9249. /**
  9250. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  9251. * Iteration is stopped once `predicate` returns falsey. The predicate is
  9252. * invoked with three arguments: (value, index|key, collection).
  9253. *
  9254. * **Note:** This method returns `true` for
  9255. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  9256. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  9257. * elements of empty collections.
  9258. *
  9259. * @static
  9260. * @memberOf _
  9261. * @since 0.1.0
  9262. * @category Collection
  9263. * @param {Array|Object} collection The collection to iterate over.
  9264. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9265. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9266. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  9267. * else `false`.
  9268. * @example
  9269. *
  9270. * _.every([true, 1, null, 'yes'], Boolean);
  9271. * // => false
  9272. *
  9273. * var users = [
  9274. * { 'user': 'barney', 'age': 36, 'active': false },
  9275. * { 'user': 'fred', 'age': 40, 'active': false }
  9276. * ];
  9277. *
  9278. * // The `_.matches` iteratee shorthand.
  9279. * _.every(users, { 'user': 'barney', 'active': false });
  9280. * // => false
  9281. *
  9282. * // The `_.matchesProperty` iteratee shorthand.
  9283. * _.every(users, ['active', false]);
  9284. * // => true
  9285. *
  9286. * // The `_.property` iteratee shorthand.
  9287. * _.every(users, 'active');
  9288. * // => false
  9289. */
  9290. function every(collection, predicate, guard) {
  9291. var func = isArray(collection) ? arrayEvery : baseEvery;
  9292. if (guard && isIterateeCall(collection, predicate, guard)) {
  9293. predicate = undefined;
  9294. }
  9295. return func(collection, getIteratee(predicate, 3));
  9296. }
  9297. /**
  9298. * Iterates over elements of `collection`, returning an array of all elements
  9299. * `predicate` returns truthy for. The predicate is invoked with three
  9300. * arguments: (value, index|key, collection).
  9301. *
  9302. * **Note:** Unlike `_.remove`, this method returns a new array.
  9303. *
  9304. * @static
  9305. * @memberOf _
  9306. * @since 0.1.0
  9307. * @category Collection
  9308. * @param {Array|Object} collection The collection to iterate over.
  9309. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9310. * @returns {Array} Returns the new filtered array.
  9311. * @see _.reject
  9312. * @example
  9313. *
  9314. * var users = [
  9315. * { 'user': 'barney', 'age': 36, 'active': true },
  9316. * { 'user': 'fred', 'age': 40, 'active': false }
  9317. * ];
  9318. *
  9319. * _.filter(users, function(o) { return !o.active; });
  9320. * // => objects for ['fred']
  9321. *
  9322. * // The `_.matches` iteratee shorthand.
  9323. * _.filter(users, { 'age': 36, 'active': true });
  9324. * // => objects for ['barney']
  9325. *
  9326. * // The `_.matchesProperty` iteratee shorthand.
  9327. * _.filter(users, ['active', false]);
  9328. * // => objects for ['fred']
  9329. *
  9330. * // The `_.property` iteratee shorthand.
  9331. * _.filter(users, 'active');
  9332. * // => objects for ['barney']
  9333. */
  9334. function filter(collection, predicate) {
  9335. var func = isArray(collection) ? arrayFilter : baseFilter;
  9336. return func(collection, getIteratee(predicate, 3));
  9337. }
  9338. /**
  9339. * Iterates over elements of `collection`, returning the first element
  9340. * `predicate` returns truthy for. The predicate is invoked with three
  9341. * arguments: (value, index|key, collection).
  9342. *
  9343. * @static
  9344. * @memberOf _
  9345. * @since 0.1.0
  9346. * @category Collection
  9347. * @param {Array|Object} collection The collection to inspect.
  9348. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9349. * @param {number} [fromIndex=0] The index to search from.
  9350. * @returns {*} Returns the matched element, else `undefined`.
  9351. * @example
  9352. *
  9353. * var users = [
  9354. * { 'user': 'barney', 'age': 36, 'active': true },
  9355. * { 'user': 'fred', 'age': 40, 'active': false },
  9356. * { 'user': 'pebbles', 'age': 1, 'active': true }
  9357. * ];
  9358. *
  9359. * _.find(users, function(o) { return o.age < 40; });
  9360. * // => object for 'barney'
  9361. *
  9362. * // The `_.matches` iteratee shorthand.
  9363. * _.find(users, { 'age': 1, 'active': true });
  9364. * // => object for 'pebbles'
  9365. *
  9366. * // The `_.matchesProperty` iteratee shorthand.
  9367. * _.find(users, ['active', false]);
  9368. * // => object for 'fred'
  9369. *
  9370. * // The `_.property` iteratee shorthand.
  9371. * _.find(users, 'active');
  9372. * // => object for 'barney'
  9373. */
  9374. var find = createFind(findIndex);
  9375. /**
  9376. * This method is like `_.find` except that it iterates over elements of
  9377. * `collection` from right to left.
  9378. *
  9379. * @static
  9380. * @memberOf _
  9381. * @since 2.0.0
  9382. * @category Collection
  9383. * @param {Array|Object} collection The collection to inspect.
  9384. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9385. * @param {number} [fromIndex=collection.length-1] The index to search from.
  9386. * @returns {*} Returns the matched element, else `undefined`.
  9387. * @example
  9388. *
  9389. * _.findLast([1, 2, 3, 4], function(n) {
  9390. * return n % 2 == 1;
  9391. * });
  9392. * // => 3
  9393. */
  9394. var findLast = createFind(findLastIndex);
  9395. /**
  9396. * Creates a flattened array of values by running each element in `collection`
  9397. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  9398. * with three arguments: (value, index|key, collection).
  9399. *
  9400. * @static
  9401. * @memberOf _
  9402. * @since 4.0.0
  9403. * @category Collection
  9404. * @param {Array|Object} collection The collection to iterate over.
  9405. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9406. * @returns {Array} Returns the new flattened array.
  9407. * @example
  9408. *
  9409. * function duplicate(n) {
  9410. * return [n, n];
  9411. * }
  9412. *
  9413. * _.flatMap([1, 2], duplicate);
  9414. * // => [1, 1, 2, 2]
  9415. */
  9416. function flatMap(collection, iteratee) {
  9417. return baseFlatten(map(collection, iteratee), 1);
  9418. }
  9419. /**
  9420. * This method is like `_.flatMap` except that it recursively flattens the
  9421. * mapped results.
  9422. *
  9423. * @static
  9424. * @memberOf _
  9425. * @since 4.7.0
  9426. * @category Collection
  9427. * @param {Array|Object} collection The collection to iterate over.
  9428. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9429. * @returns {Array} Returns the new flattened array.
  9430. * @example
  9431. *
  9432. * function duplicate(n) {
  9433. * return [[[n, n]]];
  9434. * }
  9435. *
  9436. * _.flatMapDeep([1, 2], duplicate);
  9437. * // => [1, 1, 2, 2]
  9438. */
  9439. function flatMapDeep(collection, iteratee) {
  9440. return baseFlatten(map(collection, iteratee), INFINITY);
  9441. }
  9442. /**
  9443. * This method is like `_.flatMap` except that it recursively flattens the
  9444. * mapped results up to `depth` times.
  9445. *
  9446. * @static
  9447. * @memberOf _
  9448. * @since 4.7.0
  9449. * @category Collection
  9450. * @param {Array|Object} collection The collection to iterate over.
  9451. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9452. * @param {number} [depth=1] The maximum recursion depth.
  9453. * @returns {Array} Returns the new flattened array.
  9454. * @example
  9455. *
  9456. * function duplicate(n) {
  9457. * return [[[n, n]]];
  9458. * }
  9459. *
  9460. * _.flatMapDepth([1, 2], duplicate, 2);
  9461. * // => [[1, 1], [2, 2]]
  9462. */
  9463. function flatMapDepth(collection, iteratee, depth) {
  9464. depth = depth === undefined ? 1 : toInteger(depth);
  9465. return baseFlatten(map(collection, iteratee), depth);
  9466. }
  9467. /**
  9468. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  9469. * The iteratee is invoked with three arguments: (value, index|key, collection).
  9470. * Iteratee functions may exit iteration early by explicitly returning `false`.
  9471. *
  9472. * **Note:** As with other "Collections" methods, objects with a "length"
  9473. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  9474. * or `_.forOwn` for object iteration.
  9475. *
  9476. * @static
  9477. * @memberOf _
  9478. * @since 0.1.0
  9479. * @alias each
  9480. * @category Collection
  9481. * @param {Array|Object} collection The collection to iterate over.
  9482. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9483. * @returns {Array|Object} Returns `collection`.
  9484. * @see _.forEachRight
  9485. * @example
  9486. *
  9487. * _.forEach([1, 2], function(value) {
  9488. * console.log(value);
  9489. * });
  9490. * // => Logs `1` then `2`.
  9491. *
  9492. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  9493. * console.log(key);
  9494. * });
  9495. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  9496. */
  9497. function forEach(collection, iteratee) {
  9498. var func = isArray(collection) ? arrayEach : baseEach;
  9499. return func(collection, getIteratee(iteratee, 3));
  9500. }
  9501. /**
  9502. * This method is like `_.forEach` except that it iterates over elements of
  9503. * `collection` from right to left.
  9504. *
  9505. * @static
  9506. * @memberOf _
  9507. * @since 2.0.0
  9508. * @alias eachRight
  9509. * @category Collection
  9510. * @param {Array|Object} collection The collection to iterate over.
  9511. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9512. * @returns {Array|Object} Returns `collection`.
  9513. * @see _.forEach
  9514. * @example
  9515. *
  9516. * _.forEachRight([1, 2], function(value) {
  9517. * console.log(value);
  9518. * });
  9519. * // => Logs `2` then `1`.
  9520. */
  9521. function forEachRight(collection, iteratee) {
  9522. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  9523. return func(collection, getIteratee(iteratee, 3));
  9524. }
  9525. /**
  9526. * Creates an object composed of keys generated from the results of running
  9527. * each element of `collection` thru `iteratee`. The order of grouped values
  9528. * is determined by the order they occur in `collection`. The corresponding
  9529. * value of each key is an array of elements responsible for generating the
  9530. * key. The iteratee is invoked with one argument: (value).
  9531. *
  9532. * @static
  9533. * @memberOf _
  9534. * @since 0.1.0
  9535. * @category Collection
  9536. * @param {Array|Object} collection The collection to iterate over.
  9537. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9538. * @returns {Object} Returns the composed aggregate object.
  9539. * @example
  9540. *
  9541. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  9542. * // => { '4': [4.2], '6': [6.1, 6.3] }
  9543. *
  9544. * // The `_.property` iteratee shorthand.
  9545. * _.groupBy(['one', 'two', 'three'], 'length');
  9546. * // => { '3': ['one', 'two'], '5': ['three'] }
  9547. */
  9548. var groupBy = createAggregator(function(result, value, key) {
  9549. if (hasOwnProperty.call(result, key)) {
  9550. result[key].push(value);
  9551. } else {
  9552. baseAssignValue(result, key, [value]);
  9553. }
  9554. });
  9555. /**
  9556. * Checks if `value` is in `collection`. If `collection` is a string, it's
  9557. * checked for a substring of `value`, otherwise
  9558. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9559. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  9560. * the offset from the end of `collection`.
  9561. *
  9562. * @static
  9563. * @memberOf _
  9564. * @since 0.1.0
  9565. * @category Collection
  9566. * @param {Array|Object|string} collection The collection to inspect.
  9567. * @param {*} value The value to search for.
  9568. * @param {number} [fromIndex=0] The index to search from.
  9569. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  9570. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  9571. * @example
  9572. *
  9573. * _.includes([1, 2, 3], 1);
  9574. * // => true
  9575. *
  9576. * _.includes([1, 2, 3], 1, 2);
  9577. * // => false
  9578. *
  9579. * _.includes({ 'a': 1, 'b': 2 }, 1);
  9580. * // => true
  9581. *
  9582. * _.includes('abcd', 'bc');
  9583. * // => true
  9584. */
  9585. function includes(collection, value, fromIndex, guard) {
  9586. collection = isArrayLike(collection) ? collection : values(collection);
  9587. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  9588. var length = collection.length;
  9589. if (fromIndex < 0) {
  9590. fromIndex = nativeMax(length + fromIndex, 0);
  9591. }
  9592. return isString(collection)
  9593. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  9594. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  9595. }
  9596. /**
  9597. * Invokes the method at `path` of each element in `collection`, returning
  9598. * an array of the results of each invoked method. Any additional arguments
  9599. * are provided to each invoked method. If `path` is a function, it's invoked
  9600. * for, and `this` bound to, each element in `collection`.
  9601. *
  9602. * @static
  9603. * @memberOf _
  9604. * @since 4.0.0
  9605. * @category Collection
  9606. * @param {Array|Object} collection The collection to iterate over.
  9607. * @param {Array|Function|string} path The path of the method to invoke or
  9608. * the function invoked per iteration.
  9609. * @param {...*} [args] The arguments to invoke each method with.
  9610. * @returns {Array} Returns the array of results.
  9611. * @example
  9612. *
  9613. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  9614. * // => [[1, 5, 7], [1, 2, 3]]
  9615. *
  9616. * _.invokeMap([123, 456], String.prototype.split, '');
  9617. * // => [['1', '2', '3'], ['4', '5', '6']]
  9618. */
  9619. var invokeMap = baseRest(function(collection, path, args) {
  9620. var index = -1,
  9621. isFunc = typeof path == 'function',
  9622. result = isArrayLike(collection) ? Array(collection.length) : [];
  9623. baseEach(collection, function(value) {
  9624. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  9625. });
  9626. return result;
  9627. });
  9628. /**
  9629. * Creates an object composed of keys generated from the results of running
  9630. * each element of `collection` thru `iteratee`. The corresponding value of
  9631. * each key is the last element responsible for generating the key. The
  9632. * iteratee is invoked with one argument: (value).
  9633. *
  9634. * @static
  9635. * @memberOf _
  9636. * @since 4.0.0
  9637. * @category Collection
  9638. * @param {Array|Object} collection The collection to iterate over.
  9639. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9640. * @returns {Object} Returns the composed aggregate object.
  9641. * @example
  9642. *
  9643. * var array = [
  9644. * { 'dir': 'left', 'code': 97 },
  9645. * { 'dir': 'right', 'code': 100 }
  9646. * ];
  9647. *
  9648. * _.keyBy(array, function(o) {
  9649. * return String.fromCharCode(o.code);
  9650. * });
  9651. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  9652. *
  9653. * _.keyBy(array, 'dir');
  9654. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  9655. */
  9656. var keyBy = createAggregator(function(result, value, key) {
  9657. baseAssignValue(result, key, value);
  9658. });
  9659. /**
  9660. * Creates an array of values by running each element in `collection` thru
  9661. * `iteratee`. The iteratee is invoked with three arguments:
  9662. * (value, index|key, collection).
  9663. *
  9664. * Many lodash methods are guarded to work as iteratees for methods like
  9665. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  9666. *
  9667. * The guarded methods are:
  9668. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  9669. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  9670. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  9671. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  9672. *
  9673. * @static
  9674. * @memberOf _
  9675. * @since 0.1.0
  9676. * @category Collection
  9677. * @param {Array|Object} collection The collection to iterate over.
  9678. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9679. * @returns {Array} Returns the new mapped array.
  9680. * @example
  9681. *
  9682. * function square(n) {
  9683. * return n * n;
  9684. * }
  9685. *
  9686. * _.map([4, 8], square);
  9687. * // => [16, 64]
  9688. *
  9689. * _.map({ 'a': 4, 'b': 8 }, square);
  9690. * // => [16, 64] (iteration order is not guaranteed)
  9691. *
  9692. * var users = [
  9693. * { 'user': 'barney' },
  9694. * { 'user': 'fred' }
  9695. * ];
  9696. *
  9697. * // The `_.property` iteratee shorthand.
  9698. * _.map(users, 'user');
  9699. * // => ['barney', 'fred']
  9700. */
  9701. function map(collection, iteratee) {
  9702. var func = isArray(collection) ? arrayMap : baseMap;
  9703. return func(collection, getIteratee(iteratee, 3));
  9704. }
  9705. /**
  9706. * This method is like `_.sortBy` except that it allows specifying the sort
  9707. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  9708. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  9709. * descending or "asc" for ascending sort order of corresponding values.
  9710. *
  9711. * @static
  9712. * @memberOf _
  9713. * @since 4.0.0
  9714. * @category Collection
  9715. * @param {Array|Object} collection The collection to iterate over.
  9716. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  9717. * The iteratees to sort by.
  9718. * @param {string[]} [orders] The sort orders of `iteratees`.
  9719. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  9720. * @returns {Array} Returns the new sorted array.
  9721. * @example
  9722. *
  9723. * var users = [
  9724. * { 'user': 'fred', 'age': 48 },
  9725. * { 'user': 'barney', 'age': 34 },
  9726. * { 'user': 'fred', 'age': 40 },
  9727. * { 'user': 'barney', 'age': 36 }
  9728. * ];
  9729. *
  9730. * // Sort by `user` in ascending order and by `age` in descending order.
  9731. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  9732. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  9733. */
  9734. function orderBy(collection, iteratees, orders, guard) {
  9735. if (collection == null) {
  9736. return [];
  9737. }
  9738. if (!isArray(iteratees)) {
  9739. iteratees = iteratees == null ? [] : [iteratees];
  9740. }
  9741. orders = guard ? undefined : orders;
  9742. if (!isArray(orders)) {
  9743. orders = orders == null ? [] : [orders];
  9744. }
  9745. return baseOrderBy(collection, iteratees, orders);
  9746. }
  9747. /**
  9748. * Creates an array of elements split into two groups, the first of which
  9749. * contains elements `predicate` returns truthy for, the second of which
  9750. * contains elements `predicate` returns falsey for. The predicate is
  9751. * invoked with one argument: (value).
  9752. *
  9753. * @static
  9754. * @memberOf _
  9755. * @since 3.0.0
  9756. * @category Collection
  9757. * @param {Array|Object} collection The collection to iterate over.
  9758. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9759. * @returns {Array} Returns the array of grouped elements.
  9760. * @example
  9761. *
  9762. * var users = [
  9763. * { 'user': 'barney', 'age': 36, 'active': false },
  9764. * { 'user': 'fred', 'age': 40, 'active': true },
  9765. * { 'user': 'pebbles', 'age': 1, 'active': false }
  9766. * ];
  9767. *
  9768. * _.partition(users, function(o) { return o.active; });
  9769. * // => objects for [['fred'], ['barney', 'pebbles']]
  9770. *
  9771. * // The `_.matches` iteratee shorthand.
  9772. * _.partition(users, { 'age': 1, 'active': false });
  9773. * // => objects for [['pebbles'], ['barney', 'fred']]
  9774. *
  9775. * // The `_.matchesProperty` iteratee shorthand.
  9776. * _.partition(users, ['active', false]);
  9777. * // => objects for [['barney', 'pebbles'], ['fred']]
  9778. *
  9779. * // The `_.property` iteratee shorthand.
  9780. * _.partition(users, 'active');
  9781. * // => objects for [['fred'], ['barney', 'pebbles']]
  9782. */
  9783. var partition = createAggregator(function(result, value, key) {
  9784. result[key ? 0 : 1].push(value);
  9785. }, function() { return [[], []]; });
  9786. /**
  9787. * Reduces `collection` to a value which is the accumulated result of running
  9788. * each element in `collection` thru `iteratee`, where each successive
  9789. * invocation is supplied the return value of the previous. If `accumulator`
  9790. * is not given, the first element of `collection` is used as the initial
  9791. * value. The iteratee is invoked with four arguments:
  9792. * (accumulator, value, index|key, collection).
  9793. *
  9794. * Many lodash methods are guarded to work as iteratees for methods like
  9795. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  9796. *
  9797. * The guarded methods are:
  9798. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  9799. * and `sortBy`
  9800. *
  9801. * @static
  9802. * @memberOf _
  9803. * @since 0.1.0
  9804. * @category Collection
  9805. * @param {Array|Object} collection The collection to iterate over.
  9806. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9807. * @param {*} [accumulator] The initial value.
  9808. * @returns {*} Returns the accumulated value.
  9809. * @see _.reduceRight
  9810. * @example
  9811. *
  9812. * _.reduce([1, 2], function(sum, n) {
  9813. * return sum + n;
  9814. * }, 0);
  9815. * // => 3
  9816. *
  9817. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  9818. * (result[value] || (result[value] = [])).push(key);
  9819. * return result;
  9820. * }, {});
  9821. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  9822. */
  9823. function reduce(collection, iteratee, accumulator) {
  9824. var func = isArray(collection) ? arrayReduce : baseReduce,
  9825. initAccum = arguments.length < 3;
  9826. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  9827. }
  9828. /**
  9829. * This method is like `_.reduce` except that it iterates over elements of
  9830. * `collection` from right to left.
  9831. *
  9832. * @static
  9833. * @memberOf _
  9834. * @since 0.1.0
  9835. * @category Collection
  9836. * @param {Array|Object} collection The collection to iterate over.
  9837. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9838. * @param {*} [accumulator] The initial value.
  9839. * @returns {*} Returns the accumulated value.
  9840. * @see _.reduce
  9841. * @example
  9842. *
  9843. * var array = [[0, 1], [2, 3], [4, 5]];
  9844. *
  9845. * _.reduceRight(array, function(flattened, other) {
  9846. * return flattened.concat(other);
  9847. * }, []);
  9848. * // => [4, 5, 2, 3, 0, 1]
  9849. */
  9850. function reduceRight(collection, iteratee, accumulator) {
  9851. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  9852. initAccum = arguments.length < 3;
  9853. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  9854. }
  9855. /**
  9856. * The opposite of `_.filter`; this method returns the elements of `collection`
  9857. * that `predicate` does **not** return truthy for.
  9858. *
  9859. * @static
  9860. * @memberOf _
  9861. * @since 0.1.0
  9862. * @category Collection
  9863. * @param {Array|Object} collection The collection to iterate over.
  9864. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9865. * @returns {Array} Returns the new filtered array.
  9866. * @see _.filter
  9867. * @example
  9868. *
  9869. * var users = [
  9870. * { 'user': 'barney', 'age': 36, 'active': false },
  9871. * { 'user': 'fred', 'age': 40, 'active': true }
  9872. * ];
  9873. *
  9874. * _.reject(users, function(o) { return !o.active; });
  9875. * // => objects for ['fred']
  9876. *
  9877. * // The `_.matches` iteratee shorthand.
  9878. * _.reject(users, { 'age': 40, 'active': true });
  9879. * // => objects for ['barney']
  9880. *
  9881. * // The `_.matchesProperty` iteratee shorthand.
  9882. * _.reject(users, ['active', false]);
  9883. * // => objects for ['fred']
  9884. *
  9885. * // The `_.property` iteratee shorthand.
  9886. * _.reject(users, 'active');
  9887. * // => objects for ['barney']
  9888. */
  9889. function reject(collection, predicate) {
  9890. var func = isArray(collection) ? arrayFilter : baseFilter;
  9891. return func(collection, negate(getIteratee(predicate, 3)));
  9892. }
  9893. /**
  9894. * Gets a random element from `collection`.
  9895. *
  9896. * @static
  9897. * @memberOf _
  9898. * @since 2.0.0
  9899. * @category Collection
  9900. * @param {Array|Object} collection The collection to sample.
  9901. * @returns {*} Returns the random element.
  9902. * @example
  9903. *
  9904. * _.sample([1, 2, 3, 4]);
  9905. * // => 2
  9906. */
  9907. function sample(collection) {
  9908. var func = isArray(collection) ? arraySample : baseSample;
  9909. return func(collection);
  9910. }
  9911. /**
  9912. * Gets `n` random elements at unique keys from `collection` up to the
  9913. * size of `collection`.
  9914. *
  9915. * @static
  9916. * @memberOf _
  9917. * @since 4.0.0
  9918. * @category Collection
  9919. * @param {Array|Object} collection The collection to sample.
  9920. * @param {number} [n=1] The number of elements to sample.
  9921. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9922. * @returns {Array} Returns the random elements.
  9923. * @example
  9924. *
  9925. * _.sampleSize([1, 2, 3], 2);
  9926. * // => [3, 1]
  9927. *
  9928. * _.sampleSize([1, 2, 3], 4);
  9929. * // => [2, 3, 1]
  9930. */
  9931. function sampleSize(collection, n, guard) {
  9932. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  9933. n = 1;
  9934. } else {
  9935. n = toInteger(n);
  9936. }
  9937. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  9938. return func(collection, n);
  9939. }
  9940. /**
  9941. * Creates an array of shuffled values, using a version of the
  9942. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  9943. *
  9944. * @static
  9945. * @memberOf _
  9946. * @since 0.1.0
  9947. * @category Collection
  9948. * @param {Array|Object} collection The collection to shuffle.
  9949. * @returns {Array} Returns the new shuffled array.
  9950. * @example
  9951. *
  9952. * _.shuffle([1, 2, 3, 4]);
  9953. * // => [4, 1, 3, 2]
  9954. */
  9955. function shuffle(collection) {
  9956. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  9957. return func(collection);
  9958. }
  9959. /**
  9960. * Gets the size of `collection` by returning its length for array-like
  9961. * values or the number of own enumerable string keyed properties for objects.
  9962. *
  9963. * @static
  9964. * @memberOf _
  9965. * @since 0.1.0
  9966. * @category Collection
  9967. * @param {Array|Object|string} collection The collection to inspect.
  9968. * @returns {number} Returns the collection size.
  9969. * @example
  9970. *
  9971. * _.size([1, 2, 3]);
  9972. * // => 3
  9973. *
  9974. * _.size({ 'a': 1, 'b': 2 });
  9975. * // => 2
  9976. *
  9977. * _.size('pebbles');
  9978. * // => 7
  9979. */
  9980. function size(collection) {
  9981. if (collection == null) {
  9982. return 0;
  9983. }
  9984. if (isArrayLike(collection)) {
  9985. return isString(collection) ? stringSize(collection) : collection.length;
  9986. }
  9987. var tag = getTag(collection);
  9988. if (tag == mapTag || tag == setTag) {
  9989. return collection.size;
  9990. }
  9991. return baseKeys(collection).length;
  9992. }
  9993. /**
  9994. * Checks if `predicate` returns truthy for **any** element of `collection`.
  9995. * Iteration is stopped once `predicate` returns truthy. The predicate is
  9996. * invoked with three arguments: (value, index|key, collection).
  9997. *
  9998. * @static
  9999. * @memberOf _
  10000. * @since 0.1.0
  10001. * @category Collection
  10002. * @param {Array|Object} collection The collection to iterate over.
  10003. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10004. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10005. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10006. * else `false`.
  10007. * @example
  10008. *
  10009. * _.some([null, 0, 'yes', false], Boolean);
  10010. * // => true
  10011. *
  10012. * var users = [
  10013. * { 'user': 'barney', 'active': true },
  10014. * { 'user': 'fred', 'active': false }
  10015. * ];
  10016. *
  10017. * // The `_.matches` iteratee shorthand.
  10018. * _.some(users, { 'user': 'barney', 'active': false });
  10019. * // => false
  10020. *
  10021. * // The `_.matchesProperty` iteratee shorthand.
  10022. * _.some(users, ['active', false]);
  10023. * // => true
  10024. *
  10025. * // The `_.property` iteratee shorthand.
  10026. * _.some(users, 'active');
  10027. * // => true
  10028. */
  10029. function some(collection, predicate, guard) {
  10030. var func = isArray(collection) ? arraySome : baseSome;
  10031. if (guard && isIterateeCall(collection, predicate, guard)) {
  10032. predicate = undefined;
  10033. }
  10034. return func(collection, getIteratee(predicate, 3));
  10035. }
  10036. /**
  10037. * Creates an array of elements, sorted in ascending order by the results of
  10038. * running each element in a collection thru each iteratee. This method
  10039. * performs a stable sort, that is, it preserves the original sort order of
  10040. * equal elements. The iteratees are invoked with one argument: (value).
  10041. *
  10042. * @static
  10043. * @memberOf _
  10044. * @since 0.1.0
  10045. * @category Collection
  10046. * @param {Array|Object} collection The collection to iterate over.
  10047. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  10048. * The iteratees to sort by.
  10049. * @returns {Array} Returns the new sorted array.
  10050. * @example
  10051. *
  10052. * var users = [
  10053. * { 'user': 'fred', 'age': 48 },
  10054. * { 'user': 'barney', 'age': 36 },
  10055. * { 'user': 'fred', 'age': 40 },
  10056. * { 'user': 'barney', 'age': 34 }
  10057. * ];
  10058. *
  10059. * _.sortBy(users, [function(o) { return o.user; }]);
  10060. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  10061. *
  10062. * _.sortBy(users, ['user', 'age']);
  10063. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  10064. */
  10065. var sortBy = baseRest(function(collection, iteratees) {
  10066. if (collection == null) {
  10067. return [];
  10068. }
  10069. var length = iteratees.length;
  10070. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  10071. iteratees = [];
  10072. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  10073. iteratees = [iteratees[0]];
  10074. }
  10075. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  10076. });
  10077. /*------------------------------------------------------------------------*/
  10078. /**
  10079. * Gets the timestamp of the number of milliseconds that have elapsed since
  10080. * the Unix epoch (1 January 1970 00:00:00 UTC).
  10081. *
  10082. * @static
  10083. * @memberOf _
  10084. * @since 2.4.0
  10085. * @category Date
  10086. * @returns {number} Returns the timestamp.
  10087. * @example
  10088. *
  10089. * _.defer(function(stamp) {
  10090. * console.log(_.now() - stamp);
  10091. * }, _.now());
  10092. * // => Logs the number of milliseconds it took for the deferred invocation.
  10093. */
  10094. var now = ctxNow || function() {
  10095. return root.Date.now();
  10096. };
  10097. /*------------------------------------------------------------------------*/
  10098. /**
  10099. * The opposite of `_.before`; this method creates a function that invokes
  10100. * `func` once it's called `n` or more times.
  10101. *
  10102. * @static
  10103. * @memberOf _
  10104. * @since 0.1.0
  10105. * @category Function
  10106. * @param {number} n The number of calls before `func` is invoked.
  10107. * @param {Function} func The function to restrict.
  10108. * @returns {Function} Returns the new restricted function.
  10109. * @example
  10110. *
  10111. * var saves = ['profile', 'settings'];
  10112. *
  10113. * var done = _.after(saves.length, function() {
  10114. * console.log('done saving!');
  10115. * });
  10116. *
  10117. * _.forEach(saves, function(type) {
  10118. * asyncSave({ 'type': type, 'complete': done });
  10119. * });
  10120. * // => Logs 'done saving!' after the two async saves have completed.
  10121. */
  10122. function after(n, func) {
  10123. if (typeof func != 'function') {
  10124. throw new TypeError(FUNC_ERROR_TEXT);
  10125. }
  10126. n = toInteger(n);
  10127. return function() {
  10128. if (--n < 1) {
  10129. return func.apply(this, arguments);
  10130. }
  10131. };
  10132. }
  10133. /**
  10134. * Creates a function that invokes `func`, with up to `n` arguments,
  10135. * ignoring any additional arguments.
  10136. *
  10137. * @static
  10138. * @memberOf _
  10139. * @since 3.0.0
  10140. * @category Function
  10141. * @param {Function} func The function to cap arguments for.
  10142. * @param {number} [n=func.length] The arity cap.
  10143. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10144. * @returns {Function} Returns the new capped function.
  10145. * @example
  10146. *
  10147. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  10148. * // => [6, 8, 10]
  10149. */
  10150. function ary(func, n, guard) {
  10151. n = guard ? undefined : n;
  10152. n = (func && n == null) ? func.length : n;
  10153. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  10154. }
  10155. /**
  10156. * Creates a function that invokes `func`, with the `this` binding and arguments
  10157. * of the created function, while it's called less than `n` times. Subsequent
  10158. * calls to the created function return the result of the last `func` invocation.
  10159. *
  10160. * @static
  10161. * @memberOf _
  10162. * @since 3.0.0
  10163. * @category Function
  10164. * @param {number} n The number of calls at which `func` is no longer invoked.
  10165. * @param {Function} func The function to restrict.
  10166. * @returns {Function} Returns the new restricted function.
  10167. * @example
  10168. *
  10169. * jQuery(element).on('click', _.before(5, addContactToList));
  10170. * // => Allows adding up to 4 contacts to the list.
  10171. */
  10172. function before(n, func) {
  10173. var result;
  10174. if (typeof func != 'function') {
  10175. throw new TypeError(FUNC_ERROR_TEXT);
  10176. }
  10177. n = toInteger(n);
  10178. return function() {
  10179. if (--n > 0) {
  10180. result = func.apply(this, arguments);
  10181. }
  10182. if (n <= 1) {
  10183. func = undefined;
  10184. }
  10185. return result;
  10186. };
  10187. }
  10188. /**
  10189. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  10190. * and `partials` prepended to the arguments it receives.
  10191. *
  10192. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  10193. * may be used as a placeholder for partially applied arguments.
  10194. *
  10195. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  10196. * property of bound functions.
  10197. *
  10198. * @static
  10199. * @memberOf _
  10200. * @since 0.1.0
  10201. * @category Function
  10202. * @param {Function} func The function to bind.
  10203. * @param {*} thisArg The `this` binding of `func`.
  10204. * @param {...*} [partials] The arguments to be partially applied.
  10205. * @returns {Function} Returns the new bound function.
  10206. * @example
  10207. *
  10208. * function greet(greeting, punctuation) {
  10209. * return greeting + ' ' + this.user + punctuation;
  10210. * }
  10211. *
  10212. * var object = { 'user': 'fred' };
  10213. *
  10214. * var bound = _.bind(greet, object, 'hi');
  10215. * bound('!');
  10216. * // => 'hi fred!'
  10217. *
  10218. * // Bound with placeholders.
  10219. * var bound = _.bind(greet, object, _, '!');
  10220. * bound('hi');
  10221. * // => 'hi fred!'
  10222. */
  10223. var bind = baseRest(function(func, thisArg, partials) {
  10224. var bitmask = WRAP_BIND_FLAG;
  10225. if (partials.length) {
  10226. var holders = replaceHolders(partials, getHolder(bind));
  10227. bitmask |= WRAP_PARTIAL_FLAG;
  10228. }
  10229. return createWrap(func, bitmask, thisArg, partials, holders);
  10230. });
  10231. /**
  10232. * Creates a function that invokes the method at `object[key]` with `partials`
  10233. * prepended to the arguments it receives.
  10234. *
  10235. * This method differs from `_.bind` by allowing bound functions to reference
  10236. * methods that may be redefined or don't yet exist. See
  10237. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  10238. * for more details.
  10239. *
  10240. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  10241. * builds, may be used as a placeholder for partially applied arguments.
  10242. *
  10243. * @static
  10244. * @memberOf _
  10245. * @since 0.10.0
  10246. * @category Function
  10247. * @param {Object} object The object to invoke the method on.
  10248. * @param {string} key The key of the method.
  10249. * @param {...*} [partials] The arguments to be partially applied.
  10250. * @returns {Function} Returns the new bound function.
  10251. * @example
  10252. *
  10253. * var object = {
  10254. * 'user': 'fred',
  10255. * 'greet': function(greeting, punctuation) {
  10256. * return greeting + ' ' + this.user + punctuation;
  10257. * }
  10258. * };
  10259. *
  10260. * var bound = _.bindKey(object, 'greet', 'hi');
  10261. * bound('!');
  10262. * // => 'hi fred!'
  10263. *
  10264. * object.greet = function(greeting, punctuation) {
  10265. * return greeting + 'ya ' + this.user + punctuation;
  10266. * };
  10267. *
  10268. * bound('!');
  10269. * // => 'hiya fred!'
  10270. *
  10271. * // Bound with placeholders.
  10272. * var bound = _.bindKey(object, 'greet', _, '!');
  10273. * bound('hi');
  10274. * // => 'hiya fred!'
  10275. */
  10276. var bindKey = baseRest(function(object, key, partials) {
  10277. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  10278. if (partials.length) {
  10279. var holders = replaceHolders(partials, getHolder(bindKey));
  10280. bitmask |= WRAP_PARTIAL_FLAG;
  10281. }
  10282. return createWrap(key, bitmask, object, partials, holders);
  10283. });
  10284. /**
  10285. * Creates a function that accepts arguments of `func` and either invokes
  10286. * `func` returning its result, if at least `arity` number of arguments have
  10287. * been provided, or returns a function that accepts the remaining `func`
  10288. * arguments, and so on. The arity of `func` may be specified if `func.length`
  10289. * is not sufficient.
  10290. *
  10291. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  10292. * may be used as a placeholder for provided arguments.
  10293. *
  10294. * **Note:** This method doesn't set the "length" property of curried functions.
  10295. *
  10296. * @static
  10297. * @memberOf _
  10298. * @since 2.0.0
  10299. * @category Function
  10300. * @param {Function} func The function to curry.
  10301. * @param {number} [arity=func.length] The arity of `func`.
  10302. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10303. * @returns {Function} Returns the new curried function.
  10304. * @example
  10305. *
  10306. * var abc = function(a, b, c) {
  10307. * return [a, b, c];
  10308. * };
  10309. *
  10310. * var curried = _.curry(abc);
  10311. *
  10312. * curried(1)(2)(3);
  10313. * // => [1, 2, 3]
  10314. *
  10315. * curried(1, 2)(3);
  10316. * // => [1, 2, 3]
  10317. *
  10318. * curried(1, 2, 3);
  10319. * // => [1, 2, 3]
  10320. *
  10321. * // Curried with placeholders.
  10322. * curried(1)(_, 3)(2);
  10323. * // => [1, 2, 3]
  10324. */
  10325. function curry(func, arity, guard) {
  10326. arity = guard ? undefined : arity;
  10327. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  10328. result.placeholder = curry.placeholder;
  10329. return result;
  10330. }
  10331. /**
  10332. * This method is like `_.curry` except that arguments are applied to `func`
  10333. * in the manner of `_.partialRight` instead of `_.partial`.
  10334. *
  10335. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  10336. * builds, may be used as a placeholder for provided arguments.
  10337. *
  10338. * **Note:** This method doesn't set the "length" property of curried functions.
  10339. *
  10340. * @static
  10341. * @memberOf _
  10342. * @since 3.0.0
  10343. * @category Function
  10344. * @param {Function} func The function to curry.
  10345. * @param {number} [arity=func.length] The arity of `func`.
  10346. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10347. * @returns {Function} Returns the new curried function.
  10348. * @example
  10349. *
  10350. * var abc = function(a, b, c) {
  10351. * return [a, b, c];
  10352. * };
  10353. *
  10354. * var curried = _.curryRight(abc);
  10355. *
  10356. * curried(3)(2)(1);
  10357. * // => [1, 2, 3]
  10358. *
  10359. * curried(2, 3)(1);
  10360. * // => [1, 2, 3]
  10361. *
  10362. * curried(1, 2, 3);
  10363. * // => [1, 2, 3]
  10364. *
  10365. * // Curried with placeholders.
  10366. * curried(3)(1, _)(2);
  10367. * // => [1, 2, 3]
  10368. */
  10369. function curryRight(func, arity, guard) {
  10370. arity = guard ? undefined : arity;
  10371. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  10372. result.placeholder = curryRight.placeholder;
  10373. return result;
  10374. }
  10375. /**
  10376. * Creates a debounced function that delays invoking `func` until after `wait`
  10377. * milliseconds have elapsed since the last time the debounced function was
  10378. * invoked. The debounced function comes with a `cancel` method to cancel
  10379. * delayed `func` invocations and a `flush` method to immediately invoke them.
  10380. * Provide `options` to indicate whether `func` should be invoked on the
  10381. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  10382. * with the last arguments provided to the debounced function. Subsequent
  10383. * calls to the debounced function return the result of the last `func`
  10384. * invocation.
  10385. *
  10386. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  10387. * invoked on the trailing edge of the timeout only if the debounced function
  10388. * is invoked more than once during the `wait` timeout.
  10389. *
  10390. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  10391. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  10392. *
  10393. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  10394. * for details over the differences between `_.debounce` and `_.throttle`.
  10395. *
  10396. * @static
  10397. * @memberOf _
  10398. * @since 0.1.0
  10399. * @category Function
  10400. * @param {Function} func The function to debounce.
  10401. * @param {number} [wait=0] The number of milliseconds to delay.
  10402. * @param {Object} [options={}] The options object.
  10403. * @param {boolean} [options.leading=false]
  10404. * Specify invoking on the leading edge of the timeout.
  10405. * @param {number} [options.maxWait]
  10406. * The maximum time `func` is allowed to be delayed before it's invoked.
  10407. * @param {boolean} [options.trailing=true]
  10408. * Specify invoking on the trailing edge of the timeout.
  10409. * @returns {Function} Returns the new debounced function.
  10410. * @example
  10411. *
  10412. * // Avoid costly calculations while the window size is in flux.
  10413. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  10414. *
  10415. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  10416. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  10417. * 'leading': true,
  10418. * 'trailing': false
  10419. * }));
  10420. *
  10421. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  10422. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  10423. * var source = new EventSource('/stream');
  10424. * jQuery(source).on('message', debounced);
  10425. *
  10426. * // Cancel the trailing debounced invocation.
  10427. * jQuery(window).on('popstate', debounced.cancel);
  10428. */
  10429. function debounce(func, wait, options) {
  10430. var lastArgs,
  10431. lastThis,
  10432. maxWait,
  10433. result,
  10434. timerId,
  10435. lastCallTime,
  10436. lastInvokeTime = 0,
  10437. leading = false,
  10438. maxing = false,
  10439. trailing = true;
  10440. if (typeof func != 'function') {
  10441. throw new TypeError(FUNC_ERROR_TEXT);
  10442. }
  10443. wait = toNumber(wait) || 0;
  10444. if (isObject(options)) {
  10445. leading = !!options.leading;
  10446. maxing = 'maxWait' in options;
  10447. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  10448. trailing = 'trailing' in options ? !!options.trailing : trailing;
  10449. }
  10450. function invokeFunc(time) {
  10451. var args = lastArgs,
  10452. thisArg = lastThis;
  10453. lastArgs = lastThis = undefined;
  10454. lastInvokeTime = time;
  10455. result = func.apply(thisArg, args);
  10456. return result;
  10457. }
  10458. function leadingEdge(time) {
  10459. // Reset any `maxWait` timer.
  10460. lastInvokeTime = time;
  10461. // Start the timer for the trailing edge.
  10462. timerId = setTimeout(timerExpired, wait);
  10463. // Invoke the leading edge.
  10464. return leading ? invokeFunc(time) : result;
  10465. }
  10466. function remainingWait(time) {
  10467. var timeSinceLastCall = time - lastCallTime,
  10468. timeSinceLastInvoke = time - lastInvokeTime,
  10469. result = wait - timeSinceLastCall;
  10470. return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
  10471. }
  10472. function shouldInvoke(time) {
  10473. var timeSinceLastCall = time - lastCallTime,
  10474. timeSinceLastInvoke = time - lastInvokeTime;
  10475. // Either this is the first call, activity has stopped and we're at the
  10476. // trailing edge, the system time has gone backwards and we're treating
  10477. // it as the trailing edge, or we've hit the `maxWait` limit.
  10478. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  10479. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  10480. }
  10481. function timerExpired() {
  10482. var time = now();
  10483. if (shouldInvoke(time)) {
  10484. return trailingEdge(time);
  10485. }
  10486. // Restart the timer.
  10487. timerId = setTimeout(timerExpired, remainingWait(time));
  10488. }
  10489. function trailingEdge(time) {
  10490. timerId = undefined;
  10491. // Only invoke if we have `lastArgs` which means `func` has been
  10492. // debounced at least once.
  10493. if (trailing && lastArgs) {
  10494. return invokeFunc(time);
  10495. }
  10496. lastArgs = lastThis = undefined;
  10497. return result;
  10498. }
  10499. function cancel() {
  10500. if (timerId !== undefined) {
  10501. clearTimeout(timerId);
  10502. }
  10503. lastInvokeTime = 0;
  10504. lastArgs = lastCallTime = lastThis = timerId = undefined;
  10505. }
  10506. function flush() {
  10507. return timerId === undefined ? result : trailingEdge(now());
  10508. }
  10509. function debounced() {
  10510. var time = now(),
  10511. isInvoking = shouldInvoke(time);
  10512. lastArgs = arguments;
  10513. lastThis = this;
  10514. lastCallTime = time;
  10515. if (isInvoking) {
  10516. if (timerId === undefined) {
  10517. return leadingEdge(lastCallTime);
  10518. }
  10519. if (maxing) {
  10520. // Handle invocations in a tight loop.
  10521. timerId = setTimeout(timerExpired, wait);
  10522. return invokeFunc(lastCallTime);
  10523. }
  10524. }
  10525. if (timerId === undefined) {
  10526. timerId = setTimeout(timerExpired, wait);
  10527. }
  10528. return result;
  10529. }
  10530. debounced.cancel = cancel;
  10531. debounced.flush = flush;
  10532. return debounced;
  10533. }
  10534. /**
  10535. * Defers invoking the `func` until the current call stack has cleared. Any
  10536. * additional arguments are provided to `func` when it's invoked.
  10537. *
  10538. * @static
  10539. * @memberOf _
  10540. * @since 0.1.0
  10541. * @category Function
  10542. * @param {Function} func The function to defer.
  10543. * @param {...*} [args] The arguments to invoke `func` with.
  10544. * @returns {number} Returns the timer id.
  10545. * @example
  10546. *
  10547. * _.defer(function(text) {
  10548. * console.log(text);
  10549. * }, 'deferred');
  10550. * // => Logs 'deferred' after one millisecond.
  10551. */
  10552. var defer = baseRest(function(func, args) {
  10553. return baseDelay(func, 1, args);
  10554. });
  10555. /**
  10556. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  10557. * provided to `func` when it's invoked.
  10558. *
  10559. * @static
  10560. * @memberOf _
  10561. * @since 0.1.0
  10562. * @category Function
  10563. * @param {Function} func The function to delay.
  10564. * @param {number} wait The number of milliseconds to delay invocation.
  10565. * @param {...*} [args] The arguments to invoke `func` with.
  10566. * @returns {number} Returns the timer id.
  10567. * @example
  10568. *
  10569. * _.delay(function(text) {
  10570. * console.log(text);
  10571. * }, 1000, 'later');
  10572. * // => Logs 'later' after one second.
  10573. */
  10574. var delay = baseRest(function(func, wait, args) {
  10575. return baseDelay(func, toNumber(wait) || 0, args);
  10576. });
  10577. /**
  10578. * Creates a function that invokes `func` with arguments reversed.
  10579. *
  10580. * @static
  10581. * @memberOf _
  10582. * @since 4.0.0
  10583. * @category Function
  10584. * @param {Function} func The function to flip arguments for.
  10585. * @returns {Function} Returns the new flipped function.
  10586. * @example
  10587. *
  10588. * var flipped = _.flip(function() {
  10589. * return _.toArray(arguments);
  10590. * });
  10591. *
  10592. * flipped('a', 'b', 'c', 'd');
  10593. * // => ['d', 'c', 'b', 'a']
  10594. */
  10595. function flip(func) {
  10596. return createWrap(func, WRAP_FLIP_FLAG);
  10597. }
  10598. /**
  10599. * Creates a function that memoizes the result of `func`. If `resolver` is
  10600. * provided, it determines the cache key for storing the result based on the
  10601. * arguments provided to the memoized function. By default, the first argument
  10602. * provided to the memoized function is used as the map cache key. The `func`
  10603. * is invoked with the `this` binding of the memoized function.
  10604. *
  10605. * **Note:** The cache is exposed as the `cache` property on the memoized
  10606. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  10607. * constructor with one whose instances implement the
  10608. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  10609. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  10610. *
  10611. * @static
  10612. * @memberOf _
  10613. * @since 0.1.0
  10614. * @category Function
  10615. * @param {Function} func The function to have its output memoized.
  10616. * @param {Function} [resolver] The function to resolve the cache key.
  10617. * @returns {Function} Returns the new memoized function.
  10618. * @example
  10619. *
  10620. * var object = { 'a': 1, 'b': 2 };
  10621. * var other = { 'c': 3, 'd': 4 };
  10622. *
  10623. * var values = _.memoize(_.values);
  10624. * values(object);
  10625. * // => [1, 2]
  10626. *
  10627. * values(other);
  10628. * // => [3, 4]
  10629. *
  10630. * object.a = 2;
  10631. * values(object);
  10632. * // => [1, 2]
  10633. *
  10634. * // Modify the result cache.
  10635. * values.cache.set(object, ['a', 'b']);
  10636. * values(object);
  10637. * // => ['a', 'b']
  10638. *
  10639. * // Replace `_.memoize.Cache`.
  10640. * _.memoize.Cache = WeakMap;
  10641. */
  10642. function memoize(func, resolver) {
  10643. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  10644. throw new TypeError(FUNC_ERROR_TEXT);
  10645. }
  10646. var memoized = function() {
  10647. var args = arguments,
  10648. key = resolver ? resolver.apply(this, args) : args[0],
  10649. cache = memoized.cache;
  10650. if (cache.has(key)) {
  10651. return cache.get(key);
  10652. }
  10653. var result = func.apply(this, args);
  10654. memoized.cache = cache.set(key, result) || cache;
  10655. return result;
  10656. };
  10657. memoized.cache = new (memoize.Cache || MapCache);
  10658. return memoized;
  10659. }
  10660. // Expose `MapCache`.
  10661. memoize.Cache = MapCache;
  10662. /**
  10663. * Creates a function that negates the result of the predicate `func`. The
  10664. * `func` predicate is invoked with the `this` binding and arguments of the
  10665. * created function.
  10666. *
  10667. * @static
  10668. * @memberOf _
  10669. * @since 3.0.0
  10670. * @category Function
  10671. * @param {Function} predicate The predicate to negate.
  10672. * @returns {Function} Returns the new negated function.
  10673. * @example
  10674. *
  10675. * function isEven(n) {
  10676. * return n % 2 == 0;
  10677. * }
  10678. *
  10679. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  10680. * // => [1, 3, 5]
  10681. */
  10682. function negate(predicate) {
  10683. if (typeof predicate != 'function') {
  10684. throw new TypeError(FUNC_ERROR_TEXT);
  10685. }
  10686. return function() {
  10687. var args = arguments;
  10688. switch (args.length) {
  10689. case 0: return !predicate.call(this);
  10690. case 1: return !predicate.call(this, args[0]);
  10691. case 2: return !predicate.call(this, args[0], args[1]);
  10692. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  10693. }
  10694. return !predicate.apply(this, args);
  10695. };
  10696. }
  10697. /**
  10698. * Creates a function that is restricted to invoking `func` once. Repeat calls
  10699. * to the function return the value of the first invocation. The `func` is
  10700. * invoked with the `this` binding and arguments of the created function.
  10701. *
  10702. * @static
  10703. * @memberOf _
  10704. * @since 0.1.0
  10705. * @category Function
  10706. * @param {Function} func The function to restrict.
  10707. * @returns {Function} Returns the new restricted function.
  10708. * @example
  10709. *
  10710. * var initialize = _.once(createApplication);
  10711. * initialize();
  10712. * initialize();
  10713. * // => `createApplication` is invoked once
  10714. */
  10715. function once(func) {
  10716. return before(2, func);
  10717. }
  10718. /**
  10719. * Creates a function that invokes `func` with its arguments transformed.
  10720. *
  10721. * @static
  10722. * @since 4.0.0
  10723. * @memberOf _
  10724. * @category Function
  10725. * @param {Function} func The function to wrap.
  10726. * @param {...(Function|Function[])} [transforms=[_.identity]]
  10727. * The argument transforms.
  10728. * @returns {Function} Returns the new function.
  10729. * @example
  10730. *
  10731. * function doubled(n) {
  10732. * return n * 2;
  10733. * }
  10734. *
  10735. * function square(n) {
  10736. * return n * n;
  10737. * }
  10738. *
  10739. * var func = _.overArgs(function(x, y) {
  10740. * return [x, y];
  10741. * }, [square, doubled]);
  10742. *
  10743. * func(9, 3);
  10744. * // => [81, 6]
  10745. *
  10746. * func(10, 5);
  10747. * // => [100, 10]
  10748. */
  10749. var overArgs = castRest(function(func, transforms) {
  10750. transforms = (transforms.length == 1 && isArray(transforms[0]))
  10751. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  10752. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  10753. var funcsLength = transforms.length;
  10754. return baseRest(function(args) {
  10755. var index = -1,
  10756. length = nativeMin(args.length, funcsLength);
  10757. while (++index < length) {
  10758. args[index] = transforms[index].call(this, args[index]);
  10759. }
  10760. return apply(func, this, args);
  10761. });
  10762. });
  10763. /**
  10764. * Creates a function that invokes `func` with `partials` prepended to the
  10765. * arguments it receives. This method is like `_.bind` except it does **not**
  10766. * alter the `this` binding.
  10767. *
  10768. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  10769. * builds, may be used as a placeholder for partially applied arguments.
  10770. *
  10771. * **Note:** This method doesn't set the "length" property of partially
  10772. * applied functions.
  10773. *
  10774. * @static
  10775. * @memberOf _
  10776. * @since 0.2.0
  10777. * @category Function
  10778. * @param {Function} func The function to partially apply arguments to.
  10779. * @param {...*} [partials] The arguments to be partially applied.
  10780. * @returns {Function} Returns the new partially applied function.
  10781. * @example
  10782. *
  10783. * function greet(greeting, name) {
  10784. * return greeting + ' ' + name;
  10785. * }
  10786. *
  10787. * var sayHelloTo = _.partial(greet, 'hello');
  10788. * sayHelloTo('fred');
  10789. * // => 'hello fred'
  10790. *
  10791. * // Partially applied with placeholders.
  10792. * var greetFred = _.partial(greet, _, 'fred');
  10793. * greetFred('hi');
  10794. * // => 'hi fred'
  10795. */
  10796. var partial = baseRest(function(func, partials) {
  10797. var holders = replaceHolders(partials, getHolder(partial));
  10798. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  10799. });
  10800. /**
  10801. * This method is like `_.partial` except that partially applied arguments
  10802. * are appended to the arguments it receives.
  10803. *
  10804. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  10805. * builds, may be used as a placeholder for partially applied arguments.
  10806. *
  10807. * **Note:** This method doesn't set the "length" property of partially
  10808. * applied functions.
  10809. *
  10810. * @static
  10811. * @memberOf _
  10812. * @since 1.0.0
  10813. * @category Function
  10814. * @param {Function} func The function to partially apply arguments to.
  10815. * @param {...*} [partials] The arguments to be partially applied.
  10816. * @returns {Function} Returns the new partially applied function.
  10817. * @example
  10818. *
  10819. * function greet(greeting, name) {
  10820. * return greeting + ' ' + name;
  10821. * }
  10822. *
  10823. * var greetFred = _.partialRight(greet, 'fred');
  10824. * greetFred('hi');
  10825. * // => 'hi fred'
  10826. *
  10827. * // Partially applied with placeholders.
  10828. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  10829. * sayHelloTo('fred');
  10830. * // => 'hello fred'
  10831. */
  10832. var partialRight = baseRest(function(func, partials) {
  10833. var holders = replaceHolders(partials, getHolder(partialRight));
  10834. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  10835. });
  10836. /**
  10837. * Creates a function that invokes `func` with arguments arranged according
  10838. * to the specified `indexes` where the argument value at the first index is
  10839. * provided as the first argument, the argument value at the second index is
  10840. * provided as the second argument, and so on.
  10841. *
  10842. * @static
  10843. * @memberOf _
  10844. * @since 3.0.0
  10845. * @category Function
  10846. * @param {Function} func The function to rearrange arguments for.
  10847. * @param {...(number|number[])} indexes The arranged argument indexes.
  10848. * @returns {Function} Returns the new function.
  10849. * @example
  10850. *
  10851. * var rearged = _.rearg(function(a, b, c) {
  10852. * return [a, b, c];
  10853. * }, [2, 0, 1]);
  10854. *
  10855. * rearged('b', 'c', 'a')
  10856. * // => ['a', 'b', 'c']
  10857. */
  10858. var rearg = flatRest(function(func, indexes) {
  10859. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  10860. });
  10861. /**
  10862. * Creates a function that invokes `func` with the `this` binding of the
  10863. * created function and arguments from `start` and beyond provided as
  10864. * an array.
  10865. *
  10866. * **Note:** This method is based on the
  10867. * [rest parameter](https://mdn.io/rest_parameters).
  10868. *
  10869. * @static
  10870. * @memberOf _
  10871. * @since 4.0.0
  10872. * @category Function
  10873. * @param {Function} func The function to apply a rest parameter to.
  10874. * @param {number} [start=func.length-1] The start position of the rest parameter.
  10875. * @returns {Function} Returns the new function.
  10876. * @example
  10877. *
  10878. * var say = _.rest(function(what, names) {
  10879. * return what + ' ' + _.initial(names).join(', ') +
  10880. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  10881. * });
  10882. *
  10883. * say('hello', 'fred', 'barney', 'pebbles');
  10884. * // => 'hello fred, barney, & pebbles'
  10885. */
  10886. function rest(func, start) {
  10887. if (typeof func != 'function') {
  10888. throw new TypeError(FUNC_ERROR_TEXT);
  10889. }
  10890. start = start === undefined ? start : toInteger(start);
  10891. return baseRest(func, start);
  10892. }
  10893. /**
  10894. * Creates a function that invokes `func` with the `this` binding of the
  10895. * create function and an array of arguments much like
  10896. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  10897. *
  10898. * **Note:** This method is based on the
  10899. * [spread operator](https://mdn.io/spread_operator).
  10900. *
  10901. * @static
  10902. * @memberOf _
  10903. * @since 3.2.0
  10904. * @category Function
  10905. * @param {Function} func The function to spread arguments over.
  10906. * @param {number} [start=0] The start position of the spread.
  10907. * @returns {Function} Returns the new function.
  10908. * @example
  10909. *
  10910. * var say = _.spread(function(who, what) {
  10911. * return who + ' says ' + what;
  10912. * });
  10913. *
  10914. * say(['fred', 'hello']);
  10915. * // => 'fred says hello'
  10916. *
  10917. * var numbers = Promise.all([
  10918. * Promise.resolve(40),
  10919. * Promise.resolve(36)
  10920. * ]);
  10921. *
  10922. * numbers.then(_.spread(function(x, y) {
  10923. * return x + y;
  10924. * }));
  10925. * // => a Promise of 76
  10926. */
  10927. function spread(func, start) {
  10928. if (typeof func != 'function') {
  10929. throw new TypeError(FUNC_ERROR_TEXT);
  10930. }
  10931. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  10932. return baseRest(function(args) {
  10933. var array = args[start],
  10934. otherArgs = castSlice(args, 0, start);
  10935. if (array) {
  10936. arrayPush(otherArgs, array);
  10937. }
  10938. return apply(func, this, otherArgs);
  10939. });
  10940. }
  10941. /**
  10942. * Creates a throttled function that only invokes `func` at most once per
  10943. * every `wait` milliseconds. The throttled function comes with a `cancel`
  10944. * method to cancel delayed `func` invocations and a `flush` method to
  10945. * immediately invoke them. Provide `options` to indicate whether `func`
  10946. * should be invoked on the leading and/or trailing edge of the `wait`
  10947. * timeout. The `func` is invoked with the last arguments provided to the
  10948. * throttled function. Subsequent calls to the throttled function return the
  10949. * result of the last `func` invocation.
  10950. *
  10951. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  10952. * invoked on the trailing edge of the timeout only if the throttled function
  10953. * is invoked more than once during the `wait` timeout.
  10954. *
  10955. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  10956. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  10957. *
  10958. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  10959. * for details over the differences between `_.throttle` and `_.debounce`.
  10960. *
  10961. * @static
  10962. * @memberOf _
  10963. * @since 0.1.0
  10964. * @category Function
  10965. * @param {Function} func The function to throttle.
  10966. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  10967. * @param {Object} [options={}] The options object.
  10968. * @param {boolean} [options.leading=true]
  10969. * Specify invoking on the leading edge of the timeout.
  10970. * @param {boolean} [options.trailing=true]
  10971. * Specify invoking on the trailing edge of the timeout.
  10972. * @returns {Function} Returns the new throttled function.
  10973. * @example
  10974. *
  10975. * // Avoid excessively updating the position while scrolling.
  10976. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  10977. *
  10978. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  10979. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  10980. * jQuery(element).on('click', throttled);
  10981. *
  10982. * // Cancel the trailing throttled invocation.
  10983. * jQuery(window).on('popstate', throttled.cancel);
  10984. */
  10985. function throttle(func, wait, options) {
  10986. var leading = true,
  10987. trailing = true;
  10988. if (typeof func != 'function') {
  10989. throw new TypeError(FUNC_ERROR_TEXT);
  10990. }
  10991. if (isObject(options)) {
  10992. leading = 'leading' in options ? !!options.leading : leading;
  10993. trailing = 'trailing' in options ? !!options.trailing : trailing;
  10994. }
  10995. return debounce(func, wait, {
  10996. 'leading': leading,
  10997. 'maxWait': wait,
  10998. 'trailing': trailing
  10999. });
  11000. }
  11001. /**
  11002. * Creates a function that accepts up to one argument, ignoring any
  11003. * additional arguments.
  11004. *
  11005. * @static
  11006. * @memberOf _
  11007. * @since 4.0.0
  11008. * @category Function
  11009. * @param {Function} func The function to cap arguments for.
  11010. * @returns {Function} Returns the new capped function.
  11011. * @example
  11012. *
  11013. * _.map(['6', '8', '10'], _.unary(parseInt));
  11014. * // => [6, 8, 10]
  11015. */
  11016. function unary(func) {
  11017. return ary(func, 1);
  11018. }
  11019. /**
  11020. * Creates a function that provides `value` to `wrapper` as its first
  11021. * argument. Any additional arguments provided to the function are appended
  11022. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  11023. * binding of the created function.
  11024. *
  11025. * @static
  11026. * @memberOf _
  11027. * @since 0.1.0
  11028. * @category Function
  11029. * @param {*} value The value to wrap.
  11030. * @param {Function} [wrapper=identity] The wrapper function.
  11031. * @returns {Function} Returns the new function.
  11032. * @example
  11033. *
  11034. * var p = _.wrap(_.escape, function(func, text) {
  11035. * return '<p>' + func(text) + '</p>';
  11036. * });
  11037. *
  11038. * p('fred, barney, & pebbles');
  11039. * // => '<p>fred, barney, &amp; pebbles</p>'
  11040. */
  11041. function wrap(value, wrapper) {
  11042. return partial(castFunction(wrapper), value);
  11043. }
  11044. /*------------------------------------------------------------------------*/
  11045. /**
  11046. * Casts `value` as an array if it's not one.
  11047. *
  11048. * @static
  11049. * @memberOf _
  11050. * @since 4.4.0
  11051. * @category Lang
  11052. * @param {*} value The value to inspect.
  11053. * @returns {Array} Returns the cast array.
  11054. * @example
  11055. *
  11056. * _.castArray(1);
  11057. * // => [1]
  11058. *
  11059. * _.castArray({ 'a': 1 });
  11060. * // => [{ 'a': 1 }]
  11061. *
  11062. * _.castArray('abc');
  11063. * // => ['abc']
  11064. *
  11065. * _.castArray(null);
  11066. * // => [null]
  11067. *
  11068. * _.castArray(undefined);
  11069. * // => [undefined]
  11070. *
  11071. * _.castArray();
  11072. * // => []
  11073. *
  11074. * var array = [1, 2, 3];
  11075. * console.log(_.castArray(array) === array);
  11076. * // => true
  11077. */
  11078. function castArray() {
  11079. if (!arguments.length) {
  11080. return [];
  11081. }
  11082. var value = arguments[0];
  11083. return isArray(value) ? value : [value];
  11084. }
  11085. /**
  11086. * Creates a shallow clone of `value`.
  11087. *
  11088. * **Note:** This method is loosely based on the
  11089. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  11090. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  11091. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  11092. * arrays. The own enumerable properties of `arguments` objects are cloned
  11093. * as plain objects. An empty object is returned for uncloneable values such
  11094. * as error objects, functions, DOM nodes, and WeakMaps.
  11095. *
  11096. * @static
  11097. * @memberOf _
  11098. * @since 0.1.0
  11099. * @category Lang
  11100. * @param {*} value The value to clone.
  11101. * @returns {*} Returns the cloned value.
  11102. * @see _.cloneDeep
  11103. * @example
  11104. *
  11105. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11106. *
  11107. * var shallow = _.clone(objects);
  11108. * console.log(shallow[0] === objects[0]);
  11109. * // => true
  11110. */
  11111. function clone(value) {
  11112. return baseClone(value, CLONE_SYMBOLS_FLAG);
  11113. }
  11114. /**
  11115. * This method is like `_.clone` except that it accepts `customizer` which
  11116. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  11117. * cloning is handled by the method instead. The `customizer` is invoked with
  11118. * up to four arguments; (value [, index|key, object, stack]).
  11119. *
  11120. * @static
  11121. * @memberOf _
  11122. * @since 4.0.0
  11123. * @category Lang
  11124. * @param {*} value The value to clone.
  11125. * @param {Function} [customizer] The function to customize cloning.
  11126. * @returns {*} Returns the cloned value.
  11127. * @see _.cloneDeepWith
  11128. * @example
  11129. *
  11130. * function customizer(value) {
  11131. * if (_.isElement(value)) {
  11132. * return value.cloneNode(false);
  11133. * }
  11134. * }
  11135. *
  11136. * var el = _.cloneWith(document.body, customizer);
  11137. *
  11138. * console.log(el === document.body);
  11139. * // => false
  11140. * console.log(el.nodeName);
  11141. * // => 'BODY'
  11142. * console.log(el.childNodes.length);
  11143. * // => 0
  11144. */
  11145. function cloneWith(value, customizer) {
  11146. customizer = typeof customizer == 'function' ? customizer : undefined;
  11147. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  11148. }
  11149. /**
  11150. * This method is like `_.clone` except that it recursively clones `value`.
  11151. *
  11152. * @static
  11153. * @memberOf _
  11154. * @since 1.0.0
  11155. * @category Lang
  11156. * @param {*} value The value to recursively clone.
  11157. * @returns {*} Returns the deep cloned value.
  11158. * @see _.clone
  11159. * @example
  11160. *
  11161. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11162. *
  11163. * var deep = _.cloneDeep(objects);
  11164. * console.log(deep[0] === objects[0]);
  11165. * // => false
  11166. */
  11167. function cloneDeep(value) {
  11168. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  11169. }
  11170. /**
  11171. * This method is like `_.cloneWith` except that it recursively clones `value`.
  11172. *
  11173. * @static
  11174. * @memberOf _
  11175. * @since 4.0.0
  11176. * @category Lang
  11177. * @param {*} value The value to recursively clone.
  11178. * @param {Function} [customizer] The function to customize cloning.
  11179. * @returns {*} Returns the deep cloned value.
  11180. * @see _.cloneWith
  11181. * @example
  11182. *
  11183. * function customizer(value) {
  11184. * if (_.isElement(value)) {
  11185. * return value.cloneNode(true);
  11186. * }
  11187. * }
  11188. *
  11189. * var el = _.cloneDeepWith(document.body, customizer);
  11190. *
  11191. * console.log(el === document.body);
  11192. * // => false
  11193. * console.log(el.nodeName);
  11194. * // => 'BODY'
  11195. * console.log(el.childNodes.length);
  11196. * // => 20
  11197. */
  11198. function cloneDeepWith(value, customizer) {
  11199. customizer = typeof customizer == 'function' ? customizer : undefined;
  11200. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  11201. }
  11202. /**
  11203. * Checks if `object` conforms to `source` by invoking the predicate
  11204. * properties of `source` with the corresponding property values of `object`.
  11205. *
  11206. * **Note:** This method is equivalent to `_.conforms` when `source` is
  11207. * partially applied.
  11208. *
  11209. * @static
  11210. * @memberOf _
  11211. * @since 4.14.0
  11212. * @category Lang
  11213. * @param {Object} object The object to inspect.
  11214. * @param {Object} source The object of property predicates to conform to.
  11215. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  11216. * @example
  11217. *
  11218. * var object = { 'a': 1, 'b': 2 };
  11219. *
  11220. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  11221. * // => true
  11222. *
  11223. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  11224. * // => false
  11225. */
  11226. function conformsTo(object, source) {
  11227. return source == null || baseConformsTo(object, source, keys(source));
  11228. }
  11229. /**
  11230. * Performs a
  11231. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11232. * comparison between two values to determine if they are equivalent.
  11233. *
  11234. * @static
  11235. * @memberOf _
  11236. * @since 4.0.0
  11237. * @category Lang
  11238. * @param {*} value The value to compare.
  11239. * @param {*} other The other value to compare.
  11240. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11241. * @example
  11242. *
  11243. * var object = { 'a': 1 };
  11244. * var other = { 'a': 1 };
  11245. *
  11246. * _.eq(object, object);
  11247. * // => true
  11248. *
  11249. * _.eq(object, other);
  11250. * // => false
  11251. *
  11252. * _.eq('a', 'a');
  11253. * // => true
  11254. *
  11255. * _.eq('a', Object('a'));
  11256. * // => false
  11257. *
  11258. * _.eq(NaN, NaN);
  11259. * // => true
  11260. */
  11261. function eq(value, other) {
  11262. return value === other || (value !== value && other !== other);
  11263. }
  11264. /**
  11265. * Checks if `value` is greater than `other`.
  11266. *
  11267. * @static
  11268. * @memberOf _
  11269. * @since 3.9.0
  11270. * @category Lang
  11271. * @param {*} value The value to compare.
  11272. * @param {*} other The other value to compare.
  11273. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  11274. * else `false`.
  11275. * @see _.lt
  11276. * @example
  11277. *
  11278. * _.gt(3, 1);
  11279. * // => true
  11280. *
  11281. * _.gt(3, 3);
  11282. * // => false
  11283. *
  11284. * _.gt(1, 3);
  11285. * // => false
  11286. */
  11287. var gt = createRelationalOperation(baseGt);
  11288. /**
  11289. * Checks if `value` is greater than or equal to `other`.
  11290. *
  11291. * @static
  11292. * @memberOf _
  11293. * @since 3.9.0
  11294. * @category Lang
  11295. * @param {*} value The value to compare.
  11296. * @param {*} other The other value to compare.
  11297. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  11298. * `other`, else `false`.
  11299. * @see _.lte
  11300. * @example
  11301. *
  11302. * _.gte(3, 1);
  11303. * // => true
  11304. *
  11305. * _.gte(3, 3);
  11306. * // => true
  11307. *
  11308. * _.gte(1, 3);
  11309. * // => false
  11310. */
  11311. var gte = createRelationalOperation(function(value, other) {
  11312. return value >= other;
  11313. });
  11314. /**
  11315. * Checks if `value` is likely an `arguments` object.
  11316. *
  11317. * @static
  11318. * @memberOf _
  11319. * @since 0.1.0
  11320. * @category Lang
  11321. * @param {*} value The value to check.
  11322. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  11323. * else `false`.
  11324. * @example
  11325. *
  11326. * _.isArguments(function() { return arguments; }());
  11327. * // => true
  11328. *
  11329. * _.isArguments([1, 2, 3]);
  11330. * // => false
  11331. */
  11332. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  11333. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  11334. !propertyIsEnumerable.call(value, 'callee');
  11335. };
  11336. /**
  11337. * Checks if `value` is classified as an `Array` object.
  11338. *
  11339. * @static
  11340. * @memberOf _
  11341. * @since 0.1.0
  11342. * @category Lang
  11343. * @param {*} value The value to check.
  11344. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  11345. * @example
  11346. *
  11347. * _.isArray([1, 2, 3]);
  11348. * // => true
  11349. *
  11350. * _.isArray(document.body.children);
  11351. * // => false
  11352. *
  11353. * _.isArray('abc');
  11354. * // => false
  11355. *
  11356. * _.isArray(_.noop);
  11357. * // => false
  11358. */
  11359. var isArray = Array.isArray;
  11360. /**
  11361. * Checks if `value` is classified as an `ArrayBuffer` object.
  11362. *
  11363. * @static
  11364. * @memberOf _
  11365. * @since 4.3.0
  11366. * @category Lang
  11367. * @param {*} value The value to check.
  11368. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  11369. * @example
  11370. *
  11371. * _.isArrayBuffer(new ArrayBuffer(2));
  11372. * // => true
  11373. *
  11374. * _.isArrayBuffer(new Array(2));
  11375. * // => false
  11376. */
  11377. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  11378. /**
  11379. * Checks if `value` is array-like. A value is considered array-like if it's
  11380. * not a function and has a `value.length` that's an integer greater than or
  11381. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  11382. *
  11383. * @static
  11384. * @memberOf _
  11385. * @since 4.0.0
  11386. * @category Lang
  11387. * @param {*} value The value to check.
  11388. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  11389. * @example
  11390. *
  11391. * _.isArrayLike([1, 2, 3]);
  11392. * // => true
  11393. *
  11394. * _.isArrayLike(document.body.children);
  11395. * // => true
  11396. *
  11397. * _.isArrayLike('abc');
  11398. * // => true
  11399. *
  11400. * _.isArrayLike(_.noop);
  11401. * // => false
  11402. */
  11403. function isArrayLike(value) {
  11404. return value != null && isLength(value.length) && !isFunction(value);
  11405. }
  11406. /**
  11407. * This method is like `_.isArrayLike` except that it also checks if `value`
  11408. * is an object.
  11409. *
  11410. * @static
  11411. * @memberOf _
  11412. * @since 4.0.0
  11413. * @category Lang
  11414. * @param {*} value The value to check.
  11415. * @returns {boolean} Returns `true` if `value` is an array-like object,
  11416. * else `false`.
  11417. * @example
  11418. *
  11419. * _.isArrayLikeObject([1, 2, 3]);
  11420. * // => true
  11421. *
  11422. * _.isArrayLikeObject(document.body.children);
  11423. * // => true
  11424. *
  11425. * _.isArrayLikeObject('abc');
  11426. * // => false
  11427. *
  11428. * _.isArrayLikeObject(_.noop);
  11429. * // => false
  11430. */
  11431. function isArrayLikeObject(value) {
  11432. return isObjectLike(value) && isArrayLike(value);
  11433. }
  11434. /**
  11435. * Checks if `value` is classified as a boolean primitive or object.
  11436. *
  11437. * @static
  11438. * @memberOf _
  11439. * @since 0.1.0
  11440. * @category Lang
  11441. * @param {*} value The value to check.
  11442. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  11443. * @example
  11444. *
  11445. * _.isBoolean(false);
  11446. * // => true
  11447. *
  11448. * _.isBoolean(null);
  11449. * // => false
  11450. */
  11451. function isBoolean(value) {
  11452. return value === true || value === false ||
  11453. (isObjectLike(value) && baseGetTag(value) == boolTag);
  11454. }
  11455. /**
  11456. * Checks if `value` is a buffer.
  11457. *
  11458. * @static
  11459. * @memberOf _
  11460. * @since 4.3.0
  11461. * @category Lang
  11462. * @param {*} value The value to check.
  11463. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  11464. * @example
  11465. *
  11466. * _.isBuffer(new Buffer(2));
  11467. * // => true
  11468. *
  11469. * _.isBuffer(new Uint8Array(2));
  11470. * // => false
  11471. */
  11472. var isBuffer = nativeIsBuffer || stubFalse;
  11473. /**
  11474. * Checks if `value` is classified as a `Date` object.
  11475. *
  11476. * @static
  11477. * @memberOf _
  11478. * @since 0.1.0
  11479. * @category Lang
  11480. * @param {*} value The value to check.
  11481. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  11482. * @example
  11483. *
  11484. * _.isDate(new Date);
  11485. * // => true
  11486. *
  11487. * _.isDate('Mon April 23 2012');
  11488. * // => false
  11489. */
  11490. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  11491. /**
  11492. * Checks if `value` is likely a DOM element.
  11493. *
  11494. * @static
  11495. * @memberOf _
  11496. * @since 0.1.0
  11497. * @category Lang
  11498. * @param {*} value The value to check.
  11499. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  11500. * @example
  11501. *
  11502. * _.isElement(document.body);
  11503. * // => true
  11504. *
  11505. * _.isElement('<body>');
  11506. * // => false
  11507. */
  11508. function isElement(value) {
  11509. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  11510. }
  11511. /**
  11512. * Checks if `value` is an empty object, collection, map, or set.
  11513. *
  11514. * Objects are considered empty if they have no own enumerable string keyed
  11515. * properties.
  11516. *
  11517. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  11518. * jQuery-like collections are considered empty if they have a `length` of `0`.
  11519. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  11520. *
  11521. * @static
  11522. * @memberOf _
  11523. * @since 0.1.0
  11524. * @category Lang
  11525. * @param {*} value The value to check.
  11526. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  11527. * @example
  11528. *
  11529. * _.isEmpty(null);
  11530. * // => true
  11531. *
  11532. * _.isEmpty(true);
  11533. * // => true
  11534. *
  11535. * _.isEmpty(1);
  11536. * // => true
  11537. *
  11538. * _.isEmpty([1, 2, 3]);
  11539. * // => false
  11540. *
  11541. * _.isEmpty({ 'a': 1 });
  11542. * // => false
  11543. */
  11544. function isEmpty(value) {
  11545. if (value == null) {
  11546. return true;
  11547. }
  11548. if (isArrayLike(value) &&
  11549. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  11550. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  11551. return !value.length;
  11552. }
  11553. var tag = getTag(value);
  11554. if (tag == mapTag || tag == setTag) {
  11555. return !value.size;
  11556. }
  11557. if (isPrototype(value)) {
  11558. return !baseKeys(value).length;
  11559. }
  11560. for (var key in value) {
  11561. if (hasOwnProperty.call(value, key)) {
  11562. return false;
  11563. }
  11564. }
  11565. return true;
  11566. }
  11567. /**
  11568. * Performs a deep comparison between two values to determine if they are
  11569. * equivalent.
  11570. *
  11571. * **Note:** This method supports comparing arrays, array buffers, booleans,
  11572. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  11573. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  11574. * by their own, not inherited, enumerable properties. Functions and DOM
  11575. * nodes are compared by strict equality, i.e. `===`.
  11576. *
  11577. * @static
  11578. * @memberOf _
  11579. * @since 0.1.0
  11580. * @category Lang
  11581. * @param {*} value The value to compare.
  11582. * @param {*} other The other value to compare.
  11583. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11584. * @example
  11585. *
  11586. * var object = { 'a': 1 };
  11587. * var other = { 'a': 1 };
  11588. *
  11589. * _.isEqual(object, other);
  11590. * // => true
  11591. *
  11592. * object === other;
  11593. * // => false
  11594. */
  11595. function isEqual(value, other) {
  11596. return baseIsEqual(value, other);
  11597. }
  11598. /**
  11599. * This method is like `_.isEqual` except that it accepts `customizer` which
  11600. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  11601. * are handled by the method instead. The `customizer` is invoked with up to
  11602. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  11603. *
  11604. * @static
  11605. * @memberOf _
  11606. * @since 4.0.0
  11607. * @category Lang
  11608. * @param {*} value The value to compare.
  11609. * @param {*} other The other value to compare.
  11610. * @param {Function} [customizer] The function to customize comparisons.
  11611. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11612. * @example
  11613. *
  11614. * function isGreeting(value) {
  11615. * return /^h(?:i|ello)$/.test(value);
  11616. * }
  11617. *
  11618. * function customizer(objValue, othValue) {
  11619. * if (isGreeting(objValue) && isGreeting(othValue)) {
  11620. * return true;
  11621. * }
  11622. * }
  11623. *
  11624. * var array = ['hello', 'goodbye'];
  11625. * var other = ['hi', 'goodbye'];
  11626. *
  11627. * _.isEqualWith(array, other, customizer);
  11628. * // => true
  11629. */
  11630. function isEqualWith(value, other, customizer) {
  11631. customizer = typeof customizer == 'function' ? customizer : undefined;
  11632. var result = customizer ? customizer(value, other) : undefined;
  11633. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  11634. }
  11635. /**
  11636. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  11637. * `SyntaxError`, `TypeError`, or `URIError` object.
  11638. *
  11639. * @static
  11640. * @memberOf _
  11641. * @since 3.0.0
  11642. * @category Lang
  11643. * @param {*} value The value to check.
  11644. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  11645. * @example
  11646. *
  11647. * _.isError(new Error);
  11648. * // => true
  11649. *
  11650. * _.isError(Error);
  11651. * // => false
  11652. */
  11653. function isError(value) {
  11654. if (!isObjectLike(value)) {
  11655. return false;
  11656. }
  11657. var tag = baseGetTag(value);
  11658. return tag == errorTag || tag == domExcTag ||
  11659. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  11660. }
  11661. /**
  11662. * Checks if `value` is a finite primitive number.
  11663. *
  11664. * **Note:** This method is based on
  11665. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  11666. *
  11667. * @static
  11668. * @memberOf _
  11669. * @since 0.1.0
  11670. * @category Lang
  11671. * @param {*} value The value to check.
  11672. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  11673. * @example
  11674. *
  11675. * _.isFinite(3);
  11676. * // => true
  11677. *
  11678. * _.isFinite(Number.MIN_VALUE);
  11679. * // => true
  11680. *
  11681. * _.isFinite(Infinity);
  11682. * // => false
  11683. *
  11684. * _.isFinite('3');
  11685. * // => false
  11686. */
  11687. function isFinite(value) {
  11688. return typeof value == 'number' && nativeIsFinite(value);
  11689. }
  11690. /**
  11691. * Checks if `value` is classified as a `Function` object.
  11692. *
  11693. * @static
  11694. * @memberOf _
  11695. * @since 0.1.0
  11696. * @category Lang
  11697. * @param {*} value The value to check.
  11698. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  11699. * @example
  11700. *
  11701. * _.isFunction(_);
  11702. * // => true
  11703. *
  11704. * _.isFunction(/abc/);
  11705. * // => false
  11706. */
  11707. function isFunction(value) {
  11708. if (!isObject(value)) {
  11709. return false;
  11710. }
  11711. // The use of `Object#toString` avoids issues with the `typeof` operator
  11712. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  11713. var tag = baseGetTag(value);
  11714. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  11715. }
  11716. /**
  11717. * Checks if `value` is an integer.
  11718. *
  11719. * **Note:** This method is based on
  11720. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  11721. *
  11722. * @static
  11723. * @memberOf _
  11724. * @since 4.0.0
  11725. * @category Lang
  11726. * @param {*} value The value to check.
  11727. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  11728. * @example
  11729. *
  11730. * _.isInteger(3);
  11731. * // => true
  11732. *
  11733. * _.isInteger(Number.MIN_VALUE);
  11734. * // => false
  11735. *
  11736. * _.isInteger(Infinity);
  11737. * // => false
  11738. *
  11739. * _.isInteger('3');
  11740. * // => false
  11741. */
  11742. function isInteger(value) {
  11743. return typeof value == 'number' && value == toInteger(value);
  11744. }
  11745. /**
  11746. * Checks if `value` is a valid array-like length.
  11747. *
  11748. * **Note:** This method is loosely based on
  11749. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  11750. *
  11751. * @static
  11752. * @memberOf _
  11753. * @since 4.0.0
  11754. * @category Lang
  11755. * @param {*} value The value to check.
  11756. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  11757. * @example
  11758. *
  11759. * _.isLength(3);
  11760. * // => true
  11761. *
  11762. * _.isLength(Number.MIN_VALUE);
  11763. * // => false
  11764. *
  11765. * _.isLength(Infinity);
  11766. * // => false
  11767. *
  11768. * _.isLength('3');
  11769. * // => false
  11770. */
  11771. function isLength(value) {
  11772. return typeof value == 'number' &&
  11773. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  11774. }
  11775. /**
  11776. * Checks if `value` is the
  11777. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  11778. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  11779. *
  11780. * @static
  11781. * @memberOf _
  11782. * @since 0.1.0
  11783. * @category Lang
  11784. * @param {*} value The value to check.
  11785. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  11786. * @example
  11787. *
  11788. * _.isObject({});
  11789. * // => true
  11790. *
  11791. * _.isObject([1, 2, 3]);
  11792. * // => true
  11793. *
  11794. * _.isObject(_.noop);
  11795. * // => true
  11796. *
  11797. * _.isObject(null);
  11798. * // => false
  11799. */
  11800. function isObject(value) {
  11801. var type = typeof value;
  11802. return value != null && (type == 'object' || type == 'function');
  11803. }
  11804. /**
  11805. * Checks if `value` is object-like. A value is object-like if it's not `null`
  11806. * and has a `typeof` result of "object".
  11807. *
  11808. * @static
  11809. * @memberOf _
  11810. * @since 4.0.0
  11811. * @category Lang
  11812. * @param {*} value The value to check.
  11813. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  11814. * @example
  11815. *
  11816. * _.isObjectLike({});
  11817. * // => true
  11818. *
  11819. * _.isObjectLike([1, 2, 3]);
  11820. * // => true
  11821. *
  11822. * _.isObjectLike(_.noop);
  11823. * // => false
  11824. *
  11825. * _.isObjectLike(null);
  11826. * // => false
  11827. */
  11828. function isObjectLike(value) {
  11829. return value != null && typeof value == 'object';
  11830. }
  11831. /**
  11832. * Checks if `value` is classified as a `Map` object.
  11833. *
  11834. * @static
  11835. * @memberOf _
  11836. * @since 4.3.0
  11837. * @category Lang
  11838. * @param {*} value The value to check.
  11839. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11840. * @example
  11841. *
  11842. * _.isMap(new Map);
  11843. * // => true
  11844. *
  11845. * _.isMap(new WeakMap);
  11846. * // => false
  11847. */
  11848. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  11849. /**
  11850. * Performs a partial deep comparison between `object` and `source` to
  11851. * determine if `object` contains equivalent property values.
  11852. *
  11853. * **Note:** This method is equivalent to `_.matches` when `source` is
  11854. * partially applied.
  11855. *
  11856. * Partial comparisons will match empty array and empty object `source`
  11857. * values against any array or object value, respectively. See `_.isEqual`
  11858. * for a list of supported value comparisons.
  11859. *
  11860. * @static
  11861. * @memberOf _
  11862. * @since 3.0.0
  11863. * @category Lang
  11864. * @param {Object} object The object to inspect.
  11865. * @param {Object} source The object of property values to match.
  11866. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  11867. * @example
  11868. *
  11869. * var object = { 'a': 1, 'b': 2 };
  11870. *
  11871. * _.isMatch(object, { 'b': 2 });
  11872. * // => true
  11873. *
  11874. * _.isMatch(object, { 'b': 1 });
  11875. * // => false
  11876. */
  11877. function isMatch(object, source) {
  11878. return object === source || baseIsMatch(object, source, getMatchData(source));
  11879. }
  11880. /**
  11881. * This method is like `_.isMatch` except that it accepts `customizer` which
  11882. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  11883. * are handled by the method instead. The `customizer` is invoked with five
  11884. * arguments: (objValue, srcValue, index|key, object, source).
  11885. *
  11886. * @static
  11887. * @memberOf _
  11888. * @since 4.0.0
  11889. * @category Lang
  11890. * @param {Object} object The object to inspect.
  11891. * @param {Object} source The object of property values to match.
  11892. * @param {Function} [customizer] The function to customize comparisons.
  11893. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  11894. * @example
  11895. *
  11896. * function isGreeting(value) {
  11897. * return /^h(?:i|ello)$/.test(value);
  11898. * }
  11899. *
  11900. * function customizer(objValue, srcValue) {
  11901. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  11902. * return true;
  11903. * }
  11904. * }
  11905. *
  11906. * var object = { 'greeting': 'hello' };
  11907. * var source = { 'greeting': 'hi' };
  11908. *
  11909. * _.isMatchWith(object, source, customizer);
  11910. * // => true
  11911. */
  11912. function isMatchWith(object, source, customizer) {
  11913. customizer = typeof customizer == 'function' ? customizer : undefined;
  11914. return baseIsMatch(object, source, getMatchData(source), customizer);
  11915. }
  11916. /**
  11917. * Checks if `value` is `NaN`.
  11918. *
  11919. * **Note:** This method is based on
  11920. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  11921. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  11922. * `undefined` and other non-number values.
  11923. *
  11924. * @static
  11925. * @memberOf _
  11926. * @since 0.1.0
  11927. * @category Lang
  11928. * @param {*} value The value to check.
  11929. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  11930. * @example
  11931. *
  11932. * _.isNaN(NaN);
  11933. * // => true
  11934. *
  11935. * _.isNaN(new Number(NaN));
  11936. * // => true
  11937. *
  11938. * isNaN(undefined);
  11939. * // => true
  11940. *
  11941. * _.isNaN(undefined);
  11942. * // => false
  11943. */
  11944. function isNaN(value) {
  11945. // An `NaN` primitive is the only value that is not equal to itself.
  11946. // Perform the `toStringTag` check first to avoid errors with some
  11947. // ActiveX objects in IE.
  11948. return isNumber(value) && value != +value;
  11949. }
  11950. /**
  11951. * Checks if `value` is a pristine native function.
  11952. *
  11953. * **Note:** This method can't reliably detect native functions in the presence
  11954. * of the core-js package because core-js circumvents this kind of detection.
  11955. * Despite multiple requests, the core-js maintainer has made it clear: any
  11956. * attempt to fix the detection will be obstructed. As a result, we're left
  11957. * with little choice but to throw an error. Unfortunately, this also affects
  11958. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  11959. * which rely on core-js.
  11960. *
  11961. * @static
  11962. * @memberOf _
  11963. * @since 3.0.0
  11964. * @category Lang
  11965. * @param {*} value The value to check.
  11966. * @returns {boolean} Returns `true` if `value` is a native function,
  11967. * else `false`.
  11968. * @example
  11969. *
  11970. * _.isNative(Array.prototype.push);
  11971. * // => true
  11972. *
  11973. * _.isNative(_);
  11974. * // => false
  11975. */
  11976. function isNative(value) {
  11977. if (isMaskable(value)) {
  11978. throw new Error(CORE_ERROR_TEXT);
  11979. }
  11980. return baseIsNative(value);
  11981. }
  11982. /**
  11983. * Checks if `value` is `null`.
  11984. *
  11985. * @static
  11986. * @memberOf _
  11987. * @since 0.1.0
  11988. * @category Lang
  11989. * @param {*} value The value to check.
  11990. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  11991. * @example
  11992. *
  11993. * _.isNull(null);
  11994. * // => true
  11995. *
  11996. * _.isNull(void 0);
  11997. * // => false
  11998. */
  11999. function isNull(value) {
  12000. return value === null;
  12001. }
  12002. /**
  12003. * Checks if `value` is `null` or `undefined`.
  12004. *
  12005. * @static
  12006. * @memberOf _
  12007. * @since 4.0.0
  12008. * @category Lang
  12009. * @param {*} value The value to check.
  12010. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  12011. * @example
  12012. *
  12013. * _.isNil(null);
  12014. * // => true
  12015. *
  12016. * _.isNil(void 0);
  12017. * // => true
  12018. *
  12019. * _.isNil(NaN);
  12020. * // => false
  12021. */
  12022. function isNil(value) {
  12023. return value == null;
  12024. }
  12025. /**
  12026. * Checks if `value` is classified as a `Number` primitive or object.
  12027. *
  12028. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  12029. * classified as numbers, use the `_.isFinite` method.
  12030. *
  12031. * @static
  12032. * @memberOf _
  12033. * @since 0.1.0
  12034. * @category Lang
  12035. * @param {*} value The value to check.
  12036. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  12037. * @example
  12038. *
  12039. * _.isNumber(3);
  12040. * // => true
  12041. *
  12042. * _.isNumber(Number.MIN_VALUE);
  12043. * // => true
  12044. *
  12045. * _.isNumber(Infinity);
  12046. * // => true
  12047. *
  12048. * _.isNumber('3');
  12049. * // => false
  12050. */
  12051. function isNumber(value) {
  12052. return typeof value == 'number' ||
  12053. (isObjectLike(value) && baseGetTag(value) == numberTag);
  12054. }
  12055. /**
  12056. * Checks if `value` is a plain object, that is, an object created by the
  12057. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  12058. *
  12059. * @static
  12060. * @memberOf _
  12061. * @since 0.8.0
  12062. * @category Lang
  12063. * @param {*} value The value to check.
  12064. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  12065. * @example
  12066. *
  12067. * function Foo() {
  12068. * this.a = 1;
  12069. * }
  12070. *
  12071. * _.isPlainObject(new Foo);
  12072. * // => false
  12073. *
  12074. * _.isPlainObject([1, 2, 3]);
  12075. * // => false
  12076. *
  12077. * _.isPlainObject({ 'x': 0, 'y': 0 });
  12078. * // => true
  12079. *
  12080. * _.isPlainObject(Object.create(null));
  12081. * // => true
  12082. */
  12083. function isPlainObject(value) {
  12084. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  12085. return false;
  12086. }
  12087. var proto = getPrototype(value);
  12088. if (proto === null) {
  12089. return true;
  12090. }
  12091. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  12092. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  12093. funcToString.call(Ctor) == objectCtorString;
  12094. }
  12095. /**
  12096. * Checks if `value` is classified as a `RegExp` object.
  12097. *
  12098. * @static
  12099. * @memberOf _
  12100. * @since 0.1.0
  12101. * @category Lang
  12102. * @param {*} value The value to check.
  12103. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  12104. * @example
  12105. *
  12106. * _.isRegExp(/abc/);
  12107. * // => true
  12108. *
  12109. * _.isRegExp('/abc/');
  12110. * // => false
  12111. */
  12112. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  12113. /**
  12114. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  12115. * double precision number which isn't the result of a rounded unsafe integer.
  12116. *
  12117. * **Note:** This method is based on
  12118. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  12119. *
  12120. * @static
  12121. * @memberOf _
  12122. * @since 4.0.0
  12123. * @category Lang
  12124. * @param {*} value The value to check.
  12125. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  12126. * @example
  12127. *
  12128. * _.isSafeInteger(3);
  12129. * // => true
  12130. *
  12131. * _.isSafeInteger(Number.MIN_VALUE);
  12132. * // => false
  12133. *
  12134. * _.isSafeInteger(Infinity);
  12135. * // => false
  12136. *
  12137. * _.isSafeInteger('3');
  12138. * // => false
  12139. */
  12140. function isSafeInteger(value) {
  12141. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  12142. }
  12143. /**
  12144. * Checks if `value` is classified as a `Set` object.
  12145. *
  12146. * @static
  12147. * @memberOf _
  12148. * @since 4.3.0
  12149. * @category Lang
  12150. * @param {*} value The value to check.
  12151. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  12152. * @example
  12153. *
  12154. * _.isSet(new Set);
  12155. * // => true
  12156. *
  12157. * _.isSet(new WeakSet);
  12158. * // => false
  12159. */
  12160. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  12161. /**
  12162. * Checks if `value` is classified as a `String` primitive or object.
  12163. *
  12164. * @static
  12165. * @since 0.1.0
  12166. * @memberOf _
  12167. * @category Lang
  12168. * @param {*} value The value to check.
  12169. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  12170. * @example
  12171. *
  12172. * _.isString('abc');
  12173. * // => true
  12174. *
  12175. * _.isString(1);
  12176. * // => false
  12177. */
  12178. function isString(value) {
  12179. return typeof value == 'string' ||
  12180. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  12181. }
  12182. /**
  12183. * Checks if `value` is classified as a `Symbol` primitive or object.
  12184. *
  12185. * @static
  12186. * @memberOf _
  12187. * @since 4.0.0
  12188. * @category Lang
  12189. * @param {*} value The value to check.
  12190. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  12191. * @example
  12192. *
  12193. * _.isSymbol(Symbol.iterator);
  12194. * // => true
  12195. *
  12196. * _.isSymbol('abc');
  12197. * // => false
  12198. */
  12199. function isSymbol(value) {
  12200. return typeof value == 'symbol' ||
  12201. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  12202. }
  12203. /**
  12204. * Checks if `value` is classified as a typed array.
  12205. *
  12206. * @static
  12207. * @memberOf _
  12208. * @since 3.0.0
  12209. * @category Lang
  12210. * @param {*} value The value to check.
  12211. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  12212. * @example
  12213. *
  12214. * _.isTypedArray(new Uint8Array);
  12215. * // => true
  12216. *
  12217. * _.isTypedArray([]);
  12218. * // => false
  12219. */
  12220. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  12221. /**
  12222. * Checks if `value` is `undefined`.
  12223. *
  12224. * @static
  12225. * @since 0.1.0
  12226. * @memberOf _
  12227. * @category Lang
  12228. * @param {*} value The value to check.
  12229. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  12230. * @example
  12231. *
  12232. * _.isUndefined(void 0);
  12233. * // => true
  12234. *
  12235. * _.isUndefined(null);
  12236. * // => false
  12237. */
  12238. function isUndefined(value) {
  12239. return value === undefined;
  12240. }
  12241. /**
  12242. * Checks if `value` is classified as a `WeakMap` object.
  12243. *
  12244. * @static
  12245. * @memberOf _
  12246. * @since 4.3.0
  12247. * @category Lang
  12248. * @param {*} value The value to check.
  12249. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  12250. * @example
  12251. *
  12252. * _.isWeakMap(new WeakMap);
  12253. * // => true
  12254. *
  12255. * _.isWeakMap(new Map);
  12256. * // => false
  12257. */
  12258. function isWeakMap(value) {
  12259. return isObjectLike(value) && getTag(value) == weakMapTag;
  12260. }
  12261. /**
  12262. * Checks if `value` is classified as a `WeakSet` object.
  12263. *
  12264. * @static
  12265. * @memberOf _
  12266. * @since 4.3.0
  12267. * @category Lang
  12268. * @param {*} value The value to check.
  12269. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  12270. * @example
  12271. *
  12272. * _.isWeakSet(new WeakSet);
  12273. * // => true
  12274. *
  12275. * _.isWeakSet(new Set);
  12276. * // => false
  12277. */
  12278. function isWeakSet(value) {
  12279. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  12280. }
  12281. /**
  12282. * Checks if `value` is less than `other`.
  12283. *
  12284. * @static
  12285. * @memberOf _
  12286. * @since 3.9.0
  12287. * @category Lang
  12288. * @param {*} value The value to compare.
  12289. * @param {*} other The other value to compare.
  12290. * @returns {boolean} Returns `true` if `value` is less than `other`,
  12291. * else `false`.
  12292. * @see _.gt
  12293. * @example
  12294. *
  12295. * _.lt(1, 3);
  12296. * // => true
  12297. *
  12298. * _.lt(3, 3);
  12299. * // => false
  12300. *
  12301. * _.lt(3, 1);
  12302. * // => false
  12303. */
  12304. var lt = createRelationalOperation(baseLt);
  12305. /**
  12306. * Checks if `value` is less than or equal to `other`.
  12307. *
  12308. * @static
  12309. * @memberOf _
  12310. * @since 3.9.0
  12311. * @category Lang
  12312. * @param {*} value The value to compare.
  12313. * @param {*} other The other value to compare.
  12314. * @returns {boolean} Returns `true` if `value` is less than or equal to
  12315. * `other`, else `false`.
  12316. * @see _.gte
  12317. * @example
  12318. *
  12319. * _.lte(1, 3);
  12320. * // => true
  12321. *
  12322. * _.lte(3, 3);
  12323. * // => true
  12324. *
  12325. * _.lte(3, 1);
  12326. * // => false
  12327. */
  12328. var lte = createRelationalOperation(function(value, other) {
  12329. return value <= other;
  12330. });
  12331. /**
  12332. * Converts `value` to an array.
  12333. *
  12334. * @static
  12335. * @since 0.1.0
  12336. * @memberOf _
  12337. * @category Lang
  12338. * @param {*} value The value to convert.
  12339. * @returns {Array} Returns the converted array.
  12340. * @example
  12341. *
  12342. * _.toArray({ 'a': 1, 'b': 2 });
  12343. * // => [1, 2]
  12344. *
  12345. * _.toArray('abc');
  12346. * // => ['a', 'b', 'c']
  12347. *
  12348. * _.toArray(1);
  12349. * // => []
  12350. *
  12351. * _.toArray(null);
  12352. * // => []
  12353. */
  12354. function toArray(value) {
  12355. if (!value) {
  12356. return [];
  12357. }
  12358. if (isArrayLike(value)) {
  12359. return isString(value) ? stringToArray(value) : copyArray(value);
  12360. }
  12361. if (symIterator && value[symIterator]) {
  12362. return iteratorToArray(value[symIterator]());
  12363. }
  12364. var tag = getTag(value),
  12365. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  12366. return func(value);
  12367. }
  12368. /**
  12369. * Converts `value` to a finite number.
  12370. *
  12371. * @static
  12372. * @memberOf _
  12373. * @since 4.12.0
  12374. * @category Lang
  12375. * @param {*} value The value to convert.
  12376. * @returns {number} Returns the converted number.
  12377. * @example
  12378. *
  12379. * _.toFinite(3.2);
  12380. * // => 3.2
  12381. *
  12382. * _.toFinite(Number.MIN_VALUE);
  12383. * // => 5e-324
  12384. *
  12385. * _.toFinite(Infinity);
  12386. * // => 1.7976931348623157e+308
  12387. *
  12388. * _.toFinite('3.2');
  12389. * // => 3.2
  12390. */
  12391. function toFinite(value) {
  12392. if (!value) {
  12393. return value === 0 ? value : 0;
  12394. }
  12395. value = toNumber(value);
  12396. if (value === INFINITY || value === -INFINITY) {
  12397. var sign = (value < 0 ? -1 : 1);
  12398. return sign * MAX_INTEGER;
  12399. }
  12400. return value === value ? value : 0;
  12401. }
  12402. /**
  12403. * Converts `value` to an integer.
  12404. *
  12405. * **Note:** This method is loosely based on
  12406. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  12407. *
  12408. * @static
  12409. * @memberOf _
  12410. * @since 4.0.0
  12411. * @category Lang
  12412. * @param {*} value The value to convert.
  12413. * @returns {number} Returns the converted integer.
  12414. * @example
  12415. *
  12416. * _.toInteger(3.2);
  12417. * // => 3
  12418. *
  12419. * _.toInteger(Number.MIN_VALUE);
  12420. * // => 0
  12421. *
  12422. * _.toInteger(Infinity);
  12423. * // => 1.7976931348623157e+308
  12424. *
  12425. * _.toInteger('3.2');
  12426. * // => 3
  12427. */
  12428. function toInteger(value) {
  12429. var result = toFinite(value),
  12430. remainder = result % 1;
  12431. return result === result ? (remainder ? result - remainder : result) : 0;
  12432. }
  12433. /**
  12434. * Converts `value` to an integer suitable for use as the length of an
  12435. * array-like object.
  12436. *
  12437. * **Note:** This method is based on
  12438. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  12439. *
  12440. * @static
  12441. * @memberOf _
  12442. * @since 4.0.0
  12443. * @category Lang
  12444. * @param {*} value The value to convert.
  12445. * @returns {number} Returns the converted integer.
  12446. * @example
  12447. *
  12448. * _.toLength(3.2);
  12449. * // => 3
  12450. *
  12451. * _.toLength(Number.MIN_VALUE);
  12452. * // => 0
  12453. *
  12454. * _.toLength(Infinity);
  12455. * // => 4294967295
  12456. *
  12457. * _.toLength('3.2');
  12458. * // => 3
  12459. */
  12460. function toLength(value) {
  12461. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  12462. }
  12463. /**
  12464. * Converts `value` to a number.
  12465. *
  12466. * @static
  12467. * @memberOf _
  12468. * @since 4.0.0
  12469. * @category Lang
  12470. * @param {*} value The value to process.
  12471. * @returns {number} Returns the number.
  12472. * @example
  12473. *
  12474. * _.toNumber(3.2);
  12475. * // => 3.2
  12476. *
  12477. * _.toNumber(Number.MIN_VALUE);
  12478. * // => 5e-324
  12479. *
  12480. * _.toNumber(Infinity);
  12481. * // => Infinity
  12482. *
  12483. * _.toNumber('3.2');
  12484. * // => 3.2
  12485. */
  12486. function toNumber(value) {
  12487. if (typeof value == 'number') {
  12488. return value;
  12489. }
  12490. if (isSymbol(value)) {
  12491. return NAN;
  12492. }
  12493. if (isObject(value)) {
  12494. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  12495. value = isObject(other) ? (other + '') : other;
  12496. }
  12497. if (typeof value != 'string') {
  12498. return value === 0 ? value : +value;
  12499. }
  12500. value = value.replace(reTrim, '');
  12501. var isBinary = reIsBinary.test(value);
  12502. return (isBinary || reIsOctal.test(value))
  12503. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  12504. : (reIsBadHex.test(value) ? NAN : +value);
  12505. }
  12506. /**
  12507. * Converts `value` to a plain object flattening inherited enumerable string
  12508. * keyed properties of `value` to own properties of the plain object.
  12509. *
  12510. * @static
  12511. * @memberOf _
  12512. * @since 3.0.0
  12513. * @category Lang
  12514. * @param {*} value The value to convert.
  12515. * @returns {Object} Returns the converted plain object.
  12516. * @example
  12517. *
  12518. * function Foo() {
  12519. * this.b = 2;
  12520. * }
  12521. *
  12522. * Foo.prototype.c = 3;
  12523. *
  12524. * _.assign({ 'a': 1 }, new Foo);
  12525. * // => { 'a': 1, 'b': 2 }
  12526. *
  12527. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  12528. * // => { 'a': 1, 'b': 2, 'c': 3 }
  12529. */
  12530. function toPlainObject(value) {
  12531. return copyObject(value, keysIn(value));
  12532. }
  12533. /**
  12534. * Converts `value` to a safe integer. A safe integer can be compared and
  12535. * represented correctly.
  12536. *
  12537. * @static
  12538. * @memberOf _
  12539. * @since 4.0.0
  12540. * @category Lang
  12541. * @param {*} value The value to convert.
  12542. * @returns {number} Returns the converted integer.
  12543. * @example
  12544. *
  12545. * _.toSafeInteger(3.2);
  12546. * // => 3
  12547. *
  12548. * _.toSafeInteger(Number.MIN_VALUE);
  12549. * // => 0
  12550. *
  12551. * _.toSafeInteger(Infinity);
  12552. * // => 9007199254740991
  12553. *
  12554. * _.toSafeInteger('3.2');
  12555. * // => 3
  12556. */
  12557. function toSafeInteger(value) {
  12558. return value
  12559. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  12560. : (value === 0 ? value : 0);
  12561. }
  12562. /**
  12563. * Converts `value` to a string. An empty string is returned for `null`
  12564. * and `undefined` values. The sign of `-0` is preserved.
  12565. *
  12566. * @static
  12567. * @memberOf _
  12568. * @since 4.0.0
  12569. * @category Lang
  12570. * @param {*} value The value to convert.
  12571. * @returns {string} Returns the converted string.
  12572. * @example
  12573. *
  12574. * _.toString(null);
  12575. * // => ''
  12576. *
  12577. * _.toString(-0);
  12578. * // => '-0'
  12579. *
  12580. * _.toString([1, 2, 3]);
  12581. * // => '1,2,3'
  12582. */
  12583. function toString(value) {
  12584. return value == null ? '' : baseToString(value);
  12585. }
  12586. /*------------------------------------------------------------------------*/
  12587. /**
  12588. * Assigns own enumerable string keyed properties of source objects to the
  12589. * destination object. Source objects are applied from left to right.
  12590. * Subsequent sources overwrite property assignments of previous sources.
  12591. *
  12592. * **Note:** This method mutates `object` and is loosely based on
  12593. * [`Object.assign`](https://mdn.io/Object/assign).
  12594. *
  12595. * @static
  12596. * @memberOf _
  12597. * @since 0.10.0
  12598. * @category Object
  12599. * @param {Object} object The destination object.
  12600. * @param {...Object} [sources] The source objects.
  12601. * @returns {Object} Returns `object`.
  12602. * @see _.assignIn
  12603. * @example
  12604. *
  12605. * function Foo() {
  12606. * this.a = 1;
  12607. * }
  12608. *
  12609. * function Bar() {
  12610. * this.c = 3;
  12611. * }
  12612. *
  12613. * Foo.prototype.b = 2;
  12614. * Bar.prototype.d = 4;
  12615. *
  12616. * _.assign({ 'a': 0 }, new Foo, new Bar);
  12617. * // => { 'a': 1, 'c': 3 }
  12618. */
  12619. var assign = createAssigner(function(object, source) {
  12620. if (isPrototype(source) || isArrayLike(source)) {
  12621. copyObject(source, keys(source), object);
  12622. return;
  12623. }
  12624. for (var key in source) {
  12625. if (hasOwnProperty.call(source, key)) {
  12626. assignValue(object, key, source[key]);
  12627. }
  12628. }
  12629. });
  12630. /**
  12631. * This method is like `_.assign` except that it iterates over own and
  12632. * inherited source properties.
  12633. *
  12634. * **Note:** This method mutates `object`.
  12635. *
  12636. * @static
  12637. * @memberOf _
  12638. * @since 4.0.0
  12639. * @alias extend
  12640. * @category Object
  12641. * @param {Object} object The destination object.
  12642. * @param {...Object} [sources] The source objects.
  12643. * @returns {Object} Returns `object`.
  12644. * @see _.assign
  12645. * @example
  12646. *
  12647. * function Foo() {
  12648. * this.a = 1;
  12649. * }
  12650. *
  12651. * function Bar() {
  12652. * this.c = 3;
  12653. * }
  12654. *
  12655. * Foo.prototype.b = 2;
  12656. * Bar.prototype.d = 4;
  12657. *
  12658. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  12659. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  12660. */
  12661. var assignIn = createAssigner(function(object, source) {
  12662. copyObject(source, keysIn(source), object);
  12663. });
  12664. /**
  12665. * This method is like `_.assignIn` except that it accepts `customizer`
  12666. * which is invoked to produce the assigned values. If `customizer` returns
  12667. * `undefined`, assignment is handled by the method instead. The `customizer`
  12668. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  12669. *
  12670. * **Note:** This method mutates `object`.
  12671. *
  12672. * @static
  12673. * @memberOf _
  12674. * @since 4.0.0
  12675. * @alias extendWith
  12676. * @category Object
  12677. * @param {Object} object The destination object.
  12678. * @param {...Object} sources The source objects.
  12679. * @param {Function} [customizer] The function to customize assigned values.
  12680. * @returns {Object} Returns `object`.
  12681. * @see _.assignWith
  12682. * @example
  12683. *
  12684. * function customizer(objValue, srcValue) {
  12685. * return _.isUndefined(objValue) ? srcValue : objValue;
  12686. * }
  12687. *
  12688. * var defaults = _.partialRight(_.assignInWith, customizer);
  12689. *
  12690. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12691. * // => { 'a': 1, 'b': 2 }
  12692. */
  12693. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  12694. copyObject(source, keysIn(source), object, customizer);
  12695. });
  12696. /**
  12697. * This method is like `_.assign` except that it accepts `customizer`
  12698. * which is invoked to produce the assigned values. If `customizer` returns
  12699. * `undefined`, assignment is handled by the method instead. The `customizer`
  12700. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  12701. *
  12702. * **Note:** This method mutates `object`.
  12703. *
  12704. * @static
  12705. * @memberOf _
  12706. * @since 4.0.0
  12707. * @category Object
  12708. * @param {Object} object The destination object.
  12709. * @param {...Object} sources The source objects.
  12710. * @param {Function} [customizer] The function to customize assigned values.
  12711. * @returns {Object} Returns `object`.
  12712. * @see _.assignInWith
  12713. * @example
  12714. *
  12715. * function customizer(objValue, srcValue) {
  12716. * return _.isUndefined(objValue) ? srcValue : objValue;
  12717. * }
  12718. *
  12719. * var defaults = _.partialRight(_.assignWith, customizer);
  12720. *
  12721. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12722. * // => { 'a': 1, 'b': 2 }
  12723. */
  12724. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  12725. copyObject(source, keys(source), object, customizer);
  12726. });
  12727. /**
  12728. * Creates an array of values corresponding to `paths` of `object`.
  12729. *
  12730. * @static
  12731. * @memberOf _
  12732. * @since 1.0.0
  12733. * @category Object
  12734. * @param {Object} object The object to iterate over.
  12735. * @param {...(string|string[])} [paths] The property paths to pick.
  12736. * @returns {Array} Returns the picked values.
  12737. * @example
  12738. *
  12739. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  12740. *
  12741. * _.at(object, ['a[0].b.c', 'a[1]']);
  12742. * // => [3, 4]
  12743. */
  12744. var at = flatRest(baseAt);
  12745. /**
  12746. * Creates an object that inherits from the `prototype` object. If a
  12747. * `properties` object is given, its own enumerable string keyed properties
  12748. * are assigned to the created object.
  12749. *
  12750. * @static
  12751. * @memberOf _
  12752. * @since 2.3.0
  12753. * @category Object
  12754. * @param {Object} prototype The object to inherit from.
  12755. * @param {Object} [properties] The properties to assign to the object.
  12756. * @returns {Object} Returns the new object.
  12757. * @example
  12758. *
  12759. * function Shape() {
  12760. * this.x = 0;
  12761. * this.y = 0;
  12762. * }
  12763. *
  12764. * function Circle() {
  12765. * Shape.call(this);
  12766. * }
  12767. *
  12768. * Circle.prototype = _.create(Shape.prototype, {
  12769. * 'constructor': Circle
  12770. * });
  12771. *
  12772. * var circle = new Circle;
  12773. * circle instanceof Circle;
  12774. * // => true
  12775. *
  12776. * circle instanceof Shape;
  12777. * // => true
  12778. */
  12779. function create(prototype, properties) {
  12780. var result = baseCreate(prototype);
  12781. return properties == null ? result : baseAssign(result, properties);
  12782. }
  12783. /**
  12784. * Assigns own and inherited enumerable string keyed properties of source
  12785. * objects to the destination object for all destination properties that
  12786. * resolve to `undefined`. Source objects are applied from left to right.
  12787. * Once a property is set, additional values of the same property are ignored.
  12788. *
  12789. * **Note:** This method mutates `object`.
  12790. *
  12791. * @static
  12792. * @since 0.1.0
  12793. * @memberOf _
  12794. * @category Object
  12795. * @param {Object} object The destination object.
  12796. * @param {...Object} [sources] The source objects.
  12797. * @returns {Object} Returns `object`.
  12798. * @see _.defaultsDeep
  12799. * @example
  12800. *
  12801. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12802. * // => { 'a': 1, 'b': 2 }
  12803. */
  12804. var defaults = baseRest(function(args) {
  12805. args.push(undefined, customDefaultsAssignIn);
  12806. return apply(assignInWith, undefined, args);
  12807. });
  12808. /**
  12809. * This method is like `_.defaults` except that it recursively assigns
  12810. * default properties.
  12811. *
  12812. * **Note:** This method mutates `object`.
  12813. *
  12814. * @static
  12815. * @memberOf _
  12816. * @since 3.10.0
  12817. * @category Object
  12818. * @param {Object} object The destination object.
  12819. * @param {...Object} [sources] The source objects.
  12820. * @returns {Object} Returns `object`.
  12821. * @see _.defaults
  12822. * @example
  12823. *
  12824. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  12825. * // => { 'a': { 'b': 2, 'c': 3 } }
  12826. */
  12827. var defaultsDeep = baseRest(function(args) {
  12828. args.push(undefined, customDefaultsMerge);
  12829. return apply(mergeWith, undefined, args);
  12830. });
  12831. /**
  12832. * This method is like `_.find` except that it returns the key of the first
  12833. * element `predicate` returns truthy for instead of the element itself.
  12834. *
  12835. * @static
  12836. * @memberOf _
  12837. * @since 1.1.0
  12838. * @category Object
  12839. * @param {Object} object The object to inspect.
  12840. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12841. * @returns {string|undefined} Returns the key of the matched element,
  12842. * else `undefined`.
  12843. * @example
  12844. *
  12845. * var users = {
  12846. * 'barney': { 'age': 36, 'active': true },
  12847. * 'fred': { 'age': 40, 'active': false },
  12848. * 'pebbles': { 'age': 1, 'active': true }
  12849. * };
  12850. *
  12851. * _.findKey(users, function(o) { return o.age < 40; });
  12852. * // => 'barney' (iteration order is not guaranteed)
  12853. *
  12854. * // The `_.matches` iteratee shorthand.
  12855. * _.findKey(users, { 'age': 1, 'active': true });
  12856. * // => 'pebbles'
  12857. *
  12858. * // The `_.matchesProperty` iteratee shorthand.
  12859. * _.findKey(users, ['active', false]);
  12860. * // => 'fred'
  12861. *
  12862. * // The `_.property` iteratee shorthand.
  12863. * _.findKey(users, 'active');
  12864. * // => 'barney'
  12865. */
  12866. function findKey(object, predicate) {
  12867. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  12868. }
  12869. /**
  12870. * This method is like `_.findKey` except that it iterates over elements of
  12871. * a collection in the opposite order.
  12872. *
  12873. * @static
  12874. * @memberOf _
  12875. * @since 2.0.0
  12876. * @category Object
  12877. * @param {Object} object The object to inspect.
  12878. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12879. * @returns {string|undefined} Returns the key of the matched element,
  12880. * else `undefined`.
  12881. * @example
  12882. *
  12883. * var users = {
  12884. * 'barney': { 'age': 36, 'active': true },
  12885. * 'fred': { 'age': 40, 'active': false },
  12886. * 'pebbles': { 'age': 1, 'active': true }
  12887. * };
  12888. *
  12889. * _.findLastKey(users, function(o) { return o.age < 40; });
  12890. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  12891. *
  12892. * // The `_.matches` iteratee shorthand.
  12893. * _.findLastKey(users, { 'age': 36, 'active': true });
  12894. * // => 'barney'
  12895. *
  12896. * // The `_.matchesProperty` iteratee shorthand.
  12897. * _.findLastKey(users, ['active', false]);
  12898. * // => 'fred'
  12899. *
  12900. * // The `_.property` iteratee shorthand.
  12901. * _.findLastKey(users, 'active');
  12902. * // => 'pebbles'
  12903. */
  12904. function findLastKey(object, predicate) {
  12905. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  12906. }
  12907. /**
  12908. * Iterates over own and inherited enumerable string keyed properties of an
  12909. * object and invokes `iteratee` for each property. The iteratee is invoked
  12910. * with three arguments: (value, key, object). Iteratee functions may exit
  12911. * iteration early by explicitly returning `false`.
  12912. *
  12913. * @static
  12914. * @memberOf _
  12915. * @since 0.3.0
  12916. * @category Object
  12917. * @param {Object} object The object to iterate over.
  12918. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12919. * @returns {Object} Returns `object`.
  12920. * @see _.forInRight
  12921. * @example
  12922. *
  12923. * function Foo() {
  12924. * this.a = 1;
  12925. * this.b = 2;
  12926. * }
  12927. *
  12928. * Foo.prototype.c = 3;
  12929. *
  12930. * _.forIn(new Foo, function(value, key) {
  12931. * console.log(key);
  12932. * });
  12933. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  12934. */
  12935. function forIn(object, iteratee) {
  12936. return object == null
  12937. ? object
  12938. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  12939. }
  12940. /**
  12941. * This method is like `_.forIn` except that it iterates over properties of
  12942. * `object` in the opposite order.
  12943. *
  12944. * @static
  12945. * @memberOf _
  12946. * @since 2.0.0
  12947. * @category Object
  12948. * @param {Object} object The object to iterate over.
  12949. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12950. * @returns {Object} Returns `object`.
  12951. * @see _.forIn
  12952. * @example
  12953. *
  12954. * function Foo() {
  12955. * this.a = 1;
  12956. * this.b = 2;
  12957. * }
  12958. *
  12959. * Foo.prototype.c = 3;
  12960. *
  12961. * _.forInRight(new Foo, function(value, key) {
  12962. * console.log(key);
  12963. * });
  12964. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  12965. */
  12966. function forInRight(object, iteratee) {
  12967. return object == null
  12968. ? object
  12969. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  12970. }
  12971. /**
  12972. * Iterates over own enumerable string keyed properties of an object and
  12973. * invokes `iteratee` for each property. The iteratee is invoked with three
  12974. * arguments: (value, key, object). Iteratee functions may exit iteration
  12975. * early by explicitly returning `false`.
  12976. *
  12977. * @static
  12978. * @memberOf _
  12979. * @since 0.3.0
  12980. * @category Object
  12981. * @param {Object} object The object to iterate over.
  12982. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12983. * @returns {Object} Returns `object`.
  12984. * @see _.forOwnRight
  12985. * @example
  12986. *
  12987. * function Foo() {
  12988. * this.a = 1;
  12989. * this.b = 2;
  12990. * }
  12991. *
  12992. * Foo.prototype.c = 3;
  12993. *
  12994. * _.forOwn(new Foo, function(value, key) {
  12995. * console.log(key);
  12996. * });
  12997. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  12998. */
  12999. function forOwn(object, iteratee) {
  13000. return object && baseForOwn(object, getIteratee(iteratee, 3));
  13001. }
  13002. /**
  13003. * This method is like `_.forOwn` except that it iterates over properties of
  13004. * `object` in the opposite order.
  13005. *
  13006. * @static
  13007. * @memberOf _
  13008. * @since 2.0.0
  13009. * @category Object
  13010. * @param {Object} object The object to iterate over.
  13011. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13012. * @returns {Object} Returns `object`.
  13013. * @see _.forOwn
  13014. * @example
  13015. *
  13016. * function Foo() {
  13017. * this.a = 1;
  13018. * this.b = 2;
  13019. * }
  13020. *
  13021. * Foo.prototype.c = 3;
  13022. *
  13023. * _.forOwnRight(new Foo, function(value, key) {
  13024. * console.log(key);
  13025. * });
  13026. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  13027. */
  13028. function forOwnRight(object, iteratee) {
  13029. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  13030. }
  13031. /**
  13032. * Creates an array of function property names from own enumerable properties
  13033. * of `object`.
  13034. *
  13035. * @static
  13036. * @since 0.1.0
  13037. * @memberOf _
  13038. * @category Object
  13039. * @param {Object} object The object to inspect.
  13040. * @returns {Array} Returns the function names.
  13041. * @see _.functionsIn
  13042. * @example
  13043. *
  13044. * function Foo() {
  13045. * this.a = _.constant('a');
  13046. * this.b = _.constant('b');
  13047. * }
  13048. *
  13049. * Foo.prototype.c = _.constant('c');
  13050. *
  13051. * _.functions(new Foo);
  13052. * // => ['a', 'b']
  13053. */
  13054. function functions(object) {
  13055. return object == null ? [] : baseFunctions(object, keys(object));
  13056. }
  13057. /**
  13058. * Creates an array of function property names from own and inherited
  13059. * enumerable properties of `object`.
  13060. *
  13061. * @static
  13062. * @memberOf _
  13063. * @since 4.0.0
  13064. * @category Object
  13065. * @param {Object} object The object to inspect.
  13066. * @returns {Array} Returns the function names.
  13067. * @see _.functions
  13068. * @example
  13069. *
  13070. * function Foo() {
  13071. * this.a = _.constant('a');
  13072. * this.b = _.constant('b');
  13073. * }
  13074. *
  13075. * Foo.prototype.c = _.constant('c');
  13076. *
  13077. * _.functionsIn(new Foo);
  13078. * // => ['a', 'b', 'c']
  13079. */
  13080. function functionsIn(object) {
  13081. return object == null ? [] : baseFunctions(object, keysIn(object));
  13082. }
  13083. /**
  13084. * Gets the value at `path` of `object`. If the resolved value is
  13085. * `undefined`, the `defaultValue` is returned in its place.
  13086. *
  13087. * @static
  13088. * @memberOf _
  13089. * @since 3.7.0
  13090. * @category Object
  13091. * @param {Object} object The object to query.
  13092. * @param {Array|string} path The path of the property to get.
  13093. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13094. * @returns {*} Returns the resolved value.
  13095. * @example
  13096. *
  13097. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13098. *
  13099. * _.get(object, 'a[0].b.c');
  13100. * // => 3
  13101. *
  13102. * _.get(object, ['a', '0', 'b', 'c']);
  13103. * // => 3
  13104. *
  13105. * _.get(object, 'a.b.c', 'default');
  13106. * // => 'default'
  13107. */
  13108. function get(object, path, defaultValue) {
  13109. var result = object == null ? undefined : baseGet(object, path);
  13110. return result === undefined ? defaultValue : result;
  13111. }
  13112. /**
  13113. * Checks if `path` is a direct property of `object`.
  13114. *
  13115. * @static
  13116. * @since 0.1.0
  13117. * @memberOf _
  13118. * @category Object
  13119. * @param {Object} object The object to query.
  13120. * @param {Array|string} path The path to check.
  13121. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13122. * @example
  13123. *
  13124. * var object = { 'a': { 'b': 2 } };
  13125. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  13126. *
  13127. * _.has(object, 'a');
  13128. * // => true
  13129. *
  13130. * _.has(object, 'a.b');
  13131. * // => true
  13132. *
  13133. * _.has(object, ['a', 'b']);
  13134. * // => true
  13135. *
  13136. * _.has(other, 'a');
  13137. * // => false
  13138. */
  13139. function has(object, path) {
  13140. return object != null && hasPath(object, path, baseHas);
  13141. }
  13142. /**
  13143. * Checks if `path` is a direct or inherited property of `object`.
  13144. *
  13145. * @static
  13146. * @memberOf _
  13147. * @since 4.0.0
  13148. * @category Object
  13149. * @param {Object} object The object to query.
  13150. * @param {Array|string} path The path to check.
  13151. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13152. * @example
  13153. *
  13154. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  13155. *
  13156. * _.hasIn(object, 'a');
  13157. * // => true
  13158. *
  13159. * _.hasIn(object, 'a.b');
  13160. * // => true
  13161. *
  13162. * _.hasIn(object, ['a', 'b']);
  13163. * // => true
  13164. *
  13165. * _.hasIn(object, 'b');
  13166. * // => false
  13167. */
  13168. function hasIn(object, path) {
  13169. return object != null && hasPath(object, path, baseHasIn);
  13170. }
  13171. /**
  13172. * Creates an object composed of the inverted keys and values of `object`.
  13173. * If `object` contains duplicate values, subsequent values overwrite
  13174. * property assignments of previous values.
  13175. *
  13176. * @static
  13177. * @memberOf _
  13178. * @since 0.7.0
  13179. * @category Object
  13180. * @param {Object} object The object to invert.
  13181. * @returns {Object} Returns the new inverted object.
  13182. * @example
  13183. *
  13184. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13185. *
  13186. * _.invert(object);
  13187. * // => { '1': 'c', '2': 'b' }
  13188. */
  13189. var invert = createInverter(function(result, value, key) {
  13190. result[value] = key;
  13191. }, constant(identity));
  13192. /**
  13193. * This method is like `_.invert` except that the inverted object is generated
  13194. * from the results of running each element of `object` thru `iteratee`. The
  13195. * corresponding inverted value of each inverted key is an array of keys
  13196. * responsible for generating the inverted value. The iteratee is invoked
  13197. * with one argument: (value).
  13198. *
  13199. * @static
  13200. * @memberOf _
  13201. * @since 4.1.0
  13202. * @category Object
  13203. * @param {Object} object The object to invert.
  13204. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13205. * @returns {Object} Returns the new inverted object.
  13206. * @example
  13207. *
  13208. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13209. *
  13210. * _.invertBy(object);
  13211. * // => { '1': ['a', 'c'], '2': ['b'] }
  13212. *
  13213. * _.invertBy(object, function(value) {
  13214. * return 'group' + value;
  13215. * });
  13216. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  13217. */
  13218. var invertBy = createInverter(function(result, value, key) {
  13219. if (hasOwnProperty.call(result, value)) {
  13220. result[value].push(key);
  13221. } else {
  13222. result[value] = [key];
  13223. }
  13224. }, getIteratee);
  13225. /**
  13226. * Invokes the method at `path` of `object`.
  13227. *
  13228. * @static
  13229. * @memberOf _
  13230. * @since 4.0.0
  13231. * @category Object
  13232. * @param {Object} object The object to query.
  13233. * @param {Array|string} path The path of the method to invoke.
  13234. * @param {...*} [args] The arguments to invoke the method with.
  13235. * @returns {*} Returns the result of the invoked method.
  13236. * @example
  13237. *
  13238. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  13239. *
  13240. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  13241. * // => [2, 3]
  13242. */
  13243. var invoke = baseRest(baseInvoke);
  13244. /**
  13245. * Creates an array of the own enumerable property names of `object`.
  13246. *
  13247. * **Note:** Non-object values are coerced to objects. See the
  13248. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  13249. * for more details.
  13250. *
  13251. * @static
  13252. * @since 0.1.0
  13253. * @memberOf _
  13254. * @category Object
  13255. * @param {Object} object The object to query.
  13256. * @returns {Array} Returns the array of property names.
  13257. * @example
  13258. *
  13259. * function Foo() {
  13260. * this.a = 1;
  13261. * this.b = 2;
  13262. * }
  13263. *
  13264. * Foo.prototype.c = 3;
  13265. *
  13266. * _.keys(new Foo);
  13267. * // => ['a', 'b'] (iteration order is not guaranteed)
  13268. *
  13269. * _.keys('hi');
  13270. * // => ['0', '1']
  13271. */
  13272. function keys(object) {
  13273. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  13274. }
  13275. /**
  13276. * Creates an array of the own and inherited enumerable property names of `object`.
  13277. *
  13278. * **Note:** Non-object values are coerced to objects.
  13279. *
  13280. * @static
  13281. * @memberOf _
  13282. * @since 3.0.0
  13283. * @category Object
  13284. * @param {Object} object The object to query.
  13285. * @returns {Array} Returns the array of property names.
  13286. * @example
  13287. *
  13288. * function Foo() {
  13289. * this.a = 1;
  13290. * this.b = 2;
  13291. * }
  13292. *
  13293. * Foo.prototype.c = 3;
  13294. *
  13295. * _.keysIn(new Foo);
  13296. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  13297. */
  13298. function keysIn(object) {
  13299. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  13300. }
  13301. /**
  13302. * The opposite of `_.mapValues`; this method creates an object with the
  13303. * same values as `object` and keys generated by running each own enumerable
  13304. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  13305. * with three arguments: (value, key, object).
  13306. *
  13307. * @static
  13308. * @memberOf _
  13309. * @since 3.8.0
  13310. * @category Object
  13311. * @param {Object} object The object to iterate over.
  13312. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13313. * @returns {Object} Returns the new mapped object.
  13314. * @see _.mapValues
  13315. * @example
  13316. *
  13317. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  13318. * return key + value;
  13319. * });
  13320. * // => { 'a1': 1, 'b2': 2 }
  13321. */
  13322. function mapKeys(object, iteratee) {
  13323. var result = {};
  13324. iteratee = getIteratee(iteratee, 3);
  13325. baseForOwn(object, function(value, key, object) {
  13326. baseAssignValue(result, iteratee(value, key, object), value);
  13327. });
  13328. return result;
  13329. }
  13330. /**
  13331. * Creates an object with the same keys as `object` and values generated
  13332. * by running each own enumerable string keyed property of `object` thru
  13333. * `iteratee`. The iteratee is invoked with three arguments:
  13334. * (value, key, object).
  13335. *
  13336. * @static
  13337. * @memberOf _
  13338. * @since 2.4.0
  13339. * @category Object
  13340. * @param {Object} object The object to iterate over.
  13341. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13342. * @returns {Object} Returns the new mapped object.
  13343. * @see _.mapKeys
  13344. * @example
  13345. *
  13346. * var users = {
  13347. * 'fred': { 'user': 'fred', 'age': 40 },
  13348. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  13349. * };
  13350. *
  13351. * _.mapValues(users, function(o) { return o.age; });
  13352. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  13353. *
  13354. * // The `_.property` iteratee shorthand.
  13355. * _.mapValues(users, 'age');
  13356. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  13357. */
  13358. function mapValues(object, iteratee) {
  13359. var result = {};
  13360. iteratee = getIteratee(iteratee, 3);
  13361. baseForOwn(object, function(value, key, object) {
  13362. baseAssignValue(result, key, iteratee(value, key, object));
  13363. });
  13364. return result;
  13365. }
  13366. /**
  13367. * This method is like `_.assign` except that it recursively merges own and
  13368. * inherited enumerable string keyed properties of source objects into the
  13369. * destination object. Source properties that resolve to `undefined` are
  13370. * skipped if a destination value exists. Array and plain object properties
  13371. * are merged recursively. Other objects and value types are overridden by
  13372. * assignment. Source objects are applied from left to right. Subsequent
  13373. * sources overwrite property assignments of previous sources.
  13374. *
  13375. * **Note:** This method mutates `object`.
  13376. *
  13377. * @static
  13378. * @memberOf _
  13379. * @since 0.5.0
  13380. * @category Object
  13381. * @param {Object} object The destination object.
  13382. * @param {...Object} [sources] The source objects.
  13383. * @returns {Object} Returns `object`.
  13384. * @example
  13385. *
  13386. * var object = {
  13387. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  13388. * };
  13389. *
  13390. * var other = {
  13391. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  13392. * };
  13393. *
  13394. * _.merge(object, other);
  13395. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  13396. */
  13397. var merge = createAssigner(function(object, source, srcIndex) {
  13398. baseMerge(object, source, srcIndex);
  13399. });
  13400. /**
  13401. * This method is like `_.merge` except that it accepts `customizer` which
  13402. * is invoked to produce the merged values of the destination and source
  13403. * properties. If `customizer` returns `undefined`, merging is handled by the
  13404. * method instead. The `customizer` is invoked with six arguments:
  13405. * (objValue, srcValue, key, object, source, stack).
  13406. *
  13407. * **Note:** This method mutates `object`.
  13408. *
  13409. * @static
  13410. * @memberOf _
  13411. * @since 4.0.0
  13412. * @category Object
  13413. * @param {Object} object The destination object.
  13414. * @param {...Object} sources The source objects.
  13415. * @param {Function} customizer The function to customize assigned values.
  13416. * @returns {Object} Returns `object`.
  13417. * @example
  13418. *
  13419. * function customizer(objValue, srcValue) {
  13420. * if (_.isArray(objValue)) {
  13421. * return objValue.concat(srcValue);
  13422. * }
  13423. * }
  13424. *
  13425. * var object = { 'a': [1], 'b': [2] };
  13426. * var other = { 'a': [3], 'b': [4] };
  13427. *
  13428. * _.mergeWith(object, other, customizer);
  13429. * // => { 'a': [1, 3], 'b': [2, 4] }
  13430. */
  13431. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  13432. baseMerge(object, source, srcIndex, customizer);
  13433. });
  13434. /**
  13435. * The opposite of `_.pick`; this method creates an object composed of the
  13436. * own and inherited enumerable property paths of `object` that are not omitted.
  13437. *
  13438. * **Note:** This method is considerably slower than `_.pick`.
  13439. *
  13440. * @static
  13441. * @since 0.1.0
  13442. * @memberOf _
  13443. * @category Object
  13444. * @param {Object} object The source object.
  13445. * @param {...(string|string[])} [paths] The property paths to omit.
  13446. * @returns {Object} Returns the new object.
  13447. * @example
  13448. *
  13449. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13450. *
  13451. * _.omit(object, ['a', 'c']);
  13452. * // => { 'b': '2' }
  13453. */
  13454. var omit = flatRest(function(object, paths) {
  13455. var result = {};
  13456. if (object == null) {
  13457. return result;
  13458. }
  13459. var isDeep = false;
  13460. paths = arrayMap(paths, function(path) {
  13461. path = castPath(path, object);
  13462. isDeep || (isDeep = path.length > 1);
  13463. return path;
  13464. });
  13465. copyObject(object, getAllKeysIn(object), result);
  13466. if (isDeep) {
  13467. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  13468. }
  13469. var length = paths.length;
  13470. while (length--) {
  13471. baseUnset(result, paths[length]);
  13472. }
  13473. return result;
  13474. });
  13475. /**
  13476. * The opposite of `_.pickBy`; this method creates an object composed of
  13477. * the own and inherited enumerable string keyed properties of `object` that
  13478. * `predicate` doesn't return truthy for. The predicate is invoked with two
  13479. * arguments: (value, key).
  13480. *
  13481. * @static
  13482. * @memberOf _
  13483. * @since 4.0.0
  13484. * @category Object
  13485. * @param {Object} object The source object.
  13486. * @param {Function} [predicate=_.identity] The function invoked per property.
  13487. * @returns {Object} Returns the new object.
  13488. * @example
  13489. *
  13490. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13491. *
  13492. * _.omitBy(object, _.isNumber);
  13493. * // => { 'b': '2' }
  13494. */
  13495. function omitBy(object, predicate) {
  13496. return pickBy(object, negate(getIteratee(predicate)));
  13497. }
  13498. /**
  13499. * Creates an object composed of the picked `object` properties.
  13500. *
  13501. * @static
  13502. * @since 0.1.0
  13503. * @memberOf _
  13504. * @category Object
  13505. * @param {Object} object The source object.
  13506. * @param {...(string|string[])} [paths] The property paths to pick.
  13507. * @returns {Object} Returns the new object.
  13508. * @example
  13509. *
  13510. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13511. *
  13512. * _.pick(object, ['a', 'c']);
  13513. * // => { 'a': 1, 'c': 3 }
  13514. */
  13515. var pick = flatRest(function(object, paths) {
  13516. return object == null ? {} : basePick(object, paths);
  13517. });
  13518. /**
  13519. * Creates an object composed of the `object` properties `predicate` returns
  13520. * truthy for. The predicate is invoked with two arguments: (value, key).
  13521. *
  13522. * @static
  13523. * @memberOf _
  13524. * @since 4.0.0
  13525. * @category Object
  13526. * @param {Object} object The source object.
  13527. * @param {Function} [predicate=_.identity] The function invoked per property.
  13528. * @returns {Object} Returns the new object.
  13529. * @example
  13530. *
  13531. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13532. *
  13533. * _.pickBy(object, _.isNumber);
  13534. * // => { 'a': 1, 'c': 3 }
  13535. */
  13536. function pickBy(object, predicate) {
  13537. if (object == null) {
  13538. return {};
  13539. }
  13540. var props = arrayMap(getAllKeysIn(object), function(prop) {
  13541. return [prop];
  13542. });
  13543. predicate = getIteratee(predicate);
  13544. return basePickBy(object, props, function(value, path) {
  13545. return predicate(value, path[0]);
  13546. });
  13547. }
  13548. /**
  13549. * This method is like `_.get` except that if the resolved value is a
  13550. * function it's invoked with the `this` binding of its parent object and
  13551. * its result is returned.
  13552. *
  13553. * @static
  13554. * @since 0.1.0
  13555. * @memberOf _
  13556. * @category Object
  13557. * @param {Object} object The object to query.
  13558. * @param {Array|string} path The path of the property to resolve.
  13559. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13560. * @returns {*} Returns the resolved value.
  13561. * @example
  13562. *
  13563. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  13564. *
  13565. * _.result(object, 'a[0].b.c1');
  13566. * // => 3
  13567. *
  13568. * _.result(object, 'a[0].b.c2');
  13569. * // => 4
  13570. *
  13571. * _.result(object, 'a[0].b.c3', 'default');
  13572. * // => 'default'
  13573. *
  13574. * _.result(object, 'a[0].b.c3', _.constant('default'));
  13575. * // => 'default'
  13576. */
  13577. function result(object, path, defaultValue) {
  13578. path = castPath(path, object);
  13579. var index = -1,
  13580. length = path.length;
  13581. // Ensure the loop is entered when path is empty.
  13582. if (!length) {
  13583. length = 1;
  13584. object = undefined;
  13585. }
  13586. while (++index < length) {
  13587. var value = object == null ? undefined : object[toKey(path[index])];
  13588. if (value === undefined) {
  13589. index = length;
  13590. value = defaultValue;
  13591. }
  13592. object = isFunction(value) ? value.call(object) : value;
  13593. }
  13594. return object;
  13595. }
  13596. /**
  13597. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  13598. * it's created. Arrays are created for missing index properties while objects
  13599. * are created for all other missing properties. Use `_.setWith` to customize
  13600. * `path` creation.
  13601. *
  13602. * **Note:** This method mutates `object`.
  13603. *
  13604. * @static
  13605. * @memberOf _
  13606. * @since 3.7.0
  13607. * @category Object
  13608. * @param {Object} object The object to modify.
  13609. * @param {Array|string} path The path of the property to set.
  13610. * @param {*} value The value to set.
  13611. * @returns {Object} Returns `object`.
  13612. * @example
  13613. *
  13614. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13615. *
  13616. * _.set(object, 'a[0].b.c', 4);
  13617. * console.log(object.a[0].b.c);
  13618. * // => 4
  13619. *
  13620. * _.set(object, ['x', '0', 'y', 'z'], 5);
  13621. * console.log(object.x[0].y.z);
  13622. * // => 5
  13623. */
  13624. function set(object, path, value) {
  13625. return object == null ? object : baseSet(object, path, value);
  13626. }
  13627. /**
  13628. * This method is like `_.set` except that it accepts `customizer` which is
  13629. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  13630. * path creation is handled by the method instead. The `customizer` is invoked
  13631. * with three arguments: (nsValue, key, nsObject).
  13632. *
  13633. * **Note:** This method mutates `object`.
  13634. *
  13635. * @static
  13636. * @memberOf _
  13637. * @since 4.0.0
  13638. * @category Object
  13639. * @param {Object} object The object to modify.
  13640. * @param {Array|string} path The path of the property to set.
  13641. * @param {*} value The value to set.
  13642. * @param {Function} [customizer] The function to customize assigned values.
  13643. * @returns {Object} Returns `object`.
  13644. * @example
  13645. *
  13646. * var object = {};
  13647. *
  13648. * _.setWith(object, '[0][1]', 'a', Object);
  13649. * // => { '0': { '1': 'a' } }
  13650. */
  13651. function setWith(object, path, value, customizer) {
  13652. customizer = typeof customizer == 'function' ? customizer : undefined;
  13653. return object == null ? object : baseSet(object, path, value, customizer);
  13654. }
  13655. /**
  13656. * Creates an array of own enumerable string keyed-value pairs for `object`
  13657. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  13658. * entries are returned.
  13659. *
  13660. * @static
  13661. * @memberOf _
  13662. * @since 4.0.0
  13663. * @alias entries
  13664. * @category Object
  13665. * @param {Object} object The object to query.
  13666. * @returns {Array} Returns the key-value pairs.
  13667. * @example
  13668. *
  13669. * function Foo() {
  13670. * this.a = 1;
  13671. * this.b = 2;
  13672. * }
  13673. *
  13674. * Foo.prototype.c = 3;
  13675. *
  13676. * _.toPairs(new Foo);
  13677. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  13678. */
  13679. var toPairs = createToPairs(keys);
  13680. /**
  13681. * Creates an array of own and inherited enumerable string keyed-value pairs
  13682. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  13683. * or set, its entries are returned.
  13684. *
  13685. * @static
  13686. * @memberOf _
  13687. * @since 4.0.0
  13688. * @alias entriesIn
  13689. * @category Object
  13690. * @param {Object} object The object to query.
  13691. * @returns {Array} Returns the key-value pairs.
  13692. * @example
  13693. *
  13694. * function Foo() {
  13695. * this.a = 1;
  13696. * this.b = 2;
  13697. * }
  13698. *
  13699. * Foo.prototype.c = 3;
  13700. *
  13701. * _.toPairsIn(new Foo);
  13702. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  13703. */
  13704. var toPairsIn = createToPairs(keysIn);
  13705. /**
  13706. * An alternative to `_.reduce`; this method transforms `object` to a new
  13707. * `accumulator` object which is the result of running each of its own
  13708. * enumerable string keyed properties thru `iteratee`, with each invocation
  13709. * potentially mutating the `accumulator` object. If `accumulator` is not
  13710. * provided, a new object with the same `[[Prototype]]` will be used. The
  13711. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  13712. * Iteratee functions may exit iteration early by explicitly returning `false`.
  13713. *
  13714. * @static
  13715. * @memberOf _
  13716. * @since 1.3.0
  13717. * @category Object
  13718. * @param {Object} object The object to iterate over.
  13719. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13720. * @param {*} [accumulator] The custom accumulator value.
  13721. * @returns {*} Returns the accumulated value.
  13722. * @example
  13723. *
  13724. * _.transform([2, 3, 4], function(result, n) {
  13725. * result.push(n *= n);
  13726. * return n % 2 == 0;
  13727. * }, []);
  13728. * // => [4, 9]
  13729. *
  13730. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  13731. * (result[value] || (result[value] = [])).push(key);
  13732. * }, {});
  13733. * // => { '1': ['a', 'c'], '2': ['b'] }
  13734. */
  13735. function transform(object, iteratee, accumulator) {
  13736. var isArr = isArray(object),
  13737. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  13738. iteratee = getIteratee(iteratee, 4);
  13739. if (accumulator == null) {
  13740. var Ctor = object && object.constructor;
  13741. if (isArrLike) {
  13742. accumulator = isArr ? new Ctor : [];
  13743. }
  13744. else if (isObject(object)) {
  13745. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  13746. }
  13747. else {
  13748. accumulator = {};
  13749. }
  13750. }
  13751. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  13752. return iteratee(accumulator, value, index, object);
  13753. });
  13754. return accumulator;
  13755. }
  13756. /**
  13757. * Removes the property at `path` of `object`.
  13758. *
  13759. * **Note:** This method mutates `object`.
  13760. *
  13761. * @static
  13762. * @memberOf _
  13763. * @since 4.0.0
  13764. * @category Object
  13765. * @param {Object} object The object to modify.
  13766. * @param {Array|string} path The path of the property to unset.
  13767. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  13768. * @example
  13769. *
  13770. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  13771. * _.unset(object, 'a[0].b.c');
  13772. * // => true
  13773. *
  13774. * console.log(object);
  13775. * // => { 'a': [{ 'b': {} }] };
  13776. *
  13777. * _.unset(object, ['a', '0', 'b', 'c']);
  13778. * // => true
  13779. *
  13780. * console.log(object);
  13781. * // => { 'a': [{ 'b': {} }] };
  13782. */
  13783. function unset(object, path) {
  13784. return object == null ? true : baseUnset(object, path);
  13785. }
  13786. /**
  13787. * This method is like `_.set` except that accepts `updater` to produce the
  13788. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  13789. * is invoked with one argument: (value).
  13790. *
  13791. * **Note:** This method mutates `object`.
  13792. *
  13793. * @static
  13794. * @memberOf _
  13795. * @since 4.6.0
  13796. * @category Object
  13797. * @param {Object} object The object to modify.
  13798. * @param {Array|string} path The path of the property to set.
  13799. * @param {Function} updater The function to produce the updated value.
  13800. * @returns {Object} Returns `object`.
  13801. * @example
  13802. *
  13803. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13804. *
  13805. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  13806. * console.log(object.a[0].b.c);
  13807. * // => 9
  13808. *
  13809. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  13810. * console.log(object.x[0].y.z);
  13811. * // => 0
  13812. */
  13813. function update(object, path, updater) {
  13814. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  13815. }
  13816. /**
  13817. * This method is like `_.update` except that it accepts `customizer` which is
  13818. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  13819. * path creation is handled by the method instead. The `customizer` is invoked
  13820. * with three arguments: (nsValue, key, nsObject).
  13821. *
  13822. * **Note:** This method mutates `object`.
  13823. *
  13824. * @static
  13825. * @memberOf _
  13826. * @since 4.6.0
  13827. * @category Object
  13828. * @param {Object} object The object to modify.
  13829. * @param {Array|string} path The path of the property to set.
  13830. * @param {Function} updater The function to produce the updated value.
  13831. * @param {Function} [customizer] The function to customize assigned values.
  13832. * @returns {Object} Returns `object`.
  13833. * @example
  13834. *
  13835. * var object = {};
  13836. *
  13837. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  13838. * // => { '0': { '1': 'a' } }
  13839. */
  13840. function updateWith(object, path, updater, customizer) {
  13841. customizer = typeof customizer == 'function' ? customizer : undefined;
  13842. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  13843. }
  13844. /**
  13845. * Creates an array of the own enumerable string keyed property values of `object`.
  13846. *
  13847. * **Note:** Non-object values are coerced to objects.
  13848. *
  13849. * @static
  13850. * @since 0.1.0
  13851. * @memberOf _
  13852. * @category Object
  13853. * @param {Object} object The object to query.
  13854. * @returns {Array} Returns the array of property values.
  13855. * @example
  13856. *
  13857. * function Foo() {
  13858. * this.a = 1;
  13859. * this.b = 2;
  13860. * }
  13861. *
  13862. * Foo.prototype.c = 3;
  13863. *
  13864. * _.values(new Foo);
  13865. * // => [1, 2] (iteration order is not guaranteed)
  13866. *
  13867. * _.values('hi');
  13868. * // => ['h', 'i']
  13869. */
  13870. function values(object) {
  13871. return object == null ? [] : baseValues(object, keys(object));
  13872. }
  13873. /**
  13874. * Creates an array of the own and inherited enumerable string keyed property
  13875. * values of `object`.
  13876. *
  13877. * **Note:** Non-object values are coerced to objects.
  13878. *
  13879. * @static
  13880. * @memberOf _
  13881. * @since 3.0.0
  13882. * @category Object
  13883. * @param {Object} object The object to query.
  13884. * @returns {Array} Returns the array of property values.
  13885. * @example
  13886. *
  13887. * function Foo() {
  13888. * this.a = 1;
  13889. * this.b = 2;
  13890. * }
  13891. *
  13892. * Foo.prototype.c = 3;
  13893. *
  13894. * _.valuesIn(new Foo);
  13895. * // => [1, 2, 3] (iteration order is not guaranteed)
  13896. */
  13897. function valuesIn(object) {
  13898. return object == null ? [] : baseValues(object, keysIn(object));
  13899. }
  13900. /*------------------------------------------------------------------------*/
  13901. /**
  13902. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  13903. *
  13904. * @static
  13905. * @memberOf _
  13906. * @since 4.0.0
  13907. * @category Number
  13908. * @param {number} number The number to clamp.
  13909. * @param {number} [lower] The lower bound.
  13910. * @param {number} upper The upper bound.
  13911. * @returns {number} Returns the clamped number.
  13912. * @example
  13913. *
  13914. * _.clamp(-10, -5, 5);
  13915. * // => -5
  13916. *
  13917. * _.clamp(10, -5, 5);
  13918. * // => 5
  13919. */
  13920. function clamp(number, lower, upper) {
  13921. if (upper === undefined) {
  13922. upper = lower;
  13923. lower = undefined;
  13924. }
  13925. if (upper !== undefined) {
  13926. upper = toNumber(upper);
  13927. upper = upper === upper ? upper : 0;
  13928. }
  13929. if (lower !== undefined) {
  13930. lower = toNumber(lower);
  13931. lower = lower === lower ? lower : 0;
  13932. }
  13933. return baseClamp(toNumber(number), lower, upper);
  13934. }
  13935. /**
  13936. * Checks if `n` is between `start` and up to, but not including, `end`. If
  13937. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  13938. * If `start` is greater than `end` the params are swapped to support
  13939. * negative ranges.
  13940. *
  13941. * @static
  13942. * @memberOf _
  13943. * @since 3.3.0
  13944. * @category Number
  13945. * @param {number} number The number to check.
  13946. * @param {number} [start=0] The start of the range.
  13947. * @param {number} end The end of the range.
  13948. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  13949. * @see _.range, _.rangeRight
  13950. * @example
  13951. *
  13952. * _.inRange(3, 2, 4);
  13953. * // => true
  13954. *
  13955. * _.inRange(4, 8);
  13956. * // => true
  13957. *
  13958. * _.inRange(4, 2);
  13959. * // => false
  13960. *
  13961. * _.inRange(2, 2);
  13962. * // => false
  13963. *
  13964. * _.inRange(1.2, 2);
  13965. * // => true
  13966. *
  13967. * _.inRange(5.2, 4);
  13968. * // => false
  13969. *
  13970. * _.inRange(-3, -2, -6);
  13971. * // => true
  13972. */
  13973. function inRange(number, start, end) {
  13974. start = toFinite(start);
  13975. if (end === undefined) {
  13976. end = start;
  13977. start = 0;
  13978. } else {
  13979. end = toFinite(end);
  13980. }
  13981. number = toNumber(number);
  13982. return baseInRange(number, start, end);
  13983. }
  13984. /**
  13985. * Produces a random number between the inclusive `lower` and `upper` bounds.
  13986. * If only one argument is provided a number between `0` and the given number
  13987. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  13988. * floats, a floating-point number is returned instead of an integer.
  13989. *
  13990. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  13991. * floating-point values which can produce unexpected results.
  13992. *
  13993. * @static
  13994. * @memberOf _
  13995. * @since 0.7.0
  13996. * @category Number
  13997. * @param {number} [lower=0] The lower bound.
  13998. * @param {number} [upper=1] The upper bound.
  13999. * @param {boolean} [floating] Specify returning a floating-point number.
  14000. * @returns {number} Returns the random number.
  14001. * @example
  14002. *
  14003. * _.random(0, 5);
  14004. * // => an integer between 0 and 5
  14005. *
  14006. * _.random(5);
  14007. * // => also an integer between 0 and 5
  14008. *
  14009. * _.random(5, true);
  14010. * // => a floating-point number between 0 and 5
  14011. *
  14012. * _.random(1.2, 5.2);
  14013. * // => a floating-point number between 1.2 and 5.2
  14014. */
  14015. function random(lower, upper, floating) {
  14016. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  14017. upper = floating = undefined;
  14018. }
  14019. if (floating === undefined) {
  14020. if (typeof upper == 'boolean') {
  14021. floating = upper;
  14022. upper = undefined;
  14023. }
  14024. else if (typeof lower == 'boolean') {
  14025. floating = lower;
  14026. lower = undefined;
  14027. }
  14028. }
  14029. if (lower === undefined && upper === undefined) {
  14030. lower = 0;
  14031. upper = 1;
  14032. }
  14033. else {
  14034. lower = toFinite(lower);
  14035. if (upper === undefined) {
  14036. upper = lower;
  14037. lower = 0;
  14038. } else {
  14039. upper = toFinite(upper);
  14040. }
  14041. }
  14042. if (lower > upper) {
  14043. var temp = lower;
  14044. lower = upper;
  14045. upper = temp;
  14046. }
  14047. if (floating || lower % 1 || upper % 1) {
  14048. var rand = nativeRandom();
  14049. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  14050. }
  14051. return baseRandom(lower, upper);
  14052. }
  14053. /*------------------------------------------------------------------------*/
  14054. /**
  14055. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  14056. *
  14057. * @static
  14058. * @memberOf _
  14059. * @since 3.0.0
  14060. * @category String
  14061. * @param {string} [string=''] The string to convert.
  14062. * @returns {string} Returns the camel cased string.
  14063. * @example
  14064. *
  14065. * _.camelCase('Foo Bar');
  14066. * // => 'fooBar'
  14067. *
  14068. * _.camelCase('--foo-bar--');
  14069. * // => 'fooBar'
  14070. *
  14071. * _.camelCase('__FOO_BAR__');
  14072. * // => 'fooBar'
  14073. */
  14074. var camelCase = createCompounder(function(result, word, index) {
  14075. word = word.toLowerCase();
  14076. return result + (index ? capitalize(word) : word);
  14077. });
  14078. /**
  14079. * Converts the first character of `string` to upper case and the remaining
  14080. * to lower case.
  14081. *
  14082. * @static
  14083. * @memberOf _
  14084. * @since 3.0.0
  14085. * @category String
  14086. * @param {string} [string=''] The string to capitalize.
  14087. * @returns {string} Returns the capitalized string.
  14088. * @example
  14089. *
  14090. * _.capitalize('FRED');
  14091. * // => 'Fred'
  14092. */
  14093. function capitalize(string) {
  14094. return upperFirst(toString(string).toLowerCase());
  14095. }
  14096. /**
  14097. * Deburrs `string` by converting
  14098. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  14099. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  14100. * letters to basic Latin letters and removing
  14101. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  14102. *
  14103. * @static
  14104. * @memberOf _
  14105. * @since 3.0.0
  14106. * @category String
  14107. * @param {string} [string=''] The string to deburr.
  14108. * @returns {string} Returns the deburred string.
  14109. * @example
  14110. *
  14111. * _.deburr('déjà vu');
  14112. * // => 'deja vu'
  14113. */
  14114. function deburr(string) {
  14115. string = toString(string);
  14116. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  14117. }
  14118. /**
  14119. * Checks if `string` ends with the given target string.
  14120. *
  14121. * @static
  14122. * @memberOf _
  14123. * @since 3.0.0
  14124. * @category String
  14125. * @param {string} [string=''] The string to inspect.
  14126. * @param {string} [target] The string to search for.
  14127. * @param {number} [position=string.length] The position to search up to.
  14128. * @returns {boolean} Returns `true` if `string` ends with `target`,
  14129. * else `false`.
  14130. * @example
  14131. *
  14132. * _.endsWith('abc', 'c');
  14133. * // => true
  14134. *
  14135. * _.endsWith('abc', 'b');
  14136. * // => false
  14137. *
  14138. * _.endsWith('abc', 'b', 2);
  14139. * // => true
  14140. */
  14141. function endsWith(string, target, position) {
  14142. string = toString(string);
  14143. target = baseToString(target);
  14144. var length = string.length;
  14145. position = position === undefined
  14146. ? length
  14147. : baseClamp(toInteger(position), 0, length);
  14148. var end = position;
  14149. position -= target.length;
  14150. return position >= 0 && string.slice(position, end) == target;
  14151. }
  14152. /**
  14153. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  14154. * corresponding HTML entities.
  14155. *
  14156. * **Note:** No other characters are escaped. To escape additional
  14157. * characters use a third-party library like [_he_](https://mths.be/he).
  14158. *
  14159. * Though the ">" character is escaped for symmetry, characters like
  14160. * ">" and "/" don't need escaping in HTML and have no special meaning
  14161. * unless they're part of a tag or unquoted attribute value. See
  14162. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  14163. * (under "semi-related fun fact") for more details.
  14164. *
  14165. * When working with HTML you should always
  14166. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  14167. * XSS vectors.
  14168. *
  14169. * @static
  14170. * @since 0.1.0
  14171. * @memberOf _
  14172. * @category String
  14173. * @param {string} [string=''] The string to escape.
  14174. * @returns {string} Returns the escaped string.
  14175. * @example
  14176. *
  14177. * _.escape('fred, barney, & pebbles');
  14178. * // => 'fred, barney, &amp; pebbles'
  14179. */
  14180. function escape(string) {
  14181. string = toString(string);
  14182. return (string && reHasUnescapedHtml.test(string))
  14183. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  14184. : string;
  14185. }
  14186. /**
  14187. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  14188. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  14189. *
  14190. * @static
  14191. * @memberOf _
  14192. * @since 3.0.0
  14193. * @category String
  14194. * @param {string} [string=''] The string to escape.
  14195. * @returns {string} Returns the escaped string.
  14196. * @example
  14197. *
  14198. * _.escapeRegExp('[lodash](https://lodash.com/)');
  14199. * // => '\[lodash\]\(https://lodash\.com/\)'
  14200. */
  14201. function escapeRegExp(string) {
  14202. string = toString(string);
  14203. return (string && reHasRegExpChar.test(string))
  14204. ? string.replace(reRegExpChar, '\\$&')
  14205. : string;
  14206. }
  14207. /**
  14208. * Converts `string` to
  14209. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  14210. *
  14211. * @static
  14212. * @memberOf _
  14213. * @since 3.0.0
  14214. * @category String
  14215. * @param {string} [string=''] The string to convert.
  14216. * @returns {string} Returns the kebab cased string.
  14217. * @example
  14218. *
  14219. * _.kebabCase('Foo Bar');
  14220. * // => 'foo-bar'
  14221. *
  14222. * _.kebabCase('fooBar');
  14223. * // => 'foo-bar'
  14224. *
  14225. * _.kebabCase('__FOO_BAR__');
  14226. * // => 'foo-bar'
  14227. */
  14228. var kebabCase = createCompounder(function(result, word, index) {
  14229. return result + (index ? '-' : '') + word.toLowerCase();
  14230. });
  14231. /**
  14232. * Converts `string`, as space separated words, to lower case.
  14233. *
  14234. * @static
  14235. * @memberOf _
  14236. * @since 4.0.0
  14237. * @category String
  14238. * @param {string} [string=''] The string to convert.
  14239. * @returns {string} Returns the lower cased string.
  14240. * @example
  14241. *
  14242. * _.lowerCase('--Foo-Bar--');
  14243. * // => 'foo bar'
  14244. *
  14245. * _.lowerCase('fooBar');
  14246. * // => 'foo bar'
  14247. *
  14248. * _.lowerCase('__FOO_BAR__');
  14249. * // => 'foo bar'
  14250. */
  14251. var lowerCase = createCompounder(function(result, word, index) {
  14252. return result + (index ? ' ' : '') + word.toLowerCase();
  14253. });
  14254. /**
  14255. * Converts the first character of `string` to lower case.
  14256. *
  14257. * @static
  14258. * @memberOf _
  14259. * @since 4.0.0
  14260. * @category String
  14261. * @param {string} [string=''] The string to convert.
  14262. * @returns {string} Returns the converted string.
  14263. * @example
  14264. *
  14265. * _.lowerFirst('Fred');
  14266. * // => 'fred'
  14267. *
  14268. * _.lowerFirst('FRED');
  14269. * // => 'fRED'
  14270. */
  14271. var lowerFirst = createCaseFirst('toLowerCase');
  14272. /**
  14273. * Pads `string` on the left and right sides if it's shorter than `length`.
  14274. * Padding characters are truncated if they can't be evenly divided by `length`.
  14275. *
  14276. * @static
  14277. * @memberOf _
  14278. * @since 3.0.0
  14279. * @category String
  14280. * @param {string} [string=''] The string to pad.
  14281. * @param {number} [length=0] The padding length.
  14282. * @param {string} [chars=' '] The string used as padding.
  14283. * @returns {string} Returns the padded string.
  14284. * @example
  14285. *
  14286. * _.pad('abc', 8);
  14287. * // => ' abc '
  14288. *
  14289. * _.pad('abc', 8, '_-');
  14290. * // => '_-abc_-_'
  14291. *
  14292. * _.pad('abc', 3);
  14293. * // => 'abc'
  14294. */
  14295. function pad(string, length, chars) {
  14296. string = toString(string);
  14297. length = toInteger(length);
  14298. var strLength = length ? stringSize(string) : 0;
  14299. if (!length || strLength >= length) {
  14300. return string;
  14301. }
  14302. var mid = (length - strLength) / 2;
  14303. return (
  14304. createPadding(nativeFloor(mid), chars) +
  14305. string +
  14306. createPadding(nativeCeil(mid), chars)
  14307. );
  14308. }
  14309. /**
  14310. * Pads `string` on the right side if it's shorter than `length`. Padding
  14311. * characters are truncated if they exceed `length`.
  14312. *
  14313. * @static
  14314. * @memberOf _
  14315. * @since 4.0.0
  14316. * @category String
  14317. * @param {string} [string=''] The string to pad.
  14318. * @param {number} [length=0] The padding length.
  14319. * @param {string} [chars=' '] The string used as padding.
  14320. * @returns {string} Returns the padded string.
  14321. * @example
  14322. *
  14323. * _.padEnd('abc', 6);
  14324. * // => 'abc '
  14325. *
  14326. * _.padEnd('abc', 6, '_-');
  14327. * // => 'abc_-_'
  14328. *
  14329. * _.padEnd('abc', 3);
  14330. * // => 'abc'
  14331. */
  14332. function padEnd(string, length, chars) {
  14333. string = toString(string);
  14334. length = toInteger(length);
  14335. var strLength = length ? stringSize(string) : 0;
  14336. return (length && strLength < length)
  14337. ? (string + createPadding(length - strLength, chars))
  14338. : string;
  14339. }
  14340. /**
  14341. * Pads `string` on the left side if it's shorter than `length`. Padding
  14342. * characters are truncated if they exceed `length`.
  14343. *
  14344. * @static
  14345. * @memberOf _
  14346. * @since 4.0.0
  14347. * @category String
  14348. * @param {string} [string=''] The string to pad.
  14349. * @param {number} [length=0] The padding length.
  14350. * @param {string} [chars=' '] The string used as padding.
  14351. * @returns {string} Returns the padded string.
  14352. * @example
  14353. *
  14354. * _.padStart('abc', 6);
  14355. * // => ' abc'
  14356. *
  14357. * _.padStart('abc', 6, '_-');
  14358. * // => '_-_abc'
  14359. *
  14360. * _.padStart('abc', 3);
  14361. * // => 'abc'
  14362. */
  14363. function padStart(string, length, chars) {
  14364. string = toString(string);
  14365. length = toInteger(length);
  14366. var strLength = length ? stringSize(string) : 0;
  14367. return (length && strLength < length)
  14368. ? (createPadding(length - strLength, chars) + string)
  14369. : string;
  14370. }
  14371. /**
  14372. * Converts `string` to an integer of the specified radix. If `radix` is
  14373. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  14374. * hexadecimal, in which case a `radix` of `16` is used.
  14375. *
  14376. * **Note:** This method aligns with the
  14377. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  14378. *
  14379. * @static
  14380. * @memberOf _
  14381. * @since 1.1.0
  14382. * @category String
  14383. * @param {string} string The string to convert.
  14384. * @param {number} [radix=10] The radix to interpret `value` by.
  14385. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14386. * @returns {number} Returns the converted integer.
  14387. * @example
  14388. *
  14389. * _.parseInt('08');
  14390. * // => 8
  14391. *
  14392. * _.map(['6', '08', '10'], _.parseInt);
  14393. * // => [6, 8, 10]
  14394. */
  14395. function parseInt(string, radix, guard) {
  14396. if (guard || radix == null) {
  14397. radix = 0;
  14398. } else if (radix) {
  14399. radix = +radix;
  14400. }
  14401. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  14402. }
  14403. /**
  14404. * Repeats the given string `n` times.
  14405. *
  14406. * @static
  14407. * @memberOf _
  14408. * @since 3.0.0
  14409. * @category String
  14410. * @param {string} [string=''] The string to repeat.
  14411. * @param {number} [n=1] The number of times to repeat the string.
  14412. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14413. * @returns {string} Returns the repeated string.
  14414. * @example
  14415. *
  14416. * _.repeat('*', 3);
  14417. * // => '***'
  14418. *
  14419. * _.repeat('abc', 2);
  14420. * // => 'abcabc'
  14421. *
  14422. * _.repeat('abc', 0);
  14423. * // => ''
  14424. */
  14425. function repeat(string, n, guard) {
  14426. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  14427. n = 1;
  14428. } else {
  14429. n = toInteger(n);
  14430. }
  14431. return baseRepeat(toString(string), n);
  14432. }
  14433. /**
  14434. * Replaces matches for `pattern` in `string` with `replacement`.
  14435. *
  14436. * **Note:** This method is based on
  14437. * [`String#replace`](https://mdn.io/String/replace).
  14438. *
  14439. * @static
  14440. * @memberOf _
  14441. * @since 4.0.0
  14442. * @category String
  14443. * @param {string} [string=''] The string to modify.
  14444. * @param {RegExp|string} pattern The pattern to replace.
  14445. * @param {Function|string} replacement The match replacement.
  14446. * @returns {string} Returns the modified string.
  14447. * @example
  14448. *
  14449. * _.replace('Hi Fred', 'Fred', 'Barney');
  14450. * // => 'Hi Barney'
  14451. */
  14452. function replace() {
  14453. var args = arguments,
  14454. string = toString(args[0]);
  14455. return args.length < 3 ? string : string.replace(args[1], args[2]);
  14456. }
  14457. /**
  14458. * Converts `string` to
  14459. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  14460. *
  14461. * @static
  14462. * @memberOf _
  14463. * @since 3.0.0
  14464. * @category String
  14465. * @param {string} [string=''] The string to convert.
  14466. * @returns {string} Returns the snake cased string.
  14467. * @example
  14468. *
  14469. * _.snakeCase('Foo Bar');
  14470. * // => 'foo_bar'
  14471. *
  14472. * _.snakeCase('fooBar');
  14473. * // => 'foo_bar'
  14474. *
  14475. * _.snakeCase('--FOO-BAR--');
  14476. * // => 'foo_bar'
  14477. */
  14478. var snakeCase = createCompounder(function(result, word, index) {
  14479. return result + (index ? '_' : '') + word.toLowerCase();
  14480. });
  14481. /**
  14482. * Splits `string` by `separator`.
  14483. *
  14484. * **Note:** This method is based on
  14485. * [`String#split`](https://mdn.io/String/split).
  14486. *
  14487. * @static
  14488. * @memberOf _
  14489. * @since 4.0.0
  14490. * @category String
  14491. * @param {string} [string=''] The string to split.
  14492. * @param {RegExp|string} separator The separator pattern to split by.
  14493. * @param {number} [limit] The length to truncate results to.
  14494. * @returns {Array} Returns the string segments.
  14495. * @example
  14496. *
  14497. * _.split('a-b-c', '-', 2);
  14498. * // => ['a', 'b']
  14499. */
  14500. function split(string, separator, limit) {
  14501. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  14502. separator = limit = undefined;
  14503. }
  14504. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  14505. if (!limit) {
  14506. return [];
  14507. }
  14508. string = toString(string);
  14509. if (string && (
  14510. typeof separator == 'string' ||
  14511. (separator != null && !isRegExp(separator))
  14512. )) {
  14513. separator = baseToString(separator);
  14514. if (!separator && hasUnicode(string)) {
  14515. return castSlice(stringToArray(string), 0, limit);
  14516. }
  14517. }
  14518. return string.split(separator, limit);
  14519. }
  14520. /**
  14521. * Converts `string` to
  14522. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  14523. *
  14524. * @static
  14525. * @memberOf _
  14526. * @since 3.1.0
  14527. * @category String
  14528. * @param {string} [string=''] The string to convert.
  14529. * @returns {string} Returns the start cased string.
  14530. * @example
  14531. *
  14532. * _.startCase('--foo-bar--');
  14533. * // => 'Foo Bar'
  14534. *
  14535. * _.startCase('fooBar');
  14536. * // => 'Foo Bar'
  14537. *
  14538. * _.startCase('__FOO_BAR__');
  14539. * // => 'FOO BAR'
  14540. */
  14541. var startCase = createCompounder(function(result, word, index) {
  14542. return result + (index ? ' ' : '') + upperFirst(word);
  14543. });
  14544. /**
  14545. * Checks if `string` starts with the given target string.
  14546. *
  14547. * @static
  14548. * @memberOf _
  14549. * @since 3.0.0
  14550. * @category String
  14551. * @param {string} [string=''] The string to inspect.
  14552. * @param {string} [target] The string to search for.
  14553. * @param {number} [position=0] The position to search from.
  14554. * @returns {boolean} Returns `true` if `string` starts with `target`,
  14555. * else `false`.
  14556. * @example
  14557. *
  14558. * _.startsWith('abc', 'a');
  14559. * // => true
  14560. *
  14561. * _.startsWith('abc', 'b');
  14562. * // => false
  14563. *
  14564. * _.startsWith('abc', 'b', 1);
  14565. * // => true
  14566. */
  14567. function startsWith(string, target, position) {
  14568. string = toString(string);
  14569. position = position == null
  14570. ? 0
  14571. : baseClamp(toInteger(position), 0, string.length);
  14572. target = baseToString(target);
  14573. return string.slice(position, position + target.length) == target;
  14574. }
  14575. /**
  14576. * Creates a compiled template function that can interpolate data properties
  14577. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  14578. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  14579. * properties may be accessed as free variables in the template. If a setting
  14580. * object is given, it takes precedence over `_.templateSettings` values.
  14581. *
  14582. * **Note:** In the development build `_.template` utilizes
  14583. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  14584. * for easier debugging.
  14585. *
  14586. * For more information on precompiling templates see
  14587. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  14588. *
  14589. * For more information on Chrome extension sandboxes see
  14590. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  14591. *
  14592. * @static
  14593. * @since 0.1.0
  14594. * @memberOf _
  14595. * @category String
  14596. * @param {string} [string=''] The template string.
  14597. * @param {Object} [options={}] The options object.
  14598. * @param {RegExp} [options.escape=_.templateSettings.escape]
  14599. * The HTML "escape" delimiter.
  14600. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  14601. * The "evaluate" delimiter.
  14602. * @param {Object} [options.imports=_.templateSettings.imports]
  14603. * An object to import into the template as free variables.
  14604. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  14605. * The "interpolate" delimiter.
  14606. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  14607. * The sourceURL of the compiled template.
  14608. * @param {string} [options.variable='obj']
  14609. * The data object variable name.
  14610. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14611. * @returns {Function} Returns the compiled template function.
  14612. * @example
  14613. *
  14614. * // Use the "interpolate" delimiter to create a compiled template.
  14615. * var compiled = _.template('hello <%= user %>!');
  14616. * compiled({ 'user': 'fred' });
  14617. * // => 'hello fred!'
  14618. *
  14619. * // Use the HTML "escape" delimiter to escape data property values.
  14620. * var compiled = _.template('<b><%- value %></b>');
  14621. * compiled({ 'value': '<script>' });
  14622. * // => '<b>&lt;script&gt;</b>'
  14623. *
  14624. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  14625. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  14626. * compiled({ 'users': ['fred', 'barney'] });
  14627. * // => '<li>fred</li><li>barney</li>'
  14628. *
  14629. * // Use the internal `print` function in "evaluate" delimiters.
  14630. * var compiled = _.template('<% print("hello " + user); %>!');
  14631. * compiled({ 'user': 'barney' });
  14632. * // => 'hello barney!'
  14633. *
  14634. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  14635. * // Disable support by replacing the "interpolate" delimiter.
  14636. * var compiled = _.template('hello ${ user }!');
  14637. * compiled({ 'user': 'pebbles' });
  14638. * // => 'hello pebbles!'
  14639. *
  14640. * // Use backslashes to treat delimiters as plain text.
  14641. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  14642. * compiled({ 'value': 'ignored' });
  14643. * // => '<%- value %>'
  14644. *
  14645. * // Use the `imports` option to import `jQuery` as `jq`.
  14646. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  14647. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  14648. * compiled({ 'users': ['fred', 'barney'] });
  14649. * // => '<li>fred</li><li>barney</li>'
  14650. *
  14651. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  14652. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  14653. * compiled(data);
  14654. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  14655. *
  14656. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  14657. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  14658. * compiled.source;
  14659. * // => function(data) {
  14660. * // var __t, __p = '';
  14661. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  14662. * // return __p;
  14663. * // }
  14664. *
  14665. * // Use custom template delimiters.
  14666. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  14667. * var compiled = _.template('hello {{ user }}!');
  14668. * compiled({ 'user': 'mustache' });
  14669. * // => 'hello mustache!'
  14670. *
  14671. * // Use the `source` property to inline compiled templates for meaningful
  14672. * // line numbers in error messages and stack traces.
  14673. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  14674. * var JST = {\
  14675. * "main": ' + _.template(mainText).source + '\
  14676. * };\
  14677. * ');
  14678. */
  14679. function template(string, options, guard) {
  14680. // Based on John Resig's `tmpl` implementation
  14681. // (http://ejohn.org/blog/javascript-micro-templating/)
  14682. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  14683. var settings = lodash.templateSettings;
  14684. if (guard && isIterateeCall(string, options, guard)) {
  14685. options = undefined;
  14686. }
  14687. string = toString(string);
  14688. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  14689. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  14690. importsKeys = keys(imports),
  14691. importsValues = baseValues(imports, importsKeys);
  14692. var isEscaping,
  14693. isEvaluating,
  14694. index = 0,
  14695. interpolate = options.interpolate || reNoMatch,
  14696. source = "__p += '";
  14697. // Compile the regexp to match each delimiter.
  14698. var reDelimiters = RegExp(
  14699. (options.escape || reNoMatch).source + '|' +
  14700. interpolate.source + '|' +
  14701. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  14702. (options.evaluate || reNoMatch).source + '|$'
  14703. , 'g');
  14704. // Use a sourceURL for easier debugging.
  14705. var sourceURL = '//# sourceURL=' +
  14706. ('sourceURL' in options
  14707. ? options.sourceURL
  14708. : ('lodash.templateSources[' + (++templateCounter) + ']')
  14709. ) + '\n';
  14710. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  14711. interpolateValue || (interpolateValue = esTemplateValue);
  14712. // Escape characters that can't be included in string literals.
  14713. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  14714. // Replace delimiters with snippets.
  14715. if (escapeValue) {
  14716. isEscaping = true;
  14717. source += "' +\n__e(" + escapeValue + ") +\n'";
  14718. }
  14719. if (evaluateValue) {
  14720. isEvaluating = true;
  14721. source += "';\n" + evaluateValue + ";\n__p += '";
  14722. }
  14723. if (interpolateValue) {
  14724. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  14725. }
  14726. index = offset + match.length;
  14727. // The JS engine embedded in Adobe products needs `match` returned in
  14728. // order to produce the correct `offset` value.
  14729. return match;
  14730. });
  14731. source += "';\n";
  14732. // If `variable` is not specified wrap a with-statement around the generated
  14733. // code to add the data object to the top of the scope chain.
  14734. var variable = options.variable;
  14735. if (!variable) {
  14736. source = 'with (obj) {\n' + source + '\n}\n';
  14737. }
  14738. // Cleanup code by stripping empty strings.
  14739. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  14740. .replace(reEmptyStringMiddle, '$1')
  14741. .replace(reEmptyStringTrailing, '$1;');
  14742. // Frame code as the function body.
  14743. source = 'function(' + (variable || 'obj') + ') {\n' +
  14744. (variable
  14745. ? ''
  14746. : 'obj || (obj = {});\n'
  14747. ) +
  14748. "var __t, __p = ''" +
  14749. (isEscaping
  14750. ? ', __e = _.escape'
  14751. : ''
  14752. ) +
  14753. (isEvaluating
  14754. ? ', __j = Array.prototype.join;\n' +
  14755. "function print() { __p += __j.call(arguments, '') }\n"
  14756. : ';\n'
  14757. ) +
  14758. source +
  14759. 'return __p\n}';
  14760. var result = attempt(function() {
  14761. return Function(importsKeys, sourceURL + 'return ' + source)
  14762. .apply(undefined, importsValues);
  14763. });
  14764. // Provide the compiled function's source by its `toString` method or
  14765. // the `source` property as a convenience for inlining compiled templates.
  14766. result.source = source;
  14767. if (isError(result)) {
  14768. throw result;
  14769. }
  14770. return result;
  14771. }
  14772. /**
  14773. * Converts `string`, as a whole, to lower case just like
  14774. * [String#toLowerCase](https://mdn.io/toLowerCase).
  14775. *
  14776. * @static
  14777. * @memberOf _
  14778. * @since 4.0.0
  14779. * @category String
  14780. * @param {string} [string=''] The string to convert.
  14781. * @returns {string} Returns the lower cased string.
  14782. * @example
  14783. *
  14784. * _.toLower('--Foo-Bar--');
  14785. * // => '--foo-bar--'
  14786. *
  14787. * _.toLower('fooBar');
  14788. * // => 'foobar'
  14789. *
  14790. * _.toLower('__FOO_BAR__');
  14791. * // => '__foo_bar__'
  14792. */
  14793. function toLower(value) {
  14794. return toString(value).toLowerCase();
  14795. }
  14796. /**
  14797. * Converts `string`, as a whole, to upper case just like
  14798. * [String#toUpperCase](https://mdn.io/toUpperCase).
  14799. *
  14800. * @static
  14801. * @memberOf _
  14802. * @since 4.0.0
  14803. * @category String
  14804. * @param {string} [string=''] The string to convert.
  14805. * @returns {string} Returns the upper cased string.
  14806. * @example
  14807. *
  14808. * _.toUpper('--foo-bar--');
  14809. * // => '--FOO-BAR--'
  14810. *
  14811. * _.toUpper('fooBar');
  14812. * // => 'FOOBAR'
  14813. *
  14814. * _.toUpper('__foo_bar__');
  14815. * // => '__FOO_BAR__'
  14816. */
  14817. function toUpper(value) {
  14818. return toString(value).toUpperCase();
  14819. }
  14820. /**
  14821. * Removes leading and trailing whitespace or specified characters from `string`.
  14822. *
  14823. * @static
  14824. * @memberOf _
  14825. * @since 3.0.0
  14826. * @category String
  14827. * @param {string} [string=''] The string to trim.
  14828. * @param {string} [chars=whitespace] The characters to trim.
  14829. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14830. * @returns {string} Returns the trimmed string.
  14831. * @example
  14832. *
  14833. * _.trim(' abc ');
  14834. * // => 'abc'
  14835. *
  14836. * _.trim('-_-abc-_-', '_-');
  14837. * // => 'abc'
  14838. *
  14839. * _.map([' foo ', ' bar '], _.trim);
  14840. * // => ['foo', 'bar']
  14841. */
  14842. function trim(string, chars, guard) {
  14843. string = toString(string);
  14844. if (string && (guard || chars === undefined)) {
  14845. return string.replace(reTrim, '');
  14846. }
  14847. if (!string || !(chars = baseToString(chars))) {
  14848. return string;
  14849. }
  14850. var strSymbols = stringToArray(string),
  14851. chrSymbols = stringToArray(chars),
  14852. start = charsStartIndex(strSymbols, chrSymbols),
  14853. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  14854. return castSlice(strSymbols, start, end).join('');
  14855. }
  14856. /**
  14857. * Removes trailing whitespace or specified characters from `string`.
  14858. *
  14859. * @static
  14860. * @memberOf _
  14861. * @since 4.0.0
  14862. * @category String
  14863. * @param {string} [string=''] The string to trim.
  14864. * @param {string} [chars=whitespace] The characters to trim.
  14865. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14866. * @returns {string} Returns the trimmed string.
  14867. * @example
  14868. *
  14869. * _.trimEnd(' abc ');
  14870. * // => ' abc'
  14871. *
  14872. * _.trimEnd('-_-abc-_-', '_-');
  14873. * // => '-_-abc'
  14874. */
  14875. function trimEnd(string, chars, guard) {
  14876. string = toString(string);
  14877. if (string && (guard || chars === undefined)) {
  14878. return string.replace(reTrimEnd, '');
  14879. }
  14880. if (!string || !(chars = baseToString(chars))) {
  14881. return string;
  14882. }
  14883. var strSymbols = stringToArray(string),
  14884. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  14885. return castSlice(strSymbols, 0, end).join('');
  14886. }
  14887. /**
  14888. * Removes leading whitespace or specified characters from `string`.
  14889. *
  14890. * @static
  14891. * @memberOf _
  14892. * @since 4.0.0
  14893. * @category String
  14894. * @param {string} [string=''] The string to trim.
  14895. * @param {string} [chars=whitespace] The characters to trim.
  14896. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14897. * @returns {string} Returns the trimmed string.
  14898. * @example
  14899. *
  14900. * _.trimStart(' abc ');
  14901. * // => 'abc '
  14902. *
  14903. * _.trimStart('-_-abc-_-', '_-');
  14904. * // => 'abc-_-'
  14905. */
  14906. function trimStart(string, chars, guard) {
  14907. string = toString(string);
  14908. if (string && (guard || chars === undefined)) {
  14909. return string.replace(reTrimStart, '');
  14910. }
  14911. if (!string || !(chars = baseToString(chars))) {
  14912. return string;
  14913. }
  14914. var strSymbols = stringToArray(string),
  14915. start = charsStartIndex(strSymbols, stringToArray(chars));
  14916. return castSlice(strSymbols, start).join('');
  14917. }
  14918. /**
  14919. * Truncates `string` if it's longer than the given maximum string length.
  14920. * The last characters of the truncated string are replaced with the omission
  14921. * string which defaults to "...".
  14922. *
  14923. * @static
  14924. * @memberOf _
  14925. * @since 4.0.0
  14926. * @category String
  14927. * @param {string} [string=''] The string to truncate.
  14928. * @param {Object} [options={}] The options object.
  14929. * @param {number} [options.length=30] The maximum string length.
  14930. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  14931. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  14932. * @returns {string} Returns the truncated string.
  14933. * @example
  14934. *
  14935. * _.truncate('hi-diddly-ho there, neighborino');
  14936. * // => 'hi-diddly-ho there, neighbo...'
  14937. *
  14938. * _.truncate('hi-diddly-ho there, neighborino', {
  14939. * 'length': 24,
  14940. * 'separator': ' '
  14941. * });
  14942. * // => 'hi-diddly-ho there,...'
  14943. *
  14944. * _.truncate('hi-diddly-ho there, neighborino', {
  14945. * 'length': 24,
  14946. * 'separator': /,? +/
  14947. * });
  14948. * // => 'hi-diddly-ho there...'
  14949. *
  14950. * _.truncate('hi-diddly-ho there, neighborino', {
  14951. * 'omission': ' [...]'
  14952. * });
  14953. * // => 'hi-diddly-ho there, neig [...]'
  14954. */
  14955. function truncate(string, options) {
  14956. var length = DEFAULT_TRUNC_LENGTH,
  14957. omission = DEFAULT_TRUNC_OMISSION;
  14958. if (isObject(options)) {
  14959. var separator = 'separator' in options ? options.separator : separator;
  14960. length = 'length' in options ? toInteger(options.length) : length;
  14961. omission = 'omission' in options ? baseToString(options.omission) : omission;
  14962. }
  14963. string = toString(string);
  14964. var strLength = string.length;
  14965. if (hasUnicode(string)) {
  14966. var strSymbols = stringToArray(string);
  14967. strLength = strSymbols.length;
  14968. }
  14969. if (length >= strLength) {
  14970. return string;
  14971. }
  14972. var end = length - stringSize(omission);
  14973. if (end < 1) {
  14974. return omission;
  14975. }
  14976. var result = strSymbols
  14977. ? castSlice(strSymbols, 0, end).join('')
  14978. : string.slice(0, end);
  14979. if (separator === undefined) {
  14980. return result + omission;
  14981. }
  14982. if (strSymbols) {
  14983. end += (result.length - end);
  14984. }
  14985. if (isRegExp(separator)) {
  14986. if (string.slice(end).search(separator)) {
  14987. var match,
  14988. substring = result;
  14989. if (!separator.global) {
  14990. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  14991. }
  14992. separator.lastIndex = 0;
  14993. while ((match = separator.exec(substring))) {
  14994. var newEnd = match.index;
  14995. }
  14996. result = result.slice(0, newEnd === undefined ? end : newEnd);
  14997. }
  14998. } else if (string.indexOf(baseToString(separator), end) != end) {
  14999. var index = result.lastIndexOf(separator);
  15000. if (index > -1) {
  15001. result = result.slice(0, index);
  15002. }
  15003. }
  15004. return result + omission;
  15005. }
  15006. /**
  15007. * The inverse of `_.escape`; this method converts the HTML entities
  15008. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  15009. * their corresponding characters.
  15010. *
  15011. * **Note:** No other HTML entities are unescaped. To unescape additional
  15012. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  15013. *
  15014. * @static
  15015. * @memberOf _
  15016. * @since 0.6.0
  15017. * @category String
  15018. * @param {string} [string=''] The string to unescape.
  15019. * @returns {string} Returns the unescaped string.
  15020. * @example
  15021. *
  15022. * _.unescape('fred, barney, &amp; pebbles');
  15023. * // => 'fred, barney, & pebbles'
  15024. */
  15025. function unescape(string) {
  15026. string = toString(string);
  15027. return (string && reHasEscapedHtml.test(string))
  15028. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  15029. : string;
  15030. }
  15031. /**
  15032. * Converts `string`, as space separated words, to upper case.
  15033. *
  15034. * @static
  15035. * @memberOf _
  15036. * @since 4.0.0
  15037. * @category String
  15038. * @param {string} [string=''] The string to convert.
  15039. * @returns {string} Returns the upper cased string.
  15040. * @example
  15041. *
  15042. * _.upperCase('--foo-bar');
  15043. * // => 'FOO BAR'
  15044. *
  15045. * _.upperCase('fooBar');
  15046. * // => 'FOO BAR'
  15047. *
  15048. * _.upperCase('__foo_bar__');
  15049. * // => 'FOO BAR'
  15050. */
  15051. var upperCase = createCompounder(function(result, word, index) {
  15052. return result + (index ? ' ' : '') + word.toUpperCase();
  15053. });
  15054. /**
  15055. * Converts the first character of `string` to upper case.
  15056. *
  15057. * @static
  15058. * @memberOf _
  15059. * @since 4.0.0
  15060. * @category String
  15061. * @param {string} [string=''] The string to convert.
  15062. * @returns {string} Returns the converted string.
  15063. * @example
  15064. *
  15065. * _.upperFirst('fred');
  15066. * // => 'Fred'
  15067. *
  15068. * _.upperFirst('FRED');
  15069. * // => 'FRED'
  15070. */
  15071. var upperFirst = createCaseFirst('toUpperCase');
  15072. /**
  15073. * Splits `string` into an array of its words.
  15074. *
  15075. * @static
  15076. * @memberOf _
  15077. * @since 3.0.0
  15078. * @category String
  15079. * @param {string} [string=''] The string to inspect.
  15080. * @param {RegExp|string} [pattern] The pattern to match words.
  15081. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15082. * @returns {Array} Returns the words of `string`.
  15083. * @example
  15084. *
  15085. * _.words('fred, barney, & pebbles');
  15086. * // => ['fred', 'barney', 'pebbles']
  15087. *
  15088. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  15089. * // => ['fred', 'barney', '&', 'pebbles']
  15090. */
  15091. function words(string, pattern, guard) {
  15092. string = toString(string);
  15093. pattern = guard ? undefined : pattern;
  15094. if (pattern === undefined) {
  15095. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  15096. }
  15097. return string.match(pattern) || [];
  15098. }
  15099. /*------------------------------------------------------------------------*/
  15100. /**
  15101. * Attempts to invoke `func`, returning either the result or the caught error
  15102. * object. Any additional arguments are provided to `func` when it's invoked.
  15103. *
  15104. * @static
  15105. * @memberOf _
  15106. * @since 3.0.0
  15107. * @category Util
  15108. * @param {Function} func The function to attempt.
  15109. * @param {...*} [args] The arguments to invoke `func` with.
  15110. * @returns {*} Returns the `func` result or error object.
  15111. * @example
  15112. *
  15113. * // Avoid throwing errors for invalid selectors.
  15114. * var elements = _.attempt(function(selector) {
  15115. * return document.querySelectorAll(selector);
  15116. * }, '>_>');
  15117. *
  15118. * if (_.isError(elements)) {
  15119. * elements = [];
  15120. * }
  15121. */
  15122. var attempt = baseRest(function(func, args) {
  15123. try {
  15124. return apply(func, undefined, args);
  15125. } catch (e) {
  15126. return isError(e) ? e : new Error(e);
  15127. }
  15128. });
  15129. /**
  15130. * Binds methods of an object to the object itself, overwriting the existing
  15131. * method.
  15132. *
  15133. * **Note:** This method doesn't set the "length" property of bound functions.
  15134. *
  15135. * @static
  15136. * @since 0.1.0
  15137. * @memberOf _
  15138. * @category Util
  15139. * @param {Object} object The object to bind and assign the bound methods to.
  15140. * @param {...(string|string[])} methodNames The object method names to bind.
  15141. * @returns {Object} Returns `object`.
  15142. * @example
  15143. *
  15144. * var view = {
  15145. * 'label': 'docs',
  15146. * 'click': function() {
  15147. * console.log('clicked ' + this.label);
  15148. * }
  15149. * };
  15150. *
  15151. * _.bindAll(view, ['click']);
  15152. * jQuery(element).on('click', view.click);
  15153. * // => Logs 'clicked docs' when clicked.
  15154. */
  15155. var bindAll = flatRest(function(object, methodNames) {
  15156. arrayEach(methodNames, function(key) {
  15157. key = toKey(key);
  15158. baseAssignValue(object, key, bind(object[key], object));
  15159. });
  15160. return object;
  15161. });
  15162. /**
  15163. * Creates a function that iterates over `pairs` and invokes the corresponding
  15164. * function of the first predicate to return truthy. The predicate-function
  15165. * pairs are invoked with the `this` binding and arguments of the created
  15166. * function.
  15167. *
  15168. * @static
  15169. * @memberOf _
  15170. * @since 4.0.0
  15171. * @category Util
  15172. * @param {Array} pairs The predicate-function pairs.
  15173. * @returns {Function} Returns the new composite function.
  15174. * @example
  15175. *
  15176. * var func = _.cond([
  15177. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  15178. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  15179. * [_.stubTrue, _.constant('no match')]
  15180. * ]);
  15181. *
  15182. * func({ 'a': 1, 'b': 2 });
  15183. * // => 'matches A'
  15184. *
  15185. * func({ 'a': 0, 'b': 1 });
  15186. * // => 'matches B'
  15187. *
  15188. * func({ 'a': '1', 'b': '2' });
  15189. * // => 'no match'
  15190. */
  15191. function cond(pairs) {
  15192. var length = pairs == null ? 0 : pairs.length,
  15193. toIteratee = getIteratee();
  15194. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  15195. if (typeof pair[1] != 'function') {
  15196. throw new TypeError(FUNC_ERROR_TEXT);
  15197. }
  15198. return [toIteratee(pair[0]), pair[1]];
  15199. });
  15200. return baseRest(function(args) {
  15201. var index = -1;
  15202. while (++index < length) {
  15203. var pair = pairs[index];
  15204. if (apply(pair[0], this, args)) {
  15205. return apply(pair[1], this, args);
  15206. }
  15207. }
  15208. });
  15209. }
  15210. /**
  15211. * Creates a function that invokes the predicate properties of `source` with
  15212. * the corresponding property values of a given object, returning `true` if
  15213. * all predicates return truthy, else `false`.
  15214. *
  15215. * **Note:** The created function is equivalent to `_.conformsTo` with
  15216. * `source` partially applied.
  15217. *
  15218. * @static
  15219. * @memberOf _
  15220. * @since 4.0.0
  15221. * @category Util
  15222. * @param {Object} source The object of property predicates to conform to.
  15223. * @returns {Function} Returns the new spec function.
  15224. * @example
  15225. *
  15226. * var objects = [
  15227. * { 'a': 2, 'b': 1 },
  15228. * { 'a': 1, 'b': 2 }
  15229. * ];
  15230. *
  15231. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  15232. * // => [{ 'a': 1, 'b': 2 }]
  15233. */
  15234. function conforms(source) {
  15235. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  15236. }
  15237. /**
  15238. * Creates a function that returns `value`.
  15239. *
  15240. * @static
  15241. * @memberOf _
  15242. * @since 2.4.0
  15243. * @category Util
  15244. * @param {*} value The value to return from the new function.
  15245. * @returns {Function} Returns the new constant function.
  15246. * @example
  15247. *
  15248. * var objects = _.times(2, _.constant({ 'a': 1 }));
  15249. *
  15250. * console.log(objects);
  15251. * // => [{ 'a': 1 }, { 'a': 1 }]
  15252. *
  15253. * console.log(objects[0] === objects[1]);
  15254. * // => true
  15255. */
  15256. function constant(value) {
  15257. return function() {
  15258. return value;
  15259. };
  15260. }
  15261. /**
  15262. * Checks `value` to determine whether a default value should be returned in
  15263. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  15264. * or `undefined`.
  15265. *
  15266. * @static
  15267. * @memberOf _
  15268. * @since 4.14.0
  15269. * @category Util
  15270. * @param {*} value The value to check.
  15271. * @param {*} defaultValue The default value.
  15272. * @returns {*} Returns the resolved value.
  15273. * @example
  15274. *
  15275. * _.defaultTo(1, 10);
  15276. * // => 1
  15277. *
  15278. * _.defaultTo(undefined, 10);
  15279. * // => 10
  15280. */
  15281. function defaultTo(value, defaultValue) {
  15282. return (value == null || value !== value) ? defaultValue : value;
  15283. }
  15284. /**
  15285. * Creates a function that returns the result of invoking the given functions
  15286. * with the `this` binding of the created function, where each successive
  15287. * invocation is supplied the return value of the previous.
  15288. *
  15289. * @static
  15290. * @memberOf _
  15291. * @since 3.0.0
  15292. * @category Util
  15293. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  15294. * @returns {Function} Returns the new composite function.
  15295. * @see _.flowRight
  15296. * @example
  15297. *
  15298. * function square(n) {
  15299. * return n * n;
  15300. * }
  15301. *
  15302. * var addSquare = _.flow([_.add, square]);
  15303. * addSquare(1, 2);
  15304. * // => 9
  15305. */
  15306. var flow = createFlow();
  15307. /**
  15308. * This method is like `_.flow` except that it creates a function that
  15309. * invokes the given functions from right to left.
  15310. *
  15311. * @static
  15312. * @since 3.0.0
  15313. * @memberOf _
  15314. * @category Util
  15315. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  15316. * @returns {Function} Returns the new composite function.
  15317. * @see _.flow
  15318. * @example
  15319. *
  15320. * function square(n) {
  15321. * return n * n;
  15322. * }
  15323. *
  15324. * var addSquare = _.flowRight([square, _.add]);
  15325. * addSquare(1, 2);
  15326. * // => 9
  15327. */
  15328. var flowRight = createFlow(true);
  15329. /**
  15330. * This method returns the first argument it receives.
  15331. *
  15332. * @static
  15333. * @since 0.1.0
  15334. * @memberOf _
  15335. * @category Util
  15336. * @param {*} value Any value.
  15337. * @returns {*} Returns `value`.
  15338. * @example
  15339. *
  15340. * var object = { 'a': 1 };
  15341. *
  15342. * console.log(_.identity(object) === object);
  15343. * // => true
  15344. */
  15345. function identity(value) {
  15346. return value;
  15347. }
  15348. /**
  15349. * Creates a function that invokes `func` with the arguments of the created
  15350. * function. If `func` is a property name, the created function returns the
  15351. * property value for a given element. If `func` is an array or object, the
  15352. * created function returns `true` for elements that contain the equivalent
  15353. * source properties, otherwise it returns `false`.
  15354. *
  15355. * @static
  15356. * @since 4.0.0
  15357. * @memberOf _
  15358. * @category Util
  15359. * @param {*} [func=_.identity] The value to convert to a callback.
  15360. * @returns {Function} Returns the callback.
  15361. * @example
  15362. *
  15363. * var users = [
  15364. * { 'user': 'barney', 'age': 36, 'active': true },
  15365. * { 'user': 'fred', 'age': 40, 'active': false }
  15366. * ];
  15367. *
  15368. * // The `_.matches` iteratee shorthand.
  15369. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  15370. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  15371. *
  15372. * // The `_.matchesProperty` iteratee shorthand.
  15373. * _.filter(users, _.iteratee(['user', 'fred']));
  15374. * // => [{ 'user': 'fred', 'age': 40 }]
  15375. *
  15376. * // The `_.property` iteratee shorthand.
  15377. * _.map(users, _.iteratee('user'));
  15378. * // => ['barney', 'fred']
  15379. *
  15380. * // Create custom iteratee shorthands.
  15381. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  15382. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  15383. * return func.test(string);
  15384. * };
  15385. * });
  15386. *
  15387. * _.filter(['abc', 'def'], /ef/);
  15388. * // => ['def']
  15389. */
  15390. function iteratee(func) {
  15391. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  15392. }
  15393. /**
  15394. * Creates a function that performs a partial deep comparison between a given
  15395. * object and `source`, returning `true` if the given object has equivalent
  15396. * property values, else `false`.
  15397. *
  15398. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  15399. * partially applied.
  15400. *
  15401. * Partial comparisons will match empty array and empty object `source`
  15402. * values against any array or object value, respectively. See `_.isEqual`
  15403. * for a list of supported value comparisons.
  15404. *
  15405. * @static
  15406. * @memberOf _
  15407. * @since 3.0.0
  15408. * @category Util
  15409. * @param {Object} source The object of property values to match.
  15410. * @returns {Function} Returns the new spec function.
  15411. * @example
  15412. *
  15413. * var objects = [
  15414. * { 'a': 1, 'b': 2, 'c': 3 },
  15415. * { 'a': 4, 'b': 5, 'c': 6 }
  15416. * ];
  15417. *
  15418. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  15419. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  15420. */
  15421. function matches(source) {
  15422. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  15423. }
  15424. /**
  15425. * Creates a function that performs a partial deep comparison between the
  15426. * value at `path` of a given object to `srcValue`, returning `true` if the
  15427. * object value is equivalent, else `false`.
  15428. *
  15429. * **Note:** Partial comparisons will match empty array and empty object
  15430. * `srcValue` values against any array or object value, respectively. See
  15431. * `_.isEqual` for a list of supported value comparisons.
  15432. *
  15433. * @static
  15434. * @memberOf _
  15435. * @since 3.2.0
  15436. * @category Util
  15437. * @param {Array|string} path The path of the property to get.
  15438. * @param {*} srcValue The value to match.
  15439. * @returns {Function} Returns the new spec function.
  15440. * @example
  15441. *
  15442. * var objects = [
  15443. * { 'a': 1, 'b': 2, 'c': 3 },
  15444. * { 'a': 4, 'b': 5, 'c': 6 }
  15445. * ];
  15446. *
  15447. * _.find(objects, _.matchesProperty('a', 4));
  15448. * // => { 'a': 4, 'b': 5, 'c': 6 }
  15449. */
  15450. function matchesProperty(path, srcValue) {
  15451. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  15452. }
  15453. /**
  15454. * Creates a function that invokes the method at `path` of a given object.
  15455. * Any additional arguments are provided to the invoked method.
  15456. *
  15457. * @static
  15458. * @memberOf _
  15459. * @since 3.7.0
  15460. * @category Util
  15461. * @param {Array|string} path The path of the method to invoke.
  15462. * @param {...*} [args] The arguments to invoke the method with.
  15463. * @returns {Function} Returns the new invoker function.
  15464. * @example
  15465. *
  15466. * var objects = [
  15467. * { 'a': { 'b': _.constant(2) } },
  15468. * { 'a': { 'b': _.constant(1) } }
  15469. * ];
  15470. *
  15471. * _.map(objects, _.method('a.b'));
  15472. * // => [2, 1]
  15473. *
  15474. * _.map(objects, _.method(['a', 'b']));
  15475. * // => [2, 1]
  15476. */
  15477. var method = baseRest(function(path, args) {
  15478. return function(object) {
  15479. return baseInvoke(object, path, args);
  15480. };
  15481. });
  15482. /**
  15483. * The opposite of `_.method`; this method creates a function that invokes
  15484. * the method at a given path of `object`. Any additional arguments are
  15485. * provided to the invoked method.
  15486. *
  15487. * @static
  15488. * @memberOf _
  15489. * @since 3.7.0
  15490. * @category Util
  15491. * @param {Object} object The object to query.
  15492. * @param {...*} [args] The arguments to invoke the method with.
  15493. * @returns {Function} Returns the new invoker function.
  15494. * @example
  15495. *
  15496. * var array = _.times(3, _.constant),
  15497. * object = { 'a': array, 'b': array, 'c': array };
  15498. *
  15499. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  15500. * // => [2, 0]
  15501. *
  15502. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  15503. * // => [2, 0]
  15504. */
  15505. var methodOf = baseRest(function(object, args) {
  15506. return function(path) {
  15507. return baseInvoke(object, path, args);
  15508. };
  15509. });
  15510. /**
  15511. * Adds all own enumerable string keyed function properties of a source
  15512. * object to the destination object. If `object` is a function, then methods
  15513. * are added to its prototype as well.
  15514. *
  15515. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  15516. * avoid conflicts caused by modifying the original.
  15517. *
  15518. * @static
  15519. * @since 0.1.0
  15520. * @memberOf _
  15521. * @category Util
  15522. * @param {Function|Object} [object=lodash] The destination object.
  15523. * @param {Object} source The object of functions to add.
  15524. * @param {Object} [options={}] The options object.
  15525. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  15526. * @returns {Function|Object} Returns `object`.
  15527. * @example
  15528. *
  15529. * function vowels(string) {
  15530. * return _.filter(string, function(v) {
  15531. * return /[aeiou]/i.test(v);
  15532. * });
  15533. * }
  15534. *
  15535. * _.mixin({ 'vowels': vowels });
  15536. * _.vowels('fred');
  15537. * // => ['e']
  15538. *
  15539. * _('fred').vowels().value();
  15540. * // => ['e']
  15541. *
  15542. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  15543. * _('fred').vowels();
  15544. * // => ['e']
  15545. */
  15546. function mixin(object, source, options) {
  15547. var props = keys(source),
  15548. methodNames = baseFunctions(source, props);
  15549. if (options == null &&
  15550. !(isObject(source) && (methodNames.length || !props.length))) {
  15551. options = source;
  15552. source = object;
  15553. object = this;
  15554. methodNames = baseFunctions(source, keys(source));
  15555. }
  15556. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  15557. isFunc = isFunction(object);
  15558. arrayEach(methodNames, function(methodName) {
  15559. var func = source[methodName];
  15560. object[methodName] = func;
  15561. if (isFunc) {
  15562. object.prototype[methodName] = function() {
  15563. var chainAll = this.__chain__;
  15564. if (chain || chainAll) {
  15565. var result = object(this.__wrapped__),
  15566. actions = result.__actions__ = copyArray(this.__actions__);
  15567. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  15568. result.__chain__ = chainAll;
  15569. return result;
  15570. }
  15571. return func.apply(object, arrayPush([this.value()], arguments));
  15572. };
  15573. }
  15574. });
  15575. return object;
  15576. }
  15577. /**
  15578. * Reverts the `_` variable to its previous value and returns a reference to
  15579. * the `lodash` function.
  15580. *
  15581. * @static
  15582. * @since 0.1.0
  15583. * @memberOf _
  15584. * @category Util
  15585. * @returns {Function} Returns the `lodash` function.
  15586. * @example
  15587. *
  15588. * var lodash = _.noConflict();
  15589. */
  15590. function noConflict() {
  15591. if (root._ === this) {
  15592. root._ = oldDash;
  15593. }
  15594. return this;
  15595. }
  15596. /**
  15597. * This method returns `undefined`.
  15598. *
  15599. * @static
  15600. * @memberOf _
  15601. * @since 2.3.0
  15602. * @category Util
  15603. * @example
  15604. *
  15605. * _.times(2, _.noop);
  15606. * // => [undefined, undefined]
  15607. */
  15608. function noop() {
  15609. // No operation performed.
  15610. }
  15611. /**
  15612. * Creates a function that gets the argument at index `n`. If `n` is negative,
  15613. * the nth argument from the end is returned.
  15614. *
  15615. * @static
  15616. * @memberOf _
  15617. * @since 4.0.0
  15618. * @category Util
  15619. * @param {number} [n=0] The index of the argument to return.
  15620. * @returns {Function} Returns the new pass-thru function.
  15621. * @example
  15622. *
  15623. * var func = _.nthArg(1);
  15624. * func('a', 'b', 'c', 'd');
  15625. * // => 'b'
  15626. *
  15627. * var func = _.nthArg(-2);
  15628. * func('a', 'b', 'c', 'd');
  15629. * // => 'c'
  15630. */
  15631. function nthArg(n) {
  15632. n = toInteger(n);
  15633. return baseRest(function(args) {
  15634. return baseNth(args, n);
  15635. });
  15636. }
  15637. /**
  15638. * Creates a function that invokes `iteratees` with the arguments it receives
  15639. * and returns their results.
  15640. *
  15641. * @static
  15642. * @memberOf _
  15643. * @since 4.0.0
  15644. * @category Util
  15645. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  15646. * The iteratees to invoke.
  15647. * @returns {Function} Returns the new function.
  15648. * @example
  15649. *
  15650. * var func = _.over([Math.max, Math.min]);
  15651. *
  15652. * func(1, 2, 3, 4);
  15653. * // => [4, 1]
  15654. */
  15655. var over = createOver(arrayMap);
  15656. /**
  15657. * Creates a function that checks if **all** of the `predicates` return
  15658. * truthy when invoked with the arguments it receives.
  15659. *
  15660. * @static
  15661. * @memberOf _
  15662. * @since 4.0.0
  15663. * @category Util
  15664. * @param {...(Function|Function[])} [predicates=[_.identity]]
  15665. * The predicates to check.
  15666. * @returns {Function} Returns the new function.
  15667. * @example
  15668. *
  15669. * var func = _.overEvery([Boolean, isFinite]);
  15670. *
  15671. * func('1');
  15672. * // => true
  15673. *
  15674. * func(null);
  15675. * // => false
  15676. *
  15677. * func(NaN);
  15678. * // => false
  15679. */
  15680. var overEvery = createOver(arrayEvery);
  15681. /**
  15682. * Creates a function that checks if **any** of the `predicates` return
  15683. * truthy when invoked with the arguments it receives.
  15684. *
  15685. * @static
  15686. * @memberOf _
  15687. * @since 4.0.0
  15688. * @category Util
  15689. * @param {...(Function|Function[])} [predicates=[_.identity]]
  15690. * The predicates to check.
  15691. * @returns {Function} Returns the new function.
  15692. * @example
  15693. *
  15694. * var func = _.overSome([Boolean, isFinite]);
  15695. *
  15696. * func('1');
  15697. * // => true
  15698. *
  15699. * func(null);
  15700. * // => true
  15701. *
  15702. * func(NaN);
  15703. * // => false
  15704. */
  15705. var overSome = createOver(arraySome);
  15706. /**
  15707. * Creates a function that returns the value at `path` of a given object.
  15708. *
  15709. * @static
  15710. * @memberOf _
  15711. * @since 2.4.0
  15712. * @category Util
  15713. * @param {Array|string} path The path of the property to get.
  15714. * @returns {Function} Returns the new accessor function.
  15715. * @example
  15716. *
  15717. * var objects = [
  15718. * { 'a': { 'b': 2 } },
  15719. * { 'a': { 'b': 1 } }
  15720. * ];
  15721. *
  15722. * _.map(objects, _.property('a.b'));
  15723. * // => [2, 1]
  15724. *
  15725. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  15726. * // => [1, 2]
  15727. */
  15728. function property(path) {
  15729. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  15730. }
  15731. /**
  15732. * The opposite of `_.property`; this method creates a function that returns
  15733. * the value at a given path of `object`.
  15734. *
  15735. * @static
  15736. * @memberOf _
  15737. * @since 3.0.0
  15738. * @category Util
  15739. * @param {Object} object The object to query.
  15740. * @returns {Function} Returns the new accessor function.
  15741. * @example
  15742. *
  15743. * var array = [0, 1, 2],
  15744. * object = { 'a': array, 'b': array, 'c': array };
  15745. *
  15746. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  15747. * // => [2, 0]
  15748. *
  15749. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  15750. * // => [2, 0]
  15751. */
  15752. function propertyOf(object) {
  15753. return function(path) {
  15754. return object == null ? undefined : baseGet(object, path);
  15755. };
  15756. }
  15757. /**
  15758. * Creates an array of numbers (positive and/or negative) progressing from
  15759. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  15760. * `start` is specified without an `end` or `step`. If `end` is not specified,
  15761. * it's set to `start` with `start` then set to `0`.
  15762. *
  15763. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  15764. * floating-point values which can produce unexpected results.
  15765. *
  15766. * @static
  15767. * @since 0.1.0
  15768. * @memberOf _
  15769. * @category Util
  15770. * @param {number} [start=0] The start of the range.
  15771. * @param {number} end The end of the range.
  15772. * @param {number} [step=1] The value to increment or decrement by.
  15773. * @returns {Array} Returns the range of numbers.
  15774. * @see _.inRange, _.rangeRight
  15775. * @example
  15776. *
  15777. * _.range(4);
  15778. * // => [0, 1, 2, 3]
  15779. *
  15780. * _.range(-4);
  15781. * // => [0, -1, -2, -3]
  15782. *
  15783. * _.range(1, 5);
  15784. * // => [1, 2, 3, 4]
  15785. *
  15786. * _.range(0, 20, 5);
  15787. * // => [0, 5, 10, 15]
  15788. *
  15789. * _.range(0, -4, -1);
  15790. * // => [0, -1, -2, -3]
  15791. *
  15792. * _.range(1, 4, 0);
  15793. * // => [1, 1, 1]
  15794. *
  15795. * _.range(0);
  15796. * // => []
  15797. */
  15798. var range = createRange();
  15799. /**
  15800. * This method is like `_.range` except that it populates values in
  15801. * descending order.
  15802. *
  15803. * @static
  15804. * @memberOf _
  15805. * @since 4.0.0
  15806. * @category Util
  15807. * @param {number} [start=0] The start of the range.
  15808. * @param {number} end The end of the range.
  15809. * @param {number} [step=1] The value to increment or decrement by.
  15810. * @returns {Array} Returns the range of numbers.
  15811. * @see _.inRange, _.range
  15812. * @example
  15813. *
  15814. * _.rangeRight(4);
  15815. * // => [3, 2, 1, 0]
  15816. *
  15817. * _.rangeRight(-4);
  15818. * // => [-3, -2, -1, 0]
  15819. *
  15820. * _.rangeRight(1, 5);
  15821. * // => [4, 3, 2, 1]
  15822. *
  15823. * _.rangeRight(0, 20, 5);
  15824. * // => [15, 10, 5, 0]
  15825. *
  15826. * _.rangeRight(0, -4, -1);
  15827. * // => [-3, -2, -1, 0]
  15828. *
  15829. * _.rangeRight(1, 4, 0);
  15830. * // => [1, 1, 1]
  15831. *
  15832. * _.rangeRight(0);
  15833. * // => []
  15834. */
  15835. var rangeRight = createRange(true);
  15836. /**
  15837. * This method returns a new empty array.
  15838. *
  15839. * @static
  15840. * @memberOf _
  15841. * @since 4.13.0
  15842. * @category Util
  15843. * @returns {Array} Returns the new empty array.
  15844. * @example
  15845. *
  15846. * var arrays = _.times(2, _.stubArray);
  15847. *
  15848. * console.log(arrays);
  15849. * // => [[], []]
  15850. *
  15851. * console.log(arrays[0] === arrays[1]);
  15852. * // => false
  15853. */
  15854. function stubArray() {
  15855. return [];
  15856. }
  15857. /**
  15858. * This method returns `false`.
  15859. *
  15860. * @static
  15861. * @memberOf _
  15862. * @since 4.13.0
  15863. * @category Util
  15864. * @returns {boolean} Returns `false`.
  15865. * @example
  15866. *
  15867. * _.times(2, _.stubFalse);
  15868. * // => [false, false]
  15869. */
  15870. function stubFalse() {
  15871. return false;
  15872. }
  15873. /**
  15874. * This method returns a new empty object.
  15875. *
  15876. * @static
  15877. * @memberOf _
  15878. * @since 4.13.0
  15879. * @category Util
  15880. * @returns {Object} Returns the new empty object.
  15881. * @example
  15882. *
  15883. * var objects = _.times(2, _.stubObject);
  15884. *
  15885. * console.log(objects);
  15886. * // => [{}, {}]
  15887. *
  15888. * console.log(objects[0] === objects[1]);
  15889. * // => false
  15890. */
  15891. function stubObject() {
  15892. return {};
  15893. }
  15894. /**
  15895. * This method returns an empty string.
  15896. *
  15897. * @static
  15898. * @memberOf _
  15899. * @since 4.13.0
  15900. * @category Util
  15901. * @returns {string} Returns the empty string.
  15902. * @example
  15903. *
  15904. * _.times(2, _.stubString);
  15905. * // => ['', '']
  15906. */
  15907. function stubString() {
  15908. return '';
  15909. }
  15910. /**
  15911. * This method returns `true`.
  15912. *
  15913. * @static
  15914. * @memberOf _
  15915. * @since 4.13.0
  15916. * @category Util
  15917. * @returns {boolean} Returns `true`.
  15918. * @example
  15919. *
  15920. * _.times(2, _.stubTrue);
  15921. * // => [true, true]
  15922. */
  15923. function stubTrue() {
  15924. return true;
  15925. }
  15926. /**
  15927. * Invokes the iteratee `n` times, returning an array of the results of
  15928. * each invocation. The iteratee is invoked with one argument; (index).
  15929. *
  15930. * @static
  15931. * @since 0.1.0
  15932. * @memberOf _
  15933. * @category Util
  15934. * @param {number} n The number of times to invoke `iteratee`.
  15935. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  15936. * @returns {Array} Returns the array of results.
  15937. * @example
  15938. *
  15939. * _.times(3, String);
  15940. * // => ['0', '1', '2']
  15941. *
  15942. * _.times(4, _.constant(0));
  15943. * // => [0, 0, 0, 0]
  15944. */
  15945. function times(n, iteratee) {
  15946. n = toInteger(n);
  15947. if (n < 1 || n > MAX_SAFE_INTEGER) {
  15948. return [];
  15949. }
  15950. var index = MAX_ARRAY_LENGTH,
  15951. length = nativeMin(n, MAX_ARRAY_LENGTH);
  15952. iteratee = getIteratee(iteratee);
  15953. n -= MAX_ARRAY_LENGTH;
  15954. var result = baseTimes(length, iteratee);
  15955. while (++index < n) {
  15956. iteratee(index);
  15957. }
  15958. return result;
  15959. }
  15960. /**
  15961. * Converts `value` to a property path array.
  15962. *
  15963. * @static
  15964. * @memberOf _
  15965. * @since 4.0.0
  15966. * @category Util
  15967. * @param {*} value The value to convert.
  15968. * @returns {Array} Returns the new property path array.
  15969. * @example
  15970. *
  15971. * _.toPath('a.b.c');
  15972. * // => ['a', 'b', 'c']
  15973. *
  15974. * _.toPath('a[0].b.c');
  15975. * // => ['a', '0', 'b', 'c']
  15976. */
  15977. function toPath(value) {
  15978. if (isArray(value)) {
  15979. return arrayMap(value, toKey);
  15980. }
  15981. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  15982. }
  15983. /**
  15984. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  15985. *
  15986. * @static
  15987. * @since 0.1.0
  15988. * @memberOf _
  15989. * @category Util
  15990. * @param {string} [prefix=''] The value to prefix the ID with.
  15991. * @returns {string} Returns the unique ID.
  15992. * @example
  15993. *
  15994. * _.uniqueId('contact_');
  15995. * // => 'contact_104'
  15996. *
  15997. * _.uniqueId();
  15998. * // => '105'
  15999. */
  16000. function uniqueId(prefix) {
  16001. var id = ++idCounter;
  16002. return toString(prefix) + id;
  16003. }
  16004. /*------------------------------------------------------------------------*/
  16005. /**
  16006. * Adds two numbers.
  16007. *
  16008. * @static
  16009. * @memberOf _
  16010. * @since 3.4.0
  16011. * @category Math
  16012. * @param {number} augend The first number in an addition.
  16013. * @param {number} addend The second number in an addition.
  16014. * @returns {number} Returns the total.
  16015. * @example
  16016. *
  16017. * _.add(6, 4);
  16018. * // => 10
  16019. */
  16020. var add = createMathOperation(function(augend, addend) {
  16021. return augend + addend;
  16022. }, 0);
  16023. /**
  16024. * Computes `number` rounded up to `precision`.
  16025. *
  16026. * @static
  16027. * @memberOf _
  16028. * @since 3.10.0
  16029. * @category Math
  16030. * @param {number} number The number to round up.
  16031. * @param {number} [precision=0] The precision to round up to.
  16032. * @returns {number} Returns the rounded up number.
  16033. * @example
  16034. *
  16035. * _.ceil(4.006);
  16036. * // => 5
  16037. *
  16038. * _.ceil(6.004, 2);
  16039. * // => 6.01
  16040. *
  16041. * _.ceil(6040, -2);
  16042. * // => 6100
  16043. */
  16044. var ceil = createRound('ceil');
  16045. /**
  16046. * Divide two numbers.
  16047. *
  16048. * @static
  16049. * @memberOf _
  16050. * @since 4.7.0
  16051. * @category Math
  16052. * @param {number} dividend The first number in a division.
  16053. * @param {number} divisor The second number in a division.
  16054. * @returns {number} Returns the quotient.
  16055. * @example
  16056. *
  16057. * _.divide(6, 4);
  16058. * // => 1.5
  16059. */
  16060. var divide = createMathOperation(function(dividend, divisor) {
  16061. return dividend / divisor;
  16062. }, 1);
  16063. /**
  16064. * Computes `number` rounded down to `precision`.
  16065. *
  16066. * @static
  16067. * @memberOf _
  16068. * @since 3.10.0
  16069. * @category Math
  16070. * @param {number} number The number to round down.
  16071. * @param {number} [precision=0] The precision to round down to.
  16072. * @returns {number} Returns the rounded down number.
  16073. * @example
  16074. *
  16075. * _.floor(4.006);
  16076. * // => 4
  16077. *
  16078. * _.floor(0.046, 2);
  16079. * // => 0.04
  16080. *
  16081. * _.floor(4060, -2);
  16082. * // => 4000
  16083. */
  16084. var floor = createRound('floor');
  16085. /**
  16086. * Computes the maximum value of `array`. If `array` is empty or falsey,
  16087. * `undefined` is returned.
  16088. *
  16089. * @static
  16090. * @since 0.1.0
  16091. * @memberOf _
  16092. * @category Math
  16093. * @param {Array} array The array to iterate over.
  16094. * @returns {*} Returns the maximum value.
  16095. * @example
  16096. *
  16097. * _.max([4, 2, 8, 6]);
  16098. * // => 8
  16099. *
  16100. * _.max([]);
  16101. * // => undefined
  16102. */
  16103. function max(array) {
  16104. return (array && array.length)
  16105. ? baseExtremum(array, identity, baseGt)
  16106. : undefined;
  16107. }
  16108. /**
  16109. * This method is like `_.max` except that it accepts `iteratee` which is
  16110. * invoked for each element in `array` to generate the criterion by which
  16111. * the value is ranked. The iteratee is invoked with one argument: (value).
  16112. *
  16113. * @static
  16114. * @memberOf _
  16115. * @since 4.0.0
  16116. * @category Math
  16117. * @param {Array} array The array to iterate over.
  16118. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16119. * @returns {*} Returns the maximum value.
  16120. * @example
  16121. *
  16122. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16123. *
  16124. * _.maxBy(objects, function(o) { return o.n; });
  16125. * // => { 'n': 2 }
  16126. *
  16127. * // The `_.property` iteratee shorthand.
  16128. * _.maxBy(objects, 'n');
  16129. * // => { 'n': 2 }
  16130. */
  16131. function maxBy(array, iteratee) {
  16132. return (array && array.length)
  16133. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  16134. : undefined;
  16135. }
  16136. /**
  16137. * Computes the mean of the values in `array`.
  16138. *
  16139. * @static
  16140. * @memberOf _
  16141. * @since 4.0.0
  16142. * @category Math
  16143. * @param {Array} array The array to iterate over.
  16144. * @returns {number} Returns the mean.
  16145. * @example
  16146. *
  16147. * _.mean([4, 2, 8, 6]);
  16148. * // => 5
  16149. */
  16150. function mean(array) {
  16151. return baseMean(array, identity);
  16152. }
  16153. /**
  16154. * This method is like `_.mean` except that it accepts `iteratee` which is
  16155. * invoked for each element in `array` to generate the value to be averaged.
  16156. * The iteratee is invoked with one argument: (value).
  16157. *
  16158. * @static
  16159. * @memberOf _
  16160. * @since 4.7.0
  16161. * @category Math
  16162. * @param {Array} array The array to iterate over.
  16163. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16164. * @returns {number} Returns the mean.
  16165. * @example
  16166. *
  16167. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16168. *
  16169. * _.meanBy(objects, function(o) { return o.n; });
  16170. * // => 5
  16171. *
  16172. * // The `_.property` iteratee shorthand.
  16173. * _.meanBy(objects, 'n');
  16174. * // => 5
  16175. */
  16176. function meanBy(array, iteratee) {
  16177. return baseMean(array, getIteratee(iteratee, 2));
  16178. }
  16179. /**
  16180. * Computes the minimum value of `array`. If `array` is empty or falsey,
  16181. * `undefined` is returned.
  16182. *
  16183. * @static
  16184. * @since 0.1.0
  16185. * @memberOf _
  16186. * @category Math
  16187. * @param {Array} array The array to iterate over.
  16188. * @returns {*} Returns the minimum value.
  16189. * @example
  16190. *
  16191. * _.min([4, 2, 8, 6]);
  16192. * // => 2
  16193. *
  16194. * _.min([]);
  16195. * // => undefined
  16196. */
  16197. function min(array) {
  16198. return (array && array.length)
  16199. ? baseExtremum(array, identity, baseLt)
  16200. : undefined;
  16201. }
  16202. /**
  16203. * This method is like `_.min` except that it accepts `iteratee` which is
  16204. * invoked for each element in `array` to generate the criterion by which
  16205. * the value is ranked. The iteratee is invoked with one argument: (value).
  16206. *
  16207. * @static
  16208. * @memberOf _
  16209. * @since 4.0.0
  16210. * @category Math
  16211. * @param {Array} array The array to iterate over.
  16212. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16213. * @returns {*} Returns the minimum value.
  16214. * @example
  16215. *
  16216. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16217. *
  16218. * _.minBy(objects, function(o) { return o.n; });
  16219. * // => { 'n': 1 }
  16220. *
  16221. * // The `_.property` iteratee shorthand.
  16222. * _.minBy(objects, 'n');
  16223. * // => { 'n': 1 }
  16224. */
  16225. function minBy(array, iteratee) {
  16226. return (array && array.length)
  16227. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  16228. : undefined;
  16229. }
  16230. /**
  16231. * Multiply two numbers.
  16232. *
  16233. * @static
  16234. * @memberOf _
  16235. * @since 4.7.0
  16236. * @category Math
  16237. * @param {number} multiplier The first number in a multiplication.
  16238. * @param {number} multiplicand The second number in a multiplication.
  16239. * @returns {number} Returns the product.
  16240. * @example
  16241. *
  16242. * _.multiply(6, 4);
  16243. * // => 24
  16244. */
  16245. var multiply = createMathOperation(function(multiplier, multiplicand) {
  16246. return multiplier * multiplicand;
  16247. }, 1);
  16248. /**
  16249. * Computes `number` rounded to `precision`.
  16250. *
  16251. * @static
  16252. * @memberOf _
  16253. * @since 3.10.0
  16254. * @category Math
  16255. * @param {number} number The number to round.
  16256. * @param {number} [precision=0] The precision to round to.
  16257. * @returns {number} Returns the rounded number.
  16258. * @example
  16259. *
  16260. * _.round(4.006);
  16261. * // => 4
  16262. *
  16263. * _.round(4.006, 2);
  16264. * // => 4.01
  16265. *
  16266. * _.round(4060, -2);
  16267. * // => 4100
  16268. */
  16269. var round = createRound('round');
  16270. /**
  16271. * Subtract two numbers.
  16272. *
  16273. * @static
  16274. * @memberOf _
  16275. * @since 4.0.0
  16276. * @category Math
  16277. * @param {number} minuend The first number in a subtraction.
  16278. * @param {number} subtrahend The second number in a subtraction.
  16279. * @returns {number} Returns the difference.
  16280. * @example
  16281. *
  16282. * _.subtract(6, 4);
  16283. * // => 2
  16284. */
  16285. var subtract = createMathOperation(function(minuend, subtrahend) {
  16286. return minuend - subtrahend;
  16287. }, 0);
  16288. /**
  16289. * Computes the sum of the values in `array`.
  16290. *
  16291. * @static
  16292. * @memberOf _
  16293. * @since 3.4.0
  16294. * @category Math
  16295. * @param {Array} array The array to iterate over.
  16296. * @returns {number} Returns the sum.
  16297. * @example
  16298. *
  16299. * _.sum([4, 2, 8, 6]);
  16300. * // => 20
  16301. */
  16302. function sum(array) {
  16303. return (array && array.length)
  16304. ? baseSum(array, identity)
  16305. : 0;
  16306. }
  16307. /**
  16308. * This method is like `_.sum` except that it accepts `iteratee` which is
  16309. * invoked for each element in `array` to generate the value to be summed.
  16310. * The iteratee is invoked with one argument: (value).
  16311. *
  16312. * @static
  16313. * @memberOf _
  16314. * @since 4.0.0
  16315. * @category Math
  16316. * @param {Array} array The array to iterate over.
  16317. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16318. * @returns {number} Returns the sum.
  16319. * @example
  16320. *
  16321. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16322. *
  16323. * _.sumBy(objects, function(o) { return o.n; });
  16324. * // => 20
  16325. *
  16326. * // The `_.property` iteratee shorthand.
  16327. * _.sumBy(objects, 'n');
  16328. * // => 20
  16329. */
  16330. function sumBy(array, iteratee) {
  16331. return (array && array.length)
  16332. ? baseSum(array, getIteratee(iteratee, 2))
  16333. : 0;
  16334. }
  16335. /*------------------------------------------------------------------------*/
  16336. // Add methods that return wrapped values in chain sequences.
  16337. lodash.after = after;
  16338. lodash.ary = ary;
  16339. lodash.assign = assign;
  16340. lodash.assignIn = assignIn;
  16341. lodash.assignInWith = assignInWith;
  16342. lodash.assignWith = assignWith;
  16343. lodash.at = at;
  16344. lodash.before = before;
  16345. lodash.bind = bind;
  16346. lodash.bindAll = bindAll;
  16347. lodash.bindKey = bindKey;
  16348. lodash.castArray = castArray;
  16349. lodash.chain = chain;
  16350. lodash.chunk = chunk;
  16351. lodash.compact = compact;
  16352. lodash.concat = concat;
  16353. lodash.cond = cond;
  16354. lodash.conforms = conforms;
  16355. lodash.constant = constant;
  16356. lodash.countBy = countBy;
  16357. lodash.create = create;
  16358. lodash.curry = curry;
  16359. lodash.curryRight = curryRight;
  16360. lodash.debounce = debounce;
  16361. lodash.defaults = defaults;
  16362. lodash.defaultsDeep = defaultsDeep;
  16363. lodash.defer = defer;
  16364. lodash.delay = delay;
  16365. lodash.difference = difference;
  16366. lodash.differenceBy = differenceBy;
  16367. lodash.differenceWith = differenceWith;
  16368. lodash.drop = drop;
  16369. lodash.dropRight = dropRight;
  16370. lodash.dropRightWhile = dropRightWhile;
  16371. lodash.dropWhile = dropWhile;
  16372. lodash.fill = fill;
  16373. lodash.filter = filter;
  16374. lodash.flatMap = flatMap;
  16375. lodash.flatMapDeep = flatMapDeep;
  16376. lodash.flatMapDepth = flatMapDepth;
  16377. lodash.flatten = flatten;
  16378. lodash.flattenDeep = flattenDeep;
  16379. lodash.flattenDepth = flattenDepth;
  16380. lodash.flip = flip;
  16381. lodash.flow = flow;
  16382. lodash.flowRight = flowRight;
  16383. lodash.fromPairs = fromPairs;
  16384. lodash.functions = functions;
  16385. lodash.functionsIn = functionsIn;
  16386. lodash.groupBy = groupBy;
  16387. lodash.initial = initial;
  16388. lodash.intersection = intersection;
  16389. lodash.intersectionBy = intersectionBy;
  16390. lodash.intersectionWith = intersectionWith;
  16391. lodash.invert = invert;
  16392. lodash.invertBy = invertBy;
  16393. lodash.invokeMap = invokeMap;
  16394. lodash.iteratee = iteratee;
  16395. lodash.keyBy = keyBy;
  16396. lodash.keys = keys;
  16397. lodash.keysIn = keysIn;
  16398. lodash.map = map;
  16399. lodash.mapKeys = mapKeys;
  16400. lodash.mapValues = mapValues;
  16401. lodash.matches = matches;
  16402. lodash.matchesProperty = matchesProperty;
  16403. lodash.memoize = memoize;
  16404. lodash.merge = merge;
  16405. lodash.mergeWith = mergeWith;
  16406. lodash.method = method;
  16407. lodash.methodOf = methodOf;
  16408. lodash.mixin = mixin;
  16409. lodash.negate = negate;
  16410. lodash.nthArg = nthArg;
  16411. lodash.omit = omit;
  16412. lodash.omitBy = omitBy;
  16413. lodash.once = once;
  16414. lodash.orderBy = orderBy;
  16415. lodash.over = over;
  16416. lodash.overArgs = overArgs;
  16417. lodash.overEvery = overEvery;
  16418. lodash.overSome = overSome;
  16419. lodash.partial = partial;
  16420. lodash.partialRight = partialRight;
  16421. lodash.partition = partition;
  16422. lodash.pick = pick;
  16423. lodash.pickBy = pickBy;
  16424. lodash.property = property;
  16425. lodash.propertyOf = propertyOf;
  16426. lodash.pull = pull;
  16427. lodash.pullAll = pullAll;
  16428. lodash.pullAllBy = pullAllBy;
  16429. lodash.pullAllWith = pullAllWith;
  16430. lodash.pullAt = pullAt;
  16431. lodash.range = range;
  16432. lodash.rangeRight = rangeRight;
  16433. lodash.rearg = rearg;
  16434. lodash.reject = reject;
  16435. lodash.remove = remove;
  16436. lodash.rest = rest;
  16437. lodash.reverse = reverse;
  16438. lodash.sampleSize = sampleSize;
  16439. lodash.set = set;
  16440. lodash.setWith = setWith;
  16441. lodash.shuffle = shuffle;
  16442. lodash.slice = slice;
  16443. lodash.sortBy = sortBy;
  16444. lodash.sortedUniq = sortedUniq;
  16445. lodash.sortedUniqBy = sortedUniqBy;
  16446. lodash.split = split;
  16447. lodash.spread = spread;
  16448. lodash.tail = tail;
  16449. lodash.take = take;
  16450. lodash.takeRight = takeRight;
  16451. lodash.takeRightWhile = takeRightWhile;
  16452. lodash.takeWhile = takeWhile;
  16453. lodash.tap = tap;
  16454. lodash.throttle = throttle;
  16455. lodash.thru = thru;
  16456. lodash.toArray = toArray;
  16457. lodash.toPairs = toPairs;
  16458. lodash.toPairsIn = toPairsIn;
  16459. lodash.toPath = toPath;
  16460. lodash.toPlainObject = toPlainObject;
  16461. lodash.transform = transform;
  16462. lodash.unary = unary;
  16463. lodash.union = union;
  16464. lodash.unionBy = unionBy;
  16465. lodash.unionWith = unionWith;
  16466. lodash.uniq = uniq;
  16467. lodash.uniqBy = uniqBy;
  16468. lodash.uniqWith = uniqWith;
  16469. lodash.unset = unset;
  16470. lodash.unzip = unzip;
  16471. lodash.unzipWith = unzipWith;
  16472. lodash.update = update;
  16473. lodash.updateWith = updateWith;
  16474. lodash.values = values;
  16475. lodash.valuesIn = valuesIn;
  16476. lodash.without = without;
  16477. lodash.words = words;
  16478. lodash.wrap = wrap;
  16479. lodash.xor = xor;
  16480. lodash.xorBy = xorBy;
  16481. lodash.xorWith = xorWith;
  16482. lodash.zip = zip;
  16483. lodash.zipObject = zipObject;
  16484. lodash.zipObjectDeep = zipObjectDeep;
  16485. lodash.zipWith = zipWith;
  16486. // Add aliases.
  16487. lodash.entries = toPairs;
  16488. lodash.entriesIn = toPairsIn;
  16489. lodash.extend = assignIn;
  16490. lodash.extendWith = assignInWith;
  16491. // Add methods to `lodash.prototype`.
  16492. mixin(lodash, lodash);
  16493. /*------------------------------------------------------------------------*/
  16494. // Add methods that return unwrapped values in chain sequences.
  16495. lodash.add = add;
  16496. lodash.attempt = attempt;
  16497. lodash.camelCase = camelCase;
  16498. lodash.capitalize = capitalize;
  16499. lodash.ceil = ceil;
  16500. lodash.clamp = clamp;
  16501. lodash.clone = clone;
  16502. lodash.cloneDeep = cloneDeep;
  16503. lodash.cloneDeepWith = cloneDeepWith;
  16504. lodash.cloneWith = cloneWith;
  16505. lodash.conformsTo = conformsTo;
  16506. lodash.deburr = deburr;
  16507. lodash.defaultTo = defaultTo;
  16508. lodash.divide = divide;
  16509. lodash.endsWith = endsWith;
  16510. lodash.eq = eq;
  16511. lodash.escape = escape;
  16512. lodash.escapeRegExp = escapeRegExp;
  16513. lodash.every = every;
  16514. lodash.find = find;
  16515. lodash.findIndex = findIndex;
  16516. lodash.findKey = findKey;
  16517. lodash.findLast = findLast;
  16518. lodash.findLastIndex = findLastIndex;
  16519. lodash.findLastKey = findLastKey;
  16520. lodash.floor = floor;
  16521. lodash.forEach = forEach;
  16522. lodash.forEachRight = forEachRight;
  16523. lodash.forIn = forIn;
  16524. lodash.forInRight = forInRight;
  16525. lodash.forOwn = forOwn;
  16526. lodash.forOwnRight = forOwnRight;
  16527. lodash.get = get;
  16528. lodash.gt = gt;
  16529. lodash.gte = gte;
  16530. lodash.has = has;
  16531. lodash.hasIn = hasIn;
  16532. lodash.head = head;
  16533. lodash.identity = identity;
  16534. lodash.includes = includes;
  16535. lodash.indexOf = indexOf;
  16536. lodash.inRange = inRange;
  16537. lodash.invoke = invoke;
  16538. lodash.isArguments = isArguments;
  16539. lodash.isArray = isArray;
  16540. lodash.isArrayBuffer = isArrayBuffer;
  16541. lodash.isArrayLike = isArrayLike;
  16542. lodash.isArrayLikeObject = isArrayLikeObject;
  16543. lodash.isBoolean = isBoolean;
  16544. lodash.isBuffer = isBuffer;
  16545. lodash.isDate = isDate;
  16546. lodash.isElement = isElement;
  16547. lodash.isEmpty = isEmpty;
  16548. lodash.isEqual = isEqual;
  16549. lodash.isEqualWith = isEqualWith;
  16550. lodash.isError = isError;
  16551. lodash.isFinite = isFinite;
  16552. lodash.isFunction = isFunction;
  16553. lodash.isInteger = isInteger;
  16554. lodash.isLength = isLength;
  16555. lodash.isMap = isMap;
  16556. lodash.isMatch = isMatch;
  16557. lodash.isMatchWith = isMatchWith;
  16558. lodash.isNaN = isNaN;
  16559. lodash.isNative = isNative;
  16560. lodash.isNil = isNil;
  16561. lodash.isNull = isNull;
  16562. lodash.isNumber = isNumber;
  16563. lodash.isObject = isObject;
  16564. lodash.isObjectLike = isObjectLike;
  16565. lodash.isPlainObject = isPlainObject;
  16566. lodash.isRegExp = isRegExp;
  16567. lodash.isSafeInteger = isSafeInteger;
  16568. lodash.isSet = isSet;
  16569. lodash.isString = isString;
  16570. lodash.isSymbol = isSymbol;
  16571. lodash.isTypedArray = isTypedArray;
  16572. lodash.isUndefined = isUndefined;
  16573. lodash.isWeakMap = isWeakMap;
  16574. lodash.isWeakSet = isWeakSet;
  16575. lodash.join = join;
  16576. lodash.kebabCase = kebabCase;
  16577. lodash.last = last;
  16578. lodash.lastIndexOf = lastIndexOf;
  16579. lodash.lowerCase = lowerCase;
  16580. lodash.lowerFirst = lowerFirst;
  16581. lodash.lt = lt;
  16582. lodash.lte = lte;
  16583. lodash.max = max;
  16584. lodash.maxBy = maxBy;
  16585. lodash.mean = mean;
  16586. lodash.meanBy = meanBy;
  16587. lodash.min = min;
  16588. lodash.minBy = minBy;
  16589. lodash.stubArray = stubArray;
  16590. lodash.stubFalse = stubFalse;
  16591. lodash.stubObject = stubObject;
  16592. lodash.stubString = stubString;
  16593. lodash.stubTrue = stubTrue;
  16594. lodash.multiply = multiply;
  16595. lodash.nth = nth;
  16596. lodash.noConflict = noConflict;
  16597. lodash.noop = noop;
  16598. lodash.now = now;
  16599. lodash.pad = pad;
  16600. lodash.padEnd = padEnd;
  16601. lodash.padStart = padStart;
  16602. lodash.parseInt = parseInt;
  16603. lodash.random = random;
  16604. lodash.reduce = reduce;
  16605. lodash.reduceRight = reduceRight;
  16606. lodash.repeat = repeat;
  16607. lodash.replace = replace;
  16608. lodash.result = result;
  16609. lodash.round = round;
  16610. lodash.runInContext = runInContext;
  16611. lodash.sample = sample;
  16612. lodash.size = size;
  16613. lodash.snakeCase = snakeCase;
  16614. lodash.some = some;
  16615. lodash.sortedIndex = sortedIndex;
  16616. lodash.sortedIndexBy = sortedIndexBy;
  16617. lodash.sortedIndexOf = sortedIndexOf;
  16618. lodash.sortedLastIndex = sortedLastIndex;
  16619. lodash.sortedLastIndexBy = sortedLastIndexBy;
  16620. lodash.sortedLastIndexOf = sortedLastIndexOf;
  16621. lodash.startCase = startCase;
  16622. lodash.startsWith = startsWith;
  16623. lodash.subtract = subtract;
  16624. lodash.sum = sum;
  16625. lodash.sumBy = sumBy;
  16626. lodash.template = template;
  16627. lodash.times = times;
  16628. lodash.toFinite = toFinite;
  16629. lodash.toInteger = toInteger;
  16630. lodash.toLength = toLength;
  16631. lodash.toLower = toLower;
  16632. lodash.toNumber = toNumber;
  16633. lodash.toSafeInteger = toSafeInteger;
  16634. lodash.toString = toString;
  16635. lodash.toUpper = toUpper;
  16636. lodash.trim = trim;
  16637. lodash.trimEnd = trimEnd;
  16638. lodash.trimStart = trimStart;
  16639. lodash.truncate = truncate;
  16640. lodash.unescape = unescape;
  16641. lodash.uniqueId = uniqueId;
  16642. lodash.upperCase = upperCase;
  16643. lodash.upperFirst = upperFirst;
  16644. // Add aliases.
  16645. lodash.each = forEach;
  16646. lodash.eachRight = forEachRight;
  16647. lodash.first = head;
  16648. mixin(lodash, (function() {
  16649. var source = {};
  16650. baseForOwn(lodash, function(func, methodName) {
  16651. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  16652. source[methodName] = func;
  16653. }
  16654. });
  16655. return source;
  16656. }()), { 'chain': false });
  16657. /*------------------------------------------------------------------------*/
  16658. /**
  16659. * The semantic version number.
  16660. *
  16661. * @static
  16662. * @memberOf _
  16663. * @type {string}
  16664. */
  16665. lodash.VERSION = VERSION;
  16666. // Assign default placeholders.
  16667. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  16668. lodash[methodName].placeholder = lodash;
  16669. });
  16670. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  16671. arrayEach(['drop', 'take'], function(methodName, index) {
  16672. LazyWrapper.prototype[methodName] = function(n) {
  16673. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  16674. var result = (this.__filtered__ && !index)
  16675. ? new LazyWrapper(this)
  16676. : this.clone();
  16677. if (result.__filtered__) {
  16678. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  16679. } else {
  16680. result.__views__.push({
  16681. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  16682. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  16683. });
  16684. }
  16685. return result;
  16686. };
  16687. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  16688. return this.reverse()[methodName](n).reverse();
  16689. };
  16690. });
  16691. // Add `LazyWrapper` methods that accept an `iteratee` value.
  16692. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  16693. var type = index + 1,
  16694. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  16695. LazyWrapper.prototype[methodName] = function(iteratee) {
  16696. var result = this.clone();
  16697. result.__iteratees__.push({
  16698. 'iteratee': getIteratee(iteratee, 3),
  16699. 'type': type
  16700. });
  16701. result.__filtered__ = result.__filtered__ || isFilter;
  16702. return result;
  16703. };
  16704. });
  16705. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  16706. arrayEach(['head', 'last'], function(methodName, index) {
  16707. var takeName = 'take' + (index ? 'Right' : '');
  16708. LazyWrapper.prototype[methodName] = function() {
  16709. return this[takeName](1).value()[0];
  16710. };
  16711. });
  16712. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  16713. arrayEach(['initial', 'tail'], function(methodName, index) {
  16714. var dropName = 'drop' + (index ? '' : 'Right');
  16715. LazyWrapper.prototype[methodName] = function() {
  16716. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  16717. };
  16718. });
  16719. LazyWrapper.prototype.compact = function() {
  16720. return this.filter(identity);
  16721. };
  16722. LazyWrapper.prototype.find = function(predicate) {
  16723. return this.filter(predicate).head();
  16724. };
  16725. LazyWrapper.prototype.findLast = function(predicate) {
  16726. return this.reverse().find(predicate);
  16727. };
  16728. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  16729. if (typeof path == 'function') {
  16730. return new LazyWrapper(this);
  16731. }
  16732. return this.map(function(value) {
  16733. return baseInvoke(value, path, args);
  16734. });
  16735. });
  16736. LazyWrapper.prototype.reject = function(predicate) {
  16737. return this.filter(negate(getIteratee(predicate)));
  16738. };
  16739. LazyWrapper.prototype.slice = function(start, end) {
  16740. start = toInteger(start);
  16741. var result = this;
  16742. if (result.__filtered__ && (start > 0 || end < 0)) {
  16743. return new LazyWrapper(result);
  16744. }
  16745. if (start < 0) {
  16746. result = result.takeRight(-start);
  16747. } else if (start) {
  16748. result = result.drop(start);
  16749. }
  16750. if (end !== undefined) {
  16751. end = toInteger(end);
  16752. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  16753. }
  16754. return result;
  16755. };
  16756. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  16757. return this.reverse().takeWhile(predicate).reverse();
  16758. };
  16759. LazyWrapper.prototype.toArray = function() {
  16760. return this.take(MAX_ARRAY_LENGTH);
  16761. };
  16762. // Add `LazyWrapper` methods to `lodash.prototype`.
  16763. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  16764. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  16765. isTaker = /^(?:head|last)$/.test(methodName),
  16766. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  16767. retUnwrapped = isTaker || /^find/.test(methodName);
  16768. if (!lodashFunc) {
  16769. return;
  16770. }
  16771. lodash.prototype[methodName] = function() {
  16772. var value = this.__wrapped__,
  16773. args = isTaker ? [1] : arguments,
  16774. isLazy = value instanceof LazyWrapper,
  16775. iteratee = args[0],
  16776. useLazy = isLazy || isArray(value);
  16777. var interceptor = function(value) {
  16778. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  16779. return (isTaker && chainAll) ? result[0] : result;
  16780. };
  16781. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  16782. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  16783. isLazy = useLazy = false;
  16784. }
  16785. var chainAll = this.__chain__,
  16786. isHybrid = !!this.__actions__.length,
  16787. isUnwrapped = retUnwrapped && !chainAll,
  16788. onlyLazy = isLazy && !isHybrid;
  16789. if (!retUnwrapped && useLazy) {
  16790. value = onlyLazy ? value : new LazyWrapper(this);
  16791. var result = func.apply(value, args);
  16792. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  16793. return new LodashWrapper(result, chainAll);
  16794. }
  16795. if (isUnwrapped && onlyLazy) {
  16796. return func.apply(this, args);
  16797. }
  16798. result = this.thru(interceptor);
  16799. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  16800. };
  16801. });
  16802. // Add `Array` methods to `lodash.prototype`.
  16803. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  16804. var func = arrayProto[methodName],
  16805. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  16806. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  16807. lodash.prototype[methodName] = function() {
  16808. var args = arguments;
  16809. if (retUnwrapped && !this.__chain__) {
  16810. var value = this.value();
  16811. return func.apply(isArray(value) ? value : [], args);
  16812. }
  16813. return this[chainName](function(value) {
  16814. return func.apply(isArray(value) ? value : [], args);
  16815. });
  16816. };
  16817. });
  16818. // Map minified method names to their real names.
  16819. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  16820. var lodashFunc = lodash[methodName];
  16821. if (lodashFunc) {
  16822. var key = (lodashFunc.name + ''),
  16823. names = realNames[key] || (realNames[key] = []);
  16824. names.push({ 'name': methodName, 'func': lodashFunc });
  16825. }
  16826. });
  16827. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  16828. 'name': 'wrapper',
  16829. 'func': undefined
  16830. }];
  16831. // Add methods to `LazyWrapper`.
  16832. LazyWrapper.prototype.clone = lazyClone;
  16833. LazyWrapper.prototype.reverse = lazyReverse;
  16834. LazyWrapper.prototype.value = lazyValue;
  16835. // Add chain sequence methods to the `lodash` wrapper.
  16836. lodash.prototype.at = wrapperAt;
  16837. lodash.prototype.chain = wrapperChain;
  16838. lodash.prototype.commit = wrapperCommit;
  16839. lodash.prototype.next = wrapperNext;
  16840. lodash.prototype.plant = wrapperPlant;
  16841. lodash.prototype.reverse = wrapperReverse;
  16842. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  16843. // Add lazy aliases.
  16844. lodash.prototype.first = lodash.prototype.head;
  16845. if (symIterator) {
  16846. lodash.prototype[symIterator] = wrapperToIterator;
  16847. }
  16848. return lodash;
  16849. });
  16850. /*--------------------------------------------------------------------------*/
  16851. // Export lodash.
  16852. var _ = runInContext();
  16853. // Some AMD build optimizers, like r.js, check for condition patterns like:
  16854. if (true) {
  16855. // Expose Lodash on the global object to prevent errors when Lodash is
  16856. // loaded by a script tag in the presence of an AMD loader.
  16857. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  16858. // Use `_.noConflict` to remove Lodash from the global object.
  16859. root._ = _;
  16860. // Define as an anonymous module so, through path mapping, it can be
  16861. // referenced as the "underscore" module.
  16862. !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
  16863. return _;
  16864. }.call(exports, __webpack_require__, exports, module),
  16865. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16866. }
  16867. // Check for `exports` after `define` in case a build optimizer adds it.
  16868. else if (freeModule) {
  16869. // Export for Node.js.
  16870. (freeModule.exports = _)._ = _;
  16871. // Export for CommonJS support.
  16872. freeExports._ = _;
  16873. }
  16874. else {
  16875. // Export to the global object.
  16876. root._ = _;
  16877. }
  16878. }.call(this));
  16879. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(13)(module)))
  16880. /***/ }),
  16881. /* 13 */
  16882. /***/ (function(module, exports) {
  16883. module.exports = function(module) {
  16884. if(!module.webpackPolyfill) {
  16885. module.deprecate = function() {};
  16886. module.paths = [];
  16887. // module.parent = undefined by default
  16888. if(!module.children) module.children = [];
  16889. Object.defineProperty(module, "loaded", {
  16890. enumerable: true,
  16891. get: function() {
  16892. return module.l;
  16893. }
  16894. });
  16895. Object.defineProperty(module, "id", {
  16896. enumerable: true,
  16897. get: function() {
  16898. return module.i;
  16899. }
  16900. });
  16901. module.webpackPolyfill = 1;
  16902. }
  16903. return module;
  16904. };
  16905. /***/ }),
  16906. /* 14 */
  16907. /***/ (function(module, exports, __webpack_require__) {
  16908. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  16909. * jQuery JavaScript Library v3.2.1
  16910. * https://jquery.com/
  16911. *
  16912. * Includes Sizzle.js
  16913. * https://sizzlejs.com/
  16914. *
  16915. * Copyright JS Foundation and other contributors
  16916. * Released under the MIT license
  16917. * https://jquery.org/license
  16918. *
  16919. * Date: 2017-03-20T18:59Z
  16920. */
  16921. ( function( global, factory ) {
  16922. "use strict";
  16923. if ( typeof module === "object" && typeof module.exports === "object" ) {
  16924. // For CommonJS and CommonJS-like environments where a proper `window`
  16925. // is present, execute the factory and get jQuery.
  16926. // For environments that do not have a `window` with a `document`
  16927. // (such as Node.js), expose a factory as module.exports.
  16928. // This accentuates the need for the creation of a real `window`.
  16929. // e.g. var jQuery = require("jquery")(window);
  16930. // See ticket #14549 for more info.
  16931. module.exports = global.document ?
  16932. factory( global, true ) :
  16933. function( w ) {
  16934. if ( !w.document ) {
  16935. throw new Error( "jQuery requires a window with a document" );
  16936. }
  16937. return factory( w );
  16938. };
  16939. } else {
  16940. factory( global );
  16941. }
  16942. // Pass this if window is not defined yet
  16943. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  16944. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  16945. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  16946. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  16947. // enough that all such attempts are guarded in a try block.
  16948. "use strict";
  16949. var arr = [];
  16950. var document = window.document;
  16951. var getProto = Object.getPrototypeOf;
  16952. var slice = arr.slice;
  16953. var concat = arr.concat;
  16954. var push = arr.push;
  16955. var indexOf = arr.indexOf;
  16956. var class2type = {};
  16957. var toString = class2type.toString;
  16958. var hasOwn = class2type.hasOwnProperty;
  16959. var fnToString = hasOwn.toString;
  16960. var ObjectFunctionString = fnToString.call( Object );
  16961. var support = {};
  16962. function DOMEval( code, doc ) {
  16963. doc = doc || document;
  16964. var script = doc.createElement( "script" );
  16965. script.text = code;
  16966. doc.head.appendChild( script ).parentNode.removeChild( script );
  16967. }
  16968. /* global Symbol */
  16969. // Defining this global in .eslintrc.json would create a danger of using the global
  16970. // unguarded in another place, it seems safer to define global only for this module
  16971. var
  16972. version = "3.2.1",
  16973. // Define a local copy of jQuery
  16974. jQuery = function( selector, context ) {
  16975. // The jQuery object is actually just the init constructor 'enhanced'
  16976. // Need init if jQuery is called (just allow error to be thrown if not included)
  16977. return new jQuery.fn.init( selector, context );
  16978. },
  16979. // Support: Android <=4.0 only
  16980. // Make sure we trim BOM and NBSP
  16981. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  16982. // Matches dashed string for camelizing
  16983. rmsPrefix = /^-ms-/,
  16984. rdashAlpha = /-([a-z])/g,
  16985. // Used by jQuery.camelCase as callback to replace()
  16986. fcamelCase = function( all, letter ) {
  16987. return letter.toUpperCase();
  16988. };
  16989. jQuery.fn = jQuery.prototype = {
  16990. // The current version of jQuery being used
  16991. jquery: version,
  16992. constructor: jQuery,
  16993. // The default length of a jQuery object is 0
  16994. length: 0,
  16995. toArray: function() {
  16996. return slice.call( this );
  16997. },
  16998. // Get the Nth element in the matched element set OR
  16999. // Get the whole matched element set as a clean array
  17000. get: function( num ) {
  17001. // Return all the elements in a clean array
  17002. if ( num == null ) {
  17003. return slice.call( this );
  17004. }
  17005. // Return just the one element from the set
  17006. return num < 0 ? this[ num + this.length ] : this[ num ];
  17007. },
  17008. // Take an array of elements and push it onto the stack
  17009. // (returning the new matched element set)
  17010. pushStack: function( elems ) {
  17011. // Build a new jQuery matched element set
  17012. var ret = jQuery.merge( this.constructor(), elems );
  17013. // Add the old object onto the stack (as a reference)
  17014. ret.prevObject = this;
  17015. // Return the newly-formed element set
  17016. return ret;
  17017. },
  17018. // Execute a callback for every element in the matched set.
  17019. each: function( callback ) {
  17020. return jQuery.each( this, callback );
  17021. },
  17022. map: function( callback ) {
  17023. return this.pushStack( jQuery.map( this, function( elem, i ) {
  17024. return callback.call( elem, i, elem );
  17025. } ) );
  17026. },
  17027. slice: function() {
  17028. return this.pushStack( slice.apply( this, arguments ) );
  17029. },
  17030. first: function() {
  17031. return this.eq( 0 );
  17032. },
  17033. last: function() {
  17034. return this.eq( -1 );
  17035. },
  17036. eq: function( i ) {
  17037. var len = this.length,
  17038. j = +i + ( i < 0 ? len : 0 );
  17039. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  17040. },
  17041. end: function() {
  17042. return this.prevObject || this.constructor();
  17043. },
  17044. // For internal use only.
  17045. // Behaves like an Array's method, not like a jQuery method.
  17046. push: push,
  17047. sort: arr.sort,
  17048. splice: arr.splice
  17049. };
  17050. jQuery.extend = jQuery.fn.extend = function() {
  17051. var options, name, src, copy, copyIsArray, clone,
  17052. target = arguments[ 0 ] || {},
  17053. i = 1,
  17054. length = arguments.length,
  17055. deep = false;
  17056. // Handle a deep copy situation
  17057. if ( typeof target === "boolean" ) {
  17058. deep = target;
  17059. // Skip the boolean and the target
  17060. target = arguments[ i ] || {};
  17061. i++;
  17062. }
  17063. // Handle case when target is a string or something (possible in deep copy)
  17064. if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
  17065. target = {};
  17066. }
  17067. // Extend jQuery itself if only one argument is passed
  17068. if ( i === length ) {
  17069. target = this;
  17070. i--;
  17071. }
  17072. for ( ; i < length; i++ ) {
  17073. // Only deal with non-null/undefined values
  17074. if ( ( options = arguments[ i ] ) != null ) {
  17075. // Extend the base object
  17076. for ( name in options ) {
  17077. src = target[ name ];
  17078. copy = options[ name ];
  17079. // Prevent never-ending loop
  17080. if ( target === copy ) {
  17081. continue;
  17082. }
  17083. // Recurse if we're merging plain objects or arrays
  17084. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  17085. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  17086. if ( copyIsArray ) {
  17087. copyIsArray = false;
  17088. clone = src && Array.isArray( src ) ? src : [];
  17089. } else {
  17090. clone = src && jQuery.isPlainObject( src ) ? src : {};
  17091. }
  17092. // Never move original objects, clone them
  17093. target[ name ] = jQuery.extend( deep, clone, copy );
  17094. // Don't bring in undefined values
  17095. } else if ( copy !== undefined ) {
  17096. target[ name ] = copy;
  17097. }
  17098. }
  17099. }
  17100. }
  17101. // Return the modified object
  17102. return target;
  17103. };
  17104. jQuery.extend( {
  17105. // Unique for each copy of jQuery on the page
  17106. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  17107. // Assume jQuery is ready without the ready module
  17108. isReady: true,
  17109. error: function( msg ) {
  17110. throw new Error( msg );
  17111. },
  17112. noop: function() {},
  17113. isFunction: function( obj ) {
  17114. return jQuery.type( obj ) === "function";
  17115. },
  17116. isWindow: function( obj ) {
  17117. return obj != null && obj === obj.window;
  17118. },
  17119. isNumeric: function( obj ) {
  17120. // As of jQuery 3.0, isNumeric is limited to
  17121. // strings and numbers (primitives or objects)
  17122. // that can be coerced to finite numbers (gh-2662)
  17123. var type = jQuery.type( obj );
  17124. return ( type === "number" || type === "string" ) &&
  17125. // parseFloat NaNs numeric-cast false positives ("")
  17126. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  17127. // subtraction forces infinities to NaN
  17128. !isNaN( obj - parseFloat( obj ) );
  17129. },
  17130. isPlainObject: function( obj ) {
  17131. var proto, Ctor;
  17132. // Detect obvious negatives
  17133. // Use toString instead of jQuery.type to catch host objects
  17134. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  17135. return false;
  17136. }
  17137. proto = getProto( obj );
  17138. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  17139. if ( !proto ) {
  17140. return true;
  17141. }
  17142. // Objects with prototype are plain iff they were constructed by a global Object function
  17143. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  17144. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  17145. },
  17146. isEmptyObject: function( obj ) {
  17147. /* eslint-disable no-unused-vars */
  17148. // See https://github.com/eslint/eslint/issues/6125
  17149. var name;
  17150. for ( name in obj ) {
  17151. return false;
  17152. }
  17153. return true;
  17154. },
  17155. type: function( obj ) {
  17156. if ( obj == null ) {
  17157. return obj + "";
  17158. }
  17159. // Support: Android <=2.3 only (functionish RegExp)
  17160. return typeof obj === "object" || typeof obj === "function" ?
  17161. class2type[ toString.call( obj ) ] || "object" :
  17162. typeof obj;
  17163. },
  17164. // Evaluates a script in a global context
  17165. globalEval: function( code ) {
  17166. DOMEval( code );
  17167. },
  17168. // Convert dashed to camelCase; used by the css and data modules
  17169. // Support: IE <=9 - 11, Edge 12 - 13
  17170. // Microsoft forgot to hump their vendor prefix (#9572)
  17171. camelCase: function( string ) {
  17172. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  17173. },
  17174. each: function( obj, callback ) {
  17175. var length, i = 0;
  17176. if ( isArrayLike( obj ) ) {
  17177. length = obj.length;
  17178. for ( ; i < length; i++ ) {
  17179. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  17180. break;
  17181. }
  17182. }
  17183. } else {
  17184. for ( i in obj ) {
  17185. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  17186. break;
  17187. }
  17188. }
  17189. }
  17190. return obj;
  17191. },
  17192. // Support: Android <=4.0 only
  17193. trim: function( text ) {
  17194. return text == null ?
  17195. "" :
  17196. ( text + "" ).replace( rtrim, "" );
  17197. },
  17198. // results is for internal usage only
  17199. makeArray: function( arr, results ) {
  17200. var ret = results || [];
  17201. if ( arr != null ) {
  17202. if ( isArrayLike( Object( arr ) ) ) {
  17203. jQuery.merge( ret,
  17204. typeof arr === "string" ?
  17205. [ arr ] : arr
  17206. );
  17207. } else {
  17208. push.call( ret, arr );
  17209. }
  17210. }
  17211. return ret;
  17212. },
  17213. inArray: function( elem, arr, i ) {
  17214. return arr == null ? -1 : indexOf.call( arr, elem, i );
  17215. },
  17216. // Support: Android <=4.0 only, PhantomJS 1 only
  17217. // push.apply(_, arraylike) throws on ancient WebKit
  17218. merge: function( first, second ) {
  17219. var len = +second.length,
  17220. j = 0,
  17221. i = first.length;
  17222. for ( ; j < len; j++ ) {
  17223. first[ i++ ] = second[ j ];
  17224. }
  17225. first.length = i;
  17226. return first;
  17227. },
  17228. grep: function( elems, callback, invert ) {
  17229. var callbackInverse,
  17230. matches = [],
  17231. i = 0,
  17232. length = elems.length,
  17233. callbackExpect = !invert;
  17234. // Go through the array, only saving the items
  17235. // that pass the validator function
  17236. for ( ; i < length; i++ ) {
  17237. callbackInverse = !callback( elems[ i ], i );
  17238. if ( callbackInverse !== callbackExpect ) {
  17239. matches.push( elems[ i ] );
  17240. }
  17241. }
  17242. return matches;
  17243. },
  17244. // arg is for internal usage only
  17245. map: function( elems, callback, arg ) {
  17246. var length, value,
  17247. i = 0,
  17248. ret = [];
  17249. // Go through the array, translating each of the items to their new values
  17250. if ( isArrayLike( elems ) ) {
  17251. length = elems.length;
  17252. for ( ; i < length; i++ ) {
  17253. value = callback( elems[ i ], i, arg );
  17254. if ( value != null ) {
  17255. ret.push( value );
  17256. }
  17257. }
  17258. // Go through every key on the object,
  17259. } else {
  17260. for ( i in elems ) {
  17261. value = callback( elems[ i ], i, arg );
  17262. if ( value != null ) {
  17263. ret.push( value );
  17264. }
  17265. }
  17266. }
  17267. // Flatten any nested arrays
  17268. return concat.apply( [], ret );
  17269. },
  17270. // A global GUID counter for objects
  17271. guid: 1,
  17272. // Bind a function to a context, optionally partially applying any
  17273. // arguments.
  17274. proxy: function( fn, context ) {
  17275. var tmp, args, proxy;
  17276. if ( typeof context === "string" ) {
  17277. tmp = fn[ context ];
  17278. context = fn;
  17279. fn = tmp;
  17280. }
  17281. // Quick check to determine if target is callable, in the spec
  17282. // this throws a TypeError, but we will just return undefined.
  17283. if ( !jQuery.isFunction( fn ) ) {
  17284. return undefined;
  17285. }
  17286. // Simulated bind
  17287. args = slice.call( arguments, 2 );
  17288. proxy = function() {
  17289. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  17290. };
  17291. // Set the guid of unique handler to the same of original handler, so it can be removed
  17292. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  17293. return proxy;
  17294. },
  17295. now: Date.now,
  17296. // jQuery.support is not used in Core but other projects attach their
  17297. // properties to it so it needs to exist.
  17298. support: support
  17299. } );
  17300. if ( typeof Symbol === "function" ) {
  17301. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  17302. }
  17303. // Populate the class2type map
  17304. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  17305. function( i, name ) {
  17306. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  17307. } );
  17308. function isArrayLike( obj ) {
  17309. // Support: real iOS 8.2 only (not reproducible in simulator)
  17310. // `in` check used to prevent JIT error (gh-2145)
  17311. // hasOwn isn't used here due to false negatives
  17312. // regarding Nodelist length in IE
  17313. var length = !!obj && "length" in obj && obj.length,
  17314. type = jQuery.type( obj );
  17315. if ( type === "function" || jQuery.isWindow( obj ) ) {
  17316. return false;
  17317. }
  17318. return type === "array" || length === 0 ||
  17319. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  17320. }
  17321. var Sizzle =
  17322. /*!
  17323. * Sizzle CSS Selector Engine v2.3.3
  17324. * https://sizzlejs.com/
  17325. *
  17326. * Copyright jQuery Foundation and other contributors
  17327. * Released under the MIT license
  17328. * http://jquery.org/license
  17329. *
  17330. * Date: 2016-08-08
  17331. */
  17332. (function( window ) {
  17333. var i,
  17334. support,
  17335. Expr,
  17336. getText,
  17337. isXML,
  17338. tokenize,
  17339. compile,
  17340. select,
  17341. outermostContext,
  17342. sortInput,
  17343. hasDuplicate,
  17344. // Local document vars
  17345. setDocument,
  17346. document,
  17347. docElem,
  17348. documentIsHTML,
  17349. rbuggyQSA,
  17350. rbuggyMatches,
  17351. matches,
  17352. contains,
  17353. // Instance-specific data
  17354. expando = "sizzle" + 1 * new Date(),
  17355. preferredDoc = window.document,
  17356. dirruns = 0,
  17357. done = 0,
  17358. classCache = createCache(),
  17359. tokenCache = createCache(),
  17360. compilerCache = createCache(),
  17361. sortOrder = function( a, b ) {
  17362. if ( a === b ) {
  17363. hasDuplicate = true;
  17364. }
  17365. return 0;
  17366. },
  17367. // Instance methods
  17368. hasOwn = ({}).hasOwnProperty,
  17369. arr = [],
  17370. pop = arr.pop,
  17371. push_native = arr.push,
  17372. push = arr.push,
  17373. slice = arr.slice,
  17374. // Use a stripped-down indexOf as it's faster than native
  17375. // https://jsperf.com/thor-indexof-vs-for/5
  17376. indexOf = function( list, elem ) {
  17377. var i = 0,
  17378. len = list.length;
  17379. for ( ; i < len; i++ ) {
  17380. if ( list[i] === elem ) {
  17381. return i;
  17382. }
  17383. }
  17384. return -1;
  17385. },
  17386. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  17387. // Regular expressions
  17388. // http://www.w3.org/TR/css3-selectors/#whitespace
  17389. whitespace = "[\\x20\\t\\r\\n\\f]",
  17390. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  17391. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  17392. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  17393. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  17394. // Operator (capture 2)
  17395. "*([*^$|!~]?=)" + whitespace +
  17396. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  17397. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  17398. "*\\]",
  17399. pseudos = ":(" + identifier + ")(?:\\((" +
  17400. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  17401. // 1. quoted (capture 3; capture 4 or capture 5)
  17402. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  17403. // 2. simple (capture 6)
  17404. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  17405. // 3. anything else (capture 2)
  17406. ".*" +
  17407. ")\\)|)",
  17408. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  17409. rwhitespace = new RegExp( whitespace + "+", "g" ),
  17410. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  17411. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  17412. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  17413. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  17414. rpseudo = new RegExp( pseudos ),
  17415. ridentifier = new RegExp( "^" + identifier + "$" ),
  17416. matchExpr = {
  17417. "ID": new RegExp( "^#(" + identifier + ")" ),
  17418. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  17419. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  17420. "ATTR": new RegExp( "^" + attributes ),
  17421. "PSEUDO": new RegExp( "^" + pseudos ),
  17422. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  17423. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  17424. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  17425. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  17426. // For use in libraries implementing .is()
  17427. // We use this for POS matching in `select`
  17428. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  17429. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  17430. },
  17431. rinputs = /^(?:input|select|textarea|button)$/i,
  17432. rheader = /^h\d$/i,
  17433. rnative = /^[^{]+\{\s*\[native \w/,
  17434. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  17435. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  17436. rsibling = /[+~]/,
  17437. // CSS escapes
  17438. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  17439. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  17440. funescape = function( _, escaped, escapedWhitespace ) {
  17441. var high = "0x" + escaped - 0x10000;
  17442. // NaN means non-codepoint
  17443. // Support: Firefox<24
  17444. // Workaround erroneous numeric interpretation of +"0x"
  17445. return high !== high || escapedWhitespace ?
  17446. escaped :
  17447. high < 0 ?
  17448. // BMP codepoint
  17449. String.fromCharCode( high + 0x10000 ) :
  17450. // Supplemental Plane codepoint (surrogate pair)
  17451. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  17452. },
  17453. // CSS string/identifier serialization
  17454. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  17455. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  17456. fcssescape = function( ch, asCodePoint ) {
  17457. if ( asCodePoint ) {
  17458. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  17459. if ( ch === "\0" ) {
  17460. return "\uFFFD";
  17461. }
  17462. // Control characters and (dependent upon position) numbers get escaped as code points
  17463. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  17464. }
  17465. // Other potentially-special ASCII characters get backslash-escaped
  17466. return "\\" + ch;
  17467. },
  17468. // Used for iframes
  17469. // See setDocument()
  17470. // Removing the function wrapper causes a "Permission Denied"
  17471. // error in IE
  17472. unloadHandler = function() {
  17473. setDocument();
  17474. },
  17475. disabledAncestor = addCombinator(
  17476. function( elem ) {
  17477. return elem.disabled === true && ("form" in elem || "label" in elem);
  17478. },
  17479. { dir: "parentNode", next: "legend" }
  17480. );
  17481. // Optimize for push.apply( _, NodeList )
  17482. try {
  17483. push.apply(
  17484. (arr = slice.call( preferredDoc.childNodes )),
  17485. preferredDoc.childNodes
  17486. );
  17487. // Support: Android<4.0
  17488. // Detect silently failing push.apply
  17489. arr[ preferredDoc.childNodes.length ].nodeType;
  17490. } catch ( e ) {
  17491. push = { apply: arr.length ?
  17492. // Leverage slice if possible
  17493. function( target, els ) {
  17494. push_native.apply( target, slice.call(els) );
  17495. } :
  17496. // Support: IE<9
  17497. // Otherwise append directly
  17498. function( target, els ) {
  17499. var j = target.length,
  17500. i = 0;
  17501. // Can't trust NodeList.length
  17502. while ( (target[j++] = els[i++]) ) {}
  17503. target.length = j - 1;
  17504. }
  17505. };
  17506. }
  17507. function Sizzle( selector, context, results, seed ) {
  17508. var m, i, elem, nid, match, groups, newSelector,
  17509. newContext = context && context.ownerDocument,
  17510. // nodeType defaults to 9, since context defaults to document
  17511. nodeType = context ? context.nodeType : 9;
  17512. results = results || [];
  17513. // Return early from calls with invalid selector or context
  17514. if ( typeof selector !== "string" || !selector ||
  17515. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  17516. return results;
  17517. }
  17518. // Try to shortcut find operations (as opposed to filters) in HTML documents
  17519. if ( !seed ) {
  17520. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  17521. setDocument( context );
  17522. }
  17523. context = context || document;
  17524. if ( documentIsHTML ) {
  17525. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  17526. // (excepting DocumentFragment context, where the methods don't exist)
  17527. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  17528. // ID selector
  17529. if ( (m = match[1]) ) {
  17530. // Document context
  17531. if ( nodeType === 9 ) {
  17532. if ( (elem = context.getElementById( m )) ) {
  17533. // Support: IE, Opera, Webkit
  17534. // TODO: identify versions
  17535. // getElementById can match elements by name instead of ID
  17536. if ( elem.id === m ) {
  17537. results.push( elem );
  17538. return results;
  17539. }
  17540. } else {
  17541. return results;
  17542. }
  17543. // Element context
  17544. } else {
  17545. // Support: IE, Opera, Webkit
  17546. // TODO: identify versions
  17547. // getElementById can match elements by name instead of ID
  17548. if ( newContext && (elem = newContext.getElementById( m )) &&
  17549. contains( context, elem ) &&
  17550. elem.id === m ) {
  17551. results.push( elem );
  17552. return results;
  17553. }
  17554. }
  17555. // Type selector
  17556. } else if ( match[2] ) {
  17557. push.apply( results, context.getElementsByTagName( selector ) );
  17558. return results;
  17559. // Class selector
  17560. } else if ( (m = match[3]) && support.getElementsByClassName &&
  17561. context.getElementsByClassName ) {
  17562. push.apply( results, context.getElementsByClassName( m ) );
  17563. return results;
  17564. }
  17565. }
  17566. // Take advantage of querySelectorAll
  17567. if ( support.qsa &&
  17568. !compilerCache[ selector + " " ] &&
  17569. (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  17570. if ( nodeType !== 1 ) {
  17571. newContext = context;
  17572. newSelector = selector;
  17573. // qSA looks outside Element context, which is not what we want
  17574. // Thanks to Andrew Dupont for this workaround technique
  17575. // Support: IE <=8
  17576. // Exclude object elements
  17577. } else if ( context.nodeName.toLowerCase() !== "object" ) {
  17578. // Capture the context ID, setting it first if necessary
  17579. if ( (nid = context.getAttribute( "id" )) ) {
  17580. nid = nid.replace( rcssescape, fcssescape );
  17581. } else {
  17582. context.setAttribute( "id", (nid = expando) );
  17583. }
  17584. // Prefix every selector in the list
  17585. groups = tokenize( selector );
  17586. i = groups.length;
  17587. while ( i-- ) {
  17588. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  17589. }
  17590. newSelector = groups.join( "," );
  17591. // Expand context for sibling selectors
  17592. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  17593. context;
  17594. }
  17595. if ( newSelector ) {
  17596. try {
  17597. push.apply( results,
  17598. newContext.querySelectorAll( newSelector )
  17599. );
  17600. return results;
  17601. } catch ( qsaError ) {
  17602. } finally {
  17603. if ( nid === expando ) {
  17604. context.removeAttribute( "id" );
  17605. }
  17606. }
  17607. }
  17608. }
  17609. }
  17610. }
  17611. // All others
  17612. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  17613. }
  17614. /**
  17615. * Create key-value caches of limited size
  17616. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  17617. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  17618. * deleting the oldest entry
  17619. */
  17620. function createCache() {
  17621. var keys = [];
  17622. function cache( key, value ) {
  17623. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  17624. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  17625. // Only keep the most recent entries
  17626. delete cache[ keys.shift() ];
  17627. }
  17628. return (cache[ key + " " ] = value);
  17629. }
  17630. return cache;
  17631. }
  17632. /**
  17633. * Mark a function for special use by Sizzle
  17634. * @param {Function} fn The function to mark
  17635. */
  17636. function markFunction( fn ) {
  17637. fn[ expando ] = true;
  17638. return fn;
  17639. }
  17640. /**
  17641. * Support testing using an element
  17642. * @param {Function} fn Passed the created element and returns a boolean result
  17643. */
  17644. function assert( fn ) {
  17645. var el = document.createElement("fieldset");
  17646. try {
  17647. return !!fn( el );
  17648. } catch (e) {
  17649. return false;
  17650. } finally {
  17651. // Remove from its parent by default
  17652. if ( el.parentNode ) {
  17653. el.parentNode.removeChild( el );
  17654. }
  17655. // release memory in IE
  17656. el = null;
  17657. }
  17658. }
  17659. /**
  17660. * Adds the same handler for all of the specified attrs
  17661. * @param {String} attrs Pipe-separated list of attributes
  17662. * @param {Function} handler The method that will be applied
  17663. */
  17664. function addHandle( attrs, handler ) {
  17665. var arr = attrs.split("|"),
  17666. i = arr.length;
  17667. while ( i-- ) {
  17668. Expr.attrHandle[ arr[i] ] = handler;
  17669. }
  17670. }
  17671. /**
  17672. * Checks document order of two siblings
  17673. * @param {Element} a
  17674. * @param {Element} b
  17675. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  17676. */
  17677. function siblingCheck( a, b ) {
  17678. var cur = b && a,
  17679. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  17680. a.sourceIndex - b.sourceIndex;
  17681. // Use IE sourceIndex if available on both nodes
  17682. if ( diff ) {
  17683. return diff;
  17684. }
  17685. // Check if b follows a
  17686. if ( cur ) {
  17687. while ( (cur = cur.nextSibling) ) {
  17688. if ( cur === b ) {
  17689. return -1;
  17690. }
  17691. }
  17692. }
  17693. return a ? 1 : -1;
  17694. }
  17695. /**
  17696. * Returns a function to use in pseudos for input types
  17697. * @param {String} type
  17698. */
  17699. function createInputPseudo( type ) {
  17700. return function( elem ) {
  17701. var name = elem.nodeName.toLowerCase();
  17702. return name === "input" && elem.type === type;
  17703. };
  17704. }
  17705. /**
  17706. * Returns a function to use in pseudos for buttons
  17707. * @param {String} type
  17708. */
  17709. function createButtonPseudo( type ) {
  17710. return function( elem ) {
  17711. var name = elem.nodeName.toLowerCase();
  17712. return (name === "input" || name === "button") && elem.type === type;
  17713. };
  17714. }
  17715. /**
  17716. * Returns a function to use in pseudos for :enabled/:disabled
  17717. * @param {Boolean} disabled true for :disabled; false for :enabled
  17718. */
  17719. function createDisabledPseudo( disabled ) {
  17720. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  17721. return function( elem ) {
  17722. // Only certain elements can match :enabled or :disabled
  17723. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  17724. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  17725. if ( "form" in elem ) {
  17726. // Check for inherited disabledness on relevant non-disabled elements:
  17727. // * listed form-associated elements in a disabled fieldset
  17728. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  17729. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  17730. // * option elements in a disabled optgroup
  17731. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  17732. // All such elements have a "form" property.
  17733. if ( elem.parentNode && elem.disabled === false ) {
  17734. // Option elements defer to a parent optgroup if present
  17735. if ( "label" in elem ) {
  17736. if ( "label" in elem.parentNode ) {
  17737. return elem.parentNode.disabled === disabled;
  17738. } else {
  17739. return elem.disabled === disabled;
  17740. }
  17741. }
  17742. // Support: IE 6 - 11
  17743. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  17744. return elem.isDisabled === disabled ||
  17745. // Where there is no isDisabled, check manually
  17746. /* jshint -W018 */
  17747. elem.isDisabled !== !disabled &&
  17748. disabledAncestor( elem ) === disabled;
  17749. }
  17750. return elem.disabled === disabled;
  17751. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  17752. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  17753. // even exist on them, let alone have a boolean value.
  17754. } else if ( "label" in elem ) {
  17755. return elem.disabled === disabled;
  17756. }
  17757. // Remaining elements are neither :enabled nor :disabled
  17758. return false;
  17759. };
  17760. }
  17761. /**
  17762. * Returns a function to use in pseudos for positionals
  17763. * @param {Function} fn
  17764. */
  17765. function createPositionalPseudo( fn ) {
  17766. return markFunction(function( argument ) {
  17767. argument = +argument;
  17768. return markFunction(function( seed, matches ) {
  17769. var j,
  17770. matchIndexes = fn( [], seed.length, argument ),
  17771. i = matchIndexes.length;
  17772. // Match elements found at the specified indexes
  17773. while ( i-- ) {
  17774. if ( seed[ (j = matchIndexes[i]) ] ) {
  17775. seed[j] = !(matches[j] = seed[j]);
  17776. }
  17777. }
  17778. });
  17779. });
  17780. }
  17781. /**
  17782. * Checks a node for validity as a Sizzle context
  17783. * @param {Element|Object=} context
  17784. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  17785. */
  17786. function testContext( context ) {
  17787. return context && typeof context.getElementsByTagName !== "undefined" && context;
  17788. }
  17789. // Expose support vars for convenience
  17790. support = Sizzle.support = {};
  17791. /**
  17792. * Detects XML nodes
  17793. * @param {Element|Object} elem An element or a document
  17794. * @returns {Boolean} True iff elem is a non-HTML XML node
  17795. */
  17796. isXML = Sizzle.isXML = function( elem ) {
  17797. // documentElement is verified for cases where it doesn't yet exist
  17798. // (such as loading iframes in IE - #4833)
  17799. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  17800. return documentElement ? documentElement.nodeName !== "HTML" : false;
  17801. };
  17802. /**
  17803. * Sets document-related variables once based on the current document
  17804. * @param {Element|Object} [doc] An element or document object to use to set the document
  17805. * @returns {Object} Returns the current document
  17806. */
  17807. setDocument = Sizzle.setDocument = function( node ) {
  17808. var hasCompare, subWindow,
  17809. doc = node ? node.ownerDocument || node : preferredDoc;
  17810. // Return early if doc is invalid or already selected
  17811. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  17812. return document;
  17813. }
  17814. // Update global variables
  17815. document = doc;
  17816. docElem = document.documentElement;
  17817. documentIsHTML = !isXML( document );
  17818. // Support: IE 9-11, Edge
  17819. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  17820. if ( preferredDoc !== document &&
  17821. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  17822. // Support: IE 11, Edge
  17823. if ( subWindow.addEventListener ) {
  17824. subWindow.addEventListener( "unload", unloadHandler, false );
  17825. // Support: IE 9 - 10 only
  17826. } else if ( subWindow.attachEvent ) {
  17827. subWindow.attachEvent( "onunload", unloadHandler );
  17828. }
  17829. }
  17830. /* Attributes
  17831. ---------------------------------------------------------------------- */
  17832. // Support: IE<8
  17833. // Verify that getAttribute really returns attributes and not properties
  17834. // (excepting IE8 booleans)
  17835. support.attributes = assert(function( el ) {
  17836. el.className = "i";
  17837. return !el.getAttribute("className");
  17838. });
  17839. /* getElement(s)By*
  17840. ---------------------------------------------------------------------- */
  17841. // Check if getElementsByTagName("*") returns only elements
  17842. support.getElementsByTagName = assert(function( el ) {
  17843. el.appendChild( document.createComment("") );
  17844. return !el.getElementsByTagName("*").length;
  17845. });
  17846. // Support: IE<9
  17847. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  17848. // Support: IE<10
  17849. // Check if getElementById returns elements by name
  17850. // The broken getElementById methods don't pick up programmatically-set names,
  17851. // so use a roundabout getElementsByName test
  17852. support.getById = assert(function( el ) {
  17853. docElem.appendChild( el ).id = expando;
  17854. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  17855. });
  17856. // ID filter and find
  17857. if ( support.getById ) {
  17858. Expr.filter["ID"] = function( id ) {
  17859. var attrId = id.replace( runescape, funescape );
  17860. return function( elem ) {
  17861. return elem.getAttribute("id") === attrId;
  17862. };
  17863. };
  17864. Expr.find["ID"] = function( id, context ) {
  17865. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  17866. var elem = context.getElementById( id );
  17867. return elem ? [ elem ] : [];
  17868. }
  17869. };
  17870. } else {
  17871. Expr.filter["ID"] = function( id ) {
  17872. var attrId = id.replace( runescape, funescape );
  17873. return function( elem ) {
  17874. var node = typeof elem.getAttributeNode !== "undefined" &&
  17875. elem.getAttributeNode("id");
  17876. return node && node.value === attrId;
  17877. };
  17878. };
  17879. // Support: IE 6 - 7 only
  17880. // getElementById is not reliable as a find shortcut
  17881. Expr.find["ID"] = function( id, context ) {
  17882. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  17883. var node, i, elems,
  17884. elem = context.getElementById( id );
  17885. if ( elem ) {
  17886. // Verify the id attribute
  17887. node = elem.getAttributeNode("id");
  17888. if ( node && node.value === id ) {
  17889. return [ elem ];
  17890. }
  17891. // Fall back on getElementsByName
  17892. elems = context.getElementsByName( id );
  17893. i = 0;
  17894. while ( (elem = elems[i++]) ) {
  17895. node = elem.getAttributeNode("id");
  17896. if ( node && node.value === id ) {
  17897. return [ elem ];
  17898. }
  17899. }
  17900. }
  17901. return [];
  17902. }
  17903. };
  17904. }
  17905. // Tag
  17906. Expr.find["TAG"] = support.getElementsByTagName ?
  17907. function( tag, context ) {
  17908. if ( typeof context.getElementsByTagName !== "undefined" ) {
  17909. return context.getElementsByTagName( tag );
  17910. // DocumentFragment nodes don't have gEBTN
  17911. } else if ( support.qsa ) {
  17912. return context.querySelectorAll( tag );
  17913. }
  17914. } :
  17915. function( tag, context ) {
  17916. var elem,
  17917. tmp = [],
  17918. i = 0,
  17919. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  17920. results = context.getElementsByTagName( tag );
  17921. // Filter out possible comments
  17922. if ( tag === "*" ) {
  17923. while ( (elem = results[i++]) ) {
  17924. if ( elem.nodeType === 1 ) {
  17925. tmp.push( elem );
  17926. }
  17927. }
  17928. return tmp;
  17929. }
  17930. return results;
  17931. };
  17932. // Class
  17933. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  17934. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  17935. return context.getElementsByClassName( className );
  17936. }
  17937. };
  17938. /* QSA/matchesSelector
  17939. ---------------------------------------------------------------------- */
  17940. // QSA and matchesSelector support
  17941. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  17942. rbuggyMatches = [];
  17943. // qSa(:focus) reports false when true (Chrome 21)
  17944. // We allow this because of a bug in IE8/9 that throws an error
  17945. // whenever `document.activeElement` is accessed on an iframe
  17946. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  17947. // See https://bugs.jquery.com/ticket/13378
  17948. rbuggyQSA = [];
  17949. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  17950. // Build QSA regex
  17951. // Regex strategy adopted from Diego Perini
  17952. assert(function( el ) {
  17953. // Select is set to empty string on purpose
  17954. // This is to test IE's treatment of not explicitly
  17955. // setting a boolean content attribute,
  17956. // since its presence should be enough
  17957. // https://bugs.jquery.com/ticket/12359
  17958. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  17959. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  17960. "<option selected=''></option></select>";
  17961. // Support: IE8, Opera 11-12.16
  17962. // Nothing should be selected when empty strings follow ^= or $= or *=
  17963. // The test attribute must be unknown in Opera but "safe" for WinRT
  17964. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  17965. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  17966. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  17967. }
  17968. // Support: IE8
  17969. // Boolean attributes and "value" are not treated correctly
  17970. if ( !el.querySelectorAll("[selected]").length ) {
  17971. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  17972. }
  17973. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  17974. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  17975. rbuggyQSA.push("~=");
  17976. }
  17977. // Webkit/Opera - :checked should return selected option elements
  17978. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  17979. // IE8 throws error here and will not see later tests
  17980. if ( !el.querySelectorAll(":checked").length ) {
  17981. rbuggyQSA.push(":checked");
  17982. }
  17983. // Support: Safari 8+, iOS 8+
  17984. // https://bugs.webkit.org/show_bug.cgi?id=136851
  17985. // In-page `selector#id sibling-combinator selector` fails
  17986. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  17987. rbuggyQSA.push(".#.+[+~]");
  17988. }
  17989. });
  17990. assert(function( el ) {
  17991. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  17992. "<select disabled='disabled'><option/></select>";
  17993. // Support: Windows 8 Native Apps
  17994. // The type and name attributes are restricted during .innerHTML assignment
  17995. var input = document.createElement("input");
  17996. input.setAttribute( "type", "hidden" );
  17997. el.appendChild( input ).setAttribute( "name", "D" );
  17998. // Support: IE8
  17999. // Enforce case-sensitivity of name attribute
  18000. if ( el.querySelectorAll("[name=d]").length ) {
  18001. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  18002. }
  18003. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  18004. // IE8 throws error here and will not see later tests
  18005. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  18006. rbuggyQSA.push( ":enabled", ":disabled" );
  18007. }
  18008. // Support: IE9-11+
  18009. // IE's :disabled selector does not pick up the children of disabled fieldsets
  18010. docElem.appendChild( el ).disabled = true;
  18011. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  18012. rbuggyQSA.push( ":enabled", ":disabled" );
  18013. }
  18014. // Opera 10-11 does not throw on post-comma invalid pseudos
  18015. el.querySelectorAll("*,:x");
  18016. rbuggyQSA.push(",.*:");
  18017. });
  18018. }
  18019. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  18020. docElem.webkitMatchesSelector ||
  18021. docElem.mozMatchesSelector ||
  18022. docElem.oMatchesSelector ||
  18023. docElem.msMatchesSelector) )) ) {
  18024. assert(function( el ) {
  18025. // Check to see if it's possible to do matchesSelector
  18026. // on a disconnected node (IE 9)
  18027. support.disconnectedMatch = matches.call( el, "*" );
  18028. // This should fail with an exception
  18029. // Gecko does not error, returns false instead
  18030. matches.call( el, "[s!='']:x" );
  18031. rbuggyMatches.push( "!=", pseudos );
  18032. });
  18033. }
  18034. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  18035. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  18036. /* Contains
  18037. ---------------------------------------------------------------------- */
  18038. hasCompare = rnative.test( docElem.compareDocumentPosition );
  18039. // Element contains another
  18040. // Purposefully self-exclusive
  18041. // As in, an element does not contain itself
  18042. contains = hasCompare || rnative.test( docElem.contains ) ?
  18043. function( a, b ) {
  18044. var adown = a.nodeType === 9 ? a.documentElement : a,
  18045. bup = b && b.parentNode;
  18046. return a === bup || !!( bup && bup.nodeType === 1 && (
  18047. adown.contains ?
  18048. adown.contains( bup ) :
  18049. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  18050. ));
  18051. } :
  18052. function( a, b ) {
  18053. if ( b ) {
  18054. while ( (b = b.parentNode) ) {
  18055. if ( b === a ) {
  18056. return true;
  18057. }
  18058. }
  18059. }
  18060. return false;
  18061. };
  18062. /* Sorting
  18063. ---------------------------------------------------------------------- */
  18064. // Document order sorting
  18065. sortOrder = hasCompare ?
  18066. function( a, b ) {
  18067. // Flag for duplicate removal
  18068. if ( a === b ) {
  18069. hasDuplicate = true;
  18070. return 0;
  18071. }
  18072. // Sort on method existence if only one input has compareDocumentPosition
  18073. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  18074. if ( compare ) {
  18075. return compare;
  18076. }
  18077. // Calculate position if both inputs belong to the same document
  18078. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  18079. a.compareDocumentPosition( b ) :
  18080. // Otherwise we know they are disconnected
  18081. 1;
  18082. // Disconnected nodes
  18083. if ( compare & 1 ||
  18084. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  18085. // Choose the first element that is related to our preferred document
  18086. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  18087. return -1;
  18088. }
  18089. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  18090. return 1;
  18091. }
  18092. // Maintain original order
  18093. return sortInput ?
  18094. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  18095. 0;
  18096. }
  18097. return compare & 4 ? -1 : 1;
  18098. } :
  18099. function( a, b ) {
  18100. // Exit early if the nodes are identical
  18101. if ( a === b ) {
  18102. hasDuplicate = true;
  18103. return 0;
  18104. }
  18105. var cur,
  18106. i = 0,
  18107. aup = a.parentNode,
  18108. bup = b.parentNode,
  18109. ap = [ a ],
  18110. bp = [ b ];
  18111. // Parentless nodes are either documents or disconnected
  18112. if ( !aup || !bup ) {
  18113. return a === document ? -1 :
  18114. b === document ? 1 :
  18115. aup ? -1 :
  18116. bup ? 1 :
  18117. sortInput ?
  18118. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  18119. 0;
  18120. // If the nodes are siblings, we can do a quick check
  18121. } else if ( aup === bup ) {
  18122. return siblingCheck( a, b );
  18123. }
  18124. // Otherwise we need full lists of their ancestors for comparison
  18125. cur = a;
  18126. while ( (cur = cur.parentNode) ) {
  18127. ap.unshift( cur );
  18128. }
  18129. cur = b;
  18130. while ( (cur = cur.parentNode) ) {
  18131. bp.unshift( cur );
  18132. }
  18133. // Walk down the tree looking for a discrepancy
  18134. while ( ap[i] === bp[i] ) {
  18135. i++;
  18136. }
  18137. return i ?
  18138. // Do a sibling check if the nodes have a common ancestor
  18139. siblingCheck( ap[i], bp[i] ) :
  18140. // Otherwise nodes in our document sort first
  18141. ap[i] === preferredDoc ? -1 :
  18142. bp[i] === preferredDoc ? 1 :
  18143. 0;
  18144. };
  18145. return document;
  18146. };
  18147. Sizzle.matches = function( expr, elements ) {
  18148. return Sizzle( expr, null, null, elements );
  18149. };
  18150. Sizzle.matchesSelector = function( elem, expr ) {
  18151. // Set document vars if needed
  18152. if ( ( elem.ownerDocument || elem ) !== document ) {
  18153. setDocument( elem );
  18154. }
  18155. // Make sure that attribute selectors are quoted
  18156. expr = expr.replace( rattributeQuotes, "='$1']" );
  18157. if ( support.matchesSelector && documentIsHTML &&
  18158. !compilerCache[ expr + " " ] &&
  18159. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  18160. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  18161. try {
  18162. var ret = matches.call( elem, expr );
  18163. // IE 9's matchesSelector returns false on disconnected nodes
  18164. if ( ret || support.disconnectedMatch ||
  18165. // As well, disconnected nodes are said to be in a document
  18166. // fragment in IE 9
  18167. elem.document && elem.document.nodeType !== 11 ) {
  18168. return ret;
  18169. }
  18170. } catch (e) {}
  18171. }
  18172. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  18173. };
  18174. Sizzle.contains = function( context, elem ) {
  18175. // Set document vars if needed
  18176. if ( ( context.ownerDocument || context ) !== document ) {
  18177. setDocument( context );
  18178. }
  18179. return contains( context, elem );
  18180. };
  18181. Sizzle.attr = function( elem, name ) {
  18182. // Set document vars if needed
  18183. if ( ( elem.ownerDocument || elem ) !== document ) {
  18184. setDocument( elem );
  18185. }
  18186. var fn = Expr.attrHandle[ name.toLowerCase() ],
  18187. // Don't get fooled by Object.prototype properties (jQuery #13807)
  18188. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  18189. fn( elem, name, !documentIsHTML ) :
  18190. undefined;
  18191. return val !== undefined ?
  18192. val :
  18193. support.attributes || !documentIsHTML ?
  18194. elem.getAttribute( name ) :
  18195. (val = elem.getAttributeNode(name)) && val.specified ?
  18196. val.value :
  18197. null;
  18198. };
  18199. Sizzle.escape = function( sel ) {
  18200. return (sel + "").replace( rcssescape, fcssescape );
  18201. };
  18202. Sizzle.error = function( msg ) {
  18203. throw new Error( "Syntax error, unrecognized expression: " + msg );
  18204. };
  18205. /**
  18206. * Document sorting and removing duplicates
  18207. * @param {ArrayLike} results
  18208. */
  18209. Sizzle.uniqueSort = function( results ) {
  18210. var elem,
  18211. duplicates = [],
  18212. j = 0,
  18213. i = 0;
  18214. // Unless we *know* we can detect duplicates, assume their presence
  18215. hasDuplicate = !support.detectDuplicates;
  18216. sortInput = !support.sortStable && results.slice( 0 );
  18217. results.sort( sortOrder );
  18218. if ( hasDuplicate ) {
  18219. while ( (elem = results[i++]) ) {
  18220. if ( elem === results[ i ] ) {
  18221. j = duplicates.push( i );
  18222. }
  18223. }
  18224. while ( j-- ) {
  18225. results.splice( duplicates[ j ], 1 );
  18226. }
  18227. }
  18228. // Clear input after sorting to release objects
  18229. // See https://github.com/jquery/sizzle/pull/225
  18230. sortInput = null;
  18231. return results;
  18232. };
  18233. /**
  18234. * Utility function for retrieving the text value of an array of DOM nodes
  18235. * @param {Array|Element} elem
  18236. */
  18237. getText = Sizzle.getText = function( elem ) {
  18238. var node,
  18239. ret = "",
  18240. i = 0,
  18241. nodeType = elem.nodeType;
  18242. if ( !nodeType ) {
  18243. // If no nodeType, this is expected to be an array
  18244. while ( (node = elem[i++]) ) {
  18245. // Do not traverse comment nodes
  18246. ret += getText( node );
  18247. }
  18248. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  18249. // Use textContent for elements
  18250. // innerText usage removed for consistency of new lines (jQuery #11153)
  18251. if ( typeof elem.textContent === "string" ) {
  18252. return elem.textContent;
  18253. } else {
  18254. // Traverse its children
  18255. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  18256. ret += getText( elem );
  18257. }
  18258. }
  18259. } else if ( nodeType === 3 || nodeType === 4 ) {
  18260. return elem.nodeValue;
  18261. }
  18262. // Do not include comment or processing instruction nodes
  18263. return ret;
  18264. };
  18265. Expr = Sizzle.selectors = {
  18266. // Can be adjusted by the user
  18267. cacheLength: 50,
  18268. createPseudo: markFunction,
  18269. match: matchExpr,
  18270. attrHandle: {},
  18271. find: {},
  18272. relative: {
  18273. ">": { dir: "parentNode", first: true },
  18274. " ": { dir: "parentNode" },
  18275. "+": { dir: "previousSibling", first: true },
  18276. "~": { dir: "previousSibling" }
  18277. },
  18278. preFilter: {
  18279. "ATTR": function( match ) {
  18280. match[1] = match[1].replace( runescape, funescape );
  18281. // Move the given value to match[3] whether quoted or unquoted
  18282. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  18283. if ( match[2] === "~=" ) {
  18284. match[3] = " " + match[3] + " ";
  18285. }
  18286. return match.slice( 0, 4 );
  18287. },
  18288. "CHILD": function( match ) {
  18289. /* matches from matchExpr["CHILD"]
  18290. 1 type (only|nth|...)
  18291. 2 what (child|of-type)
  18292. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  18293. 4 xn-component of xn+y argument ([+-]?\d*n|)
  18294. 5 sign of xn-component
  18295. 6 x of xn-component
  18296. 7 sign of y-component
  18297. 8 y of y-component
  18298. */
  18299. match[1] = match[1].toLowerCase();
  18300. if ( match[1].slice( 0, 3 ) === "nth" ) {
  18301. // nth-* requires argument
  18302. if ( !match[3] ) {
  18303. Sizzle.error( match[0] );
  18304. }
  18305. // numeric x and y parameters for Expr.filter.CHILD
  18306. // remember that false/true cast respectively to 0/1
  18307. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  18308. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  18309. // other types prohibit arguments
  18310. } else if ( match[3] ) {
  18311. Sizzle.error( match[0] );
  18312. }
  18313. return match;
  18314. },
  18315. "PSEUDO": function( match ) {
  18316. var excess,
  18317. unquoted = !match[6] && match[2];
  18318. if ( matchExpr["CHILD"].test( match[0] ) ) {
  18319. return null;
  18320. }
  18321. // Accept quoted arguments as-is
  18322. if ( match[3] ) {
  18323. match[2] = match[4] || match[5] || "";
  18324. // Strip excess characters from unquoted arguments
  18325. } else if ( unquoted && rpseudo.test( unquoted ) &&
  18326. // Get excess from tokenize (recursively)
  18327. (excess = tokenize( unquoted, true )) &&
  18328. // advance to the next closing parenthesis
  18329. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  18330. // excess is a negative index
  18331. match[0] = match[0].slice( 0, excess );
  18332. match[2] = unquoted.slice( 0, excess );
  18333. }
  18334. // Return only captures needed by the pseudo filter method (type and argument)
  18335. return match.slice( 0, 3 );
  18336. }
  18337. },
  18338. filter: {
  18339. "TAG": function( nodeNameSelector ) {
  18340. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  18341. return nodeNameSelector === "*" ?
  18342. function() { return true; } :
  18343. function( elem ) {
  18344. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  18345. };
  18346. },
  18347. "CLASS": function( className ) {
  18348. var pattern = classCache[ className + " " ];
  18349. return pattern ||
  18350. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  18351. classCache( className, function( elem ) {
  18352. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  18353. });
  18354. },
  18355. "ATTR": function( name, operator, check ) {
  18356. return function( elem ) {
  18357. var result = Sizzle.attr( elem, name );
  18358. if ( result == null ) {
  18359. return operator === "!=";
  18360. }
  18361. if ( !operator ) {
  18362. return true;
  18363. }
  18364. result += "";
  18365. return operator === "=" ? result === check :
  18366. operator === "!=" ? result !== check :
  18367. operator === "^=" ? check && result.indexOf( check ) === 0 :
  18368. operator === "*=" ? check && result.indexOf( check ) > -1 :
  18369. operator === "$=" ? check && result.slice( -check.length ) === check :
  18370. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  18371. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  18372. false;
  18373. };
  18374. },
  18375. "CHILD": function( type, what, argument, first, last ) {
  18376. var simple = type.slice( 0, 3 ) !== "nth",
  18377. forward = type.slice( -4 ) !== "last",
  18378. ofType = what === "of-type";
  18379. return first === 1 && last === 0 ?
  18380. // Shortcut for :nth-*(n)
  18381. function( elem ) {
  18382. return !!elem.parentNode;
  18383. } :
  18384. function( elem, context, xml ) {
  18385. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  18386. dir = simple !== forward ? "nextSibling" : "previousSibling",
  18387. parent = elem.parentNode,
  18388. name = ofType && elem.nodeName.toLowerCase(),
  18389. useCache = !xml && !ofType,
  18390. diff = false;
  18391. if ( parent ) {
  18392. // :(first|last|only)-(child|of-type)
  18393. if ( simple ) {
  18394. while ( dir ) {
  18395. node = elem;
  18396. while ( (node = node[ dir ]) ) {
  18397. if ( ofType ?
  18398. node.nodeName.toLowerCase() === name :
  18399. node.nodeType === 1 ) {
  18400. return false;
  18401. }
  18402. }
  18403. // Reverse direction for :only-* (if we haven't yet done so)
  18404. start = dir = type === "only" && !start && "nextSibling";
  18405. }
  18406. return true;
  18407. }
  18408. start = [ forward ? parent.firstChild : parent.lastChild ];
  18409. // non-xml :nth-child(...) stores cache data on `parent`
  18410. if ( forward && useCache ) {
  18411. // Seek `elem` from a previously-cached index
  18412. // ...in a gzip-friendly way
  18413. node = parent;
  18414. outerCache = node[ expando ] || (node[ expando ] = {});
  18415. // Support: IE <9 only
  18416. // Defend against cloned attroperties (jQuery gh-1709)
  18417. uniqueCache = outerCache[ node.uniqueID ] ||
  18418. (outerCache[ node.uniqueID ] = {});
  18419. cache = uniqueCache[ type ] || [];
  18420. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  18421. diff = nodeIndex && cache[ 2 ];
  18422. node = nodeIndex && parent.childNodes[ nodeIndex ];
  18423. while ( (node = ++nodeIndex && node && node[ dir ] ||
  18424. // Fallback to seeking `elem` from the start
  18425. (diff = nodeIndex = 0) || start.pop()) ) {
  18426. // When found, cache indexes on `parent` and break
  18427. if ( node.nodeType === 1 && ++diff && node === elem ) {
  18428. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  18429. break;
  18430. }
  18431. }
  18432. } else {
  18433. // Use previously-cached element index if available
  18434. if ( useCache ) {
  18435. // ...in a gzip-friendly way
  18436. node = elem;
  18437. outerCache = node[ expando ] || (node[ expando ] = {});
  18438. // Support: IE <9 only
  18439. // Defend against cloned attroperties (jQuery gh-1709)
  18440. uniqueCache = outerCache[ node.uniqueID ] ||
  18441. (outerCache[ node.uniqueID ] = {});
  18442. cache = uniqueCache[ type ] || [];
  18443. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  18444. diff = nodeIndex;
  18445. }
  18446. // xml :nth-child(...)
  18447. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  18448. if ( diff === false ) {
  18449. // Use the same loop as above to seek `elem` from the start
  18450. while ( (node = ++nodeIndex && node && node[ dir ] ||
  18451. (diff = nodeIndex = 0) || start.pop()) ) {
  18452. if ( ( ofType ?
  18453. node.nodeName.toLowerCase() === name :
  18454. node.nodeType === 1 ) &&
  18455. ++diff ) {
  18456. // Cache the index of each encountered element
  18457. if ( useCache ) {
  18458. outerCache = node[ expando ] || (node[ expando ] = {});
  18459. // Support: IE <9 only
  18460. // Defend against cloned attroperties (jQuery gh-1709)
  18461. uniqueCache = outerCache[ node.uniqueID ] ||
  18462. (outerCache[ node.uniqueID ] = {});
  18463. uniqueCache[ type ] = [ dirruns, diff ];
  18464. }
  18465. if ( node === elem ) {
  18466. break;
  18467. }
  18468. }
  18469. }
  18470. }
  18471. }
  18472. // Incorporate the offset, then check against cycle size
  18473. diff -= last;
  18474. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  18475. }
  18476. };
  18477. },
  18478. "PSEUDO": function( pseudo, argument ) {
  18479. // pseudo-class names are case-insensitive
  18480. // http://www.w3.org/TR/selectors/#pseudo-classes
  18481. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  18482. // Remember that setFilters inherits from pseudos
  18483. var args,
  18484. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  18485. Sizzle.error( "unsupported pseudo: " + pseudo );
  18486. // The user may use createPseudo to indicate that
  18487. // arguments are needed to create the filter function
  18488. // just as Sizzle does
  18489. if ( fn[ expando ] ) {
  18490. return fn( argument );
  18491. }
  18492. // But maintain support for old signatures
  18493. if ( fn.length > 1 ) {
  18494. args = [ pseudo, pseudo, "", argument ];
  18495. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  18496. markFunction(function( seed, matches ) {
  18497. var idx,
  18498. matched = fn( seed, argument ),
  18499. i = matched.length;
  18500. while ( i-- ) {
  18501. idx = indexOf( seed, matched[i] );
  18502. seed[ idx ] = !( matches[ idx ] = matched[i] );
  18503. }
  18504. }) :
  18505. function( elem ) {
  18506. return fn( elem, 0, args );
  18507. };
  18508. }
  18509. return fn;
  18510. }
  18511. },
  18512. pseudos: {
  18513. // Potentially complex pseudos
  18514. "not": markFunction(function( selector ) {
  18515. // Trim the selector passed to compile
  18516. // to avoid treating leading and trailing
  18517. // spaces as combinators
  18518. var input = [],
  18519. results = [],
  18520. matcher = compile( selector.replace( rtrim, "$1" ) );
  18521. return matcher[ expando ] ?
  18522. markFunction(function( seed, matches, context, xml ) {
  18523. var elem,
  18524. unmatched = matcher( seed, null, xml, [] ),
  18525. i = seed.length;
  18526. // Match elements unmatched by `matcher`
  18527. while ( i-- ) {
  18528. if ( (elem = unmatched[i]) ) {
  18529. seed[i] = !(matches[i] = elem);
  18530. }
  18531. }
  18532. }) :
  18533. function( elem, context, xml ) {
  18534. input[0] = elem;
  18535. matcher( input, null, xml, results );
  18536. // Don't keep the element (issue #299)
  18537. input[0] = null;
  18538. return !results.pop();
  18539. };
  18540. }),
  18541. "has": markFunction(function( selector ) {
  18542. return function( elem ) {
  18543. return Sizzle( selector, elem ).length > 0;
  18544. };
  18545. }),
  18546. "contains": markFunction(function( text ) {
  18547. text = text.replace( runescape, funescape );
  18548. return function( elem ) {
  18549. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  18550. };
  18551. }),
  18552. // "Whether an element is represented by a :lang() selector
  18553. // is based solely on the element's language value
  18554. // being equal to the identifier C,
  18555. // or beginning with the identifier C immediately followed by "-".
  18556. // The matching of C against the element's language value is performed case-insensitively.
  18557. // The identifier C does not have to be a valid language name."
  18558. // http://www.w3.org/TR/selectors/#lang-pseudo
  18559. "lang": markFunction( function( lang ) {
  18560. // lang value must be a valid identifier
  18561. if ( !ridentifier.test(lang || "") ) {
  18562. Sizzle.error( "unsupported lang: " + lang );
  18563. }
  18564. lang = lang.replace( runescape, funescape ).toLowerCase();
  18565. return function( elem ) {
  18566. var elemLang;
  18567. do {
  18568. if ( (elemLang = documentIsHTML ?
  18569. elem.lang :
  18570. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  18571. elemLang = elemLang.toLowerCase();
  18572. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  18573. }
  18574. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  18575. return false;
  18576. };
  18577. }),
  18578. // Miscellaneous
  18579. "target": function( elem ) {
  18580. var hash = window.location && window.location.hash;
  18581. return hash && hash.slice( 1 ) === elem.id;
  18582. },
  18583. "root": function( elem ) {
  18584. return elem === docElem;
  18585. },
  18586. "focus": function( elem ) {
  18587. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  18588. },
  18589. // Boolean properties
  18590. "enabled": createDisabledPseudo( false ),
  18591. "disabled": createDisabledPseudo( true ),
  18592. "checked": function( elem ) {
  18593. // In CSS3, :checked should return both checked and selected elements
  18594. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  18595. var nodeName = elem.nodeName.toLowerCase();
  18596. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  18597. },
  18598. "selected": function( elem ) {
  18599. // Accessing this property makes selected-by-default
  18600. // options in Safari work properly
  18601. if ( elem.parentNode ) {
  18602. elem.parentNode.selectedIndex;
  18603. }
  18604. return elem.selected === true;
  18605. },
  18606. // Contents
  18607. "empty": function( elem ) {
  18608. // http://www.w3.org/TR/selectors/#empty-pseudo
  18609. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  18610. // but not by others (comment: 8; processing instruction: 7; etc.)
  18611. // nodeType < 6 works because attributes (2) do not appear as children
  18612. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  18613. if ( elem.nodeType < 6 ) {
  18614. return false;
  18615. }
  18616. }
  18617. return true;
  18618. },
  18619. "parent": function( elem ) {
  18620. return !Expr.pseudos["empty"]( elem );
  18621. },
  18622. // Element/input types
  18623. "header": function( elem ) {
  18624. return rheader.test( elem.nodeName );
  18625. },
  18626. "input": function( elem ) {
  18627. return rinputs.test( elem.nodeName );
  18628. },
  18629. "button": function( elem ) {
  18630. var name = elem.nodeName.toLowerCase();
  18631. return name === "input" && elem.type === "button" || name === "button";
  18632. },
  18633. "text": function( elem ) {
  18634. var attr;
  18635. return elem.nodeName.toLowerCase() === "input" &&
  18636. elem.type === "text" &&
  18637. // Support: IE<8
  18638. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  18639. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  18640. },
  18641. // Position-in-collection
  18642. "first": createPositionalPseudo(function() {
  18643. return [ 0 ];
  18644. }),
  18645. "last": createPositionalPseudo(function( matchIndexes, length ) {
  18646. return [ length - 1 ];
  18647. }),
  18648. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18649. return [ argument < 0 ? argument + length : argument ];
  18650. }),
  18651. "even": createPositionalPseudo(function( matchIndexes, length ) {
  18652. var i = 0;
  18653. for ( ; i < length; i += 2 ) {
  18654. matchIndexes.push( i );
  18655. }
  18656. return matchIndexes;
  18657. }),
  18658. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  18659. var i = 1;
  18660. for ( ; i < length; i += 2 ) {
  18661. matchIndexes.push( i );
  18662. }
  18663. return matchIndexes;
  18664. }),
  18665. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18666. var i = argument < 0 ? argument + length : argument;
  18667. for ( ; --i >= 0; ) {
  18668. matchIndexes.push( i );
  18669. }
  18670. return matchIndexes;
  18671. }),
  18672. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18673. var i = argument < 0 ? argument + length : argument;
  18674. for ( ; ++i < length; ) {
  18675. matchIndexes.push( i );
  18676. }
  18677. return matchIndexes;
  18678. })
  18679. }
  18680. };
  18681. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  18682. // Add button/input type pseudos
  18683. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  18684. Expr.pseudos[ i ] = createInputPseudo( i );
  18685. }
  18686. for ( i in { submit: true, reset: true } ) {
  18687. Expr.pseudos[ i ] = createButtonPseudo( i );
  18688. }
  18689. // Easy API for creating new setFilters
  18690. function setFilters() {}
  18691. setFilters.prototype = Expr.filters = Expr.pseudos;
  18692. Expr.setFilters = new setFilters();
  18693. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  18694. var matched, match, tokens, type,
  18695. soFar, groups, preFilters,
  18696. cached = tokenCache[ selector + " " ];
  18697. if ( cached ) {
  18698. return parseOnly ? 0 : cached.slice( 0 );
  18699. }
  18700. soFar = selector;
  18701. groups = [];
  18702. preFilters = Expr.preFilter;
  18703. while ( soFar ) {
  18704. // Comma and first run
  18705. if ( !matched || (match = rcomma.exec( soFar )) ) {
  18706. if ( match ) {
  18707. // Don't consume trailing commas as valid
  18708. soFar = soFar.slice( match[0].length ) || soFar;
  18709. }
  18710. groups.push( (tokens = []) );
  18711. }
  18712. matched = false;
  18713. // Combinators
  18714. if ( (match = rcombinators.exec( soFar )) ) {
  18715. matched = match.shift();
  18716. tokens.push({
  18717. value: matched,
  18718. // Cast descendant combinators to space
  18719. type: match[0].replace( rtrim, " " )
  18720. });
  18721. soFar = soFar.slice( matched.length );
  18722. }
  18723. // Filters
  18724. for ( type in Expr.filter ) {
  18725. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  18726. (match = preFilters[ type ]( match ))) ) {
  18727. matched = match.shift();
  18728. tokens.push({
  18729. value: matched,
  18730. type: type,
  18731. matches: match
  18732. });
  18733. soFar = soFar.slice( matched.length );
  18734. }
  18735. }
  18736. if ( !matched ) {
  18737. break;
  18738. }
  18739. }
  18740. // Return the length of the invalid excess
  18741. // if we're just parsing
  18742. // Otherwise, throw an error or return tokens
  18743. return parseOnly ?
  18744. soFar.length :
  18745. soFar ?
  18746. Sizzle.error( selector ) :
  18747. // Cache the tokens
  18748. tokenCache( selector, groups ).slice( 0 );
  18749. };
  18750. function toSelector( tokens ) {
  18751. var i = 0,
  18752. len = tokens.length,
  18753. selector = "";
  18754. for ( ; i < len; i++ ) {
  18755. selector += tokens[i].value;
  18756. }
  18757. return selector;
  18758. }
  18759. function addCombinator( matcher, combinator, base ) {
  18760. var dir = combinator.dir,
  18761. skip = combinator.next,
  18762. key = skip || dir,
  18763. checkNonElements = base && key === "parentNode",
  18764. doneName = done++;
  18765. return combinator.first ?
  18766. // Check against closest ancestor/preceding element
  18767. function( elem, context, xml ) {
  18768. while ( (elem = elem[ dir ]) ) {
  18769. if ( elem.nodeType === 1 || checkNonElements ) {
  18770. return matcher( elem, context, xml );
  18771. }
  18772. }
  18773. return false;
  18774. } :
  18775. // Check against all ancestor/preceding elements
  18776. function( elem, context, xml ) {
  18777. var oldCache, uniqueCache, outerCache,
  18778. newCache = [ dirruns, doneName ];
  18779. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  18780. if ( xml ) {
  18781. while ( (elem = elem[ dir ]) ) {
  18782. if ( elem.nodeType === 1 || checkNonElements ) {
  18783. if ( matcher( elem, context, xml ) ) {
  18784. return true;
  18785. }
  18786. }
  18787. }
  18788. } else {
  18789. while ( (elem = elem[ dir ]) ) {
  18790. if ( elem.nodeType === 1 || checkNonElements ) {
  18791. outerCache = elem[ expando ] || (elem[ expando ] = {});
  18792. // Support: IE <9 only
  18793. // Defend against cloned attroperties (jQuery gh-1709)
  18794. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  18795. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  18796. elem = elem[ dir ] || elem;
  18797. } else if ( (oldCache = uniqueCache[ key ]) &&
  18798. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  18799. // Assign to newCache so results back-propagate to previous elements
  18800. return (newCache[ 2 ] = oldCache[ 2 ]);
  18801. } else {
  18802. // Reuse newcache so results back-propagate to previous elements
  18803. uniqueCache[ key ] = newCache;
  18804. // A match means we're done; a fail means we have to keep checking
  18805. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  18806. return true;
  18807. }
  18808. }
  18809. }
  18810. }
  18811. }
  18812. return false;
  18813. };
  18814. }
  18815. function elementMatcher( matchers ) {
  18816. return matchers.length > 1 ?
  18817. function( elem, context, xml ) {
  18818. var i = matchers.length;
  18819. while ( i-- ) {
  18820. if ( !matchers[i]( elem, context, xml ) ) {
  18821. return false;
  18822. }
  18823. }
  18824. return true;
  18825. } :
  18826. matchers[0];
  18827. }
  18828. function multipleContexts( selector, contexts, results ) {
  18829. var i = 0,
  18830. len = contexts.length;
  18831. for ( ; i < len; i++ ) {
  18832. Sizzle( selector, contexts[i], results );
  18833. }
  18834. return results;
  18835. }
  18836. function condense( unmatched, map, filter, context, xml ) {
  18837. var elem,
  18838. newUnmatched = [],
  18839. i = 0,
  18840. len = unmatched.length,
  18841. mapped = map != null;
  18842. for ( ; i < len; i++ ) {
  18843. if ( (elem = unmatched[i]) ) {
  18844. if ( !filter || filter( elem, context, xml ) ) {
  18845. newUnmatched.push( elem );
  18846. if ( mapped ) {
  18847. map.push( i );
  18848. }
  18849. }
  18850. }
  18851. }
  18852. return newUnmatched;
  18853. }
  18854. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  18855. if ( postFilter && !postFilter[ expando ] ) {
  18856. postFilter = setMatcher( postFilter );
  18857. }
  18858. if ( postFinder && !postFinder[ expando ] ) {
  18859. postFinder = setMatcher( postFinder, postSelector );
  18860. }
  18861. return markFunction(function( seed, results, context, xml ) {
  18862. var temp, i, elem,
  18863. preMap = [],
  18864. postMap = [],
  18865. preexisting = results.length,
  18866. // Get initial elements from seed or context
  18867. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  18868. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  18869. matcherIn = preFilter && ( seed || !selector ) ?
  18870. condense( elems, preMap, preFilter, context, xml ) :
  18871. elems,
  18872. matcherOut = matcher ?
  18873. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  18874. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  18875. // ...intermediate processing is necessary
  18876. [] :
  18877. // ...otherwise use results directly
  18878. results :
  18879. matcherIn;
  18880. // Find primary matches
  18881. if ( matcher ) {
  18882. matcher( matcherIn, matcherOut, context, xml );
  18883. }
  18884. // Apply postFilter
  18885. if ( postFilter ) {
  18886. temp = condense( matcherOut, postMap );
  18887. postFilter( temp, [], context, xml );
  18888. // Un-match failing elements by moving them back to matcherIn
  18889. i = temp.length;
  18890. while ( i-- ) {
  18891. if ( (elem = temp[i]) ) {
  18892. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  18893. }
  18894. }
  18895. }
  18896. if ( seed ) {
  18897. if ( postFinder || preFilter ) {
  18898. if ( postFinder ) {
  18899. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  18900. temp = [];
  18901. i = matcherOut.length;
  18902. while ( i-- ) {
  18903. if ( (elem = matcherOut[i]) ) {
  18904. // Restore matcherIn since elem is not yet a final match
  18905. temp.push( (matcherIn[i] = elem) );
  18906. }
  18907. }
  18908. postFinder( null, (matcherOut = []), temp, xml );
  18909. }
  18910. // Move matched elements from seed to results to keep them synchronized
  18911. i = matcherOut.length;
  18912. while ( i-- ) {
  18913. if ( (elem = matcherOut[i]) &&
  18914. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  18915. seed[temp] = !(results[temp] = elem);
  18916. }
  18917. }
  18918. }
  18919. // Add elements to results, through postFinder if defined
  18920. } else {
  18921. matcherOut = condense(
  18922. matcherOut === results ?
  18923. matcherOut.splice( preexisting, matcherOut.length ) :
  18924. matcherOut
  18925. );
  18926. if ( postFinder ) {
  18927. postFinder( null, results, matcherOut, xml );
  18928. } else {
  18929. push.apply( results, matcherOut );
  18930. }
  18931. }
  18932. });
  18933. }
  18934. function matcherFromTokens( tokens ) {
  18935. var checkContext, matcher, j,
  18936. len = tokens.length,
  18937. leadingRelative = Expr.relative[ tokens[0].type ],
  18938. implicitRelative = leadingRelative || Expr.relative[" "],
  18939. i = leadingRelative ? 1 : 0,
  18940. // The foundational matcher ensures that elements are reachable from top-level context(s)
  18941. matchContext = addCombinator( function( elem ) {
  18942. return elem === checkContext;
  18943. }, implicitRelative, true ),
  18944. matchAnyContext = addCombinator( function( elem ) {
  18945. return indexOf( checkContext, elem ) > -1;
  18946. }, implicitRelative, true ),
  18947. matchers = [ function( elem, context, xml ) {
  18948. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  18949. (checkContext = context).nodeType ?
  18950. matchContext( elem, context, xml ) :
  18951. matchAnyContext( elem, context, xml ) );
  18952. // Avoid hanging onto element (issue #299)
  18953. checkContext = null;
  18954. return ret;
  18955. } ];
  18956. for ( ; i < len; i++ ) {
  18957. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  18958. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  18959. } else {
  18960. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  18961. // Return special upon seeing a positional matcher
  18962. if ( matcher[ expando ] ) {
  18963. // Find the next relative operator (if any) for proper handling
  18964. j = ++i;
  18965. for ( ; j < len; j++ ) {
  18966. if ( Expr.relative[ tokens[j].type ] ) {
  18967. break;
  18968. }
  18969. }
  18970. return setMatcher(
  18971. i > 1 && elementMatcher( matchers ),
  18972. i > 1 && toSelector(
  18973. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  18974. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  18975. ).replace( rtrim, "$1" ),
  18976. matcher,
  18977. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  18978. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  18979. j < len && toSelector( tokens )
  18980. );
  18981. }
  18982. matchers.push( matcher );
  18983. }
  18984. }
  18985. return elementMatcher( matchers );
  18986. }
  18987. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  18988. var bySet = setMatchers.length > 0,
  18989. byElement = elementMatchers.length > 0,
  18990. superMatcher = function( seed, context, xml, results, outermost ) {
  18991. var elem, j, matcher,
  18992. matchedCount = 0,
  18993. i = "0",
  18994. unmatched = seed && [],
  18995. setMatched = [],
  18996. contextBackup = outermostContext,
  18997. // We must always have either seed elements or outermost context
  18998. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  18999. // Use integer dirruns iff this is the outermost matcher
  19000. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  19001. len = elems.length;
  19002. if ( outermost ) {
  19003. outermostContext = context === document || context || outermost;
  19004. }
  19005. // Add elements passing elementMatchers directly to results
  19006. // Support: IE<9, Safari
  19007. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  19008. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  19009. if ( byElement && elem ) {
  19010. j = 0;
  19011. if ( !context && elem.ownerDocument !== document ) {
  19012. setDocument( elem );
  19013. xml = !documentIsHTML;
  19014. }
  19015. while ( (matcher = elementMatchers[j++]) ) {
  19016. if ( matcher( elem, context || document, xml) ) {
  19017. results.push( elem );
  19018. break;
  19019. }
  19020. }
  19021. if ( outermost ) {
  19022. dirruns = dirrunsUnique;
  19023. }
  19024. }
  19025. // Track unmatched elements for set filters
  19026. if ( bySet ) {
  19027. // They will have gone through all possible matchers
  19028. if ( (elem = !matcher && elem) ) {
  19029. matchedCount--;
  19030. }
  19031. // Lengthen the array for every element, matched or not
  19032. if ( seed ) {
  19033. unmatched.push( elem );
  19034. }
  19035. }
  19036. }
  19037. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  19038. // makes the latter nonnegative.
  19039. matchedCount += i;
  19040. // Apply set filters to unmatched elements
  19041. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  19042. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  19043. // no element matchers and no seed.
  19044. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  19045. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  19046. // numerically zero.
  19047. if ( bySet && i !== matchedCount ) {
  19048. j = 0;
  19049. while ( (matcher = setMatchers[j++]) ) {
  19050. matcher( unmatched, setMatched, context, xml );
  19051. }
  19052. if ( seed ) {
  19053. // Reintegrate element matches to eliminate the need for sorting
  19054. if ( matchedCount > 0 ) {
  19055. while ( i-- ) {
  19056. if ( !(unmatched[i] || setMatched[i]) ) {
  19057. setMatched[i] = pop.call( results );
  19058. }
  19059. }
  19060. }
  19061. // Discard index placeholder values to get only actual matches
  19062. setMatched = condense( setMatched );
  19063. }
  19064. // Add matches to results
  19065. push.apply( results, setMatched );
  19066. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  19067. if ( outermost && !seed && setMatched.length > 0 &&
  19068. ( matchedCount + setMatchers.length ) > 1 ) {
  19069. Sizzle.uniqueSort( results );
  19070. }
  19071. }
  19072. // Override manipulation of globals by nested matchers
  19073. if ( outermost ) {
  19074. dirruns = dirrunsUnique;
  19075. outermostContext = contextBackup;
  19076. }
  19077. return unmatched;
  19078. };
  19079. return bySet ?
  19080. markFunction( superMatcher ) :
  19081. superMatcher;
  19082. }
  19083. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  19084. var i,
  19085. setMatchers = [],
  19086. elementMatchers = [],
  19087. cached = compilerCache[ selector + " " ];
  19088. if ( !cached ) {
  19089. // Generate a function of recursive functions that can be used to check each element
  19090. if ( !match ) {
  19091. match = tokenize( selector );
  19092. }
  19093. i = match.length;
  19094. while ( i-- ) {
  19095. cached = matcherFromTokens( match[i] );
  19096. if ( cached[ expando ] ) {
  19097. setMatchers.push( cached );
  19098. } else {
  19099. elementMatchers.push( cached );
  19100. }
  19101. }
  19102. // Cache the compiled function
  19103. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  19104. // Save selector and tokenization
  19105. cached.selector = selector;
  19106. }
  19107. return cached;
  19108. };
  19109. /**
  19110. * A low-level selection function that works with Sizzle's compiled
  19111. * selector functions
  19112. * @param {String|Function} selector A selector or a pre-compiled
  19113. * selector function built with Sizzle.compile
  19114. * @param {Element} context
  19115. * @param {Array} [results]
  19116. * @param {Array} [seed] A set of elements to match against
  19117. */
  19118. select = Sizzle.select = function( selector, context, results, seed ) {
  19119. var i, tokens, token, type, find,
  19120. compiled = typeof selector === "function" && selector,
  19121. match = !seed && tokenize( (selector = compiled.selector || selector) );
  19122. results = results || [];
  19123. // Try to minimize operations if there is only one selector in the list and no seed
  19124. // (the latter of which guarantees us context)
  19125. if ( match.length === 1 ) {
  19126. // Reduce context if the leading compound selector is an ID
  19127. tokens = match[0] = match[0].slice( 0 );
  19128. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  19129. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  19130. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  19131. if ( !context ) {
  19132. return results;
  19133. // Precompiled matchers will still verify ancestry, so step up a level
  19134. } else if ( compiled ) {
  19135. context = context.parentNode;
  19136. }
  19137. selector = selector.slice( tokens.shift().value.length );
  19138. }
  19139. // Fetch a seed set for right-to-left matching
  19140. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  19141. while ( i-- ) {
  19142. token = tokens[i];
  19143. // Abort if we hit a combinator
  19144. if ( Expr.relative[ (type = token.type) ] ) {
  19145. break;
  19146. }
  19147. if ( (find = Expr.find[ type ]) ) {
  19148. // Search, expanding context for leading sibling combinators
  19149. if ( (seed = find(
  19150. token.matches[0].replace( runescape, funescape ),
  19151. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  19152. )) ) {
  19153. // If seed is empty or no tokens remain, we can return early
  19154. tokens.splice( i, 1 );
  19155. selector = seed.length && toSelector( tokens );
  19156. if ( !selector ) {
  19157. push.apply( results, seed );
  19158. return results;
  19159. }
  19160. break;
  19161. }
  19162. }
  19163. }
  19164. }
  19165. // Compile and execute a filtering function if one is not provided
  19166. // Provide `match` to avoid retokenization if we modified the selector above
  19167. ( compiled || compile( selector, match ) )(
  19168. seed,
  19169. context,
  19170. !documentIsHTML,
  19171. results,
  19172. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  19173. );
  19174. return results;
  19175. };
  19176. // One-time assignments
  19177. // Sort stability
  19178. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  19179. // Support: Chrome 14-35+
  19180. // Always assume duplicates if they aren't passed to the comparison function
  19181. support.detectDuplicates = !!hasDuplicate;
  19182. // Initialize against the default document
  19183. setDocument();
  19184. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  19185. // Detached nodes confoundingly follow *each other*
  19186. support.sortDetached = assert(function( el ) {
  19187. // Should return 1, but returns 4 (following)
  19188. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  19189. });
  19190. // Support: IE<8
  19191. // Prevent attribute/property "interpolation"
  19192. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  19193. if ( !assert(function( el ) {
  19194. el.innerHTML = "<a href='#'></a>";
  19195. return el.firstChild.getAttribute("href") === "#" ;
  19196. }) ) {
  19197. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  19198. if ( !isXML ) {
  19199. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  19200. }
  19201. });
  19202. }
  19203. // Support: IE<9
  19204. // Use defaultValue in place of getAttribute("value")
  19205. if ( !support.attributes || !assert(function( el ) {
  19206. el.innerHTML = "<input/>";
  19207. el.firstChild.setAttribute( "value", "" );
  19208. return el.firstChild.getAttribute( "value" ) === "";
  19209. }) ) {
  19210. addHandle( "value", function( elem, name, isXML ) {
  19211. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  19212. return elem.defaultValue;
  19213. }
  19214. });
  19215. }
  19216. // Support: IE<9
  19217. // Use getAttributeNode to fetch booleans when getAttribute lies
  19218. if ( !assert(function( el ) {
  19219. return el.getAttribute("disabled") == null;
  19220. }) ) {
  19221. addHandle( booleans, function( elem, name, isXML ) {
  19222. var val;
  19223. if ( !isXML ) {
  19224. return elem[ name ] === true ? name.toLowerCase() :
  19225. (val = elem.getAttributeNode( name )) && val.specified ?
  19226. val.value :
  19227. null;
  19228. }
  19229. });
  19230. }
  19231. return Sizzle;
  19232. })( window );
  19233. jQuery.find = Sizzle;
  19234. jQuery.expr = Sizzle.selectors;
  19235. // Deprecated
  19236. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  19237. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  19238. jQuery.text = Sizzle.getText;
  19239. jQuery.isXMLDoc = Sizzle.isXML;
  19240. jQuery.contains = Sizzle.contains;
  19241. jQuery.escapeSelector = Sizzle.escape;
  19242. var dir = function( elem, dir, until ) {
  19243. var matched = [],
  19244. truncate = until !== undefined;
  19245. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  19246. if ( elem.nodeType === 1 ) {
  19247. if ( truncate && jQuery( elem ).is( until ) ) {
  19248. break;
  19249. }
  19250. matched.push( elem );
  19251. }
  19252. }
  19253. return matched;
  19254. };
  19255. var siblings = function( n, elem ) {
  19256. var matched = [];
  19257. for ( ; n; n = n.nextSibling ) {
  19258. if ( n.nodeType === 1 && n !== elem ) {
  19259. matched.push( n );
  19260. }
  19261. }
  19262. return matched;
  19263. };
  19264. var rneedsContext = jQuery.expr.match.needsContext;
  19265. function nodeName( elem, name ) {
  19266. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  19267. };
  19268. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  19269. var risSimple = /^.[^:#\[\.,]*$/;
  19270. // Implement the identical functionality for filter and not
  19271. function winnow( elements, qualifier, not ) {
  19272. if ( jQuery.isFunction( qualifier ) ) {
  19273. return jQuery.grep( elements, function( elem, i ) {
  19274. return !!qualifier.call( elem, i, elem ) !== not;
  19275. } );
  19276. }
  19277. // Single element
  19278. if ( qualifier.nodeType ) {
  19279. return jQuery.grep( elements, function( elem ) {
  19280. return ( elem === qualifier ) !== not;
  19281. } );
  19282. }
  19283. // Arraylike of elements (jQuery, arguments, Array)
  19284. if ( typeof qualifier !== "string" ) {
  19285. return jQuery.grep( elements, function( elem ) {
  19286. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  19287. } );
  19288. }
  19289. // Simple selector that can be filtered directly, removing non-Elements
  19290. if ( risSimple.test( qualifier ) ) {
  19291. return jQuery.filter( qualifier, elements, not );
  19292. }
  19293. // Complex selector, compare the two sets, removing non-Elements
  19294. qualifier = jQuery.filter( qualifier, elements );
  19295. return jQuery.grep( elements, function( elem ) {
  19296. return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
  19297. } );
  19298. }
  19299. jQuery.filter = function( expr, elems, not ) {
  19300. var elem = elems[ 0 ];
  19301. if ( not ) {
  19302. expr = ":not(" + expr + ")";
  19303. }
  19304. if ( elems.length === 1 && elem.nodeType === 1 ) {
  19305. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  19306. }
  19307. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  19308. return elem.nodeType === 1;
  19309. } ) );
  19310. };
  19311. jQuery.fn.extend( {
  19312. find: function( selector ) {
  19313. var i, ret,
  19314. len = this.length,
  19315. self = this;
  19316. if ( typeof selector !== "string" ) {
  19317. return this.pushStack( jQuery( selector ).filter( function() {
  19318. for ( i = 0; i < len; i++ ) {
  19319. if ( jQuery.contains( self[ i ], this ) ) {
  19320. return true;
  19321. }
  19322. }
  19323. } ) );
  19324. }
  19325. ret = this.pushStack( [] );
  19326. for ( i = 0; i < len; i++ ) {
  19327. jQuery.find( selector, self[ i ], ret );
  19328. }
  19329. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  19330. },
  19331. filter: function( selector ) {
  19332. return this.pushStack( winnow( this, selector || [], false ) );
  19333. },
  19334. not: function( selector ) {
  19335. return this.pushStack( winnow( this, selector || [], true ) );
  19336. },
  19337. is: function( selector ) {
  19338. return !!winnow(
  19339. this,
  19340. // If this is a positional/relative selector, check membership in the returned set
  19341. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  19342. typeof selector === "string" && rneedsContext.test( selector ) ?
  19343. jQuery( selector ) :
  19344. selector || [],
  19345. false
  19346. ).length;
  19347. }
  19348. } );
  19349. // Initialize a jQuery object
  19350. // A central reference to the root jQuery(document)
  19351. var rootjQuery,
  19352. // A simple way to check for HTML strings
  19353. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  19354. // Strict HTML recognition (#11290: must start with <)
  19355. // Shortcut simple #id case for speed
  19356. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  19357. init = jQuery.fn.init = function( selector, context, root ) {
  19358. var match, elem;
  19359. // HANDLE: $(""), $(null), $(undefined), $(false)
  19360. if ( !selector ) {
  19361. return this;
  19362. }
  19363. // Method init() accepts an alternate rootjQuery
  19364. // so migrate can support jQuery.sub (gh-2101)
  19365. root = root || rootjQuery;
  19366. // Handle HTML strings
  19367. if ( typeof selector === "string" ) {
  19368. if ( selector[ 0 ] === "<" &&
  19369. selector[ selector.length - 1 ] === ">" &&
  19370. selector.length >= 3 ) {
  19371. // Assume that strings that start and end with <> are HTML and skip the regex check
  19372. match = [ null, selector, null ];
  19373. } else {
  19374. match = rquickExpr.exec( selector );
  19375. }
  19376. // Match html or make sure no context is specified for #id
  19377. if ( match && ( match[ 1 ] || !context ) ) {
  19378. // HANDLE: $(html) -> $(array)
  19379. if ( match[ 1 ] ) {
  19380. context = context instanceof jQuery ? context[ 0 ] : context;
  19381. // Option to run scripts is true for back-compat
  19382. // Intentionally let the error be thrown if parseHTML is not present
  19383. jQuery.merge( this, jQuery.parseHTML(
  19384. match[ 1 ],
  19385. context && context.nodeType ? context.ownerDocument || context : document,
  19386. true
  19387. ) );
  19388. // HANDLE: $(html, props)
  19389. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  19390. for ( match in context ) {
  19391. // Properties of context are called as methods if possible
  19392. if ( jQuery.isFunction( this[ match ] ) ) {
  19393. this[ match ]( context[ match ] );
  19394. // ...and otherwise set as attributes
  19395. } else {
  19396. this.attr( match, context[ match ] );
  19397. }
  19398. }
  19399. }
  19400. return this;
  19401. // HANDLE: $(#id)
  19402. } else {
  19403. elem = document.getElementById( match[ 2 ] );
  19404. if ( elem ) {
  19405. // Inject the element directly into the jQuery object
  19406. this[ 0 ] = elem;
  19407. this.length = 1;
  19408. }
  19409. return this;
  19410. }
  19411. // HANDLE: $(expr, $(...))
  19412. } else if ( !context || context.jquery ) {
  19413. return ( context || root ).find( selector );
  19414. // HANDLE: $(expr, context)
  19415. // (which is just equivalent to: $(context).find(expr)
  19416. } else {
  19417. return this.constructor( context ).find( selector );
  19418. }
  19419. // HANDLE: $(DOMElement)
  19420. } else if ( selector.nodeType ) {
  19421. this[ 0 ] = selector;
  19422. this.length = 1;
  19423. return this;
  19424. // HANDLE: $(function)
  19425. // Shortcut for document ready
  19426. } else if ( jQuery.isFunction( selector ) ) {
  19427. return root.ready !== undefined ?
  19428. root.ready( selector ) :
  19429. // Execute immediately if ready is not present
  19430. selector( jQuery );
  19431. }
  19432. return jQuery.makeArray( selector, this );
  19433. };
  19434. // Give the init function the jQuery prototype for later instantiation
  19435. init.prototype = jQuery.fn;
  19436. // Initialize central reference
  19437. rootjQuery = jQuery( document );
  19438. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  19439. // Methods guaranteed to produce a unique set when starting from a unique set
  19440. guaranteedUnique = {
  19441. children: true,
  19442. contents: true,
  19443. next: true,
  19444. prev: true
  19445. };
  19446. jQuery.fn.extend( {
  19447. has: function( target ) {
  19448. var targets = jQuery( target, this ),
  19449. l = targets.length;
  19450. return this.filter( function() {
  19451. var i = 0;
  19452. for ( ; i < l; i++ ) {
  19453. if ( jQuery.contains( this, targets[ i ] ) ) {
  19454. return true;
  19455. }
  19456. }
  19457. } );
  19458. },
  19459. closest: function( selectors, context ) {
  19460. var cur,
  19461. i = 0,
  19462. l = this.length,
  19463. matched = [],
  19464. targets = typeof selectors !== "string" && jQuery( selectors );
  19465. // Positional selectors never match, since there's no _selection_ context
  19466. if ( !rneedsContext.test( selectors ) ) {
  19467. for ( ; i < l; i++ ) {
  19468. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  19469. // Always skip document fragments
  19470. if ( cur.nodeType < 11 && ( targets ?
  19471. targets.index( cur ) > -1 :
  19472. // Don't pass non-elements to Sizzle
  19473. cur.nodeType === 1 &&
  19474. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  19475. matched.push( cur );
  19476. break;
  19477. }
  19478. }
  19479. }
  19480. }
  19481. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  19482. },
  19483. // Determine the position of an element within the set
  19484. index: function( elem ) {
  19485. // No argument, return index in parent
  19486. if ( !elem ) {
  19487. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  19488. }
  19489. // Index in selector
  19490. if ( typeof elem === "string" ) {
  19491. return indexOf.call( jQuery( elem ), this[ 0 ] );
  19492. }
  19493. // Locate the position of the desired element
  19494. return indexOf.call( this,
  19495. // If it receives a jQuery object, the first element is used
  19496. elem.jquery ? elem[ 0 ] : elem
  19497. );
  19498. },
  19499. add: function( selector, context ) {
  19500. return this.pushStack(
  19501. jQuery.uniqueSort(
  19502. jQuery.merge( this.get(), jQuery( selector, context ) )
  19503. )
  19504. );
  19505. },
  19506. addBack: function( selector ) {
  19507. return this.add( selector == null ?
  19508. this.prevObject : this.prevObject.filter( selector )
  19509. );
  19510. }
  19511. } );
  19512. function sibling( cur, dir ) {
  19513. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  19514. return cur;
  19515. }
  19516. jQuery.each( {
  19517. parent: function( elem ) {
  19518. var parent = elem.parentNode;
  19519. return parent && parent.nodeType !== 11 ? parent : null;
  19520. },
  19521. parents: function( elem ) {
  19522. return dir( elem, "parentNode" );
  19523. },
  19524. parentsUntil: function( elem, i, until ) {
  19525. return dir( elem, "parentNode", until );
  19526. },
  19527. next: function( elem ) {
  19528. return sibling( elem, "nextSibling" );
  19529. },
  19530. prev: function( elem ) {
  19531. return sibling( elem, "previousSibling" );
  19532. },
  19533. nextAll: function( elem ) {
  19534. return dir( elem, "nextSibling" );
  19535. },
  19536. prevAll: function( elem ) {
  19537. return dir( elem, "previousSibling" );
  19538. },
  19539. nextUntil: function( elem, i, until ) {
  19540. return dir( elem, "nextSibling", until );
  19541. },
  19542. prevUntil: function( elem, i, until ) {
  19543. return dir( elem, "previousSibling", until );
  19544. },
  19545. siblings: function( elem ) {
  19546. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  19547. },
  19548. children: function( elem ) {
  19549. return siblings( elem.firstChild );
  19550. },
  19551. contents: function( elem ) {
  19552. if ( nodeName( elem, "iframe" ) ) {
  19553. return elem.contentDocument;
  19554. }
  19555. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  19556. // Treat the template element as a regular one in browsers that
  19557. // don't support it.
  19558. if ( nodeName( elem, "template" ) ) {
  19559. elem = elem.content || elem;
  19560. }
  19561. return jQuery.merge( [], elem.childNodes );
  19562. }
  19563. }, function( name, fn ) {
  19564. jQuery.fn[ name ] = function( until, selector ) {
  19565. var matched = jQuery.map( this, fn, until );
  19566. if ( name.slice( -5 ) !== "Until" ) {
  19567. selector = until;
  19568. }
  19569. if ( selector && typeof selector === "string" ) {
  19570. matched = jQuery.filter( selector, matched );
  19571. }
  19572. if ( this.length > 1 ) {
  19573. // Remove duplicates
  19574. if ( !guaranteedUnique[ name ] ) {
  19575. jQuery.uniqueSort( matched );
  19576. }
  19577. // Reverse order for parents* and prev-derivatives
  19578. if ( rparentsprev.test( name ) ) {
  19579. matched.reverse();
  19580. }
  19581. }
  19582. return this.pushStack( matched );
  19583. };
  19584. } );
  19585. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  19586. // Convert String-formatted options into Object-formatted ones
  19587. function createOptions( options ) {
  19588. var object = {};
  19589. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  19590. object[ flag ] = true;
  19591. } );
  19592. return object;
  19593. }
  19594. /*
  19595. * Create a callback list using the following parameters:
  19596. *
  19597. * options: an optional list of space-separated options that will change how
  19598. * the callback list behaves or a more traditional option object
  19599. *
  19600. * By default a callback list will act like an event callback list and can be
  19601. * "fired" multiple times.
  19602. *
  19603. * Possible options:
  19604. *
  19605. * once: will ensure the callback list can only be fired once (like a Deferred)
  19606. *
  19607. * memory: will keep track of previous values and will call any callback added
  19608. * after the list has been fired right away with the latest "memorized"
  19609. * values (like a Deferred)
  19610. *
  19611. * unique: will ensure a callback can only be added once (no duplicate in the list)
  19612. *
  19613. * stopOnFalse: interrupt callings when a callback returns false
  19614. *
  19615. */
  19616. jQuery.Callbacks = function( options ) {
  19617. // Convert options from String-formatted to Object-formatted if needed
  19618. // (we check in cache first)
  19619. options = typeof options === "string" ?
  19620. createOptions( options ) :
  19621. jQuery.extend( {}, options );
  19622. var // Flag to know if list is currently firing
  19623. firing,
  19624. // Last fire value for non-forgettable lists
  19625. memory,
  19626. // Flag to know if list was already fired
  19627. fired,
  19628. // Flag to prevent firing
  19629. locked,
  19630. // Actual callback list
  19631. list = [],
  19632. // Queue of execution data for repeatable lists
  19633. queue = [],
  19634. // Index of currently firing callback (modified by add/remove as needed)
  19635. firingIndex = -1,
  19636. // Fire callbacks
  19637. fire = function() {
  19638. // Enforce single-firing
  19639. locked = locked || options.once;
  19640. // Execute callbacks for all pending executions,
  19641. // respecting firingIndex overrides and runtime changes
  19642. fired = firing = true;
  19643. for ( ; queue.length; firingIndex = -1 ) {
  19644. memory = queue.shift();
  19645. while ( ++firingIndex < list.length ) {
  19646. // Run callback and check for early termination
  19647. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  19648. options.stopOnFalse ) {
  19649. // Jump to end and forget the data so .add doesn't re-fire
  19650. firingIndex = list.length;
  19651. memory = false;
  19652. }
  19653. }
  19654. }
  19655. // Forget the data if we're done with it
  19656. if ( !options.memory ) {
  19657. memory = false;
  19658. }
  19659. firing = false;
  19660. // Clean up if we're done firing for good
  19661. if ( locked ) {
  19662. // Keep an empty list if we have data for future add calls
  19663. if ( memory ) {
  19664. list = [];
  19665. // Otherwise, this object is spent
  19666. } else {
  19667. list = "";
  19668. }
  19669. }
  19670. },
  19671. // Actual Callbacks object
  19672. self = {
  19673. // Add a callback or a collection of callbacks to the list
  19674. add: function() {
  19675. if ( list ) {
  19676. // If we have memory from a past run, we should fire after adding
  19677. if ( memory && !firing ) {
  19678. firingIndex = list.length - 1;
  19679. queue.push( memory );
  19680. }
  19681. ( function add( args ) {
  19682. jQuery.each( args, function( _, arg ) {
  19683. if ( jQuery.isFunction( arg ) ) {
  19684. if ( !options.unique || !self.has( arg ) ) {
  19685. list.push( arg );
  19686. }
  19687. } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
  19688. // Inspect recursively
  19689. add( arg );
  19690. }
  19691. } );
  19692. } )( arguments );
  19693. if ( memory && !firing ) {
  19694. fire();
  19695. }
  19696. }
  19697. return this;
  19698. },
  19699. // Remove a callback from the list
  19700. remove: function() {
  19701. jQuery.each( arguments, function( _, arg ) {
  19702. var index;
  19703. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  19704. list.splice( index, 1 );
  19705. // Handle firing indexes
  19706. if ( index <= firingIndex ) {
  19707. firingIndex--;
  19708. }
  19709. }
  19710. } );
  19711. return this;
  19712. },
  19713. // Check if a given callback is in the list.
  19714. // If no argument is given, return whether or not list has callbacks attached.
  19715. has: function( fn ) {
  19716. return fn ?
  19717. jQuery.inArray( fn, list ) > -1 :
  19718. list.length > 0;
  19719. },
  19720. // Remove all callbacks from the list
  19721. empty: function() {
  19722. if ( list ) {
  19723. list = [];
  19724. }
  19725. return this;
  19726. },
  19727. // Disable .fire and .add
  19728. // Abort any current/pending executions
  19729. // Clear all callbacks and values
  19730. disable: function() {
  19731. locked = queue = [];
  19732. list = memory = "";
  19733. return this;
  19734. },
  19735. disabled: function() {
  19736. return !list;
  19737. },
  19738. // Disable .fire
  19739. // Also disable .add unless we have memory (since it would have no effect)
  19740. // Abort any pending executions
  19741. lock: function() {
  19742. locked = queue = [];
  19743. if ( !memory && !firing ) {
  19744. list = memory = "";
  19745. }
  19746. return this;
  19747. },
  19748. locked: function() {
  19749. return !!locked;
  19750. },
  19751. // Call all callbacks with the given context and arguments
  19752. fireWith: function( context, args ) {
  19753. if ( !locked ) {
  19754. args = args || [];
  19755. args = [ context, args.slice ? args.slice() : args ];
  19756. queue.push( args );
  19757. if ( !firing ) {
  19758. fire();
  19759. }
  19760. }
  19761. return this;
  19762. },
  19763. // Call all the callbacks with the given arguments
  19764. fire: function() {
  19765. self.fireWith( this, arguments );
  19766. return this;
  19767. },
  19768. // To know if the callbacks have already been called at least once
  19769. fired: function() {
  19770. return !!fired;
  19771. }
  19772. };
  19773. return self;
  19774. };
  19775. function Identity( v ) {
  19776. return v;
  19777. }
  19778. function Thrower( ex ) {
  19779. throw ex;
  19780. }
  19781. function adoptValue( value, resolve, reject, noValue ) {
  19782. var method;
  19783. try {
  19784. // Check for promise aspect first to privilege synchronous behavior
  19785. if ( value && jQuery.isFunction( ( method = value.promise ) ) ) {
  19786. method.call( value ).done( resolve ).fail( reject );
  19787. // Other thenables
  19788. } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) {
  19789. method.call( value, resolve, reject );
  19790. // Other non-thenables
  19791. } else {
  19792. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  19793. // * false: [ value ].slice( 0 ) => resolve( value )
  19794. // * true: [ value ].slice( 1 ) => resolve()
  19795. resolve.apply( undefined, [ value ].slice( noValue ) );
  19796. }
  19797. // For Promises/A+, convert exceptions into rejections
  19798. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  19799. // Deferred#then to conditionally suppress rejection.
  19800. } catch ( value ) {
  19801. // Support: Android 4.0 only
  19802. // Strict mode functions invoked without .call/.apply get global-object context
  19803. reject.apply( undefined, [ value ] );
  19804. }
  19805. }
  19806. jQuery.extend( {
  19807. Deferred: function( func ) {
  19808. var tuples = [
  19809. // action, add listener, callbacks,
  19810. // ... .then handlers, argument index, [final state]
  19811. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  19812. jQuery.Callbacks( "memory" ), 2 ],
  19813. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  19814. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  19815. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  19816. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  19817. ],
  19818. state = "pending",
  19819. promise = {
  19820. state: function() {
  19821. return state;
  19822. },
  19823. always: function() {
  19824. deferred.done( arguments ).fail( arguments );
  19825. return this;
  19826. },
  19827. "catch": function( fn ) {
  19828. return promise.then( null, fn );
  19829. },
  19830. // Keep pipe for back-compat
  19831. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  19832. var fns = arguments;
  19833. return jQuery.Deferred( function( newDefer ) {
  19834. jQuery.each( tuples, function( i, tuple ) {
  19835. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  19836. var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  19837. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  19838. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  19839. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  19840. deferred[ tuple[ 1 ] ]( function() {
  19841. var returned = fn && fn.apply( this, arguments );
  19842. if ( returned && jQuery.isFunction( returned.promise ) ) {
  19843. returned.promise()
  19844. .progress( newDefer.notify )
  19845. .done( newDefer.resolve )
  19846. .fail( newDefer.reject );
  19847. } else {
  19848. newDefer[ tuple[ 0 ] + "With" ](
  19849. this,
  19850. fn ? [ returned ] : arguments
  19851. );
  19852. }
  19853. } );
  19854. } );
  19855. fns = null;
  19856. } ).promise();
  19857. },
  19858. then: function( onFulfilled, onRejected, onProgress ) {
  19859. var maxDepth = 0;
  19860. function resolve( depth, deferred, handler, special ) {
  19861. return function() {
  19862. var that = this,
  19863. args = arguments,
  19864. mightThrow = function() {
  19865. var returned, then;
  19866. // Support: Promises/A+ section 2.3.3.3.3
  19867. // https://promisesaplus.com/#point-59
  19868. // Ignore double-resolution attempts
  19869. if ( depth < maxDepth ) {
  19870. return;
  19871. }
  19872. returned = handler.apply( that, args );
  19873. // Support: Promises/A+ section 2.3.1
  19874. // https://promisesaplus.com/#point-48
  19875. if ( returned === deferred.promise() ) {
  19876. throw new TypeError( "Thenable self-resolution" );
  19877. }
  19878. // Support: Promises/A+ sections 2.3.3.1, 3.5
  19879. // https://promisesaplus.com/#point-54
  19880. // https://promisesaplus.com/#point-75
  19881. // Retrieve `then` only once
  19882. then = returned &&
  19883. // Support: Promises/A+ section 2.3.4
  19884. // https://promisesaplus.com/#point-64
  19885. // Only check objects and functions for thenability
  19886. ( typeof returned === "object" ||
  19887. typeof returned === "function" ) &&
  19888. returned.then;
  19889. // Handle a returned thenable
  19890. if ( jQuery.isFunction( then ) ) {
  19891. // Special processors (notify) just wait for resolution
  19892. if ( special ) {
  19893. then.call(
  19894. returned,
  19895. resolve( maxDepth, deferred, Identity, special ),
  19896. resolve( maxDepth, deferred, Thrower, special )
  19897. );
  19898. // Normal processors (resolve) also hook into progress
  19899. } else {
  19900. // ...and disregard older resolution values
  19901. maxDepth++;
  19902. then.call(
  19903. returned,
  19904. resolve( maxDepth, deferred, Identity, special ),
  19905. resolve( maxDepth, deferred, Thrower, special ),
  19906. resolve( maxDepth, deferred, Identity,
  19907. deferred.notifyWith )
  19908. );
  19909. }
  19910. // Handle all other returned values
  19911. } else {
  19912. // Only substitute handlers pass on context
  19913. // and multiple values (non-spec behavior)
  19914. if ( handler !== Identity ) {
  19915. that = undefined;
  19916. args = [ returned ];
  19917. }
  19918. // Process the value(s)
  19919. // Default process is resolve
  19920. ( special || deferred.resolveWith )( that, args );
  19921. }
  19922. },
  19923. // Only normal processors (resolve) catch and reject exceptions
  19924. process = special ?
  19925. mightThrow :
  19926. function() {
  19927. try {
  19928. mightThrow();
  19929. } catch ( e ) {
  19930. if ( jQuery.Deferred.exceptionHook ) {
  19931. jQuery.Deferred.exceptionHook( e,
  19932. process.stackTrace );
  19933. }
  19934. // Support: Promises/A+ section 2.3.3.3.4.1
  19935. // https://promisesaplus.com/#point-61
  19936. // Ignore post-resolution exceptions
  19937. if ( depth + 1 >= maxDepth ) {
  19938. // Only substitute handlers pass on context
  19939. // and multiple values (non-spec behavior)
  19940. if ( handler !== Thrower ) {
  19941. that = undefined;
  19942. args = [ e ];
  19943. }
  19944. deferred.rejectWith( that, args );
  19945. }
  19946. }
  19947. };
  19948. // Support: Promises/A+ section 2.3.3.3.1
  19949. // https://promisesaplus.com/#point-57
  19950. // Re-resolve promises immediately to dodge false rejection from
  19951. // subsequent errors
  19952. if ( depth ) {
  19953. process();
  19954. } else {
  19955. // Call an optional hook to record the stack, in case of exception
  19956. // since it's otherwise lost when execution goes async
  19957. if ( jQuery.Deferred.getStackHook ) {
  19958. process.stackTrace = jQuery.Deferred.getStackHook();
  19959. }
  19960. window.setTimeout( process );
  19961. }
  19962. };
  19963. }
  19964. return jQuery.Deferred( function( newDefer ) {
  19965. // progress_handlers.add( ... )
  19966. tuples[ 0 ][ 3 ].add(
  19967. resolve(
  19968. 0,
  19969. newDefer,
  19970. jQuery.isFunction( onProgress ) ?
  19971. onProgress :
  19972. Identity,
  19973. newDefer.notifyWith
  19974. )
  19975. );
  19976. // fulfilled_handlers.add( ... )
  19977. tuples[ 1 ][ 3 ].add(
  19978. resolve(
  19979. 0,
  19980. newDefer,
  19981. jQuery.isFunction( onFulfilled ) ?
  19982. onFulfilled :
  19983. Identity
  19984. )
  19985. );
  19986. // rejected_handlers.add( ... )
  19987. tuples[ 2 ][ 3 ].add(
  19988. resolve(
  19989. 0,
  19990. newDefer,
  19991. jQuery.isFunction( onRejected ) ?
  19992. onRejected :
  19993. Thrower
  19994. )
  19995. );
  19996. } ).promise();
  19997. },
  19998. // Get a promise for this deferred
  19999. // If obj is provided, the promise aspect is added to the object
  20000. promise: function( obj ) {
  20001. return obj != null ? jQuery.extend( obj, promise ) : promise;
  20002. }
  20003. },
  20004. deferred = {};
  20005. // Add list-specific methods
  20006. jQuery.each( tuples, function( i, tuple ) {
  20007. var list = tuple[ 2 ],
  20008. stateString = tuple[ 5 ];
  20009. // promise.progress = list.add
  20010. // promise.done = list.add
  20011. // promise.fail = list.add
  20012. promise[ tuple[ 1 ] ] = list.add;
  20013. // Handle state
  20014. if ( stateString ) {
  20015. list.add(
  20016. function() {
  20017. // state = "resolved" (i.e., fulfilled)
  20018. // state = "rejected"
  20019. state = stateString;
  20020. },
  20021. // rejected_callbacks.disable
  20022. // fulfilled_callbacks.disable
  20023. tuples[ 3 - i ][ 2 ].disable,
  20024. // progress_callbacks.lock
  20025. tuples[ 0 ][ 2 ].lock
  20026. );
  20027. }
  20028. // progress_handlers.fire
  20029. // fulfilled_handlers.fire
  20030. // rejected_handlers.fire
  20031. list.add( tuple[ 3 ].fire );
  20032. // deferred.notify = function() { deferred.notifyWith(...) }
  20033. // deferred.resolve = function() { deferred.resolveWith(...) }
  20034. // deferred.reject = function() { deferred.rejectWith(...) }
  20035. deferred[ tuple[ 0 ] ] = function() {
  20036. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  20037. return this;
  20038. };
  20039. // deferred.notifyWith = list.fireWith
  20040. // deferred.resolveWith = list.fireWith
  20041. // deferred.rejectWith = list.fireWith
  20042. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  20043. } );
  20044. // Make the deferred a promise
  20045. promise.promise( deferred );
  20046. // Call given func if any
  20047. if ( func ) {
  20048. func.call( deferred, deferred );
  20049. }
  20050. // All done!
  20051. return deferred;
  20052. },
  20053. // Deferred helper
  20054. when: function( singleValue ) {
  20055. var
  20056. // count of uncompleted subordinates
  20057. remaining = arguments.length,
  20058. // count of unprocessed arguments
  20059. i = remaining,
  20060. // subordinate fulfillment data
  20061. resolveContexts = Array( i ),
  20062. resolveValues = slice.call( arguments ),
  20063. // the master Deferred
  20064. master = jQuery.Deferred(),
  20065. // subordinate callback factory
  20066. updateFunc = function( i ) {
  20067. return function( value ) {
  20068. resolveContexts[ i ] = this;
  20069. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  20070. if ( !( --remaining ) ) {
  20071. master.resolveWith( resolveContexts, resolveValues );
  20072. }
  20073. };
  20074. };
  20075. // Single- and empty arguments are adopted like Promise.resolve
  20076. if ( remaining <= 1 ) {
  20077. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  20078. !remaining );
  20079. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  20080. if ( master.state() === "pending" ||
  20081. jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  20082. return master.then();
  20083. }
  20084. }
  20085. // Multiple arguments are aggregated like Promise.all array elements
  20086. while ( i-- ) {
  20087. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  20088. }
  20089. return master.promise();
  20090. }
  20091. } );
  20092. // These usually indicate a programmer mistake during development,
  20093. // warn about them ASAP rather than swallowing them by default.
  20094. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  20095. jQuery.Deferred.exceptionHook = function( error, stack ) {
  20096. // Support: IE 8 - 9 only
  20097. // Console exists when dev tools are open, which can happen at any time
  20098. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  20099. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  20100. }
  20101. };
  20102. jQuery.readyException = function( error ) {
  20103. window.setTimeout( function() {
  20104. throw error;
  20105. } );
  20106. };
  20107. // The deferred used on DOM ready
  20108. var readyList = jQuery.Deferred();
  20109. jQuery.fn.ready = function( fn ) {
  20110. readyList
  20111. .then( fn )
  20112. // Wrap jQuery.readyException in a function so that the lookup
  20113. // happens at the time of error handling instead of callback
  20114. // registration.
  20115. .catch( function( error ) {
  20116. jQuery.readyException( error );
  20117. } );
  20118. return this;
  20119. };
  20120. jQuery.extend( {
  20121. // Is the DOM ready to be used? Set to true once it occurs.
  20122. isReady: false,
  20123. // A counter to track how many items to wait for before
  20124. // the ready event fires. See #6781
  20125. readyWait: 1,
  20126. // Handle when the DOM is ready
  20127. ready: function( wait ) {
  20128. // Abort if there are pending holds or we're already ready
  20129. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  20130. return;
  20131. }
  20132. // Remember that the DOM is ready
  20133. jQuery.isReady = true;
  20134. // If a normal DOM Ready event fired, decrement, and wait if need be
  20135. if ( wait !== true && --jQuery.readyWait > 0 ) {
  20136. return;
  20137. }
  20138. // If there are functions bound, to execute
  20139. readyList.resolveWith( document, [ jQuery ] );
  20140. }
  20141. } );
  20142. jQuery.ready.then = readyList.then;
  20143. // The ready event handler and self cleanup method
  20144. function completed() {
  20145. document.removeEventListener( "DOMContentLoaded", completed );
  20146. window.removeEventListener( "load", completed );
  20147. jQuery.ready();
  20148. }
  20149. // Catch cases where $(document).ready() is called
  20150. // after the browser event has already occurred.
  20151. // Support: IE <=9 - 10 only
  20152. // Older IE sometimes signals "interactive" too soon
  20153. if ( document.readyState === "complete" ||
  20154. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  20155. // Handle it asynchronously to allow scripts the opportunity to delay ready
  20156. window.setTimeout( jQuery.ready );
  20157. } else {
  20158. // Use the handy event callback
  20159. document.addEventListener( "DOMContentLoaded", completed );
  20160. // A fallback to window.onload, that will always work
  20161. window.addEventListener( "load", completed );
  20162. }
  20163. // Multifunctional method to get and set values of a collection
  20164. // The value/s can optionally be executed if it's a function
  20165. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  20166. var i = 0,
  20167. len = elems.length,
  20168. bulk = key == null;
  20169. // Sets many values
  20170. if ( jQuery.type( key ) === "object" ) {
  20171. chainable = true;
  20172. for ( i in key ) {
  20173. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  20174. }
  20175. // Sets one value
  20176. } else if ( value !== undefined ) {
  20177. chainable = true;
  20178. if ( !jQuery.isFunction( value ) ) {
  20179. raw = true;
  20180. }
  20181. if ( bulk ) {
  20182. // Bulk operations run against the entire set
  20183. if ( raw ) {
  20184. fn.call( elems, value );
  20185. fn = null;
  20186. // ...except when executing function values
  20187. } else {
  20188. bulk = fn;
  20189. fn = function( elem, key, value ) {
  20190. return bulk.call( jQuery( elem ), value );
  20191. };
  20192. }
  20193. }
  20194. if ( fn ) {
  20195. for ( ; i < len; i++ ) {
  20196. fn(
  20197. elems[ i ], key, raw ?
  20198. value :
  20199. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  20200. );
  20201. }
  20202. }
  20203. }
  20204. if ( chainable ) {
  20205. return elems;
  20206. }
  20207. // Gets
  20208. if ( bulk ) {
  20209. return fn.call( elems );
  20210. }
  20211. return len ? fn( elems[ 0 ], key ) : emptyGet;
  20212. };
  20213. var acceptData = function( owner ) {
  20214. // Accepts only:
  20215. // - Node
  20216. // - Node.ELEMENT_NODE
  20217. // - Node.DOCUMENT_NODE
  20218. // - Object
  20219. // - Any
  20220. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  20221. };
  20222. function Data() {
  20223. this.expando = jQuery.expando + Data.uid++;
  20224. }
  20225. Data.uid = 1;
  20226. Data.prototype = {
  20227. cache: function( owner ) {
  20228. // Check if the owner object already has a cache
  20229. var value = owner[ this.expando ];
  20230. // If not, create one
  20231. if ( !value ) {
  20232. value = {};
  20233. // We can accept data for non-element nodes in modern browsers,
  20234. // but we should not, see #8335.
  20235. // Always return an empty object.
  20236. if ( acceptData( owner ) ) {
  20237. // If it is a node unlikely to be stringify-ed or looped over
  20238. // use plain assignment
  20239. if ( owner.nodeType ) {
  20240. owner[ this.expando ] = value;
  20241. // Otherwise secure it in a non-enumerable property
  20242. // configurable must be true to allow the property to be
  20243. // deleted when data is removed
  20244. } else {
  20245. Object.defineProperty( owner, this.expando, {
  20246. value: value,
  20247. configurable: true
  20248. } );
  20249. }
  20250. }
  20251. }
  20252. return value;
  20253. },
  20254. set: function( owner, data, value ) {
  20255. var prop,
  20256. cache = this.cache( owner );
  20257. // Handle: [ owner, key, value ] args
  20258. // Always use camelCase key (gh-2257)
  20259. if ( typeof data === "string" ) {
  20260. cache[ jQuery.camelCase( data ) ] = value;
  20261. // Handle: [ owner, { properties } ] args
  20262. } else {
  20263. // Copy the properties one-by-one to the cache object
  20264. for ( prop in data ) {
  20265. cache[ jQuery.camelCase( prop ) ] = data[ prop ];
  20266. }
  20267. }
  20268. return cache;
  20269. },
  20270. get: function( owner, key ) {
  20271. return key === undefined ?
  20272. this.cache( owner ) :
  20273. // Always use camelCase key (gh-2257)
  20274. owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
  20275. },
  20276. access: function( owner, key, value ) {
  20277. // In cases where either:
  20278. //
  20279. // 1. No key was specified
  20280. // 2. A string key was specified, but no value provided
  20281. //
  20282. // Take the "read" path and allow the get method to determine
  20283. // which value to return, respectively either:
  20284. //
  20285. // 1. The entire cache object
  20286. // 2. The data stored at the key
  20287. //
  20288. if ( key === undefined ||
  20289. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  20290. return this.get( owner, key );
  20291. }
  20292. // When the key is not a string, or both a key and value
  20293. // are specified, set or extend (existing objects) with either:
  20294. //
  20295. // 1. An object of properties
  20296. // 2. A key and value
  20297. //
  20298. this.set( owner, key, value );
  20299. // Since the "set" path can have two possible entry points
  20300. // return the expected data based on which path was taken[*]
  20301. return value !== undefined ? value : key;
  20302. },
  20303. remove: function( owner, key ) {
  20304. var i,
  20305. cache = owner[ this.expando ];
  20306. if ( cache === undefined ) {
  20307. return;
  20308. }
  20309. if ( key !== undefined ) {
  20310. // Support array or space separated string of keys
  20311. if ( Array.isArray( key ) ) {
  20312. // If key is an array of keys...
  20313. // We always set camelCase keys, so remove that.
  20314. key = key.map( jQuery.camelCase );
  20315. } else {
  20316. key = jQuery.camelCase( key );
  20317. // If a key with the spaces exists, use it.
  20318. // Otherwise, create an array by matching non-whitespace
  20319. key = key in cache ?
  20320. [ key ] :
  20321. ( key.match( rnothtmlwhite ) || [] );
  20322. }
  20323. i = key.length;
  20324. while ( i-- ) {
  20325. delete cache[ key[ i ] ];
  20326. }
  20327. }
  20328. // Remove the expando if there's no more data
  20329. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  20330. // Support: Chrome <=35 - 45
  20331. // Webkit & Blink performance suffers when deleting properties
  20332. // from DOM nodes, so set to undefined instead
  20333. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  20334. if ( owner.nodeType ) {
  20335. owner[ this.expando ] = undefined;
  20336. } else {
  20337. delete owner[ this.expando ];
  20338. }
  20339. }
  20340. },
  20341. hasData: function( owner ) {
  20342. var cache = owner[ this.expando ];
  20343. return cache !== undefined && !jQuery.isEmptyObject( cache );
  20344. }
  20345. };
  20346. var dataPriv = new Data();
  20347. var dataUser = new Data();
  20348. // Implementation Summary
  20349. //
  20350. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  20351. // 2. Improve the module's maintainability by reducing the storage
  20352. // paths to a single mechanism.
  20353. // 3. Use the same single mechanism to support "private" and "user" data.
  20354. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  20355. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  20356. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  20357. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  20358. rmultiDash = /[A-Z]/g;
  20359. function getData( data ) {
  20360. if ( data === "true" ) {
  20361. return true;
  20362. }
  20363. if ( data === "false" ) {
  20364. return false;
  20365. }
  20366. if ( data === "null" ) {
  20367. return null;
  20368. }
  20369. // Only convert to a number if it doesn't change the string
  20370. if ( data === +data + "" ) {
  20371. return +data;
  20372. }
  20373. if ( rbrace.test( data ) ) {
  20374. return JSON.parse( data );
  20375. }
  20376. return data;
  20377. }
  20378. function dataAttr( elem, key, data ) {
  20379. var name;
  20380. // If nothing was found internally, try to fetch any
  20381. // data from the HTML5 data-* attribute
  20382. if ( data === undefined && elem.nodeType === 1 ) {
  20383. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  20384. data = elem.getAttribute( name );
  20385. if ( typeof data === "string" ) {
  20386. try {
  20387. data = getData( data );
  20388. } catch ( e ) {}
  20389. // Make sure we set the data so it isn't changed later
  20390. dataUser.set( elem, key, data );
  20391. } else {
  20392. data = undefined;
  20393. }
  20394. }
  20395. return data;
  20396. }
  20397. jQuery.extend( {
  20398. hasData: function( elem ) {
  20399. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  20400. },
  20401. data: function( elem, name, data ) {
  20402. return dataUser.access( elem, name, data );
  20403. },
  20404. removeData: function( elem, name ) {
  20405. dataUser.remove( elem, name );
  20406. },
  20407. // TODO: Now that all calls to _data and _removeData have been replaced
  20408. // with direct calls to dataPriv methods, these can be deprecated.
  20409. _data: function( elem, name, data ) {
  20410. return dataPriv.access( elem, name, data );
  20411. },
  20412. _removeData: function( elem, name ) {
  20413. dataPriv.remove( elem, name );
  20414. }
  20415. } );
  20416. jQuery.fn.extend( {
  20417. data: function( key, value ) {
  20418. var i, name, data,
  20419. elem = this[ 0 ],
  20420. attrs = elem && elem.attributes;
  20421. // Gets all values
  20422. if ( key === undefined ) {
  20423. if ( this.length ) {
  20424. data = dataUser.get( elem );
  20425. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  20426. i = attrs.length;
  20427. while ( i-- ) {
  20428. // Support: IE 11 only
  20429. // The attrs elements can be null (#14894)
  20430. if ( attrs[ i ] ) {
  20431. name = attrs[ i ].name;
  20432. if ( name.indexOf( "data-" ) === 0 ) {
  20433. name = jQuery.camelCase( name.slice( 5 ) );
  20434. dataAttr( elem, name, data[ name ] );
  20435. }
  20436. }
  20437. }
  20438. dataPriv.set( elem, "hasDataAttrs", true );
  20439. }
  20440. }
  20441. return data;
  20442. }
  20443. // Sets multiple values
  20444. if ( typeof key === "object" ) {
  20445. return this.each( function() {
  20446. dataUser.set( this, key );
  20447. } );
  20448. }
  20449. return access( this, function( value ) {
  20450. var data;
  20451. // The calling jQuery object (element matches) is not empty
  20452. // (and therefore has an element appears at this[ 0 ]) and the
  20453. // `value` parameter was not undefined. An empty jQuery object
  20454. // will result in `undefined` for elem = this[ 0 ] which will
  20455. // throw an exception if an attempt to read a data cache is made.
  20456. if ( elem && value === undefined ) {
  20457. // Attempt to get data from the cache
  20458. // The key will always be camelCased in Data
  20459. data = dataUser.get( elem, key );
  20460. if ( data !== undefined ) {
  20461. return data;
  20462. }
  20463. // Attempt to "discover" the data in
  20464. // HTML5 custom data-* attrs
  20465. data = dataAttr( elem, key );
  20466. if ( data !== undefined ) {
  20467. return data;
  20468. }
  20469. // We tried really hard, but the data doesn't exist.
  20470. return;
  20471. }
  20472. // Set the data...
  20473. this.each( function() {
  20474. // We always store the camelCased key
  20475. dataUser.set( this, key, value );
  20476. } );
  20477. }, null, value, arguments.length > 1, null, true );
  20478. },
  20479. removeData: function( key ) {
  20480. return this.each( function() {
  20481. dataUser.remove( this, key );
  20482. } );
  20483. }
  20484. } );
  20485. jQuery.extend( {
  20486. queue: function( elem, type, data ) {
  20487. var queue;
  20488. if ( elem ) {
  20489. type = ( type || "fx" ) + "queue";
  20490. queue = dataPriv.get( elem, type );
  20491. // Speed up dequeue by getting out quickly if this is just a lookup
  20492. if ( data ) {
  20493. if ( !queue || Array.isArray( data ) ) {
  20494. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  20495. } else {
  20496. queue.push( data );
  20497. }
  20498. }
  20499. return queue || [];
  20500. }
  20501. },
  20502. dequeue: function( elem, type ) {
  20503. type = type || "fx";
  20504. var queue = jQuery.queue( elem, type ),
  20505. startLength = queue.length,
  20506. fn = queue.shift(),
  20507. hooks = jQuery._queueHooks( elem, type ),
  20508. next = function() {
  20509. jQuery.dequeue( elem, type );
  20510. };
  20511. // If the fx queue is dequeued, always remove the progress sentinel
  20512. if ( fn === "inprogress" ) {
  20513. fn = queue.shift();
  20514. startLength--;
  20515. }
  20516. if ( fn ) {
  20517. // Add a progress sentinel to prevent the fx queue from being
  20518. // automatically dequeued
  20519. if ( type === "fx" ) {
  20520. queue.unshift( "inprogress" );
  20521. }
  20522. // Clear up the last queue stop function
  20523. delete hooks.stop;
  20524. fn.call( elem, next, hooks );
  20525. }
  20526. if ( !startLength && hooks ) {
  20527. hooks.empty.fire();
  20528. }
  20529. },
  20530. // Not public - generate a queueHooks object, or return the current one
  20531. _queueHooks: function( elem, type ) {
  20532. var key = type + "queueHooks";
  20533. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  20534. empty: jQuery.Callbacks( "once memory" ).add( function() {
  20535. dataPriv.remove( elem, [ type + "queue", key ] );
  20536. } )
  20537. } );
  20538. }
  20539. } );
  20540. jQuery.fn.extend( {
  20541. queue: function( type, data ) {
  20542. var setter = 2;
  20543. if ( typeof type !== "string" ) {
  20544. data = type;
  20545. type = "fx";
  20546. setter--;
  20547. }
  20548. if ( arguments.length < setter ) {
  20549. return jQuery.queue( this[ 0 ], type );
  20550. }
  20551. return data === undefined ?
  20552. this :
  20553. this.each( function() {
  20554. var queue = jQuery.queue( this, type, data );
  20555. // Ensure a hooks for this queue
  20556. jQuery._queueHooks( this, type );
  20557. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  20558. jQuery.dequeue( this, type );
  20559. }
  20560. } );
  20561. },
  20562. dequeue: function( type ) {
  20563. return this.each( function() {
  20564. jQuery.dequeue( this, type );
  20565. } );
  20566. },
  20567. clearQueue: function( type ) {
  20568. return this.queue( type || "fx", [] );
  20569. },
  20570. // Get a promise resolved when queues of a certain type
  20571. // are emptied (fx is the type by default)
  20572. promise: function( type, obj ) {
  20573. var tmp,
  20574. count = 1,
  20575. defer = jQuery.Deferred(),
  20576. elements = this,
  20577. i = this.length,
  20578. resolve = function() {
  20579. if ( !( --count ) ) {
  20580. defer.resolveWith( elements, [ elements ] );
  20581. }
  20582. };
  20583. if ( typeof type !== "string" ) {
  20584. obj = type;
  20585. type = undefined;
  20586. }
  20587. type = type || "fx";
  20588. while ( i-- ) {
  20589. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  20590. if ( tmp && tmp.empty ) {
  20591. count++;
  20592. tmp.empty.add( resolve );
  20593. }
  20594. }
  20595. resolve();
  20596. return defer.promise( obj );
  20597. }
  20598. } );
  20599. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  20600. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  20601. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  20602. var isHiddenWithinTree = function( elem, el ) {
  20603. // isHiddenWithinTree might be called from jQuery#filter function;
  20604. // in that case, element will be second argument
  20605. elem = el || elem;
  20606. // Inline style trumps all
  20607. return elem.style.display === "none" ||
  20608. elem.style.display === "" &&
  20609. // Otherwise, check computed style
  20610. // Support: Firefox <=43 - 45
  20611. // Disconnected elements can have computed display: none, so first confirm that elem is
  20612. // in the document.
  20613. jQuery.contains( elem.ownerDocument, elem ) &&
  20614. jQuery.css( elem, "display" ) === "none";
  20615. };
  20616. var swap = function( elem, options, callback, args ) {
  20617. var ret, name,
  20618. old = {};
  20619. // Remember the old values, and insert the new ones
  20620. for ( name in options ) {
  20621. old[ name ] = elem.style[ name ];
  20622. elem.style[ name ] = options[ name ];
  20623. }
  20624. ret = callback.apply( elem, args || [] );
  20625. // Revert the old values
  20626. for ( name in options ) {
  20627. elem.style[ name ] = old[ name ];
  20628. }
  20629. return ret;
  20630. };
  20631. function adjustCSS( elem, prop, valueParts, tween ) {
  20632. var adjusted,
  20633. scale = 1,
  20634. maxIterations = 20,
  20635. currentValue = tween ?
  20636. function() {
  20637. return tween.cur();
  20638. } :
  20639. function() {
  20640. return jQuery.css( elem, prop, "" );
  20641. },
  20642. initial = currentValue(),
  20643. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  20644. // Starting value computation is required for potential unit mismatches
  20645. initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  20646. rcssNum.exec( jQuery.css( elem, prop ) );
  20647. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  20648. // Trust units reported by jQuery.css
  20649. unit = unit || initialInUnit[ 3 ];
  20650. // Make sure we update the tween properties later on
  20651. valueParts = valueParts || [];
  20652. // Iteratively approximate from a nonzero starting point
  20653. initialInUnit = +initial || 1;
  20654. do {
  20655. // If previous iteration zeroed out, double until we get *something*.
  20656. // Use string for doubling so we don't accidentally see scale as unchanged below
  20657. scale = scale || ".5";
  20658. // Adjust and apply
  20659. initialInUnit = initialInUnit / scale;
  20660. jQuery.style( elem, prop, initialInUnit + unit );
  20661. // Update scale, tolerating zero or NaN from tween.cur()
  20662. // Break the loop if scale is unchanged or perfect, or if we've just had enough.
  20663. } while (
  20664. scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
  20665. );
  20666. }
  20667. if ( valueParts ) {
  20668. initialInUnit = +initialInUnit || +initial || 0;
  20669. // Apply relative offset (+=/-=) if specified
  20670. adjusted = valueParts[ 1 ] ?
  20671. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  20672. +valueParts[ 2 ];
  20673. if ( tween ) {
  20674. tween.unit = unit;
  20675. tween.start = initialInUnit;
  20676. tween.end = adjusted;
  20677. }
  20678. }
  20679. return adjusted;
  20680. }
  20681. var defaultDisplayMap = {};
  20682. function getDefaultDisplay( elem ) {
  20683. var temp,
  20684. doc = elem.ownerDocument,
  20685. nodeName = elem.nodeName,
  20686. display = defaultDisplayMap[ nodeName ];
  20687. if ( display ) {
  20688. return display;
  20689. }
  20690. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  20691. display = jQuery.css( temp, "display" );
  20692. temp.parentNode.removeChild( temp );
  20693. if ( display === "none" ) {
  20694. display = "block";
  20695. }
  20696. defaultDisplayMap[ nodeName ] = display;
  20697. return display;
  20698. }
  20699. function showHide( elements, show ) {
  20700. var display, elem,
  20701. values = [],
  20702. index = 0,
  20703. length = elements.length;
  20704. // Determine new display value for elements that need to change
  20705. for ( ; index < length; index++ ) {
  20706. elem = elements[ index ];
  20707. if ( !elem.style ) {
  20708. continue;
  20709. }
  20710. display = elem.style.display;
  20711. if ( show ) {
  20712. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  20713. // check is required in this first loop unless we have a nonempty display value (either
  20714. // inline or about-to-be-restored)
  20715. if ( display === "none" ) {
  20716. values[ index ] = dataPriv.get( elem, "display" ) || null;
  20717. if ( !values[ index ] ) {
  20718. elem.style.display = "";
  20719. }
  20720. }
  20721. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  20722. values[ index ] = getDefaultDisplay( elem );
  20723. }
  20724. } else {
  20725. if ( display !== "none" ) {
  20726. values[ index ] = "none";
  20727. // Remember what we're overwriting
  20728. dataPriv.set( elem, "display", display );
  20729. }
  20730. }
  20731. }
  20732. // Set the display of the elements in a second loop to avoid constant reflow
  20733. for ( index = 0; index < length; index++ ) {
  20734. if ( values[ index ] != null ) {
  20735. elements[ index ].style.display = values[ index ];
  20736. }
  20737. }
  20738. return elements;
  20739. }
  20740. jQuery.fn.extend( {
  20741. show: function() {
  20742. return showHide( this, true );
  20743. },
  20744. hide: function() {
  20745. return showHide( this );
  20746. },
  20747. toggle: function( state ) {
  20748. if ( typeof state === "boolean" ) {
  20749. return state ? this.show() : this.hide();
  20750. }
  20751. return this.each( function() {
  20752. if ( isHiddenWithinTree( this ) ) {
  20753. jQuery( this ).show();
  20754. } else {
  20755. jQuery( this ).hide();
  20756. }
  20757. } );
  20758. }
  20759. } );
  20760. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  20761. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
  20762. var rscriptType = ( /^$|\/(?:java|ecma)script/i );
  20763. // We have to close these tags to support XHTML (#13200)
  20764. var wrapMap = {
  20765. // Support: IE <=9 only
  20766. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  20767. // XHTML parsers do not magically insert elements in the
  20768. // same way that tag soup parsers do. So we cannot shorten
  20769. // this by omitting <tbody> or other required elements.
  20770. thead: [ 1, "<table>", "</table>" ],
  20771. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  20772. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  20773. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  20774. _default: [ 0, "", "" ]
  20775. };
  20776. // Support: IE <=9 only
  20777. wrapMap.optgroup = wrapMap.option;
  20778. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  20779. wrapMap.th = wrapMap.td;
  20780. function getAll( context, tag ) {
  20781. // Support: IE <=9 - 11 only
  20782. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  20783. var ret;
  20784. if ( typeof context.getElementsByTagName !== "undefined" ) {
  20785. ret = context.getElementsByTagName( tag || "*" );
  20786. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  20787. ret = context.querySelectorAll( tag || "*" );
  20788. } else {
  20789. ret = [];
  20790. }
  20791. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  20792. return jQuery.merge( [ context ], ret );
  20793. }
  20794. return ret;
  20795. }
  20796. // Mark scripts as having already been evaluated
  20797. function setGlobalEval( elems, refElements ) {
  20798. var i = 0,
  20799. l = elems.length;
  20800. for ( ; i < l; i++ ) {
  20801. dataPriv.set(
  20802. elems[ i ],
  20803. "globalEval",
  20804. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  20805. );
  20806. }
  20807. }
  20808. var rhtml = /<|&#?\w+;/;
  20809. function buildFragment( elems, context, scripts, selection, ignored ) {
  20810. var elem, tmp, tag, wrap, contains, j,
  20811. fragment = context.createDocumentFragment(),
  20812. nodes = [],
  20813. i = 0,
  20814. l = elems.length;
  20815. for ( ; i < l; i++ ) {
  20816. elem = elems[ i ];
  20817. if ( elem || elem === 0 ) {
  20818. // Add nodes directly
  20819. if ( jQuery.type( elem ) === "object" ) {
  20820. // Support: Android <=4.0 only, PhantomJS 1 only
  20821. // push.apply(_, arraylike) throws on ancient WebKit
  20822. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  20823. // Convert non-html into a text node
  20824. } else if ( !rhtml.test( elem ) ) {
  20825. nodes.push( context.createTextNode( elem ) );
  20826. // Convert html into DOM nodes
  20827. } else {
  20828. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  20829. // Deserialize a standard representation
  20830. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  20831. wrap = wrapMap[ tag ] || wrapMap._default;
  20832. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  20833. // Descend through wrappers to the right content
  20834. j = wrap[ 0 ];
  20835. while ( j-- ) {
  20836. tmp = tmp.lastChild;
  20837. }
  20838. // Support: Android <=4.0 only, PhantomJS 1 only
  20839. // push.apply(_, arraylike) throws on ancient WebKit
  20840. jQuery.merge( nodes, tmp.childNodes );
  20841. // Remember the top-level container
  20842. tmp = fragment.firstChild;
  20843. // Ensure the created nodes are orphaned (#12392)
  20844. tmp.textContent = "";
  20845. }
  20846. }
  20847. }
  20848. // Remove wrapper from fragment
  20849. fragment.textContent = "";
  20850. i = 0;
  20851. while ( ( elem = nodes[ i++ ] ) ) {
  20852. // Skip elements already in the context collection (trac-4087)
  20853. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  20854. if ( ignored ) {
  20855. ignored.push( elem );
  20856. }
  20857. continue;
  20858. }
  20859. contains = jQuery.contains( elem.ownerDocument, elem );
  20860. // Append to fragment
  20861. tmp = getAll( fragment.appendChild( elem ), "script" );
  20862. // Preserve script evaluation history
  20863. if ( contains ) {
  20864. setGlobalEval( tmp );
  20865. }
  20866. // Capture executables
  20867. if ( scripts ) {
  20868. j = 0;
  20869. while ( ( elem = tmp[ j++ ] ) ) {
  20870. if ( rscriptType.test( elem.type || "" ) ) {
  20871. scripts.push( elem );
  20872. }
  20873. }
  20874. }
  20875. }
  20876. return fragment;
  20877. }
  20878. ( function() {
  20879. var fragment = document.createDocumentFragment(),
  20880. div = fragment.appendChild( document.createElement( "div" ) ),
  20881. input = document.createElement( "input" );
  20882. // Support: Android 4.0 - 4.3 only
  20883. // Check state lost if the name is set (#11217)
  20884. // Support: Windows Web Apps (WWA)
  20885. // `name` and `type` must use .setAttribute for WWA (#14901)
  20886. input.setAttribute( "type", "radio" );
  20887. input.setAttribute( "checked", "checked" );
  20888. input.setAttribute( "name", "t" );
  20889. div.appendChild( input );
  20890. // Support: Android <=4.1 only
  20891. // Older WebKit doesn't clone checked state correctly in fragments
  20892. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  20893. // Support: IE <=11 only
  20894. // Make sure textarea (and checkbox) defaultValue is properly cloned
  20895. div.innerHTML = "<textarea>x</textarea>";
  20896. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  20897. } )();
  20898. var documentElement = document.documentElement;
  20899. var
  20900. rkeyEvent = /^key/,
  20901. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  20902. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  20903. function returnTrue() {
  20904. return true;
  20905. }
  20906. function returnFalse() {
  20907. return false;
  20908. }
  20909. // Support: IE <=9 only
  20910. // See #13393 for more info
  20911. function safeActiveElement() {
  20912. try {
  20913. return document.activeElement;
  20914. } catch ( err ) { }
  20915. }
  20916. function on( elem, types, selector, data, fn, one ) {
  20917. var origFn, type;
  20918. // Types can be a map of types/handlers
  20919. if ( typeof types === "object" ) {
  20920. // ( types-Object, selector, data )
  20921. if ( typeof selector !== "string" ) {
  20922. // ( types-Object, data )
  20923. data = data || selector;
  20924. selector = undefined;
  20925. }
  20926. for ( type in types ) {
  20927. on( elem, type, selector, data, types[ type ], one );
  20928. }
  20929. return elem;
  20930. }
  20931. if ( data == null && fn == null ) {
  20932. // ( types, fn )
  20933. fn = selector;
  20934. data = selector = undefined;
  20935. } else if ( fn == null ) {
  20936. if ( typeof selector === "string" ) {
  20937. // ( types, selector, fn )
  20938. fn = data;
  20939. data = undefined;
  20940. } else {
  20941. // ( types, data, fn )
  20942. fn = data;
  20943. data = selector;
  20944. selector = undefined;
  20945. }
  20946. }
  20947. if ( fn === false ) {
  20948. fn = returnFalse;
  20949. } else if ( !fn ) {
  20950. return elem;
  20951. }
  20952. if ( one === 1 ) {
  20953. origFn = fn;
  20954. fn = function( event ) {
  20955. // Can use an empty set, since event contains the info
  20956. jQuery().off( event );
  20957. return origFn.apply( this, arguments );
  20958. };
  20959. // Use same guid so caller can remove using origFn
  20960. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  20961. }
  20962. return elem.each( function() {
  20963. jQuery.event.add( this, types, fn, data, selector );
  20964. } );
  20965. }
  20966. /*
  20967. * Helper functions for managing events -- not part of the public interface.
  20968. * Props to Dean Edwards' addEvent library for many of the ideas.
  20969. */
  20970. jQuery.event = {
  20971. global: {},
  20972. add: function( elem, types, handler, data, selector ) {
  20973. var handleObjIn, eventHandle, tmp,
  20974. events, t, handleObj,
  20975. special, handlers, type, namespaces, origType,
  20976. elemData = dataPriv.get( elem );
  20977. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  20978. if ( !elemData ) {
  20979. return;
  20980. }
  20981. // Caller can pass in an object of custom data in lieu of the handler
  20982. if ( handler.handler ) {
  20983. handleObjIn = handler;
  20984. handler = handleObjIn.handler;
  20985. selector = handleObjIn.selector;
  20986. }
  20987. // Ensure that invalid selectors throw exceptions at attach time
  20988. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  20989. if ( selector ) {
  20990. jQuery.find.matchesSelector( documentElement, selector );
  20991. }
  20992. // Make sure that the handler has a unique ID, used to find/remove it later
  20993. if ( !handler.guid ) {
  20994. handler.guid = jQuery.guid++;
  20995. }
  20996. // Init the element's event structure and main handler, if this is the first
  20997. if ( !( events = elemData.events ) ) {
  20998. events = elemData.events = {};
  20999. }
  21000. if ( !( eventHandle = elemData.handle ) ) {
  21001. eventHandle = elemData.handle = function( e ) {
  21002. // Discard the second event of a jQuery.event.trigger() and
  21003. // when an event is called after a page has unloaded
  21004. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  21005. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  21006. };
  21007. }
  21008. // Handle multiple events separated by a space
  21009. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  21010. t = types.length;
  21011. while ( t-- ) {
  21012. tmp = rtypenamespace.exec( types[ t ] ) || [];
  21013. type = origType = tmp[ 1 ];
  21014. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  21015. // There *must* be a type, no attaching namespace-only handlers
  21016. if ( !type ) {
  21017. continue;
  21018. }
  21019. // If event changes its type, use the special event handlers for the changed type
  21020. special = jQuery.event.special[ type ] || {};
  21021. // If selector defined, determine special event api type, otherwise given type
  21022. type = ( selector ? special.delegateType : special.bindType ) || type;
  21023. // Update special based on newly reset type
  21024. special = jQuery.event.special[ type ] || {};
  21025. // handleObj is passed to all event handlers
  21026. handleObj = jQuery.extend( {
  21027. type: type,
  21028. origType: origType,
  21029. data: data,
  21030. handler: handler,
  21031. guid: handler.guid,
  21032. selector: selector,
  21033. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  21034. namespace: namespaces.join( "." )
  21035. }, handleObjIn );
  21036. // Init the event handler queue if we're the first
  21037. if ( !( handlers = events[ type ] ) ) {
  21038. handlers = events[ type ] = [];
  21039. handlers.delegateCount = 0;
  21040. // Only use addEventListener if the special events handler returns false
  21041. if ( !special.setup ||
  21042. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  21043. if ( elem.addEventListener ) {
  21044. elem.addEventListener( type, eventHandle );
  21045. }
  21046. }
  21047. }
  21048. if ( special.add ) {
  21049. special.add.call( elem, handleObj );
  21050. if ( !handleObj.handler.guid ) {
  21051. handleObj.handler.guid = handler.guid;
  21052. }
  21053. }
  21054. // Add to the element's handler list, delegates in front
  21055. if ( selector ) {
  21056. handlers.splice( handlers.delegateCount++, 0, handleObj );
  21057. } else {
  21058. handlers.push( handleObj );
  21059. }
  21060. // Keep track of which events have ever been used, for event optimization
  21061. jQuery.event.global[ type ] = true;
  21062. }
  21063. },
  21064. // Detach an event or set of events from an element
  21065. remove: function( elem, types, handler, selector, mappedTypes ) {
  21066. var j, origCount, tmp,
  21067. events, t, handleObj,
  21068. special, handlers, type, namespaces, origType,
  21069. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  21070. if ( !elemData || !( events = elemData.events ) ) {
  21071. return;
  21072. }
  21073. // Once for each type.namespace in types; type may be omitted
  21074. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  21075. t = types.length;
  21076. while ( t-- ) {
  21077. tmp = rtypenamespace.exec( types[ t ] ) || [];
  21078. type = origType = tmp[ 1 ];
  21079. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  21080. // Unbind all events (on this namespace, if provided) for the element
  21081. if ( !type ) {
  21082. for ( type in events ) {
  21083. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  21084. }
  21085. continue;
  21086. }
  21087. special = jQuery.event.special[ type ] || {};
  21088. type = ( selector ? special.delegateType : special.bindType ) || type;
  21089. handlers = events[ type ] || [];
  21090. tmp = tmp[ 2 ] &&
  21091. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  21092. // Remove matching events
  21093. origCount = j = handlers.length;
  21094. while ( j-- ) {
  21095. handleObj = handlers[ j ];
  21096. if ( ( mappedTypes || origType === handleObj.origType ) &&
  21097. ( !handler || handler.guid === handleObj.guid ) &&
  21098. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  21099. ( !selector || selector === handleObj.selector ||
  21100. selector === "**" && handleObj.selector ) ) {
  21101. handlers.splice( j, 1 );
  21102. if ( handleObj.selector ) {
  21103. handlers.delegateCount--;
  21104. }
  21105. if ( special.remove ) {
  21106. special.remove.call( elem, handleObj );
  21107. }
  21108. }
  21109. }
  21110. // Remove generic event handler if we removed something and no more handlers exist
  21111. // (avoids potential for endless recursion during removal of special event handlers)
  21112. if ( origCount && !handlers.length ) {
  21113. if ( !special.teardown ||
  21114. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  21115. jQuery.removeEvent( elem, type, elemData.handle );
  21116. }
  21117. delete events[ type ];
  21118. }
  21119. }
  21120. // Remove data and the expando if it's no longer used
  21121. if ( jQuery.isEmptyObject( events ) ) {
  21122. dataPriv.remove( elem, "handle events" );
  21123. }
  21124. },
  21125. dispatch: function( nativeEvent ) {
  21126. // Make a writable jQuery.Event from the native event object
  21127. var event = jQuery.event.fix( nativeEvent );
  21128. var i, j, ret, matched, handleObj, handlerQueue,
  21129. args = new Array( arguments.length ),
  21130. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  21131. special = jQuery.event.special[ event.type ] || {};
  21132. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  21133. args[ 0 ] = event;
  21134. for ( i = 1; i < arguments.length; i++ ) {
  21135. args[ i ] = arguments[ i ];
  21136. }
  21137. event.delegateTarget = this;
  21138. // Call the preDispatch hook for the mapped type, and let it bail if desired
  21139. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  21140. return;
  21141. }
  21142. // Determine handlers
  21143. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  21144. // Run delegates first; they may want to stop propagation beneath us
  21145. i = 0;
  21146. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  21147. event.currentTarget = matched.elem;
  21148. j = 0;
  21149. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  21150. !event.isImmediatePropagationStopped() ) {
  21151. // Triggered event must either 1) have no namespace, or 2) have namespace(s)
  21152. // a subset or equal to those in the bound event (both can have no namespace).
  21153. if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
  21154. event.handleObj = handleObj;
  21155. event.data = handleObj.data;
  21156. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  21157. handleObj.handler ).apply( matched.elem, args );
  21158. if ( ret !== undefined ) {
  21159. if ( ( event.result = ret ) === false ) {
  21160. event.preventDefault();
  21161. event.stopPropagation();
  21162. }
  21163. }
  21164. }
  21165. }
  21166. }
  21167. // Call the postDispatch hook for the mapped type
  21168. if ( special.postDispatch ) {
  21169. special.postDispatch.call( this, event );
  21170. }
  21171. return event.result;
  21172. },
  21173. handlers: function( event, handlers ) {
  21174. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  21175. handlerQueue = [],
  21176. delegateCount = handlers.delegateCount,
  21177. cur = event.target;
  21178. // Find delegate handlers
  21179. if ( delegateCount &&
  21180. // Support: IE <=9
  21181. // Black-hole SVG <use> instance trees (trac-13180)
  21182. cur.nodeType &&
  21183. // Support: Firefox <=42
  21184. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  21185. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  21186. // Support: IE 11 only
  21187. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  21188. !( event.type === "click" && event.button >= 1 ) ) {
  21189. for ( ; cur !== this; cur = cur.parentNode || this ) {
  21190. // Don't check non-elements (#13208)
  21191. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  21192. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  21193. matchedHandlers = [];
  21194. matchedSelectors = {};
  21195. for ( i = 0; i < delegateCount; i++ ) {
  21196. handleObj = handlers[ i ];
  21197. // Don't conflict with Object.prototype properties (#13203)
  21198. sel = handleObj.selector + " ";
  21199. if ( matchedSelectors[ sel ] === undefined ) {
  21200. matchedSelectors[ sel ] = handleObj.needsContext ?
  21201. jQuery( sel, this ).index( cur ) > -1 :
  21202. jQuery.find( sel, this, null, [ cur ] ).length;
  21203. }
  21204. if ( matchedSelectors[ sel ] ) {
  21205. matchedHandlers.push( handleObj );
  21206. }
  21207. }
  21208. if ( matchedHandlers.length ) {
  21209. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  21210. }
  21211. }
  21212. }
  21213. }
  21214. // Add the remaining (directly-bound) handlers
  21215. cur = this;
  21216. if ( delegateCount < handlers.length ) {
  21217. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  21218. }
  21219. return handlerQueue;
  21220. },
  21221. addProp: function( name, hook ) {
  21222. Object.defineProperty( jQuery.Event.prototype, name, {
  21223. enumerable: true,
  21224. configurable: true,
  21225. get: jQuery.isFunction( hook ) ?
  21226. function() {
  21227. if ( this.originalEvent ) {
  21228. return hook( this.originalEvent );
  21229. }
  21230. } :
  21231. function() {
  21232. if ( this.originalEvent ) {
  21233. return this.originalEvent[ name ];
  21234. }
  21235. },
  21236. set: function( value ) {
  21237. Object.defineProperty( this, name, {
  21238. enumerable: true,
  21239. configurable: true,
  21240. writable: true,
  21241. value: value
  21242. } );
  21243. }
  21244. } );
  21245. },
  21246. fix: function( originalEvent ) {
  21247. return originalEvent[ jQuery.expando ] ?
  21248. originalEvent :
  21249. new jQuery.Event( originalEvent );
  21250. },
  21251. special: {
  21252. load: {
  21253. // Prevent triggered image.load events from bubbling to window.load
  21254. noBubble: true
  21255. },
  21256. focus: {
  21257. // Fire native event if possible so blur/focus sequence is correct
  21258. trigger: function() {
  21259. if ( this !== safeActiveElement() && this.focus ) {
  21260. this.focus();
  21261. return false;
  21262. }
  21263. },
  21264. delegateType: "focusin"
  21265. },
  21266. blur: {
  21267. trigger: function() {
  21268. if ( this === safeActiveElement() && this.blur ) {
  21269. this.blur();
  21270. return false;
  21271. }
  21272. },
  21273. delegateType: "focusout"
  21274. },
  21275. click: {
  21276. // For checkbox, fire native event so checked state will be right
  21277. trigger: function() {
  21278. if ( this.type === "checkbox" && this.click && nodeName( this, "input" ) ) {
  21279. this.click();
  21280. return false;
  21281. }
  21282. },
  21283. // For cross-browser consistency, don't fire native .click() on links
  21284. _default: function( event ) {
  21285. return nodeName( event.target, "a" );
  21286. }
  21287. },
  21288. beforeunload: {
  21289. postDispatch: function( event ) {
  21290. // Support: Firefox 20+
  21291. // Firefox doesn't alert if the returnValue field is not set.
  21292. if ( event.result !== undefined && event.originalEvent ) {
  21293. event.originalEvent.returnValue = event.result;
  21294. }
  21295. }
  21296. }
  21297. }
  21298. };
  21299. jQuery.removeEvent = function( elem, type, handle ) {
  21300. // This "if" is needed for plain objects
  21301. if ( elem.removeEventListener ) {
  21302. elem.removeEventListener( type, handle );
  21303. }
  21304. };
  21305. jQuery.Event = function( src, props ) {
  21306. // Allow instantiation without the 'new' keyword
  21307. if ( !( this instanceof jQuery.Event ) ) {
  21308. return new jQuery.Event( src, props );
  21309. }
  21310. // Event object
  21311. if ( src && src.type ) {
  21312. this.originalEvent = src;
  21313. this.type = src.type;
  21314. // Events bubbling up the document may have been marked as prevented
  21315. // by a handler lower down the tree; reflect the correct value.
  21316. this.isDefaultPrevented = src.defaultPrevented ||
  21317. src.defaultPrevented === undefined &&
  21318. // Support: Android <=2.3 only
  21319. src.returnValue === false ?
  21320. returnTrue :
  21321. returnFalse;
  21322. // Create target properties
  21323. // Support: Safari <=6 - 7 only
  21324. // Target should not be a text node (#504, #13143)
  21325. this.target = ( src.target && src.target.nodeType === 3 ) ?
  21326. src.target.parentNode :
  21327. src.target;
  21328. this.currentTarget = src.currentTarget;
  21329. this.relatedTarget = src.relatedTarget;
  21330. // Event type
  21331. } else {
  21332. this.type = src;
  21333. }
  21334. // Put explicitly provided properties onto the event object
  21335. if ( props ) {
  21336. jQuery.extend( this, props );
  21337. }
  21338. // Create a timestamp if incoming event doesn't have one
  21339. this.timeStamp = src && src.timeStamp || jQuery.now();
  21340. // Mark it as fixed
  21341. this[ jQuery.expando ] = true;
  21342. };
  21343. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  21344. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  21345. jQuery.Event.prototype = {
  21346. constructor: jQuery.Event,
  21347. isDefaultPrevented: returnFalse,
  21348. isPropagationStopped: returnFalse,
  21349. isImmediatePropagationStopped: returnFalse,
  21350. isSimulated: false,
  21351. preventDefault: function() {
  21352. var e = this.originalEvent;
  21353. this.isDefaultPrevented = returnTrue;
  21354. if ( e && !this.isSimulated ) {
  21355. e.preventDefault();
  21356. }
  21357. },
  21358. stopPropagation: function() {
  21359. var e = this.originalEvent;
  21360. this.isPropagationStopped = returnTrue;
  21361. if ( e && !this.isSimulated ) {
  21362. e.stopPropagation();
  21363. }
  21364. },
  21365. stopImmediatePropagation: function() {
  21366. var e = this.originalEvent;
  21367. this.isImmediatePropagationStopped = returnTrue;
  21368. if ( e && !this.isSimulated ) {
  21369. e.stopImmediatePropagation();
  21370. }
  21371. this.stopPropagation();
  21372. }
  21373. };
  21374. // Includes all common event props including KeyEvent and MouseEvent specific props
  21375. jQuery.each( {
  21376. altKey: true,
  21377. bubbles: true,
  21378. cancelable: true,
  21379. changedTouches: true,
  21380. ctrlKey: true,
  21381. detail: true,
  21382. eventPhase: true,
  21383. metaKey: true,
  21384. pageX: true,
  21385. pageY: true,
  21386. shiftKey: true,
  21387. view: true,
  21388. "char": true,
  21389. charCode: true,
  21390. key: true,
  21391. keyCode: true,
  21392. button: true,
  21393. buttons: true,
  21394. clientX: true,
  21395. clientY: true,
  21396. offsetX: true,
  21397. offsetY: true,
  21398. pointerId: true,
  21399. pointerType: true,
  21400. screenX: true,
  21401. screenY: true,
  21402. targetTouches: true,
  21403. toElement: true,
  21404. touches: true,
  21405. which: function( event ) {
  21406. var button = event.button;
  21407. // Add which for key events
  21408. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  21409. return event.charCode != null ? event.charCode : event.keyCode;
  21410. }
  21411. // Add which for click: 1 === left; 2 === middle; 3 === right
  21412. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  21413. if ( button & 1 ) {
  21414. return 1;
  21415. }
  21416. if ( button & 2 ) {
  21417. return 3;
  21418. }
  21419. if ( button & 4 ) {
  21420. return 2;
  21421. }
  21422. return 0;
  21423. }
  21424. return event.which;
  21425. }
  21426. }, jQuery.event.addProp );
  21427. // Create mouseenter/leave events using mouseover/out and event-time checks
  21428. // so that event delegation works in jQuery.
  21429. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  21430. //
  21431. // Support: Safari 7 only
  21432. // Safari sends mouseenter too often; see:
  21433. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  21434. // for the description of the bug (it existed in older Chrome versions as well).
  21435. jQuery.each( {
  21436. mouseenter: "mouseover",
  21437. mouseleave: "mouseout",
  21438. pointerenter: "pointerover",
  21439. pointerleave: "pointerout"
  21440. }, function( orig, fix ) {
  21441. jQuery.event.special[ orig ] = {
  21442. delegateType: fix,
  21443. bindType: fix,
  21444. handle: function( event ) {
  21445. var ret,
  21446. target = this,
  21447. related = event.relatedTarget,
  21448. handleObj = event.handleObj;
  21449. // For mouseenter/leave call the handler if related is outside the target.
  21450. // NB: No relatedTarget if the mouse left/entered the browser window
  21451. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  21452. event.type = handleObj.origType;
  21453. ret = handleObj.handler.apply( this, arguments );
  21454. event.type = fix;
  21455. }
  21456. return ret;
  21457. }
  21458. };
  21459. } );
  21460. jQuery.fn.extend( {
  21461. on: function( types, selector, data, fn ) {
  21462. return on( this, types, selector, data, fn );
  21463. },
  21464. one: function( types, selector, data, fn ) {
  21465. return on( this, types, selector, data, fn, 1 );
  21466. },
  21467. off: function( types, selector, fn ) {
  21468. var handleObj, type;
  21469. if ( types && types.preventDefault && types.handleObj ) {
  21470. // ( event ) dispatched jQuery.Event
  21471. handleObj = types.handleObj;
  21472. jQuery( types.delegateTarget ).off(
  21473. handleObj.namespace ?
  21474. handleObj.origType + "." + handleObj.namespace :
  21475. handleObj.origType,
  21476. handleObj.selector,
  21477. handleObj.handler
  21478. );
  21479. return this;
  21480. }
  21481. if ( typeof types === "object" ) {
  21482. // ( types-object [, selector] )
  21483. for ( type in types ) {
  21484. this.off( type, selector, types[ type ] );
  21485. }
  21486. return this;
  21487. }
  21488. if ( selector === false || typeof selector === "function" ) {
  21489. // ( types [, fn] )
  21490. fn = selector;
  21491. selector = undefined;
  21492. }
  21493. if ( fn === false ) {
  21494. fn = returnFalse;
  21495. }
  21496. return this.each( function() {
  21497. jQuery.event.remove( this, types, fn, selector );
  21498. } );
  21499. }
  21500. } );
  21501. var
  21502. /* eslint-disable max-len */
  21503. // See https://github.com/eslint/eslint/issues/3229
  21504. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  21505. /* eslint-enable */
  21506. // Support: IE <=10 - 11, Edge 12 - 13
  21507. // In IE/Edge using regex groups here causes severe slowdowns.
  21508. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  21509. rnoInnerhtml = /<script|<style|<link/i,
  21510. // checked="checked" or checked
  21511. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  21512. rscriptTypeMasked = /^true\/(.*)/,
  21513. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  21514. // Prefer a tbody over its parent table for containing new rows
  21515. function manipulationTarget( elem, content ) {
  21516. if ( nodeName( elem, "table" ) &&
  21517. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  21518. return jQuery( ">tbody", elem )[ 0 ] || elem;
  21519. }
  21520. return elem;
  21521. }
  21522. // Replace/restore the type attribute of script elements for safe DOM manipulation
  21523. function disableScript( elem ) {
  21524. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  21525. return elem;
  21526. }
  21527. function restoreScript( elem ) {
  21528. var match = rscriptTypeMasked.exec( elem.type );
  21529. if ( match ) {
  21530. elem.type = match[ 1 ];
  21531. } else {
  21532. elem.removeAttribute( "type" );
  21533. }
  21534. return elem;
  21535. }
  21536. function cloneCopyEvent( src, dest ) {
  21537. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  21538. if ( dest.nodeType !== 1 ) {
  21539. return;
  21540. }
  21541. // 1. Copy private data: events, handlers, etc.
  21542. if ( dataPriv.hasData( src ) ) {
  21543. pdataOld = dataPriv.access( src );
  21544. pdataCur = dataPriv.set( dest, pdataOld );
  21545. events = pdataOld.events;
  21546. if ( events ) {
  21547. delete pdataCur.handle;
  21548. pdataCur.events = {};
  21549. for ( type in events ) {
  21550. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  21551. jQuery.event.add( dest, type, events[ type ][ i ] );
  21552. }
  21553. }
  21554. }
  21555. }
  21556. // 2. Copy user data
  21557. if ( dataUser.hasData( src ) ) {
  21558. udataOld = dataUser.access( src );
  21559. udataCur = jQuery.extend( {}, udataOld );
  21560. dataUser.set( dest, udataCur );
  21561. }
  21562. }
  21563. // Fix IE bugs, see support tests
  21564. function fixInput( src, dest ) {
  21565. var nodeName = dest.nodeName.toLowerCase();
  21566. // Fails to persist the checked state of a cloned checkbox or radio button.
  21567. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  21568. dest.checked = src.checked;
  21569. // Fails to return the selected option to the default selected state when cloning options
  21570. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  21571. dest.defaultValue = src.defaultValue;
  21572. }
  21573. }
  21574. function domManip( collection, args, callback, ignored ) {
  21575. // Flatten any nested arrays
  21576. args = concat.apply( [], args );
  21577. var fragment, first, scripts, hasScripts, node, doc,
  21578. i = 0,
  21579. l = collection.length,
  21580. iNoClone = l - 1,
  21581. value = args[ 0 ],
  21582. isFunction = jQuery.isFunction( value );
  21583. // We can't cloneNode fragments that contain checked, in WebKit
  21584. if ( isFunction ||
  21585. ( l > 1 && typeof value === "string" &&
  21586. !support.checkClone && rchecked.test( value ) ) ) {
  21587. return collection.each( function( index ) {
  21588. var self = collection.eq( index );
  21589. if ( isFunction ) {
  21590. args[ 0 ] = value.call( this, index, self.html() );
  21591. }
  21592. domManip( self, args, callback, ignored );
  21593. } );
  21594. }
  21595. if ( l ) {
  21596. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  21597. first = fragment.firstChild;
  21598. if ( fragment.childNodes.length === 1 ) {
  21599. fragment = first;
  21600. }
  21601. // Require either new content or an interest in ignored elements to invoke the callback
  21602. if ( first || ignored ) {
  21603. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  21604. hasScripts = scripts.length;
  21605. // Use the original fragment for the last item
  21606. // instead of the first because it can end up
  21607. // being emptied incorrectly in certain situations (#8070).
  21608. for ( ; i < l; i++ ) {
  21609. node = fragment;
  21610. if ( i !== iNoClone ) {
  21611. node = jQuery.clone( node, true, true );
  21612. // Keep references to cloned scripts for later restoration
  21613. if ( hasScripts ) {
  21614. // Support: Android <=4.0 only, PhantomJS 1 only
  21615. // push.apply(_, arraylike) throws on ancient WebKit
  21616. jQuery.merge( scripts, getAll( node, "script" ) );
  21617. }
  21618. }
  21619. callback.call( collection[ i ], node, i );
  21620. }
  21621. if ( hasScripts ) {
  21622. doc = scripts[ scripts.length - 1 ].ownerDocument;
  21623. // Reenable scripts
  21624. jQuery.map( scripts, restoreScript );
  21625. // Evaluate executable scripts on first document insertion
  21626. for ( i = 0; i < hasScripts; i++ ) {
  21627. node = scripts[ i ];
  21628. if ( rscriptType.test( node.type || "" ) &&
  21629. !dataPriv.access( node, "globalEval" ) &&
  21630. jQuery.contains( doc, node ) ) {
  21631. if ( node.src ) {
  21632. // Optional AJAX dependency, but won't run scripts if not present
  21633. if ( jQuery._evalUrl ) {
  21634. jQuery._evalUrl( node.src );
  21635. }
  21636. } else {
  21637. DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
  21638. }
  21639. }
  21640. }
  21641. }
  21642. }
  21643. }
  21644. return collection;
  21645. }
  21646. function remove( elem, selector, keepData ) {
  21647. var node,
  21648. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  21649. i = 0;
  21650. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  21651. if ( !keepData && node.nodeType === 1 ) {
  21652. jQuery.cleanData( getAll( node ) );
  21653. }
  21654. if ( node.parentNode ) {
  21655. if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
  21656. setGlobalEval( getAll( node, "script" ) );
  21657. }
  21658. node.parentNode.removeChild( node );
  21659. }
  21660. }
  21661. return elem;
  21662. }
  21663. jQuery.extend( {
  21664. htmlPrefilter: function( html ) {
  21665. return html.replace( rxhtmlTag, "<$1></$2>" );
  21666. },
  21667. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  21668. var i, l, srcElements, destElements,
  21669. clone = elem.cloneNode( true ),
  21670. inPage = jQuery.contains( elem.ownerDocument, elem );
  21671. // Fix IE cloning issues
  21672. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  21673. !jQuery.isXMLDoc( elem ) ) {
  21674. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  21675. destElements = getAll( clone );
  21676. srcElements = getAll( elem );
  21677. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  21678. fixInput( srcElements[ i ], destElements[ i ] );
  21679. }
  21680. }
  21681. // Copy the events from the original to the clone
  21682. if ( dataAndEvents ) {
  21683. if ( deepDataAndEvents ) {
  21684. srcElements = srcElements || getAll( elem );
  21685. destElements = destElements || getAll( clone );
  21686. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  21687. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  21688. }
  21689. } else {
  21690. cloneCopyEvent( elem, clone );
  21691. }
  21692. }
  21693. // Preserve script evaluation history
  21694. destElements = getAll( clone, "script" );
  21695. if ( destElements.length > 0 ) {
  21696. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  21697. }
  21698. // Return the cloned set
  21699. return clone;
  21700. },
  21701. cleanData: function( elems ) {
  21702. var data, elem, type,
  21703. special = jQuery.event.special,
  21704. i = 0;
  21705. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  21706. if ( acceptData( elem ) ) {
  21707. if ( ( data = elem[ dataPriv.expando ] ) ) {
  21708. if ( data.events ) {
  21709. for ( type in data.events ) {
  21710. if ( special[ type ] ) {
  21711. jQuery.event.remove( elem, type );
  21712. // This is a shortcut to avoid jQuery.event.remove's overhead
  21713. } else {
  21714. jQuery.removeEvent( elem, type, data.handle );
  21715. }
  21716. }
  21717. }
  21718. // Support: Chrome <=35 - 45+
  21719. // Assign undefined instead of using delete, see Data#remove
  21720. elem[ dataPriv.expando ] = undefined;
  21721. }
  21722. if ( elem[ dataUser.expando ] ) {
  21723. // Support: Chrome <=35 - 45+
  21724. // Assign undefined instead of using delete, see Data#remove
  21725. elem[ dataUser.expando ] = undefined;
  21726. }
  21727. }
  21728. }
  21729. }
  21730. } );
  21731. jQuery.fn.extend( {
  21732. detach: function( selector ) {
  21733. return remove( this, selector, true );
  21734. },
  21735. remove: function( selector ) {
  21736. return remove( this, selector );
  21737. },
  21738. text: function( value ) {
  21739. return access( this, function( value ) {
  21740. return value === undefined ?
  21741. jQuery.text( this ) :
  21742. this.empty().each( function() {
  21743. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  21744. this.textContent = value;
  21745. }
  21746. } );
  21747. }, null, value, arguments.length );
  21748. },
  21749. append: 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.appendChild( elem );
  21754. }
  21755. } );
  21756. },
  21757. prepend: function() {
  21758. return domManip( this, arguments, function( elem ) {
  21759. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  21760. var target = manipulationTarget( this, elem );
  21761. target.insertBefore( elem, target.firstChild );
  21762. }
  21763. } );
  21764. },
  21765. before: function() {
  21766. return domManip( this, arguments, function( elem ) {
  21767. if ( this.parentNode ) {
  21768. this.parentNode.insertBefore( elem, this );
  21769. }
  21770. } );
  21771. },
  21772. after: function() {
  21773. return domManip( this, arguments, function( elem ) {
  21774. if ( this.parentNode ) {
  21775. this.parentNode.insertBefore( elem, this.nextSibling );
  21776. }
  21777. } );
  21778. },
  21779. empty: function() {
  21780. var elem,
  21781. i = 0;
  21782. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  21783. if ( elem.nodeType === 1 ) {
  21784. // Prevent memory leaks
  21785. jQuery.cleanData( getAll( elem, false ) );
  21786. // Remove any remaining nodes
  21787. elem.textContent = "";
  21788. }
  21789. }
  21790. return this;
  21791. },
  21792. clone: function( dataAndEvents, deepDataAndEvents ) {
  21793. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  21794. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  21795. return this.map( function() {
  21796. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  21797. } );
  21798. },
  21799. html: function( value ) {
  21800. return access( this, function( value ) {
  21801. var elem = this[ 0 ] || {},
  21802. i = 0,
  21803. l = this.length;
  21804. if ( value === undefined && elem.nodeType === 1 ) {
  21805. return elem.innerHTML;
  21806. }
  21807. // See if we can take a shortcut and just use innerHTML
  21808. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  21809. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  21810. value = jQuery.htmlPrefilter( value );
  21811. try {
  21812. for ( ; i < l; i++ ) {
  21813. elem = this[ i ] || {};
  21814. // Remove element nodes and prevent memory leaks
  21815. if ( elem.nodeType === 1 ) {
  21816. jQuery.cleanData( getAll( elem, false ) );
  21817. elem.innerHTML = value;
  21818. }
  21819. }
  21820. elem = 0;
  21821. // If using innerHTML throws an exception, use the fallback method
  21822. } catch ( e ) {}
  21823. }
  21824. if ( elem ) {
  21825. this.empty().append( value );
  21826. }
  21827. }, null, value, arguments.length );
  21828. },
  21829. replaceWith: function() {
  21830. var ignored = [];
  21831. // Make the changes, replacing each non-ignored context element with the new content
  21832. return domManip( this, arguments, function( elem ) {
  21833. var parent = this.parentNode;
  21834. if ( jQuery.inArray( this, ignored ) < 0 ) {
  21835. jQuery.cleanData( getAll( this ) );
  21836. if ( parent ) {
  21837. parent.replaceChild( elem, this );
  21838. }
  21839. }
  21840. // Force callback invocation
  21841. }, ignored );
  21842. }
  21843. } );
  21844. jQuery.each( {
  21845. appendTo: "append",
  21846. prependTo: "prepend",
  21847. insertBefore: "before",
  21848. insertAfter: "after",
  21849. replaceAll: "replaceWith"
  21850. }, function( name, original ) {
  21851. jQuery.fn[ name ] = function( selector ) {
  21852. var elems,
  21853. ret = [],
  21854. insert = jQuery( selector ),
  21855. last = insert.length - 1,
  21856. i = 0;
  21857. for ( ; i <= last; i++ ) {
  21858. elems = i === last ? this : this.clone( true );
  21859. jQuery( insert[ i ] )[ original ]( elems );
  21860. // Support: Android <=4.0 only, PhantomJS 1 only
  21861. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  21862. push.apply( ret, elems.get() );
  21863. }
  21864. return this.pushStack( ret );
  21865. };
  21866. } );
  21867. var rmargin = ( /^margin/ );
  21868. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  21869. var getStyles = function( elem ) {
  21870. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  21871. // IE throws on elements created in popups
  21872. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  21873. var view = elem.ownerDocument.defaultView;
  21874. if ( !view || !view.opener ) {
  21875. view = window;
  21876. }
  21877. return view.getComputedStyle( elem );
  21878. };
  21879. ( function() {
  21880. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  21881. // so they're executed at the same time to save the second computation.
  21882. function computeStyleTests() {
  21883. // This is a singleton, we need to execute it only once
  21884. if ( !div ) {
  21885. return;
  21886. }
  21887. div.style.cssText =
  21888. "box-sizing:border-box;" +
  21889. "position:relative;display:block;" +
  21890. "margin:auto;border:1px;padding:1px;" +
  21891. "top:1%;width:50%";
  21892. div.innerHTML = "";
  21893. documentElement.appendChild( container );
  21894. var divStyle = window.getComputedStyle( div );
  21895. pixelPositionVal = divStyle.top !== "1%";
  21896. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  21897. reliableMarginLeftVal = divStyle.marginLeft === "2px";
  21898. boxSizingReliableVal = divStyle.width === "4px";
  21899. // Support: Android 4.0 - 4.3 only
  21900. // Some styles come back with percentage values, even though they shouldn't
  21901. div.style.marginRight = "50%";
  21902. pixelMarginRightVal = divStyle.marginRight === "4px";
  21903. documentElement.removeChild( container );
  21904. // Nullify the div so it wouldn't be stored in the memory and
  21905. // it will also be a sign that checks already performed
  21906. div = null;
  21907. }
  21908. var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
  21909. container = document.createElement( "div" ),
  21910. div = document.createElement( "div" );
  21911. // Finish early in limited (non-browser) environments
  21912. if ( !div.style ) {
  21913. return;
  21914. }
  21915. // Support: IE <=9 - 11 only
  21916. // Style of cloned element affects source element cloned (#8908)
  21917. div.style.backgroundClip = "content-box";
  21918. div.cloneNode( true ).style.backgroundClip = "";
  21919. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  21920. container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
  21921. "padding:0;margin-top:1px;position:absolute";
  21922. container.appendChild( div );
  21923. jQuery.extend( support, {
  21924. pixelPosition: function() {
  21925. computeStyleTests();
  21926. return pixelPositionVal;
  21927. },
  21928. boxSizingReliable: function() {
  21929. computeStyleTests();
  21930. return boxSizingReliableVal;
  21931. },
  21932. pixelMarginRight: function() {
  21933. computeStyleTests();
  21934. return pixelMarginRightVal;
  21935. },
  21936. reliableMarginLeft: function() {
  21937. computeStyleTests();
  21938. return reliableMarginLeftVal;
  21939. }
  21940. } );
  21941. } )();
  21942. function curCSS( elem, name, computed ) {
  21943. var width, minWidth, maxWidth, ret,
  21944. // Support: Firefox 51+
  21945. // Retrieving style before computed somehow
  21946. // fixes an issue with getting wrong values
  21947. // on detached elements
  21948. style = elem.style;
  21949. computed = computed || getStyles( elem );
  21950. // getPropertyValue is needed for:
  21951. // .css('filter') (IE 9 only, #12537)
  21952. // .css('--customProperty) (#3144)
  21953. if ( computed ) {
  21954. ret = computed.getPropertyValue( name ) || computed[ name ];
  21955. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  21956. ret = jQuery.style( elem, name );
  21957. }
  21958. // A tribute to the "awesome hack by Dean Edwards"
  21959. // Android Browser returns percentage for some values,
  21960. // but width seems to be reliably pixels.
  21961. // This is against the CSSOM draft spec:
  21962. // https://drafts.csswg.org/cssom/#resolved-values
  21963. if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  21964. // Remember the original values
  21965. width = style.width;
  21966. minWidth = style.minWidth;
  21967. maxWidth = style.maxWidth;
  21968. // Put in the new values to get a computed value out
  21969. style.minWidth = style.maxWidth = style.width = ret;
  21970. ret = computed.width;
  21971. // Revert the changed values
  21972. style.width = width;
  21973. style.minWidth = minWidth;
  21974. style.maxWidth = maxWidth;
  21975. }
  21976. }
  21977. return ret !== undefined ?
  21978. // Support: IE <=9 - 11 only
  21979. // IE returns zIndex value as an integer.
  21980. ret + "" :
  21981. ret;
  21982. }
  21983. function addGetHookIf( conditionFn, hookFn ) {
  21984. // Define the hook, we'll check on the first run if it's really needed.
  21985. return {
  21986. get: function() {
  21987. if ( conditionFn() ) {
  21988. // Hook not needed (or it's not possible to use it due
  21989. // to missing dependency), remove it.
  21990. delete this.get;
  21991. return;
  21992. }
  21993. // Hook needed; redefine it so that the support test is not executed again.
  21994. return ( this.get = hookFn ).apply( this, arguments );
  21995. }
  21996. };
  21997. }
  21998. var
  21999. // Swappable if display is none or starts with table
  22000. // except "table", "table-cell", or "table-caption"
  22001. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  22002. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  22003. rcustomProp = /^--/,
  22004. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  22005. cssNormalTransform = {
  22006. letterSpacing: "0",
  22007. fontWeight: "400"
  22008. },
  22009. cssPrefixes = [ "Webkit", "Moz", "ms" ],
  22010. emptyStyle = document.createElement( "div" ).style;
  22011. // Return a css property mapped to a potentially vendor prefixed property
  22012. function vendorPropName( name ) {
  22013. // Shortcut for names that are not vendor prefixed
  22014. if ( name in emptyStyle ) {
  22015. return name;
  22016. }
  22017. // Check for vendor prefixed names
  22018. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  22019. i = cssPrefixes.length;
  22020. while ( i-- ) {
  22021. name = cssPrefixes[ i ] + capName;
  22022. if ( name in emptyStyle ) {
  22023. return name;
  22024. }
  22025. }
  22026. }
  22027. // Return a property mapped along what jQuery.cssProps suggests or to
  22028. // a vendor prefixed property.
  22029. function finalPropName( name ) {
  22030. var ret = jQuery.cssProps[ name ];
  22031. if ( !ret ) {
  22032. ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
  22033. }
  22034. return ret;
  22035. }
  22036. function setPositiveNumber( elem, value, subtract ) {
  22037. // Any relative (+/-) values have already been
  22038. // normalized at this point
  22039. var matches = rcssNum.exec( value );
  22040. return matches ?
  22041. // Guard against undefined "subtract", e.g., when used as in cssHooks
  22042. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  22043. value;
  22044. }
  22045. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  22046. var i,
  22047. val = 0;
  22048. // If we already have the right measurement, avoid augmentation
  22049. if ( extra === ( isBorderBox ? "border" : "content" ) ) {
  22050. i = 4;
  22051. // Otherwise initialize for horizontal or vertical properties
  22052. } else {
  22053. i = name === "width" ? 1 : 0;
  22054. }
  22055. for ( ; i < 4; i += 2 ) {
  22056. // Both box models exclude margin, so add it if we want it
  22057. if ( extra === "margin" ) {
  22058. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  22059. }
  22060. if ( isBorderBox ) {
  22061. // border-box includes padding, so remove it if we want content
  22062. if ( extra === "content" ) {
  22063. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  22064. }
  22065. // At this point, extra isn't border nor margin, so remove border
  22066. if ( extra !== "margin" ) {
  22067. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  22068. }
  22069. } else {
  22070. // At this point, extra isn't content, so add padding
  22071. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  22072. // At this point, extra isn't content nor padding, so add border
  22073. if ( extra !== "padding" ) {
  22074. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  22075. }
  22076. }
  22077. }
  22078. return val;
  22079. }
  22080. function getWidthOrHeight( elem, name, extra ) {
  22081. // Start with computed style
  22082. var valueIsBorderBox,
  22083. styles = getStyles( elem ),
  22084. val = curCSS( elem, name, styles ),
  22085. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  22086. // Computed unit is not pixels. Stop here and return.
  22087. if ( rnumnonpx.test( val ) ) {
  22088. return val;
  22089. }
  22090. // Check for style in case a browser which returns unreliable values
  22091. // for getComputedStyle silently falls back to the reliable elem.style
  22092. valueIsBorderBox = isBorderBox &&
  22093. ( support.boxSizingReliable() || val === elem.style[ name ] );
  22094. // Fall back to offsetWidth/Height when value is "auto"
  22095. // This happens for inline elements with no explicit setting (gh-3571)
  22096. if ( val === "auto" ) {
  22097. val = elem[ "offset" + name[ 0 ].toUpperCase() + name.slice( 1 ) ];
  22098. }
  22099. // Normalize "", auto, and prepare for extra
  22100. val = parseFloat( val ) || 0;
  22101. // Use the active box-sizing model to add/subtract irrelevant styles
  22102. return ( val +
  22103. augmentWidthOrHeight(
  22104. elem,
  22105. name,
  22106. extra || ( isBorderBox ? "border" : "content" ),
  22107. valueIsBorderBox,
  22108. styles
  22109. )
  22110. ) + "px";
  22111. }
  22112. jQuery.extend( {
  22113. // Add in style property hooks for overriding the default
  22114. // behavior of getting and setting a style property
  22115. cssHooks: {
  22116. opacity: {
  22117. get: function( elem, computed ) {
  22118. if ( computed ) {
  22119. // We should always get a number back from opacity
  22120. var ret = curCSS( elem, "opacity" );
  22121. return ret === "" ? "1" : ret;
  22122. }
  22123. }
  22124. }
  22125. },
  22126. // Don't automatically add "px" to these possibly-unitless properties
  22127. cssNumber: {
  22128. "animationIterationCount": true,
  22129. "columnCount": true,
  22130. "fillOpacity": true,
  22131. "flexGrow": true,
  22132. "flexShrink": true,
  22133. "fontWeight": true,
  22134. "lineHeight": true,
  22135. "opacity": true,
  22136. "order": true,
  22137. "orphans": true,
  22138. "widows": true,
  22139. "zIndex": true,
  22140. "zoom": true
  22141. },
  22142. // Add in properties whose names you wish to fix before
  22143. // setting or getting the value
  22144. cssProps: {
  22145. "float": "cssFloat"
  22146. },
  22147. // Get and set the style property on a DOM Node
  22148. style: function( elem, name, value, extra ) {
  22149. // Don't set styles on text and comment nodes
  22150. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  22151. return;
  22152. }
  22153. // Make sure that we're working with the right name
  22154. var ret, type, hooks,
  22155. origName = jQuery.camelCase( name ),
  22156. isCustomProp = rcustomProp.test( name ),
  22157. style = elem.style;
  22158. // Make sure that we're working with the right name. We don't
  22159. // want to query the value if it is a CSS custom property
  22160. // since they are user-defined.
  22161. if ( !isCustomProp ) {
  22162. name = finalPropName( origName );
  22163. }
  22164. // Gets hook for the prefixed version, then unprefixed version
  22165. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  22166. // Check if we're setting a value
  22167. if ( value !== undefined ) {
  22168. type = typeof value;
  22169. // Convert "+=" or "-=" to relative numbers (#7345)
  22170. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  22171. value = adjustCSS( elem, name, ret );
  22172. // Fixes bug #9237
  22173. type = "number";
  22174. }
  22175. // Make sure that null and NaN values aren't set (#7116)
  22176. if ( value == null || value !== value ) {
  22177. return;
  22178. }
  22179. // If a number was passed in, add the unit (except for certain CSS properties)
  22180. if ( type === "number" ) {
  22181. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  22182. }
  22183. // background-* props affect original clone's values
  22184. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  22185. style[ name ] = "inherit";
  22186. }
  22187. // If a hook was provided, use that value, otherwise just set the specified value
  22188. if ( !hooks || !( "set" in hooks ) ||
  22189. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  22190. if ( isCustomProp ) {
  22191. style.setProperty( name, value );
  22192. } else {
  22193. style[ name ] = value;
  22194. }
  22195. }
  22196. } else {
  22197. // If a hook was provided get the non-computed value from there
  22198. if ( hooks && "get" in hooks &&
  22199. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  22200. return ret;
  22201. }
  22202. // Otherwise just get the value from the style object
  22203. return style[ name ];
  22204. }
  22205. },
  22206. css: function( elem, name, extra, styles ) {
  22207. var val, num, hooks,
  22208. origName = jQuery.camelCase( name ),
  22209. isCustomProp = rcustomProp.test( name );
  22210. // Make sure that we're working with the right name. We don't
  22211. // want to modify the value if it is a CSS custom property
  22212. // since they are user-defined.
  22213. if ( !isCustomProp ) {
  22214. name = finalPropName( origName );
  22215. }
  22216. // Try prefixed name followed by the unprefixed name
  22217. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  22218. // If a hook was provided get the computed value from there
  22219. if ( hooks && "get" in hooks ) {
  22220. val = hooks.get( elem, true, extra );
  22221. }
  22222. // Otherwise, if a way to get the computed value exists, use that
  22223. if ( val === undefined ) {
  22224. val = curCSS( elem, name, styles );
  22225. }
  22226. // Convert "normal" to computed value
  22227. if ( val === "normal" && name in cssNormalTransform ) {
  22228. val = cssNormalTransform[ name ];
  22229. }
  22230. // Make numeric if forced or a qualifier was provided and val looks numeric
  22231. if ( extra === "" || extra ) {
  22232. num = parseFloat( val );
  22233. return extra === true || isFinite( num ) ? num || 0 : val;
  22234. }
  22235. return val;
  22236. }
  22237. } );
  22238. jQuery.each( [ "height", "width" ], function( i, name ) {
  22239. jQuery.cssHooks[ name ] = {
  22240. get: function( elem, computed, extra ) {
  22241. if ( computed ) {
  22242. // Certain elements can have dimension info if we invisibly show them
  22243. // but it must have a current display style that would benefit
  22244. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  22245. // Support: Safari 8+
  22246. // Table columns in Safari have non-zero offsetWidth & zero
  22247. // getBoundingClientRect().width unless display is changed.
  22248. // Support: IE <=11 only
  22249. // Running getBoundingClientRect on a disconnected node
  22250. // in IE throws an error.
  22251. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  22252. swap( elem, cssShow, function() {
  22253. return getWidthOrHeight( elem, name, extra );
  22254. } ) :
  22255. getWidthOrHeight( elem, name, extra );
  22256. }
  22257. },
  22258. set: function( elem, value, extra ) {
  22259. var matches,
  22260. styles = extra && getStyles( elem ),
  22261. subtract = extra && augmentWidthOrHeight(
  22262. elem,
  22263. name,
  22264. extra,
  22265. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  22266. styles
  22267. );
  22268. // Convert to pixels if value adjustment is needed
  22269. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  22270. ( matches[ 3 ] || "px" ) !== "px" ) {
  22271. elem.style[ name ] = value;
  22272. value = jQuery.css( elem, name );
  22273. }
  22274. return setPositiveNumber( elem, value, subtract );
  22275. }
  22276. };
  22277. } );
  22278. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  22279. function( elem, computed ) {
  22280. if ( computed ) {
  22281. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  22282. elem.getBoundingClientRect().left -
  22283. swap( elem, { marginLeft: 0 }, function() {
  22284. return elem.getBoundingClientRect().left;
  22285. } )
  22286. ) + "px";
  22287. }
  22288. }
  22289. );
  22290. // These hooks are used by animate to expand properties
  22291. jQuery.each( {
  22292. margin: "",
  22293. padding: "",
  22294. border: "Width"
  22295. }, function( prefix, suffix ) {
  22296. jQuery.cssHooks[ prefix + suffix ] = {
  22297. expand: function( value ) {
  22298. var i = 0,
  22299. expanded = {},
  22300. // Assumes a single number if not a string
  22301. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  22302. for ( ; i < 4; i++ ) {
  22303. expanded[ prefix + cssExpand[ i ] + suffix ] =
  22304. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  22305. }
  22306. return expanded;
  22307. }
  22308. };
  22309. if ( !rmargin.test( prefix ) ) {
  22310. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  22311. }
  22312. } );
  22313. jQuery.fn.extend( {
  22314. css: function( name, value ) {
  22315. return access( this, function( elem, name, value ) {
  22316. var styles, len,
  22317. map = {},
  22318. i = 0;
  22319. if ( Array.isArray( name ) ) {
  22320. styles = getStyles( elem );
  22321. len = name.length;
  22322. for ( ; i < len; i++ ) {
  22323. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  22324. }
  22325. return map;
  22326. }
  22327. return value !== undefined ?
  22328. jQuery.style( elem, name, value ) :
  22329. jQuery.css( elem, name );
  22330. }, name, value, arguments.length > 1 );
  22331. }
  22332. } );
  22333. function Tween( elem, options, prop, end, easing ) {
  22334. return new Tween.prototype.init( elem, options, prop, end, easing );
  22335. }
  22336. jQuery.Tween = Tween;
  22337. Tween.prototype = {
  22338. constructor: Tween,
  22339. init: function( elem, options, prop, end, easing, unit ) {
  22340. this.elem = elem;
  22341. this.prop = prop;
  22342. this.easing = easing || jQuery.easing._default;
  22343. this.options = options;
  22344. this.start = this.now = this.cur();
  22345. this.end = end;
  22346. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  22347. },
  22348. cur: function() {
  22349. var hooks = Tween.propHooks[ this.prop ];
  22350. return hooks && hooks.get ?
  22351. hooks.get( this ) :
  22352. Tween.propHooks._default.get( this );
  22353. },
  22354. run: function( percent ) {
  22355. var eased,
  22356. hooks = Tween.propHooks[ this.prop ];
  22357. if ( this.options.duration ) {
  22358. this.pos = eased = jQuery.easing[ this.easing ](
  22359. percent, this.options.duration * percent, 0, 1, this.options.duration
  22360. );
  22361. } else {
  22362. this.pos = eased = percent;
  22363. }
  22364. this.now = ( this.end - this.start ) * eased + this.start;
  22365. if ( this.options.step ) {
  22366. this.options.step.call( this.elem, this.now, this );
  22367. }
  22368. if ( hooks && hooks.set ) {
  22369. hooks.set( this );
  22370. } else {
  22371. Tween.propHooks._default.set( this );
  22372. }
  22373. return this;
  22374. }
  22375. };
  22376. Tween.prototype.init.prototype = Tween.prototype;
  22377. Tween.propHooks = {
  22378. _default: {
  22379. get: function( tween ) {
  22380. var result;
  22381. // Use a property on the element directly when it is not a DOM element,
  22382. // or when there is no matching style property that exists.
  22383. if ( tween.elem.nodeType !== 1 ||
  22384. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  22385. return tween.elem[ tween.prop ];
  22386. }
  22387. // Passing an empty string as a 3rd parameter to .css will automatically
  22388. // attempt a parseFloat and fallback to a string if the parse fails.
  22389. // Simple values such as "10px" are parsed to Float;
  22390. // complex values such as "rotate(1rad)" are returned as-is.
  22391. result = jQuery.css( tween.elem, tween.prop, "" );
  22392. // Empty strings, null, undefined and "auto" are converted to 0.
  22393. return !result || result === "auto" ? 0 : result;
  22394. },
  22395. set: function( tween ) {
  22396. // Use step hook for back compat.
  22397. // Use cssHook if its there.
  22398. // Use .style if available and use plain properties where available.
  22399. if ( jQuery.fx.step[ tween.prop ] ) {
  22400. jQuery.fx.step[ tween.prop ]( tween );
  22401. } else if ( tween.elem.nodeType === 1 &&
  22402. ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
  22403. jQuery.cssHooks[ tween.prop ] ) ) {
  22404. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  22405. } else {
  22406. tween.elem[ tween.prop ] = tween.now;
  22407. }
  22408. }
  22409. }
  22410. };
  22411. // Support: IE <=9 only
  22412. // Panic based approach to setting things on disconnected nodes
  22413. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  22414. set: function( tween ) {
  22415. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  22416. tween.elem[ tween.prop ] = tween.now;
  22417. }
  22418. }
  22419. };
  22420. jQuery.easing = {
  22421. linear: function( p ) {
  22422. return p;
  22423. },
  22424. swing: function( p ) {
  22425. return 0.5 - Math.cos( p * Math.PI ) / 2;
  22426. },
  22427. _default: "swing"
  22428. };
  22429. jQuery.fx = Tween.prototype.init;
  22430. // Back compat <1.8 extension point
  22431. jQuery.fx.step = {};
  22432. var
  22433. fxNow, inProgress,
  22434. rfxtypes = /^(?:toggle|show|hide)$/,
  22435. rrun = /queueHooks$/;
  22436. function schedule() {
  22437. if ( inProgress ) {
  22438. if ( document.hidden === false && window.requestAnimationFrame ) {
  22439. window.requestAnimationFrame( schedule );
  22440. } else {
  22441. window.setTimeout( schedule, jQuery.fx.interval );
  22442. }
  22443. jQuery.fx.tick();
  22444. }
  22445. }
  22446. // Animations created synchronously will run synchronously
  22447. function createFxNow() {
  22448. window.setTimeout( function() {
  22449. fxNow = undefined;
  22450. } );
  22451. return ( fxNow = jQuery.now() );
  22452. }
  22453. // Generate parameters to create a standard animation
  22454. function genFx( type, includeWidth ) {
  22455. var which,
  22456. i = 0,
  22457. attrs = { height: type };
  22458. // If we include width, step value is 1 to do all cssExpand values,
  22459. // otherwise step value is 2 to skip over Left and Right
  22460. includeWidth = includeWidth ? 1 : 0;
  22461. for ( ; i < 4; i += 2 - includeWidth ) {
  22462. which = cssExpand[ i ];
  22463. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  22464. }
  22465. if ( includeWidth ) {
  22466. attrs.opacity = attrs.width = type;
  22467. }
  22468. return attrs;
  22469. }
  22470. function createTween( value, prop, animation ) {
  22471. var tween,
  22472. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  22473. index = 0,
  22474. length = collection.length;
  22475. for ( ; index < length; index++ ) {
  22476. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  22477. // We're done with this property
  22478. return tween;
  22479. }
  22480. }
  22481. }
  22482. function defaultPrefilter( elem, props, opts ) {
  22483. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  22484. isBox = "width" in props || "height" in props,
  22485. anim = this,
  22486. orig = {},
  22487. style = elem.style,
  22488. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  22489. dataShow = dataPriv.get( elem, "fxshow" );
  22490. // Queue-skipping animations hijack the fx hooks
  22491. if ( !opts.queue ) {
  22492. hooks = jQuery._queueHooks( elem, "fx" );
  22493. if ( hooks.unqueued == null ) {
  22494. hooks.unqueued = 0;
  22495. oldfire = hooks.empty.fire;
  22496. hooks.empty.fire = function() {
  22497. if ( !hooks.unqueued ) {
  22498. oldfire();
  22499. }
  22500. };
  22501. }
  22502. hooks.unqueued++;
  22503. anim.always( function() {
  22504. // Ensure the complete handler is called before this completes
  22505. anim.always( function() {
  22506. hooks.unqueued--;
  22507. if ( !jQuery.queue( elem, "fx" ).length ) {
  22508. hooks.empty.fire();
  22509. }
  22510. } );
  22511. } );
  22512. }
  22513. // Detect show/hide animations
  22514. for ( prop in props ) {
  22515. value = props[ prop ];
  22516. if ( rfxtypes.test( value ) ) {
  22517. delete props[ prop ];
  22518. toggle = toggle || value === "toggle";
  22519. if ( value === ( hidden ? "hide" : "show" ) ) {
  22520. // Pretend to be hidden if this is a "show" and
  22521. // there is still data from a stopped show/hide
  22522. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  22523. hidden = true;
  22524. // Ignore all other no-op show/hide data
  22525. } else {
  22526. continue;
  22527. }
  22528. }
  22529. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  22530. }
  22531. }
  22532. // Bail out if this is a no-op like .hide().hide()
  22533. propTween = !jQuery.isEmptyObject( props );
  22534. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  22535. return;
  22536. }
  22537. // Restrict "overflow" and "display" styles during box animations
  22538. if ( isBox && elem.nodeType === 1 ) {
  22539. // Support: IE <=9 - 11, Edge 12 - 13
  22540. // Record all 3 overflow attributes because IE does not infer the shorthand
  22541. // from identically-valued overflowX and overflowY
  22542. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  22543. // Identify a display type, preferring old show/hide data over the CSS cascade
  22544. restoreDisplay = dataShow && dataShow.display;
  22545. if ( restoreDisplay == null ) {
  22546. restoreDisplay = dataPriv.get( elem, "display" );
  22547. }
  22548. display = jQuery.css( elem, "display" );
  22549. if ( display === "none" ) {
  22550. if ( restoreDisplay ) {
  22551. display = restoreDisplay;
  22552. } else {
  22553. // Get nonempty value(s) by temporarily forcing visibility
  22554. showHide( [ elem ], true );
  22555. restoreDisplay = elem.style.display || restoreDisplay;
  22556. display = jQuery.css( elem, "display" );
  22557. showHide( [ elem ] );
  22558. }
  22559. }
  22560. // Animate inline elements as inline-block
  22561. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  22562. if ( jQuery.css( elem, "float" ) === "none" ) {
  22563. // Restore the original display value at the end of pure show/hide animations
  22564. if ( !propTween ) {
  22565. anim.done( function() {
  22566. style.display = restoreDisplay;
  22567. } );
  22568. if ( restoreDisplay == null ) {
  22569. display = style.display;
  22570. restoreDisplay = display === "none" ? "" : display;
  22571. }
  22572. }
  22573. style.display = "inline-block";
  22574. }
  22575. }
  22576. }
  22577. if ( opts.overflow ) {
  22578. style.overflow = "hidden";
  22579. anim.always( function() {
  22580. style.overflow = opts.overflow[ 0 ];
  22581. style.overflowX = opts.overflow[ 1 ];
  22582. style.overflowY = opts.overflow[ 2 ];
  22583. } );
  22584. }
  22585. // Implement show/hide animations
  22586. propTween = false;
  22587. for ( prop in orig ) {
  22588. // General show/hide setup for this element animation
  22589. if ( !propTween ) {
  22590. if ( dataShow ) {
  22591. if ( "hidden" in dataShow ) {
  22592. hidden = dataShow.hidden;
  22593. }
  22594. } else {
  22595. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  22596. }
  22597. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  22598. if ( toggle ) {
  22599. dataShow.hidden = !hidden;
  22600. }
  22601. // Show elements before animating them
  22602. if ( hidden ) {
  22603. showHide( [ elem ], true );
  22604. }
  22605. /* eslint-disable no-loop-func */
  22606. anim.done( function() {
  22607. /* eslint-enable no-loop-func */
  22608. // The final step of a "hide" animation is actually hiding the element
  22609. if ( !hidden ) {
  22610. showHide( [ elem ] );
  22611. }
  22612. dataPriv.remove( elem, "fxshow" );
  22613. for ( prop in orig ) {
  22614. jQuery.style( elem, prop, orig[ prop ] );
  22615. }
  22616. } );
  22617. }
  22618. // Per-property setup
  22619. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  22620. if ( !( prop in dataShow ) ) {
  22621. dataShow[ prop ] = propTween.start;
  22622. if ( hidden ) {
  22623. propTween.end = propTween.start;
  22624. propTween.start = 0;
  22625. }
  22626. }
  22627. }
  22628. }
  22629. function propFilter( props, specialEasing ) {
  22630. var index, name, easing, value, hooks;
  22631. // camelCase, specialEasing and expand cssHook pass
  22632. for ( index in props ) {
  22633. name = jQuery.camelCase( index );
  22634. easing = specialEasing[ name ];
  22635. value = props[ index ];
  22636. if ( Array.isArray( value ) ) {
  22637. easing = value[ 1 ];
  22638. value = props[ index ] = value[ 0 ];
  22639. }
  22640. if ( index !== name ) {
  22641. props[ name ] = value;
  22642. delete props[ index ];
  22643. }
  22644. hooks = jQuery.cssHooks[ name ];
  22645. if ( hooks && "expand" in hooks ) {
  22646. value = hooks.expand( value );
  22647. delete props[ name ];
  22648. // Not quite $.extend, this won't overwrite existing keys.
  22649. // Reusing 'index' because we have the correct "name"
  22650. for ( index in value ) {
  22651. if ( !( index in props ) ) {
  22652. props[ index ] = value[ index ];
  22653. specialEasing[ index ] = easing;
  22654. }
  22655. }
  22656. } else {
  22657. specialEasing[ name ] = easing;
  22658. }
  22659. }
  22660. }
  22661. function Animation( elem, properties, options ) {
  22662. var result,
  22663. stopped,
  22664. index = 0,
  22665. length = Animation.prefilters.length,
  22666. deferred = jQuery.Deferred().always( function() {
  22667. // Don't match elem in the :animated selector
  22668. delete tick.elem;
  22669. } ),
  22670. tick = function() {
  22671. if ( stopped ) {
  22672. return false;
  22673. }
  22674. var currentTime = fxNow || createFxNow(),
  22675. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  22676. // Support: Android 2.3 only
  22677. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  22678. temp = remaining / animation.duration || 0,
  22679. percent = 1 - temp,
  22680. index = 0,
  22681. length = animation.tweens.length;
  22682. for ( ; index < length; index++ ) {
  22683. animation.tweens[ index ].run( percent );
  22684. }
  22685. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  22686. // If there's more to do, yield
  22687. if ( percent < 1 && length ) {
  22688. return remaining;
  22689. }
  22690. // If this was an empty animation, synthesize a final progress notification
  22691. if ( !length ) {
  22692. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  22693. }
  22694. // Resolve the animation and report its conclusion
  22695. deferred.resolveWith( elem, [ animation ] );
  22696. return false;
  22697. },
  22698. animation = deferred.promise( {
  22699. elem: elem,
  22700. props: jQuery.extend( {}, properties ),
  22701. opts: jQuery.extend( true, {
  22702. specialEasing: {},
  22703. easing: jQuery.easing._default
  22704. }, options ),
  22705. originalProperties: properties,
  22706. originalOptions: options,
  22707. startTime: fxNow || createFxNow(),
  22708. duration: options.duration,
  22709. tweens: [],
  22710. createTween: function( prop, end ) {
  22711. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  22712. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  22713. animation.tweens.push( tween );
  22714. return tween;
  22715. },
  22716. stop: function( gotoEnd ) {
  22717. var index = 0,
  22718. // If we are going to the end, we want to run all the tweens
  22719. // otherwise we skip this part
  22720. length = gotoEnd ? animation.tweens.length : 0;
  22721. if ( stopped ) {
  22722. return this;
  22723. }
  22724. stopped = true;
  22725. for ( ; index < length; index++ ) {
  22726. animation.tweens[ index ].run( 1 );
  22727. }
  22728. // Resolve when we played the last frame; otherwise, reject
  22729. if ( gotoEnd ) {
  22730. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  22731. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  22732. } else {
  22733. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  22734. }
  22735. return this;
  22736. }
  22737. } ),
  22738. props = animation.props;
  22739. propFilter( props, animation.opts.specialEasing );
  22740. for ( ; index < length; index++ ) {
  22741. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  22742. if ( result ) {
  22743. if ( jQuery.isFunction( result.stop ) ) {
  22744. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  22745. jQuery.proxy( result.stop, result );
  22746. }
  22747. return result;
  22748. }
  22749. }
  22750. jQuery.map( props, createTween, animation );
  22751. if ( jQuery.isFunction( animation.opts.start ) ) {
  22752. animation.opts.start.call( elem, animation );
  22753. }
  22754. // Attach callbacks from options
  22755. animation
  22756. .progress( animation.opts.progress )
  22757. .done( animation.opts.done, animation.opts.complete )
  22758. .fail( animation.opts.fail )
  22759. .always( animation.opts.always );
  22760. jQuery.fx.timer(
  22761. jQuery.extend( tick, {
  22762. elem: elem,
  22763. anim: animation,
  22764. queue: animation.opts.queue
  22765. } )
  22766. );
  22767. return animation;
  22768. }
  22769. jQuery.Animation = jQuery.extend( Animation, {
  22770. tweeners: {
  22771. "*": [ function( prop, value ) {
  22772. var tween = this.createTween( prop, value );
  22773. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  22774. return tween;
  22775. } ]
  22776. },
  22777. tweener: function( props, callback ) {
  22778. if ( jQuery.isFunction( props ) ) {
  22779. callback = props;
  22780. props = [ "*" ];
  22781. } else {
  22782. props = props.match( rnothtmlwhite );
  22783. }
  22784. var prop,
  22785. index = 0,
  22786. length = props.length;
  22787. for ( ; index < length; index++ ) {
  22788. prop = props[ index ];
  22789. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  22790. Animation.tweeners[ prop ].unshift( callback );
  22791. }
  22792. },
  22793. prefilters: [ defaultPrefilter ],
  22794. prefilter: function( callback, prepend ) {
  22795. if ( prepend ) {
  22796. Animation.prefilters.unshift( callback );
  22797. } else {
  22798. Animation.prefilters.push( callback );
  22799. }
  22800. }
  22801. } );
  22802. jQuery.speed = function( speed, easing, fn ) {
  22803. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  22804. complete: fn || !fn && easing ||
  22805. jQuery.isFunction( speed ) && speed,
  22806. duration: speed,
  22807. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  22808. };
  22809. // Go to the end state if fx are off
  22810. if ( jQuery.fx.off ) {
  22811. opt.duration = 0;
  22812. } else {
  22813. if ( typeof opt.duration !== "number" ) {
  22814. if ( opt.duration in jQuery.fx.speeds ) {
  22815. opt.duration = jQuery.fx.speeds[ opt.duration ];
  22816. } else {
  22817. opt.duration = jQuery.fx.speeds._default;
  22818. }
  22819. }
  22820. }
  22821. // Normalize opt.queue - true/undefined/null -> "fx"
  22822. if ( opt.queue == null || opt.queue === true ) {
  22823. opt.queue = "fx";
  22824. }
  22825. // Queueing
  22826. opt.old = opt.complete;
  22827. opt.complete = function() {
  22828. if ( jQuery.isFunction( opt.old ) ) {
  22829. opt.old.call( this );
  22830. }
  22831. if ( opt.queue ) {
  22832. jQuery.dequeue( this, opt.queue );
  22833. }
  22834. };
  22835. return opt;
  22836. };
  22837. jQuery.fn.extend( {
  22838. fadeTo: function( speed, to, easing, callback ) {
  22839. // Show any hidden elements after setting opacity to 0
  22840. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  22841. // Animate to the value specified
  22842. .end().animate( { opacity: to }, speed, easing, callback );
  22843. },
  22844. animate: function( prop, speed, easing, callback ) {
  22845. var empty = jQuery.isEmptyObject( prop ),
  22846. optall = jQuery.speed( speed, easing, callback ),
  22847. doAnimation = function() {
  22848. // Operate on a copy of prop so per-property easing won't be lost
  22849. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  22850. // Empty animations, or finishing resolves immediately
  22851. if ( empty || dataPriv.get( this, "finish" ) ) {
  22852. anim.stop( true );
  22853. }
  22854. };
  22855. doAnimation.finish = doAnimation;
  22856. return empty || optall.queue === false ?
  22857. this.each( doAnimation ) :
  22858. this.queue( optall.queue, doAnimation );
  22859. },
  22860. stop: function( type, clearQueue, gotoEnd ) {
  22861. var stopQueue = function( hooks ) {
  22862. var stop = hooks.stop;
  22863. delete hooks.stop;
  22864. stop( gotoEnd );
  22865. };
  22866. if ( typeof type !== "string" ) {
  22867. gotoEnd = clearQueue;
  22868. clearQueue = type;
  22869. type = undefined;
  22870. }
  22871. if ( clearQueue && type !== false ) {
  22872. this.queue( type || "fx", [] );
  22873. }
  22874. return this.each( function() {
  22875. var dequeue = true,
  22876. index = type != null && type + "queueHooks",
  22877. timers = jQuery.timers,
  22878. data = dataPriv.get( this );
  22879. if ( index ) {
  22880. if ( data[ index ] && data[ index ].stop ) {
  22881. stopQueue( data[ index ] );
  22882. }
  22883. } else {
  22884. for ( index in data ) {
  22885. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  22886. stopQueue( data[ index ] );
  22887. }
  22888. }
  22889. }
  22890. for ( index = timers.length; index--; ) {
  22891. if ( timers[ index ].elem === this &&
  22892. ( type == null || timers[ index ].queue === type ) ) {
  22893. timers[ index ].anim.stop( gotoEnd );
  22894. dequeue = false;
  22895. timers.splice( index, 1 );
  22896. }
  22897. }
  22898. // Start the next in the queue if the last step wasn't forced.
  22899. // Timers currently will call their complete callbacks, which
  22900. // will dequeue but only if they were gotoEnd.
  22901. if ( dequeue || !gotoEnd ) {
  22902. jQuery.dequeue( this, type );
  22903. }
  22904. } );
  22905. },
  22906. finish: function( type ) {
  22907. if ( type !== false ) {
  22908. type = type || "fx";
  22909. }
  22910. return this.each( function() {
  22911. var index,
  22912. data = dataPriv.get( this ),
  22913. queue = data[ type + "queue" ],
  22914. hooks = data[ type + "queueHooks" ],
  22915. timers = jQuery.timers,
  22916. length = queue ? queue.length : 0;
  22917. // Enable finishing flag on private data
  22918. data.finish = true;
  22919. // Empty the queue first
  22920. jQuery.queue( this, type, [] );
  22921. if ( hooks && hooks.stop ) {
  22922. hooks.stop.call( this, true );
  22923. }
  22924. // Look for any active animations, and finish them
  22925. for ( index = timers.length; index--; ) {
  22926. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  22927. timers[ index ].anim.stop( true );
  22928. timers.splice( index, 1 );
  22929. }
  22930. }
  22931. // Look for any animations in the old queue and finish them
  22932. for ( index = 0; index < length; index++ ) {
  22933. if ( queue[ index ] && queue[ index ].finish ) {
  22934. queue[ index ].finish.call( this );
  22935. }
  22936. }
  22937. // Turn off finishing flag
  22938. delete data.finish;
  22939. } );
  22940. }
  22941. } );
  22942. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  22943. var cssFn = jQuery.fn[ name ];
  22944. jQuery.fn[ name ] = function( speed, easing, callback ) {
  22945. return speed == null || typeof speed === "boolean" ?
  22946. cssFn.apply( this, arguments ) :
  22947. this.animate( genFx( name, true ), speed, easing, callback );
  22948. };
  22949. } );
  22950. // Generate shortcuts for custom animations
  22951. jQuery.each( {
  22952. slideDown: genFx( "show" ),
  22953. slideUp: genFx( "hide" ),
  22954. slideToggle: genFx( "toggle" ),
  22955. fadeIn: { opacity: "show" },
  22956. fadeOut: { opacity: "hide" },
  22957. fadeToggle: { opacity: "toggle" }
  22958. }, function( name, props ) {
  22959. jQuery.fn[ name ] = function( speed, easing, callback ) {
  22960. return this.animate( props, speed, easing, callback );
  22961. };
  22962. } );
  22963. jQuery.timers = [];
  22964. jQuery.fx.tick = function() {
  22965. var timer,
  22966. i = 0,
  22967. timers = jQuery.timers;
  22968. fxNow = jQuery.now();
  22969. for ( ; i < timers.length; i++ ) {
  22970. timer = timers[ i ];
  22971. // Run the timer and safely remove it when done (allowing for external removal)
  22972. if ( !timer() && timers[ i ] === timer ) {
  22973. timers.splice( i--, 1 );
  22974. }
  22975. }
  22976. if ( !timers.length ) {
  22977. jQuery.fx.stop();
  22978. }
  22979. fxNow = undefined;
  22980. };
  22981. jQuery.fx.timer = function( timer ) {
  22982. jQuery.timers.push( timer );
  22983. jQuery.fx.start();
  22984. };
  22985. jQuery.fx.interval = 13;
  22986. jQuery.fx.start = function() {
  22987. if ( inProgress ) {
  22988. return;
  22989. }
  22990. inProgress = true;
  22991. schedule();
  22992. };
  22993. jQuery.fx.stop = function() {
  22994. inProgress = null;
  22995. };
  22996. jQuery.fx.speeds = {
  22997. slow: 600,
  22998. fast: 200,
  22999. // Default speed
  23000. _default: 400
  23001. };
  23002. // Based off of the plugin by Clint Helfers, with permission.
  23003. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  23004. jQuery.fn.delay = function( time, type ) {
  23005. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  23006. type = type || "fx";
  23007. return this.queue( type, function( next, hooks ) {
  23008. var timeout = window.setTimeout( next, time );
  23009. hooks.stop = function() {
  23010. window.clearTimeout( timeout );
  23011. };
  23012. } );
  23013. };
  23014. ( function() {
  23015. var input = document.createElement( "input" ),
  23016. select = document.createElement( "select" ),
  23017. opt = select.appendChild( document.createElement( "option" ) );
  23018. input.type = "checkbox";
  23019. // Support: Android <=4.3 only
  23020. // Default value for a checkbox should be "on"
  23021. support.checkOn = input.value !== "";
  23022. // Support: IE <=11 only
  23023. // Must access selectedIndex to make default options select
  23024. support.optSelected = opt.selected;
  23025. // Support: IE <=11 only
  23026. // An input loses its value after becoming a radio
  23027. input = document.createElement( "input" );
  23028. input.value = "t";
  23029. input.type = "radio";
  23030. support.radioValue = input.value === "t";
  23031. } )();
  23032. var boolHook,
  23033. attrHandle = jQuery.expr.attrHandle;
  23034. jQuery.fn.extend( {
  23035. attr: function( name, value ) {
  23036. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  23037. },
  23038. removeAttr: function( name ) {
  23039. return this.each( function() {
  23040. jQuery.removeAttr( this, name );
  23041. } );
  23042. }
  23043. } );
  23044. jQuery.extend( {
  23045. attr: function( elem, name, value ) {
  23046. var ret, hooks,
  23047. nType = elem.nodeType;
  23048. // Don't get/set attributes on text, comment and attribute nodes
  23049. if ( nType === 3 || nType === 8 || nType === 2 ) {
  23050. return;
  23051. }
  23052. // Fallback to prop when attributes are not supported
  23053. if ( typeof elem.getAttribute === "undefined" ) {
  23054. return jQuery.prop( elem, name, value );
  23055. }
  23056. // Attribute hooks are determined by the lowercase version
  23057. // Grab necessary hook if one is defined
  23058. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  23059. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  23060. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  23061. }
  23062. if ( value !== undefined ) {
  23063. if ( value === null ) {
  23064. jQuery.removeAttr( elem, name );
  23065. return;
  23066. }
  23067. if ( hooks && "set" in hooks &&
  23068. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  23069. return ret;
  23070. }
  23071. elem.setAttribute( name, value + "" );
  23072. return value;
  23073. }
  23074. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  23075. return ret;
  23076. }
  23077. ret = jQuery.find.attr( elem, name );
  23078. // Non-existent attributes return null, we normalize to undefined
  23079. return ret == null ? undefined : ret;
  23080. },
  23081. attrHooks: {
  23082. type: {
  23083. set: function( elem, value ) {
  23084. if ( !support.radioValue && value === "radio" &&
  23085. nodeName( elem, "input" ) ) {
  23086. var val = elem.value;
  23087. elem.setAttribute( "type", value );
  23088. if ( val ) {
  23089. elem.value = val;
  23090. }
  23091. return value;
  23092. }
  23093. }
  23094. }
  23095. },
  23096. removeAttr: function( elem, value ) {
  23097. var name,
  23098. i = 0,
  23099. // Attribute names can contain non-HTML whitespace characters
  23100. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  23101. attrNames = value && value.match( rnothtmlwhite );
  23102. if ( attrNames && elem.nodeType === 1 ) {
  23103. while ( ( name = attrNames[ i++ ] ) ) {
  23104. elem.removeAttribute( name );
  23105. }
  23106. }
  23107. }
  23108. } );
  23109. // Hooks for boolean attributes
  23110. boolHook = {
  23111. set: function( elem, value, name ) {
  23112. if ( value === false ) {
  23113. // Remove boolean attributes when set to false
  23114. jQuery.removeAttr( elem, name );
  23115. } else {
  23116. elem.setAttribute( name, name );
  23117. }
  23118. return name;
  23119. }
  23120. };
  23121. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  23122. var getter = attrHandle[ name ] || jQuery.find.attr;
  23123. attrHandle[ name ] = function( elem, name, isXML ) {
  23124. var ret, handle,
  23125. lowercaseName = name.toLowerCase();
  23126. if ( !isXML ) {
  23127. // Avoid an infinite loop by temporarily removing this function from the getter
  23128. handle = attrHandle[ lowercaseName ];
  23129. attrHandle[ lowercaseName ] = ret;
  23130. ret = getter( elem, name, isXML ) != null ?
  23131. lowercaseName :
  23132. null;
  23133. attrHandle[ lowercaseName ] = handle;
  23134. }
  23135. return ret;
  23136. };
  23137. } );
  23138. var rfocusable = /^(?:input|select|textarea|button)$/i,
  23139. rclickable = /^(?:a|area)$/i;
  23140. jQuery.fn.extend( {
  23141. prop: function( name, value ) {
  23142. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  23143. },
  23144. removeProp: function( name ) {
  23145. return this.each( function() {
  23146. delete this[ jQuery.propFix[ name ] || name ];
  23147. } );
  23148. }
  23149. } );
  23150. jQuery.extend( {
  23151. prop: function( elem, name, value ) {
  23152. var ret, hooks,
  23153. nType = elem.nodeType;
  23154. // Don't get/set properties on text, comment and attribute nodes
  23155. if ( nType === 3 || nType === 8 || nType === 2 ) {
  23156. return;
  23157. }
  23158. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  23159. // Fix name and attach hooks
  23160. name = jQuery.propFix[ name ] || name;
  23161. hooks = jQuery.propHooks[ name ];
  23162. }
  23163. if ( value !== undefined ) {
  23164. if ( hooks && "set" in hooks &&
  23165. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  23166. return ret;
  23167. }
  23168. return ( elem[ name ] = value );
  23169. }
  23170. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  23171. return ret;
  23172. }
  23173. return elem[ name ];
  23174. },
  23175. propHooks: {
  23176. tabIndex: {
  23177. get: function( elem ) {
  23178. // Support: IE <=9 - 11 only
  23179. // elem.tabIndex doesn't always return the
  23180. // correct value when it hasn't been explicitly set
  23181. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  23182. // Use proper attribute retrieval(#12072)
  23183. var tabindex = jQuery.find.attr( elem, "tabindex" );
  23184. if ( tabindex ) {
  23185. return parseInt( tabindex, 10 );
  23186. }
  23187. if (
  23188. rfocusable.test( elem.nodeName ) ||
  23189. rclickable.test( elem.nodeName ) &&
  23190. elem.href
  23191. ) {
  23192. return 0;
  23193. }
  23194. return -1;
  23195. }
  23196. }
  23197. },
  23198. propFix: {
  23199. "for": "htmlFor",
  23200. "class": "className"
  23201. }
  23202. } );
  23203. // Support: IE <=11 only
  23204. // Accessing the selectedIndex property
  23205. // forces the browser to respect setting selected
  23206. // on the option
  23207. // The getter ensures a default option is selected
  23208. // when in an optgroup
  23209. // eslint rule "no-unused-expressions" is disabled for this code
  23210. // since it considers such accessions noop
  23211. if ( !support.optSelected ) {
  23212. jQuery.propHooks.selected = {
  23213. get: function( elem ) {
  23214. /* eslint no-unused-expressions: "off" */
  23215. var parent = elem.parentNode;
  23216. if ( parent && parent.parentNode ) {
  23217. parent.parentNode.selectedIndex;
  23218. }
  23219. return null;
  23220. },
  23221. set: function( elem ) {
  23222. /* eslint no-unused-expressions: "off" */
  23223. var parent = elem.parentNode;
  23224. if ( parent ) {
  23225. parent.selectedIndex;
  23226. if ( parent.parentNode ) {
  23227. parent.parentNode.selectedIndex;
  23228. }
  23229. }
  23230. }
  23231. };
  23232. }
  23233. jQuery.each( [
  23234. "tabIndex",
  23235. "readOnly",
  23236. "maxLength",
  23237. "cellSpacing",
  23238. "cellPadding",
  23239. "rowSpan",
  23240. "colSpan",
  23241. "useMap",
  23242. "frameBorder",
  23243. "contentEditable"
  23244. ], function() {
  23245. jQuery.propFix[ this.toLowerCase() ] = this;
  23246. } );
  23247. // Strip and collapse whitespace according to HTML spec
  23248. // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
  23249. function stripAndCollapse( value ) {
  23250. var tokens = value.match( rnothtmlwhite ) || [];
  23251. return tokens.join( " " );
  23252. }
  23253. function getClass( elem ) {
  23254. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  23255. }
  23256. jQuery.fn.extend( {
  23257. addClass: function( value ) {
  23258. var classes, elem, cur, curValue, clazz, j, finalValue,
  23259. i = 0;
  23260. if ( jQuery.isFunction( value ) ) {
  23261. return this.each( function( j ) {
  23262. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  23263. } );
  23264. }
  23265. if ( typeof value === "string" && value ) {
  23266. classes = value.match( rnothtmlwhite ) || [];
  23267. while ( ( elem = this[ i++ ] ) ) {
  23268. curValue = getClass( elem );
  23269. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  23270. if ( cur ) {
  23271. j = 0;
  23272. while ( ( clazz = classes[ j++ ] ) ) {
  23273. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  23274. cur += clazz + " ";
  23275. }
  23276. }
  23277. // Only assign if different to avoid unneeded rendering.
  23278. finalValue = stripAndCollapse( cur );
  23279. if ( curValue !== finalValue ) {
  23280. elem.setAttribute( "class", finalValue );
  23281. }
  23282. }
  23283. }
  23284. }
  23285. return this;
  23286. },
  23287. removeClass: function( value ) {
  23288. var classes, elem, cur, curValue, clazz, j, finalValue,
  23289. i = 0;
  23290. if ( jQuery.isFunction( value ) ) {
  23291. return this.each( function( j ) {
  23292. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  23293. } );
  23294. }
  23295. if ( !arguments.length ) {
  23296. return this.attr( "class", "" );
  23297. }
  23298. if ( typeof value === "string" && value ) {
  23299. classes = value.match( rnothtmlwhite ) || [];
  23300. while ( ( elem = this[ i++ ] ) ) {
  23301. curValue = getClass( elem );
  23302. // This expression is here for better compressibility (see addClass)
  23303. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  23304. if ( cur ) {
  23305. j = 0;
  23306. while ( ( clazz = classes[ j++ ] ) ) {
  23307. // Remove *all* instances
  23308. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  23309. cur = cur.replace( " " + clazz + " ", " " );
  23310. }
  23311. }
  23312. // Only assign if different to avoid unneeded rendering.
  23313. finalValue = stripAndCollapse( cur );
  23314. if ( curValue !== finalValue ) {
  23315. elem.setAttribute( "class", finalValue );
  23316. }
  23317. }
  23318. }
  23319. }
  23320. return this;
  23321. },
  23322. toggleClass: function( value, stateVal ) {
  23323. var type = typeof value;
  23324. if ( typeof stateVal === "boolean" && type === "string" ) {
  23325. return stateVal ? this.addClass( value ) : this.removeClass( value );
  23326. }
  23327. if ( jQuery.isFunction( value ) ) {
  23328. return this.each( function( i ) {
  23329. jQuery( this ).toggleClass(
  23330. value.call( this, i, getClass( this ), stateVal ),
  23331. stateVal
  23332. );
  23333. } );
  23334. }
  23335. return this.each( function() {
  23336. var className, i, self, classNames;
  23337. if ( type === "string" ) {
  23338. // Toggle individual class names
  23339. i = 0;
  23340. self = jQuery( this );
  23341. classNames = value.match( rnothtmlwhite ) || [];
  23342. while ( ( className = classNames[ i++ ] ) ) {
  23343. // Check each className given, space separated list
  23344. if ( self.hasClass( className ) ) {
  23345. self.removeClass( className );
  23346. } else {
  23347. self.addClass( className );
  23348. }
  23349. }
  23350. // Toggle whole class name
  23351. } else if ( value === undefined || type === "boolean" ) {
  23352. className = getClass( this );
  23353. if ( className ) {
  23354. // Store className if set
  23355. dataPriv.set( this, "__className__", className );
  23356. }
  23357. // If the element has a class name or if we're passed `false`,
  23358. // then remove the whole classname (if there was one, the above saved it).
  23359. // Otherwise bring back whatever was previously saved (if anything),
  23360. // falling back to the empty string if nothing was stored.
  23361. if ( this.setAttribute ) {
  23362. this.setAttribute( "class",
  23363. className || value === false ?
  23364. "" :
  23365. dataPriv.get( this, "__className__" ) || ""
  23366. );
  23367. }
  23368. }
  23369. } );
  23370. },
  23371. hasClass: function( selector ) {
  23372. var className, elem,
  23373. i = 0;
  23374. className = " " + selector + " ";
  23375. while ( ( elem = this[ i++ ] ) ) {
  23376. if ( elem.nodeType === 1 &&
  23377. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  23378. return true;
  23379. }
  23380. }
  23381. return false;
  23382. }
  23383. } );
  23384. var rreturn = /\r/g;
  23385. jQuery.fn.extend( {
  23386. val: function( value ) {
  23387. var hooks, ret, isFunction,
  23388. elem = this[ 0 ];
  23389. if ( !arguments.length ) {
  23390. if ( elem ) {
  23391. hooks = jQuery.valHooks[ elem.type ] ||
  23392. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  23393. if ( hooks &&
  23394. "get" in hooks &&
  23395. ( ret = hooks.get( elem, "value" ) ) !== undefined
  23396. ) {
  23397. return ret;
  23398. }
  23399. ret = elem.value;
  23400. // Handle most common string cases
  23401. if ( typeof ret === "string" ) {
  23402. return ret.replace( rreturn, "" );
  23403. }
  23404. // Handle cases where value is null/undef or number
  23405. return ret == null ? "" : ret;
  23406. }
  23407. return;
  23408. }
  23409. isFunction = jQuery.isFunction( value );
  23410. return this.each( function( i ) {
  23411. var val;
  23412. if ( this.nodeType !== 1 ) {
  23413. return;
  23414. }
  23415. if ( isFunction ) {
  23416. val = value.call( this, i, jQuery( this ).val() );
  23417. } else {
  23418. val = value;
  23419. }
  23420. // Treat null/undefined as ""; convert numbers to string
  23421. if ( val == null ) {
  23422. val = "";
  23423. } else if ( typeof val === "number" ) {
  23424. val += "";
  23425. } else if ( Array.isArray( val ) ) {
  23426. val = jQuery.map( val, function( value ) {
  23427. return value == null ? "" : value + "";
  23428. } );
  23429. }
  23430. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  23431. // If set returns undefined, fall back to normal setting
  23432. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  23433. this.value = val;
  23434. }
  23435. } );
  23436. }
  23437. } );
  23438. jQuery.extend( {
  23439. valHooks: {
  23440. option: {
  23441. get: function( elem ) {
  23442. var val = jQuery.find.attr( elem, "value" );
  23443. return val != null ?
  23444. val :
  23445. // Support: IE <=10 - 11 only
  23446. // option.text throws exceptions (#14686, #14858)
  23447. // Strip and collapse whitespace
  23448. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  23449. stripAndCollapse( jQuery.text( elem ) );
  23450. }
  23451. },
  23452. select: {
  23453. get: function( elem ) {
  23454. var value, option, i,
  23455. options = elem.options,
  23456. index = elem.selectedIndex,
  23457. one = elem.type === "select-one",
  23458. values = one ? null : [],
  23459. max = one ? index + 1 : options.length;
  23460. if ( index < 0 ) {
  23461. i = max;
  23462. } else {
  23463. i = one ? index : 0;
  23464. }
  23465. // Loop through all the selected options
  23466. for ( ; i < max; i++ ) {
  23467. option = options[ i ];
  23468. // Support: IE <=9 only
  23469. // IE8-9 doesn't update selected after form reset (#2551)
  23470. if ( ( option.selected || i === index ) &&
  23471. // Don't return options that are disabled or in a disabled optgroup
  23472. !option.disabled &&
  23473. ( !option.parentNode.disabled ||
  23474. !nodeName( option.parentNode, "optgroup" ) ) ) {
  23475. // Get the specific value for the option
  23476. value = jQuery( option ).val();
  23477. // We don't need an array for one selects
  23478. if ( one ) {
  23479. return value;
  23480. }
  23481. // Multi-Selects return an array
  23482. values.push( value );
  23483. }
  23484. }
  23485. return values;
  23486. },
  23487. set: function( elem, value ) {
  23488. var optionSet, option,
  23489. options = elem.options,
  23490. values = jQuery.makeArray( value ),
  23491. i = options.length;
  23492. while ( i-- ) {
  23493. option = options[ i ];
  23494. /* eslint-disable no-cond-assign */
  23495. if ( option.selected =
  23496. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  23497. ) {
  23498. optionSet = true;
  23499. }
  23500. /* eslint-enable no-cond-assign */
  23501. }
  23502. // Force browsers to behave consistently when non-matching value is set
  23503. if ( !optionSet ) {
  23504. elem.selectedIndex = -1;
  23505. }
  23506. return values;
  23507. }
  23508. }
  23509. }
  23510. } );
  23511. // Radios and checkboxes getter/setter
  23512. jQuery.each( [ "radio", "checkbox" ], function() {
  23513. jQuery.valHooks[ this ] = {
  23514. set: function( elem, value ) {
  23515. if ( Array.isArray( value ) ) {
  23516. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  23517. }
  23518. }
  23519. };
  23520. if ( !support.checkOn ) {
  23521. jQuery.valHooks[ this ].get = function( elem ) {
  23522. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  23523. };
  23524. }
  23525. } );
  23526. // Return jQuery for attributes-only inclusion
  23527. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
  23528. jQuery.extend( jQuery.event, {
  23529. trigger: function( event, data, elem, onlyHandlers ) {
  23530. var i, cur, tmp, bubbleType, ontype, handle, special,
  23531. eventPath = [ elem || document ],
  23532. type = hasOwn.call( event, "type" ) ? event.type : event,
  23533. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  23534. cur = tmp = elem = elem || document;
  23535. // Don't do events on text and comment nodes
  23536. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  23537. return;
  23538. }
  23539. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  23540. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  23541. return;
  23542. }
  23543. if ( type.indexOf( "." ) > -1 ) {
  23544. // Namespaced trigger; create a regexp to match event type in handle()
  23545. namespaces = type.split( "." );
  23546. type = namespaces.shift();
  23547. namespaces.sort();
  23548. }
  23549. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  23550. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  23551. event = event[ jQuery.expando ] ?
  23552. event :
  23553. new jQuery.Event( type, typeof event === "object" && event );
  23554. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  23555. event.isTrigger = onlyHandlers ? 2 : 3;
  23556. event.namespace = namespaces.join( "." );
  23557. event.rnamespace = event.namespace ?
  23558. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  23559. null;
  23560. // Clean up the event in case it is being reused
  23561. event.result = undefined;
  23562. if ( !event.target ) {
  23563. event.target = elem;
  23564. }
  23565. // Clone any incoming data and prepend the event, creating the handler arg list
  23566. data = data == null ?
  23567. [ event ] :
  23568. jQuery.makeArray( data, [ event ] );
  23569. // Allow special events to draw outside the lines
  23570. special = jQuery.event.special[ type ] || {};
  23571. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  23572. return;
  23573. }
  23574. // Determine event propagation path in advance, per W3C events spec (#9951)
  23575. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  23576. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  23577. bubbleType = special.delegateType || type;
  23578. if ( !rfocusMorph.test( bubbleType + type ) ) {
  23579. cur = cur.parentNode;
  23580. }
  23581. for ( ; cur; cur = cur.parentNode ) {
  23582. eventPath.push( cur );
  23583. tmp = cur;
  23584. }
  23585. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  23586. if ( tmp === ( elem.ownerDocument || document ) ) {
  23587. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  23588. }
  23589. }
  23590. // Fire handlers on the event path
  23591. i = 0;
  23592. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  23593. event.type = i > 1 ?
  23594. bubbleType :
  23595. special.bindType || type;
  23596. // jQuery handler
  23597. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  23598. dataPriv.get( cur, "handle" );
  23599. if ( handle ) {
  23600. handle.apply( cur, data );
  23601. }
  23602. // Native handler
  23603. handle = ontype && cur[ ontype ];
  23604. if ( handle && handle.apply && acceptData( cur ) ) {
  23605. event.result = handle.apply( cur, data );
  23606. if ( event.result === false ) {
  23607. event.preventDefault();
  23608. }
  23609. }
  23610. }
  23611. event.type = type;
  23612. // If nobody prevented the default action, do it now
  23613. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  23614. if ( ( !special._default ||
  23615. special._default.apply( eventPath.pop(), data ) === false ) &&
  23616. acceptData( elem ) ) {
  23617. // Call a native DOM method on the target with the same name as the event.
  23618. // Don't do default actions on window, that's where global variables be (#6170)
  23619. if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
  23620. // Don't re-trigger an onFOO event when we call its FOO() method
  23621. tmp = elem[ ontype ];
  23622. if ( tmp ) {
  23623. elem[ ontype ] = null;
  23624. }
  23625. // Prevent re-triggering of the same event, since we already bubbled it above
  23626. jQuery.event.triggered = type;
  23627. elem[ type ]();
  23628. jQuery.event.triggered = undefined;
  23629. if ( tmp ) {
  23630. elem[ ontype ] = tmp;
  23631. }
  23632. }
  23633. }
  23634. }
  23635. return event.result;
  23636. },
  23637. // Piggyback on a donor event to simulate a different one
  23638. // Used only for `focus(in | out)` events
  23639. simulate: function( type, elem, event ) {
  23640. var e = jQuery.extend(
  23641. new jQuery.Event(),
  23642. event,
  23643. {
  23644. type: type,
  23645. isSimulated: true
  23646. }
  23647. );
  23648. jQuery.event.trigger( e, null, elem );
  23649. }
  23650. } );
  23651. jQuery.fn.extend( {
  23652. trigger: function( type, data ) {
  23653. return this.each( function() {
  23654. jQuery.event.trigger( type, data, this );
  23655. } );
  23656. },
  23657. triggerHandler: function( type, data ) {
  23658. var elem = this[ 0 ];
  23659. if ( elem ) {
  23660. return jQuery.event.trigger( type, data, elem, true );
  23661. }
  23662. }
  23663. } );
  23664. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  23665. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  23666. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  23667. function( i, name ) {
  23668. // Handle event binding
  23669. jQuery.fn[ name ] = function( data, fn ) {
  23670. return arguments.length > 0 ?
  23671. this.on( name, null, data, fn ) :
  23672. this.trigger( name );
  23673. };
  23674. } );
  23675. jQuery.fn.extend( {
  23676. hover: function( fnOver, fnOut ) {
  23677. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  23678. }
  23679. } );
  23680. support.focusin = "onfocusin" in window;
  23681. // Support: Firefox <=44
  23682. // Firefox doesn't have focus(in | out) events
  23683. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  23684. //
  23685. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  23686. // focus(in | out) events fire after focus & blur events,
  23687. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  23688. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  23689. if ( !support.focusin ) {
  23690. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  23691. // Attach a single capturing handler on the document while someone wants focusin/focusout
  23692. var handler = function( event ) {
  23693. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  23694. };
  23695. jQuery.event.special[ fix ] = {
  23696. setup: function() {
  23697. var doc = this.ownerDocument || this,
  23698. attaches = dataPriv.access( doc, fix );
  23699. if ( !attaches ) {
  23700. doc.addEventListener( orig, handler, true );
  23701. }
  23702. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  23703. },
  23704. teardown: function() {
  23705. var doc = this.ownerDocument || this,
  23706. attaches = dataPriv.access( doc, fix ) - 1;
  23707. if ( !attaches ) {
  23708. doc.removeEventListener( orig, handler, true );
  23709. dataPriv.remove( doc, fix );
  23710. } else {
  23711. dataPriv.access( doc, fix, attaches );
  23712. }
  23713. }
  23714. };
  23715. } );
  23716. }
  23717. var location = window.location;
  23718. var nonce = jQuery.now();
  23719. var rquery = ( /\?/ );
  23720. // Cross-browser xml parsing
  23721. jQuery.parseXML = function( data ) {
  23722. var xml;
  23723. if ( !data || typeof data !== "string" ) {
  23724. return null;
  23725. }
  23726. // Support: IE 9 - 11 only
  23727. // IE throws on parseFromString with invalid input.
  23728. try {
  23729. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  23730. } catch ( e ) {
  23731. xml = undefined;
  23732. }
  23733. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  23734. jQuery.error( "Invalid XML: " + data );
  23735. }
  23736. return xml;
  23737. };
  23738. var
  23739. rbracket = /\[\]$/,
  23740. rCRLF = /\r?\n/g,
  23741. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  23742. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  23743. function buildParams( prefix, obj, traditional, add ) {
  23744. var name;
  23745. if ( Array.isArray( obj ) ) {
  23746. // Serialize array item.
  23747. jQuery.each( obj, function( i, v ) {
  23748. if ( traditional || rbracket.test( prefix ) ) {
  23749. // Treat each array item as a scalar.
  23750. add( prefix, v );
  23751. } else {
  23752. // Item is non-scalar (array or object), encode its numeric index.
  23753. buildParams(
  23754. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  23755. v,
  23756. traditional,
  23757. add
  23758. );
  23759. }
  23760. } );
  23761. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  23762. // Serialize object item.
  23763. for ( name in obj ) {
  23764. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  23765. }
  23766. } else {
  23767. // Serialize scalar item.
  23768. add( prefix, obj );
  23769. }
  23770. }
  23771. // Serialize an array of form elements or a set of
  23772. // key/values into a query string
  23773. jQuery.param = function( a, traditional ) {
  23774. var prefix,
  23775. s = [],
  23776. add = function( key, valueOrFunction ) {
  23777. // If value is a function, invoke it and use its return value
  23778. var value = jQuery.isFunction( valueOrFunction ) ?
  23779. valueOrFunction() :
  23780. valueOrFunction;
  23781. s[ s.length ] = encodeURIComponent( key ) + "=" +
  23782. encodeURIComponent( value == null ? "" : value );
  23783. };
  23784. // If an array was passed in, assume that it is an array of form elements.
  23785. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  23786. // Serialize the form elements
  23787. jQuery.each( a, function() {
  23788. add( this.name, this.value );
  23789. } );
  23790. } else {
  23791. // If traditional, encode the "old" way (the way 1.3.2 or older
  23792. // did it), otherwise encode params recursively.
  23793. for ( prefix in a ) {
  23794. buildParams( prefix, a[ prefix ], traditional, add );
  23795. }
  23796. }
  23797. // Return the resulting serialization
  23798. return s.join( "&" );
  23799. };
  23800. jQuery.fn.extend( {
  23801. serialize: function() {
  23802. return jQuery.param( this.serializeArray() );
  23803. },
  23804. serializeArray: function() {
  23805. return this.map( function() {
  23806. // Can add propHook for "elements" to filter or add form elements
  23807. var elements = jQuery.prop( this, "elements" );
  23808. return elements ? jQuery.makeArray( elements ) : this;
  23809. } )
  23810. .filter( function() {
  23811. var type = this.type;
  23812. // Use .is( ":disabled" ) so that fieldset[disabled] works
  23813. return this.name && !jQuery( this ).is( ":disabled" ) &&
  23814. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  23815. ( this.checked || !rcheckableType.test( type ) );
  23816. } )
  23817. .map( function( i, elem ) {
  23818. var val = jQuery( this ).val();
  23819. if ( val == null ) {
  23820. return null;
  23821. }
  23822. if ( Array.isArray( val ) ) {
  23823. return jQuery.map( val, function( val ) {
  23824. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  23825. } );
  23826. }
  23827. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  23828. } ).get();
  23829. }
  23830. } );
  23831. var
  23832. r20 = /%20/g,
  23833. rhash = /#.*$/,
  23834. rantiCache = /([?&])_=[^&]*/,
  23835. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  23836. // #7653, #8125, #8152: local protocol detection
  23837. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  23838. rnoContent = /^(?:GET|HEAD)$/,
  23839. rprotocol = /^\/\//,
  23840. /* Prefilters
  23841. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  23842. * 2) These are called:
  23843. * - BEFORE asking for a transport
  23844. * - AFTER param serialization (s.data is a string if s.processData is true)
  23845. * 3) key is the dataType
  23846. * 4) the catchall symbol "*" can be used
  23847. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  23848. */
  23849. prefilters = {},
  23850. /* Transports bindings
  23851. * 1) key is the dataType
  23852. * 2) the catchall symbol "*" can be used
  23853. * 3) selection will start with transport dataType and THEN go to "*" if needed
  23854. */
  23855. transports = {},
  23856. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  23857. allTypes = "*/".concat( "*" ),
  23858. // Anchor tag for parsing the document origin
  23859. originAnchor = document.createElement( "a" );
  23860. originAnchor.href = location.href;
  23861. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  23862. function addToPrefiltersOrTransports( structure ) {
  23863. // dataTypeExpression is optional and defaults to "*"
  23864. return function( dataTypeExpression, func ) {
  23865. if ( typeof dataTypeExpression !== "string" ) {
  23866. func = dataTypeExpression;
  23867. dataTypeExpression = "*";
  23868. }
  23869. var dataType,
  23870. i = 0,
  23871. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  23872. if ( jQuery.isFunction( func ) ) {
  23873. // For each dataType in the dataTypeExpression
  23874. while ( ( dataType = dataTypes[ i++ ] ) ) {
  23875. // Prepend if requested
  23876. if ( dataType[ 0 ] === "+" ) {
  23877. dataType = dataType.slice( 1 ) || "*";
  23878. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  23879. // Otherwise append
  23880. } else {
  23881. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  23882. }
  23883. }
  23884. }
  23885. };
  23886. }
  23887. // Base inspection function for prefilters and transports
  23888. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  23889. var inspected = {},
  23890. seekingTransport = ( structure === transports );
  23891. function inspect( dataType ) {
  23892. var selected;
  23893. inspected[ dataType ] = true;
  23894. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  23895. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  23896. if ( typeof dataTypeOrTransport === "string" &&
  23897. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  23898. options.dataTypes.unshift( dataTypeOrTransport );
  23899. inspect( dataTypeOrTransport );
  23900. return false;
  23901. } else if ( seekingTransport ) {
  23902. return !( selected = dataTypeOrTransport );
  23903. }
  23904. } );
  23905. return selected;
  23906. }
  23907. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  23908. }
  23909. // A special extend for ajax options
  23910. // that takes "flat" options (not to be deep extended)
  23911. // Fixes #9887
  23912. function ajaxExtend( target, src ) {
  23913. var key, deep,
  23914. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  23915. for ( key in src ) {
  23916. if ( src[ key ] !== undefined ) {
  23917. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  23918. }
  23919. }
  23920. if ( deep ) {
  23921. jQuery.extend( true, target, deep );
  23922. }
  23923. return target;
  23924. }
  23925. /* Handles responses to an ajax request:
  23926. * - finds the right dataType (mediates between content-type and expected dataType)
  23927. * - returns the corresponding response
  23928. */
  23929. function ajaxHandleResponses( s, jqXHR, responses ) {
  23930. var ct, type, finalDataType, firstDataType,
  23931. contents = s.contents,
  23932. dataTypes = s.dataTypes;
  23933. // Remove auto dataType and get content-type in the process
  23934. while ( dataTypes[ 0 ] === "*" ) {
  23935. dataTypes.shift();
  23936. if ( ct === undefined ) {
  23937. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  23938. }
  23939. }
  23940. // Check if we're dealing with a known content-type
  23941. if ( ct ) {
  23942. for ( type in contents ) {
  23943. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  23944. dataTypes.unshift( type );
  23945. break;
  23946. }
  23947. }
  23948. }
  23949. // Check to see if we have a response for the expected dataType
  23950. if ( dataTypes[ 0 ] in responses ) {
  23951. finalDataType = dataTypes[ 0 ];
  23952. } else {
  23953. // Try convertible dataTypes
  23954. for ( type in responses ) {
  23955. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  23956. finalDataType = type;
  23957. break;
  23958. }
  23959. if ( !firstDataType ) {
  23960. firstDataType = type;
  23961. }
  23962. }
  23963. // Or just use first one
  23964. finalDataType = finalDataType || firstDataType;
  23965. }
  23966. // If we found a dataType
  23967. // We add the dataType to the list if needed
  23968. // and return the corresponding response
  23969. if ( finalDataType ) {
  23970. if ( finalDataType !== dataTypes[ 0 ] ) {
  23971. dataTypes.unshift( finalDataType );
  23972. }
  23973. return responses[ finalDataType ];
  23974. }
  23975. }
  23976. /* Chain conversions given the request and the original response
  23977. * Also sets the responseXXX fields on the jqXHR instance
  23978. */
  23979. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  23980. var conv2, current, conv, tmp, prev,
  23981. converters = {},
  23982. // Work with a copy of dataTypes in case we need to modify it for conversion
  23983. dataTypes = s.dataTypes.slice();
  23984. // Create converters map with lowercased keys
  23985. if ( dataTypes[ 1 ] ) {
  23986. for ( conv in s.converters ) {
  23987. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  23988. }
  23989. }
  23990. current = dataTypes.shift();
  23991. // Convert to each sequential dataType
  23992. while ( current ) {
  23993. if ( s.responseFields[ current ] ) {
  23994. jqXHR[ s.responseFields[ current ] ] = response;
  23995. }
  23996. // Apply the dataFilter if provided
  23997. if ( !prev && isSuccess && s.dataFilter ) {
  23998. response = s.dataFilter( response, s.dataType );
  23999. }
  24000. prev = current;
  24001. current = dataTypes.shift();
  24002. if ( current ) {
  24003. // There's only work to do if current dataType is non-auto
  24004. if ( current === "*" ) {
  24005. current = prev;
  24006. // Convert response if prev dataType is non-auto and differs from current
  24007. } else if ( prev !== "*" && prev !== current ) {
  24008. // Seek a direct converter
  24009. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  24010. // If none found, seek a pair
  24011. if ( !conv ) {
  24012. for ( conv2 in converters ) {
  24013. // If conv2 outputs current
  24014. tmp = conv2.split( " " );
  24015. if ( tmp[ 1 ] === current ) {
  24016. // If prev can be converted to accepted input
  24017. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  24018. converters[ "* " + tmp[ 0 ] ];
  24019. if ( conv ) {
  24020. // Condense equivalence converters
  24021. if ( conv === true ) {
  24022. conv = converters[ conv2 ];
  24023. // Otherwise, insert the intermediate dataType
  24024. } else if ( converters[ conv2 ] !== true ) {
  24025. current = tmp[ 0 ];
  24026. dataTypes.unshift( tmp[ 1 ] );
  24027. }
  24028. break;
  24029. }
  24030. }
  24031. }
  24032. }
  24033. // Apply converter (if not an equivalence)
  24034. if ( conv !== true ) {
  24035. // Unless errors are allowed to bubble, catch and return them
  24036. if ( conv && s.throws ) {
  24037. response = conv( response );
  24038. } else {
  24039. try {
  24040. response = conv( response );
  24041. } catch ( e ) {
  24042. return {
  24043. state: "parsererror",
  24044. error: conv ? e : "No conversion from " + prev + " to " + current
  24045. };
  24046. }
  24047. }
  24048. }
  24049. }
  24050. }
  24051. }
  24052. return { state: "success", data: response };
  24053. }
  24054. jQuery.extend( {
  24055. // Counter for holding the number of active queries
  24056. active: 0,
  24057. // Last-Modified header cache for next request
  24058. lastModified: {},
  24059. etag: {},
  24060. ajaxSettings: {
  24061. url: location.href,
  24062. type: "GET",
  24063. isLocal: rlocalProtocol.test( location.protocol ),
  24064. global: true,
  24065. processData: true,
  24066. async: true,
  24067. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  24068. /*
  24069. timeout: 0,
  24070. data: null,
  24071. dataType: null,
  24072. username: null,
  24073. password: null,
  24074. cache: null,
  24075. throws: false,
  24076. traditional: false,
  24077. headers: {},
  24078. */
  24079. accepts: {
  24080. "*": allTypes,
  24081. text: "text/plain",
  24082. html: "text/html",
  24083. xml: "application/xml, text/xml",
  24084. json: "application/json, text/javascript"
  24085. },
  24086. contents: {
  24087. xml: /\bxml\b/,
  24088. html: /\bhtml/,
  24089. json: /\bjson\b/
  24090. },
  24091. responseFields: {
  24092. xml: "responseXML",
  24093. text: "responseText",
  24094. json: "responseJSON"
  24095. },
  24096. // Data converters
  24097. // Keys separate source (or catchall "*") and destination types with a single space
  24098. converters: {
  24099. // Convert anything to text
  24100. "* text": String,
  24101. // Text to html (true = no transformation)
  24102. "text html": true,
  24103. // Evaluate text as a json expression
  24104. "text json": JSON.parse,
  24105. // Parse text as xml
  24106. "text xml": jQuery.parseXML
  24107. },
  24108. // For options that shouldn't be deep extended:
  24109. // you can add your own custom options here if
  24110. // and when you create one that shouldn't be
  24111. // deep extended (see ajaxExtend)
  24112. flatOptions: {
  24113. url: true,
  24114. context: true
  24115. }
  24116. },
  24117. // Creates a full fledged settings object into target
  24118. // with both ajaxSettings and settings fields.
  24119. // If target is omitted, writes into ajaxSettings.
  24120. ajaxSetup: function( target, settings ) {
  24121. return settings ?
  24122. // Building a settings object
  24123. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  24124. // Extending ajaxSettings
  24125. ajaxExtend( jQuery.ajaxSettings, target );
  24126. },
  24127. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  24128. ajaxTransport: addToPrefiltersOrTransports( transports ),
  24129. // Main method
  24130. ajax: function( url, options ) {
  24131. // If url is an object, simulate pre-1.5 signature
  24132. if ( typeof url === "object" ) {
  24133. options = url;
  24134. url = undefined;
  24135. }
  24136. // Force options to be an object
  24137. options = options || {};
  24138. var transport,
  24139. // URL without anti-cache param
  24140. cacheURL,
  24141. // Response headers
  24142. responseHeadersString,
  24143. responseHeaders,
  24144. // timeout handle
  24145. timeoutTimer,
  24146. // Url cleanup var
  24147. urlAnchor,
  24148. // Request state (becomes false upon send and true upon completion)
  24149. completed,
  24150. // To know if global events are to be dispatched
  24151. fireGlobals,
  24152. // Loop variable
  24153. i,
  24154. // uncached part of the url
  24155. uncached,
  24156. // Create the final options object
  24157. s = jQuery.ajaxSetup( {}, options ),
  24158. // Callbacks context
  24159. callbackContext = s.context || s,
  24160. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  24161. globalEventContext = s.context &&
  24162. ( callbackContext.nodeType || callbackContext.jquery ) ?
  24163. jQuery( callbackContext ) :
  24164. jQuery.event,
  24165. // Deferreds
  24166. deferred = jQuery.Deferred(),
  24167. completeDeferred = jQuery.Callbacks( "once memory" ),
  24168. // Status-dependent callbacks
  24169. statusCode = s.statusCode || {},
  24170. // Headers (they are sent all at once)
  24171. requestHeaders = {},
  24172. requestHeadersNames = {},
  24173. // Default abort message
  24174. strAbort = "canceled",
  24175. // Fake xhr
  24176. jqXHR = {
  24177. readyState: 0,
  24178. // Builds headers hashtable if needed
  24179. getResponseHeader: function( key ) {
  24180. var match;
  24181. if ( completed ) {
  24182. if ( !responseHeaders ) {
  24183. responseHeaders = {};
  24184. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  24185. responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
  24186. }
  24187. }
  24188. match = responseHeaders[ key.toLowerCase() ];
  24189. }
  24190. return match == null ? null : match;
  24191. },
  24192. // Raw string
  24193. getAllResponseHeaders: function() {
  24194. return completed ? responseHeadersString : null;
  24195. },
  24196. // Caches the header
  24197. setRequestHeader: function( name, value ) {
  24198. if ( completed == null ) {
  24199. name = requestHeadersNames[ name.toLowerCase() ] =
  24200. requestHeadersNames[ name.toLowerCase() ] || name;
  24201. requestHeaders[ name ] = value;
  24202. }
  24203. return this;
  24204. },
  24205. // Overrides response content-type header
  24206. overrideMimeType: function( type ) {
  24207. if ( completed == null ) {
  24208. s.mimeType = type;
  24209. }
  24210. return this;
  24211. },
  24212. // Status-dependent callbacks
  24213. statusCode: function( map ) {
  24214. var code;
  24215. if ( map ) {
  24216. if ( completed ) {
  24217. // Execute the appropriate callbacks
  24218. jqXHR.always( map[ jqXHR.status ] );
  24219. } else {
  24220. // Lazy-add the new callbacks in a way that preserves old ones
  24221. for ( code in map ) {
  24222. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  24223. }
  24224. }
  24225. }
  24226. return this;
  24227. },
  24228. // Cancel the request
  24229. abort: function( statusText ) {
  24230. var finalText = statusText || strAbort;
  24231. if ( transport ) {
  24232. transport.abort( finalText );
  24233. }
  24234. done( 0, finalText );
  24235. return this;
  24236. }
  24237. };
  24238. // Attach deferreds
  24239. deferred.promise( jqXHR );
  24240. // Add protocol if not provided (prefilters might expect it)
  24241. // Handle falsy url in the settings object (#10093: consistency with old signature)
  24242. // We also use the url parameter if available
  24243. s.url = ( ( url || s.url || location.href ) + "" )
  24244. .replace( rprotocol, location.protocol + "//" );
  24245. // Alias method option to type as per ticket #12004
  24246. s.type = options.method || options.type || s.method || s.type;
  24247. // Extract dataTypes list
  24248. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  24249. // A cross-domain request is in order when the origin doesn't match the current origin.
  24250. if ( s.crossDomain == null ) {
  24251. urlAnchor = document.createElement( "a" );
  24252. // Support: IE <=8 - 11, Edge 12 - 13
  24253. // IE throws exception on accessing the href property if url is malformed,
  24254. // e.g. http://example.com:80x/
  24255. try {
  24256. urlAnchor.href = s.url;
  24257. // Support: IE <=8 - 11 only
  24258. // Anchor's host property isn't correctly set when s.url is relative
  24259. urlAnchor.href = urlAnchor.href;
  24260. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  24261. urlAnchor.protocol + "//" + urlAnchor.host;
  24262. } catch ( e ) {
  24263. // If there is an error parsing the URL, assume it is crossDomain,
  24264. // it can be rejected by the transport if it is invalid
  24265. s.crossDomain = true;
  24266. }
  24267. }
  24268. // Convert data if not already a string
  24269. if ( s.data && s.processData && typeof s.data !== "string" ) {
  24270. s.data = jQuery.param( s.data, s.traditional );
  24271. }
  24272. // Apply prefilters
  24273. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  24274. // If request was aborted inside a prefilter, stop there
  24275. if ( completed ) {
  24276. return jqXHR;
  24277. }
  24278. // We can fire global events as of now if asked to
  24279. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  24280. fireGlobals = jQuery.event && s.global;
  24281. // Watch for a new set of requests
  24282. if ( fireGlobals && jQuery.active++ === 0 ) {
  24283. jQuery.event.trigger( "ajaxStart" );
  24284. }
  24285. // Uppercase the type
  24286. s.type = s.type.toUpperCase();
  24287. // Determine if request has content
  24288. s.hasContent = !rnoContent.test( s.type );
  24289. // Save the URL in case we're toying with the If-Modified-Since
  24290. // and/or If-None-Match header later on
  24291. // Remove hash to simplify url manipulation
  24292. cacheURL = s.url.replace( rhash, "" );
  24293. // More options handling for requests with no content
  24294. if ( !s.hasContent ) {
  24295. // Remember the hash so we can put it back
  24296. uncached = s.url.slice( cacheURL.length );
  24297. // If data is available, append data to url
  24298. if ( s.data ) {
  24299. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  24300. // #9682: remove data so that it's not used in an eventual retry
  24301. delete s.data;
  24302. }
  24303. // Add or update anti-cache param if needed
  24304. if ( s.cache === false ) {
  24305. cacheURL = cacheURL.replace( rantiCache, "$1" );
  24306. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  24307. }
  24308. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  24309. s.url = cacheURL + uncached;
  24310. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  24311. } else if ( s.data && s.processData &&
  24312. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  24313. s.data = s.data.replace( r20, "+" );
  24314. }
  24315. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  24316. if ( s.ifModified ) {
  24317. if ( jQuery.lastModified[ cacheURL ] ) {
  24318. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  24319. }
  24320. if ( jQuery.etag[ cacheURL ] ) {
  24321. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  24322. }
  24323. }
  24324. // Set the correct header, if data is being sent
  24325. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  24326. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  24327. }
  24328. // Set the Accepts header for the server, depending on the dataType
  24329. jqXHR.setRequestHeader(
  24330. "Accept",
  24331. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  24332. s.accepts[ s.dataTypes[ 0 ] ] +
  24333. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  24334. s.accepts[ "*" ]
  24335. );
  24336. // Check for headers option
  24337. for ( i in s.headers ) {
  24338. jqXHR.setRequestHeader( i, s.headers[ i ] );
  24339. }
  24340. // Allow custom headers/mimetypes and early abort
  24341. if ( s.beforeSend &&
  24342. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  24343. // Abort if not done already and return
  24344. return jqXHR.abort();
  24345. }
  24346. // Aborting is no longer a cancellation
  24347. strAbort = "abort";
  24348. // Install callbacks on deferreds
  24349. completeDeferred.add( s.complete );
  24350. jqXHR.done( s.success );
  24351. jqXHR.fail( s.error );
  24352. // Get transport
  24353. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  24354. // If no transport, we auto-abort
  24355. if ( !transport ) {
  24356. done( -1, "No Transport" );
  24357. } else {
  24358. jqXHR.readyState = 1;
  24359. // Send global event
  24360. if ( fireGlobals ) {
  24361. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  24362. }
  24363. // If request was aborted inside ajaxSend, stop there
  24364. if ( completed ) {
  24365. return jqXHR;
  24366. }
  24367. // Timeout
  24368. if ( s.async && s.timeout > 0 ) {
  24369. timeoutTimer = window.setTimeout( function() {
  24370. jqXHR.abort( "timeout" );
  24371. }, s.timeout );
  24372. }
  24373. try {
  24374. completed = false;
  24375. transport.send( requestHeaders, done );
  24376. } catch ( e ) {
  24377. // Rethrow post-completion exceptions
  24378. if ( completed ) {
  24379. throw e;
  24380. }
  24381. // Propagate others as results
  24382. done( -1, e );
  24383. }
  24384. }
  24385. // Callback for when everything is done
  24386. function done( status, nativeStatusText, responses, headers ) {
  24387. var isSuccess, success, error, response, modified,
  24388. statusText = nativeStatusText;
  24389. // Ignore repeat invocations
  24390. if ( completed ) {
  24391. return;
  24392. }
  24393. completed = true;
  24394. // Clear timeout if it exists
  24395. if ( timeoutTimer ) {
  24396. window.clearTimeout( timeoutTimer );
  24397. }
  24398. // Dereference transport for early garbage collection
  24399. // (no matter how long the jqXHR object will be used)
  24400. transport = undefined;
  24401. // Cache response headers
  24402. responseHeadersString = headers || "";
  24403. // Set readyState
  24404. jqXHR.readyState = status > 0 ? 4 : 0;
  24405. // Determine if successful
  24406. isSuccess = status >= 200 && status < 300 || status === 304;
  24407. // Get response data
  24408. if ( responses ) {
  24409. response = ajaxHandleResponses( s, jqXHR, responses );
  24410. }
  24411. // Convert no matter what (that way responseXXX fields are always set)
  24412. response = ajaxConvert( s, response, jqXHR, isSuccess );
  24413. // If successful, handle type chaining
  24414. if ( isSuccess ) {
  24415. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  24416. if ( s.ifModified ) {
  24417. modified = jqXHR.getResponseHeader( "Last-Modified" );
  24418. if ( modified ) {
  24419. jQuery.lastModified[ cacheURL ] = modified;
  24420. }
  24421. modified = jqXHR.getResponseHeader( "etag" );
  24422. if ( modified ) {
  24423. jQuery.etag[ cacheURL ] = modified;
  24424. }
  24425. }
  24426. // if no content
  24427. if ( status === 204 || s.type === "HEAD" ) {
  24428. statusText = "nocontent";
  24429. // if not modified
  24430. } else if ( status === 304 ) {
  24431. statusText = "notmodified";
  24432. // If we have data, let's convert it
  24433. } else {
  24434. statusText = response.state;
  24435. success = response.data;
  24436. error = response.error;
  24437. isSuccess = !error;
  24438. }
  24439. } else {
  24440. // Extract error from statusText and normalize for non-aborts
  24441. error = statusText;
  24442. if ( status || !statusText ) {
  24443. statusText = "error";
  24444. if ( status < 0 ) {
  24445. status = 0;
  24446. }
  24447. }
  24448. }
  24449. // Set data for the fake xhr object
  24450. jqXHR.status = status;
  24451. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  24452. // Success/Error
  24453. if ( isSuccess ) {
  24454. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  24455. } else {
  24456. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  24457. }
  24458. // Status-dependent callbacks
  24459. jqXHR.statusCode( statusCode );
  24460. statusCode = undefined;
  24461. if ( fireGlobals ) {
  24462. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  24463. [ jqXHR, s, isSuccess ? success : error ] );
  24464. }
  24465. // Complete
  24466. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  24467. if ( fireGlobals ) {
  24468. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  24469. // Handle the global AJAX counter
  24470. if ( !( --jQuery.active ) ) {
  24471. jQuery.event.trigger( "ajaxStop" );
  24472. }
  24473. }
  24474. }
  24475. return jqXHR;
  24476. },
  24477. getJSON: function( url, data, callback ) {
  24478. return jQuery.get( url, data, callback, "json" );
  24479. },
  24480. getScript: function( url, callback ) {
  24481. return jQuery.get( url, undefined, callback, "script" );
  24482. }
  24483. } );
  24484. jQuery.each( [ "get", "post" ], function( i, method ) {
  24485. jQuery[ method ] = function( url, data, callback, type ) {
  24486. // Shift arguments if data argument was omitted
  24487. if ( jQuery.isFunction( data ) ) {
  24488. type = type || callback;
  24489. callback = data;
  24490. data = undefined;
  24491. }
  24492. // The url can be an options object (which then must have .url)
  24493. return jQuery.ajax( jQuery.extend( {
  24494. url: url,
  24495. type: method,
  24496. dataType: type,
  24497. data: data,
  24498. success: callback
  24499. }, jQuery.isPlainObject( url ) && url ) );
  24500. };
  24501. } );
  24502. jQuery._evalUrl = function( url ) {
  24503. return jQuery.ajax( {
  24504. url: url,
  24505. // Make this explicit, since user can override this through ajaxSetup (#11264)
  24506. type: "GET",
  24507. dataType: "script",
  24508. cache: true,
  24509. async: false,
  24510. global: false,
  24511. "throws": true
  24512. } );
  24513. };
  24514. jQuery.fn.extend( {
  24515. wrapAll: function( html ) {
  24516. var wrap;
  24517. if ( this[ 0 ] ) {
  24518. if ( jQuery.isFunction( html ) ) {
  24519. html = html.call( this[ 0 ] );
  24520. }
  24521. // The elements to wrap the target around
  24522. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  24523. if ( this[ 0 ].parentNode ) {
  24524. wrap.insertBefore( this[ 0 ] );
  24525. }
  24526. wrap.map( function() {
  24527. var elem = this;
  24528. while ( elem.firstElementChild ) {
  24529. elem = elem.firstElementChild;
  24530. }
  24531. return elem;
  24532. } ).append( this );
  24533. }
  24534. return this;
  24535. },
  24536. wrapInner: function( html ) {
  24537. if ( jQuery.isFunction( html ) ) {
  24538. return this.each( function( i ) {
  24539. jQuery( this ).wrapInner( html.call( this, i ) );
  24540. } );
  24541. }
  24542. return this.each( function() {
  24543. var self = jQuery( this ),
  24544. contents = self.contents();
  24545. if ( contents.length ) {
  24546. contents.wrapAll( html );
  24547. } else {
  24548. self.append( html );
  24549. }
  24550. } );
  24551. },
  24552. wrap: function( html ) {
  24553. var isFunction = jQuery.isFunction( html );
  24554. return this.each( function( i ) {
  24555. jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
  24556. } );
  24557. },
  24558. unwrap: function( selector ) {
  24559. this.parent( selector ).not( "body" ).each( function() {
  24560. jQuery( this ).replaceWith( this.childNodes );
  24561. } );
  24562. return this;
  24563. }
  24564. } );
  24565. jQuery.expr.pseudos.hidden = function( elem ) {
  24566. return !jQuery.expr.pseudos.visible( elem );
  24567. };
  24568. jQuery.expr.pseudos.visible = function( elem ) {
  24569. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  24570. };
  24571. jQuery.ajaxSettings.xhr = function() {
  24572. try {
  24573. return new window.XMLHttpRequest();
  24574. } catch ( e ) {}
  24575. };
  24576. var xhrSuccessStatus = {
  24577. // File protocol always yields status code 0, assume 200
  24578. 0: 200,
  24579. // Support: IE <=9 only
  24580. // #1450: sometimes IE returns 1223 when it should be 204
  24581. 1223: 204
  24582. },
  24583. xhrSupported = jQuery.ajaxSettings.xhr();
  24584. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  24585. support.ajax = xhrSupported = !!xhrSupported;
  24586. jQuery.ajaxTransport( function( options ) {
  24587. var callback, errorCallback;
  24588. // Cross domain only allowed if supported through XMLHttpRequest
  24589. if ( support.cors || xhrSupported && !options.crossDomain ) {
  24590. return {
  24591. send: function( headers, complete ) {
  24592. var i,
  24593. xhr = options.xhr();
  24594. xhr.open(
  24595. options.type,
  24596. options.url,
  24597. options.async,
  24598. options.username,
  24599. options.password
  24600. );
  24601. // Apply custom fields if provided
  24602. if ( options.xhrFields ) {
  24603. for ( i in options.xhrFields ) {
  24604. xhr[ i ] = options.xhrFields[ i ];
  24605. }
  24606. }
  24607. // Override mime type if needed
  24608. if ( options.mimeType && xhr.overrideMimeType ) {
  24609. xhr.overrideMimeType( options.mimeType );
  24610. }
  24611. // X-Requested-With header
  24612. // For cross-domain requests, seeing as conditions for a preflight are
  24613. // akin to a jigsaw puzzle, we simply never set it to be sure.
  24614. // (it can always be set on a per-request basis or even using ajaxSetup)
  24615. // For same-domain requests, won't change header if already provided.
  24616. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  24617. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  24618. }
  24619. // Set headers
  24620. for ( i in headers ) {
  24621. xhr.setRequestHeader( i, headers[ i ] );
  24622. }
  24623. // Callback
  24624. callback = function( type ) {
  24625. return function() {
  24626. if ( callback ) {
  24627. callback = errorCallback = xhr.onload =
  24628. xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
  24629. if ( type === "abort" ) {
  24630. xhr.abort();
  24631. } else if ( type === "error" ) {
  24632. // Support: IE <=9 only
  24633. // On a manual native abort, IE9 throws
  24634. // errors on any property access that is not readyState
  24635. if ( typeof xhr.status !== "number" ) {
  24636. complete( 0, "error" );
  24637. } else {
  24638. complete(
  24639. // File: protocol always yields status 0; see #8605, #14207
  24640. xhr.status,
  24641. xhr.statusText
  24642. );
  24643. }
  24644. } else {
  24645. complete(
  24646. xhrSuccessStatus[ xhr.status ] || xhr.status,
  24647. xhr.statusText,
  24648. // Support: IE <=9 only
  24649. // IE9 has no XHR2 but throws on binary (trac-11426)
  24650. // For XHR2 non-text, let the caller handle it (gh-2498)
  24651. ( xhr.responseType || "text" ) !== "text" ||
  24652. typeof xhr.responseText !== "string" ?
  24653. { binary: xhr.response } :
  24654. { text: xhr.responseText },
  24655. xhr.getAllResponseHeaders()
  24656. );
  24657. }
  24658. }
  24659. };
  24660. };
  24661. // Listen to events
  24662. xhr.onload = callback();
  24663. errorCallback = xhr.onerror = callback( "error" );
  24664. // Support: IE 9 only
  24665. // Use onreadystatechange to replace onabort
  24666. // to handle uncaught aborts
  24667. if ( xhr.onabort !== undefined ) {
  24668. xhr.onabort = errorCallback;
  24669. } else {
  24670. xhr.onreadystatechange = function() {
  24671. // Check readyState before timeout as it changes
  24672. if ( xhr.readyState === 4 ) {
  24673. // Allow onerror to be called first,
  24674. // but that will not handle a native abort
  24675. // Also, save errorCallback to a variable
  24676. // as xhr.onerror cannot be accessed
  24677. window.setTimeout( function() {
  24678. if ( callback ) {
  24679. errorCallback();
  24680. }
  24681. } );
  24682. }
  24683. };
  24684. }
  24685. // Create the abort callback
  24686. callback = callback( "abort" );
  24687. try {
  24688. // Do send the request (this may raise an exception)
  24689. xhr.send( options.hasContent && options.data || null );
  24690. } catch ( e ) {
  24691. // #14683: Only rethrow if this hasn't been notified as an error yet
  24692. if ( callback ) {
  24693. throw e;
  24694. }
  24695. }
  24696. },
  24697. abort: function() {
  24698. if ( callback ) {
  24699. callback();
  24700. }
  24701. }
  24702. };
  24703. }
  24704. } );
  24705. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  24706. jQuery.ajaxPrefilter( function( s ) {
  24707. if ( s.crossDomain ) {
  24708. s.contents.script = false;
  24709. }
  24710. } );
  24711. // Install script dataType
  24712. jQuery.ajaxSetup( {
  24713. accepts: {
  24714. script: "text/javascript, application/javascript, " +
  24715. "application/ecmascript, application/x-ecmascript"
  24716. },
  24717. contents: {
  24718. script: /\b(?:java|ecma)script\b/
  24719. },
  24720. converters: {
  24721. "text script": function( text ) {
  24722. jQuery.globalEval( text );
  24723. return text;
  24724. }
  24725. }
  24726. } );
  24727. // Handle cache's special case and crossDomain
  24728. jQuery.ajaxPrefilter( "script", function( s ) {
  24729. if ( s.cache === undefined ) {
  24730. s.cache = false;
  24731. }
  24732. if ( s.crossDomain ) {
  24733. s.type = "GET";
  24734. }
  24735. } );
  24736. // Bind script tag hack transport
  24737. jQuery.ajaxTransport( "script", function( s ) {
  24738. // This transport only deals with cross domain requests
  24739. if ( s.crossDomain ) {
  24740. var script, callback;
  24741. return {
  24742. send: function( _, complete ) {
  24743. script = jQuery( "<script>" ).prop( {
  24744. charset: s.scriptCharset,
  24745. src: s.url
  24746. } ).on(
  24747. "load error",
  24748. callback = function( evt ) {
  24749. script.remove();
  24750. callback = null;
  24751. if ( evt ) {
  24752. complete( evt.type === "error" ? 404 : 200, evt.type );
  24753. }
  24754. }
  24755. );
  24756. // Use native DOM manipulation to avoid our domManip AJAX trickery
  24757. document.head.appendChild( script[ 0 ] );
  24758. },
  24759. abort: function() {
  24760. if ( callback ) {
  24761. callback();
  24762. }
  24763. }
  24764. };
  24765. }
  24766. } );
  24767. var oldCallbacks = [],
  24768. rjsonp = /(=)\?(?=&|$)|\?\?/;
  24769. // Default jsonp settings
  24770. jQuery.ajaxSetup( {
  24771. jsonp: "callback",
  24772. jsonpCallback: function() {
  24773. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  24774. this[ callback ] = true;
  24775. return callback;
  24776. }
  24777. } );
  24778. // Detect, normalize options and install callbacks for jsonp requests
  24779. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  24780. var callbackName, overwritten, responseContainer,
  24781. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  24782. "url" :
  24783. typeof s.data === "string" &&
  24784. ( s.contentType || "" )
  24785. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  24786. rjsonp.test( s.data ) && "data"
  24787. );
  24788. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  24789. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  24790. // Get callback name, remembering preexisting value associated with it
  24791. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  24792. s.jsonpCallback() :
  24793. s.jsonpCallback;
  24794. // Insert callback into url or form data
  24795. if ( jsonProp ) {
  24796. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  24797. } else if ( s.jsonp !== false ) {
  24798. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  24799. }
  24800. // Use data converter to retrieve json after script execution
  24801. s.converters[ "script json" ] = function() {
  24802. if ( !responseContainer ) {
  24803. jQuery.error( callbackName + " was not called" );
  24804. }
  24805. return responseContainer[ 0 ];
  24806. };
  24807. // Force json dataType
  24808. s.dataTypes[ 0 ] = "json";
  24809. // Install callback
  24810. overwritten = window[ callbackName ];
  24811. window[ callbackName ] = function() {
  24812. responseContainer = arguments;
  24813. };
  24814. // Clean-up function (fires after converters)
  24815. jqXHR.always( function() {
  24816. // If previous value didn't exist - remove it
  24817. if ( overwritten === undefined ) {
  24818. jQuery( window ).removeProp( callbackName );
  24819. // Otherwise restore preexisting value
  24820. } else {
  24821. window[ callbackName ] = overwritten;
  24822. }
  24823. // Save back as free
  24824. if ( s[ callbackName ] ) {
  24825. // Make sure that re-using the options doesn't screw things around
  24826. s.jsonpCallback = originalSettings.jsonpCallback;
  24827. // Save the callback name for future use
  24828. oldCallbacks.push( callbackName );
  24829. }
  24830. // Call if it was a function and we have a response
  24831. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  24832. overwritten( responseContainer[ 0 ] );
  24833. }
  24834. responseContainer = overwritten = undefined;
  24835. } );
  24836. // Delegate to script
  24837. return "script";
  24838. }
  24839. } );
  24840. // Support: Safari 8 only
  24841. // In Safari 8 documents created via document.implementation.createHTMLDocument
  24842. // collapse sibling forms: the second one becomes a child of the first one.
  24843. // Because of that, this security measure has to be disabled in Safari 8.
  24844. // https://bugs.webkit.org/show_bug.cgi?id=137337
  24845. support.createHTMLDocument = ( function() {
  24846. var body = document.implementation.createHTMLDocument( "" ).body;
  24847. body.innerHTML = "<form></form><form></form>";
  24848. return body.childNodes.length === 2;
  24849. } )();
  24850. // Argument "data" should be string of html
  24851. // context (optional): If specified, the fragment will be created in this context,
  24852. // defaults to document
  24853. // keepScripts (optional): If true, will include scripts passed in the html string
  24854. jQuery.parseHTML = function( data, context, keepScripts ) {
  24855. if ( typeof data !== "string" ) {
  24856. return [];
  24857. }
  24858. if ( typeof context === "boolean" ) {
  24859. keepScripts = context;
  24860. context = false;
  24861. }
  24862. var base, parsed, scripts;
  24863. if ( !context ) {
  24864. // Stop scripts or inline event handlers from being executed immediately
  24865. // by using document.implementation
  24866. if ( support.createHTMLDocument ) {
  24867. context = document.implementation.createHTMLDocument( "" );
  24868. // Set the base href for the created document
  24869. // so any parsed elements with URLs
  24870. // are based on the document's URL (gh-2965)
  24871. base = context.createElement( "base" );
  24872. base.href = document.location.href;
  24873. context.head.appendChild( base );
  24874. } else {
  24875. context = document;
  24876. }
  24877. }
  24878. parsed = rsingleTag.exec( data );
  24879. scripts = !keepScripts && [];
  24880. // Single tag
  24881. if ( parsed ) {
  24882. return [ context.createElement( parsed[ 1 ] ) ];
  24883. }
  24884. parsed = buildFragment( [ data ], context, scripts );
  24885. if ( scripts && scripts.length ) {
  24886. jQuery( scripts ).remove();
  24887. }
  24888. return jQuery.merge( [], parsed.childNodes );
  24889. };
  24890. /**
  24891. * Load a url into a page
  24892. */
  24893. jQuery.fn.load = function( url, params, callback ) {
  24894. var selector, type, response,
  24895. self = this,
  24896. off = url.indexOf( " " );
  24897. if ( off > -1 ) {
  24898. selector = stripAndCollapse( url.slice( off ) );
  24899. url = url.slice( 0, off );
  24900. }
  24901. // If it's a function
  24902. if ( jQuery.isFunction( params ) ) {
  24903. // We assume that it's the callback
  24904. callback = params;
  24905. params = undefined;
  24906. // Otherwise, build a param string
  24907. } else if ( params && typeof params === "object" ) {
  24908. type = "POST";
  24909. }
  24910. // If we have elements to modify, make the request
  24911. if ( self.length > 0 ) {
  24912. jQuery.ajax( {
  24913. url: url,
  24914. // If "type" variable is undefined, then "GET" method will be used.
  24915. // Make value of this field explicit since
  24916. // user can override it through ajaxSetup method
  24917. type: type || "GET",
  24918. dataType: "html",
  24919. data: params
  24920. } ).done( function( responseText ) {
  24921. // Save response for use in complete callback
  24922. response = arguments;
  24923. self.html( selector ?
  24924. // If a selector was specified, locate the right elements in a dummy div
  24925. // Exclude scripts to avoid IE 'Permission Denied' errors
  24926. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  24927. // Otherwise use the full result
  24928. responseText );
  24929. // If the request succeeds, this function gets "data", "status", "jqXHR"
  24930. // but they are ignored because response was set above.
  24931. // If it fails, this function gets "jqXHR", "status", "error"
  24932. } ).always( callback && function( jqXHR, status ) {
  24933. self.each( function() {
  24934. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  24935. } );
  24936. } );
  24937. }
  24938. return this;
  24939. };
  24940. // Attach a bunch of functions for handling common AJAX events
  24941. jQuery.each( [
  24942. "ajaxStart",
  24943. "ajaxStop",
  24944. "ajaxComplete",
  24945. "ajaxError",
  24946. "ajaxSuccess",
  24947. "ajaxSend"
  24948. ], function( i, type ) {
  24949. jQuery.fn[ type ] = function( fn ) {
  24950. return this.on( type, fn );
  24951. };
  24952. } );
  24953. jQuery.expr.pseudos.animated = function( elem ) {
  24954. return jQuery.grep( jQuery.timers, function( fn ) {
  24955. return elem === fn.elem;
  24956. } ).length;
  24957. };
  24958. jQuery.offset = {
  24959. setOffset: function( elem, options, i ) {
  24960. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  24961. position = jQuery.css( elem, "position" ),
  24962. curElem = jQuery( elem ),
  24963. props = {};
  24964. // Set position first, in-case top/left are set even on static elem
  24965. if ( position === "static" ) {
  24966. elem.style.position = "relative";
  24967. }
  24968. curOffset = curElem.offset();
  24969. curCSSTop = jQuery.css( elem, "top" );
  24970. curCSSLeft = jQuery.css( elem, "left" );
  24971. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  24972. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  24973. // Need to be able to calculate position if either
  24974. // top or left is auto and position is either absolute or fixed
  24975. if ( calculatePosition ) {
  24976. curPosition = curElem.position();
  24977. curTop = curPosition.top;
  24978. curLeft = curPosition.left;
  24979. } else {
  24980. curTop = parseFloat( curCSSTop ) || 0;
  24981. curLeft = parseFloat( curCSSLeft ) || 0;
  24982. }
  24983. if ( jQuery.isFunction( options ) ) {
  24984. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  24985. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  24986. }
  24987. if ( options.top != null ) {
  24988. props.top = ( options.top - curOffset.top ) + curTop;
  24989. }
  24990. if ( options.left != null ) {
  24991. props.left = ( options.left - curOffset.left ) + curLeft;
  24992. }
  24993. if ( "using" in options ) {
  24994. options.using.call( elem, props );
  24995. } else {
  24996. curElem.css( props );
  24997. }
  24998. }
  24999. };
  25000. jQuery.fn.extend( {
  25001. offset: function( options ) {
  25002. // Preserve chaining for setter
  25003. if ( arguments.length ) {
  25004. return options === undefined ?
  25005. this :
  25006. this.each( function( i ) {
  25007. jQuery.offset.setOffset( this, options, i );
  25008. } );
  25009. }
  25010. var doc, docElem, rect, win,
  25011. elem = this[ 0 ];
  25012. if ( !elem ) {
  25013. return;
  25014. }
  25015. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  25016. // Support: IE <=11 only
  25017. // Running getBoundingClientRect on a
  25018. // disconnected node in IE throws an error
  25019. if ( !elem.getClientRects().length ) {
  25020. return { top: 0, left: 0 };
  25021. }
  25022. rect = elem.getBoundingClientRect();
  25023. doc = elem.ownerDocument;
  25024. docElem = doc.documentElement;
  25025. win = doc.defaultView;
  25026. return {
  25027. top: rect.top + win.pageYOffset - docElem.clientTop,
  25028. left: rect.left + win.pageXOffset - docElem.clientLeft
  25029. };
  25030. },
  25031. position: function() {
  25032. if ( !this[ 0 ] ) {
  25033. return;
  25034. }
  25035. var offsetParent, offset,
  25036. elem = this[ 0 ],
  25037. parentOffset = { top: 0, left: 0 };
  25038. // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
  25039. // because it is its only offset parent
  25040. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  25041. // Assume getBoundingClientRect is there when computed position is fixed
  25042. offset = elem.getBoundingClientRect();
  25043. } else {
  25044. // Get *real* offsetParent
  25045. offsetParent = this.offsetParent();
  25046. // Get correct offsets
  25047. offset = this.offset();
  25048. if ( !nodeName( offsetParent[ 0 ], "html" ) ) {
  25049. parentOffset = offsetParent.offset();
  25050. }
  25051. // Add offsetParent borders
  25052. parentOffset = {
  25053. top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ),
  25054. left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true )
  25055. };
  25056. }
  25057. // Subtract parent offsets and element margins
  25058. return {
  25059. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  25060. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  25061. };
  25062. },
  25063. // This method will return documentElement in the following cases:
  25064. // 1) For the element inside the iframe without offsetParent, this method will return
  25065. // documentElement of the parent window
  25066. // 2) For the hidden or detached element
  25067. // 3) For body or html element, i.e. in case of the html node - it will return itself
  25068. //
  25069. // but those exceptions were never presented as a real life use-cases
  25070. // and might be considered as more preferable results.
  25071. //
  25072. // This logic, however, is not guaranteed and can change at any point in the future
  25073. offsetParent: function() {
  25074. return this.map( function() {
  25075. var offsetParent = this.offsetParent;
  25076. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  25077. offsetParent = offsetParent.offsetParent;
  25078. }
  25079. return offsetParent || documentElement;
  25080. } );
  25081. }
  25082. } );
  25083. // Create scrollLeft and scrollTop methods
  25084. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  25085. var top = "pageYOffset" === prop;
  25086. jQuery.fn[ method ] = function( val ) {
  25087. return access( this, function( elem, method, val ) {
  25088. // Coalesce documents and windows
  25089. var win;
  25090. if ( jQuery.isWindow( elem ) ) {
  25091. win = elem;
  25092. } else if ( elem.nodeType === 9 ) {
  25093. win = elem.defaultView;
  25094. }
  25095. if ( val === undefined ) {
  25096. return win ? win[ prop ] : elem[ method ];
  25097. }
  25098. if ( win ) {
  25099. win.scrollTo(
  25100. !top ? val : win.pageXOffset,
  25101. top ? val : win.pageYOffset
  25102. );
  25103. } else {
  25104. elem[ method ] = val;
  25105. }
  25106. }, method, val, arguments.length );
  25107. };
  25108. } );
  25109. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  25110. // Add the top/left cssHooks using jQuery.fn.position
  25111. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  25112. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  25113. // getComputedStyle returns percent when specified for top/left/bottom/right;
  25114. // rather than make the css module depend on the offset module, just check for it here
  25115. jQuery.each( [ "top", "left" ], function( i, prop ) {
  25116. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  25117. function( elem, computed ) {
  25118. if ( computed ) {
  25119. computed = curCSS( elem, prop );
  25120. // If curCSS returns percentage, fallback to offset
  25121. return rnumnonpx.test( computed ) ?
  25122. jQuery( elem ).position()[ prop ] + "px" :
  25123. computed;
  25124. }
  25125. }
  25126. );
  25127. } );
  25128. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  25129. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  25130. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  25131. function( defaultExtra, funcName ) {
  25132. // Margin is only for outerHeight, outerWidth
  25133. jQuery.fn[ funcName ] = function( margin, value ) {
  25134. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  25135. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  25136. return access( this, function( elem, type, value ) {
  25137. var doc;
  25138. if ( jQuery.isWindow( elem ) ) {
  25139. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  25140. return funcName.indexOf( "outer" ) === 0 ?
  25141. elem[ "inner" + name ] :
  25142. elem.document.documentElement[ "client" + name ];
  25143. }
  25144. // Get document width or height
  25145. if ( elem.nodeType === 9 ) {
  25146. doc = elem.documentElement;
  25147. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  25148. // whichever is greatest
  25149. return Math.max(
  25150. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  25151. elem.body[ "offset" + name ], doc[ "offset" + name ],
  25152. doc[ "client" + name ]
  25153. );
  25154. }
  25155. return value === undefined ?
  25156. // Get width or height on the element, requesting but not forcing parseFloat
  25157. jQuery.css( elem, type, extra ) :
  25158. // Set width or height on the element
  25159. jQuery.style( elem, type, value, extra );
  25160. }, type, chainable ? margin : undefined, chainable );
  25161. };
  25162. } );
  25163. } );
  25164. jQuery.fn.extend( {
  25165. bind: function( types, data, fn ) {
  25166. return this.on( types, null, data, fn );
  25167. },
  25168. unbind: function( types, fn ) {
  25169. return this.off( types, null, fn );
  25170. },
  25171. delegate: function( selector, types, data, fn ) {
  25172. return this.on( types, selector, data, fn );
  25173. },
  25174. undelegate: function( selector, types, fn ) {
  25175. // ( namespace ) or ( selector, types [, fn] )
  25176. return arguments.length === 1 ?
  25177. this.off( selector, "**" ) :
  25178. this.off( types, selector || "**", fn );
  25179. }
  25180. } );
  25181. jQuery.holdReady = function( hold ) {
  25182. if ( hold ) {
  25183. jQuery.readyWait++;
  25184. } else {
  25185. jQuery.ready( true );
  25186. }
  25187. };
  25188. jQuery.isArray = Array.isArray;
  25189. jQuery.parseJSON = JSON.parse;
  25190. jQuery.nodeName = nodeName;
  25191. // Register as a named AMD module, since jQuery can be concatenated with other
  25192. // files that may use define, but not via a proper concatenation script that
  25193. // understands anonymous AMD modules. A named AMD is safest and most robust
  25194. // way to register. Lowercase jquery is used because AMD module names are
  25195. // derived from file names, and jQuery is normally delivered in a lowercase
  25196. // file name. Do this after creating the global so that if an AMD module wants
  25197. // to call noConflict to hide this version of jQuery, it will work.
  25198. // Note that for maximum portability, libraries that are not jQuery should
  25199. // declare themselves as anonymous modules, and avoid setting a global if an
  25200. // AMD loader is present. jQuery is a special case. For more information, see
  25201. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  25202. if ( true ) {
  25203. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
  25204. return jQuery;
  25205. }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  25206. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  25207. }
  25208. var
  25209. // Map over jQuery in case of overwrite
  25210. _jQuery = window.jQuery,
  25211. // Map over the $ in case of overwrite
  25212. _$ = window.$;
  25213. jQuery.noConflict = function( deep ) {
  25214. if ( window.$ === jQuery ) {
  25215. window.$ = _$;
  25216. }
  25217. if ( deep && window.jQuery === jQuery ) {
  25218. window.jQuery = _jQuery;
  25219. }
  25220. return jQuery;
  25221. };
  25222. // Expose jQuery and $ identifiers, even in AMD
  25223. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  25224. // and CommonJS for browser emulators (#13566)
  25225. if ( !noGlobal ) {
  25226. window.jQuery = window.$ = jQuery;
  25227. }
  25228. return jQuery;
  25229. } );
  25230. /***/ }),
  25231. /* 15 */
  25232. /***/ (function(module, exports) {
  25233. /*!
  25234. * Bootstrap v3.3.7 (http://getbootstrap.com)
  25235. * Copyright 2011-2016 Twitter, Inc.
  25236. * Licensed under the MIT license
  25237. */
  25238. if (typeof jQuery === 'undefined') {
  25239. throw new Error('Bootstrap\'s JavaScript requires jQuery')
  25240. }
  25241. +function ($) {
  25242. 'use strict';
  25243. var version = $.fn.jquery.split(' ')[0].split('.')
  25244. if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 3)) {
  25245. throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4')
  25246. }
  25247. }(jQuery);
  25248. /* ========================================================================
  25249. * Bootstrap: transition.js v3.3.7
  25250. * http://getbootstrap.com/javascript/#transitions
  25251. * ========================================================================
  25252. * Copyright 2011-2016 Twitter, Inc.
  25253. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25254. * ======================================================================== */
  25255. +function ($) {
  25256. 'use strict';
  25257. // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  25258. // ============================================================
  25259. function transitionEnd() {
  25260. var el = document.createElement('bootstrap')
  25261. var transEndEventNames = {
  25262. WebkitTransition : 'webkitTransitionEnd',
  25263. MozTransition : 'transitionend',
  25264. OTransition : 'oTransitionEnd otransitionend',
  25265. transition : 'transitionend'
  25266. }
  25267. for (var name in transEndEventNames) {
  25268. if (el.style[name] !== undefined) {
  25269. return { end: transEndEventNames[name] }
  25270. }
  25271. }
  25272. return false // explicit for ie8 ( ._.)
  25273. }
  25274. // http://blog.alexmaccaw.com/css-transitions
  25275. $.fn.emulateTransitionEnd = function (duration) {
  25276. var called = false
  25277. var $el = this
  25278. $(this).one('bsTransitionEnd', function () { called = true })
  25279. var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
  25280. setTimeout(callback, duration)
  25281. return this
  25282. }
  25283. $(function () {
  25284. $.support.transition = transitionEnd()
  25285. if (!$.support.transition) return
  25286. $.event.special.bsTransitionEnd = {
  25287. bindType: $.support.transition.end,
  25288. delegateType: $.support.transition.end,
  25289. handle: function (e) {
  25290. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
  25291. }
  25292. }
  25293. })
  25294. }(jQuery);
  25295. /* ========================================================================
  25296. * Bootstrap: alert.js v3.3.7
  25297. * http://getbootstrap.com/javascript/#alerts
  25298. * ========================================================================
  25299. * Copyright 2011-2016 Twitter, Inc.
  25300. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25301. * ======================================================================== */
  25302. +function ($) {
  25303. 'use strict';
  25304. // ALERT CLASS DEFINITION
  25305. // ======================
  25306. var dismiss = '[data-dismiss="alert"]'
  25307. var Alert = function (el) {
  25308. $(el).on('click', dismiss, this.close)
  25309. }
  25310. Alert.VERSION = '3.3.7'
  25311. Alert.TRANSITION_DURATION = 150
  25312. Alert.prototype.close = function (e) {
  25313. var $this = $(this)
  25314. var selector = $this.attr('data-target')
  25315. if (!selector) {
  25316. selector = $this.attr('href')
  25317. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  25318. }
  25319. var $parent = $(selector === '#' ? [] : selector)
  25320. if (e) e.preventDefault()
  25321. if (!$parent.length) {
  25322. $parent = $this.closest('.alert')
  25323. }
  25324. $parent.trigger(e = $.Event('close.bs.alert'))
  25325. if (e.isDefaultPrevented()) return
  25326. $parent.removeClass('in')
  25327. function removeElement() {
  25328. // detach from parent, fire event then clean up data
  25329. $parent.detach().trigger('closed.bs.alert').remove()
  25330. }
  25331. $.support.transition && $parent.hasClass('fade') ?
  25332. $parent
  25333. .one('bsTransitionEnd', removeElement)
  25334. .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
  25335. removeElement()
  25336. }
  25337. // ALERT PLUGIN DEFINITION
  25338. // =======================
  25339. function Plugin(option) {
  25340. return this.each(function () {
  25341. var $this = $(this)
  25342. var data = $this.data('bs.alert')
  25343. if (!data) $this.data('bs.alert', (data = new Alert(this)))
  25344. if (typeof option == 'string') data[option].call($this)
  25345. })
  25346. }
  25347. var old = $.fn.alert
  25348. $.fn.alert = Plugin
  25349. $.fn.alert.Constructor = Alert
  25350. // ALERT NO CONFLICT
  25351. // =================
  25352. $.fn.alert.noConflict = function () {
  25353. $.fn.alert = old
  25354. return this
  25355. }
  25356. // ALERT DATA-API
  25357. // ==============
  25358. $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
  25359. }(jQuery);
  25360. /* ========================================================================
  25361. * Bootstrap: button.js v3.3.7
  25362. * http://getbootstrap.com/javascript/#buttons
  25363. * ========================================================================
  25364. * Copyright 2011-2016 Twitter, Inc.
  25365. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25366. * ======================================================================== */
  25367. +function ($) {
  25368. 'use strict';
  25369. // BUTTON PUBLIC CLASS DEFINITION
  25370. // ==============================
  25371. var Button = function (element, options) {
  25372. this.$element = $(element)
  25373. this.options = $.extend({}, Button.DEFAULTS, options)
  25374. this.isLoading = false
  25375. }
  25376. Button.VERSION = '3.3.7'
  25377. Button.DEFAULTS = {
  25378. loadingText: 'loading...'
  25379. }
  25380. Button.prototype.setState = function (state) {
  25381. var d = 'disabled'
  25382. var $el = this.$element
  25383. var val = $el.is('input') ? 'val' : 'html'
  25384. var data = $el.data()
  25385. state += 'Text'
  25386. if (data.resetText == null) $el.data('resetText', $el[val]())
  25387. // push to event loop to allow forms to submit
  25388. setTimeout($.proxy(function () {
  25389. $el[val](data[state] == null ? this.options[state] : data[state])
  25390. if (state == 'loadingText') {
  25391. this.isLoading = true
  25392. $el.addClass(d).attr(d, d).prop(d, true)
  25393. } else if (this.isLoading) {
  25394. this.isLoading = false
  25395. $el.removeClass(d).removeAttr(d).prop(d, false)
  25396. }
  25397. }, this), 0)
  25398. }
  25399. Button.prototype.toggle = function () {
  25400. var changed = true
  25401. var $parent = this.$element.closest('[data-toggle="buttons"]')
  25402. if ($parent.length) {
  25403. var $input = this.$element.find('input')
  25404. if ($input.prop('type') == 'radio') {
  25405. if ($input.prop('checked')) changed = false
  25406. $parent.find('.active').removeClass('active')
  25407. this.$element.addClass('active')
  25408. } else if ($input.prop('type') == 'checkbox') {
  25409. if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
  25410. this.$element.toggleClass('active')
  25411. }
  25412. $input.prop('checked', this.$element.hasClass('active'))
  25413. if (changed) $input.trigger('change')
  25414. } else {
  25415. this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
  25416. this.$element.toggleClass('active')
  25417. }
  25418. }
  25419. // BUTTON PLUGIN DEFINITION
  25420. // ========================
  25421. function Plugin(option) {
  25422. return this.each(function () {
  25423. var $this = $(this)
  25424. var data = $this.data('bs.button')
  25425. var options = typeof option == 'object' && option
  25426. if (!data) $this.data('bs.button', (data = new Button(this, options)))
  25427. if (option == 'toggle') data.toggle()
  25428. else if (option) data.setState(option)
  25429. })
  25430. }
  25431. var old = $.fn.button
  25432. $.fn.button = Plugin
  25433. $.fn.button.Constructor = Button
  25434. // BUTTON NO CONFLICT
  25435. // ==================
  25436. $.fn.button.noConflict = function () {
  25437. $.fn.button = old
  25438. return this
  25439. }
  25440. // BUTTON DATA-API
  25441. // ===============
  25442. $(document)
  25443. .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
  25444. var $btn = $(e.target).closest('.btn')
  25445. Plugin.call($btn, 'toggle')
  25446. if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) {
  25447. // Prevent double click on radios, and the double selections (so cancellation) on checkboxes
  25448. e.preventDefault()
  25449. // The target component still receive the focus
  25450. if ($btn.is('input,button')) $btn.trigger('focus')
  25451. else $btn.find('input:visible,button:visible').first().trigger('focus')
  25452. }
  25453. })
  25454. .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
  25455. $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
  25456. })
  25457. }(jQuery);
  25458. /* ========================================================================
  25459. * Bootstrap: carousel.js v3.3.7
  25460. * http://getbootstrap.com/javascript/#carousel
  25461. * ========================================================================
  25462. * Copyright 2011-2016 Twitter, Inc.
  25463. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25464. * ======================================================================== */
  25465. +function ($) {
  25466. 'use strict';
  25467. // CAROUSEL CLASS DEFINITION
  25468. // =========================
  25469. var Carousel = function (element, options) {
  25470. this.$element = $(element)
  25471. this.$indicators = this.$element.find('.carousel-indicators')
  25472. this.options = options
  25473. this.paused = null
  25474. this.sliding = null
  25475. this.interval = null
  25476. this.$active = null
  25477. this.$items = null
  25478. this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
  25479. this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
  25480. .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
  25481. .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
  25482. }
  25483. Carousel.VERSION = '3.3.7'
  25484. Carousel.TRANSITION_DURATION = 600
  25485. Carousel.DEFAULTS = {
  25486. interval: 5000,
  25487. pause: 'hover',
  25488. wrap: true,
  25489. keyboard: true
  25490. }
  25491. Carousel.prototype.keydown = function (e) {
  25492. if (/input|textarea/i.test(e.target.tagName)) return
  25493. switch (e.which) {
  25494. case 37: this.prev(); break
  25495. case 39: this.next(); break
  25496. default: return
  25497. }
  25498. e.preventDefault()
  25499. }
  25500. Carousel.prototype.cycle = function (e) {
  25501. e || (this.paused = false)
  25502. this.interval && clearInterval(this.interval)
  25503. this.options.interval
  25504. && !this.paused
  25505. && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
  25506. return this
  25507. }
  25508. Carousel.prototype.getItemIndex = function (item) {
  25509. this.$items = item.parent().children('.item')
  25510. return this.$items.index(item || this.$active)
  25511. }
  25512. Carousel.prototype.getItemForDirection = function (direction, active) {
  25513. var activeIndex = this.getItemIndex(active)
  25514. var willWrap = (direction == 'prev' && activeIndex === 0)
  25515. || (direction == 'next' && activeIndex == (this.$items.length - 1))
  25516. if (willWrap && !this.options.wrap) return active
  25517. var delta = direction == 'prev' ? -1 : 1
  25518. var itemIndex = (activeIndex + delta) % this.$items.length
  25519. return this.$items.eq(itemIndex)
  25520. }
  25521. Carousel.prototype.to = function (pos) {
  25522. var that = this
  25523. var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
  25524. if (pos > (this.$items.length - 1) || pos < 0) return
  25525. if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
  25526. if (activeIndex == pos) return this.pause().cycle()
  25527. return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos))
  25528. }
  25529. Carousel.prototype.pause = function (e) {
  25530. e || (this.paused = true)
  25531. if (this.$element.find('.next, .prev').length && $.support.transition) {
  25532. this.$element.trigger($.support.transition.end)
  25533. this.cycle(true)
  25534. }
  25535. this.interval = clearInterval(this.interval)
  25536. return this
  25537. }
  25538. Carousel.prototype.next = function () {
  25539. if (this.sliding) return
  25540. return this.slide('next')
  25541. }
  25542. Carousel.prototype.prev = function () {
  25543. if (this.sliding) return
  25544. return this.slide('prev')
  25545. }
  25546. Carousel.prototype.slide = function (type, next) {
  25547. var $active = this.$element.find('.item.active')
  25548. var $next = next || this.getItemForDirection(type, $active)
  25549. var isCycling = this.interval
  25550. var direction = type == 'next' ? 'left' : 'right'
  25551. var that = this
  25552. if ($next.hasClass('active')) return (this.sliding = false)
  25553. var relatedTarget = $next[0]
  25554. var slideEvent = $.Event('slide.bs.carousel', {
  25555. relatedTarget: relatedTarget,
  25556. direction: direction
  25557. })
  25558. this.$element.trigger(slideEvent)
  25559. if (slideEvent.isDefaultPrevented()) return
  25560. this.sliding = true
  25561. isCycling && this.pause()
  25562. if (this.$indicators.length) {
  25563. this.$indicators.find('.active').removeClass('active')
  25564. var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
  25565. $nextIndicator && $nextIndicator.addClass('active')
  25566. }
  25567. var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
  25568. if ($.support.transition && this.$element.hasClass('slide')) {
  25569. $next.addClass(type)
  25570. $next[0].offsetWidth // force reflow
  25571. $active.addClass(direction)
  25572. $next.addClass(direction)
  25573. $active
  25574. .one('bsTransitionEnd', function () {
  25575. $next.removeClass([type, direction].join(' ')).addClass('active')
  25576. $active.removeClass(['active', direction].join(' '))
  25577. that.sliding = false
  25578. setTimeout(function () {
  25579. that.$element.trigger(slidEvent)
  25580. }, 0)
  25581. })
  25582. .emulateTransitionEnd(Carousel.TRANSITION_DURATION)
  25583. } else {
  25584. $active.removeClass('active')
  25585. $next.addClass('active')
  25586. this.sliding = false
  25587. this.$element.trigger(slidEvent)
  25588. }
  25589. isCycling && this.cycle()
  25590. return this
  25591. }
  25592. // CAROUSEL PLUGIN DEFINITION
  25593. // ==========================
  25594. function Plugin(option) {
  25595. return this.each(function () {
  25596. var $this = $(this)
  25597. var data = $this.data('bs.carousel')
  25598. var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
  25599. var action = typeof option == 'string' ? option : options.slide
  25600. if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
  25601. if (typeof option == 'number') data.to(option)
  25602. else if (action) data[action]()
  25603. else if (options.interval) data.pause().cycle()
  25604. })
  25605. }
  25606. var old = $.fn.carousel
  25607. $.fn.carousel = Plugin
  25608. $.fn.carousel.Constructor = Carousel
  25609. // CAROUSEL NO CONFLICT
  25610. // ====================
  25611. $.fn.carousel.noConflict = function () {
  25612. $.fn.carousel = old
  25613. return this
  25614. }
  25615. // CAROUSEL DATA-API
  25616. // =================
  25617. var clickHandler = function (e) {
  25618. var href
  25619. var $this = $(this)
  25620. var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
  25621. if (!$target.hasClass('carousel')) return
  25622. var options = $.extend({}, $target.data(), $this.data())
  25623. var slideIndex = $this.attr('data-slide-to')
  25624. if (slideIndex) options.interval = false
  25625. Plugin.call($target, options)
  25626. if (slideIndex) {
  25627. $target.data('bs.carousel').to(slideIndex)
  25628. }
  25629. e.preventDefault()
  25630. }
  25631. $(document)
  25632. .on('click.bs.carousel.data-api', '[data-slide]', clickHandler)
  25633. .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)
  25634. $(window).on('load', function () {
  25635. $('[data-ride="carousel"]').each(function () {
  25636. var $carousel = $(this)
  25637. Plugin.call($carousel, $carousel.data())
  25638. })
  25639. })
  25640. }(jQuery);
  25641. /* ========================================================================
  25642. * Bootstrap: collapse.js v3.3.7
  25643. * http://getbootstrap.com/javascript/#collapse
  25644. * ========================================================================
  25645. * Copyright 2011-2016 Twitter, Inc.
  25646. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25647. * ======================================================================== */
  25648. /* jshint latedef: false */
  25649. +function ($) {
  25650. 'use strict';
  25651. // COLLAPSE PUBLIC CLASS DEFINITION
  25652. // ================================
  25653. var Collapse = function (element, options) {
  25654. this.$element = $(element)
  25655. this.options = $.extend({}, Collapse.DEFAULTS, options)
  25656. this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
  25657. '[data-toggle="collapse"][data-target="#' + element.id + '"]')
  25658. this.transitioning = null
  25659. if (this.options.parent) {
  25660. this.$parent = this.getParent()
  25661. } else {
  25662. this.addAriaAndCollapsedClass(this.$element, this.$trigger)
  25663. }
  25664. if (this.options.toggle) this.toggle()
  25665. }
  25666. Collapse.VERSION = '3.3.7'
  25667. Collapse.TRANSITION_DURATION = 350
  25668. Collapse.DEFAULTS = {
  25669. toggle: true
  25670. }
  25671. Collapse.prototype.dimension = function () {
  25672. var hasWidth = this.$element.hasClass('width')
  25673. return hasWidth ? 'width' : 'height'
  25674. }
  25675. Collapse.prototype.show = function () {
  25676. if (this.transitioning || this.$element.hasClass('in')) return
  25677. var activesData
  25678. var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')
  25679. if (actives && actives.length) {
  25680. activesData = actives.data('bs.collapse')
  25681. if (activesData && activesData.transitioning) return
  25682. }
  25683. var startEvent = $.Event('show.bs.collapse')
  25684. this.$element.trigger(startEvent)
  25685. if (startEvent.isDefaultPrevented()) return
  25686. if (actives && actives.length) {
  25687. Plugin.call(actives, 'hide')
  25688. activesData || actives.data('bs.collapse', null)
  25689. }
  25690. var dimension = this.dimension()
  25691. this.$element
  25692. .removeClass('collapse')
  25693. .addClass('collapsing')[dimension](0)
  25694. .attr('aria-expanded', true)
  25695. this.$trigger
  25696. .removeClass('collapsed')
  25697. .attr('aria-expanded', true)
  25698. this.transitioning = 1
  25699. var complete = function () {
  25700. this.$element
  25701. .removeClass('collapsing')
  25702. .addClass('collapse in')[dimension]('')
  25703. this.transitioning = 0
  25704. this.$element
  25705. .trigger('shown.bs.collapse')
  25706. }
  25707. if (!$.support.transition) return complete.call(this)
  25708. var scrollSize = $.camelCase(['scroll', dimension].join('-'))
  25709. this.$element
  25710. .one('bsTransitionEnd', $.proxy(complete, this))
  25711. .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])
  25712. }
  25713. Collapse.prototype.hide = function () {
  25714. if (this.transitioning || !this.$element.hasClass('in')) return
  25715. var startEvent = $.Event('hide.bs.collapse')
  25716. this.$element.trigger(startEvent)
  25717. if (startEvent.isDefaultPrevented()) return
  25718. var dimension = this.dimension()
  25719. this.$element[dimension](this.$element[dimension]())[0].offsetHeight
  25720. this.$element
  25721. .addClass('collapsing')
  25722. .removeClass('collapse in')
  25723. .attr('aria-expanded', false)
  25724. this.$trigger
  25725. .addClass('collapsed')
  25726. .attr('aria-expanded', false)
  25727. this.transitioning = 1
  25728. var complete = function () {
  25729. this.transitioning = 0
  25730. this.$element
  25731. .removeClass('collapsing')
  25732. .addClass('collapse')
  25733. .trigger('hidden.bs.collapse')
  25734. }
  25735. if (!$.support.transition) return complete.call(this)
  25736. this.$element
  25737. [dimension](0)
  25738. .one('bsTransitionEnd', $.proxy(complete, this))
  25739. .emulateTransitionEnd(Collapse.TRANSITION_DURATION)
  25740. }
  25741. Collapse.prototype.toggle = function () {
  25742. this[this.$element.hasClass('in') ? 'hide' : 'show']()
  25743. }
  25744. Collapse.prototype.getParent = function () {
  25745. return $(this.options.parent)
  25746. .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]')
  25747. .each($.proxy(function (i, element) {
  25748. var $element = $(element)
  25749. this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)
  25750. }, this))
  25751. .end()
  25752. }
  25753. Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
  25754. var isOpen = $element.hasClass('in')
  25755. $element.attr('aria-expanded', isOpen)
  25756. $trigger
  25757. .toggleClass('collapsed', !isOpen)
  25758. .attr('aria-expanded', isOpen)
  25759. }
  25760. function getTargetFromTrigger($trigger) {
  25761. var href
  25762. var target = $trigger.attr('data-target')
  25763. || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
  25764. return $(target)
  25765. }
  25766. // COLLAPSE PLUGIN DEFINITION
  25767. // ==========================
  25768. function Plugin(option) {
  25769. return this.each(function () {
  25770. var $this = $(this)
  25771. var data = $this.data('bs.collapse')
  25772. var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
  25773. if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false
  25774. if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
  25775. if (typeof option == 'string') data[option]()
  25776. })
  25777. }
  25778. var old = $.fn.collapse
  25779. $.fn.collapse = Plugin
  25780. $.fn.collapse.Constructor = Collapse
  25781. // COLLAPSE NO CONFLICT
  25782. // ====================
  25783. $.fn.collapse.noConflict = function () {
  25784. $.fn.collapse = old
  25785. return this
  25786. }
  25787. // COLLAPSE DATA-API
  25788. // =================
  25789. $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
  25790. var $this = $(this)
  25791. if (!$this.attr('data-target')) e.preventDefault()
  25792. var $target = getTargetFromTrigger($this)
  25793. var data = $target.data('bs.collapse')
  25794. var option = data ? 'toggle' : $this.data()
  25795. Plugin.call($target, option)
  25796. })
  25797. }(jQuery);
  25798. /* ========================================================================
  25799. * Bootstrap: dropdown.js v3.3.7
  25800. * http://getbootstrap.com/javascript/#dropdowns
  25801. * ========================================================================
  25802. * Copyright 2011-2016 Twitter, Inc.
  25803. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25804. * ======================================================================== */
  25805. +function ($) {
  25806. 'use strict';
  25807. // DROPDOWN CLASS DEFINITION
  25808. // =========================
  25809. var backdrop = '.dropdown-backdrop'
  25810. var toggle = '[data-toggle="dropdown"]'
  25811. var Dropdown = function (element) {
  25812. $(element).on('click.bs.dropdown', this.toggle)
  25813. }
  25814. Dropdown.VERSION = '3.3.7'
  25815. function getParent($this) {
  25816. var selector = $this.attr('data-target')
  25817. if (!selector) {
  25818. selector = $this.attr('href')
  25819. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  25820. }
  25821. var $parent = selector && $(selector)
  25822. return $parent && $parent.length ? $parent : $this.parent()
  25823. }
  25824. function clearMenus(e) {
  25825. if (e && e.which === 3) return
  25826. $(backdrop).remove()
  25827. $(toggle).each(function () {
  25828. var $this = $(this)
  25829. var $parent = getParent($this)
  25830. var relatedTarget = { relatedTarget: this }
  25831. if (!$parent.hasClass('open')) return
  25832. if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
  25833. $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
  25834. if (e.isDefaultPrevented()) return
  25835. $this.attr('aria-expanded', 'false')
  25836. $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
  25837. })
  25838. }
  25839. Dropdown.prototype.toggle = function (e) {
  25840. var $this = $(this)
  25841. if ($this.is('.disabled, :disabled')) return
  25842. var $parent = getParent($this)
  25843. var isActive = $parent.hasClass('open')
  25844. clearMenus()
  25845. if (!isActive) {
  25846. if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
  25847. // if mobile we use a backdrop because click events don't delegate
  25848. $(document.createElement('div'))
  25849. .addClass('dropdown-backdrop')
  25850. .insertAfter($(this))
  25851. .on('click', clearMenus)
  25852. }
  25853. var relatedTarget = { relatedTarget: this }
  25854. $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
  25855. if (e.isDefaultPrevented()) return
  25856. $this
  25857. .trigger('focus')
  25858. .attr('aria-expanded', 'true')
  25859. $parent
  25860. .toggleClass('open')
  25861. .trigger($.Event('shown.bs.dropdown', relatedTarget))
  25862. }
  25863. return false
  25864. }
  25865. Dropdown.prototype.keydown = function (e) {
  25866. if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
  25867. var $this = $(this)
  25868. e.preventDefault()
  25869. e.stopPropagation()
  25870. if ($this.is('.disabled, :disabled')) return
  25871. var $parent = getParent($this)
  25872. var isActive = $parent.hasClass('open')
  25873. if (!isActive && e.which != 27 || isActive && e.which == 27) {
  25874. if (e.which == 27) $parent.find(toggle).trigger('focus')
  25875. return $this.trigger('click')
  25876. }
  25877. var desc = ' li:not(.disabled):visible a'
  25878. var $items = $parent.find('.dropdown-menu' + desc)
  25879. if (!$items.length) return
  25880. var index = $items.index(e.target)
  25881. if (e.which == 38 && index > 0) index-- // up
  25882. if (e.which == 40 && index < $items.length - 1) index++ // down
  25883. if (!~index) index = 0
  25884. $items.eq(index).trigger('focus')
  25885. }
  25886. // DROPDOWN PLUGIN DEFINITION
  25887. // ==========================
  25888. function Plugin(option) {
  25889. return this.each(function () {
  25890. var $this = $(this)
  25891. var data = $this.data('bs.dropdown')
  25892. if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
  25893. if (typeof option == 'string') data[option].call($this)
  25894. })
  25895. }
  25896. var old = $.fn.dropdown
  25897. $.fn.dropdown = Plugin
  25898. $.fn.dropdown.Constructor = Dropdown
  25899. // DROPDOWN NO CONFLICT
  25900. // ====================
  25901. $.fn.dropdown.noConflict = function () {
  25902. $.fn.dropdown = old
  25903. return this
  25904. }
  25905. // APPLY TO STANDARD DROPDOWN ELEMENTS
  25906. // ===================================
  25907. $(document)
  25908. .on('click.bs.dropdown.data-api', clearMenus)
  25909. .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
  25910. .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
  25911. .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
  25912. .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
  25913. }(jQuery);
  25914. /* ========================================================================
  25915. * Bootstrap: modal.js v3.3.7
  25916. * http://getbootstrap.com/javascript/#modals
  25917. * ========================================================================
  25918. * Copyright 2011-2016 Twitter, Inc.
  25919. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25920. * ======================================================================== */
  25921. +function ($) {
  25922. 'use strict';
  25923. // MODAL CLASS DEFINITION
  25924. // ======================
  25925. var Modal = function (element, options) {
  25926. this.options = options
  25927. this.$body = $(document.body)
  25928. this.$element = $(element)
  25929. this.$dialog = this.$element.find('.modal-dialog')
  25930. this.$backdrop = null
  25931. this.isShown = null
  25932. this.originalBodyPad = null
  25933. this.scrollbarWidth = 0
  25934. this.ignoreBackdropClick = false
  25935. if (this.options.remote) {
  25936. this.$element
  25937. .find('.modal-content')
  25938. .load(this.options.remote, $.proxy(function () {
  25939. this.$element.trigger('loaded.bs.modal')
  25940. }, this))
  25941. }
  25942. }
  25943. Modal.VERSION = '3.3.7'
  25944. Modal.TRANSITION_DURATION = 300
  25945. Modal.BACKDROP_TRANSITION_DURATION = 150
  25946. Modal.DEFAULTS = {
  25947. backdrop: true,
  25948. keyboard: true,
  25949. show: true
  25950. }
  25951. Modal.prototype.toggle = function (_relatedTarget) {
  25952. return this.isShown ? this.hide() : this.show(_relatedTarget)
  25953. }
  25954. Modal.prototype.show = function (_relatedTarget) {
  25955. var that = this
  25956. var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
  25957. this.$element.trigger(e)
  25958. if (this.isShown || e.isDefaultPrevented()) return
  25959. this.isShown = true
  25960. this.checkScrollbar()
  25961. this.setScrollbar()
  25962. this.$body.addClass('modal-open')
  25963. this.escape()
  25964. this.resize()
  25965. this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
  25966. this.$dialog.on('mousedown.dismiss.bs.modal', function () {
  25967. that.$element.one('mouseup.dismiss.bs.modal', function (e) {
  25968. if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
  25969. })
  25970. })
  25971. this.backdrop(function () {
  25972. var transition = $.support.transition && that.$element.hasClass('fade')
  25973. if (!that.$element.parent().length) {
  25974. that.$element.appendTo(that.$body) // don't move modals dom position
  25975. }
  25976. that.$element
  25977. .show()
  25978. .scrollTop(0)
  25979. that.adjustDialog()
  25980. if (transition) {
  25981. that.$element[0].offsetWidth // force reflow
  25982. }
  25983. that.$element.addClass('in')
  25984. that.enforceFocus()
  25985. var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
  25986. transition ?
  25987. that.$dialog // wait for modal to slide in
  25988. .one('bsTransitionEnd', function () {
  25989. that.$element.trigger('focus').trigger(e)
  25990. })
  25991. .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
  25992. that.$element.trigger('focus').trigger(e)
  25993. })
  25994. }
  25995. Modal.prototype.hide = function (e) {
  25996. if (e) e.preventDefault()
  25997. e = $.Event('hide.bs.modal')
  25998. this.$element.trigger(e)
  25999. if (!this.isShown || e.isDefaultPrevented()) return
  26000. this.isShown = false
  26001. this.escape()
  26002. this.resize()
  26003. $(document).off('focusin.bs.modal')
  26004. this.$element
  26005. .removeClass('in')
  26006. .off('click.dismiss.bs.modal')
  26007. .off('mouseup.dismiss.bs.modal')
  26008. this.$dialog.off('mousedown.dismiss.bs.modal')
  26009. $.support.transition && this.$element.hasClass('fade') ?
  26010. this.$element
  26011. .one('bsTransitionEnd', $.proxy(this.hideModal, this))
  26012. .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
  26013. this.hideModal()
  26014. }
  26015. Modal.prototype.enforceFocus = function () {
  26016. $(document)
  26017. .off('focusin.bs.modal') // guard against infinite focus loop
  26018. .on('focusin.bs.modal', $.proxy(function (e) {
  26019. if (document !== e.target &&
  26020. this.$element[0] !== e.target &&
  26021. !this.$element.has(e.target).length) {
  26022. this.$element.trigger('focus')
  26023. }
  26024. }, this))
  26025. }
  26026. Modal.prototype.escape = function () {
  26027. if (this.isShown && this.options.keyboard) {
  26028. this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
  26029. e.which == 27 && this.hide()
  26030. }, this))
  26031. } else if (!this.isShown) {
  26032. this.$element.off('keydown.dismiss.bs.modal')
  26033. }
  26034. }
  26035. Modal.prototype.resize = function () {
  26036. if (this.isShown) {
  26037. $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
  26038. } else {
  26039. $(window).off('resize.bs.modal')
  26040. }
  26041. }
  26042. Modal.prototype.hideModal = function () {
  26043. var that = this
  26044. this.$element.hide()
  26045. this.backdrop(function () {
  26046. that.$body.removeClass('modal-open')
  26047. that.resetAdjustments()
  26048. that.resetScrollbar()
  26049. that.$element.trigger('hidden.bs.modal')
  26050. })
  26051. }
  26052. Modal.prototype.removeBackdrop = function () {
  26053. this.$backdrop && this.$backdrop.remove()
  26054. this.$backdrop = null
  26055. }
  26056. Modal.prototype.backdrop = function (callback) {
  26057. var that = this
  26058. var animate = this.$element.hasClass('fade') ? 'fade' : ''
  26059. if (this.isShown && this.options.backdrop) {
  26060. var doAnimate = $.support.transition && animate
  26061. this.$backdrop = $(document.createElement('div'))
  26062. .addClass('modal-backdrop ' + animate)
  26063. .appendTo(this.$body)
  26064. this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
  26065. if (this.ignoreBackdropClick) {
  26066. this.ignoreBackdropClick = false
  26067. return
  26068. }
  26069. if (e.target !== e.currentTarget) return
  26070. this.options.backdrop == 'static'
  26071. ? this.$element[0].focus()
  26072. : this.hide()
  26073. }, this))
  26074. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  26075. this.$backdrop.addClass('in')
  26076. if (!callback) return
  26077. doAnimate ?
  26078. this.$backdrop
  26079. .one('bsTransitionEnd', callback)
  26080. .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
  26081. callback()
  26082. } else if (!this.isShown && this.$backdrop) {
  26083. this.$backdrop.removeClass('in')
  26084. var callbackRemove = function () {
  26085. that.removeBackdrop()
  26086. callback && callback()
  26087. }
  26088. $.support.transition && this.$element.hasClass('fade') ?
  26089. this.$backdrop
  26090. .one('bsTransitionEnd', callbackRemove)
  26091. .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
  26092. callbackRemove()
  26093. } else if (callback) {
  26094. callback()
  26095. }
  26096. }
  26097. // these following methods are used to handle overflowing modals
  26098. Modal.prototype.handleUpdate = function () {
  26099. this.adjustDialog()
  26100. }
  26101. Modal.prototype.adjustDialog = function () {
  26102. var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
  26103. this.$element.css({
  26104. paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
  26105. paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
  26106. })
  26107. }
  26108. Modal.prototype.resetAdjustments = function () {
  26109. this.$element.css({
  26110. paddingLeft: '',
  26111. paddingRight: ''
  26112. })
  26113. }
  26114. Modal.prototype.checkScrollbar = function () {
  26115. var fullWindowWidth = window.innerWidth
  26116. if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
  26117. var documentElementRect = document.documentElement.getBoundingClientRect()
  26118. fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
  26119. }
  26120. this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
  26121. this.scrollbarWidth = this.measureScrollbar()
  26122. }
  26123. Modal.prototype.setScrollbar = function () {
  26124. var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
  26125. this.originalBodyPad = document.body.style.paddingRight || ''
  26126. if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
  26127. }
  26128. Modal.prototype.resetScrollbar = function () {
  26129. this.$body.css('padding-right', this.originalBodyPad)
  26130. }
  26131. Modal.prototype.measureScrollbar = function () { // thx walsh
  26132. var scrollDiv = document.createElement('div')
  26133. scrollDiv.className = 'modal-scrollbar-measure'
  26134. this.$body.append(scrollDiv)
  26135. var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
  26136. this.$body[0].removeChild(scrollDiv)
  26137. return scrollbarWidth
  26138. }
  26139. // MODAL PLUGIN DEFINITION
  26140. // =======================
  26141. function Plugin(option, _relatedTarget) {
  26142. return this.each(function () {
  26143. var $this = $(this)
  26144. var data = $this.data('bs.modal')
  26145. var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
  26146. if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
  26147. if (typeof option == 'string') data[option](_relatedTarget)
  26148. else if (options.show) data.show(_relatedTarget)
  26149. })
  26150. }
  26151. var old = $.fn.modal
  26152. $.fn.modal = Plugin
  26153. $.fn.modal.Constructor = Modal
  26154. // MODAL NO CONFLICT
  26155. // =================
  26156. $.fn.modal.noConflict = function () {
  26157. $.fn.modal = old
  26158. return this
  26159. }
  26160. // MODAL DATA-API
  26161. // ==============
  26162. $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
  26163. var $this = $(this)
  26164. var href = $this.attr('href')
  26165. var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
  26166. var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
  26167. if ($this.is('a')) e.preventDefault()
  26168. $target.one('show.bs.modal', function (showEvent) {
  26169. if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
  26170. $target.one('hidden.bs.modal', function () {
  26171. $this.is(':visible') && $this.trigger('focus')
  26172. })
  26173. })
  26174. Plugin.call($target, option, this)
  26175. })
  26176. }(jQuery);
  26177. /* ========================================================================
  26178. * Bootstrap: tooltip.js v3.3.7
  26179. * http://getbootstrap.com/javascript/#tooltip
  26180. * Inspired by the original jQuery.tipsy by Jason Frame
  26181. * ========================================================================
  26182. * Copyright 2011-2016 Twitter, Inc.
  26183. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26184. * ======================================================================== */
  26185. +function ($) {
  26186. 'use strict';
  26187. // TOOLTIP PUBLIC CLASS DEFINITION
  26188. // ===============================
  26189. var Tooltip = function (element, options) {
  26190. this.type = null
  26191. this.options = null
  26192. this.enabled = null
  26193. this.timeout = null
  26194. this.hoverState = null
  26195. this.$element = null
  26196. this.inState = null
  26197. this.init('tooltip', element, options)
  26198. }
  26199. Tooltip.VERSION = '3.3.7'
  26200. Tooltip.TRANSITION_DURATION = 150
  26201. Tooltip.DEFAULTS = {
  26202. animation: true,
  26203. placement: 'top',
  26204. selector: false,
  26205. template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  26206. trigger: 'hover focus',
  26207. title: '',
  26208. delay: 0,
  26209. html: false,
  26210. container: false,
  26211. viewport: {
  26212. selector: 'body',
  26213. padding: 0
  26214. }
  26215. }
  26216. Tooltip.prototype.init = function (type, element, options) {
  26217. this.enabled = true
  26218. this.type = type
  26219. this.$element = $(element)
  26220. this.options = this.getOptions(options)
  26221. this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
  26222. this.inState = { click: false, hover: false, focus: false }
  26223. if (this.$element[0] instanceof document.constructor && !this.options.selector) {
  26224. throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
  26225. }
  26226. var triggers = this.options.trigger.split(' ')
  26227. for (var i = triggers.length; i--;) {
  26228. var trigger = triggers[i]
  26229. if (trigger == 'click') {
  26230. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  26231. } else if (trigger != 'manual') {
  26232. var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
  26233. var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
  26234. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  26235. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  26236. }
  26237. }
  26238. this.options.selector ?
  26239. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  26240. this.fixTitle()
  26241. }
  26242. Tooltip.prototype.getDefaults = function () {
  26243. return Tooltip.DEFAULTS
  26244. }
  26245. Tooltip.prototype.getOptions = function (options) {
  26246. options = $.extend({}, this.getDefaults(), this.$element.data(), options)
  26247. if (options.delay && typeof options.delay == 'number') {
  26248. options.delay = {
  26249. show: options.delay,
  26250. hide: options.delay
  26251. }
  26252. }
  26253. return options
  26254. }
  26255. Tooltip.prototype.getDelegateOptions = function () {
  26256. var options = {}
  26257. var defaults = this.getDefaults()
  26258. this._options && $.each(this._options, function (key, value) {
  26259. if (defaults[key] != value) options[key] = value
  26260. })
  26261. return options
  26262. }
  26263. Tooltip.prototype.enter = function (obj) {
  26264. var self = obj instanceof this.constructor ?
  26265. obj : $(obj.currentTarget).data('bs.' + this.type)
  26266. if (!self) {
  26267. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  26268. $(obj.currentTarget).data('bs.' + this.type, self)
  26269. }
  26270. if (obj instanceof $.Event) {
  26271. self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
  26272. }
  26273. if (self.tip().hasClass('in') || self.hoverState == 'in') {
  26274. self.hoverState = 'in'
  26275. return
  26276. }
  26277. clearTimeout(self.timeout)
  26278. self.hoverState = 'in'
  26279. if (!self.options.delay || !self.options.delay.show) return self.show()
  26280. self.timeout = setTimeout(function () {
  26281. if (self.hoverState == 'in') self.show()
  26282. }, self.options.delay.show)
  26283. }
  26284. Tooltip.prototype.isInStateTrue = function () {
  26285. for (var key in this.inState) {
  26286. if (this.inState[key]) return true
  26287. }
  26288. return false
  26289. }
  26290. Tooltip.prototype.leave = function (obj) {
  26291. var self = obj instanceof this.constructor ?
  26292. obj : $(obj.currentTarget).data('bs.' + this.type)
  26293. if (!self) {
  26294. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  26295. $(obj.currentTarget).data('bs.' + this.type, self)
  26296. }
  26297. if (obj instanceof $.Event) {
  26298. self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
  26299. }
  26300. if (self.isInStateTrue()) return
  26301. clearTimeout(self.timeout)
  26302. self.hoverState = 'out'
  26303. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  26304. self.timeout = setTimeout(function () {
  26305. if (self.hoverState == 'out') self.hide()
  26306. }, self.options.delay.hide)
  26307. }
  26308. Tooltip.prototype.show = function () {
  26309. var e = $.Event('show.bs.' + this.type)
  26310. if (this.hasContent() && this.enabled) {
  26311. this.$element.trigger(e)
  26312. var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
  26313. if (e.isDefaultPrevented() || !inDom) return
  26314. var that = this
  26315. var $tip = this.tip()
  26316. var tipId = this.getUID(this.type)
  26317. this.setContent()
  26318. $tip.attr('id', tipId)
  26319. this.$element.attr('aria-describedby', tipId)
  26320. if (this.options.animation) $tip.addClass('fade')
  26321. var placement = typeof this.options.placement == 'function' ?
  26322. this.options.placement.call(this, $tip[0], this.$element[0]) :
  26323. this.options.placement
  26324. var autoToken = /\s?auto?\s?/i
  26325. var autoPlace = autoToken.test(placement)
  26326. if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
  26327. $tip
  26328. .detach()
  26329. .css({ top: 0, left: 0, display: 'block' })
  26330. .addClass(placement)
  26331. .data('bs.' + this.type, this)
  26332. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
  26333. this.$element.trigger('inserted.bs.' + this.type)
  26334. var pos = this.getPosition()
  26335. var actualWidth = $tip[0].offsetWidth
  26336. var actualHeight = $tip[0].offsetHeight
  26337. if (autoPlace) {
  26338. var orgPlacement = placement
  26339. var viewportDim = this.getPosition(this.$viewport)
  26340. placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
  26341. placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
  26342. placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
  26343. placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
  26344. placement
  26345. $tip
  26346. .removeClass(orgPlacement)
  26347. .addClass(placement)
  26348. }
  26349. var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
  26350. this.applyPlacement(calculatedOffset, placement)
  26351. var complete = function () {
  26352. var prevHoverState = that.hoverState
  26353. that.$element.trigger('shown.bs.' + that.type)
  26354. that.hoverState = null
  26355. if (prevHoverState == 'out') that.leave(that)
  26356. }
  26357. $.support.transition && this.$tip.hasClass('fade') ?
  26358. $tip
  26359. .one('bsTransitionEnd', complete)
  26360. .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
  26361. complete()
  26362. }
  26363. }
  26364. Tooltip.prototype.applyPlacement = function (offset, placement) {
  26365. var $tip = this.tip()
  26366. var width = $tip[0].offsetWidth
  26367. var height = $tip[0].offsetHeight
  26368. // manually read margins because getBoundingClientRect includes difference
  26369. var marginTop = parseInt($tip.css('margin-top'), 10)
  26370. var marginLeft = parseInt($tip.css('margin-left'), 10)
  26371. // we must check for NaN for ie 8/9
  26372. if (isNaN(marginTop)) marginTop = 0
  26373. if (isNaN(marginLeft)) marginLeft = 0
  26374. offset.top += marginTop
  26375. offset.left += marginLeft
  26376. // $.fn.offset doesn't round pixel values
  26377. // so we use setOffset directly with our own function B-0
  26378. $.offset.setOffset($tip[0], $.extend({
  26379. using: function (props) {
  26380. $tip.css({
  26381. top: Math.round(props.top),
  26382. left: Math.round(props.left)
  26383. })
  26384. }
  26385. }, offset), 0)
  26386. $tip.addClass('in')
  26387. // check to see if placing tip in new offset caused the tip to resize itself
  26388. var actualWidth = $tip[0].offsetWidth
  26389. var actualHeight = $tip[0].offsetHeight
  26390. if (placement == 'top' && actualHeight != height) {
  26391. offset.top = offset.top + height - actualHeight
  26392. }
  26393. var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
  26394. if (delta.left) offset.left += delta.left
  26395. else offset.top += delta.top
  26396. var isVertical = /top|bottom/.test(placement)
  26397. var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
  26398. var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
  26399. $tip.offset(offset)
  26400. this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
  26401. }
  26402. Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
  26403. this.arrow()
  26404. .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
  26405. .css(isVertical ? 'top' : 'left', '')
  26406. }
  26407. Tooltip.prototype.setContent = function () {
  26408. var $tip = this.tip()
  26409. var title = this.getTitle()
  26410. $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  26411. $tip.removeClass('fade in top bottom left right')
  26412. }
  26413. Tooltip.prototype.hide = function (callback) {
  26414. var that = this
  26415. var $tip = $(this.$tip)
  26416. var e = $.Event('hide.bs.' + this.type)
  26417. function complete() {
  26418. if (that.hoverState != 'in') $tip.detach()
  26419. if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
  26420. that.$element
  26421. .removeAttr('aria-describedby')
  26422. .trigger('hidden.bs.' + that.type)
  26423. }
  26424. callback && callback()
  26425. }
  26426. this.$element.trigger(e)
  26427. if (e.isDefaultPrevented()) return
  26428. $tip.removeClass('in')
  26429. $.support.transition && $tip.hasClass('fade') ?
  26430. $tip
  26431. .one('bsTransitionEnd', complete)
  26432. .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
  26433. complete()
  26434. this.hoverState = null
  26435. return this
  26436. }
  26437. Tooltip.prototype.fixTitle = function () {
  26438. var $e = this.$element
  26439. if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
  26440. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  26441. }
  26442. }
  26443. Tooltip.prototype.hasContent = function () {
  26444. return this.getTitle()
  26445. }
  26446. Tooltip.prototype.getPosition = function ($element) {
  26447. $element = $element || this.$element
  26448. var el = $element[0]
  26449. var isBody = el.tagName == 'BODY'
  26450. var elRect = el.getBoundingClientRect()
  26451. if (elRect.width == null) {
  26452. // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
  26453. elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
  26454. }
  26455. var isSvg = window.SVGElement && el instanceof window.SVGElement
  26456. // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
  26457. // See https://github.com/twbs/bootstrap/issues/20280
  26458. var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
  26459. var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
  26460. var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
  26461. return $.extend({}, elRect, scroll, outerDims, elOffset)
  26462. }
  26463. Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
  26464. return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  26465. placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  26466. placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
  26467. /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
  26468. }
  26469. Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
  26470. var delta = { top: 0, left: 0 }
  26471. if (!this.$viewport) return delta
  26472. var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
  26473. var viewportDimensions = this.getPosition(this.$viewport)
  26474. if (/right|left/.test(placement)) {
  26475. var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
  26476. var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
  26477. if (topEdgeOffset < viewportDimensions.top) { // top overflow
  26478. delta.top = viewportDimensions.top - topEdgeOffset
  26479. } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
  26480. delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
  26481. }
  26482. } else {
  26483. var leftEdgeOffset = pos.left - viewportPadding
  26484. var rightEdgeOffset = pos.left + viewportPadding + actualWidth
  26485. if (leftEdgeOffset < viewportDimensions.left) { // left overflow
  26486. delta.left = viewportDimensions.left - leftEdgeOffset
  26487. } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
  26488. delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
  26489. }
  26490. }
  26491. return delta
  26492. }
  26493. Tooltip.prototype.getTitle = function () {
  26494. var title
  26495. var $e = this.$element
  26496. var o = this.options
  26497. title = $e.attr('data-original-title')
  26498. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  26499. return title
  26500. }
  26501. Tooltip.prototype.getUID = function (prefix) {
  26502. do prefix += ~~(Math.random() * 1000000)
  26503. while (document.getElementById(prefix))
  26504. return prefix
  26505. }
  26506. Tooltip.prototype.tip = function () {
  26507. if (!this.$tip) {
  26508. this.$tip = $(this.options.template)
  26509. if (this.$tip.length != 1) {
  26510. throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
  26511. }
  26512. }
  26513. return this.$tip
  26514. }
  26515. Tooltip.prototype.arrow = function () {
  26516. return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
  26517. }
  26518. Tooltip.prototype.enable = function () {
  26519. this.enabled = true
  26520. }
  26521. Tooltip.prototype.disable = function () {
  26522. this.enabled = false
  26523. }
  26524. Tooltip.prototype.toggleEnabled = function () {
  26525. this.enabled = !this.enabled
  26526. }
  26527. Tooltip.prototype.toggle = function (e) {
  26528. var self = this
  26529. if (e) {
  26530. self = $(e.currentTarget).data('bs.' + this.type)
  26531. if (!self) {
  26532. self = new this.constructor(e.currentTarget, this.getDelegateOptions())
  26533. $(e.currentTarget).data('bs.' + this.type, self)
  26534. }
  26535. }
  26536. if (e) {
  26537. self.inState.click = !self.inState.click
  26538. if (self.isInStateTrue()) self.enter(self)
  26539. else self.leave(self)
  26540. } else {
  26541. self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  26542. }
  26543. }
  26544. Tooltip.prototype.destroy = function () {
  26545. var that = this
  26546. clearTimeout(this.timeout)
  26547. this.hide(function () {
  26548. that.$element.off('.' + that.type).removeData('bs.' + that.type)
  26549. if (that.$tip) {
  26550. that.$tip.detach()
  26551. }
  26552. that.$tip = null
  26553. that.$arrow = null
  26554. that.$viewport = null
  26555. that.$element = null
  26556. })
  26557. }
  26558. // TOOLTIP PLUGIN DEFINITION
  26559. // =========================
  26560. function Plugin(option) {
  26561. return this.each(function () {
  26562. var $this = $(this)
  26563. var data = $this.data('bs.tooltip')
  26564. var options = typeof option == 'object' && option
  26565. if (!data && /destroy|hide/.test(option)) return
  26566. if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
  26567. if (typeof option == 'string') data[option]()
  26568. })
  26569. }
  26570. var old = $.fn.tooltip
  26571. $.fn.tooltip = Plugin
  26572. $.fn.tooltip.Constructor = Tooltip
  26573. // TOOLTIP NO CONFLICT
  26574. // ===================
  26575. $.fn.tooltip.noConflict = function () {
  26576. $.fn.tooltip = old
  26577. return this
  26578. }
  26579. }(jQuery);
  26580. /* ========================================================================
  26581. * Bootstrap: popover.js v3.3.7
  26582. * http://getbootstrap.com/javascript/#popovers
  26583. * ========================================================================
  26584. * Copyright 2011-2016 Twitter, Inc.
  26585. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26586. * ======================================================================== */
  26587. +function ($) {
  26588. 'use strict';
  26589. // POPOVER PUBLIC CLASS DEFINITION
  26590. // ===============================
  26591. var Popover = function (element, options) {
  26592. this.init('popover', element, options)
  26593. }
  26594. if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
  26595. Popover.VERSION = '3.3.7'
  26596. Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
  26597. placement: 'right',
  26598. trigger: 'click',
  26599. content: '',
  26600. template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  26601. })
  26602. // NOTE: POPOVER EXTENDS tooltip.js
  26603. // ================================
  26604. Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
  26605. Popover.prototype.constructor = Popover
  26606. Popover.prototype.getDefaults = function () {
  26607. return Popover.DEFAULTS
  26608. }
  26609. Popover.prototype.setContent = function () {
  26610. var $tip = this.tip()
  26611. var title = this.getTitle()
  26612. var content = this.getContent()
  26613. $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
  26614. $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
  26615. this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
  26616. ](content)
  26617. $tip.removeClass('fade top bottom left right in')
  26618. // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
  26619. // this manually by checking the contents.
  26620. if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
  26621. }
  26622. Popover.prototype.hasContent = function () {
  26623. return this.getTitle() || this.getContent()
  26624. }
  26625. Popover.prototype.getContent = function () {
  26626. var $e = this.$element
  26627. var o = this.options
  26628. return $e.attr('data-content')
  26629. || (typeof o.content == 'function' ?
  26630. o.content.call($e[0]) :
  26631. o.content)
  26632. }
  26633. Popover.prototype.arrow = function () {
  26634. return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  26635. }
  26636. // POPOVER PLUGIN DEFINITION
  26637. // =========================
  26638. function Plugin(option) {
  26639. return this.each(function () {
  26640. var $this = $(this)
  26641. var data = $this.data('bs.popover')
  26642. var options = typeof option == 'object' && option
  26643. if (!data && /destroy|hide/.test(option)) return
  26644. if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
  26645. if (typeof option == 'string') data[option]()
  26646. })
  26647. }
  26648. var old = $.fn.popover
  26649. $.fn.popover = Plugin
  26650. $.fn.popover.Constructor = Popover
  26651. // POPOVER NO CONFLICT
  26652. // ===================
  26653. $.fn.popover.noConflict = function () {
  26654. $.fn.popover = old
  26655. return this
  26656. }
  26657. }(jQuery);
  26658. /* ========================================================================
  26659. * Bootstrap: scrollspy.js v3.3.7
  26660. * http://getbootstrap.com/javascript/#scrollspy
  26661. * ========================================================================
  26662. * Copyright 2011-2016 Twitter, Inc.
  26663. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26664. * ======================================================================== */
  26665. +function ($) {
  26666. 'use strict';
  26667. // SCROLLSPY CLASS DEFINITION
  26668. // ==========================
  26669. function ScrollSpy(element, options) {
  26670. this.$body = $(document.body)
  26671. this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)
  26672. this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
  26673. this.selector = (this.options.target || '') + ' .nav li > a'
  26674. this.offsets = []
  26675. this.targets = []
  26676. this.activeTarget = null
  26677. this.scrollHeight = 0
  26678. this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))
  26679. this.refresh()
  26680. this.process()
  26681. }
  26682. ScrollSpy.VERSION = '3.3.7'
  26683. ScrollSpy.DEFAULTS = {
  26684. offset: 10
  26685. }
  26686. ScrollSpy.prototype.getScrollHeight = function () {
  26687. return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
  26688. }
  26689. ScrollSpy.prototype.refresh = function () {
  26690. var that = this
  26691. var offsetMethod = 'offset'
  26692. var offsetBase = 0
  26693. this.offsets = []
  26694. this.targets = []
  26695. this.scrollHeight = this.getScrollHeight()
  26696. if (!$.isWindow(this.$scrollElement[0])) {
  26697. offsetMethod = 'position'
  26698. offsetBase = this.$scrollElement.scrollTop()
  26699. }
  26700. this.$body
  26701. .find(this.selector)
  26702. .map(function () {
  26703. var $el = $(this)
  26704. var href = $el.data('target') || $el.attr('href')
  26705. var $href = /^#./.test(href) && $(href)
  26706. return ($href
  26707. && $href.length
  26708. && $href.is(':visible')
  26709. && [[$href[offsetMethod]().top + offsetBase, href]]) || null
  26710. })
  26711. .sort(function (a, b) { return a[0] - b[0] })
  26712. .each(function () {
  26713. that.offsets.push(this[0])
  26714. that.targets.push(this[1])
  26715. })
  26716. }
  26717. ScrollSpy.prototype.process = function () {
  26718. var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
  26719. var scrollHeight = this.getScrollHeight()
  26720. var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
  26721. var offsets = this.offsets
  26722. var targets = this.targets
  26723. var activeTarget = this.activeTarget
  26724. var i
  26725. if (this.scrollHeight != scrollHeight) {
  26726. this.refresh()
  26727. }
  26728. if (scrollTop >= maxScroll) {
  26729. return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
  26730. }
  26731. if (activeTarget && scrollTop < offsets[0]) {
  26732. this.activeTarget = null
  26733. return this.clear()
  26734. }
  26735. for (i = offsets.length; i--;) {
  26736. activeTarget != targets[i]
  26737. && scrollTop >= offsets[i]
  26738. && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1])
  26739. && this.activate(targets[i])
  26740. }
  26741. }
  26742. ScrollSpy.prototype.activate = function (target) {
  26743. this.activeTarget = target
  26744. this.clear()
  26745. var selector = this.selector +
  26746. '[data-target="' + target + '"],' +
  26747. this.selector + '[href="' + target + '"]'
  26748. var active = $(selector)
  26749. .parents('li')
  26750. .addClass('active')
  26751. if (active.parent('.dropdown-menu').length) {
  26752. active = active
  26753. .closest('li.dropdown')
  26754. .addClass('active')
  26755. }
  26756. active.trigger('activate.bs.scrollspy')
  26757. }
  26758. ScrollSpy.prototype.clear = function () {
  26759. $(this.selector)
  26760. .parentsUntil(this.options.target, '.active')
  26761. .removeClass('active')
  26762. }
  26763. // SCROLLSPY PLUGIN DEFINITION
  26764. // ===========================
  26765. function Plugin(option) {
  26766. return this.each(function () {
  26767. var $this = $(this)
  26768. var data = $this.data('bs.scrollspy')
  26769. var options = typeof option == 'object' && option
  26770. if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
  26771. if (typeof option == 'string') data[option]()
  26772. })
  26773. }
  26774. var old = $.fn.scrollspy
  26775. $.fn.scrollspy = Plugin
  26776. $.fn.scrollspy.Constructor = ScrollSpy
  26777. // SCROLLSPY NO CONFLICT
  26778. // =====================
  26779. $.fn.scrollspy.noConflict = function () {
  26780. $.fn.scrollspy = old
  26781. return this
  26782. }
  26783. // SCROLLSPY DATA-API
  26784. // ==================
  26785. $(window).on('load.bs.scrollspy.data-api', function () {
  26786. $('[data-spy="scroll"]').each(function () {
  26787. var $spy = $(this)
  26788. Plugin.call($spy, $spy.data())
  26789. })
  26790. })
  26791. }(jQuery);
  26792. /* ========================================================================
  26793. * Bootstrap: tab.js v3.3.7
  26794. * http://getbootstrap.com/javascript/#tabs
  26795. * ========================================================================
  26796. * Copyright 2011-2016 Twitter, Inc.
  26797. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26798. * ======================================================================== */
  26799. +function ($) {
  26800. 'use strict';
  26801. // TAB CLASS DEFINITION
  26802. // ====================
  26803. var Tab = function (element) {
  26804. // jscs:disable requireDollarBeforejQueryAssignment
  26805. this.element = $(element)
  26806. // jscs:enable requireDollarBeforejQueryAssignment
  26807. }
  26808. Tab.VERSION = '3.3.7'
  26809. Tab.TRANSITION_DURATION = 150
  26810. Tab.prototype.show = function () {
  26811. var $this = this.element
  26812. var $ul = $this.closest('ul:not(.dropdown-menu)')
  26813. var selector = $this.data('target')
  26814. if (!selector) {
  26815. selector = $this.attr('href')
  26816. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  26817. }
  26818. if ($this.parent('li').hasClass('active')) return
  26819. var $previous = $ul.find('.active:last a')
  26820. var hideEvent = $.Event('hide.bs.tab', {
  26821. relatedTarget: $this[0]
  26822. })
  26823. var showEvent = $.Event('show.bs.tab', {
  26824. relatedTarget: $previous[0]
  26825. })
  26826. $previous.trigger(hideEvent)
  26827. $this.trigger(showEvent)
  26828. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
  26829. var $target = $(selector)
  26830. this.activate($this.closest('li'), $ul)
  26831. this.activate($target, $target.parent(), function () {
  26832. $previous.trigger({
  26833. type: 'hidden.bs.tab',
  26834. relatedTarget: $this[0]
  26835. })
  26836. $this.trigger({
  26837. type: 'shown.bs.tab',
  26838. relatedTarget: $previous[0]
  26839. })
  26840. })
  26841. }
  26842. Tab.prototype.activate = function (element, container, callback) {
  26843. var $active = container.find('> .active')
  26844. var transition = callback
  26845. && $.support.transition
  26846. && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
  26847. function next() {
  26848. $active
  26849. .removeClass('active')
  26850. .find('> .dropdown-menu > .active')
  26851. .removeClass('active')
  26852. .end()
  26853. .find('[data-toggle="tab"]')
  26854. .attr('aria-expanded', false)
  26855. element
  26856. .addClass('active')
  26857. .find('[data-toggle="tab"]')
  26858. .attr('aria-expanded', true)
  26859. if (transition) {
  26860. element[0].offsetWidth // reflow for transition
  26861. element.addClass('in')
  26862. } else {
  26863. element.removeClass('fade')
  26864. }
  26865. if (element.parent('.dropdown-menu').length) {
  26866. element
  26867. .closest('li.dropdown')
  26868. .addClass('active')
  26869. .end()
  26870. .find('[data-toggle="tab"]')
  26871. .attr('aria-expanded', true)
  26872. }
  26873. callback && callback()
  26874. }
  26875. $active.length && transition ?
  26876. $active
  26877. .one('bsTransitionEnd', next)
  26878. .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
  26879. next()
  26880. $active.removeClass('in')
  26881. }
  26882. // TAB PLUGIN DEFINITION
  26883. // =====================
  26884. function Plugin(option) {
  26885. return this.each(function () {
  26886. var $this = $(this)
  26887. var data = $this.data('bs.tab')
  26888. if (!data) $this.data('bs.tab', (data = new Tab(this)))
  26889. if (typeof option == 'string') data[option]()
  26890. })
  26891. }
  26892. var old = $.fn.tab
  26893. $.fn.tab = Plugin
  26894. $.fn.tab.Constructor = Tab
  26895. // TAB NO CONFLICT
  26896. // ===============
  26897. $.fn.tab.noConflict = function () {
  26898. $.fn.tab = old
  26899. return this
  26900. }
  26901. // TAB DATA-API
  26902. // ============
  26903. var clickHandler = function (e) {
  26904. e.preventDefault()
  26905. Plugin.call($(this), 'show')
  26906. }
  26907. $(document)
  26908. .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
  26909. .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
  26910. }(jQuery);
  26911. /* ========================================================================
  26912. * Bootstrap: affix.js v3.3.7
  26913. * http://getbootstrap.com/javascript/#affix
  26914. * ========================================================================
  26915. * Copyright 2011-2016 Twitter, Inc.
  26916. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26917. * ======================================================================== */
  26918. +function ($) {
  26919. 'use strict';
  26920. // AFFIX CLASS DEFINITION
  26921. // ======================
  26922. var Affix = function (element, options) {
  26923. this.options = $.extend({}, Affix.DEFAULTS, options)
  26924. this.$target = $(this.options.target)
  26925. .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
  26926. .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
  26927. this.$element = $(element)
  26928. this.affixed = null
  26929. this.unpin = null
  26930. this.pinnedOffset = null
  26931. this.checkPosition()
  26932. }
  26933. Affix.VERSION = '3.3.7'
  26934. Affix.RESET = 'affix affix-top affix-bottom'
  26935. Affix.DEFAULTS = {
  26936. offset: 0,
  26937. target: window
  26938. }
  26939. Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
  26940. var scrollTop = this.$target.scrollTop()
  26941. var position = this.$element.offset()
  26942. var targetHeight = this.$target.height()
  26943. if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false
  26944. if (this.affixed == 'bottom') {
  26945. if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
  26946. return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
  26947. }
  26948. var initializing = this.affixed == null
  26949. var colliderTop = initializing ? scrollTop : position.top
  26950. var colliderHeight = initializing ? targetHeight : height
  26951. if (offsetTop != null && scrollTop <= offsetTop) return 'top'
  26952. if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
  26953. return false
  26954. }
  26955. Affix.prototype.getPinnedOffset = function () {
  26956. if (this.pinnedOffset) return this.pinnedOffset
  26957. this.$element.removeClass(Affix.RESET).addClass('affix')
  26958. var scrollTop = this.$target.scrollTop()
  26959. var position = this.$element.offset()
  26960. return (this.pinnedOffset = position.top - scrollTop)
  26961. }
  26962. Affix.prototype.checkPositionWithEventLoop = function () {
  26963. setTimeout($.proxy(this.checkPosition, this), 1)
  26964. }
  26965. Affix.prototype.checkPosition = function () {
  26966. if (!this.$element.is(':visible')) return
  26967. var height = this.$element.height()
  26968. var offset = this.options.offset
  26969. var offsetTop = offset.top
  26970. var offsetBottom = offset.bottom
  26971. var scrollHeight = Math.max($(document).height(), $(document.body).height())
  26972. if (typeof offset != 'object') offsetBottom = offsetTop = offset
  26973. if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
  26974. if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
  26975. var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)
  26976. if (this.affixed != affix) {
  26977. if (this.unpin != null) this.$element.css('top', '')
  26978. var affixType = 'affix' + (affix ? '-' + affix : '')
  26979. var e = $.Event(affixType + '.bs.affix')
  26980. this.$element.trigger(e)
  26981. if (e.isDefaultPrevented()) return
  26982. this.affixed = affix
  26983. this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
  26984. this.$element
  26985. .removeClass(Affix.RESET)
  26986. .addClass(affixType)
  26987. .trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
  26988. }
  26989. if (affix == 'bottom') {
  26990. this.$element.offset({
  26991. top: scrollHeight - height - offsetBottom
  26992. })
  26993. }
  26994. }
  26995. // AFFIX PLUGIN DEFINITION
  26996. // =======================
  26997. function Plugin(option) {
  26998. return this.each(function () {
  26999. var $this = $(this)
  27000. var data = $this.data('bs.affix')
  27001. var options = typeof option == 'object' && option
  27002. if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
  27003. if (typeof option == 'string') data[option]()
  27004. })
  27005. }
  27006. var old = $.fn.affix
  27007. $.fn.affix = Plugin
  27008. $.fn.affix.Constructor = Affix
  27009. // AFFIX NO CONFLICT
  27010. // =================
  27011. $.fn.affix.noConflict = function () {
  27012. $.fn.affix = old
  27013. return this
  27014. }
  27015. // AFFIX DATA-API
  27016. // ==============
  27017. $(window).on('load', function () {
  27018. $('[data-spy="affix"]').each(function () {
  27019. var $spy = $(this)
  27020. var data = $spy.data()
  27021. data.offset = data.offset || {}
  27022. if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
  27023. if (data.offsetTop != null) data.offset.top = data.offsetTop
  27024. Plugin.call($spy, data)
  27025. })
  27026. })
  27027. }(jQuery);
  27028. /***/ }),
  27029. /* 16 */
  27030. /***/ (function(module, exports, __webpack_require__) {
  27031. module.exports = __webpack_require__(17);
  27032. /***/ }),
  27033. /* 17 */
  27034. /***/ (function(module, exports, __webpack_require__) {
  27035. "use strict";
  27036. var utils = __webpack_require__(0);
  27037. var bind = __webpack_require__(3);
  27038. var Axios = __webpack_require__(19);
  27039. var defaults = __webpack_require__(1);
  27040. /**
  27041. * Create an instance of Axios
  27042. *
  27043. * @param {Object} defaultConfig The default config for the instance
  27044. * @return {Axios} A new instance of Axios
  27045. */
  27046. function createInstance(defaultConfig) {
  27047. var context = new Axios(defaultConfig);
  27048. var instance = bind(Axios.prototype.request, context);
  27049. // Copy axios.prototype to instance
  27050. utils.extend(instance, Axios.prototype, context);
  27051. // Copy context to instance
  27052. utils.extend(instance, context);
  27053. return instance;
  27054. }
  27055. // Create the default instance to be exported
  27056. var axios = createInstance(defaults);
  27057. // Expose Axios class to allow class inheritance
  27058. axios.Axios = Axios;
  27059. // Factory for creating new instances
  27060. axios.create = function create(instanceConfig) {
  27061. return createInstance(utils.merge(defaults, instanceConfig));
  27062. };
  27063. // Expose Cancel & CancelToken
  27064. axios.Cancel = __webpack_require__(7);
  27065. axios.CancelToken = __webpack_require__(34);
  27066. axios.isCancel = __webpack_require__(6);
  27067. // Expose all/spread
  27068. axios.all = function all(promises) {
  27069. return Promise.all(promises);
  27070. };
  27071. axios.spread = __webpack_require__(35);
  27072. module.exports = axios;
  27073. // Allow use of default import syntax in TypeScript
  27074. module.exports.default = axios;
  27075. /***/ }),
  27076. /* 18 */
  27077. /***/ (function(module, exports) {
  27078. /*!
  27079. * Determine if an object is a Buffer
  27080. *
  27081. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  27082. * @license MIT
  27083. */
  27084. // The _isBuffer check is for Safari 5-7 support, because it's missing
  27085. // Object.prototype.constructor. Remove this eventually
  27086. module.exports = function (obj) {
  27087. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  27088. }
  27089. function isBuffer (obj) {
  27090. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  27091. }
  27092. // For Node v0.10 support. Remove this eventually.
  27093. function isSlowBuffer (obj) {
  27094. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  27095. }
  27096. /***/ }),
  27097. /* 19 */
  27098. /***/ (function(module, exports, __webpack_require__) {
  27099. "use strict";
  27100. var defaults = __webpack_require__(1);
  27101. var utils = __webpack_require__(0);
  27102. var InterceptorManager = __webpack_require__(29);
  27103. var dispatchRequest = __webpack_require__(30);
  27104. var isAbsoluteURL = __webpack_require__(32);
  27105. var combineURLs = __webpack_require__(33);
  27106. /**
  27107. * Create a new instance of Axios
  27108. *
  27109. * @param {Object} instanceConfig The default config for the instance
  27110. */
  27111. function Axios(instanceConfig) {
  27112. this.defaults = instanceConfig;
  27113. this.interceptors = {
  27114. request: new InterceptorManager(),
  27115. response: new InterceptorManager()
  27116. };
  27117. }
  27118. /**
  27119. * Dispatch a request
  27120. *
  27121. * @param {Object} config The config specific for this request (merged with this.defaults)
  27122. */
  27123. Axios.prototype.request = function request(config) {
  27124. /*eslint no-param-reassign:0*/
  27125. // Allow for axios('example/url'[, config]) a la fetch API
  27126. if (typeof config === 'string') {
  27127. config = utils.merge({
  27128. url: arguments[0]
  27129. }, arguments[1]);
  27130. }
  27131. config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
  27132. config.method = config.method.toLowerCase();
  27133. // Support baseURL config
  27134. if (config.baseURL && !isAbsoluteURL(config.url)) {
  27135. config.url = combineURLs(config.baseURL, config.url);
  27136. }
  27137. // Hook up interceptors middleware
  27138. var chain = [dispatchRequest, undefined];
  27139. var promise = Promise.resolve(config);
  27140. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  27141. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  27142. });
  27143. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  27144. chain.push(interceptor.fulfilled, interceptor.rejected);
  27145. });
  27146. while (chain.length) {
  27147. promise = promise.then(chain.shift(), chain.shift());
  27148. }
  27149. return promise;
  27150. };
  27151. // Provide aliases for supported request methods
  27152. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  27153. /*eslint func-names:0*/
  27154. Axios.prototype[method] = function(url, config) {
  27155. return this.request(utils.merge(config || {}, {
  27156. method: method,
  27157. url: url
  27158. }));
  27159. };
  27160. });
  27161. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  27162. /*eslint func-names:0*/
  27163. Axios.prototype[method] = function(url, data, config) {
  27164. return this.request(utils.merge(config || {}, {
  27165. method: method,
  27166. url: url,
  27167. data: data
  27168. }));
  27169. };
  27170. });
  27171. module.exports = Axios;
  27172. /***/ }),
  27173. /* 20 */
  27174. /***/ (function(module, exports) {
  27175. // shim for using process in browser
  27176. var process = module.exports = {};
  27177. // cached from whatever global is present so that test runners that stub it
  27178. // don't break things. But we need to wrap it in a try catch in case it is
  27179. // wrapped in strict mode code which doesn't define any globals. It's inside a
  27180. // function because try/catches deoptimize in certain engines.
  27181. var cachedSetTimeout;
  27182. var cachedClearTimeout;
  27183. function defaultSetTimout() {
  27184. throw new Error('setTimeout has not been defined');
  27185. }
  27186. function defaultClearTimeout () {
  27187. throw new Error('clearTimeout has not been defined');
  27188. }
  27189. (function () {
  27190. try {
  27191. if (typeof setTimeout === 'function') {
  27192. cachedSetTimeout = setTimeout;
  27193. } else {
  27194. cachedSetTimeout = defaultSetTimout;
  27195. }
  27196. } catch (e) {
  27197. cachedSetTimeout = defaultSetTimout;
  27198. }
  27199. try {
  27200. if (typeof clearTimeout === 'function') {
  27201. cachedClearTimeout = clearTimeout;
  27202. } else {
  27203. cachedClearTimeout = defaultClearTimeout;
  27204. }
  27205. } catch (e) {
  27206. cachedClearTimeout = defaultClearTimeout;
  27207. }
  27208. } ())
  27209. function runTimeout(fun) {
  27210. if (cachedSetTimeout === setTimeout) {
  27211. //normal enviroments in sane situations
  27212. return setTimeout(fun, 0);
  27213. }
  27214. // if setTimeout wasn't available but was latter defined
  27215. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  27216. cachedSetTimeout = setTimeout;
  27217. return setTimeout(fun, 0);
  27218. }
  27219. try {
  27220. // when when somebody has screwed with setTimeout but no I.E. maddness
  27221. return cachedSetTimeout(fun, 0);
  27222. } catch(e){
  27223. try {
  27224. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  27225. return cachedSetTimeout.call(null, fun, 0);
  27226. } catch(e){
  27227. // 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
  27228. return cachedSetTimeout.call(this, fun, 0);
  27229. }
  27230. }
  27231. }
  27232. function runClearTimeout(marker) {
  27233. if (cachedClearTimeout === clearTimeout) {
  27234. //normal enviroments in sane situations
  27235. return clearTimeout(marker);
  27236. }
  27237. // if clearTimeout wasn't available but was latter defined
  27238. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  27239. cachedClearTimeout = clearTimeout;
  27240. return clearTimeout(marker);
  27241. }
  27242. try {
  27243. // when when somebody has screwed with setTimeout but no I.E. maddness
  27244. return cachedClearTimeout(marker);
  27245. } catch (e){
  27246. try {
  27247. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  27248. return cachedClearTimeout.call(null, marker);
  27249. } catch (e){
  27250. // 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.
  27251. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  27252. return cachedClearTimeout.call(this, marker);
  27253. }
  27254. }
  27255. }
  27256. var queue = [];
  27257. var draining = false;
  27258. var currentQueue;
  27259. var queueIndex = -1;
  27260. function cleanUpNextTick() {
  27261. if (!draining || !currentQueue) {
  27262. return;
  27263. }
  27264. draining = false;
  27265. if (currentQueue.length) {
  27266. queue = currentQueue.concat(queue);
  27267. } else {
  27268. queueIndex = -1;
  27269. }
  27270. if (queue.length) {
  27271. drainQueue();
  27272. }
  27273. }
  27274. function drainQueue() {
  27275. if (draining) {
  27276. return;
  27277. }
  27278. var timeout = runTimeout(cleanUpNextTick);
  27279. draining = true;
  27280. var len = queue.length;
  27281. while(len) {
  27282. currentQueue = queue;
  27283. queue = [];
  27284. while (++queueIndex < len) {
  27285. if (currentQueue) {
  27286. currentQueue[queueIndex].run();
  27287. }
  27288. }
  27289. queueIndex = -1;
  27290. len = queue.length;
  27291. }
  27292. currentQueue = null;
  27293. draining = false;
  27294. runClearTimeout(timeout);
  27295. }
  27296. process.nextTick = function (fun) {
  27297. var args = new Array(arguments.length - 1);
  27298. if (arguments.length > 1) {
  27299. for (var i = 1; i < arguments.length; i++) {
  27300. args[i - 1] = arguments[i];
  27301. }
  27302. }
  27303. queue.push(new Item(fun, args));
  27304. if (queue.length === 1 && !draining) {
  27305. runTimeout(drainQueue);
  27306. }
  27307. };
  27308. // v8 likes predictible objects
  27309. function Item(fun, array) {
  27310. this.fun = fun;
  27311. this.array = array;
  27312. }
  27313. Item.prototype.run = function () {
  27314. this.fun.apply(null, this.array);
  27315. };
  27316. process.title = 'browser';
  27317. process.browser = true;
  27318. process.env = {};
  27319. process.argv = [];
  27320. process.version = ''; // empty string to avoid regexp issues
  27321. process.versions = {};
  27322. function noop() {}
  27323. process.on = noop;
  27324. process.addListener = noop;
  27325. process.once = noop;
  27326. process.off = noop;
  27327. process.removeListener = noop;
  27328. process.removeAllListeners = noop;
  27329. process.emit = noop;
  27330. process.prependListener = noop;
  27331. process.prependOnceListener = noop;
  27332. process.listeners = function (name) { return [] }
  27333. process.binding = function (name) {
  27334. throw new Error('process.binding is not supported');
  27335. };
  27336. process.cwd = function () { return '/' };
  27337. process.chdir = function (dir) {
  27338. throw new Error('process.chdir is not supported');
  27339. };
  27340. process.umask = function() { return 0; };
  27341. /***/ }),
  27342. /* 21 */
  27343. /***/ (function(module, exports, __webpack_require__) {
  27344. "use strict";
  27345. var utils = __webpack_require__(0);
  27346. module.exports = function normalizeHeaderName(headers, normalizedName) {
  27347. utils.forEach(headers, function processHeader(value, name) {
  27348. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  27349. headers[normalizedName] = value;
  27350. delete headers[name];
  27351. }
  27352. });
  27353. };
  27354. /***/ }),
  27355. /* 22 */
  27356. /***/ (function(module, exports, __webpack_require__) {
  27357. "use strict";
  27358. var createError = __webpack_require__(5);
  27359. /**
  27360. * Resolve or reject a Promise based on response status.
  27361. *
  27362. * @param {Function} resolve A function that resolves the promise.
  27363. * @param {Function} reject A function that rejects the promise.
  27364. * @param {object} response The response.
  27365. */
  27366. module.exports = function settle(resolve, reject, response) {
  27367. var validateStatus = response.config.validateStatus;
  27368. // Note: status is not exposed by XDomainRequest
  27369. if (!response.status || !validateStatus || validateStatus(response.status)) {
  27370. resolve(response);
  27371. } else {
  27372. reject(createError(
  27373. 'Request failed with status code ' + response.status,
  27374. response.config,
  27375. null,
  27376. response.request,
  27377. response
  27378. ));
  27379. }
  27380. };
  27381. /***/ }),
  27382. /* 23 */
  27383. /***/ (function(module, exports, __webpack_require__) {
  27384. "use strict";
  27385. /**
  27386. * Update an Error with the specified config, error code, and response.
  27387. *
  27388. * @param {Error} error The error to update.
  27389. * @param {Object} config The config.
  27390. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  27391. * @param {Object} [request] The request.
  27392. * @param {Object} [response] The response.
  27393. * @returns {Error} The error.
  27394. */
  27395. module.exports = function enhanceError(error, config, code, request, response) {
  27396. error.config = config;
  27397. if (code) {
  27398. error.code = code;
  27399. }
  27400. error.request = request;
  27401. error.response = response;
  27402. return error;
  27403. };
  27404. /***/ }),
  27405. /* 24 */
  27406. /***/ (function(module, exports, __webpack_require__) {
  27407. "use strict";
  27408. var utils = __webpack_require__(0);
  27409. function encode(val) {
  27410. return encodeURIComponent(val).
  27411. replace(/%40/gi, '@').
  27412. replace(/%3A/gi, ':').
  27413. replace(/%24/g, '$').
  27414. replace(/%2C/gi, ',').
  27415. replace(/%20/g, '+').
  27416. replace(/%5B/gi, '[').
  27417. replace(/%5D/gi, ']');
  27418. }
  27419. /**
  27420. * Build a URL by appending params to the end
  27421. *
  27422. * @param {string} url The base of the url (e.g., http://www.google.com)
  27423. * @param {object} [params] The params to be appended
  27424. * @returns {string} The formatted url
  27425. */
  27426. module.exports = function buildURL(url, params, paramsSerializer) {
  27427. /*eslint no-param-reassign:0*/
  27428. if (!params) {
  27429. return url;
  27430. }
  27431. var serializedParams;
  27432. if (paramsSerializer) {
  27433. serializedParams = paramsSerializer(params);
  27434. } else if (utils.isURLSearchParams(params)) {
  27435. serializedParams = params.toString();
  27436. } else {
  27437. var parts = [];
  27438. utils.forEach(params, function serialize(val, key) {
  27439. if (val === null || typeof val === 'undefined') {
  27440. return;
  27441. }
  27442. if (utils.isArray(val)) {
  27443. key = key + '[]';
  27444. }
  27445. if (!utils.isArray(val)) {
  27446. val = [val];
  27447. }
  27448. utils.forEach(val, function parseValue(v) {
  27449. if (utils.isDate(v)) {
  27450. v = v.toISOString();
  27451. } else if (utils.isObject(v)) {
  27452. v = JSON.stringify(v);
  27453. }
  27454. parts.push(encode(key) + '=' + encode(v));
  27455. });
  27456. });
  27457. serializedParams = parts.join('&');
  27458. }
  27459. if (serializedParams) {
  27460. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  27461. }
  27462. return url;
  27463. };
  27464. /***/ }),
  27465. /* 25 */
  27466. /***/ (function(module, exports, __webpack_require__) {
  27467. "use strict";
  27468. var utils = __webpack_require__(0);
  27469. /**
  27470. * Parse headers into an object
  27471. *
  27472. * ```
  27473. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  27474. * Content-Type: application/json
  27475. * Connection: keep-alive
  27476. * Transfer-Encoding: chunked
  27477. * ```
  27478. *
  27479. * @param {String} headers Headers needing to be parsed
  27480. * @returns {Object} Headers parsed into an object
  27481. */
  27482. module.exports = function parseHeaders(headers) {
  27483. var parsed = {};
  27484. var key;
  27485. var val;
  27486. var i;
  27487. if (!headers) { return parsed; }
  27488. utils.forEach(headers.split('\n'), function parser(line) {
  27489. i = line.indexOf(':');
  27490. key = utils.trim(line.substr(0, i)).toLowerCase();
  27491. val = utils.trim(line.substr(i + 1));
  27492. if (key) {
  27493. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  27494. }
  27495. });
  27496. return parsed;
  27497. };
  27498. /***/ }),
  27499. /* 26 */
  27500. /***/ (function(module, exports, __webpack_require__) {
  27501. "use strict";
  27502. var utils = __webpack_require__(0);
  27503. module.exports = (
  27504. utils.isStandardBrowserEnv() ?
  27505. // Standard browser envs have full support of the APIs needed to test
  27506. // whether the request URL is of the same origin as current location.
  27507. (function standardBrowserEnv() {
  27508. var msie = /(msie|trident)/i.test(navigator.userAgent);
  27509. var urlParsingNode = document.createElement('a');
  27510. var originURL;
  27511. /**
  27512. * Parse a URL to discover it's components
  27513. *
  27514. * @param {String} url The URL to be parsed
  27515. * @returns {Object}
  27516. */
  27517. function resolveURL(url) {
  27518. var href = url;
  27519. if (msie) {
  27520. // IE needs attribute set twice to normalize properties
  27521. urlParsingNode.setAttribute('href', href);
  27522. href = urlParsingNode.href;
  27523. }
  27524. urlParsingNode.setAttribute('href', href);
  27525. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  27526. return {
  27527. href: urlParsingNode.href,
  27528. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  27529. host: urlParsingNode.host,
  27530. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  27531. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  27532. hostname: urlParsingNode.hostname,
  27533. port: urlParsingNode.port,
  27534. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  27535. urlParsingNode.pathname :
  27536. '/' + urlParsingNode.pathname
  27537. };
  27538. }
  27539. originURL = resolveURL(window.location.href);
  27540. /**
  27541. * Determine if a URL shares the same origin as the current location
  27542. *
  27543. * @param {String} requestURL The URL to test
  27544. * @returns {boolean} True if URL shares the same origin, otherwise false
  27545. */
  27546. return function isURLSameOrigin(requestURL) {
  27547. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  27548. return (parsed.protocol === originURL.protocol &&
  27549. parsed.host === originURL.host);
  27550. };
  27551. })() :
  27552. // Non standard browser envs (web workers, react-native) lack needed support.
  27553. (function nonStandardBrowserEnv() {
  27554. return function isURLSameOrigin() {
  27555. return true;
  27556. };
  27557. })()
  27558. );
  27559. /***/ }),
  27560. /* 27 */
  27561. /***/ (function(module, exports, __webpack_require__) {
  27562. "use strict";
  27563. // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
  27564. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  27565. function E() {
  27566. this.message = 'String contains an invalid character';
  27567. }
  27568. E.prototype = new Error;
  27569. E.prototype.code = 5;
  27570. E.prototype.name = 'InvalidCharacterError';
  27571. function btoa(input) {
  27572. var str = String(input);
  27573. var output = '';
  27574. for (
  27575. // initialize result and counter
  27576. var block, charCode, idx = 0, map = chars;
  27577. // if the next str index does not exist:
  27578. // change the mapping table to "="
  27579. // check if d has no fractional digits
  27580. str.charAt(idx | 0) || (map = '=', idx % 1);
  27581. // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
  27582. output += map.charAt(63 & block >> 8 - idx % 1 * 8)
  27583. ) {
  27584. charCode = str.charCodeAt(idx += 3 / 4);
  27585. if (charCode > 0xFF) {
  27586. throw new E();
  27587. }
  27588. block = block << 8 | charCode;
  27589. }
  27590. return output;
  27591. }
  27592. module.exports = btoa;
  27593. /***/ }),
  27594. /* 28 */
  27595. /***/ (function(module, exports, __webpack_require__) {
  27596. "use strict";
  27597. var utils = __webpack_require__(0);
  27598. module.exports = (
  27599. utils.isStandardBrowserEnv() ?
  27600. // Standard browser envs support document.cookie
  27601. (function standardBrowserEnv() {
  27602. return {
  27603. write: function write(name, value, expires, path, domain, secure) {
  27604. var cookie = [];
  27605. cookie.push(name + '=' + encodeURIComponent(value));
  27606. if (utils.isNumber(expires)) {
  27607. cookie.push('expires=' + new Date(expires).toGMTString());
  27608. }
  27609. if (utils.isString(path)) {
  27610. cookie.push('path=' + path);
  27611. }
  27612. if (utils.isString(domain)) {
  27613. cookie.push('domain=' + domain);
  27614. }
  27615. if (secure === true) {
  27616. cookie.push('secure');
  27617. }
  27618. document.cookie = cookie.join('; ');
  27619. },
  27620. read: function read(name) {
  27621. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  27622. return (match ? decodeURIComponent(match[3]) : null);
  27623. },
  27624. remove: function remove(name) {
  27625. this.write(name, '', Date.now() - 86400000);
  27626. }
  27627. };
  27628. })() :
  27629. // Non standard browser env (web workers, react-native) lack needed support.
  27630. (function nonStandardBrowserEnv() {
  27631. return {
  27632. write: function write() {},
  27633. read: function read() { return null; },
  27634. remove: function remove() {}
  27635. };
  27636. })()
  27637. );
  27638. /***/ }),
  27639. /* 29 */
  27640. /***/ (function(module, exports, __webpack_require__) {
  27641. "use strict";
  27642. var utils = __webpack_require__(0);
  27643. function InterceptorManager() {
  27644. this.handlers = [];
  27645. }
  27646. /**
  27647. * Add a new interceptor to the stack
  27648. *
  27649. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  27650. * @param {Function} rejected The function to handle `reject` for a `Promise`
  27651. *
  27652. * @return {Number} An ID used to remove interceptor later
  27653. */
  27654. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  27655. this.handlers.push({
  27656. fulfilled: fulfilled,
  27657. rejected: rejected
  27658. });
  27659. return this.handlers.length - 1;
  27660. };
  27661. /**
  27662. * Remove an interceptor from the stack
  27663. *
  27664. * @param {Number} id The ID that was returned by `use`
  27665. */
  27666. InterceptorManager.prototype.eject = function eject(id) {
  27667. if (this.handlers[id]) {
  27668. this.handlers[id] = null;
  27669. }
  27670. };
  27671. /**
  27672. * Iterate over all the registered interceptors
  27673. *
  27674. * This method is particularly useful for skipping over any
  27675. * interceptors that may have become `null` calling `eject`.
  27676. *
  27677. * @param {Function} fn The function to call for each interceptor
  27678. */
  27679. InterceptorManager.prototype.forEach = function forEach(fn) {
  27680. utils.forEach(this.handlers, function forEachHandler(h) {
  27681. if (h !== null) {
  27682. fn(h);
  27683. }
  27684. });
  27685. };
  27686. module.exports = InterceptorManager;
  27687. /***/ }),
  27688. /* 30 */
  27689. /***/ (function(module, exports, __webpack_require__) {
  27690. "use strict";
  27691. var utils = __webpack_require__(0);
  27692. var transformData = __webpack_require__(31);
  27693. var isCancel = __webpack_require__(6);
  27694. var defaults = __webpack_require__(1);
  27695. /**
  27696. * Throws a `Cancel` if cancellation has been requested.
  27697. */
  27698. function throwIfCancellationRequested(config) {
  27699. if (config.cancelToken) {
  27700. config.cancelToken.throwIfRequested();
  27701. }
  27702. }
  27703. /**
  27704. * Dispatch a request to the server using the configured adapter.
  27705. *
  27706. * @param {object} config The config that is to be used for the request
  27707. * @returns {Promise} The Promise to be fulfilled
  27708. */
  27709. module.exports = function dispatchRequest(config) {
  27710. throwIfCancellationRequested(config);
  27711. // Ensure headers exist
  27712. config.headers = config.headers || {};
  27713. // Transform request data
  27714. config.data = transformData(
  27715. config.data,
  27716. config.headers,
  27717. config.transformRequest
  27718. );
  27719. // Flatten headers
  27720. config.headers = utils.merge(
  27721. config.headers.common || {},
  27722. config.headers[config.method] || {},
  27723. config.headers || {}
  27724. );
  27725. utils.forEach(
  27726. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  27727. function cleanHeaderConfig(method) {
  27728. delete config.headers[method];
  27729. }
  27730. );
  27731. var adapter = config.adapter || defaults.adapter;
  27732. return adapter(config).then(function onAdapterResolution(response) {
  27733. throwIfCancellationRequested(config);
  27734. // Transform response data
  27735. response.data = transformData(
  27736. response.data,
  27737. response.headers,
  27738. config.transformResponse
  27739. );
  27740. return response;
  27741. }, function onAdapterRejection(reason) {
  27742. if (!isCancel(reason)) {
  27743. throwIfCancellationRequested(config);
  27744. // Transform response data
  27745. if (reason && reason.response) {
  27746. reason.response.data = transformData(
  27747. reason.response.data,
  27748. reason.response.headers,
  27749. config.transformResponse
  27750. );
  27751. }
  27752. }
  27753. return Promise.reject(reason);
  27754. });
  27755. };
  27756. /***/ }),
  27757. /* 31 */
  27758. /***/ (function(module, exports, __webpack_require__) {
  27759. "use strict";
  27760. var utils = __webpack_require__(0);
  27761. /**
  27762. * Transform the data for a request or a response
  27763. *
  27764. * @param {Object|String} data The data to be transformed
  27765. * @param {Array} headers The headers for the request or response
  27766. * @param {Array|Function} fns A single function or Array of functions
  27767. * @returns {*} The resulting transformed data
  27768. */
  27769. module.exports = function transformData(data, headers, fns) {
  27770. /*eslint no-param-reassign:0*/
  27771. utils.forEach(fns, function transform(fn) {
  27772. data = fn(data, headers);
  27773. });
  27774. return data;
  27775. };
  27776. /***/ }),
  27777. /* 32 */
  27778. /***/ (function(module, exports, __webpack_require__) {
  27779. "use strict";
  27780. /**
  27781. * Determines whether the specified URL is absolute
  27782. *
  27783. * @param {string} url The URL to test
  27784. * @returns {boolean} True if the specified URL is absolute, otherwise false
  27785. */
  27786. module.exports = function isAbsoluteURL(url) {
  27787. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  27788. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  27789. // by any combination of letters, digits, plus, period, or hyphen.
  27790. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  27791. };
  27792. /***/ }),
  27793. /* 33 */
  27794. /***/ (function(module, exports, __webpack_require__) {
  27795. "use strict";
  27796. /**
  27797. * Creates a new URL by combining the specified URLs
  27798. *
  27799. * @param {string} baseURL The base URL
  27800. * @param {string} relativeURL The relative URL
  27801. * @returns {string} The combined URL
  27802. */
  27803. module.exports = function combineURLs(baseURL, relativeURL) {
  27804. return relativeURL
  27805. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  27806. : baseURL;
  27807. };
  27808. /***/ }),
  27809. /* 34 */
  27810. /***/ (function(module, exports, __webpack_require__) {
  27811. "use strict";
  27812. var Cancel = __webpack_require__(7);
  27813. /**
  27814. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  27815. *
  27816. * @class
  27817. * @param {Function} executor The executor function.
  27818. */
  27819. function CancelToken(executor) {
  27820. if (typeof executor !== 'function') {
  27821. throw new TypeError('executor must be a function.');
  27822. }
  27823. var resolvePromise;
  27824. this.promise = new Promise(function promiseExecutor(resolve) {
  27825. resolvePromise = resolve;
  27826. });
  27827. var token = this;
  27828. executor(function cancel(message) {
  27829. if (token.reason) {
  27830. // Cancellation has already been requested
  27831. return;
  27832. }
  27833. token.reason = new Cancel(message);
  27834. resolvePromise(token.reason);
  27835. });
  27836. }
  27837. /**
  27838. * Throws a `Cancel` if cancellation has been requested.
  27839. */
  27840. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  27841. if (this.reason) {
  27842. throw this.reason;
  27843. }
  27844. };
  27845. /**
  27846. * Returns an object that contains a new `CancelToken` and a function that, when called,
  27847. * cancels the `CancelToken`.
  27848. */
  27849. CancelToken.source = function source() {
  27850. var cancel;
  27851. var token = new CancelToken(function executor(c) {
  27852. cancel = c;
  27853. });
  27854. return {
  27855. token: token,
  27856. cancel: cancel
  27857. };
  27858. };
  27859. module.exports = CancelToken;
  27860. /***/ }),
  27861. /* 35 */
  27862. /***/ (function(module, exports, __webpack_require__) {
  27863. "use strict";
  27864. /**
  27865. * Syntactic sugar for invoking a function and expanding an array for arguments.
  27866. *
  27867. * Common use case would be to use `Function.prototype.apply`.
  27868. *
  27869. * ```js
  27870. * function f(x, y, z) {}
  27871. * var args = [1, 2, 3];
  27872. * f.apply(null, args);
  27873. * ```
  27874. *
  27875. * With `spread` this example can be re-written.
  27876. *
  27877. * ```js
  27878. * spread(function(x, y, z) {})([1, 2, 3]);
  27879. * ```
  27880. *
  27881. * @param {Function} callback
  27882. * @returns {Function}
  27883. */
  27884. module.exports = function spread(callback) {
  27885. return function wrap(arr) {
  27886. return callback.apply(null, arr);
  27887. };
  27888. };
  27889. /***/ }),
  27890. /* 36 */
  27891. /***/ (function(module, exports) {
  27892. var asyncGenerator = function () {
  27893. function AwaitValue(value) {
  27894. this.value = value;
  27895. }
  27896. function AsyncGenerator(gen) {
  27897. var front, back;
  27898. function send(key, arg) {
  27899. return new Promise(function (resolve, reject) {
  27900. var request = {
  27901. key: key,
  27902. arg: arg,
  27903. resolve: resolve,
  27904. reject: reject,
  27905. next: null
  27906. };
  27907. if (back) {
  27908. back = back.next = request;
  27909. } else {
  27910. front = back = request;
  27911. resume(key, arg);
  27912. }
  27913. });
  27914. }
  27915. function resume(key, arg) {
  27916. try {
  27917. var result = gen[key](arg);
  27918. var value = result.value;
  27919. if (value instanceof AwaitValue) {
  27920. Promise.resolve(value.value).then(function (arg) {
  27921. resume("next", arg);
  27922. }, function (arg) {
  27923. resume("throw", arg);
  27924. });
  27925. } else {
  27926. settle(result.done ? "return" : "normal", result.value);
  27927. }
  27928. } catch (err) {
  27929. settle("throw", err);
  27930. }
  27931. }
  27932. function settle(type, value) {
  27933. switch (type) {
  27934. case "return":
  27935. front.resolve({
  27936. value: value,
  27937. done: true
  27938. });
  27939. break;
  27940. case "throw":
  27941. front.reject(value);
  27942. break;
  27943. default:
  27944. front.resolve({
  27945. value: value,
  27946. done: false
  27947. });
  27948. break;
  27949. }
  27950. front = front.next;
  27951. if (front) {
  27952. resume(front.key, front.arg);
  27953. } else {
  27954. back = null;
  27955. }
  27956. }
  27957. this._invoke = send;
  27958. if (typeof gen.return !== "function") {
  27959. this.return = undefined;
  27960. }
  27961. }
  27962. if (typeof Symbol === "function" && Symbol.asyncIterator) {
  27963. AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
  27964. return this;
  27965. };
  27966. }
  27967. AsyncGenerator.prototype.next = function (arg) {
  27968. return this._invoke("next", arg);
  27969. };
  27970. AsyncGenerator.prototype.throw = function (arg) {
  27971. return this._invoke("throw", arg);
  27972. };
  27973. AsyncGenerator.prototype.return = function (arg) {
  27974. return this._invoke("return", arg);
  27975. };
  27976. return {
  27977. wrap: function (fn) {
  27978. return function () {
  27979. return new AsyncGenerator(fn.apply(this, arguments));
  27980. };
  27981. },
  27982. await: function (value) {
  27983. return new AwaitValue(value);
  27984. }
  27985. };
  27986. }();
  27987. var classCallCheck = function (instance, Constructor) {
  27988. if (!(instance instanceof Constructor)) {
  27989. throw new TypeError("Cannot call a class as a function");
  27990. }
  27991. };
  27992. var createClass = function () {
  27993. function defineProperties(target, props) {
  27994. for (var i = 0; i < props.length; i++) {
  27995. var descriptor = props[i];
  27996. descriptor.enumerable = descriptor.enumerable || false;
  27997. descriptor.configurable = true;
  27998. if ("value" in descriptor) descriptor.writable = true;
  27999. Object.defineProperty(target, descriptor.key, descriptor);
  28000. }
  28001. }
  28002. return function (Constructor, protoProps, staticProps) {
  28003. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  28004. if (staticProps) defineProperties(Constructor, staticProps);
  28005. return Constructor;
  28006. };
  28007. }();
  28008. var _extends = Object.assign || function (target) {
  28009. for (var i = 1; i < arguments.length; i++) {
  28010. var source = arguments[i];
  28011. for (var key in source) {
  28012. if (Object.prototype.hasOwnProperty.call(source, key)) {
  28013. target[key] = source[key];
  28014. }
  28015. }
  28016. }
  28017. return target;
  28018. };
  28019. var inherits = function (subClass, superClass) {
  28020. if (typeof superClass !== "function" && superClass !== null) {
  28021. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  28022. }
  28023. subClass.prototype = Object.create(superClass && superClass.prototype, {
  28024. constructor: {
  28025. value: subClass,
  28026. enumerable: false,
  28027. writable: true,
  28028. configurable: true
  28029. }
  28030. });
  28031. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  28032. };
  28033. var possibleConstructorReturn = function (self, call) {
  28034. if (!self) {
  28035. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  28036. }
  28037. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  28038. };
  28039. var Connector = function () {
  28040. function Connector(options) {
  28041. classCallCheck(this, Connector);
  28042. this._defaultOptions = {
  28043. auth: {
  28044. headers: {}
  28045. },
  28046. authEndpoint: '/broadcasting/auth',
  28047. broadcaster: 'pusher',
  28048. csrfToken: null,
  28049. host: null,
  28050. key: null,
  28051. namespace: 'App.Events'
  28052. };
  28053. this.setOptions(options);
  28054. this.connect();
  28055. }
  28056. createClass(Connector, [{
  28057. key: 'setOptions',
  28058. value: function setOptions(options) {
  28059. this.options = _extends(this._defaultOptions, options);
  28060. if (this.csrfToken()) {
  28061. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  28062. }
  28063. return options;
  28064. }
  28065. }, {
  28066. key: 'csrfToken',
  28067. value: function csrfToken() {
  28068. var selector = void 0;
  28069. if (window && window['Laravel'] && window['Laravel'].csrfToken) {
  28070. return window['Laravel'].csrfToken;
  28071. } else if (this.options.csrfToken) {
  28072. return this.options.csrfToken;
  28073. } else if (typeof document !== 'undefined' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  28074. return selector.getAttribute('content');
  28075. }
  28076. return null;
  28077. }
  28078. }]);
  28079. return Connector;
  28080. }();
  28081. var Channel = function () {
  28082. function Channel() {
  28083. classCallCheck(this, Channel);
  28084. }
  28085. createClass(Channel, [{
  28086. key: 'notification',
  28087. value: function notification(callback) {
  28088. return this.listen('.Illuminate.Notifications.Events.BroadcastNotificationCreated', callback);
  28089. }
  28090. }, {
  28091. key: 'listenForWhisper',
  28092. value: function listenForWhisper(event, callback) {
  28093. return this.listen('.client-' + event, callback);
  28094. }
  28095. }]);
  28096. return Channel;
  28097. }();
  28098. var EventFormatter = function () {
  28099. function EventFormatter(namespace) {
  28100. classCallCheck(this, EventFormatter);
  28101. this.setNamespace(namespace);
  28102. }
  28103. createClass(EventFormatter, [{
  28104. key: 'format',
  28105. value: function format(event) {
  28106. if (this.namespace) {
  28107. if (event.charAt(0) != '\\' && event.charAt(0) != '.') {
  28108. event = this.namespace + '.' + event;
  28109. } else {
  28110. event = event.substr(1);
  28111. }
  28112. }
  28113. return event.replace(/\./g, '\\');
  28114. }
  28115. }, {
  28116. key: 'setNamespace',
  28117. value: function setNamespace(value) {
  28118. this.namespace = value;
  28119. }
  28120. }]);
  28121. return EventFormatter;
  28122. }();
  28123. var PusherChannel = function (_Channel) {
  28124. inherits(PusherChannel, _Channel);
  28125. function PusherChannel(pusher, name, options) {
  28126. classCallCheck(this, PusherChannel);
  28127. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  28128. _this.name = name;
  28129. _this.pusher = pusher;
  28130. _this.options = options;
  28131. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  28132. _this.subscribe();
  28133. return _this;
  28134. }
  28135. createClass(PusherChannel, [{
  28136. key: 'subscribe',
  28137. value: function subscribe() {
  28138. this.subscription = this.pusher.subscribe(this.name);
  28139. }
  28140. }, {
  28141. key: 'unsubscribe',
  28142. value: function unsubscribe() {
  28143. this.pusher.unsubscribe(this.name);
  28144. }
  28145. }, {
  28146. key: 'listen',
  28147. value: function listen(event, callback) {
  28148. this.on(this.eventFormatter.format(event), callback);
  28149. return this;
  28150. }
  28151. }, {
  28152. key: 'stopListening',
  28153. value: function stopListening(event) {
  28154. this.subscription.unbind(this.eventFormatter.format(event));
  28155. return this;
  28156. }
  28157. }, {
  28158. key: 'on',
  28159. value: function on(event, callback) {
  28160. this.subscription.bind(event, callback);
  28161. return this;
  28162. }
  28163. }]);
  28164. return PusherChannel;
  28165. }(Channel);
  28166. var PusherPrivateChannel = function (_PusherChannel) {
  28167. inherits(PusherPrivateChannel, _PusherChannel);
  28168. function PusherPrivateChannel() {
  28169. classCallCheck(this, PusherPrivateChannel);
  28170. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  28171. }
  28172. createClass(PusherPrivateChannel, [{
  28173. key: 'whisper',
  28174. value: function whisper(eventName, data) {
  28175. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  28176. return this;
  28177. }
  28178. }]);
  28179. return PusherPrivateChannel;
  28180. }(PusherChannel);
  28181. var PusherPresenceChannel = function (_PusherChannel) {
  28182. inherits(PusherPresenceChannel, _PusherChannel);
  28183. function PusherPresenceChannel() {
  28184. classCallCheck(this, PusherPresenceChannel);
  28185. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  28186. }
  28187. createClass(PusherPresenceChannel, [{
  28188. key: 'here',
  28189. value: function here(callback) {
  28190. this.on('pusher:subscription_succeeded', function (data) {
  28191. callback(Object.keys(data.members).map(function (k) {
  28192. return data.members[k];
  28193. }));
  28194. });
  28195. return this;
  28196. }
  28197. }, {
  28198. key: 'joining',
  28199. value: function joining(callback) {
  28200. this.on('pusher:member_added', function (member) {
  28201. callback(member.info);
  28202. });
  28203. return this;
  28204. }
  28205. }, {
  28206. key: 'leaving',
  28207. value: function leaving(callback) {
  28208. this.on('pusher:member_removed', function (member) {
  28209. callback(member.info);
  28210. });
  28211. return this;
  28212. }
  28213. }, {
  28214. key: 'whisper',
  28215. value: function whisper(eventName, data) {
  28216. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  28217. return this;
  28218. }
  28219. }]);
  28220. return PusherPresenceChannel;
  28221. }(PusherChannel);
  28222. var SocketIoChannel = function (_Channel) {
  28223. inherits(SocketIoChannel, _Channel);
  28224. function SocketIoChannel(socket, name, options) {
  28225. classCallCheck(this, SocketIoChannel);
  28226. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  28227. _this.events = {};
  28228. _this.name = name;
  28229. _this.socket = socket;
  28230. _this.options = options;
  28231. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  28232. _this.subscribe();
  28233. _this.configureReconnector();
  28234. return _this;
  28235. }
  28236. createClass(SocketIoChannel, [{
  28237. key: 'subscribe',
  28238. value: function subscribe() {
  28239. this.socket.emit('subscribe', {
  28240. channel: this.name,
  28241. auth: this.options.auth || {}
  28242. });
  28243. }
  28244. }, {
  28245. key: 'unsubscribe',
  28246. value: function unsubscribe() {
  28247. this.unbind();
  28248. this.socket.emit('unsubscribe', {
  28249. channel: this.name,
  28250. auth: this.options.auth || {}
  28251. });
  28252. }
  28253. }, {
  28254. key: 'listen',
  28255. value: function listen(event, callback) {
  28256. this.on(this.eventFormatter.format(event), callback);
  28257. return this;
  28258. }
  28259. }, {
  28260. key: 'on',
  28261. value: function on(event, callback) {
  28262. var _this2 = this;
  28263. var listener = function listener(channel, data) {
  28264. if (_this2.name == channel) {
  28265. callback(data);
  28266. }
  28267. };
  28268. this.socket.on(event, listener);
  28269. this.bind(event, listener);
  28270. }
  28271. }, {
  28272. key: 'configureReconnector',
  28273. value: function configureReconnector() {
  28274. var _this3 = this;
  28275. var listener = function listener() {
  28276. _this3.subscribe();
  28277. };
  28278. this.socket.on('reconnect', listener);
  28279. this.bind('reconnect', listener);
  28280. }
  28281. }, {
  28282. key: 'bind',
  28283. value: function bind(event, callback) {
  28284. this.events[event] = this.events[event] || [];
  28285. this.events[event].push(callback);
  28286. }
  28287. }, {
  28288. key: 'unbind',
  28289. value: function unbind() {
  28290. var _this4 = this;
  28291. Object.keys(this.events).forEach(function (event) {
  28292. _this4.events[event].forEach(function (callback) {
  28293. _this4.socket.removeListener(event, callback);
  28294. });
  28295. delete _this4.events[event];
  28296. });
  28297. }
  28298. }]);
  28299. return SocketIoChannel;
  28300. }(Channel);
  28301. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  28302. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  28303. function SocketIoPrivateChannel() {
  28304. classCallCheck(this, SocketIoPrivateChannel);
  28305. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  28306. }
  28307. createClass(SocketIoPrivateChannel, [{
  28308. key: 'whisper',
  28309. value: function whisper(eventName, data) {
  28310. this.socket.emit('client event', {
  28311. channel: this.name,
  28312. event: 'client-' + eventName,
  28313. data: data
  28314. });
  28315. return this;
  28316. }
  28317. }]);
  28318. return SocketIoPrivateChannel;
  28319. }(SocketIoChannel);
  28320. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  28321. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  28322. function SocketIoPresenceChannel() {
  28323. classCallCheck(this, SocketIoPresenceChannel);
  28324. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  28325. }
  28326. createClass(SocketIoPresenceChannel, [{
  28327. key: 'here',
  28328. value: function here(callback) {
  28329. this.on('presence:subscribed', function (members) {
  28330. callback(members.map(function (m) {
  28331. return m.user_info;
  28332. }));
  28333. });
  28334. return this;
  28335. }
  28336. }, {
  28337. key: 'joining',
  28338. value: function joining(callback) {
  28339. this.on('presence:joining', function (member) {
  28340. return callback(member.user_info);
  28341. });
  28342. return this;
  28343. }
  28344. }, {
  28345. key: 'leaving',
  28346. value: function leaving(callback) {
  28347. this.on('presence:leaving', function (member) {
  28348. return callback(member.user_info);
  28349. });
  28350. return this;
  28351. }
  28352. }]);
  28353. return SocketIoPresenceChannel;
  28354. }(SocketIoPrivateChannel);
  28355. var PusherConnector = function (_Connector) {
  28356. inherits(PusherConnector, _Connector);
  28357. function PusherConnector() {
  28358. var _ref;
  28359. classCallCheck(this, PusherConnector);
  28360. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  28361. args[_key] = arguments[_key];
  28362. }
  28363. var _this = possibleConstructorReturn(this, (_ref = PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).call.apply(_ref, [this].concat(args)));
  28364. _this.channels = {};
  28365. return _this;
  28366. }
  28367. createClass(PusherConnector, [{
  28368. key: 'connect',
  28369. value: function connect() {
  28370. this.pusher = new Pusher(this.options.key, this.options);
  28371. }
  28372. }, {
  28373. key: 'listen',
  28374. value: function listen(name, event, callback) {
  28375. return this.channel(name).listen(event, callback);
  28376. }
  28377. }, {
  28378. key: 'channel',
  28379. value: function channel(name) {
  28380. if (!this.channels[name]) {
  28381. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  28382. }
  28383. return this.channels[name];
  28384. }
  28385. }, {
  28386. key: 'privateChannel',
  28387. value: function privateChannel(name) {
  28388. if (!this.channels['private-' + name]) {
  28389. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  28390. }
  28391. return this.channels['private-' + name];
  28392. }
  28393. }, {
  28394. key: 'presenceChannel',
  28395. value: function presenceChannel(name) {
  28396. if (!this.channels['presence-' + name]) {
  28397. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  28398. }
  28399. return this.channels['presence-' + name];
  28400. }
  28401. }, {
  28402. key: 'leave',
  28403. value: function leave(name) {
  28404. var _this2 = this;
  28405. var channels = [name, 'private-' + name, 'presence-' + name];
  28406. channels.forEach(function (name, index) {
  28407. if (_this2.channels[name]) {
  28408. _this2.channels[name].unsubscribe();
  28409. delete _this2.channels[name];
  28410. }
  28411. });
  28412. }
  28413. }, {
  28414. key: 'socketId',
  28415. value: function socketId() {
  28416. return this.pusher.connection.socket_id;
  28417. }
  28418. }]);
  28419. return PusherConnector;
  28420. }(Connector);
  28421. var SocketIoConnector = function (_Connector) {
  28422. inherits(SocketIoConnector, _Connector);
  28423. function SocketIoConnector() {
  28424. var _ref;
  28425. classCallCheck(this, SocketIoConnector);
  28426. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  28427. args[_key] = arguments[_key];
  28428. }
  28429. var _this = possibleConstructorReturn(this, (_ref = SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).call.apply(_ref, [this].concat(args)));
  28430. _this.channels = {};
  28431. return _this;
  28432. }
  28433. createClass(SocketIoConnector, [{
  28434. key: 'connect',
  28435. value: function connect() {
  28436. this.socket = io(this.options.host, this.options);
  28437. return this.socket;
  28438. }
  28439. }, {
  28440. key: 'listen',
  28441. value: function listen(name, event, callback) {
  28442. return this.channel(name).listen(event, callback);
  28443. }
  28444. }, {
  28445. key: 'channel',
  28446. value: function channel(name) {
  28447. if (!this.channels[name]) {
  28448. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  28449. }
  28450. return this.channels[name];
  28451. }
  28452. }, {
  28453. key: 'privateChannel',
  28454. value: function privateChannel(name) {
  28455. if (!this.channels['private-' + name]) {
  28456. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  28457. }
  28458. return this.channels['private-' + name];
  28459. }
  28460. }, {
  28461. key: 'presenceChannel',
  28462. value: function presenceChannel(name) {
  28463. if (!this.channels['presence-' + name]) {
  28464. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  28465. }
  28466. return this.channels['presence-' + name];
  28467. }
  28468. }, {
  28469. key: 'leave',
  28470. value: function leave(name) {
  28471. var _this2 = this;
  28472. var channels = [name, 'private-' + name, 'presence-' + name];
  28473. channels.forEach(function (name) {
  28474. if (_this2.channels[name]) {
  28475. _this2.channels[name].unsubscribe();
  28476. delete _this2.channels[name];
  28477. }
  28478. });
  28479. }
  28480. }, {
  28481. key: 'socketId',
  28482. value: function socketId() {
  28483. return this.socket.id;
  28484. }
  28485. }]);
  28486. return SocketIoConnector;
  28487. }(Connector);
  28488. var Echo = function () {
  28489. function Echo(options) {
  28490. classCallCheck(this, Echo);
  28491. this.options = options;
  28492. if (typeof Vue === 'function' && Vue.http) {
  28493. this.registerVueRequestInterceptor();
  28494. }
  28495. if (typeof axios === 'function') {
  28496. this.registerAxiosRequestInterceptor();
  28497. }
  28498. if (typeof jQuery === 'function') {
  28499. this.registerjQueryAjaxSetup();
  28500. }
  28501. if (this.options.broadcaster == 'pusher') {
  28502. this.connector = new PusherConnector(this.options);
  28503. } else if (this.options.broadcaster == 'socket.io') {
  28504. this.connector = new SocketIoConnector(this.options);
  28505. }
  28506. }
  28507. createClass(Echo, [{
  28508. key: 'registerVueRequestInterceptor',
  28509. value: function registerVueRequestInterceptor() {
  28510. var _this = this;
  28511. Vue.http.interceptors.push(function (request, next) {
  28512. if (_this.socketId()) {
  28513. request.headers.set('X-Socket-ID', _this.socketId());
  28514. }
  28515. next();
  28516. });
  28517. }
  28518. }, {
  28519. key: 'registerAxiosRequestInterceptor',
  28520. value: function registerAxiosRequestInterceptor() {
  28521. var _this2 = this;
  28522. axios.interceptors.request.use(function (config) {
  28523. if (_this2.socketId()) {
  28524. config.headers['X-Socket-Id'] = _this2.socketId();
  28525. }
  28526. return config;
  28527. });
  28528. }
  28529. }, {
  28530. key: 'registerjQueryAjaxSetup',
  28531. value: function registerjQueryAjaxSetup() {
  28532. var _this3 = this;
  28533. if (typeof jQuery.ajax != 'undefined') {
  28534. jQuery.ajaxSetup({
  28535. beforeSend: function beforeSend(xhr) {
  28536. if (_this3.socketId()) {
  28537. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  28538. }
  28539. }
  28540. });
  28541. }
  28542. }
  28543. }, {
  28544. key: 'listen',
  28545. value: function listen(channel, event, callback) {
  28546. return this.connector.listen(channel, event, callback);
  28547. }
  28548. }, {
  28549. key: 'channel',
  28550. value: function channel(_channel) {
  28551. return this.connector.channel(_channel);
  28552. }
  28553. }, {
  28554. key: 'private',
  28555. value: function _private(channel) {
  28556. return this.connector.privateChannel(channel);
  28557. }
  28558. }, {
  28559. key: 'join',
  28560. value: function join(channel) {
  28561. return this.connector.presenceChannel(channel);
  28562. }
  28563. }, {
  28564. key: 'leave',
  28565. value: function leave(channel) {
  28566. this.connector.leave(channel);
  28567. }
  28568. }, {
  28569. key: 'socketId',
  28570. value: function socketId() {
  28571. return this.connector.socketId();
  28572. }
  28573. }]);
  28574. return Echo;
  28575. }();
  28576. module.exports = Echo;
  28577. /***/ }),
  28578. /* 37 */
  28579. /***/ (function(module, exports, __webpack_require__) {
  28580. /*!
  28581. * Pusher JavaScript Library v4.1.0
  28582. * https://pusher.com/
  28583. *
  28584. * Copyright 2017, Pusher
  28585. * Released under the MIT licence.
  28586. */
  28587. (function webpackUniversalModuleDefinition(root, factory) {
  28588. if(true)
  28589. module.exports = factory();
  28590. else if(typeof define === 'function' && define.amd)
  28591. define([], factory);
  28592. else if(typeof exports === 'object')
  28593. exports["Pusher"] = factory();
  28594. else
  28595. root["Pusher"] = factory();
  28596. })(this, function() {
  28597. return /******/ (function(modules) { // webpackBootstrap
  28598. /******/ // The module cache
  28599. /******/ var installedModules = {};
  28600. /******/ // The require function
  28601. /******/ function __webpack_require__(moduleId) {
  28602. /******/ // Check if module is in cache
  28603. /******/ if(installedModules[moduleId])
  28604. /******/ return installedModules[moduleId].exports;
  28605. /******/ // Create a new module (and put it into the cache)
  28606. /******/ var module = installedModules[moduleId] = {
  28607. /******/ exports: {},
  28608. /******/ id: moduleId,
  28609. /******/ loaded: false
  28610. /******/ };
  28611. /******/ // Execute the module function
  28612. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  28613. /******/ // Flag the module as loaded
  28614. /******/ module.loaded = true;
  28615. /******/ // Return the exports of the module
  28616. /******/ return module.exports;
  28617. /******/ }
  28618. /******/ // expose the modules object (__webpack_modules__)
  28619. /******/ __webpack_require__.m = modules;
  28620. /******/ // expose the module cache
  28621. /******/ __webpack_require__.c = installedModules;
  28622. /******/ // __webpack_public_path__
  28623. /******/ __webpack_require__.p = "";
  28624. /******/ // Load entry module and return exports
  28625. /******/ return __webpack_require__(0);
  28626. /******/ })
  28627. /************************************************************************/
  28628. /******/ ([
  28629. /* 0 */
  28630. /***/ (function(module, exports, __webpack_require__) {
  28631. "use strict";
  28632. var pusher_1 = __webpack_require__(1);
  28633. module.exports = pusher_1["default"];
  28634. /***/ }),
  28635. /* 1 */
  28636. /***/ (function(module, exports, __webpack_require__) {
  28637. "use strict";
  28638. var runtime_1 = __webpack_require__(2);
  28639. var Collections = __webpack_require__(9);
  28640. var dispatcher_1 = __webpack_require__(23);
  28641. var timeline_1 = __webpack_require__(38);
  28642. var level_1 = __webpack_require__(39);
  28643. var StrategyBuilder = __webpack_require__(40);
  28644. var timers_1 = __webpack_require__(12);
  28645. var defaults_1 = __webpack_require__(5);
  28646. var DefaultConfig = __webpack_require__(62);
  28647. var logger_1 = __webpack_require__(8);
  28648. var factory_1 = __webpack_require__(42);
  28649. var Pusher = (function () {
  28650. function Pusher(app_key, options) {
  28651. var _this = this;
  28652. checkAppKey(app_key);
  28653. options = options || {};
  28654. this.key = app_key;
  28655. this.config = Collections.extend(DefaultConfig.getGlobalConfig(), options.cluster ? DefaultConfig.getClusterConfig(options.cluster) : {}, options);
  28656. this.channels = factory_1["default"].createChannels();
  28657. this.global_emitter = new dispatcher_1["default"]();
  28658. this.sessionID = Math.floor(Math.random() * 1000000000);
  28659. this.timeline = new timeline_1["default"](this.key, this.sessionID, {
  28660. cluster: this.config.cluster,
  28661. features: Pusher.getClientFeatures(),
  28662. params: this.config.timelineParams || {},
  28663. limit: 50,
  28664. level: level_1["default"].INFO,
  28665. version: defaults_1["default"].VERSION
  28666. });
  28667. if (!this.config.disableStats) {
  28668. this.timelineSender = factory_1["default"].createTimelineSender(this.timeline, {
  28669. host: this.config.statsHost,
  28670. path: "/timeline/v2/" + runtime_1["default"].TimelineTransport.name
  28671. });
  28672. }
  28673. var getStrategy = function (options) {
  28674. var config = Collections.extend({}, _this.config, options);
  28675. return StrategyBuilder.build(runtime_1["default"].getDefaultStrategy(config), config);
  28676. };
  28677. this.connection = factory_1["default"].createConnectionManager(this.key, Collections.extend({ getStrategy: getStrategy,
  28678. timeline: this.timeline,
  28679. activityTimeout: this.config.activity_timeout,
  28680. pongTimeout: this.config.pong_timeout,
  28681. unavailableTimeout: this.config.unavailable_timeout
  28682. }, this.config, { encrypted: this.isEncrypted() }));
  28683. this.connection.bind('connected', function () {
  28684. _this.subscribeAll();
  28685. if (_this.timelineSender) {
  28686. _this.timelineSender.send(_this.connection.isEncrypted());
  28687. }
  28688. });
  28689. this.connection.bind('message', function (params) {
  28690. var internal = (params.event.indexOf('pusher_internal:') === 0);
  28691. if (params.channel) {
  28692. var channel = _this.channel(params.channel);
  28693. if (channel) {
  28694. channel.handleEvent(params.event, params.data);
  28695. }
  28696. }
  28697. if (!internal) {
  28698. _this.global_emitter.emit(params.event, params.data);
  28699. }
  28700. });
  28701. this.connection.bind('connecting', function () {
  28702. _this.channels.disconnect();
  28703. });
  28704. this.connection.bind('disconnected', function () {
  28705. _this.channels.disconnect();
  28706. });
  28707. this.connection.bind('error', function (err) {
  28708. logger_1["default"].warn('Error', err);
  28709. });
  28710. Pusher.instances.push(this);
  28711. this.timeline.info({ instances: Pusher.instances.length });
  28712. if (Pusher.isReady) {
  28713. this.connect();
  28714. }
  28715. }
  28716. Pusher.ready = function () {
  28717. Pusher.isReady = true;
  28718. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  28719. Pusher.instances[i].connect();
  28720. }
  28721. };
  28722. Pusher.log = function (message) {
  28723. if (Pusher.logToConsole && (window).console && (window).console.log) {
  28724. (window).console.log(message);
  28725. }
  28726. };
  28727. Pusher.getClientFeatures = function () {
  28728. return Collections.keys(Collections.filterObject({ "ws": runtime_1["default"].Transports.ws }, function (t) { return t.isSupported({}); }));
  28729. };
  28730. Pusher.prototype.channel = function (name) {
  28731. return this.channels.find(name);
  28732. };
  28733. Pusher.prototype.allChannels = function () {
  28734. return this.channels.all();
  28735. };
  28736. Pusher.prototype.connect = function () {
  28737. this.connection.connect();
  28738. if (this.timelineSender) {
  28739. if (!this.timelineSenderTimer) {
  28740. var encrypted = this.connection.isEncrypted();
  28741. var timelineSender = this.timelineSender;
  28742. this.timelineSenderTimer = new timers_1.PeriodicTimer(60000, function () {
  28743. timelineSender.send(encrypted);
  28744. });
  28745. }
  28746. }
  28747. };
  28748. Pusher.prototype.disconnect = function () {
  28749. this.connection.disconnect();
  28750. if (this.timelineSenderTimer) {
  28751. this.timelineSenderTimer.ensureAborted();
  28752. this.timelineSenderTimer = null;
  28753. }
  28754. };
  28755. Pusher.prototype.bind = function (event_name, callback, context) {
  28756. this.global_emitter.bind(event_name, callback, context);
  28757. return this;
  28758. };
  28759. Pusher.prototype.unbind = function (event_name, callback, context) {
  28760. this.global_emitter.unbind(event_name, callback, context);
  28761. return this;
  28762. };
  28763. Pusher.prototype.bind_global = function (callback) {
  28764. this.global_emitter.bind_global(callback);
  28765. return this;
  28766. };
  28767. Pusher.prototype.unbind_global = function (callback) {
  28768. this.global_emitter.unbind_global(callback);
  28769. return this;
  28770. };
  28771. Pusher.prototype.unbind_all = function (callback) {
  28772. this.global_emitter.unbind_all();
  28773. return this;
  28774. };
  28775. Pusher.prototype.subscribeAll = function () {
  28776. var channelName;
  28777. for (channelName in this.channels.channels) {
  28778. if (this.channels.channels.hasOwnProperty(channelName)) {
  28779. this.subscribe(channelName);
  28780. }
  28781. }
  28782. };
  28783. Pusher.prototype.subscribe = function (channel_name) {
  28784. var channel = this.channels.add(channel_name, this);
  28785. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  28786. channel.reinstateSubscription();
  28787. }
  28788. else if (!channel.subscriptionPending && this.connection.state === "connected") {
  28789. channel.subscribe();
  28790. }
  28791. return channel;
  28792. };
  28793. Pusher.prototype.unsubscribe = function (channel_name) {
  28794. var channel = this.channels.find(channel_name);
  28795. if (channel && channel.subscriptionPending) {
  28796. channel.cancelSubscription();
  28797. }
  28798. else {
  28799. channel = this.channels.remove(channel_name);
  28800. if (channel && this.connection.state === "connected") {
  28801. channel.unsubscribe();
  28802. }
  28803. }
  28804. };
  28805. Pusher.prototype.send_event = function (event_name, data, channel) {
  28806. return this.connection.send_event(event_name, data, channel);
  28807. };
  28808. Pusher.prototype.isEncrypted = function () {
  28809. if (runtime_1["default"].getProtocol() === "https:") {
  28810. return true;
  28811. }
  28812. else {
  28813. return Boolean(this.config.encrypted);
  28814. }
  28815. };
  28816. Pusher.instances = [];
  28817. Pusher.isReady = false;
  28818. Pusher.logToConsole = false;
  28819. Pusher.Runtime = runtime_1["default"];
  28820. Pusher.ScriptReceivers = runtime_1["default"].ScriptReceivers;
  28821. Pusher.DependenciesReceivers = runtime_1["default"].DependenciesReceivers;
  28822. Pusher.auth_callbacks = runtime_1["default"].auth_callbacks;
  28823. return Pusher;
  28824. }());
  28825. exports.__esModule = true;
  28826. exports["default"] = Pusher;
  28827. function checkAppKey(key) {
  28828. if (key === null || key === undefined) {
  28829. throw "You must pass your app key when you instantiate Pusher.";
  28830. }
  28831. }
  28832. runtime_1["default"].setup(Pusher);
  28833. /***/ }),
  28834. /* 2 */
  28835. /***/ (function(module, exports, __webpack_require__) {
  28836. "use strict";
  28837. var dependencies_1 = __webpack_require__(3);
  28838. var xhr_auth_1 = __webpack_require__(7);
  28839. var jsonp_auth_1 = __webpack_require__(14);
  28840. var script_request_1 = __webpack_require__(15);
  28841. var jsonp_request_1 = __webpack_require__(16);
  28842. var script_receiver_factory_1 = __webpack_require__(4);
  28843. var jsonp_timeline_1 = __webpack_require__(17);
  28844. var transports_1 = __webpack_require__(18);
  28845. var net_info_1 = __webpack_require__(25);
  28846. var default_strategy_1 = __webpack_require__(26);
  28847. var transport_connection_initializer_1 = __webpack_require__(27);
  28848. var http_1 = __webpack_require__(28);
  28849. var Runtime = {
  28850. nextAuthCallbackID: 1,
  28851. auth_callbacks: {},
  28852. ScriptReceivers: script_receiver_factory_1.ScriptReceivers,
  28853. DependenciesReceivers: dependencies_1.DependenciesReceivers,
  28854. getDefaultStrategy: default_strategy_1["default"],
  28855. Transports: transports_1["default"],
  28856. transportConnectionInitializer: transport_connection_initializer_1["default"],
  28857. HTTPFactory: http_1["default"],
  28858. TimelineTransport: jsonp_timeline_1["default"],
  28859. getXHRAPI: function () {
  28860. return window.XMLHttpRequest;
  28861. },
  28862. getWebSocketAPI: function () {
  28863. return window.WebSocket || window.MozWebSocket;
  28864. },
  28865. setup: function (PusherClass) {
  28866. var _this = this;
  28867. window.Pusher = PusherClass;
  28868. var initializeOnDocumentBody = function () {
  28869. _this.onDocumentBody(PusherClass.ready);
  28870. };
  28871. if (!window.JSON) {
  28872. dependencies_1.Dependencies.load("json2", {}, initializeOnDocumentBody);
  28873. }
  28874. else {
  28875. initializeOnDocumentBody();
  28876. }
  28877. },
  28878. getDocument: function () {
  28879. return document;
  28880. },
  28881. getProtocol: function () {
  28882. return this.getDocument().location.protocol;
  28883. },
  28884. getAuthorizers: function () {
  28885. return { ajax: xhr_auth_1["default"], jsonp: jsonp_auth_1["default"] };
  28886. },
  28887. onDocumentBody: function (callback) {
  28888. var _this = this;
  28889. if (document.body) {
  28890. callback();
  28891. }
  28892. else {
  28893. setTimeout(function () {
  28894. _this.onDocumentBody(callback);
  28895. }, 0);
  28896. }
  28897. },
  28898. createJSONPRequest: function (url, data) {
  28899. return new jsonp_request_1["default"](url, data);
  28900. },
  28901. createScriptRequest: function (src) {
  28902. return new script_request_1["default"](src);
  28903. },
  28904. getLocalStorage: function () {
  28905. try {
  28906. return window.localStorage;
  28907. }
  28908. catch (e) {
  28909. return undefined;
  28910. }
  28911. },
  28912. createXHR: function () {
  28913. if (this.getXHRAPI()) {
  28914. return this.createXMLHttpRequest();
  28915. }
  28916. else {
  28917. return this.createMicrosoftXHR();
  28918. }
  28919. },
  28920. createXMLHttpRequest: function () {
  28921. var Constructor = this.getXHRAPI();
  28922. return new Constructor();
  28923. },
  28924. createMicrosoftXHR: function () {
  28925. return new ActiveXObject("Microsoft.XMLHTTP");
  28926. },
  28927. getNetwork: function () {
  28928. return net_info_1.Network;
  28929. },
  28930. createWebSocket: function (url) {
  28931. var Constructor = this.getWebSocketAPI();
  28932. return new Constructor(url);
  28933. },
  28934. createSocketRequest: function (method, url) {
  28935. if (this.isXHRSupported()) {
  28936. return this.HTTPFactory.createXHR(method, url);
  28937. }
  28938. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  28939. return this.HTTPFactory.createXDR(method, url);
  28940. }
  28941. else {
  28942. throw "Cross-origin HTTP requests are not supported";
  28943. }
  28944. },
  28945. isXHRSupported: function () {
  28946. var Constructor = this.getXHRAPI();
  28947. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  28948. },
  28949. isXDRSupported: function (encrypted) {
  28950. var protocol = encrypted ? "https:" : "http:";
  28951. var documentProtocol = this.getProtocol();
  28952. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  28953. },
  28954. addUnloadListener: function (listener) {
  28955. if (window.addEventListener !== undefined) {
  28956. window.addEventListener("unload", listener, false);
  28957. }
  28958. else if (window.attachEvent !== undefined) {
  28959. window.attachEvent("onunload", listener);
  28960. }
  28961. },
  28962. removeUnloadListener: function (listener) {
  28963. if (window.addEventListener !== undefined) {
  28964. window.removeEventListener("unload", listener, false);
  28965. }
  28966. else if (window.detachEvent !== undefined) {
  28967. window.detachEvent("onunload", listener);
  28968. }
  28969. }
  28970. };
  28971. exports.__esModule = true;
  28972. exports["default"] = Runtime;
  28973. /***/ }),
  28974. /* 3 */
  28975. /***/ (function(module, exports, __webpack_require__) {
  28976. "use strict";
  28977. var script_receiver_factory_1 = __webpack_require__(4);
  28978. var defaults_1 = __webpack_require__(5);
  28979. var dependency_loader_1 = __webpack_require__(6);
  28980. exports.DependenciesReceivers = new script_receiver_factory_1.ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  28981. exports.Dependencies = new dependency_loader_1["default"]({
  28982. cdn_http: defaults_1["default"].cdn_http,
  28983. cdn_https: defaults_1["default"].cdn_https,
  28984. version: defaults_1["default"].VERSION,
  28985. suffix: defaults_1["default"].dependency_suffix,
  28986. receivers: exports.DependenciesReceivers
  28987. });
  28988. /***/ }),
  28989. /* 4 */
  28990. /***/ (function(module, exports) {
  28991. "use strict";
  28992. var ScriptReceiverFactory = (function () {
  28993. function ScriptReceiverFactory(prefix, name) {
  28994. this.lastId = 0;
  28995. this.prefix = prefix;
  28996. this.name = name;
  28997. }
  28998. ScriptReceiverFactory.prototype.create = function (callback) {
  28999. this.lastId++;
  29000. var number = this.lastId;
  29001. var id = this.prefix + number;
  29002. var name = this.name + "[" + number + "]";
  29003. var called = false;
  29004. var callbackWrapper = function () {
  29005. if (!called) {
  29006. callback.apply(null, arguments);
  29007. called = true;
  29008. }
  29009. };
  29010. this[number] = callbackWrapper;
  29011. return { number: number, id: id, name: name, callback: callbackWrapper };
  29012. };
  29013. ScriptReceiverFactory.prototype.remove = function (receiver) {
  29014. delete this[receiver.number];
  29015. };
  29016. return ScriptReceiverFactory;
  29017. }());
  29018. exports.ScriptReceiverFactory = ScriptReceiverFactory;
  29019. exports.ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  29020. /***/ }),
  29021. /* 5 */
  29022. /***/ (function(module, exports) {
  29023. "use strict";
  29024. var Defaults = {
  29025. VERSION: "4.1.0",
  29026. PROTOCOL: 7,
  29027. host: 'ws.pusherapp.com',
  29028. ws_port: 80,
  29029. wss_port: 443,
  29030. sockjs_host: 'sockjs.pusher.com',
  29031. sockjs_http_port: 80,
  29032. sockjs_https_port: 443,
  29033. sockjs_path: "/pusher",
  29034. stats_host: 'stats.pusher.com',
  29035. channel_auth_endpoint: '/pusher/auth',
  29036. channel_auth_transport: 'ajax',
  29037. activity_timeout: 120000,
  29038. pong_timeout: 30000,
  29039. unavailable_timeout: 10000,
  29040. cdn_http: 'http://js.pusher.com',
  29041. cdn_https: 'https://js.pusher.com',
  29042. dependency_suffix: ''
  29043. };
  29044. exports.__esModule = true;
  29045. exports["default"] = Defaults;
  29046. /***/ }),
  29047. /* 6 */
  29048. /***/ (function(module, exports, __webpack_require__) {
  29049. "use strict";
  29050. var script_receiver_factory_1 = __webpack_require__(4);
  29051. var runtime_1 = __webpack_require__(2);
  29052. var DependencyLoader = (function () {
  29053. function DependencyLoader(options) {
  29054. this.options = options;
  29055. this.receivers = options.receivers || script_receiver_factory_1.ScriptReceivers;
  29056. this.loading = {};
  29057. }
  29058. DependencyLoader.prototype.load = function (name, options, callback) {
  29059. var self = this;
  29060. if (self.loading[name] && self.loading[name].length > 0) {
  29061. self.loading[name].push(callback);
  29062. }
  29063. else {
  29064. self.loading[name] = [callback];
  29065. var request = runtime_1["default"].createScriptRequest(self.getPath(name, options));
  29066. var receiver = self.receivers.create(function (error) {
  29067. self.receivers.remove(receiver);
  29068. if (self.loading[name]) {
  29069. var callbacks = self.loading[name];
  29070. delete self.loading[name];
  29071. var successCallback = function (wasSuccessful) {
  29072. if (!wasSuccessful) {
  29073. request.cleanup();
  29074. }
  29075. };
  29076. for (var i = 0; i < callbacks.length; i++) {
  29077. callbacks[i](error, successCallback);
  29078. }
  29079. }
  29080. });
  29081. request.send(receiver);
  29082. }
  29083. };
  29084. DependencyLoader.prototype.getRoot = function (options) {
  29085. var cdn;
  29086. var protocol = runtime_1["default"].getDocument().location.protocol;
  29087. if ((options && options.encrypted) || protocol === "https:") {
  29088. cdn = this.options.cdn_https;
  29089. }
  29090. else {
  29091. cdn = this.options.cdn_http;
  29092. }
  29093. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  29094. };
  29095. DependencyLoader.prototype.getPath = function (name, options) {
  29096. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  29097. };
  29098. ;
  29099. return DependencyLoader;
  29100. }());
  29101. exports.__esModule = true;
  29102. exports["default"] = DependencyLoader;
  29103. /***/ }),
  29104. /* 7 */
  29105. /***/ (function(module, exports, __webpack_require__) {
  29106. "use strict";
  29107. var logger_1 = __webpack_require__(8);
  29108. var runtime_1 = __webpack_require__(2);
  29109. var ajax = function (context, socketId, callback) {
  29110. var self = this, xhr;
  29111. xhr = runtime_1["default"].createXHR();
  29112. xhr.open("POST", self.options.authEndpoint, true);
  29113. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  29114. for (var headerName in this.authOptions.headers) {
  29115. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  29116. }
  29117. xhr.onreadystatechange = function () {
  29118. if (xhr.readyState === 4) {
  29119. if (xhr.status === 200) {
  29120. var data, parsed = false;
  29121. try {
  29122. data = JSON.parse(xhr.responseText);
  29123. parsed = true;
  29124. }
  29125. catch (e) {
  29126. callback(true, 'JSON returned from webapp was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  29127. }
  29128. if (parsed) {
  29129. callback(false, data);
  29130. }
  29131. }
  29132. else {
  29133. logger_1["default"].warn("Couldn't get auth info from your webapp", xhr.status);
  29134. callback(true, xhr.status);
  29135. }
  29136. }
  29137. };
  29138. xhr.send(this.composeQuery(socketId));
  29139. return xhr;
  29140. };
  29141. exports.__esModule = true;
  29142. exports["default"] = ajax;
  29143. /***/ }),
  29144. /* 8 */
  29145. /***/ (function(module, exports, __webpack_require__) {
  29146. "use strict";
  29147. var collections_1 = __webpack_require__(9);
  29148. var pusher_1 = __webpack_require__(1);
  29149. var Logger = {
  29150. debug: function () {
  29151. var args = [];
  29152. for (var _i = 0; _i < arguments.length; _i++) {
  29153. args[_i - 0] = arguments[_i];
  29154. }
  29155. if (!pusher_1["default"].log) {
  29156. return;
  29157. }
  29158. pusher_1["default"].log(collections_1.stringify.apply(this, arguments));
  29159. },
  29160. warn: function () {
  29161. var args = [];
  29162. for (var _i = 0; _i < arguments.length; _i++) {
  29163. args[_i - 0] = arguments[_i];
  29164. }
  29165. var message = collections_1.stringify.apply(this, arguments);
  29166. if ((window).console) {
  29167. if ((window).console.warn) {
  29168. (window).console.warn(message);
  29169. }
  29170. else if ((window).console.log) {
  29171. (window).console.log(message);
  29172. }
  29173. }
  29174. if (pusher_1["default"].log) {
  29175. pusher_1["default"].log(message);
  29176. }
  29177. }
  29178. };
  29179. exports.__esModule = true;
  29180. exports["default"] = Logger;
  29181. /***/ }),
  29182. /* 9 */
  29183. /***/ (function(module, exports, __webpack_require__) {
  29184. "use strict";
  29185. var base64_1 = __webpack_require__(10);
  29186. var util_1 = __webpack_require__(11);
  29187. function extend(target) {
  29188. var sources = [];
  29189. for (var _i = 1; _i < arguments.length; _i++) {
  29190. sources[_i - 1] = arguments[_i];
  29191. }
  29192. for (var i = 0; i < sources.length; i++) {
  29193. var extensions = sources[i];
  29194. for (var property in extensions) {
  29195. if (extensions[property] && extensions[property].constructor &&
  29196. extensions[property].constructor === Object) {
  29197. target[property] = extend(target[property] || {}, extensions[property]);
  29198. }
  29199. else {
  29200. target[property] = extensions[property];
  29201. }
  29202. }
  29203. }
  29204. return target;
  29205. }
  29206. exports.extend = extend;
  29207. function stringify() {
  29208. var m = ["Pusher"];
  29209. for (var i = 0; i < arguments.length; i++) {
  29210. if (typeof arguments[i] === "string") {
  29211. m.push(arguments[i]);
  29212. }
  29213. else {
  29214. m.push(safeJSONStringify(arguments[i]));
  29215. }
  29216. }
  29217. return m.join(" : ");
  29218. }
  29219. exports.stringify = stringify;
  29220. function arrayIndexOf(array, item) {
  29221. var nativeIndexOf = Array.prototype.indexOf;
  29222. if (array === null) {
  29223. return -1;
  29224. }
  29225. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  29226. return array.indexOf(item);
  29227. }
  29228. for (var i = 0, l = array.length; i < l; i++) {
  29229. if (array[i] === item) {
  29230. return i;
  29231. }
  29232. }
  29233. return -1;
  29234. }
  29235. exports.arrayIndexOf = arrayIndexOf;
  29236. function objectApply(object, f) {
  29237. for (var key in object) {
  29238. if (Object.prototype.hasOwnProperty.call(object, key)) {
  29239. f(object[key], key, object);
  29240. }
  29241. }
  29242. }
  29243. exports.objectApply = objectApply;
  29244. function keys(object) {
  29245. var keys = [];
  29246. objectApply(object, function (_, key) {
  29247. keys.push(key);
  29248. });
  29249. return keys;
  29250. }
  29251. exports.keys = keys;
  29252. function values(object) {
  29253. var values = [];
  29254. objectApply(object, function (value) {
  29255. values.push(value);
  29256. });
  29257. return values;
  29258. }
  29259. exports.values = values;
  29260. function apply(array, f, context) {
  29261. for (var i = 0; i < array.length; i++) {
  29262. f.call(context || (window), array[i], i, array);
  29263. }
  29264. }
  29265. exports.apply = apply;
  29266. function map(array, f) {
  29267. var result = [];
  29268. for (var i = 0; i < array.length; i++) {
  29269. result.push(f(array[i], i, array, result));
  29270. }
  29271. return result;
  29272. }
  29273. exports.map = map;
  29274. function mapObject(object, f) {
  29275. var result = {};
  29276. objectApply(object, function (value, key) {
  29277. result[key] = f(value);
  29278. });
  29279. return result;
  29280. }
  29281. exports.mapObject = mapObject;
  29282. function filter(array, test) {
  29283. test = test || function (value) { return !!value; };
  29284. var result = [];
  29285. for (var i = 0; i < array.length; i++) {
  29286. if (test(array[i], i, array, result)) {
  29287. result.push(array[i]);
  29288. }
  29289. }
  29290. return result;
  29291. }
  29292. exports.filter = filter;
  29293. function filterObject(object, test) {
  29294. var result = {};
  29295. objectApply(object, function (value, key) {
  29296. if ((test && test(value, key, object, result)) || Boolean(value)) {
  29297. result[key] = value;
  29298. }
  29299. });
  29300. return result;
  29301. }
  29302. exports.filterObject = filterObject;
  29303. function flatten(object) {
  29304. var result = [];
  29305. objectApply(object, function (value, key) {
  29306. result.push([key, value]);
  29307. });
  29308. return result;
  29309. }
  29310. exports.flatten = flatten;
  29311. function any(array, test) {
  29312. for (var i = 0; i < array.length; i++) {
  29313. if (test(array[i], i, array)) {
  29314. return true;
  29315. }
  29316. }
  29317. return false;
  29318. }
  29319. exports.any = any;
  29320. function all(array, test) {
  29321. for (var i = 0; i < array.length; i++) {
  29322. if (!test(array[i], i, array)) {
  29323. return false;
  29324. }
  29325. }
  29326. return true;
  29327. }
  29328. exports.all = all;
  29329. function encodeParamsObject(data) {
  29330. return mapObject(data, function (value) {
  29331. if (typeof value === "object") {
  29332. value = safeJSONStringify(value);
  29333. }
  29334. return encodeURIComponent(base64_1["default"](value.toString()));
  29335. });
  29336. }
  29337. exports.encodeParamsObject = encodeParamsObject;
  29338. function buildQueryString(data) {
  29339. var params = filterObject(data, function (value) {
  29340. return value !== undefined;
  29341. });
  29342. var query = map(flatten(encodeParamsObject(params)), util_1["default"].method("join", "=")).join("&");
  29343. return query;
  29344. }
  29345. exports.buildQueryString = buildQueryString;
  29346. function decycleObject(object) {
  29347. var objects = [], paths = [];
  29348. return (function derez(value, path) {
  29349. var i, name, nu;
  29350. switch (typeof value) {
  29351. case 'object':
  29352. if (!value) {
  29353. return null;
  29354. }
  29355. for (i = 0; i < objects.length; i += 1) {
  29356. if (objects[i] === value) {
  29357. return { $ref: paths[i] };
  29358. }
  29359. }
  29360. objects.push(value);
  29361. paths.push(path);
  29362. if (Object.prototype.toString.apply(value) === '[object Array]') {
  29363. nu = [];
  29364. for (i = 0; i < value.length; i += 1) {
  29365. nu[i] = derez(value[i], path + '[' + i + ']');
  29366. }
  29367. }
  29368. else {
  29369. nu = {};
  29370. for (name in value) {
  29371. if (Object.prototype.hasOwnProperty.call(value, name)) {
  29372. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  29373. }
  29374. }
  29375. }
  29376. return nu;
  29377. case 'number':
  29378. case 'string':
  29379. case 'boolean':
  29380. return value;
  29381. }
  29382. }(object, '$'));
  29383. }
  29384. exports.decycleObject = decycleObject;
  29385. function safeJSONStringify(source) {
  29386. try {
  29387. return JSON.stringify(source);
  29388. }
  29389. catch (e) {
  29390. return JSON.stringify(decycleObject(source));
  29391. }
  29392. }
  29393. exports.safeJSONStringify = safeJSONStringify;
  29394. /***/ }),
  29395. /* 10 */
  29396. /***/ (function(module, exports, __webpack_require__) {
  29397. "use strict";
  29398. function encode(s) {
  29399. return btoa(utob(s));
  29400. }
  29401. exports.__esModule = true;
  29402. exports["default"] = encode;
  29403. var fromCharCode = String.fromCharCode;
  29404. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  29405. var b64tab = {};
  29406. for (var i = 0, l = b64chars.length; i < l; i++) {
  29407. b64tab[b64chars.charAt(i)] = i;
  29408. }
  29409. var cb_utob = function (c) {
  29410. var cc = c.charCodeAt(0);
  29411. return cc < 0x80 ? c
  29412. : cc < 0x800 ? fromCharCode(0xc0 | (cc >>> 6)) +
  29413. fromCharCode(0x80 | (cc & 0x3f))
  29414. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  29415. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  29416. fromCharCode(0x80 | (cc & 0x3f));
  29417. };
  29418. var utob = function (u) {
  29419. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  29420. };
  29421. var cb_encode = function (ccc) {
  29422. var padlen = [0, 2, 1][ccc.length % 3];
  29423. var ord = ccc.charCodeAt(0) << 16
  29424. | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
  29425. | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0));
  29426. var chars = [
  29427. b64chars.charAt(ord >>> 18),
  29428. b64chars.charAt((ord >>> 12) & 63),
  29429. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  29430. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  29431. ];
  29432. return chars.join('');
  29433. };
  29434. var btoa = (window).btoa || function (b) {
  29435. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  29436. };
  29437. /***/ }),
  29438. /* 11 */
  29439. /***/ (function(module, exports, __webpack_require__) {
  29440. "use strict";
  29441. var timers_1 = __webpack_require__(12);
  29442. var Util = {
  29443. now: function () {
  29444. if (Date.now) {
  29445. return Date.now();
  29446. }
  29447. else {
  29448. return new Date().valueOf();
  29449. }
  29450. },
  29451. defer: function (callback) {
  29452. return new timers_1.OneOffTimer(0, callback);
  29453. },
  29454. method: function (name) {
  29455. var args = [];
  29456. for (var _i = 1; _i < arguments.length; _i++) {
  29457. args[_i - 1] = arguments[_i];
  29458. }
  29459. var boundArguments = Array.prototype.slice.call(arguments, 1);
  29460. return function (object) {
  29461. return object[name].apply(object, boundArguments.concat(arguments));
  29462. };
  29463. }
  29464. };
  29465. exports.__esModule = true;
  29466. exports["default"] = Util;
  29467. /***/ }),
  29468. /* 12 */
  29469. /***/ (function(module, exports, __webpack_require__) {
  29470. "use strict";
  29471. var __extends = (this && this.__extends) || function (d, b) {
  29472. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29473. function __() { this.constructor = d; }
  29474. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29475. };
  29476. var abstract_timer_1 = __webpack_require__(13);
  29477. function clearTimeout(timer) {
  29478. (window).clearTimeout(timer);
  29479. }
  29480. function clearInterval(timer) {
  29481. (window).clearInterval(timer);
  29482. }
  29483. var OneOffTimer = (function (_super) {
  29484. __extends(OneOffTimer, _super);
  29485. function OneOffTimer(delay, callback) {
  29486. _super.call(this, setTimeout, clearTimeout, delay, function (timer) {
  29487. callback();
  29488. return null;
  29489. });
  29490. }
  29491. return OneOffTimer;
  29492. }(abstract_timer_1["default"]));
  29493. exports.OneOffTimer = OneOffTimer;
  29494. var PeriodicTimer = (function (_super) {
  29495. __extends(PeriodicTimer, _super);
  29496. function PeriodicTimer(delay, callback) {
  29497. _super.call(this, setInterval, clearInterval, delay, function (timer) {
  29498. callback();
  29499. return timer;
  29500. });
  29501. }
  29502. return PeriodicTimer;
  29503. }(abstract_timer_1["default"]));
  29504. exports.PeriodicTimer = PeriodicTimer;
  29505. /***/ }),
  29506. /* 13 */
  29507. /***/ (function(module, exports) {
  29508. "use strict";
  29509. var Timer = (function () {
  29510. function Timer(set, clear, delay, callback) {
  29511. var _this = this;
  29512. this.clear = clear;
  29513. this.timer = set(function () {
  29514. if (_this.timer) {
  29515. _this.timer = callback(_this.timer);
  29516. }
  29517. }, delay);
  29518. }
  29519. Timer.prototype.isRunning = function () {
  29520. return this.timer !== null;
  29521. };
  29522. Timer.prototype.ensureAborted = function () {
  29523. if (this.timer) {
  29524. this.clear(this.timer);
  29525. this.timer = null;
  29526. }
  29527. };
  29528. return Timer;
  29529. }());
  29530. exports.__esModule = true;
  29531. exports["default"] = Timer;
  29532. /***/ }),
  29533. /* 14 */
  29534. /***/ (function(module, exports, __webpack_require__) {
  29535. "use strict";
  29536. var logger_1 = __webpack_require__(8);
  29537. var jsonp = function (context, socketId, callback) {
  29538. if (this.authOptions.headers !== undefined) {
  29539. logger_1["default"].warn("Warn", "To send headers with the auth request, you must use AJAX, rather than JSONP.");
  29540. }
  29541. var callbackName = context.nextAuthCallbackID.toString();
  29542. context.nextAuthCallbackID++;
  29543. var document = context.getDocument();
  29544. var script = document.createElement("script");
  29545. context.auth_callbacks[callbackName] = function (data) {
  29546. callback(false, data);
  29547. };
  29548. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  29549. script.src = this.options.authEndpoint +
  29550. '?callback=' +
  29551. encodeURIComponent(callback_name) +
  29552. '&' +
  29553. this.composeQuery(socketId);
  29554. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  29555. head.insertBefore(script, head.firstChild);
  29556. };
  29557. exports.__esModule = true;
  29558. exports["default"] = jsonp;
  29559. /***/ }),
  29560. /* 15 */
  29561. /***/ (function(module, exports) {
  29562. "use strict";
  29563. var ScriptRequest = (function () {
  29564. function ScriptRequest(src) {
  29565. this.src = src;
  29566. }
  29567. ScriptRequest.prototype.send = function (receiver) {
  29568. var self = this;
  29569. var errorString = "Error loading " + self.src;
  29570. self.script = document.createElement("script");
  29571. self.script.id = receiver.id;
  29572. self.script.src = self.src;
  29573. self.script.type = "text/javascript";
  29574. self.script.charset = "UTF-8";
  29575. if (self.script.addEventListener) {
  29576. self.script.onerror = function () {
  29577. receiver.callback(errorString);
  29578. };
  29579. self.script.onload = function () {
  29580. receiver.callback(null);
  29581. };
  29582. }
  29583. else {
  29584. self.script.onreadystatechange = function () {
  29585. if (self.script.readyState === 'loaded' ||
  29586. self.script.readyState === 'complete') {
  29587. receiver.callback(null);
  29588. }
  29589. };
  29590. }
  29591. if (self.script.async === undefined && document.attachEvent &&
  29592. /opera/i.test(navigator.userAgent)) {
  29593. self.errorScript = document.createElement("script");
  29594. self.errorScript.id = receiver.id + "_error";
  29595. self.errorScript.text = receiver.name + "('" + errorString + "');";
  29596. self.script.async = self.errorScript.async = false;
  29597. }
  29598. else {
  29599. self.script.async = true;
  29600. }
  29601. var head = document.getElementsByTagName('head')[0];
  29602. head.insertBefore(self.script, head.firstChild);
  29603. if (self.errorScript) {
  29604. head.insertBefore(self.errorScript, self.script.nextSibling);
  29605. }
  29606. };
  29607. ScriptRequest.prototype.cleanup = function () {
  29608. if (this.script) {
  29609. this.script.onload = this.script.onerror = null;
  29610. this.script.onreadystatechange = null;
  29611. }
  29612. if (this.script && this.script.parentNode) {
  29613. this.script.parentNode.removeChild(this.script);
  29614. }
  29615. if (this.errorScript && this.errorScript.parentNode) {
  29616. this.errorScript.parentNode.removeChild(this.errorScript);
  29617. }
  29618. this.script = null;
  29619. this.errorScript = null;
  29620. };
  29621. return ScriptRequest;
  29622. }());
  29623. exports.__esModule = true;
  29624. exports["default"] = ScriptRequest;
  29625. /***/ }),
  29626. /* 16 */
  29627. /***/ (function(module, exports, __webpack_require__) {
  29628. "use strict";
  29629. var Collections = __webpack_require__(9);
  29630. var runtime_1 = __webpack_require__(2);
  29631. var JSONPRequest = (function () {
  29632. function JSONPRequest(url, data) {
  29633. this.url = url;
  29634. this.data = data;
  29635. }
  29636. JSONPRequest.prototype.send = function (receiver) {
  29637. if (this.request) {
  29638. return;
  29639. }
  29640. var query = Collections.buildQueryString(this.data);
  29641. var url = this.url + "/" + receiver.number + "?" + query;
  29642. this.request = runtime_1["default"].createScriptRequest(url);
  29643. this.request.send(receiver);
  29644. };
  29645. JSONPRequest.prototype.cleanup = function () {
  29646. if (this.request) {
  29647. this.request.cleanup();
  29648. }
  29649. };
  29650. return JSONPRequest;
  29651. }());
  29652. exports.__esModule = true;
  29653. exports["default"] = JSONPRequest;
  29654. /***/ }),
  29655. /* 17 */
  29656. /***/ (function(module, exports, __webpack_require__) {
  29657. "use strict";
  29658. var runtime_1 = __webpack_require__(2);
  29659. var script_receiver_factory_1 = __webpack_require__(4);
  29660. var getAgent = function (sender, encrypted) {
  29661. return function (data, callback) {
  29662. var scheme = "http" + (encrypted ? "s" : "") + "://";
  29663. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  29664. var request = runtime_1["default"].createJSONPRequest(url, data);
  29665. var receiver = runtime_1["default"].ScriptReceivers.create(function (error, result) {
  29666. script_receiver_factory_1.ScriptReceivers.remove(receiver);
  29667. request.cleanup();
  29668. if (result && result.host) {
  29669. sender.host = result.host;
  29670. }
  29671. if (callback) {
  29672. callback(error, result);
  29673. }
  29674. });
  29675. request.send(receiver);
  29676. };
  29677. };
  29678. var jsonp = {
  29679. name: 'jsonp',
  29680. getAgent: getAgent
  29681. };
  29682. exports.__esModule = true;
  29683. exports["default"] = jsonp;
  29684. /***/ }),
  29685. /* 18 */
  29686. /***/ (function(module, exports, __webpack_require__) {
  29687. "use strict";
  29688. var transports_1 = __webpack_require__(19);
  29689. var transport_1 = __webpack_require__(21);
  29690. var URLSchemes = __webpack_require__(20);
  29691. var runtime_1 = __webpack_require__(2);
  29692. var dependencies_1 = __webpack_require__(3);
  29693. var Collections = __webpack_require__(9);
  29694. var SockJSTransport = new transport_1["default"]({
  29695. file: "sockjs",
  29696. urls: URLSchemes.sockjs,
  29697. handlesActivityChecks: true,
  29698. supportsPing: false,
  29699. isSupported: function () {
  29700. return true;
  29701. },
  29702. isInitialized: function () {
  29703. return window.SockJS !== undefined;
  29704. },
  29705. getSocket: function (url, options) {
  29706. return new window.SockJS(url, null, {
  29707. js_path: dependencies_1.Dependencies.getPath("sockjs", {
  29708. encrypted: options.encrypted
  29709. }),
  29710. ignore_null_origin: options.ignoreNullOrigin
  29711. });
  29712. },
  29713. beforeOpen: function (socket, path) {
  29714. socket.send(JSON.stringify({
  29715. path: path
  29716. }));
  29717. }
  29718. });
  29719. var xdrConfiguration = {
  29720. isSupported: function (environment) {
  29721. var yes = runtime_1["default"].isXDRSupported(environment.encrypted);
  29722. return yes;
  29723. }
  29724. };
  29725. var XDRStreamingTransport = new transport_1["default"](Collections.extend({}, transports_1.streamingConfiguration, xdrConfiguration));
  29726. var XDRPollingTransport = new transport_1["default"](Collections.extend({}, transports_1.pollingConfiguration, xdrConfiguration));
  29727. transports_1["default"].xdr_streaming = XDRStreamingTransport;
  29728. transports_1["default"].xdr_polling = XDRPollingTransport;
  29729. transports_1["default"].sockjs = SockJSTransport;
  29730. exports.__esModule = true;
  29731. exports["default"] = transports_1["default"];
  29732. /***/ }),
  29733. /* 19 */
  29734. /***/ (function(module, exports, __webpack_require__) {
  29735. "use strict";
  29736. var URLSchemes = __webpack_require__(20);
  29737. var transport_1 = __webpack_require__(21);
  29738. var Collections = __webpack_require__(9);
  29739. var runtime_1 = __webpack_require__(2);
  29740. var WSTransport = new transport_1["default"]({
  29741. urls: URLSchemes.ws,
  29742. handlesActivityChecks: false,
  29743. supportsPing: false,
  29744. isInitialized: function () {
  29745. return Boolean(runtime_1["default"].getWebSocketAPI());
  29746. },
  29747. isSupported: function () {
  29748. return Boolean(runtime_1["default"].getWebSocketAPI());
  29749. },
  29750. getSocket: function (url) {
  29751. return runtime_1["default"].createWebSocket(url);
  29752. }
  29753. });
  29754. var httpConfiguration = {
  29755. urls: URLSchemes.http,
  29756. handlesActivityChecks: false,
  29757. supportsPing: true,
  29758. isInitialized: function () {
  29759. return true;
  29760. }
  29761. };
  29762. exports.streamingConfiguration = Collections.extend({ getSocket: function (url) {
  29763. return runtime_1["default"].HTTPFactory.createStreamingSocket(url);
  29764. }
  29765. }, httpConfiguration);
  29766. exports.pollingConfiguration = Collections.extend({ getSocket: function (url) {
  29767. return runtime_1["default"].HTTPFactory.createPollingSocket(url);
  29768. }
  29769. }, httpConfiguration);
  29770. var xhrConfiguration = {
  29771. isSupported: function () {
  29772. return runtime_1["default"].isXHRSupported();
  29773. }
  29774. };
  29775. var XHRStreamingTransport = new transport_1["default"](Collections.extend({}, exports.streamingConfiguration, xhrConfiguration));
  29776. var XHRPollingTransport = new transport_1["default"](Collections.extend({}, exports.pollingConfiguration, xhrConfiguration));
  29777. var Transports = {
  29778. ws: WSTransport,
  29779. xhr_streaming: XHRStreamingTransport,
  29780. xhr_polling: XHRPollingTransport
  29781. };
  29782. exports.__esModule = true;
  29783. exports["default"] = Transports;
  29784. /***/ }),
  29785. /* 20 */
  29786. /***/ (function(module, exports, __webpack_require__) {
  29787. "use strict";
  29788. var defaults_1 = __webpack_require__(5);
  29789. function getGenericURL(baseScheme, params, path) {
  29790. var scheme = baseScheme + (params.encrypted ? "s" : "");
  29791. var host = params.encrypted ? params.hostEncrypted : params.hostUnencrypted;
  29792. return scheme + "://" + host + path;
  29793. }
  29794. function getGenericPath(key, queryString) {
  29795. var path = "/app/" + key;
  29796. var query = "?protocol=" + defaults_1["default"].PROTOCOL +
  29797. "&client=js" +
  29798. "&version=" + defaults_1["default"].VERSION +
  29799. (queryString ? ("&" + queryString) : "");
  29800. return path + query;
  29801. }
  29802. exports.ws = {
  29803. getInitial: function (key, params) {
  29804. return getGenericURL("ws", params, getGenericPath(key, "flash=false"));
  29805. }
  29806. };
  29807. exports.http = {
  29808. getInitial: function (key, params) {
  29809. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  29810. return getGenericURL("http", params, path);
  29811. }
  29812. };
  29813. exports.sockjs = {
  29814. getInitial: function (key, params) {
  29815. return getGenericURL("http", params, params.httpPath || "/pusher");
  29816. },
  29817. getPath: function (key, params) {
  29818. return getGenericPath(key);
  29819. }
  29820. };
  29821. /***/ }),
  29822. /* 21 */
  29823. /***/ (function(module, exports, __webpack_require__) {
  29824. "use strict";
  29825. var transport_connection_1 = __webpack_require__(22);
  29826. var Transport = (function () {
  29827. function Transport(hooks) {
  29828. this.hooks = hooks;
  29829. }
  29830. Transport.prototype.isSupported = function (environment) {
  29831. return this.hooks.isSupported(environment);
  29832. };
  29833. Transport.prototype.createConnection = function (name, priority, key, options) {
  29834. return new transport_connection_1["default"](this.hooks, name, priority, key, options);
  29835. };
  29836. return Transport;
  29837. }());
  29838. exports.__esModule = true;
  29839. exports["default"] = Transport;
  29840. /***/ }),
  29841. /* 22 */
  29842. /***/ (function(module, exports, __webpack_require__) {
  29843. "use strict";
  29844. var __extends = (this && this.__extends) || function (d, b) {
  29845. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29846. function __() { this.constructor = d; }
  29847. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29848. };
  29849. var util_1 = __webpack_require__(11);
  29850. var Collections = __webpack_require__(9);
  29851. var dispatcher_1 = __webpack_require__(23);
  29852. var logger_1 = __webpack_require__(8);
  29853. var runtime_1 = __webpack_require__(2);
  29854. var TransportConnection = (function (_super) {
  29855. __extends(TransportConnection, _super);
  29856. function TransportConnection(hooks, name, priority, key, options) {
  29857. _super.call(this);
  29858. this.initialize = runtime_1["default"].transportConnectionInitializer;
  29859. this.hooks = hooks;
  29860. this.name = name;
  29861. this.priority = priority;
  29862. this.key = key;
  29863. this.options = options;
  29864. this.state = "new";
  29865. this.timeline = options.timeline;
  29866. this.activityTimeout = options.activityTimeout;
  29867. this.id = this.timeline.generateUniqueID();
  29868. }
  29869. TransportConnection.prototype.handlesActivityChecks = function () {
  29870. return Boolean(this.hooks.handlesActivityChecks);
  29871. };
  29872. TransportConnection.prototype.supportsPing = function () {
  29873. return Boolean(this.hooks.supportsPing);
  29874. };
  29875. TransportConnection.prototype.connect = function () {
  29876. var _this = this;
  29877. if (this.socket || this.state !== "initialized") {
  29878. return false;
  29879. }
  29880. var url = this.hooks.urls.getInitial(this.key, this.options);
  29881. try {
  29882. this.socket = this.hooks.getSocket(url, this.options);
  29883. }
  29884. catch (e) {
  29885. util_1["default"].defer(function () {
  29886. _this.onError(e);
  29887. _this.changeState("closed");
  29888. });
  29889. return false;
  29890. }
  29891. this.bindListeners();
  29892. logger_1["default"].debug("Connecting", { transport: this.name, url: url });
  29893. this.changeState("connecting");
  29894. return true;
  29895. };
  29896. TransportConnection.prototype.close = function () {
  29897. if (this.socket) {
  29898. this.socket.close();
  29899. return true;
  29900. }
  29901. else {
  29902. return false;
  29903. }
  29904. };
  29905. TransportConnection.prototype.send = function (data) {
  29906. var _this = this;
  29907. if (this.state === "open") {
  29908. util_1["default"].defer(function () {
  29909. if (_this.socket) {
  29910. _this.socket.send(data);
  29911. }
  29912. });
  29913. return true;
  29914. }
  29915. else {
  29916. return false;
  29917. }
  29918. };
  29919. TransportConnection.prototype.ping = function () {
  29920. if (this.state === "open" && this.supportsPing()) {
  29921. this.socket.ping();
  29922. }
  29923. };
  29924. TransportConnection.prototype.onOpen = function () {
  29925. if (this.hooks.beforeOpen) {
  29926. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  29927. }
  29928. this.changeState("open");
  29929. this.socket.onopen = undefined;
  29930. };
  29931. TransportConnection.prototype.onError = function (error) {
  29932. this.emit("error", { type: 'WebSocketError', error: error });
  29933. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  29934. };
  29935. TransportConnection.prototype.onClose = function (closeEvent) {
  29936. if (closeEvent) {
  29937. this.changeState("closed", {
  29938. code: closeEvent.code,
  29939. reason: closeEvent.reason,
  29940. wasClean: closeEvent.wasClean
  29941. });
  29942. }
  29943. else {
  29944. this.changeState("closed");
  29945. }
  29946. this.unbindListeners();
  29947. this.socket = undefined;
  29948. };
  29949. TransportConnection.prototype.onMessage = function (message) {
  29950. this.emit("message", message);
  29951. };
  29952. TransportConnection.prototype.onActivity = function () {
  29953. this.emit("activity");
  29954. };
  29955. TransportConnection.prototype.bindListeners = function () {
  29956. var _this = this;
  29957. this.socket.onopen = function () {
  29958. _this.onOpen();
  29959. };
  29960. this.socket.onerror = function (error) {
  29961. _this.onError(error);
  29962. };
  29963. this.socket.onclose = function (closeEvent) {
  29964. _this.onClose(closeEvent);
  29965. };
  29966. this.socket.onmessage = function (message) {
  29967. _this.onMessage(message);
  29968. };
  29969. if (this.supportsPing()) {
  29970. this.socket.onactivity = function () { _this.onActivity(); };
  29971. }
  29972. };
  29973. TransportConnection.prototype.unbindListeners = function () {
  29974. if (this.socket) {
  29975. this.socket.onopen = undefined;
  29976. this.socket.onerror = undefined;
  29977. this.socket.onclose = undefined;
  29978. this.socket.onmessage = undefined;
  29979. if (this.supportsPing()) {
  29980. this.socket.onactivity = undefined;
  29981. }
  29982. }
  29983. };
  29984. TransportConnection.prototype.changeState = function (state, params) {
  29985. this.state = state;
  29986. this.timeline.info(this.buildTimelineMessage({
  29987. state: state,
  29988. params: params
  29989. }));
  29990. this.emit(state, params);
  29991. };
  29992. TransportConnection.prototype.buildTimelineMessage = function (message) {
  29993. return Collections.extend({ cid: this.id }, message);
  29994. };
  29995. return TransportConnection;
  29996. }(dispatcher_1["default"]));
  29997. exports.__esModule = true;
  29998. exports["default"] = TransportConnection;
  29999. /***/ }),
  30000. /* 23 */
  30001. /***/ (function(module, exports, __webpack_require__) {
  30002. "use strict";
  30003. var Collections = __webpack_require__(9);
  30004. var callback_registry_1 = __webpack_require__(24);
  30005. var Dispatcher = (function () {
  30006. function Dispatcher(failThrough) {
  30007. this.callbacks = new callback_registry_1["default"]();
  30008. this.global_callbacks = [];
  30009. this.failThrough = failThrough;
  30010. }
  30011. Dispatcher.prototype.bind = function (eventName, callback, context) {
  30012. this.callbacks.add(eventName, callback, context);
  30013. return this;
  30014. };
  30015. Dispatcher.prototype.bind_global = function (callback) {
  30016. this.global_callbacks.push(callback);
  30017. return this;
  30018. };
  30019. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  30020. this.callbacks.remove(eventName, callback, context);
  30021. return this;
  30022. };
  30023. Dispatcher.prototype.unbind_global = function (callback) {
  30024. if (!callback) {
  30025. this.global_callbacks = [];
  30026. return this;
  30027. }
  30028. this.global_callbacks = Collections.filter(this.global_callbacks || [], function (c) { return c !== callback; });
  30029. return this;
  30030. };
  30031. Dispatcher.prototype.unbind_all = function () {
  30032. this.unbind();
  30033. this.unbind_global();
  30034. return this;
  30035. };
  30036. Dispatcher.prototype.emit = function (eventName, data) {
  30037. var i;
  30038. for (i = 0; i < this.global_callbacks.length; i++) {
  30039. this.global_callbacks[i](eventName, data);
  30040. }
  30041. var callbacks = this.callbacks.get(eventName);
  30042. if (callbacks && callbacks.length > 0) {
  30043. for (i = 0; i < callbacks.length; i++) {
  30044. callbacks[i].fn.call(callbacks[i].context || (window), data);
  30045. }
  30046. }
  30047. else if (this.failThrough) {
  30048. this.failThrough(eventName, data);
  30049. }
  30050. return this;
  30051. };
  30052. return Dispatcher;
  30053. }());
  30054. exports.__esModule = true;
  30055. exports["default"] = Dispatcher;
  30056. /***/ }),
  30057. /* 24 */
  30058. /***/ (function(module, exports, __webpack_require__) {
  30059. "use strict";
  30060. var Collections = __webpack_require__(9);
  30061. var CallbackRegistry = (function () {
  30062. function CallbackRegistry() {
  30063. this._callbacks = {};
  30064. }
  30065. CallbackRegistry.prototype.get = function (name) {
  30066. return this._callbacks[prefix(name)];
  30067. };
  30068. CallbackRegistry.prototype.add = function (name, callback, context) {
  30069. var prefixedEventName = prefix(name);
  30070. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  30071. this._callbacks[prefixedEventName].push({
  30072. fn: callback,
  30073. context: context
  30074. });
  30075. };
  30076. CallbackRegistry.prototype.remove = function (name, callback, context) {
  30077. if (!name && !callback && !context) {
  30078. this._callbacks = {};
  30079. return;
  30080. }
  30081. var names = name ? [prefix(name)] : Collections.keys(this._callbacks);
  30082. if (callback || context) {
  30083. this.removeCallback(names, callback, context);
  30084. }
  30085. else {
  30086. this.removeAllCallbacks(names);
  30087. }
  30088. };
  30089. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  30090. Collections.apply(names, function (name) {
  30091. this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function (binding) {
  30092. return (callback && callback !== binding.fn) ||
  30093. (context && context !== binding.context);
  30094. });
  30095. if (this._callbacks[name].length === 0) {
  30096. delete this._callbacks[name];
  30097. }
  30098. }, this);
  30099. };
  30100. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  30101. Collections.apply(names, function (name) {
  30102. delete this._callbacks[name];
  30103. }, this);
  30104. };
  30105. return CallbackRegistry;
  30106. }());
  30107. exports.__esModule = true;
  30108. exports["default"] = CallbackRegistry;
  30109. function prefix(name) {
  30110. return "_" + name;
  30111. }
  30112. /***/ }),
  30113. /* 25 */
  30114. /***/ (function(module, exports, __webpack_require__) {
  30115. "use strict";
  30116. var __extends = (this && this.__extends) || function (d, b) {
  30117. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30118. function __() { this.constructor = d; }
  30119. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30120. };
  30121. var dispatcher_1 = __webpack_require__(23);
  30122. var NetInfo = (function (_super) {
  30123. __extends(NetInfo, _super);
  30124. function NetInfo() {
  30125. _super.call(this);
  30126. var self = this;
  30127. if (window.addEventListener !== undefined) {
  30128. window.addEventListener("online", function () {
  30129. self.emit('online');
  30130. }, false);
  30131. window.addEventListener("offline", function () {
  30132. self.emit('offline');
  30133. }, false);
  30134. }
  30135. }
  30136. NetInfo.prototype.isOnline = function () {
  30137. if (window.navigator.onLine === undefined) {
  30138. return true;
  30139. }
  30140. else {
  30141. return window.navigator.onLine;
  30142. }
  30143. };
  30144. return NetInfo;
  30145. }(dispatcher_1["default"]));
  30146. exports.NetInfo = NetInfo;
  30147. exports.Network = new NetInfo();
  30148. /***/ }),
  30149. /* 26 */
  30150. /***/ (function(module, exports) {
  30151. "use strict";
  30152. var getDefaultStrategy = function (config) {
  30153. var wsStrategy;
  30154. if (config.encrypted) {
  30155. wsStrategy = [
  30156. ":best_connected_ever",
  30157. ":ws_loop",
  30158. [":delayed", 2000, [":http_fallback_loop"]]
  30159. ];
  30160. }
  30161. else {
  30162. wsStrategy = [
  30163. ":best_connected_ever",
  30164. ":ws_loop",
  30165. [":delayed", 2000, [":wss_loop"]],
  30166. [":delayed", 5000, [":http_fallback_loop"]]
  30167. ];
  30168. }
  30169. return [
  30170. [":def", "ws_options", {
  30171. hostUnencrypted: config.wsHost + ":" + config.wsPort,
  30172. hostEncrypted: config.wsHost + ":" + config.wssPort
  30173. }],
  30174. [":def", "wss_options", [":extend", ":ws_options", {
  30175. encrypted: true
  30176. }]],
  30177. [":def", "sockjs_options", {
  30178. hostUnencrypted: config.httpHost + ":" + config.httpPort,
  30179. hostEncrypted: config.httpHost + ":" + config.httpsPort,
  30180. httpPath: config.httpPath
  30181. }],
  30182. [":def", "timeouts", {
  30183. loop: true,
  30184. timeout: 15000,
  30185. timeoutLimit: 60000
  30186. }],
  30187. [":def", "ws_manager", [":transport_manager", {
  30188. lives: 2,
  30189. minPingDelay: 10000,
  30190. maxPingDelay: config.activity_timeout
  30191. }]],
  30192. [":def", "streaming_manager", [":transport_manager", {
  30193. lives: 2,
  30194. minPingDelay: 10000,
  30195. maxPingDelay: config.activity_timeout
  30196. }]],
  30197. [":def_transport", "ws", "ws", 3, ":ws_options", ":ws_manager"],
  30198. [":def_transport", "wss", "ws", 3, ":wss_options", ":ws_manager"],
  30199. [":def_transport", "sockjs", "sockjs", 1, ":sockjs_options"],
  30200. [":def_transport", "xhr_streaming", "xhr_streaming", 1, ":sockjs_options", ":streaming_manager"],
  30201. [":def_transport", "xdr_streaming", "xdr_streaming", 1, ":sockjs_options", ":streaming_manager"],
  30202. [":def_transport", "xhr_polling", "xhr_polling", 1, ":sockjs_options"],
  30203. [":def_transport", "xdr_polling", "xdr_polling", 1, ":sockjs_options"],
  30204. [":def", "ws_loop", [":sequential", ":timeouts", ":ws"]],
  30205. [":def", "wss_loop", [":sequential", ":timeouts", ":wss"]],
  30206. [":def", "sockjs_loop", [":sequential", ":timeouts", ":sockjs"]],
  30207. [":def", "streaming_loop", [":sequential", ":timeouts",
  30208. [":if", [":is_supported", ":xhr_streaming"],
  30209. ":xhr_streaming",
  30210. ":xdr_streaming"
  30211. ]
  30212. ]],
  30213. [":def", "polling_loop", [":sequential", ":timeouts",
  30214. [":if", [":is_supported", ":xhr_polling"],
  30215. ":xhr_polling",
  30216. ":xdr_polling"
  30217. ]
  30218. ]],
  30219. [":def", "http_loop", [":if", [":is_supported", ":streaming_loop"], [
  30220. ":best_connected_ever",
  30221. ":streaming_loop",
  30222. [":delayed", 4000, [":polling_loop"]]
  30223. ], [
  30224. ":polling_loop"
  30225. ]]],
  30226. [":def", "http_fallback_loop",
  30227. [":if", [":is_supported", ":http_loop"], [
  30228. ":http_loop"
  30229. ], [
  30230. ":sockjs_loop"
  30231. ]]
  30232. ],
  30233. [":def", "strategy",
  30234. [":cached", 1800000,
  30235. [":first_connected",
  30236. [":if", [":is_supported", ":ws"],
  30237. wsStrategy,
  30238. ":http_fallback_loop"
  30239. ]
  30240. ]
  30241. ]
  30242. ]
  30243. ];
  30244. };
  30245. exports.__esModule = true;
  30246. exports["default"] = getDefaultStrategy;
  30247. /***/ }),
  30248. /* 27 */
  30249. /***/ (function(module, exports, __webpack_require__) {
  30250. "use strict";
  30251. var dependencies_1 = __webpack_require__(3);
  30252. function default_1() {
  30253. var self = this;
  30254. self.timeline.info(self.buildTimelineMessage({
  30255. transport: self.name + (self.options.encrypted ? "s" : "")
  30256. }));
  30257. if (self.hooks.isInitialized()) {
  30258. self.changeState("initialized");
  30259. }
  30260. else if (self.hooks.file) {
  30261. self.changeState("initializing");
  30262. dependencies_1.Dependencies.load(self.hooks.file, { encrypted: self.options.encrypted }, function (error, callback) {
  30263. if (self.hooks.isInitialized()) {
  30264. self.changeState("initialized");
  30265. callback(true);
  30266. }
  30267. else {
  30268. if (error) {
  30269. self.onError(error);
  30270. }
  30271. self.onClose();
  30272. callback(false);
  30273. }
  30274. });
  30275. }
  30276. else {
  30277. self.onClose();
  30278. }
  30279. }
  30280. exports.__esModule = true;
  30281. exports["default"] = default_1;
  30282. /***/ }),
  30283. /* 28 */
  30284. /***/ (function(module, exports, __webpack_require__) {
  30285. "use strict";
  30286. var http_xdomain_request_1 = __webpack_require__(29);
  30287. var http_1 = __webpack_require__(31);
  30288. http_1["default"].createXDR = function (method, url) {
  30289. return this.createRequest(http_xdomain_request_1["default"], method, url);
  30290. };
  30291. exports.__esModule = true;
  30292. exports["default"] = http_1["default"];
  30293. /***/ }),
  30294. /* 29 */
  30295. /***/ (function(module, exports, __webpack_require__) {
  30296. "use strict";
  30297. var Errors = __webpack_require__(30);
  30298. var hooks = {
  30299. getRequest: function (socket) {
  30300. var xdr = new window.XDomainRequest();
  30301. xdr.ontimeout = function () {
  30302. socket.emit("error", new Errors.RequestTimedOut());
  30303. socket.close();
  30304. };
  30305. xdr.onerror = function (e) {
  30306. socket.emit("error", e);
  30307. socket.close();
  30308. };
  30309. xdr.onprogress = function () {
  30310. if (xdr.responseText && xdr.responseText.length > 0) {
  30311. socket.onChunk(200, xdr.responseText);
  30312. }
  30313. };
  30314. xdr.onload = function () {
  30315. if (xdr.responseText && xdr.responseText.length > 0) {
  30316. socket.onChunk(200, xdr.responseText);
  30317. }
  30318. socket.emit("finished", 200);
  30319. socket.close();
  30320. };
  30321. return xdr;
  30322. },
  30323. abortRequest: function (xdr) {
  30324. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  30325. xdr.abort();
  30326. }
  30327. };
  30328. exports.__esModule = true;
  30329. exports["default"] = hooks;
  30330. /***/ }),
  30331. /* 30 */
  30332. /***/ (function(module, exports) {
  30333. "use strict";
  30334. var __extends = (this && this.__extends) || function (d, b) {
  30335. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30336. function __() { this.constructor = d; }
  30337. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30338. };
  30339. var BadEventName = (function (_super) {
  30340. __extends(BadEventName, _super);
  30341. function BadEventName() {
  30342. _super.apply(this, arguments);
  30343. }
  30344. return BadEventName;
  30345. }(Error));
  30346. exports.BadEventName = BadEventName;
  30347. var RequestTimedOut = (function (_super) {
  30348. __extends(RequestTimedOut, _super);
  30349. function RequestTimedOut() {
  30350. _super.apply(this, arguments);
  30351. }
  30352. return RequestTimedOut;
  30353. }(Error));
  30354. exports.RequestTimedOut = RequestTimedOut;
  30355. var TransportPriorityTooLow = (function (_super) {
  30356. __extends(TransportPriorityTooLow, _super);
  30357. function TransportPriorityTooLow() {
  30358. _super.apply(this, arguments);
  30359. }
  30360. return TransportPriorityTooLow;
  30361. }(Error));
  30362. exports.TransportPriorityTooLow = TransportPriorityTooLow;
  30363. var TransportClosed = (function (_super) {
  30364. __extends(TransportClosed, _super);
  30365. function TransportClosed() {
  30366. _super.apply(this, arguments);
  30367. }
  30368. return TransportClosed;
  30369. }(Error));
  30370. exports.TransportClosed = TransportClosed;
  30371. var UnsupportedTransport = (function (_super) {
  30372. __extends(UnsupportedTransport, _super);
  30373. function UnsupportedTransport() {
  30374. _super.apply(this, arguments);
  30375. }
  30376. return UnsupportedTransport;
  30377. }(Error));
  30378. exports.UnsupportedTransport = UnsupportedTransport;
  30379. var UnsupportedStrategy = (function (_super) {
  30380. __extends(UnsupportedStrategy, _super);
  30381. function UnsupportedStrategy() {
  30382. _super.apply(this, arguments);
  30383. }
  30384. return UnsupportedStrategy;
  30385. }(Error));
  30386. exports.UnsupportedStrategy = UnsupportedStrategy;
  30387. /***/ }),
  30388. /* 31 */
  30389. /***/ (function(module, exports, __webpack_require__) {
  30390. "use strict";
  30391. var http_request_1 = __webpack_require__(32);
  30392. var http_socket_1 = __webpack_require__(33);
  30393. var http_streaming_socket_1 = __webpack_require__(35);
  30394. var http_polling_socket_1 = __webpack_require__(36);
  30395. var http_xhr_request_1 = __webpack_require__(37);
  30396. var HTTP = {
  30397. createStreamingSocket: function (url) {
  30398. return this.createSocket(http_streaming_socket_1["default"], url);
  30399. },
  30400. createPollingSocket: function (url) {
  30401. return this.createSocket(http_polling_socket_1["default"], url);
  30402. },
  30403. createSocket: function (hooks, url) {
  30404. return new http_socket_1["default"](hooks, url);
  30405. },
  30406. createXHR: function (method, url) {
  30407. return this.createRequest(http_xhr_request_1["default"], method, url);
  30408. },
  30409. createRequest: function (hooks, method, url) {
  30410. return new http_request_1["default"](hooks, method, url);
  30411. }
  30412. };
  30413. exports.__esModule = true;
  30414. exports["default"] = HTTP;
  30415. /***/ }),
  30416. /* 32 */
  30417. /***/ (function(module, exports, __webpack_require__) {
  30418. "use strict";
  30419. var __extends = (this && this.__extends) || function (d, b) {
  30420. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30421. function __() { this.constructor = d; }
  30422. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30423. };
  30424. var runtime_1 = __webpack_require__(2);
  30425. var dispatcher_1 = __webpack_require__(23);
  30426. var MAX_BUFFER_LENGTH = 256 * 1024;
  30427. var HTTPRequest = (function (_super) {
  30428. __extends(HTTPRequest, _super);
  30429. function HTTPRequest(hooks, method, url) {
  30430. _super.call(this);
  30431. this.hooks = hooks;
  30432. this.method = method;
  30433. this.url = url;
  30434. }
  30435. HTTPRequest.prototype.start = function (payload) {
  30436. var _this = this;
  30437. this.position = 0;
  30438. this.xhr = this.hooks.getRequest(this);
  30439. this.unloader = function () {
  30440. _this.close();
  30441. };
  30442. runtime_1["default"].addUnloadListener(this.unloader);
  30443. this.xhr.open(this.method, this.url, true);
  30444. if (this.xhr.setRequestHeader) {
  30445. this.xhr.setRequestHeader("Content-Type", "application/json");
  30446. }
  30447. this.xhr.send(payload);
  30448. };
  30449. HTTPRequest.prototype.close = function () {
  30450. if (this.unloader) {
  30451. runtime_1["default"].removeUnloadListener(this.unloader);
  30452. this.unloader = null;
  30453. }
  30454. if (this.xhr) {
  30455. this.hooks.abortRequest(this.xhr);
  30456. this.xhr = null;
  30457. }
  30458. };
  30459. HTTPRequest.prototype.onChunk = function (status, data) {
  30460. while (true) {
  30461. var chunk = this.advanceBuffer(data);
  30462. if (chunk) {
  30463. this.emit("chunk", { status: status, data: chunk });
  30464. }
  30465. else {
  30466. break;
  30467. }
  30468. }
  30469. if (this.isBufferTooLong(data)) {
  30470. this.emit("buffer_too_long");
  30471. }
  30472. };
  30473. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  30474. var unreadData = buffer.slice(this.position);
  30475. var endOfLinePosition = unreadData.indexOf("\n");
  30476. if (endOfLinePosition !== -1) {
  30477. this.position += endOfLinePosition + 1;
  30478. return unreadData.slice(0, endOfLinePosition);
  30479. }
  30480. else {
  30481. return null;
  30482. }
  30483. };
  30484. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  30485. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  30486. };
  30487. return HTTPRequest;
  30488. }(dispatcher_1["default"]));
  30489. exports.__esModule = true;
  30490. exports["default"] = HTTPRequest;
  30491. /***/ }),
  30492. /* 33 */
  30493. /***/ (function(module, exports, __webpack_require__) {
  30494. "use strict";
  30495. var state_1 = __webpack_require__(34);
  30496. var util_1 = __webpack_require__(11);
  30497. var runtime_1 = __webpack_require__(2);
  30498. var autoIncrement = 1;
  30499. var HTTPSocket = (function () {
  30500. function HTTPSocket(hooks, url) {
  30501. this.hooks = hooks;
  30502. this.session = randomNumber(1000) + "/" + randomString(8);
  30503. this.location = getLocation(url);
  30504. this.readyState = state_1["default"].CONNECTING;
  30505. this.openStream();
  30506. }
  30507. HTTPSocket.prototype.send = function (payload) {
  30508. return this.sendRaw(JSON.stringify([payload]));
  30509. };
  30510. HTTPSocket.prototype.ping = function () {
  30511. this.hooks.sendHeartbeat(this);
  30512. };
  30513. HTTPSocket.prototype.close = function (code, reason) {
  30514. this.onClose(code, reason, true);
  30515. };
  30516. HTTPSocket.prototype.sendRaw = function (payload) {
  30517. if (this.readyState === state_1["default"].OPEN) {
  30518. try {
  30519. runtime_1["default"].createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  30520. return true;
  30521. }
  30522. catch (e) {
  30523. return false;
  30524. }
  30525. }
  30526. else {
  30527. return false;
  30528. }
  30529. };
  30530. HTTPSocket.prototype.reconnect = function () {
  30531. this.closeStream();
  30532. this.openStream();
  30533. };
  30534. ;
  30535. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  30536. this.closeStream();
  30537. this.readyState = state_1["default"].CLOSED;
  30538. if (this.onclose) {
  30539. this.onclose({
  30540. code: code,
  30541. reason: reason,
  30542. wasClean: wasClean
  30543. });
  30544. }
  30545. };
  30546. HTTPSocket.prototype.onChunk = function (chunk) {
  30547. if (chunk.status !== 200) {
  30548. return;
  30549. }
  30550. if (this.readyState === state_1["default"].OPEN) {
  30551. this.onActivity();
  30552. }
  30553. var payload;
  30554. var type = chunk.data.slice(0, 1);
  30555. switch (type) {
  30556. case 'o':
  30557. payload = JSON.parse(chunk.data.slice(1) || '{}');
  30558. this.onOpen(payload);
  30559. break;
  30560. case 'a':
  30561. payload = JSON.parse(chunk.data.slice(1) || '[]');
  30562. for (var i = 0; i < payload.length; i++) {
  30563. this.onEvent(payload[i]);
  30564. }
  30565. break;
  30566. case 'm':
  30567. payload = JSON.parse(chunk.data.slice(1) || 'null');
  30568. this.onEvent(payload);
  30569. break;
  30570. case 'h':
  30571. this.hooks.onHeartbeat(this);
  30572. break;
  30573. case 'c':
  30574. payload = JSON.parse(chunk.data.slice(1) || '[]');
  30575. this.onClose(payload[0], payload[1], true);
  30576. break;
  30577. }
  30578. };
  30579. HTTPSocket.prototype.onOpen = function (options) {
  30580. if (this.readyState === state_1["default"].CONNECTING) {
  30581. if (options && options.hostname) {
  30582. this.location.base = replaceHost(this.location.base, options.hostname);
  30583. }
  30584. this.readyState = state_1["default"].OPEN;
  30585. if (this.onopen) {
  30586. this.onopen();
  30587. }
  30588. }
  30589. else {
  30590. this.onClose(1006, "Server lost session", true);
  30591. }
  30592. };
  30593. HTTPSocket.prototype.onEvent = function (event) {
  30594. if (this.readyState === state_1["default"].OPEN && this.onmessage) {
  30595. this.onmessage({ data: event });
  30596. }
  30597. };
  30598. HTTPSocket.prototype.onActivity = function () {
  30599. if (this.onactivity) {
  30600. this.onactivity();
  30601. }
  30602. };
  30603. HTTPSocket.prototype.onError = function (error) {
  30604. if (this.onerror) {
  30605. this.onerror(error);
  30606. }
  30607. };
  30608. HTTPSocket.prototype.openStream = function () {
  30609. var _this = this;
  30610. this.stream = runtime_1["default"].createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  30611. this.stream.bind("chunk", function (chunk) {
  30612. _this.onChunk(chunk);
  30613. });
  30614. this.stream.bind("finished", function (status) {
  30615. _this.hooks.onFinished(_this, status);
  30616. });
  30617. this.stream.bind("buffer_too_long", function () {
  30618. _this.reconnect();
  30619. });
  30620. try {
  30621. this.stream.start();
  30622. }
  30623. catch (error) {
  30624. util_1["default"].defer(function () {
  30625. _this.onError(error);
  30626. _this.onClose(1006, "Could not start streaming", false);
  30627. });
  30628. }
  30629. };
  30630. HTTPSocket.prototype.closeStream = function () {
  30631. if (this.stream) {
  30632. this.stream.unbind_all();
  30633. this.stream.close();
  30634. this.stream = null;
  30635. }
  30636. };
  30637. return HTTPSocket;
  30638. }());
  30639. function getLocation(url) {
  30640. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  30641. return {
  30642. base: parts[1],
  30643. queryString: parts[2]
  30644. };
  30645. }
  30646. function getSendURL(url, session) {
  30647. return url.base + "/" + session + "/xhr_send";
  30648. }
  30649. function getUniqueURL(url) {
  30650. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  30651. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  30652. }
  30653. function replaceHost(url, hostname) {
  30654. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  30655. return urlParts[1] + hostname + urlParts[3];
  30656. }
  30657. function randomNumber(max) {
  30658. return Math.floor(Math.random() * max);
  30659. }
  30660. function randomString(length) {
  30661. var result = [];
  30662. for (var i = 0; i < length; i++) {
  30663. result.push(randomNumber(32).toString(32));
  30664. }
  30665. return result.join('');
  30666. }
  30667. exports.__esModule = true;
  30668. exports["default"] = HTTPSocket;
  30669. /***/ }),
  30670. /* 34 */
  30671. /***/ (function(module, exports) {
  30672. "use strict";
  30673. var State;
  30674. (function (State) {
  30675. State[State["CONNECTING"] = 0] = "CONNECTING";
  30676. State[State["OPEN"] = 1] = "OPEN";
  30677. State[State["CLOSED"] = 3] = "CLOSED";
  30678. })(State || (State = {}));
  30679. exports.__esModule = true;
  30680. exports["default"] = State;
  30681. /***/ }),
  30682. /* 35 */
  30683. /***/ (function(module, exports) {
  30684. "use strict";
  30685. var hooks = {
  30686. getReceiveURL: function (url, session) {
  30687. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  30688. },
  30689. onHeartbeat: function (socket) {
  30690. socket.sendRaw("[]");
  30691. },
  30692. sendHeartbeat: function (socket) {
  30693. socket.sendRaw("[]");
  30694. },
  30695. onFinished: function (socket, status) {
  30696. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  30697. }
  30698. };
  30699. exports.__esModule = true;
  30700. exports["default"] = hooks;
  30701. /***/ }),
  30702. /* 36 */
  30703. /***/ (function(module, exports) {
  30704. "use strict";
  30705. var hooks = {
  30706. getReceiveURL: function (url, session) {
  30707. return url.base + "/" + session + "/xhr" + url.queryString;
  30708. },
  30709. onHeartbeat: function () {
  30710. },
  30711. sendHeartbeat: function (socket) {
  30712. socket.sendRaw("[]");
  30713. },
  30714. onFinished: function (socket, status) {
  30715. if (status === 200) {
  30716. socket.reconnect();
  30717. }
  30718. else {
  30719. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  30720. }
  30721. }
  30722. };
  30723. exports.__esModule = true;
  30724. exports["default"] = hooks;
  30725. /***/ }),
  30726. /* 37 */
  30727. /***/ (function(module, exports, __webpack_require__) {
  30728. "use strict";
  30729. var runtime_1 = __webpack_require__(2);
  30730. var hooks = {
  30731. getRequest: function (socket) {
  30732. var Constructor = runtime_1["default"].getXHRAPI();
  30733. var xhr = new Constructor();
  30734. xhr.onreadystatechange = xhr.onprogress = function () {
  30735. switch (xhr.readyState) {
  30736. case 3:
  30737. if (xhr.responseText && xhr.responseText.length > 0) {
  30738. socket.onChunk(xhr.status, xhr.responseText);
  30739. }
  30740. break;
  30741. case 4:
  30742. if (xhr.responseText && xhr.responseText.length > 0) {
  30743. socket.onChunk(xhr.status, xhr.responseText);
  30744. }
  30745. socket.emit("finished", xhr.status);
  30746. socket.close();
  30747. break;
  30748. }
  30749. };
  30750. return xhr;
  30751. },
  30752. abortRequest: function (xhr) {
  30753. xhr.onreadystatechange = null;
  30754. xhr.abort();
  30755. }
  30756. };
  30757. exports.__esModule = true;
  30758. exports["default"] = hooks;
  30759. /***/ }),
  30760. /* 38 */
  30761. /***/ (function(module, exports, __webpack_require__) {
  30762. "use strict";
  30763. var Collections = __webpack_require__(9);
  30764. var util_1 = __webpack_require__(11);
  30765. var level_1 = __webpack_require__(39);
  30766. var Timeline = (function () {
  30767. function Timeline(key, session, options) {
  30768. this.key = key;
  30769. this.session = session;
  30770. this.events = [];
  30771. this.options = options || {};
  30772. this.sent = 0;
  30773. this.uniqueID = 0;
  30774. }
  30775. Timeline.prototype.log = function (level, event) {
  30776. if (level <= this.options.level) {
  30777. this.events.push(Collections.extend({}, event, { timestamp: util_1["default"].now() }));
  30778. if (this.options.limit && this.events.length > this.options.limit) {
  30779. this.events.shift();
  30780. }
  30781. }
  30782. };
  30783. Timeline.prototype.error = function (event) {
  30784. this.log(level_1["default"].ERROR, event);
  30785. };
  30786. Timeline.prototype.info = function (event) {
  30787. this.log(level_1["default"].INFO, event);
  30788. };
  30789. Timeline.prototype.debug = function (event) {
  30790. this.log(level_1["default"].DEBUG, event);
  30791. };
  30792. Timeline.prototype.isEmpty = function () {
  30793. return this.events.length === 0;
  30794. };
  30795. Timeline.prototype.send = function (sendfn, callback) {
  30796. var _this = this;
  30797. var data = Collections.extend({
  30798. session: this.session,
  30799. bundle: this.sent + 1,
  30800. key: this.key,
  30801. lib: "js",
  30802. version: this.options.version,
  30803. cluster: this.options.cluster,
  30804. features: this.options.features,
  30805. timeline: this.events
  30806. }, this.options.params);
  30807. this.events = [];
  30808. sendfn(data, function (error, result) {
  30809. if (!error) {
  30810. _this.sent++;
  30811. }
  30812. if (callback) {
  30813. callback(error, result);
  30814. }
  30815. });
  30816. return true;
  30817. };
  30818. Timeline.prototype.generateUniqueID = function () {
  30819. this.uniqueID++;
  30820. return this.uniqueID;
  30821. };
  30822. return Timeline;
  30823. }());
  30824. exports.__esModule = true;
  30825. exports["default"] = Timeline;
  30826. /***/ }),
  30827. /* 39 */
  30828. /***/ (function(module, exports) {
  30829. "use strict";
  30830. var TimelineLevel;
  30831. (function (TimelineLevel) {
  30832. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  30833. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  30834. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  30835. })(TimelineLevel || (TimelineLevel = {}));
  30836. exports.__esModule = true;
  30837. exports["default"] = TimelineLevel;
  30838. /***/ }),
  30839. /* 40 */
  30840. /***/ (function(module, exports, __webpack_require__) {
  30841. "use strict";
  30842. var Collections = __webpack_require__(9);
  30843. var util_1 = __webpack_require__(11);
  30844. var transport_manager_1 = __webpack_require__(41);
  30845. var Errors = __webpack_require__(30);
  30846. var transport_strategy_1 = __webpack_require__(55);
  30847. var sequential_strategy_1 = __webpack_require__(56);
  30848. var best_connected_ever_strategy_1 = __webpack_require__(57);
  30849. var cached_strategy_1 = __webpack_require__(58);
  30850. var delayed_strategy_1 = __webpack_require__(59);
  30851. var if_strategy_1 = __webpack_require__(60);
  30852. var first_connected_strategy_1 = __webpack_require__(61);
  30853. var runtime_1 = __webpack_require__(2);
  30854. var Transports = runtime_1["default"].Transports;
  30855. exports.build = function (scheme, options) {
  30856. var context = Collections.extend({}, globalContext, options);
  30857. return evaluate(scheme, context)[1].strategy;
  30858. };
  30859. var UnsupportedStrategy = {
  30860. isSupported: function () {
  30861. return false;
  30862. },
  30863. connect: function (_, callback) {
  30864. var deferred = util_1["default"].defer(function () {
  30865. callback(new Errors.UnsupportedStrategy());
  30866. });
  30867. return {
  30868. abort: function () {
  30869. deferred.ensureAborted();
  30870. },
  30871. forceMinPriority: function () { }
  30872. };
  30873. }
  30874. };
  30875. function returnWithOriginalContext(f) {
  30876. return function (context) {
  30877. return [f.apply(this, arguments), context];
  30878. };
  30879. }
  30880. var globalContext = {
  30881. extend: function (context, first, second) {
  30882. return [Collections.extend({}, first, second), context];
  30883. },
  30884. def: function (context, name, value) {
  30885. if (context[name] !== undefined) {
  30886. throw "Redefining symbol " + name;
  30887. }
  30888. context[name] = value;
  30889. return [undefined, context];
  30890. },
  30891. def_transport: function (context, name, type, priority, options, manager) {
  30892. var transportClass = Transports[type];
  30893. if (!transportClass) {
  30894. throw new Errors.UnsupportedTransport(type);
  30895. }
  30896. var enabled = (!context.enabledTransports ||
  30897. Collections.arrayIndexOf(context.enabledTransports, name) !== -1) &&
  30898. (!context.disabledTransports ||
  30899. Collections.arrayIndexOf(context.disabledTransports, name) === -1);
  30900. var transport;
  30901. if (enabled) {
  30902. transport = new transport_strategy_1["default"](name, priority, manager ? manager.getAssistant(transportClass) : transportClass, Collections.extend({
  30903. key: context.key,
  30904. encrypted: context.encrypted,
  30905. timeline: context.timeline,
  30906. ignoreNullOrigin: context.ignoreNullOrigin
  30907. }, options));
  30908. }
  30909. else {
  30910. transport = UnsupportedStrategy;
  30911. }
  30912. var newContext = context.def(context, name, transport)[1];
  30913. newContext.Transports = context.Transports || {};
  30914. newContext.Transports[name] = transport;
  30915. return [undefined, newContext];
  30916. },
  30917. transport_manager: returnWithOriginalContext(function (_, options) {
  30918. return new transport_manager_1["default"](options);
  30919. }),
  30920. sequential: returnWithOriginalContext(function (_, options) {
  30921. var strategies = Array.prototype.slice.call(arguments, 2);
  30922. return new sequential_strategy_1["default"](strategies, options);
  30923. }),
  30924. cached: returnWithOriginalContext(function (context, ttl, strategy) {
  30925. return new cached_strategy_1["default"](strategy, context.Transports, {
  30926. ttl: ttl,
  30927. timeline: context.timeline,
  30928. encrypted: context.encrypted
  30929. });
  30930. }),
  30931. first_connected: returnWithOriginalContext(function (_, strategy) {
  30932. return new first_connected_strategy_1["default"](strategy);
  30933. }),
  30934. best_connected_ever: returnWithOriginalContext(function () {
  30935. var strategies = Array.prototype.slice.call(arguments, 1);
  30936. return new best_connected_ever_strategy_1["default"](strategies);
  30937. }),
  30938. delayed: returnWithOriginalContext(function (_, delay, strategy) {
  30939. return new delayed_strategy_1["default"](strategy, { delay: delay });
  30940. }),
  30941. "if": returnWithOriginalContext(function (_, test, trueBranch, falseBranch) {
  30942. return new if_strategy_1["default"](test, trueBranch, falseBranch);
  30943. }),
  30944. is_supported: returnWithOriginalContext(function (_, strategy) {
  30945. return function () {
  30946. return strategy.isSupported();
  30947. };
  30948. })
  30949. };
  30950. function isSymbol(expression) {
  30951. return (typeof expression === "string") && expression.charAt(0) === ":";
  30952. }
  30953. function getSymbolValue(expression, context) {
  30954. return context[expression.slice(1)];
  30955. }
  30956. function evaluateListOfExpressions(expressions, context) {
  30957. if (expressions.length === 0) {
  30958. return [[], context];
  30959. }
  30960. var head = evaluate(expressions[0], context);
  30961. var tail = evaluateListOfExpressions(expressions.slice(1), head[1]);
  30962. return [[head[0]].concat(tail[0]), tail[1]];
  30963. }
  30964. function evaluateString(expression, context) {
  30965. if (!isSymbol(expression)) {
  30966. return [expression, context];
  30967. }
  30968. var value = getSymbolValue(expression, context);
  30969. if (value === undefined) {
  30970. throw "Undefined symbol " + expression;
  30971. }
  30972. return [value, context];
  30973. }
  30974. function evaluateArray(expression, context) {
  30975. if (isSymbol(expression[0])) {
  30976. var f = getSymbolValue(expression[0], context);
  30977. if (expression.length > 1) {
  30978. if (typeof f !== "function") {
  30979. throw "Calling non-function " + expression[0];
  30980. }
  30981. var args = [Collections.extend({}, context)].concat(Collections.map(expression.slice(1), function (arg) {
  30982. return evaluate(arg, Collections.extend({}, context))[0];
  30983. }));
  30984. return f.apply(this, args);
  30985. }
  30986. else {
  30987. return [f, context];
  30988. }
  30989. }
  30990. else {
  30991. return evaluateListOfExpressions(expression, context);
  30992. }
  30993. }
  30994. function evaluate(expression, context) {
  30995. if (typeof expression === "string") {
  30996. return evaluateString(expression, context);
  30997. }
  30998. else if (typeof expression === "object") {
  30999. if (expression instanceof Array && expression.length > 0) {
  31000. return evaluateArray(expression, context);
  31001. }
  31002. }
  31003. return [expression, context];
  31004. }
  31005. /***/ }),
  31006. /* 41 */
  31007. /***/ (function(module, exports, __webpack_require__) {
  31008. "use strict";
  31009. var factory_1 = __webpack_require__(42);
  31010. var TransportManager = (function () {
  31011. function TransportManager(options) {
  31012. this.options = options || {};
  31013. this.livesLeft = this.options.lives || Infinity;
  31014. }
  31015. TransportManager.prototype.getAssistant = function (transport) {
  31016. return factory_1["default"].createAssistantToTheTransportManager(this, transport, {
  31017. minPingDelay: this.options.minPingDelay,
  31018. maxPingDelay: this.options.maxPingDelay
  31019. });
  31020. };
  31021. TransportManager.prototype.isAlive = function () {
  31022. return this.livesLeft > 0;
  31023. };
  31024. TransportManager.prototype.reportDeath = function () {
  31025. this.livesLeft -= 1;
  31026. };
  31027. return TransportManager;
  31028. }());
  31029. exports.__esModule = true;
  31030. exports["default"] = TransportManager;
  31031. /***/ }),
  31032. /* 42 */
  31033. /***/ (function(module, exports, __webpack_require__) {
  31034. "use strict";
  31035. var assistant_to_the_transport_manager_1 = __webpack_require__(43);
  31036. var handshake_1 = __webpack_require__(44);
  31037. var pusher_authorizer_1 = __webpack_require__(47);
  31038. var timeline_sender_1 = __webpack_require__(48);
  31039. var presence_channel_1 = __webpack_require__(49);
  31040. var private_channel_1 = __webpack_require__(50);
  31041. var channel_1 = __webpack_require__(51);
  31042. var connection_manager_1 = __webpack_require__(53);
  31043. var channels_1 = __webpack_require__(54);
  31044. var Factory = {
  31045. createChannels: function () {
  31046. return new channels_1["default"]();
  31047. },
  31048. createConnectionManager: function (key, options) {
  31049. return new connection_manager_1["default"](key, options);
  31050. },
  31051. createChannel: function (name, pusher) {
  31052. return new channel_1["default"](name, pusher);
  31053. },
  31054. createPrivateChannel: function (name, pusher) {
  31055. return new private_channel_1["default"](name, pusher);
  31056. },
  31057. createPresenceChannel: function (name, pusher) {
  31058. return new presence_channel_1["default"](name, pusher);
  31059. },
  31060. createTimelineSender: function (timeline, options) {
  31061. return new timeline_sender_1["default"](timeline, options);
  31062. },
  31063. createAuthorizer: function (channel, options) {
  31064. if (options.authorizer) {
  31065. return options.authorizer(channel, options);
  31066. }
  31067. return new pusher_authorizer_1["default"](channel, options);
  31068. },
  31069. createHandshake: function (transport, callback) {
  31070. return new handshake_1["default"](transport, callback);
  31071. },
  31072. createAssistantToTheTransportManager: function (manager, transport, options) {
  31073. return new assistant_to_the_transport_manager_1["default"](manager, transport, options);
  31074. }
  31075. };
  31076. exports.__esModule = true;
  31077. exports["default"] = Factory;
  31078. /***/ }),
  31079. /* 43 */
  31080. /***/ (function(module, exports, __webpack_require__) {
  31081. "use strict";
  31082. var util_1 = __webpack_require__(11);
  31083. var Collections = __webpack_require__(9);
  31084. var AssistantToTheTransportManager = (function () {
  31085. function AssistantToTheTransportManager(manager, transport, options) {
  31086. this.manager = manager;
  31087. this.transport = transport;
  31088. this.minPingDelay = options.minPingDelay;
  31089. this.maxPingDelay = options.maxPingDelay;
  31090. this.pingDelay = undefined;
  31091. }
  31092. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  31093. var _this = this;
  31094. options = Collections.extend({}, options, {
  31095. activityTimeout: this.pingDelay
  31096. });
  31097. var connection = this.transport.createConnection(name, priority, key, options);
  31098. var openTimestamp = null;
  31099. var onOpen = function () {
  31100. connection.unbind("open", onOpen);
  31101. connection.bind("closed", onClosed);
  31102. openTimestamp = util_1["default"].now();
  31103. };
  31104. var onClosed = function (closeEvent) {
  31105. connection.unbind("closed", onClosed);
  31106. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  31107. _this.manager.reportDeath();
  31108. }
  31109. else if (!closeEvent.wasClean && openTimestamp) {
  31110. var lifespan = util_1["default"].now() - openTimestamp;
  31111. if (lifespan < 2 * _this.maxPingDelay) {
  31112. _this.manager.reportDeath();
  31113. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  31114. }
  31115. }
  31116. };
  31117. connection.bind("open", onOpen);
  31118. return connection;
  31119. };
  31120. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  31121. return this.manager.isAlive() && this.transport.isSupported(environment);
  31122. };
  31123. return AssistantToTheTransportManager;
  31124. }());
  31125. exports.__esModule = true;
  31126. exports["default"] = AssistantToTheTransportManager;
  31127. /***/ }),
  31128. /* 44 */
  31129. /***/ (function(module, exports, __webpack_require__) {
  31130. "use strict";
  31131. var Collections = __webpack_require__(9);
  31132. var Protocol = __webpack_require__(45);
  31133. var connection_1 = __webpack_require__(46);
  31134. var Handshake = (function () {
  31135. function Handshake(transport, callback) {
  31136. this.transport = transport;
  31137. this.callback = callback;
  31138. this.bindListeners();
  31139. }
  31140. Handshake.prototype.close = function () {
  31141. this.unbindListeners();
  31142. this.transport.close();
  31143. };
  31144. Handshake.prototype.bindListeners = function () {
  31145. var _this = this;
  31146. this.onMessage = function (m) {
  31147. _this.unbindListeners();
  31148. var result;
  31149. try {
  31150. result = Protocol.processHandshake(m);
  31151. }
  31152. catch (e) {
  31153. _this.finish("error", { error: e });
  31154. _this.transport.close();
  31155. return;
  31156. }
  31157. if (result.action === "connected") {
  31158. _this.finish("connected", {
  31159. connection: new connection_1["default"](result.id, _this.transport),
  31160. activityTimeout: result.activityTimeout
  31161. });
  31162. }
  31163. else {
  31164. _this.finish(result.action, { error: result.error });
  31165. _this.transport.close();
  31166. }
  31167. };
  31168. this.onClosed = function (closeEvent) {
  31169. _this.unbindListeners();
  31170. var action = Protocol.getCloseAction(closeEvent) || "backoff";
  31171. var error = Protocol.getCloseError(closeEvent);
  31172. _this.finish(action, { error: error });
  31173. };
  31174. this.transport.bind("message", this.onMessage);
  31175. this.transport.bind("closed", this.onClosed);
  31176. };
  31177. Handshake.prototype.unbindListeners = function () {
  31178. this.transport.unbind("message", this.onMessage);
  31179. this.transport.unbind("closed", this.onClosed);
  31180. };
  31181. Handshake.prototype.finish = function (action, params) {
  31182. this.callback(Collections.extend({ transport: this.transport, action: action }, params));
  31183. };
  31184. return Handshake;
  31185. }());
  31186. exports.__esModule = true;
  31187. exports["default"] = Handshake;
  31188. /***/ }),
  31189. /* 45 */
  31190. /***/ (function(module, exports) {
  31191. "use strict";
  31192. exports.decodeMessage = function (message) {
  31193. try {
  31194. var params = JSON.parse(message.data);
  31195. if (typeof params.data === 'string') {
  31196. try {
  31197. params.data = JSON.parse(params.data);
  31198. }
  31199. catch (e) {
  31200. if (!(e instanceof SyntaxError)) {
  31201. throw e;
  31202. }
  31203. }
  31204. }
  31205. return params;
  31206. }
  31207. catch (e) {
  31208. throw { type: 'MessageParseError', error: e, data: message.data };
  31209. }
  31210. };
  31211. exports.encodeMessage = function (message) {
  31212. return JSON.stringify(message);
  31213. };
  31214. exports.processHandshake = function (message) {
  31215. message = exports.decodeMessage(message);
  31216. if (message.event === "pusher:connection_established") {
  31217. if (!message.data.activity_timeout) {
  31218. throw "No activity timeout specified in handshake";
  31219. }
  31220. return {
  31221. action: "connected",
  31222. id: message.data.socket_id,
  31223. activityTimeout: message.data.activity_timeout * 1000
  31224. };
  31225. }
  31226. else if (message.event === "pusher:error") {
  31227. return {
  31228. action: this.getCloseAction(message.data),
  31229. error: this.getCloseError(message.data)
  31230. };
  31231. }
  31232. else {
  31233. throw "Invalid handshake";
  31234. }
  31235. };
  31236. exports.getCloseAction = function (closeEvent) {
  31237. if (closeEvent.code < 4000) {
  31238. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  31239. return "backoff";
  31240. }
  31241. else {
  31242. return null;
  31243. }
  31244. }
  31245. else if (closeEvent.code === 4000) {
  31246. return "ssl_only";
  31247. }
  31248. else if (closeEvent.code < 4100) {
  31249. return "refused";
  31250. }
  31251. else if (closeEvent.code < 4200) {
  31252. return "backoff";
  31253. }
  31254. else if (closeEvent.code < 4300) {
  31255. return "retry";
  31256. }
  31257. else {
  31258. return "refused";
  31259. }
  31260. };
  31261. exports.getCloseError = function (closeEvent) {
  31262. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  31263. return {
  31264. type: 'PusherError',
  31265. data: {
  31266. code: closeEvent.code,
  31267. message: closeEvent.reason || closeEvent.message
  31268. }
  31269. };
  31270. }
  31271. else {
  31272. return null;
  31273. }
  31274. };
  31275. /***/ }),
  31276. /* 46 */
  31277. /***/ (function(module, exports, __webpack_require__) {
  31278. "use strict";
  31279. var __extends = (this && this.__extends) || function (d, b) {
  31280. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31281. function __() { this.constructor = d; }
  31282. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31283. };
  31284. var Collections = __webpack_require__(9);
  31285. var dispatcher_1 = __webpack_require__(23);
  31286. var Protocol = __webpack_require__(45);
  31287. var logger_1 = __webpack_require__(8);
  31288. var Connection = (function (_super) {
  31289. __extends(Connection, _super);
  31290. function Connection(id, transport) {
  31291. _super.call(this);
  31292. this.id = id;
  31293. this.transport = transport;
  31294. this.activityTimeout = transport.activityTimeout;
  31295. this.bindListeners();
  31296. }
  31297. Connection.prototype.handlesActivityChecks = function () {
  31298. return this.transport.handlesActivityChecks();
  31299. };
  31300. Connection.prototype.send = function (data) {
  31301. return this.transport.send(data);
  31302. };
  31303. Connection.prototype.send_event = function (name, data, channel) {
  31304. var message = { event: name, data: data };
  31305. if (channel) {
  31306. message.channel = channel;
  31307. }
  31308. logger_1["default"].debug('Event sent', message);
  31309. return this.send(Protocol.encodeMessage(message));
  31310. };
  31311. Connection.prototype.ping = function () {
  31312. if (this.transport.supportsPing()) {
  31313. this.transport.ping();
  31314. }
  31315. else {
  31316. this.send_event('pusher:ping', {});
  31317. }
  31318. };
  31319. Connection.prototype.close = function () {
  31320. this.transport.close();
  31321. };
  31322. Connection.prototype.bindListeners = function () {
  31323. var _this = this;
  31324. var listeners = {
  31325. message: function (m) {
  31326. var message;
  31327. try {
  31328. message = Protocol.decodeMessage(m);
  31329. }
  31330. catch (e) {
  31331. _this.emit('error', {
  31332. type: 'MessageParseError',
  31333. error: e,
  31334. data: m.data
  31335. });
  31336. }
  31337. if (message !== undefined) {
  31338. logger_1["default"].debug('Event recd', message);
  31339. switch (message.event) {
  31340. case 'pusher:error':
  31341. _this.emit('error', { type: 'PusherError', data: message.data });
  31342. break;
  31343. case 'pusher:ping':
  31344. _this.emit("ping");
  31345. break;
  31346. case 'pusher:pong':
  31347. _this.emit("pong");
  31348. break;
  31349. }
  31350. _this.emit('message', message);
  31351. }
  31352. },
  31353. activity: function () {
  31354. _this.emit("activity");
  31355. },
  31356. error: function (error) {
  31357. _this.emit("error", { type: "WebSocketError", error: error });
  31358. },
  31359. closed: function (closeEvent) {
  31360. unbindListeners();
  31361. if (closeEvent && closeEvent.code) {
  31362. _this.handleCloseEvent(closeEvent);
  31363. }
  31364. _this.transport = null;
  31365. _this.emit("closed");
  31366. }
  31367. };
  31368. var unbindListeners = function () {
  31369. Collections.objectApply(listeners, function (listener, event) {
  31370. _this.transport.unbind(event, listener);
  31371. });
  31372. };
  31373. Collections.objectApply(listeners, function (listener, event) {
  31374. _this.transport.bind(event, listener);
  31375. });
  31376. };
  31377. Connection.prototype.handleCloseEvent = function (closeEvent) {
  31378. var action = Protocol.getCloseAction(closeEvent);
  31379. var error = Protocol.getCloseError(closeEvent);
  31380. if (error) {
  31381. this.emit('error', error);
  31382. }
  31383. if (action) {
  31384. this.emit(action);
  31385. }
  31386. };
  31387. return Connection;
  31388. }(dispatcher_1["default"]));
  31389. exports.__esModule = true;
  31390. exports["default"] = Connection;
  31391. /***/ }),
  31392. /* 47 */
  31393. /***/ (function(module, exports, __webpack_require__) {
  31394. "use strict";
  31395. var runtime_1 = __webpack_require__(2);
  31396. var PusherAuthorizer = (function () {
  31397. function PusherAuthorizer(channel, options) {
  31398. this.channel = channel;
  31399. var authTransport = options.authTransport;
  31400. if (typeof runtime_1["default"].getAuthorizers()[authTransport] === "undefined") {
  31401. throw "'" + authTransport + "' is not a recognized auth transport";
  31402. }
  31403. this.type = authTransport;
  31404. this.options = options;
  31405. this.authOptions = (options || {}).auth || {};
  31406. }
  31407. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  31408. var query = 'socket_id=' + encodeURIComponent(socketId) +
  31409. '&channel_name=' + encodeURIComponent(this.channel.name);
  31410. for (var i in this.authOptions.params) {
  31411. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  31412. }
  31413. return query;
  31414. };
  31415. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  31416. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime_1["default"].getAuthorizers();
  31417. return PusherAuthorizer.authorizers[this.type].call(this, runtime_1["default"], socketId, callback);
  31418. };
  31419. return PusherAuthorizer;
  31420. }());
  31421. exports.__esModule = true;
  31422. exports["default"] = PusherAuthorizer;
  31423. /***/ }),
  31424. /* 48 */
  31425. /***/ (function(module, exports, __webpack_require__) {
  31426. "use strict";
  31427. var runtime_1 = __webpack_require__(2);
  31428. var TimelineSender = (function () {
  31429. function TimelineSender(timeline, options) {
  31430. this.timeline = timeline;
  31431. this.options = options || {};
  31432. }
  31433. TimelineSender.prototype.send = function (encrypted, callback) {
  31434. if (this.timeline.isEmpty()) {
  31435. return;
  31436. }
  31437. this.timeline.send(runtime_1["default"].TimelineTransport.getAgent(this, encrypted), callback);
  31438. };
  31439. return TimelineSender;
  31440. }());
  31441. exports.__esModule = true;
  31442. exports["default"] = TimelineSender;
  31443. /***/ }),
  31444. /* 49 */
  31445. /***/ (function(module, exports, __webpack_require__) {
  31446. "use strict";
  31447. var __extends = (this && this.__extends) || function (d, b) {
  31448. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31449. function __() { this.constructor = d; }
  31450. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31451. };
  31452. var private_channel_1 = __webpack_require__(50);
  31453. var logger_1 = __webpack_require__(8);
  31454. var members_1 = __webpack_require__(52);
  31455. var PresenceChannel = (function (_super) {
  31456. __extends(PresenceChannel, _super);
  31457. function PresenceChannel(name, pusher) {
  31458. _super.call(this, name, pusher);
  31459. this.members = new members_1["default"]();
  31460. }
  31461. PresenceChannel.prototype.authorize = function (socketId, callback) {
  31462. var _this = this;
  31463. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  31464. if (!error) {
  31465. if (authData.channel_data === undefined) {
  31466. logger_1["default"].warn("Invalid auth response for channel '" +
  31467. _this.name +
  31468. "', expected 'channel_data' field");
  31469. callback("Invalid auth response");
  31470. return;
  31471. }
  31472. var channelData = JSON.parse(authData.channel_data);
  31473. _this.members.setMyID(channelData.user_id);
  31474. }
  31475. callback(error, authData);
  31476. });
  31477. };
  31478. PresenceChannel.prototype.handleEvent = function (event, data) {
  31479. switch (event) {
  31480. case "pusher_internal:subscription_succeeded":
  31481. this.subscriptionPending = false;
  31482. this.subscribed = true;
  31483. if (this.subscriptionCancelled) {
  31484. this.pusher.unsubscribe(this.name);
  31485. }
  31486. else {
  31487. this.members.onSubscription(data);
  31488. this.emit("pusher:subscription_succeeded", this.members);
  31489. }
  31490. break;
  31491. case "pusher_internal:member_added":
  31492. var addedMember = this.members.addMember(data);
  31493. this.emit('pusher:member_added', addedMember);
  31494. break;
  31495. case "pusher_internal:member_removed":
  31496. var removedMember = this.members.removeMember(data);
  31497. if (removedMember) {
  31498. this.emit('pusher:member_removed', removedMember);
  31499. }
  31500. break;
  31501. default:
  31502. private_channel_1["default"].prototype.handleEvent.call(this, event, data);
  31503. }
  31504. };
  31505. PresenceChannel.prototype.disconnect = function () {
  31506. this.members.reset();
  31507. _super.prototype.disconnect.call(this);
  31508. };
  31509. return PresenceChannel;
  31510. }(private_channel_1["default"]));
  31511. exports.__esModule = true;
  31512. exports["default"] = PresenceChannel;
  31513. /***/ }),
  31514. /* 50 */
  31515. /***/ (function(module, exports, __webpack_require__) {
  31516. "use strict";
  31517. var __extends = (this && this.__extends) || function (d, b) {
  31518. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31519. function __() { this.constructor = d; }
  31520. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31521. };
  31522. var factory_1 = __webpack_require__(42);
  31523. var channel_1 = __webpack_require__(51);
  31524. var PrivateChannel = (function (_super) {
  31525. __extends(PrivateChannel, _super);
  31526. function PrivateChannel() {
  31527. _super.apply(this, arguments);
  31528. }
  31529. PrivateChannel.prototype.authorize = function (socketId, callback) {
  31530. var authorizer = factory_1["default"].createAuthorizer(this, this.pusher.config);
  31531. return authorizer.authorize(socketId, callback);
  31532. };
  31533. return PrivateChannel;
  31534. }(channel_1["default"]));
  31535. exports.__esModule = true;
  31536. exports["default"] = PrivateChannel;
  31537. /***/ }),
  31538. /* 51 */
  31539. /***/ (function(module, exports, __webpack_require__) {
  31540. "use strict";
  31541. var __extends = (this && this.__extends) || function (d, b) {
  31542. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31543. function __() { this.constructor = d; }
  31544. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31545. };
  31546. var dispatcher_1 = __webpack_require__(23);
  31547. var Errors = __webpack_require__(30);
  31548. var logger_1 = __webpack_require__(8);
  31549. var Channel = (function (_super) {
  31550. __extends(Channel, _super);
  31551. function Channel(name, pusher) {
  31552. _super.call(this, function (event, data) {
  31553. logger_1["default"].debug('No callbacks on ' + name + ' for ' + event);
  31554. });
  31555. this.name = name;
  31556. this.pusher = pusher;
  31557. this.subscribed = false;
  31558. this.subscriptionPending = false;
  31559. this.subscriptionCancelled = false;
  31560. }
  31561. Channel.prototype.authorize = function (socketId, callback) {
  31562. return callback(false, {});
  31563. };
  31564. Channel.prototype.trigger = function (event, data) {
  31565. if (event.indexOf("client-") !== 0) {
  31566. throw new Errors.BadEventName("Event '" + event + "' does not start with 'client-'");
  31567. }
  31568. return this.pusher.send_event(event, data, this.name);
  31569. };
  31570. Channel.prototype.disconnect = function () {
  31571. this.subscribed = false;
  31572. };
  31573. Channel.prototype.handleEvent = function (event, data) {
  31574. if (event.indexOf("pusher_internal:") === 0) {
  31575. if (event === "pusher_internal:subscription_succeeded") {
  31576. this.subscriptionPending = false;
  31577. this.subscribed = true;
  31578. if (this.subscriptionCancelled) {
  31579. this.pusher.unsubscribe(this.name);
  31580. }
  31581. else {
  31582. this.emit("pusher:subscription_succeeded", data);
  31583. }
  31584. }
  31585. }
  31586. else {
  31587. this.emit(event, data);
  31588. }
  31589. };
  31590. Channel.prototype.subscribe = function () {
  31591. var _this = this;
  31592. if (this.subscribed) {
  31593. return;
  31594. }
  31595. this.subscriptionPending = true;
  31596. this.subscriptionCancelled = false;
  31597. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  31598. if (error) {
  31599. _this.handleEvent('pusher:subscription_error', data);
  31600. }
  31601. else {
  31602. _this.pusher.send_event('pusher:subscribe', {
  31603. auth: data.auth,
  31604. channel_data: data.channel_data,
  31605. channel: _this.name
  31606. });
  31607. }
  31608. });
  31609. };
  31610. Channel.prototype.unsubscribe = function () {
  31611. this.subscribed = false;
  31612. this.pusher.send_event('pusher:unsubscribe', {
  31613. channel: this.name
  31614. });
  31615. };
  31616. Channel.prototype.cancelSubscription = function () {
  31617. this.subscriptionCancelled = true;
  31618. };
  31619. Channel.prototype.reinstateSubscription = function () {
  31620. this.subscriptionCancelled = false;
  31621. };
  31622. return Channel;
  31623. }(dispatcher_1["default"]));
  31624. exports.__esModule = true;
  31625. exports["default"] = Channel;
  31626. /***/ }),
  31627. /* 52 */
  31628. /***/ (function(module, exports, __webpack_require__) {
  31629. "use strict";
  31630. var Collections = __webpack_require__(9);
  31631. var Members = (function () {
  31632. function Members() {
  31633. this.reset();
  31634. }
  31635. Members.prototype.get = function (id) {
  31636. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  31637. return {
  31638. id: id,
  31639. info: this.members[id]
  31640. };
  31641. }
  31642. else {
  31643. return null;
  31644. }
  31645. };
  31646. Members.prototype.each = function (callback) {
  31647. var _this = this;
  31648. Collections.objectApply(this.members, function (member, id) {
  31649. callback(_this.get(id));
  31650. });
  31651. };
  31652. Members.prototype.setMyID = function (id) {
  31653. this.myID = id;
  31654. };
  31655. Members.prototype.onSubscription = function (subscriptionData) {
  31656. this.members = subscriptionData.presence.hash;
  31657. this.count = subscriptionData.presence.count;
  31658. this.me = this.get(this.myID);
  31659. };
  31660. Members.prototype.addMember = function (memberData) {
  31661. if (this.get(memberData.user_id) === null) {
  31662. this.count++;
  31663. }
  31664. this.members[memberData.user_id] = memberData.user_info;
  31665. return this.get(memberData.user_id);
  31666. };
  31667. Members.prototype.removeMember = function (memberData) {
  31668. var member = this.get(memberData.user_id);
  31669. if (member) {
  31670. delete this.members[memberData.user_id];
  31671. this.count--;
  31672. }
  31673. return member;
  31674. };
  31675. Members.prototype.reset = function () {
  31676. this.members = {};
  31677. this.count = 0;
  31678. this.myID = null;
  31679. this.me = null;
  31680. };
  31681. return Members;
  31682. }());
  31683. exports.__esModule = true;
  31684. exports["default"] = Members;
  31685. /***/ }),
  31686. /* 53 */
  31687. /***/ (function(module, exports, __webpack_require__) {
  31688. "use strict";
  31689. var __extends = (this && this.__extends) || function (d, b) {
  31690. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31691. function __() { this.constructor = d; }
  31692. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31693. };
  31694. var dispatcher_1 = __webpack_require__(23);
  31695. var timers_1 = __webpack_require__(12);
  31696. var logger_1 = __webpack_require__(8);
  31697. var Collections = __webpack_require__(9);
  31698. var runtime_1 = __webpack_require__(2);
  31699. var ConnectionManager = (function (_super) {
  31700. __extends(ConnectionManager, _super);
  31701. function ConnectionManager(key, options) {
  31702. var _this = this;
  31703. _super.call(this);
  31704. this.key = key;
  31705. this.options = options || {};
  31706. this.state = "initialized";
  31707. this.connection = null;
  31708. this.encrypted = !!options.encrypted;
  31709. this.timeline = this.options.timeline;
  31710. this.connectionCallbacks = this.buildConnectionCallbacks();
  31711. this.errorCallbacks = this.buildErrorCallbacks();
  31712. this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
  31713. var Network = runtime_1["default"].getNetwork();
  31714. Network.bind("online", function () {
  31715. _this.timeline.info({ netinfo: "online" });
  31716. if (_this.state === "connecting" || _this.state === "unavailable") {
  31717. _this.retryIn(0);
  31718. }
  31719. });
  31720. Network.bind("offline", function () {
  31721. _this.timeline.info({ netinfo: "offline" });
  31722. if (_this.connection) {
  31723. _this.sendActivityCheck();
  31724. }
  31725. });
  31726. this.updateStrategy();
  31727. }
  31728. ConnectionManager.prototype.connect = function () {
  31729. if (this.connection || this.runner) {
  31730. return;
  31731. }
  31732. if (!this.strategy.isSupported()) {
  31733. this.updateState("failed");
  31734. return;
  31735. }
  31736. this.updateState("connecting");
  31737. this.startConnecting();
  31738. this.setUnavailableTimer();
  31739. };
  31740. ;
  31741. ConnectionManager.prototype.send = function (data) {
  31742. if (this.connection) {
  31743. return this.connection.send(data);
  31744. }
  31745. else {
  31746. return false;
  31747. }
  31748. };
  31749. ;
  31750. ConnectionManager.prototype.send_event = function (name, data, channel) {
  31751. if (this.connection) {
  31752. return this.connection.send_event(name, data, channel);
  31753. }
  31754. else {
  31755. return false;
  31756. }
  31757. };
  31758. ;
  31759. ConnectionManager.prototype.disconnect = function () {
  31760. this.disconnectInternally();
  31761. this.updateState("disconnected");
  31762. };
  31763. ;
  31764. ConnectionManager.prototype.isEncrypted = function () {
  31765. return this.encrypted;
  31766. };
  31767. ;
  31768. ConnectionManager.prototype.startConnecting = function () {
  31769. var _this = this;
  31770. var callback = function (error, handshake) {
  31771. if (error) {
  31772. _this.runner = _this.strategy.connect(0, callback);
  31773. }
  31774. else {
  31775. if (handshake.action === "error") {
  31776. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  31777. _this.timeline.error({ handshakeError: handshake.error });
  31778. }
  31779. else {
  31780. _this.abortConnecting();
  31781. _this.handshakeCallbacks[handshake.action](handshake);
  31782. }
  31783. }
  31784. };
  31785. this.runner = this.strategy.connect(0, callback);
  31786. };
  31787. ;
  31788. ConnectionManager.prototype.abortConnecting = function () {
  31789. if (this.runner) {
  31790. this.runner.abort();
  31791. this.runner = null;
  31792. }
  31793. };
  31794. ;
  31795. ConnectionManager.prototype.disconnectInternally = function () {
  31796. this.abortConnecting();
  31797. this.clearRetryTimer();
  31798. this.clearUnavailableTimer();
  31799. if (this.connection) {
  31800. var connection = this.abandonConnection();
  31801. connection.close();
  31802. }
  31803. };
  31804. ;
  31805. ConnectionManager.prototype.updateStrategy = function () {
  31806. this.strategy = this.options.getStrategy({
  31807. key: this.key,
  31808. timeline: this.timeline,
  31809. encrypted: this.encrypted
  31810. });
  31811. };
  31812. ;
  31813. ConnectionManager.prototype.retryIn = function (delay) {
  31814. var _this = this;
  31815. this.timeline.info({ action: "retry", delay: delay });
  31816. if (delay > 0) {
  31817. this.emit("connecting_in", Math.round(delay / 1000));
  31818. }
  31819. this.retryTimer = new timers_1.OneOffTimer(delay || 0, function () {
  31820. _this.disconnectInternally();
  31821. _this.connect();
  31822. });
  31823. };
  31824. ;
  31825. ConnectionManager.prototype.clearRetryTimer = function () {
  31826. if (this.retryTimer) {
  31827. this.retryTimer.ensureAborted();
  31828. this.retryTimer = null;
  31829. }
  31830. };
  31831. ;
  31832. ConnectionManager.prototype.setUnavailableTimer = function () {
  31833. var _this = this;
  31834. this.unavailableTimer = new timers_1.OneOffTimer(this.options.unavailableTimeout, function () {
  31835. _this.updateState("unavailable");
  31836. });
  31837. };
  31838. ;
  31839. ConnectionManager.prototype.clearUnavailableTimer = function () {
  31840. if (this.unavailableTimer) {
  31841. this.unavailableTimer.ensureAborted();
  31842. }
  31843. };
  31844. ;
  31845. ConnectionManager.prototype.sendActivityCheck = function () {
  31846. var _this = this;
  31847. this.stopActivityCheck();
  31848. this.connection.ping();
  31849. this.activityTimer = new timers_1.OneOffTimer(this.options.pongTimeout, function () {
  31850. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  31851. _this.retryIn(0);
  31852. });
  31853. };
  31854. ;
  31855. ConnectionManager.prototype.resetActivityCheck = function () {
  31856. var _this = this;
  31857. this.stopActivityCheck();
  31858. if (!this.connection.handlesActivityChecks()) {
  31859. this.activityTimer = new timers_1.OneOffTimer(this.activityTimeout, function () {
  31860. _this.sendActivityCheck();
  31861. });
  31862. }
  31863. };
  31864. ;
  31865. ConnectionManager.prototype.stopActivityCheck = function () {
  31866. if (this.activityTimer) {
  31867. this.activityTimer.ensureAborted();
  31868. }
  31869. };
  31870. ;
  31871. ConnectionManager.prototype.buildConnectionCallbacks = function () {
  31872. var _this = this;
  31873. return {
  31874. message: function (message) {
  31875. _this.resetActivityCheck();
  31876. _this.emit('message', message);
  31877. },
  31878. ping: function () {
  31879. _this.send_event('pusher:pong', {});
  31880. },
  31881. activity: function () {
  31882. _this.resetActivityCheck();
  31883. },
  31884. error: function (error) {
  31885. _this.emit("error", { type: "WebSocketError", error: error });
  31886. },
  31887. closed: function () {
  31888. _this.abandonConnection();
  31889. if (_this.shouldRetry()) {
  31890. _this.retryIn(1000);
  31891. }
  31892. }
  31893. };
  31894. };
  31895. ;
  31896. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  31897. var _this = this;
  31898. return Collections.extend({}, errorCallbacks, {
  31899. connected: function (handshake) {
  31900. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  31901. _this.clearUnavailableTimer();
  31902. _this.setConnection(handshake.connection);
  31903. _this.socket_id = _this.connection.id;
  31904. _this.updateState("connected", { socket_id: _this.socket_id });
  31905. }
  31906. });
  31907. };
  31908. ;
  31909. ConnectionManager.prototype.buildErrorCallbacks = function () {
  31910. var _this = this;
  31911. var withErrorEmitted = function (callback) {
  31912. return function (result) {
  31913. if (result.error) {
  31914. _this.emit("error", { type: "WebSocketError", error: result.error });
  31915. }
  31916. callback(result);
  31917. };
  31918. };
  31919. return {
  31920. ssl_only: withErrorEmitted(function () {
  31921. _this.encrypted = true;
  31922. _this.updateStrategy();
  31923. _this.retryIn(0);
  31924. }),
  31925. refused: withErrorEmitted(function () {
  31926. _this.disconnect();
  31927. }),
  31928. backoff: withErrorEmitted(function () {
  31929. _this.retryIn(1000);
  31930. }),
  31931. retry: withErrorEmitted(function () {
  31932. _this.retryIn(0);
  31933. })
  31934. };
  31935. };
  31936. ;
  31937. ConnectionManager.prototype.setConnection = function (connection) {
  31938. this.connection = connection;
  31939. for (var event in this.connectionCallbacks) {
  31940. this.connection.bind(event, this.connectionCallbacks[event]);
  31941. }
  31942. this.resetActivityCheck();
  31943. };
  31944. ;
  31945. ConnectionManager.prototype.abandonConnection = function () {
  31946. if (!this.connection) {
  31947. return;
  31948. }
  31949. this.stopActivityCheck();
  31950. for (var event in this.connectionCallbacks) {
  31951. this.connection.unbind(event, this.connectionCallbacks[event]);
  31952. }
  31953. var connection = this.connection;
  31954. this.connection = null;
  31955. return connection;
  31956. };
  31957. ConnectionManager.prototype.updateState = function (newState, data) {
  31958. var previousState = this.state;
  31959. this.state = newState;
  31960. if (previousState !== newState) {
  31961. var newStateDescription = newState;
  31962. if (newStateDescription === "connected") {
  31963. newStateDescription += " with new socket ID " + data.socket_id;
  31964. }
  31965. logger_1["default"].debug('State changed', previousState + ' -> ' + newStateDescription);
  31966. this.timeline.info({ state: newState, params: data });
  31967. this.emit('state_change', { previous: previousState, current: newState });
  31968. this.emit(newState, data);
  31969. }
  31970. };
  31971. ConnectionManager.prototype.shouldRetry = function () {
  31972. return this.state === "connecting" || this.state === "connected";
  31973. };
  31974. return ConnectionManager;
  31975. }(dispatcher_1["default"]));
  31976. exports.__esModule = true;
  31977. exports["default"] = ConnectionManager;
  31978. /***/ }),
  31979. /* 54 */
  31980. /***/ (function(module, exports, __webpack_require__) {
  31981. "use strict";
  31982. var Collections = __webpack_require__(9);
  31983. var factory_1 = __webpack_require__(42);
  31984. var Channels = (function () {
  31985. function Channels() {
  31986. this.channels = {};
  31987. }
  31988. Channels.prototype.add = function (name, pusher) {
  31989. if (!this.channels[name]) {
  31990. this.channels[name] = createChannel(name, pusher);
  31991. }
  31992. return this.channels[name];
  31993. };
  31994. Channels.prototype.all = function () {
  31995. return Collections.values(this.channels);
  31996. };
  31997. Channels.prototype.find = function (name) {
  31998. return this.channels[name];
  31999. };
  32000. Channels.prototype.remove = function (name) {
  32001. var channel = this.channels[name];
  32002. delete this.channels[name];
  32003. return channel;
  32004. };
  32005. Channels.prototype.disconnect = function () {
  32006. Collections.objectApply(this.channels, function (channel) {
  32007. channel.disconnect();
  32008. });
  32009. };
  32010. return Channels;
  32011. }());
  32012. exports.__esModule = true;
  32013. exports["default"] = Channels;
  32014. function createChannel(name, pusher) {
  32015. if (name.indexOf('private-') === 0) {
  32016. return factory_1["default"].createPrivateChannel(name, pusher);
  32017. }
  32018. else if (name.indexOf('presence-') === 0) {
  32019. return factory_1["default"].createPresenceChannel(name, pusher);
  32020. }
  32021. else {
  32022. return factory_1["default"].createChannel(name, pusher);
  32023. }
  32024. }
  32025. /***/ }),
  32026. /* 55 */
  32027. /***/ (function(module, exports, __webpack_require__) {
  32028. "use strict";
  32029. var factory_1 = __webpack_require__(42);
  32030. var util_1 = __webpack_require__(11);
  32031. var Errors = __webpack_require__(30);
  32032. var Collections = __webpack_require__(9);
  32033. var TransportStrategy = (function () {
  32034. function TransportStrategy(name, priority, transport, options) {
  32035. this.name = name;
  32036. this.priority = priority;
  32037. this.transport = transport;
  32038. this.options = options || {};
  32039. }
  32040. TransportStrategy.prototype.isSupported = function () {
  32041. return this.transport.isSupported({
  32042. encrypted: this.options.encrypted
  32043. });
  32044. };
  32045. TransportStrategy.prototype.connect = function (minPriority, callback) {
  32046. var _this = this;
  32047. if (!this.isSupported()) {
  32048. return failAttempt(new Errors.UnsupportedStrategy(), callback);
  32049. }
  32050. else if (this.priority < minPriority) {
  32051. return failAttempt(new Errors.TransportPriorityTooLow(), callback);
  32052. }
  32053. var connected = false;
  32054. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  32055. var handshake = null;
  32056. var onInitialized = function () {
  32057. transport.unbind("initialized", onInitialized);
  32058. transport.connect();
  32059. };
  32060. var onOpen = function () {
  32061. handshake = factory_1["default"].createHandshake(transport, function (result) {
  32062. connected = true;
  32063. unbindListeners();
  32064. callback(null, result);
  32065. });
  32066. };
  32067. var onError = function (error) {
  32068. unbindListeners();
  32069. callback(error);
  32070. };
  32071. var onClosed = function () {
  32072. unbindListeners();
  32073. var serializedTransport;
  32074. serializedTransport = Collections.safeJSONStringify(transport);
  32075. callback(new Errors.TransportClosed(serializedTransport));
  32076. };
  32077. var unbindListeners = function () {
  32078. transport.unbind("initialized", onInitialized);
  32079. transport.unbind("open", onOpen);
  32080. transport.unbind("error", onError);
  32081. transport.unbind("closed", onClosed);
  32082. };
  32083. transport.bind("initialized", onInitialized);
  32084. transport.bind("open", onOpen);
  32085. transport.bind("error", onError);
  32086. transport.bind("closed", onClosed);
  32087. transport.initialize();
  32088. return {
  32089. abort: function () {
  32090. if (connected) {
  32091. return;
  32092. }
  32093. unbindListeners();
  32094. if (handshake) {
  32095. handshake.close();
  32096. }
  32097. else {
  32098. transport.close();
  32099. }
  32100. },
  32101. forceMinPriority: function (p) {
  32102. if (connected) {
  32103. return;
  32104. }
  32105. if (_this.priority < p) {
  32106. if (handshake) {
  32107. handshake.close();
  32108. }
  32109. else {
  32110. transport.close();
  32111. }
  32112. }
  32113. }
  32114. };
  32115. };
  32116. return TransportStrategy;
  32117. }());
  32118. exports.__esModule = true;
  32119. exports["default"] = TransportStrategy;
  32120. function failAttempt(error, callback) {
  32121. util_1["default"].defer(function () {
  32122. callback(error);
  32123. });
  32124. return {
  32125. abort: function () { },
  32126. forceMinPriority: function () { }
  32127. };
  32128. }
  32129. /***/ }),
  32130. /* 56 */
  32131. /***/ (function(module, exports, __webpack_require__) {
  32132. "use strict";
  32133. var Collections = __webpack_require__(9);
  32134. var util_1 = __webpack_require__(11);
  32135. var timers_1 = __webpack_require__(12);
  32136. var SequentialStrategy = (function () {
  32137. function SequentialStrategy(strategies, options) {
  32138. this.strategies = strategies;
  32139. this.loop = Boolean(options.loop);
  32140. this.failFast = Boolean(options.failFast);
  32141. this.timeout = options.timeout;
  32142. this.timeoutLimit = options.timeoutLimit;
  32143. }
  32144. SequentialStrategy.prototype.isSupported = function () {
  32145. return Collections.any(this.strategies, util_1["default"].method("isSupported"));
  32146. };
  32147. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  32148. var _this = this;
  32149. var strategies = this.strategies;
  32150. var current = 0;
  32151. var timeout = this.timeout;
  32152. var runner = null;
  32153. var tryNextStrategy = function (error, handshake) {
  32154. if (handshake) {
  32155. callback(null, handshake);
  32156. }
  32157. else {
  32158. current = current + 1;
  32159. if (_this.loop) {
  32160. current = current % strategies.length;
  32161. }
  32162. if (current < strategies.length) {
  32163. if (timeout) {
  32164. timeout = timeout * 2;
  32165. if (_this.timeoutLimit) {
  32166. timeout = Math.min(timeout, _this.timeoutLimit);
  32167. }
  32168. }
  32169. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  32170. }
  32171. else {
  32172. callback(true);
  32173. }
  32174. }
  32175. };
  32176. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  32177. return {
  32178. abort: function () {
  32179. runner.abort();
  32180. },
  32181. forceMinPriority: function (p) {
  32182. minPriority = p;
  32183. if (runner) {
  32184. runner.forceMinPriority(p);
  32185. }
  32186. }
  32187. };
  32188. };
  32189. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  32190. var timer = null;
  32191. var runner = null;
  32192. if (options.timeout > 0) {
  32193. timer = new timers_1.OneOffTimer(options.timeout, function () {
  32194. runner.abort();
  32195. callback(true);
  32196. });
  32197. }
  32198. runner = strategy.connect(minPriority, function (error, handshake) {
  32199. if (error && timer && timer.isRunning() && !options.failFast) {
  32200. return;
  32201. }
  32202. if (timer) {
  32203. timer.ensureAborted();
  32204. }
  32205. callback(error, handshake);
  32206. });
  32207. return {
  32208. abort: function () {
  32209. if (timer) {
  32210. timer.ensureAborted();
  32211. }
  32212. runner.abort();
  32213. },
  32214. forceMinPriority: function (p) {
  32215. runner.forceMinPriority(p);
  32216. }
  32217. };
  32218. };
  32219. return SequentialStrategy;
  32220. }());
  32221. exports.__esModule = true;
  32222. exports["default"] = SequentialStrategy;
  32223. /***/ }),
  32224. /* 57 */
  32225. /***/ (function(module, exports, __webpack_require__) {
  32226. "use strict";
  32227. var Collections = __webpack_require__(9);
  32228. var util_1 = __webpack_require__(11);
  32229. var BestConnectedEverStrategy = (function () {
  32230. function BestConnectedEverStrategy(strategies) {
  32231. this.strategies = strategies;
  32232. }
  32233. BestConnectedEverStrategy.prototype.isSupported = function () {
  32234. return Collections.any(this.strategies, util_1["default"].method("isSupported"));
  32235. };
  32236. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  32237. return connect(this.strategies, minPriority, function (i, runners) {
  32238. return function (error, handshake) {
  32239. runners[i].error = error;
  32240. if (error) {
  32241. if (allRunnersFailed(runners)) {
  32242. callback(true);
  32243. }
  32244. return;
  32245. }
  32246. Collections.apply(runners, function (runner) {
  32247. runner.forceMinPriority(handshake.transport.priority);
  32248. });
  32249. callback(null, handshake);
  32250. };
  32251. });
  32252. };
  32253. return BestConnectedEverStrategy;
  32254. }());
  32255. exports.__esModule = true;
  32256. exports["default"] = BestConnectedEverStrategy;
  32257. function connect(strategies, minPriority, callbackBuilder) {
  32258. var runners = Collections.map(strategies, function (strategy, i, _, rs) {
  32259. return strategy.connect(minPriority, callbackBuilder(i, rs));
  32260. });
  32261. return {
  32262. abort: function () {
  32263. Collections.apply(runners, abortRunner);
  32264. },
  32265. forceMinPriority: function (p) {
  32266. Collections.apply(runners, function (runner) {
  32267. runner.forceMinPriority(p);
  32268. });
  32269. }
  32270. };
  32271. }
  32272. function allRunnersFailed(runners) {
  32273. return Collections.all(runners, function (runner) {
  32274. return Boolean(runner.error);
  32275. });
  32276. }
  32277. function abortRunner(runner) {
  32278. if (!runner.error && !runner.aborted) {
  32279. runner.abort();
  32280. runner.aborted = true;
  32281. }
  32282. }
  32283. /***/ }),
  32284. /* 58 */
  32285. /***/ (function(module, exports, __webpack_require__) {
  32286. "use strict";
  32287. var util_1 = __webpack_require__(11);
  32288. var runtime_1 = __webpack_require__(2);
  32289. var sequential_strategy_1 = __webpack_require__(56);
  32290. var Collections = __webpack_require__(9);
  32291. var CachedStrategy = (function () {
  32292. function CachedStrategy(strategy, transports, options) {
  32293. this.strategy = strategy;
  32294. this.transports = transports;
  32295. this.ttl = options.ttl || 1800 * 1000;
  32296. this.encrypted = options.encrypted;
  32297. this.timeline = options.timeline;
  32298. }
  32299. CachedStrategy.prototype.isSupported = function () {
  32300. return this.strategy.isSupported();
  32301. };
  32302. CachedStrategy.prototype.connect = function (minPriority, callback) {
  32303. var encrypted = this.encrypted;
  32304. var info = fetchTransportCache(encrypted);
  32305. var strategies = [this.strategy];
  32306. if (info && info.timestamp + this.ttl >= util_1["default"].now()) {
  32307. var transport = this.transports[info.transport];
  32308. if (transport) {
  32309. this.timeline.info({
  32310. cached: true,
  32311. transport: info.transport,
  32312. latency: info.latency
  32313. });
  32314. strategies.push(new sequential_strategy_1["default"]([transport], {
  32315. timeout: info.latency * 2 + 1000,
  32316. failFast: true
  32317. }));
  32318. }
  32319. }
  32320. var startTimestamp = util_1["default"].now();
  32321. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  32322. if (error) {
  32323. flushTransportCache(encrypted);
  32324. if (strategies.length > 0) {
  32325. startTimestamp = util_1["default"].now();
  32326. runner = strategies.pop().connect(minPriority, cb);
  32327. }
  32328. else {
  32329. callback(error);
  32330. }
  32331. }
  32332. else {
  32333. storeTransportCache(encrypted, handshake.transport.name, util_1["default"].now() - startTimestamp);
  32334. callback(null, handshake);
  32335. }
  32336. });
  32337. return {
  32338. abort: function () {
  32339. runner.abort();
  32340. },
  32341. forceMinPriority: function (p) {
  32342. minPriority = p;
  32343. if (runner) {
  32344. runner.forceMinPriority(p);
  32345. }
  32346. }
  32347. };
  32348. };
  32349. return CachedStrategy;
  32350. }());
  32351. exports.__esModule = true;
  32352. exports["default"] = CachedStrategy;
  32353. function getTransportCacheKey(encrypted) {
  32354. return "pusherTransport" + (encrypted ? "Encrypted" : "Unencrypted");
  32355. }
  32356. function fetchTransportCache(encrypted) {
  32357. var storage = runtime_1["default"].getLocalStorage();
  32358. if (storage) {
  32359. try {
  32360. var serializedCache = storage[getTransportCacheKey(encrypted)];
  32361. if (serializedCache) {
  32362. return JSON.parse(serializedCache);
  32363. }
  32364. }
  32365. catch (e) {
  32366. flushTransportCache(encrypted);
  32367. }
  32368. }
  32369. return null;
  32370. }
  32371. function storeTransportCache(encrypted, transport, latency) {
  32372. var storage = runtime_1["default"].getLocalStorage();
  32373. if (storage) {
  32374. try {
  32375. storage[getTransportCacheKey(encrypted)] = Collections.safeJSONStringify({
  32376. timestamp: util_1["default"].now(),
  32377. transport: transport,
  32378. latency: latency
  32379. });
  32380. }
  32381. catch (e) {
  32382. }
  32383. }
  32384. }
  32385. function flushTransportCache(encrypted) {
  32386. var storage = runtime_1["default"].getLocalStorage();
  32387. if (storage) {
  32388. try {
  32389. delete storage[getTransportCacheKey(encrypted)];
  32390. }
  32391. catch (e) {
  32392. }
  32393. }
  32394. }
  32395. /***/ }),
  32396. /* 59 */
  32397. /***/ (function(module, exports, __webpack_require__) {
  32398. "use strict";
  32399. var timers_1 = __webpack_require__(12);
  32400. var DelayedStrategy = (function () {
  32401. function DelayedStrategy(strategy, _a) {
  32402. var number = _a.delay;
  32403. this.strategy = strategy;
  32404. this.options = { delay: number };
  32405. }
  32406. DelayedStrategy.prototype.isSupported = function () {
  32407. return this.strategy.isSupported();
  32408. };
  32409. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  32410. var strategy = this.strategy;
  32411. var runner;
  32412. var timer = new timers_1.OneOffTimer(this.options.delay, function () {
  32413. runner = strategy.connect(minPriority, callback);
  32414. });
  32415. return {
  32416. abort: function () {
  32417. timer.ensureAborted();
  32418. if (runner) {
  32419. runner.abort();
  32420. }
  32421. },
  32422. forceMinPriority: function (p) {
  32423. minPriority = p;
  32424. if (runner) {
  32425. runner.forceMinPriority(p);
  32426. }
  32427. }
  32428. };
  32429. };
  32430. return DelayedStrategy;
  32431. }());
  32432. exports.__esModule = true;
  32433. exports["default"] = DelayedStrategy;
  32434. /***/ }),
  32435. /* 60 */
  32436. /***/ (function(module, exports) {
  32437. "use strict";
  32438. var IfStrategy = (function () {
  32439. function IfStrategy(test, trueBranch, falseBranch) {
  32440. this.test = test;
  32441. this.trueBranch = trueBranch;
  32442. this.falseBranch = falseBranch;
  32443. }
  32444. IfStrategy.prototype.isSupported = function () {
  32445. var branch = this.test() ? this.trueBranch : this.falseBranch;
  32446. return branch.isSupported();
  32447. };
  32448. IfStrategy.prototype.connect = function (minPriority, callback) {
  32449. var branch = this.test() ? this.trueBranch : this.falseBranch;
  32450. return branch.connect(minPriority, callback);
  32451. };
  32452. return IfStrategy;
  32453. }());
  32454. exports.__esModule = true;
  32455. exports["default"] = IfStrategy;
  32456. /***/ }),
  32457. /* 61 */
  32458. /***/ (function(module, exports) {
  32459. "use strict";
  32460. var FirstConnectedStrategy = (function () {
  32461. function FirstConnectedStrategy(strategy) {
  32462. this.strategy = strategy;
  32463. }
  32464. FirstConnectedStrategy.prototype.isSupported = function () {
  32465. return this.strategy.isSupported();
  32466. };
  32467. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  32468. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  32469. if (handshake) {
  32470. runner.abort();
  32471. }
  32472. callback(error, handshake);
  32473. });
  32474. return runner;
  32475. };
  32476. return FirstConnectedStrategy;
  32477. }());
  32478. exports.__esModule = true;
  32479. exports["default"] = FirstConnectedStrategy;
  32480. /***/ }),
  32481. /* 62 */
  32482. /***/ (function(module, exports, __webpack_require__) {
  32483. "use strict";
  32484. var defaults_1 = __webpack_require__(5);
  32485. exports.getGlobalConfig = function () {
  32486. return {
  32487. wsHost: defaults_1["default"].host,
  32488. wsPort: defaults_1["default"].ws_port,
  32489. wssPort: defaults_1["default"].wss_port,
  32490. httpHost: defaults_1["default"].sockjs_host,
  32491. httpPort: defaults_1["default"].sockjs_http_port,
  32492. httpsPort: defaults_1["default"].sockjs_https_port,
  32493. httpPath: defaults_1["default"].sockjs_path,
  32494. statsHost: defaults_1["default"].stats_host,
  32495. authEndpoint: defaults_1["default"].channel_auth_endpoint,
  32496. authTransport: defaults_1["default"].channel_auth_transport,
  32497. activity_timeout: defaults_1["default"].activity_timeout,
  32498. pong_timeout: defaults_1["default"].pong_timeout,
  32499. unavailable_timeout: defaults_1["default"].unavailable_timeout
  32500. };
  32501. };
  32502. exports.getClusterConfig = function (clusterName) {
  32503. return {
  32504. wsHost: "ws-" + clusterName + ".pusher.com",
  32505. httpHost: "sockjs-" + clusterName + ".pusher.com"
  32506. };
  32507. };
  32508. /***/ })
  32509. /******/ ])
  32510. });
  32511. ;
  32512. /***/ }),
  32513. /* 38 */
  32514. /***/ (function(module, exports, __webpack_require__) {
  32515. "use strict";
  32516. /* WEBPACK VAR INJECTION */(function(global) {/*!
  32517. * Vue.js v2.3.4
  32518. * (c) 2014-2017 Evan You
  32519. * Released under the MIT License.
  32520. */
  32521. /* */
  32522. // these helpers produces better vm code in JS engines due to their
  32523. // explicitness and function inlining
  32524. function isUndef (v) {
  32525. return v === undefined || v === null
  32526. }
  32527. function isDef (v) {
  32528. return v !== undefined && v !== null
  32529. }
  32530. function isTrue (v) {
  32531. return v === true
  32532. }
  32533. function isFalse (v) {
  32534. return v === false
  32535. }
  32536. /**
  32537. * Check if value is primitive
  32538. */
  32539. function isPrimitive (value) {
  32540. return typeof value === 'string' || typeof value === 'number'
  32541. }
  32542. /**
  32543. * Quick object check - this is primarily used to tell
  32544. * Objects from primitive values when we know the value
  32545. * is a JSON-compliant type.
  32546. */
  32547. function isObject (obj) {
  32548. return obj !== null && typeof obj === 'object'
  32549. }
  32550. var _toString = Object.prototype.toString;
  32551. /**
  32552. * Strict object type check. Only returns true
  32553. * for plain JavaScript objects.
  32554. */
  32555. function isPlainObject (obj) {
  32556. return _toString.call(obj) === '[object Object]'
  32557. }
  32558. function isRegExp (v) {
  32559. return _toString.call(v) === '[object RegExp]'
  32560. }
  32561. /**
  32562. * Convert a value to a string that is actually rendered.
  32563. */
  32564. function toString (val) {
  32565. return val == null
  32566. ? ''
  32567. : typeof val === 'object'
  32568. ? JSON.stringify(val, null, 2)
  32569. : String(val)
  32570. }
  32571. /**
  32572. * Convert a input value to a number for persistence.
  32573. * If the conversion fails, return original string.
  32574. */
  32575. function toNumber (val) {
  32576. var n = parseFloat(val);
  32577. return isNaN(n) ? val : n
  32578. }
  32579. /**
  32580. * Make a map and return a function for checking if a key
  32581. * is in that map.
  32582. */
  32583. function makeMap (
  32584. str,
  32585. expectsLowerCase
  32586. ) {
  32587. var map = Object.create(null);
  32588. var list = str.split(',');
  32589. for (var i = 0; i < list.length; i++) {
  32590. map[list[i]] = true;
  32591. }
  32592. return expectsLowerCase
  32593. ? function (val) { return map[val.toLowerCase()]; }
  32594. : function (val) { return map[val]; }
  32595. }
  32596. /**
  32597. * Check if a tag is a built-in tag.
  32598. */
  32599. var isBuiltInTag = makeMap('slot,component', true);
  32600. /**
  32601. * Remove an item from an array
  32602. */
  32603. function remove (arr, item) {
  32604. if (arr.length) {
  32605. var index = arr.indexOf(item);
  32606. if (index > -1) {
  32607. return arr.splice(index, 1)
  32608. }
  32609. }
  32610. }
  32611. /**
  32612. * Check whether the object has the property.
  32613. */
  32614. var hasOwnProperty = Object.prototype.hasOwnProperty;
  32615. function hasOwn (obj, key) {
  32616. return hasOwnProperty.call(obj, key)
  32617. }
  32618. /**
  32619. * Create a cached version of a pure function.
  32620. */
  32621. function cached (fn) {
  32622. var cache = Object.create(null);
  32623. return (function cachedFn (str) {
  32624. var hit = cache[str];
  32625. return hit || (cache[str] = fn(str))
  32626. })
  32627. }
  32628. /**
  32629. * Camelize a hyphen-delimited string.
  32630. */
  32631. var camelizeRE = /-(\w)/g;
  32632. var camelize = cached(function (str) {
  32633. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  32634. });
  32635. /**
  32636. * Capitalize a string.
  32637. */
  32638. var capitalize = cached(function (str) {
  32639. return str.charAt(0).toUpperCase() + str.slice(1)
  32640. });
  32641. /**
  32642. * Hyphenate a camelCase string.
  32643. */
  32644. var hyphenateRE = /([^-])([A-Z])/g;
  32645. var hyphenate = cached(function (str) {
  32646. return str
  32647. .replace(hyphenateRE, '$1-$2')
  32648. .replace(hyphenateRE, '$1-$2')
  32649. .toLowerCase()
  32650. });
  32651. /**
  32652. * Simple bind, faster than native
  32653. */
  32654. function bind (fn, ctx) {
  32655. function boundFn (a) {
  32656. var l = arguments.length;
  32657. return l
  32658. ? l > 1
  32659. ? fn.apply(ctx, arguments)
  32660. : fn.call(ctx, a)
  32661. : fn.call(ctx)
  32662. }
  32663. // record original fn length
  32664. boundFn._length = fn.length;
  32665. return boundFn
  32666. }
  32667. /**
  32668. * Convert an Array-like object to a real Array.
  32669. */
  32670. function toArray (list, start) {
  32671. start = start || 0;
  32672. var i = list.length - start;
  32673. var ret = new Array(i);
  32674. while (i--) {
  32675. ret[i] = list[i + start];
  32676. }
  32677. return ret
  32678. }
  32679. /**
  32680. * Mix properties into target object.
  32681. */
  32682. function extend (to, _from) {
  32683. for (var key in _from) {
  32684. to[key] = _from[key];
  32685. }
  32686. return to
  32687. }
  32688. /**
  32689. * Merge an Array of Objects into a single Object.
  32690. */
  32691. function toObject (arr) {
  32692. var res = {};
  32693. for (var i = 0; i < arr.length; i++) {
  32694. if (arr[i]) {
  32695. extend(res, arr[i]);
  32696. }
  32697. }
  32698. return res
  32699. }
  32700. /**
  32701. * Perform no operation.
  32702. */
  32703. function noop () {}
  32704. /**
  32705. * Always return false.
  32706. */
  32707. var no = function () { return false; };
  32708. /**
  32709. * Return same value
  32710. */
  32711. var identity = function (_) { return _; };
  32712. /**
  32713. * Generate a static keys string from compiler modules.
  32714. */
  32715. function genStaticKeys (modules) {
  32716. return modules.reduce(function (keys, m) {
  32717. return keys.concat(m.staticKeys || [])
  32718. }, []).join(',')
  32719. }
  32720. /**
  32721. * Check if two values are loosely equal - that is,
  32722. * if they are plain objects, do they have the same shape?
  32723. */
  32724. function looseEqual (a, b) {
  32725. var isObjectA = isObject(a);
  32726. var isObjectB = isObject(b);
  32727. if (isObjectA && isObjectB) {
  32728. try {
  32729. return JSON.stringify(a) === JSON.stringify(b)
  32730. } catch (e) {
  32731. // possible circular reference
  32732. return a === b
  32733. }
  32734. } else if (!isObjectA && !isObjectB) {
  32735. return String(a) === String(b)
  32736. } else {
  32737. return false
  32738. }
  32739. }
  32740. function looseIndexOf (arr, val) {
  32741. for (var i = 0; i < arr.length; i++) {
  32742. if (looseEqual(arr[i], val)) { return i }
  32743. }
  32744. return -1
  32745. }
  32746. /**
  32747. * Ensure a function is called only once.
  32748. */
  32749. function once (fn) {
  32750. var called = false;
  32751. return function () {
  32752. if (!called) {
  32753. called = true;
  32754. fn.apply(this, arguments);
  32755. }
  32756. }
  32757. }
  32758. var SSR_ATTR = 'data-server-rendered';
  32759. var ASSET_TYPES = [
  32760. 'component',
  32761. 'directive',
  32762. 'filter'
  32763. ];
  32764. var LIFECYCLE_HOOKS = [
  32765. 'beforeCreate',
  32766. 'created',
  32767. 'beforeMount',
  32768. 'mounted',
  32769. 'beforeUpdate',
  32770. 'updated',
  32771. 'beforeDestroy',
  32772. 'destroyed',
  32773. 'activated',
  32774. 'deactivated'
  32775. ];
  32776. /* */
  32777. var config = ({
  32778. /**
  32779. * Option merge strategies (used in core/util/options)
  32780. */
  32781. optionMergeStrategies: Object.create(null),
  32782. /**
  32783. * Whether to suppress warnings.
  32784. */
  32785. silent: false,
  32786. /**
  32787. * Show production mode tip message on boot?
  32788. */
  32789. productionTip: "development" !== 'production',
  32790. /**
  32791. * Whether to enable devtools
  32792. */
  32793. devtools: "development" !== 'production',
  32794. /**
  32795. * Whether to record perf
  32796. */
  32797. performance: false,
  32798. /**
  32799. * Error handler for watcher errors
  32800. */
  32801. errorHandler: null,
  32802. /**
  32803. * Ignore certain custom elements
  32804. */
  32805. ignoredElements: [],
  32806. /**
  32807. * Custom user key aliases for v-on
  32808. */
  32809. keyCodes: Object.create(null),
  32810. /**
  32811. * Check if a tag is reserved so that it cannot be registered as a
  32812. * component. This is platform-dependent and may be overwritten.
  32813. */
  32814. isReservedTag: no,
  32815. /**
  32816. * Check if an attribute is reserved so that it cannot be used as a component
  32817. * prop. This is platform-dependent and may be overwritten.
  32818. */
  32819. isReservedAttr: no,
  32820. /**
  32821. * Check if a tag is an unknown element.
  32822. * Platform-dependent.
  32823. */
  32824. isUnknownElement: no,
  32825. /**
  32826. * Get the namespace of an element
  32827. */
  32828. getTagNamespace: noop,
  32829. /**
  32830. * Parse the real tag name for the specific platform.
  32831. */
  32832. parsePlatformTagName: identity,
  32833. /**
  32834. * Check if an attribute must be bound using property, e.g. value
  32835. * Platform-dependent.
  32836. */
  32837. mustUseProp: no,
  32838. /**
  32839. * Exposed for legacy reasons
  32840. */
  32841. _lifecycleHooks: LIFECYCLE_HOOKS
  32842. });
  32843. /* */
  32844. var emptyObject = Object.freeze({});
  32845. /**
  32846. * Check if a string starts with $ or _
  32847. */
  32848. function isReserved (str) {
  32849. var c = (str + '').charCodeAt(0);
  32850. return c === 0x24 || c === 0x5F
  32851. }
  32852. /**
  32853. * Define a property.
  32854. */
  32855. function def (obj, key, val, enumerable) {
  32856. Object.defineProperty(obj, key, {
  32857. value: val,
  32858. enumerable: !!enumerable,
  32859. writable: true,
  32860. configurable: true
  32861. });
  32862. }
  32863. /**
  32864. * Parse simple path.
  32865. */
  32866. var bailRE = /[^\w.$]/;
  32867. function parsePath (path) {
  32868. if (bailRE.test(path)) {
  32869. return
  32870. }
  32871. var segments = path.split('.');
  32872. return function (obj) {
  32873. for (var i = 0; i < segments.length; i++) {
  32874. if (!obj) { return }
  32875. obj = obj[segments[i]];
  32876. }
  32877. return obj
  32878. }
  32879. }
  32880. /* */
  32881. var warn = noop;
  32882. var tip = noop;
  32883. var formatComponentName = (null); // work around flow check
  32884. if (true) {
  32885. var hasConsole = typeof console !== 'undefined';
  32886. var classifyRE = /(?:^|[-_])(\w)/g;
  32887. var classify = function (str) { return str
  32888. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  32889. .replace(/[-_]/g, ''); };
  32890. warn = function (msg, vm) {
  32891. if (hasConsole && (!config.silent)) {
  32892. console.error("[Vue warn]: " + msg + (
  32893. vm ? generateComponentTrace(vm) : ''
  32894. ));
  32895. }
  32896. };
  32897. tip = function (msg, vm) {
  32898. if (hasConsole && (!config.silent)) {
  32899. console.warn("[Vue tip]: " + msg + (
  32900. vm ? generateComponentTrace(vm) : ''
  32901. ));
  32902. }
  32903. };
  32904. formatComponentName = function (vm, includeFile) {
  32905. if (vm.$root === vm) {
  32906. return '<Root>'
  32907. }
  32908. var name = typeof vm === 'string'
  32909. ? vm
  32910. : typeof vm === 'function' && vm.options
  32911. ? vm.options.name
  32912. : vm._isVue
  32913. ? vm.$options.name || vm.$options._componentTag
  32914. : vm.name;
  32915. var file = vm._isVue && vm.$options.__file;
  32916. if (!name && file) {
  32917. var match = file.match(/([^/\\]+)\.vue$/);
  32918. name = match && match[1];
  32919. }
  32920. return (
  32921. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  32922. (file && includeFile !== false ? (" at " + file) : '')
  32923. )
  32924. };
  32925. var repeat = function (str, n) {
  32926. var res = '';
  32927. while (n) {
  32928. if (n % 2 === 1) { res += str; }
  32929. if (n > 1) { str += str; }
  32930. n >>= 1;
  32931. }
  32932. return res
  32933. };
  32934. var generateComponentTrace = function (vm) {
  32935. if (vm._isVue && vm.$parent) {
  32936. var tree = [];
  32937. var currentRecursiveSequence = 0;
  32938. while (vm) {
  32939. if (tree.length > 0) {
  32940. var last = tree[tree.length - 1];
  32941. if (last.constructor === vm.constructor) {
  32942. currentRecursiveSequence++;
  32943. vm = vm.$parent;
  32944. continue
  32945. } else if (currentRecursiveSequence > 0) {
  32946. tree[tree.length - 1] = [last, currentRecursiveSequence];
  32947. currentRecursiveSequence = 0;
  32948. }
  32949. }
  32950. tree.push(vm);
  32951. vm = vm.$parent;
  32952. }
  32953. return '\n\nfound in\n\n' + tree
  32954. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  32955. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  32956. : formatComponentName(vm))); })
  32957. .join('\n')
  32958. } else {
  32959. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  32960. }
  32961. };
  32962. }
  32963. /* */
  32964. function handleError (err, vm, info) {
  32965. if (config.errorHandler) {
  32966. config.errorHandler.call(null, err, vm, info);
  32967. } else {
  32968. if (true) {
  32969. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  32970. }
  32971. /* istanbul ignore else */
  32972. if (inBrowser && typeof console !== 'undefined') {
  32973. console.error(err);
  32974. } else {
  32975. throw err
  32976. }
  32977. }
  32978. }
  32979. /* */
  32980. /* globals MutationObserver */
  32981. // can we use __proto__?
  32982. var hasProto = '__proto__' in {};
  32983. // Browser environment sniffing
  32984. var inBrowser = typeof window !== 'undefined';
  32985. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  32986. var isIE = UA && /msie|trident/.test(UA);
  32987. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  32988. var isEdge = UA && UA.indexOf('edge/') > 0;
  32989. var isAndroid = UA && UA.indexOf('android') > 0;
  32990. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  32991. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  32992. var supportsPassive = false;
  32993. if (inBrowser) {
  32994. try {
  32995. var opts = {};
  32996. Object.defineProperty(opts, 'passive', ({
  32997. get: function get () {
  32998. /* istanbul ignore next */
  32999. supportsPassive = true;
  33000. }
  33001. } )); // https://github.com/facebook/flow/issues/285
  33002. window.addEventListener('test-passive', null, opts);
  33003. } catch (e) {}
  33004. }
  33005. // this needs to be lazy-evaled because vue may be required before
  33006. // vue-server-renderer can set VUE_ENV
  33007. var _isServer;
  33008. var isServerRendering = function () {
  33009. if (_isServer === undefined) {
  33010. /* istanbul ignore if */
  33011. if (!inBrowser && typeof global !== 'undefined') {
  33012. // detect presence of vue-server-renderer and avoid
  33013. // Webpack shimming the process
  33014. _isServer = global['process'].env.VUE_ENV === 'server';
  33015. } else {
  33016. _isServer = false;
  33017. }
  33018. }
  33019. return _isServer
  33020. };
  33021. // detect devtools
  33022. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  33023. /* istanbul ignore next */
  33024. function isNative (Ctor) {
  33025. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  33026. }
  33027. var hasSymbol =
  33028. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  33029. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  33030. /**
  33031. * Defer a task to execute it asynchronously.
  33032. */
  33033. var nextTick = (function () {
  33034. var callbacks = [];
  33035. var pending = false;
  33036. var timerFunc;
  33037. function nextTickHandler () {
  33038. pending = false;
  33039. var copies = callbacks.slice(0);
  33040. callbacks.length = 0;
  33041. for (var i = 0; i < copies.length; i++) {
  33042. copies[i]();
  33043. }
  33044. }
  33045. // the nextTick behavior leverages the microtask queue, which can be accessed
  33046. // via either native Promise.then or MutationObserver.
  33047. // MutationObserver has wider support, however it is seriously bugged in
  33048. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  33049. // completely stops working after triggering a few times... so, if native
  33050. // Promise is available, we will use it:
  33051. /* istanbul ignore if */
  33052. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  33053. var p = Promise.resolve();
  33054. var logError = function (err) { console.error(err); };
  33055. timerFunc = function () {
  33056. p.then(nextTickHandler).catch(logError);
  33057. // in problematic UIWebViews, Promise.then doesn't completely break, but
  33058. // it can get stuck in a weird state where callbacks are pushed into the
  33059. // microtask queue but the queue isn't being flushed, until the browser
  33060. // needs to do some other work, e.g. handle a timer. Therefore we can
  33061. // "force" the microtask queue to be flushed by adding an empty timer.
  33062. if (isIOS) { setTimeout(noop); }
  33063. };
  33064. } else if (typeof MutationObserver !== 'undefined' && (
  33065. isNative(MutationObserver) ||
  33066. // PhantomJS and iOS 7.x
  33067. MutationObserver.toString() === '[object MutationObserverConstructor]'
  33068. )) {
  33069. // use MutationObserver where native Promise is not available,
  33070. // e.g. PhantomJS IE11, iOS7, Android 4.4
  33071. var counter = 1;
  33072. var observer = new MutationObserver(nextTickHandler);
  33073. var textNode = document.createTextNode(String(counter));
  33074. observer.observe(textNode, {
  33075. characterData: true
  33076. });
  33077. timerFunc = function () {
  33078. counter = (counter + 1) % 2;
  33079. textNode.data = String(counter);
  33080. };
  33081. } else {
  33082. // fallback to setTimeout
  33083. /* istanbul ignore next */
  33084. timerFunc = function () {
  33085. setTimeout(nextTickHandler, 0);
  33086. };
  33087. }
  33088. return function queueNextTick (cb, ctx) {
  33089. var _resolve;
  33090. callbacks.push(function () {
  33091. if (cb) {
  33092. try {
  33093. cb.call(ctx);
  33094. } catch (e) {
  33095. handleError(e, ctx, 'nextTick');
  33096. }
  33097. } else if (_resolve) {
  33098. _resolve(ctx);
  33099. }
  33100. });
  33101. if (!pending) {
  33102. pending = true;
  33103. timerFunc();
  33104. }
  33105. if (!cb && typeof Promise !== 'undefined') {
  33106. return new Promise(function (resolve, reject) {
  33107. _resolve = resolve;
  33108. })
  33109. }
  33110. }
  33111. })();
  33112. var _Set;
  33113. /* istanbul ignore if */
  33114. if (typeof Set !== 'undefined' && isNative(Set)) {
  33115. // use native Set when available.
  33116. _Set = Set;
  33117. } else {
  33118. // a non-standard Set polyfill that only works with primitive keys.
  33119. _Set = (function () {
  33120. function Set () {
  33121. this.set = Object.create(null);
  33122. }
  33123. Set.prototype.has = function has (key) {
  33124. return this.set[key] === true
  33125. };
  33126. Set.prototype.add = function add (key) {
  33127. this.set[key] = true;
  33128. };
  33129. Set.prototype.clear = function clear () {
  33130. this.set = Object.create(null);
  33131. };
  33132. return Set;
  33133. }());
  33134. }
  33135. /* */
  33136. var uid = 0;
  33137. /**
  33138. * A dep is an observable that can have multiple
  33139. * directives subscribing to it.
  33140. */
  33141. var Dep = function Dep () {
  33142. this.id = uid++;
  33143. this.subs = [];
  33144. };
  33145. Dep.prototype.addSub = function addSub (sub) {
  33146. this.subs.push(sub);
  33147. };
  33148. Dep.prototype.removeSub = function removeSub (sub) {
  33149. remove(this.subs, sub);
  33150. };
  33151. Dep.prototype.depend = function depend () {
  33152. if (Dep.target) {
  33153. Dep.target.addDep(this);
  33154. }
  33155. };
  33156. Dep.prototype.notify = function notify () {
  33157. // stabilize the subscriber list first
  33158. var subs = this.subs.slice();
  33159. for (var i = 0, l = subs.length; i < l; i++) {
  33160. subs[i].update();
  33161. }
  33162. };
  33163. // the current target watcher being evaluated.
  33164. // this is globally unique because there could be only one
  33165. // watcher being evaluated at any time.
  33166. Dep.target = null;
  33167. var targetStack = [];
  33168. function pushTarget (_target) {
  33169. if (Dep.target) { targetStack.push(Dep.target); }
  33170. Dep.target = _target;
  33171. }
  33172. function popTarget () {
  33173. Dep.target = targetStack.pop();
  33174. }
  33175. /*
  33176. * not type checking this file because flow doesn't play well with
  33177. * dynamically accessing methods on Array prototype
  33178. */
  33179. var arrayProto = Array.prototype;
  33180. var arrayMethods = Object.create(arrayProto);[
  33181. 'push',
  33182. 'pop',
  33183. 'shift',
  33184. 'unshift',
  33185. 'splice',
  33186. 'sort',
  33187. 'reverse'
  33188. ]
  33189. .forEach(function (method) {
  33190. // cache original method
  33191. var original = arrayProto[method];
  33192. def(arrayMethods, method, function mutator () {
  33193. var arguments$1 = arguments;
  33194. // avoid leaking arguments:
  33195. // http://jsperf.com/closure-with-arguments
  33196. var i = arguments.length;
  33197. var args = new Array(i);
  33198. while (i--) {
  33199. args[i] = arguments$1[i];
  33200. }
  33201. var result = original.apply(this, args);
  33202. var ob = this.__ob__;
  33203. var inserted;
  33204. switch (method) {
  33205. case 'push':
  33206. inserted = args;
  33207. break
  33208. case 'unshift':
  33209. inserted = args;
  33210. break
  33211. case 'splice':
  33212. inserted = args.slice(2);
  33213. break
  33214. }
  33215. if (inserted) { ob.observeArray(inserted); }
  33216. // notify change
  33217. ob.dep.notify();
  33218. return result
  33219. });
  33220. });
  33221. /* */
  33222. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  33223. /**
  33224. * By default, when a reactive property is set, the new value is
  33225. * also converted to become reactive. However when passing down props,
  33226. * we don't want to force conversion because the value may be a nested value
  33227. * under a frozen data structure. Converting it would defeat the optimization.
  33228. */
  33229. var observerState = {
  33230. shouldConvert: true,
  33231. isSettingProps: false
  33232. };
  33233. /**
  33234. * Observer class that are attached to each observed
  33235. * object. Once attached, the observer converts target
  33236. * object's property keys into getter/setters that
  33237. * collect dependencies and dispatches updates.
  33238. */
  33239. var Observer = function Observer (value) {
  33240. this.value = value;
  33241. this.dep = new Dep();
  33242. this.vmCount = 0;
  33243. def(value, '__ob__', this);
  33244. if (Array.isArray(value)) {
  33245. var augment = hasProto
  33246. ? protoAugment
  33247. : copyAugment;
  33248. augment(value, arrayMethods, arrayKeys);
  33249. this.observeArray(value);
  33250. } else {
  33251. this.walk(value);
  33252. }
  33253. };
  33254. /**
  33255. * Walk through each property and convert them into
  33256. * getter/setters. This method should only be called when
  33257. * value type is Object.
  33258. */
  33259. Observer.prototype.walk = function walk (obj) {
  33260. var keys = Object.keys(obj);
  33261. for (var i = 0; i < keys.length; i++) {
  33262. defineReactive$$1(obj, keys[i], obj[keys[i]]);
  33263. }
  33264. };
  33265. /**
  33266. * Observe a list of Array items.
  33267. */
  33268. Observer.prototype.observeArray = function observeArray (items) {
  33269. for (var i = 0, l = items.length; i < l; i++) {
  33270. observe(items[i]);
  33271. }
  33272. };
  33273. // helpers
  33274. /**
  33275. * Augment an target Object or Array by intercepting
  33276. * the prototype chain using __proto__
  33277. */
  33278. function protoAugment (target, src) {
  33279. /* eslint-disable no-proto */
  33280. target.__proto__ = src;
  33281. /* eslint-enable no-proto */
  33282. }
  33283. /**
  33284. * Augment an target Object or Array by defining
  33285. * hidden properties.
  33286. */
  33287. /* istanbul ignore next */
  33288. function copyAugment (target, src, keys) {
  33289. for (var i = 0, l = keys.length; i < l; i++) {
  33290. var key = keys[i];
  33291. def(target, key, src[key]);
  33292. }
  33293. }
  33294. /**
  33295. * Attempt to create an observer instance for a value,
  33296. * returns the new observer if successfully observed,
  33297. * or the existing observer if the value already has one.
  33298. */
  33299. function observe (value, asRootData) {
  33300. if (!isObject(value)) {
  33301. return
  33302. }
  33303. var ob;
  33304. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  33305. ob = value.__ob__;
  33306. } else if (
  33307. observerState.shouldConvert &&
  33308. !isServerRendering() &&
  33309. (Array.isArray(value) || isPlainObject(value)) &&
  33310. Object.isExtensible(value) &&
  33311. !value._isVue
  33312. ) {
  33313. ob = new Observer(value);
  33314. }
  33315. if (asRootData && ob) {
  33316. ob.vmCount++;
  33317. }
  33318. return ob
  33319. }
  33320. /**
  33321. * Define a reactive property on an Object.
  33322. */
  33323. function defineReactive$$1 (
  33324. obj,
  33325. key,
  33326. val,
  33327. customSetter
  33328. ) {
  33329. var dep = new Dep();
  33330. var property = Object.getOwnPropertyDescriptor(obj, key);
  33331. if (property && property.configurable === false) {
  33332. return
  33333. }
  33334. // cater for pre-defined getter/setters
  33335. var getter = property && property.get;
  33336. var setter = property && property.set;
  33337. var childOb = observe(val);
  33338. Object.defineProperty(obj, key, {
  33339. enumerable: true,
  33340. configurable: true,
  33341. get: function reactiveGetter () {
  33342. var value = getter ? getter.call(obj) : val;
  33343. if (Dep.target) {
  33344. dep.depend();
  33345. if (childOb) {
  33346. childOb.dep.depend();
  33347. }
  33348. if (Array.isArray(value)) {
  33349. dependArray(value);
  33350. }
  33351. }
  33352. return value
  33353. },
  33354. set: function reactiveSetter (newVal) {
  33355. var value = getter ? getter.call(obj) : val;
  33356. /* eslint-disable no-self-compare */
  33357. if (newVal === value || (newVal !== newVal && value !== value)) {
  33358. return
  33359. }
  33360. /* eslint-enable no-self-compare */
  33361. if ("development" !== 'production' && customSetter) {
  33362. customSetter();
  33363. }
  33364. if (setter) {
  33365. setter.call(obj, newVal);
  33366. } else {
  33367. val = newVal;
  33368. }
  33369. childOb = observe(newVal);
  33370. dep.notify();
  33371. }
  33372. });
  33373. }
  33374. /**
  33375. * Set a property on an object. Adds the new property and
  33376. * triggers change notification if the property doesn't
  33377. * already exist.
  33378. */
  33379. function set (target, key, val) {
  33380. if (Array.isArray(target) && typeof key === 'number') {
  33381. target.length = Math.max(target.length, key);
  33382. target.splice(key, 1, val);
  33383. return val
  33384. }
  33385. if (hasOwn(target, key)) {
  33386. target[key] = val;
  33387. return val
  33388. }
  33389. var ob = (target ).__ob__;
  33390. if (target._isVue || (ob && ob.vmCount)) {
  33391. "development" !== 'production' && warn(
  33392. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  33393. 'at runtime - declare it upfront in the data option.'
  33394. );
  33395. return val
  33396. }
  33397. if (!ob) {
  33398. target[key] = val;
  33399. return val
  33400. }
  33401. defineReactive$$1(ob.value, key, val);
  33402. ob.dep.notify();
  33403. return val
  33404. }
  33405. /**
  33406. * Delete a property and trigger change if necessary.
  33407. */
  33408. function del (target, key) {
  33409. if (Array.isArray(target) && typeof key === 'number') {
  33410. target.splice(key, 1);
  33411. return
  33412. }
  33413. var ob = (target ).__ob__;
  33414. if (target._isVue || (ob && ob.vmCount)) {
  33415. "development" !== 'production' && warn(
  33416. 'Avoid deleting properties on a Vue instance or its root $data ' +
  33417. '- just set it to null.'
  33418. );
  33419. return
  33420. }
  33421. if (!hasOwn(target, key)) {
  33422. return
  33423. }
  33424. delete target[key];
  33425. if (!ob) {
  33426. return
  33427. }
  33428. ob.dep.notify();
  33429. }
  33430. /**
  33431. * Collect dependencies on array elements when the array is touched, since
  33432. * we cannot intercept array element access like property getters.
  33433. */
  33434. function dependArray (value) {
  33435. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  33436. e = value[i];
  33437. e && e.__ob__ && e.__ob__.dep.depend();
  33438. if (Array.isArray(e)) {
  33439. dependArray(e);
  33440. }
  33441. }
  33442. }
  33443. /* */
  33444. /**
  33445. * Option overwriting strategies are functions that handle
  33446. * how to merge a parent option value and a child option
  33447. * value into the final value.
  33448. */
  33449. var strats = config.optionMergeStrategies;
  33450. /**
  33451. * Options with restrictions
  33452. */
  33453. if (true) {
  33454. strats.el = strats.propsData = function (parent, child, vm, key) {
  33455. if (!vm) {
  33456. warn(
  33457. "option \"" + key + "\" can only be used during instance " +
  33458. 'creation with the `new` keyword.'
  33459. );
  33460. }
  33461. return defaultStrat(parent, child)
  33462. };
  33463. }
  33464. /**
  33465. * Helper that recursively merges two data objects together.
  33466. */
  33467. function mergeData (to, from) {
  33468. if (!from) { return to }
  33469. var key, toVal, fromVal;
  33470. var keys = Object.keys(from);
  33471. for (var i = 0; i < keys.length; i++) {
  33472. key = keys[i];
  33473. toVal = to[key];
  33474. fromVal = from[key];
  33475. if (!hasOwn(to, key)) {
  33476. set(to, key, fromVal);
  33477. } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
  33478. mergeData(toVal, fromVal);
  33479. }
  33480. }
  33481. return to
  33482. }
  33483. /**
  33484. * Data
  33485. */
  33486. strats.data = function (
  33487. parentVal,
  33488. childVal,
  33489. vm
  33490. ) {
  33491. if (!vm) {
  33492. // in a Vue.extend merge, both should be functions
  33493. if (!childVal) {
  33494. return parentVal
  33495. }
  33496. if (typeof childVal !== 'function') {
  33497. "development" !== 'production' && warn(
  33498. 'The "data" option should be a function ' +
  33499. 'that returns a per-instance value in component ' +
  33500. 'definitions.',
  33501. vm
  33502. );
  33503. return parentVal
  33504. }
  33505. if (!parentVal) {
  33506. return childVal
  33507. }
  33508. // when parentVal & childVal are both present,
  33509. // we need to return a function that returns the
  33510. // merged result of both functions... no need to
  33511. // check if parentVal is a function here because
  33512. // it has to be a function to pass previous merges.
  33513. return function mergedDataFn () {
  33514. return mergeData(
  33515. childVal.call(this),
  33516. parentVal.call(this)
  33517. )
  33518. }
  33519. } else if (parentVal || childVal) {
  33520. return function mergedInstanceDataFn () {
  33521. // instance merge
  33522. var instanceData = typeof childVal === 'function'
  33523. ? childVal.call(vm)
  33524. : childVal;
  33525. var defaultData = typeof parentVal === 'function'
  33526. ? parentVal.call(vm)
  33527. : undefined;
  33528. if (instanceData) {
  33529. return mergeData(instanceData, defaultData)
  33530. } else {
  33531. return defaultData
  33532. }
  33533. }
  33534. }
  33535. };
  33536. /**
  33537. * Hooks and props are merged as arrays.
  33538. */
  33539. function mergeHook (
  33540. parentVal,
  33541. childVal
  33542. ) {
  33543. return childVal
  33544. ? parentVal
  33545. ? parentVal.concat(childVal)
  33546. : Array.isArray(childVal)
  33547. ? childVal
  33548. : [childVal]
  33549. : parentVal
  33550. }
  33551. LIFECYCLE_HOOKS.forEach(function (hook) {
  33552. strats[hook] = mergeHook;
  33553. });
  33554. /**
  33555. * Assets
  33556. *
  33557. * When a vm is present (instance creation), we need to do
  33558. * a three-way merge between constructor options, instance
  33559. * options and parent options.
  33560. */
  33561. function mergeAssets (parentVal, childVal) {
  33562. var res = Object.create(parentVal || null);
  33563. return childVal
  33564. ? extend(res, childVal)
  33565. : res
  33566. }
  33567. ASSET_TYPES.forEach(function (type) {
  33568. strats[type + 's'] = mergeAssets;
  33569. });
  33570. /**
  33571. * Watchers.
  33572. *
  33573. * Watchers hashes should not overwrite one
  33574. * another, so we merge them as arrays.
  33575. */
  33576. strats.watch = function (parentVal, childVal) {
  33577. /* istanbul ignore if */
  33578. if (!childVal) { return Object.create(parentVal || null) }
  33579. if (!parentVal) { return childVal }
  33580. var ret = {};
  33581. extend(ret, parentVal);
  33582. for (var key in childVal) {
  33583. var parent = ret[key];
  33584. var child = childVal[key];
  33585. if (parent && !Array.isArray(parent)) {
  33586. parent = [parent];
  33587. }
  33588. ret[key] = parent
  33589. ? parent.concat(child)
  33590. : [child];
  33591. }
  33592. return ret
  33593. };
  33594. /**
  33595. * Other object hashes.
  33596. */
  33597. strats.props =
  33598. strats.methods =
  33599. strats.computed = function (parentVal, childVal) {
  33600. if (!childVal) { return Object.create(parentVal || null) }
  33601. if (!parentVal) { return childVal }
  33602. var ret = Object.create(null);
  33603. extend(ret, parentVal);
  33604. extend(ret, childVal);
  33605. return ret
  33606. };
  33607. /**
  33608. * Default strategy.
  33609. */
  33610. var defaultStrat = function (parentVal, childVal) {
  33611. return childVal === undefined
  33612. ? parentVal
  33613. : childVal
  33614. };
  33615. /**
  33616. * Validate component names
  33617. */
  33618. function checkComponents (options) {
  33619. for (var key in options.components) {
  33620. var lower = key.toLowerCase();
  33621. if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
  33622. warn(
  33623. 'Do not use built-in or reserved HTML elements as component ' +
  33624. 'id: ' + key
  33625. );
  33626. }
  33627. }
  33628. }
  33629. /**
  33630. * Ensure all props option syntax are normalized into the
  33631. * Object-based format.
  33632. */
  33633. function normalizeProps (options) {
  33634. var props = options.props;
  33635. if (!props) { return }
  33636. var res = {};
  33637. var i, val, name;
  33638. if (Array.isArray(props)) {
  33639. i = props.length;
  33640. while (i--) {
  33641. val = props[i];
  33642. if (typeof val === 'string') {
  33643. name = camelize(val);
  33644. res[name] = { type: null };
  33645. } else if (true) {
  33646. warn('props must be strings when using array syntax.');
  33647. }
  33648. }
  33649. } else if (isPlainObject(props)) {
  33650. for (var key in props) {
  33651. val = props[key];
  33652. name = camelize(key);
  33653. res[name] = isPlainObject(val)
  33654. ? val
  33655. : { type: val };
  33656. }
  33657. }
  33658. options.props = res;
  33659. }
  33660. /**
  33661. * Normalize raw function directives into object format.
  33662. */
  33663. function normalizeDirectives (options) {
  33664. var dirs = options.directives;
  33665. if (dirs) {
  33666. for (var key in dirs) {
  33667. var def = dirs[key];
  33668. if (typeof def === 'function') {
  33669. dirs[key] = { bind: def, update: def };
  33670. }
  33671. }
  33672. }
  33673. }
  33674. /**
  33675. * Merge two option objects into a new one.
  33676. * Core utility used in both instantiation and inheritance.
  33677. */
  33678. function mergeOptions (
  33679. parent,
  33680. child,
  33681. vm
  33682. ) {
  33683. if (true) {
  33684. checkComponents(child);
  33685. }
  33686. if (typeof child === 'function') {
  33687. child = child.options;
  33688. }
  33689. normalizeProps(child);
  33690. normalizeDirectives(child);
  33691. var extendsFrom = child.extends;
  33692. if (extendsFrom) {
  33693. parent = mergeOptions(parent, extendsFrom, vm);
  33694. }
  33695. if (child.mixins) {
  33696. for (var i = 0, l = child.mixins.length; i < l; i++) {
  33697. parent = mergeOptions(parent, child.mixins[i], vm);
  33698. }
  33699. }
  33700. var options = {};
  33701. var key;
  33702. for (key in parent) {
  33703. mergeField(key);
  33704. }
  33705. for (key in child) {
  33706. if (!hasOwn(parent, key)) {
  33707. mergeField(key);
  33708. }
  33709. }
  33710. function mergeField (key) {
  33711. var strat = strats[key] || defaultStrat;
  33712. options[key] = strat(parent[key], child[key], vm, key);
  33713. }
  33714. return options
  33715. }
  33716. /**
  33717. * Resolve an asset.
  33718. * This function is used because child instances need access
  33719. * to assets defined in its ancestor chain.
  33720. */
  33721. function resolveAsset (
  33722. options,
  33723. type,
  33724. id,
  33725. warnMissing
  33726. ) {
  33727. /* istanbul ignore if */
  33728. if (typeof id !== 'string') {
  33729. return
  33730. }
  33731. var assets = options[type];
  33732. // check local registration variations first
  33733. if (hasOwn(assets, id)) { return assets[id] }
  33734. var camelizedId = camelize(id);
  33735. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  33736. var PascalCaseId = capitalize(camelizedId);
  33737. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  33738. // fallback to prototype chain
  33739. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  33740. if ("development" !== 'production' && warnMissing && !res) {
  33741. warn(
  33742. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  33743. options
  33744. );
  33745. }
  33746. return res
  33747. }
  33748. /* */
  33749. function validateProp (
  33750. key,
  33751. propOptions,
  33752. propsData,
  33753. vm
  33754. ) {
  33755. var prop = propOptions[key];
  33756. var absent = !hasOwn(propsData, key);
  33757. var value = propsData[key];
  33758. // handle boolean props
  33759. if (isType(Boolean, prop.type)) {
  33760. if (absent && !hasOwn(prop, 'default')) {
  33761. value = false;
  33762. } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
  33763. value = true;
  33764. }
  33765. }
  33766. // check default value
  33767. if (value === undefined) {
  33768. value = getPropDefaultValue(vm, prop, key);
  33769. // since the default value is a fresh copy,
  33770. // make sure to observe it.
  33771. var prevShouldConvert = observerState.shouldConvert;
  33772. observerState.shouldConvert = true;
  33773. observe(value);
  33774. observerState.shouldConvert = prevShouldConvert;
  33775. }
  33776. if (true) {
  33777. assertProp(prop, key, value, vm, absent);
  33778. }
  33779. return value
  33780. }
  33781. /**
  33782. * Get the default value of a prop.
  33783. */
  33784. function getPropDefaultValue (vm, prop, key) {
  33785. // no default, return undefined
  33786. if (!hasOwn(prop, 'default')) {
  33787. return undefined
  33788. }
  33789. var def = prop.default;
  33790. // warn against non-factory defaults for Object & Array
  33791. if ("development" !== 'production' && isObject(def)) {
  33792. warn(
  33793. 'Invalid default value for prop "' + key + '": ' +
  33794. 'Props with type Object/Array must use a factory function ' +
  33795. 'to return the default value.',
  33796. vm
  33797. );
  33798. }
  33799. // the raw prop value was also undefined from previous render,
  33800. // return previous default value to avoid unnecessary watcher trigger
  33801. if (vm && vm.$options.propsData &&
  33802. vm.$options.propsData[key] === undefined &&
  33803. vm._props[key] !== undefined
  33804. ) {
  33805. return vm._props[key]
  33806. }
  33807. // call factory function for non-Function types
  33808. // a value is Function if its prototype is function even across different execution context
  33809. return typeof def === 'function' && getType(prop.type) !== 'Function'
  33810. ? def.call(vm)
  33811. : def
  33812. }
  33813. /**
  33814. * Assert whether a prop is valid.
  33815. */
  33816. function assertProp (
  33817. prop,
  33818. name,
  33819. value,
  33820. vm,
  33821. absent
  33822. ) {
  33823. if (prop.required && absent) {
  33824. warn(
  33825. 'Missing required prop: "' + name + '"',
  33826. vm
  33827. );
  33828. return
  33829. }
  33830. if (value == null && !prop.required) {
  33831. return
  33832. }
  33833. var type = prop.type;
  33834. var valid = !type || type === true;
  33835. var expectedTypes = [];
  33836. if (type) {
  33837. if (!Array.isArray(type)) {
  33838. type = [type];
  33839. }
  33840. for (var i = 0; i < type.length && !valid; i++) {
  33841. var assertedType = assertType(value, type[i]);
  33842. expectedTypes.push(assertedType.expectedType || '');
  33843. valid = assertedType.valid;
  33844. }
  33845. }
  33846. if (!valid) {
  33847. warn(
  33848. 'Invalid prop: type check failed for prop "' + name + '".' +
  33849. ' Expected ' + expectedTypes.map(capitalize).join(', ') +
  33850. ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
  33851. vm
  33852. );
  33853. return
  33854. }
  33855. var validator = prop.validator;
  33856. if (validator) {
  33857. if (!validator(value)) {
  33858. warn(
  33859. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  33860. vm
  33861. );
  33862. }
  33863. }
  33864. }
  33865. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  33866. function assertType (value, type) {
  33867. var valid;
  33868. var expectedType = getType(type);
  33869. if (simpleCheckRE.test(expectedType)) {
  33870. valid = typeof value === expectedType.toLowerCase();
  33871. } else if (expectedType === 'Object') {
  33872. valid = isPlainObject(value);
  33873. } else if (expectedType === 'Array') {
  33874. valid = Array.isArray(value);
  33875. } else {
  33876. valid = value instanceof type;
  33877. }
  33878. return {
  33879. valid: valid,
  33880. expectedType: expectedType
  33881. }
  33882. }
  33883. /**
  33884. * Use function string name to check built-in types,
  33885. * because a simple equality check will fail when running
  33886. * across different vms / iframes.
  33887. */
  33888. function getType (fn) {
  33889. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  33890. return match ? match[1] : ''
  33891. }
  33892. function isType (type, fn) {
  33893. if (!Array.isArray(fn)) {
  33894. return getType(fn) === getType(type)
  33895. }
  33896. for (var i = 0, len = fn.length; i < len; i++) {
  33897. if (getType(fn[i]) === getType(type)) {
  33898. return true
  33899. }
  33900. }
  33901. /* istanbul ignore next */
  33902. return false
  33903. }
  33904. /* */
  33905. var mark;
  33906. var measure;
  33907. if (true) {
  33908. var perf = inBrowser && window.performance;
  33909. /* istanbul ignore if */
  33910. if (
  33911. perf &&
  33912. perf.mark &&
  33913. perf.measure &&
  33914. perf.clearMarks &&
  33915. perf.clearMeasures
  33916. ) {
  33917. mark = function (tag) { return perf.mark(tag); };
  33918. measure = function (name, startTag, endTag) {
  33919. perf.measure(name, startTag, endTag);
  33920. perf.clearMarks(startTag);
  33921. perf.clearMarks(endTag);
  33922. perf.clearMeasures(name);
  33923. };
  33924. }
  33925. }
  33926. /* not type checking this file because flow doesn't play well with Proxy */
  33927. var initProxy;
  33928. if (true) {
  33929. var allowedGlobals = makeMap(
  33930. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  33931. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  33932. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  33933. 'require' // for Webpack/Browserify
  33934. );
  33935. var warnNonPresent = function (target, key) {
  33936. warn(
  33937. "Property or method \"" + key + "\" is not defined on the instance but " +
  33938. "referenced during render. Make sure to declare reactive data " +
  33939. "properties in the data option.",
  33940. target
  33941. );
  33942. };
  33943. var hasProxy =
  33944. typeof Proxy !== 'undefined' &&
  33945. Proxy.toString().match(/native code/);
  33946. if (hasProxy) {
  33947. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta');
  33948. config.keyCodes = new Proxy(config.keyCodes, {
  33949. set: function set (target, key, value) {
  33950. if (isBuiltInModifier(key)) {
  33951. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  33952. return false
  33953. } else {
  33954. target[key] = value;
  33955. return true
  33956. }
  33957. }
  33958. });
  33959. }
  33960. var hasHandler = {
  33961. has: function has (target, key) {
  33962. var has = key in target;
  33963. var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
  33964. if (!has && !isAllowed) {
  33965. warnNonPresent(target, key);
  33966. }
  33967. return has || !isAllowed
  33968. }
  33969. };
  33970. var getHandler = {
  33971. get: function get (target, key) {
  33972. if (typeof key === 'string' && !(key in target)) {
  33973. warnNonPresent(target, key);
  33974. }
  33975. return target[key]
  33976. }
  33977. };
  33978. initProxy = function initProxy (vm) {
  33979. if (hasProxy) {
  33980. // determine which proxy handler to use
  33981. var options = vm.$options;
  33982. var handlers = options.render && options.render._withStripped
  33983. ? getHandler
  33984. : hasHandler;
  33985. vm._renderProxy = new Proxy(vm, handlers);
  33986. } else {
  33987. vm._renderProxy = vm;
  33988. }
  33989. };
  33990. }
  33991. /* */
  33992. var VNode = function VNode (
  33993. tag,
  33994. data,
  33995. children,
  33996. text,
  33997. elm,
  33998. context,
  33999. componentOptions
  34000. ) {
  34001. this.tag = tag;
  34002. this.data = data;
  34003. this.children = children;
  34004. this.text = text;
  34005. this.elm = elm;
  34006. this.ns = undefined;
  34007. this.context = context;
  34008. this.functionalContext = undefined;
  34009. this.key = data && data.key;
  34010. this.componentOptions = componentOptions;
  34011. this.componentInstance = undefined;
  34012. this.parent = undefined;
  34013. this.raw = false;
  34014. this.isStatic = false;
  34015. this.isRootInsert = true;
  34016. this.isComment = false;
  34017. this.isCloned = false;
  34018. this.isOnce = false;
  34019. };
  34020. var prototypeAccessors = { child: {} };
  34021. // DEPRECATED: alias for componentInstance for backwards compat.
  34022. /* istanbul ignore next */
  34023. prototypeAccessors.child.get = function () {
  34024. return this.componentInstance
  34025. };
  34026. Object.defineProperties( VNode.prototype, prototypeAccessors );
  34027. var createEmptyVNode = function () {
  34028. var node = new VNode();
  34029. node.text = '';
  34030. node.isComment = true;
  34031. return node
  34032. };
  34033. function createTextVNode (val) {
  34034. return new VNode(undefined, undefined, undefined, String(val))
  34035. }
  34036. // optimized shallow clone
  34037. // used for static nodes and slot nodes because they may be reused across
  34038. // multiple renders, cloning them avoids errors when DOM manipulations rely
  34039. // on their elm reference.
  34040. function cloneVNode (vnode) {
  34041. var cloned = new VNode(
  34042. vnode.tag,
  34043. vnode.data,
  34044. vnode.children,
  34045. vnode.text,
  34046. vnode.elm,
  34047. vnode.context,
  34048. vnode.componentOptions
  34049. );
  34050. cloned.ns = vnode.ns;
  34051. cloned.isStatic = vnode.isStatic;
  34052. cloned.key = vnode.key;
  34053. cloned.isComment = vnode.isComment;
  34054. cloned.isCloned = true;
  34055. return cloned
  34056. }
  34057. function cloneVNodes (vnodes) {
  34058. var len = vnodes.length;
  34059. var res = new Array(len);
  34060. for (var i = 0; i < len; i++) {
  34061. res[i] = cloneVNode(vnodes[i]);
  34062. }
  34063. return res
  34064. }
  34065. /* */
  34066. var normalizeEvent = cached(function (name) {
  34067. var passive = name.charAt(0) === '&';
  34068. name = passive ? name.slice(1) : name;
  34069. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  34070. name = once$$1 ? name.slice(1) : name;
  34071. var capture = name.charAt(0) === '!';
  34072. name = capture ? name.slice(1) : name;
  34073. return {
  34074. name: name,
  34075. once: once$$1,
  34076. capture: capture,
  34077. passive: passive
  34078. }
  34079. });
  34080. function createFnInvoker (fns) {
  34081. function invoker () {
  34082. var arguments$1 = arguments;
  34083. var fns = invoker.fns;
  34084. if (Array.isArray(fns)) {
  34085. for (var i = 0; i < fns.length; i++) {
  34086. fns[i].apply(null, arguments$1);
  34087. }
  34088. } else {
  34089. // return handler return value for single handlers
  34090. return fns.apply(null, arguments)
  34091. }
  34092. }
  34093. invoker.fns = fns;
  34094. return invoker
  34095. }
  34096. function updateListeners (
  34097. on,
  34098. oldOn,
  34099. add,
  34100. remove$$1,
  34101. vm
  34102. ) {
  34103. var name, cur, old, event;
  34104. for (name in on) {
  34105. cur = on[name];
  34106. old = oldOn[name];
  34107. event = normalizeEvent(name);
  34108. if (isUndef(cur)) {
  34109. "development" !== 'production' && warn(
  34110. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  34111. vm
  34112. );
  34113. } else if (isUndef(old)) {
  34114. if (isUndef(cur.fns)) {
  34115. cur = on[name] = createFnInvoker(cur);
  34116. }
  34117. add(event.name, cur, event.once, event.capture, event.passive);
  34118. } else if (cur !== old) {
  34119. old.fns = cur;
  34120. on[name] = old;
  34121. }
  34122. }
  34123. for (name in oldOn) {
  34124. if (isUndef(on[name])) {
  34125. event = normalizeEvent(name);
  34126. remove$$1(event.name, oldOn[name], event.capture);
  34127. }
  34128. }
  34129. }
  34130. /* */
  34131. function mergeVNodeHook (def, hookKey, hook) {
  34132. var invoker;
  34133. var oldHook = def[hookKey];
  34134. function wrappedHook () {
  34135. hook.apply(this, arguments);
  34136. // important: remove merged hook to ensure it's called only once
  34137. // and prevent memory leak
  34138. remove(invoker.fns, wrappedHook);
  34139. }
  34140. if (isUndef(oldHook)) {
  34141. // no existing hook
  34142. invoker = createFnInvoker([wrappedHook]);
  34143. } else {
  34144. /* istanbul ignore if */
  34145. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  34146. // already a merged invoker
  34147. invoker = oldHook;
  34148. invoker.fns.push(wrappedHook);
  34149. } else {
  34150. // existing plain hook
  34151. invoker = createFnInvoker([oldHook, wrappedHook]);
  34152. }
  34153. }
  34154. invoker.merged = true;
  34155. def[hookKey] = invoker;
  34156. }
  34157. /* */
  34158. function extractPropsFromVNodeData (
  34159. data,
  34160. Ctor,
  34161. tag
  34162. ) {
  34163. // we are only extracting raw values here.
  34164. // validation and default values are handled in the child
  34165. // component itself.
  34166. var propOptions = Ctor.options.props;
  34167. if (isUndef(propOptions)) {
  34168. return
  34169. }
  34170. var res = {};
  34171. var attrs = data.attrs;
  34172. var props = data.props;
  34173. if (isDef(attrs) || isDef(props)) {
  34174. for (var key in propOptions) {
  34175. var altKey = hyphenate(key);
  34176. if (true) {
  34177. var keyInLowerCase = key.toLowerCase();
  34178. if (
  34179. key !== keyInLowerCase &&
  34180. attrs && hasOwn(attrs, keyInLowerCase)
  34181. ) {
  34182. tip(
  34183. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  34184. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  34185. " \"" + key + "\". " +
  34186. "Note that HTML attributes are case-insensitive and camelCased " +
  34187. "props need to use their kebab-case equivalents when using in-DOM " +
  34188. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  34189. );
  34190. }
  34191. }
  34192. checkProp(res, props, key, altKey, true) ||
  34193. checkProp(res, attrs, key, altKey, false);
  34194. }
  34195. }
  34196. return res
  34197. }
  34198. function checkProp (
  34199. res,
  34200. hash,
  34201. key,
  34202. altKey,
  34203. preserve
  34204. ) {
  34205. if (isDef(hash)) {
  34206. if (hasOwn(hash, key)) {
  34207. res[key] = hash[key];
  34208. if (!preserve) {
  34209. delete hash[key];
  34210. }
  34211. return true
  34212. } else if (hasOwn(hash, altKey)) {
  34213. res[key] = hash[altKey];
  34214. if (!preserve) {
  34215. delete hash[altKey];
  34216. }
  34217. return true
  34218. }
  34219. }
  34220. return false
  34221. }
  34222. /* */
  34223. // The template compiler attempts to minimize the need for normalization by
  34224. // statically analyzing the template at compile time.
  34225. //
  34226. // For plain HTML markup, normalization can be completely skipped because the
  34227. // generated render function is guaranteed to return Array<VNode>. There are
  34228. // two cases where extra normalization is needed:
  34229. // 1. When the children contains components - because a functional component
  34230. // may return an Array instead of a single root. In this case, just a simple
  34231. // normalization is needed - if any child is an Array, we flatten the whole
  34232. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  34233. // because functional components already normalize their own children.
  34234. function simpleNormalizeChildren (children) {
  34235. for (var i = 0; i < children.length; i++) {
  34236. if (Array.isArray(children[i])) {
  34237. return Array.prototype.concat.apply([], children)
  34238. }
  34239. }
  34240. return children
  34241. }
  34242. // 2. When the children contains constructs that always generated nested Arrays,
  34243. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  34244. // with hand-written render functions / JSX. In such cases a full normalization
  34245. // is needed to cater to all possible types of children values.
  34246. function normalizeChildren (children) {
  34247. return isPrimitive(children)
  34248. ? [createTextVNode(children)]
  34249. : Array.isArray(children)
  34250. ? normalizeArrayChildren(children)
  34251. : undefined
  34252. }
  34253. function isTextNode (node) {
  34254. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  34255. }
  34256. function normalizeArrayChildren (children, nestedIndex) {
  34257. var res = [];
  34258. var i, c, last;
  34259. for (i = 0; i < children.length; i++) {
  34260. c = children[i];
  34261. if (isUndef(c) || typeof c === 'boolean') { continue }
  34262. last = res[res.length - 1];
  34263. // nested
  34264. if (Array.isArray(c)) {
  34265. res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
  34266. } else if (isPrimitive(c)) {
  34267. if (isTextNode(last)) {
  34268. // merge adjacent text nodes
  34269. // this is necessary for SSR hydration because text nodes are
  34270. // essentially merged when rendered to HTML strings
  34271. (last).text += String(c);
  34272. } else if (c !== '') {
  34273. // convert primitive to vnode
  34274. res.push(createTextVNode(c));
  34275. }
  34276. } else {
  34277. if (isTextNode(c) && isTextNode(last)) {
  34278. // merge adjacent text nodes
  34279. res[res.length - 1] = createTextVNode(last.text + c.text);
  34280. } else {
  34281. // default key for nested array children (likely generated by v-for)
  34282. if (isTrue(children._isVList) &&
  34283. isDef(c.tag) &&
  34284. isUndef(c.key) &&
  34285. isDef(nestedIndex)) {
  34286. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  34287. }
  34288. res.push(c);
  34289. }
  34290. }
  34291. }
  34292. return res
  34293. }
  34294. /* */
  34295. function ensureCtor (comp, base) {
  34296. return isObject(comp)
  34297. ? base.extend(comp)
  34298. : comp
  34299. }
  34300. function resolveAsyncComponent (
  34301. factory,
  34302. baseCtor,
  34303. context
  34304. ) {
  34305. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  34306. return factory.errorComp
  34307. }
  34308. if (isDef(factory.resolved)) {
  34309. return factory.resolved
  34310. }
  34311. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  34312. return factory.loadingComp
  34313. }
  34314. if (isDef(factory.contexts)) {
  34315. // already pending
  34316. factory.contexts.push(context);
  34317. } else {
  34318. var contexts = factory.contexts = [context];
  34319. var sync = true;
  34320. var forceRender = function () {
  34321. for (var i = 0, l = contexts.length; i < l; i++) {
  34322. contexts[i].$forceUpdate();
  34323. }
  34324. };
  34325. var resolve = once(function (res) {
  34326. // cache resolved
  34327. factory.resolved = ensureCtor(res, baseCtor);
  34328. // invoke callbacks only if this is not a synchronous resolve
  34329. // (async resolves are shimmed as synchronous during SSR)
  34330. if (!sync) {
  34331. forceRender();
  34332. }
  34333. });
  34334. var reject = once(function (reason) {
  34335. "development" !== 'production' && warn(
  34336. "Failed to resolve async component: " + (String(factory)) +
  34337. (reason ? ("\nReason: " + reason) : '')
  34338. );
  34339. if (isDef(factory.errorComp)) {
  34340. factory.error = true;
  34341. forceRender();
  34342. }
  34343. });
  34344. var res = factory(resolve, reject);
  34345. if (isObject(res)) {
  34346. if (typeof res.then === 'function') {
  34347. // () => Promise
  34348. if (isUndef(factory.resolved)) {
  34349. res.then(resolve, reject);
  34350. }
  34351. } else if (isDef(res.component) && typeof res.component.then === 'function') {
  34352. res.component.then(resolve, reject);
  34353. if (isDef(res.error)) {
  34354. factory.errorComp = ensureCtor(res.error, baseCtor);
  34355. }
  34356. if (isDef(res.loading)) {
  34357. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  34358. if (res.delay === 0) {
  34359. factory.loading = true;
  34360. } else {
  34361. setTimeout(function () {
  34362. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  34363. factory.loading = true;
  34364. forceRender();
  34365. }
  34366. }, res.delay || 200);
  34367. }
  34368. }
  34369. if (isDef(res.timeout)) {
  34370. setTimeout(function () {
  34371. if (isUndef(factory.resolved)) {
  34372. reject(
  34373. true
  34374. ? ("timeout (" + (res.timeout) + "ms)")
  34375. : null
  34376. );
  34377. }
  34378. }, res.timeout);
  34379. }
  34380. }
  34381. }
  34382. sync = false;
  34383. // return in case resolved synchronously
  34384. return factory.loading
  34385. ? factory.loadingComp
  34386. : factory.resolved
  34387. }
  34388. }
  34389. /* */
  34390. function getFirstComponentChild (children) {
  34391. if (Array.isArray(children)) {
  34392. for (var i = 0; i < children.length; i++) {
  34393. var c = children[i];
  34394. if (isDef(c) && isDef(c.componentOptions)) {
  34395. return c
  34396. }
  34397. }
  34398. }
  34399. }
  34400. /* */
  34401. /* */
  34402. function initEvents (vm) {
  34403. vm._events = Object.create(null);
  34404. vm._hasHookEvent = false;
  34405. // init parent attached events
  34406. var listeners = vm.$options._parentListeners;
  34407. if (listeners) {
  34408. updateComponentListeners(vm, listeners);
  34409. }
  34410. }
  34411. var target;
  34412. function add (event, fn, once$$1) {
  34413. if (once$$1) {
  34414. target.$once(event, fn);
  34415. } else {
  34416. target.$on(event, fn);
  34417. }
  34418. }
  34419. function remove$1 (event, fn) {
  34420. target.$off(event, fn);
  34421. }
  34422. function updateComponentListeners (
  34423. vm,
  34424. listeners,
  34425. oldListeners
  34426. ) {
  34427. target = vm;
  34428. updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
  34429. }
  34430. function eventsMixin (Vue) {
  34431. var hookRE = /^hook:/;
  34432. Vue.prototype.$on = function (event, fn) {
  34433. var this$1 = this;
  34434. var vm = this;
  34435. if (Array.isArray(event)) {
  34436. for (var i = 0, l = event.length; i < l; i++) {
  34437. this$1.$on(event[i], fn);
  34438. }
  34439. } else {
  34440. (vm._events[event] || (vm._events[event] = [])).push(fn);
  34441. // optimize hook:event cost by using a boolean flag marked at registration
  34442. // instead of a hash lookup
  34443. if (hookRE.test(event)) {
  34444. vm._hasHookEvent = true;
  34445. }
  34446. }
  34447. return vm
  34448. };
  34449. Vue.prototype.$once = function (event, fn) {
  34450. var vm = this;
  34451. function on () {
  34452. vm.$off(event, on);
  34453. fn.apply(vm, arguments);
  34454. }
  34455. on.fn = fn;
  34456. vm.$on(event, on);
  34457. return vm
  34458. };
  34459. Vue.prototype.$off = function (event, fn) {
  34460. var this$1 = this;
  34461. var vm = this;
  34462. // all
  34463. if (!arguments.length) {
  34464. vm._events = Object.create(null);
  34465. return vm
  34466. }
  34467. // array of events
  34468. if (Array.isArray(event)) {
  34469. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  34470. this$1.$off(event[i$1], fn);
  34471. }
  34472. return vm
  34473. }
  34474. // specific event
  34475. var cbs = vm._events[event];
  34476. if (!cbs) {
  34477. return vm
  34478. }
  34479. if (arguments.length === 1) {
  34480. vm._events[event] = null;
  34481. return vm
  34482. }
  34483. // specific handler
  34484. var cb;
  34485. var i = cbs.length;
  34486. while (i--) {
  34487. cb = cbs[i];
  34488. if (cb === fn || cb.fn === fn) {
  34489. cbs.splice(i, 1);
  34490. break
  34491. }
  34492. }
  34493. return vm
  34494. };
  34495. Vue.prototype.$emit = function (event) {
  34496. var vm = this;
  34497. if (true) {
  34498. var lowerCaseEvent = event.toLowerCase();
  34499. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  34500. tip(
  34501. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  34502. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  34503. "Note that HTML attributes are case-insensitive and you cannot use " +
  34504. "v-on to listen to camelCase events when using in-DOM templates. " +
  34505. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  34506. );
  34507. }
  34508. }
  34509. var cbs = vm._events[event];
  34510. if (cbs) {
  34511. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  34512. var args = toArray(arguments, 1);
  34513. for (var i = 0, l = cbs.length; i < l; i++) {
  34514. cbs[i].apply(vm, args);
  34515. }
  34516. }
  34517. return vm
  34518. };
  34519. }
  34520. /* */
  34521. /**
  34522. * Runtime helper for resolving raw children VNodes into a slot object.
  34523. */
  34524. function resolveSlots (
  34525. children,
  34526. context
  34527. ) {
  34528. var slots = {};
  34529. if (!children) {
  34530. return slots
  34531. }
  34532. var defaultSlot = [];
  34533. for (var i = 0, l = children.length; i < l; i++) {
  34534. var child = children[i];
  34535. // named slots should only be respected if the vnode was rendered in the
  34536. // same context.
  34537. if ((child.context === context || child.functionalContext === context) &&
  34538. child.data && child.data.slot != null
  34539. ) {
  34540. var name = child.data.slot;
  34541. var slot = (slots[name] || (slots[name] = []));
  34542. if (child.tag === 'template') {
  34543. slot.push.apply(slot, child.children);
  34544. } else {
  34545. slot.push(child);
  34546. }
  34547. } else {
  34548. defaultSlot.push(child);
  34549. }
  34550. }
  34551. // ignore whitespace
  34552. if (!defaultSlot.every(isWhitespace)) {
  34553. slots.default = defaultSlot;
  34554. }
  34555. return slots
  34556. }
  34557. function isWhitespace (node) {
  34558. return node.isComment || node.text === ' '
  34559. }
  34560. function resolveScopedSlots (
  34561. fns, // see flow/vnode
  34562. res
  34563. ) {
  34564. res = res || {};
  34565. for (var i = 0; i < fns.length; i++) {
  34566. if (Array.isArray(fns[i])) {
  34567. resolveScopedSlots(fns[i], res);
  34568. } else {
  34569. res[fns[i].key] = fns[i].fn;
  34570. }
  34571. }
  34572. return res
  34573. }
  34574. /* */
  34575. var activeInstance = null;
  34576. function initLifecycle (vm) {
  34577. var options = vm.$options;
  34578. // locate first non-abstract parent
  34579. var parent = options.parent;
  34580. if (parent && !options.abstract) {
  34581. while (parent.$options.abstract && parent.$parent) {
  34582. parent = parent.$parent;
  34583. }
  34584. parent.$children.push(vm);
  34585. }
  34586. vm.$parent = parent;
  34587. vm.$root = parent ? parent.$root : vm;
  34588. vm.$children = [];
  34589. vm.$refs = {};
  34590. vm._watcher = null;
  34591. vm._inactive = null;
  34592. vm._directInactive = false;
  34593. vm._isMounted = false;
  34594. vm._isDestroyed = false;
  34595. vm._isBeingDestroyed = false;
  34596. }
  34597. function lifecycleMixin (Vue) {
  34598. Vue.prototype._update = function (vnode, hydrating) {
  34599. var vm = this;
  34600. if (vm._isMounted) {
  34601. callHook(vm, 'beforeUpdate');
  34602. }
  34603. var prevEl = vm.$el;
  34604. var prevVnode = vm._vnode;
  34605. var prevActiveInstance = activeInstance;
  34606. activeInstance = vm;
  34607. vm._vnode = vnode;
  34608. // Vue.prototype.__patch__ is injected in entry points
  34609. // based on the rendering backend used.
  34610. if (!prevVnode) {
  34611. // initial render
  34612. vm.$el = vm.__patch__(
  34613. vm.$el, vnode, hydrating, false /* removeOnly */,
  34614. vm.$options._parentElm,
  34615. vm.$options._refElm
  34616. );
  34617. } else {
  34618. // updates
  34619. vm.$el = vm.__patch__(prevVnode, vnode);
  34620. }
  34621. activeInstance = prevActiveInstance;
  34622. // update __vue__ reference
  34623. if (prevEl) {
  34624. prevEl.__vue__ = null;
  34625. }
  34626. if (vm.$el) {
  34627. vm.$el.__vue__ = vm;
  34628. }
  34629. // if parent is an HOC, update its $el as well
  34630. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  34631. vm.$parent.$el = vm.$el;
  34632. }
  34633. // updated hook is called by the scheduler to ensure that children are
  34634. // updated in a parent's updated hook.
  34635. };
  34636. Vue.prototype.$forceUpdate = function () {
  34637. var vm = this;
  34638. if (vm._watcher) {
  34639. vm._watcher.update();
  34640. }
  34641. };
  34642. Vue.prototype.$destroy = function () {
  34643. var vm = this;
  34644. if (vm._isBeingDestroyed) {
  34645. return
  34646. }
  34647. callHook(vm, 'beforeDestroy');
  34648. vm._isBeingDestroyed = true;
  34649. // remove self from parent
  34650. var parent = vm.$parent;
  34651. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  34652. remove(parent.$children, vm);
  34653. }
  34654. // teardown watchers
  34655. if (vm._watcher) {
  34656. vm._watcher.teardown();
  34657. }
  34658. var i = vm._watchers.length;
  34659. while (i--) {
  34660. vm._watchers[i].teardown();
  34661. }
  34662. // remove reference from data ob
  34663. // frozen object may not have observer.
  34664. if (vm._data.__ob__) {
  34665. vm._data.__ob__.vmCount--;
  34666. }
  34667. // call the last hook...
  34668. vm._isDestroyed = true;
  34669. // invoke destroy hooks on current rendered tree
  34670. vm.__patch__(vm._vnode, null);
  34671. // fire destroyed hook
  34672. callHook(vm, 'destroyed');
  34673. // turn off all instance listeners.
  34674. vm.$off();
  34675. // remove __vue__ reference
  34676. if (vm.$el) {
  34677. vm.$el.__vue__ = null;
  34678. }
  34679. // remove reference to DOM nodes (prevents leak)
  34680. vm.$options._parentElm = vm.$options._refElm = null;
  34681. };
  34682. }
  34683. function mountComponent (
  34684. vm,
  34685. el,
  34686. hydrating
  34687. ) {
  34688. vm.$el = el;
  34689. if (!vm.$options.render) {
  34690. vm.$options.render = createEmptyVNode;
  34691. if (true) {
  34692. /* istanbul ignore if */
  34693. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  34694. vm.$options.el || el) {
  34695. warn(
  34696. 'You are using the runtime-only build of Vue where the template ' +
  34697. 'compiler is not available. Either pre-compile the templates into ' +
  34698. 'render functions, or use the compiler-included build.',
  34699. vm
  34700. );
  34701. } else {
  34702. warn(
  34703. 'Failed to mount component: template or render function not defined.',
  34704. vm
  34705. );
  34706. }
  34707. }
  34708. }
  34709. callHook(vm, 'beforeMount');
  34710. var updateComponent;
  34711. /* istanbul ignore if */
  34712. if ("development" !== 'production' && config.performance && mark) {
  34713. updateComponent = function () {
  34714. var name = vm._name;
  34715. var id = vm._uid;
  34716. var startTag = "vue-perf-start:" + id;
  34717. var endTag = "vue-perf-end:" + id;
  34718. mark(startTag);
  34719. var vnode = vm._render();
  34720. mark(endTag);
  34721. measure((name + " render"), startTag, endTag);
  34722. mark(startTag);
  34723. vm._update(vnode, hydrating);
  34724. mark(endTag);
  34725. measure((name + " patch"), startTag, endTag);
  34726. };
  34727. } else {
  34728. updateComponent = function () {
  34729. vm._update(vm._render(), hydrating);
  34730. };
  34731. }
  34732. vm._watcher = new Watcher(vm, updateComponent, noop);
  34733. hydrating = false;
  34734. // manually mounted instance, call mounted on self
  34735. // mounted is called for render-created child components in its inserted hook
  34736. if (vm.$vnode == null) {
  34737. vm._isMounted = true;
  34738. callHook(vm, 'mounted');
  34739. }
  34740. return vm
  34741. }
  34742. function updateChildComponent (
  34743. vm,
  34744. propsData,
  34745. listeners,
  34746. parentVnode,
  34747. renderChildren
  34748. ) {
  34749. // determine whether component has slot children
  34750. // we need to do this before overwriting $options._renderChildren
  34751. var hasChildren = !!(
  34752. renderChildren || // has new static slots
  34753. vm.$options._renderChildren || // has old static slots
  34754. parentVnode.data.scopedSlots || // has new scoped slots
  34755. vm.$scopedSlots !== emptyObject // has old scoped slots
  34756. );
  34757. vm.$options._parentVnode = parentVnode;
  34758. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  34759. if (vm._vnode) { // update child tree's parent
  34760. vm._vnode.parent = parentVnode;
  34761. }
  34762. vm.$options._renderChildren = renderChildren;
  34763. // update props
  34764. if (propsData && vm.$options.props) {
  34765. observerState.shouldConvert = false;
  34766. if (true) {
  34767. observerState.isSettingProps = true;
  34768. }
  34769. var props = vm._props;
  34770. var propKeys = vm.$options._propKeys || [];
  34771. for (var i = 0; i < propKeys.length; i++) {
  34772. var key = propKeys[i];
  34773. props[key] = validateProp(key, vm.$options.props, propsData, vm);
  34774. }
  34775. observerState.shouldConvert = true;
  34776. if (true) {
  34777. observerState.isSettingProps = false;
  34778. }
  34779. // keep a copy of raw propsData
  34780. vm.$options.propsData = propsData;
  34781. }
  34782. // update listeners
  34783. if (listeners) {
  34784. var oldListeners = vm.$options._parentListeners;
  34785. vm.$options._parentListeners = listeners;
  34786. updateComponentListeners(vm, listeners, oldListeners);
  34787. }
  34788. // resolve slots + force update if has children
  34789. if (hasChildren) {
  34790. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  34791. vm.$forceUpdate();
  34792. }
  34793. }
  34794. function isInInactiveTree (vm) {
  34795. while (vm && (vm = vm.$parent)) {
  34796. if (vm._inactive) { return true }
  34797. }
  34798. return false
  34799. }
  34800. function activateChildComponent (vm, direct) {
  34801. if (direct) {
  34802. vm._directInactive = false;
  34803. if (isInInactiveTree(vm)) {
  34804. return
  34805. }
  34806. } else if (vm._directInactive) {
  34807. return
  34808. }
  34809. if (vm._inactive || vm._inactive === null) {
  34810. vm._inactive = false;
  34811. for (var i = 0; i < vm.$children.length; i++) {
  34812. activateChildComponent(vm.$children[i]);
  34813. }
  34814. callHook(vm, 'activated');
  34815. }
  34816. }
  34817. function deactivateChildComponent (vm, direct) {
  34818. if (direct) {
  34819. vm._directInactive = true;
  34820. if (isInInactiveTree(vm)) {
  34821. return
  34822. }
  34823. }
  34824. if (!vm._inactive) {
  34825. vm._inactive = true;
  34826. for (var i = 0; i < vm.$children.length; i++) {
  34827. deactivateChildComponent(vm.$children[i]);
  34828. }
  34829. callHook(vm, 'deactivated');
  34830. }
  34831. }
  34832. function callHook (vm, hook) {
  34833. var handlers = vm.$options[hook];
  34834. if (handlers) {
  34835. for (var i = 0, j = handlers.length; i < j; i++) {
  34836. try {
  34837. handlers[i].call(vm);
  34838. } catch (e) {
  34839. handleError(e, vm, (hook + " hook"));
  34840. }
  34841. }
  34842. }
  34843. if (vm._hasHookEvent) {
  34844. vm.$emit('hook:' + hook);
  34845. }
  34846. }
  34847. /* */
  34848. var MAX_UPDATE_COUNT = 100;
  34849. var queue = [];
  34850. var activatedChildren = [];
  34851. var has = {};
  34852. var circular = {};
  34853. var waiting = false;
  34854. var flushing = false;
  34855. var index = 0;
  34856. /**
  34857. * Reset the scheduler's state.
  34858. */
  34859. function resetSchedulerState () {
  34860. index = queue.length = activatedChildren.length = 0;
  34861. has = {};
  34862. if (true) {
  34863. circular = {};
  34864. }
  34865. waiting = flushing = false;
  34866. }
  34867. /**
  34868. * Flush both queues and run the watchers.
  34869. */
  34870. function flushSchedulerQueue () {
  34871. flushing = true;
  34872. var watcher, id;
  34873. // Sort queue before flush.
  34874. // This ensures that:
  34875. // 1. Components are updated from parent to child. (because parent is always
  34876. // created before the child)
  34877. // 2. A component's user watchers are run before its render watcher (because
  34878. // user watchers are created before the render watcher)
  34879. // 3. If a component is destroyed during a parent component's watcher run,
  34880. // its watchers can be skipped.
  34881. queue.sort(function (a, b) { return a.id - b.id; });
  34882. // do not cache length because more watchers might be pushed
  34883. // as we run existing watchers
  34884. for (index = 0; index < queue.length; index++) {
  34885. watcher = queue[index];
  34886. id = watcher.id;
  34887. has[id] = null;
  34888. watcher.run();
  34889. // in dev build, check and stop circular updates.
  34890. if ("development" !== 'production' && has[id] != null) {
  34891. circular[id] = (circular[id] || 0) + 1;
  34892. if (circular[id] > MAX_UPDATE_COUNT) {
  34893. warn(
  34894. 'You may have an infinite update loop ' + (
  34895. watcher.user
  34896. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  34897. : "in a component render function."
  34898. ),
  34899. watcher.vm
  34900. );
  34901. break
  34902. }
  34903. }
  34904. }
  34905. // keep copies of post queues before resetting state
  34906. var activatedQueue = activatedChildren.slice();
  34907. var updatedQueue = queue.slice();
  34908. resetSchedulerState();
  34909. // call component updated and activated hooks
  34910. callActivatedHooks(activatedQueue);
  34911. callUpdateHooks(updatedQueue);
  34912. // devtool hook
  34913. /* istanbul ignore if */
  34914. if (devtools && config.devtools) {
  34915. devtools.emit('flush');
  34916. }
  34917. }
  34918. function callUpdateHooks (queue) {
  34919. var i = queue.length;
  34920. while (i--) {
  34921. var watcher = queue[i];
  34922. var vm = watcher.vm;
  34923. if (vm._watcher === watcher && vm._isMounted) {
  34924. callHook(vm, 'updated');
  34925. }
  34926. }
  34927. }
  34928. /**
  34929. * Queue a kept-alive component that was activated during patch.
  34930. * The queue will be processed after the entire tree has been patched.
  34931. */
  34932. function queueActivatedComponent (vm) {
  34933. // setting _inactive to false here so that a render function can
  34934. // rely on checking whether it's in an inactive tree (e.g. router-view)
  34935. vm._inactive = false;
  34936. activatedChildren.push(vm);
  34937. }
  34938. function callActivatedHooks (queue) {
  34939. for (var i = 0; i < queue.length; i++) {
  34940. queue[i]._inactive = true;
  34941. activateChildComponent(queue[i], true /* true */);
  34942. }
  34943. }
  34944. /**
  34945. * Push a watcher into the watcher queue.
  34946. * Jobs with duplicate IDs will be skipped unless it's
  34947. * pushed when the queue is being flushed.
  34948. */
  34949. function queueWatcher (watcher) {
  34950. var id = watcher.id;
  34951. if (has[id] == null) {
  34952. has[id] = true;
  34953. if (!flushing) {
  34954. queue.push(watcher);
  34955. } else {
  34956. // if already flushing, splice the watcher based on its id
  34957. // if already past its id, it will be run next immediately.
  34958. var i = queue.length - 1;
  34959. while (i > index && queue[i].id > watcher.id) {
  34960. i--;
  34961. }
  34962. queue.splice(i + 1, 0, watcher);
  34963. }
  34964. // queue the flush
  34965. if (!waiting) {
  34966. waiting = true;
  34967. nextTick(flushSchedulerQueue);
  34968. }
  34969. }
  34970. }
  34971. /* */
  34972. var uid$2 = 0;
  34973. /**
  34974. * A watcher parses an expression, collects dependencies,
  34975. * and fires callback when the expression value changes.
  34976. * This is used for both the $watch() api and directives.
  34977. */
  34978. var Watcher = function Watcher (
  34979. vm,
  34980. expOrFn,
  34981. cb,
  34982. options
  34983. ) {
  34984. this.vm = vm;
  34985. vm._watchers.push(this);
  34986. // options
  34987. if (options) {
  34988. this.deep = !!options.deep;
  34989. this.user = !!options.user;
  34990. this.lazy = !!options.lazy;
  34991. this.sync = !!options.sync;
  34992. } else {
  34993. this.deep = this.user = this.lazy = this.sync = false;
  34994. }
  34995. this.cb = cb;
  34996. this.id = ++uid$2; // uid for batching
  34997. this.active = true;
  34998. this.dirty = this.lazy; // for lazy watchers
  34999. this.deps = [];
  35000. this.newDeps = [];
  35001. this.depIds = new _Set();
  35002. this.newDepIds = new _Set();
  35003. this.expression = true
  35004. ? expOrFn.toString()
  35005. : '';
  35006. // parse expression for getter
  35007. if (typeof expOrFn === 'function') {
  35008. this.getter = expOrFn;
  35009. } else {
  35010. this.getter = parsePath(expOrFn);
  35011. if (!this.getter) {
  35012. this.getter = function () {};
  35013. "development" !== 'production' && warn(
  35014. "Failed watching path: \"" + expOrFn + "\" " +
  35015. 'Watcher only accepts simple dot-delimited paths. ' +
  35016. 'For full control, use a function instead.',
  35017. vm
  35018. );
  35019. }
  35020. }
  35021. this.value = this.lazy
  35022. ? undefined
  35023. : this.get();
  35024. };
  35025. /**
  35026. * Evaluate the getter, and re-collect dependencies.
  35027. */
  35028. Watcher.prototype.get = function get () {
  35029. pushTarget(this);
  35030. var value;
  35031. var vm = this.vm;
  35032. if (this.user) {
  35033. try {
  35034. value = this.getter.call(vm, vm);
  35035. } catch (e) {
  35036. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  35037. }
  35038. } else {
  35039. value = this.getter.call(vm, vm);
  35040. }
  35041. // "touch" every property so they are all tracked as
  35042. // dependencies for deep watching
  35043. if (this.deep) {
  35044. traverse(value);
  35045. }
  35046. popTarget();
  35047. this.cleanupDeps();
  35048. return value
  35049. };
  35050. /**
  35051. * Add a dependency to this directive.
  35052. */
  35053. Watcher.prototype.addDep = function addDep (dep) {
  35054. var id = dep.id;
  35055. if (!this.newDepIds.has(id)) {
  35056. this.newDepIds.add(id);
  35057. this.newDeps.push(dep);
  35058. if (!this.depIds.has(id)) {
  35059. dep.addSub(this);
  35060. }
  35061. }
  35062. };
  35063. /**
  35064. * Clean up for dependency collection.
  35065. */
  35066. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  35067. var this$1 = this;
  35068. var i = this.deps.length;
  35069. while (i--) {
  35070. var dep = this$1.deps[i];
  35071. if (!this$1.newDepIds.has(dep.id)) {
  35072. dep.removeSub(this$1);
  35073. }
  35074. }
  35075. var tmp = this.depIds;
  35076. this.depIds = this.newDepIds;
  35077. this.newDepIds = tmp;
  35078. this.newDepIds.clear();
  35079. tmp = this.deps;
  35080. this.deps = this.newDeps;
  35081. this.newDeps = tmp;
  35082. this.newDeps.length = 0;
  35083. };
  35084. /**
  35085. * Subscriber interface.
  35086. * Will be called when a dependency changes.
  35087. */
  35088. Watcher.prototype.update = function update () {
  35089. /* istanbul ignore else */
  35090. if (this.lazy) {
  35091. this.dirty = true;
  35092. } else if (this.sync) {
  35093. this.run();
  35094. } else {
  35095. queueWatcher(this);
  35096. }
  35097. };
  35098. /**
  35099. * Scheduler job interface.
  35100. * Will be called by the scheduler.
  35101. */
  35102. Watcher.prototype.run = function run () {
  35103. if (this.active) {
  35104. var value = this.get();
  35105. if (
  35106. value !== this.value ||
  35107. // Deep watchers and watchers on Object/Arrays should fire even
  35108. // when the value is the same, because the value may
  35109. // have mutated.
  35110. isObject(value) ||
  35111. this.deep
  35112. ) {
  35113. // set new value
  35114. var oldValue = this.value;
  35115. this.value = value;
  35116. if (this.user) {
  35117. try {
  35118. this.cb.call(this.vm, value, oldValue);
  35119. } catch (e) {
  35120. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  35121. }
  35122. } else {
  35123. this.cb.call(this.vm, value, oldValue);
  35124. }
  35125. }
  35126. }
  35127. };
  35128. /**
  35129. * Evaluate the value of the watcher.
  35130. * This only gets called for lazy watchers.
  35131. */
  35132. Watcher.prototype.evaluate = function evaluate () {
  35133. this.value = this.get();
  35134. this.dirty = false;
  35135. };
  35136. /**
  35137. * Depend on all deps collected by this watcher.
  35138. */
  35139. Watcher.prototype.depend = function depend () {
  35140. var this$1 = this;
  35141. var i = this.deps.length;
  35142. while (i--) {
  35143. this$1.deps[i].depend();
  35144. }
  35145. };
  35146. /**
  35147. * Remove self from all dependencies' subscriber list.
  35148. */
  35149. Watcher.prototype.teardown = function teardown () {
  35150. var this$1 = this;
  35151. if (this.active) {
  35152. // remove self from vm's watcher list
  35153. // this is a somewhat expensive operation so we skip it
  35154. // if the vm is being destroyed.
  35155. if (!this.vm._isBeingDestroyed) {
  35156. remove(this.vm._watchers, this);
  35157. }
  35158. var i = this.deps.length;
  35159. while (i--) {
  35160. this$1.deps[i].removeSub(this$1);
  35161. }
  35162. this.active = false;
  35163. }
  35164. };
  35165. /**
  35166. * Recursively traverse an object to evoke all converted
  35167. * getters, so that every nested property inside the object
  35168. * is collected as a "deep" dependency.
  35169. */
  35170. var seenObjects = new _Set();
  35171. function traverse (val) {
  35172. seenObjects.clear();
  35173. _traverse(val, seenObjects);
  35174. }
  35175. function _traverse (val, seen) {
  35176. var i, keys;
  35177. var isA = Array.isArray(val);
  35178. if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
  35179. return
  35180. }
  35181. if (val.__ob__) {
  35182. var depId = val.__ob__.dep.id;
  35183. if (seen.has(depId)) {
  35184. return
  35185. }
  35186. seen.add(depId);
  35187. }
  35188. if (isA) {
  35189. i = val.length;
  35190. while (i--) { _traverse(val[i], seen); }
  35191. } else {
  35192. keys = Object.keys(val);
  35193. i = keys.length;
  35194. while (i--) { _traverse(val[keys[i]], seen); }
  35195. }
  35196. }
  35197. /* */
  35198. var sharedPropertyDefinition = {
  35199. enumerable: true,
  35200. configurable: true,
  35201. get: noop,
  35202. set: noop
  35203. };
  35204. function proxy (target, sourceKey, key) {
  35205. sharedPropertyDefinition.get = function proxyGetter () {
  35206. return this[sourceKey][key]
  35207. };
  35208. sharedPropertyDefinition.set = function proxySetter (val) {
  35209. this[sourceKey][key] = val;
  35210. };
  35211. Object.defineProperty(target, key, sharedPropertyDefinition);
  35212. }
  35213. function initState (vm) {
  35214. vm._watchers = [];
  35215. var opts = vm.$options;
  35216. if (opts.props) { initProps(vm, opts.props); }
  35217. if (opts.methods) { initMethods(vm, opts.methods); }
  35218. if (opts.data) {
  35219. initData(vm);
  35220. } else {
  35221. observe(vm._data = {}, true /* asRootData */);
  35222. }
  35223. if (opts.computed) { initComputed(vm, opts.computed); }
  35224. if (opts.watch) { initWatch(vm, opts.watch); }
  35225. }
  35226. var isReservedProp = {
  35227. key: 1,
  35228. ref: 1,
  35229. slot: 1
  35230. };
  35231. function initProps (vm, propsOptions) {
  35232. var propsData = vm.$options.propsData || {};
  35233. var props = vm._props = {};
  35234. // cache prop keys so that future props updates can iterate using Array
  35235. // instead of dynamic object key enumeration.
  35236. var keys = vm.$options._propKeys = [];
  35237. var isRoot = !vm.$parent;
  35238. // root instance props should be converted
  35239. observerState.shouldConvert = isRoot;
  35240. var loop = function ( key ) {
  35241. keys.push(key);
  35242. var value = validateProp(key, propsOptions, propsData, vm);
  35243. /* istanbul ignore else */
  35244. if (true) {
  35245. if (isReservedProp[key] || config.isReservedAttr(key)) {
  35246. warn(
  35247. ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
  35248. vm
  35249. );
  35250. }
  35251. defineReactive$$1(props, key, value, function () {
  35252. if (vm.$parent && !observerState.isSettingProps) {
  35253. warn(
  35254. "Avoid mutating a prop directly since the value will be " +
  35255. "overwritten whenever the parent component re-renders. " +
  35256. "Instead, use a data or computed property based on the prop's " +
  35257. "value. Prop being mutated: \"" + key + "\"",
  35258. vm
  35259. );
  35260. }
  35261. });
  35262. } else {
  35263. defineReactive$$1(props, key, value);
  35264. }
  35265. // static props are already proxied on the component's prototype
  35266. // during Vue.extend(). We only need to proxy props defined at
  35267. // instantiation here.
  35268. if (!(key in vm)) {
  35269. proxy(vm, "_props", key);
  35270. }
  35271. };
  35272. for (var key in propsOptions) loop( key );
  35273. observerState.shouldConvert = true;
  35274. }
  35275. function initData (vm) {
  35276. var data = vm.$options.data;
  35277. data = vm._data = typeof data === 'function'
  35278. ? getData(data, vm)
  35279. : data || {};
  35280. if (!isPlainObject(data)) {
  35281. data = {};
  35282. "development" !== 'production' && warn(
  35283. 'data functions should return an object:\n' +
  35284. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  35285. vm
  35286. );
  35287. }
  35288. // proxy data on instance
  35289. var keys = Object.keys(data);
  35290. var props = vm.$options.props;
  35291. var i = keys.length;
  35292. while (i--) {
  35293. if (props && hasOwn(props, keys[i])) {
  35294. "development" !== 'production' && warn(
  35295. "The data property \"" + (keys[i]) + "\" is already declared as a prop. " +
  35296. "Use prop default value instead.",
  35297. vm
  35298. );
  35299. } else if (!isReserved(keys[i])) {
  35300. proxy(vm, "_data", keys[i]);
  35301. }
  35302. }
  35303. // observe data
  35304. observe(data, true /* asRootData */);
  35305. }
  35306. function getData (data, vm) {
  35307. try {
  35308. return data.call(vm)
  35309. } catch (e) {
  35310. handleError(e, vm, "data()");
  35311. return {}
  35312. }
  35313. }
  35314. var computedWatcherOptions = { lazy: true };
  35315. function initComputed (vm, computed) {
  35316. var watchers = vm._computedWatchers = Object.create(null);
  35317. for (var key in computed) {
  35318. var userDef = computed[key];
  35319. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  35320. if (true) {
  35321. if (getter === undefined) {
  35322. warn(
  35323. ("No getter function has been defined for computed property \"" + key + "\"."),
  35324. vm
  35325. );
  35326. getter = noop;
  35327. }
  35328. }
  35329. // create internal watcher for the computed property.
  35330. watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions);
  35331. // component-defined computed properties are already defined on the
  35332. // component prototype. We only need to define computed properties defined
  35333. // at instantiation here.
  35334. if (!(key in vm)) {
  35335. defineComputed(vm, key, userDef);
  35336. } else if (true) {
  35337. if (key in vm.$data) {
  35338. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  35339. } else if (vm.$options.props && key in vm.$options.props) {
  35340. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  35341. }
  35342. }
  35343. }
  35344. }
  35345. function defineComputed (target, key, userDef) {
  35346. if (typeof userDef === 'function') {
  35347. sharedPropertyDefinition.get = createComputedGetter(key);
  35348. sharedPropertyDefinition.set = noop;
  35349. } else {
  35350. sharedPropertyDefinition.get = userDef.get
  35351. ? userDef.cache !== false
  35352. ? createComputedGetter(key)
  35353. : userDef.get
  35354. : noop;
  35355. sharedPropertyDefinition.set = userDef.set
  35356. ? userDef.set
  35357. : noop;
  35358. }
  35359. Object.defineProperty(target, key, sharedPropertyDefinition);
  35360. }
  35361. function createComputedGetter (key) {
  35362. return function computedGetter () {
  35363. var watcher = this._computedWatchers && this._computedWatchers[key];
  35364. if (watcher) {
  35365. if (watcher.dirty) {
  35366. watcher.evaluate();
  35367. }
  35368. if (Dep.target) {
  35369. watcher.depend();
  35370. }
  35371. return watcher.value
  35372. }
  35373. }
  35374. }
  35375. function initMethods (vm, methods) {
  35376. var props = vm.$options.props;
  35377. for (var key in methods) {
  35378. vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
  35379. if (true) {
  35380. if (methods[key] == null) {
  35381. warn(
  35382. "method \"" + key + "\" has an undefined value in the component definition. " +
  35383. "Did you reference the function correctly?",
  35384. vm
  35385. );
  35386. }
  35387. if (props && hasOwn(props, key)) {
  35388. warn(
  35389. ("method \"" + key + "\" has already been defined as a prop."),
  35390. vm
  35391. );
  35392. }
  35393. }
  35394. }
  35395. }
  35396. function initWatch (vm, watch) {
  35397. for (var key in watch) {
  35398. var handler = watch[key];
  35399. if (Array.isArray(handler)) {
  35400. for (var i = 0; i < handler.length; i++) {
  35401. createWatcher(vm, key, handler[i]);
  35402. }
  35403. } else {
  35404. createWatcher(vm, key, handler);
  35405. }
  35406. }
  35407. }
  35408. function createWatcher (vm, key, handler) {
  35409. var options;
  35410. if (isPlainObject(handler)) {
  35411. options = handler;
  35412. handler = handler.handler;
  35413. }
  35414. if (typeof handler === 'string') {
  35415. handler = vm[handler];
  35416. }
  35417. vm.$watch(key, handler, options);
  35418. }
  35419. function stateMixin (Vue) {
  35420. // flow somehow has problems with directly declared definition object
  35421. // when using Object.defineProperty, so we have to procedurally build up
  35422. // the object here.
  35423. var dataDef = {};
  35424. dataDef.get = function () { return this._data };
  35425. var propsDef = {};
  35426. propsDef.get = function () { return this._props };
  35427. if (true) {
  35428. dataDef.set = function (newData) {
  35429. warn(
  35430. 'Avoid replacing instance root $data. ' +
  35431. 'Use nested data properties instead.',
  35432. this
  35433. );
  35434. };
  35435. propsDef.set = function () {
  35436. warn("$props is readonly.", this);
  35437. };
  35438. }
  35439. Object.defineProperty(Vue.prototype, '$data', dataDef);
  35440. Object.defineProperty(Vue.prototype, '$props', propsDef);
  35441. Vue.prototype.$set = set;
  35442. Vue.prototype.$delete = del;
  35443. Vue.prototype.$watch = function (
  35444. expOrFn,
  35445. cb,
  35446. options
  35447. ) {
  35448. var vm = this;
  35449. options = options || {};
  35450. options.user = true;
  35451. var watcher = new Watcher(vm, expOrFn, cb, options);
  35452. if (options.immediate) {
  35453. cb.call(vm, watcher.value);
  35454. }
  35455. return function unwatchFn () {
  35456. watcher.teardown();
  35457. }
  35458. };
  35459. }
  35460. /* */
  35461. function initProvide (vm) {
  35462. var provide = vm.$options.provide;
  35463. if (provide) {
  35464. vm._provided = typeof provide === 'function'
  35465. ? provide.call(vm)
  35466. : provide;
  35467. }
  35468. }
  35469. function initInjections (vm) {
  35470. var result = resolveInject(vm.$options.inject, vm);
  35471. if (result) {
  35472. Object.keys(result).forEach(function (key) {
  35473. /* istanbul ignore else */
  35474. if (true) {
  35475. defineReactive$$1(vm, key, result[key], function () {
  35476. warn(
  35477. "Avoid mutating an injected value directly since the changes will be " +
  35478. "overwritten whenever the provided component re-renders. " +
  35479. "injection being mutated: \"" + key + "\"",
  35480. vm
  35481. );
  35482. });
  35483. } else {
  35484. defineReactive$$1(vm, key, result[key]);
  35485. }
  35486. });
  35487. }
  35488. }
  35489. function resolveInject (inject, vm) {
  35490. if (inject) {
  35491. // inject is :any because flow is not smart enough to figure out cached
  35492. // isArray here
  35493. var isArray = Array.isArray(inject);
  35494. var result = Object.create(null);
  35495. var keys = isArray
  35496. ? inject
  35497. : hasSymbol
  35498. ? Reflect.ownKeys(inject)
  35499. : Object.keys(inject);
  35500. for (var i = 0; i < keys.length; i++) {
  35501. var key = keys[i];
  35502. var provideKey = isArray ? key : inject[key];
  35503. var source = vm;
  35504. while (source) {
  35505. if (source._provided && provideKey in source._provided) {
  35506. result[key] = source._provided[provideKey];
  35507. break
  35508. }
  35509. source = source.$parent;
  35510. }
  35511. }
  35512. return result
  35513. }
  35514. }
  35515. /* */
  35516. function createFunctionalComponent (
  35517. Ctor,
  35518. propsData,
  35519. data,
  35520. context,
  35521. children
  35522. ) {
  35523. var props = {};
  35524. var propOptions = Ctor.options.props;
  35525. if (isDef(propOptions)) {
  35526. for (var key in propOptions) {
  35527. props[key] = validateProp(key, propOptions, propsData || {});
  35528. }
  35529. } else {
  35530. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  35531. if (isDef(data.props)) { mergeProps(props, data.props); }
  35532. }
  35533. // ensure the createElement function in functional components
  35534. // gets a unique context - this is necessary for correct named slot check
  35535. var _context = Object.create(context);
  35536. var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
  35537. var vnode = Ctor.options.render.call(null, h, {
  35538. data: data,
  35539. props: props,
  35540. children: children,
  35541. parent: context,
  35542. listeners: data.on || {},
  35543. injections: resolveInject(Ctor.options.inject, context),
  35544. slots: function () { return resolveSlots(children, context); }
  35545. });
  35546. if (vnode instanceof VNode) {
  35547. vnode.functionalContext = context;
  35548. vnode.functionalOptions = Ctor.options;
  35549. if (data.slot) {
  35550. (vnode.data || (vnode.data = {})).slot = data.slot;
  35551. }
  35552. }
  35553. return vnode
  35554. }
  35555. function mergeProps (to, from) {
  35556. for (var key in from) {
  35557. to[camelize(key)] = from[key];
  35558. }
  35559. }
  35560. /* */
  35561. // hooks to be invoked on component VNodes during patch
  35562. var componentVNodeHooks = {
  35563. init: function init (
  35564. vnode,
  35565. hydrating,
  35566. parentElm,
  35567. refElm
  35568. ) {
  35569. if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
  35570. var child = vnode.componentInstance = createComponentInstanceForVnode(
  35571. vnode,
  35572. activeInstance,
  35573. parentElm,
  35574. refElm
  35575. );
  35576. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  35577. } else if (vnode.data.keepAlive) {
  35578. // kept-alive components, treat as a patch
  35579. var mountedNode = vnode; // work around flow
  35580. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  35581. }
  35582. },
  35583. prepatch: function prepatch (oldVnode, vnode) {
  35584. var options = vnode.componentOptions;
  35585. var child = vnode.componentInstance = oldVnode.componentInstance;
  35586. updateChildComponent(
  35587. child,
  35588. options.propsData, // updated props
  35589. options.listeners, // updated listeners
  35590. vnode, // new parent vnode
  35591. options.children // new children
  35592. );
  35593. },
  35594. insert: function insert (vnode) {
  35595. var context = vnode.context;
  35596. var componentInstance = vnode.componentInstance;
  35597. if (!componentInstance._isMounted) {
  35598. componentInstance._isMounted = true;
  35599. callHook(componentInstance, 'mounted');
  35600. }
  35601. if (vnode.data.keepAlive) {
  35602. if (context._isMounted) {
  35603. // vue-router#1212
  35604. // During updates, a kept-alive component's child components may
  35605. // change, so directly walking the tree here may call activated hooks
  35606. // on incorrect children. Instead we push them into a queue which will
  35607. // be processed after the whole patch process ended.
  35608. queueActivatedComponent(componentInstance);
  35609. } else {
  35610. activateChildComponent(componentInstance, true /* direct */);
  35611. }
  35612. }
  35613. },
  35614. destroy: function destroy (vnode) {
  35615. var componentInstance = vnode.componentInstance;
  35616. if (!componentInstance._isDestroyed) {
  35617. if (!vnode.data.keepAlive) {
  35618. componentInstance.$destroy();
  35619. } else {
  35620. deactivateChildComponent(componentInstance, true /* direct */);
  35621. }
  35622. }
  35623. }
  35624. };
  35625. var hooksToMerge = Object.keys(componentVNodeHooks);
  35626. function createComponent (
  35627. Ctor,
  35628. data,
  35629. context,
  35630. children,
  35631. tag
  35632. ) {
  35633. if (isUndef(Ctor)) {
  35634. return
  35635. }
  35636. var baseCtor = context.$options._base;
  35637. // plain options object: turn it into a constructor
  35638. if (isObject(Ctor)) {
  35639. Ctor = baseCtor.extend(Ctor);
  35640. }
  35641. // if at this stage it's not a constructor or an async component factory,
  35642. // reject.
  35643. if (typeof Ctor !== 'function') {
  35644. if (true) {
  35645. warn(("Invalid Component definition: " + (String(Ctor))), context);
  35646. }
  35647. return
  35648. }
  35649. // async component
  35650. if (isUndef(Ctor.cid)) {
  35651. Ctor = resolveAsyncComponent(Ctor, baseCtor, context);
  35652. if (Ctor === undefined) {
  35653. // return nothing if this is indeed an async component
  35654. // wait for the callback to trigger parent update.
  35655. return
  35656. }
  35657. }
  35658. // resolve constructor options in case global mixins are applied after
  35659. // component constructor creation
  35660. resolveConstructorOptions(Ctor);
  35661. data = data || {};
  35662. // transform component v-model data into props & events
  35663. if (isDef(data.model)) {
  35664. transformModel(Ctor.options, data);
  35665. }
  35666. // extract props
  35667. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  35668. // functional component
  35669. if (isTrue(Ctor.options.functional)) {
  35670. return createFunctionalComponent(Ctor, propsData, data, context, children)
  35671. }
  35672. // extract listeners, since these needs to be treated as
  35673. // child component listeners instead of DOM listeners
  35674. var listeners = data.on;
  35675. // replace with listeners with .native modifier
  35676. data.on = data.nativeOn;
  35677. if (isTrue(Ctor.options.abstract)) {
  35678. // abstract components do not keep anything
  35679. // other than props & listeners
  35680. data = {};
  35681. }
  35682. // merge component management hooks onto the placeholder node
  35683. mergeHooks(data);
  35684. // return a placeholder vnode
  35685. var name = Ctor.options.name || tag;
  35686. var vnode = new VNode(
  35687. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  35688. data, undefined, undefined, undefined, context,
  35689. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }
  35690. );
  35691. return vnode
  35692. }
  35693. function createComponentInstanceForVnode (
  35694. vnode, // we know it's MountedComponentVNode but flow doesn't
  35695. parent, // activeInstance in lifecycle state
  35696. parentElm,
  35697. refElm
  35698. ) {
  35699. var vnodeComponentOptions = vnode.componentOptions;
  35700. var options = {
  35701. _isComponent: true,
  35702. parent: parent,
  35703. propsData: vnodeComponentOptions.propsData,
  35704. _componentTag: vnodeComponentOptions.tag,
  35705. _parentVnode: vnode,
  35706. _parentListeners: vnodeComponentOptions.listeners,
  35707. _renderChildren: vnodeComponentOptions.children,
  35708. _parentElm: parentElm || null,
  35709. _refElm: refElm || null
  35710. };
  35711. // check inline-template render functions
  35712. var inlineTemplate = vnode.data.inlineTemplate;
  35713. if (isDef(inlineTemplate)) {
  35714. options.render = inlineTemplate.render;
  35715. options.staticRenderFns = inlineTemplate.staticRenderFns;
  35716. }
  35717. return new vnodeComponentOptions.Ctor(options)
  35718. }
  35719. function mergeHooks (data) {
  35720. if (!data.hook) {
  35721. data.hook = {};
  35722. }
  35723. for (var i = 0; i < hooksToMerge.length; i++) {
  35724. var key = hooksToMerge[i];
  35725. var fromParent = data.hook[key];
  35726. var ours = componentVNodeHooks[key];
  35727. data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
  35728. }
  35729. }
  35730. function mergeHook$1 (one, two) {
  35731. return function (a, b, c, d) {
  35732. one(a, b, c, d);
  35733. two(a, b, c, d);
  35734. }
  35735. }
  35736. // transform component v-model info (value and callback) into
  35737. // prop and event handler respectively.
  35738. function transformModel (options, data) {
  35739. var prop = (options.model && options.model.prop) || 'value';
  35740. var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
  35741. var on = data.on || (data.on = {});
  35742. if (isDef(on[event])) {
  35743. on[event] = [data.model.callback].concat(on[event]);
  35744. } else {
  35745. on[event] = data.model.callback;
  35746. }
  35747. }
  35748. /* */
  35749. var SIMPLE_NORMALIZE = 1;
  35750. var ALWAYS_NORMALIZE = 2;
  35751. // wrapper function for providing a more flexible interface
  35752. // without getting yelled at by flow
  35753. function createElement (
  35754. context,
  35755. tag,
  35756. data,
  35757. children,
  35758. normalizationType,
  35759. alwaysNormalize
  35760. ) {
  35761. if (Array.isArray(data) || isPrimitive(data)) {
  35762. normalizationType = children;
  35763. children = data;
  35764. data = undefined;
  35765. }
  35766. if (isTrue(alwaysNormalize)) {
  35767. normalizationType = ALWAYS_NORMALIZE;
  35768. }
  35769. return _createElement(context, tag, data, children, normalizationType)
  35770. }
  35771. function _createElement (
  35772. context,
  35773. tag,
  35774. data,
  35775. children,
  35776. normalizationType
  35777. ) {
  35778. if (isDef(data) && isDef((data).__ob__)) {
  35779. "development" !== 'production' && warn(
  35780. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  35781. 'Always create fresh vnode data objects in each render!',
  35782. context
  35783. );
  35784. return createEmptyVNode()
  35785. }
  35786. if (!tag) {
  35787. // in case of component :is set to falsy value
  35788. return createEmptyVNode()
  35789. }
  35790. // support single function children as default scoped slot
  35791. if (Array.isArray(children) &&
  35792. typeof children[0] === 'function'
  35793. ) {
  35794. data = data || {};
  35795. data.scopedSlots = { default: children[0] };
  35796. children.length = 0;
  35797. }
  35798. if (normalizationType === ALWAYS_NORMALIZE) {
  35799. children = normalizeChildren(children);
  35800. } else if (normalizationType === SIMPLE_NORMALIZE) {
  35801. children = simpleNormalizeChildren(children);
  35802. }
  35803. var vnode, ns;
  35804. if (typeof tag === 'string') {
  35805. var Ctor;
  35806. ns = config.getTagNamespace(tag);
  35807. if (config.isReservedTag(tag)) {
  35808. // platform built-in elements
  35809. vnode = new VNode(
  35810. config.parsePlatformTagName(tag), data, children,
  35811. undefined, undefined, context
  35812. );
  35813. } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  35814. // component
  35815. vnode = createComponent(Ctor, data, context, children, tag);
  35816. } else {
  35817. // unknown or unlisted namespaced elements
  35818. // check at runtime because it may get assigned a namespace when its
  35819. // parent normalizes children
  35820. vnode = new VNode(
  35821. tag, data, children,
  35822. undefined, undefined, context
  35823. );
  35824. }
  35825. } else {
  35826. // direct component options / constructor
  35827. vnode = createComponent(tag, data, context, children);
  35828. }
  35829. if (isDef(vnode)) {
  35830. if (ns) { applyNS(vnode, ns); }
  35831. return vnode
  35832. } else {
  35833. return createEmptyVNode()
  35834. }
  35835. }
  35836. function applyNS (vnode, ns) {
  35837. vnode.ns = ns;
  35838. if (vnode.tag === 'foreignObject') {
  35839. // use default namespace inside foreignObject
  35840. return
  35841. }
  35842. if (isDef(vnode.children)) {
  35843. for (var i = 0, l = vnode.children.length; i < l; i++) {
  35844. var child = vnode.children[i];
  35845. if (isDef(child.tag) && isUndef(child.ns)) {
  35846. applyNS(child, ns);
  35847. }
  35848. }
  35849. }
  35850. }
  35851. /* */
  35852. /**
  35853. * Runtime helper for rendering v-for lists.
  35854. */
  35855. function renderList (
  35856. val,
  35857. render
  35858. ) {
  35859. var ret, i, l, keys, key;
  35860. if (Array.isArray(val) || typeof val === 'string') {
  35861. ret = new Array(val.length);
  35862. for (i = 0, l = val.length; i < l; i++) {
  35863. ret[i] = render(val[i], i);
  35864. }
  35865. } else if (typeof val === 'number') {
  35866. ret = new Array(val);
  35867. for (i = 0; i < val; i++) {
  35868. ret[i] = render(i + 1, i);
  35869. }
  35870. } else if (isObject(val)) {
  35871. keys = Object.keys(val);
  35872. ret = new Array(keys.length);
  35873. for (i = 0, l = keys.length; i < l; i++) {
  35874. key = keys[i];
  35875. ret[i] = render(val[key], key, i);
  35876. }
  35877. }
  35878. if (isDef(ret)) {
  35879. (ret)._isVList = true;
  35880. }
  35881. return ret
  35882. }
  35883. /* */
  35884. /**
  35885. * Runtime helper for rendering <slot>
  35886. */
  35887. function renderSlot (
  35888. name,
  35889. fallback,
  35890. props,
  35891. bindObject
  35892. ) {
  35893. var scopedSlotFn = this.$scopedSlots[name];
  35894. if (scopedSlotFn) { // scoped slot
  35895. props = props || {};
  35896. if (bindObject) {
  35897. extend(props, bindObject);
  35898. }
  35899. return scopedSlotFn(props) || fallback
  35900. } else {
  35901. var slotNodes = this.$slots[name];
  35902. // warn duplicate slot usage
  35903. if (slotNodes && "development" !== 'production') {
  35904. slotNodes._rendered && warn(
  35905. "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
  35906. "- this will likely cause render errors.",
  35907. this
  35908. );
  35909. slotNodes._rendered = true;
  35910. }
  35911. return slotNodes || fallback
  35912. }
  35913. }
  35914. /* */
  35915. /**
  35916. * Runtime helper for resolving filters
  35917. */
  35918. function resolveFilter (id) {
  35919. return resolveAsset(this.$options, 'filters', id, true) || identity
  35920. }
  35921. /* */
  35922. /**
  35923. * Runtime helper for checking keyCodes from config.
  35924. */
  35925. function checkKeyCodes (
  35926. eventKeyCode,
  35927. key,
  35928. builtInAlias
  35929. ) {
  35930. var keyCodes = config.keyCodes[key] || builtInAlias;
  35931. if (Array.isArray(keyCodes)) {
  35932. return keyCodes.indexOf(eventKeyCode) === -1
  35933. } else {
  35934. return keyCodes !== eventKeyCode
  35935. }
  35936. }
  35937. /* */
  35938. /**
  35939. * Runtime helper for merging v-bind="object" into a VNode's data.
  35940. */
  35941. function bindObjectProps (
  35942. data,
  35943. tag,
  35944. value,
  35945. asProp
  35946. ) {
  35947. if (value) {
  35948. if (!isObject(value)) {
  35949. "development" !== 'production' && warn(
  35950. 'v-bind without argument expects an Object or Array value',
  35951. this
  35952. );
  35953. } else {
  35954. if (Array.isArray(value)) {
  35955. value = toObject(value);
  35956. }
  35957. var hash;
  35958. for (var key in value) {
  35959. if (key === 'class' || key === 'style') {
  35960. hash = data;
  35961. } else {
  35962. var type = data.attrs && data.attrs.type;
  35963. hash = asProp || config.mustUseProp(tag, type, key)
  35964. ? data.domProps || (data.domProps = {})
  35965. : data.attrs || (data.attrs = {});
  35966. }
  35967. if (!(key in hash)) {
  35968. hash[key] = value[key];
  35969. }
  35970. }
  35971. }
  35972. }
  35973. return data
  35974. }
  35975. /* */
  35976. /**
  35977. * Runtime helper for rendering static trees.
  35978. */
  35979. function renderStatic (
  35980. index,
  35981. isInFor
  35982. ) {
  35983. var tree = this._staticTrees[index];
  35984. // if has already-rendered static tree and not inside v-for,
  35985. // we can reuse the same tree by doing a shallow clone.
  35986. if (tree && !isInFor) {
  35987. return Array.isArray(tree)
  35988. ? cloneVNodes(tree)
  35989. : cloneVNode(tree)
  35990. }
  35991. // otherwise, render a fresh tree.
  35992. tree = this._staticTrees[index] =
  35993. this.$options.staticRenderFns[index].call(this._renderProxy);
  35994. markStatic(tree, ("__static__" + index), false);
  35995. return tree
  35996. }
  35997. /**
  35998. * Runtime helper for v-once.
  35999. * Effectively it means marking the node as static with a unique key.
  36000. */
  36001. function markOnce (
  36002. tree,
  36003. index,
  36004. key
  36005. ) {
  36006. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  36007. return tree
  36008. }
  36009. function markStatic (
  36010. tree,
  36011. key,
  36012. isOnce
  36013. ) {
  36014. if (Array.isArray(tree)) {
  36015. for (var i = 0; i < tree.length; i++) {
  36016. if (tree[i] && typeof tree[i] !== 'string') {
  36017. markStaticNode(tree[i], (key + "_" + i), isOnce);
  36018. }
  36019. }
  36020. } else {
  36021. markStaticNode(tree, key, isOnce);
  36022. }
  36023. }
  36024. function markStaticNode (node, key, isOnce) {
  36025. node.isStatic = true;
  36026. node.key = key;
  36027. node.isOnce = isOnce;
  36028. }
  36029. /* */
  36030. function initRender (vm) {
  36031. vm._vnode = null; // the root of the child tree
  36032. vm._staticTrees = null;
  36033. var parentVnode = vm.$vnode = vm.$options._parentVnode; // the placeholder node in parent tree
  36034. var renderContext = parentVnode && parentVnode.context;
  36035. vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
  36036. vm.$scopedSlots = emptyObject;
  36037. // bind the createElement fn to this instance
  36038. // so that we get proper render context inside it.
  36039. // args order: tag, data, children, normalizationType, alwaysNormalize
  36040. // internal version is used by render functions compiled from templates
  36041. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  36042. // normalization is always applied for the public version, used in
  36043. // user-written render functions.
  36044. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  36045. }
  36046. function renderMixin (Vue) {
  36047. Vue.prototype.$nextTick = function (fn) {
  36048. return nextTick(fn, this)
  36049. };
  36050. Vue.prototype._render = function () {
  36051. var vm = this;
  36052. var ref = vm.$options;
  36053. var render = ref.render;
  36054. var staticRenderFns = ref.staticRenderFns;
  36055. var _parentVnode = ref._parentVnode;
  36056. if (vm._isMounted) {
  36057. // clone slot nodes on re-renders
  36058. for (var key in vm.$slots) {
  36059. vm.$slots[key] = cloneVNodes(vm.$slots[key]);
  36060. }
  36061. }
  36062. vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject;
  36063. if (staticRenderFns && !vm._staticTrees) {
  36064. vm._staticTrees = [];
  36065. }
  36066. // set parent vnode. this allows render functions to have access
  36067. // to the data on the placeholder node.
  36068. vm.$vnode = _parentVnode;
  36069. // render self
  36070. var vnode;
  36071. try {
  36072. vnode = render.call(vm._renderProxy, vm.$createElement);
  36073. } catch (e) {
  36074. handleError(e, vm, "render function");
  36075. // return error render result,
  36076. // or previous vnode to prevent render error causing blank component
  36077. /* istanbul ignore else */
  36078. if (true) {
  36079. vnode = vm.$options.renderError
  36080. ? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)
  36081. : vm._vnode;
  36082. } else {
  36083. vnode = vm._vnode;
  36084. }
  36085. }
  36086. // return empty vnode in case the render function errored out
  36087. if (!(vnode instanceof VNode)) {
  36088. if ("development" !== 'production' && Array.isArray(vnode)) {
  36089. warn(
  36090. 'Multiple root nodes returned from render function. Render function ' +
  36091. 'should return a single root node.',
  36092. vm
  36093. );
  36094. }
  36095. vnode = createEmptyVNode();
  36096. }
  36097. // set parent
  36098. vnode.parent = _parentVnode;
  36099. return vnode
  36100. };
  36101. // internal render helpers.
  36102. // these are exposed on the instance prototype to reduce generated render
  36103. // code size.
  36104. Vue.prototype._o = markOnce;
  36105. Vue.prototype._n = toNumber;
  36106. Vue.prototype._s = toString;
  36107. Vue.prototype._l = renderList;
  36108. Vue.prototype._t = renderSlot;
  36109. Vue.prototype._q = looseEqual;
  36110. Vue.prototype._i = looseIndexOf;
  36111. Vue.prototype._m = renderStatic;
  36112. Vue.prototype._f = resolveFilter;
  36113. Vue.prototype._k = checkKeyCodes;
  36114. Vue.prototype._b = bindObjectProps;
  36115. Vue.prototype._v = createTextVNode;
  36116. Vue.prototype._e = createEmptyVNode;
  36117. Vue.prototype._u = resolveScopedSlots;
  36118. }
  36119. /* */
  36120. var uid$1 = 0;
  36121. function initMixin (Vue) {
  36122. Vue.prototype._init = function (options) {
  36123. var vm = this;
  36124. // a uid
  36125. vm._uid = uid$1++;
  36126. var startTag, endTag;
  36127. /* istanbul ignore if */
  36128. if ("development" !== 'production' && config.performance && mark) {
  36129. startTag = "vue-perf-init:" + (vm._uid);
  36130. endTag = "vue-perf-end:" + (vm._uid);
  36131. mark(startTag);
  36132. }
  36133. // a flag to avoid this being observed
  36134. vm._isVue = true;
  36135. // merge options
  36136. if (options && options._isComponent) {
  36137. // optimize internal component instantiation
  36138. // since dynamic options merging is pretty slow, and none of the
  36139. // internal component options needs special treatment.
  36140. initInternalComponent(vm, options);
  36141. } else {
  36142. vm.$options = mergeOptions(
  36143. resolveConstructorOptions(vm.constructor),
  36144. options || {},
  36145. vm
  36146. );
  36147. }
  36148. /* istanbul ignore else */
  36149. if (true) {
  36150. initProxy(vm);
  36151. } else {
  36152. vm._renderProxy = vm;
  36153. }
  36154. // expose real self
  36155. vm._self = vm;
  36156. initLifecycle(vm);
  36157. initEvents(vm);
  36158. initRender(vm);
  36159. callHook(vm, 'beforeCreate');
  36160. initInjections(vm); // resolve injections before data/props
  36161. initState(vm);
  36162. initProvide(vm); // resolve provide after data/props
  36163. callHook(vm, 'created');
  36164. /* istanbul ignore if */
  36165. if ("development" !== 'production' && config.performance && mark) {
  36166. vm._name = formatComponentName(vm, false);
  36167. mark(endTag);
  36168. measure(((vm._name) + " init"), startTag, endTag);
  36169. }
  36170. if (vm.$options.el) {
  36171. vm.$mount(vm.$options.el);
  36172. }
  36173. };
  36174. }
  36175. function initInternalComponent (vm, options) {
  36176. var opts = vm.$options = Object.create(vm.constructor.options);
  36177. // doing this because it's faster than dynamic enumeration.
  36178. opts.parent = options.parent;
  36179. opts.propsData = options.propsData;
  36180. opts._parentVnode = options._parentVnode;
  36181. opts._parentListeners = options._parentListeners;
  36182. opts._renderChildren = options._renderChildren;
  36183. opts._componentTag = options._componentTag;
  36184. opts._parentElm = options._parentElm;
  36185. opts._refElm = options._refElm;
  36186. if (options.render) {
  36187. opts.render = options.render;
  36188. opts.staticRenderFns = options.staticRenderFns;
  36189. }
  36190. }
  36191. function resolveConstructorOptions (Ctor) {
  36192. var options = Ctor.options;
  36193. if (Ctor.super) {
  36194. var superOptions = resolveConstructorOptions(Ctor.super);
  36195. var cachedSuperOptions = Ctor.superOptions;
  36196. if (superOptions !== cachedSuperOptions) {
  36197. // super option changed,
  36198. // need to resolve new options.
  36199. Ctor.superOptions = superOptions;
  36200. // check if there are any late-modified/attached options (#4976)
  36201. var modifiedOptions = resolveModifiedOptions(Ctor);
  36202. // update base extend options
  36203. if (modifiedOptions) {
  36204. extend(Ctor.extendOptions, modifiedOptions);
  36205. }
  36206. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  36207. if (options.name) {
  36208. options.components[options.name] = Ctor;
  36209. }
  36210. }
  36211. }
  36212. return options
  36213. }
  36214. function resolveModifiedOptions (Ctor) {
  36215. var modified;
  36216. var latest = Ctor.options;
  36217. var extended = Ctor.extendOptions;
  36218. var sealed = Ctor.sealedOptions;
  36219. for (var key in latest) {
  36220. if (latest[key] !== sealed[key]) {
  36221. if (!modified) { modified = {}; }
  36222. modified[key] = dedupe(latest[key], extended[key], sealed[key]);
  36223. }
  36224. }
  36225. return modified
  36226. }
  36227. function dedupe (latest, extended, sealed) {
  36228. // compare latest and sealed to ensure lifecycle hooks won't be duplicated
  36229. // between merges
  36230. if (Array.isArray(latest)) {
  36231. var res = [];
  36232. sealed = Array.isArray(sealed) ? sealed : [sealed];
  36233. extended = Array.isArray(extended) ? extended : [extended];
  36234. for (var i = 0; i < latest.length; i++) {
  36235. // push original options and not sealed options to exclude duplicated options
  36236. if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) {
  36237. res.push(latest[i]);
  36238. }
  36239. }
  36240. return res
  36241. } else {
  36242. return latest
  36243. }
  36244. }
  36245. function Vue$3 (options) {
  36246. if ("development" !== 'production' &&
  36247. !(this instanceof Vue$3)
  36248. ) {
  36249. warn('Vue is a constructor and should be called with the `new` keyword');
  36250. }
  36251. this._init(options);
  36252. }
  36253. initMixin(Vue$3);
  36254. stateMixin(Vue$3);
  36255. eventsMixin(Vue$3);
  36256. lifecycleMixin(Vue$3);
  36257. renderMixin(Vue$3);
  36258. /* */
  36259. function initUse (Vue) {
  36260. Vue.use = function (plugin) {
  36261. /* istanbul ignore if */
  36262. if (plugin.installed) {
  36263. return this
  36264. }
  36265. // additional parameters
  36266. var args = toArray(arguments, 1);
  36267. args.unshift(this);
  36268. if (typeof plugin.install === 'function') {
  36269. plugin.install.apply(plugin, args);
  36270. } else if (typeof plugin === 'function') {
  36271. plugin.apply(null, args);
  36272. }
  36273. plugin.installed = true;
  36274. return this
  36275. };
  36276. }
  36277. /* */
  36278. function initMixin$1 (Vue) {
  36279. Vue.mixin = function (mixin) {
  36280. this.options = mergeOptions(this.options, mixin);
  36281. return this
  36282. };
  36283. }
  36284. /* */
  36285. function initExtend (Vue) {
  36286. /**
  36287. * Each instance constructor, including Vue, has a unique
  36288. * cid. This enables us to create wrapped "child
  36289. * constructors" for prototypal inheritance and cache them.
  36290. */
  36291. Vue.cid = 0;
  36292. var cid = 1;
  36293. /**
  36294. * Class inheritance
  36295. */
  36296. Vue.extend = function (extendOptions) {
  36297. extendOptions = extendOptions || {};
  36298. var Super = this;
  36299. var SuperId = Super.cid;
  36300. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  36301. if (cachedCtors[SuperId]) {
  36302. return cachedCtors[SuperId]
  36303. }
  36304. var name = extendOptions.name || Super.options.name;
  36305. if (true) {
  36306. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  36307. warn(
  36308. 'Invalid component name: "' + name + '". Component names ' +
  36309. 'can only contain alphanumeric characters and the hyphen, ' +
  36310. 'and must start with a letter.'
  36311. );
  36312. }
  36313. }
  36314. var Sub = function VueComponent (options) {
  36315. this._init(options);
  36316. };
  36317. Sub.prototype = Object.create(Super.prototype);
  36318. Sub.prototype.constructor = Sub;
  36319. Sub.cid = cid++;
  36320. Sub.options = mergeOptions(
  36321. Super.options,
  36322. extendOptions
  36323. );
  36324. Sub['super'] = Super;
  36325. // For props and computed properties, we define the proxy getters on
  36326. // the Vue instances at extension time, on the extended prototype. This
  36327. // avoids Object.defineProperty calls for each instance created.
  36328. if (Sub.options.props) {
  36329. initProps$1(Sub);
  36330. }
  36331. if (Sub.options.computed) {
  36332. initComputed$1(Sub);
  36333. }
  36334. // allow further extension/mixin/plugin usage
  36335. Sub.extend = Super.extend;
  36336. Sub.mixin = Super.mixin;
  36337. Sub.use = Super.use;
  36338. // create asset registers, so extended classes
  36339. // can have their private assets too.
  36340. ASSET_TYPES.forEach(function (type) {
  36341. Sub[type] = Super[type];
  36342. });
  36343. // enable recursive self-lookup
  36344. if (name) {
  36345. Sub.options.components[name] = Sub;
  36346. }
  36347. // keep a reference to the super options at extension time.
  36348. // later at instantiation we can check if Super's options have
  36349. // been updated.
  36350. Sub.superOptions = Super.options;
  36351. Sub.extendOptions = extendOptions;
  36352. Sub.sealedOptions = extend({}, Sub.options);
  36353. // cache constructor
  36354. cachedCtors[SuperId] = Sub;
  36355. return Sub
  36356. };
  36357. }
  36358. function initProps$1 (Comp) {
  36359. var props = Comp.options.props;
  36360. for (var key in props) {
  36361. proxy(Comp.prototype, "_props", key);
  36362. }
  36363. }
  36364. function initComputed$1 (Comp) {
  36365. var computed = Comp.options.computed;
  36366. for (var key in computed) {
  36367. defineComputed(Comp.prototype, key, computed[key]);
  36368. }
  36369. }
  36370. /* */
  36371. function initAssetRegisters (Vue) {
  36372. /**
  36373. * Create asset registration methods.
  36374. */
  36375. ASSET_TYPES.forEach(function (type) {
  36376. Vue[type] = function (
  36377. id,
  36378. definition
  36379. ) {
  36380. if (!definition) {
  36381. return this.options[type + 's'][id]
  36382. } else {
  36383. /* istanbul ignore if */
  36384. if (true) {
  36385. if (type === 'component' && config.isReservedTag(id)) {
  36386. warn(
  36387. 'Do not use built-in or reserved HTML elements as component ' +
  36388. 'id: ' + id
  36389. );
  36390. }
  36391. }
  36392. if (type === 'component' && isPlainObject(definition)) {
  36393. definition.name = definition.name || id;
  36394. definition = this.options._base.extend(definition);
  36395. }
  36396. if (type === 'directive' && typeof definition === 'function') {
  36397. definition = { bind: definition, update: definition };
  36398. }
  36399. this.options[type + 's'][id] = definition;
  36400. return definition
  36401. }
  36402. };
  36403. });
  36404. }
  36405. /* */
  36406. var patternTypes = [String, RegExp];
  36407. function getComponentName (opts) {
  36408. return opts && (opts.Ctor.options.name || opts.tag)
  36409. }
  36410. function matches (pattern, name) {
  36411. if (typeof pattern === 'string') {
  36412. return pattern.split(',').indexOf(name) > -1
  36413. } else if (isRegExp(pattern)) {
  36414. return pattern.test(name)
  36415. }
  36416. /* istanbul ignore next */
  36417. return false
  36418. }
  36419. function pruneCache (cache, current, filter) {
  36420. for (var key in cache) {
  36421. var cachedNode = cache[key];
  36422. if (cachedNode) {
  36423. var name = getComponentName(cachedNode.componentOptions);
  36424. if (name && !filter(name)) {
  36425. if (cachedNode !== current) {
  36426. pruneCacheEntry(cachedNode);
  36427. }
  36428. cache[key] = null;
  36429. }
  36430. }
  36431. }
  36432. }
  36433. function pruneCacheEntry (vnode) {
  36434. if (vnode) {
  36435. vnode.componentInstance.$destroy();
  36436. }
  36437. }
  36438. var KeepAlive = {
  36439. name: 'keep-alive',
  36440. abstract: true,
  36441. props: {
  36442. include: patternTypes,
  36443. exclude: patternTypes
  36444. },
  36445. created: function created () {
  36446. this.cache = Object.create(null);
  36447. },
  36448. destroyed: function destroyed () {
  36449. var this$1 = this;
  36450. for (var key in this$1.cache) {
  36451. pruneCacheEntry(this$1.cache[key]);
  36452. }
  36453. },
  36454. watch: {
  36455. include: function include (val) {
  36456. pruneCache(this.cache, this._vnode, function (name) { return matches(val, name); });
  36457. },
  36458. exclude: function exclude (val) {
  36459. pruneCache(this.cache, this._vnode, function (name) { return !matches(val, name); });
  36460. }
  36461. },
  36462. render: function render () {
  36463. var vnode = getFirstComponentChild(this.$slots.default);
  36464. var componentOptions = vnode && vnode.componentOptions;
  36465. if (componentOptions) {
  36466. // check pattern
  36467. var name = getComponentName(componentOptions);
  36468. if (name && (
  36469. (this.include && !matches(this.include, name)) ||
  36470. (this.exclude && matches(this.exclude, name))
  36471. )) {
  36472. return vnode
  36473. }
  36474. var key = vnode.key == null
  36475. // same constructor may get registered as different local components
  36476. // so cid alone is not enough (#3269)
  36477. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  36478. : vnode.key;
  36479. if (this.cache[key]) {
  36480. vnode.componentInstance = this.cache[key].componentInstance;
  36481. } else {
  36482. this.cache[key] = vnode;
  36483. }
  36484. vnode.data.keepAlive = true;
  36485. }
  36486. return vnode
  36487. }
  36488. };
  36489. var builtInComponents = {
  36490. KeepAlive: KeepAlive
  36491. };
  36492. /* */
  36493. function initGlobalAPI (Vue) {
  36494. // config
  36495. var configDef = {};
  36496. configDef.get = function () { return config; };
  36497. if (true) {
  36498. configDef.set = function () {
  36499. warn(
  36500. 'Do not replace the Vue.config object, set individual fields instead.'
  36501. );
  36502. };
  36503. }
  36504. Object.defineProperty(Vue, 'config', configDef);
  36505. // exposed util methods.
  36506. // NOTE: these are not considered part of the public API - avoid relying on
  36507. // them unless you are aware of the risk.
  36508. Vue.util = {
  36509. warn: warn,
  36510. extend: extend,
  36511. mergeOptions: mergeOptions,
  36512. defineReactive: defineReactive$$1
  36513. };
  36514. Vue.set = set;
  36515. Vue.delete = del;
  36516. Vue.nextTick = nextTick;
  36517. Vue.options = Object.create(null);
  36518. ASSET_TYPES.forEach(function (type) {
  36519. Vue.options[type + 's'] = Object.create(null);
  36520. });
  36521. // this is used to identify the "base" constructor to extend all plain-object
  36522. // components with in Weex's multi-instance scenarios.
  36523. Vue.options._base = Vue;
  36524. extend(Vue.options.components, builtInComponents);
  36525. initUse(Vue);
  36526. initMixin$1(Vue);
  36527. initExtend(Vue);
  36528. initAssetRegisters(Vue);
  36529. }
  36530. initGlobalAPI(Vue$3);
  36531. Object.defineProperty(Vue$3.prototype, '$isServer', {
  36532. get: isServerRendering
  36533. });
  36534. Object.defineProperty(Vue$3.prototype, '$ssrContext', {
  36535. get: function get () {
  36536. /* istanbul ignore next */
  36537. return this.$vnode.ssrContext
  36538. }
  36539. });
  36540. Vue$3.version = '2.3.4';
  36541. /* */
  36542. // these are reserved for web because they are directly compiled away
  36543. // during template compilation
  36544. var isReservedAttr = makeMap('style,class');
  36545. // attributes that should be using props for binding
  36546. var acceptValue = makeMap('input,textarea,option,select');
  36547. var mustUseProp = function (tag, type, attr) {
  36548. return (
  36549. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  36550. (attr === 'selected' && tag === 'option') ||
  36551. (attr === 'checked' && tag === 'input') ||
  36552. (attr === 'muted' && tag === 'video')
  36553. )
  36554. };
  36555. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  36556. var isBooleanAttr = makeMap(
  36557. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  36558. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  36559. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  36560. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  36561. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  36562. 'truespeed,typemustmatch,visible'
  36563. );
  36564. var xlinkNS = 'http://www.w3.org/1999/xlink';
  36565. var isXlink = function (name) {
  36566. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  36567. };
  36568. var getXlinkProp = function (name) {
  36569. return isXlink(name) ? name.slice(6, name.length) : ''
  36570. };
  36571. var isFalsyAttrValue = function (val) {
  36572. return val == null || val === false
  36573. };
  36574. /* */
  36575. function genClassForVnode (vnode) {
  36576. var data = vnode.data;
  36577. var parentNode = vnode;
  36578. var childNode = vnode;
  36579. while (isDef(childNode.componentInstance)) {
  36580. childNode = childNode.componentInstance._vnode;
  36581. if (childNode.data) {
  36582. data = mergeClassData(childNode.data, data);
  36583. }
  36584. }
  36585. while (isDef(parentNode = parentNode.parent)) {
  36586. if (parentNode.data) {
  36587. data = mergeClassData(data, parentNode.data);
  36588. }
  36589. }
  36590. return genClassFromData(data)
  36591. }
  36592. function mergeClassData (child, parent) {
  36593. return {
  36594. staticClass: concat(child.staticClass, parent.staticClass),
  36595. class: isDef(child.class)
  36596. ? [child.class, parent.class]
  36597. : parent.class
  36598. }
  36599. }
  36600. function genClassFromData (data) {
  36601. var dynamicClass = data.class;
  36602. var staticClass = data.staticClass;
  36603. if (isDef(staticClass) || isDef(dynamicClass)) {
  36604. return concat(staticClass, stringifyClass(dynamicClass))
  36605. }
  36606. /* istanbul ignore next */
  36607. return ''
  36608. }
  36609. function concat (a, b) {
  36610. return a ? b ? (a + ' ' + b) : a : (b || '')
  36611. }
  36612. function stringifyClass (value) {
  36613. if (isUndef(value)) {
  36614. return ''
  36615. }
  36616. if (typeof value === 'string') {
  36617. return value
  36618. }
  36619. var res = '';
  36620. if (Array.isArray(value)) {
  36621. var stringified;
  36622. for (var i = 0, l = value.length; i < l; i++) {
  36623. if (isDef(value[i])) {
  36624. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  36625. res += stringified + ' ';
  36626. }
  36627. }
  36628. }
  36629. return res.slice(0, -1)
  36630. }
  36631. if (isObject(value)) {
  36632. for (var key in value) {
  36633. if (value[key]) { res += key + ' '; }
  36634. }
  36635. return res.slice(0, -1)
  36636. }
  36637. /* istanbul ignore next */
  36638. return res
  36639. }
  36640. /* */
  36641. var namespaceMap = {
  36642. svg: 'http://www.w3.org/2000/svg',
  36643. math: 'http://www.w3.org/1998/Math/MathML'
  36644. };
  36645. var isHTMLTag = makeMap(
  36646. 'html,body,base,head,link,meta,style,title,' +
  36647. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  36648. 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' +
  36649. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  36650. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  36651. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  36652. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  36653. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  36654. 'output,progress,select,textarea,' +
  36655. 'details,dialog,menu,menuitem,summary,' +
  36656. 'content,element,shadow,template'
  36657. );
  36658. // this map is intentionally selective, only covering SVG elements that may
  36659. // contain child elements.
  36660. var isSVG = makeMap(
  36661. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  36662. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  36663. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  36664. true
  36665. );
  36666. var isPreTag = function (tag) { return tag === 'pre'; };
  36667. var isReservedTag = function (tag) {
  36668. return isHTMLTag(tag) || isSVG(tag)
  36669. };
  36670. function getTagNamespace (tag) {
  36671. if (isSVG(tag)) {
  36672. return 'svg'
  36673. }
  36674. // basic support for MathML
  36675. // note it doesn't support other MathML elements being component roots
  36676. if (tag === 'math') {
  36677. return 'math'
  36678. }
  36679. }
  36680. var unknownElementCache = Object.create(null);
  36681. function isUnknownElement (tag) {
  36682. /* istanbul ignore if */
  36683. if (!inBrowser) {
  36684. return true
  36685. }
  36686. if (isReservedTag(tag)) {
  36687. return false
  36688. }
  36689. tag = tag.toLowerCase();
  36690. /* istanbul ignore if */
  36691. if (unknownElementCache[tag] != null) {
  36692. return unknownElementCache[tag]
  36693. }
  36694. var el = document.createElement(tag);
  36695. if (tag.indexOf('-') > -1) {
  36696. // http://stackoverflow.com/a/28210364/1070244
  36697. return (unknownElementCache[tag] = (
  36698. el.constructor === window.HTMLUnknownElement ||
  36699. el.constructor === window.HTMLElement
  36700. ))
  36701. } else {
  36702. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  36703. }
  36704. }
  36705. /* */
  36706. /**
  36707. * Query an element selector if it's not an element already.
  36708. */
  36709. function query (el) {
  36710. if (typeof el === 'string') {
  36711. var selected = document.querySelector(el);
  36712. if (!selected) {
  36713. "development" !== 'production' && warn(
  36714. 'Cannot find element: ' + el
  36715. );
  36716. return document.createElement('div')
  36717. }
  36718. return selected
  36719. } else {
  36720. return el
  36721. }
  36722. }
  36723. /* */
  36724. function createElement$1 (tagName, vnode) {
  36725. var elm = document.createElement(tagName);
  36726. if (tagName !== 'select') {
  36727. return elm
  36728. }
  36729. // false or null will remove the attribute but undefined will not
  36730. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  36731. elm.setAttribute('multiple', 'multiple');
  36732. }
  36733. return elm
  36734. }
  36735. function createElementNS (namespace, tagName) {
  36736. return document.createElementNS(namespaceMap[namespace], tagName)
  36737. }
  36738. function createTextNode (text) {
  36739. return document.createTextNode(text)
  36740. }
  36741. function createComment (text) {
  36742. return document.createComment(text)
  36743. }
  36744. function insertBefore (parentNode, newNode, referenceNode) {
  36745. parentNode.insertBefore(newNode, referenceNode);
  36746. }
  36747. function removeChild (node, child) {
  36748. node.removeChild(child);
  36749. }
  36750. function appendChild (node, child) {
  36751. node.appendChild(child);
  36752. }
  36753. function parentNode (node) {
  36754. return node.parentNode
  36755. }
  36756. function nextSibling (node) {
  36757. return node.nextSibling
  36758. }
  36759. function tagName (node) {
  36760. return node.tagName
  36761. }
  36762. function setTextContent (node, text) {
  36763. node.textContent = text;
  36764. }
  36765. function setAttribute (node, key, val) {
  36766. node.setAttribute(key, val);
  36767. }
  36768. var nodeOps = Object.freeze({
  36769. createElement: createElement$1,
  36770. createElementNS: createElementNS,
  36771. createTextNode: createTextNode,
  36772. createComment: createComment,
  36773. insertBefore: insertBefore,
  36774. removeChild: removeChild,
  36775. appendChild: appendChild,
  36776. parentNode: parentNode,
  36777. nextSibling: nextSibling,
  36778. tagName: tagName,
  36779. setTextContent: setTextContent,
  36780. setAttribute: setAttribute
  36781. });
  36782. /* */
  36783. var ref = {
  36784. create: function create (_, vnode) {
  36785. registerRef(vnode);
  36786. },
  36787. update: function update (oldVnode, vnode) {
  36788. if (oldVnode.data.ref !== vnode.data.ref) {
  36789. registerRef(oldVnode, true);
  36790. registerRef(vnode);
  36791. }
  36792. },
  36793. destroy: function destroy (vnode) {
  36794. registerRef(vnode, true);
  36795. }
  36796. };
  36797. function registerRef (vnode, isRemoval) {
  36798. var key = vnode.data.ref;
  36799. if (!key) { return }
  36800. var vm = vnode.context;
  36801. var ref = vnode.componentInstance || vnode.elm;
  36802. var refs = vm.$refs;
  36803. if (isRemoval) {
  36804. if (Array.isArray(refs[key])) {
  36805. remove(refs[key], ref);
  36806. } else if (refs[key] === ref) {
  36807. refs[key] = undefined;
  36808. }
  36809. } else {
  36810. if (vnode.data.refInFor) {
  36811. if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) {
  36812. refs[key].push(ref);
  36813. } else {
  36814. refs[key] = [ref];
  36815. }
  36816. } else {
  36817. refs[key] = ref;
  36818. }
  36819. }
  36820. }
  36821. /**
  36822. * Virtual DOM patching algorithm based on Snabbdom by
  36823. * Simon Friis Vindum (@paldepind)
  36824. * Licensed under the MIT License
  36825. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  36826. *
  36827. * modified by Evan You (@yyx990803)
  36828. *
  36829. /*
  36830. * Not type-checking this because this file is perf-critical and the cost
  36831. * of making flow understand it is not worth it.
  36832. */
  36833. var emptyNode = new VNode('', {}, []);
  36834. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  36835. function sameVnode (a, b) {
  36836. return (
  36837. a.key === b.key &&
  36838. a.tag === b.tag &&
  36839. a.isComment === b.isComment &&
  36840. isDef(a.data) === isDef(b.data) &&
  36841. sameInputType(a, b)
  36842. )
  36843. }
  36844. // Some browsers do not support dynamically changing type for <input>
  36845. // so they need to be treated as different nodes
  36846. function sameInputType (a, b) {
  36847. if (a.tag !== 'input') { return true }
  36848. var i;
  36849. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  36850. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  36851. return typeA === typeB
  36852. }
  36853. function createKeyToOldIdx (children, beginIdx, endIdx) {
  36854. var i, key;
  36855. var map = {};
  36856. for (i = beginIdx; i <= endIdx; ++i) {
  36857. key = children[i].key;
  36858. if (isDef(key)) { map[key] = i; }
  36859. }
  36860. return map
  36861. }
  36862. function createPatchFunction (backend) {
  36863. var i, j;
  36864. var cbs = {};
  36865. var modules = backend.modules;
  36866. var nodeOps = backend.nodeOps;
  36867. for (i = 0; i < hooks.length; ++i) {
  36868. cbs[hooks[i]] = [];
  36869. for (j = 0; j < modules.length; ++j) {
  36870. if (isDef(modules[j][hooks[i]])) {
  36871. cbs[hooks[i]].push(modules[j][hooks[i]]);
  36872. }
  36873. }
  36874. }
  36875. function emptyNodeAt (elm) {
  36876. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  36877. }
  36878. function createRmCb (childElm, listeners) {
  36879. function remove$$1 () {
  36880. if (--remove$$1.listeners === 0) {
  36881. removeNode(childElm);
  36882. }
  36883. }
  36884. remove$$1.listeners = listeners;
  36885. return remove$$1
  36886. }
  36887. function removeNode (el) {
  36888. var parent = nodeOps.parentNode(el);
  36889. // element may have already been removed due to v-html / v-text
  36890. if (isDef(parent)) {
  36891. nodeOps.removeChild(parent, el);
  36892. }
  36893. }
  36894. var inPre = 0;
  36895. function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) {
  36896. vnode.isRootInsert = !nested; // for transition enter check
  36897. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  36898. return
  36899. }
  36900. var data = vnode.data;
  36901. var children = vnode.children;
  36902. var tag = vnode.tag;
  36903. if (isDef(tag)) {
  36904. if (true) {
  36905. if (data && data.pre) {
  36906. inPre++;
  36907. }
  36908. if (
  36909. !inPre &&
  36910. !vnode.ns &&
  36911. !(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) &&
  36912. config.isUnknownElement(tag)
  36913. ) {
  36914. warn(
  36915. 'Unknown custom element: <' + tag + '> - did you ' +
  36916. 'register the component correctly? For recursive components, ' +
  36917. 'make sure to provide the "name" option.',
  36918. vnode.context
  36919. );
  36920. }
  36921. }
  36922. vnode.elm = vnode.ns
  36923. ? nodeOps.createElementNS(vnode.ns, tag)
  36924. : nodeOps.createElement(tag, vnode);
  36925. setScope(vnode);
  36926. /* istanbul ignore if */
  36927. {
  36928. createChildren(vnode, children, insertedVnodeQueue);
  36929. if (isDef(data)) {
  36930. invokeCreateHooks(vnode, insertedVnodeQueue);
  36931. }
  36932. insert(parentElm, vnode.elm, refElm);
  36933. }
  36934. if ("development" !== 'production' && data && data.pre) {
  36935. inPre--;
  36936. }
  36937. } else if (isTrue(vnode.isComment)) {
  36938. vnode.elm = nodeOps.createComment(vnode.text);
  36939. insert(parentElm, vnode.elm, refElm);
  36940. } else {
  36941. vnode.elm = nodeOps.createTextNode(vnode.text);
  36942. insert(parentElm, vnode.elm, refElm);
  36943. }
  36944. }
  36945. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  36946. var i = vnode.data;
  36947. if (isDef(i)) {
  36948. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  36949. if (isDef(i = i.hook) && isDef(i = i.init)) {
  36950. i(vnode, false /* hydrating */, parentElm, refElm);
  36951. }
  36952. // after calling the init hook, if the vnode is a child component
  36953. // it should've created a child instance and mounted it. the child
  36954. // component also has set the placeholder vnode's elm.
  36955. // in that case we can just return the element and be done.
  36956. if (isDef(vnode.componentInstance)) {
  36957. initComponent(vnode, insertedVnodeQueue);
  36958. if (isTrue(isReactivated)) {
  36959. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  36960. }
  36961. return true
  36962. }
  36963. }
  36964. }
  36965. function initComponent (vnode, insertedVnodeQueue) {
  36966. if (isDef(vnode.data.pendingInsert)) {
  36967. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  36968. vnode.data.pendingInsert = null;
  36969. }
  36970. vnode.elm = vnode.componentInstance.$el;
  36971. if (isPatchable(vnode)) {
  36972. invokeCreateHooks(vnode, insertedVnodeQueue);
  36973. setScope(vnode);
  36974. } else {
  36975. // empty component root.
  36976. // skip all element-related modules except for ref (#3455)
  36977. registerRef(vnode);
  36978. // make sure to invoke the insert hook
  36979. insertedVnodeQueue.push(vnode);
  36980. }
  36981. }
  36982. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  36983. var i;
  36984. // hack for #4339: a reactivated component with inner transition
  36985. // does not trigger because the inner node's created hooks are not called
  36986. // again. It's not ideal to involve module-specific logic in here but
  36987. // there doesn't seem to be a better way to do it.
  36988. var innerNode = vnode;
  36989. while (innerNode.componentInstance) {
  36990. innerNode = innerNode.componentInstance._vnode;
  36991. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  36992. for (i = 0; i < cbs.activate.length; ++i) {
  36993. cbs.activate[i](emptyNode, innerNode);
  36994. }
  36995. insertedVnodeQueue.push(innerNode);
  36996. break
  36997. }
  36998. }
  36999. // unlike a newly created component,
  37000. // a reactivated keep-alive component doesn't insert itself
  37001. insert(parentElm, vnode.elm, refElm);
  37002. }
  37003. function insert (parent, elm, ref) {
  37004. if (isDef(parent)) {
  37005. if (isDef(ref)) {
  37006. if (ref.parentNode === parent) {
  37007. nodeOps.insertBefore(parent, elm, ref);
  37008. }
  37009. } else {
  37010. nodeOps.appendChild(parent, elm);
  37011. }
  37012. }
  37013. }
  37014. function createChildren (vnode, children, insertedVnodeQueue) {
  37015. if (Array.isArray(children)) {
  37016. for (var i = 0; i < children.length; ++i) {
  37017. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
  37018. }
  37019. } else if (isPrimitive(vnode.text)) {
  37020. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
  37021. }
  37022. }
  37023. function isPatchable (vnode) {
  37024. while (vnode.componentInstance) {
  37025. vnode = vnode.componentInstance._vnode;
  37026. }
  37027. return isDef(vnode.tag)
  37028. }
  37029. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  37030. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  37031. cbs.create[i$1](emptyNode, vnode);
  37032. }
  37033. i = vnode.data.hook; // Reuse variable
  37034. if (isDef(i)) {
  37035. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  37036. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  37037. }
  37038. }
  37039. // set scope id attribute for scoped CSS.
  37040. // this is implemented as a special case to avoid the overhead
  37041. // of going through the normal attribute patching process.
  37042. function setScope (vnode) {
  37043. var i;
  37044. var ancestor = vnode;
  37045. while (ancestor) {
  37046. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  37047. nodeOps.setAttribute(vnode.elm, i, '');
  37048. }
  37049. ancestor = ancestor.parent;
  37050. }
  37051. // for slot content they should also get the scopeId from the host instance.
  37052. if (isDef(i = activeInstance) &&
  37053. i !== vnode.context &&
  37054. isDef(i = i.$options._scopeId)
  37055. ) {
  37056. nodeOps.setAttribute(vnode.elm, i, '');
  37057. }
  37058. }
  37059. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  37060. for (; startIdx <= endIdx; ++startIdx) {
  37061. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm);
  37062. }
  37063. }
  37064. function invokeDestroyHook (vnode) {
  37065. var i, j;
  37066. var data = vnode.data;
  37067. if (isDef(data)) {
  37068. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  37069. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  37070. }
  37071. if (isDef(i = vnode.children)) {
  37072. for (j = 0; j < vnode.children.length; ++j) {
  37073. invokeDestroyHook(vnode.children[j]);
  37074. }
  37075. }
  37076. }
  37077. function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
  37078. for (; startIdx <= endIdx; ++startIdx) {
  37079. var ch = vnodes[startIdx];
  37080. if (isDef(ch)) {
  37081. if (isDef(ch.tag)) {
  37082. removeAndInvokeRemoveHook(ch);
  37083. invokeDestroyHook(ch);
  37084. } else { // Text node
  37085. removeNode(ch.elm);
  37086. }
  37087. }
  37088. }
  37089. }
  37090. function removeAndInvokeRemoveHook (vnode, rm) {
  37091. if (isDef(rm) || isDef(vnode.data)) {
  37092. var i;
  37093. var listeners = cbs.remove.length + 1;
  37094. if (isDef(rm)) {
  37095. // we have a recursively passed down rm callback
  37096. // increase the listeners count
  37097. rm.listeners += listeners;
  37098. } else {
  37099. // directly removing
  37100. rm = createRmCb(vnode.elm, listeners);
  37101. }
  37102. // recursively invoke hooks on child component root node
  37103. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  37104. removeAndInvokeRemoveHook(i, rm);
  37105. }
  37106. for (i = 0; i < cbs.remove.length; ++i) {
  37107. cbs.remove[i](vnode, rm);
  37108. }
  37109. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  37110. i(vnode, rm);
  37111. } else {
  37112. rm();
  37113. }
  37114. } else {
  37115. removeNode(vnode.elm);
  37116. }
  37117. }
  37118. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  37119. var oldStartIdx = 0;
  37120. var newStartIdx = 0;
  37121. var oldEndIdx = oldCh.length - 1;
  37122. var oldStartVnode = oldCh[0];
  37123. var oldEndVnode = oldCh[oldEndIdx];
  37124. var newEndIdx = newCh.length - 1;
  37125. var newStartVnode = newCh[0];
  37126. var newEndVnode = newCh[newEndIdx];
  37127. var oldKeyToIdx, idxInOld, elmToMove, refElm;
  37128. // removeOnly is a special flag used only by <transition-group>
  37129. // to ensure removed elements stay in correct relative positions
  37130. // during leaving transitions
  37131. var canMove = !removeOnly;
  37132. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  37133. if (isUndef(oldStartVnode)) {
  37134. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  37135. } else if (isUndef(oldEndVnode)) {
  37136. oldEndVnode = oldCh[--oldEndIdx];
  37137. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  37138. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
  37139. oldStartVnode = oldCh[++oldStartIdx];
  37140. newStartVnode = newCh[++newStartIdx];
  37141. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  37142. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
  37143. oldEndVnode = oldCh[--oldEndIdx];
  37144. newEndVnode = newCh[--newEndIdx];
  37145. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  37146. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
  37147. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  37148. oldStartVnode = oldCh[++oldStartIdx];
  37149. newEndVnode = newCh[--newEndIdx];
  37150. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  37151. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
  37152. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  37153. oldEndVnode = oldCh[--oldEndIdx];
  37154. newStartVnode = newCh[++newStartIdx];
  37155. } else {
  37156. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  37157. idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
  37158. if (isUndef(idxInOld)) { // New element
  37159. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  37160. newStartVnode = newCh[++newStartIdx];
  37161. } else {
  37162. elmToMove = oldCh[idxInOld];
  37163. /* istanbul ignore if */
  37164. if ("development" !== 'production' && !elmToMove) {
  37165. warn(
  37166. 'It seems there are duplicate keys that is causing an update error. ' +
  37167. 'Make sure each v-for item has a unique key.'
  37168. );
  37169. }
  37170. if (sameVnode(elmToMove, newStartVnode)) {
  37171. patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
  37172. oldCh[idxInOld] = undefined;
  37173. canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm);
  37174. newStartVnode = newCh[++newStartIdx];
  37175. } else {
  37176. // same key but different element. treat as new element
  37177. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  37178. newStartVnode = newCh[++newStartIdx];
  37179. }
  37180. }
  37181. }
  37182. }
  37183. if (oldStartIdx > oldEndIdx) {
  37184. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  37185. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  37186. } else if (newStartIdx > newEndIdx) {
  37187. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  37188. }
  37189. }
  37190. function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
  37191. if (oldVnode === vnode) {
  37192. return
  37193. }
  37194. // reuse element for static trees.
  37195. // note we only do this if the vnode is cloned -
  37196. // if the new node is not cloned it means the render functions have been
  37197. // reset by the hot-reload-api and we need to do a proper re-render.
  37198. if (isTrue(vnode.isStatic) &&
  37199. isTrue(oldVnode.isStatic) &&
  37200. vnode.key === oldVnode.key &&
  37201. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  37202. ) {
  37203. vnode.elm = oldVnode.elm;
  37204. vnode.componentInstance = oldVnode.componentInstance;
  37205. return
  37206. }
  37207. var i;
  37208. var data = vnode.data;
  37209. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  37210. i(oldVnode, vnode);
  37211. }
  37212. var elm = vnode.elm = oldVnode.elm;
  37213. var oldCh = oldVnode.children;
  37214. var ch = vnode.children;
  37215. if (isDef(data) && isPatchable(vnode)) {
  37216. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  37217. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  37218. }
  37219. if (isUndef(vnode.text)) {
  37220. if (isDef(oldCh) && isDef(ch)) {
  37221. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  37222. } else if (isDef(ch)) {
  37223. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  37224. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  37225. } else if (isDef(oldCh)) {
  37226. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  37227. } else if (isDef(oldVnode.text)) {
  37228. nodeOps.setTextContent(elm, '');
  37229. }
  37230. } else if (oldVnode.text !== vnode.text) {
  37231. nodeOps.setTextContent(elm, vnode.text);
  37232. }
  37233. if (isDef(data)) {
  37234. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  37235. }
  37236. }
  37237. function invokeInsertHook (vnode, queue, initial) {
  37238. // delay insert hooks for component root nodes, invoke them after the
  37239. // element is really inserted
  37240. if (isTrue(initial) && isDef(vnode.parent)) {
  37241. vnode.parent.data.pendingInsert = queue;
  37242. } else {
  37243. for (var i = 0; i < queue.length; ++i) {
  37244. queue[i].data.hook.insert(queue[i]);
  37245. }
  37246. }
  37247. }
  37248. var bailed = false;
  37249. // list of modules that can skip create hook during hydration because they
  37250. // are already rendered on the client or has no need for initialization
  37251. var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key');
  37252. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  37253. function hydrate (elm, vnode, insertedVnodeQueue) {
  37254. if (true) {
  37255. if (!assertNodeMatch(elm, vnode)) {
  37256. return false
  37257. }
  37258. }
  37259. vnode.elm = elm;
  37260. var tag = vnode.tag;
  37261. var data = vnode.data;
  37262. var children = vnode.children;
  37263. if (isDef(data)) {
  37264. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  37265. if (isDef(i = vnode.componentInstance)) {
  37266. // child component. it should have hydrated its own tree.
  37267. initComponent(vnode, insertedVnodeQueue);
  37268. return true
  37269. }
  37270. }
  37271. if (isDef(tag)) {
  37272. if (isDef(children)) {
  37273. // empty element, allow client to pick up and populate children
  37274. if (!elm.hasChildNodes()) {
  37275. createChildren(vnode, children, insertedVnodeQueue);
  37276. } else {
  37277. var childrenMatch = true;
  37278. var childNode = elm.firstChild;
  37279. for (var i$1 = 0; i$1 < children.length; i$1++) {
  37280. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
  37281. childrenMatch = false;
  37282. break
  37283. }
  37284. childNode = childNode.nextSibling;
  37285. }
  37286. // if childNode is not null, it means the actual childNodes list is
  37287. // longer than the virtual children list.
  37288. if (!childrenMatch || childNode) {
  37289. if ("development" !== 'production' &&
  37290. typeof console !== 'undefined' &&
  37291. !bailed
  37292. ) {
  37293. bailed = true;
  37294. console.warn('Parent: ', elm);
  37295. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  37296. }
  37297. return false
  37298. }
  37299. }
  37300. }
  37301. if (isDef(data)) {
  37302. for (var key in data) {
  37303. if (!isRenderedModule(key)) {
  37304. invokeCreateHooks(vnode, insertedVnodeQueue);
  37305. break
  37306. }
  37307. }
  37308. }
  37309. } else if (elm.data !== vnode.text) {
  37310. elm.data = vnode.text;
  37311. }
  37312. return true
  37313. }
  37314. function assertNodeMatch (node, vnode) {
  37315. if (isDef(vnode.tag)) {
  37316. return (
  37317. vnode.tag.indexOf('vue-component') === 0 ||
  37318. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  37319. )
  37320. } else {
  37321. return node.nodeType === (vnode.isComment ? 8 : 3)
  37322. }
  37323. }
  37324. return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) {
  37325. if (isUndef(vnode)) {
  37326. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  37327. return
  37328. }
  37329. var isInitialPatch = false;
  37330. var insertedVnodeQueue = [];
  37331. if (isUndef(oldVnode)) {
  37332. // empty mount (likely as component), create new root element
  37333. isInitialPatch = true;
  37334. createElm(vnode, insertedVnodeQueue, parentElm, refElm);
  37335. } else {
  37336. var isRealElement = isDef(oldVnode.nodeType);
  37337. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  37338. // patch existing root node
  37339. patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
  37340. } else {
  37341. if (isRealElement) {
  37342. // mounting to a real element
  37343. // check if this is server-rendered content and if we can perform
  37344. // a successful hydration.
  37345. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  37346. oldVnode.removeAttribute(SSR_ATTR);
  37347. hydrating = true;
  37348. }
  37349. if (isTrue(hydrating)) {
  37350. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  37351. invokeInsertHook(vnode, insertedVnodeQueue, true);
  37352. return oldVnode
  37353. } else if (true) {
  37354. warn(
  37355. 'The client-side rendered virtual DOM tree is not matching ' +
  37356. 'server-rendered content. This is likely caused by incorrect ' +
  37357. 'HTML markup, for example nesting block-level elements inside ' +
  37358. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  37359. 'full client-side render.'
  37360. );
  37361. }
  37362. }
  37363. // either not server-rendered, or hydration failed.
  37364. // create an empty node and replace it
  37365. oldVnode = emptyNodeAt(oldVnode);
  37366. }
  37367. // replacing existing element
  37368. var oldElm = oldVnode.elm;
  37369. var parentElm$1 = nodeOps.parentNode(oldElm);
  37370. createElm(
  37371. vnode,
  37372. insertedVnodeQueue,
  37373. // extremely rare edge case: do not insert if old element is in a
  37374. // leaving transition. Only happens when combining transition +
  37375. // keep-alive + HOCs. (#4590)
  37376. oldElm._leaveCb ? null : parentElm$1,
  37377. nodeOps.nextSibling(oldElm)
  37378. );
  37379. if (isDef(vnode.parent)) {
  37380. // component root element replaced.
  37381. // update parent placeholder node element, recursively
  37382. var ancestor = vnode.parent;
  37383. while (ancestor) {
  37384. ancestor.elm = vnode.elm;
  37385. ancestor = ancestor.parent;
  37386. }
  37387. if (isPatchable(vnode)) {
  37388. for (var i = 0; i < cbs.create.length; ++i) {
  37389. cbs.create[i](emptyNode, vnode.parent);
  37390. }
  37391. }
  37392. }
  37393. if (isDef(parentElm$1)) {
  37394. removeVnodes(parentElm$1, [oldVnode], 0, 0);
  37395. } else if (isDef(oldVnode.tag)) {
  37396. invokeDestroyHook(oldVnode);
  37397. }
  37398. }
  37399. }
  37400. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  37401. return vnode.elm
  37402. }
  37403. }
  37404. /* */
  37405. var directives = {
  37406. create: updateDirectives,
  37407. update: updateDirectives,
  37408. destroy: function unbindDirectives (vnode) {
  37409. updateDirectives(vnode, emptyNode);
  37410. }
  37411. };
  37412. function updateDirectives (oldVnode, vnode) {
  37413. if (oldVnode.data.directives || vnode.data.directives) {
  37414. _update(oldVnode, vnode);
  37415. }
  37416. }
  37417. function _update (oldVnode, vnode) {
  37418. var isCreate = oldVnode === emptyNode;
  37419. var isDestroy = vnode === emptyNode;
  37420. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  37421. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  37422. var dirsWithInsert = [];
  37423. var dirsWithPostpatch = [];
  37424. var key, oldDir, dir;
  37425. for (key in newDirs) {
  37426. oldDir = oldDirs[key];
  37427. dir = newDirs[key];
  37428. if (!oldDir) {
  37429. // new directive, bind
  37430. callHook$1(dir, 'bind', vnode, oldVnode);
  37431. if (dir.def && dir.def.inserted) {
  37432. dirsWithInsert.push(dir);
  37433. }
  37434. } else {
  37435. // existing directive, update
  37436. dir.oldValue = oldDir.value;
  37437. callHook$1(dir, 'update', vnode, oldVnode);
  37438. if (dir.def && dir.def.componentUpdated) {
  37439. dirsWithPostpatch.push(dir);
  37440. }
  37441. }
  37442. }
  37443. if (dirsWithInsert.length) {
  37444. var callInsert = function () {
  37445. for (var i = 0; i < dirsWithInsert.length; i++) {
  37446. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  37447. }
  37448. };
  37449. if (isCreate) {
  37450. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert);
  37451. } else {
  37452. callInsert();
  37453. }
  37454. }
  37455. if (dirsWithPostpatch.length) {
  37456. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () {
  37457. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  37458. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  37459. }
  37460. });
  37461. }
  37462. if (!isCreate) {
  37463. for (key in oldDirs) {
  37464. if (!newDirs[key]) {
  37465. // no longer present, unbind
  37466. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  37467. }
  37468. }
  37469. }
  37470. }
  37471. var emptyModifiers = Object.create(null);
  37472. function normalizeDirectives$1 (
  37473. dirs,
  37474. vm
  37475. ) {
  37476. var res = Object.create(null);
  37477. if (!dirs) {
  37478. return res
  37479. }
  37480. var i, dir;
  37481. for (i = 0; i < dirs.length; i++) {
  37482. dir = dirs[i];
  37483. if (!dir.modifiers) {
  37484. dir.modifiers = emptyModifiers;
  37485. }
  37486. res[getRawDirName(dir)] = dir;
  37487. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  37488. }
  37489. return res
  37490. }
  37491. function getRawDirName (dir) {
  37492. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  37493. }
  37494. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  37495. var fn = dir.def && dir.def[hook];
  37496. if (fn) {
  37497. try {
  37498. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  37499. } catch (e) {
  37500. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  37501. }
  37502. }
  37503. }
  37504. var baseModules = [
  37505. ref,
  37506. directives
  37507. ];
  37508. /* */
  37509. function updateAttrs (oldVnode, vnode) {
  37510. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  37511. return
  37512. }
  37513. var key, cur, old;
  37514. var elm = vnode.elm;
  37515. var oldAttrs = oldVnode.data.attrs || {};
  37516. var attrs = vnode.data.attrs || {};
  37517. // clone observed objects, as the user probably wants to mutate it
  37518. if (isDef(attrs.__ob__)) {
  37519. attrs = vnode.data.attrs = extend({}, attrs);
  37520. }
  37521. for (key in attrs) {
  37522. cur = attrs[key];
  37523. old = oldAttrs[key];
  37524. if (old !== cur) {
  37525. setAttr(elm, key, cur);
  37526. }
  37527. }
  37528. // #4391: in IE9, setting type can reset value for input[type=radio]
  37529. /* istanbul ignore if */
  37530. if (isIE9 && attrs.value !== oldAttrs.value) {
  37531. setAttr(elm, 'value', attrs.value);
  37532. }
  37533. for (key in oldAttrs) {
  37534. if (isUndef(attrs[key])) {
  37535. if (isXlink(key)) {
  37536. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  37537. } else if (!isEnumeratedAttr(key)) {
  37538. elm.removeAttribute(key);
  37539. }
  37540. }
  37541. }
  37542. }
  37543. function setAttr (el, key, value) {
  37544. if (isBooleanAttr(key)) {
  37545. // set attribute for blank value
  37546. // e.g. <option disabled>Select one</option>
  37547. if (isFalsyAttrValue(value)) {
  37548. el.removeAttribute(key);
  37549. } else {
  37550. el.setAttribute(key, key);
  37551. }
  37552. } else if (isEnumeratedAttr(key)) {
  37553. el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
  37554. } else if (isXlink(key)) {
  37555. if (isFalsyAttrValue(value)) {
  37556. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  37557. } else {
  37558. el.setAttributeNS(xlinkNS, key, value);
  37559. }
  37560. } else {
  37561. if (isFalsyAttrValue(value)) {
  37562. el.removeAttribute(key);
  37563. } else {
  37564. el.setAttribute(key, value);
  37565. }
  37566. }
  37567. }
  37568. var attrs = {
  37569. create: updateAttrs,
  37570. update: updateAttrs
  37571. };
  37572. /* */
  37573. function updateClass (oldVnode, vnode) {
  37574. var el = vnode.elm;
  37575. var data = vnode.data;
  37576. var oldData = oldVnode.data;
  37577. if (
  37578. isUndef(data.staticClass) &&
  37579. isUndef(data.class) && (
  37580. isUndef(oldData) || (
  37581. isUndef(oldData.staticClass) &&
  37582. isUndef(oldData.class)
  37583. )
  37584. )
  37585. ) {
  37586. return
  37587. }
  37588. var cls = genClassForVnode(vnode);
  37589. // handle transition classes
  37590. var transitionClass = el._transitionClasses;
  37591. if (isDef(transitionClass)) {
  37592. cls = concat(cls, stringifyClass(transitionClass));
  37593. }
  37594. // set the class
  37595. if (cls !== el._prevClass) {
  37596. el.setAttribute('class', cls);
  37597. el._prevClass = cls;
  37598. }
  37599. }
  37600. var klass = {
  37601. create: updateClass,
  37602. update: updateClass
  37603. };
  37604. /* */
  37605. var validDivisionCharRE = /[\w).+\-_$\]]/;
  37606. function parseFilters (exp) {
  37607. var inSingle = false;
  37608. var inDouble = false;
  37609. var inTemplateString = false;
  37610. var inRegex = false;
  37611. var curly = 0;
  37612. var square = 0;
  37613. var paren = 0;
  37614. var lastFilterIndex = 0;
  37615. var c, prev, i, expression, filters;
  37616. for (i = 0; i < exp.length; i++) {
  37617. prev = c;
  37618. c = exp.charCodeAt(i);
  37619. if (inSingle) {
  37620. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  37621. } else if (inDouble) {
  37622. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  37623. } else if (inTemplateString) {
  37624. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  37625. } else if (inRegex) {
  37626. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  37627. } else if (
  37628. c === 0x7C && // pipe
  37629. exp.charCodeAt(i + 1) !== 0x7C &&
  37630. exp.charCodeAt(i - 1) !== 0x7C &&
  37631. !curly && !square && !paren
  37632. ) {
  37633. if (expression === undefined) {
  37634. // first filter, end of expression
  37635. lastFilterIndex = i + 1;
  37636. expression = exp.slice(0, i).trim();
  37637. } else {
  37638. pushFilter();
  37639. }
  37640. } else {
  37641. switch (c) {
  37642. case 0x22: inDouble = true; break // "
  37643. case 0x27: inSingle = true; break // '
  37644. case 0x60: inTemplateString = true; break // `
  37645. case 0x28: paren++; break // (
  37646. case 0x29: paren--; break // )
  37647. case 0x5B: square++; break // [
  37648. case 0x5D: square--; break // ]
  37649. case 0x7B: curly++; break // {
  37650. case 0x7D: curly--; break // }
  37651. }
  37652. if (c === 0x2f) { // /
  37653. var j = i - 1;
  37654. var p = (void 0);
  37655. // find first non-whitespace prev char
  37656. for (; j >= 0; j--) {
  37657. p = exp.charAt(j);
  37658. if (p !== ' ') { break }
  37659. }
  37660. if (!p || !validDivisionCharRE.test(p)) {
  37661. inRegex = true;
  37662. }
  37663. }
  37664. }
  37665. }
  37666. if (expression === undefined) {
  37667. expression = exp.slice(0, i).trim();
  37668. } else if (lastFilterIndex !== 0) {
  37669. pushFilter();
  37670. }
  37671. function pushFilter () {
  37672. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  37673. lastFilterIndex = i + 1;
  37674. }
  37675. if (filters) {
  37676. for (i = 0; i < filters.length; i++) {
  37677. expression = wrapFilter(expression, filters[i]);
  37678. }
  37679. }
  37680. return expression
  37681. }
  37682. function wrapFilter (exp, filter) {
  37683. var i = filter.indexOf('(');
  37684. if (i < 0) {
  37685. // _f: resolveFilter
  37686. return ("_f(\"" + filter + "\")(" + exp + ")")
  37687. } else {
  37688. var name = filter.slice(0, i);
  37689. var args = filter.slice(i + 1);
  37690. return ("_f(\"" + name + "\")(" + exp + "," + args)
  37691. }
  37692. }
  37693. /* */
  37694. function baseWarn (msg) {
  37695. console.error(("[Vue compiler]: " + msg));
  37696. }
  37697. function pluckModuleFunction (
  37698. modules,
  37699. key
  37700. ) {
  37701. return modules
  37702. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  37703. : []
  37704. }
  37705. function addProp (el, name, value) {
  37706. (el.props || (el.props = [])).push({ name: name, value: value });
  37707. }
  37708. function addAttr (el, name, value) {
  37709. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  37710. }
  37711. function addDirective (
  37712. el,
  37713. name,
  37714. rawName,
  37715. value,
  37716. arg,
  37717. modifiers
  37718. ) {
  37719. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  37720. }
  37721. function addHandler (
  37722. el,
  37723. name,
  37724. value,
  37725. modifiers,
  37726. important,
  37727. warn
  37728. ) {
  37729. // warn prevent and passive modifier
  37730. /* istanbul ignore if */
  37731. if (
  37732. "development" !== 'production' && warn &&
  37733. modifiers && modifiers.prevent && modifiers.passive
  37734. ) {
  37735. warn(
  37736. 'passive and prevent can\'t be used together. ' +
  37737. 'Passive handler can\'t prevent default event.'
  37738. );
  37739. }
  37740. // check capture modifier
  37741. if (modifiers && modifiers.capture) {
  37742. delete modifiers.capture;
  37743. name = '!' + name; // mark the event as captured
  37744. }
  37745. if (modifiers && modifiers.once) {
  37746. delete modifiers.once;
  37747. name = '~' + name; // mark the event as once
  37748. }
  37749. /* istanbul ignore if */
  37750. if (modifiers && modifiers.passive) {
  37751. delete modifiers.passive;
  37752. name = '&' + name; // mark the event as passive
  37753. }
  37754. var events;
  37755. if (modifiers && modifiers.native) {
  37756. delete modifiers.native;
  37757. events = el.nativeEvents || (el.nativeEvents = {});
  37758. } else {
  37759. events = el.events || (el.events = {});
  37760. }
  37761. var newHandler = { value: value, modifiers: modifiers };
  37762. var handlers = events[name];
  37763. /* istanbul ignore if */
  37764. if (Array.isArray(handlers)) {
  37765. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  37766. } else if (handlers) {
  37767. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  37768. } else {
  37769. events[name] = newHandler;
  37770. }
  37771. }
  37772. function getBindingAttr (
  37773. el,
  37774. name,
  37775. getStatic
  37776. ) {
  37777. var dynamicValue =
  37778. getAndRemoveAttr(el, ':' + name) ||
  37779. getAndRemoveAttr(el, 'v-bind:' + name);
  37780. if (dynamicValue != null) {
  37781. return parseFilters(dynamicValue)
  37782. } else if (getStatic !== false) {
  37783. var staticValue = getAndRemoveAttr(el, name);
  37784. if (staticValue != null) {
  37785. return JSON.stringify(staticValue)
  37786. }
  37787. }
  37788. }
  37789. function getAndRemoveAttr (el, name) {
  37790. var val;
  37791. if ((val = el.attrsMap[name]) != null) {
  37792. var list = el.attrsList;
  37793. for (var i = 0, l = list.length; i < l; i++) {
  37794. if (list[i].name === name) {
  37795. list.splice(i, 1);
  37796. break
  37797. }
  37798. }
  37799. }
  37800. return val
  37801. }
  37802. /* */
  37803. /**
  37804. * Cross-platform code generation for component v-model
  37805. */
  37806. function genComponentModel (
  37807. el,
  37808. value,
  37809. modifiers
  37810. ) {
  37811. var ref = modifiers || {};
  37812. var number = ref.number;
  37813. var trim = ref.trim;
  37814. var baseValueExpression = '$$v';
  37815. var valueExpression = baseValueExpression;
  37816. if (trim) {
  37817. valueExpression =
  37818. "(typeof " + baseValueExpression + " === 'string'" +
  37819. "? " + baseValueExpression + ".trim()" +
  37820. ": " + baseValueExpression + ")";
  37821. }
  37822. if (number) {
  37823. valueExpression = "_n(" + valueExpression + ")";
  37824. }
  37825. var assignment = genAssignmentCode(value, valueExpression);
  37826. el.model = {
  37827. value: ("(" + value + ")"),
  37828. expression: ("\"" + value + "\""),
  37829. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  37830. };
  37831. }
  37832. /**
  37833. * Cross-platform codegen helper for generating v-model value assignment code.
  37834. */
  37835. function genAssignmentCode (
  37836. value,
  37837. assignment
  37838. ) {
  37839. var modelRs = parseModel(value);
  37840. if (modelRs.idx === null) {
  37841. return (value + "=" + assignment)
  37842. } else {
  37843. return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" +
  37844. "if (!Array.isArray($$exp)){" +
  37845. value + "=" + assignment + "}" +
  37846. "else{$$exp.splice($$idx, 1, " + assignment + ")}"
  37847. }
  37848. }
  37849. /**
  37850. * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
  37851. *
  37852. * for loop possible cases:
  37853. *
  37854. * - test
  37855. * - test[idx]
  37856. * - test[test1[idx]]
  37857. * - test["a"][idx]
  37858. * - xxx.test[a[a].test1[idx]]
  37859. * - test.xxx.a["asa"][test1[idx]]
  37860. *
  37861. */
  37862. var len;
  37863. var str;
  37864. var chr;
  37865. var index$1;
  37866. var expressionPos;
  37867. var expressionEndPos;
  37868. function parseModel (val) {
  37869. str = val;
  37870. len = str.length;
  37871. index$1 = expressionPos = expressionEndPos = 0;
  37872. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  37873. return {
  37874. exp: val,
  37875. idx: null
  37876. }
  37877. }
  37878. while (!eof()) {
  37879. chr = next();
  37880. /* istanbul ignore if */
  37881. if (isStringStart(chr)) {
  37882. parseString(chr);
  37883. } else if (chr === 0x5B) {
  37884. parseBracket(chr);
  37885. }
  37886. }
  37887. return {
  37888. exp: val.substring(0, expressionPos),
  37889. idx: val.substring(expressionPos + 1, expressionEndPos)
  37890. }
  37891. }
  37892. function next () {
  37893. return str.charCodeAt(++index$1)
  37894. }
  37895. function eof () {
  37896. return index$1 >= len
  37897. }
  37898. function isStringStart (chr) {
  37899. return chr === 0x22 || chr === 0x27
  37900. }
  37901. function parseBracket (chr) {
  37902. var inBracket = 1;
  37903. expressionPos = index$1;
  37904. while (!eof()) {
  37905. chr = next();
  37906. if (isStringStart(chr)) {
  37907. parseString(chr);
  37908. continue
  37909. }
  37910. if (chr === 0x5B) { inBracket++; }
  37911. if (chr === 0x5D) { inBracket--; }
  37912. if (inBracket === 0) {
  37913. expressionEndPos = index$1;
  37914. break
  37915. }
  37916. }
  37917. }
  37918. function parseString (chr) {
  37919. var stringQuote = chr;
  37920. while (!eof()) {
  37921. chr = next();
  37922. if (chr === stringQuote) {
  37923. break
  37924. }
  37925. }
  37926. }
  37927. /* */
  37928. var warn$1;
  37929. // in some cases, the event used has to be determined at runtime
  37930. // so we used some reserved tokens during compile.
  37931. var RANGE_TOKEN = '__r';
  37932. var CHECKBOX_RADIO_TOKEN = '__c';
  37933. function model (
  37934. el,
  37935. dir,
  37936. _warn
  37937. ) {
  37938. warn$1 = _warn;
  37939. var value = dir.value;
  37940. var modifiers = dir.modifiers;
  37941. var tag = el.tag;
  37942. var type = el.attrsMap.type;
  37943. if (true) {
  37944. var dynamicType = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  37945. if (tag === 'input' && dynamicType) {
  37946. warn$1(
  37947. "<input :type=\"" + dynamicType + "\" v-model=\"" + value + "\">:\n" +
  37948. "v-model does not support dynamic input types. Use v-if branches instead."
  37949. );
  37950. }
  37951. // inputs with type="file" are read only and setting the input's
  37952. // value will throw an error.
  37953. if (tag === 'input' && type === 'file') {
  37954. warn$1(
  37955. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  37956. "File inputs are read only. Use a v-on:change listener instead."
  37957. );
  37958. }
  37959. }
  37960. if (tag === 'select') {
  37961. genSelect(el, value, modifiers);
  37962. } else if (tag === 'input' && type === 'checkbox') {
  37963. genCheckboxModel(el, value, modifiers);
  37964. } else if (tag === 'input' && type === 'radio') {
  37965. genRadioModel(el, value, modifiers);
  37966. } else if (tag === 'input' || tag === 'textarea') {
  37967. genDefaultModel(el, value, modifiers);
  37968. } else if (!config.isReservedTag(tag)) {
  37969. genComponentModel(el, value, modifiers);
  37970. // component v-model doesn't need extra runtime
  37971. return false
  37972. } else if (true) {
  37973. warn$1(
  37974. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  37975. "v-model is not supported on this element type. " +
  37976. 'If you are working with contenteditable, it\'s recommended to ' +
  37977. 'wrap a library dedicated for that purpose inside a custom component.'
  37978. );
  37979. }
  37980. // ensure runtime directive metadata
  37981. return true
  37982. }
  37983. function genCheckboxModel (
  37984. el,
  37985. value,
  37986. modifiers
  37987. ) {
  37988. var number = modifiers && modifiers.number;
  37989. var valueBinding = getBindingAttr(el, 'value') || 'null';
  37990. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  37991. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  37992. addProp(el, 'checked',
  37993. "Array.isArray(" + value + ")" +
  37994. "?_i(" + value + "," + valueBinding + ")>-1" + (
  37995. trueValueBinding === 'true'
  37996. ? (":(" + value + ")")
  37997. : (":_q(" + value + "," + trueValueBinding + ")")
  37998. )
  37999. );
  38000. addHandler(el, CHECKBOX_RADIO_TOKEN,
  38001. "var $$a=" + value + "," +
  38002. '$$el=$event.target,' +
  38003. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  38004. 'if(Array.isArray($$a)){' +
  38005. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  38006. '$$i=_i($$a,$$v);' +
  38007. "if($$c){$$i<0&&(" + value + "=$$a.concat($$v))}" +
  38008. "else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
  38009. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  38010. null, true
  38011. );
  38012. }
  38013. function genRadioModel (
  38014. el,
  38015. value,
  38016. modifiers
  38017. ) {
  38018. var number = modifiers && modifiers.number;
  38019. var valueBinding = getBindingAttr(el, 'value') || 'null';
  38020. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  38021. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  38022. addHandler(el, CHECKBOX_RADIO_TOKEN, genAssignmentCode(value, valueBinding), null, true);
  38023. }
  38024. function genSelect (
  38025. el,
  38026. value,
  38027. modifiers
  38028. ) {
  38029. var number = modifiers && modifiers.number;
  38030. var selectedVal = "Array.prototype.filter" +
  38031. ".call($event.target.options,function(o){return o.selected})" +
  38032. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  38033. "return " + (number ? '_n(val)' : 'val') + "})";
  38034. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  38035. var code = "var $$selectedVal = " + selectedVal + ";";
  38036. code = code + " " + (genAssignmentCode(value, assignment));
  38037. addHandler(el, 'change', code, null, true);
  38038. }
  38039. function genDefaultModel (
  38040. el,
  38041. value,
  38042. modifiers
  38043. ) {
  38044. var type = el.attrsMap.type;
  38045. var ref = modifiers || {};
  38046. var lazy = ref.lazy;
  38047. var number = ref.number;
  38048. var trim = ref.trim;
  38049. var needCompositionGuard = !lazy && type !== 'range';
  38050. var event = lazy
  38051. ? 'change'
  38052. : type === 'range'
  38053. ? RANGE_TOKEN
  38054. : 'input';
  38055. var valueExpression = '$event.target.value';
  38056. if (trim) {
  38057. valueExpression = "$event.target.value.trim()";
  38058. }
  38059. if (number) {
  38060. valueExpression = "_n(" + valueExpression + ")";
  38061. }
  38062. var code = genAssignmentCode(value, valueExpression);
  38063. if (needCompositionGuard) {
  38064. code = "if($event.target.composing)return;" + code;
  38065. }
  38066. addProp(el, 'value', ("(" + value + ")"));
  38067. addHandler(el, event, code, null, true);
  38068. if (trim || number || type === 'number') {
  38069. addHandler(el, 'blur', '$forceUpdate()');
  38070. }
  38071. }
  38072. /* */
  38073. // normalize v-model event tokens that can only be determined at runtime.
  38074. // it's important to place the event as the first in the array because
  38075. // the whole point is ensuring the v-model callback gets called before
  38076. // user-attached handlers.
  38077. function normalizeEvents (on) {
  38078. var event;
  38079. /* istanbul ignore if */
  38080. if (isDef(on[RANGE_TOKEN])) {
  38081. // IE input[type=range] only supports `change` event
  38082. event = isIE ? 'change' : 'input';
  38083. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  38084. delete on[RANGE_TOKEN];
  38085. }
  38086. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  38087. // Chrome fires microtasks in between click/change, leads to #4521
  38088. event = isChrome ? 'click' : 'change';
  38089. on[event] = [].concat(on[CHECKBOX_RADIO_TOKEN], on[event] || []);
  38090. delete on[CHECKBOX_RADIO_TOKEN];
  38091. }
  38092. }
  38093. var target$1;
  38094. function add$1 (
  38095. event,
  38096. handler,
  38097. once$$1,
  38098. capture,
  38099. passive
  38100. ) {
  38101. if (once$$1) {
  38102. var oldHandler = handler;
  38103. var _target = target$1; // save current target element in closure
  38104. handler = function (ev) {
  38105. var res = arguments.length === 1
  38106. ? oldHandler(ev)
  38107. : oldHandler.apply(null, arguments);
  38108. if (res !== null) {
  38109. remove$2(event, handler, capture, _target);
  38110. }
  38111. };
  38112. }
  38113. target$1.addEventListener(
  38114. event,
  38115. handler,
  38116. supportsPassive
  38117. ? { capture: capture, passive: passive }
  38118. : capture
  38119. );
  38120. }
  38121. function remove$2 (
  38122. event,
  38123. handler,
  38124. capture,
  38125. _target
  38126. ) {
  38127. (_target || target$1).removeEventListener(event, handler, capture);
  38128. }
  38129. function updateDOMListeners (oldVnode, vnode) {
  38130. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  38131. return
  38132. }
  38133. var on = vnode.data.on || {};
  38134. var oldOn = oldVnode.data.on || {};
  38135. target$1 = vnode.elm;
  38136. normalizeEvents(on);
  38137. updateListeners(on, oldOn, add$1, remove$2, vnode.context);
  38138. }
  38139. var events = {
  38140. create: updateDOMListeners,
  38141. update: updateDOMListeners
  38142. };
  38143. /* */
  38144. function updateDOMProps (oldVnode, vnode) {
  38145. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  38146. return
  38147. }
  38148. var key, cur;
  38149. var elm = vnode.elm;
  38150. var oldProps = oldVnode.data.domProps || {};
  38151. var props = vnode.data.domProps || {};
  38152. // clone observed objects, as the user probably wants to mutate it
  38153. if (isDef(props.__ob__)) {
  38154. props = vnode.data.domProps = extend({}, props);
  38155. }
  38156. for (key in oldProps) {
  38157. if (isUndef(props[key])) {
  38158. elm[key] = '';
  38159. }
  38160. }
  38161. for (key in props) {
  38162. cur = props[key];
  38163. // ignore children if the node has textContent or innerHTML,
  38164. // as these will throw away existing DOM nodes and cause removal errors
  38165. // on subsequent patches (#3360)
  38166. if (key === 'textContent' || key === 'innerHTML') {
  38167. if (vnode.children) { vnode.children.length = 0; }
  38168. if (cur === oldProps[key]) { continue }
  38169. }
  38170. if (key === 'value') {
  38171. // store value as _value as well since
  38172. // non-string values will be stringified
  38173. elm._value = cur;
  38174. // avoid resetting cursor position when value is the same
  38175. var strCur = isUndef(cur) ? '' : String(cur);
  38176. if (shouldUpdateValue(elm, vnode, strCur)) {
  38177. elm.value = strCur;
  38178. }
  38179. } else {
  38180. elm[key] = cur;
  38181. }
  38182. }
  38183. }
  38184. // check platforms/web/util/attrs.js acceptValue
  38185. function shouldUpdateValue (
  38186. elm,
  38187. vnode,
  38188. checkVal
  38189. ) {
  38190. return (!elm.composing && (
  38191. vnode.tag === 'option' ||
  38192. isDirty(elm, checkVal) ||
  38193. isInputChanged(elm, checkVal)
  38194. ))
  38195. }
  38196. function isDirty (elm, checkVal) {
  38197. // return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value
  38198. return document.activeElement !== elm && elm.value !== checkVal
  38199. }
  38200. function isInputChanged (elm, newVal) {
  38201. var value = elm.value;
  38202. var modifiers = elm._vModifiers; // injected by v-model runtime
  38203. if ((isDef(modifiers) && modifiers.number) || elm.type === 'number') {
  38204. return toNumber(value) !== toNumber(newVal)
  38205. }
  38206. if (isDef(modifiers) && modifiers.trim) {
  38207. return value.trim() !== newVal.trim()
  38208. }
  38209. return value !== newVal
  38210. }
  38211. var domProps = {
  38212. create: updateDOMProps,
  38213. update: updateDOMProps
  38214. };
  38215. /* */
  38216. var parseStyleText = cached(function (cssText) {
  38217. var res = {};
  38218. var listDelimiter = /;(?![^(]*\))/g;
  38219. var propertyDelimiter = /:(.+)/;
  38220. cssText.split(listDelimiter).forEach(function (item) {
  38221. if (item) {
  38222. var tmp = item.split(propertyDelimiter);
  38223. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  38224. }
  38225. });
  38226. return res
  38227. });
  38228. // merge static and dynamic style data on the same vnode
  38229. function normalizeStyleData (data) {
  38230. var style = normalizeStyleBinding(data.style);
  38231. // static style is pre-processed into an object during compilation
  38232. // and is always a fresh object, so it's safe to merge into it
  38233. return data.staticStyle
  38234. ? extend(data.staticStyle, style)
  38235. : style
  38236. }
  38237. // normalize possible array / string values into Object
  38238. function normalizeStyleBinding (bindingStyle) {
  38239. if (Array.isArray(bindingStyle)) {
  38240. return toObject(bindingStyle)
  38241. }
  38242. if (typeof bindingStyle === 'string') {
  38243. return parseStyleText(bindingStyle)
  38244. }
  38245. return bindingStyle
  38246. }
  38247. /**
  38248. * parent component style should be after child's
  38249. * so that parent component's style could override it
  38250. */
  38251. function getStyle (vnode, checkChild) {
  38252. var res = {};
  38253. var styleData;
  38254. if (checkChild) {
  38255. var childNode = vnode;
  38256. while (childNode.componentInstance) {
  38257. childNode = childNode.componentInstance._vnode;
  38258. if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
  38259. extend(res, styleData);
  38260. }
  38261. }
  38262. }
  38263. if ((styleData = normalizeStyleData(vnode.data))) {
  38264. extend(res, styleData);
  38265. }
  38266. var parentNode = vnode;
  38267. while ((parentNode = parentNode.parent)) {
  38268. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  38269. extend(res, styleData);
  38270. }
  38271. }
  38272. return res
  38273. }
  38274. /* */
  38275. var cssVarRE = /^--/;
  38276. var importantRE = /\s*!important$/;
  38277. var setProp = function (el, name, val) {
  38278. /* istanbul ignore if */
  38279. if (cssVarRE.test(name)) {
  38280. el.style.setProperty(name, val);
  38281. } else if (importantRE.test(val)) {
  38282. el.style.setProperty(name, val.replace(importantRE, ''), 'important');
  38283. } else {
  38284. var normalizedName = normalize(name);
  38285. if (Array.isArray(val)) {
  38286. // Support values array created by autoprefixer, e.g.
  38287. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  38288. // Set them one by one, and the browser will only set those it can recognize
  38289. for (var i = 0, len = val.length; i < len; i++) {
  38290. el.style[normalizedName] = val[i];
  38291. }
  38292. } else {
  38293. el.style[normalizedName] = val;
  38294. }
  38295. }
  38296. };
  38297. var prefixes = ['Webkit', 'Moz', 'ms'];
  38298. var testEl;
  38299. var normalize = cached(function (prop) {
  38300. testEl = testEl || document.createElement('div');
  38301. prop = camelize(prop);
  38302. if (prop !== 'filter' && (prop in testEl.style)) {
  38303. return prop
  38304. }
  38305. var upper = prop.charAt(0).toUpperCase() + prop.slice(1);
  38306. for (var i = 0; i < prefixes.length; i++) {
  38307. var prefixed = prefixes[i] + upper;
  38308. if (prefixed in testEl.style) {
  38309. return prefixed
  38310. }
  38311. }
  38312. });
  38313. function updateStyle (oldVnode, vnode) {
  38314. var data = vnode.data;
  38315. var oldData = oldVnode.data;
  38316. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  38317. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  38318. ) {
  38319. return
  38320. }
  38321. var cur, name;
  38322. var el = vnode.elm;
  38323. var oldStaticStyle = oldData.staticStyle;
  38324. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  38325. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  38326. var oldStyle = oldStaticStyle || oldStyleBinding;
  38327. var style = normalizeStyleBinding(vnode.data.style) || {};
  38328. // store normalized style under a different key for next diff
  38329. // make sure to clone it if it's reactive, since the user likley wants
  38330. // to mutate it.
  38331. vnode.data.normalizedStyle = isDef(style.__ob__)
  38332. ? extend({}, style)
  38333. : style;
  38334. var newStyle = getStyle(vnode, true);
  38335. for (name in oldStyle) {
  38336. if (isUndef(newStyle[name])) {
  38337. setProp(el, name, '');
  38338. }
  38339. }
  38340. for (name in newStyle) {
  38341. cur = newStyle[name];
  38342. if (cur !== oldStyle[name]) {
  38343. // ie9 setting to null has no effect, must use empty string
  38344. setProp(el, name, cur == null ? '' : cur);
  38345. }
  38346. }
  38347. }
  38348. var style = {
  38349. create: updateStyle,
  38350. update: updateStyle
  38351. };
  38352. /* */
  38353. /**
  38354. * Add class with compatibility for SVG since classList is not supported on
  38355. * SVG elements in IE
  38356. */
  38357. function addClass (el, cls) {
  38358. /* istanbul ignore if */
  38359. if (!cls || !(cls = cls.trim())) {
  38360. return
  38361. }
  38362. /* istanbul ignore else */
  38363. if (el.classList) {
  38364. if (cls.indexOf(' ') > -1) {
  38365. cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); });
  38366. } else {
  38367. el.classList.add(cls);
  38368. }
  38369. } else {
  38370. var cur = " " + (el.getAttribute('class') || '') + " ";
  38371. if (cur.indexOf(' ' + cls + ' ') < 0) {
  38372. el.setAttribute('class', (cur + cls).trim());
  38373. }
  38374. }
  38375. }
  38376. /**
  38377. * Remove class with compatibility for SVG since classList is not supported on
  38378. * SVG elements in IE
  38379. */
  38380. function removeClass (el, cls) {
  38381. /* istanbul ignore if */
  38382. if (!cls || !(cls = cls.trim())) {
  38383. return
  38384. }
  38385. /* istanbul ignore else */
  38386. if (el.classList) {
  38387. if (cls.indexOf(' ') > -1) {
  38388. cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
  38389. } else {
  38390. el.classList.remove(cls);
  38391. }
  38392. } else {
  38393. var cur = " " + (el.getAttribute('class') || '') + " ";
  38394. var tar = ' ' + cls + ' ';
  38395. while (cur.indexOf(tar) >= 0) {
  38396. cur = cur.replace(tar, ' ');
  38397. }
  38398. el.setAttribute('class', cur.trim());
  38399. }
  38400. }
  38401. /* */
  38402. function resolveTransition (def$$1) {
  38403. if (!def$$1) {
  38404. return
  38405. }
  38406. /* istanbul ignore else */
  38407. if (typeof def$$1 === 'object') {
  38408. var res = {};
  38409. if (def$$1.css !== false) {
  38410. extend(res, autoCssTransition(def$$1.name || 'v'));
  38411. }
  38412. extend(res, def$$1);
  38413. return res
  38414. } else if (typeof def$$1 === 'string') {
  38415. return autoCssTransition(def$$1)
  38416. }
  38417. }
  38418. var autoCssTransition = cached(function (name) {
  38419. return {
  38420. enterClass: (name + "-enter"),
  38421. enterToClass: (name + "-enter-to"),
  38422. enterActiveClass: (name + "-enter-active"),
  38423. leaveClass: (name + "-leave"),
  38424. leaveToClass: (name + "-leave-to"),
  38425. leaveActiveClass: (name + "-leave-active")
  38426. }
  38427. });
  38428. var hasTransition = inBrowser && !isIE9;
  38429. var TRANSITION = 'transition';
  38430. var ANIMATION = 'animation';
  38431. // Transition property/event sniffing
  38432. var transitionProp = 'transition';
  38433. var transitionEndEvent = 'transitionend';
  38434. var animationProp = 'animation';
  38435. var animationEndEvent = 'animationend';
  38436. if (hasTransition) {
  38437. /* istanbul ignore if */
  38438. if (window.ontransitionend === undefined &&
  38439. window.onwebkittransitionend !== undefined
  38440. ) {
  38441. transitionProp = 'WebkitTransition';
  38442. transitionEndEvent = 'webkitTransitionEnd';
  38443. }
  38444. if (window.onanimationend === undefined &&
  38445. window.onwebkitanimationend !== undefined
  38446. ) {
  38447. animationProp = 'WebkitAnimation';
  38448. animationEndEvent = 'webkitAnimationEnd';
  38449. }
  38450. }
  38451. // binding to window is necessary to make hot reload work in IE in strict mode
  38452. var raf = inBrowser && window.requestAnimationFrame
  38453. ? window.requestAnimationFrame.bind(window)
  38454. : setTimeout;
  38455. function nextFrame (fn) {
  38456. raf(function () {
  38457. raf(fn);
  38458. });
  38459. }
  38460. function addTransitionClass (el, cls) {
  38461. (el._transitionClasses || (el._transitionClasses = [])).push(cls);
  38462. addClass(el, cls);
  38463. }
  38464. function removeTransitionClass (el, cls) {
  38465. if (el._transitionClasses) {
  38466. remove(el._transitionClasses, cls);
  38467. }
  38468. removeClass(el, cls);
  38469. }
  38470. function whenTransitionEnds (
  38471. el,
  38472. expectedType,
  38473. cb
  38474. ) {
  38475. var ref = getTransitionInfo(el, expectedType);
  38476. var type = ref.type;
  38477. var timeout = ref.timeout;
  38478. var propCount = ref.propCount;
  38479. if (!type) { return cb() }
  38480. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  38481. var ended = 0;
  38482. var end = function () {
  38483. el.removeEventListener(event, onEnd);
  38484. cb();
  38485. };
  38486. var onEnd = function (e) {
  38487. if (e.target === el) {
  38488. if (++ended >= propCount) {
  38489. end();
  38490. }
  38491. }
  38492. };
  38493. setTimeout(function () {
  38494. if (ended < propCount) {
  38495. end();
  38496. }
  38497. }, timeout + 1);
  38498. el.addEventListener(event, onEnd);
  38499. }
  38500. var transformRE = /\b(transform|all)(,|$)/;
  38501. function getTransitionInfo (el, expectedType) {
  38502. var styles = window.getComputedStyle(el);
  38503. var transitionDelays = styles[transitionProp + 'Delay'].split(', ');
  38504. var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
  38505. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  38506. var animationDelays = styles[animationProp + 'Delay'].split(', ');
  38507. var animationDurations = styles[animationProp + 'Duration'].split(', ');
  38508. var animationTimeout = getTimeout(animationDelays, animationDurations);
  38509. var type;
  38510. var timeout = 0;
  38511. var propCount = 0;
  38512. /* istanbul ignore if */
  38513. if (expectedType === TRANSITION) {
  38514. if (transitionTimeout > 0) {
  38515. type = TRANSITION;
  38516. timeout = transitionTimeout;
  38517. propCount = transitionDurations.length;
  38518. }
  38519. } else if (expectedType === ANIMATION) {
  38520. if (animationTimeout > 0) {
  38521. type = ANIMATION;
  38522. timeout = animationTimeout;
  38523. propCount = animationDurations.length;
  38524. }
  38525. } else {
  38526. timeout = Math.max(transitionTimeout, animationTimeout);
  38527. type = timeout > 0
  38528. ? transitionTimeout > animationTimeout
  38529. ? TRANSITION
  38530. : ANIMATION
  38531. : null;
  38532. propCount = type
  38533. ? type === TRANSITION
  38534. ? transitionDurations.length
  38535. : animationDurations.length
  38536. : 0;
  38537. }
  38538. var hasTransform =
  38539. type === TRANSITION &&
  38540. transformRE.test(styles[transitionProp + 'Property']);
  38541. return {
  38542. type: type,
  38543. timeout: timeout,
  38544. propCount: propCount,
  38545. hasTransform: hasTransform
  38546. }
  38547. }
  38548. function getTimeout (delays, durations) {
  38549. /* istanbul ignore next */
  38550. while (delays.length < durations.length) {
  38551. delays = delays.concat(delays);
  38552. }
  38553. return Math.max.apply(null, durations.map(function (d, i) {
  38554. return toMs(d) + toMs(delays[i])
  38555. }))
  38556. }
  38557. function toMs (s) {
  38558. return Number(s.slice(0, -1)) * 1000
  38559. }
  38560. /* */
  38561. function enter (vnode, toggleDisplay) {
  38562. var el = vnode.elm;
  38563. // call leave callback now
  38564. if (isDef(el._leaveCb)) {
  38565. el._leaveCb.cancelled = true;
  38566. el._leaveCb();
  38567. }
  38568. var data = resolveTransition(vnode.data.transition);
  38569. if (isUndef(data)) {
  38570. return
  38571. }
  38572. /* istanbul ignore if */
  38573. if (isDef(el._enterCb) || el.nodeType !== 1) {
  38574. return
  38575. }
  38576. var css = data.css;
  38577. var type = data.type;
  38578. var enterClass = data.enterClass;
  38579. var enterToClass = data.enterToClass;
  38580. var enterActiveClass = data.enterActiveClass;
  38581. var appearClass = data.appearClass;
  38582. var appearToClass = data.appearToClass;
  38583. var appearActiveClass = data.appearActiveClass;
  38584. var beforeEnter = data.beforeEnter;
  38585. var enter = data.enter;
  38586. var afterEnter = data.afterEnter;
  38587. var enterCancelled = data.enterCancelled;
  38588. var beforeAppear = data.beforeAppear;
  38589. var appear = data.appear;
  38590. var afterAppear = data.afterAppear;
  38591. var appearCancelled = data.appearCancelled;
  38592. var duration = data.duration;
  38593. // activeInstance will always be the <transition> component managing this
  38594. // transition. One edge case to check is when the <transition> is placed
  38595. // as the root node of a child component. In that case we need to check
  38596. // <transition>'s parent for appear check.
  38597. var context = activeInstance;
  38598. var transitionNode = activeInstance.$vnode;
  38599. while (transitionNode && transitionNode.parent) {
  38600. transitionNode = transitionNode.parent;
  38601. context = transitionNode.context;
  38602. }
  38603. var isAppear = !context._isMounted || !vnode.isRootInsert;
  38604. if (isAppear && !appear && appear !== '') {
  38605. return
  38606. }
  38607. var startClass = isAppear && appearClass
  38608. ? appearClass
  38609. : enterClass;
  38610. var activeClass = isAppear && appearActiveClass
  38611. ? appearActiveClass
  38612. : enterActiveClass;
  38613. var toClass = isAppear && appearToClass
  38614. ? appearToClass
  38615. : enterToClass;
  38616. var beforeEnterHook = isAppear
  38617. ? (beforeAppear || beforeEnter)
  38618. : beforeEnter;
  38619. var enterHook = isAppear
  38620. ? (typeof appear === 'function' ? appear : enter)
  38621. : enter;
  38622. var afterEnterHook = isAppear
  38623. ? (afterAppear || afterEnter)
  38624. : afterEnter;
  38625. var enterCancelledHook = isAppear
  38626. ? (appearCancelled || enterCancelled)
  38627. : enterCancelled;
  38628. var explicitEnterDuration = toNumber(
  38629. isObject(duration)
  38630. ? duration.enter
  38631. : duration
  38632. );
  38633. if ("development" !== 'production' && explicitEnterDuration != null) {
  38634. checkDuration(explicitEnterDuration, 'enter', vnode);
  38635. }
  38636. var expectsCSS = css !== false && !isIE9;
  38637. var userWantsControl = getHookArgumentsLength(enterHook);
  38638. var cb = el._enterCb = once(function () {
  38639. if (expectsCSS) {
  38640. removeTransitionClass(el, toClass);
  38641. removeTransitionClass(el, activeClass);
  38642. }
  38643. if (cb.cancelled) {
  38644. if (expectsCSS) {
  38645. removeTransitionClass(el, startClass);
  38646. }
  38647. enterCancelledHook && enterCancelledHook(el);
  38648. } else {
  38649. afterEnterHook && afterEnterHook(el);
  38650. }
  38651. el._enterCb = null;
  38652. });
  38653. if (!vnode.data.show) {
  38654. // remove pending leave element on enter by injecting an insert hook
  38655. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
  38656. var parent = el.parentNode;
  38657. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  38658. if (pendingNode &&
  38659. pendingNode.tag === vnode.tag &&
  38660. pendingNode.elm._leaveCb
  38661. ) {
  38662. pendingNode.elm._leaveCb();
  38663. }
  38664. enterHook && enterHook(el, cb);
  38665. });
  38666. }
  38667. // start enter transition
  38668. beforeEnterHook && beforeEnterHook(el);
  38669. if (expectsCSS) {
  38670. addTransitionClass(el, startClass);
  38671. addTransitionClass(el, activeClass);
  38672. nextFrame(function () {
  38673. addTransitionClass(el, toClass);
  38674. removeTransitionClass(el, startClass);
  38675. if (!cb.cancelled && !userWantsControl) {
  38676. if (isValidDuration(explicitEnterDuration)) {
  38677. setTimeout(cb, explicitEnterDuration);
  38678. } else {
  38679. whenTransitionEnds(el, type, cb);
  38680. }
  38681. }
  38682. });
  38683. }
  38684. if (vnode.data.show) {
  38685. toggleDisplay && toggleDisplay();
  38686. enterHook && enterHook(el, cb);
  38687. }
  38688. if (!expectsCSS && !userWantsControl) {
  38689. cb();
  38690. }
  38691. }
  38692. function leave (vnode, rm) {
  38693. var el = vnode.elm;
  38694. // call enter callback now
  38695. if (isDef(el._enterCb)) {
  38696. el._enterCb.cancelled = true;
  38697. el._enterCb();
  38698. }
  38699. var data = resolveTransition(vnode.data.transition);
  38700. if (isUndef(data)) {
  38701. return rm()
  38702. }
  38703. /* istanbul ignore if */
  38704. if (isDef(el._leaveCb) || el.nodeType !== 1) {
  38705. return
  38706. }
  38707. var css = data.css;
  38708. var type = data.type;
  38709. var leaveClass = data.leaveClass;
  38710. var leaveToClass = data.leaveToClass;
  38711. var leaveActiveClass = data.leaveActiveClass;
  38712. var beforeLeave = data.beforeLeave;
  38713. var leave = data.leave;
  38714. var afterLeave = data.afterLeave;
  38715. var leaveCancelled = data.leaveCancelled;
  38716. var delayLeave = data.delayLeave;
  38717. var duration = data.duration;
  38718. var expectsCSS = css !== false && !isIE9;
  38719. var userWantsControl = getHookArgumentsLength(leave);
  38720. var explicitLeaveDuration = toNumber(
  38721. isObject(duration)
  38722. ? duration.leave
  38723. : duration
  38724. );
  38725. if ("development" !== 'production' && isDef(explicitLeaveDuration)) {
  38726. checkDuration(explicitLeaveDuration, 'leave', vnode);
  38727. }
  38728. var cb = el._leaveCb = once(function () {
  38729. if (el.parentNode && el.parentNode._pending) {
  38730. el.parentNode._pending[vnode.key] = null;
  38731. }
  38732. if (expectsCSS) {
  38733. removeTransitionClass(el, leaveToClass);
  38734. removeTransitionClass(el, leaveActiveClass);
  38735. }
  38736. if (cb.cancelled) {
  38737. if (expectsCSS) {
  38738. removeTransitionClass(el, leaveClass);
  38739. }
  38740. leaveCancelled && leaveCancelled(el);
  38741. } else {
  38742. rm();
  38743. afterLeave && afterLeave(el);
  38744. }
  38745. el._leaveCb = null;
  38746. });
  38747. if (delayLeave) {
  38748. delayLeave(performLeave);
  38749. } else {
  38750. performLeave();
  38751. }
  38752. function performLeave () {
  38753. // the delayed leave may have already been cancelled
  38754. if (cb.cancelled) {
  38755. return
  38756. }
  38757. // record leaving element
  38758. if (!vnode.data.show) {
  38759. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  38760. }
  38761. beforeLeave && beforeLeave(el);
  38762. if (expectsCSS) {
  38763. addTransitionClass(el, leaveClass);
  38764. addTransitionClass(el, leaveActiveClass);
  38765. nextFrame(function () {
  38766. addTransitionClass(el, leaveToClass);
  38767. removeTransitionClass(el, leaveClass);
  38768. if (!cb.cancelled && !userWantsControl) {
  38769. if (isValidDuration(explicitLeaveDuration)) {
  38770. setTimeout(cb, explicitLeaveDuration);
  38771. } else {
  38772. whenTransitionEnds(el, type, cb);
  38773. }
  38774. }
  38775. });
  38776. }
  38777. leave && leave(el, cb);
  38778. if (!expectsCSS && !userWantsControl) {
  38779. cb();
  38780. }
  38781. }
  38782. }
  38783. // only used in dev mode
  38784. function checkDuration (val, name, vnode) {
  38785. if (typeof val !== 'number') {
  38786. warn(
  38787. "<transition> explicit " + name + " duration is not a valid number - " +
  38788. "got " + (JSON.stringify(val)) + ".",
  38789. vnode.context
  38790. );
  38791. } else if (isNaN(val)) {
  38792. warn(
  38793. "<transition> explicit " + name + " duration is NaN - " +
  38794. 'the duration expression might be incorrect.',
  38795. vnode.context
  38796. );
  38797. }
  38798. }
  38799. function isValidDuration (val) {
  38800. return typeof val === 'number' && !isNaN(val)
  38801. }
  38802. /**
  38803. * Normalize a transition hook's argument length. The hook may be:
  38804. * - a merged hook (invoker) with the original in .fns
  38805. * - a wrapped component method (check ._length)
  38806. * - a plain function (.length)
  38807. */
  38808. function getHookArgumentsLength (fn) {
  38809. if (isUndef(fn)) {
  38810. return false
  38811. }
  38812. var invokerFns = fn.fns;
  38813. if (isDef(invokerFns)) {
  38814. // invoker
  38815. return getHookArgumentsLength(
  38816. Array.isArray(invokerFns)
  38817. ? invokerFns[0]
  38818. : invokerFns
  38819. )
  38820. } else {
  38821. return (fn._length || fn.length) > 1
  38822. }
  38823. }
  38824. function _enter (_, vnode) {
  38825. if (vnode.data.show !== true) {
  38826. enter(vnode);
  38827. }
  38828. }
  38829. var transition = inBrowser ? {
  38830. create: _enter,
  38831. activate: _enter,
  38832. remove: function remove$$1 (vnode, rm) {
  38833. /* istanbul ignore else */
  38834. if (vnode.data.show !== true) {
  38835. leave(vnode, rm);
  38836. } else {
  38837. rm();
  38838. }
  38839. }
  38840. } : {};
  38841. var platformModules = [
  38842. attrs,
  38843. klass,
  38844. events,
  38845. domProps,
  38846. style,
  38847. transition
  38848. ];
  38849. /* */
  38850. // the directive module should be applied last, after all
  38851. // built-in modules have been applied.
  38852. var modules = platformModules.concat(baseModules);
  38853. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  38854. /**
  38855. * Not type checking this file because flow doesn't like attaching
  38856. * properties to Elements.
  38857. */
  38858. /* istanbul ignore if */
  38859. if (isIE9) {
  38860. // http://www.matts411.com/post/internet-explorer-9-oninput/
  38861. document.addEventListener('selectionchange', function () {
  38862. var el = document.activeElement;
  38863. if (el && el.vmodel) {
  38864. trigger(el, 'input');
  38865. }
  38866. });
  38867. }
  38868. var model$1 = {
  38869. inserted: function inserted (el, binding, vnode) {
  38870. if (vnode.tag === 'select') {
  38871. var cb = function () {
  38872. setSelected(el, binding, vnode.context);
  38873. };
  38874. cb();
  38875. /* istanbul ignore if */
  38876. if (isIE || isEdge) {
  38877. setTimeout(cb, 0);
  38878. }
  38879. } else if (vnode.tag === 'textarea' || el.type === 'text' || el.type === 'password') {
  38880. el._vModifiers = binding.modifiers;
  38881. if (!binding.modifiers.lazy) {
  38882. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  38883. // switching focus before confirming composition choice
  38884. // this also fixes the issue where some browsers e.g. iOS Chrome
  38885. // fires "change" instead of "input" on autocomplete.
  38886. el.addEventListener('change', onCompositionEnd);
  38887. if (!isAndroid) {
  38888. el.addEventListener('compositionstart', onCompositionStart);
  38889. el.addEventListener('compositionend', onCompositionEnd);
  38890. }
  38891. /* istanbul ignore if */
  38892. if (isIE9) {
  38893. el.vmodel = true;
  38894. }
  38895. }
  38896. }
  38897. },
  38898. componentUpdated: function componentUpdated (el, binding, vnode) {
  38899. if (vnode.tag === 'select') {
  38900. setSelected(el, binding, vnode.context);
  38901. // in case the options rendered by v-for have changed,
  38902. // it's possible that the value is out-of-sync with the rendered options.
  38903. // detect such cases and filter out values that no longer has a matching
  38904. // option in the DOM.
  38905. var needReset = el.multiple
  38906. ? binding.value.some(function (v) { return hasNoMatchingOption(v, el.options); })
  38907. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options);
  38908. if (needReset) {
  38909. trigger(el, 'change');
  38910. }
  38911. }
  38912. }
  38913. };
  38914. function setSelected (el, binding, vm) {
  38915. var value = binding.value;
  38916. var isMultiple = el.multiple;
  38917. if (isMultiple && !Array.isArray(value)) {
  38918. "development" !== 'production' && warn(
  38919. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  38920. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  38921. vm
  38922. );
  38923. return
  38924. }
  38925. var selected, option;
  38926. for (var i = 0, l = el.options.length; i < l; i++) {
  38927. option = el.options[i];
  38928. if (isMultiple) {
  38929. selected = looseIndexOf(value, getValue(option)) > -1;
  38930. if (option.selected !== selected) {
  38931. option.selected = selected;
  38932. }
  38933. } else {
  38934. if (looseEqual(getValue(option), value)) {
  38935. if (el.selectedIndex !== i) {
  38936. el.selectedIndex = i;
  38937. }
  38938. return
  38939. }
  38940. }
  38941. }
  38942. if (!isMultiple) {
  38943. el.selectedIndex = -1;
  38944. }
  38945. }
  38946. function hasNoMatchingOption (value, options) {
  38947. for (var i = 0, l = options.length; i < l; i++) {
  38948. if (looseEqual(getValue(options[i]), value)) {
  38949. return false
  38950. }
  38951. }
  38952. return true
  38953. }
  38954. function getValue (option) {
  38955. return '_value' in option
  38956. ? option._value
  38957. : option.value
  38958. }
  38959. function onCompositionStart (e) {
  38960. e.target.composing = true;
  38961. }
  38962. function onCompositionEnd (e) {
  38963. // prevent triggering an input event for no reason
  38964. if (!e.target.composing) { return }
  38965. e.target.composing = false;
  38966. trigger(e.target, 'input');
  38967. }
  38968. function trigger (el, type) {
  38969. var e = document.createEvent('HTMLEvents');
  38970. e.initEvent(type, true, true);
  38971. el.dispatchEvent(e);
  38972. }
  38973. /* */
  38974. // recursively search for possible transition defined inside the component root
  38975. function locateNode (vnode) {
  38976. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  38977. ? locateNode(vnode.componentInstance._vnode)
  38978. : vnode
  38979. }
  38980. var show = {
  38981. bind: function bind (el, ref, vnode) {
  38982. var value = ref.value;
  38983. vnode = locateNode(vnode);
  38984. var transition = vnode.data && vnode.data.transition;
  38985. var originalDisplay = el.__vOriginalDisplay =
  38986. el.style.display === 'none' ? '' : el.style.display;
  38987. if (value && transition && !isIE9) {
  38988. vnode.data.show = true;
  38989. enter(vnode, function () {
  38990. el.style.display = originalDisplay;
  38991. });
  38992. } else {
  38993. el.style.display = value ? originalDisplay : 'none';
  38994. }
  38995. },
  38996. update: function update (el, ref, vnode) {
  38997. var value = ref.value;
  38998. var oldValue = ref.oldValue;
  38999. /* istanbul ignore if */
  39000. if (value === oldValue) { return }
  39001. vnode = locateNode(vnode);
  39002. var transition = vnode.data && vnode.data.transition;
  39003. if (transition && !isIE9) {
  39004. vnode.data.show = true;
  39005. if (value) {
  39006. enter(vnode, function () {
  39007. el.style.display = el.__vOriginalDisplay;
  39008. });
  39009. } else {
  39010. leave(vnode, function () {
  39011. el.style.display = 'none';
  39012. });
  39013. }
  39014. } else {
  39015. el.style.display = value ? el.__vOriginalDisplay : 'none';
  39016. }
  39017. },
  39018. unbind: function unbind (
  39019. el,
  39020. binding,
  39021. vnode,
  39022. oldVnode,
  39023. isDestroy
  39024. ) {
  39025. if (!isDestroy) {
  39026. el.style.display = el.__vOriginalDisplay;
  39027. }
  39028. }
  39029. };
  39030. var platformDirectives = {
  39031. model: model$1,
  39032. show: show
  39033. };
  39034. /* */
  39035. // Provides transition support for a single element/component.
  39036. // supports transition mode (out-in / in-out)
  39037. var transitionProps = {
  39038. name: String,
  39039. appear: Boolean,
  39040. css: Boolean,
  39041. mode: String,
  39042. type: String,
  39043. enterClass: String,
  39044. leaveClass: String,
  39045. enterToClass: String,
  39046. leaveToClass: String,
  39047. enterActiveClass: String,
  39048. leaveActiveClass: String,
  39049. appearClass: String,
  39050. appearActiveClass: String,
  39051. appearToClass: String,
  39052. duration: [Number, String, Object]
  39053. };
  39054. // in case the child is also an abstract component, e.g. <keep-alive>
  39055. // we want to recursively retrieve the real component to be rendered
  39056. function getRealChild (vnode) {
  39057. var compOptions = vnode && vnode.componentOptions;
  39058. if (compOptions && compOptions.Ctor.options.abstract) {
  39059. return getRealChild(getFirstComponentChild(compOptions.children))
  39060. } else {
  39061. return vnode
  39062. }
  39063. }
  39064. function extractTransitionData (comp) {
  39065. var data = {};
  39066. var options = comp.$options;
  39067. // props
  39068. for (var key in options.propsData) {
  39069. data[key] = comp[key];
  39070. }
  39071. // events.
  39072. // extract listeners and pass them directly to the transition methods
  39073. var listeners = options._parentListeners;
  39074. for (var key$1 in listeners) {
  39075. data[camelize(key$1)] = listeners[key$1];
  39076. }
  39077. return data
  39078. }
  39079. function placeholder (h, rawChild) {
  39080. if (/\d-keep-alive$/.test(rawChild.tag)) {
  39081. return h('keep-alive', {
  39082. props: rawChild.componentOptions.propsData
  39083. })
  39084. }
  39085. }
  39086. function hasParentTransition (vnode) {
  39087. while ((vnode = vnode.parent)) {
  39088. if (vnode.data.transition) {
  39089. return true
  39090. }
  39091. }
  39092. }
  39093. function isSameChild (child, oldChild) {
  39094. return oldChild.key === child.key && oldChild.tag === child.tag
  39095. }
  39096. var Transition = {
  39097. name: 'transition',
  39098. props: transitionProps,
  39099. abstract: true,
  39100. render: function render (h) {
  39101. var this$1 = this;
  39102. var children = this.$slots.default;
  39103. if (!children) {
  39104. return
  39105. }
  39106. // filter out text nodes (possible whitespaces)
  39107. children = children.filter(function (c) { return c.tag; });
  39108. /* istanbul ignore if */
  39109. if (!children.length) {
  39110. return
  39111. }
  39112. // warn multiple elements
  39113. if ("development" !== 'production' && children.length > 1) {
  39114. warn(
  39115. '<transition> can only be used on a single element. Use ' +
  39116. '<transition-group> for lists.',
  39117. this.$parent
  39118. );
  39119. }
  39120. var mode = this.mode;
  39121. // warn invalid mode
  39122. if ("development" !== 'production' &&
  39123. mode && mode !== 'in-out' && mode !== 'out-in'
  39124. ) {
  39125. warn(
  39126. 'invalid <transition> mode: ' + mode,
  39127. this.$parent
  39128. );
  39129. }
  39130. var rawChild = children[0];
  39131. // if this is a component root node and the component's
  39132. // parent container node also has transition, skip.
  39133. if (hasParentTransition(this.$vnode)) {
  39134. return rawChild
  39135. }
  39136. // apply transition data to child
  39137. // use getRealChild() to ignore abstract components e.g. keep-alive
  39138. var child = getRealChild(rawChild);
  39139. /* istanbul ignore if */
  39140. if (!child) {
  39141. return rawChild
  39142. }
  39143. if (this._leaving) {
  39144. return placeholder(h, rawChild)
  39145. }
  39146. // ensure a key that is unique to the vnode type and to this transition
  39147. // component instance. This key will be used to remove pending leaving nodes
  39148. // during entering.
  39149. var id = "__transition-" + (this._uid) + "-";
  39150. child.key = child.key == null
  39151. ? id + child.tag
  39152. : isPrimitive(child.key)
  39153. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  39154. : child.key;
  39155. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  39156. var oldRawChild = this._vnode;
  39157. var oldChild = getRealChild(oldRawChild);
  39158. // mark v-show
  39159. // so that the transition module can hand over the control to the directive
  39160. if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
  39161. child.data.show = true;
  39162. }
  39163. if (oldChild && oldChild.data && !isSameChild(child, oldChild)) {
  39164. // replace old child transition data with fresh one
  39165. // important for dynamic transitions!
  39166. var oldData = oldChild && (oldChild.data.transition = extend({}, data));
  39167. // handle transition mode
  39168. if (mode === 'out-in') {
  39169. // return placeholder node and queue update when leave finishes
  39170. this._leaving = true;
  39171. mergeVNodeHook(oldData, 'afterLeave', function () {
  39172. this$1._leaving = false;
  39173. this$1.$forceUpdate();
  39174. });
  39175. return placeholder(h, rawChild)
  39176. } else if (mode === 'in-out') {
  39177. var delayedLeave;
  39178. var performLeave = function () { delayedLeave(); };
  39179. mergeVNodeHook(data, 'afterEnter', performLeave);
  39180. mergeVNodeHook(data, 'enterCancelled', performLeave);
  39181. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  39182. }
  39183. }
  39184. return rawChild
  39185. }
  39186. };
  39187. /* */
  39188. // Provides transition support for list items.
  39189. // supports move transitions using the FLIP technique.
  39190. // Because the vdom's children update algorithm is "unstable" - i.e.
  39191. // it doesn't guarantee the relative positioning of removed elements,
  39192. // we force transition-group to update its children into two passes:
  39193. // in the first pass, we remove all nodes that need to be removed,
  39194. // triggering their leaving transition; in the second pass, we insert/move
  39195. // into the final desired state. This way in the second pass removed
  39196. // nodes will remain where they should be.
  39197. var props = extend({
  39198. tag: String,
  39199. moveClass: String
  39200. }, transitionProps);
  39201. delete props.mode;
  39202. var TransitionGroup = {
  39203. props: props,
  39204. render: function render (h) {
  39205. var tag = this.tag || this.$vnode.data.tag || 'span';
  39206. var map = Object.create(null);
  39207. var prevChildren = this.prevChildren = this.children;
  39208. var rawChildren = this.$slots.default || [];
  39209. var children = this.children = [];
  39210. var transitionData = extractTransitionData(this);
  39211. for (var i = 0; i < rawChildren.length; i++) {
  39212. var c = rawChildren[i];
  39213. if (c.tag) {
  39214. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  39215. children.push(c);
  39216. map[c.key] = c
  39217. ;(c.data || (c.data = {})).transition = transitionData;
  39218. } else if (true) {
  39219. var opts = c.componentOptions;
  39220. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  39221. warn(("<transition-group> children must be keyed: <" + name + ">"));
  39222. }
  39223. }
  39224. }
  39225. if (prevChildren) {
  39226. var kept = [];
  39227. var removed = [];
  39228. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  39229. var c$1 = prevChildren[i$1];
  39230. c$1.data.transition = transitionData;
  39231. c$1.data.pos = c$1.elm.getBoundingClientRect();
  39232. if (map[c$1.key]) {
  39233. kept.push(c$1);
  39234. } else {
  39235. removed.push(c$1);
  39236. }
  39237. }
  39238. this.kept = h(tag, null, kept);
  39239. this.removed = removed;
  39240. }
  39241. return h(tag, null, children)
  39242. },
  39243. beforeUpdate: function beforeUpdate () {
  39244. // force removing pass
  39245. this.__patch__(
  39246. this._vnode,
  39247. this.kept,
  39248. false, // hydrating
  39249. true // removeOnly (!important, avoids unnecessary moves)
  39250. );
  39251. this._vnode = this.kept;
  39252. },
  39253. updated: function updated () {
  39254. var children = this.prevChildren;
  39255. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  39256. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  39257. return
  39258. }
  39259. // we divide the work into three loops to avoid mixing DOM reads and writes
  39260. // in each iteration - which helps prevent layout thrashing.
  39261. children.forEach(callPendingCbs);
  39262. children.forEach(recordPosition);
  39263. children.forEach(applyTranslation);
  39264. // force reflow to put everything in position
  39265. var body = document.body;
  39266. var f = body.offsetHeight; // eslint-disable-line
  39267. children.forEach(function (c) {
  39268. if (c.data.moved) {
  39269. var el = c.elm;
  39270. var s = el.style;
  39271. addTransitionClass(el, moveClass);
  39272. s.transform = s.WebkitTransform = s.transitionDuration = '';
  39273. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  39274. if (!e || /transform$/.test(e.propertyName)) {
  39275. el.removeEventListener(transitionEndEvent, cb);
  39276. el._moveCb = null;
  39277. removeTransitionClass(el, moveClass);
  39278. }
  39279. });
  39280. }
  39281. });
  39282. },
  39283. methods: {
  39284. hasMove: function hasMove (el, moveClass) {
  39285. /* istanbul ignore if */
  39286. if (!hasTransition) {
  39287. return false
  39288. }
  39289. if (this._hasMove != null) {
  39290. return this._hasMove
  39291. }
  39292. // Detect whether an element with the move class applied has
  39293. // CSS transitions. Since the element may be inside an entering
  39294. // transition at this very moment, we make a clone of it and remove
  39295. // all other transition classes applied to ensure only the move class
  39296. // is applied.
  39297. var clone = el.cloneNode();
  39298. if (el._transitionClasses) {
  39299. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  39300. }
  39301. addClass(clone, moveClass);
  39302. clone.style.display = 'none';
  39303. this.$el.appendChild(clone);
  39304. var info = getTransitionInfo(clone);
  39305. this.$el.removeChild(clone);
  39306. return (this._hasMove = info.hasTransform)
  39307. }
  39308. }
  39309. };
  39310. function callPendingCbs (c) {
  39311. /* istanbul ignore if */
  39312. if (c.elm._moveCb) {
  39313. c.elm._moveCb();
  39314. }
  39315. /* istanbul ignore if */
  39316. if (c.elm._enterCb) {
  39317. c.elm._enterCb();
  39318. }
  39319. }
  39320. function recordPosition (c) {
  39321. c.data.newPos = c.elm.getBoundingClientRect();
  39322. }
  39323. function applyTranslation (c) {
  39324. var oldPos = c.data.pos;
  39325. var newPos = c.data.newPos;
  39326. var dx = oldPos.left - newPos.left;
  39327. var dy = oldPos.top - newPos.top;
  39328. if (dx || dy) {
  39329. c.data.moved = true;
  39330. var s = c.elm.style;
  39331. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  39332. s.transitionDuration = '0s';
  39333. }
  39334. }
  39335. var platformComponents = {
  39336. Transition: Transition,
  39337. TransitionGroup: TransitionGroup
  39338. };
  39339. /* */
  39340. // install platform specific utils
  39341. Vue$3.config.mustUseProp = mustUseProp;
  39342. Vue$3.config.isReservedTag = isReservedTag;
  39343. Vue$3.config.isReservedAttr = isReservedAttr;
  39344. Vue$3.config.getTagNamespace = getTagNamespace;
  39345. Vue$3.config.isUnknownElement = isUnknownElement;
  39346. // install platform runtime directives & components
  39347. extend(Vue$3.options.directives, platformDirectives);
  39348. extend(Vue$3.options.components, platformComponents);
  39349. // install platform patch function
  39350. Vue$3.prototype.__patch__ = inBrowser ? patch : noop;
  39351. // public mount method
  39352. Vue$3.prototype.$mount = function (
  39353. el,
  39354. hydrating
  39355. ) {
  39356. el = el && inBrowser ? query(el) : undefined;
  39357. return mountComponent(this, el, hydrating)
  39358. };
  39359. // devtools global hook
  39360. /* istanbul ignore next */
  39361. setTimeout(function () {
  39362. if (config.devtools) {
  39363. if (devtools) {
  39364. devtools.emit('init', Vue$3);
  39365. } else if ("development" !== 'production' && isChrome) {
  39366. console[console.info ? 'info' : 'log'](
  39367. 'Download the Vue Devtools extension for a better development experience:\n' +
  39368. 'https://github.com/vuejs/vue-devtools'
  39369. );
  39370. }
  39371. }
  39372. if ("development" !== 'production' &&
  39373. config.productionTip !== false &&
  39374. inBrowser && typeof console !== 'undefined'
  39375. ) {
  39376. console[console.info ? 'info' : 'log'](
  39377. "You are running Vue in development mode.\n" +
  39378. "Make sure to turn on production mode when deploying for production.\n" +
  39379. "See more tips at https://vuejs.org/guide/deployment.html"
  39380. );
  39381. }
  39382. }, 0);
  39383. /* */
  39384. // check whether current browser encodes a char inside attribute values
  39385. function shouldDecode (content, encoded) {
  39386. var div = document.createElement('div');
  39387. div.innerHTML = "<div a=\"" + content + "\">";
  39388. return div.innerHTML.indexOf(encoded) > 0
  39389. }
  39390. // #3663
  39391. // IE encodes newlines inside attribute values while other browsers don't
  39392. var shouldDecodeNewlines = inBrowser ? shouldDecode('\n', '&#10;') : false;
  39393. /* */
  39394. var isUnaryTag = makeMap(
  39395. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  39396. 'link,meta,param,source,track,wbr'
  39397. );
  39398. // Elements that you can, intentionally, leave open
  39399. // (and which close themselves)
  39400. var canBeLeftOpenTag = makeMap(
  39401. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  39402. );
  39403. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  39404. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  39405. var isNonPhrasingTag = makeMap(
  39406. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  39407. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  39408. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  39409. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  39410. 'title,tr,track'
  39411. );
  39412. /* */
  39413. var decoder;
  39414. function decode (html) {
  39415. decoder = decoder || document.createElement('div');
  39416. decoder.innerHTML = html;
  39417. return decoder.textContent
  39418. }
  39419. /**
  39420. * Not type-checking this file because it's mostly vendor code.
  39421. */
  39422. /*!
  39423. * HTML Parser By John Resig (ejohn.org)
  39424. * Modified by Juriy "kangax" Zaytsev
  39425. * Original code by Erik Arvidsson, Mozilla Public License
  39426. * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
  39427. */
  39428. // Regular Expressions for parsing tags and attributes
  39429. var singleAttrIdentifier = /([^\s"'<>/=]+)/;
  39430. var singleAttrAssign = /(?:=)/;
  39431. var singleAttrValues = [
  39432. // attr value double quotes
  39433. /"([^"]*)"+/.source,
  39434. // attr value, single quotes
  39435. /'([^']*)'+/.source,
  39436. // attr value, no quotes
  39437. /([^\s"'=<>`]+)/.source
  39438. ];
  39439. var attribute = new RegExp(
  39440. '^\\s*' + singleAttrIdentifier.source +
  39441. '(?:\\s*(' + singleAttrAssign.source + ')' +
  39442. '\\s*(?:' + singleAttrValues.join('|') + '))?'
  39443. );
  39444. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  39445. // but for Vue templates we can enforce a simple charset
  39446. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  39447. var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
  39448. var startTagOpen = new RegExp('^<' + qnameCapture);
  39449. var startTagClose = /^\s*(\/?)>/;
  39450. var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
  39451. var doctype = /^<!DOCTYPE [^>]+>/i;
  39452. var comment = /^<!--/;
  39453. var conditionalComment = /^<!\[/;
  39454. var IS_REGEX_CAPTURING_BROKEN = false;
  39455. 'x'.replace(/x(.)?/g, function (m, g) {
  39456. IS_REGEX_CAPTURING_BROKEN = g === '';
  39457. });
  39458. // Special Elements (can contain anything)
  39459. var isPlainTextElement = makeMap('script,style,textarea', true);
  39460. var reCache = {};
  39461. var decodingMap = {
  39462. '&lt;': '<',
  39463. '&gt;': '>',
  39464. '&quot;': '"',
  39465. '&amp;': '&',
  39466. '&#10;': '\n'
  39467. };
  39468. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  39469. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g;
  39470. function decodeAttr (value, shouldDecodeNewlines) {
  39471. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  39472. return value.replace(re, function (match) { return decodingMap[match]; })
  39473. }
  39474. function parseHTML (html, options) {
  39475. var stack = [];
  39476. var expectHTML = options.expectHTML;
  39477. var isUnaryTag$$1 = options.isUnaryTag || no;
  39478. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  39479. var index = 0;
  39480. var last, lastTag;
  39481. while (html) {
  39482. last = html;
  39483. // Make sure we're not in a plaintext content element like script/style
  39484. if (!lastTag || !isPlainTextElement(lastTag)) {
  39485. var textEnd = html.indexOf('<');
  39486. if (textEnd === 0) {
  39487. // Comment:
  39488. if (comment.test(html)) {
  39489. var commentEnd = html.indexOf('-->');
  39490. if (commentEnd >= 0) {
  39491. advance(commentEnd + 3);
  39492. continue
  39493. }
  39494. }
  39495. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  39496. if (conditionalComment.test(html)) {
  39497. var conditionalEnd = html.indexOf(']>');
  39498. if (conditionalEnd >= 0) {
  39499. advance(conditionalEnd + 2);
  39500. continue
  39501. }
  39502. }
  39503. // Doctype:
  39504. var doctypeMatch = html.match(doctype);
  39505. if (doctypeMatch) {
  39506. advance(doctypeMatch[0].length);
  39507. continue
  39508. }
  39509. // End tag:
  39510. var endTagMatch = html.match(endTag);
  39511. if (endTagMatch) {
  39512. var curIndex = index;
  39513. advance(endTagMatch[0].length);
  39514. parseEndTag(endTagMatch[1], curIndex, index);
  39515. continue
  39516. }
  39517. // Start tag:
  39518. var startTagMatch = parseStartTag();
  39519. if (startTagMatch) {
  39520. handleStartTag(startTagMatch);
  39521. continue
  39522. }
  39523. }
  39524. var text = (void 0), rest$1 = (void 0), next = (void 0);
  39525. if (textEnd >= 0) {
  39526. rest$1 = html.slice(textEnd);
  39527. while (
  39528. !endTag.test(rest$1) &&
  39529. !startTagOpen.test(rest$1) &&
  39530. !comment.test(rest$1) &&
  39531. !conditionalComment.test(rest$1)
  39532. ) {
  39533. // < in plain text, be forgiving and treat it as text
  39534. next = rest$1.indexOf('<', 1);
  39535. if (next < 0) { break }
  39536. textEnd += next;
  39537. rest$1 = html.slice(textEnd);
  39538. }
  39539. text = html.substring(0, textEnd);
  39540. advance(textEnd);
  39541. }
  39542. if (textEnd < 0) {
  39543. text = html;
  39544. html = '';
  39545. }
  39546. if (options.chars && text) {
  39547. options.chars(text);
  39548. }
  39549. } else {
  39550. var stackedTag = lastTag.toLowerCase();
  39551. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  39552. var endTagLength = 0;
  39553. var rest = html.replace(reStackedTag, function (all, text, endTag) {
  39554. endTagLength = endTag.length;
  39555. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  39556. text = text
  39557. .replace(/<!--([\s\S]*?)-->/g, '$1')
  39558. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  39559. }
  39560. if (options.chars) {
  39561. options.chars(text);
  39562. }
  39563. return ''
  39564. });
  39565. index += html.length - rest.length;
  39566. html = rest;
  39567. parseEndTag(stackedTag, index - endTagLength, index);
  39568. }
  39569. if (html === last) {
  39570. options.chars && options.chars(html);
  39571. if ("development" !== 'production' && !stack.length && options.warn) {
  39572. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  39573. }
  39574. break
  39575. }
  39576. }
  39577. // Clean up any remaining tags
  39578. parseEndTag();
  39579. function advance (n) {
  39580. index += n;
  39581. html = html.substring(n);
  39582. }
  39583. function parseStartTag () {
  39584. var start = html.match(startTagOpen);
  39585. if (start) {
  39586. var match = {
  39587. tagName: start[1],
  39588. attrs: [],
  39589. start: index
  39590. };
  39591. advance(start[0].length);
  39592. var end, attr;
  39593. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  39594. advance(attr[0].length);
  39595. match.attrs.push(attr);
  39596. }
  39597. if (end) {
  39598. match.unarySlash = end[1];
  39599. advance(end[0].length);
  39600. match.end = index;
  39601. return match
  39602. }
  39603. }
  39604. }
  39605. function handleStartTag (match) {
  39606. var tagName = match.tagName;
  39607. var unarySlash = match.unarySlash;
  39608. if (expectHTML) {
  39609. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  39610. parseEndTag(lastTag);
  39611. }
  39612. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  39613. parseEndTag(tagName);
  39614. }
  39615. }
  39616. var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
  39617. var l = match.attrs.length;
  39618. var attrs = new Array(l);
  39619. for (var i = 0; i < l; i++) {
  39620. var args = match.attrs[i];
  39621. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  39622. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  39623. if (args[3] === '') { delete args[3]; }
  39624. if (args[4] === '') { delete args[4]; }
  39625. if (args[5] === '') { delete args[5]; }
  39626. }
  39627. var value = args[3] || args[4] || args[5] || '';
  39628. attrs[i] = {
  39629. name: args[1],
  39630. value: decodeAttr(
  39631. value,
  39632. options.shouldDecodeNewlines
  39633. )
  39634. };
  39635. }
  39636. if (!unary) {
  39637. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  39638. lastTag = tagName;
  39639. }
  39640. if (options.start) {
  39641. options.start(tagName, attrs, unary, match.start, match.end);
  39642. }
  39643. }
  39644. function parseEndTag (tagName, start, end) {
  39645. var pos, lowerCasedTagName;
  39646. if (start == null) { start = index; }
  39647. if (end == null) { end = index; }
  39648. if (tagName) {
  39649. lowerCasedTagName = tagName.toLowerCase();
  39650. }
  39651. // Find the closest opened tag of the same type
  39652. if (tagName) {
  39653. for (pos = stack.length - 1; pos >= 0; pos--) {
  39654. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  39655. break
  39656. }
  39657. }
  39658. } else {
  39659. // If no tag name is provided, clean shop
  39660. pos = 0;
  39661. }
  39662. if (pos >= 0) {
  39663. // Close all the open elements, up the stack
  39664. for (var i = stack.length - 1; i >= pos; i--) {
  39665. if ("development" !== 'production' &&
  39666. (i > pos || !tagName) &&
  39667. options.warn
  39668. ) {
  39669. options.warn(
  39670. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  39671. );
  39672. }
  39673. if (options.end) {
  39674. options.end(stack[i].tag, start, end);
  39675. }
  39676. }
  39677. // Remove the open elements from the stack
  39678. stack.length = pos;
  39679. lastTag = pos && stack[pos - 1].tag;
  39680. } else if (lowerCasedTagName === 'br') {
  39681. if (options.start) {
  39682. options.start(tagName, [], true, start, end);
  39683. }
  39684. } else if (lowerCasedTagName === 'p') {
  39685. if (options.start) {
  39686. options.start(tagName, [], false, start, end);
  39687. }
  39688. if (options.end) {
  39689. options.end(tagName, start, end);
  39690. }
  39691. }
  39692. }
  39693. }
  39694. /* */
  39695. var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
  39696. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  39697. var buildRegex = cached(function (delimiters) {
  39698. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  39699. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  39700. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  39701. });
  39702. function parseText (
  39703. text,
  39704. delimiters
  39705. ) {
  39706. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  39707. if (!tagRE.test(text)) {
  39708. return
  39709. }
  39710. var tokens = [];
  39711. var lastIndex = tagRE.lastIndex = 0;
  39712. var match, index;
  39713. while ((match = tagRE.exec(text))) {
  39714. index = match.index;
  39715. // push text token
  39716. if (index > lastIndex) {
  39717. tokens.push(JSON.stringify(text.slice(lastIndex, index)));
  39718. }
  39719. // tag token
  39720. var exp = parseFilters(match[1].trim());
  39721. tokens.push(("_s(" + exp + ")"));
  39722. lastIndex = index + match[0].length;
  39723. }
  39724. if (lastIndex < text.length) {
  39725. tokens.push(JSON.stringify(text.slice(lastIndex)));
  39726. }
  39727. return tokens.join('+')
  39728. }
  39729. /* */
  39730. var onRE = /^@|^v-on:/;
  39731. var dirRE = /^v-|^@|^:/;
  39732. var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
  39733. var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
  39734. var argRE = /:(.*)$/;
  39735. var bindRE = /^:|^v-bind:/;
  39736. var modifierRE = /\.[^.]+/g;
  39737. var decodeHTMLCached = cached(decode);
  39738. // configurable state
  39739. var warn$2;
  39740. var delimiters;
  39741. var transforms;
  39742. var preTransforms;
  39743. var postTransforms;
  39744. var platformIsPreTag;
  39745. var platformMustUseProp;
  39746. var platformGetTagNamespace;
  39747. /**
  39748. * Convert HTML string to AST.
  39749. */
  39750. function parse (
  39751. template,
  39752. options
  39753. ) {
  39754. warn$2 = options.warn || baseWarn;
  39755. platformGetTagNamespace = options.getTagNamespace || no;
  39756. platformMustUseProp = options.mustUseProp || no;
  39757. platformIsPreTag = options.isPreTag || no;
  39758. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  39759. transforms = pluckModuleFunction(options.modules, 'transformNode');
  39760. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  39761. delimiters = options.delimiters;
  39762. var stack = [];
  39763. var preserveWhitespace = options.preserveWhitespace !== false;
  39764. var root;
  39765. var currentParent;
  39766. var inVPre = false;
  39767. var inPre = false;
  39768. var warned = false;
  39769. function warnOnce (msg) {
  39770. if (!warned) {
  39771. warned = true;
  39772. warn$2(msg);
  39773. }
  39774. }
  39775. function endPre (element) {
  39776. // check pre state
  39777. if (element.pre) {
  39778. inVPre = false;
  39779. }
  39780. if (platformIsPreTag(element.tag)) {
  39781. inPre = false;
  39782. }
  39783. }
  39784. parseHTML(template, {
  39785. warn: warn$2,
  39786. expectHTML: options.expectHTML,
  39787. isUnaryTag: options.isUnaryTag,
  39788. canBeLeftOpenTag: options.canBeLeftOpenTag,
  39789. shouldDecodeNewlines: options.shouldDecodeNewlines,
  39790. start: function start (tag, attrs, unary) {
  39791. // check namespace.
  39792. // inherit parent ns if there is one
  39793. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  39794. // handle IE svg bug
  39795. /* istanbul ignore if */
  39796. if (isIE && ns === 'svg') {
  39797. attrs = guardIESVGBug(attrs);
  39798. }
  39799. var element = {
  39800. type: 1,
  39801. tag: tag,
  39802. attrsList: attrs,
  39803. attrsMap: makeAttrsMap(attrs),
  39804. parent: currentParent,
  39805. children: []
  39806. };
  39807. if (ns) {
  39808. element.ns = ns;
  39809. }
  39810. if (isForbiddenTag(element) && !isServerRendering()) {
  39811. element.forbidden = true;
  39812. "development" !== 'production' && warn$2(
  39813. 'Templates should only be responsible for mapping the state to the ' +
  39814. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  39815. "<" + tag + ">" + ', as they will not be parsed.'
  39816. );
  39817. }
  39818. // apply pre-transforms
  39819. for (var i = 0; i < preTransforms.length; i++) {
  39820. preTransforms[i](element, options);
  39821. }
  39822. if (!inVPre) {
  39823. processPre(element);
  39824. if (element.pre) {
  39825. inVPre = true;
  39826. }
  39827. }
  39828. if (platformIsPreTag(element.tag)) {
  39829. inPre = true;
  39830. }
  39831. if (inVPre) {
  39832. processRawAttrs(element);
  39833. } else {
  39834. processFor(element);
  39835. processIf(element);
  39836. processOnce(element);
  39837. processKey(element);
  39838. // determine whether this is a plain element after
  39839. // removing structural attributes
  39840. element.plain = !element.key && !attrs.length;
  39841. processRef(element);
  39842. processSlot(element);
  39843. processComponent(element);
  39844. for (var i$1 = 0; i$1 < transforms.length; i$1++) {
  39845. transforms[i$1](element, options);
  39846. }
  39847. processAttrs(element);
  39848. }
  39849. function checkRootConstraints (el) {
  39850. if (true) {
  39851. if (el.tag === 'slot' || el.tag === 'template') {
  39852. warnOnce(
  39853. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  39854. 'contain multiple nodes.'
  39855. );
  39856. }
  39857. if (el.attrsMap.hasOwnProperty('v-for')) {
  39858. warnOnce(
  39859. 'Cannot use v-for on stateful component root element because ' +
  39860. 'it renders multiple elements.'
  39861. );
  39862. }
  39863. }
  39864. }
  39865. // tree management
  39866. if (!root) {
  39867. root = element;
  39868. checkRootConstraints(root);
  39869. } else if (!stack.length) {
  39870. // allow root elements with v-if, v-else-if and v-else
  39871. if (root.if && (element.elseif || element.else)) {
  39872. checkRootConstraints(element);
  39873. addIfCondition(root, {
  39874. exp: element.elseif,
  39875. block: element
  39876. });
  39877. } else if (true) {
  39878. warnOnce(
  39879. "Component template should contain exactly one root element. " +
  39880. "If you are using v-if on multiple elements, " +
  39881. "use v-else-if to chain them instead."
  39882. );
  39883. }
  39884. }
  39885. if (currentParent && !element.forbidden) {
  39886. if (element.elseif || element.else) {
  39887. processIfConditions(element, currentParent);
  39888. } else if (element.slotScope) { // scoped slot
  39889. currentParent.plain = false;
  39890. var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  39891. } else {
  39892. currentParent.children.push(element);
  39893. element.parent = currentParent;
  39894. }
  39895. }
  39896. if (!unary) {
  39897. currentParent = element;
  39898. stack.push(element);
  39899. } else {
  39900. endPre(element);
  39901. }
  39902. // apply post-transforms
  39903. for (var i$2 = 0; i$2 < postTransforms.length; i$2++) {
  39904. postTransforms[i$2](element, options);
  39905. }
  39906. },
  39907. end: function end () {
  39908. // remove trailing whitespace
  39909. var element = stack[stack.length - 1];
  39910. var lastNode = element.children[element.children.length - 1];
  39911. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  39912. element.children.pop();
  39913. }
  39914. // pop stack
  39915. stack.length -= 1;
  39916. currentParent = stack[stack.length - 1];
  39917. endPre(element);
  39918. },
  39919. chars: function chars (text) {
  39920. if (!currentParent) {
  39921. if (true) {
  39922. if (text === template) {
  39923. warnOnce(
  39924. 'Component template requires a root element, rather than just text.'
  39925. );
  39926. } else if ((text = text.trim())) {
  39927. warnOnce(
  39928. ("text \"" + text + "\" outside root element will be ignored.")
  39929. );
  39930. }
  39931. }
  39932. return
  39933. }
  39934. // IE textarea placeholder bug
  39935. /* istanbul ignore if */
  39936. if (isIE &&
  39937. currentParent.tag === 'textarea' &&
  39938. currentParent.attrsMap.placeholder === text
  39939. ) {
  39940. return
  39941. }
  39942. var children = currentParent.children;
  39943. text = inPre || text.trim()
  39944. ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
  39945. // only preserve whitespace if its not right after a starting tag
  39946. : preserveWhitespace && children.length ? ' ' : '';
  39947. if (text) {
  39948. var expression;
  39949. if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
  39950. children.push({
  39951. type: 2,
  39952. expression: expression,
  39953. text: text
  39954. });
  39955. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  39956. children.push({
  39957. type: 3,
  39958. text: text
  39959. });
  39960. }
  39961. }
  39962. }
  39963. });
  39964. return root
  39965. }
  39966. function processPre (el) {
  39967. if (getAndRemoveAttr(el, 'v-pre') != null) {
  39968. el.pre = true;
  39969. }
  39970. }
  39971. function processRawAttrs (el) {
  39972. var l = el.attrsList.length;
  39973. if (l) {
  39974. var attrs = el.attrs = new Array(l);
  39975. for (var i = 0; i < l; i++) {
  39976. attrs[i] = {
  39977. name: el.attrsList[i].name,
  39978. value: JSON.stringify(el.attrsList[i].value)
  39979. };
  39980. }
  39981. } else if (!el.pre) {
  39982. // non root node in pre blocks with no attributes
  39983. el.plain = true;
  39984. }
  39985. }
  39986. function processKey (el) {
  39987. var exp = getBindingAttr(el, 'key');
  39988. if (exp) {
  39989. if ("development" !== 'production' && el.tag === 'template') {
  39990. warn$2("<template> cannot be keyed. Place the key on real elements instead.");
  39991. }
  39992. el.key = exp;
  39993. }
  39994. }
  39995. function processRef (el) {
  39996. var ref = getBindingAttr(el, 'ref');
  39997. if (ref) {
  39998. el.ref = ref;
  39999. el.refInFor = checkInFor(el);
  40000. }
  40001. }
  40002. function processFor (el) {
  40003. var exp;
  40004. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  40005. var inMatch = exp.match(forAliasRE);
  40006. if (!inMatch) {
  40007. "development" !== 'production' && warn$2(
  40008. ("Invalid v-for expression: " + exp)
  40009. );
  40010. return
  40011. }
  40012. el.for = inMatch[2].trim();
  40013. var alias = inMatch[1].trim();
  40014. var iteratorMatch = alias.match(forIteratorRE);
  40015. if (iteratorMatch) {
  40016. el.alias = iteratorMatch[1].trim();
  40017. el.iterator1 = iteratorMatch[2].trim();
  40018. if (iteratorMatch[3]) {
  40019. el.iterator2 = iteratorMatch[3].trim();
  40020. }
  40021. } else {
  40022. el.alias = alias;
  40023. }
  40024. }
  40025. }
  40026. function processIf (el) {
  40027. var exp = getAndRemoveAttr(el, 'v-if');
  40028. if (exp) {
  40029. el.if = exp;
  40030. addIfCondition(el, {
  40031. exp: exp,
  40032. block: el
  40033. });
  40034. } else {
  40035. if (getAndRemoveAttr(el, 'v-else') != null) {
  40036. el.else = true;
  40037. }
  40038. var elseif = getAndRemoveAttr(el, 'v-else-if');
  40039. if (elseif) {
  40040. el.elseif = elseif;
  40041. }
  40042. }
  40043. }
  40044. function processIfConditions (el, parent) {
  40045. var prev = findPrevElement(parent.children);
  40046. if (prev && prev.if) {
  40047. addIfCondition(prev, {
  40048. exp: el.elseif,
  40049. block: el
  40050. });
  40051. } else if (true) {
  40052. warn$2(
  40053. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  40054. "used on element <" + (el.tag) + "> without corresponding v-if."
  40055. );
  40056. }
  40057. }
  40058. function findPrevElement (children) {
  40059. var i = children.length;
  40060. while (i--) {
  40061. if (children[i].type === 1) {
  40062. return children[i]
  40063. } else {
  40064. if ("development" !== 'production' && children[i].text !== ' ') {
  40065. warn$2(
  40066. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  40067. "will be ignored."
  40068. );
  40069. }
  40070. children.pop();
  40071. }
  40072. }
  40073. }
  40074. function addIfCondition (el, condition) {
  40075. if (!el.ifConditions) {
  40076. el.ifConditions = [];
  40077. }
  40078. el.ifConditions.push(condition);
  40079. }
  40080. function processOnce (el) {
  40081. var once$$1 = getAndRemoveAttr(el, 'v-once');
  40082. if (once$$1 != null) {
  40083. el.once = true;
  40084. }
  40085. }
  40086. function processSlot (el) {
  40087. if (el.tag === 'slot') {
  40088. el.slotName = getBindingAttr(el, 'name');
  40089. if ("development" !== 'production' && el.key) {
  40090. warn$2(
  40091. "`key` does not work on <slot> because slots are abstract outlets " +
  40092. "and can possibly expand into multiple elements. " +
  40093. "Use the key on a wrapping element instead."
  40094. );
  40095. }
  40096. } else {
  40097. var slotTarget = getBindingAttr(el, 'slot');
  40098. if (slotTarget) {
  40099. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  40100. }
  40101. if (el.tag === 'template') {
  40102. el.slotScope = getAndRemoveAttr(el, 'scope');
  40103. }
  40104. }
  40105. }
  40106. function processComponent (el) {
  40107. var binding;
  40108. if ((binding = getBindingAttr(el, 'is'))) {
  40109. el.component = binding;
  40110. }
  40111. if (getAndRemoveAttr(el, 'inline-template') != null) {
  40112. el.inlineTemplate = true;
  40113. }
  40114. }
  40115. function processAttrs (el) {
  40116. var list = el.attrsList;
  40117. var i, l, name, rawName, value, modifiers, isProp;
  40118. for (i = 0, l = list.length; i < l; i++) {
  40119. name = rawName = list[i].name;
  40120. value = list[i].value;
  40121. if (dirRE.test(name)) {
  40122. // mark element as dynamic
  40123. el.hasBindings = true;
  40124. // modifiers
  40125. modifiers = parseModifiers(name);
  40126. if (modifiers) {
  40127. name = name.replace(modifierRE, '');
  40128. }
  40129. if (bindRE.test(name)) { // v-bind
  40130. name = name.replace(bindRE, '');
  40131. value = parseFilters(value);
  40132. isProp = false;
  40133. if (modifiers) {
  40134. if (modifiers.prop) {
  40135. isProp = true;
  40136. name = camelize(name);
  40137. if (name === 'innerHtml') { name = 'innerHTML'; }
  40138. }
  40139. if (modifiers.camel) {
  40140. name = camelize(name);
  40141. }
  40142. if (modifiers.sync) {
  40143. addHandler(
  40144. el,
  40145. ("update:" + (camelize(name))),
  40146. genAssignmentCode(value, "$event")
  40147. );
  40148. }
  40149. }
  40150. if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  40151. addProp(el, name, value);
  40152. } else {
  40153. addAttr(el, name, value);
  40154. }
  40155. } else if (onRE.test(name)) { // v-on
  40156. name = name.replace(onRE, '');
  40157. addHandler(el, name, value, modifiers, false, warn$2);
  40158. } else { // normal directives
  40159. name = name.replace(dirRE, '');
  40160. // parse arg
  40161. var argMatch = name.match(argRE);
  40162. var arg = argMatch && argMatch[1];
  40163. if (arg) {
  40164. name = name.slice(0, -(arg.length + 1));
  40165. }
  40166. addDirective(el, name, rawName, value, arg, modifiers);
  40167. if ("development" !== 'production' && name === 'model') {
  40168. checkForAliasModel(el, value);
  40169. }
  40170. }
  40171. } else {
  40172. // literal attribute
  40173. if (true) {
  40174. var expression = parseText(value, delimiters);
  40175. if (expression) {
  40176. warn$2(
  40177. name + "=\"" + value + "\": " +
  40178. 'Interpolation inside attributes has been removed. ' +
  40179. 'Use v-bind or the colon shorthand instead. For example, ' +
  40180. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  40181. );
  40182. }
  40183. }
  40184. addAttr(el, name, JSON.stringify(value));
  40185. }
  40186. }
  40187. }
  40188. function checkInFor (el) {
  40189. var parent = el;
  40190. while (parent) {
  40191. if (parent.for !== undefined) {
  40192. return true
  40193. }
  40194. parent = parent.parent;
  40195. }
  40196. return false
  40197. }
  40198. function parseModifiers (name) {
  40199. var match = name.match(modifierRE);
  40200. if (match) {
  40201. var ret = {};
  40202. match.forEach(function (m) { ret[m.slice(1)] = true; });
  40203. return ret
  40204. }
  40205. }
  40206. function makeAttrsMap (attrs) {
  40207. var map = {};
  40208. for (var i = 0, l = attrs.length; i < l; i++) {
  40209. if (
  40210. "development" !== 'production' &&
  40211. map[attrs[i].name] && !isIE && !isEdge
  40212. ) {
  40213. warn$2('duplicate attribute: ' + attrs[i].name);
  40214. }
  40215. map[attrs[i].name] = attrs[i].value;
  40216. }
  40217. return map
  40218. }
  40219. // for script (e.g. type="x/template") or style, do not decode content
  40220. function isTextTag (el) {
  40221. return el.tag === 'script' || el.tag === 'style'
  40222. }
  40223. function isForbiddenTag (el) {
  40224. return (
  40225. el.tag === 'style' ||
  40226. (el.tag === 'script' && (
  40227. !el.attrsMap.type ||
  40228. el.attrsMap.type === 'text/javascript'
  40229. ))
  40230. )
  40231. }
  40232. var ieNSBug = /^xmlns:NS\d+/;
  40233. var ieNSPrefix = /^NS\d+:/;
  40234. /* istanbul ignore next */
  40235. function guardIESVGBug (attrs) {
  40236. var res = [];
  40237. for (var i = 0; i < attrs.length; i++) {
  40238. var attr = attrs[i];
  40239. if (!ieNSBug.test(attr.name)) {
  40240. attr.name = attr.name.replace(ieNSPrefix, '');
  40241. res.push(attr);
  40242. }
  40243. }
  40244. return res
  40245. }
  40246. function checkForAliasModel (el, value) {
  40247. var _el = el;
  40248. while (_el) {
  40249. if (_el.for && _el.alias === value) {
  40250. warn$2(
  40251. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  40252. "You are binding v-model directly to a v-for iteration alias. " +
  40253. "This will not be able to modify the v-for source array because " +
  40254. "writing to the alias is like modifying a function local variable. " +
  40255. "Consider using an array of objects and use v-model on an object property instead."
  40256. );
  40257. }
  40258. _el = _el.parent;
  40259. }
  40260. }
  40261. /* */
  40262. var isStaticKey;
  40263. var isPlatformReservedTag;
  40264. var genStaticKeysCached = cached(genStaticKeys$1);
  40265. /**
  40266. * Goal of the optimizer: walk the generated template AST tree
  40267. * and detect sub-trees that are purely static, i.e. parts of
  40268. * the DOM that never needs to change.
  40269. *
  40270. * Once we detect these sub-trees, we can:
  40271. *
  40272. * 1. Hoist them into constants, so that we no longer need to
  40273. * create fresh nodes for them on each re-render;
  40274. * 2. Completely skip them in the patching process.
  40275. */
  40276. function optimize (root, options) {
  40277. if (!root) { return }
  40278. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  40279. isPlatformReservedTag = options.isReservedTag || no;
  40280. // first pass: mark all non-static nodes.
  40281. markStatic$1(root);
  40282. // second pass: mark static roots.
  40283. markStaticRoots(root, false);
  40284. }
  40285. function genStaticKeys$1 (keys) {
  40286. return makeMap(
  40287. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  40288. (keys ? ',' + keys : '')
  40289. )
  40290. }
  40291. function markStatic$1 (node) {
  40292. node.static = isStatic(node);
  40293. if (node.type === 1) {
  40294. // do not make component slot content static. this avoids
  40295. // 1. components not able to mutate slot nodes
  40296. // 2. static slot content fails for hot-reloading
  40297. if (
  40298. !isPlatformReservedTag(node.tag) &&
  40299. node.tag !== 'slot' &&
  40300. node.attrsMap['inline-template'] == null
  40301. ) {
  40302. return
  40303. }
  40304. for (var i = 0, l = node.children.length; i < l; i++) {
  40305. var child = node.children[i];
  40306. markStatic$1(child);
  40307. if (!child.static) {
  40308. node.static = false;
  40309. }
  40310. }
  40311. }
  40312. }
  40313. function markStaticRoots (node, isInFor) {
  40314. if (node.type === 1) {
  40315. if (node.static || node.once) {
  40316. node.staticInFor = isInFor;
  40317. }
  40318. // For a node to qualify as a static root, it should have children that
  40319. // are not just static text. Otherwise the cost of hoisting out will
  40320. // outweigh the benefits and it's better off to just always render it fresh.
  40321. if (node.static && node.children.length && !(
  40322. node.children.length === 1 &&
  40323. node.children[0].type === 3
  40324. )) {
  40325. node.staticRoot = true;
  40326. return
  40327. } else {
  40328. node.staticRoot = false;
  40329. }
  40330. if (node.children) {
  40331. for (var i = 0, l = node.children.length; i < l; i++) {
  40332. markStaticRoots(node.children[i], isInFor || !!node.for);
  40333. }
  40334. }
  40335. if (node.ifConditions) {
  40336. walkThroughConditionsBlocks(node.ifConditions, isInFor);
  40337. }
  40338. }
  40339. }
  40340. function walkThroughConditionsBlocks (conditionBlocks, isInFor) {
  40341. for (var i = 1, len = conditionBlocks.length; i < len; i++) {
  40342. markStaticRoots(conditionBlocks[i].block, isInFor);
  40343. }
  40344. }
  40345. function isStatic (node) {
  40346. if (node.type === 2) { // expression
  40347. return false
  40348. }
  40349. if (node.type === 3) { // text
  40350. return true
  40351. }
  40352. return !!(node.pre || (
  40353. !node.hasBindings && // no dynamic bindings
  40354. !node.if && !node.for && // not v-if or v-for or v-else
  40355. !isBuiltInTag(node.tag) && // not a built-in
  40356. isPlatformReservedTag(node.tag) && // not a component
  40357. !isDirectChildOfTemplateFor(node) &&
  40358. Object.keys(node).every(isStaticKey)
  40359. ))
  40360. }
  40361. function isDirectChildOfTemplateFor (node) {
  40362. while (node.parent) {
  40363. node = node.parent;
  40364. if (node.tag !== 'template') {
  40365. return false
  40366. }
  40367. if (node.for) {
  40368. return true
  40369. }
  40370. }
  40371. return false
  40372. }
  40373. /* */
  40374. var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  40375. var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
  40376. // keyCode aliases
  40377. var keyCodes = {
  40378. esc: 27,
  40379. tab: 9,
  40380. enter: 13,
  40381. space: 32,
  40382. up: 38,
  40383. left: 37,
  40384. right: 39,
  40385. down: 40,
  40386. 'delete': [8, 46]
  40387. };
  40388. // #4868: modifiers that prevent the execution of the listener
  40389. // need to explicitly return null so that we can determine whether to remove
  40390. // the listener for .once
  40391. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  40392. var modifierCode = {
  40393. stop: '$event.stopPropagation();',
  40394. prevent: '$event.preventDefault();',
  40395. self: genGuard("$event.target !== $event.currentTarget"),
  40396. ctrl: genGuard("!$event.ctrlKey"),
  40397. shift: genGuard("!$event.shiftKey"),
  40398. alt: genGuard("!$event.altKey"),
  40399. meta: genGuard("!$event.metaKey"),
  40400. left: genGuard("'button' in $event && $event.button !== 0"),
  40401. middle: genGuard("'button' in $event && $event.button !== 1"),
  40402. right: genGuard("'button' in $event && $event.button !== 2")
  40403. };
  40404. function genHandlers (
  40405. events,
  40406. isNative,
  40407. warn
  40408. ) {
  40409. var res = isNative ? 'nativeOn:{' : 'on:{';
  40410. for (var name in events) {
  40411. var handler = events[name];
  40412. // #5330: warn click.right, since right clicks do not actually fire click events.
  40413. if ("development" !== 'production' &&
  40414. name === 'click' &&
  40415. handler && handler.modifiers && handler.modifiers.right
  40416. ) {
  40417. warn(
  40418. "Use \"contextmenu\" instead of \"click.right\" since right clicks " +
  40419. "do not actually fire \"click\" events."
  40420. );
  40421. }
  40422. res += "\"" + name + "\":" + (genHandler(name, handler)) + ",";
  40423. }
  40424. return res.slice(0, -1) + '}'
  40425. }
  40426. function genHandler (
  40427. name,
  40428. handler
  40429. ) {
  40430. if (!handler) {
  40431. return 'function(){}'
  40432. }
  40433. if (Array.isArray(handler)) {
  40434. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  40435. }
  40436. var isMethodPath = simplePathRE.test(handler.value);
  40437. var isFunctionExpression = fnExpRE.test(handler.value);
  40438. if (!handler.modifiers) {
  40439. return isMethodPath || isFunctionExpression
  40440. ? handler.value
  40441. : ("function($event){" + (handler.value) + "}") // inline statement
  40442. } else {
  40443. var code = '';
  40444. var genModifierCode = '';
  40445. var keys = [];
  40446. for (var key in handler.modifiers) {
  40447. if (modifierCode[key]) {
  40448. genModifierCode += modifierCode[key];
  40449. // left/right
  40450. if (keyCodes[key]) {
  40451. keys.push(key);
  40452. }
  40453. } else {
  40454. keys.push(key);
  40455. }
  40456. }
  40457. if (keys.length) {
  40458. code += genKeyFilter(keys);
  40459. }
  40460. // Make sure modifiers like prevent and stop get executed after key filtering
  40461. if (genModifierCode) {
  40462. code += genModifierCode;
  40463. }
  40464. var handlerCode = isMethodPath
  40465. ? handler.value + '($event)'
  40466. : isFunctionExpression
  40467. ? ("(" + (handler.value) + ")($event)")
  40468. : handler.value;
  40469. return ("function($event){" + code + handlerCode + "}")
  40470. }
  40471. }
  40472. function genKeyFilter (keys) {
  40473. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  40474. }
  40475. function genFilterCode (key) {
  40476. var keyVal = parseInt(key, 10);
  40477. if (keyVal) {
  40478. return ("$event.keyCode!==" + keyVal)
  40479. }
  40480. var alias = keyCodes[key];
  40481. return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
  40482. }
  40483. /* */
  40484. function bind$1 (el, dir) {
  40485. el.wrapData = function (code) {
  40486. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")")
  40487. };
  40488. }
  40489. /* */
  40490. var baseDirectives = {
  40491. bind: bind$1,
  40492. cloak: noop
  40493. };
  40494. /* */
  40495. // configurable state
  40496. var warn$3;
  40497. var transforms$1;
  40498. var dataGenFns;
  40499. var platformDirectives$1;
  40500. var isPlatformReservedTag$1;
  40501. var staticRenderFns;
  40502. var onceCount;
  40503. var currentOptions;
  40504. function generate (
  40505. ast,
  40506. options
  40507. ) {
  40508. // save previous staticRenderFns so generate calls can be nested
  40509. var prevStaticRenderFns = staticRenderFns;
  40510. var currentStaticRenderFns = staticRenderFns = [];
  40511. var prevOnceCount = onceCount;
  40512. onceCount = 0;
  40513. currentOptions = options;
  40514. warn$3 = options.warn || baseWarn;
  40515. transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
  40516. dataGenFns = pluckModuleFunction(options.modules, 'genData');
  40517. platformDirectives$1 = options.directives || {};
  40518. isPlatformReservedTag$1 = options.isReservedTag || no;
  40519. var code = ast ? genElement(ast) : '_c("div")';
  40520. staticRenderFns = prevStaticRenderFns;
  40521. onceCount = prevOnceCount;
  40522. return {
  40523. render: ("with(this){return " + code + "}"),
  40524. staticRenderFns: currentStaticRenderFns
  40525. }
  40526. }
  40527. function genElement (el) {
  40528. if (el.staticRoot && !el.staticProcessed) {
  40529. return genStatic(el)
  40530. } else if (el.once && !el.onceProcessed) {
  40531. return genOnce(el)
  40532. } else if (el.for && !el.forProcessed) {
  40533. return genFor(el)
  40534. } else if (el.if && !el.ifProcessed) {
  40535. return genIf(el)
  40536. } else if (el.tag === 'template' && !el.slotTarget) {
  40537. return genChildren(el) || 'void 0'
  40538. } else if (el.tag === 'slot') {
  40539. return genSlot(el)
  40540. } else {
  40541. // component or element
  40542. var code;
  40543. if (el.component) {
  40544. code = genComponent(el.component, el);
  40545. } else {
  40546. var data = el.plain ? undefined : genData(el);
  40547. var children = el.inlineTemplate ? null : genChildren(el, true);
  40548. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  40549. }
  40550. // module transforms
  40551. for (var i = 0; i < transforms$1.length; i++) {
  40552. code = transforms$1[i](el, code);
  40553. }
  40554. return code
  40555. }
  40556. }
  40557. // hoist static sub-trees out
  40558. function genStatic (el) {
  40559. el.staticProcessed = true;
  40560. staticRenderFns.push(("with(this){return " + (genElement(el)) + "}"));
  40561. return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  40562. }
  40563. // v-once
  40564. function genOnce (el) {
  40565. el.onceProcessed = true;
  40566. if (el.if && !el.ifProcessed) {
  40567. return genIf(el)
  40568. } else if (el.staticInFor) {
  40569. var key = '';
  40570. var parent = el.parent;
  40571. while (parent) {
  40572. if (parent.for) {
  40573. key = parent.key;
  40574. break
  40575. }
  40576. parent = parent.parent;
  40577. }
  40578. if (!key) {
  40579. "development" !== 'production' && warn$3(
  40580. "v-once can only be used inside v-for that is keyed. "
  40581. );
  40582. return genElement(el)
  40583. }
  40584. return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")")
  40585. } else {
  40586. return genStatic(el)
  40587. }
  40588. }
  40589. function genIf (el) {
  40590. el.ifProcessed = true; // avoid recursion
  40591. return genIfConditions(el.ifConditions.slice())
  40592. }
  40593. function genIfConditions (conditions) {
  40594. if (!conditions.length) {
  40595. return '_e()'
  40596. }
  40597. var condition = conditions.shift();
  40598. if (condition.exp) {
  40599. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions)))
  40600. } else {
  40601. return ("" + (genTernaryExp(condition.block)))
  40602. }
  40603. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  40604. function genTernaryExp (el) {
  40605. return el.once ? genOnce(el) : genElement(el)
  40606. }
  40607. }
  40608. function genFor (el) {
  40609. var exp = el.for;
  40610. var alias = el.alias;
  40611. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  40612. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  40613. if (
  40614. "development" !== 'production' &&
  40615. maybeComponent(el) && el.tag !== 'slot' && el.tag !== 'template' && !el.key
  40616. ) {
  40617. warn$3(
  40618. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  40619. "v-for should have explicit keys. " +
  40620. "See https://vuejs.org/guide/list.html#key for more info.",
  40621. true /* tip */
  40622. );
  40623. }
  40624. el.forProcessed = true; // avoid recursion
  40625. return "_l((" + exp + ")," +
  40626. "function(" + alias + iterator1 + iterator2 + "){" +
  40627. "return " + (genElement(el)) +
  40628. '})'
  40629. }
  40630. function genData (el) {
  40631. var data = '{';
  40632. // directives first.
  40633. // directives may mutate the el's other properties before they are generated.
  40634. var dirs = genDirectives(el);
  40635. if (dirs) { data += dirs + ','; }
  40636. // key
  40637. if (el.key) {
  40638. data += "key:" + (el.key) + ",";
  40639. }
  40640. // ref
  40641. if (el.ref) {
  40642. data += "ref:" + (el.ref) + ",";
  40643. }
  40644. if (el.refInFor) {
  40645. data += "refInFor:true,";
  40646. }
  40647. // pre
  40648. if (el.pre) {
  40649. data += "pre:true,";
  40650. }
  40651. // record original tag name for components using "is" attribute
  40652. if (el.component) {
  40653. data += "tag:\"" + (el.tag) + "\",";
  40654. }
  40655. // module data generation functions
  40656. for (var i = 0; i < dataGenFns.length; i++) {
  40657. data += dataGenFns[i](el);
  40658. }
  40659. // attributes
  40660. if (el.attrs) {
  40661. data += "attrs:{" + (genProps(el.attrs)) + "},";
  40662. }
  40663. // DOM props
  40664. if (el.props) {
  40665. data += "domProps:{" + (genProps(el.props)) + "},";
  40666. }
  40667. // event handlers
  40668. if (el.events) {
  40669. data += (genHandlers(el.events, false, warn$3)) + ",";
  40670. }
  40671. if (el.nativeEvents) {
  40672. data += (genHandlers(el.nativeEvents, true, warn$3)) + ",";
  40673. }
  40674. // slot target
  40675. if (el.slotTarget) {
  40676. data += "slot:" + (el.slotTarget) + ",";
  40677. }
  40678. // scoped slots
  40679. if (el.scopedSlots) {
  40680. data += (genScopedSlots(el.scopedSlots)) + ",";
  40681. }
  40682. // component v-model
  40683. if (el.model) {
  40684. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  40685. }
  40686. // inline-template
  40687. if (el.inlineTemplate) {
  40688. var inlineTemplate = genInlineTemplate(el);
  40689. if (inlineTemplate) {
  40690. data += inlineTemplate + ",";
  40691. }
  40692. }
  40693. data = data.replace(/,$/, '') + '}';
  40694. // v-bind data wrap
  40695. if (el.wrapData) {
  40696. data = el.wrapData(data);
  40697. }
  40698. return data
  40699. }
  40700. function genDirectives (el) {
  40701. var dirs = el.directives;
  40702. if (!dirs) { return }
  40703. var res = 'directives:[';
  40704. var hasRuntime = false;
  40705. var i, l, dir, needRuntime;
  40706. for (i = 0, l = dirs.length; i < l; i++) {
  40707. dir = dirs[i];
  40708. needRuntime = true;
  40709. var gen = platformDirectives$1[dir.name] || baseDirectives[dir.name];
  40710. if (gen) {
  40711. // compile-time directive that manipulates AST.
  40712. // returns true if it also needs a runtime counterpart.
  40713. needRuntime = !!gen(el, dir, warn$3);
  40714. }
  40715. if (needRuntime) {
  40716. hasRuntime = true;
  40717. 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))) : '') + "},";
  40718. }
  40719. }
  40720. if (hasRuntime) {
  40721. return res.slice(0, -1) + ']'
  40722. }
  40723. }
  40724. function genInlineTemplate (el) {
  40725. var ast = el.children[0];
  40726. if ("development" !== 'production' && (
  40727. el.children.length > 1 || ast.type !== 1
  40728. )) {
  40729. warn$3('Inline-template components must have exactly one child element.');
  40730. }
  40731. if (ast.type === 1) {
  40732. var inlineRenderFns = generate(ast, currentOptions);
  40733. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  40734. }
  40735. }
  40736. function genScopedSlots (slots) {
  40737. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "])")
  40738. }
  40739. function genScopedSlot (key, el) {
  40740. if (el.for && !el.forProcessed) {
  40741. return genForScopedSlot(key, el)
  40742. }
  40743. return "{key:" + key + ",fn:function(" + (String(el.attrsMap.scope)) + "){" +
  40744. "return " + (el.tag === 'template'
  40745. ? genChildren(el) || 'void 0'
  40746. : genElement(el)) + "}}"
  40747. }
  40748. function genForScopedSlot (key, el) {
  40749. var exp = el.for;
  40750. var alias = el.alias;
  40751. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  40752. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  40753. el.forProcessed = true; // avoid recursion
  40754. return "_l((" + exp + ")," +
  40755. "function(" + alias + iterator1 + iterator2 + "){" +
  40756. "return " + (genScopedSlot(key, el)) +
  40757. '})'
  40758. }
  40759. function genChildren (el, checkSkip) {
  40760. var children = el.children;
  40761. if (children.length) {
  40762. var el$1 = children[0];
  40763. // optimize single v-for
  40764. if (children.length === 1 &&
  40765. el$1.for &&
  40766. el$1.tag !== 'template' &&
  40767. el$1.tag !== 'slot'
  40768. ) {
  40769. return genElement(el$1)
  40770. }
  40771. var normalizationType = checkSkip ? getNormalizationType(children) : 0;
  40772. return ("[" + (children.map(genNode).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
  40773. }
  40774. }
  40775. // determine the normalization needed for the children array.
  40776. // 0: no normalization needed
  40777. // 1: simple normalization needed (possible 1-level deep nested array)
  40778. // 2: full normalization needed
  40779. function getNormalizationType (children) {
  40780. var res = 0;
  40781. for (var i = 0; i < children.length; i++) {
  40782. var el = children[i];
  40783. if (el.type !== 1) {
  40784. continue
  40785. }
  40786. if (needsNormalization(el) ||
  40787. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  40788. res = 2;
  40789. break
  40790. }
  40791. if (maybeComponent(el) ||
  40792. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  40793. res = 1;
  40794. }
  40795. }
  40796. return res
  40797. }
  40798. function needsNormalization (el) {
  40799. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  40800. }
  40801. function maybeComponent (el) {
  40802. return !isPlatformReservedTag$1(el.tag)
  40803. }
  40804. function genNode (node) {
  40805. if (node.type === 1) {
  40806. return genElement(node)
  40807. } else {
  40808. return genText(node)
  40809. }
  40810. }
  40811. function genText (text) {
  40812. return ("_v(" + (text.type === 2
  40813. ? text.expression // no need for () because already wrapped in _s()
  40814. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  40815. }
  40816. function genSlot (el) {
  40817. var slotName = el.slotName || '"default"';
  40818. var children = genChildren(el);
  40819. var res = "_t(" + slotName + (children ? ("," + children) : '');
  40820. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  40821. var bind$$1 = el.attrsMap['v-bind'];
  40822. if ((attrs || bind$$1) && !children) {
  40823. res += ",null";
  40824. }
  40825. if (attrs) {
  40826. res += "," + attrs;
  40827. }
  40828. if (bind$$1) {
  40829. res += (attrs ? '' : ',null') + "," + bind$$1;
  40830. }
  40831. return res + ')'
  40832. }
  40833. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  40834. function genComponent (componentName, el) {
  40835. var children = el.inlineTemplate ? null : genChildren(el, true);
  40836. return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")")
  40837. }
  40838. function genProps (props) {
  40839. var res = '';
  40840. for (var i = 0; i < props.length; i++) {
  40841. var prop = props[i];
  40842. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  40843. }
  40844. return res.slice(0, -1)
  40845. }
  40846. // #3895, #4268
  40847. function transformSpecialNewlines (text) {
  40848. return text
  40849. .replace(/\u2028/g, '\\u2028')
  40850. .replace(/\u2029/g, '\\u2029')
  40851. }
  40852. /* */
  40853. // these keywords should not appear inside expressions, but operators like
  40854. // typeof, instanceof and in are allowed
  40855. var prohibitedKeywordRE = new RegExp('\\b' + (
  40856. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  40857. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  40858. 'extends,finally,continue,debugger,function,arguments'
  40859. ).split(',').join('\\b|\\b') + '\\b');
  40860. // these unary operators should not be used as property/method names
  40861. var unaryOperatorsRE = new RegExp('\\b' + (
  40862. 'delete,typeof,void'
  40863. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  40864. // check valid identifier for v-for
  40865. var identRE = /[A-Za-z_$][\w$]*/;
  40866. // strip strings in expressions
  40867. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  40868. // detect problematic expressions in a template
  40869. function detectErrors (ast) {
  40870. var errors = [];
  40871. if (ast) {
  40872. checkNode(ast, errors);
  40873. }
  40874. return errors
  40875. }
  40876. function checkNode (node, errors) {
  40877. if (node.type === 1) {
  40878. for (var name in node.attrsMap) {
  40879. if (dirRE.test(name)) {
  40880. var value = node.attrsMap[name];
  40881. if (value) {
  40882. if (name === 'v-for') {
  40883. checkFor(node, ("v-for=\"" + value + "\""), errors);
  40884. } else if (onRE.test(name)) {
  40885. checkEvent(value, (name + "=\"" + value + "\""), errors);
  40886. } else {
  40887. checkExpression(value, (name + "=\"" + value + "\""), errors);
  40888. }
  40889. }
  40890. }
  40891. }
  40892. if (node.children) {
  40893. for (var i = 0; i < node.children.length; i++) {
  40894. checkNode(node.children[i], errors);
  40895. }
  40896. }
  40897. } else if (node.type === 2) {
  40898. checkExpression(node.expression, node.text, errors);
  40899. }
  40900. }
  40901. function checkEvent (exp, text, errors) {
  40902. var stipped = exp.replace(stripStringRE, '');
  40903. var keywordMatch = stipped.match(unaryOperatorsRE);
  40904. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  40905. errors.push(
  40906. "avoid using JavaScript unary operator as property name: " +
  40907. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  40908. );
  40909. }
  40910. checkExpression(exp, text, errors);
  40911. }
  40912. function checkFor (node, text, errors) {
  40913. checkExpression(node.for || '', text, errors);
  40914. checkIdentifier(node.alias, 'v-for alias', text, errors);
  40915. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  40916. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  40917. }
  40918. function checkIdentifier (ident, type, text, errors) {
  40919. if (typeof ident === 'string' && !identRE.test(ident)) {
  40920. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  40921. }
  40922. }
  40923. function checkExpression (exp, text, errors) {
  40924. try {
  40925. new Function(("return " + exp));
  40926. } catch (e) {
  40927. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  40928. if (keywordMatch) {
  40929. errors.push(
  40930. "avoid using JavaScript keyword as property name: " +
  40931. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  40932. );
  40933. } else {
  40934. errors.push(("invalid expression: " + (text.trim())));
  40935. }
  40936. }
  40937. }
  40938. /* */
  40939. function baseCompile (
  40940. template,
  40941. options
  40942. ) {
  40943. var ast = parse(template.trim(), options);
  40944. optimize(ast, options);
  40945. var code = generate(ast, options);
  40946. return {
  40947. ast: ast,
  40948. render: code.render,
  40949. staticRenderFns: code.staticRenderFns
  40950. }
  40951. }
  40952. function makeFunction (code, errors) {
  40953. try {
  40954. return new Function(code)
  40955. } catch (err) {
  40956. errors.push({ err: err, code: code });
  40957. return noop
  40958. }
  40959. }
  40960. function createCompiler (baseOptions) {
  40961. var functionCompileCache = Object.create(null);
  40962. function compile (
  40963. template,
  40964. options
  40965. ) {
  40966. var finalOptions = Object.create(baseOptions);
  40967. var errors = [];
  40968. var tips = [];
  40969. finalOptions.warn = function (msg, tip$$1) {
  40970. (tip$$1 ? tips : errors).push(msg);
  40971. };
  40972. if (options) {
  40973. // merge custom modules
  40974. if (options.modules) {
  40975. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  40976. }
  40977. // merge custom directives
  40978. if (options.directives) {
  40979. finalOptions.directives = extend(
  40980. Object.create(baseOptions.directives),
  40981. options.directives
  40982. );
  40983. }
  40984. // copy other options
  40985. for (var key in options) {
  40986. if (key !== 'modules' && key !== 'directives') {
  40987. finalOptions[key] = options[key];
  40988. }
  40989. }
  40990. }
  40991. var compiled = baseCompile(template, finalOptions);
  40992. if (true) {
  40993. errors.push.apply(errors, detectErrors(compiled.ast));
  40994. }
  40995. compiled.errors = errors;
  40996. compiled.tips = tips;
  40997. return compiled
  40998. }
  40999. function compileToFunctions (
  41000. template,
  41001. options,
  41002. vm
  41003. ) {
  41004. options = options || {};
  41005. /* istanbul ignore if */
  41006. if (true) {
  41007. // detect possible CSP restriction
  41008. try {
  41009. new Function('return 1');
  41010. } catch (e) {
  41011. if (e.toString().match(/unsafe-eval|CSP/)) {
  41012. warn(
  41013. 'It seems you are using the standalone build of Vue.js in an ' +
  41014. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  41015. 'The template compiler cannot work in this environment. Consider ' +
  41016. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  41017. 'templates into render functions.'
  41018. );
  41019. }
  41020. }
  41021. }
  41022. // check cache
  41023. var key = options.delimiters
  41024. ? String(options.delimiters) + template
  41025. : template;
  41026. if (functionCompileCache[key]) {
  41027. return functionCompileCache[key]
  41028. }
  41029. // compile
  41030. var compiled = compile(template, options);
  41031. // check compilation errors/tips
  41032. if (true) {
  41033. if (compiled.errors && compiled.errors.length) {
  41034. warn(
  41035. "Error compiling template:\n\n" + template + "\n\n" +
  41036. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  41037. vm
  41038. );
  41039. }
  41040. if (compiled.tips && compiled.tips.length) {
  41041. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  41042. }
  41043. }
  41044. // turn code into functions
  41045. var res = {};
  41046. var fnGenErrors = [];
  41047. res.render = makeFunction(compiled.render, fnGenErrors);
  41048. var l = compiled.staticRenderFns.length;
  41049. res.staticRenderFns = new Array(l);
  41050. for (var i = 0; i < l; i++) {
  41051. res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors);
  41052. }
  41053. // check function generation errors.
  41054. // this should only happen if there is a bug in the compiler itself.
  41055. // mostly for codegen development use
  41056. /* istanbul ignore if */
  41057. if (true) {
  41058. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  41059. warn(
  41060. "Failed to generate render function:\n\n" +
  41061. fnGenErrors.map(function (ref) {
  41062. var err = ref.err;
  41063. var code = ref.code;
  41064. return ((err.toString()) + " in\n\n" + code + "\n");
  41065. }).join('\n'),
  41066. vm
  41067. );
  41068. }
  41069. }
  41070. return (functionCompileCache[key] = res)
  41071. }
  41072. return {
  41073. compile: compile,
  41074. compileToFunctions: compileToFunctions
  41075. }
  41076. }
  41077. /* */
  41078. function transformNode (el, options) {
  41079. var warn = options.warn || baseWarn;
  41080. var staticClass = getAndRemoveAttr(el, 'class');
  41081. if ("development" !== 'production' && staticClass) {
  41082. var expression = parseText(staticClass, options.delimiters);
  41083. if (expression) {
  41084. warn(
  41085. "class=\"" + staticClass + "\": " +
  41086. 'Interpolation inside attributes has been removed. ' +
  41087. 'Use v-bind or the colon shorthand instead. For example, ' +
  41088. 'instead of <div class="{{ val }}">, use <div :class="val">.'
  41089. );
  41090. }
  41091. }
  41092. if (staticClass) {
  41093. el.staticClass = JSON.stringify(staticClass);
  41094. }
  41095. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  41096. if (classBinding) {
  41097. el.classBinding = classBinding;
  41098. }
  41099. }
  41100. function genData$1 (el) {
  41101. var data = '';
  41102. if (el.staticClass) {
  41103. data += "staticClass:" + (el.staticClass) + ",";
  41104. }
  41105. if (el.classBinding) {
  41106. data += "class:" + (el.classBinding) + ",";
  41107. }
  41108. return data
  41109. }
  41110. var klass$1 = {
  41111. staticKeys: ['staticClass'],
  41112. transformNode: transformNode,
  41113. genData: genData$1
  41114. };
  41115. /* */
  41116. function transformNode$1 (el, options) {
  41117. var warn = options.warn || baseWarn;
  41118. var staticStyle = getAndRemoveAttr(el, 'style');
  41119. if (staticStyle) {
  41120. /* istanbul ignore if */
  41121. if (true) {
  41122. var expression = parseText(staticStyle, options.delimiters);
  41123. if (expression) {
  41124. warn(
  41125. "style=\"" + staticStyle + "\": " +
  41126. 'Interpolation inside attributes has been removed. ' +
  41127. 'Use v-bind or the colon shorthand instead. For example, ' +
  41128. 'instead of <div style="{{ val }}">, use <div :style="val">.'
  41129. );
  41130. }
  41131. }
  41132. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  41133. }
  41134. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  41135. if (styleBinding) {
  41136. el.styleBinding = styleBinding;
  41137. }
  41138. }
  41139. function genData$2 (el) {
  41140. var data = '';
  41141. if (el.staticStyle) {
  41142. data += "staticStyle:" + (el.staticStyle) + ",";
  41143. }
  41144. if (el.styleBinding) {
  41145. data += "style:(" + (el.styleBinding) + "),";
  41146. }
  41147. return data
  41148. }
  41149. var style$1 = {
  41150. staticKeys: ['staticStyle'],
  41151. transformNode: transformNode$1,
  41152. genData: genData$2
  41153. };
  41154. var modules$1 = [
  41155. klass$1,
  41156. style$1
  41157. ];
  41158. /* */
  41159. function text (el, dir) {
  41160. if (dir.value) {
  41161. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
  41162. }
  41163. }
  41164. /* */
  41165. function html (el, dir) {
  41166. if (dir.value) {
  41167. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
  41168. }
  41169. }
  41170. var directives$1 = {
  41171. model: model,
  41172. text: text,
  41173. html: html
  41174. };
  41175. /* */
  41176. var baseOptions = {
  41177. expectHTML: true,
  41178. modules: modules$1,
  41179. directives: directives$1,
  41180. isPreTag: isPreTag,
  41181. isUnaryTag: isUnaryTag,
  41182. mustUseProp: mustUseProp,
  41183. canBeLeftOpenTag: canBeLeftOpenTag,
  41184. isReservedTag: isReservedTag,
  41185. getTagNamespace: getTagNamespace,
  41186. staticKeys: genStaticKeys(modules$1)
  41187. };
  41188. var ref$1 = createCompiler(baseOptions);
  41189. var compileToFunctions = ref$1.compileToFunctions;
  41190. /* */
  41191. var idToTemplate = cached(function (id) {
  41192. var el = query(id);
  41193. return el && el.innerHTML
  41194. });
  41195. var mount = Vue$3.prototype.$mount;
  41196. Vue$3.prototype.$mount = function (
  41197. el,
  41198. hydrating
  41199. ) {
  41200. el = el && query(el);
  41201. /* istanbul ignore if */
  41202. if (el === document.body || el === document.documentElement) {
  41203. "development" !== 'production' && warn(
  41204. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  41205. );
  41206. return this
  41207. }
  41208. var options = this.$options;
  41209. // resolve template/el and convert to render function
  41210. if (!options.render) {
  41211. var template = options.template;
  41212. if (template) {
  41213. if (typeof template === 'string') {
  41214. if (template.charAt(0) === '#') {
  41215. template = idToTemplate(template);
  41216. /* istanbul ignore if */
  41217. if ("development" !== 'production' && !template) {
  41218. warn(
  41219. ("Template element not found or is empty: " + (options.template)),
  41220. this
  41221. );
  41222. }
  41223. }
  41224. } else if (template.nodeType) {
  41225. template = template.innerHTML;
  41226. } else {
  41227. if (true) {
  41228. warn('invalid template option:' + template, this);
  41229. }
  41230. return this
  41231. }
  41232. } else if (el) {
  41233. template = getOuterHTML(el);
  41234. }
  41235. if (template) {
  41236. /* istanbul ignore if */
  41237. if ("development" !== 'production' && config.performance && mark) {
  41238. mark('compile');
  41239. }
  41240. var ref = compileToFunctions(template, {
  41241. shouldDecodeNewlines: shouldDecodeNewlines,
  41242. delimiters: options.delimiters
  41243. }, this);
  41244. var render = ref.render;
  41245. var staticRenderFns = ref.staticRenderFns;
  41246. options.render = render;
  41247. options.staticRenderFns = staticRenderFns;
  41248. /* istanbul ignore if */
  41249. if ("development" !== 'production' && config.performance && mark) {
  41250. mark('compile end');
  41251. measure(((this._name) + " compile"), 'compile', 'compile end');
  41252. }
  41253. }
  41254. }
  41255. return mount.call(this, el, hydrating)
  41256. };
  41257. /**
  41258. * Get outerHTML of elements, taking care
  41259. * of SVG elements in IE as well.
  41260. */
  41261. function getOuterHTML (el) {
  41262. if (el.outerHTML) {
  41263. return el.outerHTML
  41264. } else {
  41265. var container = document.createElement('div');
  41266. container.appendChild(el.cloneNode(true));
  41267. return container.innerHTML
  41268. }
  41269. }
  41270. Vue$3.compile = compileToFunctions;
  41271. module.exports = Vue$3;
  41272. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
  41273. /***/ }),
  41274. /* 39 */,
  41275. /* 40 */,
  41276. /* 41 */,
  41277. /* 42 */,
  41278. /* 43 */,
  41279. /* 44 */,
  41280. /* 45 */
  41281. /***/ (function(module, exports) {
  41282. // removed by extract-text-webpack-plugin
  41283. /***/ }),
  41284. /* 46 */,
  41285. /* 47 */,
  41286. /* 48 */,
  41287. /* 49 */,
  41288. /* 50 */,
  41289. /* 51 */,
  41290. /* 52 */,
  41291. /* 53 */,
  41292. /* 54 */,
  41293. /* 55 */,
  41294. /* 56 */
  41295. /***/ (function(module, exports, __webpack_require__) {
  41296. var disposed = false
  41297. var Component = __webpack_require__(8)(
  41298. /* script */
  41299. __webpack_require__(57),
  41300. /* template */
  41301. __webpack_require__(58),
  41302. /* styles */
  41303. null,
  41304. /* scopeId */
  41305. null,
  41306. /* moduleIdentifier (server only) */
  41307. null
  41308. )
  41309. Component.options.__file = "/Users/aaronpk/Code/spy30/resources/assets/js/components/TweetQueue.vue"
  41310. 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.")}
  41311. if (Component.options.functional) {console.error("[vue-loader] TweetQueue.vue: functional components are not supported with templates, they should use render functions.")}
  41312. /* hot reload */
  41313. if (false) {(function () {
  41314. var hotAPI = require("vue-hot-reload-api")
  41315. hotAPI.install(require("vue"), false)
  41316. if (!hotAPI.compatible) return
  41317. module.hot.accept()
  41318. if (!module.hot.data) {
  41319. hotAPI.createRecord("data-v-1798c0a1", Component.options)
  41320. } else {
  41321. hotAPI.reload("data-v-1798c0a1", Component.options)
  41322. }
  41323. module.hot.dispose(function (data) {
  41324. disposed = true
  41325. })
  41326. })()}
  41327. module.exports = Component.exports
  41328. /***/ }),
  41329. /* 57 */
  41330. /***/ (function(module, exports) {
  41331. //
  41332. //
  41333. //
  41334. //
  41335. //
  41336. //
  41337. //
  41338. //
  41339. //
  41340. //
  41341. //
  41342. //
  41343. //
  41344. //
  41345. //
  41346. //
  41347. //
  41348. //
  41349. //
  41350. //
  41351. //
  41352. //
  41353. //
  41354. //
  41355. //
  41356. module.exports = {
  41357. data: function data() {
  41358. return {
  41359. queue: [],
  41360. tweet: {},
  41361. show: false
  41362. };
  41363. },
  41364. methods: {
  41365. loadQueue: function loadQueue() {
  41366. $.get('/dashboard/queue', function (tweets) {
  41367. var _this = this;
  41368. for (var i in tweets.queue) {
  41369. this.queue.push(tweets.queue[i]);
  41370. }
  41371. // Listen for new items on the queue
  41372. Echo.channel('tweet-queue').listen('NewTweetEvent', function (e) {
  41373. if (_this.findTweetInQueue(e.tweet_id) === false) {
  41374. _this.queue.push(e);
  41375. // If the new tweet is one that timed out, dismiss it
  41376. if (_this.show && _this.tweet.tweet_id == e.tweet_id) {
  41377. _this.tweet = {};
  41378. _this.show = false;
  41379. }
  41380. }
  41381. }).listen('TweetClaimedEvent', function (e) {
  41382. _this.removeTweetFromQueue(e.tweet_id);
  41383. });
  41384. }.bind(this));
  41385. },
  41386. dashboardPing: function dashboardPing() {
  41387. setTimeout(function () {
  41388. $.get('/dashboard/ping', function () {
  41389. this.dashboardPing();
  41390. }.bind(this));
  41391. }.bind(this), 15000);
  41392. },
  41393. findTweetInQueue: function findTweetInQueue(tweet_id) {
  41394. var queueIndex = false;
  41395. for (var i in this.queue) {
  41396. if (parseInt(this.queue[i].tweet_id) == parseInt(tweet_id)) {
  41397. queueIndex = i;
  41398. }
  41399. }
  41400. return queueIndex;
  41401. },
  41402. removeTweetFromQueue: function removeTweetFromQueue(tweet_id) {
  41403. var queueIndex = this.findTweetInQueue(tweet_id);
  41404. if (queueIndex !== false) {
  41405. var removed = this.queue.splice(queueIndex, 1);
  41406. return removed[0];
  41407. }
  41408. },
  41409. clickedTweet: function clickedTweet(tweet_index) {
  41410. // If another tweet was already open, dismiss that first
  41411. if (this.show) {
  41412. this.dismissTweet();
  41413. }
  41414. var tweet_data = this.queue[tweet_index];
  41415. var tweet_id = tweet_data.tweet_id;
  41416. if (tweet_data) {
  41417. // Mark this as claimed
  41418. $.post('/dashboard/claim-tweet', {
  41419. tweet_id: tweet_id
  41420. }, function (response) {});
  41421. this.removeTweetFromQueue(tweet_id);
  41422. // Load in the scorecard viewer
  41423. this.tweet = tweet_data;
  41424. this.show = true;
  41425. } else {
  41426. console.log("Tweet not found: " + tweet_id);
  41427. }
  41428. },
  41429. dismissTweet: function dismissTweet() {
  41430. this.queue.push(this.tweet);
  41431. // Mark as un-claimed
  41432. $.post('/dashboard/claim-tweet', {
  41433. tweet_id: this.tweet.tweet_id,
  41434. status: 'unclaimed'
  41435. }, function (response) {});
  41436. this.tweet = {};
  41437. this.show = false;
  41438. },
  41439. completedTweet: function completedTweet() {
  41440. this.tweet = {};
  41441. this.show = false;
  41442. }
  41443. },
  41444. created: function created() {
  41445. this.loadQueue();
  41446. this.dashboardPing();
  41447. }
  41448. };
  41449. /***/ }),
  41450. /* 58 */
  41451. /***/ (function(module, exports, __webpack_require__) {
  41452. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41453. return _c('div', {
  41454. staticClass: "container"
  41455. }, [_c('div', {
  41456. staticClass: "row"
  41457. }, [_c('div', {
  41458. staticClass: "col-xs-4 col-md-4"
  41459. }, [_c('div', {
  41460. staticClass: "panel panel-default"
  41461. }, [_c('div', {
  41462. staticClass: "panel-heading"
  41463. }, [_vm._v("Queue")]), _vm._v(" "), _c('div', {
  41464. staticClass: "panel-body tweet-queue"
  41465. }, _vm._l((_vm.queue), function(tweet, index) {
  41466. return _c('div', {
  41467. staticClass: "tweet",
  41468. on: {
  41469. "click": function($event) {
  41470. _vm.clickedTweet(index)
  41471. }
  41472. }
  41473. }, [_c('div', {
  41474. staticClass: "mission"
  41475. }, [_vm._v(_vm._s(tweet.mission))]), _vm._v(" "), _c('div', {
  41476. staticClass: "profile"
  41477. }, [_c('img', {
  41478. style: ('border-color: #' + tweet.team_color),
  41479. attrs: {
  41480. "src": tweet.player_photo
  41481. }
  41482. }), _vm._v(" "), _c('span', [_vm._v("@" + _vm._s(tweet.player_username))])]), _vm._v(" "), _c('div', {
  41483. staticClass: "text"
  41484. }, [_vm._v(_vm._s(tweet.text))])])
  41485. }))])]), _vm._v(" "), _c('div', {
  41486. staticClass: "col-xs-8 col-md-8"
  41487. }, [_c('scorecard', {
  41488. attrs: {
  41489. "show": _vm.show,
  41490. "tweet": _vm.tweet
  41491. },
  41492. on: {
  41493. "update:show": function($event) {
  41494. _vm.show = $event
  41495. },
  41496. "dismiss": _vm.dismissTweet,
  41497. "complete": _vm.completedTweet
  41498. }
  41499. })], 1)])])
  41500. },staticRenderFns: []}
  41501. module.exports.render._withStripped = true
  41502. if (false) {
  41503. module.hot.accept()
  41504. if (module.hot.data) {
  41505. require("vue-hot-reload-api").rerender("data-v-1798c0a1", module.exports)
  41506. }
  41507. }
  41508. /***/ }),
  41509. /* 59 */
  41510. /***/ (function(module, exports, __webpack_require__) {
  41511. var disposed = false
  41512. var Component = __webpack_require__(8)(
  41513. /* script */
  41514. __webpack_require__(61),
  41515. /* template */
  41516. __webpack_require__(60),
  41517. /* styles */
  41518. null,
  41519. /* scopeId */
  41520. null,
  41521. /* moduleIdentifier (server only) */
  41522. null
  41523. )
  41524. Component.options.__file = "/Users/aaronpk/Code/spy30/resources/assets/js/components/Scorecard.vue"
  41525. 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.")}
  41526. if (Component.options.functional) {console.error("[vue-loader] Scorecard.vue: functional components are not supported with templates, they should use render functions.")}
  41527. /* hot reload */
  41528. if (false) {(function () {
  41529. var hotAPI = require("vue-hot-reload-api")
  41530. hotAPI.install(require("vue"), false)
  41531. if (!hotAPI.compatible) return
  41532. module.hot.accept()
  41533. if (!module.hot.data) {
  41534. hotAPI.createRecord("data-v-1098d79e", Component.options)
  41535. } else {
  41536. hotAPI.reload("data-v-1098d79e", Component.options)
  41537. }
  41538. module.hot.dispose(function (data) {
  41539. disposed = true
  41540. })
  41541. })()}
  41542. module.exports = Component.exports
  41543. /***/ }),
  41544. /* 60 */
  41545. /***/ (function(module, exports, __webpack_require__) {
  41546. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41547. return (_vm.show) ? _c('div', {
  41548. staticClass: "panel panel-default scorecard"
  41549. }, [_c('div', {
  41550. staticClass: "panel-heading"
  41551. }, [_c('div', {
  41552. staticClass: "team"
  41553. }, [_c('span', {
  41554. staticClass: "team-icon",
  41555. style: ('background-color: #' + _vm.tweet.team_color)
  41556. }), _vm._v(" "), _c('span', {
  41557. staticClass: "team-name"
  41558. }, [_vm._v(_vm._s(_vm.tweet.team_name))])]), _vm._v(" "), _c('h2', [_vm._v(_vm._s(_vm.tweet.mission))]), _vm._v(" "), _c('button', {
  41559. staticClass: "close",
  41560. attrs: {
  41561. "type": "button"
  41562. },
  41563. on: {
  41564. "click": _vm.dismiss
  41565. }
  41566. }, [_c('span', [_vm._v("×")])])]), _vm._v(" "), _c('div', {
  41567. staticClass: "panel-body"
  41568. }, [_c('div', {
  41569. staticClass: "row"
  41570. }, [_c('div', {
  41571. staticClass: "col-md-8"
  41572. }, [_c('div', {
  41573. staticClass: "profile"
  41574. }, [_c('img', {
  41575. style: ('border-color: #' + _vm.tweet.team_color),
  41576. attrs: {
  41577. "src": _vm.tweet.player_photo
  41578. }
  41579. }), _vm._v(" "), _c('span', [_c('a', {
  41580. attrs: {
  41581. "href": 'https://twitter.com/' + _vm.tweet.player_username
  41582. }
  41583. }, [_vm._v("@" + _vm._s(_vm.tweet.player_username))])])]), _vm._v(" "), _c('div', {
  41584. staticClass: "tweet"
  41585. }, [_c('div', {
  41586. staticClass: "text"
  41587. }, [_vm._v(_vm._s(_vm.tweet.text))]), _vm._v(" "), (_vm.tweet.photos) ? _c('div', [(_vm.tweet.photos) ? _c('div', {
  41588. class: 'multi-photo photos-' + _vm.tweet.photos.length
  41589. }, _vm._l((_vm.tweet.photos), function(img) {
  41590. return _c('div', {
  41591. staticClass: "photo",
  41592. style: ('background-image:url(' + img + ')'),
  41593. attrs: {
  41594. "data-featherlight": img
  41595. }
  41596. }, [_c('img', {
  41597. attrs: {
  41598. "src": img
  41599. }
  41600. })])
  41601. })) : _vm._e(), _vm._v(" "), _c('div', {
  41602. staticClass: "multi-photo-clear"
  41603. })]) : _vm._e()]), _vm._v(" "), _c('div', {
  41604. staticClass: "tweet-reply"
  41605. }, [_c('textarea', {
  41606. directives: [{
  41607. name: "model",
  41608. rawName: "v-model",
  41609. value: (_vm.replyText),
  41610. expression: "replyText"
  41611. }],
  41612. staticClass: "form-control",
  41613. staticStyle: {
  41614. "margin-bottom": "4px"
  41615. },
  41616. attrs: {
  41617. "rows": "2"
  41618. },
  41619. domProps: {
  41620. "value": (_vm.replyText)
  41621. },
  41622. on: {
  41623. "input": function($event) {
  41624. if ($event.target.composing) { return; }
  41625. _vm.replyText = $event.target.value
  41626. }
  41627. }
  41628. }), _vm._v(" "), _c('button', {
  41629. staticClass: "btn btn-primary",
  41630. attrs: {
  41631. "type": "submit",
  41632. "disabled": _vm.isTweetReplyDisabled
  41633. }
  41634. }, [_vm._v("Reply")]), _vm._v(" "), _c('div', {
  41635. staticClass: "clear"
  41636. })]), _vm._v(" "), _c('div', {
  41637. staticClass: "tweet-actions"
  41638. }, [_c('button', {
  41639. staticClass: "btn btn-success",
  41640. attrs: {
  41641. "type": "button",
  41642. "disabled": _vm.isAcceptDisabled
  41643. },
  41644. on: {
  41645. "click": _vm.scoreTweet
  41646. }
  41647. }, [_vm._v("Accept")]), _vm._v(" "), _c('button', {
  41648. staticClass: "btn btn-danger",
  41649. attrs: {
  41650. "type": "button"
  41651. },
  41652. on: {
  41653. "click": _vm.rejectTweet
  41654. }
  41655. }, [_vm._v("Reject")])])]), _vm._v(" "), _c('div', {
  41656. staticClass: "col-md-4"
  41657. }, [(_vm.tweet.mission_id == 1) ? [_c('p', {
  41658. staticClass: "instructions"
  41659. }, [_vm._v("\n The photo must show the sign with the transit line\n ")]), _vm._v(" "), _c('div', {
  41660. staticClass: "form-group"
  41661. }, [_c('select', {
  41662. directives: [{
  41663. name: "model",
  41664. rawName: "v-model",
  41665. value: (_vm.selectedTransitLine),
  41666. expression: "selectedTransitLine"
  41667. }],
  41668. staticClass: "form-control",
  41669. on: {
  41670. "change": function($event) {
  41671. var $$selectedVal = Array.prototype.filter.call($event.target.options, function(o) {
  41672. return o.selected
  41673. }).map(function(o) {
  41674. var val = "_value" in o ? o._value : o.value;
  41675. return val
  41676. });
  41677. _vm.selectedTransitLine = $event.target.multiple ? $$selectedVal : $$selectedVal[0]
  41678. }
  41679. }
  41680. }, [_c('option', {
  41681. attrs: {
  41682. "value": ""
  41683. }
  41684. }), _vm._v(" "), _vm._l((_vm.lines), function(line) {
  41685. return _c('option', {
  41686. domProps: {
  41687. "value": line.id
  41688. }
  41689. }, [_vm._v(_vm._s(line.name))])
  41690. })], 2)]), _vm._v(" "), _c('div', {
  41691. staticClass: "form-group"
  41692. }, [_c('input', {
  41693. directives: [{
  41694. name: "model",
  41695. rawName: "v-model",
  41696. value: (_vm.selectedNonTrimetLine),
  41697. expression: "selectedNonTrimetLine"
  41698. }],
  41699. staticClass: "form-control",
  41700. attrs: {
  41701. "type": "text",
  41702. "placeholder": "Non-Trimet Line"
  41703. },
  41704. domProps: {
  41705. "value": (_vm.selectedNonTrimetLine)
  41706. },
  41707. on: {
  41708. "input": function($event) {
  41709. if ($event.target.composing) { return; }
  41710. _vm.selectedNonTrimetLine = $event.target.value
  41711. }
  41712. }
  41713. })])] : _vm._e(), _vm._v(" "), (_vm.tweet.mission_id == 2) ? [_vm._m(0), _vm._v(" "), _c('div', {
  41714. staticClass: "form-group"
  41715. }, [_c('select', {
  41716. directives: [{
  41717. name: "model",
  41718. rawName: "v-model",
  41719. value: (_vm.selectedTransitCenter),
  41720. expression: "selectedTransitCenter"
  41721. }],
  41722. staticClass: "form-control",
  41723. on: {
  41724. "change": function($event) {
  41725. var $$selectedVal = Array.prototype.filter.call($event.target.options, function(o) {
  41726. return o.selected
  41727. }).map(function(o) {
  41728. var val = "_value" in o ? o._value : o.value;
  41729. return val
  41730. });
  41731. _vm.selectedTransitCenter = $event.target.multiple ? $$selectedVal : $$selectedVal[0]
  41732. }
  41733. }
  41734. }, [_c('option', {
  41735. attrs: {
  41736. "value": ""
  41737. }
  41738. }), _vm._v(" "), _vm._l((_vm.centers), function(stop) {
  41739. return _c('option', {
  41740. domProps: {
  41741. "value": stop.id
  41742. }
  41743. }, [_vm._v(_vm._s(stop.name))])
  41744. })], 2)]), _vm._v(" "), _c('div', {
  41745. staticClass: "form-group"
  41746. }, [_c('div', {
  41747. staticClass: "checkbox"
  41748. }, [_c('label', [_c('input', {
  41749. directives: [{
  41750. name: "model",
  41751. rawName: "v-model",
  41752. value: (_vm.selectedPhotoHasAnotherTeam),
  41753. expression: "selectedPhotoHasAnotherTeam"
  41754. }],
  41755. attrs: {
  41756. "type": "checkbox"
  41757. },
  41758. domProps: {
  41759. "checked": Array.isArray(_vm.selectedPhotoHasAnotherTeam) ? _vm._i(_vm.selectedPhotoHasAnotherTeam, null) > -1 : (_vm.selectedPhotoHasAnotherTeam)
  41760. },
  41761. on: {
  41762. "__c": function($event) {
  41763. var $$a = _vm.selectedPhotoHasAnotherTeam,
  41764. $$el = $event.target,
  41765. $$c = $$el.checked ? (true) : (false);
  41766. if (Array.isArray($$a)) {
  41767. var $$v = null,
  41768. $$i = _vm._i($$a, $$v);
  41769. if ($$c) {
  41770. $$i < 0 && (_vm.selectedPhotoHasAnotherTeam = $$a.concat($$v))
  41771. } else {
  41772. $$i > -1 && (_vm.selectedPhotoHasAnotherTeam = $$a.slice(0, $$i).concat($$a.slice($$i + 1)))
  41773. }
  41774. } else {
  41775. _vm.selectedPhotoHasAnotherTeam = $$c
  41776. }
  41777. }
  41778. }
  41779. }), _vm._v("\n Another team is in the photo\n ")])])])] : _vm._e(), _vm._v(" "), (_vm.tweet.mission_id == 3) ? [_vm._m(1)] : _vm._e(), _vm._v(" "), (_vm.tweet.mission_id == 4) ? [_vm._m(2)] : _vm._e(), _vm._v(" "), (_vm.tweet.mission_id == 5) ? [_c('p', {
  41780. staticClass: "instructions"
  41781. }, [_vm._v("\n Accept a photo of either a team member singing, or a photo of tipping the bus driver\n ")]), _vm._v(" "), _c('div', {
  41782. staticClass: "form-group"
  41783. }, [_c('label', [_c('input', {
  41784. directives: [{
  41785. name: "model",
  41786. rawName: "v-model",
  41787. value: (_vm.selectedM5Singing),
  41788. expression: "selectedM5Singing"
  41789. }],
  41790. attrs: {
  41791. "type": "checkbox"
  41792. },
  41793. domProps: {
  41794. "checked": Array.isArray(_vm.selectedM5Singing) ? _vm._i(_vm.selectedM5Singing, null) > -1 : (_vm.selectedM5Singing)
  41795. },
  41796. on: {
  41797. "__c": function($event) {
  41798. var $$a = _vm.selectedM5Singing,
  41799. $$el = $event.target,
  41800. $$c = $$el.checked ? (true) : (false);
  41801. if (Array.isArray($$a)) {
  41802. var $$v = null,
  41803. $$i = _vm._i($$a, $$v);
  41804. if ($$c) {
  41805. $$i < 0 && (_vm.selectedM5Singing = $$a.concat($$v))
  41806. } else {
  41807. $$i > -1 && (_vm.selectedM5Singing = $$a.slice(0, $$i).concat($$a.slice($$i + 1)))
  41808. }
  41809. } else {
  41810. _vm.selectedM5Singing = $$c
  41811. }
  41812. }
  41813. }
  41814. }), _vm._v("\n Singing\n ")]), _vm._v(" "), _c('br'), _vm._v(" "), _c('label', [_c('input', {
  41815. directives: [{
  41816. name: "model",
  41817. rawName: "v-model",
  41818. value: (_vm.selectedM5Tipping),
  41819. expression: "selectedM5Tipping"
  41820. }],
  41821. attrs: {
  41822. "type": "checkbox"
  41823. },
  41824. domProps: {
  41825. "checked": Array.isArray(_vm.selectedM5Tipping) ? _vm._i(_vm.selectedM5Tipping, null) > -1 : (_vm.selectedM5Tipping)
  41826. },
  41827. on: {
  41828. "__c": function($event) {
  41829. var $$a = _vm.selectedM5Tipping,
  41830. $$el = $event.target,
  41831. $$c = $$el.checked ? (true) : (false);
  41832. if (Array.isArray($$a)) {
  41833. var $$v = null,
  41834. $$i = _vm._i($$a, $$v);
  41835. if ($$c) {
  41836. $$i < 0 && (_vm.selectedM5Tipping = $$a.concat($$v))
  41837. } else {
  41838. $$i > -1 && (_vm.selectedM5Tipping = $$a.slice(0, $$i).concat($$a.slice($$i + 1)))
  41839. }
  41840. } else {
  41841. _vm.selectedM5Tipping = $$c
  41842. }
  41843. }
  41844. }
  41845. }), _vm._v("\n Tipping the driver\n ")])])] : _vm._e(), _vm._v(" "), (_vm.tweet.mission_id == 6) ? [_c('p', {
  41846. staticClass: "instructions"
  41847. }, [_vm._v("\n The photo must show all team members with their completed visas\n ")])] : _vm._e(), _vm._v(" "), (_vm.tweet.mission_id == 7) ? [_c('p', {
  41848. staticClass: "instructions"
  41849. }, [_vm._v("\n Accept a photo that completes one of the below documents:\n ")]), _vm._v(" "), _c('div', {
  41850. staticClass: "form-group"
  41851. }, _vm._l((_vm.documents), function(doc) {
  41852. return _c('div', {
  41853. staticClass: "radio"
  41854. }, [_c('label', [_c('input', {
  41855. directives: [{
  41856. name: "model",
  41857. rawName: "v-model",
  41858. value: (_vm.selectedDocument),
  41859. expression: "selectedDocument"
  41860. }],
  41861. attrs: {
  41862. "type": "radio",
  41863. "name": "selectedDocument"
  41864. },
  41865. domProps: {
  41866. "value": doc.id,
  41867. "checked": _vm._q(_vm.selectedDocument, doc.id)
  41868. },
  41869. on: {
  41870. "__c": function($event) {
  41871. _vm.selectedDocument = doc.id
  41872. }
  41873. }
  41874. }), _vm._v("\n " + _vm._s(doc.description) + "\n ")])])
  41875. }))] : _vm._e()], 2)])])]) : _vm._e()
  41876. },staticRenderFns: [function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41877. return _c('p', {
  41878. staticClass: "instructions"
  41879. }, [_c('ul', [_c('li', [_vm._v("Photo must show the sign with the transit center")]), _vm._v(" "), _c('li', [_vm._v("Bonus points if another team and their pennant are visible!")])])])
  41880. },function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41881. return _c('p', {
  41882. staticClass: "instructions"
  41883. }, [_c('ul', [_c('li', [_vm._v("Make sure this photo is on the tram or at the top tram station")]), _vm._v(" "), _c('li', [_vm._v("Reject if it shows the rooftop with the code!")])])])
  41884. },function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41885. return _c('p', {
  41886. staticClass: "instructions"
  41887. }, [_c('ul', [_c('li', [_vm._v("The photo must include the radio")]), _vm._v(" "), _c('li', [_vm._v("Reject if it shows the decoded message")])])])
  41888. }]}
  41889. module.exports.render._withStripped = true
  41890. if (false) {
  41891. module.hot.accept()
  41892. if (module.hot.data) {
  41893. require("vue-hot-reload-api").rerender("data-v-1098d79e", module.exports)
  41894. }
  41895. }
  41896. /***/ }),
  41897. /* 61 */
  41898. /***/ (function(module, exports) {
  41899. //
  41900. //
  41901. //
  41902. //
  41903. //
  41904. //
  41905. //
  41906. //
  41907. //
  41908. //
  41909. //
  41910. //
  41911. //
  41912. //
  41913. //
  41914. //
  41915. //
  41916. //
  41917. //
  41918. //
  41919. //
  41920. //
  41921. //
  41922. //
  41923. //
  41924. //
  41925. //
  41926. //
  41927. //
  41928. //
  41929. //
  41930. //
  41931. //
  41932. //
  41933. //
  41934. //
  41935. //
  41936. //
  41937. //
  41938. //
  41939. //
  41940. //
  41941. //
  41942. //
  41943. //
  41944. //
  41945. //
  41946. //
  41947. //
  41948. //
  41949. //
  41950. //
  41951. //
  41952. //
  41953. //
  41954. //
  41955. //
  41956. //
  41957. //
  41958. //
  41959. //
  41960. //
  41961. //
  41962. //
  41963. //
  41964. //
  41965. //
  41966. //
  41967. //
  41968. //
  41969. //
  41970. //
  41971. //
  41972. //
  41973. //
  41974. //
  41975. //
  41976. //
  41977. //
  41978. //
  41979. //
  41980. //
  41981. //
  41982. //
  41983. //
  41984. //
  41985. //
  41986. //
  41987. //
  41988. //
  41989. //
  41990. //
  41991. //
  41992. //
  41993. //
  41994. //
  41995. //
  41996. //
  41997. //
  41998. //
  41999. //
  42000. //
  42001. //
  42002. //
  42003. //
  42004. //
  42005. //
  42006. //
  42007. //
  42008. //
  42009. //
  42010. //
  42011. //
  42012. //
  42013. //
  42014. //
  42015. //
  42016. //
  42017. //
  42018. //
  42019. //
  42020. //
  42021. //
  42022. //
  42023. //
  42024. //
  42025. //
  42026. //
  42027. //
  42028. //
  42029. //
  42030. //
  42031. //
  42032. //
  42033. //
  42034. //
  42035. //
  42036. //
  42037. //
  42038. //
  42039. //
  42040. //
  42041. //
  42042. //
  42043. //
  42044. //
  42045. //
  42046. //
  42047. //
  42048. //
  42049. //
  42050. //
  42051. //
  42052. //
  42053. //
  42054. //
  42055. //
  42056. //
  42057. //
  42058. //
  42059. //
  42060. //
  42061. module.exports = {
  42062. props: ['show', 'tweet'],
  42063. data: function data() {
  42064. return {
  42065. documents: [],
  42066. centers: [],
  42067. lines: [],
  42068. replyText: '',
  42069. selectedDocument: null,
  42070. selectedTransitCenter: null,
  42071. selectedTransitLine: null,
  42072. selectedNonTrimetLine: '',
  42073. selectedPhotoHasAnotherTeam: false,
  42074. selectedM5Singing: false,
  42075. selectedM5Tipping: false
  42076. };
  42077. },
  42078. computed: {
  42079. isAcceptDisabled: function isAcceptDisabled() {
  42080. if (this.show) {
  42081. switch (this.tweet.mission_id) {
  42082. case 1:
  42083. return this.selectedTransitLine == null && this.selectedNonTrimetLine == '';
  42084. case 2:
  42085. return this.selectedTransitCenter == null;
  42086. case 3:
  42087. case 4:
  42088. case 6:
  42089. // Nothing to check
  42090. return false;
  42091. case 5:
  42092. return this.selectedM5Singing == false && this.selectedM5Tipping == false;
  42093. case 7:
  42094. return this.selectedDocument == null;
  42095. default:
  42096. return true;
  42097. }
  42098. } else {
  42099. return true;
  42100. }
  42101. },
  42102. isTweetReplyDisabled: function isTweetReplyDisabled() {
  42103. return this.replyText == '';
  42104. }
  42105. },
  42106. methods: {
  42107. clearState: function clearState() {
  42108. this.selectedDocument = null;
  42109. this.selectedTransitCenter = null;
  42110. this.selectedTransitLine = null;
  42111. this.selectedNonTrimetLine = '';
  42112. this.selectedPhotoHasAnotherTeam = false;
  42113. this.selectedM5Singing = false;
  42114. this.selectedM5Tipping = false;
  42115. this.replyText = '';
  42116. },
  42117. dismiss: function dismiss() {
  42118. this.clearState();
  42119. this.$emit('dismiss');
  42120. },
  42121. rejectTweet: function rejectTweet() {
  42122. $.post("/dashboard/reject-tweet", {
  42123. tweet_id: this.tweet.tweet_id
  42124. }, function () {
  42125. this.clearState();
  42126. this.$emit('complete');
  42127. }.bind(this));
  42128. },
  42129. scoreTweet: function scoreTweet() {
  42130. var score_data = {};
  42131. switch (this.tweet.mission_id) {
  42132. case 1:
  42133. score_data['m1_complete'] = 1;
  42134. score_data['m1_transit_line_id'] = this.selectedTransitLine;
  42135. score_data['m1_non_trimet'] = this.selectedNonTrimetLine;
  42136. break;
  42137. case 2:
  42138. score_data['m2_complete'] = this.selectedTransitCenter ? 1 : 0;
  42139. score_data['m2_transit_center_id'] = this.selectedTransitCenter;
  42140. score_data['m2_with_other_team'] = this.selectedPhotoHasAnotherTeam ? 1 : 0;
  42141. break;
  42142. case 3:
  42143. score_data['m3_complete'] = 1;
  42144. break;
  42145. case 4:
  42146. score_data['m4_complete'] = 1;
  42147. break;
  42148. case 5:
  42149. score_data['m5_complete'] = this.selectedM5Singing ? 1 : 0;
  42150. score_data['m5_tip'] = this.selectedM5Tipping ? 1 : 0;
  42151. break;
  42152. case 6:
  42153. score_data['m6_complete'] = 1;
  42154. break;
  42155. case 7:
  42156. score_data['m7_document_id'] = this.selectedDocument;
  42157. break;
  42158. }
  42159. $.post("/dashboard/score-tweet", {
  42160. tweet_id: this.tweet.tweet_id,
  42161. score_data: score_data
  42162. }, function () {
  42163. this.clearState();
  42164. this.$emit('complete');
  42165. }.bind(this));
  42166. }
  42167. },
  42168. watch: {
  42169. // https://vuejs.org/v2/guide/computed.html#Watchers
  42170. show: function show(val) {
  42171. if (val) {
  42172. // https://vuejs.org/v2/guide/reactivity.html#Async-Update-Queue
  42173. Vue.nextTick(function () {
  42174. $(".multi-photo .photo").featherlight();
  42175. }.bind(this));
  42176. }
  42177. }
  42178. },
  42179. created: function created() {
  42180. $.get("/dashboard/dropdowns", function (response) {
  42181. this.centers = response.transit_centers;
  42182. this.lines = response.transit_lines;
  42183. this.documents = response.documents;
  42184. }.bind(this));
  42185. }
  42186. };
  42187. /***/ }),
  42188. /* 62 */,
  42189. /* 63 */,
  42190. /* 64 */
  42191. /***/ (function(module, exports) {
  42192. /**
  42193. * Featherlight - ultra slim jQuery lightbox
  42194. * Version 1.7.6 - http://noelboss.github.io/featherlight/
  42195. *
  42196. * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com)
  42197. * MIT Licensed.
  42198. **/
  42199. !function(a){"use strict";function b(a,c){if(!(this instanceof b)){var d=new b(a,c);return d.open(),d}this.id=b.id++,this.setup(a,c),this.chainCallbacks(b._callbackChain)}function c(a,b){var c={};for(var d in a)d in b&&(c[d]=a[d],delete a[d]);return c}function d(a,b){var c={},d=new RegExp("^"+b+"([A-Z])(.*)");for(var e in a){var f=e.match(d);if(f){var g=(f[1]+f[2].replace(/([A-Z])/g,"-$1")).toLowerCase();c[g]=a[e]}}return c}if("undefined"==typeof a)return void("console"in window&&window.console.info("Too much lightness, Featherlight needs jQuery."));var e=[],f=function(b){return e=a.grep(e,function(a){return a!==b&&a.$instance.closest("body").length>0})},g={allowfullscreen:1,frameborder:1,height:1,longdesc:1,marginheight:1,marginwidth:1,name:1,referrerpolicy:1,scrolling:1,sandbox:1,src:1,srcdoc:1,width:1},h={keyup:"onKeyUp",resize:"onResize"},i=function(c){a.each(b.opened().reverse(),function(){return c.isDefaultPrevented()||!1!==this[h[c.type]](c)?void 0:(c.preventDefault(),c.stopPropagation(),!1)})},j=function(c){if(c!==b._globalHandlerInstalled){b._globalHandlerInstalled=c;var d=a.map(h,function(a,c){return c+"."+b.prototype.namespace}).join(" ");a(window)[c?"on":"off"](d,i)}};b.prototype={constructor:b,namespace:"featherlight",targetAttr:"data-featherlight",variant:null,resetCss:!1,background:null,openTrigger:"click",closeTrigger:"click",filter:null,root:"body",openSpeed:250,closeSpeed:250,closeOnClick:"background",closeOnEsc:!0,closeIcon:"&#10005;",loading:"",persist:!1,otherClose:null,beforeOpen:a.noop,beforeContent:a.noop,beforeClose:a.noop,afterOpen:a.noop,afterContent:a.noop,afterClose:a.noop,onKeyUp:a.noop,onResize:a.noop,type:null,contentFilters:["jquery","image","html","ajax","iframe","text"],setup:function(b,c){"object"!=typeof b||b instanceof a!=!1||c||(c=b,b=void 0);var d=a.extend(this,c,{target:b}),e=d.resetCss?d.namespace+"-reset":d.namespace,f=a(d.background||['<div class="'+e+"-loading "+e+'">','<div class="'+e+'-content">','<button class="'+e+"-close-icon "+d.namespace+'-close" aria-label="Close">',d.closeIcon,"</button>",'<div class="'+d.namespace+'-inner">'+d.loading+"</div>","</div>","</div>"].join("")),g="."+d.namespace+"-close"+(d.otherClose?","+d.otherClose:"");return d.$instance=f.clone().addClass(d.variant),d.$instance.on(d.closeTrigger+"."+d.namespace,function(b){var c=a(b.target);("background"===d.closeOnClick&&c.is("."+d.namespace)||"anywhere"===d.closeOnClick||c.closest(g).length)&&(d.close(b),b.preventDefault())}),this},getContent:function(){if(this.persist!==!1&&this.$content)return this.$content;var b=this,c=this.constructor.contentFilters,d=function(a){return b.$currentTarget&&b.$currentTarget.attr(a)},e=d(b.targetAttr),f=b.target||e||"",g=c[b.type];if(!g&&f in c&&(g=c[f],f=b.target&&e),f=f||d("href")||"",!g)for(var h in c)b[h]&&(g=c[h],f=b[h]);if(!g){var i=f;if(f=null,a.each(b.contentFilters,function(){return g=c[this],g.test&&(f=g.test(i)),!f&&g.regex&&i.match&&i.match(g.regex)&&(f=i),!f}),!f)return"console"in window&&window.console.error("Featherlight: no content filter found "+(i?' for "'+i+'"':" (no target specified)")),!1}return g.process.call(b,f)},setContent:function(b){var c=this;return b.is("iframe")&&c.$instance.addClass(c.namespace+"-iframe"),c.$instance.removeClass(c.namespace+"-loading"),c.$instance.find("."+c.namespace+"-inner").not(b).slice(1).remove().end().replaceWith(a.contains(c.$instance[0],b[0])?"":b),c.$content=b.addClass(c.namespace+"-inner"),c},open:function(b){var c=this;if(c.$instance.hide().appendTo(c.root),!(b&&b.isDefaultPrevented()||c.beforeOpen(b)===!1)){b&&b.preventDefault();var d=c.getContent();if(d)return e.push(c),j(!0),c.$instance.fadeIn(c.openSpeed),c.beforeContent(b),a.when(d).always(function(a){c.setContent(a),c.afterContent(b)}).then(c.$instance.promise()).done(function(){c.afterOpen(b)})}return c.$instance.detach(),a.Deferred().reject().promise()},close:function(b){var c=this,d=a.Deferred();return c.beforeClose(b)===!1?d.reject():(0===f(c).length&&j(!1),c.$instance.fadeOut(c.closeSpeed,function(){c.$instance.detach(),c.afterClose(b),d.resolve(
  42200. /***/ })
  42201. /******/ ]);