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.

48749 lines
1.4 MiB

6 years ago
6 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. window.twitter = __webpack_require__(65);
  829. /***/ }),
  830. /* 12 */
  831. /***/ (function(module, exports, __webpack_require__) {
  832. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  833. * @license
  834. * Lodash <https://lodash.com/>
  835. * Copyright JS Foundation and other contributors <https://js.foundation/>
  836. * Released under MIT license <https://lodash.com/license>
  837. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  838. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  839. */
  840. ;(function() {
  841. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  842. var undefined;
  843. /** Used as the semantic version number. */
  844. var VERSION = '4.17.4';
  845. /** Used as the size to enable large array optimizations. */
  846. var LARGE_ARRAY_SIZE = 200;
  847. /** Error message constants. */
  848. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  849. FUNC_ERROR_TEXT = 'Expected a function';
  850. /** Used to stand-in for `undefined` hash values. */
  851. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  852. /** Used as the maximum memoize cache size. */
  853. var MAX_MEMOIZE_SIZE = 500;
  854. /** Used as the internal argument placeholder. */
  855. var PLACEHOLDER = '__lodash_placeholder__';
  856. /** Used to compose bitmasks for cloning. */
  857. var CLONE_DEEP_FLAG = 1,
  858. CLONE_FLAT_FLAG = 2,
  859. CLONE_SYMBOLS_FLAG = 4;
  860. /** Used to compose bitmasks for value comparisons. */
  861. var COMPARE_PARTIAL_FLAG = 1,
  862. COMPARE_UNORDERED_FLAG = 2;
  863. /** Used to compose bitmasks for function metadata. */
  864. var WRAP_BIND_FLAG = 1,
  865. WRAP_BIND_KEY_FLAG = 2,
  866. WRAP_CURRY_BOUND_FLAG = 4,
  867. WRAP_CURRY_FLAG = 8,
  868. WRAP_CURRY_RIGHT_FLAG = 16,
  869. WRAP_PARTIAL_FLAG = 32,
  870. WRAP_PARTIAL_RIGHT_FLAG = 64,
  871. WRAP_ARY_FLAG = 128,
  872. WRAP_REARG_FLAG = 256,
  873. WRAP_FLIP_FLAG = 512;
  874. /** Used as default options for `_.truncate`. */
  875. var DEFAULT_TRUNC_LENGTH = 30,
  876. DEFAULT_TRUNC_OMISSION = '...';
  877. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  878. var HOT_COUNT = 800,
  879. HOT_SPAN = 16;
  880. /** Used to indicate the type of lazy iteratees. */
  881. var LAZY_FILTER_FLAG = 1,
  882. LAZY_MAP_FLAG = 2,
  883. LAZY_WHILE_FLAG = 3;
  884. /** Used as references for various `Number` constants. */
  885. var INFINITY = 1 / 0,
  886. MAX_SAFE_INTEGER = 9007199254740991,
  887. MAX_INTEGER = 1.7976931348623157e+308,
  888. NAN = 0 / 0;
  889. /** Used as references for the maximum length and index of an array. */
  890. var MAX_ARRAY_LENGTH = 4294967295,
  891. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  892. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  893. /** Used to associate wrap methods with their bit flags. */
  894. var wrapFlags = [
  895. ['ary', WRAP_ARY_FLAG],
  896. ['bind', WRAP_BIND_FLAG],
  897. ['bindKey', WRAP_BIND_KEY_FLAG],
  898. ['curry', WRAP_CURRY_FLAG],
  899. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  900. ['flip', WRAP_FLIP_FLAG],
  901. ['partial', WRAP_PARTIAL_FLAG],
  902. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  903. ['rearg', WRAP_REARG_FLAG]
  904. ];
  905. /** `Object#toString` result references. */
  906. var argsTag = '[object Arguments]',
  907. arrayTag = '[object Array]',
  908. asyncTag = '[object AsyncFunction]',
  909. boolTag = '[object Boolean]',
  910. dateTag = '[object Date]',
  911. domExcTag = '[object DOMException]',
  912. errorTag = '[object Error]',
  913. funcTag = '[object Function]',
  914. genTag = '[object GeneratorFunction]',
  915. mapTag = '[object Map]',
  916. numberTag = '[object Number]',
  917. nullTag = '[object Null]',
  918. objectTag = '[object Object]',
  919. promiseTag = '[object Promise]',
  920. proxyTag = '[object Proxy]',
  921. regexpTag = '[object RegExp]',
  922. setTag = '[object Set]',
  923. stringTag = '[object String]',
  924. symbolTag = '[object Symbol]',
  925. undefinedTag = '[object Undefined]',
  926. weakMapTag = '[object WeakMap]',
  927. weakSetTag = '[object WeakSet]';
  928. var arrayBufferTag = '[object ArrayBuffer]',
  929. dataViewTag = '[object DataView]',
  930. float32Tag = '[object Float32Array]',
  931. float64Tag = '[object Float64Array]',
  932. int8Tag = '[object Int8Array]',
  933. int16Tag = '[object Int16Array]',
  934. int32Tag = '[object Int32Array]',
  935. uint8Tag = '[object Uint8Array]',
  936. uint8ClampedTag = '[object Uint8ClampedArray]',
  937. uint16Tag = '[object Uint16Array]',
  938. uint32Tag = '[object Uint32Array]';
  939. /** Used to match empty string literals in compiled template source. */
  940. var reEmptyStringLeading = /\b__p \+= '';/g,
  941. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  942. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  943. /** Used to match HTML entities and HTML characters. */
  944. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  945. reUnescapedHtml = /[&<>"']/g,
  946. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  947. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  948. /** Used to match template delimiters. */
  949. var reEscape = /<%-([\s\S]+?)%>/g,
  950. reEvaluate = /<%([\s\S]+?)%>/g,
  951. reInterpolate = /<%=([\s\S]+?)%>/g;
  952. /** Used to match property names within property paths. */
  953. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  954. reIsPlainProp = /^\w*$/,
  955. reLeadingDot = /^\./,
  956. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  957. /**
  958. * Used to match `RegExp`
  959. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  960. */
  961. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  962. reHasRegExpChar = RegExp(reRegExpChar.source);
  963. /** Used to match leading and trailing whitespace. */
  964. var reTrim = /^\s+|\s+$/g,
  965. reTrimStart = /^\s+/,
  966. reTrimEnd = /\s+$/;
  967. /** Used to match wrap detail comments. */
  968. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  969. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  970. reSplitDetails = /,? & /;
  971. /** Used to match words composed of alphanumeric characters. */
  972. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  973. /** Used to match backslashes in property paths. */
  974. var reEscapeChar = /\\(\\)?/g;
  975. /**
  976. * Used to match
  977. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  978. */
  979. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  980. /** Used to match `RegExp` flags from their coerced string values. */
  981. var reFlags = /\w*$/;
  982. /** Used to detect bad signed hexadecimal string values. */
  983. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  984. /** Used to detect binary string values. */
  985. var reIsBinary = /^0b[01]+$/i;
  986. /** Used to detect host constructors (Safari). */
  987. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  988. /** Used to detect octal string values. */
  989. var reIsOctal = /^0o[0-7]+$/i;
  990. /** Used to detect unsigned integer values. */
  991. var reIsUint = /^(?:0|[1-9]\d*)$/;
  992. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  993. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  994. /** Used to ensure capturing order of template delimiters. */
  995. var reNoMatch = /($^)/;
  996. /** Used to match unescaped characters in compiled string literals. */
  997. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  998. /** Used to compose unicode character classes. */
  999. var rsAstralRange = '\\ud800-\\udfff',
  1000. rsComboMarksRange = '\\u0300-\\u036f',
  1001. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  1002. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  1003. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  1004. rsDingbatRange = '\\u2700-\\u27bf',
  1005. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  1006. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  1007. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  1008. rsPunctuationRange = '\\u2000-\\u206f',
  1009. 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',
  1010. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  1011. rsVarRange = '\\ufe0e\\ufe0f',
  1012. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  1013. /** Used to compose unicode capture groups. */
  1014. var rsApos = "['\u2019]",
  1015. rsAstral = '[' + rsAstralRange + ']',
  1016. rsBreak = '[' + rsBreakRange + ']',
  1017. rsCombo = '[' + rsComboRange + ']',
  1018. rsDigits = '\\d+',
  1019. rsDingbat = '[' + rsDingbatRange + ']',
  1020. rsLower = '[' + rsLowerRange + ']',
  1021. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  1022. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  1023. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  1024. rsNonAstral = '[^' + rsAstralRange + ']',
  1025. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  1026. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  1027. rsUpper = '[' + rsUpperRange + ']',
  1028. rsZWJ = '\\u200d';
  1029. /** Used to compose unicode regexes. */
  1030. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  1031. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  1032. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  1033. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  1034. reOptMod = rsModifier + '?',
  1035. rsOptVar = '[' + rsVarRange + ']?',
  1036. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  1037. rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
  1038. rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
  1039. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  1040. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  1041. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  1042. /** Used to match apostrophes. */
  1043. var reApos = RegExp(rsApos, 'g');
  1044. /**
  1045. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  1046. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  1047. */
  1048. var reComboMark = RegExp(rsCombo, 'g');
  1049. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  1050. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  1051. /** Used to match complex or compound words. */
  1052. var reUnicodeWord = RegExp([
  1053. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  1054. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  1055. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  1056. rsUpper + '+' + rsOptContrUpper,
  1057. rsOrdUpper,
  1058. rsOrdLower,
  1059. rsDigits,
  1060. rsEmoji
  1061. ].join('|'), 'g');
  1062. /** 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/). */
  1063. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  1064. /** Used to detect strings that need a more robust regexp to match words. */
  1065. 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 ]/;
  1066. /** Used to assign default `context` object properties. */
  1067. var contextProps = [
  1068. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  1069. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  1070. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  1071. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  1072. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  1073. ];
  1074. /** Used to make template sourceURLs easier to identify. */
  1075. var templateCounter = -1;
  1076. /** Used to identify `toStringTag` values of typed arrays. */
  1077. var typedArrayTags = {};
  1078. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1079. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1080. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1081. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1082. typedArrayTags[uint32Tag] = true;
  1083. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1084. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1085. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  1086. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  1087. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  1088. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  1089. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  1090. typedArrayTags[weakMapTag] = false;
  1091. /** Used to identify `toStringTag` values supported by `_.clone`. */
  1092. var cloneableTags = {};
  1093. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1094. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  1095. cloneableTags[boolTag] = cloneableTags[dateTag] =
  1096. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  1097. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  1098. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  1099. cloneableTags[numberTag] = cloneableTags[objectTag] =
  1100. cloneableTags[regexpTag] = cloneableTags[setTag] =
  1101. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  1102. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  1103. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  1104. cloneableTags[errorTag] = cloneableTags[funcTag] =
  1105. cloneableTags[weakMapTag] = false;
  1106. /** Used to map Latin Unicode letters to basic Latin letters. */
  1107. var deburredLetters = {
  1108. // Latin-1 Supplement block.
  1109. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  1110. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  1111. '\xc7': 'C', '\xe7': 'c',
  1112. '\xd0': 'D', '\xf0': 'd',
  1113. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  1114. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  1115. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  1116. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  1117. '\xd1': 'N', '\xf1': 'n',
  1118. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  1119. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  1120. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  1121. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  1122. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  1123. '\xc6': 'Ae', '\xe6': 'ae',
  1124. '\xde': 'Th', '\xfe': 'th',
  1125. '\xdf': 'ss',
  1126. // Latin Extended-A block.
  1127. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  1128. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  1129. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  1130. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  1131. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  1132. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  1133. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  1134. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  1135. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  1136. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  1137. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  1138. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  1139. '\u0134': 'J', '\u0135': 'j',
  1140. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  1141. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  1142. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  1143. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  1144. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  1145. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  1146. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  1147. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  1148. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  1149. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  1150. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  1151. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  1152. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  1153. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  1154. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  1155. '\u0174': 'W', '\u0175': 'w',
  1156. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  1157. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  1158. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  1159. '\u0132': 'IJ', '\u0133': 'ij',
  1160. '\u0152': 'Oe', '\u0153': 'oe',
  1161. '\u0149': "'n", '\u017f': 's'
  1162. };
  1163. /** Used to map characters to HTML entities. */
  1164. var htmlEscapes = {
  1165. '&': '&amp;',
  1166. '<': '&lt;',
  1167. '>': '&gt;',
  1168. '"': '&quot;',
  1169. "'": '&#39;'
  1170. };
  1171. /** Used to map HTML entities to characters. */
  1172. var htmlUnescapes = {
  1173. '&amp;': '&',
  1174. '&lt;': '<',
  1175. '&gt;': '>',
  1176. '&quot;': '"',
  1177. '&#39;': "'"
  1178. };
  1179. /** Used to escape characters for inclusion in compiled string literals. */
  1180. var stringEscapes = {
  1181. '\\': '\\',
  1182. "'": "'",
  1183. '\n': 'n',
  1184. '\r': 'r',
  1185. '\u2028': 'u2028',
  1186. '\u2029': 'u2029'
  1187. };
  1188. /** Built-in method references without a dependency on `root`. */
  1189. var freeParseFloat = parseFloat,
  1190. freeParseInt = parseInt;
  1191. /** Detect free variable `global` from Node.js. */
  1192. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  1193. /** Detect free variable `self`. */
  1194. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1195. /** Used as a reference to the global object. */
  1196. var root = freeGlobal || freeSelf || Function('return this')();
  1197. /** Detect free variable `exports`. */
  1198. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  1199. /** Detect free variable `module`. */
  1200. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  1201. /** Detect the popular CommonJS extension `module.exports`. */
  1202. var moduleExports = freeModule && freeModule.exports === freeExports;
  1203. /** Detect free variable `process` from Node.js. */
  1204. var freeProcess = moduleExports && freeGlobal.process;
  1205. /** Used to access faster Node.js helpers. */
  1206. var nodeUtil = (function() {
  1207. try {
  1208. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  1209. } catch (e) {}
  1210. }());
  1211. /* Node.js helper references. */
  1212. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  1213. nodeIsDate = nodeUtil && nodeUtil.isDate,
  1214. nodeIsMap = nodeUtil && nodeUtil.isMap,
  1215. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  1216. nodeIsSet = nodeUtil && nodeUtil.isSet,
  1217. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  1218. /*--------------------------------------------------------------------------*/
  1219. /**
  1220. * Adds the key-value `pair` to `map`.
  1221. *
  1222. * @private
  1223. * @param {Object} map The map to modify.
  1224. * @param {Array} pair The key-value pair to add.
  1225. * @returns {Object} Returns `map`.
  1226. */
  1227. function addMapEntry(map, pair) {
  1228. // Don't return `map.set` because it's not chainable in IE 11.
  1229. map.set(pair[0], pair[1]);
  1230. return map;
  1231. }
  1232. /**
  1233. * Adds `value` to `set`.
  1234. *
  1235. * @private
  1236. * @param {Object} set The set to modify.
  1237. * @param {*} value The value to add.
  1238. * @returns {Object} Returns `set`.
  1239. */
  1240. function addSetEntry(set, value) {
  1241. // Don't return `set.add` because it's not chainable in IE 11.
  1242. set.add(value);
  1243. return set;
  1244. }
  1245. /**
  1246. * A faster alternative to `Function#apply`, this function invokes `func`
  1247. * with the `this` binding of `thisArg` and the arguments of `args`.
  1248. *
  1249. * @private
  1250. * @param {Function} func The function to invoke.
  1251. * @param {*} thisArg The `this` binding of `func`.
  1252. * @param {Array} args The arguments to invoke `func` with.
  1253. * @returns {*} Returns the result of `func`.
  1254. */
  1255. function apply(func, thisArg, args) {
  1256. switch (args.length) {
  1257. case 0: return func.call(thisArg);
  1258. case 1: return func.call(thisArg, args[0]);
  1259. case 2: return func.call(thisArg, args[0], args[1]);
  1260. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  1261. }
  1262. return func.apply(thisArg, args);
  1263. }
  1264. /**
  1265. * A specialized version of `baseAggregator` for arrays.
  1266. *
  1267. * @private
  1268. * @param {Array} [array] The array to iterate over.
  1269. * @param {Function} setter The function to set `accumulator` values.
  1270. * @param {Function} iteratee The iteratee to transform keys.
  1271. * @param {Object} accumulator The initial aggregated object.
  1272. * @returns {Function} Returns `accumulator`.
  1273. */
  1274. function arrayAggregator(array, setter, iteratee, accumulator) {
  1275. var index = -1,
  1276. length = array == null ? 0 : array.length;
  1277. while (++index < length) {
  1278. var value = array[index];
  1279. setter(accumulator, value, iteratee(value), array);
  1280. }
  1281. return accumulator;
  1282. }
  1283. /**
  1284. * A specialized version of `_.forEach` for arrays without support for
  1285. * iteratee shorthands.
  1286. *
  1287. * @private
  1288. * @param {Array} [array] The array to iterate over.
  1289. * @param {Function} iteratee The function invoked per iteration.
  1290. * @returns {Array} Returns `array`.
  1291. */
  1292. function arrayEach(array, iteratee) {
  1293. var index = -1,
  1294. length = array == null ? 0 : array.length;
  1295. while (++index < length) {
  1296. if (iteratee(array[index], index, array) === false) {
  1297. break;
  1298. }
  1299. }
  1300. return array;
  1301. }
  1302. /**
  1303. * A specialized version of `_.forEachRight` for arrays without support for
  1304. * iteratee shorthands.
  1305. *
  1306. * @private
  1307. * @param {Array} [array] The array to iterate over.
  1308. * @param {Function} iteratee The function invoked per iteration.
  1309. * @returns {Array} Returns `array`.
  1310. */
  1311. function arrayEachRight(array, iteratee) {
  1312. var length = array == null ? 0 : array.length;
  1313. while (length--) {
  1314. if (iteratee(array[length], length, array) === false) {
  1315. break;
  1316. }
  1317. }
  1318. return array;
  1319. }
  1320. /**
  1321. * A specialized version of `_.every` for arrays without support for
  1322. * iteratee shorthands.
  1323. *
  1324. * @private
  1325. * @param {Array} [array] The array to iterate over.
  1326. * @param {Function} predicate The function invoked per iteration.
  1327. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  1328. * else `false`.
  1329. */
  1330. function arrayEvery(array, predicate) {
  1331. var index = -1,
  1332. length = array == null ? 0 : array.length;
  1333. while (++index < length) {
  1334. if (!predicate(array[index], index, array)) {
  1335. return false;
  1336. }
  1337. }
  1338. return true;
  1339. }
  1340. /**
  1341. * A specialized version of `_.filter` for arrays without support for
  1342. * iteratee shorthands.
  1343. *
  1344. * @private
  1345. * @param {Array} [array] The array to iterate over.
  1346. * @param {Function} predicate The function invoked per iteration.
  1347. * @returns {Array} Returns the new filtered array.
  1348. */
  1349. function arrayFilter(array, predicate) {
  1350. var index = -1,
  1351. length = array == null ? 0 : array.length,
  1352. resIndex = 0,
  1353. result = [];
  1354. while (++index < length) {
  1355. var value = array[index];
  1356. if (predicate(value, index, array)) {
  1357. result[resIndex++] = value;
  1358. }
  1359. }
  1360. return result;
  1361. }
  1362. /**
  1363. * A specialized version of `_.includes` for arrays without support for
  1364. * specifying an index to search from.
  1365. *
  1366. * @private
  1367. * @param {Array} [array] The array to inspect.
  1368. * @param {*} target The value to search for.
  1369. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  1370. */
  1371. function arrayIncludes(array, value) {
  1372. var length = array == null ? 0 : array.length;
  1373. return !!length && baseIndexOf(array, value, 0) > -1;
  1374. }
  1375. /**
  1376. * This function is like `arrayIncludes` except that it accepts a comparator.
  1377. *
  1378. * @private
  1379. * @param {Array} [array] The array to inspect.
  1380. * @param {*} target The value to search for.
  1381. * @param {Function} comparator The comparator invoked per element.
  1382. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  1383. */
  1384. function arrayIncludesWith(array, value, comparator) {
  1385. var index = -1,
  1386. length = array == null ? 0 : array.length;
  1387. while (++index < length) {
  1388. if (comparator(value, array[index])) {
  1389. return true;
  1390. }
  1391. }
  1392. return false;
  1393. }
  1394. /**
  1395. * A specialized version of `_.map` for arrays without support for iteratee
  1396. * shorthands.
  1397. *
  1398. * @private
  1399. * @param {Array} [array] The array to iterate over.
  1400. * @param {Function} iteratee The function invoked per iteration.
  1401. * @returns {Array} Returns the new mapped array.
  1402. */
  1403. function arrayMap(array, iteratee) {
  1404. var index = -1,
  1405. length = array == null ? 0 : array.length,
  1406. result = Array(length);
  1407. while (++index < length) {
  1408. result[index] = iteratee(array[index], index, array);
  1409. }
  1410. return result;
  1411. }
  1412. /**
  1413. * Appends the elements of `values` to `array`.
  1414. *
  1415. * @private
  1416. * @param {Array} array The array to modify.
  1417. * @param {Array} values The values to append.
  1418. * @returns {Array} Returns `array`.
  1419. */
  1420. function arrayPush(array, values) {
  1421. var index = -1,
  1422. length = values.length,
  1423. offset = array.length;
  1424. while (++index < length) {
  1425. array[offset + index] = values[index];
  1426. }
  1427. return array;
  1428. }
  1429. /**
  1430. * A specialized version of `_.reduce` for arrays without support for
  1431. * iteratee shorthands.
  1432. *
  1433. * @private
  1434. * @param {Array} [array] The array to iterate over.
  1435. * @param {Function} iteratee The function invoked per iteration.
  1436. * @param {*} [accumulator] The initial value.
  1437. * @param {boolean} [initAccum] Specify using the first element of `array` as
  1438. * the initial value.
  1439. * @returns {*} Returns the accumulated value.
  1440. */
  1441. function arrayReduce(array, iteratee, accumulator, initAccum) {
  1442. var index = -1,
  1443. length = array == null ? 0 : array.length;
  1444. if (initAccum && length) {
  1445. accumulator = array[++index];
  1446. }
  1447. while (++index < length) {
  1448. accumulator = iteratee(accumulator, array[index], index, array);
  1449. }
  1450. return accumulator;
  1451. }
  1452. /**
  1453. * A specialized version of `_.reduceRight` for arrays without support for
  1454. * iteratee shorthands.
  1455. *
  1456. * @private
  1457. * @param {Array} [array] The array to iterate over.
  1458. * @param {Function} iteratee The function invoked per iteration.
  1459. * @param {*} [accumulator] The initial value.
  1460. * @param {boolean} [initAccum] Specify using the last element of `array` as
  1461. * the initial value.
  1462. * @returns {*} Returns the accumulated value.
  1463. */
  1464. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  1465. var length = array == null ? 0 : array.length;
  1466. if (initAccum && length) {
  1467. accumulator = array[--length];
  1468. }
  1469. while (length--) {
  1470. accumulator = iteratee(accumulator, array[length], length, array);
  1471. }
  1472. return accumulator;
  1473. }
  1474. /**
  1475. * A specialized version of `_.some` for arrays without support for iteratee
  1476. * shorthands.
  1477. *
  1478. * @private
  1479. * @param {Array} [array] The array to iterate over.
  1480. * @param {Function} predicate The function invoked per iteration.
  1481. * @returns {boolean} Returns `true` if any element passes the predicate check,
  1482. * else `false`.
  1483. */
  1484. function arraySome(array, predicate) {
  1485. var index = -1,
  1486. length = array == null ? 0 : array.length;
  1487. while (++index < length) {
  1488. if (predicate(array[index], index, array)) {
  1489. return true;
  1490. }
  1491. }
  1492. return false;
  1493. }
  1494. /**
  1495. * Gets the size of an ASCII `string`.
  1496. *
  1497. * @private
  1498. * @param {string} string The string inspect.
  1499. * @returns {number} Returns the string size.
  1500. */
  1501. var asciiSize = baseProperty('length');
  1502. /**
  1503. * Converts an ASCII `string` to an array.
  1504. *
  1505. * @private
  1506. * @param {string} string The string to convert.
  1507. * @returns {Array} Returns the converted array.
  1508. */
  1509. function asciiToArray(string) {
  1510. return string.split('');
  1511. }
  1512. /**
  1513. * Splits an ASCII `string` into an array of its words.
  1514. *
  1515. * @private
  1516. * @param {string} The string to inspect.
  1517. * @returns {Array} Returns the words of `string`.
  1518. */
  1519. function asciiWords(string) {
  1520. return string.match(reAsciiWord) || [];
  1521. }
  1522. /**
  1523. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  1524. * without support for iteratee shorthands, which iterates over `collection`
  1525. * using `eachFunc`.
  1526. *
  1527. * @private
  1528. * @param {Array|Object} collection The collection to inspect.
  1529. * @param {Function} predicate The function invoked per iteration.
  1530. * @param {Function} eachFunc The function to iterate over `collection`.
  1531. * @returns {*} Returns the found element or its key, else `undefined`.
  1532. */
  1533. function baseFindKey(collection, predicate, eachFunc) {
  1534. var result;
  1535. eachFunc(collection, function(value, key, collection) {
  1536. if (predicate(value, key, collection)) {
  1537. result = key;
  1538. return false;
  1539. }
  1540. });
  1541. return result;
  1542. }
  1543. /**
  1544. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  1545. * support for iteratee shorthands.
  1546. *
  1547. * @private
  1548. * @param {Array} array The array to inspect.
  1549. * @param {Function} predicate The function invoked per iteration.
  1550. * @param {number} fromIndex The index to search from.
  1551. * @param {boolean} [fromRight] Specify iterating from right to left.
  1552. * @returns {number} Returns the index of the matched value, else `-1`.
  1553. */
  1554. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  1555. var length = array.length,
  1556. index = fromIndex + (fromRight ? 1 : -1);
  1557. while ((fromRight ? index-- : ++index < length)) {
  1558. if (predicate(array[index], index, array)) {
  1559. return index;
  1560. }
  1561. }
  1562. return -1;
  1563. }
  1564. /**
  1565. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  1566. *
  1567. * @private
  1568. * @param {Array} array The array to inspect.
  1569. * @param {*} value The value to search for.
  1570. * @param {number} fromIndex The index to search from.
  1571. * @returns {number} Returns the index of the matched value, else `-1`.
  1572. */
  1573. function baseIndexOf(array, value, fromIndex) {
  1574. return value === value
  1575. ? strictIndexOf(array, value, fromIndex)
  1576. : baseFindIndex(array, baseIsNaN, fromIndex);
  1577. }
  1578. /**
  1579. * This function is like `baseIndexOf` except that it accepts a comparator.
  1580. *
  1581. * @private
  1582. * @param {Array} array The array to inspect.
  1583. * @param {*} value The value to search for.
  1584. * @param {number} fromIndex The index to search from.
  1585. * @param {Function} comparator The comparator invoked per element.
  1586. * @returns {number} Returns the index of the matched value, else `-1`.
  1587. */
  1588. function baseIndexOfWith(array, value, fromIndex, comparator) {
  1589. var index = fromIndex - 1,
  1590. length = array.length;
  1591. while (++index < length) {
  1592. if (comparator(array[index], value)) {
  1593. return index;
  1594. }
  1595. }
  1596. return -1;
  1597. }
  1598. /**
  1599. * The base implementation of `_.isNaN` without support for number objects.
  1600. *
  1601. * @private
  1602. * @param {*} value The value to check.
  1603. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  1604. */
  1605. function baseIsNaN(value) {
  1606. return value !== value;
  1607. }
  1608. /**
  1609. * The base implementation of `_.mean` and `_.meanBy` without support for
  1610. * iteratee shorthands.
  1611. *
  1612. * @private
  1613. * @param {Array} array The array to iterate over.
  1614. * @param {Function} iteratee The function invoked per iteration.
  1615. * @returns {number} Returns the mean.
  1616. */
  1617. function baseMean(array, iteratee) {
  1618. var length = array == null ? 0 : array.length;
  1619. return length ? (baseSum(array, iteratee) / length) : NAN;
  1620. }
  1621. /**
  1622. * The base implementation of `_.property` without support for deep paths.
  1623. *
  1624. * @private
  1625. * @param {string} key The key of the property to get.
  1626. * @returns {Function} Returns the new accessor function.
  1627. */
  1628. function baseProperty(key) {
  1629. return function(object) {
  1630. return object == null ? undefined : object[key];
  1631. };
  1632. }
  1633. /**
  1634. * The base implementation of `_.propertyOf` without support for deep paths.
  1635. *
  1636. * @private
  1637. * @param {Object} object The object to query.
  1638. * @returns {Function} Returns the new accessor function.
  1639. */
  1640. function basePropertyOf(object) {
  1641. return function(key) {
  1642. return object == null ? undefined : object[key];
  1643. };
  1644. }
  1645. /**
  1646. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  1647. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  1648. *
  1649. * @private
  1650. * @param {Array|Object} collection The collection to iterate over.
  1651. * @param {Function} iteratee The function invoked per iteration.
  1652. * @param {*} accumulator The initial value.
  1653. * @param {boolean} initAccum Specify using the first or last element of
  1654. * `collection` as the initial value.
  1655. * @param {Function} eachFunc The function to iterate over `collection`.
  1656. * @returns {*} Returns the accumulated value.
  1657. */
  1658. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  1659. eachFunc(collection, function(value, index, collection) {
  1660. accumulator = initAccum
  1661. ? (initAccum = false, value)
  1662. : iteratee(accumulator, value, index, collection);
  1663. });
  1664. return accumulator;
  1665. }
  1666. /**
  1667. * The base implementation of `_.sortBy` which uses `comparer` to define the
  1668. * sort order of `array` and replaces criteria objects with their corresponding
  1669. * values.
  1670. *
  1671. * @private
  1672. * @param {Array} array The array to sort.
  1673. * @param {Function} comparer The function to define sort order.
  1674. * @returns {Array} Returns `array`.
  1675. */
  1676. function baseSortBy(array, comparer) {
  1677. var length = array.length;
  1678. array.sort(comparer);
  1679. while (length--) {
  1680. array[length] = array[length].value;
  1681. }
  1682. return array;
  1683. }
  1684. /**
  1685. * The base implementation of `_.sum` and `_.sumBy` without support for
  1686. * iteratee shorthands.
  1687. *
  1688. * @private
  1689. * @param {Array} array The array to iterate over.
  1690. * @param {Function} iteratee The function invoked per iteration.
  1691. * @returns {number} Returns the sum.
  1692. */
  1693. function baseSum(array, iteratee) {
  1694. var result,
  1695. index = -1,
  1696. length = array.length;
  1697. while (++index < length) {
  1698. var current = iteratee(array[index]);
  1699. if (current !== undefined) {
  1700. result = result === undefined ? current : (result + current);
  1701. }
  1702. }
  1703. return result;
  1704. }
  1705. /**
  1706. * The base implementation of `_.times` without support for iteratee shorthands
  1707. * or max array length checks.
  1708. *
  1709. * @private
  1710. * @param {number} n The number of times to invoke `iteratee`.
  1711. * @param {Function} iteratee The function invoked per iteration.
  1712. * @returns {Array} Returns the array of results.
  1713. */
  1714. function baseTimes(n, iteratee) {
  1715. var index = -1,
  1716. result = Array(n);
  1717. while (++index < n) {
  1718. result[index] = iteratee(index);
  1719. }
  1720. return result;
  1721. }
  1722. /**
  1723. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  1724. * of key-value pairs for `object` corresponding to the property names of `props`.
  1725. *
  1726. * @private
  1727. * @param {Object} object The object to query.
  1728. * @param {Array} props The property names to get values for.
  1729. * @returns {Object} Returns the key-value pairs.
  1730. */
  1731. function baseToPairs(object, props) {
  1732. return arrayMap(props, function(key) {
  1733. return [key, object[key]];
  1734. });
  1735. }
  1736. /**
  1737. * The base implementation of `_.unary` without support for storing metadata.
  1738. *
  1739. * @private
  1740. * @param {Function} func The function to cap arguments for.
  1741. * @returns {Function} Returns the new capped function.
  1742. */
  1743. function baseUnary(func) {
  1744. return function(value) {
  1745. return func(value);
  1746. };
  1747. }
  1748. /**
  1749. * The base implementation of `_.values` and `_.valuesIn` which creates an
  1750. * array of `object` property values corresponding to the property names
  1751. * of `props`.
  1752. *
  1753. * @private
  1754. * @param {Object} object The object to query.
  1755. * @param {Array} props The property names to get values for.
  1756. * @returns {Object} Returns the array of property values.
  1757. */
  1758. function baseValues(object, props) {
  1759. return arrayMap(props, function(key) {
  1760. return object[key];
  1761. });
  1762. }
  1763. /**
  1764. * Checks if a `cache` value for `key` exists.
  1765. *
  1766. * @private
  1767. * @param {Object} cache The cache to query.
  1768. * @param {string} key The key of the entry to check.
  1769. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1770. */
  1771. function cacheHas(cache, key) {
  1772. return cache.has(key);
  1773. }
  1774. /**
  1775. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  1776. * that is not found in the character symbols.
  1777. *
  1778. * @private
  1779. * @param {Array} strSymbols The string symbols to inspect.
  1780. * @param {Array} chrSymbols The character symbols to find.
  1781. * @returns {number} Returns the index of the first unmatched string symbol.
  1782. */
  1783. function charsStartIndex(strSymbols, chrSymbols) {
  1784. var index = -1,
  1785. length = strSymbols.length;
  1786. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  1787. return index;
  1788. }
  1789. /**
  1790. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  1791. * that is not found in the character symbols.
  1792. *
  1793. * @private
  1794. * @param {Array} strSymbols The string symbols to inspect.
  1795. * @param {Array} chrSymbols The character symbols to find.
  1796. * @returns {number} Returns the index of the last unmatched string symbol.
  1797. */
  1798. function charsEndIndex(strSymbols, chrSymbols) {
  1799. var index = strSymbols.length;
  1800. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  1801. return index;
  1802. }
  1803. /**
  1804. * Gets the number of `placeholder` occurrences in `array`.
  1805. *
  1806. * @private
  1807. * @param {Array} array The array to inspect.
  1808. * @param {*} placeholder The placeholder to search for.
  1809. * @returns {number} Returns the placeholder count.
  1810. */
  1811. function countHolders(array, placeholder) {
  1812. var length = array.length,
  1813. result = 0;
  1814. while (length--) {
  1815. if (array[length] === placeholder) {
  1816. ++result;
  1817. }
  1818. }
  1819. return result;
  1820. }
  1821. /**
  1822. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  1823. * letters to basic Latin letters.
  1824. *
  1825. * @private
  1826. * @param {string} letter The matched letter to deburr.
  1827. * @returns {string} Returns the deburred letter.
  1828. */
  1829. var deburrLetter = basePropertyOf(deburredLetters);
  1830. /**
  1831. * Used by `_.escape` to convert characters to HTML entities.
  1832. *
  1833. * @private
  1834. * @param {string} chr The matched character to escape.
  1835. * @returns {string} Returns the escaped character.
  1836. */
  1837. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  1838. /**
  1839. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  1840. *
  1841. * @private
  1842. * @param {string} chr The matched character to escape.
  1843. * @returns {string} Returns the escaped character.
  1844. */
  1845. function escapeStringChar(chr) {
  1846. return '\\' + stringEscapes[chr];
  1847. }
  1848. /**
  1849. * Gets the value at `key` of `object`.
  1850. *
  1851. * @private
  1852. * @param {Object} [object] The object to query.
  1853. * @param {string} key The key of the property to get.
  1854. * @returns {*} Returns the property value.
  1855. */
  1856. function getValue(object, key) {
  1857. return object == null ? undefined : object[key];
  1858. }
  1859. /**
  1860. * Checks if `string` contains Unicode symbols.
  1861. *
  1862. * @private
  1863. * @param {string} string The string to inspect.
  1864. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  1865. */
  1866. function hasUnicode(string) {
  1867. return reHasUnicode.test(string);
  1868. }
  1869. /**
  1870. * Checks if `string` contains a word composed of Unicode symbols.
  1871. *
  1872. * @private
  1873. * @param {string} string The string to inspect.
  1874. * @returns {boolean} Returns `true` if a word is found, else `false`.
  1875. */
  1876. function hasUnicodeWord(string) {
  1877. return reHasUnicodeWord.test(string);
  1878. }
  1879. /**
  1880. * Converts `iterator` to an array.
  1881. *
  1882. * @private
  1883. * @param {Object} iterator The iterator to convert.
  1884. * @returns {Array} Returns the converted array.
  1885. */
  1886. function iteratorToArray(iterator) {
  1887. var data,
  1888. result = [];
  1889. while (!(data = iterator.next()).done) {
  1890. result.push(data.value);
  1891. }
  1892. return result;
  1893. }
  1894. /**
  1895. * Converts `map` to its key-value pairs.
  1896. *
  1897. * @private
  1898. * @param {Object} map The map to convert.
  1899. * @returns {Array} Returns the key-value pairs.
  1900. */
  1901. function mapToArray(map) {
  1902. var index = -1,
  1903. result = Array(map.size);
  1904. map.forEach(function(value, key) {
  1905. result[++index] = [key, value];
  1906. });
  1907. return result;
  1908. }
  1909. /**
  1910. * Creates a unary function that invokes `func` with its argument transformed.
  1911. *
  1912. * @private
  1913. * @param {Function} func The function to wrap.
  1914. * @param {Function} transform The argument transform.
  1915. * @returns {Function} Returns the new function.
  1916. */
  1917. function overArg(func, transform) {
  1918. return function(arg) {
  1919. return func(transform(arg));
  1920. };
  1921. }
  1922. /**
  1923. * Replaces all `placeholder` elements in `array` with an internal placeholder
  1924. * and returns an array of their indexes.
  1925. *
  1926. * @private
  1927. * @param {Array} array The array to modify.
  1928. * @param {*} placeholder The placeholder to replace.
  1929. * @returns {Array} Returns the new array of placeholder indexes.
  1930. */
  1931. function replaceHolders(array, placeholder) {
  1932. var index = -1,
  1933. length = array.length,
  1934. resIndex = 0,
  1935. result = [];
  1936. while (++index < length) {
  1937. var value = array[index];
  1938. if (value === placeholder || value === PLACEHOLDER) {
  1939. array[index] = PLACEHOLDER;
  1940. result[resIndex++] = index;
  1941. }
  1942. }
  1943. return result;
  1944. }
  1945. /**
  1946. * Converts `set` to an array of its values.
  1947. *
  1948. * @private
  1949. * @param {Object} set The set to convert.
  1950. * @returns {Array} Returns the values.
  1951. */
  1952. function setToArray(set) {
  1953. var index = -1,
  1954. result = Array(set.size);
  1955. set.forEach(function(value) {
  1956. result[++index] = value;
  1957. });
  1958. return result;
  1959. }
  1960. /**
  1961. * Converts `set` to its value-value pairs.
  1962. *
  1963. * @private
  1964. * @param {Object} set The set to convert.
  1965. * @returns {Array} Returns the value-value pairs.
  1966. */
  1967. function setToPairs(set) {
  1968. var index = -1,
  1969. result = Array(set.size);
  1970. set.forEach(function(value) {
  1971. result[++index] = [value, value];
  1972. });
  1973. return result;
  1974. }
  1975. /**
  1976. * A specialized version of `_.indexOf` which performs strict equality
  1977. * comparisons of values, i.e. `===`.
  1978. *
  1979. * @private
  1980. * @param {Array} array The array to inspect.
  1981. * @param {*} value The value to search for.
  1982. * @param {number} fromIndex The index to search from.
  1983. * @returns {number} Returns the index of the matched value, else `-1`.
  1984. */
  1985. function strictIndexOf(array, value, fromIndex) {
  1986. var index = fromIndex - 1,
  1987. length = array.length;
  1988. while (++index < length) {
  1989. if (array[index] === value) {
  1990. return index;
  1991. }
  1992. }
  1993. return -1;
  1994. }
  1995. /**
  1996. * A specialized version of `_.lastIndexOf` which performs strict equality
  1997. * comparisons of values, i.e. `===`.
  1998. *
  1999. * @private
  2000. * @param {Array} array The array to inspect.
  2001. * @param {*} value The value to search for.
  2002. * @param {number} fromIndex The index to search from.
  2003. * @returns {number} Returns the index of the matched value, else `-1`.
  2004. */
  2005. function strictLastIndexOf(array, value, fromIndex) {
  2006. var index = fromIndex + 1;
  2007. while (index--) {
  2008. if (array[index] === value) {
  2009. return index;
  2010. }
  2011. }
  2012. return index;
  2013. }
  2014. /**
  2015. * Gets the number of symbols in `string`.
  2016. *
  2017. * @private
  2018. * @param {string} string The string to inspect.
  2019. * @returns {number} Returns the string size.
  2020. */
  2021. function stringSize(string) {
  2022. return hasUnicode(string)
  2023. ? unicodeSize(string)
  2024. : asciiSize(string);
  2025. }
  2026. /**
  2027. * Converts `string` to an array.
  2028. *
  2029. * @private
  2030. * @param {string} string The string to convert.
  2031. * @returns {Array} Returns the converted array.
  2032. */
  2033. function stringToArray(string) {
  2034. return hasUnicode(string)
  2035. ? unicodeToArray(string)
  2036. : asciiToArray(string);
  2037. }
  2038. /**
  2039. * Used by `_.unescape` to convert HTML entities to characters.
  2040. *
  2041. * @private
  2042. * @param {string} chr The matched character to unescape.
  2043. * @returns {string} Returns the unescaped character.
  2044. */
  2045. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  2046. /**
  2047. * Gets the size of a Unicode `string`.
  2048. *
  2049. * @private
  2050. * @param {string} string The string inspect.
  2051. * @returns {number} Returns the string size.
  2052. */
  2053. function unicodeSize(string) {
  2054. var result = reUnicode.lastIndex = 0;
  2055. while (reUnicode.test(string)) {
  2056. ++result;
  2057. }
  2058. return result;
  2059. }
  2060. /**
  2061. * Converts a Unicode `string` to an array.
  2062. *
  2063. * @private
  2064. * @param {string} string The string to convert.
  2065. * @returns {Array} Returns the converted array.
  2066. */
  2067. function unicodeToArray(string) {
  2068. return string.match(reUnicode) || [];
  2069. }
  2070. /**
  2071. * Splits a Unicode `string` into an array of its words.
  2072. *
  2073. * @private
  2074. * @param {string} The string to inspect.
  2075. * @returns {Array} Returns the words of `string`.
  2076. */
  2077. function unicodeWords(string) {
  2078. return string.match(reUnicodeWord) || [];
  2079. }
  2080. /*--------------------------------------------------------------------------*/
  2081. /**
  2082. * Create a new pristine `lodash` function using the `context` object.
  2083. *
  2084. * @static
  2085. * @memberOf _
  2086. * @since 1.1.0
  2087. * @category Util
  2088. * @param {Object} [context=root] The context object.
  2089. * @returns {Function} Returns a new `lodash` function.
  2090. * @example
  2091. *
  2092. * _.mixin({ 'foo': _.constant('foo') });
  2093. *
  2094. * var lodash = _.runInContext();
  2095. * lodash.mixin({ 'bar': lodash.constant('bar') });
  2096. *
  2097. * _.isFunction(_.foo);
  2098. * // => true
  2099. * _.isFunction(_.bar);
  2100. * // => false
  2101. *
  2102. * lodash.isFunction(lodash.foo);
  2103. * // => false
  2104. * lodash.isFunction(lodash.bar);
  2105. * // => true
  2106. *
  2107. * // Create a suped-up `defer` in Node.js.
  2108. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  2109. */
  2110. var runInContext = (function runInContext(context) {
  2111. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  2112. /** Built-in constructor references. */
  2113. var Array = context.Array,
  2114. Date = context.Date,
  2115. Error = context.Error,
  2116. Function = context.Function,
  2117. Math = context.Math,
  2118. Object = context.Object,
  2119. RegExp = context.RegExp,
  2120. String = context.String,
  2121. TypeError = context.TypeError;
  2122. /** Used for built-in method references. */
  2123. var arrayProto = Array.prototype,
  2124. funcProto = Function.prototype,
  2125. objectProto = Object.prototype;
  2126. /** Used to detect overreaching core-js shims. */
  2127. var coreJsData = context['__core-js_shared__'];
  2128. /** Used to resolve the decompiled source of functions. */
  2129. var funcToString = funcProto.toString;
  2130. /** Used to check objects for own properties. */
  2131. var hasOwnProperty = objectProto.hasOwnProperty;
  2132. /** Used to generate unique IDs. */
  2133. var idCounter = 0;
  2134. /** Used to detect methods masquerading as native. */
  2135. var maskSrcKey = (function() {
  2136. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2137. return uid ? ('Symbol(src)_1.' + uid) : '';
  2138. }());
  2139. /**
  2140. * Used to resolve the
  2141. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2142. * of values.
  2143. */
  2144. var nativeObjectToString = objectProto.toString;
  2145. /** Used to infer the `Object` constructor. */
  2146. var objectCtorString = funcToString.call(Object);
  2147. /** Used to restore the original `_` reference in `_.noConflict`. */
  2148. var oldDash = root._;
  2149. /** Used to detect if a method is native. */
  2150. var reIsNative = RegExp('^' +
  2151. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2152. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2153. );
  2154. /** Built-in value references. */
  2155. var Buffer = moduleExports ? context.Buffer : undefined,
  2156. Symbol = context.Symbol,
  2157. Uint8Array = context.Uint8Array,
  2158. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  2159. getPrototype = overArg(Object.getPrototypeOf, Object),
  2160. objectCreate = Object.create,
  2161. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2162. splice = arrayProto.splice,
  2163. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  2164. symIterator = Symbol ? Symbol.iterator : undefined,
  2165. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  2166. var defineProperty = (function() {
  2167. try {
  2168. var func = getNative(Object, 'defineProperty');
  2169. func({}, '', {});
  2170. return func;
  2171. } catch (e) {}
  2172. }());
  2173. /** Mocked built-ins. */
  2174. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  2175. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  2176. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  2177. /* Built-in method references for those with the same name as other `lodash` methods. */
  2178. var nativeCeil = Math.ceil,
  2179. nativeFloor = Math.floor,
  2180. nativeGetSymbols = Object.getOwnPropertySymbols,
  2181. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  2182. nativeIsFinite = context.isFinite,
  2183. nativeJoin = arrayProto.join,
  2184. nativeKeys = overArg(Object.keys, Object),
  2185. nativeMax = Math.max,
  2186. nativeMin = Math.min,
  2187. nativeNow = Date.now,
  2188. nativeParseInt = context.parseInt,
  2189. nativeRandom = Math.random,
  2190. nativeReverse = arrayProto.reverse;
  2191. /* Built-in method references that are verified to be native. */
  2192. var DataView = getNative(context, 'DataView'),
  2193. Map = getNative(context, 'Map'),
  2194. Promise = getNative(context, 'Promise'),
  2195. Set = getNative(context, 'Set'),
  2196. WeakMap = getNative(context, 'WeakMap'),
  2197. nativeCreate = getNative(Object, 'create');
  2198. /** Used to store function metadata. */
  2199. var metaMap = WeakMap && new WeakMap;
  2200. /** Used to lookup unminified function names. */
  2201. var realNames = {};
  2202. /** Used to detect maps, sets, and weakmaps. */
  2203. var dataViewCtorString = toSource(DataView),
  2204. mapCtorString = toSource(Map),
  2205. promiseCtorString = toSource(Promise),
  2206. setCtorString = toSource(Set),
  2207. weakMapCtorString = toSource(WeakMap);
  2208. /** Used to convert symbols to primitives and strings. */
  2209. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2210. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2211. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2212. /*------------------------------------------------------------------------*/
  2213. /**
  2214. * Creates a `lodash` object which wraps `value` to enable implicit method
  2215. * chain sequences. Methods that operate on and return arrays, collections,
  2216. * and functions can be chained together. Methods that retrieve a single value
  2217. * or may return a primitive value will automatically end the chain sequence
  2218. * and return the unwrapped value. Otherwise, the value must be unwrapped
  2219. * with `_#value`.
  2220. *
  2221. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  2222. * enabled using `_.chain`.
  2223. *
  2224. * The execution of chained methods is lazy, that is, it's deferred until
  2225. * `_#value` is implicitly or explicitly called.
  2226. *
  2227. * Lazy evaluation allows several methods to support shortcut fusion.
  2228. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  2229. * the creation of intermediate arrays and can greatly reduce the number of
  2230. * iteratee executions. Sections of a chain sequence qualify for shortcut
  2231. * fusion if the section is applied to an array and iteratees accept only
  2232. * one argument. The heuristic for whether a section qualifies for shortcut
  2233. * fusion is subject to change.
  2234. *
  2235. * Chaining is supported in custom builds as long as the `_#value` method is
  2236. * directly or indirectly included in the build.
  2237. *
  2238. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  2239. *
  2240. * The wrapper `Array` methods are:
  2241. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  2242. *
  2243. * The wrapper `String` methods are:
  2244. * `replace` and `split`
  2245. *
  2246. * The wrapper methods that support shortcut fusion are:
  2247. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  2248. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  2249. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  2250. *
  2251. * The chainable wrapper methods are:
  2252. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  2253. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  2254. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  2255. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  2256. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  2257. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  2258. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  2259. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  2260. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  2261. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  2262. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  2263. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  2264. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  2265. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  2266. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  2267. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  2268. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  2269. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  2270. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  2271. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  2272. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  2273. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  2274. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  2275. * `zipObject`, `zipObjectDeep`, and `zipWith`
  2276. *
  2277. * The wrapper methods that are **not** chainable by default are:
  2278. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  2279. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  2280. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  2281. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  2282. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  2283. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  2284. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  2285. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  2286. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  2287. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  2288. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  2289. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  2290. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  2291. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  2292. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  2293. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  2294. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  2295. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  2296. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  2297. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  2298. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  2299. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  2300. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  2301. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  2302. * `upperFirst`, `value`, and `words`
  2303. *
  2304. * @name _
  2305. * @constructor
  2306. * @category Seq
  2307. * @param {*} value The value to wrap in a `lodash` instance.
  2308. * @returns {Object} Returns the new `lodash` wrapper instance.
  2309. * @example
  2310. *
  2311. * function square(n) {
  2312. * return n * n;
  2313. * }
  2314. *
  2315. * var wrapped = _([1, 2, 3]);
  2316. *
  2317. * // Returns an unwrapped value.
  2318. * wrapped.reduce(_.add);
  2319. * // => 6
  2320. *
  2321. * // Returns a wrapped value.
  2322. * var squares = wrapped.map(square);
  2323. *
  2324. * _.isArray(squares);
  2325. * // => false
  2326. *
  2327. * _.isArray(squares.value());
  2328. * // => true
  2329. */
  2330. function lodash(value) {
  2331. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  2332. if (value instanceof LodashWrapper) {
  2333. return value;
  2334. }
  2335. if (hasOwnProperty.call(value, '__wrapped__')) {
  2336. return wrapperClone(value);
  2337. }
  2338. }
  2339. return new LodashWrapper(value);
  2340. }
  2341. /**
  2342. * The base implementation of `_.create` without support for assigning
  2343. * properties to the created object.
  2344. *
  2345. * @private
  2346. * @param {Object} proto The object to inherit from.
  2347. * @returns {Object} Returns the new object.
  2348. */
  2349. var baseCreate = (function() {
  2350. function object() {}
  2351. return function(proto) {
  2352. if (!isObject(proto)) {
  2353. return {};
  2354. }
  2355. if (objectCreate) {
  2356. return objectCreate(proto);
  2357. }
  2358. object.prototype = proto;
  2359. var result = new object;
  2360. object.prototype = undefined;
  2361. return result;
  2362. };
  2363. }());
  2364. /**
  2365. * The function whose prototype chain sequence wrappers inherit from.
  2366. *
  2367. * @private
  2368. */
  2369. function baseLodash() {
  2370. // No operation performed.
  2371. }
  2372. /**
  2373. * The base constructor for creating `lodash` wrapper objects.
  2374. *
  2375. * @private
  2376. * @param {*} value The value to wrap.
  2377. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  2378. */
  2379. function LodashWrapper(value, chainAll) {
  2380. this.__wrapped__ = value;
  2381. this.__actions__ = [];
  2382. this.__chain__ = !!chainAll;
  2383. this.__index__ = 0;
  2384. this.__values__ = undefined;
  2385. }
  2386. /**
  2387. * By default, the template delimiters used by lodash are like those in
  2388. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  2389. * following template settings to use alternative delimiters.
  2390. *
  2391. * @static
  2392. * @memberOf _
  2393. * @type {Object}
  2394. */
  2395. lodash.templateSettings = {
  2396. /**
  2397. * Used to detect `data` property values to be HTML-escaped.
  2398. *
  2399. * @memberOf _.templateSettings
  2400. * @type {RegExp}
  2401. */
  2402. 'escape': reEscape,
  2403. /**
  2404. * Used to detect code to be evaluated.
  2405. *
  2406. * @memberOf _.templateSettings
  2407. * @type {RegExp}
  2408. */
  2409. 'evaluate': reEvaluate,
  2410. /**
  2411. * Used to detect `data` property values to inject.
  2412. *
  2413. * @memberOf _.templateSettings
  2414. * @type {RegExp}
  2415. */
  2416. 'interpolate': reInterpolate,
  2417. /**
  2418. * Used to reference the data object in the template text.
  2419. *
  2420. * @memberOf _.templateSettings
  2421. * @type {string}
  2422. */
  2423. 'variable': '',
  2424. /**
  2425. * Used to import variables into the compiled template.
  2426. *
  2427. * @memberOf _.templateSettings
  2428. * @type {Object}
  2429. */
  2430. 'imports': {
  2431. /**
  2432. * A reference to the `lodash` function.
  2433. *
  2434. * @memberOf _.templateSettings.imports
  2435. * @type {Function}
  2436. */
  2437. '_': lodash
  2438. }
  2439. };
  2440. // Ensure wrappers are instances of `baseLodash`.
  2441. lodash.prototype = baseLodash.prototype;
  2442. lodash.prototype.constructor = lodash;
  2443. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  2444. LodashWrapper.prototype.constructor = LodashWrapper;
  2445. /*------------------------------------------------------------------------*/
  2446. /**
  2447. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  2448. *
  2449. * @private
  2450. * @constructor
  2451. * @param {*} value The value to wrap.
  2452. */
  2453. function LazyWrapper(value) {
  2454. this.__wrapped__ = value;
  2455. this.__actions__ = [];
  2456. this.__dir__ = 1;
  2457. this.__filtered__ = false;
  2458. this.__iteratees__ = [];
  2459. this.__takeCount__ = MAX_ARRAY_LENGTH;
  2460. this.__views__ = [];
  2461. }
  2462. /**
  2463. * Creates a clone of the lazy wrapper object.
  2464. *
  2465. * @private
  2466. * @name clone
  2467. * @memberOf LazyWrapper
  2468. * @returns {Object} Returns the cloned `LazyWrapper` object.
  2469. */
  2470. function lazyClone() {
  2471. var result = new LazyWrapper(this.__wrapped__);
  2472. result.__actions__ = copyArray(this.__actions__);
  2473. result.__dir__ = this.__dir__;
  2474. result.__filtered__ = this.__filtered__;
  2475. result.__iteratees__ = copyArray(this.__iteratees__);
  2476. result.__takeCount__ = this.__takeCount__;
  2477. result.__views__ = copyArray(this.__views__);
  2478. return result;
  2479. }
  2480. /**
  2481. * Reverses the direction of lazy iteration.
  2482. *
  2483. * @private
  2484. * @name reverse
  2485. * @memberOf LazyWrapper
  2486. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  2487. */
  2488. function lazyReverse() {
  2489. if (this.__filtered__) {
  2490. var result = new LazyWrapper(this);
  2491. result.__dir__ = -1;
  2492. result.__filtered__ = true;
  2493. } else {
  2494. result = this.clone();
  2495. result.__dir__ *= -1;
  2496. }
  2497. return result;
  2498. }
  2499. /**
  2500. * Extracts the unwrapped value from its lazy wrapper.
  2501. *
  2502. * @private
  2503. * @name value
  2504. * @memberOf LazyWrapper
  2505. * @returns {*} Returns the unwrapped value.
  2506. */
  2507. function lazyValue() {
  2508. var array = this.__wrapped__.value(),
  2509. dir = this.__dir__,
  2510. isArr = isArray(array),
  2511. isRight = dir < 0,
  2512. arrLength = isArr ? array.length : 0,
  2513. view = getView(0, arrLength, this.__views__),
  2514. start = view.start,
  2515. end = view.end,
  2516. length = end - start,
  2517. index = isRight ? end : (start - 1),
  2518. iteratees = this.__iteratees__,
  2519. iterLength = iteratees.length,
  2520. resIndex = 0,
  2521. takeCount = nativeMin(length, this.__takeCount__);
  2522. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  2523. return baseWrapperValue(array, this.__actions__);
  2524. }
  2525. var result = [];
  2526. outer:
  2527. while (length-- && resIndex < takeCount) {
  2528. index += dir;
  2529. var iterIndex = -1,
  2530. value = array[index];
  2531. while (++iterIndex < iterLength) {
  2532. var data = iteratees[iterIndex],
  2533. iteratee = data.iteratee,
  2534. type = data.type,
  2535. computed = iteratee(value);
  2536. if (type == LAZY_MAP_FLAG) {
  2537. value = computed;
  2538. } else if (!computed) {
  2539. if (type == LAZY_FILTER_FLAG) {
  2540. continue outer;
  2541. } else {
  2542. break outer;
  2543. }
  2544. }
  2545. }
  2546. result[resIndex++] = value;
  2547. }
  2548. return result;
  2549. }
  2550. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  2551. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  2552. LazyWrapper.prototype.constructor = LazyWrapper;
  2553. /*------------------------------------------------------------------------*/
  2554. /**
  2555. * Creates a hash object.
  2556. *
  2557. * @private
  2558. * @constructor
  2559. * @param {Array} [entries] The key-value pairs to cache.
  2560. */
  2561. function Hash(entries) {
  2562. var index = -1,
  2563. length = entries == null ? 0 : entries.length;
  2564. this.clear();
  2565. while (++index < length) {
  2566. var entry = entries[index];
  2567. this.set(entry[0], entry[1]);
  2568. }
  2569. }
  2570. /**
  2571. * Removes all key-value entries from the hash.
  2572. *
  2573. * @private
  2574. * @name clear
  2575. * @memberOf Hash
  2576. */
  2577. function hashClear() {
  2578. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  2579. this.size = 0;
  2580. }
  2581. /**
  2582. * Removes `key` and its value from the hash.
  2583. *
  2584. * @private
  2585. * @name delete
  2586. * @memberOf Hash
  2587. * @param {Object} hash The hash to modify.
  2588. * @param {string} key The key of the value to remove.
  2589. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2590. */
  2591. function hashDelete(key) {
  2592. var result = this.has(key) && delete this.__data__[key];
  2593. this.size -= result ? 1 : 0;
  2594. return result;
  2595. }
  2596. /**
  2597. * Gets the hash value for `key`.
  2598. *
  2599. * @private
  2600. * @name get
  2601. * @memberOf Hash
  2602. * @param {string} key The key of the value to get.
  2603. * @returns {*} Returns the entry value.
  2604. */
  2605. function hashGet(key) {
  2606. var data = this.__data__;
  2607. if (nativeCreate) {
  2608. var result = data[key];
  2609. return result === HASH_UNDEFINED ? undefined : result;
  2610. }
  2611. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  2612. }
  2613. /**
  2614. * Checks if a hash value for `key` exists.
  2615. *
  2616. * @private
  2617. * @name has
  2618. * @memberOf Hash
  2619. * @param {string} key The key of the entry to check.
  2620. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2621. */
  2622. function hashHas(key) {
  2623. var data = this.__data__;
  2624. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  2625. }
  2626. /**
  2627. * Sets the hash `key` to `value`.
  2628. *
  2629. * @private
  2630. * @name set
  2631. * @memberOf Hash
  2632. * @param {string} key The key of the value to set.
  2633. * @param {*} value The value to set.
  2634. * @returns {Object} Returns the hash instance.
  2635. */
  2636. function hashSet(key, value) {
  2637. var data = this.__data__;
  2638. this.size += this.has(key) ? 0 : 1;
  2639. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  2640. return this;
  2641. }
  2642. // Add methods to `Hash`.
  2643. Hash.prototype.clear = hashClear;
  2644. Hash.prototype['delete'] = hashDelete;
  2645. Hash.prototype.get = hashGet;
  2646. Hash.prototype.has = hashHas;
  2647. Hash.prototype.set = hashSet;
  2648. /*------------------------------------------------------------------------*/
  2649. /**
  2650. * Creates an list cache object.
  2651. *
  2652. * @private
  2653. * @constructor
  2654. * @param {Array} [entries] The key-value pairs to cache.
  2655. */
  2656. function ListCache(entries) {
  2657. var index = -1,
  2658. length = entries == null ? 0 : entries.length;
  2659. this.clear();
  2660. while (++index < length) {
  2661. var entry = entries[index];
  2662. this.set(entry[0], entry[1]);
  2663. }
  2664. }
  2665. /**
  2666. * Removes all key-value entries from the list cache.
  2667. *
  2668. * @private
  2669. * @name clear
  2670. * @memberOf ListCache
  2671. */
  2672. function listCacheClear() {
  2673. this.__data__ = [];
  2674. this.size = 0;
  2675. }
  2676. /**
  2677. * Removes `key` and its value from the list cache.
  2678. *
  2679. * @private
  2680. * @name delete
  2681. * @memberOf ListCache
  2682. * @param {string} key The key of the value to remove.
  2683. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2684. */
  2685. function listCacheDelete(key) {
  2686. var data = this.__data__,
  2687. index = assocIndexOf(data, key);
  2688. if (index < 0) {
  2689. return false;
  2690. }
  2691. var lastIndex = data.length - 1;
  2692. if (index == lastIndex) {
  2693. data.pop();
  2694. } else {
  2695. splice.call(data, index, 1);
  2696. }
  2697. --this.size;
  2698. return true;
  2699. }
  2700. /**
  2701. * Gets the list cache value for `key`.
  2702. *
  2703. * @private
  2704. * @name get
  2705. * @memberOf ListCache
  2706. * @param {string} key The key of the value to get.
  2707. * @returns {*} Returns the entry value.
  2708. */
  2709. function listCacheGet(key) {
  2710. var data = this.__data__,
  2711. index = assocIndexOf(data, key);
  2712. return index < 0 ? undefined : data[index][1];
  2713. }
  2714. /**
  2715. * Checks if a list cache value for `key` exists.
  2716. *
  2717. * @private
  2718. * @name has
  2719. * @memberOf ListCache
  2720. * @param {string} key The key of the entry to check.
  2721. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2722. */
  2723. function listCacheHas(key) {
  2724. return assocIndexOf(this.__data__, key) > -1;
  2725. }
  2726. /**
  2727. * Sets the list cache `key` to `value`.
  2728. *
  2729. * @private
  2730. * @name set
  2731. * @memberOf ListCache
  2732. * @param {string} key The key of the value to set.
  2733. * @param {*} value The value to set.
  2734. * @returns {Object} Returns the list cache instance.
  2735. */
  2736. function listCacheSet(key, value) {
  2737. var data = this.__data__,
  2738. index = assocIndexOf(data, key);
  2739. if (index < 0) {
  2740. ++this.size;
  2741. data.push([key, value]);
  2742. } else {
  2743. data[index][1] = value;
  2744. }
  2745. return this;
  2746. }
  2747. // Add methods to `ListCache`.
  2748. ListCache.prototype.clear = listCacheClear;
  2749. ListCache.prototype['delete'] = listCacheDelete;
  2750. ListCache.prototype.get = listCacheGet;
  2751. ListCache.prototype.has = listCacheHas;
  2752. ListCache.prototype.set = listCacheSet;
  2753. /*------------------------------------------------------------------------*/
  2754. /**
  2755. * Creates a map cache object to store key-value pairs.
  2756. *
  2757. * @private
  2758. * @constructor
  2759. * @param {Array} [entries] The key-value pairs to cache.
  2760. */
  2761. function MapCache(entries) {
  2762. var index = -1,
  2763. length = entries == null ? 0 : entries.length;
  2764. this.clear();
  2765. while (++index < length) {
  2766. var entry = entries[index];
  2767. this.set(entry[0], entry[1]);
  2768. }
  2769. }
  2770. /**
  2771. * Removes all key-value entries from the map.
  2772. *
  2773. * @private
  2774. * @name clear
  2775. * @memberOf MapCache
  2776. */
  2777. function mapCacheClear() {
  2778. this.size = 0;
  2779. this.__data__ = {
  2780. 'hash': new Hash,
  2781. 'map': new (Map || ListCache),
  2782. 'string': new Hash
  2783. };
  2784. }
  2785. /**
  2786. * Removes `key` and its value from the map.
  2787. *
  2788. * @private
  2789. * @name delete
  2790. * @memberOf MapCache
  2791. * @param {string} key The key of the value to remove.
  2792. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2793. */
  2794. function mapCacheDelete(key) {
  2795. var result = getMapData(this, key)['delete'](key);
  2796. this.size -= result ? 1 : 0;
  2797. return result;
  2798. }
  2799. /**
  2800. * Gets the map value for `key`.
  2801. *
  2802. * @private
  2803. * @name get
  2804. * @memberOf MapCache
  2805. * @param {string} key The key of the value to get.
  2806. * @returns {*} Returns the entry value.
  2807. */
  2808. function mapCacheGet(key) {
  2809. return getMapData(this, key).get(key);
  2810. }
  2811. /**
  2812. * Checks if a map value for `key` exists.
  2813. *
  2814. * @private
  2815. * @name has
  2816. * @memberOf MapCache
  2817. * @param {string} key The key of the entry to check.
  2818. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2819. */
  2820. function mapCacheHas(key) {
  2821. return getMapData(this, key).has(key);
  2822. }
  2823. /**
  2824. * Sets the map `key` to `value`.
  2825. *
  2826. * @private
  2827. * @name set
  2828. * @memberOf MapCache
  2829. * @param {string} key The key of the value to set.
  2830. * @param {*} value The value to set.
  2831. * @returns {Object} Returns the map cache instance.
  2832. */
  2833. function mapCacheSet(key, value) {
  2834. var data = getMapData(this, key),
  2835. size = data.size;
  2836. data.set(key, value);
  2837. this.size += data.size == size ? 0 : 1;
  2838. return this;
  2839. }
  2840. // Add methods to `MapCache`.
  2841. MapCache.prototype.clear = mapCacheClear;
  2842. MapCache.prototype['delete'] = mapCacheDelete;
  2843. MapCache.prototype.get = mapCacheGet;
  2844. MapCache.prototype.has = mapCacheHas;
  2845. MapCache.prototype.set = mapCacheSet;
  2846. /*------------------------------------------------------------------------*/
  2847. /**
  2848. *
  2849. * Creates an array cache object to store unique values.
  2850. *
  2851. * @private
  2852. * @constructor
  2853. * @param {Array} [values] The values to cache.
  2854. */
  2855. function SetCache(values) {
  2856. var index = -1,
  2857. length = values == null ? 0 : values.length;
  2858. this.__data__ = new MapCache;
  2859. while (++index < length) {
  2860. this.add(values[index]);
  2861. }
  2862. }
  2863. /**
  2864. * Adds `value` to the array cache.
  2865. *
  2866. * @private
  2867. * @name add
  2868. * @memberOf SetCache
  2869. * @alias push
  2870. * @param {*} value The value to cache.
  2871. * @returns {Object} Returns the cache instance.
  2872. */
  2873. function setCacheAdd(value) {
  2874. this.__data__.set(value, HASH_UNDEFINED);
  2875. return this;
  2876. }
  2877. /**
  2878. * Checks if `value` is in the array cache.
  2879. *
  2880. * @private
  2881. * @name has
  2882. * @memberOf SetCache
  2883. * @param {*} value The value to search for.
  2884. * @returns {number} Returns `true` if `value` is found, else `false`.
  2885. */
  2886. function setCacheHas(value) {
  2887. return this.__data__.has(value);
  2888. }
  2889. // Add methods to `SetCache`.
  2890. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  2891. SetCache.prototype.has = setCacheHas;
  2892. /*------------------------------------------------------------------------*/
  2893. /**
  2894. * Creates a stack cache object to store key-value pairs.
  2895. *
  2896. * @private
  2897. * @constructor
  2898. * @param {Array} [entries] The key-value pairs to cache.
  2899. */
  2900. function Stack(entries) {
  2901. var data = this.__data__ = new ListCache(entries);
  2902. this.size = data.size;
  2903. }
  2904. /**
  2905. * Removes all key-value entries from the stack.
  2906. *
  2907. * @private
  2908. * @name clear
  2909. * @memberOf Stack
  2910. */
  2911. function stackClear() {
  2912. this.__data__ = new ListCache;
  2913. this.size = 0;
  2914. }
  2915. /**
  2916. * Removes `key` and its value from the stack.
  2917. *
  2918. * @private
  2919. * @name delete
  2920. * @memberOf Stack
  2921. * @param {string} key The key of the value to remove.
  2922. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2923. */
  2924. function stackDelete(key) {
  2925. var data = this.__data__,
  2926. result = data['delete'](key);
  2927. this.size = data.size;
  2928. return result;
  2929. }
  2930. /**
  2931. * Gets the stack value for `key`.
  2932. *
  2933. * @private
  2934. * @name get
  2935. * @memberOf Stack
  2936. * @param {string} key The key of the value to get.
  2937. * @returns {*} Returns the entry value.
  2938. */
  2939. function stackGet(key) {
  2940. return this.__data__.get(key);
  2941. }
  2942. /**
  2943. * Checks if a stack value for `key` exists.
  2944. *
  2945. * @private
  2946. * @name has
  2947. * @memberOf Stack
  2948. * @param {string} key The key of the entry to check.
  2949. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2950. */
  2951. function stackHas(key) {
  2952. return this.__data__.has(key);
  2953. }
  2954. /**
  2955. * Sets the stack `key` to `value`.
  2956. *
  2957. * @private
  2958. * @name set
  2959. * @memberOf Stack
  2960. * @param {string} key The key of the value to set.
  2961. * @param {*} value The value to set.
  2962. * @returns {Object} Returns the stack cache instance.
  2963. */
  2964. function stackSet(key, value) {
  2965. var data = this.__data__;
  2966. if (data instanceof ListCache) {
  2967. var pairs = data.__data__;
  2968. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  2969. pairs.push([key, value]);
  2970. this.size = ++data.size;
  2971. return this;
  2972. }
  2973. data = this.__data__ = new MapCache(pairs);
  2974. }
  2975. data.set(key, value);
  2976. this.size = data.size;
  2977. return this;
  2978. }
  2979. // Add methods to `Stack`.
  2980. Stack.prototype.clear = stackClear;
  2981. Stack.prototype['delete'] = stackDelete;
  2982. Stack.prototype.get = stackGet;
  2983. Stack.prototype.has = stackHas;
  2984. Stack.prototype.set = stackSet;
  2985. /*------------------------------------------------------------------------*/
  2986. /**
  2987. * Creates an array of the enumerable property names of the array-like `value`.
  2988. *
  2989. * @private
  2990. * @param {*} value The value to query.
  2991. * @param {boolean} inherited Specify returning inherited property names.
  2992. * @returns {Array} Returns the array of property names.
  2993. */
  2994. function arrayLikeKeys(value, inherited) {
  2995. var isArr = isArray(value),
  2996. isArg = !isArr && isArguments(value),
  2997. isBuff = !isArr && !isArg && isBuffer(value),
  2998. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  2999. skipIndexes = isArr || isArg || isBuff || isType,
  3000. result = skipIndexes ? baseTimes(value.length, String) : [],
  3001. length = result.length;
  3002. for (var key in value) {
  3003. if ((inherited || hasOwnProperty.call(value, key)) &&
  3004. !(skipIndexes && (
  3005. // Safari 9 has enumerable `arguments.length` in strict mode.
  3006. key == 'length' ||
  3007. // Node.js 0.10 has enumerable non-index properties on buffers.
  3008. (isBuff && (key == 'offset' || key == 'parent')) ||
  3009. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3010. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  3011. // Skip index properties.
  3012. isIndex(key, length)
  3013. ))) {
  3014. result.push(key);
  3015. }
  3016. }
  3017. return result;
  3018. }
  3019. /**
  3020. * A specialized version of `_.sample` for arrays.
  3021. *
  3022. * @private
  3023. * @param {Array} array The array to sample.
  3024. * @returns {*} Returns the random element.
  3025. */
  3026. function arraySample(array) {
  3027. var length = array.length;
  3028. return length ? array[baseRandom(0, length - 1)] : undefined;
  3029. }
  3030. /**
  3031. * A specialized version of `_.sampleSize` for arrays.
  3032. *
  3033. * @private
  3034. * @param {Array} array The array to sample.
  3035. * @param {number} n The number of elements to sample.
  3036. * @returns {Array} Returns the random elements.
  3037. */
  3038. function arraySampleSize(array, n) {
  3039. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  3040. }
  3041. /**
  3042. * A specialized version of `_.shuffle` for arrays.
  3043. *
  3044. * @private
  3045. * @param {Array} array The array to shuffle.
  3046. * @returns {Array} Returns the new shuffled array.
  3047. */
  3048. function arrayShuffle(array) {
  3049. return shuffleSelf(copyArray(array));
  3050. }
  3051. /**
  3052. * This function is like `assignValue` except that it doesn't assign
  3053. * `undefined` values.
  3054. *
  3055. * @private
  3056. * @param {Object} object The object to modify.
  3057. * @param {string} key The key of the property to assign.
  3058. * @param {*} value The value to assign.
  3059. */
  3060. function assignMergeValue(object, key, value) {
  3061. if ((value !== undefined && !eq(object[key], value)) ||
  3062. (value === undefined && !(key in object))) {
  3063. baseAssignValue(object, key, value);
  3064. }
  3065. }
  3066. /**
  3067. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  3068. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3069. * for equality comparisons.
  3070. *
  3071. * @private
  3072. * @param {Object} object The object to modify.
  3073. * @param {string} key The key of the property to assign.
  3074. * @param {*} value The value to assign.
  3075. */
  3076. function assignValue(object, key, value) {
  3077. var objValue = object[key];
  3078. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  3079. (value === undefined && !(key in object))) {
  3080. baseAssignValue(object, key, value);
  3081. }
  3082. }
  3083. /**
  3084. * Gets the index at which the `key` is found in `array` of key-value pairs.
  3085. *
  3086. * @private
  3087. * @param {Array} array The array to inspect.
  3088. * @param {*} key The key to search for.
  3089. * @returns {number} Returns the index of the matched value, else `-1`.
  3090. */
  3091. function assocIndexOf(array, key) {
  3092. var length = array.length;
  3093. while (length--) {
  3094. if (eq(array[length][0], key)) {
  3095. return length;
  3096. }
  3097. }
  3098. return -1;
  3099. }
  3100. /**
  3101. * Aggregates elements of `collection` on `accumulator` with keys transformed
  3102. * by `iteratee` and values set by `setter`.
  3103. *
  3104. * @private
  3105. * @param {Array|Object} collection The collection to iterate over.
  3106. * @param {Function} setter The function to set `accumulator` values.
  3107. * @param {Function} iteratee The iteratee to transform keys.
  3108. * @param {Object} accumulator The initial aggregated object.
  3109. * @returns {Function} Returns `accumulator`.
  3110. */
  3111. function baseAggregator(collection, setter, iteratee, accumulator) {
  3112. baseEach(collection, function(value, key, collection) {
  3113. setter(accumulator, value, iteratee(value), collection);
  3114. });
  3115. return accumulator;
  3116. }
  3117. /**
  3118. * The base implementation of `_.assign` without support for multiple sources
  3119. * or `customizer` functions.
  3120. *
  3121. * @private
  3122. * @param {Object} object The destination object.
  3123. * @param {Object} source The source object.
  3124. * @returns {Object} Returns `object`.
  3125. */
  3126. function baseAssign(object, source) {
  3127. return object && copyObject(source, keys(source), object);
  3128. }
  3129. /**
  3130. * The base implementation of `_.assignIn` without support for multiple sources
  3131. * or `customizer` functions.
  3132. *
  3133. * @private
  3134. * @param {Object} object The destination object.
  3135. * @param {Object} source The source object.
  3136. * @returns {Object} Returns `object`.
  3137. */
  3138. function baseAssignIn(object, source) {
  3139. return object && copyObject(source, keysIn(source), object);
  3140. }
  3141. /**
  3142. * The base implementation of `assignValue` and `assignMergeValue` without
  3143. * value checks.
  3144. *
  3145. * @private
  3146. * @param {Object} object The object to modify.
  3147. * @param {string} key The key of the property to assign.
  3148. * @param {*} value The value to assign.
  3149. */
  3150. function baseAssignValue(object, key, value) {
  3151. if (key == '__proto__' && defineProperty) {
  3152. defineProperty(object, key, {
  3153. 'configurable': true,
  3154. 'enumerable': true,
  3155. 'value': value,
  3156. 'writable': true
  3157. });
  3158. } else {
  3159. object[key] = value;
  3160. }
  3161. }
  3162. /**
  3163. * The base implementation of `_.at` without support for individual paths.
  3164. *
  3165. * @private
  3166. * @param {Object} object The object to iterate over.
  3167. * @param {string[]} paths The property paths to pick.
  3168. * @returns {Array} Returns the picked elements.
  3169. */
  3170. function baseAt(object, paths) {
  3171. var index = -1,
  3172. length = paths.length,
  3173. result = Array(length),
  3174. skip = object == null;
  3175. while (++index < length) {
  3176. result[index] = skip ? undefined : get(object, paths[index]);
  3177. }
  3178. return result;
  3179. }
  3180. /**
  3181. * The base implementation of `_.clamp` which doesn't coerce arguments.
  3182. *
  3183. * @private
  3184. * @param {number} number The number to clamp.
  3185. * @param {number} [lower] The lower bound.
  3186. * @param {number} upper The upper bound.
  3187. * @returns {number} Returns the clamped number.
  3188. */
  3189. function baseClamp(number, lower, upper) {
  3190. if (number === number) {
  3191. if (upper !== undefined) {
  3192. number = number <= upper ? number : upper;
  3193. }
  3194. if (lower !== undefined) {
  3195. number = number >= lower ? number : lower;
  3196. }
  3197. }
  3198. return number;
  3199. }
  3200. /**
  3201. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  3202. * traversed objects.
  3203. *
  3204. * @private
  3205. * @param {*} value The value to clone.
  3206. * @param {boolean} bitmask The bitmask flags.
  3207. * 1 - Deep clone
  3208. * 2 - Flatten inherited properties
  3209. * 4 - Clone symbols
  3210. * @param {Function} [customizer] The function to customize cloning.
  3211. * @param {string} [key] The key of `value`.
  3212. * @param {Object} [object] The parent object of `value`.
  3213. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  3214. * @returns {*} Returns the cloned value.
  3215. */
  3216. function baseClone(value, bitmask, customizer, key, object, stack) {
  3217. var result,
  3218. isDeep = bitmask & CLONE_DEEP_FLAG,
  3219. isFlat = bitmask & CLONE_FLAT_FLAG,
  3220. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  3221. if (customizer) {
  3222. result = object ? customizer(value, key, object, stack) : customizer(value);
  3223. }
  3224. if (result !== undefined) {
  3225. return result;
  3226. }
  3227. if (!isObject(value)) {
  3228. return value;
  3229. }
  3230. var isArr = isArray(value);
  3231. if (isArr) {
  3232. result = initCloneArray(value);
  3233. if (!isDeep) {
  3234. return copyArray(value, result);
  3235. }
  3236. } else {
  3237. var tag = getTag(value),
  3238. isFunc = tag == funcTag || tag == genTag;
  3239. if (isBuffer(value)) {
  3240. return cloneBuffer(value, isDeep);
  3241. }
  3242. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  3243. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  3244. if (!isDeep) {
  3245. return isFlat
  3246. ? copySymbolsIn(value, baseAssignIn(result, value))
  3247. : copySymbols(value, baseAssign(result, value));
  3248. }
  3249. } else {
  3250. if (!cloneableTags[tag]) {
  3251. return object ? value : {};
  3252. }
  3253. result = initCloneByTag(value, tag, baseClone, isDeep);
  3254. }
  3255. }
  3256. // Check for circular references and return its corresponding clone.
  3257. stack || (stack = new Stack);
  3258. var stacked = stack.get(value);
  3259. if (stacked) {
  3260. return stacked;
  3261. }
  3262. stack.set(value, result);
  3263. var keysFunc = isFull
  3264. ? (isFlat ? getAllKeysIn : getAllKeys)
  3265. : (isFlat ? keysIn : keys);
  3266. var props = isArr ? undefined : keysFunc(value);
  3267. arrayEach(props || value, function(subValue, key) {
  3268. if (props) {
  3269. key = subValue;
  3270. subValue = value[key];
  3271. }
  3272. // Recursively populate clone (susceptible to call stack limits).
  3273. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  3274. });
  3275. return result;
  3276. }
  3277. /**
  3278. * The base implementation of `_.conforms` which doesn't clone `source`.
  3279. *
  3280. * @private
  3281. * @param {Object} source The object of property predicates to conform to.
  3282. * @returns {Function} Returns the new spec function.
  3283. */
  3284. function baseConforms(source) {
  3285. var props = keys(source);
  3286. return function(object) {
  3287. return baseConformsTo(object, source, props);
  3288. };
  3289. }
  3290. /**
  3291. * The base implementation of `_.conformsTo` which accepts `props` to check.
  3292. *
  3293. * @private
  3294. * @param {Object} object The object to inspect.
  3295. * @param {Object} source The object of property predicates to conform to.
  3296. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  3297. */
  3298. function baseConformsTo(object, source, props) {
  3299. var length = props.length;
  3300. if (object == null) {
  3301. return !length;
  3302. }
  3303. object = Object(object);
  3304. while (length--) {
  3305. var key = props[length],
  3306. predicate = source[key],
  3307. value = object[key];
  3308. if ((value === undefined && !(key in object)) || !predicate(value)) {
  3309. return false;
  3310. }
  3311. }
  3312. return true;
  3313. }
  3314. /**
  3315. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  3316. * to provide to `func`.
  3317. *
  3318. * @private
  3319. * @param {Function} func The function to delay.
  3320. * @param {number} wait The number of milliseconds to delay invocation.
  3321. * @param {Array} args The arguments to provide to `func`.
  3322. * @returns {number|Object} Returns the timer id or timeout object.
  3323. */
  3324. function baseDelay(func, wait, args) {
  3325. if (typeof func != 'function') {
  3326. throw new TypeError(FUNC_ERROR_TEXT);
  3327. }
  3328. return setTimeout(function() { func.apply(undefined, args); }, wait);
  3329. }
  3330. /**
  3331. * The base implementation of methods like `_.difference` without support
  3332. * for excluding multiple arrays or iteratee shorthands.
  3333. *
  3334. * @private
  3335. * @param {Array} array The array to inspect.
  3336. * @param {Array} values The values to exclude.
  3337. * @param {Function} [iteratee] The iteratee invoked per element.
  3338. * @param {Function} [comparator] The comparator invoked per element.
  3339. * @returns {Array} Returns the new array of filtered values.
  3340. */
  3341. function baseDifference(array, values, iteratee, comparator) {
  3342. var index = -1,
  3343. includes = arrayIncludes,
  3344. isCommon = true,
  3345. length = array.length,
  3346. result = [],
  3347. valuesLength = values.length;
  3348. if (!length) {
  3349. return result;
  3350. }
  3351. if (iteratee) {
  3352. values = arrayMap(values, baseUnary(iteratee));
  3353. }
  3354. if (comparator) {
  3355. includes = arrayIncludesWith;
  3356. isCommon = false;
  3357. }
  3358. else if (values.length >= LARGE_ARRAY_SIZE) {
  3359. includes = cacheHas;
  3360. isCommon = false;
  3361. values = new SetCache(values);
  3362. }
  3363. outer:
  3364. while (++index < length) {
  3365. var value = array[index],
  3366. computed = iteratee == null ? value : iteratee(value);
  3367. value = (comparator || value !== 0) ? value : 0;
  3368. if (isCommon && computed === computed) {
  3369. var valuesIndex = valuesLength;
  3370. while (valuesIndex--) {
  3371. if (values[valuesIndex] === computed) {
  3372. continue outer;
  3373. }
  3374. }
  3375. result.push(value);
  3376. }
  3377. else if (!includes(values, computed, comparator)) {
  3378. result.push(value);
  3379. }
  3380. }
  3381. return result;
  3382. }
  3383. /**
  3384. * The base implementation of `_.forEach` without support for iteratee shorthands.
  3385. *
  3386. * @private
  3387. * @param {Array|Object} collection The collection to iterate over.
  3388. * @param {Function} iteratee The function invoked per iteration.
  3389. * @returns {Array|Object} Returns `collection`.
  3390. */
  3391. var baseEach = createBaseEach(baseForOwn);
  3392. /**
  3393. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  3394. *
  3395. * @private
  3396. * @param {Array|Object} collection The collection to iterate over.
  3397. * @param {Function} iteratee The function invoked per iteration.
  3398. * @returns {Array|Object} Returns `collection`.
  3399. */
  3400. var baseEachRight = createBaseEach(baseForOwnRight, true);
  3401. /**
  3402. * The base implementation of `_.every` without support for iteratee shorthands.
  3403. *
  3404. * @private
  3405. * @param {Array|Object} collection The collection to iterate over.
  3406. * @param {Function} predicate The function invoked per iteration.
  3407. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  3408. * else `false`
  3409. */
  3410. function baseEvery(collection, predicate) {
  3411. var result = true;
  3412. baseEach(collection, function(value, index, collection) {
  3413. result = !!predicate(value, index, collection);
  3414. return result;
  3415. });
  3416. return result;
  3417. }
  3418. /**
  3419. * The base implementation of methods like `_.max` and `_.min` which accepts a
  3420. * `comparator` to determine the extremum value.
  3421. *
  3422. * @private
  3423. * @param {Array} array The array to iterate over.
  3424. * @param {Function} iteratee The iteratee invoked per iteration.
  3425. * @param {Function} comparator The comparator used to compare values.
  3426. * @returns {*} Returns the extremum value.
  3427. */
  3428. function baseExtremum(array, iteratee, comparator) {
  3429. var index = -1,
  3430. length = array.length;
  3431. while (++index < length) {
  3432. var value = array[index],
  3433. current = iteratee(value);
  3434. if (current != null && (computed === undefined
  3435. ? (current === current && !isSymbol(current))
  3436. : comparator(current, computed)
  3437. )) {
  3438. var computed = current,
  3439. result = value;
  3440. }
  3441. }
  3442. return result;
  3443. }
  3444. /**
  3445. * The base implementation of `_.fill` without an iteratee call guard.
  3446. *
  3447. * @private
  3448. * @param {Array} array The array to fill.
  3449. * @param {*} value The value to fill `array` with.
  3450. * @param {number} [start=0] The start position.
  3451. * @param {number} [end=array.length] The end position.
  3452. * @returns {Array} Returns `array`.
  3453. */
  3454. function baseFill(array, value, start, end) {
  3455. var length = array.length;
  3456. start = toInteger(start);
  3457. if (start < 0) {
  3458. start = -start > length ? 0 : (length + start);
  3459. }
  3460. end = (end === undefined || end > length) ? length : toInteger(end);
  3461. if (end < 0) {
  3462. end += length;
  3463. }
  3464. end = start > end ? 0 : toLength(end);
  3465. while (start < end) {
  3466. array[start++] = value;
  3467. }
  3468. return array;
  3469. }
  3470. /**
  3471. * The base implementation of `_.filter` without support for iteratee shorthands.
  3472. *
  3473. * @private
  3474. * @param {Array|Object} collection The collection to iterate over.
  3475. * @param {Function} predicate The function invoked per iteration.
  3476. * @returns {Array} Returns the new filtered array.
  3477. */
  3478. function baseFilter(collection, predicate) {
  3479. var result = [];
  3480. baseEach(collection, function(value, index, collection) {
  3481. if (predicate(value, index, collection)) {
  3482. result.push(value);
  3483. }
  3484. });
  3485. return result;
  3486. }
  3487. /**
  3488. * The base implementation of `_.flatten` with support for restricting flattening.
  3489. *
  3490. * @private
  3491. * @param {Array} array The array to flatten.
  3492. * @param {number} depth The maximum recursion depth.
  3493. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  3494. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  3495. * @param {Array} [result=[]] The initial result value.
  3496. * @returns {Array} Returns the new flattened array.
  3497. */
  3498. function baseFlatten(array, depth, predicate, isStrict, result) {
  3499. var index = -1,
  3500. length = array.length;
  3501. predicate || (predicate = isFlattenable);
  3502. result || (result = []);
  3503. while (++index < length) {
  3504. var value = array[index];
  3505. if (depth > 0 && predicate(value)) {
  3506. if (depth > 1) {
  3507. // Recursively flatten arrays (susceptible to call stack limits).
  3508. baseFlatten(value, depth - 1, predicate, isStrict, result);
  3509. } else {
  3510. arrayPush(result, value);
  3511. }
  3512. } else if (!isStrict) {
  3513. result[result.length] = value;
  3514. }
  3515. }
  3516. return result;
  3517. }
  3518. /**
  3519. * The base implementation of `baseForOwn` which iterates over `object`
  3520. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  3521. * Iteratee functions may exit iteration early by explicitly returning `false`.
  3522. *
  3523. * @private
  3524. * @param {Object} object The object to iterate over.
  3525. * @param {Function} iteratee The function invoked per iteration.
  3526. * @param {Function} keysFunc The function to get the keys of `object`.
  3527. * @returns {Object} Returns `object`.
  3528. */
  3529. var baseFor = createBaseFor();
  3530. /**
  3531. * This function is like `baseFor` except that it iterates over properties
  3532. * in the opposite order.
  3533. *
  3534. * @private
  3535. * @param {Object} object The object to iterate over.
  3536. * @param {Function} iteratee The function invoked per iteration.
  3537. * @param {Function} keysFunc The function to get the keys of `object`.
  3538. * @returns {Object} Returns `object`.
  3539. */
  3540. var baseForRight = createBaseFor(true);
  3541. /**
  3542. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  3543. *
  3544. * @private
  3545. * @param {Object} object The object to iterate over.
  3546. * @param {Function} iteratee The function invoked per iteration.
  3547. * @returns {Object} Returns `object`.
  3548. */
  3549. function baseForOwn(object, iteratee) {
  3550. return object && baseFor(object, iteratee, keys);
  3551. }
  3552. /**
  3553. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  3554. *
  3555. * @private
  3556. * @param {Object} object The object to iterate over.
  3557. * @param {Function} iteratee The function invoked per iteration.
  3558. * @returns {Object} Returns `object`.
  3559. */
  3560. function baseForOwnRight(object, iteratee) {
  3561. return object && baseForRight(object, iteratee, keys);
  3562. }
  3563. /**
  3564. * The base implementation of `_.functions` which creates an array of
  3565. * `object` function property names filtered from `props`.
  3566. *
  3567. * @private
  3568. * @param {Object} object The object to inspect.
  3569. * @param {Array} props The property names to filter.
  3570. * @returns {Array} Returns the function names.
  3571. */
  3572. function baseFunctions(object, props) {
  3573. return arrayFilter(props, function(key) {
  3574. return isFunction(object[key]);
  3575. });
  3576. }
  3577. /**
  3578. * The base implementation of `_.get` without support for default values.
  3579. *
  3580. * @private
  3581. * @param {Object} object The object to query.
  3582. * @param {Array|string} path The path of the property to get.
  3583. * @returns {*} Returns the resolved value.
  3584. */
  3585. function baseGet(object, path) {
  3586. path = castPath(path, object);
  3587. var index = 0,
  3588. length = path.length;
  3589. while (object != null && index < length) {
  3590. object = object[toKey(path[index++])];
  3591. }
  3592. return (index && index == length) ? object : undefined;
  3593. }
  3594. /**
  3595. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  3596. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  3597. * symbols of `object`.
  3598. *
  3599. * @private
  3600. * @param {Object} object The object to query.
  3601. * @param {Function} keysFunc The function to get the keys of `object`.
  3602. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  3603. * @returns {Array} Returns the array of property names and symbols.
  3604. */
  3605. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  3606. var result = keysFunc(object);
  3607. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  3608. }
  3609. /**
  3610. * The base implementation of `getTag` without fallbacks for buggy environments.
  3611. *
  3612. * @private
  3613. * @param {*} value The value to query.
  3614. * @returns {string} Returns the `toStringTag`.
  3615. */
  3616. function baseGetTag(value) {
  3617. if (value == null) {
  3618. return value === undefined ? undefinedTag : nullTag;
  3619. }
  3620. return (symToStringTag && symToStringTag in Object(value))
  3621. ? getRawTag(value)
  3622. : objectToString(value);
  3623. }
  3624. /**
  3625. * The base implementation of `_.gt` which doesn't coerce arguments.
  3626. *
  3627. * @private
  3628. * @param {*} value The value to compare.
  3629. * @param {*} other The other value to compare.
  3630. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  3631. * else `false`.
  3632. */
  3633. function baseGt(value, other) {
  3634. return value > other;
  3635. }
  3636. /**
  3637. * The base implementation of `_.has` without support for deep paths.
  3638. *
  3639. * @private
  3640. * @param {Object} [object] The object to query.
  3641. * @param {Array|string} key The key to check.
  3642. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3643. */
  3644. function baseHas(object, key) {
  3645. return object != null && hasOwnProperty.call(object, key);
  3646. }
  3647. /**
  3648. * The base implementation of `_.hasIn` without support for deep paths.
  3649. *
  3650. * @private
  3651. * @param {Object} [object] The object to query.
  3652. * @param {Array|string} key The key to check.
  3653. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3654. */
  3655. function baseHasIn(object, key) {
  3656. return object != null && key in Object(object);
  3657. }
  3658. /**
  3659. * The base implementation of `_.inRange` which doesn't coerce arguments.
  3660. *
  3661. * @private
  3662. * @param {number} number The number to check.
  3663. * @param {number} start The start of the range.
  3664. * @param {number} end The end of the range.
  3665. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  3666. */
  3667. function baseInRange(number, start, end) {
  3668. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  3669. }
  3670. /**
  3671. * The base implementation of methods like `_.intersection`, without support
  3672. * for iteratee shorthands, that accepts an array of arrays to inspect.
  3673. *
  3674. * @private
  3675. * @param {Array} arrays The arrays to inspect.
  3676. * @param {Function} [iteratee] The iteratee invoked per element.
  3677. * @param {Function} [comparator] The comparator invoked per element.
  3678. * @returns {Array} Returns the new array of shared values.
  3679. */
  3680. function baseIntersection(arrays, iteratee, comparator) {
  3681. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  3682. length = arrays[0].length,
  3683. othLength = arrays.length,
  3684. othIndex = othLength,
  3685. caches = Array(othLength),
  3686. maxLength = Infinity,
  3687. result = [];
  3688. while (othIndex--) {
  3689. var array = arrays[othIndex];
  3690. if (othIndex && iteratee) {
  3691. array = arrayMap(array, baseUnary(iteratee));
  3692. }
  3693. maxLength = nativeMin(array.length, maxLength);
  3694. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  3695. ? new SetCache(othIndex && array)
  3696. : undefined;
  3697. }
  3698. array = arrays[0];
  3699. var index = -1,
  3700. seen = caches[0];
  3701. outer:
  3702. while (++index < length && result.length < maxLength) {
  3703. var value = array[index],
  3704. computed = iteratee ? iteratee(value) : value;
  3705. value = (comparator || value !== 0) ? value : 0;
  3706. if (!(seen
  3707. ? cacheHas(seen, computed)
  3708. : includes(result, computed, comparator)
  3709. )) {
  3710. othIndex = othLength;
  3711. while (--othIndex) {
  3712. var cache = caches[othIndex];
  3713. if (!(cache
  3714. ? cacheHas(cache, computed)
  3715. : includes(arrays[othIndex], computed, comparator))
  3716. ) {
  3717. continue outer;
  3718. }
  3719. }
  3720. if (seen) {
  3721. seen.push(computed);
  3722. }
  3723. result.push(value);
  3724. }
  3725. }
  3726. return result;
  3727. }
  3728. /**
  3729. * The base implementation of `_.invert` and `_.invertBy` which inverts
  3730. * `object` with values transformed by `iteratee` and set by `setter`.
  3731. *
  3732. * @private
  3733. * @param {Object} object The object to iterate over.
  3734. * @param {Function} setter The function to set `accumulator` values.
  3735. * @param {Function} iteratee The iteratee to transform values.
  3736. * @param {Object} accumulator The initial inverted object.
  3737. * @returns {Function} Returns `accumulator`.
  3738. */
  3739. function baseInverter(object, setter, iteratee, accumulator) {
  3740. baseForOwn(object, function(value, key, object) {
  3741. setter(accumulator, iteratee(value), key, object);
  3742. });
  3743. return accumulator;
  3744. }
  3745. /**
  3746. * The base implementation of `_.invoke` without support for individual
  3747. * method arguments.
  3748. *
  3749. * @private
  3750. * @param {Object} object The object to query.
  3751. * @param {Array|string} path The path of the method to invoke.
  3752. * @param {Array} args The arguments to invoke the method with.
  3753. * @returns {*} Returns the result of the invoked method.
  3754. */
  3755. function baseInvoke(object, path, args) {
  3756. path = castPath(path, object);
  3757. object = parent(object, path);
  3758. var func = object == null ? object : object[toKey(last(path))];
  3759. return func == null ? undefined : apply(func, object, args);
  3760. }
  3761. /**
  3762. * The base implementation of `_.isArguments`.
  3763. *
  3764. * @private
  3765. * @param {*} value The value to check.
  3766. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  3767. */
  3768. function baseIsArguments(value) {
  3769. return isObjectLike(value) && baseGetTag(value) == argsTag;
  3770. }
  3771. /**
  3772. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  3773. *
  3774. * @private
  3775. * @param {*} value The value to check.
  3776. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  3777. */
  3778. function baseIsArrayBuffer(value) {
  3779. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  3780. }
  3781. /**
  3782. * The base implementation of `_.isDate` without Node.js optimizations.
  3783. *
  3784. * @private
  3785. * @param {*} value The value to check.
  3786. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  3787. */
  3788. function baseIsDate(value) {
  3789. return isObjectLike(value) && baseGetTag(value) == dateTag;
  3790. }
  3791. /**
  3792. * The base implementation of `_.isEqual` which supports partial comparisons
  3793. * and tracks traversed objects.
  3794. *
  3795. * @private
  3796. * @param {*} value The value to compare.
  3797. * @param {*} other The other value to compare.
  3798. * @param {boolean} bitmask The bitmask flags.
  3799. * 1 - Unordered comparison
  3800. * 2 - Partial comparison
  3801. * @param {Function} [customizer] The function to customize comparisons.
  3802. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  3803. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3804. */
  3805. function baseIsEqual(value, other, bitmask, customizer, stack) {
  3806. if (value === other) {
  3807. return true;
  3808. }
  3809. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  3810. return value !== value && other !== other;
  3811. }
  3812. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  3813. }
  3814. /**
  3815. * A specialized version of `baseIsEqual` for arrays and objects which performs
  3816. * deep comparisons and tracks traversed objects enabling objects with circular
  3817. * references to be compared.
  3818. *
  3819. * @private
  3820. * @param {Object} object The object to compare.
  3821. * @param {Object} other The other object to compare.
  3822. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  3823. * @param {Function} customizer The function to customize comparisons.
  3824. * @param {Function} equalFunc The function to determine equivalents of values.
  3825. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  3826. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3827. */
  3828. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  3829. var objIsArr = isArray(object),
  3830. othIsArr = isArray(other),
  3831. objTag = objIsArr ? arrayTag : getTag(object),
  3832. othTag = othIsArr ? arrayTag : getTag(other);
  3833. objTag = objTag == argsTag ? objectTag : objTag;
  3834. othTag = othTag == argsTag ? objectTag : othTag;
  3835. var objIsObj = objTag == objectTag,
  3836. othIsObj = othTag == objectTag,
  3837. isSameTag = objTag == othTag;
  3838. if (isSameTag && isBuffer(object)) {
  3839. if (!isBuffer(other)) {
  3840. return false;
  3841. }
  3842. objIsArr = true;
  3843. objIsObj = false;
  3844. }
  3845. if (isSameTag && !objIsObj) {
  3846. stack || (stack = new Stack);
  3847. return (objIsArr || isTypedArray(object))
  3848. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  3849. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  3850. }
  3851. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  3852. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  3853. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  3854. if (objIsWrapped || othIsWrapped) {
  3855. var objUnwrapped = objIsWrapped ? object.value() : object,
  3856. othUnwrapped = othIsWrapped ? other.value() : other;
  3857. stack || (stack = new Stack);
  3858. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  3859. }
  3860. }
  3861. if (!isSameTag) {
  3862. return false;
  3863. }
  3864. stack || (stack = new Stack);
  3865. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  3866. }
  3867. /**
  3868. * The base implementation of `_.isMap` without Node.js optimizations.
  3869. *
  3870. * @private
  3871. * @param {*} value The value to check.
  3872. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  3873. */
  3874. function baseIsMap(value) {
  3875. return isObjectLike(value) && getTag(value) == mapTag;
  3876. }
  3877. /**
  3878. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  3879. *
  3880. * @private
  3881. * @param {Object} object The object to inspect.
  3882. * @param {Object} source The object of property values to match.
  3883. * @param {Array} matchData The property names, values, and compare flags to match.
  3884. * @param {Function} [customizer] The function to customize comparisons.
  3885. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  3886. */
  3887. function baseIsMatch(object, source, matchData, customizer) {
  3888. var index = matchData.length,
  3889. length = index,
  3890. noCustomizer = !customizer;
  3891. if (object == null) {
  3892. return !length;
  3893. }
  3894. object = Object(object);
  3895. while (index--) {
  3896. var data = matchData[index];
  3897. if ((noCustomizer && data[2])
  3898. ? data[1] !== object[data[0]]
  3899. : !(data[0] in object)
  3900. ) {
  3901. return false;
  3902. }
  3903. }
  3904. while (++index < length) {
  3905. data = matchData[index];
  3906. var key = data[0],
  3907. objValue = object[key],
  3908. srcValue = data[1];
  3909. if (noCustomizer && data[2]) {
  3910. if (objValue === undefined && !(key in object)) {
  3911. return false;
  3912. }
  3913. } else {
  3914. var stack = new Stack;
  3915. if (customizer) {
  3916. var result = customizer(objValue, srcValue, key, object, source, stack);
  3917. }
  3918. if (!(result === undefined
  3919. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  3920. : result
  3921. )) {
  3922. return false;
  3923. }
  3924. }
  3925. }
  3926. return true;
  3927. }
  3928. /**
  3929. * The base implementation of `_.isNative` without bad shim checks.
  3930. *
  3931. * @private
  3932. * @param {*} value The value to check.
  3933. * @returns {boolean} Returns `true` if `value` is a native function,
  3934. * else `false`.
  3935. */
  3936. function baseIsNative(value) {
  3937. if (!isObject(value) || isMasked(value)) {
  3938. return false;
  3939. }
  3940. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  3941. return pattern.test(toSource(value));
  3942. }
  3943. /**
  3944. * The base implementation of `_.isRegExp` without Node.js optimizations.
  3945. *
  3946. * @private
  3947. * @param {*} value The value to check.
  3948. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  3949. */
  3950. function baseIsRegExp(value) {
  3951. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  3952. }
  3953. /**
  3954. * The base implementation of `_.isSet` without Node.js optimizations.
  3955. *
  3956. * @private
  3957. * @param {*} value The value to check.
  3958. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  3959. */
  3960. function baseIsSet(value) {
  3961. return isObjectLike(value) && getTag(value) == setTag;
  3962. }
  3963. /**
  3964. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  3965. *
  3966. * @private
  3967. * @param {*} value The value to check.
  3968. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3969. */
  3970. function baseIsTypedArray(value) {
  3971. return isObjectLike(value) &&
  3972. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  3973. }
  3974. /**
  3975. * The base implementation of `_.iteratee`.
  3976. *
  3977. * @private
  3978. * @param {*} [value=_.identity] The value to convert to an iteratee.
  3979. * @returns {Function} Returns the iteratee.
  3980. */
  3981. function baseIteratee(value) {
  3982. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  3983. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  3984. if (typeof value == 'function') {
  3985. return value;
  3986. }
  3987. if (value == null) {
  3988. return identity;
  3989. }
  3990. if (typeof value == 'object') {
  3991. return isArray(value)
  3992. ? baseMatchesProperty(value[0], value[1])
  3993. : baseMatches(value);
  3994. }
  3995. return property(value);
  3996. }
  3997. /**
  3998. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  3999. *
  4000. * @private
  4001. * @param {Object} object The object to query.
  4002. * @returns {Array} Returns the array of property names.
  4003. */
  4004. function baseKeys(object) {
  4005. if (!isPrototype(object)) {
  4006. return nativeKeys(object);
  4007. }
  4008. var result = [];
  4009. for (var key in Object(object)) {
  4010. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  4011. result.push(key);
  4012. }
  4013. }
  4014. return result;
  4015. }
  4016. /**
  4017. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  4018. *
  4019. * @private
  4020. * @param {Object} object The object to query.
  4021. * @returns {Array} Returns the array of property names.
  4022. */
  4023. function baseKeysIn(object) {
  4024. if (!isObject(object)) {
  4025. return nativeKeysIn(object);
  4026. }
  4027. var isProto = isPrototype(object),
  4028. result = [];
  4029. for (var key in object) {
  4030. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  4031. result.push(key);
  4032. }
  4033. }
  4034. return result;
  4035. }
  4036. /**
  4037. * The base implementation of `_.lt` which doesn't coerce arguments.
  4038. *
  4039. * @private
  4040. * @param {*} value The value to compare.
  4041. * @param {*} other The other value to compare.
  4042. * @returns {boolean} Returns `true` if `value` is less than `other`,
  4043. * else `false`.
  4044. */
  4045. function baseLt(value, other) {
  4046. return value < other;
  4047. }
  4048. /**
  4049. * The base implementation of `_.map` without support for iteratee shorthands.
  4050. *
  4051. * @private
  4052. * @param {Array|Object} collection The collection to iterate over.
  4053. * @param {Function} iteratee The function invoked per iteration.
  4054. * @returns {Array} Returns the new mapped array.
  4055. */
  4056. function baseMap(collection, iteratee) {
  4057. var index = -1,
  4058. result = isArrayLike(collection) ? Array(collection.length) : [];
  4059. baseEach(collection, function(value, key, collection) {
  4060. result[++index] = iteratee(value, key, collection);
  4061. });
  4062. return result;
  4063. }
  4064. /**
  4065. * The base implementation of `_.matches` which doesn't clone `source`.
  4066. *
  4067. * @private
  4068. * @param {Object} source The object of property values to match.
  4069. * @returns {Function} Returns the new spec function.
  4070. */
  4071. function baseMatches(source) {
  4072. var matchData = getMatchData(source);
  4073. if (matchData.length == 1 && matchData[0][2]) {
  4074. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  4075. }
  4076. return function(object) {
  4077. return object === source || baseIsMatch(object, source, matchData);
  4078. };
  4079. }
  4080. /**
  4081. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  4082. *
  4083. * @private
  4084. * @param {string} path The path of the property to get.
  4085. * @param {*} srcValue The value to match.
  4086. * @returns {Function} Returns the new spec function.
  4087. */
  4088. function baseMatchesProperty(path, srcValue) {
  4089. if (isKey(path) && isStrictComparable(srcValue)) {
  4090. return matchesStrictComparable(toKey(path), srcValue);
  4091. }
  4092. return function(object) {
  4093. var objValue = get(object, path);
  4094. return (objValue === undefined && objValue === srcValue)
  4095. ? hasIn(object, path)
  4096. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  4097. };
  4098. }
  4099. /**
  4100. * The base implementation of `_.merge` without support for multiple sources.
  4101. *
  4102. * @private
  4103. * @param {Object} object The destination object.
  4104. * @param {Object} source The source object.
  4105. * @param {number} srcIndex The index of `source`.
  4106. * @param {Function} [customizer] The function to customize merged values.
  4107. * @param {Object} [stack] Tracks traversed source values and their merged
  4108. * counterparts.
  4109. */
  4110. function baseMerge(object, source, srcIndex, customizer, stack) {
  4111. if (object === source) {
  4112. return;
  4113. }
  4114. baseFor(source, function(srcValue, key) {
  4115. if (isObject(srcValue)) {
  4116. stack || (stack = new Stack);
  4117. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  4118. }
  4119. else {
  4120. var newValue = customizer
  4121. ? customizer(object[key], srcValue, (key + ''), object, source, stack)
  4122. : undefined;
  4123. if (newValue === undefined) {
  4124. newValue = srcValue;
  4125. }
  4126. assignMergeValue(object, key, newValue);
  4127. }
  4128. }, keysIn);
  4129. }
  4130. /**
  4131. * A specialized version of `baseMerge` for arrays and objects which performs
  4132. * deep merges and tracks traversed objects enabling objects with circular
  4133. * references to be merged.
  4134. *
  4135. * @private
  4136. * @param {Object} object The destination object.
  4137. * @param {Object} source The source object.
  4138. * @param {string} key The key of the value to merge.
  4139. * @param {number} srcIndex The index of `source`.
  4140. * @param {Function} mergeFunc The function to merge values.
  4141. * @param {Function} [customizer] The function to customize assigned values.
  4142. * @param {Object} [stack] Tracks traversed source values and their merged
  4143. * counterparts.
  4144. */
  4145. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  4146. var objValue = object[key],
  4147. srcValue = source[key],
  4148. stacked = stack.get(srcValue);
  4149. if (stacked) {
  4150. assignMergeValue(object, key, stacked);
  4151. return;
  4152. }
  4153. var newValue = customizer
  4154. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  4155. : undefined;
  4156. var isCommon = newValue === undefined;
  4157. if (isCommon) {
  4158. var isArr = isArray(srcValue),
  4159. isBuff = !isArr && isBuffer(srcValue),
  4160. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  4161. newValue = srcValue;
  4162. if (isArr || isBuff || isTyped) {
  4163. if (isArray(objValue)) {
  4164. newValue = objValue;
  4165. }
  4166. else if (isArrayLikeObject(objValue)) {
  4167. newValue = copyArray(objValue);
  4168. }
  4169. else if (isBuff) {
  4170. isCommon = false;
  4171. newValue = cloneBuffer(srcValue, true);
  4172. }
  4173. else if (isTyped) {
  4174. isCommon = false;
  4175. newValue = cloneTypedArray(srcValue, true);
  4176. }
  4177. else {
  4178. newValue = [];
  4179. }
  4180. }
  4181. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  4182. newValue = objValue;
  4183. if (isArguments(objValue)) {
  4184. newValue = toPlainObject(objValue);
  4185. }
  4186. else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
  4187. newValue = initCloneObject(srcValue);
  4188. }
  4189. }
  4190. else {
  4191. isCommon = false;
  4192. }
  4193. }
  4194. if (isCommon) {
  4195. // Recursively merge objects and arrays (susceptible to call stack limits).
  4196. stack.set(srcValue, newValue);
  4197. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  4198. stack['delete'](srcValue);
  4199. }
  4200. assignMergeValue(object, key, newValue);
  4201. }
  4202. /**
  4203. * The base implementation of `_.nth` which doesn't coerce arguments.
  4204. *
  4205. * @private
  4206. * @param {Array} array The array to query.
  4207. * @param {number} n The index of the element to return.
  4208. * @returns {*} Returns the nth element of `array`.
  4209. */
  4210. function baseNth(array, n) {
  4211. var length = array.length;
  4212. if (!length) {
  4213. return;
  4214. }
  4215. n += n < 0 ? length : 0;
  4216. return isIndex(n, length) ? array[n] : undefined;
  4217. }
  4218. /**
  4219. * The base implementation of `_.orderBy` without param guards.
  4220. *
  4221. * @private
  4222. * @param {Array|Object} collection The collection to iterate over.
  4223. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  4224. * @param {string[]} orders The sort orders of `iteratees`.
  4225. * @returns {Array} Returns the new sorted array.
  4226. */
  4227. function baseOrderBy(collection, iteratees, orders) {
  4228. var index = -1;
  4229. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  4230. var result = baseMap(collection, function(value, key, collection) {
  4231. var criteria = arrayMap(iteratees, function(iteratee) {
  4232. return iteratee(value);
  4233. });
  4234. return { 'criteria': criteria, 'index': ++index, 'value': value };
  4235. });
  4236. return baseSortBy(result, function(object, other) {
  4237. return compareMultiple(object, other, orders);
  4238. });
  4239. }
  4240. /**
  4241. * The base implementation of `_.pick` without support for individual
  4242. * property identifiers.
  4243. *
  4244. * @private
  4245. * @param {Object} object The source object.
  4246. * @param {string[]} paths The property paths to pick.
  4247. * @returns {Object} Returns the new object.
  4248. */
  4249. function basePick(object, paths) {
  4250. return basePickBy(object, paths, function(value, path) {
  4251. return hasIn(object, path);
  4252. });
  4253. }
  4254. /**
  4255. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  4256. *
  4257. * @private
  4258. * @param {Object} object The source object.
  4259. * @param {string[]} paths The property paths to pick.
  4260. * @param {Function} predicate The function invoked per property.
  4261. * @returns {Object} Returns the new object.
  4262. */
  4263. function basePickBy(object, paths, predicate) {
  4264. var index = -1,
  4265. length = paths.length,
  4266. result = {};
  4267. while (++index < length) {
  4268. var path = paths[index],
  4269. value = baseGet(object, path);
  4270. if (predicate(value, path)) {
  4271. baseSet(result, castPath(path, object), value);
  4272. }
  4273. }
  4274. return result;
  4275. }
  4276. /**
  4277. * A specialized version of `baseProperty` which supports deep paths.
  4278. *
  4279. * @private
  4280. * @param {Array|string} path The path of the property to get.
  4281. * @returns {Function} Returns the new accessor function.
  4282. */
  4283. function basePropertyDeep(path) {
  4284. return function(object) {
  4285. return baseGet(object, path);
  4286. };
  4287. }
  4288. /**
  4289. * The base implementation of `_.pullAllBy` without support for iteratee
  4290. * shorthands.
  4291. *
  4292. * @private
  4293. * @param {Array} array The array to modify.
  4294. * @param {Array} values The values to remove.
  4295. * @param {Function} [iteratee] The iteratee invoked per element.
  4296. * @param {Function} [comparator] The comparator invoked per element.
  4297. * @returns {Array} Returns `array`.
  4298. */
  4299. function basePullAll(array, values, iteratee, comparator) {
  4300. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  4301. index = -1,
  4302. length = values.length,
  4303. seen = array;
  4304. if (array === values) {
  4305. values = copyArray(values);
  4306. }
  4307. if (iteratee) {
  4308. seen = arrayMap(array, baseUnary(iteratee));
  4309. }
  4310. while (++index < length) {
  4311. var fromIndex = 0,
  4312. value = values[index],
  4313. computed = iteratee ? iteratee(value) : value;
  4314. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  4315. if (seen !== array) {
  4316. splice.call(seen, fromIndex, 1);
  4317. }
  4318. splice.call(array, fromIndex, 1);
  4319. }
  4320. }
  4321. return array;
  4322. }
  4323. /**
  4324. * The base implementation of `_.pullAt` without support for individual
  4325. * indexes or capturing the removed elements.
  4326. *
  4327. * @private
  4328. * @param {Array} array The array to modify.
  4329. * @param {number[]} indexes The indexes of elements to remove.
  4330. * @returns {Array} Returns `array`.
  4331. */
  4332. function basePullAt(array, indexes) {
  4333. var length = array ? indexes.length : 0,
  4334. lastIndex = length - 1;
  4335. while (length--) {
  4336. var index = indexes[length];
  4337. if (length == lastIndex || index !== previous) {
  4338. var previous = index;
  4339. if (isIndex(index)) {
  4340. splice.call(array, index, 1);
  4341. } else {
  4342. baseUnset(array, index);
  4343. }
  4344. }
  4345. }
  4346. return array;
  4347. }
  4348. /**
  4349. * The base implementation of `_.random` without support for returning
  4350. * floating-point numbers.
  4351. *
  4352. * @private
  4353. * @param {number} lower The lower bound.
  4354. * @param {number} upper The upper bound.
  4355. * @returns {number} Returns the random number.
  4356. */
  4357. function baseRandom(lower, upper) {
  4358. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  4359. }
  4360. /**
  4361. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  4362. * coerce arguments.
  4363. *
  4364. * @private
  4365. * @param {number} start The start of the range.
  4366. * @param {number} end The end of the range.
  4367. * @param {number} step The value to increment or decrement by.
  4368. * @param {boolean} [fromRight] Specify iterating from right to left.
  4369. * @returns {Array} Returns the range of numbers.
  4370. */
  4371. function baseRange(start, end, step, fromRight) {
  4372. var index = -1,
  4373. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  4374. result = Array(length);
  4375. while (length--) {
  4376. result[fromRight ? length : ++index] = start;
  4377. start += step;
  4378. }
  4379. return result;
  4380. }
  4381. /**
  4382. * The base implementation of `_.repeat` which doesn't coerce arguments.
  4383. *
  4384. * @private
  4385. * @param {string} string The string to repeat.
  4386. * @param {number} n The number of times to repeat the string.
  4387. * @returns {string} Returns the repeated string.
  4388. */
  4389. function baseRepeat(string, n) {
  4390. var result = '';
  4391. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  4392. return result;
  4393. }
  4394. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  4395. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  4396. do {
  4397. if (n % 2) {
  4398. result += string;
  4399. }
  4400. n = nativeFloor(n / 2);
  4401. if (n) {
  4402. string += string;
  4403. }
  4404. } while (n);
  4405. return result;
  4406. }
  4407. /**
  4408. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  4409. *
  4410. * @private
  4411. * @param {Function} func The function to apply a rest parameter to.
  4412. * @param {number} [start=func.length-1] The start position of the rest parameter.
  4413. * @returns {Function} Returns the new function.
  4414. */
  4415. function baseRest(func, start) {
  4416. return setToString(overRest(func, start, identity), func + '');
  4417. }
  4418. /**
  4419. * The base implementation of `_.sample`.
  4420. *
  4421. * @private
  4422. * @param {Array|Object} collection The collection to sample.
  4423. * @returns {*} Returns the random element.
  4424. */
  4425. function baseSample(collection) {
  4426. return arraySample(values(collection));
  4427. }
  4428. /**
  4429. * The base implementation of `_.sampleSize` without param guards.
  4430. *
  4431. * @private
  4432. * @param {Array|Object} collection The collection to sample.
  4433. * @param {number} n The number of elements to sample.
  4434. * @returns {Array} Returns the random elements.
  4435. */
  4436. function baseSampleSize(collection, n) {
  4437. var array = values(collection);
  4438. return shuffleSelf(array, baseClamp(n, 0, array.length));
  4439. }
  4440. /**
  4441. * The base implementation of `_.set`.
  4442. *
  4443. * @private
  4444. * @param {Object} object The object to modify.
  4445. * @param {Array|string} path The path of the property to set.
  4446. * @param {*} value The value to set.
  4447. * @param {Function} [customizer] The function to customize path creation.
  4448. * @returns {Object} Returns `object`.
  4449. */
  4450. function baseSet(object, path, value, customizer) {
  4451. if (!isObject(object)) {
  4452. return object;
  4453. }
  4454. path = castPath(path, object);
  4455. var index = -1,
  4456. length = path.length,
  4457. lastIndex = length - 1,
  4458. nested = object;
  4459. while (nested != null && ++index < length) {
  4460. var key = toKey(path[index]),
  4461. newValue = value;
  4462. if (index != lastIndex) {
  4463. var objValue = nested[key];
  4464. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  4465. if (newValue === undefined) {
  4466. newValue = isObject(objValue)
  4467. ? objValue
  4468. : (isIndex(path[index + 1]) ? [] : {});
  4469. }
  4470. }
  4471. assignValue(nested, key, newValue);
  4472. nested = nested[key];
  4473. }
  4474. return object;
  4475. }
  4476. /**
  4477. * The base implementation of `setData` without support for hot loop shorting.
  4478. *
  4479. * @private
  4480. * @param {Function} func The function to associate metadata with.
  4481. * @param {*} data The metadata.
  4482. * @returns {Function} Returns `func`.
  4483. */
  4484. var baseSetData = !metaMap ? identity : function(func, data) {
  4485. metaMap.set(func, data);
  4486. return func;
  4487. };
  4488. /**
  4489. * The base implementation of `setToString` without support for hot loop shorting.
  4490. *
  4491. * @private
  4492. * @param {Function} func The function to modify.
  4493. * @param {Function} string The `toString` result.
  4494. * @returns {Function} Returns `func`.
  4495. */
  4496. var baseSetToString = !defineProperty ? identity : function(func, string) {
  4497. return defineProperty(func, 'toString', {
  4498. 'configurable': true,
  4499. 'enumerable': false,
  4500. 'value': constant(string),
  4501. 'writable': true
  4502. });
  4503. };
  4504. /**
  4505. * The base implementation of `_.shuffle`.
  4506. *
  4507. * @private
  4508. * @param {Array|Object} collection The collection to shuffle.
  4509. * @returns {Array} Returns the new shuffled array.
  4510. */
  4511. function baseShuffle(collection) {
  4512. return shuffleSelf(values(collection));
  4513. }
  4514. /**
  4515. * The base implementation of `_.slice` without an iteratee call guard.
  4516. *
  4517. * @private
  4518. * @param {Array} array The array to slice.
  4519. * @param {number} [start=0] The start position.
  4520. * @param {number} [end=array.length] The end position.
  4521. * @returns {Array} Returns the slice of `array`.
  4522. */
  4523. function baseSlice(array, start, end) {
  4524. var index = -1,
  4525. length = array.length;
  4526. if (start < 0) {
  4527. start = -start > length ? 0 : (length + start);
  4528. }
  4529. end = end > length ? length : end;
  4530. if (end < 0) {
  4531. end += length;
  4532. }
  4533. length = start > end ? 0 : ((end - start) >>> 0);
  4534. start >>>= 0;
  4535. var result = Array(length);
  4536. while (++index < length) {
  4537. result[index] = array[index + start];
  4538. }
  4539. return result;
  4540. }
  4541. /**
  4542. * The base implementation of `_.some` without support for iteratee shorthands.
  4543. *
  4544. * @private
  4545. * @param {Array|Object} collection The collection to iterate over.
  4546. * @param {Function} predicate The function invoked per iteration.
  4547. * @returns {boolean} Returns `true` if any element passes the predicate check,
  4548. * else `false`.
  4549. */
  4550. function baseSome(collection, predicate) {
  4551. var result;
  4552. baseEach(collection, function(value, index, collection) {
  4553. result = predicate(value, index, collection);
  4554. return !result;
  4555. });
  4556. return !!result;
  4557. }
  4558. /**
  4559. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  4560. * performs a binary search of `array` to determine the index at which `value`
  4561. * should be inserted into `array` in order to maintain its sort order.
  4562. *
  4563. * @private
  4564. * @param {Array} array The sorted array to inspect.
  4565. * @param {*} value The value to evaluate.
  4566. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  4567. * @returns {number} Returns the index at which `value` should be inserted
  4568. * into `array`.
  4569. */
  4570. function baseSortedIndex(array, value, retHighest) {
  4571. var low = 0,
  4572. high = array == null ? low : array.length;
  4573. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  4574. while (low < high) {
  4575. var mid = (low + high) >>> 1,
  4576. computed = array[mid];
  4577. if (computed !== null && !isSymbol(computed) &&
  4578. (retHighest ? (computed <= value) : (computed < value))) {
  4579. low = mid + 1;
  4580. } else {
  4581. high = mid;
  4582. }
  4583. }
  4584. return high;
  4585. }
  4586. return baseSortedIndexBy(array, value, identity, retHighest);
  4587. }
  4588. /**
  4589. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  4590. * which invokes `iteratee` for `value` and each element of `array` to compute
  4591. * their sort ranking. The iteratee is invoked with one argument; (value).
  4592. *
  4593. * @private
  4594. * @param {Array} array The sorted array to inspect.
  4595. * @param {*} value The value to evaluate.
  4596. * @param {Function} iteratee The iteratee invoked per element.
  4597. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  4598. * @returns {number} Returns the index at which `value` should be inserted
  4599. * into `array`.
  4600. */
  4601. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  4602. value = iteratee(value);
  4603. var low = 0,
  4604. high = array == null ? 0 : array.length,
  4605. valIsNaN = value !== value,
  4606. valIsNull = value === null,
  4607. valIsSymbol = isSymbol(value),
  4608. valIsUndefined = value === undefined;
  4609. while (low < high) {
  4610. var mid = nativeFloor((low + high) / 2),
  4611. computed = iteratee(array[mid]),
  4612. othIsDefined = computed !== undefined,
  4613. othIsNull = computed === null,
  4614. othIsReflexive = computed === computed,
  4615. othIsSymbol = isSymbol(computed);
  4616. if (valIsNaN) {
  4617. var setLow = retHighest || othIsReflexive;
  4618. } else if (valIsUndefined) {
  4619. setLow = othIsReflexive && (retHighest || othIsDefined);
  4620. } else if (valIsNull) {
  4621. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  4622. } else if (valIsSymbol) {
  4623. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  4624. } else if (othIsNull || othIsSymbol) {
  4625. setLow = false;
  4626. } else {
  4627. setLow = retHighest ? (computed <= value) : (computed < value);
  4628. }
  4629. if (setLow) {
  4630. low = mid + 1;
  4631. } else {
  4632. high = mid;
  4633. }
  4634. }
  4635. return nativeMin(high, MAX_ARRAY_INDEX);
  4636. }
  4637. /**
  4638. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  4639. * support for iteratee shorthands.
  4640. *
  4641. * @private
  4642. * @param {Array} array The array to inspect.
  4643. * @param {Function} [iteratee] The iteratee invoked per element.
  4644. * @returns {Array} Returns the new duplicate free array.
  4645. */
  4646. function baseSortedUniq(array, iteratee) {
  4647. var index = -1,
  4648. length = array.length,
  4649. resIndex = 0,
  4650. result = [];
  4651. while (++index < length) {
  4652. var value = array[index],
  4653. computed = iteratee ? iteratee(value) : value;
  4654. if (!index || !eq(computed, seen)) {
  4655. var seen = computed;
  4656. result[resIndex++] = value === 0 ? 0 : value;
  4657. }
  4658. }
  4659. return result;
  4660. }
  4661. /**
  4662. * The base implementation of `_.toNumber` which doesn't ensure correct
  4663. * conversions of binary, hexadecimal, or octal string values.
  4664. *
  4665. * @private
  4666. * @param {*} value The value to process.
  4667. * @returns {number} Returns the number.
  4668. */
  4669. function baseToNumber(value) {
  4670. if (typeof value == 'number') {
  4671. return value;
  4672. }
  4673. if (isSymbol(value)) {
  4674. return NAN;
  4675. }
  4676. return +value;
  4677. }
  4678. /**
  4679. * The base implementation of `_.toString` which doesn't convert nullish
  4680. * values to empty strings.
  4681. *
  4682. * @private
  4683. * @param {*} value The value to process.
  4684. * @returns {string} Returns the string.
  4685. */
  4686. function baseToString(value) {
  4687. // Exit early for strings to avoid a performance hit in some environments.
  4688. if (typeof value == 'string') {
  4689. return value;
  4690. }
  4691. if (isArray(value)) {
  4692. // Recursively convert values (susceptible to call stack limits).
  4693. return arrayMap(value, baseToString) + '';
  4694. }
  4695. if (isSymbol(value)) {
  4696. return symbolToString ? symbolToString.call(value) : '';
  4697. }
  4698. var result = (value + '');
  4699. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  4700. }
  4701. /**
  4702. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  4703. *
  4704. * @private
  4705. * @param {Array} array The array to inspect.
  4706. * @param {Function} [iteratee] The iteratee invoked per element.
  4707. * @param {Function} [comparator] The comparator invoked per element.
  4708. * @returns {Array} Returns the new duplicate free array.
  4709. */
  4710. function baseUniq(array, iteratee, comparator) {
  4711. var index = -1,
  4712. includes = arrayIncludes,
  4713. length = array.length,
  4714. isCommon = true,
  4715. result = [],
  4716. seen = result;
  4717. if (comparator) {
  4718. isCommon = false;
  4719. includes = arrayIncludesWith;
  4720. }
  4721. else if (length >= LARGE_ARRAY_SIZE) {
  4722. var set = iteratee ? null : createSet(array);
  4723. if (set) {
  4724. return setToArray(set);
  4725. }
  4726. isCommon = false;
  4727. includes = cacheHas;
  4728. seen = new SetCache;
  4729. }
  4730. else {
  4731. seen = iteratee ? [] : result;
  4732. }
  4733. outer:
  4734. while (++index < length) {
  4735. var value = array[index],
  4736. computed = iteratee ? iteratee(value) : value;
  4737. value = (comparator || value !== 0) ? value : 0;
  4738. if (isCommon && computed === computed) {
  4739. var seenIndex = seen.length;
  4740. while (seenIndex--) {
  4741. if (seen[seenIndex] === computed) {
  4742. continue outer;
  4743. }
  4744. }
  4745. if (iteratee) {
  4746. seen.push(computed);
  4747. }
  4748. result.push(value);
  4749. }
  4750. else if (!includes(seen, computed, comparator)) {
  4751. if (seen !== result) {
  4752. seen.push(computed);
  4753. }
  4754. result.push(value);
  4755. }
  4756. }
  4757. return result;
  4758. }
  4759. /**
  4760. * The base implementation of `_.unset`.
  4761. *
  4762. * @private
  4763. * @param {Object} object The object to modify.
  4764. * @param {Array|string} path The property path to unset.
  4765. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  4766. */
  4767. function baseUnset(object, path) {
  4768. path = castPath(path, object);
  4769. object = parent(object, path);
  4770. return object == null || delete object[toKey(last(path))];
  4771. }
  4772. /**
  4773. * The base implementation of `_.update`.
  4774. *
  4775. * @private
  4776. * @param {Object} object The object to modify.
  4777. * @param {Array|string} path The path of the property to update.
  4778. * @param {Function} updater The function to produce the updated value.
  4779. * @param {Function} [customizer] The function to customize path creation.
  4780. * @returns {Object} Returns `object`.
  4781. */
  4782. function baseUpdate(object, path, updater, customizer) {
  4783. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  4784. }
  4785. /**
  4786. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  4787. * without support for iteratee shorthands.
  4788. *
  4789. * @private
  4790. * @param {Array} array The array to query.
  4791. * @param {Function} predicate The function invoked per iteration.
  4792. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  4793. * @param {boolean} [fromRight] Specify iterating from right to left.
  4794. * @returns {Array} Returns the slice of `array`.
  4795. */
  4796. function baseWhile(array, predicate, isDrop, fromRight) {
  4797. var length = array.length,
  4798. index = fromRight ? length : -1;
  4799. while ((fromRight ? index-- : ++index < length) &&
  4800. predicate(array[index], index, array)) {}
  4801. return isDrop
  4802. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  4803. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  4804. }
  4805. /**
  4806. * The base implementation of `wrapperValue` which returns the result of
  4807. * performing a sequence of actions on the unwrapped `value`, where each
  4808. * successive action is supplied the return value of the previous.
  4809. *
  4810. * @private
  4811. * @param {*} value The unwrapped value.
  4812. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  4813. * @returns {*} Returns the resolved value.
  4814. */
  4815. function baseWrapperValue(value, actions) {
  4816. var result = value;
  4817. if (result instanceof LazyWrapper) {
  4818. result = result.value();
  4819. }
  4820. return arrayReduce(actions, function(result, action) {
  4821. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  4822. }, result);
  4823. }
  4824. /**
  4825. * The base implementation of methods like `_.xor`, without support for
  4826. * iteratee shorthands, that accepts an array of arrays to inspect.
  4827. *
  4828. * @private
  4829. * @param {Array} arrays The arrays to inspect.
  4830. * @param {Function} [iteratee] The iteratee invoked per element.
  4831. * @param {Function} [comparator] The comparator invoked per element.
  4832. * @returns {Array} Returns the new array of values.
  4833. */
  4834. function baseXor(arrays, iteratee, comparator) {
  4835. var length = arrays.length;
  4836. if (length < 2) {
  4837. return length ? baseUniq(arrays[0]) : [];
  4838. }
  4839. var index = -1,
  4840. result = Array(length);
  4841. while (++index < length) {
  4842. var array = arrays[index],
  4843. othIndex = -1;
  4844. while (++othIndex < length) {
  4845. if (othIndex != index) {
  4846. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  4847. }
  4848. }
  4849. }
  4850. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  4851. }
  4852. /**
  4853. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  4854. *
  4855. * @private
  4856. * @param {Array} props The property identifiers.
  4857. * @param {Array} values The property values.
  4858. * @param {Function} assignFunc The function to assign values.
  4859. * @returns {Object} Returns the new object.
  4860. */
  4861. function baseZipObject(props, values, assignFunc) {
  4862. var index = -1,
  4863. length = props.length,
  4864. valsLength = values.length,
  4865. result = {};
  4866. while (++index < length) {
  4867. var value = index < valsLength ? values[index] : undefined;
  4868. assignFunc(result, props[index], value);
  4869. }
  4870. return result;
  4871. }
  4872. /**
  4873. * Casts `value` to an empty array if it's not an array like object.
  4874. *
  4875. * @private
  4876. * @param {*} value The value to inspect.
  4877. * @returns {Array|Object} Returns the cast array-like object.
  4878. */
  4879. function castArrayLikeObject(value) {
  4880. return isArrayLikeObject(value) ? value : [];
  4881. }
  4882. /**
  4883. * Casts `value` to `identity` if it's not a function.
  4884. *
  4885. * @private
  4886. * @param {*} value The value to inspect.
  4887. * @returns {Function} Returns cast function.
  4888. */
  4889. function castFunction(value) {
  4890. return typeof value == 'function' ? value : identity;
  4891. }
  4892. /**
  4893. * Casts `value` to a path array if it's not one.
  4894. *
  4895. * @private
  4896. * @param {*} value The value to inspect.
  4897. * @param {Object} [object] The object to query keys on.
  4898. * @returns {Array} Returns the cast property path array.
  4899. */
  4900. function castPath(value, object) {
  4901. if (isArray(value)) {
  4902. return value;
  4903. }
  4904. return isKey(value, object) ? [value] : stringToPath(toString(value));
  4905. }
  4906. /**
  4907. * A `baseRest` alias which can be replaced with `identity` by module
  4908. * replacement plugins.
  4909. *
  4910. * @private
  4911. * @type {Function}
  4912. * @param {Function} func The function to apply a rest parameter to.
  4913. * @returns {Function} Returns the new function.
  4914. */
  4915. var castRest = baseRest;
  4916. /**
  4917. * Casts `array` to a slice if it's needed.
  4918. *
  4919. * @private
  4920. * @param {Array} array The array to inspect.
  4921. * @param {number} start The start position.
  4922. * @param {number} [end=array.length] The end position.
  4923. * @returns {Array} Returns the cast slice.
  4924. */
  4925. function castSlice(array, start, end) {
  4926. var length = array.length;
  4927. end = end === undefined ? length : end;
  4928. return (!start && end >= length) ? array : baseSlice(array, start, end);
  4929. }
  4930. /**
  4931. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  4932. *
  4933. * @private
  4934. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  4935. */
  4936. var clearTimeout = ctxClearTimeout || function(id) {
  4937. return root.clearTimeout(id);
  4938. };
  4939. /**
  4940. * Creates a clone of `buffer`.
  4941. *
  4942. * @private
  4943. * @param {Buffer} buffer The buffer to clone.
  4944. * @param {boolean} [isDeep] Specify a deep clone.
  4945. * @returns {Buffer} Returns the cloned buffer.
  4946. */
  4947. function cloneBuffer(buffer, isDeep) {
  4948. if (isDeep) {
  4949. return buffer.slice();
  4950. }
  4951. var length = buffer.length,
  4952. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  4953. buffer.copy(result);
  4954. return result;
  4955. }
  4956. /**
  4957. * Creates a clone of `arrayBuffer`.
  4958. *
  4959. * @private
  4960. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  4961. * @returns {ArrayBuffer} Returns the cloned array buffer.
  4962. */
  4963. function cloneArrayBuffer(arrayBuffer) {
  4964. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  4965. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  4966. return result;
  4967. }
  4968. /**
  4969. * Creates a clone of `dataView`.
  4970. *
  4971. * @private
  4972. * @param {Object} dataView The data view to clone.
  4973. * @param {boolean} [isDeep] Specify a deep clone.
  4974. * @returns {Object} Returns the cloned data view.
  4975. */
  4976. function cloneDataView(dataView, isDeep) {
  4977. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  4978. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  4979. }
  4980. /**
  4981. * Creates a clone of `map`.
  4982. *
  4983. * @private
  4984. * @param {Object} map The map to clone.
  4985. * @param {Function} cloneFunc The function to clone values.
  4986. * @param {boolean} [isDeep] Specify a deep clone.
  4987. * @returns {Object} Returns the cloned map.
  4988. */
  4989. function cloneMap(map, isDeep, cloneFunc) {
  4990. var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
  4991. return arrayReduce(array, addMapEntry, new map.constructor);
  4992. }
  4993. /**
  4994. * Creates a clone of `regexp`.
  4995. *
  4996. * @private
  4997. * @param {Object} regexp The regexp to clone.
  4998. * @returns {Object} Returns the cloned regexp.
  4999. */
  5000. function cloneRegExp(regexp) {
  5001. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  5002. result.lastIndex = regexp.lastIndex;
  5003. return result;
  5004. }
  5005. /**
  5006. * Creates a clone of `set`.
  5007. *
  5008. * @private
  5009. * @param {Object} set The set to clone.
  5010. * @param {Function} cloneFunc The function to clone values.
  5011. * @param {boolean} [isDeep] Specify a deep clone.
  5012. * @returns {Object} Returns the cloned set.
  5013. */
  5014. function cloneSet(set, isDeep, cloneFunc) {
  5015. var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
  5016. return arrayReduce(array, addSetEntry, new set.constructor);
  5017. }
  5018. /**
  5019. * Creates a clone of the `symbol` object.
  5020. *
  5021. * @private
  5022. * @param {Object} symbol The symbol object to clone.
  5023. * @returns {Object} Returns the cloned symbol object.
  5024. */
  5025. function cloneSymbol(symbol) {
  5026. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  5027. }
  5028. /**
  5029. * Creates a clone of `typedArray`.
  5030. *
  5031. * @private
  5032. * @param {Object} typedArray The typed array to clone.
  5033. * @param {boolean} [isDeep] Specify a deep clone.
  5034. * @returns {Object} Returns the cloned typed array.
  5035. */
  5036. function cloneTypedArray(typedArray, isDeep) {
  5037. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  5038. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  5039. }
  5040. /**
  5041. * Compares values to sort them in ascending order.
  5042. *
  5043. * @private
  5044. * @param {*} value The value to compare.
  5045. * @param {*} other The other value to compare.
  5046. * @returns {number} Returns the sort order indicator for `value`.
  5047. */
  5048. function compareAscending(value, other) {
  5049. if (value !== other) {
  5050. var valIsDefined = value !== undefined,
  5051. valIsNull = value === null,
  5052. valIsReflexive = value === value,
  5053. valIsSymbol = isSymbol(value);
  5054. var othIsDefined = other !== undefined,
  5055. othIsNull = other === null,
  5056. othIsReflexive = other === other,
  5057. othIsSymbol = isSymbol(other);
  5058. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  5059. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  5060. (valIsNull && othIsDefined && othIsReflexive) ||
  5061. (!valIsDefined && othIsReflexive) ||
  5062. !valIsReflexive) {
  5063. return 1;
  5064. }
  5065. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  5066. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  5067. (othIsNull && valIsDefined && valIsReflexive) ||
  5068. (!othIsDefined && valIsReflexive) ||
  5069. !othIsReflexive) {
  5070. return -1;
  5071. }
  5072. }
  5073. return 0;
  5074. }
  5075. /**
  5076. * Used by `_.orderBy` to compare multiple properties of a value to another
  5077. * and stable sort them.
  5078. *
  5079. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  5080. * specify an order of "desc" for descending or "asc" for ascending sort order
  5081. * of corresponding values.
  5082. *
  5083. * @private
  5084. * @param {Object} object The object to compare.
  5085. * @param {Object} other The other object to compare.
  5086. * @param {boolean[]|string[]} orders The order to sort by for each property.
  5087. * @returns {number} Returns the sort order indicator for `object`.
  5088. */
  5089. function compareMultiple(object, other, orders) {
  5090. var index = -1,
  5091. objCriteria = object.criteria,
  5092. othCriteria = other.criteria,
  5093. length = objCriteria.length,
  5094. ordersLength = orders.length;
  5095. while (++index < length) {
  5096. var result = compareAscending(objCriteria[index], othCriteria[index]);
  5097. if (result) {
  5098. if (index >= ordersLength) {
  5099. return result;
  5100. }
  5101. var order = orders[index];
  5102. return result * (order == 'desc' ? -1 : 1);
  5103. }
  5104. }
  5105. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  5106. // that causes it, under certain circumstances, to provide the same value for
  5107. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  5108. // for more details.
  5109. //
  5110. // This also ensures a stable sort in V8 and other engines.
  5111. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  5112. return object.index - other.index;
  5113. }
  5114. /**
  5115. * Creates an array that is the composition of partially applied arguments,
  5116. * placeholders, and provided arguments into a single array of arguments.
  5117. *
  5118. * @private
  5119. * @param {Array} args The provided arguments.
  5120. * @param {Array} partials The arguments to prepend to those provided.
  5121. * @param {Array} holders The `partials` placeholder indexes.
  5122. * @params {boolean} [isCurried] Specify composing for a curried function.
  5123. * @returns {Array} Returns the new array of composed arguments.
  5124. */
  5125. function composeArgs(args, partials, holders, isCurried) {
  5126. var argsIndex = -1,
  5127. argsLength = args.length,
  5128. holdersLength = holders.length,
  5129. leftIndex = -1,
  5130. leftLength = partials.length,
  5131. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5132. result = Array(leftLength + rangeLength),
  5133. isUncurried = !isCurried;
  5134. while (++leftIndex < leftLength) {
  5135. result[leftIndex] = partials[leftIndex];
  5136. }
  5137. while (++argsIndex < holdersLength) {
  5138. if (isUncurried || argsIndex < argsLength) {
  5139. result[holders[argsIndex]] = args[argsIndex];
  5140. }
  5141. }
  5142. while (rangeLength--) {
  5143. result[leftIndex++] = args[argsIndex++];
  5144. }
  5145. return result;
  5146. }
  5147. /**
  5148. * This function is like `composeArgs` except that the arguments composition
  5149. * is tailored for `_.partialRight`.
  5150. *
  5151. * @private
  5152. * @param {Array} args The provided arguments.
  5153. * @param {Array} partials The arguments to append to those provided.
  5154. * @param {Array} holders The `partials` placeholder indexes.
  5155. * @params {boolean} [isCurried] Specify composing for a curried function.
  5156. * @returns {Array} Returns the new array of composed arguments.
  5157. */
  5158. function composeArgsRight(args, partials, holders, isCurried) {
  5159. var argsIndex = -1,
  5160. argsLength = args.length,
  5161. holdersIndex = -1,
  5162. holdersLength = holders.length,
  5163. rightIndex = -1,
  5164. rightLength = partials.length,
  5165. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5166. result = Array(rangeLength + rightLength),
  5167. isUncurried = !isCurried;
  5168. while (++argsIndex < rangeLength) {
  5169. result[argsIndex] = args[argsIndex];
  5170. }
  5171. var offset = argsIndex;
  5172. while (++rightIndex < rightLength) {
  5173. result[offset + rightIndex] = partials[rightIndex];
  5174. }
  5175. while (++holdersIndex < holdersLength) {
  5176. if (isUncurried || argsIndex < argsLength) {
  5177. result[offset + holders[holdersIndex]] = args[argsIndex++];
  5178. }
  5179. }
  5180. return result;
  5181. }
  5182. /**
  5183. * Copies the values of `source` to `array`.
  5184. *
  5185. * @private
  5186. * @param {Array} source The array to copy values from.
  5187. * @param {Array} [array=[]] The array to copy values to.
  5188. * @returns {Array} Returns `array`.
  5189. */
  5190. function copyArray(source, array) {
  5191. var index = -1,
  5192. length = source.length;
  5193. array || (array = Array(length));
  5194. while (++index < length) {
  5195. array[index] = source[index];
  5196. }
  5197. return array;
  5198. }
  5199. /**
  5200. * Copies properties of `source` to `object`.
  5201. *
  5202. * @private
  5203. * @param {Object} source The object to copy properties from.
  5204. * @param {Array} props The property identifiers to copy.
  5205. * @param {Object} [object={}] The object to copy properties to.
  5206. * @param {Function} [customizer] The function to customize copied values.
  5207. * @returns {Object} Returns `object`.
  5208. */
  5209. function copyObject(source, props, object, customizer) {
  5210. var isNew = !object;
  5211. object || (object = {});
  5212. var index = -1,
  5213. length = props.length;
  5214. while (++index < length) {
  5215. var key = props[index];
  5216. var newValue = customizer
  5217. ? customizer(object[key], source[key], key, object, source)
  5218. : undefined;
  5219. if (newValue === undefined) {
  5220. newValue = source[key];
  5221. }
  5222. if (isNew) {
  5223. baseAssignValue(object, key, newValue);
  5224. } else {
  5225. assignValue(object, key, newValue);
  5226. }
  5227. }
  5228. return object;
  5229. }
  5230. /**
  5231. * Copies own symbols of `source` to `object`.
  5232. *
  5233. * @private
  5234. * @param {Object} source The object to copy symbols from.
  5235. * @param {Object} [object={}] The object to copy symbols to.
  5236. * @returns {Object} Returns `object`.
  5237. */
  5238. function copySymbols(source, object) {
  5239. return copyObject(source, getSymbols(source), object);
  5240. }
  5241. /**
  5242. * Copies own and inherited symbols of `source` to `object`.
  5243. *
  5244. * @private
  5245. * @param {Object} source The object to copy symbols from.
  5246. * @param {Object} [object={}] The object to copy symbols to.
  5247. * @returns {Object} Returns `object`.
  5248. */
  5249. function copySymbolsIn(source, object) {
  5250. return copyObject(source, getSymbolsIn(source), object);
  5251. }
  5252. /**
  5253. * Creates a function like `_.groupBy`.
  5254. *
  5255. * @private
  5256. * @param {Function} setter The function to set accumulator values.
  5257. * @param {Function} [initializer] The accumulator object initializer.
  5258. * @returns {Function} Returns the new aggregator function.
  5259. */
  5260. function createAggregator(setter, initializer) {
  5261. return function(collection, iteratee) {
  5262. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  5263. accumulator = initializer ? initializer() : {};
  5264. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  5265. };
  5266. }
  5267. /**
  5268. * Creates a function like `_.assign`.
  5269. *
  5270. * @private
  5271. * @param {Function} assigner The function to assign values.
  5272. * @returns {Function} Returns the new assigner function.
  5273. */
  5274. function createAssigner(assigner) {
  5275. return baseRest(function(object, sources) {
  5276. var index = -1,
  5277. length = sources.length,
  5278. customizer = length > 1 ? sources[length - 1] : undefined,
  5279. guard = length > 2 ? sources[2] : undefined;
  5280. customizer = (assigner.length > 3 && typeof customizer == 'function')
  5281. ? (length--, customizer)
  5282. : undefined;
  5283. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  5284. customizer = length < 3 ? undefined : customizer;
  5285. length = 1;
  5286. }
  5287. object = Object(object);
  5288. while (++index < length) {
  5289. var source = sources[index];
  5290. if (source) {
  5291. assigner(object, source, index, customizer);
  5292. }
  5293. }
  5294. return object;
  5295. });
  5296. }
  5297. /**
  5298. * Creates a `baseEach` or `baseEachRight` function.
  5299. *
  5300. * @private
  5301. * @param {Function} eachFunc The function to iterate over a collection.
  5302. * @param {boolean} [fromRight] Specify iterating from right to left.
  5303. * @returns {Function} Returns the new base function.
  5304. */
  5305. function createBaseEach(eachFunc, fromRight) {
  5306. return function(collection, iteratee) {
  5307. if (collection == null) {
  5308. return collection;
  5309. }
  5310. if (!isArrayLike(collection)) {
  5311. return eachFunc(collection, iteratee);
  5312. }
  5313. var length = collection.length,
  5314. index = fromRight ? length : -1,
  5315. iterable = Object(collection);
  5316. while ((fromRight ? index-- : ++index < length)) {
  5317. if (iteratee(iterable[index], index, iterable) === false) {
  5318. break;
  5319. }
  5320. }
  5321. return collection;
  5322. };
  5323. }
  5324. /**
  5325. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  5326. *
  5327. * @private
  5328. * @param {boolean} [fromRight] Specify iterating from right to left.
  5329. * @returns {Function} Returns the new base function.
  5330. */
  5331. function createBaseFor(fromRight) {
  5332. return function(object, iteratee, keysFunc) {
  5333. var index = -1,
  5334. iterable = Object(object),
  5335. props = keysFunc(object),
  5336. length = props.length;
  5337. while (length--) {
  5338. var key = props[fromRight ? length : ++index];
  5339. if (iteratee(iterable[key], key, iterable) === false) {
  5340. break;
  5341. }
  5342. }
  5343. return object;
  5344. };
  5345. }
  5346. /**
  5347. * Creates a function that wraps `func` to invoke it with the optional `this`
  5348. * binding of `thisArg`.
  5349. *
  5350. * @private
  5351. * @param {Function} func The function to wrap.
  5352. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5353. * @param {*} [thisArg] The `this` binding of `func`.
  5354. * @returns {Function} Returns the new wrapped function.
  5355. */
  5356. function createBind(func, bitmask, thisArg) {
  5357. var isBind = bitmask & WRAP_BIND_FLAG,
  5358. Ctor = createCtor(func);
  5359. function wrapper() {
  5360. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5361. return fn.apply(isBind ? thisArg : this, arguments);
  5362. }
  5363. return wrapper;
  5364. }
  5365. /**
  5366. * Creates a function like `_.lowerFirst`.
  5367. *
  5368. * @private
  5369. * @param {string} methodName The name of the `String` case method to use.
  5370. * @returns {Function} Returns the new case function.
  5371. */
  5372. function createCaseFirst(methodName) {
  5373. return function(string) {
  5374. string = toString(string);
  5375. var strSymbols = hasUnicode(string)
  5376. ? stringToArray(string)
  5377. : undefined;
  5378. var chr = strSymbols
  5379. ? strSymbols[0]
  5380. : string.charAt(0);
  5381. var trailing = strSymbols
  5382. ? castSlice(strSymbols, 1).join('')
  5383. : string.slice(1);
  5384. return chr[methodName]() + trailing;
  5385. };
  5386. }
  5387. /**
  5388. * Creates a function like `_.camelCase`.
  5389. *
  5390. * @private
  5391. * @param {Function} callback The function to combine each word.
  5392. * @returns {Function} Returns the new compounder function.
  5393. */
  5394. function createCompounder(callback) {
  5395. return function(string) {
  5396. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  5397. };
  5398. }
  5399. /**
  5400. * Creates a function that produces an instance of `Ctor` regardless of
  5401. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  5402. *
  5403. * @private
  5404. * @param {Function} Ctor The constructor to wrap.
  5405. * @returns {Function} Returns the new wrapped function.
  5406. */
  5407. function createCtor(Ctor) {
  5408. return function() {
  5409. // Use a `switch` statement to work with class constructors. See
  5410. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  5411. // for more details.
  5412. var args = arguments;
  5413. switch (args.length) {
  5414. case 0: return new Ctor;
  5415. case 1: return new Ctor(args[0]);
  5416. case 2: return new Ctor(args[0], args[1]);
  5417. case 3: return new Ctor(args[0], args[1], args[2]);
  5418. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  5419. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  5420. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  5421. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  5422. }
  5423. var thisBinding = baseCreate(Ctor.prototype),
  5424. result = Ctor.apply(thisBinding, args);
  5425. // Mimic the constructor's `return` behavior.
  5426. // See https://es5.github.io/#x13.2.2 for more details.
  5427. return isObject(result) ? result : thisBinding;
  5428. };
  5429. }
  5430. /**
  5431. * Creates a function that wraps `func` to enable currying.
  5432. *
  5433. * @private
  5434. * @param {Function} func The function to wrap.
  5435. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5436. * @param {number} arity The arity of `func`.
  5437. * @returns {Function} Returns the new wrapped function.
  5438. */
  5439. function createCurry(func, bitmask, arity) {
  5440. var Ctor = createCtor(func);
  5441. function wrapper() {
  5442. var length = arguments.length,
  5443. args = Array(length),
  5444. index = length,
  5445. placeholder = getHolder(wrapper);
  5446. while (index--) {
  5447. args[index] = arguments[index];
  5448. }
  5449. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  5450. ? []
  5451. : replaceHolders(args, placeholder);
  5452. length -= holders.length;
  5453. if (length < arity) {
  5454. return createRecurry(
  5455. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  5456. args, holders, undefined, undefined, arity - length);
  5457. }
  5458. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5459. return apply(fn, this, args);
  5460. }
  5461. return wrapper;
  5462. }
  5463. /**
  5464. * Creates a `_.find` or `_.findLast` function.
  5465. *
  5466. * @private
  5467. * @param {Function} findIndexFunc The function to find the collection index.
  5468. * @returns {Function} Returns the new find function.
  5469. */
  5470. function createFind(findIndexFunc) {
  5471. return function(collection, predicate, fromIndex) {
  5472. var iterable = Object(collection);
  5473. if (!isArrayLike(collection)) {
  5474. var iteratee = getIteratee(predicate, 3);
  5475. collection = keys(collection);
  5476. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  5477. }
  5478. var index = findIndexFunc(collection, predicate, fromIndex);
  5479. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  5480. };
  5481. }
  5482. /**
  5483. * Creates a `_.flow` or `_.flowRight` function.
  5484. *
  5485. * @private
  5486. * @param {boolean} [fromRight] Specify iterating from right to left.
  5487. * @returns {Function} Returns the new flow function.
  5488. */
  5489. function createFlow(fromRight) {
  5490. return flatRest(function(funcs) {
  5491. var length = funcs.length,
  5492. index = length,
  5493. prereq = LodashWrapper.prototype.thru;
  5494. if (fromRight) {
  5495. funcs.reverse();
  5496. }
  5497. while (index--) {
  5498. var func = funcs[index];
  5499. if (typeof func != 'function') {
  5500. throw new TypeError(FUNC_ERROR_TEXT);
  5501. }
  5502. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  5503. var wrapper = new LodashWrapper([], true);
  5504. }
  5505. }
  5506. index = wrapper ? index : length;
  5507. while (++index < length) {
  5508. func = funcs[index];
  5509. var funcName = getFuncName(func),
  5510. data = funcName == 'wrapper' ? getData(func) : undefined;
  5511. if (data && isLaziable(data[0]) &&
  5512. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  5513. !data[4].length && data[9] == 1
  5514. ) {
  5515. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  5516. } else {
  5517. wrapper = (func.length == 1 && isLaziable(func))
  5518. ? wrapper[funcName]()
  5519. : wrapper.thru(func);
  5520. }
  5521. }
  5522. return function() {
  5523. var args = arguments,
  5524. value = args[0];
  5525. if (wrapper && args.length == 1 && isArray(value)) {
  5526. return wrapper.plant(value).value();
  5527. }
  5528. var index = 0,
  5529. result = length ? funcs[index].apply(this, args) : value;
  5530. while (++index < length) {
  5531. result = funcs[index].call(this, result);
  5532. }
  5533. return result;
  5534. };
  5535. });
  5536. }
  5537. /**
  5538. * Creates a function that wraps `func` to invoke it with optional `this`
  5539. * binding of `thisArg`, partial application, and currying.
  5540. *
  5541. * @private
  5542. * @param {Function|string} func The function or method name to wrap.
  5543. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5544. * @param {*} [thisArg] The `this` binding of `func`.
  5545. * @param {Array} [partials] The arguments to prepend to those provided to
  5546. * the new function.
  5547. * @param {Array} [holders] The `partials` placeholder indexes.
  5548. * @param {Array} [partialsRight] The arguments to append to those provided
  5549. * to the new function.
  5550. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  5551. * @param {Array} [argPos] The argument positions of the new function.
  5552. * @param {number} [ary] The arity cap of `func`.
  5553. * @param {number} [arity] The arity of `func`.
  5554. * @returns {Function} Returns the new wrapped function.
  5555. */
  5556. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  5557. var isAry = bitmask & WRAP_ARY_FLAG,
  5558. isBind = bitmask & WRAP_BIND_FLAG,
  5559. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  5560. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  5561. isFlip = bitmask & WRAP_FLIP_FLAG,
  5562. Ctor = isBindKey ? undefined : createCtor(func);
  5563. function wrapper() {
  5564. var length = arguments.length,
  5565. args = Array(length),
  5566. index = length;
  5567. while (index--) {
  5568. args[index] = arguments[index];
  5569. }
  5570. if (isCurried) {
  5571. var placeholder = getHolder(wrapper),
  5572. holdersCount = countHolders(args, placeholder);
  5573. }
  5574. if (partials) {
  5575. args = composeArgs(args, partials, holders, isCurried);
  5576. }
  5577. if (partialsRight) {
  5578. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  5579. }
  5580. length -= holdersCount;
  5581. if (isCurried && length < arity) {
  5582. var newHolders = replaceHolders(args, placeholder);
  5583. return createRecurry(
  5584. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  5585. args, newHolders, argPos, ary, arity - length
  5586. );
  5587. }
  5588. var thisBinding = isBind ? thisArg : this,
  5589. fn = isBindKey ? thisBinding[func] : func;
  5590. length = args.length;
  5591. if (argPos) {
  5592. args = reorder(args, argPos);
  5593. } else if (isFlip && length > 1) {
  5594. args.reverse();
  5595. }
  5596. if (isAry && ary < length) {
  5597. args.length = ary;
  5598. }
  5599. if (this && this !== root && this instanceof wrapper) {
  5600. fn = Ctor || createCtor(fn);
  5601. }
  5602. return fn.apply(thisBinding, args);
  5603. }
  5604. return wrapper;
  5605. }
  5606. /**
  5607. * Creates a function like `_.invertBy`.
  5608. *
  5609. * @private
  5610. * @param {Function} setter The function to set accumulator values.
  5611. * @param {Function} toIteratee The function to resolve iteratees.
  5612. * @returns {Function} Returns the new inverter function.
  5613. */
  5614. function createInverter(setter, toIteratee) {
  5615. return function(object, iteratee) {
  5616. return baseInverter(object, setter, toIteratee(iteratee), {});
  5617. };
  5618. }
  5619. /**
  5620. * Creates a function that performs a mathematical operation on two values.
  5621. *
  5622. * @private
  5623. * @param {Function} operator The function to perform the operation.
  5624. * @param {number} [defaultValue] The value used for `undefined` arguments.
  5625. * @returns {Function} Returns the new mathematical operation function.
  5626. */
  5627. function createMathOperation(operator, defaultValue) {
  5628. return function(value, other) {
  5629. var result;
  5630. if (value === undefined && other === undefined) {
  5631. return defaultValue;
  5632. }
  5633. if (value !== undefined) {
  5634. result = value;
  5635. }
  5636. if (other !== undefined) {
  5637. if (result === undefined) {
  5638. return other;
  5639. }
  5640. if (typeof value == 'string' || typeof other == 'string') {
  5641. value = baseToString(value);
  5642. other = baseToString(other);
  5643. } else {
  5644. value = baseToNumber(value);
  5645. other = baseToNumber(other);
  5646. }
  5647. result = operator(value, other);
  5648. }
  5649. return result;
  5650. };
  5651. }
  5652. /**
  5653. * Creates a function like `_.over`.
  5654. *
  5655. * @private
  5656. * @param {Function} arrayFunc The function to iterate over iteratees.
  5657. * @returns {Function} Returns the new over function.
  5658. */
  5659. function createOver(arrayFunc) {
  5660. return flatRest(function(iteratees) {
  5661. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  5662. return baseRest(function(args) {
  5663. var thisArg = this;
  5664. return arrayFunc(iteratees, function(iteratee) {
  5665. return apply(iteratee, thisArg, args);
  5666. });
  5667. });
  5668. });
  5669. }
  5670. /**
  5671. * Creates the padding for `string` based on `length`. The `chars` string
  5672. * is truncated if the number of characters exceeds `length`.
  5673. *
  5674. * @private
  5675. * @param {number} length The padding length.
  5676. * @param {string} [chars=' '] The string used as padding.
  5677. * @returns {string} Returns the padding for `string`.
  5678. */
  5679. function createPadding(length, chars) {
  5680. chars = chars === undefined ? ' ' : baseToString(chars);
  5681. var charsLength = chars.length;
  5682. if (charsLength < 2) {
  5683. return charsLength ? baseRepeat(chars, length) : chars;
  5684. }
  5685. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  5686. return hasUnicode(chars)
  5687. ? castSlice(stringToArray(result), 0, length).join('')
  5688. : result.slice(0, length);
  5689. }
  5690. /**
  5691. * Creates a function that wraps `func` to invoke it with the `this` binding
  5692. * of `thisArg` and `partials` prepended to the arguments it receives.
  5693. *
  5694. * @private
  5695. * @param {Function} func The function to wrap.
  5696. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5697. * @param {*} thisArg The `this` binding of `func`.
  5698. * @param {Array} partials The arguments to prepend to those provided to
  5699. * the new function.
  5700. * @returns {Function} Returns the new wrapped function.
  5701. */
  5702. function createPartial(func, bitmask, thisArg, partials) {
  5703. var isBind = bitmask & WRAP_BIND_FLAG,
  5704. Ctor = createCtor(func);
  5705. function wrapper() {
  5706. var argsIndex = -1,
  5707. argsLength = arguments.length,
  5708. leftIndex = -1,
  5709. leftLength = partials.length,
  5710. args = Array(leftLength + argsLength),
  5711. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5712. while (++leftIndex < leftLength) {
  5713. args[leftIndex] = partials[leftIndex];
  5714. }
  5715. while (argsLength--) {
  5716. args[leftIndex++] = arguments[++argsIndex];
  5717. }
  5718. return apply(fn, isBind ? thisArg : this, args);
  5719. }
  5720. return wrapper;
  5721. }
  5722. /**
  5723. * Creates a `_.range` or `_.rangeRight` function.
  5724. *
  5725. * @private
  5726. * @param {boolean} [fromRight] Specify iterating from right to left.
  5727. * @returns {Function} Returns the new range function.
  5728. */
  5729. function createRange(fromRight) {
  5730. return function(start, end, step) {
  5731. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  5732. end = step = undefined;
  5733. }
  5734. // Ensure the sign of `-0` is preserved.
  5735. start = toFinite(start);
  5736. if (end === undefined) {
  5737. end = start;
  5738. start = 0;
  5739. } else {
  5740. end = toFinite(end);
  5741. }
  5742. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  5743. return baseRange(start, end, step, fromRight);
  5744. };
  5745. }
  5746. /**
  5747. * Creates a function that performs a relational operation on two values.
  5748. *
  5749. * @private
  5750. * @param {Function} operator The function to perform the operation.
  5751. * @returns {Function} Returns the new relational operation function.
  5752. */
  5753. function createRelationalOperation(operator) {
  5754. return function(value, other) {
  5755. if (!(typeof value == 'string' && typeof other == 'string')) {
  5756. value = toNumber(value);
  5757. other = toNumber(other);
  5758. }
  5759. return operator(value, other);
  5760. };
  5761. }
  5762. /**
  5763. * Creates a function that wraps `func` to continue currying.
  5764. *
  5765. * @private
  5766. * @param {Function} func The function to wrap.
  5767. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5768. * @param {Function} wrapFunc The function to create the `func` wrapper.
  5769. * @param {*} placeholder The placeholder value.
  5770. * @param {*} [thisArg] The `this` binding of `func`.
  5771. * @param {Array} [partials] The arguments to prepend to those provided to
  5772. * the new function.
  5773. * @param {Array} [holders] The `partials` placeholder indexes.
  5774. * @param {Array} [argPos] The argument positions of the new function.
  5775. * @param {number} [ary] The arity cap of `func`.
  5776. * @param {number} [arity] The arity of `func`.
  5777. * @returns {Function} Returns the new wrapped function.
  5778. */
  5779. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  5780. var isCurry = bitmask & WRAP_CURRY_FLAG,
  5781. newHolders = isCurry ? holders : undefined,
  5782. newHoldersRight = isCurry ? undefined : holders,
  5783. newPartials = isCurry ? partials : undefined,
  5784. newPartialsRight = isCurry ? undefined : partials;
  5785. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  5786. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  5787. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  5788. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  5789. }
  5790. var newData = [
  5791. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  5792. newHoldersRight, argPos, ary, arity
  5793. ];
  5794. var result = wrapFunc.apply(undefined, newData);
  5795. if (isLaziable(func)) {
  5796. setData(result, newData);
  5797. }
  5798. result.placeholder = placeholder;
  5799. return setWrapToString(result, func, bitmask);
  5800. }
  5801. /**
  5802. * Creates a function like `_.round`.
  5803. *
  5804. * @private
  5805. * @param {string} methodName The name of the `Math` method to use when rounding.
  5806. * @returns {Function} Returns the new round function.
  5807. */
  5808. function createRound(methodName) {
  5809. var func = Math[methodName];
  5810. return function(number, precision) {
  5811. number = toNumber(number);
  5812. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  5813. if (precision) {
  5814. // Shift with exponential notation to avoid floating-point issues.
  5815. // See [MDN](https://mdn.io/round#Examples) for more details.
  5816. var pair = (toString(number) + 'e').split('e'),
  5817. value = func(pair[0] + 'e' + (+pair[1] + precision));
  5818. pair = (toString(value) + 'e').split('e');
  5819. return +(pair[0] + 'e' + (+pair[1] - precision));
  5820. }
  5821. return func(number);
  5822. };
  5823. }
  5824. /**
  5825. * Creates a set object of `values`.
  5826. *
  5827. * @private
  5828. * @param {Array} values The values to add to the set.
  5829. * @returns {Object} Returns the new set.
  5830. */
  5831. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  5832. return new Set(values);
  5833. };
  5834. /**
  5835. * Creates a `_.toPairs` or `_.toPairsIn` function.
  5836. *
  5837. * @private
  5838. * @param {Function} keysFunc The function to get the keys of a given object.
  5839. * @returns {Function} Returns the new pairs function.
  5840. */
  5841. function createToPairs(keysFunc) {
  5842. return function(object) {
  5843. var tag = getTag(object);
  5844. if (tag == mapTag) {
  5845. return mapToArray(object);
  5846. }
  5847. if (tag == setTag) {
  5848. return setToPairs(object);
  5849. }
  5850. return baseToPairs(object, keysFunc(object));
  5851. };
  5852. }
  5853. /**
  5854. * Creates a function that either curries or invokes `func` with optional
  5855. * `this` binding and partially applied arguments.
  5856. *
  5857. * @private
  5858. * @param {Function|string} func The function or method name to wrap.
  5859. * @param {number} bitmask The bitmask flags.
  5860. * 1 - `_.bind`
  5861. * 2 - `_.bindKey`
  5862. * 4 - `_.curry` or `_.curryRight` of a bound function
  5863. * 8 - `_.curry`
  5864. * 16 - `_.curryRight`
  5865. * 32 - `_.partial`
  5866. * 64 - `_.partialRight`
  5867. * 128 - `_.rearg`
  5868. * 256 - `_.ary`
  5869. * 512 - `_.flip`
  5870. * @param {*} [thisArg] The `this` binding of `func`.
  5871. * @param {Array} [partials] The arguments to be partially applied.
  5872. * @param {Array} [holders] The `partials` placeholder indexes.
  5873. * @param {Array} [argPos] The argument positions of the new function.
  5874. * @param {number} [ary] The arity cap of `func`.
  5875. * @param {number} [arity] The arity of `func`.
  5876. * @returns {Function} Returns the new wrapped function.
  5877. */
  5878. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  5879. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  5880. if (!isBindKey && typeof func != 'function') {
  5881. throw new TypeError(FUNC_ERROR_TEXT);
  5882. }
  5883. var length = partials ? partials.length : 0;
  5884. if (!length) {
  5885. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  5886. partials = holders = undefined;
  5887. }
  5888. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  5889. arity = arity === undefined ? arity : toInteger(arity);
  5890. length -= holders ? holders.length : 0;
  5891. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  5892. var partialsRight = partials,
  5893. holdersRight = holders;
  5894. partials = holders = undefined;
  5895. }
  5896. var data = isBindKey ? undefined : getData(func);
  5897. var newData = [
  5898. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  5899. argPos, ary, arity
  5900. ];
  5901. if (data) {
  5902. mergeData(newData, data);
  5903. }
  5904. func = newData[0];
  5905. bitmask = newData[1];
  5906. thisArg = newData[2];
  5907. partials = newData[3];
  5908. holders = newData[4];
  5909. arity = newData[9] = newData[9] === undefined
  5910. ? (isBindKey ? 0 : func.length)
  5911. : nativeMax(newData[9] - length, 0);
  5912. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  5913. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  5914. }
  5915. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  5916. var result = createBind(func, bitmask, thisArg);
  5917. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  5918. result = createCurry(func, bitmask, arity);
  5919. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  5920. result = createPartial(func, bitmask, thisArg, partials);
  5921. } else {
  5922. result = createHybrid.apply(undefined, newData);
  5923. }
  5924. var setter = data ? baseSetData : setData;
  5925. return setWrapToString(setter(result, newData), func, bitmask);
  5926. }
  5927. /**
  5928. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  5929. * of source objects to the destination object for all destination properties
  5930. * that resolve to `undefined`.
  5931. *
  5932. * @private
  5933. * @param {*} objValue The destination value.
  5934. * @param {*} srcValue The source value.
  5935. * @param {string} key The key of the property to assign.
  5936. * @param {Object} object The parent object of `objValue`.
  5937. * @returns {*} Returns the value to assign.
  5938. */
  5939. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  5940. if (objValue === undefined ||
  5941. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  5942. return srcValue;
  5943. }
  5944. return objValue;
  5945. }
  5946. /**
  5947. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  5948. * objects into destination objects that are passed thru.
  5949. *
  5950. * @private
  5951. * @param {*} objValue The destination value.
  5952. * @param {*} srcValue The source value.
  5953. * @param {string} key The key of the property to merge.
  5954. * @param {Object} object The parent object of `objValue`.
  5955. * @param {Object} source The parent object of `srcValue`.
  5956. * @param {Object} [stack] Tracks traversed source values and their merged
  5957. * counterparts.
  5958. * @returns {*} Returns the value to assign.
  5959. */
  5960. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  5961. if (isObject(objValue) && isObject(srcValue)) {
  5962. // Recursively merge objects and arrays (susceptible to call stack limits).
  5963. stack.set(srcValue, objValue);
  5964. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  5965. stack['delete'](srcValue);
  5966. }
  5967. return objValue;
  5968. }
  5969. /**
  5970. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  5971. * objects.
  5972. *
  5973. * @private
  5974. * @param {*} value The value to inspect.
  5975. * @param {string} key The key of the property to inspect.
  5976. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  5977. */
  5978. function customOmitClone(value) {
  5979. return isPlainObject(value) ? undefined : value;
  5980. }
  5981. /**
  5982. * A specialized version of `baseIsEqualDeep` for arrays with support for
  5983. * partial deep comparisons.
  5984. *
  5985. * @private
  5986. * @param {Array} array The array to compare.
  5987. * @param {Array} other The other array to compare.
  5988. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  5989. * @param {Function} customizer The function to customize comparisons.
  5990. * @param {Function} equalFunc The function to determine equivalents of values.
  5991. * @param {Object} stack Tracks traversed `array` and `other` objects.
  5992. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  5993. */
  5994. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  5995. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  5996. arrLength = array.length,
  5997. othLength = other.length;
  5998. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  5999. return false;
  6000. }
  6001. // Assume cyclic values are equal.
  6002. var stacked = stack.get(array);
  6003. if (stacked && stack.get(other)) {
  6004. return stacked == other;
  6005. }
  6006. var index = -1,
  6007. result = true,
  6008. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  6009. stack.set(array, other);
  6010. stack.set(other, array);
  6011. // Ignore non-index properties.
  6012. while (++index < arrLength) {
  6013. var arrValue = array[index],
  6014. othValue = other[index];
  6015. if (customizer) {
  6016. var compared = isPartial
  6017. ? customizer(othValue, arrValue, index, other, array, stack)
  6018. : customizer(arrValue, othValue, index, array, other, stack);
  6019. }
  6020. if (compared !== undefined) {
  6021. if (compared) {
  6022. continue;
  6023. }
  6024. result = false;
  6025. break;
  6026. }
  6027. // Recursively compare arrays (susceptible to call stack limits).
  6028. if (seen) {
  6029. if (!arraySome(other, function(othValue, othIndex) {
  6030. if (!cacheHas(seen, othIndex) &&
  6031. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  6032. return seen.push(othIndex);
  6033. }
  6034. })) {
  6035. result = false;
  6036. break;
  6037. }
  6038. } else if (!(
  6039. arrValue === othValue ||
  6040. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  6041. )) {
  6042. result = false;
  6043. break;
  6044. }
  6045. }
  6046. stack['delete'](array);
  6047. stack['delete'](other);
  6048. return result;
  6049. }
  6050. /**
  6051. * A specialized version of `baseIsEqualDeep` for comparing objects of
  6052. * the same `toStringTag`.
  6053. *
  6054. * **Note:** This function only supports comparing values with tags of
  6055. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6056. *
  6057. * @private
  6058. * @param {Object} object The object to compare.
  6059. * @param {Object} other The other object to compare.
  6060. * @param {string} tag The `toStringTag` of the objects to compare.
  6061. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6062. * @param {Function} customizer The function to customize comparisons.
  6063. * @param {Function} equalFunc The function to determine equivalents of values.
  6064. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6065. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6066. */
  6067. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  6068. switch (tag) {
  6069. case dataViewTag:
  6070. if ((object.byteLength != other.byteLength) ||
  6071. (object.byteOffset != other.byteOffset)) {
  6072. return false;
  6073. }
  6074. object = object.buffer;
  6075. other = other.buffer;
  6076. case arrayBufferTag:
  6077. if ((object.byteLength != other.byteLength) ||
  6078. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  6079. return false;
  6080. }
  6081. return true;
  6082. case boolTag:
  6083. case dateTag:
  6084. case numberTag:
  6085. // Coerce booleans to `1` or `0` and dates to milliseconds.
  6086. // Invalid dates are coerced to `NaN`.
  6087. return eq(+object, +other);
  6088. case errorTag:
  6089. return object.name == other.name && object.message == other.message;
  6090. case regexpTag:
  6091. case stringTag:
  6092. // Coerce regexes to strings and treat strings, primitives and objects,
  6093. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  6094. // for more details.
  6095. return object == (other + '');
  6096. case mapTag:
  6097. var convert = mapToArray;
  6098. case setTag:
  6099. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  6100. convert || (convert = setToArray);
  6101. if (object.size != other.size && !isPartial) {
  6102. return false;
  6103. }
  6104. // Assume cyclic values are equal.
  6105. var stacked = stack.get(object);
  6106. if (stacked) {
  6107. return stacked == other;
  6108. }
  6109. bitmask |= COMPARE_UNORDERED_FLAG;
  6110. // Recursively compare objects (susceptible to call stack limits).
  6111. stack.set(object, other);
  6112. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  6113. stack['delete'](object);
  6114. return result;
  6115. case symbolTag:
  6116. if (symbolValueOf) {
  6117. return symbolValueOf.call(object) == symbolValueOf.call(other);
  6118. }
  6119. }
  6120. return false;
  6121. }
  6122. /**
  6123. * A specialized version of `baseIsEqualDeep` for objects with support for
  6124. * partial deep comparisons.
  6125. *
  6126. * @private
  6127. * @param {Object} object The object to compare.
  6128. * @param {Object} other The other object to compare.
  6129. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6130. * @param {Function} customizer The function to customize comparisons.
  6131. * @param {Function} equalFunc The function to determine equivalents of values.
  6132. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6133. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6134. */
  6135. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  6136. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6137. objProps = getAllKeys(object),
  6138. objLength = objProps.length,
  6139. othProps = getAllKeys(other),
  6140. othLength = othProps.length;
  6141. if (objLength != othLength && !isPartial) {
  6142. return false;
  6143. }
  6144. var index = objLength;
  6145. while (index--) {
  6146. var key = objProps[index];
  6147. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  6148. return false;
  6149. }
  6150. }
  6151. // Assume cyclic values are equal.
  6152. var stacked = stack.get(object);
  6153. if (stacked && stack.get(other)) {
  6154. return stacked == other;
  6155. }
  6156. var result = true;
  6157. stack.set(object, other);
  6158. stack.set(other, object);
  6159. var skipCtor = isPartial;
  6160. while (++index < objLength) {
  6161. key = objProps[index];
  6162. var objValue = object[key],
  6163. othValue = other[key];
  6164. if (customizer) {
  6165. var compared = isPartial
  6166. ? customizer(othValue, objValue, key, other, object, stack)
  6167. : customizer(objValue, othValue, key, object, other, stack);
  6168. }
  6169. // Recursively compare objects (susceptible to call stack limits).
  6170. if (!(compared === undefined
  6171. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  6172. : compared
  6173. )) {
  6174. result = false;
  6175. break;
  6176. }
  6177. skipCtor || (skipCtor = key == 'constructor');
  6178. }
  6179. if (result && !skipCtor) {
  6180. var objCtor = object.constructor,
  6181. othCtor = other.constructor;
  6182. // Non `Object` object instances with different constructors are not equal.
  6183. if (objCtor != othCtor &&
  6184. ('constructor' in object && 'constructor' in other) &&
  6185. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  6186. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  6187. result = false;
  6188. }
  6189. }
  6190. stack['delete'](object);
  6191. stack['delete'](other);
  6192. return result;
  6193. }
  6194. /**
  6195. * A specialized version of `baseRest` which flattens the rest array.
  6196. *
  6197. * @private
  6198. * @param {Function} func The function to apply a rest parameter to.
  6199. * @returns {Function} Returns the new function.
  6200. */
  6201. function flatRest(func) {
  6202. return setToString(overRest(func, undefined, flatten), func + '');
  6203. }
  6204. /**
  6205. * Creates an array of own enumerable property names and symbols of `object`.
  6206. *
  6207. * @private
  6208. * @param {Object} object The object to query.
  6209. * @returns {Array} Returns the array of property names and symbols.
  6210. */
  6211. function getAllKeys(object) {
  6212. return baseGetAllKeys(object, keys, getSymbols);
  6213. }
  6214. /**
  6215. * Creates an array of own and inherited enumerable property names and
  6216. * symbols of `object`.
  6217. *
  6218. * @private
  6219. * @param {Object} object The object to query.
  6220. * @returns {Array} Returns the array of property names and symbols.
  6221. */
  6222. function getAllKeysIn(object) {
  6223. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  6224. }
  6225. /**
  6226. * Gets metadata for `func`.
  6227. *
  6228. * @private
  6229. * @param {Function} func The function to query.
  6230. * @returns {*} Returns the metadata for `func`.
  6231. */
  6232. var getData = !metaMap ? noop : function(func) {
  6233. return metaMap.get(func);
  6234. };
  6235. /**
  6236. * Gets the name of `func`.
  6237. *
  6238. * @private
  6239. * @param {Function} func The function to query.
  6240. * @returns {string} Returns the function name.
  6241. */
  6242. function getFuncName(func) {
  6243. var result = (func.name + ''),
  6244. array = realNames[result],
  6245. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  6246. while (length--) {
  6247. var data = array[length],
  6248. otherFunc = data.func;
  6249. if (otherFunc == null || otherFunc == func) {
  6250. return data.name;
  6251. }
  6252. }
  6253. return result;
  6254. }
  6255. /**
  6256. * Gets the argument placeholder value for `func`.
  6257. *
  6258. * @private
  6259. * @param {Function} func The function to inspect.
  6260. * @returns {*} Returns the placeholder value.
  6261. */
  6262. function getHolder(func) {
  6263. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  6264. return object.placeholder;
  6265. }
  6266. /**
  6267. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  6268. * this function returns the custom method, otherwise it returns `baseIteratee`.
  6269. * If arguments are provided, the chosen function is invoked with them and
  6270. * its result is returned.
  6271. *
  6272. * @private
  6273. * @param {*} [value] The value to convert to an iteratee.
  6274. * @param {number} [arity] The arity of the created iteratee.
  6275. * @returns {Function} Returns the chosen function or its result.
  6276. */
  6277. function getIteratee() {
  6278. var result = lodash.iteratee || iteratee;
  6279. result = result === iteratee ? baseIteratee : result;
  6280. return arguments.length ? result(arguments[0], arguments[1]) : result;
  6281. }
  6282. /**
  6283. * Gets the data for `map`.
  6284. *
  6285. * @private
  6286. * @param {Object} map The map to query.
  6287. * @param {string} key The reference key.
  6288. * @returns {*} Returns the map data.
  6289. */
  6290. function getMapData(map, key) {
  6291. var data = map.__data__;
  6292. return isKeyable(key)
  6293. ? data[typeof key == 'string' ? 'string' : 'hash']
  6294. : data.map;
  6295. }
  6296. /**
  6297. * Gets the property names, values, and compare flags of `object`.
  6298. *
  6299. * @private
  6300. * @param {Object} object The object to query.
  6301. * @returns {Array} Returns the match data of `object`.
  6302. */
  6303. function getMatchData(object) {
  6304. var result = keys(object),
  6305. length = result.length;
  6306. while (length--) {
  6307. var key = result[length],
  6308. value = object[key];
  6309. result[length] = [key, value, isStrictComparable(value)];
  6310. }
  6311. return result;
  6312. }
  6313. /**
  6314. * Gets the native function at `key` of `object`.
  6315. *
  6316. * @private
  6317. * @param {Object} object The object to query.
  6318. * @param {string} key The key of the method to get.
  6319. * @returns {*} Returns the function if it's native, else `undefined`.
  6320. */
  6321. function getNative(object, key) {
  6322. var value = getValue(object, key);
  6323. return baseIsNative(value) ? value : undefined;
  6324. }
  6325. /**
  6326. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  6327. *
  6328. * @private
  6329. * @param {*} value The value to query.
  6330. * @returns {string} Returns the raw `toStringTag`.
  6331. */
  6332. function getRawTag(value) {
  6333. var isOwn = hasOwnProperty.call(value, symToStringTag),
  6334. tag = value[symToStringTag];
  6335. try {
  6336. value[symToStringTag] = undefined;
  6337. var unmasked = true;
  6338. } catch (e) {}
  6339. var result = nativeObjectToString.call(value);
  6340. if (unmasked) {
  6341. if (isOwn) {
  6342. value[symToStringTag] = tag;
  6343. } else {
  6344. delete value[symToStringTag];
  6345. }
  6346. }
  6347. return result;
  6348. }
  6349. /**
  6350. * Creates an array of the own enumerable symbols of `object`.
  6351. *
  6352. * @private
  6353. * @param {Object} object The object to query.
  6354. * @returns {Array} Returns the array of symbols.
  6355. */
  6356. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  6357. if (object == null) {
  6358. return [];
  6359. }
  6360. object = Object(object);
  6361. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  6362. return propertyIsEnumerable.call(object, symbol);
  6363. });
  6364. };
  6365. /**
  6366. * Creates an array of the own and inherited enumerable symbols of `object`.
  6367. *
  6368. * @private
  6369. * @param {Object} object The object to query.
  6370. * @returns {Array} Returns the array of symbols.
  6371. */
  6372. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  6373. var result = [];
  6374. while (object) {
  6375. arrayPush(result, getSymbols(object));
  6376. object = getPrototype(object);
  6377. }
  6378. return result;
  6379. };
  6380. /**
  6381. * Gets the `toStringTag` of `value`.
  6382. *
  6383. * @private
  6384. * @param {*} value The value to query.
  6385. * @returns {string} Returns the `toStringTag`.
  6386. */
  6387. var getTag = baseGetTag;
  6388. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  6389. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  6390. (Map && getTag(new Map) != mapTag) ||
  6391. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  6392. (Set && getTag(new Set) != setTag) ||
  6393. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  6394. getTag = function(value) {
  6395. var result = baseGetTag(value),
  6396. Ctor = result == objectTag ? value.constructor : undefined,
  6397. ctorString = Ctor ? toSource(Ctor) : '';
  6398. if (ctorString) {
  6399. switch (ctorString) {
  6400. case dataViewCtorString: return dataViewTag;
  6401. case mapCtorString: return mapTag;
  6402. case promiseCtorString: return promiseTag;
  6403. case setCtorString: return setTag;
  6404. case weakMapCtorString: return weakMapTag;
  6405. }
  6406. }
  6407. return result;
  6408. };
  6409. }
  6410. /**
  6411. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  6412. *
  6413. * @private
  6414. * @param {number} start The start of the view.
  6415. * @param {number} end The end of the view.
  6416. * @param {Array} transforms The transformations to apply to the view.
  6417. * @returns {Object} Returns an object containing the `start` and `end`
  6418. * positions of the view.
  6419. */
  6420. function getView(start, end, transforms) {
  6421. var index = -1,
  6422. length = transforms.length;
  6423. while (++index < length) {
  6424. var data = transforms[index],
  6425. size = data.size;
  6426. switch (data.type) {
  6427. case 'drop': start += size; break;
  6428. case 'dropRight': end -= size; break;
  6429. case 'take': end = nativeMin(end, start + size); break;
  6430. case 'takeRight': start = nativeMax(start, end - size); break;
  6431. }
  6432. }
  6433. return { 'start': start, 'end': end };
  6434. }
  6435. /**
  6436. * Extracts wrapper details from the `source` body comment.
  6437. *
  6438. * @private
  6439. * @param {string} source The source to inspect.
  6440. * @returns {Array} Returns the wrapper details.
  6441. */
  6442. function getWrapDetails(source) {
  6443. var match = source.match(reWrapDetails);
  6444. return match ? match[1].split(reSplitDetails) : [];
  6445. }
  6446. /**
  6447. * Checks if `path` exists on `object`.
  6448. *
  6449. * @private
  6450. * @param {Object} object The object to query.
  6451. * @param {Array|string} path The path to check.
  6452. * @param {Function} hasFunc The function to check properties.
  6453. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  6454. */
  6455. function hasPath(object, path, hasFunc) {
  6456. path = castPath(path, object);
  6457. var index = -1,
  6458. length = path.length,
  6459. result = false;
  6460. while (++index < length) {
  6461. var key = toKey(path[index]);
  6462. if (!(result = object != null && hasFunc(object, key))) {
  6463. break;
  6464. }
  6465. object = object[key];
  6466. }
  6467. if (result || ++index != length) {
  6468. return result;
  6469. }
  6470. length = object == null ? 0 : object.length;
  6471. return !!length && isLength(length) && isIndex(key, length) &&
  6472. (isArray(object) || isArguments(object));
  6473. }
  6474. /**
  6475. * Initializes an array clone.
  6476. *
  6477. * @private
  6478. * @param {Array} array The array to clone.
  6479. * @returns {Array} Returns the initialized clone.
  6480. */
  6481. function initCloneArray(array) {
  6482. var length = array.length,
  6483. result = array.constructor(length);
  6484. // Add properties assigned by `RegExp#exec`.
  6485. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  6486. result.index = array.index;
  6487. result.input = array.input;
  6488. }
  6489. return result;
  6490. }
  6491. /**
  6492. * Initializes an object clone.
  6493. *
  6494. * @private
  6495. * @param {Object} object The object to clone.
  6496. * @returns {Object} Returns the initialized clone.
  6497. */
  6498. function initCloneObject(object) {
  6499. return (typeof object.constructor == 'function' && !isPrototype(object))
  6500. ? baseCreate(getPrototype(object))
  6501. : {};
  6502. }
  6503. /**
  6504. * Initializes an object clone based on its `toStringTag`.
  6505. *
  6506. * **Note:** This function only supports cloning values with tags of
  6507. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6508. *
  6509. * @private
  6510. * @param {Object} object The object to clone.
  6511. * @param {string} tag The `toStringTag` of the object to clone.
  6512. * @param {Function} cloneFunc The function to clone values.
  6513. * @param {boolean} [isDeep] Specify a deep clone.
  6514. * @returns {Object} Returns the initialized clone.
  6515. */
  6516. function initCloneByTag(object, tag, cloneFunc, isDeep) {
  6517. var Ctor = object.constructor;
  6518. switch (tag) {
  6519. case arrayBufferTag:
  6520. return cloneArrayBuffer(object);
  6521. case boolTag:
  6522. case dateTag:
  6523. return new Ctor(+object);
  6524. case dataViewTag:
  6525. return cloneDataView(object, isDeep);
  6526. case float32Tag: case float64Tag:
  6527. case int8Tag: case int16Tag: case int32Tag:
  6528. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  6529. return cloneTypedArray(object, isDeep);
  6530. case mapTag:
  6531. return cloneMap(object, isDeep, cloneFunc);
  6532. case numberTag:
  6533. case stringTag:
  6534. return new Ctor(object);
  6535. case regexpTag:
  6536. return cloneRegExp(object);
  6537. case setTag:
  6538. return cloneSet(object, isDeep, cloneFunc);
  6539. case symbolTag:
  6540. return cloneSymbol(object);
  6541. }
  6542. }
  6543. /**
  6544. * Inserts wrapper `details` in a comment at the top of the `source` body.
  6545. *
  6546. * @private
  6547. * @param {string} source The source to modify.
  6548. * @returns {Array} details The details to insert.
  6549. * @returns {string} Returns the modified source.
  6550. */
  6551. function insertWrapDetails(source, details) {
  6552. var length = details.length;
  6553. if (!length) {
  6554. return source;
  6555. }
  6556. var lastIndex = length - 1;
  6557. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  6558. details = details.join(length > 2 ? ', ' : ' ');
  6559. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  6560. }
  6561. /**
  6562. * Checks if `value` is a flattenable `arguments` object or array.
  6563. *
  6564. * @private
  6565. * @param {*} value The value to check.
  6566. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  6567. */
  6568. function isFlattenable(value) {
  6569. return isArray(value) || isArguments(value) ||
  6570. !!(spreadableSymbol && value && value[spreadableSymbol]);
  6571. }
  6572. /**
  6573. * Checks if `value` is a valid array-like index.
  6574. *
  6575. * @private
  6576. * @param {*} value The value to check.
  6577. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  6578. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  6579. */
  6580. function isIndex(value, length) {
  6581. length = length == null ? MAX_SAFE_INTEGER : length;
  6582. return !!length &&
  6583. (typeof value == 'number' || reIsUint.test(value)) &&
  6584. (value > -1 && value % 1 == 0 && value < length);
  6585. }
  6586. /**
  6587. * Checks if the given arguments are from an iteratee call.
  6588. *
  6589. * @private
  6590. * @param {*} value The potential iteratee value argument.
  6591. * @param {*} index The potential iteratee index or key argument.
  6592. * @param {*} object The potential iteratee object argument.
  6593. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  6594. * else `false`.
  6595. */
  6596. function isIterateeCall(value, index, object) {
  6597. if (!isObject(object)) {
  6598. return false;
  6599. }
  6600. var type = typeof index;
  6601. if (type == 'number'
  6602. ? (isArrayLike(object) && isIndex(index, object.length))
  6603. : (type == 'string' && index in object)
  6604. ) {
  6605. return eq(object[index], value);
  6606. }
  6607. return false;
  6608. }
  6609. /**
  6610. * Checks if `value` is a property name and not a property path.
  6611. *
  6612. * @private
  6613. * @param {*} value The value to check.
  6614. * @param {Object} [object] The object to query keys on.
  6615. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  6616. */
  6617. function isKey(value, object) {
  6618. if (isArray(value)) {
  6619. return false;
  6620. }
  6621. var type = typeof value;
  6622. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  6623. value == null || isSymbol(value)) {
  6624. return true;
  6625. }
  6626. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  6627. (object != null && value in Object(object));
  6628. }
  6629. /**
  6630. * Checks if `value` is suitable for use as unique object key.
  6631. *
  6632. * @private
  6633. * @param {*} value The value to check.
  6634. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  6635. */
  6636. function isKeyable(value) {
  6637. var type = typeof value;
  6638. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  6639. ? (value !== '__proto__')
  6640. : (value === null);
  6641. }
  6642. /**
  6643. * Checks if `func` has a lazy counterpart.
  6644. *
  6645. * @private
  6646. * @param {Function} func The function to check.
  6647. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  6648. * else `false`.
  6649. */
  6650. function isLaziable(func) {
  6651. var funcName = getFuncName(func),
  6652. other = lodash[funcName];
  6653. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  6654. return false;
  6655. }
  6656. if (func === other) {
  6657. return true;
  6658. }
  6659. var data = getData(other);
  6660. return !!data && func === data[0];
  6661. }
  6662. /**
  6663. * Checks if `func` has its source masked.
  6664. *
  6665. * @private
  6666. * @param {Function} func The function to check.
  6667. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  6668. */
  6669. function isMasked(func) {
  6670. return !!maskSrcKey && (maskSrcKey in func);
  6671. }
  6672. /**
  6673. * Checks if `func` is capable of being masked.
  6674. *
  6675. * @private
  6676. * @param {*} value The value to check.
  6677. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  6678. */
  6679. var isMaskable = coreJsData ? isFunction : stubFalse;
  6680. /**
  6681. * Checks if `value` is likely a prototype object.
  6682. *
  6683. * @private
  6684. * @param {*} value The value to check.
  6685. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  6686. */
  6687. function isPrototype(value) {
  6688. var Ctor = value && value.constructor,
  6689. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  6690. return value === proto;
  6691. }
  6692. /**
  6693. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  6694. *
  6695. * @private
  6696. * @param {*} value The value to check.
  6697. * @returns {boolean} Returns `true` if `value` if suitable for strict
  6698. * equality comparisons, else `false`.
  6699. */
  6700. function isStrictComparable(value) {
  6701. return value === value && !isObject(value);
  6702. }
  6703. /**
  6704. * A specialized version of `matchesProperty` for source values suitable
  6705. * for strict equality comparisons, i.e. `===`.
  6706. *
  6707. * @private
  6708. * @param {string} key The key of the property to get.
  6709. * @param {*} srcValue The value to match.
  6710. * @returns {Function} Returns the new spec function.
  6711. */
  6712. function matchesStrictComparable(key, srcValue) {
  6713. return function(object) {
  6714. if (object == null) {
  6715. return false;
  6716. }
  6717. return object[key] === srcValue &&
  6718. (srcValue !== undefined || (key in Object(object)));
  6719. };
  6720. }
  6721. /**
  6722. * A specialized version of `_.memoize` which clears the memoized function's
  6723. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  6724. *
  6725. * @private
  6726. * @param {Function} func The function to have its output memoized.
  6727. * @returns {Function} Returns the new memoized function.
  6728. */
  6729. function memoizeCapped(func) {
  6730. var result = memoize(func, function(key) {
  6731. if (cache.size === MAX_MEMOIZE_SIZE) {
  6732. cache.clear();
  6733. }
  6734. return key;
  6735. });
  6736. var cache = result.cache;
  6737. return result;
  6738. }
  6739. /**
  6740. * Merges the function metadata of `source` into `data`.
  6741. *
  6742. * Merging metadata reduces the number of wrappers used to invoke a function.
  6743. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  6744. * may be applied regardless of execution order. Methods like `_.ary` and
  6745. * `_.rearg` modify function arguments, making the order in which they are
  6746. * executed important, preventing the merging of metadata. However, we make
  6747. * an exception for a safe combined case where curried functions have `_.ary`
  6748. * and or `_.rearg` applied.
  6749. *
  6750. * @private
  6751. * @param {Array} data The destination metadata.
  6752. * @param {Array} source The source metadata.
  6753. * @returns {Array} Returns `data`.
  6754. */
  6755. function mergeData(data, source) {
  6756. var bitmask = data[1],
  6757. srcBitmask = source[1],
  6758. newBitmask = bitmask | srcBitmask,
  6759. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  6760. var isCombo =
  6761. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  6762. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  6763. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  6764. // Exit early if metadata can't be merged.
  6765. if (!(isCommon || isCombo)) {
  6766. return data;
  6767. }
  6768. // Use source `thisArg` if available.
  6769. if (srcBitmask & WRAP_BIND_FLAG) {
  6770. data[2] = source[2];
  6771. // Set when currying a bound function.
  6772. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  6773. }
  6774. // Compose partial arguments.
  6775. var value = source[3];
  6776. if (value) {
  6777. var partials = data[3];
  6778. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  6779. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  6780. }
  6781. // Compose partial right arguments.
  6782. value = source[5];
  6783. if (value) {
  6784. partials = data[5];
  6785. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  6786. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  6787. }
  6788. // Use source `argPos` if available.
  6789. value = source[7];
  6790. if (value) {
  6791. data[7] = value;
  6792. }
  6793. // Use source `ary` if it's smaller.
  6794. if (srcBitmask & WRAP_ARY_FLAG) {
  6795. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  6796. }
  6797. // Use source `arity` if one is not provided.
  6798. if (data[9] == null) {
  6799. data[9] = source[9];
  6800. }
  6801. // Use source `func` and merge bitmasks.
  6802. data[0] = source[0];
  6803. data[1] = newBitmask;
  6804. return data;
  6805. }
  6806. /**
  6807. * This function is like
  6808. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  6809. * except that it includes inherited enumerable properties.
  6810. *
  6811. * @private
  6812. * @param {Object} object The object to query.
  6813. * @returns {Array} Returns the array of property names.
  6814. */
  6815. function nativeKeysIn(object) {
  6816. var result = [];
  6817. if (object != null) {
  6818. for (var key in Object(object)) {
  6819. result.push(key);
  6820. }
  6821. }
  6822. return result;
  6823. }
  6824. /**
  6825. * Converts `value` to a string using `Object.prototype.toString`.
  6826. *
  6827. * @private
  6828. * @param {*} value The value to convert.
  6829. * @returns {string} Returns the converted string.
  6830. */
  6831. function objectToString(value) {
  6832. return nativeObjectToString.call(value);
  6833. }
  6834. /**
  6835. * A specialized version of `baseRest` which transforms the rest array.
  6836. *
  6837. * @private
  6838. * @param {Function} func The function to apply a rest parameter to.
  6839. * @param {number} [start=func.length-1] The start position of the rest parameter.
  6840. * @param {Function} transform The rest array transform.
  6841. * @returns {Function} Returns the new function.
  6842. */
  6843. function overRest(func, start, transform) {
  6844. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  6845. return function() {
  6846. var args = arguments,
  6847. index = -1,
  6848. length = nativeMax(args.length - start, 0),
  6849. array = Array(length);
  6850. while (++index < length) {
  6851. array[index] = args[start + index];
  6852. }
  6853. index = -1;
  6854. var otherArgs = Array(start + 1);
  6855. while (++index < start) {
  6856. otherArgs[index] = args[index];
  6857. }
  6858. otherArgs[start] = transform(array);
  6859. return apply(func, this, otherArgs);
  6860. };
  6861. }
  6862. /**
  6863. * Gets the parent value at `path` of `object`.
  6864. *
  6865. * @private
  6866. * @param {Object} object The object to query.
  6867. * @param {Array} path The path to get the parent value of.
  6868. * @returns {*} Returns the parent value.
  6869. */
  6870. function parent(object, path) {
  6871. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  6872. }
  6873. /**
  6874. * Reorder `array` according to the specified indexes where the element at
  6875. * the first index is assigned as the first element, the element at
  6876. * the second index is assigned as the second element, and so on.
  6877. *
  6878. * @private
  6879. * @param {Array} array The array to reorder.
  6880. * @param {Array} indexes The arranged array indexes.
  6881. * @returns {Array} Returns `array`.
  6882. */
  6883. function reorder(array, indexes) {
  6884. var arrLength = array.length,
  6885. length = nativeMin(indexes.length, arrLength),
  6886. oldArray = copyArray(array);
  6887. while (length--) {
  6888. var index = indexes[length];
  6889. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  6890. }
  6891. return array;
  6892. }
  6893. /**
  6894. * Sets metadata for `func`.
  6895. *
  6896. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  6897. * period of time, it will trip its breaker and transition to an identity
  6898. * function to avoid garbage collection pauses in V8. See
  6899. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  6900. * for more details.
  6901. *
  6902. * @private
  6903. * @param {Function} func The function to associate metadata with.
  6904. * @param {*} data The metadata.
  6905. * @returns {Function} Returns `func`.
  6906. */
  6907. var setData = shortOut(baseSetData);
  6908. /**
  6909. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  6910. *
  6911. * @private
  6912. * @param {Function} func The function to delay.
  6913. * @param {number} wait The number of milliseconds to delay invocation.
  6914. * @returns {number|Object} Returns the timer id or timeout object.
  6915. */
  6916. var setTimeout = ctxSetTimeout || function(func, wait) {
  6917. return root.setTimeout(func, wait);
  6918. };
  6919. /**
  6920. * Sets the `toString` method of `func` to return `string`.
  6921. *
  6922. * @private
  6923. * @param {Function} func The function to modify.
  6924. * @param {Function} string The `toString` result.
  6925. * @returns {Function} Returns `func`.
  6926. */
  6927. var setToString = shortOut(baseSetToString);
  6928. /**
  6929. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  6930. * with wrapper details in a comment at the top of the source body.
  6931. *
  6932. * @private
  6933. * @param {Function} wrapper The function to modify.
  6934. * @param {Function} reference The reference function.
  6935. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6936. * @returns {Function} Returns `wrapper`.
  6937. */
  6938. function setWrapToString(wrapper, reference, bitmask) {
  6939. var source = (reference + '');
  6940. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  6941. }
  6942. /**
  6943. * Creates a function that'll short out and invoke `identity` instead
  6944. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  6945. * milliseconds.
  6946. *
  6947. * @private
  6948. * @param {Function} func The function to restrict.
  6949. * @returns {Function} Returns the new shortable function.
  6950. */
  6951. function shortOut(func) {
  6952. var count = 0,
  6953. lastCalled = 0;
  6954. return function() {
  6955. var stamp = nativeNow(),
  6956. remaining = HOT_SPAN - (stamp - lastCalled);
  6957. lastCalled = stamp;
  6958. if (remaining > 0) {
  6959. if (++count >= HOT_COUNT) {
  6960. return arguments[0];
  6961. }
  6962. } else {
  6963. count = 0;
  6964. }
  6965. return func.apply(undefined, arguments);
  6966. };
  6967. }
  6968. /**
  6969. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  6970. *
  6971. * @private
  6972. * @param {Array} array The array to shuffle.
  6973. * @param {number} [size=array.length] The size of `array`.
  6974. * @returns {Array} Returns `array`.
  6975. */
  6976. function shuffleSelf(array, size) {
  6977. var index = -1,
  6978. length = array.length,
  6979. lastIndex = length - 1;
  6980. size = size === undefined ? length : size;
  6981. while (++index < size) {
  6982. var rand = baseRandom(index, lastIndex),
  6983. value = array[rand];
  6984. array[rand] = array[index];
  6985. array[index] = value;
  6986. }
  6987. array.length = size;
  6988. return array;
  6989. }
  6990. /**
  6991. * Converts `string` to a property path array.
  6992. *
  6993. * @private
  6994. * @param {string} string The string to convert.
  6995. * @returns {Array} Returns the property path array.
  6996. */
  6997. var stringToPath = memoizeCapped(function(string) {
  6998. var result = [];
  6999. if (reLeadingDot.test(string)) {
  7000. result.push('');
  7001. }
  7002. string.replace(rePropName, function(match, number, quote, string) {
  7003. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  7004. });
  7005. return result;
  7006. });
  7007. /**
  7008. * Converts `value` to a string key if it's not a string or symbol.
  7009. *
  7010. * @private
  7011. * @param {*} value The value to inspect.
  7012. * @returns {string|symbol} Returns the key.
  7013. */
  7014. function toKey(value) {
  7015. if (typeof value == 'string' || isSymbol(value)) {
  7016. return value;
  7017. }
  7018. var result = (value + '');
  7019. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  7020. }
  7021. /**
  7022. * Converts `func` to its source code.
  7023. *
  7024. * @private
  7025. * @param {Function} func The function to convert.
  7026. * @returns {string} Returns the source code.
  7027. */
  7028. function toSource(func) {
  7029. if (func != null) {
  7030. try {
  7031. return funcToString.call(func);
  7032. } catch (e) {}
  7033. try {
  7034. return (func + '');
  7035. } catch (e) {}
  7036. }
  7037. return '';
  7038. }
  7039. /**
  7040. * Updates wrapper `details` based on `bitmask` flags.
  7041. *
  7042. * @private
  7043. * @returns {Array} details The details to modify.
  7044. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7045. * @returns {Array} Returns `details`.
  7046. */
  7047. function updateWrapDetails(details, bitmask) {
  7048. arrayEach(wrapFlags, function(pair) {
  7049. var value = '_.' + pair[0];
  7050. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  7051. details.push(value);
  7052. }
  7053. });
  7054. return details.sort();
  7055. }
  7056. /**
  7057. * Creates a clone of `wrapper`.
  7058. *
  7059. * @private
  7060. * @param {Object} wrapper The wrapper to clone.
  7061. * @returns {Object} Returns the cloned wrapper.
  7062. */
  7063. function wrapperClone(wrapper) {
  7064. if (wrapper instanceof LazyWrapper) {
  7065. return wrapper.clone();
  7066. }
  7067. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  7068. result.__actions__ = copyArray(wrapper.__actions__);
  7069. result.__index__ = wrapper.__index__;
  7070. result.__values__ = wrapper.__values__;
  7071. return result;
  7072. }
  7073. /*------------------------------------------------------------------------*/
  7074. /**
  7075. * Creates an array of elements split into groups the length of `size`.
  7076. * If `array` can't be split evenly, the final chunk will be the remaining
  7077. * elements.
  7078. *
  7079. * @static
  7080. * @memberOf _
  7081. * @since 3.0.0
  7082. * @category Array
  7083. * @param {Array} array The array to process.
  7084. * @param {number} [size=1] The length of each chunk
  7085. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7086. * @returns {Array} Returns the new array of chunks.
  7087. * @example
  7088. *
  7089. * _.chunk(['a', 'b', 'c', 'd'], 2);
  7090. * // => [['a', 'b'], ['c', 'd']]
  7091. *
  7092. * _.chunk(['a', 'b', 'c', 'd'], 3);
  7093. * // => [['a', 'b', 'c'], ['d']]
  7094. */
  7095. function chunk(array, size, guard) {
  7096. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  7097. size = 1;
  7098. } else {
  7099. size = nativeMax(toInteger(size), 0);
  7100. }
  7101. var length = array == null ? 0 : array.length;
  7102. if (!length || size < 1) {
  7103. return [];
  7104. }
  7105. var index = 0,
  7106. resIndex = 0,
  7107. result = Array(nativeCeil(length / size));
  7108. while (index < length) {
  7109. result[resIndex++] = baseSlice(array, index, (index += size));
  7110. }
  7111. return result;
  7112. }
  7113. /**
  7114. * Creates an array with all falsey values removed. The values `false`, `null`,
  7115. * `0`, `""`, `undefined`, and `NaN` are falsey.
  7116. *
  7117. * @static
  7118. * @memberOf _
  7119. * @since 0.1.0
  7120. * @category Array
  7121. * @param {Array} array The array to compact.
  7122. * @returns {Array} Returns the new array of filtered values.
  7123. * @example
  7124. *
  7125. * _.compact([0, 1, false, 2, '', 3]);
  7126. * // => [1, 2, 3]
  7127. */
  7128. function compact(array) {
  7129. var index = -1,
  7130. length = array == null ? 0 : array.length,
  7131. resIndex = 0,
  7132. result = [];
  7133. while (++index < length) {
  7134. var value = array[index];
  7135. if (value) {
  7136. result[resIndex++] = value;
  7137. }
  7138. }
  7139. return result;
  7140. }
  7141. /**
  7142. * Creates a new array concatenating `array` with any additional arrays
  7143. * and/or values.
  7144. *
  7145. * @static
  7146. * @memberOf _
  7147. * @since 4.0.0
  7148. * @category Array
  7149. * @param {Array} array The array to concatenate.
  7150. * @param {...*} [values] The values to concatenate.
  7151. * @returns {Array} Returns the new concatenated array.
  7152. * @example
  7153. *
  7154. * var array = [1];
  7155. * var other = _.concat(array, 2, [3], [[4]]);
  7156. *
  7157. * console.log(other);
  7158. * // => [1, 2, 3, [4]]
  7159. *
  7160. * console.log(array);
  7161. * // => [1]
  7162. */
  7163. function concat() {
  7164. var length = arguments.length;
  7165. if (!length) {
  7166. return [];
  7167. }
  7168. var args = Array(length - 1),
  7169. array = arguments[0],
  7170. index = length;
  7171. while (index--) {
  7172. args[index - 1] = arguments[index];
  7173. }
  7174. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  7175. }
  7176. /**
  7177. * Creates an array of `array` values not included in the other given arrays
  7178. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7179. * for equality comparisons. The order and references of result values are
  7180. * determined by the first array.
  7181. *
  7182. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  7183. *
  7184. * @static
  7185. * @memberOf _
  7186. * @since 0.1.0
  7187. * @category Array
  7188. * @param {Array} array The array to inspect.
  7189. * @param {...Array} [values] The values to exclude.
  7190. * @returns {Array} Returns the new array of filtered values.
  7191. * @see _.without, _.xor
  7192. * @example
  7193. *
  7194. * _.difference([2, 1], [2, 3]);
  7195. * // => [1]
  7196. */
  7197. var difference = baseRest(function(array, values) {
  7198. return isArrayLikeObject(array)
  7199. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  7200. : [];
  7201. });
  7202. /**
  7203. * This method is like `_.difference` except that it accepts `iteratee` which
  7204. * is invoked for each element of `array` and `values` to generate the criterion
  7205. * by which they're compared. The order and references of result values are
  7206. * determined by the first array. The iteratee is invoked with one argument:
  7207. * (value).
  7208. *
  7209. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  7210. *
  7211. * @static
  7212. * @memberOf _
  7213. * @since 4.0.0
  7214. * @category Array
  7215. * @param {Array} array The array to inspect.
  7216. * @param {...Array} [values] The values to exclude.
  7217. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7218. * @returns {Array} Returns the new array of filtered values.
  7219. * @example
  7220. *
  7221. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  7222. * // => [1.2]
  7223. *
  7224. * // The `_.property` iteratee shorthand.
  7225. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  7226. * // => [{ 'x': 2 }]
  7227. */
  7228. var differenceBy = baseRest(function(array, values) {
  7229. var iteratee = last(values);
  7230. if (isArrayLikeObject(iteratee)) {
  7231. iteratee = undefined;
  7232. }
  7233. return isArrayLikeObject(array)
  7234. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  7235. : [];
  7236. });
  7237. /**
  7238. * This method is like `_.difference` except that it accepts `comparator`
  7239. * which is invoked to compare elements of `array` to `values`. The order and
  7240. * references of result values are determined by the first array. The comparator
  7241. * is invoked with two arguments: (arrVal, othVal).
  7242. *
  7243. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  7244. *
  7245. * @static
  7246. * @memberOf _
  7247. * @since 4.0.0
  7248. * @category Array
  7249. * @param {Array} array The array to inspect.
  7250. * @param {...Array} [values] The values to exclude.
  7251. * @param {Function} [comparator] The comparator invoked per element.
  7252. * @returns {Array} Returns the new array of filtered values.
  7253. * @example
  7254. *
  7255. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  7256. *
  7257. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  7258. * // => [{ 'x': 2, 'y': 1 }]
  7259. */
  7260. var differenceWith = baseRest(function(array, values) {
  7261. var comparator = last(values);
  7262. if (isArrayLikeObject(comparator)) {
  7263. comparator = undefined;
  7264. }
  7265. return isArrayLikeObject(array)
  7266. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  7267. : [];
  7268. });
  7269. /**
  7270. * Creates a slice of `array` with `n` elements dropped from the beginning.
  7271. *
  7272. * @static
  7273. * @memberOf _
  7274. * @since 0.5.0
  7275. * @category Array
  7276. * @param {Array} array The array to query.
  7277. * @param {number} [n=1] The number of elements to drop.
  7278. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7279. * @returns {Array} Returns the slice of `array`.
  7280. * @example
  7281. *
  7282. * _.drop([1, 2, 3]);
  7283. * // => [2, 3]
  7284. *
  7285. * _.drop([1, 2, 3], 2);
  7286. * // => [3]
  7287. *
  7288. * _.drop([1, 2, 3], 5);
  7289. * // => []
  7290. *
  7291. * _.drop([1, 2, 3], 0);
  7292. * // => [1, 2, 3]
  7293. */
  7294. function drop(array, n, guard) {
  7295. var length = array == null ? 0 : array.length;
  7296. if (!length) {
  7297. return [];
  7298. }
  7299. n = (guard || n === undefined) ? 1 : toInteger(n);
  7300. return baseSlice(array, n < 0 ? 0 : n, length);
  7301. }
  7302. /**
  7303. * Creates a slice of `array` with `n` elements dropped from the end.
  7304. *
  7305. * @static
  7306. * @memberOf _
  7307. * @since 3.0.0
  7308. * @category Array
  7309. * @param {Array} array The array to query.
  7310. * @param {number} [n=1] The number of elements to drop.
  7311. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7312. * @returns {Array} Returns the slice of `array`.
  7313. * @example
  7314. *
  7315. * _.dropRight([1, 2, 3]);
  7316. * // => [1, 2]
  7317. *
  7318. * _.dropRight([1, 2, 3], 2);
  7319. * // => [1]
  7320. *
  7321. * _.dropRight([1, 2, 3], 5);
  7322. * // => []
  7323. *
  7324. * _.dropRight([1, 2, 3], 0);
  7325. * // => [1, 2, 3]
  7326. */
  7327. function dropRight(array, n, guard) {
  7328. var length = array == null ? 0 : array.length;
  7329. if (!length) {
  7330. return [];
  7331. }
  7332. n = (guard || n === undefined) ? 1 : toInteger(n);
  7333. n = length - n;
  7334. return baseSlice(array, 0, n < 0 ? 0 : n);
  7335. }
  7336. /**
  7337. * Creates a slice of `array` excluding elements dropped from the end.
  7338. * Elements are dropped until `predicate` returns falsey. The predicate is
  7339. * invoked with three arguments: (value, index, array).
  7340. *
  7341. * @static
  7342. * @memberOf _
  7343. * @since 3.0.0
  7344. * @category Array
  7345. * @param {Array} array The array to query.
  7346. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7347. * @returns {Array} Returns the slice of `array`.
  7348. * @example
  7349. *
  7350. * var users = [
  7351. * { 'user': 'barney', 'active': true },
  7352. * { 'user': 'fred', 'active': false },
  7353. * { 'user': 'pebbles', 'active': false }
  7354. * ];
  7355. *
  7356. * _.dropRightWhile(users, function(o) { return !o.active; });
  7357. * // => objects for ['barney']
  7358. *
  7359. * // The `_.matches` iteratee shorthand.
  7360. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  7361. * // => objects for ['barney', 'fred']
  7362. *
  7363. * // The `_.matchesProperty` iteratee shorthand.
  7364. * _.dropRightWhile(users, ['active', false]);
  7365. * // => objects for ['barney']
  7366. *
  7367. * // The `_.property` iteratee shorthand.
  7368. * _.dropRightWhile(users, 'active');
  7369. * // => objects for ['barney', 'fred', 'pebbles']
  7370. */
  7371. function dropRightWhile(array, predicate) {
  7372. return (array && array.length)
  7373. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  7374. : [];
  7375. }
  7376. /**
  7377. * Creates a slice of `array` excluding elements dropped from the beginning.
  7378. * Elements are dropped until `predicate` returns falsey. The predicate is
  7379. * invoked with three arguments: (value, index, array).
  7380. *
  7381. * @static
  7382. * @memberOf _
  7383. * @since 3.0.0
  7384. * @category Array
  7385. * @param {Array} array The array to query.
  7386. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7387. * @returns {Array} Returns the slice of `array`.
  7388. * @example
  7389. *
  7390. * var users = [
  7391. * { 'user': 'barney', 'active': false },
  7392. * { 'user': 'fred', 'active': false },
  7393. * { 'user': 'pebbles', 'active': true }
  7394. * ];
  7395. *
  7396. * _.dropWhile(users, function(o) { return !o.active; });
  7397. * // => objects for ['pebbles']
  7398. *
  7399. * // The `_.matches` iteratee shorthand.
  7400. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  7401. * // => objects for ['fred', 'pebbles']
  7402. *
  7403. * // The `_.matchesProperty` iteratee shorthand.
  7404. * _.dropWhile(users, ['active', false]);
  7405. * // => objects for ['pebbles']
  7406. *
  7407. * // The `_.property` iteratee shorthand.
  7408. * _.dropWhile(users, 'active');
  7409. * // => objects for ['barney', 'fred', 'pebbles']
  7410. */
  7411. function dropWhile(array, predicate) {
  7412. return (array && array.length)
  7413. ? baseWhile(array, getIteratee(predicate, 3), true)
  7414. : [];
  7415. }
  7416. /**
  7417. * Fills elements of `array` with `value` from `start` up to, but not
  7418. * including, `end`.
  7419. *
  7420. * **Note:** This method mutates `array`.
  7421. *
  7422. * @static
  7423. * @memberOf _
  7424. * @since 3.2.0
  7425. * @category Array
  7426. * @param {Array} array The array to fill.
  7427. * @param {*} value The value to fill `array` with.
  7428. * @param {number} [start=0] The start position.
  7429. * @param {number} [end=array.length] The end position.
  7430. * @returns {Array} Returns `array`.
  7431. * @example
  7432. *
  7433. * var array = [1, 2, 3];
  7434. *
  7435. * _.fill(array, 'a');
  7436. * console.log(array);
  7437. * // => ['a', 'a', 'a']
  7438. *
  7439. * _.fill(Array(3), 2);
  7440. * // => [2, 2, 2]
  7441. *
  7442. * _.fill([4, 6, 8, 10], '*', 1, 3);
  7443. * // => [4, '*', '*', 10]
  7444. */
  7445. function fill(array, value, start, end) {
  7446. var length = array == null ? 0 : array.length;
  7447. if (!length) {
  7448. return [];
  7449. }
  7450. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  7451. start = 0;
  7452. end = length;
  7453. }
  7454. return baseFill(array, value, start, end);
  7455. }
  7456. /**
  7457. * This method is like `_.find` except that it returns the index of the first
  7458. * element `predicate` returns truthy for instead of the element itself.
  7459. *
  7460. * @static
  7461. * @memberOf _
  7462. * @since 1.1.0
  7463. * @category Array
  7464. * @param {Array} array The array to inspect.
  7465. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7466. * @param {number} [fromIndex=0] The index to search from.
  7467. * @returns {number} Returns the index of the found element, else `-1`.
  7468. * @example
  7469. *
  7470. * var users = [
  7471. * { 'user': 'barney', 'active': false },
  7472. * { 'user': 'fred', 'active': false },
  7473. * { 'user': 'pebbles', 'active': true }
  7474. * ];
  7475. *
  7476. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  7477. * // => 0
  7478. *
  7479. * // The `_.matches` iteratee shorthand.
  7480. * _.findIndex(users, { 'user': 'fred', 'active': false });
  7481. * // => 1
  7482. *
  7483. * // The `_.matchesProperty` iteratee shorthand.
  7484. * _.findIndex(users, ['active', false]);
  7485. * // => 0
  7486. *
  7487. * // The `_.property` iteratee shorthand.
  7488. * _.findIndex(users, 'active');
  7489. * // => 2
  7490. */
  7491. function findIndex(array, predicate, fromIndex) {
  7492. var length = array == null ? 0 : array.length;
  7493. if (!length) {
  7494. return -1;
  7495. }
  7496. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  7497. if (index < 0) {
  7498. index = nativeMax(length + index, 0);
  7499. }
  7500. return baseFindIndex(array, getIteratee(predicate, 3), index);
  7501. }
  7502. /**
  7503. * This method is like `_.findIndex` except that it iterates over elements
  7504. * of `collection` from right to left.
  7505. *
  7506. * @static
  7507. * @memberOf _
  7508. * @since 2.0.0
  7509. * @category Array
  7510. * @param {Array} array The array to inspect.
  7511. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7512. * @param {number} [fromIndex=array.length-1] The index to search from.
  7513. * @returns {number} Returns the index of the found element, else `-1`.
  7514. * @example
  7515. *
  7516. * var users = [
  7517. * { 'user': 'barney', 'active': true },
  7518. * { 'user': 'fred', 'active': false },
  7519. * { 'user': 'pebbles', 'active': false }
  7520. * ];
  7521. *
  7522. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  7523. * // => 2
  7524. *
  7525. * // The `_.matches` iteratee shorthand.
  7526. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  7527. * // => 0
  7528. *
  7529. * // The `_.matchesProperty` iteratee shorthand.
  7530. * _.findLastIndex(users, ['active', false]);
  7531. * // => 2
  7532. *
  7533. * // The `_.property` iteratee shorthand.
  7534. * _.findLastIndex(users, 'active');
  7535. * // => 0
  7536. */
  7537. function findLastIndex(array, predicate, fromIndex) {
  7538. var length = array == null ? 0 : array.length;
  7539. if (!length) {
  7540. return -1;
  7541. }
  7542. var index = length - 1;
  7543. if (fromIndex !== undefined) {
  7544. index = toInteger(fromIndex);
  7545. index = fromIndex < 0
  7546. ? nativeMax(length + index, 0)
  7547. : nativeMin(index, length - 1);
  7548. }
  7549. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  7550. }
  7551. /**
  7552. * Flattens `array` a single level deep.
  7553. *
  7554. * @static
  7555. * @memberOf _
  7556. * @since 0.1.0
  7557. * @category Array
  7558. * @param {Array} array The array to flatten.
  7559. * @returns {Array} Returns the new flattened array.
  7560. * @example
  7561. *
  7562. * _.flatten([1, [2, [3, [4]], 5]]);
  7563. * // => [1, 2, [3, [4]], 5]
  7564. */
  7565. function flatten(array) {
  7566. var length = array == null ? 0 : array.length;
  7567. return length ? baseFlatten(array, 1) : [];
  7568. }
  7569. /**
  7570. * Recursively flattens `array`.
  7571. *
  7572. * @static
  7573. * @memberOf _
  7574. * @since 3.0.0
  7575. * @category Array
  7576. * @param {Array} array The array to flatten.
  7577. * @returns {Array} Returns the new flattened array.
  7578. * @example
  7579. *
  7580. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  7581. * // => [1, 2, 3, 4, 5]
  7582. */
  7583. function flattenDeep(array) {
  7584. var length = array == null ? 0 : array.length;
  7585. return length ? baseFlatten(array, INFINITY) : [];
  7586. }
  7587. /**
  7588. * Recursively flatten `array` up to `depth` times.
  7589. *
  7590. * @static
  7591. * @memberOf _
  7592. * @since 4.4.0
  7593. * @category Array
  7594. * @param {Array} array The array to flatten.
  7595. * @param {number} [depth=1] The maximum recursion depth.
  7596. * @returns {Array} Returns the new flattened array.
  7597. * @example
  7598. *
  7599. * var array = [1, [2, [3, [4]], 5]];
  7600. *
  7601. * _.flattenDepth(array, 1);
  7602. * // => [1, 2, [3, [4]], 5]
  7603. *
  7604. * _.flattenDepth(array, 2);
  7605. * // => [1, 2, 3, [4], 5]
  7606. */
  7607. function flattenDepth(array, depth) {
  7608. var length = array == null ? 0 : array.length;
  7609. if (!length) {
  7610. return [];
  7611. }
  7612. depth = depth === undefined ? 1 : toInteger(depth);
  7613. return baseFlatten(array, depth);
  7614. }
  7615. /**
  7616. * The inverse of `_.toPairs`; this method returns an object composed
  7617. * from key-value `pairs`.
  7618. *
  7619. * @static
  7620. * @memberOf _
  7621. * @since 4.0.0
  7622. * @category Array
  7623. * @param {Array} pairs The key-value pairs.
  7624. * @returns {Object} Returns the new object.
  7625. * @example
  7626. *
  7627. * _.fromPairs([['a', 1], ['b', 2]]);
  7628. * // => { 'a': 1, 'b': 2 }
  7629. */
  7630. function fromPairs(pairs) {
  7631. var index = -1,
  7632. length = pairs == null ? 0 : pairs.length,
  7633. result = {};
  7634. while (++index < length) {
  7635. var pair = pairs[index];
  7636. result[pair[0]] = pair[1];
  7637. }
  7638. return result;
  7639. }
  7640. /**
  7641. * Gets the first element of `array`.
  7642. *
  7643. * @static
  7644. * @memberOf _
  7645. * @since 0.1.0
  7646. * @alias first
  7647. * @category Array
  7648. * @param {Array} array The array to query.
  7649. * @returns {*} Returns the first element of `array`.
  7650. * @example
  7651. *
  7652. * _.head([1, 2, 3]);
  7653. * // => 1
  7654. *
  7655. * _.head([]);
  7656. * // => undefined
  7657. */
  7658. function head(array) {
  7659. return (array && array.length) ? array[0] : undefined;
  7660. }
  7661. /**
  7662. * Gets the index at which the first occurrence of `value` is found in `array`
  7663. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7664. * for equality comparisons. If `fromIndex` is negative, it's used as the
  7665. * offset from the end of `array`.
  7666. *
  7667. * @static
  7668. * @memberOf _
  7669. * @since 0.1.0
  7670. * @category Array
  7671. * @param {Array} array The array to inspect.
  7672. * @param {*} value The value to search for.
  7673. * @param {number} [fromIndex=0] The index to search from.
  7674. * @returns {number} Returns the index of the matched value, else `-1`.
  7675. * @example
  7676. *
  7677. * _.indexOf([1, 2, 1, 2], 2);
  7678. * // => 1
  7679. *
  7680. * // Search from the `fromIndex`.
  7681. * _.indexOf([1, 2, 1, 2], 2, 2);
  7682. * // => 3
  7683. */
  7684. function indexOf(array, value, fromIndex) {
  7685. var length = array == null ? 0 : array.length;
  7686. if (!length) {
  7687. return -1;
  7688. }
  7689. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  7690. if (index < 0) {
  7691. index = nativeMax(length + index, 0);
  7692. }
  7693. return baseIndexOf(array, value, index);
  7694. }
  7695. /**
  7696. * Gets all but the last element of `array`.
  7697. *
  7698. * @static
  7699. * @memberOf _
  7700. * @since 0.1.0
  7701. * @category Array
  7702. * @param {Array} array The array to query.
  7703. * @returns {Array} Returns the slice of `array`.
  7704. * @example
  7705. *
  7706. * _.initial([1, 2, 3]);
  7707. * // => [1, 2]
  7708. */
  7709. function initial(array) {
  7710. var length = array == null ? 0 : array.length;
  7711. return length ? baseSlice(array, 0, -1) : [];
  7712. }
  7713. /**
  7714. * Creates an array of unique values that are included in all given arrays
  7715. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7716. * for equality comparisons. The order and references of result values are
  7717. * determined by the first array.
  7718. *
  7719. * @static
  7720. * @memberOf _
  7721. * @since 0.1.0
  7722. * @category Array
  7723. * @param {...Array} [arrays] The arrays to inspect.
  7724. * @returns {Array} Returns the new array of intersecting values.
  7725. * @example
  7726. *
  7727. * _.intersection([2, 1], [2, 3]);
  7728. * // => [2]
  7729. */
  7730. var intersection = baseRest(function(arrays) {
  7731. var mapped = arrayMap(arrays, castArrayLikeObject);
  7732. return (mapped.length && mapped[0] === arrays[0])
  7733. ? baseIntersection(mapped)
  7734. : [];
  7735. });
  7736. /**
  7737. * This method is like `_.intersection` except that it accepts `iteratee`
  7738. * which is invoked for each element of each `arrays` to generate the criterion
  7739. * by which they're compared. The order and references of result values are
  7740. * determined by the first array. The iteratee is invoked with one argument:
  7741. * (value).
  7742. *
  7743. * @static
  7744. * @memberOf _
  7745. * @since 4.0.0
  7746. * @category Array
  7747. * @param {...Array} [arrays] The arrays to inspect.
  7748. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7749. * @returns {Array} Returns the new array of intersecting values.
  7750. * @example
  7751. *
  7752. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  7753. * // => [2.1]
  7754. *
  7755. * // The `_.property` iteratee shorthand.
  7756. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  7757. * // => [{ 'x': 1 }]
  7758. */
  7759. var intersectionBy = baseRest(function(arrays) {
  7760. var iteratee = last(arrays),
  7761. mapped = arrayMap(arrays, castArrayLikeObject);
  7762. if (iteratee === last(mapped)) {
  7763. iteratee = undefined;
  7764. } else {
  7765. mapped.pop();
  7766. }
  7767. return (mapped.length && mapped[0] === arrays[0])
  7768. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  7769. : [];
  7770. });
  7771. /**
  7772. * This method is like `_.intersection` except that it accepts `comparator`
  7773. * which is invoked to compare elements of `arrays`. The order and references
  7774. * of result values are determined by the first array. The comparator is
  7775. * invoked with two arguments: (arrVal, othVal).
  7776. *
  7777. * @static
  7778. * @memberOf _
  7779. * @since 4.0.0
  7780. * @category Array
  7781. * @param {...Array} [arrays] The arrays to inspect.
  7782. * @param {Function} [comparator] The comparator invoked per element.
  7783. * @returns {Array} Returns the new array of intersecting values.
  7784. * @example
  7785. *
  7786. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  7787. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  7788. *
  7789. * _.intersectionWith(objects, others, _.isEqual);
  7790. * // => [{ 'x': 1, 'y': 2 }]
  7791. */
  7792. var intersectionWith = baseRest(function(arrays) {
  7793. var comparator = last(arrays),
  7794. mapped = arrayMap(arrays, castArrayLikeObject);
  7795. comparator = typeof comparator == 'function' ? comparator : undefined;
  7796. if (comparator) {
  7797. mapped.pop();
  7798. }
  7799. return (mapped.length && mapped[0] === arrays[0])
  7800. ? baseIntersection(mapped, undefined, comparator)
  7801. : [];
  7802. });
  7803. /**
  7804. * Converts all elements in `array` into a string separated by `separator`.
  7805. *
  7806. * @static
  7807. * @memberOf _
  7808. * @since 4.0.0
  7809. * @category Array
  7810. * @param {Array} array The array to convert.
  7811. * @param {string} [separator=','] The element separator.
  7812. * @returns {string} Returns the joined string.
  7813. * @example
  7814. *
  7815. * _.join(['a', 'b', 'c'], '~');
  7816. * // => 'a~b~c'
  7817. */
  7818. function join(array, separator) {
  7819. return array == null ? '' : nativeJoin.call(array, separator);
  7820. }
  7821. /**
  7822. * Gets the last element of `array`.
  7823. *
  7824. * @static
  7825. * @memberOf _
  7826. * @since 0.1.0
  7827. * @category Array
  7828. * @param {Array} array The array to query.
  7829. * @returns {*} Returns the last element of `array`.
  7830. * @example
  7831. *
  7832. * _.last([1, 2, 3]);
  7833. * // => 3
  7834. */
  7835. function last(array) {
  7836. var length = array == null ? 0 : array.length;
  7837. return length ? array[length - 1] : undefined;
  7838. }
  7839. /**
  7840. * This method is like `_.indexOf` except that it iterates over elements of
  7841. * `array` from right to left.
  7842. *
  7843. * @static
  7844. * @memberOf _
  7845. * @since 0.1.0
  7846. * @category Array
  7847. * @param {Array} array The array to inspect.
  7848. * @param {*} value The value to search for.
  7849. * @param {number} [fromIndex=array.length-1] The index to search from.
  7850. * @returns {number} Returns the index of the matched value, else `-1`.
  7851. * @example
  7852. *
  7853. * _.lastIndexOf([1, 2, 1, 2], 2);
  7854. * // => 3
  7855. *
  7856. * // Search from the `fromIndex`.
  7857. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  7858. * // => 1
  7859. */
  7860. function lastIndexOf(array, value, fromIndex) {
  7861. var length = array == null ? 0 : array.length;
  7862. if (!length) {
  7863. return -1;
  7864. }
  7865. var index = length;
  7866. if (fromIndex !== undefined) {
  7867. index = toInteger(fromIndex);
  7868. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  7869. }
  7870. return value === value
  7871. ? strictLastIndexOf(array, value, index)
  7872. : baseFindIndex(array, baseIsNaN, index, true);
  7873. }
  7874. /**
  7875. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  7876. * element from the end is returned.
  7877. *
  7878. * @static
  7879. * @memberOf _
  7880. * @since 4.11.0
  7881. * @category Array
  7882. * @param {Array} array The array to query.
  7883. * @param {number} [n=0] The index of the element to return.
  7884. * @returns {*} Returns the nth element of `array`.
  7885. * @example
  7886. *
  7887. * var array = ['a', 'b', 'c', 'd'];
  7888. *
  7889. * _.nth(array, 1);
  7890. * // => 'b'
  7891. *
  7892. * _.nth(array, -2);
  7893. * // => 'c';
  7894. */
  7895. function nth(array, n) {
  7896. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  7897. }
  7898. /**
  7899. * Removes all given values from `array` using
  7900. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7901. * for equality comparisons.
  7902. *
  7903. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  7904. * to remove elements from an array by predicate.
  7905. *
  7906. * @static
  7907. * @memberOf _
  7908. * @since 2.0.0
  7909. * @category Array
  7910. * @param {Array} array The array to modify.
  7911. * @param {...*} [values] The values to remove.
  7912. * @returns {Array} Returns `array`.
  7913. * @example
  7914. *
  7915. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  7916. *
  7917. * _.pull(array, 'a', 'c');
  7918. * console.log(array);
  7919. * // => ['b', 'b']
  7920. */
  7921. var pull = baseRest(pullAll);
  7922. /**
  7923. * This method is like `_.pull` except that it accepts an array of values to remove.
  7924. *
  7925. * **Note:** Unlike `_.difference`, this method mutates `array`.
  7926. *
  7927. * @static
  7928. * @memberOf _
  7929. * @since 4.0.0
  7930. * @category Array
  7931. * @param {Array} array The array to modify.
  7932. * @param {Array} values The values to remove.
  7933. * @returns {Array} Returns `array`.
  7934. * @example
  7935. *
  7936. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  7937. *
  7938. * _.pullAll(array, ['a', 'c']);
  7939. * console.log(array);
  7940. * // => ['b', 'b']
  7941. */
  7942. function pullAll(array, values) {
  7943. return (array && array.length && values && values.length)
  7944. ? basePullAll(array, values)
  7945. : array;
  7946. }
  7947. /**
  7948. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  7949. * invoked for each element of `array` and `values` to generate the criterion
  7950. * by which they're compared. The iteratee is invoked with one argument: (value).
  7951. *
  7952. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  7953. *
  7954. * @static
  7955. * @memberOf _
  7956. * @since 4.0.0
  7957. * @category Array
  7958. * @param {Array} array The array to modify.
  7959. * @param {Array} values The values to remove.
  7960. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7961. * @returns {Array} Returns `array`.
  7962. * @example
  7963. *
  7964. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  7965. *
  7966. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  7967. * console.log(array);
  7968. * // => [{ 'x': 2 }]
  7969. */
  7970. function pullAllBy(array, values, iteratee) {
  7971. return (array && array.length && values && values.length)
  7972. ? basePullAll(array, values, getIteratee(iteratee, 2))
  7973. : array;
  7974. }
  7975. /**
  7976. * This method is like `_.pullAll` except that it accepts `comparator` which
  7977. * is invoked to compare elements of `array` to `values`. The comparator is
  7978. * invoked with two arguments: (arrVal, othVal).
  7979. *
  7980. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  7981. *
  7982. * @static
  7983. * @memberOf _
  7984. * @since 4.6.0
  7985. * @category Array
  7986. * @param {Array} array The array to modify.
  7987. * @param {Array} values The values to remove.
  7988. * @param {Function} [comparator] The comparator invoked per element.
  7989. * @returns {Array} Returns `array`.
  7990. * @example
  7991. *
  7992. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  7993. *
  7994. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  7995. * console.log(array);
  7996. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  7997. */
  7998. function pullAllWith(array, values, comparator) {
  7999. return (array && array.length && values && values.length)
  8000. ? basePullAll(array, values, undefined, comparator)
  8001. : array;
  8002. }
  8003. /**
  8004. * Removes elements from `array` corresponding to `indexes` and returns an
  8005. * array of removed elements.
  8006. *
  8007. * **Note:** Unlike `_.at`, this method mutates `array`.
  8008. *
  8009. * @static
  8010. * @memberOf _
  8011. * @since 3.0.0
  8012. * @category Array
  8013. * @param {Array} array The array to modify.
  8014. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  8015. * @returns {Array} Returns the new array of removed elements.
  8016. * @example
  8017. *
  8018. * var array = ['a', 'b', 'c', 'd'];
  8019. * var pulled = _.pullAt(array, [1, 3]);
  8020. *
  8021. * console.log(array);
  8022. * // => ['a', 'c']
  8023. *
  8024. * console.log(pulled);
  8025. * // => ['b', 'd']
  8026. */
  8027. var pullAt = flatRest(function(array, indexes) {
  8028. var length = array == null ? 0 : array.length,
  8029. result = baseAt(array, indexes);
  8030. basePullAt(array, arrayMap(indexes, function(index) {
  8031. return isIndex(index, length) ? +index : index;
  8032. }).sort(compareAscending));
  8033. return result;
  8034. });
  8035. /**
  8036. * Removes all elements from `array` that `predicate` returns truthy for
  8037. * and returns an array of the removed elements. The predicate is invoked
  8038. * with three arguments: (value, index, array).
  8039. *
  8040. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  8041. * to pull elements from an array by value.
  8042. *
  8043. * @static
  8044. * @memberOf _
  8045. * @since 2.0.0
  8046. * @category Array
  8047. * @param {Array} array The array to modify.
  8048. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8049. * @returns {Array} Returns the new array of removed elements.
  8050. * @example
  8051. *
  8052. * var array = [1, 2, 3, 4];
  8053. * var evens = _.remove(array, function(n) {
  8054. * return n % 2 == 0;
  8055. * });
  8056. *
  8057. * console.log(array);
  8058. * // => [1, 3]
  8059. *
  8060. * console.log(evens);
  8061. * // => [2, 4]
  8062. */
  8063. function remove(array, predicate) {
  8064. var result = [];
  8065. if (!(array && array.length)) {
  8066. return result;
  8067. }
  8068. var index = -1,
  8069. indexes = [],
  8070. length = array.length;
  8071. predicate = getIteratee(predicate, 3);
  8072. while (++index < length) {
  8073. var value = array[index];
  8074. if (predicate(value, index, array)) {
  8075. result.push(value);
  8076. indexes.push(index);
  8077. }
  8078. }
  8079. basePullAt(array, indexes);
  8080. return result;
  8081. }
  8082. /**
  8083. * Reverses `array` so that the first element becomes the last, the second
  8084. * element becomes the second to last, and so on.
  8085. *
  8086. * **Note:** This method mutates `array` and is based on
  8087. * [`Array#reverse`](https://mdn.io/Array/reverse).
  8088. *
  8089. * @static
  8090. * @memberOf _
  8091. * @since 4.0.0
  8092. * @category Array
  8093. * @param {Array} array The array to modify.
  8094. * @returns {Array} Returns `array`.
  8095. * @example
  8096. *
  8097. * var array = [1, 2, 3];
  8098. *
  8099. * _.reverse(array);
  8100. * // => [3, 2, 1]
  8101. *
  8102. * console.log(array);
  8103. * // => [3, 2, 1]
  8104. */
  8105. function reverse(array) {
  8106. return array == null ? array : nativeReverse.call(array);
  8107. }
  8108. /**
  8109. * Creates a slice of `array` from `start` up to, but not including, `end`.
  8110. *
  8111. * **Note:** This method is used instead of
  8112. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  8113. * returned.
  8114. *
  8115. * @static
  8116. * @memberOf _
  8117. * @since 3.0.0
  8118. * @category Array
  8119. * @param {Array} array The array to slice.
  8120. * @param {number} [start=0] The start position.
  8121. * @param {number} [end=array.length] The end position.
  8122. * @returns {Array} Returns the slice of `array`.
  8123. */
  8124. function slice(array, start, end) {
  8125. var length = array == null ? 0 : array.length;
  8126. if (!length) {
  8127. return [];
  8128. }
  8129. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  8130. start = 0;
  8131. end = length;
  8132. }
  8133. else {
  8134. start = start == null ? 0 : toInteger(start);
  8135. end = end === undefined ? length : toInteger(end);
  8136. }
  8137. return baseSlice(array, start, end);
  8138. }
  8139. /**
  8140. * Uses a binary search to determine the lowest index at which `value`
  8141. * should be inserted into `array` in order to maintain its sort order.
  8142. *
  8143. * @static
  8144. * @memberOf _
  8145. * @since 0.1.0
  8146. * @category Array
  8147. * @param {Array} array The sorted array to inspect.
  8148. * @param {*} value The value to evaluate.
  8149. * @returns {number} Returns the index at which `value` should be inserted
  8150. * into `array`.
  8151. * @example
  8152. *
  8153. * _.sortedIndex([30, 50], 40);
  8154. * // => 1
  8155. */
  8156. function sortedIndex(array, value) {
  8157. return baseSortedIndex(array, value);
  8158. }
  8159. /**
  8160. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  8161. * which is invoked for `value` and each element of `array` to compute their
  8162. * sort ranking. The iteratee is invoked with one argument: (value).
  8163. *
  8164. * @static
  8165. * @memberOf _
  8166. * @since 4.0.0
  8167. * @category Array
  8168. * @param {Array} array The sorted array to inspect.
  8169. * @param {*} value The value to evaluate.
  8170. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8171. * @returns {number} Returns the index at which `value` should be inserted
  8172. * into `array`.
  8173. * @example
  8174. *
  8175. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8176. *
  8177. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8178. * // => 0
  8179. *
  8180. * // The `_.property` iteratee shorthand.
  8181. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  8182. * // => 0
  8183. */
  8184. function sortedIndexBy(array, value, iteratee) {
  8185. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  8186. }
  8187. /**
  8188. * This method is like `_.indexOf` except that it performs a binary
  8189. * search on a sorted `array`.
  8190. *
  8191. * @static
  8192. * @memberOf _
  8193. * @since 4.0.0
  8194. * @category Array
  8195. * @param {Array} array The array to inspect.
  8196. * @param {*} value The value to search for.
  8197. * @returns {number} Returns the index of the matched value, else `-1`.
  8198. * @example
  8199. *
  8200. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  8201. * // => 1
  8202. */
  8203. function sortedIndexOf(array, value) {
  8204. var length = array == null ? 0 : array.length;
  8205. if (length) {
  8206. var index = baseSortedIndex(array, value);
  8207. if (index < length && eq(array[index], value)) {
  8208. return index;
  8209. }
  8210. }
  8211. return -1;
  8212. }
  8213. /**
  8214. * This method is like `_.sortedIndex` except that it returns the highest
  8215. * index at which `value` should be inserted into `array` in order to
  8216. * maintain its sort order.
  8217. *
  8218. * @static
  8219. * @memberOf _
  8220. * @since 3.0.0
  8221. * @category Array
  8222. * @param {Array} array The sorted array to inspect.
  8223. * @param {*} value The value to evaluate.
  8224. * @returns {number} Returns the index at which `value` should be inserted
  8225. * into `array`.
  8226. * @example
  8227. *
  8228. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  8229. * // => 4
  8230. */
  8231. function sortedLastIndex(array, value) {
  8232. return baseSortedIndex(array, value, true);
  8233. }
  8234. /**
  8235. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  8236. * which is invoked for `value` and each element of `array` to compute their
  8237. * sort ranking. The iteratee is invoked with one argument: (value).
  8238. *
  8239. * @static
  8240. * @memberOf _
  8241. * @since 4.0.0
  8242. * @category Array
  8243. * @param {Array} array The sorted array to inspect.
  8244. * @param {*} value The value to evaluate.
  8245. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8246. * @returns {number} Returns the index at which `value` should be inserted
  8247. * into `array`.
  8248. * @example
  8249. *
  8250. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8251. *
  8252. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8253. * // => 1
  8254. *
  8255. * // The `_.property` iteratee shorthand.
  8256. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  8257. * // => 1
  8258. */
  8259. function sortedLastIndexBy(array, value, iteratee) {
  8260. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  8261. }
  8262. /**
  8263. * This method is like `_.lastIndexOf` except that it performs a binary
  8264. * search on a sorted `array`.
  8265. *
  8266. * @static
  8267. * @memberOf _
  8268. * @since 4.0.0
  8269. * @category Array
  8270. * @param {Array} array The array to inspect.
  8271. * @param {*} value The value to search for.
  8272. * @returns {number} Returns the index of the matched value, else `-1`.
  8273. * @example
  8274. *
  8275. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  8276. * // => 3
  8277. */
  8278. function sortedLastIndexOf(array, value) {
  8279. var length = array == null ? 0 : array.length;
  8280. if (length) {
  8281. var index = baseSortedIndex(array, value, true) - 1;
  8282. if (eq(array[index], value)) {
  8283. return index;
  8284. }
  8285. }
  8286. return -1;
  8287. }
  8288. /**
  8289. * This method is like `_.uniq` except that it's designed and optimized
  8290. * for sorted arrays.
  8291. *
  8292. * @static
  8293. * @memberOf _
  8294. * @since 4.0.0
  8295. * @category Array
  8296. * @param {Array} array The array to inspect.
  8297. * @returns {Array} Returns the new duplicate free array.
  8298. * @example
  8299. *
  8300. * _.sortedUniq([1, 1, 2]);
  8301. * // => [1, 2]
  8302. */
  8303. function sortedUniq(array) {
  8304. return (array && array.length)
  8305. ? baseSortedUniq(array)
  8306. : [];
  8307. }
  8308. /**
  8309. * This method is like `_.uniqBy` except that it's designed and optimized
  8310. * for sorted arrays.
  8311. *
  8312. * @static
  8313. * @memberOf _
  8314. * @since 4.0.0
  8315. * @category Array
  8316. * @param {Array} array The array to inspect.
  8317. * @param {Function} [iteratee] The iteratee invoked per element.
  8318. * @returns {Array} Returns the new duplicate free array.
  8319. * @example
  8320. *
  8321. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  8322. * // => [1.1, 2.3]
  8323. */
  8324. function sortedUniqBy(array, iteratee) {
  8325. return (array && array.length)
  8326. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  8327. : [];
  8328. }
  8329. /**
  8330. * Gets all but the first element of `array`.
  8331. *
  8332. * @static
  8333. * @memberOf _
  8334. * @since 4.0.0
  8335. * @category Array
  8336. * @param {Array} array The array to query.
  8337. * @returns {Array} Returns the slice of `array`.
  8338. * @example
  8339. *
  8340. * _.tail([1, 2, 3]);
  8341. * // => [2, 3]
  8342. */
  8343. function tail(array) {
  8344. var length = array == null ? 0 : array.length;
  8345. return length ? baseSlice(array, 1, length) : [];
  8346. }
  8347. /**
  8348. * Creates a slice of `array` with `n` elements taken from the beginning.
  8349. *
  8350. * @static
  8351. * @memberOf _
  8352. * @since 0.1.0
  8353. * @category Array
  8354. * @param {Array} array The array to query.
  8355. * @param {number} [n=1] The number of elements to take.
  8356. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8357. * @returns {Array} Returns the slice of `array`.
  8358. * @example
  8359. *
  8360. * _.take([1, 2, 3]);
  8361. * // => [1]
  8362. *
  8363. * _.take([1, 2, 3], 2);
  8364. * // => [1, 2]
  8365. *
  8366. * _.take([1, 2, 3], 5);
  8367. * // => [1, 2, 3]
  8368. *
  8369. * _.take([1, 2, 3], 0);
  8370. * // => []
  8371. */
  8372. function take(array, n, guard) {
  8373. if (!(array && array.length)) {
  8374. return [];
  8375. }
  8376. n = (guard || n === undefined) ? 1 : toInteger(n);
  8377. return baseSlice(array, 0, n < 0 ? 0 : n);
  8378. }
  8379. /**
  8380. * Creates a slice of `array` with `n` elements taken from the end.
  8381. *
  8382. * @static
  8383. * @memberOf _
  8384. * @since 3.0.0
  8385. * @category Array
  8386. * @param {Array} array The array to query.
  8387. * @param {number} [n=1] The number of elements to take.
  8388. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8389. * @returns {Array} Returns the slice of `array`.
  8390. * @example
  8391. *
  8392. * _.takeRight([1, 2, 3]);
  8393. * // => [3]
  8394. *
  8395. * _.takeRight([1, 2, 3], 2);
  8396. * // => [2, 3]
  8397. *
  8398. * _.takeRight([1, 2, 3], 5);
  8399. * // => [1, 2, 3]
  8400. *
  8401. * _.takeRight([1, 2, 3], 0);
  8402. * // => []
  8403. */
  8404. function takeRight(array, n, guard) {
  8405. var length = array == null ? 0 : array.length;
  8406. if (!length) {
  8407. return [];
  8408. }
  8409. n = (guard || n === undefined) ? 1 : toInteger(n);
  8410. n = length - n;
  8411. return baseSlice(array, n < 0 ? 0 : n, length);
  8412. }
  8413. /**
  8414. * Creates a slice of `array` with elements taken from the end. Elements are
  8415. * taken until `predicate` returns falsey. The predicate is invoked with
  8416. * three arguments: (value, index, array).
  8417. *
  8418. * @static
  8419. * @memberOf _
  8420. * @since 3.0.0
  8421. * @category Array
  8422. * @param {Array} array The array to query.
  8423. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8424. * @returns {Array} Returns the slice of `array`.
  8425. * @example
  8426. *
  8427. * var users = [
  8428. * { 'user': 'barney', 'active': true },
  8429. * { 'user': 'fred', 'active': false },
  8430. * { 'user': 'pebbles', 'active': false }
  8431. * ];
  8432. *
  8433. * _.takeRightWhile(users, function(o) { return !o.active; });
  8434. * // => objects for ['fred', 'pebbles']
  8435. *
  8436. * // The `_.matches` iteratee shorthand.
  8437. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  8438. * // => objects for ['pebbles']
  8439. *
  8440. * // The `_.matchesProperty` iteratee shorthand.
  8441. * _.takeRightWhile(users, ['active', false]);
  8442. * // => objects for ['fred', 'pebbles']
  8443. *
  8444. * // The `_.property` iteratee shorthand.
  8445. * _.takeRightWhile(users, 'active');
  8446. * // => []
  8447. */
  8448. function takeRightWhile(array, predicate) {
  8449. return (array && array.length)
  8450. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  8451. : [];
  8452. }
  8453. /**
  8454. * Creates a slice of `array` with elements taken from the beginning. Elements
  8455. * are taken until `predicate` returns falsey. The predicate is invoked with
  8456. * three arguments: (value, index, array).
  8457. *
  8458. * @static
  8459. * @memberOf _
  8460. * @since 3.0.0
  8461. * @category Array
  8462. * @param {Array} array The array to query.
  8463. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8464. * @returns {Array} Returns the slice of `array`.
  8465. * @example
  8466. *
  8467. * var users = [
  8468. * { 'user': 'barney', 'active': false },
  8469. * { 'user': 'fred', 'active': false },
  8470. * { 'user': 'pebbles', 'active': true }
  8471. * ];
  8472. *
  8473. * _.takeWhile(users, function(o) { return !o.active; });
  8474. * // => objects for ['barney', 'fred']
  8475. *
  8476. * // The `_.matches` iteratee shorthand.
  8477. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  8478. * // => objects for ['barney']
  8479. *
  8480. * // The `_.matchesProperty` iteratee shorthand.
  8481. * _.takeWhile(users, ['active', false]);
  8482. * // => objects for ['barney', 'fred']
  8483. *
  8484. * // The `_.property` iteratee shorthand.
  8485. * _.takeWhile(users, 'active');
  8486. * // => []
  8487. */
  8488. function takeWhile(array, predicate) {
  8489. return (array && array.length)
  8490. ? baseWhile(array, getIteratee(predicate, 3))
  8491. : [];
  8492. }
  8493. /**
  8494. * Creates an array of unique values, in order, from all given arrays using
  8495. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8496. * for equality comparisons.
  8497. *
  8498. * @static
  8499. * @memberOf _
  8500. * @since 0.1.0
  8501. * @category Array
  8502. * @param {...Array} [arrays] The arrays to inspect.
  8503. * @returns {Array} Returns the new array of combined values.
  8504. * @example
  8505. *
  8506. * _.union([2], [1, 2]);
  8507. * // => [2, 1]
  8508. */
  8509. var union = baseRest(function(arrays) {
  8510. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  8511. });
  8512. /**
  8513. * This method is like `_.union` except that it accepts `iteratee` which is
  8514. * invoked for each element of each `arrays` to generate the criterion by
  8515. * which uniqueness is computed. Result values are chosen from the first
  8516. * array in which the value occurs. The iteratee is invoked with one argument:
  8517. * (value).
  8518. *
  8519. * @static
  8520. * @memberOf _
  8521. * @since 4.0.0
  8522. * @category Array
  8523. * @param {...Array} [arrays] The arrays to inspect.
  8524. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8525. * @returns {Array} Returns the new array of combined values.
  8526. * @example
  8527. *
  8528. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  8529. * // => [2.1, 1.2]
  8530. *
  8531. * // The `_.property` iteratee shorthand.
  8532. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8533. * // => [{ 'x': 1 }, { 'x': 2 }]
  8534. */
  8535. var unionBy = baseRest(function(arrays) {
  8536. var iteratee = last(arrays);
  8537. if (isArrayLikeObject(iteratee)) {
  8538. iteratee = undefined;
  8539. }
  8540. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  8541. });
  8542. /**
  8543. * This method is like `_.union` except that it accepts `comparator` which
  8544. * is invoked to compare elements of `arrays`. Result values are chosen from
  8545. * the first array in which the value occurs. The comparator is invoked
  8546. * with two arguments: (arrVal, othVal).
  8547. *
  8548. * @static
  8549. * @memberOf _
  8550. * @since 4.0.0
  8551. * @category Array
  8552. * @param {...Array} [arrays] The arrays to inspect.
  8553. * @param {Function} [comparator] The comparator invoked per element.
  8554. * @returns {Array} Returns the new array of combined values.
  8555. * @example
  8556. *
  8557. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8558. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8559. *
  8560. * _.unionWith(objects, others, _.isEqual);
  8561. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  8562. */
  8563. var unionWith = baseRest(function(arrays) {
  8564. var comparator = last(arrays);
  8565. comparator = typeof comparator == 'function' ? comparator : undefined;
  8566. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  8567. });
  8568. /**
  8569. * Creates a duplicate-free version of an array, using
  8570. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8571. * for equality comparisons, in which only the first occurrence of each element
  8572. * is kept. The order of result values is determined by the order they occur
  8573. * in the array.
  8574. *
  8575. * @static
  8576. * @memberOf _
  8577. * @since 0.1.0
  8578. * @category Array
  8579. * @param {Array} array The array to inspect.
  8580. * @returns {Array} Returns the new duplicate free array.
  8581. * @example
  8582. *
  8583. * _.uniq([2, 1, 2]);
  8584. * // => [2, 1]
  8585. */
  8586. function uniq(array) {
  8587. return (array && array.length) ? baseUniq(array) : [];
  8588. }
  8589. /**
  8590. * This method is like `_.uniq` except that it accepts `iteratee` which is
  8591. * invoked for each element in `array` to generate the criterion by which
  8592. * uniqueness is computed. The order of result values is determined by the
  8593. * order they occur in the array. The iteratee is invoked with one argument:
  8594. * (value).
  8595. *
  8596. * @static
  8597. * @memberOf _
  8598. * @since 4.0.0
  8599. * @category Array
  8600. * @param {Array} array The array to inspect.
  8601. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8602. * @returns {Array} Returns the new duplicate free array.
  8603. * @example
  8604. *
  8605. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  8606. * // => [2.1, 1.2]
  8607. *
  8608. * // The `_.property` iteratee shorthand.
  8609. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  8610. * // => [{ 'x': 1 }, { 'x': 2 }]
  8611. */
  8612. function uniqBy(array, iteratee) {
  8613. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  8614. }
  8615. /**
  8616. * This method is like `_.uniq` except that it accepts `comparator` which
  8617. * is invoked to compare elements of `array`. The order of result values is
  8618. * determined by the order they occur in the array.The comparator is invoked
  8619. * with two arguments: (arrVal, othVal).
  8620. *
  8621. * @static
  8622. * @memberOf _
  8623. * @since 4.0.0
  8624. * @category Array
  8625. * @param {Array} array The array to inspect.
  8626. * @param {Function} [comparator] The comparator invoked per element.
  8627. * @returns {Array} Returns the new duplicate free array.
  8628. * @example
  8629. *
  8630. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8631. *
  8632. * _.uniqWith(objects, _.isEqual);
  8633. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  8634. */
  8635. function uniqWith(array, comparator) {
  8636. comparator = typeof comparator == 'function' ? comparator : undefined;
  8637. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  8638. }
  8639. /**
  8640. * This method is like `_.zip` except that it accepts an array of grouped
  8641. * elements and creates an array regrouping the elements to their pre-zip
  8642. * configuration.
  8643. *
  8644. * @static
  8645. * @memberOf _
  8646. * @since 1.2.0
  8647. * @category Array
  8648. * @param {Array} array The array of grouped elements to process.
  8649. * @returns {Array} Returns the new array of regrouped elements.
  8650. * @example
  8651. *
  8652. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  8653. * // => [['a', 1, true], ['b', 2, false]]
  8654. *
  8655. * _.unzip(zipped);
  8656. * // => [['a', 'b'], [1, 2], [true, false]]
  8657. */
  8658. function unzip(array) {
  8659. if (!(array && array.length)) {
  8660. return [];
  8661. }
  8662. var length = 0;
  8663. array = arrayFilter(array, function(group) {
  8664. if (isArrayLikeObject(group)) {
  8665. length = nativeMax(group.length, length);
  8666. return true;
  8667. }
  8668. });
  8669. return baseTimes(length, function(index) {
  8670. return arrayMap(array, baseProperty(index));
  8671. });
  8672. }
  8673. /**
  8674. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  8675. * how regrouped values should be combined. The iteratee is invoked with the
  8676. * elements of each group: (...group).
  8677. *
  8678. * @static
  8679. * @memberOf _
  8680. * @since 3.8.0
  8681. * @category Array
  8682. * @param {Array} array The array of grouped elements to process.
  8683. * @param {Function} [iteratee=_.identity] The function to combine
  8684. * regrouped values.
  8685. * @returns {Array} Returns the new array of regrouped elements.
  8686. * @example
  8687. *
  8688. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  8689. * // => [[1, 10, 100], [2, 20, 200]]
  8690. *
  8691. * _.unzipWith(zipped, _.add);
  8692. * // => [3, 30, 300]
  8693. */
  8694. function unzipWith(array, iteratee) {
  8695. if (!(array && array.length)) {
  8696. return [];
  8697. }
  8698. var result = unzip(array);
  8699. if (iteratee == null) {
  8700. return result;
  8701. }
  8702. return arrayMap(result, function(group) {
  8703. return apply(iteratee, undefined, group);
  8704. });
  8705. }
  8706. /**
  8707. * Creates an array excluding all given values using
  8708. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8709. * for equality comparisons.
  8710. *
  8711. * **Note:** Unlike `_.pull`, this method returns a new array.
  8712. *
  8713. * @static
  8714. * @memberOf _
  8715. * @since 0.1.0
  8716. * @category Array
  8717. * @param {Array} array The array to inspect.
  8718. * @param {...*} [values] The values to exclude.
  8719. * @returns {Array} Returns the new array of filtered values.
  8720. * @see _.difference, _.xor
  8721. * @example
  8722. *
  8723. * _.without([2, 1, 2, 3], 1, 2);
  8724. * // => [3]
  8725. */
  8726. var without = baseRest(function(array, values) {
  8727. return isArrayLikeObject(array)
  8728. ? baseDifference(array, values)
  8729. : [];
  8730. });
  8731. /**
  8732. * Creates an array of unique values that is the
  8733. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  8734. * of the given arrays. The order of result values is determined by the order
  8735. * they occur in the arrays.
  8736. *
  8737. * @static
  8738. * @memberOf _
  8739. * @since 2.4.0
  8740. * @category Array
  8741. * @param {...Array} [arrays] The arrays to inspect.
  8742. * @returns {Array} Returns the new array of filtered values.
  8743. * @see _.difference, _.without
  8744. * @example
  8745. *
  8746. * _.xor([2, 1], [2, 3]);
  8747. * // => [1, 3]
  8748. */
  8749. var xor = baseRest(function(arrays) {
  8750. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  8751. });
  8752. /**
  8753. * This method is like `_.xor` except that it accepts `iteratee` which is
  8754. * invoked for each element of each `arrays` to generate the criterion by
  8755. * which by which they're compared. The order of result values is determined
  8756. * by the order they occur in the arrays. The iteratee is invoked with one
  8757. * argument: (value).
  8758. *
  8759. * @static
  8760. * @memberOf _
  8761. * @since 4.0.0
  8762. * @category Array
  8763. * @param {...Array} [arrays] The arrays to inspect.
  8764. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8765. * @returns {Array} Returns the new array of filtered values.
  8766. * @example
  8767. *
  8768. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8769. * // => [1.2, 3.4]
  8770. *
  8771. * // The `_.property` iteratee shorthand.
  8772. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8773. * // => [{ 'x': 2 }]
  8774. */
  8775. var xorBy = baseRest(function(arrays) {
  8776. var iteratee = last(arrays);
  8777. if (isArrayLikeObject(iteratee)) {
  8778. iteratee = undefined;
  8779. }
  8780. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  8781. });
  8782. /**
  8783. * This method is like `_.xor` except that it accepts `comparator` which is
  8784. * invoked to compare elements of `arrays`. The order of result values is
  8785. * determined by the order they occur in the arrays. The comparator is invoked
  8786. * with two arguments: (arrVal, othVal).
  8787. *
  8788. * @static
  8789. * @memberOf _
  8790. * @since 4.0.0
  8791. * @category Array
  8792. * @param {...Array} [arrays] The arrays to inspect.
  8793. * @param {Function} [comparator] The comparator invoked per element.
  8794. * @returns {Array} Returns the new array of filtered values.
  8795. * @example
  8796. *
  8797. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8798. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8799. *
  8800. * _.xorWith(objects, others, _.isEqual);
  8801. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  8802. */
  8803. var xorWith = baseRest(function(arrays) {
  8804. var comparator = last(arrays);
  8805. comparator = typeof comparator == 'function' ? comparator : undefined;
  8806. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  8807. });
  8808. /**
  8809. * Creates an array of grouped elements, the first of which contains the
  8810. * first elements of the given arrays, the second of which contains the
  8811. * second elements of the given arrays, and so on.
  8812. *
  8813. * @static
  8814. * @memberOf _
  8815. * @since 0.1.0
  8816. * @category Array
  8817. * @param {...Array} [arrays] The arrays to process.
  8818. * @returns {Array} Returns the new array of grouped elements.
  8819. * @example
  8820. *
  8821. * _.zip(['a', 'b'], [1, 2], [true, false]);
  8822. * // => [['a', 1, true], ['b', 2, false]]
  8823. */
  8824. var zip = baseRest(unzip);
  8825. /**
  8826. * This method is like `_.fromPairs` except that it accepts two arrays,
  8827. * one of property identifiers and one of corresponding values.
  8828. *
  8829. * @static
  8830. * @memberOf _
  8831. * @since 0.4.0
  8832. * @category Array
  8833. * @param {Array} [props=[]] The property identifiers.
  8834. * @param {Array} [values=[]] The property values.
  8835. * @returns {Object} Returns the new object.
  8836. * @example
  8837. *
  8838. * _.zipObject(['a', 'b'], [1, 2]);
  8839. * // => { 'a': 1, 'b': 2 }
  8840. */
  8841. function zipObject(props, values) {
  8842. return baseZipObject(props || [], values || [], assignValue);
  8843. }
  8844. /**
  8845. * This method is like `_.zipObject` except that it supports property paths.
  8846. *
  8847. * @static
  8848. * @memberOf _
  8849. * @since 4.1.0
  8850. * @category Array
  8851. * @param {Array} [props=[]] The property identifiers.
  8852. * @param {Array} [values=[]] The property values.
  8853. * @returns {Object} Returns the new object.
  8854. * @example
  8855. *
  8856. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  8857. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  8858. */
  8859. function zipObjectDeep(props, values) {
  8860. return baseZipObject(props || [], values || [], baseSet);
  8861. }
  8862. /**
  8863. * This method is like `_.zip` except that it accepts `iteratee` to specify
  8864. * how grouped values should be combined. The iteratee is invoked with the
  8865. * elements of each group: (...group).
  8866. *
  8867. * @static
  8868. * @memberOf _
  8869. * @since 3.8.0
  8870. * @category Array
  8871. * @param {...Array} [arrays] The arrays to process.
  8872. * @param {Function} [iteratee=_.identity] The function to combine
  8873. * grouped values.
  8874. * @returns {Array} Returns the new array of grouped elements.
  8875. * @example
  8876. *
  8877. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  8878. * return a + b + c;
  8879. * });
  8880. * // => [111, 222]
  8881. */
  8882. var zipWith = baseRest(function(arrays) {
  8883. var length = arrays.length,
  8884. iteratee = length > 1 ? arrays[length - 1] : undefined;
  8885. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  8886. return unzipWith(arrays, iteratee);
  8887. });
  8888. /*------------------------------------------------------------------------*/
  8889. /**
  8890. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  8891. * chain sequences enabled. The result of such sequences must be unwrapped
  8892. * with `_#value`.
  8893. *
  8894. * @static
  8895. * @memberOf _
  8896. * @since 1.3.0
  8897. * @category Seq
  8898. * @param {*} value The value to wrap.
  8899. * @returns {Object} Returns the new `lodash` wrapper instance.
  8900. * @example
  8901. *
  8902. * var users = [
  8903. * { 'user': 'barney', 'age': 36 },
  8904. * { 'user': 'fred', 'age': 40 },
  8905. * { 'user': 'pebbles', 'age': 1 }
  8906. * ];
  8907. *
  8908. * var youngest = _
  8909. * .chain(users)
  8910. * .sortBy('age')
  8911. * .map(function(o) {
  8912. * return o.user + ' is ' + o.age;
  8913. * })
  8914. * .head()
  8915. * .value();
  8916. * // => 'pebbles is 1'
  8917. */
  8918. function chain(value) {
  8919. var result = lodash(value);
  8920. result.__chain__ = true;
  8921. return result;
  8922. }
  8923. /**
  8924. * This method invokes `interceptor` and returns `value`. The interceptor
  8925. * is invoked with one argument; (value). The purpose of this method is to
  8926. * "tap into" a method chain sequence in order to modify intermediate results.
  8927. *
  8928. * @static
  8929. * @memberOf _
  8930. * @since 0.1.0
  8931. * @category Seq
  8932. * @param {*} value The value to provide to `interceptor`.
  8933. * @param {Function} interceptor The function to invoke.
  8934. * @returns {*} Returns `value`.
  8935. * @example
  8936. *
  8937. * _([1, 2, 3])
  8938. * .tap(function(array) {
  8939. * // Mutate input array.
  8940. * array.pop();
  8941. * })
  8942. * .reverse()
  8943. * .value();
  8944. * // => [2, 1]
  8945. */
  8946. function tap(value, interceptor) {
  8947. interceptor(value);
  8948. return value;
  8949. }
  8950. /**
  8951. * This method is like `_.tap` except that it returns the result of `interceptor`.
  8952. * The purpose of this method is to "pass thru" values replacing intermediate
  8953. * results in a method chain sequence.
  8954. *
  8955. * @static
  8956. * @memberOf _
  8957. * @since 3.0.0
  8958. * @category Seq
  8959. * @param {*} value The value to provide to `interceptor`.
  8960. * @param {Function} interceptor The function to invoke.
  8961. * @returns {*} Returns the result of `interceptor`.
  8962. * @example
  8963. *
  8964. * _(' abc ')
  8965. * .chain()
  8966. * .trim()
  8967. * .thru(function(value) {
  8968. * return [value];
  8969. * })
  8970. * .value();
  8971. * // => ['abc']
  8972. */
  8973. function thru(value, interceptor) {
  8974. return interceptor(value);
  8975. }
  8976. /**
  8977. * This method is the wrapper version of `_.at`.
  8978. *
  8979. * @name at
  8980. * @memberOf _
  8981. * @since 1.0.0
  8982. * @category Seq
  8983. * @param {...(string|string[])} [paths] The property paths to pick.
  8984. * @returns {Object} Returns the new `lodash` wrapper instance.
  8985. * @example
  8986. *
  8987. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  8988. *
  8989. * _(object).at(['a[0].b.c', 'a[1]']).value();
  8990. * // => [3, 4]
  8991. */
  8992. var wrapperAt = flatRest(function(paths) {
  8993. var length = paths.length,
  8994. start = length ? paths[0] : 0,
  8995. value = this.__wrapped__,
  8996. interceptor = function(object) { return baseAt(object, paths); };
  8997. if (length > 1 || this.__actions__.length ||
  8998. !(value instanceof LazyWrapper) || !isIndex(start)) {
  8999. return this.thru(interceptor);
  9000. }
  9001. value = value.slice(start, +start + (length ? 1 : 0));
  9002. value.__actions__.push({
  9003. 'func': thru,
  9004. 'args': [interceptor],
  9005. 'thisArg': undefined
  9006. });
  9007. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  9008. if (length && !array.length) {
  9009. array.push(undefined);
  9010. }
  9011. return array;
  9012. });
  9013. });
  9014. /**
  9015. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  9016. *
  9017. * @name chain
  9018. * @memberOf _
  9019. * @since 0.1.0
  9020. * @category Seq
  9021. * @returns {Object} Returns the new `lodash` wrapper instance.
  9022. * @example
  9023. *
  9024. * var users = [
  9025. * { 'user': 'barney', 'age': 36 },
  9026. * { 'user': 'fred', 'age': 40 }
  9027. * ];
  9028. *
  9029. * // A sequence without explicit chaining.
  9030. * _(users).head();
  9031. * // => { 'user': 'barney', 'age': 36 }
  9032. *
  9033. * // A sequence with explicit chaining.
  9034. * _(users)
  9035. * .chain()
  9036. * .head()
  9037. * .pick('user')
  9038. * .value();
  9039. * // => { 'user': 'barney' }
  9040. */
  9041. function wrapperChain() {
  9042. return chain(this);
  9043. }
  9044. /**
  9045. * Executes the chain sequence and returns the wrapped result.
  9046. *
  9047. * @name commit
  9048. * @memberOf _
  9049. * @since 3.2.0
  9050. * @category Seq
  9051. * @returns {Object} Returns the new `lodash` wrapper instance.
  9052. * @example
  9053. *
  9054. * var array = [1, 2];
  9055. * var wrapped = _(array).push(3);
  9056. *
  9057. * console.log(array);
  9058. * // => [1, 2]
  9059. *
  9060. * wrapped = wrapped.commit();
  9061. * console.log(array);
  9062. * // => [1, 2, 3]
  9063. *
  9064. * wrapped.last();
  9065. * // => 3
  9066. *
  9067. * console.log(array);
  9068. * // => [1, 2, 3]
  9069. */
  9070. function wrapperCommit() {
  9071. return new LodashWrapper(this.value(), this.__chain__);
  9072. }
  9073. /**
  9074. * Gets the next value on a wrapped object following the
  9075. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  9076. *
  9077. * @name next
  9078. * @memberOf _
  9079. * @since 4.0.0
  9080. * @category Seq
  9081. * @returns {Object} Returns the next iterator value.
  9082. * @example
  9083. *
  9084. * var wrapped = _([1, 2]);
  9085. *
  9086. * wrapped.next();
  9087. * // => { 'done': false, 'value': 1 }
  9088. *
  9089. * wrapped.next();
  9090. * // => { 'done': false, 'value': 2 }
  9091. *
  9092. * wrapped.next();
  9093. * // => { 'done': true, 'value': undefined }
  9094. */
  9095. function wrapperNext() {
  9096. if (this.__values__ === undefined) {
  9097. this.__values__ = toArray(this.value());
  9098. }
  9099. var done = this.__index__ >= this.__values__.length,
  9100. value = done ? undefined : this.__values__[this.__index__++];
  9101. return { 'done': done, 'value': value };
  9102. }
  9103. /**
  9104. * Enables the wrapper to be iterable.
  9105. *
  9106. * @name Symbol.iterator
  9107. * @memberOf _
  9108. * @since 4.0.0
  9109. * @category Seq
  9110. * @returns {Object} Returns the wrapper object.
  9111. * @example
  9112. *
  9113. * var wrapped = _([1, 2]);
  9114. *
  9115. * wrapped[Symbol.iterator]() === wrapped;
  9116. * // => true
  9117. *
  9118. * Array.from(wrapped);
  9119. * // => [1, 2]
  9120. */
  9121. function wrapperToIterator() {
  9122. return this;
  9123. }
  9124. /**
  9125. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  9126. *
  9127. * @name plant
  9128. * @memberOf _
  9129. * @since 3.2.0
  9130. * @category Seq
  9131. * @param {*} value The value to plant.
  9132. * @returns {Object} Returns the new `lodash` wrapper instance.
  9133. * @example
  9134. *
  9135. * function square(n) {
  9136. * return n * n;
  9137. * }
  9138. *
  9139. * var wrapped = _([1, 2]).map(square);
  9140. * var other = wrapped.plant([3, 4]);
  9141. *
  9142. * other.value();
  9143. * // => [9, 16]
  9144. *
  9145. * wrapped.value();
  9146. * // => [1, 4]
  9147. */
  9148. function wrapperPlant(value) {
  9149. var result,
  9150. parent = this;
  9151. while (parent instanceof baseLodash) {
  9152. var clone = wrapperClone(parent);
  9153. clone.__index__ = 0;
  9154. clone.__values__ = undefined;
  9155. if (result) {
  9156. previous.__wrapped__ = clone;
  9157. } else {
  9158. result = clone;
  9159. }
  9160. var previous = clone;
  9161. parent = parent.__wrapped__;
  9162. }
  9163. previous.__wrapped__ = value;
  9164. return result;
  9165. }
  9166. /**
  9167. * This method is the wrapper version of `_.reverse`.
  9168. *
  9169. * **Note:** This method mutates the wrapped array.
  9170. *
  9171. * @name reverse
  9172. * @memberOf _
  9173. * @since 0.1.0
  9174. * @category Seq
  9175. * @returns {Object} Returns the new `lodash` wrapper instance.
  9176. * @example
  9177. *
  9178. * var array = [1, 2, 3];
  9179. *
  9180. * _(array).reverse().value()
  9181. * // => [3, 2, 1]
  9182. *
  9183. * console.log(array);
  9184. * // => [3, 2, 1]
  9185. */
  9186. function wrapperReverse() {
  9187. var value = this.__wrapped__;
  9188. if (value instanceof LazyWrapper) {
  9189. var wrapped = value;
  9190. if (this.__actions__.length) {
  9191. wrapped = new LazyWrapper(this);
  9192. }
  9193. wrapped = wrapped.reverse();
  9194. wrapped.__actions__.push({
  9195. 'func': thru,
  9196. 'args': [reverse],
  9197. 'thisArg': undefined
  9198. });
  9199. return new LodashWrapper(wrapped, this.__chain__);
  9200. }
  9201. return this.thru(reverse);
  9202. }
  9203. /**
  9204. * Executes the chain sequence to resolve the unwrapped value.
  9205. *
  9206. * @name value
  9207. * @memberOf _
  9208. * @since 0.1.0
  9209. * @alias toJSON, valueOf
  9210. * @category Seq
  9211. * @returns {*} Returns the resolved unwrapped value.
  9212. * @example
  9213. *
  9214. * _([1, 2, 3]).value();
  9215. * // => [1, 2, 3]
  9216. */
  9217. function wrapperValue() {
  9218. return baseWrapperValue(this.__wrapped__, this.__actions__);
  9219. }
  9220. /*------------------------------------------------------------------------*/
  9221. /**
  9222. * Creates an object composed of keys generated from the results of running
  9223. * each element of `collection` thru `iteratee`. The corresponding value of
  9224. * each key is the number of times the key was returned by `iteratee`. The
  9225. * iteratee is invoked with one argument: (value).
  9226. *
  9227. * @static
  9228. * @memberOf _
  9229. * @since 0.5.0
  9230. * @category Collection
  9231. * @param {Array|Object} collection The collection to iterate over.
  9232. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9233. * @returns {Object} Returns the composed aggregate object.
  9234. * @example
  9235. *
  9236. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  9237. * // => { '4': 1, '6': 2 }
  9238. *
  9239. * // The `_.property` iteratee shorthand.
  9240. * _.countBy(['one', 'two', 'three'], 'length');
  9241. * // => { '3': 2, '5': 1 }
  9242. */
  9243. var countBy = createAggregator(function(result, value, key) {
  9244. if (hasOwnProperty.call(result, key)) {
  9245. ++result[key];
  9246. } else {
  9247. baseAssignValue(result, key, 1);
  9248. }
  9249. });
  9250. /**
  9251. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  9252. * Iteration is stopped once `predicate` returns falsey. The predicate is
  9253. * invoked with three arguments: (value, index|key, collection).
  9254. *
  9255. * **Note:** This method returns `true` for
  9256. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  9257. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  9258. * elements of empty collections.
  9259. *
  9260. * @static
  9261. * @memberOf _
  9262. * @since 0.1.0
  9263. * @category Collection
  9264. * @param {Array|Object} collection The collection to iterate over.
  9265. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9266. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9267. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  9268. * else `false`.
  9269. * @example
  9270. *
  9271. * _.every([true, 1, null, 'yes'], Boolean);
  9272. * // => false
  9273. *
  9274. * var users = [
  9275. * { 'user': 'barney', 'age': 36, 'active': false },
  9276. * { 'user': 'fred', 'age': 40, 'active': false }
  9277. * ];
  9278. *
  9279. * // The `_.matches` iteratee shorthand.
  9280. * _.every(users, { 'user': 'barney', 'active': false });
  9281. * // => false
  9282. *
  9283. * // The `_.matchesProperty` iteratee shorthand.
  9284. * _.every(users, ['active', false]);
  9285. * // => true
  9286. *
  9287. * // The `_.property` iteratee shorthand.
  9288. * _.every(users, 'active');
  9289. * // => false
  9290. */
  9291. function every(collection, predicate, guard) {
  9292. var func = isArray(collection) ? arrayEvery : baseEvery;
  9293. if (guard && isIterateeCall(collection, predicate, guard)) {
  9294. predicate = undefined;
  9295. }
  9296. return func(collection, getIteratee(predicate, 3));
  9297. }
  9298. /**
  9299. * Iterates over elements of `collection`, returning an array of all elements
  9300. * `predicate` returns truthy for. The predicate is invoked with three
  9301. * arguments: (value, index|key, collection).
  9302. *
  9303. * **Note:** Unlike `_.remove`, this method returns a new array.
  9304. *
  9305. * @static
  9306. * @memberOf _
  9307. * @since 0.1.0
  9308. * @category Collection
  9309. * @param {Array|Object} collection The collection to iterate over.
  9310. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9311. * @returns {Array} Returns the new filtered array.
  9312. * @see _.reject
  9313. * @example
  9314. *
  9315. * var users = [
  9316. * { 'user': 'barney', 'age': 36, 'active': true },
  9317. * { 'user': 'fred', 'age': 40, 'active': false }
  9318. * ];
  9319. *
  9320. * _.filter(users, function(o) { return !o.active; });
  9321. * // => objects for ['fred']
  9322. *
  9323. * // The `_.matches` iteratee shorthand.
  9324. * _.filter(users, { 'age': 36, 'active': true });
  9325. * // => objects for ['barney']
  9326. *
  9327. * // The `_.matchesProperty` iteratee shorthand.
  9328. * _.filter(users, ['active', false]);
  9329. * // => objects for ['fred']
  9330. *
  9331. * // The `_.property` iteratee shorthand.
  9332. * _.filter(users, 'active');
  9333. * // => objects for ['barney']
  9334. */
  9335. function filter(collection, predicate) {
  9336. var func = isArray(collection) ? arrayFilter : baseFilter;
  9337. return func(collection, getIteratee(predicate, 3));
  9338. }
  9339. /**
  9340. * Iterates over elements of `collection`, returning the first element
  9341. * `predicate` returns truthy for. The predicate is invoked with three
  9342. * arguments: (value, index|key, collection).
  9343. *
  9344. * @static
  9345. * @memberOf _
  9346. * @since 0.1.0
  9347. * @category Collection
  9348. * @param {Array|Object} collection The collection to inspect.
  9349. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9350. * @param {number} [fromIndex=0] The index to search from.
  9351. * @returns {*} Returns the matched element, else `undefined`.
  9352. * @example
  9353. *
  9354. * var users = [
  9355. * { 'user': 'barney', 'age': 36, 'active': true },
  9356. * { 'user': 'fred', 'age': 40, 'active': false },
  9357. * { 'user': 'pebbles', 'age': 1, 'active': true }
  9358. * ];
  9359. *
  9360. * _.find(users, function(o) { return o.age < 40; });
  9361. * // => object for 'barney'
  9362. *
  9363. * // The `_.matches` iteratee shorthand.
  9364. * _.find(users, { 'age': 1, 'active': true });
  9365. * // => object for 'pebbles'
  9366. *
  9367. * // The `_.matchesProperty` iteratee shorthand.
  9368. * _.find(users, ['active', false]);
  9369. * // => object for 'fred'
  9370. *
  9371. * // The `_.property` iteratee shorthand.
  9372. * _.find(users, 'active');
  9373. * // => object for 'barney'
  9374. */
  9375. var find = createFind(findIndex);
  9376. /**
  9377. * This method is like `_.find` except that it iterates over elements of
  9378. * `collection` from right to left.
  9379. *
  9380. * @static
  9381. * @memberOf _
  9382. * @since 2.0.0
  9383. * @category Collection
  9384. * @param {Array|Object} collection The collection to inspect.
  9385. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9386. * @param {number} [fromIndex=collection.length-1] The index to search from.
  9387. * @returns {*} Returns the matched element, else `undefined`.
  9388. * @example
  9389. *
  9390. * _.findLast([1, 2, 3, 4], function(n) {
  9391. * return n % 2 == 1;
  9392. * });
  9393. * // => 3
  9394. */
  9395. var findLast = createFind(findLastIndex);
  9396. /**
  9397. * Creates a flattened array of values by running each element in `collection`
  9398. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  9399. * with three arguments: (value, index|key, collection).
  9400. *
  9401. * @static
  9402. * @memberOf _
  9403. * @since 4.0.0
  9404. * @category Collection
  9405. * @param {Array|Object} collection The collection to iterate over.
  9406. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9407. * @returns {Array} Returns the new flattened array.
  9408. * @example
  9409. *
  9410. * function duplicate(n) {
  9411. * return [n, n];
  9412. * }
  9413. *
  9414. * _.flatMap([1, 2], duplicate);
  9415. * // => [1, 1, 2, 2]
  9416. */
  9417. function flatMap(collection, iteratee) {
  9418. return baseFlatten(map(collection, iteratee), 1);
  9419. }
  9420. /**
  9421. * This method is like `_.flatMap` except that it recursively flattens the
  9422. * mapped results.
  9423. *
  9424. * @static
  9425. * @memberOf _
  9426. * @since 4.7.0
  9427. * @category Collection
  9428. * @param {Array|Object} collection The collection to iterate over.
  9429. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9430. * @returns {Array} Returns the new flattened array.
  9431. * @example
  9432. *
  9433. * function duplicate(n) {
  9434. * return [[[n, n]]];
  9435. * }
  9436. *
  9437. * _.flatMapDeep([1, 2], duplicate);
  9438. * // => [1, 1, 2, 2]
  9439. */
  9440. function flatMapDeep(collection, iteratee) {
  9441. return baseFlatten(map(collection, iteratee), INFINITY);
  9442. }
  9443. /**
  9444. * This method is like `_.flatMap` except that it recursively flattens the
  9445. * mapped results up to `depth` times.
  9446. *
  9447. * @static
  9448. * @memberOf _
  9449. * @since 4.7.0
  9450. * @category Collection
  9451. * @param {Array|Object} collection The collection to iterate over.
  9452. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9453. * @param {number} [depth=1] The maximum recursion depth.
  9454. * @returns {Array} Returns the new flattened array.
  9455. * @example
  9456. *
  9457. * function duplicate(n) {
  9458. * return [[[n, n]]];
  9459. * }
  9460. *
  9461. * _.flatMapDepth([1, 2], duplicate, 2);
  9462. * // => [[1, 1], [2, 2]]
  9463. */
  9464. function flatMapDepth(collection, iteratee, depth) {
  9465. depth = depth === undefined ? 1 : toInteger(depth);
  9466. return baseFlatten(map(collection, iteratee), depth);
  9467. }
  9468. /**
  9469. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  9470. * The iteratee is invoked with three arguments: (value, index|key, collection).
  9471. * Iteratee functions may exit iteration early by explicitly returning `false`.
  9472. *
  9473. * **Note:** As with other "Collections" methods, objects with a "length"
  9474. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  9475. * or `_.forOwn` for object iteration.
  9476. *
  9477. * @static
  9478. * @memberOf _
  9479. * @since 0.1.0
  9480. * @alias each
  9481. * @category Collection
  9482. * @param {Array|Object} collection The collection to iterate over.
  9483. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9484. * @returns {Array|Object} Returns `collection`.
  9485. * @see _.forEachRight
  9486. * @example
  9487. *
  9488. * _.forEach([1, 2], function(value) {
  9489. * console.log(value);
  9490. * });
  9491. * // => Logs `1` then `2`.
  9492. *
  9493. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  9494. * console.log(key);
  9495. * });
  9496. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  9497. */
  9498. function forEach(collection, iteratee) {
  9499. var func = isArray(collection) ? arrayEach : baseEach;
  9500. return func(collection, getIteratee(iteratee, 3));
  9501. }
  9502. /**
  9503. * This method is like `_.forEach` except that it iterates over elements of
  9504. * `collection` from right to left.
  9505. *
  9506. * @static
  9507. * @memberOf _
  9508. * @since 2.0.0
  9509. * @alias eachRight
  9510. * @category Collection
  9511. * @param {Array|Object} collection The collection to iterate over.
  9512. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9513. * @returns {Array|Object} Returns `collection`.
  9514. * @see _.forEach
  9515. * @example
  9516. *
  9517. * _.forEachRight([1, 2], function(value) {
  9518. * console.log(value);
  9519. * });
  9520. * // => Logs `2` then `1`.
  9521. */
  9522. function forEachRight(collection, iteratee) {
  9523. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  9524. return func(collection, getIteratee(iteratee, 3));
  9525. }
  9526. /**
  9527. * Creates an object composed of keys generated from the results of running
  9528. * each element of `collection` thru `iteratee`. The order of grouped values
  9529. * is determined by the order they occur in `collection`. The corresponding
  9530. * value of each key is an array of elements responsible for generating the
  9531. * key. The iteratee is invoked with one argument: (value).
  9532. *
  9533. * @static
  9534. * @memberOf _
  9535. * @since 0.1.0
  9536. * @category Collection
  9537. * @param {Array|Object} collection The collection to iterate over.
  9538. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9539. * @returns {Object} Returns the composed aggregate object.
  9540. * @example
  9541. *
  9542. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  9543. * // => { '4': [4.2], '6': [6.1, 6.3] }
  9544. *
  9545. * // The `_.property` iteratee shorthand.
  9546. * _.groupBy(['one', 'two', 'three'], 'length');
  9547. * // => { '3': ['one', 'two'], '5': ['three'] }
  9548. */
  9549. var groupBy = createAggregator(function(result, value, key) {
  9550. if (hasOwnProperty.call(result, key)) {
  9551. result[key].push(value);
  9552. } else {
  9553. baseAssignValue(result, key, [value]);
  9554. }
  9555. });
  9556. /**
  9557. * Checks if `value` is in `collection`. If `collection` is a string, it's
  9558. * checked for a substring of `value`, otherwise
  9559. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9560. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  9561. * the offset from the end of `collection`.
  9562. *
  9563. * @static
  9564. * @memberOf _
  9565. * @since 0.1.0
  9566. * @category Collection
  9567. * @param {Array|Object|string} collection The collection to inspect.
  9568. * @param {*} value The value to search for.
  9569. * @param {number} [fromIndex=0] The index to search from.
  9570. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  9571. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  9572. * @example
  9573. *
  9574. * _.includes([1, 2, 3], 1);
  9575. * // => true
  9576. *
  9577. * _.includes([1, 2, 3], 1, 2);
  9578. * // => false
  9579. *
  9580. * _.includes({ 'a': 1, 'b': 2 }, 1);
  9581. * // => true
  9582. *
  9583. * _.includes('abcd', 'bc');
  9584. * // => true
  9585. */
  9586. function includes(collection, value, fromIndex, guard) {
  9587. collection = isArrayLike(collection) ? collection : values(collection);
  9588. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  9589. var length = collection.length;
  9590. if (fromIndex < 0) {
  9591. fromIndex = nativeMax(length + fromIndex, 0);
  9592. }
  9593. return isString(collection)
  9594. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  9595. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  9596. }
  9597. /**
  9598. * Invokes the method at `path` of each element in `collection`, returning
  9599. * an array of the results of each invoked method. Any additional arguments
  9600. * are provided to each invoked method. If `path` is a function, it's invoked
  9601. * for, and `this` bound to, each element in `collection`.
  9602. *
  9603. * @static
  9604. * @memberOf _
  9605. * @since 4.0.0
  9606. * @category Collection
  9607. * @param {Array|Object} collection The collection to iterate over.
  9608. * @param {Array|Function|string} path The path of the method to invoke or
  9609. * the function invoked per iteration.
  9610. * @param {...*} [args] The arguments to invoke each method with.
  9611. * @returns {Array} Returns the array of results.
  9612. * @example
  9613. *
  9614. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  9615. * // => [[1, 5, 7], [1, 2, 3]]
  9616. *
  9617. * _.invokeMap([123, 456], String.prototype.split, '');
  9618. * // => [['1', '2', '3'], ['4', '5', '6']]
  9619. */
  9620. var invokeMap = baseRest(function(collection, path, args) {
  9621. var index = -1,
  9622. isFunc = typeof path == 'function',
  9623. result = isArrayLike(collection) ? Array(collection.length) : [];
  9624. baseEach(collection, function(value) {
  9625. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  9626. });
  9627. return result;
  9628. });
  9629. /**
  9630. * Creates an object composed of keys generated from the results of running
  9631. * each element of `collection` thru `iteratee`. The corresponding value of
  9632. * each key is the last element responsible for generating the key. The
  9633. * iteratee is invoked with one argument: (value).
  9634. *
  9635. * @static
  9636. * @memberOf _
  9637. * @since 4.0.0
  9638. * @category Collection
  9639. * @param {Array|Object} collection The collection to iterate over.
  9640. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9641. * @returns {Object} Returns the composed aggregate object.
  9642. * @example
  9643. *
  9644. * var array = [
  9645. * { 'dir': 'left', 'code': 97 },
  9646. * { 'dir': 'right', 'code': 100 }
  9647. * ];
  9648. *
  9649. * _.keyBy(array, function(o) {
  9650. * return String.fromCharCode(o.code);
  9651. * });
  9652. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  9653. *
  9654. * _.keyBy(array, 'dir');
  9655. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  9656. */
  9657. var keyBy = createAggregator(function(result, value, key) {
  9658. baseAssignValue(result, key, value);
  9659. });
  9660. /**
  9661. * Creates an array of values by running each element in `collection` thru
  9662. * `iteratee`. The iteratee is invoked with three arguments:
  9663. * (value, index|key, collection).
  9664. *
  9665. * Many lodash methods are guarded to work as iteratees for methods like
  9666. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  9667. *
  9668. * The guarded methods are:
  9669. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  9670. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  9671. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  9672. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  9673. *
  9674. * @static
  9675. * @memberOf _
  9676. * @since 0.1.0
  9677. * @category Collection
  9678. * @param {Array|Object} collection The collection to iterate over.
  9679. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9680. * @returns {Array} Returns the new mapped array.
  9681. * @example
  9682. *
  9683. * function square(n) {
  9684. * return n * n;
  9685. * }
  9686. *
  9687. * _.map([4, 8], square);
  9688. * // => [16, 64]
  9689. *
  9690. * _.map({ 'a': 4, 'b': 8 }, square);
  9691. * // => [16, 64] (iteration order is not guaranteed)
  9692. *
  9693. * var users = [
  9694. * { 'user': 'barney' },
  9695. * { 'user': 'fred' }
  9696. * ];
  9697. *
  9698. * // The `_.property` iteratee shorthand.
  9699. * _.map(users, 'user');
  9700. * // => ['barney', 'fred']
  9701. */
  9702. function map(collection, iteratee) {
  9703. var func = isArray(collection) ? arrayMap : baseMap;
  9704. return func(collection, getIteratee(iteratee, 3));
  9705. }
  9706. /**
  9707. * This method is like `_.sortBy` except that it allows specifying the sort
  9708. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  9709. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  9710. * descending or "asc" for ascending sort order of corresponding values.
  9711. *
  9712. * @static
  9713. * @memberOf _
  9714. * @since 4.0.0
  9715. * @category Collection
  9716. * @param {Array|Object} collection The collection to iterate over.
  9717. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  9718. * The iteratees to sort by.
  9719. * @param {string[]} [orders] The sort orders of `iteratees`.
  9720. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  9721. * @returns {Array} Returns the new sorted array.
  9722. * @example
  9723. *
  9724. * var users = [
  9725. * { 'user': 'fred', 'age': 48 },
  9726. * { 'user': 'barney', 'age': 34 },
  9727. * { 'user': 'fred', 'age': 40 },
  9728. * { 'user': 'barney', 'age': 36 }
  9729. * ];
  9730. *
  9731. * // Sort by `user` in ascending order and by `age` in descending order.
  9732. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  9733. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  9734. */
  9735. function orderBy(collection, iteratees, orders, guard) {
  9736. if (collection == null) {
  9737. return [];
  9738. }
  9739. if (!isArray(iteratees)) {
  9740. iteratees = iteratees == null ? [] : [iteratees];
  9741. }
  9742. orders = guard ? undefined : orders;
  9743. if (!isArray(orders)) {
  9744. orders = orders == null ? [] : [orders];
  9745. }
  9746. return baseOrderBy(collection, iteratees, orders);
  9747. }
  9748. /**
  9749. * Creates an array of elements split into two groups, the first of which
  9750. * contains elements `predicate` returns truthy for, the second of which
  9751. * contains elements `predicate` returns falsey for. The predicate is
  9752. * invoked with one argument: (value).
  9753. *
  9754. * @static
  9755. * @memberOf _
  9756. * @since 3.0.0
  9757. * @category Collection
  9758. * @param {Array|Object} collection The collection to iterate over.
  9759. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9760. * @returns {Array} Returns the array of grouped elements.
  9761. * @example
  9762. *
  9763. * var users = [
  9764. * { 'user': 'barney', 'age': 36, 'active': false },
  9765. * { 'user': 'fred', 'age': 40, 'active': true },
  9766. * { 'user': 'pebbles', 'age': 1, 'active': false }
  9767. * ];
  9768. *
  9769. * _.partition(users, function(o) { return o.active; });
  9770. * // => objects for [['fred'], ['barney', 'pebbles']]
  9771. *
  9772. * // The `_.matches` iteratee shorthand.
  9773. * _.partition(users, { 'age': 1, 'active': false });
  9774. * // => objects for [['pebbles'], ['barney', 'fred']]
  9775. *
  9776. * // The `_.matchesProperty` iteratee shorthand.
  9777. * _.partition(users, ['active', false]);
  9778. * // => objects for [['barney', 'pebbles'], ['fred']]
  9779. *
  9780. * // The `_.property` iteratee shorthand.
  9781. * _.partition(users, 'active');
  9782. * // => objects for [['fred'], ['barney', 'pebbles']]
  9783. */
  9784. var partition = createAggregator(function(result, value, key) {
  9785. result[key ? 0 : 1].push(value);
  9786. }, function() { return [[], []]; });
  9787. /**
  9788. * Reduces `collection` to a value which is the accumulated result of running
  9789. * each element in `collection` thru `iteratee`, where each successive
  9790. * invocation is supplied the return value of the previous. If `accumulator`
  9791. * is not given, the first element of `collection` is used as the initial
  9792. * value. The iteratee is invoked with four arguments:
  9793. * (accumulator, value, index|key, collection).
  9794. *
  9795. * Many lodash methods are guarded to work as iteratees for methods like
  9796. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  9797. *
  9798. * The guarded methods are:
  9799. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  9800. * and `sortBy`
  9801. *
  9802. * @static
  9803. * @memberOf _
  9804. * @since 0.1.0
  9805. * @category Collection
  9806. * @param {Array|Object} collection The collection to iterate over.
  9807. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9808. * @param {*} [accumulator] The initial value.
  9809. * @returns {*} Returns the accumulated value.
  9810. * @see _.reduceRight
  9811. * @example
  9812. *
  9813. * _.reduce([1, 2], function(sum, n) {
  9814. * return sum + n;
  9815. * }, 0);
  9816. * // => 3
  9817. *
  9818. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  9819. * (result[value] || (result[value] = [])).push(key);
  9820. * return result;
  9821. * }, {});
  9822. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  9823. */
  9824. function reduce(collection, iteratee, accumulator) {
  9825. var func = isArray(collection) ? arrayReduce : baseReduce,
  9826. initAccum = arguments.length < 3;
  9827. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  9828. }
  9829. /**
  9830. * This method is like `_.reduce` except that it iterates over elements of
  9831. * `collection` from right to left.
  9832. *
  9833. * @static
  9834. * @memberOf _
  9835. * @since 0.1.0
  9836. * @category Collection
  9837. * @param {Array|Object} collection The collection to iterate over.
  9838. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9839. * @param {*} [accumulator] The initial value.
  9840. * @returns {*} Returns the accumulated value.
  9841. * @see _.reduce
  9842. * @example
  9843. *
  9844. * var array = [[0, 1], [2, 3], [4, 5]];
  9845. *
  9846. * _.reduceRight(array, function(flattened, other) {
  9847. * return flattened.concat(other);
  9848. * }, []);
  9849. * // => [4, 5, 2, 3, 0, 1]
  9850. */
  9851. function reduceRight(collection, iteratee, accumulator) {
  9852. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  9853. initAccum = arguments.length < 3;
  9854. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  9855. }
  9856. /**
  9857. * The opposite of `_.filter`; this method returns the elements of `collection`
  9858. * that `predicate` does **not** return truthy for.
  9859. *
  9860. * @static
  9861. * @memberOf _
  9862. * @since 0.1.0
  9863. * @category Collection
  9864. * @param {Array|Object} collection The collection to iterate over.
  9865. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9866. * @returns {Array} Returns the new filtered array.
  9867. * @see _.filter
  9868. * @example
  9869. *
  9870. * var users = [
  9871. * { 'user': 'barney', 'age': 36, 'active': false },
  9872. * { 'user': 'fred', 'age': 40, 'active': true }
  9873. * ];
  9874. *
  9875. * _.reject(users, function(o) { return !o.active; });
  9876. * // => objects for ['fred']
  9877. *
  9878. * // The `_.matches` iteratee shorthand.
  9879. * _.reject(users, { 'age': 40, 'active': true });
  9880. * // => objects for ['barney']
  9881. *
  9882. * // The `_.matchesProperty` iteratee shorthand.
  9883. * _.reject(users, ['active', false]);
  9884. * // => objects for ['fred']
  9885. *
  9886. * // The `_.property` iteratee shorthand.
  9887. * _.reject(users, 'active');
  9888. * // => objects for ['barney']
  9889. */
  9890. function reject(collection, predicate) {
  9891. var func = isArray(collection) ? arrayFilter : baseFilter;
  9892. return func(collection, negate(getIteratee(predicate, 3)));
  9893. }
  9894. /**
  9895. * Gets a random element from `collection`.
  9896. *
  9897. * @static
  9898. * @memberOf _
  9899. * @since 2.0.0
  9900. * @category Collection
  9901. * @param {Array|Object} collection The collection to sample.
  9902. * @returns {*} Returns the random element.
  9903. * @example
  9904. *
  9905. * _.sample([1, 2, 3, 4]);
  9906. * // => 2
  9907. */
  9908. function sample(collection) {
  9909. var func = isArray(collection) ? arraySample : baseSample;
  9910. return func(collection);
  9911. }
  9912. /**
  9913. * Gets `n` random elements at unique keys from `collection` up to the
  9914. * size of `collection`.
  9915. *
  9916. * @static
  9917. * @memberOf _
  9918. * @since 4.0.0
  9919. * @category Collection
  9920. * @param {Array|Object} collection The collection to sample.
  9921. * @param {number} [n=1] The number of elements to sample.
  9922. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9923. * @returns {Array} Returns the random elements.
  9924. * @example
  9925. *
  9926. * _.sampleSize([1, 2, 3], 2);
  9927. * // => [3, 1]
  9928. *
  9929. * _.sampleSize([1, 2, 3], 4);
  9930. * // => [2, 3, 1]
  9931. */
  9932. function sampleSize(collection, n, guard) {
  9933. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  9934. n = 1;
  9935. } else {
  9936. n = toInteger(n);
  9937. }
  9938. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  9939. return func(collection, n);
  9940. }
  9941. /**
  9942. * Creates an array of shuffled values, using a version of the
  9943. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  9944. *
  9945. * @static
  9946. * @memberOf _
  9947. * @since 0.1.0
  9948. * @category Collection
  9949. * @param {Array|Object} collection The collection to shuffle.
  9950. * @returns {Array} Returns the new shuffled array.
  9951. * @example
  9952. *
  9953. * _.shuffle([1, 2, 3, 4]);
  9954. * // => [4, 1, 3, 2]
  9955. */
  9956. function shuffle(collection) {
  9957. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  9958. return func(collection);
  9959. }
  9960. /**
  9961. * Gets the size of `collection` by returning its length for array-like
  9962. * values or the number of own enumerable string keyed properties for objects.
  9963. *
  9964. * @static
  9965. * @memberOf _
  9966. * @since 0.1.0
  9967. * @category Collection
  9968. * @param {Array|Object|string} collection The collection to inspect.
  9969. * @returns {number} Returns the collection size.
  9970. * @example
  9971. *
  9972. * _.size([1, 2, 3]);
  9973. * // => 3
  9974. *
  9975. * _.size({ 'a': 1, 'b': 2 });
  9976. * // => 2
  9977. *
  9978. * _.size('pebbles');
  9979. * // => 7
  9980. */
  9981. function size(collection) {
  9982. if (collection == null) {
  9983. return 0;
  9984. }
  9985. if (isArrayLike(collection)) {
  9986. return isString(collection) ? stringSize(collection) : collection.length;
  9987. }
  9988. var tag = getTag(collection);
  9989. if (tag == mapTag || tag == setTag) {
  9990. return collection.size;
  9991. }
  9992. return baseKeys(collection).length;
  9993. }
  9994. /**
  9995. * Checks if `predicate` returns truthy for **any** element of `collection`.
  9996. * Iteration is stopped once `predicate` returns truthy. The predicate is
  9997. * invoked with three arguments: (value, index|key, collection).
  9998. *
  9999. * @static
  10000. * @memberOf _
  10001. * @since 0.1.0
  10002. * @category Collection
  10003. * @param {Array|Object} collection The collection to iterate over.
  10004. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10005. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10006. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10007. * else `false`.
  10008. * @example
  10009. *
  10010. * _.some([null, 0, 'yes', false], Boolean);
  10011. * // => true
  10012. *
  10013. * var users = [
  10014. * { 'user': 'barney', 'active': true },
  10015. * { 'user': 'fred', 'active': false }
  10016. * ];
  10017. *
  10018. * // The `_.matches` iteratee shorthand.
  10019. * _.some(users, { 'user': 'barney', 'active': false });
  10020. * // => false
  10021. *
  10022. * // The `_.matchesProperty` iteratee shorthand.
  10023. * _.some(users, ['active', false]);
  10024. * // => true
  10025. *
  10026. * // The `_.property` iteratee shorthand.
  10027. * _.some(users, 'active');
  10028. * // => true
  10029. */
  10030. function some(collection, predicate, guard) {
  10031. var func = isArray(collection) ? arraySome : baseSome;
  10032. if (guard && isIterateeCall(collection, predicate, guard)) {
  10033. predicate = undefined;
  10034. }
  10035. return func(collection, getIteratee(predicate, 3));
  10036. }
  10037. /**
  10038. * Creates an array of elements, sorted in ascending order by the results of
  10039. * running each element in a collection thru each iteratee. This method
  10040. * performs a stable sort, that is, it preserves the original sort order of
  10041. * equal elements. The iteratees are invoked with one argument: (value).
  10042. *
  10043. * @static
  10044. * @memberOf _
  10045. * @since 0.1.0
  10046. * @category Collection
  10047. * @param {Array|Object} collection The collection to iterate over.
  10048. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  10049. * The iteratees to sort by.
  10050. * @returns {Array} Returns the new sorted array.
  10051. * @example
  10052. *
  10053. * var users = [
  10054. * { 'user': 'fred', 'age': 48 },
  10055. * { 'user': 'barney', 'age': 36 },
  10056. * { 'user': 'fred', 'age': 40 },
  10057. * { 'user': 'barney', 'age': 34 }
  10058. * ];
  10059. *
  10060. * _.sortBy(users, [function(o) { return o.user; }]);
  10061. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  10062. *
  10063. * _.sortBy(users, ['user', 'age']);
  10064. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  10065. */
  10066. var sortBy = baseRest(function(collection, iteratees) {
  10067. if (collection == null) {
  10068. return [];
  10069. }
  10070. var length = iteratees.length;
  10071. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  10072. iteratees = [];
  10073. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  10074. iteratees = [iteratees[0]];
  10075. }
  10076. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  10077. });
  10078. /*------------------------------------------------------------------------*/
  10079. /**
  10080. * Gets the timestamp of the number of milliseconds that have elapsed since
  10081. * the Unix epoch (1 January 1970 00:00:00 UTC).
  10082. *
  10083. * @static
  10084. * @memberOf _
  10085. * @since 2.4.0
  10086. * @category Date
  10087. * @returns {number} Returns the timestamp.
  10088. * @example
  10089. *
  10090. * _.defer(function(stamp) {
  10091. * console.log(_.now() - stamp);
  10092. * }, _.now());
  10093. * // => Logs the number of milliseconds it took for the deferred invocation.
  10094. */
  10095. var now = ctxNow || function() {
  10096. return root.Date.now();
  10097. };
  10098. /*------------------------------------------------------------------------*/
  10099. /**
  10100. * The opposite of `_.before`; this method creates a function that invokes
  10101. * `func` once it's called `n` or more times.
  10102. *
  10103. * @static
  10104. * @memberOf _
  10105. * @since 0.1.0
  10106. * @category Function
  10107. * @param {number} n The number of calls before `func` is invoked.
  10108. * @param {Function} func The function to restrict.
  10109. * @returns {Function} Returns the new restricted function.
  10110. * @example
  10111. *
  10112. * var saves = ['profile', 'settings'];
  10113. *
  10114. * var done = _.after(saves.length, function() {
  10115. * console.log('done saving!');
  10116. * });
  10117. *
  10118. * _.forEach(saves, function(type) {
  10119. * asyncSave({ 'type': type, 'complete': done });
  10120. * });
  10121. * // => Logs 'done saving!' after the two async saves have completed.
  10122. */
  10123. function after(n, func) {
  10124. if (typeof func != 'function') {
  10125. throw new TypeError(FUNC_ERROR_TEXT);
  10126. }
  10127. n = toInteger(n);
  10128. return function() {
  10129. if (--n < 1) {
  10130. return func.apply(this, arguments);
  10131. }
  10132. };
  10133. }
  10134. /**
  10135. * Creates a function that invokes `func`, with up to `n` arguments,
  10136. * ignoring any additional arguments.
  10137. *
  10138. * @static
  10139. * @memberOf _
  10140. * @since 3.0.0
  10141. * @category Function
  10142. * @param {Function} func The function to cap arguments for.
  10143. * @param {number} [n=func.length] The arity cap.
  10144. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10145. * @returns {Function} Returns the new capped function.
  10146. * @example
  10147. *
  10148. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  10149. * // => [6, 8, 10]
  10150. */
  10151. function ary(func, n, guard) {
  10152. n = guard ? undefined : n;
  10153. n = (func && n == null) ? func.length : n;
  10154. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  10155. }
  10156. /**
  10157. * Creates a function that invokes `func`, with the `this` binding and arguments
  10158. * of the created function, while it's called less than `n` times. Subsequent
  10159. * calls to the created function return the result of the last `func` invocation.
  10160. *
  10161. * @static
  10162. * @memberOf _
  10163. * @since 3.0.0
  10164. * @category Function
  10165. * @param {number} n The number of calls at which `func` is no longer invoked.
  10166. * @param {Function} func The function to restrict.
  10167. * @returns {Function} Returns the new restricted function.
  10168. * @example
  10169. *
  10170. * jQuery(element).on('click', _.before(5, addContactToList));
  10171. * // => Allows adding up to 4 contacts to the list.
  10172. */
  10173. function before(n, func) {
  10174. var result;
  10175. if (typeof func != 'function') {
  10176. throw new TypeError(FUNC_ERROR_TEXT);
  10177. }
  10178. n = toInteger(n);
  10179. return function() {
  10180. if (--n > 0) {
  10181. result = func.apply(this, arguments);
  10182. }
  10183. if (n <= 1) {
  10184. func = undefined;
  10185. }
  10186. return result;
  10187. };
  10188. }
  10189. /**
  10190. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  10191. * and `partials` prepended to the arguments it receives.
  10192. *
  10193. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  10194. * may be used as a placeholder for partially applied arguments.
  10195. *
  10196. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  10197. * property of bound functions.
  10198. *
  10199. * @static
  10200. * @memberOf _
  10201. * @since 0.1.0
  10202. * @category Function
  10203. * @param {Function} func The function to bind.
  10204. * @param {*} thisArg The `this` binding of `func`.
  10205. * @param {...*} [partials] The arguments to be partially applied.
  10206. * @returns {Function} Returns the new bound function.
  10207. * @example
  10208. *
  10209. * function greet(greeting, punctuation) {
  10210. * return greeting + ' ' + this.user + punctuation;
  10211. * }
  10212. *
  10213. * var object = { 'user': 'fred' };
  10214. *
  10215. * var bound = _.bind(greet, object, 'hi');
  10216. * bound('!');
  10217. * // => 'hi fred!'
  10218. *
  10219. * // Bound with placeholders.
  10220. * var bound = _.bind(greet, object, _, '!');
  10221. * bound('hi');
  10222. * // => 'hi fred!'
  10223. */
  10224. var bind = baseRest(function(func, thisArg, partials) {
  10225. var bitmask = WRAP_BIND_FLAG;
  10226. if (partials.length) {
  10227. var holders = replaceHolders(partials, getHolder(bind));
  10228. bitmask |= WRAP_PARTIAL_FLAG;
  10229. }
  10230. return createWrap(func, bitmask, thisArg, partials, holders);
  10231. });
  10232. /**
  10233. * Creates a function that invokes the method at `object[key]` with `partials`
  10234. * prepended to the arguments it receives.
  10235. *
  10236. * This method differs from `_.bind` by allowing bound functions to reference
  10237. * methods that may be redefined or don't yet exist. See
  10238. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  10239. * for more details.
  10240. *
  10241. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  10242. * builds, may be used as a placeholder for partially applied arguments.
  10243. *
  10244. * @static
  10245. * @memberOf _
  10246. * @since 0.10.0
  10247. * @category Function
  10248. * @param {Object} object The object to invoke the method on.
  10249. * @param {string} key The key of the method.
  10250. * @param {...*} [partials] The arguments to be partially applied.
  10251. * @returns {Function} Returns the new bound function.
  10252. * @example
  10253. *
  10254. * var object = {
  10255. * 'user': 'fred',
  10256. * 'greet': function(greeting, punctuation) {
  10257. * return greeting + ' ' + this.user + punctuation;
  10258. * }
  10259. * };
  10260. *
  10261. * var bound = _.bindKey(object, 'greet', 'hi');
  10262. * bound('!');
  10263. * // => 'hi fred!'
  10264. *
  10265. * object.greet = function(greeting, punctuation) {
  10266. * return greeting + 'ya ' + this.user + punctuation;
  10267. * };
  10268. *
  10269. * bound('!');
  10270. * // => 'hiya fred!'
  10271. *
  10272. * // Bound with placeholders.
  10273. * var bound = _.bindKey(object, 'greet', _, '!');
  10274. * bound('hi');
  10275. * // => 'hiya fred!'
  10276. */
  10277. var bindKey = baseRest(function(object, key, partials) {
  10278. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  10279. if (partials.length) {
  10280. var holders = replaceHolders(partials, getHolder(bindKey));
  10281. bitmask |= WRAP_PARTIAL_FLAG;
  10282. }
  10283. return createWrap(key, bitmask, object, partials, holders);
  10284. });
  10285. /**
  10286. * Creates a function that accepts arguments of `func` and either invokes
  10287. * `func` returning its result, if at least `arity` number of arguments have
  10288. * been provided, or returns a function that accepts the remaining `func`
  10289. * arguments, and so on. The arity of `func` may be specified if `func.length`
  10290. * is not sufficient.
  10291. *
  10292. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  10293. * may be used as a placeholder for provided arguments.
  10294. *
  10295. * **Note:** This method doesn't set the "length" property of curried functions.
  10296. *
  10297. * @static
  10298. * @memberOf _
  10299. * @since 2.0.0
  10300. * @category Function
  10301. * @param {Function} func The function to curry.
  10302. * @param {number} [arity=func.length] The arity of `func`.
  10303. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10304. * @returns {Function} Returns the new curried function.
  10305. * @example
  10306. *
  10307. * var abc = function(a, b, c) {
  10308. * return [a, b, c];
  10309. * };
  10310. *
  10311. * var curried = _.curry(abc);
  10312. *
  10313. * curried(1)(2)(3);
  10314. * // => [1, 2, 3]
  10315. *
  10316. * curried(1, 2)(3);
  10317. * // => [1, 2, 3]
  10318. *
  10319. * curried(1, 2, 3);
  10320. * // => [1, 2, 3]
  10321. *
  10322. * // Curried with placeholders.
  10323. * curried(1)(_, 3)(2);
  10324. * // => [1, 2, 3]
  10325. */
  10326. function curry(func, arity, guard) {
  10327. arity = guard ? undefined : arity;
  10328. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  10329. result.placeholder = curry.placeholder;
  10330. return result;
  10331. }
  10332. /**
  10333. * This method is like `_.curry` except that arguments are applied to `func`
  10334. * in the manner of `_.partialRight` instead of `_.partial`.
  10335. *
  10336. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  10337. * builds, may be used as a placeholder for provided arguments.
  10338. *
  10339. * **Note:** This method doesn't set the "length" property of curried functions.
  10340. *
  10341. * @static
  10342. * @memberOf _
  10343. * @since 3.0.0
  10344. * @category Function
  10345. * @param {Function} func The function to curry.
  10346. * @param {number} [arity=func.length] The arity of `func`.
  10347. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10348. * @returns {Function} Returns the new curried function.
  10349. * @example
  10350. *
  10351. * var abc = function(a, b, c) {
  10352. * return [a, b, c];
  10353. * };
  10354. *
  10355. * var curried = _.curryRight(abc);
  10356. *
  10357. * curried(3)(2)(1);
  10358. * // => [1, 2, 3]
  10359. *
  10360. * curried(2, 3)(1);
  10361. * // => [1, 2, 3]
  10362. *
  10363. * curried(1, 2, 3);
  10364. * // => [1, 2, 3]
  10365. *
  10366. * // Curried with placeholders.
  10367. * curried(3)(1, _)(2);
  10368. * // => [1, 2, 3]
  10369. */
  10370. function curryRight(func, arity, guard) {
  10371. arity = guard ? undefined : arity;
  10372. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  10373. result.placeholder = curryRight.placeholder;
  10374. return result;
  10375. }
  10376. /**
  10377. * Creates a debounced function that delays invoking `func` until after `wait`
  10378. * milliseconds have elapsed since the last time the debounced function was
  10379. * invoked. The debounced function comes with a `cancel` method to cancel
  10380. * delayed `func` invocations and a `flush` method to immediately invoke them.
  10381. * Provide `options` to indicate whether `func` should be invoked on the
  10382. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  10383. * with the last arguments provided to the debounced function. Subsequent
  10384. * calls to the debounced function return the result of the last `func`
  10385. * invocation.
  10386. *
  10387. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  10388. * invoked on the trailing edge of the timeout only if the debounced function
  10389. * is invoked more than once during the `wait` timeout.
  10390. *
  10391. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  10392. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  10393. *
  10394. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  10395. * for details over the differences between `_.debounce` and `_.throttle`.
  10396. *
  10397. * @static
  10398. * @memberOf _
  10399. * @since 0.1.0
  10400. * @category Function
  10401. * @param {Function} func The function to debounce.
  10402. * @param {number} [wait=0] The number of milliseconds to delay.
  10403. * @param {Object} [options={}] The options object.
  10404. * @param {boolean} [options.leading=false]
  10405. * Specify invoking on the leading edge of the timeout.
  10406. * @param {number} [options.maxWait]
  10407. * The maximum time `func` is allowed to be delayed before it's invoked.
  10408. * @param {boolean} [options.trailing=true]
  10409. * Specify invoking on the trailing edge of the timeout.
  10410. * @returns {Function} Returns the new debounced function.
  10411. * @example
  10412. *
  10413. * // Avoid costly calculations while the window size is in flux.
  10414. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  10415. *
  10416. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  10417. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  10418. * 'leading': true,
  10419. * 'trailing': false
  10420. * }));
  10421. *
  10422. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  10423. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  10424. * var source = new EventSource('/stream');
  10425. * jQuery(source).on('message', debounced);
  10426. *
  10427. * // Cancel the trailing debounced invocation.
  10428. * jQuery(window).on('popstate', debounced.cancel);
  10429. */
  10430. function debounce(func, wait, options) {
  10431. var lastArgs,
  10432. lastThis,
  10433. maxWait,
  10434. result,
  10435. timerId,
  10436. lastCallTime,
  10437. lastInvokeTime = 0,
  10438. leading = false,
  10439. maxing = false,
  10440. trailing = true;
  10441. if (typeof func != 'function') {
  10442. throw new TypeError(FUNC_ERROR_TEXT);
  10443. }
  10444. wait = toNumber(wait) || 0;
  10445. if (isObject(options)) {
  10446. leading = !!options.leading;
  10447. maxing = 'maxWait' in options;
  10448. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  10449. trailing = 'trailing' in options ? !!options.trailing : trailing;
  10450. }
  10451. function invokeFunc(time) {
  10452. var args = lastArgs,
  10453. thisArg = lastThis;
  10454. lastArgs = lastThis = undefined;
  10455. lastInvokeTime = time;
  10456. result = func.apply(thisArg, args);
  10457. return result;
  10458. }
  10459. function leadingEdge(time) {
  10460. // Reset any `maxWait` timer.
  10461. lastInvokeTime = time;
  10462. // Start the timer for the trailing edge.
  10463. timerId = setTimeout(timerExpired, wait);
  10464. // Invoke the leading edge.
  10465. return leading ? invokeFunc(time) : result;
  10466. }
  10467. function remainingWait(time) {
  10468. var timeSinceLastCall = time - lastCallTime,
  10469. timeSinceLastInvoke = time - lastInvokeTime,
  10470. result = wait - timeSinceLastCall;
  10471. return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
  10472. }
  10473. function shouldInvoke(time) {
  10474. var timeSinceLastCall = time - lastCallTime,
  10475. timeSinceLastInvoke = time - lastInvokeTime;
  10476. // Either this is the first call, activity has stopped and we're at the
  10477. // trailing edge, the system time has gone backwards and we're treating
  10478. // it as the trailing edge, or we've hit the `maxWait` limit.
  10479. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  10480. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  10481. }
  10482. function timerExpired() {
  10483. var time = now();
  10484. if (shouldInvoke(time)) {
  10485. return trailingEdge(time);
  10486. }
  10487. // Restart the timer.
  10488. timerId = setTimeout(timerExpired, remainingWait(time));
  10489. }
  10490. function trailingEdge(time) {
  10491. timerId = undefined;
  10492. // Only invoke if we have `lastArgs` which means `func` has been
  10493. // debounced at least once.
  10494. if (trailing && lastArgs) {
  10495. return invokeFunc(time);
  10496. }
  10497. lastArgs = lastThis = undefined;
  10498. return result;
  10499. }
  10500. function cancel() {
  10501. if (timerId !== undefined) {
  10502. clearTimeout(timerId);
  10503. }
  10504. lastInvokeTime = 0;
  10505. lastArgs = lastCallTime = lastThis = timerId = undefined;
  10506. }
  10507. function flush() {
  10508. return timerId === undefined ? result : trailingEdge(now());
  10509. }
  10510. function debounced() {
  10511. var time = now(),
  10512. isInvoking = shouldInvoke(time);
  10513. lastArgs = arguments;
  10514. lastThis = this;
  10515. lastCallTime = time;
  10516. if (isInvoking) {
  10517. if (timerId === undefined) {
  10518. return leadingEdge(lastCallTime);
  10519. }
  10520. if (maxing) {
  10521. // Handle invocations in a tight loop.
  10522. timerId = setTimeout(timerExpired, wait);
  10523. return invokeFunc(lastCallTime);
  10524. }
  10525. }
  10526. if (timerId === undefined) {
  10527. timerId = setTimeout(timerExpired, wait);
  10528. }
  10529. return result;
  10530. }
  10531. debounced.cancel = cancel;
  10532. debounced.flush = flush;
  10533. return debounced;
  10534. }
  10535. /**
  10536. * Defers invoking the `func` until the current call stack has cleared. Any
  10537. * additional arguments are provided to `func` when it's invoked.
  10538. *
  10539. * @static
  10540. * @memberOf _
  10541. * @since 0.1.0
  10542. * @category Function
  10543. * @param {Function} func The function to defer.
  10544. * @param {...*} [args] The arguments to invoke `func` with.
  10545. * @returns {number} Returns the timer id.
  10546. * @example
  10547. *
  10548. * _.defer(function(text) {
  10549. * console.log(text);
  10550. * }, 'deferred');
  10551. * // => Logs 'deferred' after one millisecond.
  10552. */
  10553. var defer = baseRest(function(func, args) {
  10554. return baseDelay(func, 1, args);
  10555. });
  10556. /**
  10557. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  10558. * provided to `func` when it's invoked.
  10559. *
  10560. * @static
  10561. * @memberOf _
  10562. * @since 0.1.0
  10563. * @category Function
  10564. * @param {Function} func The function to delay.
  10565. * @param {number} wait The number of milliseconds to delay invocation.
  10566. * @param {...*} [args] The arguments to invoke `func` with.
  10567. * @returns {number} Returns the timer id.
  10568. * @example
  10569. *
  10570. * _.delay(function(text) {
  10571. * console.log(text);
  10572. * }, 1000, 'later');
  10573. * // => Logs 'later' after one second.
  10574. */
  10575. var delay = baseRest(function(func, wait, args) {
  10576. return baseDelay(func, toNumber(wait) || 0, args);
  10577. });
  10578. /**
  10579. * Creates a function that invokes `func` with arguments reversed.
  10580. *
  10581. * @static
  10582. * @memberOf _
  10583. * @since 4.0.0
  10584. * @category Function
  10585. * @param {Function} func The function to flip arguments for.
  10586. * @returns {Function} Returns the new flipped function.
  10587. * @example
  10588. *
  10589. * var flipped = _.flip(function() {
  10590. * return _.toArray(arguments);
  10591. * });
  10592. *
  10593. * flipped('a', 'b', 'c', 'd');
  10594. * // => ['d', 'c', 'b', 'a']
  10595. */
  10596. function flip(func) {
  10597. return createWrap(func, WRAP_FLIP_FLAG);
  10598. }
  10599. /**
  10600. * Creates a function that memoizes the result of `func`. If `resolver` is
  10601. * provided, it determines the cache key for storing the result based on the
  10602. * arguments provided to the memoized function. By default, the first argument
  10603. * provided to the memoized function is used as the map cache key. The `func`
  10604. * is invoked with the `this` binding of the memoized function.
  10605. *
  10606. * **Note:** The cache is exposed as the `cache` property on the memoized
  10607. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  10608. * constructor with one whose instances implement the
  10609. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  10610. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  10611. *
  10612. * @static
  10613. * @memberOf _
  10614. * @since 0.1.0
  10615. * @category Function
  10616. * @param {Function} func The function to have its output memoized.
  10617. * @param {Function} [resolver] The function to resolve the cache key.
  10618. * @returns {Function} Returns the new memoized function.
  10619. * @example
  10620. *
  10621. * var object = { 'a': 1, 'b': 2 };
  10622. * var other = { 'c': 3, 'd': 4 };
  10623. *
  10624. * var values = _.memoize(_.values);
  10625. * values(object);
  10626. * // => [1, 2]
  10627. *
  10628. * values(other);
  10629. * // => [3, 4]
  10630. *
  10631. * object.a = 2;
  10632. * values(object);
  10633. * // => [1, 2]
  10634. *
  10635. * // Modify the result cache.
  10636. * values.cache.set(object, ['a', 'b']);
  10637. * values(object);
  10638. * // => ['a', 'b']
  10639. *
  10640. * // Replace `_.memoize.Cache`.
  10641. * _.memoize.Cache = WeakMap;
  10642. */
  10643. function memoize(func, resolver) {
  10644. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  10645. throw new TypeError(FUNC_ERROR_TEXT);
  10646. }
  10647. var memoized = function() {
  10648. var args = arguments,
  10649. key = resolver ? resolver.apply(this, args) : args[0],
  10650. cache = memoized.cache;
  10651. if (cache.has(key)) {
  10652. return cache.get(key);
  10653. }
  10654. var result = func.apply(this, args);
  10655. memoized.cache = cache.set(key, result) || cache;
  10656. return result;
  10657. };
  10658. memoized.cache = new (memoize.Cache || MapCache);
  10659. return memoized;
  10660. }
  10661. // Expose `MapCache`.
  10662. memoize.Cache = MapCache;
  10663. /**
  10664. * Creates a function that negates the result of the predicate `func`. The
  10665. * `func` predicate is invoked with the `this` binding and arguments of the
  10666. * created function.
  10667. *
  10668. * @static
  10669. * @memberOf _
  10670. * @since 3.0.0
  10671. * @category Function
  10672. * @param {Function} predicate The predicate to negate.
  10673. * @returns {Function} Returns the new negated function.
  10674. * @example
  10675. *
  10676. * function isEven(n) {
  10677. * return n % 2 == 0;
  10678. * }
  10679. *
  10680. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  10681. * // => [1, 3, 5]
  10682. */
  10683. function negate(predicate) {
  10684. if (typeof predicate != 'function') {
  10685. throw new TypeError(FUNC_ERROR_TEXT);
  10686. }
  10687. return function() {
  10688. var args = arguments;
  10689. switch (args.length) {
  10690. case 0: return !predicate.call(this);
  10691. case 1: return !predicate.call(this, args[0]);
  10692. case 2: return !predicate.call(this, args[0], args[1]);
  10693. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  10694. }
  10695. return !predicate.apply(this, args);
  10696. };
  10697. }
  10698. /**
  10699. * Creates a function that is restricted to invoking `func` once. Repeat calls
  10700. * to the function return the value of the first invocation. The `func` is
  10701. * invoked with the `this` binding and arguments of the created function.
  10702. *
  10703. * @static
  10704. * @memberOf _
  10705. * @since 0.1.0
  10706. * @category Function
  10707. * @param {Function} func The function to restrict.
  10708. * @returns {Function} Returns the new restricted function.
  10709. * @example
  10710. *
  10711. * var initialize = _.once(createApplication);
  10712. * initialize();
  10713. * initialize();
  10714. * // => `createApplication` is invoked once
  10715. */
  10716. function once(func) {
  10717. return before(2, func);
  10718. }
  10719. /**
  10720. * Creates a function that invokes `func` with its arguments transformed.
  10721. *
  10722. * @static
  10723. * @since 4.0.0
  10724. * @memberOf _
  10725. * @category Function
  10726. * @param {Function} func The function to wrap.
  10727. * @param {...(Function|Function[])} [transforms=[_.identity]]
  10728. * The argument transforms.
  10729. * @returns {Function} Returns the new function.
  10730. * @example
  10731. *
  10732. * function doubled(n) {
  10733. * return n * 2;
  10734. * }
  10735. *
  10736. * function square(n) {
  10737. * return n * n;
  10738. * }
  10739. *
  10740. * var func = _.overArgs(function(x, y) {
  10741. * return [x, y];
  10742. * }, [square, doubled]);
  10743. *
  10744. * func(9, 3);
  10745. * // => [81, 6]
  10746. *
  10747. * func(10, 5);
  10748. * // => [100, 10]
  10749. */
  10750. var overArgs = castRest(function(func, transforms) {
  10751. transforms = (transforms.length == 1 && isArray(transforms[0]))
  10752. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  10753. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  10754. var funcsLength = transforms.length;
  10755. return baseRest(function(args) {
  10756. var index = -1,
  10757. length = nativeMin(args.length, funcsLength);
  10758. while (++index < length) {
  10759. args[index] = transforms[index].call(this, args[index]);
  10760. }
  10761. return apply(func, this, args);
  10762. });
  10763. });
  10764. /**
  10765. * Creates a function that invokes `func` with `partials` prepended to the
  10766. * arguments it receives. This method is like `_.bind` except it does **not**
  10767. * alter the `this` binding.
  10768. *
  10769. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  10770. * builds, may be used as a placeholder for partially applied arguments.
  10771. *
  10772. * **Note:** This method doesn't set the "length" property of partially
  10773. * applied functions.
  10774. *
  10775. * @static
  10776. * @memberOf _
  10777. * @since 0.2.0
  10778. * @category Function
  10779. * @param {Function} func The function to partially apply arguments to.
  10780. * @param {...*} [partials] The arguments to be partially applied.
  10781. * @returns {Function} Returns the new partially applied function.
  10782. * @example
  10783. *
  10784. * function greet(greeting, name) {
  10785. * return greeting + ' ' + name;
  10786. * }
  10787. *
  10788. * var sayHelloTo = _.partial(greet, 'hello');
  10789. * sayHelloTo('fred');
  10790. * // => 'hello fred'
  10791. *
  10792. * // Partially applied with placeholders.
  10793. * var greetFred = _.partial(greet, _, 'fred');
  10794. * greetFred('hi');
  10795. * // => 'hi fred'
  10796. */
  10797. var partial = baseRest(function(func, partials) {
  10798. var holders = replaceHolders(partials, getHolder(partial));
  10799. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  10800. });
  10801. /**
  10802. * This method is like `_.partial` except that partially applied arguments
  10803. * are appended to the arguments it receives.
  10804. *
  10805. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  10806. * builds, may be used as a placeholder for partially applied arguments.
  10807. *
  10808. * **Note:** This method doesn't set the "length" property of partially
  10809. * applied functions.
  10810. *
  10811. * @static
  10812. * @memberOf _
  10813. * @since 1.0.0
  10814. * @category Function
  10815. * @param {Function} func The function to partially apply arguments to.
  10816. * @param {...*} [partials] The arguments to be partially applied.
  10817. * @returns {Function} Returns the new partially applied function.
  10818. * @example
  10819. *
  10820. * function greet(greeting, name) {
  10821. * return greeting + ' ' + name;
  10822. * }
  10823. *
  10824. * var greetFred = _.partialRight(greet, 'fred');
  10825. * greetFred('hi');
  10826. * // => 'hi fred'
  10827. *
  10828. * // Partially applied with placeholders.
  10829. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  10830. * sayHelloTo('fred');
  10831. * // => 'hello fred'
  10832. */
  10833. var partialRight = baseRest(function(func, partials) {
  10834. var holders = replaceHolders(partials, getHolder(partialRight));
  10835. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  10836. });
  10837. /**
  10838. * Creates a function that invokes `func` with arguments arranged according
  10839. * to the specified `indexes` where the argument value at the first index is
  10840. * provided as the first argument, the argument value at the second index is
  10841. * provided as the second argument, and so on.
  10842. *
  10843. * @static
  10844. * @memberOf _
  10845. * @since 3.0.0
  10846. * @category Function
  10847. * @param {Function} func The function to rearrange arguments for.
  10848. * @param {...(number|number[])} indexes The arranged argument indexes.
  10849. * @returns {Function} Returns the new function.
  10850. * @example
  10851. *
  10852. * var rearged = _.rearg(function(a, b, c) {
  10853. * return [a, b, c];
  10854. * }, [2, 0, 1]);
  10855. *
  10856. * rearged('b', 'c', 'a')
  10857. * // => ['a', 'b', 'c']
  10858. */
  10859. var rearg = flatRest(function(func, indexes) {
  10860. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  10861. });
  10862. /**
  10863. * Creates a function that invokes `func` with the `this` binding of the
  10864. * created function and arguments from `start` and beyond provided as
  10865. * an array.
  10866. *
  10867. * **Note:** This method is based on the
  10868. * [rest parameter](https://mdn.io/rest_parameters).
  10869. *
  10870. * @static
  10871. * @memberOf _
  10872. * @since 4.0.0
  10873. * @category Function
  10874. * @param {Function} func The function to apply a rest parameter to.
  10875. * @param {number} [start=func.length-1] The start position of the rest parameter.
  10876. * @returns {Function} Returns the new function.
  10877. * @example
  10878. *
  10879. * var say = _.rest(function(what, names) {
  10880. * return what + ' ' + _.initial(names).join(', ') +
  10881. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  10882. * });
  10883. *
  10884. * say('hello', 'fred', 'barney', 'pebbles');
  10885. * // => 'hello fred, barney, & pebbles'
  10886. */
  10887. function rest(func, start) {
  10888. if (typeof func != 'function') {
  10889. throw new TypeError(FUNC_ERROR_TEXT);
  10890. }
  10891. start = start === undefined ? start : toInteger(start);
  10892. return baseRest(func, start);
  10893. }
  10894. /**
  10895. * Creates a function that invokes `func` with the `this` binding of the
  10896. * create function and an array of arguments much like
  10897. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  10898. *
  10899. * **Note:** This method is based on the
  10900. * [spread operator](https://mdn.io/spread_operator).
  10901. *
  10902. * @static
  10903. * @memberOf _
  10904. * @since 3.2.0
  10905. * @category Function
  10906. * @param {Function} func The function to spread arguments over.
  10907. * @param {number} [start=0] The start position of the spread.
  10908. * @returns {Function} Returns the new function.
  10909. * @example
  10910. *
  10911. * var say = _.spread(function(who, what) {
  10912. * return who + ' says ' + what;
  10913. * });
  10914. *
  10915. * say(['fred', 'hello']);
  10916. * // => 'fred says hello'
  10917. *
  10918. * var numbers = Promise.all([
  10919. * Promise.resolve(40),
  10920. * Promise.resolve(36)
  10921. * ]);
  10922. *
  10923. * numbers.then(_.spread(function(x, y) {
  10924. * return x + y;
  10925. * }));
  10926. * // => a Promise of 76
  10927. */
  10928. function spread(func, start) {
  10929. if (typeof func != 'function') {
  10930. throw new TypeError(FUNC_ERROR_TEXT);
  10931. }
  10932. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  10933. return baseRest(function(args) {
  10934. var array = args[start],
  10935. otherArgs = castSlice(args, 0, start);
  10936. if (array) {
  10937. arrayPush(otherArgs, array);
  10938. }
  10939. return apply(func, this, otherArgs);
  10940. });
  10941. }
  10942. /**
  10943. * Creates a throttled function that only invokes `func` at most once per
  10944. * every `wait` milliseconds. The throttled function comes with a `cancel`
  10945. * method to cancel delayed `func` invocations and a `flush` method to
  10946. * immediately invoke them. Provide `options` to indicate whether `func`
  10947. * should be invoked on the leading and/or trailing edge of the `wait`
  10948. * timeout. The `func` is invoked with the last arguments provided to the
  10949. * throttled function. Subsequent calls to the throttled function return the
  10950. * result of the last `func` invocation.
  10951. *
  10952. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  10953. * invoked on the trailing edge of the timeout only if the throttled function
  10954. * is invoked more than once during the `wait` timeout.
  10955. *
  10956. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  10957. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  10958. *
  10959. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  10960. * for details over the differences between `_.throttle` and `_.debounce`.
  10961. *
  10962. * @static
  10963. * @memberOf _
  10964. * @since 0.1.0
  10965. * @category Function
  10966. * @param {Function} func The function to throttle.
  10967. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  10968. * @param {Object} [options={}] The options object.
  10969. * @param {boolean} [options.leading=true]
  10970. * Specify invoking on the leading edge of the timeout.
  10971. * @param {boolean} [options.trailing=true]
  10972. * Specify invoking on the trailing edge of the timeout.
  10973. * @returns {Function} Returns the new throttled function.
  10974. * @example
  10975. *
  10976. * // Avoid excessively updating the position while scrolling.
  10977. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  10978. *
  10979. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  10980. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  10981. * jQuery(element).on('click', throttled);
  10982. *
  10983. * // Cancel the trailing throttled invocation.
  10984. * jQuery(window).on('popstate', throttled.cancel);
  10985. */
  10986. function throttle(func, wait, options) {
  10987. var leading = true,
  10988. trailing = true;
  10989. if (typeof func != 'function') {
  10990. throw new TypeError(FUNC_ERROR_TEXT);
  10991. }
  10992. if (isObject(options)) {
  10993. leading = 'leading' in options ? !!options.leading : leading;
  10994. trailing = 'trailing' in options ? !!options.trailing : trailing;
  10995. }
  10996. return debounce(func, wait, {
  10997. 'leading': leading,
  10998. 'maxWait': wait,
  10999. 'trailing': trailing
  11000. });
  11001. }
  11002. /**
  11003. * Creates a function that accepts up to one argument, ignoring any
  11004. * additional arguments.
  11005. *
  11006. * @static
  11007. * @memberOf _
  11008. * @since 4.0.0
  11009. * @category Function
  11010. * @param {Function} func The function to cap arguments for.
  11011. * @returns {Function} Returns the new capped function.
  11012. * @example
  11013. *
  11014. * _.map(['6', '8', '10'], _.unary(parseInt));
  11015. * // => [6, 8, 10]
  11016. */
  11017. function unary(func) {
  11018. return ary(func, 1);
  11019. }
  11020. /**
  11021. * Creates a function that provides `value` to `wrapper` as its first
  11022. * argument. Any additional arguments provided to the function are appended
  11023. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  11024. * binding of the created function.
  11025. *
  11026. * @static
  11027. * @memberOf _
  11028. * @since 0.1.0
  11029. * @category Function
  11030. * @param {*} value The value to wrap.
  11031. * @param {Function} [wrapper=identity] The wrapper function.
  11032. * @returns {Function} Returns the new function.
  11033. * @example
  11034. *
  11035. * var p = _.wrap(_.escape, function(func, text) {
  11036. * return '<p>' + func(text) + '</p>';
  11037. * });
  11038. *
  11039. * p('fred, barney, & pebbles');
  11040. * // => '<p>fred, barney, &amp; pebbles</p>'
  11041. */
  11042. function wrap(value, wrapper) {
  11043. return partial(castFunction(wrapper), value);
  11044. }
  11045. /*------------------------------------------------------------------------*/
  11046. /**
  11047. * Casts `value` as an array if it's not one.
  11048. *
  11049. * @static
  11050. * @memberOf _
  11051. * @since 4.4.0
  11052. * @category Lang
  11053. * @param {*} value The value to inspect.
  11054. * @returns {Array} Returns the cast array.
  11055. * @example
  11056. *
  11057. * _.castArray(1);
  11058. * // => [1]
  11059. *
  11060. * _.castArray({ 'a': 1 });
  11061. * // => [{ 'a': 1 }]
  11062. *
  11063. * _.castArray('abc');
  11064. * // => ['abc']
  11065. *
  11066. * _.castArray(null);
  11067. * // => [null]
  11068. *
  11069. * _.castArray(undefined);
  11070. * // => [undefined]
  11071. *
  11072. * _.castArray();
  11073. * // => []
  11074. *
  11075. * var array = [1, 2, 3];
  11076. * console.log(_.castArray(array) === array);
  11077. * // => true
  11078. */
  11079. function castArray() {
  11080. if (!arguments.length) {
  11081. return [];
  11082. }
  11083. var value = arguments[0];
  11084. return isArray(value) ? value : [value];
  11085. }
  11086. /**
  11087. * Creates a shallow clone of `value`.
  11088. *
  11089. * **Note:** This method is loosely based on the
  11090. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  11091. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  11092. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  11093. * arrays. The own enumerable properties of `arguments` objects are cloned
  11094. * as plain objects. An empty object is returned for uncloneable values such
  11095. * as error objects, functions, DOM nodes, and WeakMaps.
  11096. *
  11097. * @static
  11098. * @memberOf _
  11099. * @since 0.1.0
  11100. * @category Lang
  11101. * @param {*} value The value to clone.
  11102. * @returns {*} Returns the cloned value.
  11103. * @see _.cloneDeep
  11104. * @example
  11105. *
  11106. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11107. *
  11108. * var shallow = _.clone(objects);
  11109. * console.log(shallow[0] === objects[0]);
  11110. * // => true
  11111. */
  11112. function clone(value) {
  11113. return baseClone(value, CLONE_SYMBOLS_FLAG);
  11114. }
  11115. /**
  11116. * This method is like `_.clone` except that it accepts `customizer` which
  11117. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  11118. * cloning is handled by the method instead. The `customizer` is invoked with
  11119. * up to four arguments; (value [, index|key, object, stack]).
  11120. *
  11121. * @static
  11122. * @memberOf _
  11123. * @since 4.0.0
  11124. * @category Lang
  11125. * @param {*} value The value to clone.
  11126. * @param {Function} [customizer] The function to customize cloning.
  11127. * @returns {*} Returns the cloned value.
  11128. * @see _.cloneDeepWith
  11129. * @example
  11130. *
  11131. * function customizer(value) {
  11132. * if (_.isElement(value)) {
  11133. * return value.cloneNode(false);
  11134. * }
  11135. * }
  11136. *
  11137. * var el = _.cloneWith(document.body, customizer);
  11138. *
  11139. * console.log(el === document.body);
  11140. * // => false
  11141. * console.log(el.nodeName);
  11142. * // => 'BODY'
  11143. * console.log(el.childNodes.length);
  11144. * // => 0
  11145. */
  11146. function cloneWith(value, customizer) {
  11147. customizer = typeof customizer == 'function' ? customizer : undefined;
  11148. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  11149. }
  11150. /**
  11151. * This method is like `_.clone` except that it recursively clones `value`.
  11152. *
  11153. * @static
  11154. * @memberOf _
  11155. * @since 1.0.0
  11156. * @category Lang
  11157. * @param {*} value The value to recursively clone.
  11158. * @returns {*} Returns the deep cloned value.
  11159. * @see _.clone
  11160. * @example
  11161. *
  11162. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11163. *
  11164. * var deep = _.cloneDeep(objects);
  11165. * console.log(deep[0] === objects[0]);
  11166. * // => false
  11167. */
  11168. function cloneDeep(value) {
  11169. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  11170. }
  11171. /**
  11172. * This method is like `_.cloneWith` except that it recursively clones `value`.
  11173. *
  11174. * @static
  11175. * @memberOf _
  11176. * @since 4.0.0
  11177. * @category Lang
  11178. * @param {*} value The value to recursively clone.
  11179. * @param {Function} [customizer] The function to customize cloning.
  11180. * @returns {*} Returns the deep cloned value.
  11181. * @see _.cloneWith
  11182. * @example
  11183. *
  11184. * function customizer(value) {
  11185. * if (_.isElement(value)) {
  11186. * return value.cloneNode(true);
  11187. * }
  11188. * }
  11189. *
  11190. * var el = _.cloneDeepWith(document.body, customizer);
  11191. *
  11192. * console.log(el === document.body);
  11193. * // => false
  11194. * console.log(el.nodeName);
  11195. * // => 'BODY'
  11196. * console.log(el.childNodes.length);
  11197. * // => 20
  11198. */
  11199. function cloneDeepWith(value, customizer) {
  11200. customizer = typeof customizer == 'function' ? customizer : undefined;
  11201. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  11202. }
  11203. /**
  11204. * Checks if `object` conforms to `source` by invoking the predicate
  11205. * properties of `source` with the corresponding property values of `object`.
  11206. *
  11207. * **Note:** This method is equivalent to `_.conforms` when `source` is
  11208. * partially applied.
  11209. *
  11210. * @static
  11211. * @memberOf _
  11212. * @since 4.14.0
  11213. * @category Lang
  11214. * @param {Object} object The object to inspect.
  11215. * @param {Object} source The object of property predicates to conform to.
  11216. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  11217. * @example
  11218. *
  11219. * var object = { 'a': 1, 'b': 2 };
  11220. *
  11221. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  11222. * // => true
  11223. *
  11224. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  11225. * // => false
  11226. */
  11227. function conformsTo(object, source) {
  11228. return source == null || baseConformsTo(object, source, keys(source));
  11229. }
  11230. /**
  11231. * Performs a
  11232. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11233. * comparison between two values to determine if they are equivalent.
  11234. *
  11235. * @static
  11236. * @memberOf _
  11237. * @since 4.0.0
  11238. * @category Lang
  11239. * @param {*} value The value to compare.
  11240. * @param {*} other The other value to compare.
  11241. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11242. * @example
  11243. *
  11244. * var object = { 'a': 1 };
  11245. * var other = { 'a': 1 };
  11246. *
  11247. * _.eq(object, object);
  11248. * // => true
  11249. *
  11250. * _.eq(object, other);
  11251. * // => false
  11252. *
  11253. * _.eq('a', 'a');
  11254. * // => true
  11255. *
  11256. * _.eq('a', Object('a'));
  11257. * // => false
  11258. *
  11259. * _.eq(NaN, NaN);
  11260. * // => true
  11261. */
  11262. function eq(value, other) {
  11263. return value === other || (value !== value && other !== other);
  11264. }
  11265. /**
  11266. * Checks if `value` is greater than `other`.
  11267. *
  11268. * @static
  11269. * @memberOf _
  11270. * @since 3.9.0
  11271. * @category Lang
  11272. * @param {*} value The value to compare.
  11273. * @param {*} other The other value to compare.
  11274. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  11275. * else `false`.
  11276. * @see _.lt
  11277. * @example
  11278. *
  11279. * _.gt(3, 1);
  11280. * // => true
  11281. *
  11282. * _.gt(3, 3);
  11283. * // => false
  11284. *
  11285. * _.gt(1, 3);
  11286. * // => false
  11287. */
  11288. var gt = createRelationalOperation(baseGt);
  11289. /**
  11290. * Checks if `value` is greater than or equal to `other`.
  11291. *
  11292. * @static
  11293. * @memberOf _
  11294. * @since 3.9.0
  11295. * @category Lang
  11296. * @param {*} value The value to compare.
  11297. * @param {*} other The other value to compare.
  11298. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  11299. * `other`, else `false`.
  11300. * @see _.lte
  11301. * @example
  11302. *
  11303. * _.gte(3, 1);
  11304. * // => true
  11305. *
  11306. * _.gte(3, 3);
  11307. * // => true
  11308. *
  11309. * _.gte(1, 3);
  11310. * // => false
  11311. */
  11312. var gte = createRelationalOperation(function(value, other) {
  11313. return value >= other;
  11314. });
  11315. /**
  11316. * Checks if `value` is likely an `arguments` object.
  11317. *
  11318. * @static
  11319. * @memberOf _
  11320. * @since 0.1.0
  11321. * @category Lang
  11322. * @param {*} value The value to check.
  11323. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  11324. * else `false`.
  11325. * @example
  11326. *
  11327. * _.isArguments(function() { return arguments; }());
  11328. * // => true
  11329. *
  11330. * _.isArguments([1, 2, 3]);
  11331. * // => false
  11332. */
  11333. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  11334. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  11335. !propertyIsEnumerable.call(value, 'callee');
  11336. };
  11337. /**
  11338. * Checks if `value` is classified as an `Array` object.
  11339. *
  11340. * @static
  11341. * @memberOf _
  11342. * @since 0.1.0
  11343. * @category Lang
  11344. * @param {*} value The value to check.
  11345. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  11346. * @example
  11347. *
  11348. * _.isArray([1, 2, 3]);
  11349. * // => true
  11350. *
  11351. * _.isArray(document.body.children);
  11352. * // => false
  11353. *
  11354. * _.isArray('abc');
  11355. * // => false
  11356. *
  11357. * _.isArray(_.noop);
  11358. * // => false
  11359. */
  11360. var isArray = Array.isArray;
  11361. /**
  11362. * Checks if `value` is classified as an `ArrayBuffer` object.
  11363. *
  11364. * @static
  11365. * @memberOf _
  11366. * @since 4.3.0
  11367. * @category Lang
  11368. * @param {*} value The value to check.
  11369. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  11370. * @example
  11371. *
  11372. * _.isArrayBuffer(new ArrayBuffer(2));
  11373. * // => true
  11374. *
  11375. * _.isArrayBuffer(new Array(2));
  11376. * // => false
  11377. */
  11378. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  11379. /**
  11380. * Checks if `value` is array-like. A value is considered array-like if it's
  11381. * not a function and has a `value.length` that's an integer greater than or
  11382. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  11383. *
  11384. * @static
  11385. * @memberOf _
  11386. * @since 4.0.0
  11387. * @category Lang
  11388. * @param {*} value The value to check.
  11389. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  11390. * @example
  11391. *
  11392. * _.isArrayLike([1, 2, 3]);
  11393. * // => true
  11394. *
  11395. * _.isArrayLike(document.body.children);
  11396. * // => true
  11397. *
  11398. * _.isArrayLike('abc');
  11399. * // => true
  11400. *
  11401. * _.isArrayLike(_.noop);
  11402. * // => false
  11403. */
  11404. function isArrayLike(value) {
  11405. return value != null && isLength(value.length) && !isFunction(value);
  11406. }
  11407. /**
  11408. * This method is like `_.isArrayLike` except that it also checks if `value`
  11409. * is an object.
  11410. *
  11411. * @static
  11412. * @memberOf _
  11413. * @since 4.0.0
  11414. * @category Lang
  11415. * @param {*} value The value to check.
  11416. * @returns {boolean} Returns `true` if `value` is an array-like object,
  11417. * else `false`.
  11418. * @example
  11419. *
  11420. * _.isArrayLikeObject([1, 2, 3]);
  11421. * // => true
  11422. *
  11423. * _.isArrayLikeObject(document.body.children);
  11424. * // => true
  11425. *
  11426. * _.isArrayLikeObject('abc');
  11427. * // => false
  11428. *
  11429. * _.isArrayLikeObject(_.noop);
  11430. * // => false
  11431. */
  11432. function isArrayLikeObject(value) {
  11433. return isObjectLike(value) && isArrayLike(value);
  11434. }
  11435. /**
  11436. * Checks if `value` is classified as a boolean primitive or object.
  11437. *
  11438. * @static
  11439. * @memberOf _
  11440. * @since 0.1.0
  11441. * @category Lang
  11442. * @param {*} value The value to check.
  11443. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  11444. * @example
  11445. *
  11446. * _.isBoolean(false);
  11447. * // => true
  11448. *
  11449. * _.isBoolean(null);
  11450. * // => false
  11451. */
  11452. function isBoolean(value) {
  11453. return value === true || value === false ||
  11454. (isObjectLike(value) && baseGetTag(value) == boolTag);
  11455. }
  11456. /**
  11457. * Checks if `value` is a buffer.
  11458. *
  11459. * @static
  11460. * @memberOf _
  11461. * @since 4.3.0
  11462. * @category Lang
  11463. * @param {*} value The value to check.
  11464. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  11465. * @example
  11466. *
  11467. * _.isBuffer(new Buffer(2));
  11468. * // => true
  11469. *
  11470. * _.isBuffer(new Uint8Array(2));
  11471. * // => false
  11472. */
  11473. var isBuffer = nativeIsBuffer || stubFalse;
  11474. /**
  11475. * Checks if `value` is classified as a `Date` object.
  11476. *
  11477. * @static
  11478. * @memberOf _
  11479. * @since 0.1.0
  11480. * @category Lang
  11481. * @param {*} value The value to check.
  11482. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  11483. * @example
  11484. *
  11485. * _.isDate(new Date);
  11486. * // => true
  11487. *
  11488. * _.isDate('Mon April 23 2012');
  11489. * // => false
  11490. */
  11491. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  11492. /**
  11493. * Checks if `value` is likely a DOM element.
  11494. *
  11495. * @static
  11496. * @memberOf _
  11497. * @since 0.1.0
  11498. * @category Lang
  11499. * @param {*} value The value to check.
  11500. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  11501. * @example
  11502. *
  11503. * _.isElement(document.body);
  11504. * // => true
  11505. *
  11506. * _.isElement('<body>');
  11507. * // => false
  11508. */
  11509. function isElement(value) {
  11510. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  11511. }
  11512. /**
  11513. * Checks if `value` is an empty object, collection, map, or set.
  11514. *
  11515. * Objects are considered empty if they have no own enumerable string keyed
  11516. * properties.
  11517. *
  11518. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  11519. * jQuery-like collections are considered empty if they have a `length` of `0`.
  11520. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  11521. *
  11522. * @static
  11523. * @memberOf _
  11524. * @since 0.1.0
  11525. * @category Lang
  11526. * @param {*} value The value to check.
  11527. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  11528. * @example
  11529. *
  11530. * _.isEmpty(null);
  11531. * // => true
  11532. *
  11533. * _.isEmpty(true);
  11534. * // => true
  11535. *
  11536. * _.isEmpty(1);
  11537. * // => true
  11538. *
  11539. * _.isEmpty([1, 2, 3]);
  11540. * // => false
  11541. *
  11542. * _.isEmpty({ 'a': 1 });
  11543. * // => false
  11544. */
  11545. function isEmpty(value) {
  11546. if (value == null) {
  11547. return true;
  11548. }
  11549. if (isArrayLike(value) &&
  11550. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  11551. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  11552. return !value.length;
  11553. }
  11554. var tag = getTag(value);
  11555. if (tag == mapTag || tag == setTag) {
  11556. return !value.size;
  11557. }
  11558. if (isPrototype(value)) {
  11559. return !baseKeys(value).length;
  11560. }
  11561. for (var key in value) {
  11562. if (hasOwnProperty.call(value, key)) {
  11563. return false;
  11564. }
  11565. }
  11566. return true;
  11567. }
  11568. /**
  11569. * Performs a deep comparison between two values to determine if they are
  11570. * equivalent.
  11571. *
  11572. * **Note:** This method supports comparing arrays, array buffers, booleans,
  11573. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  11574. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  11575. * by their own, not inherited, enumerable properties. Functions and DOM
  11576. * nodes are compared by strict equality, i.e. `===`.
  11577. *
  11578. * @static
  11579. * @memberOf _
  11580. * @since 0.1.0
  11581. * @category Lang
  11582. * @param {*} value The value to compare.
  11583. * @param {*} other The other value to compare.
  11584. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11585. * @example
  11586. *
  11587. * var object = { 'a': 1 };
  11588. * var other = { 'a': 1 };
  11589. *
  11590. * _.isEqual(object, other);
  11591. * // => true
  11592. *
  11593. * object === other;
  11594. * // => false
  11595. */
  11596. function isEqual(value, other) {
  11597. return baseIsEqual(value, other);
  11598. }
  11599. /**
  11600. * This method is like `_.isEqual` except that it accepts `customizer` which
  11601. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  11602. * are handled by the method instead. The `customizer` is invoked with up to
  11603. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  11604. *
  11605. * @static
  11606. * @memberOf _
  11607. * @since 4.0.0
  11608. * @category Lang
  11609. * @param {*} value The value to compare.
  11610. * @param {*} other The other value to compare.
  11611. * @param {Function} [customizer] The function to customize comparisons.
  11612. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11613. * @example
  11614. *
  11615. * function isGreeting(value) {
  11616. * return /^h(?:i|ello)$/.test(value);
  11617. * }
  11618. *
  11619. * function customizer(objValue, othValue) {
  11620. * if (isGreeting(objValue) && isGreeting(othValue)) {
  11621. * return true;
  11622. * }
  11623. * }
  11624. *
  11625. * var array = ['hello', 'goodbye'];
  11626. * var other = ['hi', 'goodbye'];
  11627. *
  11628. * _.isEqualWith(array, other, customizer);
  11629. * // => true
  11630. */
  11631. function isEqualWith(value, other, customizer) {
  11632. customizer = typeof customizer == 'function' ? customizer : undefined;
  11633. var result = customizer ? customizer(value, other) : undefined;
  11634. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  11635. }
  11636. /**
  11637. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  11638. * `SyntaxError`, `TypeError`, or `URIError` object.
  11639. *
  11640. * @static
  11641. * @memberOf _
  11642. * @since 3.0.0
  11643. * @category Lang
  11644. * @param {*} value The value to check.
  11645. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  11646. * @example
  11647. *
  11648. * _.isError(new Error);
  11649. * // => true
  11650. *
  11651. * _.isError(Error);
  11652. * // => false
  11653. */
  11654. function isError(value) {
  11655. if (!isObjectLike(value)) {
  11656. return false;
  11657. }
  11658. var tag = baseGetTag(value);
  11659. return tag == errorTag || tag == domExcTag ||
  11660. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  11661. }
  11662. /**
  11663. * Checks if `value` is a finite primitive number.
  11664. *
  11665. * **Note:** This method is based on
  11666. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  11667. *
  11668. * @static
  11669. * @memberOf _
  11670. * @since 0.1.0
  11671. * @category Lang
  11672. * @param {*} value The value to check.
  11673. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  11674. * @example
  11675. *
  11676. * _.isFinite(3);
  11677. * // => true
  11678. *
  11679. * _.isFinite(Number.MIN_VALUE);
  11680. * // => true
  11681. *
  11682. * _.isFinite(Infinity);
  11683. * // => false
  11684. *
  11685. * _.isFinite('3');
  11686. * // => false
  11687. */
  11688. function isFinite(value) {
  11689. return typeof value == 'number' && nativeIsFinite(value);
  11690. }
  11691. /**
  11692. * Checks if `value` is classified as a `Function` object.
  11693. *
  11694. * @static
  11695. * @memberOf _
  11696. * @since 0.1.0
  11697. * @category Lang
  11698. * @param {*} value The value to check.
  11699. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  11700. * @example
  11701. *
  11702. * _.isFunction(_);
  11703. * // => true
  11704. *
  11705. * _.isFunction(/abc/);
  11706. * // => false
  11707. */
  11708. function isFunction(value) {
  11709. if (!isObject(value)) {
  11710. return false;
  11711. }
  11712. // The use of `Object#toString` avoids issues with the `typeof` operator
  11713. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  11714. var tag = baseGetTag(value);
  11715. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  11716. }
  11717. /**
  11718. * Checks if `value` is an integer.
  11719. *
  11720. * **Note:** This method is based on
  11721. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  11722. *
  11723. * @static
  11724. * @memberOf _
  11725. * @since 4.0.0
  11726. * @category Lang
  11727. * @param {*} value The value to check.
  11728. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  11729. * @example
  11730. *
  11731. * _.isInteger(3);
  11732. * // => true
  11733. *
  11734. * _.isInteger(Number.MIN_VALUE);
  11735. * // => false
  11736. *
  11737. * _.isInteger(Infinity);
  11738. * // => false
  11739. *
  11740. * _.isInteger('3');
  11741. * // => false
  11742. */
  11743. function isInteger(value) {
  11744. return typeof value == 'number' && value == toInteger(value);
  11745. }
  11746. /**
  11747. * Checks if `value` is a valid array-like length.
  11748. *
  11749. * **Note:** This method is loosely based on
  11750. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  11751. *
  11752. * @static
  11753. * @memberOf _
  11754. * @since 4.0.0
  11755. * @category Lang
  11756. * @param {*} value The value to check.
  11757. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  11758. * @example
  11759. *
  11760. * _.isLength(3);
  11761. * // => true
  11762. *
  11763. * _.isLength(Number.MIN_VALUE);
  11764. * // => false
  11765. *
  11766. * _.isLength(Infinity);
  11767. * // => false
  11768. *
  11769. * _.isLength('3');
  11770. * // => false
  11771. */
  11772. function isLength(value) {
  11773. return typeof value == 'number' &&
  11774. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  11775. }
  11776. /**
  11777. * Checks if `value` is the
  11778. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  11779. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  11780. *
  11781. * @static
  11782. * @memberOf _
  11783. * @since 0.1.0
  11784. * @category Lang
  11785. * @param {*} value The value to check.
  11786. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  11787. * @example
  11788. *
  11789. * _.isObject({});
  11790. * // => true
  11791. *
  11792. * _.isObject([1, 2, 3]);
  11793. * // => true
  11794. *
  11795. * _.isObject(_.noop);
  11796. * // => true
  11797. *
  11798. * _.isObject(null);
  11799. * // => false
  11800. */
  11801. function isObject(value) {
  11802. var type = typeof value;
  11803. return value != null && (type == 'object' || type == 'function');
  11804. }
  11805. /**
  11806. * Checks if `value` is object-like. A value is object-like if it's not `null`
  11807. * and has a `typeof` result of "object".
  11808. *
  11809. * @static
  11810. * @memberOf _
  11811. * @since 4.0.0
  11812. * @category Lang
  11813. * @param {*} value The value to check.
  11814. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  11815. * @example
  11816. *
  11817. * _.isObjectLike({});
  11818. * // => true
  11819. *
  11820. * _.isObjectLike([1, 2, 3]);
  11821. * // => true
  11822. *
  11823. * _.isObjectLike(_.noop);
  11824. * // => false
  11825. *
  11826. * _.isObjectLike(null);
  11827. * // => false
  11828. */
  11829. function isObjectLike(value) {
  11830. return value != null && typeof value == 'object';
  11831. }
  11832. /**
  11833. * Checks if `value` is classified as a `Map` object.
  11834. *
  11835. * @static
  11836. * @memberOf _
  11837. * @since 4.3.0
  11838. * @category Lang
  11839. * @param {*} value The value to check.
  11840. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11841. * @example
  11842. *
  11843. * _.isMap(new Map);
  11844. * // => true
  11845. *
  11846. * _.isMap(new WeakMap);
  11847. * // => false
  11848. */
  11849. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  11850. /**
  11851. * Performs a partial deep comparison between `object` and `source` to
  11852. * determine if `object` contains equivalent property values.
  11853. *
  11854. * **Note:** This method is equivalent to `_.matches` when `source` is
  11855. * partially applied.
  11856. *
  11857. * Partial comparisons will match empty array and empty object `source`
  11858. * values against any array or object value, respectively. See `_.isEqual`
  11859. * for a list of supported value comparisons.
  11860. *
  11861. * @static
  11862. * @memberOf _
  11863. * @since 3.0.0
  11864. * @category Lang
  11865. * @param {Object} object The object to inspect.
  11866. * @param {Object} source The object of property values to match.
  11867. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  11868. * @example
  11869. *
  11870. * var object = { 'a': 1, 'b': 2 };
  11871. *
  11872. * _.isMatch(object, { 'b': 2 });
  11873. * // => true
  11874. *
  11875. * _.isMatch(object, { 'b': 1 });
  11876. * // => false
  11877. */
  11878. function isMatch(object, source) {
  11879. return object === source || baseIsMatch(object, source, getMatchData(source));
  11880. }
  11881. /**
  11882. * This method is like `_.isMatch` except that it accepts `customizer` which
  11883. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  11884. * are handled by the method instead. The `customizer` is invoked with five
  11885. * arguments: (objValue, srcValue, index|key, object, source).
  11886. *
  11887. * @static
  11888. * @memberOf _
  11889. * @since 4.0.0
  11890. * @category Lang
  11891. * @param {Object} object The object to inspect.
  11892. * @param {Object} source The object of property values to match.
  11893. * @param {Function} [customizer] The function to customize comparisons.
  11894. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  11895. * @example
  11896. *
  11897. * function isGreeting(value) {
  11898. * return /^h(?:i|ello)$/.test(value);
  11899. * }
  11900. *
  11901. * function customizer(objValue, srcValue) {
  11902. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  11903. * return true;
  11904. * }
  11905. * }
  11906. *
  11907. * var object = { 'greeting': 'hello' };
  11908. * var source = { 'greeting': 'hi' };
  11909. *
  11910. * _.isMatchWith(object, source, customizer);
  11911. * // => true
  11912. */
  11913. function isMatchWith(object, source, customizer) {
  11914. customizer = typeof customizer == 'function' ? customizer : undefined;
  11915. return baseIsMatch(object, source, getMatchData(source), customizer);
  11916. }
  11917. /**
  11918. * Checks if `value` is `NaN`.
  11919. *
  11920. * **Note:** This method is based on
  11921. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  11922. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  11923. * `undefined` and other non-number values.
  11924. *
  11925. * @static
  11926. * @memberOf _
  11927. * @since 0.1.0
  11928. * @category Lang
  11929. * @param {*} value The value to check.
  11930. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  11931. * @example
  11932. *
  11933. * _.isNaN(NaN);
  11934. * // => true
  11935. *
  11936. * _.isNaN(new Number(NaN));
  11937. * // => true
  11938. *
  11939. * isNaN(undefined);
  11940. * // => true
  11941. *
  11942. * _.isNaN(undefined);
  11943. * // => false
  11944. */
  11945. function isNaN(value) {
  11946. // An `NaN` primitive is the only value that is not equal to itself.
  11947. // Perform the `toStringTag` check first to avoid errors with some
  11948. // ActiveX objects in IE.
  11949. return isNumber(value) && value != +value;
  11950. }
  11951. /**
  11952. * Checks if `value` is a pristine native function.
  11953. *
  11954. * **Note:** This method can't reliably detect native functions in the presence
  11955. * of the core-js package because core-js circumvents this kind of detection.
  11956. * Despite multiple requests, the core-js maintainer has made it clear: any
  11957. * attempt to fix the detection will be obstructed. As a result, we're left
  11958. * with little choice but to throw an error. Unfortunately, this also affects
  11959. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  11960. * which rely on core-js.
  11961. *
  11962. * @static
  11963. * @memberOf _
  11964. * @since 3.0.0
  11965. * @category Lang
  11966. * @param {*} value The value to check.
  11967. * @returns {boolean} Returns `true` if `value` is a native function,
  11968. * else `false`.
  11969. * @example
  11970. *
  11971. * _.isNative(Array.prototype.push);
  11972. * // => true
  11973. *
  11974. * _.isNative(_);
  11975. * // => false
  11976. */
  11977. function isNative(value) {
  11978. if (isMaskable(value)) {
  11979. throw new Error(CORE_ERROR_TEXT);
  11980. }
  11981. return baseIsNative(value);
  11982. }
  11983. /**
  11984. * Checks if `value` is `null`.
  11985. *
  11986. * @static
  11987. * @memberOf _
  11988. * @since 0.1.0
  11989. * @category Lang
  11990. * @param {*} value The value to check.
  11991. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  11992. * @example
  11993. *
  11994. * _.isNull(null);
  11995. * // => true
  11996. *
  11997. * _.isNull(void 0);
  11998. * // => false
  11999. */
  12000. function isNull(value) {
  12001. return value === null;
  12002. }
  12003. /**
  12004. * Checks if `value` is `null` or `undefined`.
  12005. *
  12006. * @static
  12007. * @memberOf _
  12008. * @since 4.0.0
  12009. * @category Lang
  12010. * @param {*} value The value to check.
  12011. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  12012. * @example
  12013. *
  12014. * _.isNil(null);
  12015. * // => true
  12016. *
  12017. * _.isNil(void 0);
  12018. * // => true
  12019. *
  12020. * _.isNil(NaN);
  12021. * // => false
  12022. */
  12023. function isNil(value) {
  12024. return value == null;
  12025. }
  12026. /**
  12027. * Checks if `value` is classified as a `Number` primitive or object.
  12028. *
  12029. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  12030. * classified as numbers, use the `_.isFinite` method.
  12031. *
  12032. * @static
  12033. * @memberOf _
  12034. * @since 0.1.0
  12035. * @category Lang
  12036. * @param {*} value The value to check.
  12037. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  12038. * @example
  12039. *
  12040. * _.isNumber(3);
  12041. * // => true
  12042. *
  12043. * _.isNumber(Number.MIN_VALUE);
  12044. * // => true
  12045. *
  12046. * _.isNumber(Infinity);
  12047. * // => true
  12048. *
  12049. * _.isNumber('3');
  12050. * // => false
  12051. */
  12052. function isNumber(value) {
  12053. return typeof value == 'number' ||
  12054. (isObjectLike(value) && baseGetTag(value) == numberTag);
  12055. }
  12056. /**
  12057. * Checks if `value` is a plain object, that is, an object created by the
  12058. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  12059. *
  12060. * @static
  12061. * @memberOf _
  12062. * @since 0.8.0
  12063. * @category Lang
  12064. * @param {*} value The value to check.
  12065. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  12066. * @example
  12067. *
  12068. * function Foo() {
  12069. * this.a = 1;
  12070. * }
  12071. *
  12072. * _.isPlainObject(new Foo);
  12073. * // => false
  12074. *
  12075. * _.isPlainObject([1, 2, 3]);
  12076. * // => false
  12077. *
  12078. * _.isPlainObject({ 'x': 0, 'y': 0 });
  12079. * // => true
  12080. *
  12081. * _.isPlainObject(Object.create(null));
  12082. * // => true
  12083. */
  12084. function isPlainObject(value) {
  12085. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  12086. return false;
  12087. }
  12088. var proto = getPrototype(value);
  12089. if (proto === null) {
  12090. return true;
  12091. }
  12092. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  12093. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  12094. funcToString.call(Ctor) == objectCtorString;
  12095. }
  12096. /**
  12097. * Checks if `value` is classified as a `RegExp` object.
  12098. *
  12099. * @static
  12100. * @memberOf _
  12101. * @since 0.1.0
  12102. * @category Lang
  12103. * @param {*} value The value to check.
  12104. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  12105. * @example
  12106. *
  12107. * _.isRegExp(/abc/);
  12108. * // => true
  12109. *
  12110. * _.isRegExp('/abc/');
  12111. * // => false
  12112. */
  12113. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  12114. /**
  12115. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  12116. * double precision number which isn't the result of a rounded unsafe integer.
  12117. *
  12118. * **Note:** This method is based on
  12119. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  12120. *
  12121. * @static
  12122. * @memberOf _
  12123. * @since 4.0.0
  12124. * @category Lang
  12125. * @param {*} value The value to check.
  12126. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  12127. * @example
  12128. *
  12129. * _.isSafeInteger(3);
  12130. * // => true
  12131. *
  12132. * _.isSafeInteger(Number.MIN_VALUE);
  12133. * // => false
  12134. *
  12135. * _.isSafeInteger(Infinity);
  12136. * // => false
  12137. *
  12138. * _.isSafeInteger('3');
  12139. * // => false
  12140. */
  12141. function isSafeInteger(value) {
  12142. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  12143. }
  12144. /**
  12145. * Checks if `value` is classified as a `Set` object.
  12146. *
  12147. * @static
  12148. * @memberOf _
  12149. * @since 4.3.0
  12150. * @category Lang
  12151. * @param {*} value The value to check.
  12152. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  12153. * @example
  12154. *
  12155. * _.isSet(new Set);
  12156. * // => true
  12157. *
  12158. * _.isSet(new WeakSet);
  12159. * // => false
  12160. */
  12161. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  12162. /**
  12163. * Checks if `value` is classified as a `String` primitive or object.
  12164. *
  12165. * @static
  12166. * @since 0.1.0
  12167. * @memberOf _
  12168. * @category Lang
  12169. * @param {*} value The value to check.
  12170. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  12171. * @example
  12172. *
  12173. * _.isString('abc');
  12174. * // => true
  12175. *
  12176. * _.isString(1);
  12177. * // => false
  12178. */
  12179. function isString(value) {
  12180. return typeof value == 'string' ||
  12181. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  12182. }
  12183. /**
  12184. * Checks if `value` is classified as a `Symbol` primitive or object.
  12185. *
  12186. * @static
  12187. * @memberOf _
  12188. * @since 4.0.0
  12189. * @category Lang
  12190. * @param {*} value The value to check.
  12191. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  12192. * @example
  12193. *
  12194. * _.isSymbol(Symbol.iterator);
  12195. * // => true
  12196. *
  12197. * _.isSymbol('abc');
  12198. * // => false
  12199. */
  12200. function isSymbol(value) {
  12201. return typeof value == 'symbol' ||
  12202. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  12203. }
  12204. /**
  12205. * Checks if `value` is classified as a typed array.
  12206. *
  12207. * @static
  12208. * @memberOf _
  12209. * @since 3.0.0
  12210. * @category Lang
  12211. * @param {*} value The value to check.
  12212. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  12213. * @example
  12214. *
  12215. * _.isTypedArray(new Uint8Array);
  12216. * // => true
  12217. *
  12218. * _.isTypedArray([]);
  12219. * // => false
  12220. */
  12221. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  12222. /**
  12223. * Checks if `value` is `undefined`.
  12224. *
  12225. * @static
  12226. * @since 0.1.0
  12227. * @memberOf _
  12228. * @category Lang
  12229. * @param {*} value The value to check.
  12230. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  12231. * @example
  12232. *
  12233. * _.isUndefined(void 0);
  12234. * // => true
  12235. *
  12236. * _.isUndefined(null);
  12237. * // => false
  12238. */
  12239. function isUndefined(value) {
  12240. return value === undefined;
  12241. }
  12242. /**
  12243. * Checks if `value` is classified as a `WeakMap` object.
  12244. *
  12245. * @static
  12246. * @memberOf _
  12247. * @since 4.3.0
  12248. * @category Lang
  12249. * @param {*} value The value to check.
  12250. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  12251. * @example
  12252. *
  12253. * _.isWeakMap(new WeakMap);
  12254. * // => true
  12255. *
  12256. * _.isWeakMap(new Map);
  12257. * // => false
  12258. */
  12259. function isWeakMap(value) {
  12260. return isObjectLike(value) && getTag(value) == weakMapTag;
  12261. }
  12262. /**
  12263. * Checks if `value` is classified as a `WeakSet` object.
  12264. *
  12265. * @static
  12266. * @memberOf _
  12267. * @since 4.3.0
  12268. * @category Lang
  12269. * @param {*} value The value to check.
  12270. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  12271. * @example
  12272. *
  12273. * _.isWeakSet(new WeakSet);
  12274. * // => true
  12275. *
  12276. * _.isWeakSet(new Set);
  12277. * // => false
  12278. */
  12279. function isWeakSet(value) {
  12280. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  12281. }
  12282. /**
  12283. * Checks if `value` is less than `other`.
  12284. *
  12285. * @static
  12286. * @memberOf _
  12287. * @since 3.9.0
  12288. * @category Lang
  12289. * @param {*} value The value to compare.
  12290. * @param {*} other The other value to compare.
  12291. * @returns {boolean} Returns `true` if `value` is less than `other`,
  12292. * else `false`.
  12293. * @see _.gt
  12294. * @example
  12295. *
  12296. * _.lt(1, 3);
  12297. * // => true
  12298. *
  12299. * _.lt(3, 3);
  12300. * // => false
  12301. *
  12302. * _.lt(3, 1);
  12303. * // => false
  12304. */
  12305. var lt = createRelationalOperation(baseLt);
  12306. /**
  12307. * Checks if `value` is less than or equal to `other`.
  12308. *
  12309. * @static
  12310. * @memberOf _
  12311. * @since 3.9.0
  12312. * @category Lang
  12313. * @param {*} value The value to compare.
  12314. * @param {*} other The other value to compare.
  12315. * @returns {boolean} Returns `true` if `value` is less than or equal to
  12316. * `other`, else `false`.
  12317. * @see _.gte
  12318. * @example
  12319. *
  12320. * _.lte(1, 3);
  12321. * // => true
  12322. *
  12323. * _.lte(3, 3);
  12324. * // => true
  12325. *
  12326. * _.lte(3, 1);
  12327. * // => false
  12328. */
  12329. var lte = createRelationalOperation(function(value, other) {
  12330. return value <= other;
  12331. });
  12332. /**
  12333. * Converts `value` to an array.
  12334. *
  12335. * @static
  12336. * @since 0.1.0
  12337. * @memberOf _
  12338. * @category Lang
  12339. * @param {*} value The value to convert.
  12340. * @returns {Array} Returns the converted array.
  12341. * @example
  12342. *
  12343. * _.toArray({ 'a': 1, 'b': 2 });
  12344. * // => [1, 2]
  12345. *
  12346. * _.toArray('abc');
  12347. * // => ['a', 'b', 'c']
  12348. *
  12349. * _.toArray(1);
  12350. * // => []
  12351. *
  12352. * _.toArray(null);
  12353. * // => []
  12354. */
  12355. function toArray(value) {
  12356. if (!value) {
  12357. return [];
  12358. }
  12359. if (isArrayLike(value)) {
  12360. return isString(value) ? stringToArray(value) : copyArray(value);
  12361. }
  12362. if (symIterator && value[symIterator]) {
  12363. return iteratorToArray(value[symIterator]());
  12364. }
  12365. var tag = getTag(value),
  12366. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  12367. return func(value);
  12368. }
  12369. /**
  12370. * Converts `value` to a finite number.
  12371. *
  12372. * @static
  12373. * @memberOf _
  12374. * @since 4.12.0
  12375. * @category Lang
  12376. * @param {*} value The value to convert.
  12377. * @returns {number} Returns the converted number.
  12378. * @example
  12379. *
  12380. * _.toFinite(3.2);
  12381. * // => 3.2
  12382. *
  12383. * _.toFinite(Number.MIN_VALUE);
  12384. * // => 5e-324
  12385. *
  12386. * _.toFinite(Infinity);
  12387. * // => 1.7976931348623157e+308
  12388. *
  12389. * _.toFinite('3.2');
  12390. * // => 3.2
  12391. */
  12392. function toFinite(value) {
  12393. if (!value) {
  12394. return value === 0 ? value : 0;
  12395. }
  12396. value = toNumber(value);
  12397. if (value === INFINITY || value === -INFINITY) {
  12398. var sign = (value < 0 ? -1 : 1);
  12399. return sign * MAX_INTEGER;
  12400. }
  12401. return value === value ? value : 0;
  12402. }
  12403. /**
  12404. * Converts `value` to an integer.
  12405. *
  12406. * **Note:** This method is loosely based on
  12407. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  12408. *
  12409. * @static
  12410. * @memberOf _
  12411. * @since 4.0.0
  12412. * @category Lang
  12413. * @param {*} value The value to convert.
  12414. * @returns {number} Returns the converted integer.
  12415. * @example
  12416. *
  12417. * _.toInteger(3.2);
  12418. * // => 3
  12419. *
  12420. * _.toInteger(Number.MIN_VALUE);
  12421. * // => 0
  12422. *
  12423. * _.toInteger(Infinity);
  12424. * // => 1.7976931348623157e+308
  12425. *
  12426. * _.toInteger('3.2');
  12427. * // => 3
  12428. */
  12429. function toInteger(value) {
  12430. var result = toFinite(value),
  12431. remainder = result % 1;
  12432. return result === result ? (remainder ? result - remainder : result) : 0;
  12433. }
  12434. /**
  12435. * Converts `value` to an integer suitable for use as the length of an
  12436. * array-like object.
  12437. *
  12438. * **Note:** This method is based on
  12439. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  12440. *
  12441. * @static
  12442. * @memberOf _
  12443. * @since 4.0.0
  12444. * @category Lang
  12445. * @param {*} value The value to convert.
  12446. * @returns {number} Returns the converted integer.
  12447. * @example
  12448. *
  12449. * _.toLength(3.2);
  12450. * // => 3
  12451. *
  12452. * _.toLength(Number.MIN_VALUE);
  12453. * // => 0
  12454. *
  12455. * _.toLength(Infinity);
  12456. * // => 4294967295
  12457. *
  12458. * _.toLength('3.2');
  12459. * // => 3
  12460. */
  12461. function toLength(value) {
  12462. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  12463. }
  12464. /**
  12465. * Converts `value` to a number.
  12466. *
  12467. * @static
  12468. * @memberOf _
  12469. * @since 4.0.0
  12470. * @category Lang
  12471. * @param {*} value The value to process.
  12472. * @returns {number} Returns the number.
  12473. * @example
  12474. *
  12475. * _.toNumber(3.2);
  12476. * // => 3.2
  12477. *
  12478. * _.toNumber(Number.MIN_VALUE);
  12479. * // => 5e-324
  12480. *
  12481. * _.toNumber(Infinity);
  12482. * // => Infinity
  12483. *
  12484. * _.toNumber('3.2');
  12485. * // => 3.2
  12486. */
  12487. function toNumber(value) {
  12488. if (typeof value == 'number') {
  12489. return value;
  12490. }
  12491. if (isSymbol(value)) {
  12492. return NAN;
  12493. }
  12494. if (isObject(value)) {
  12495. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  12496. value = isObject(other) ? (other + '') : other;
  12497. }
  12498. if (typeof value != 'string') {
  12499. return value === 0 ? value : +value;
  12500. }
  12501. value = value.replace(reTrim, '');
  12502. var isBinary = reIsBinary.test(value);
  12503. return (isBinary || reIsOctal.test(value))
  12504. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  12505. : (reIsBadHex.test(value) ? NAN : +value);
  12506. }
  12507. /**
  12508. * Converts `value` to a plain object flattening inherited enumerable string
  12509. * keyed properties of `value` to own properties of the plain object.
  12510. *
  12511. * @static
  12512. * @memberOf _
  12513. * @since 3.0.0
  12514. * @category Lang
  12515. * @param {*} value The value to convert.
  12516. * @returns {Object} Returns the converted plain object.
  12517. * @example
  12518. *
  12519. * function Foo() {
  12520. * this.b = 2;
  12521. * }
  12522. *
  12523. * Foo.prototype.c = 3;
  12524. *
  12525. * _.assign({ 'a': 1 }, new Foo);
  12526. * // => { 'a': 1, 'b': 2 }
  12527. *
  12528. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  12529. * // => { 'a': 1, 'b': 2, 'c': 3 }
  12530. */
  12531. function toPlainObject(value) {
  12532. return copyObject(value, keysIn(value));
  12533. }
  12534. /**
  12535. * Converts `value` to a safe integer. A safe integer can be compared and
  12536. * represented correctly.
  12537. *
  12538. * @static
  12539. * @memberOf _
  12540. * @since 4.0.0
  12541. * @category Lang
  12542. * @param {*} value The value to convert.
  12543. * @returns {number} Returns the converted integer.
  12544. * @example
  12545. *
  12546. * _.toSafeInteger(3.2);
  12547. * // => 3
  12548. *
  12549. * _.toSafeInteger(Number.MIN_VALUE);
  12550. * // => 0
  12551. *
  12552. * _.toSafeInteger(Infinity);
  12553. * // => 9007199254740991
  12554. *
  12555. * _.toSafeInteger('3.2');
  12556. * // => 3
  12557. */
  12558. function toSafeInteger(value) {
  12559. return value
  12560. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  12561. : (value === 0 ? value : 0);
  12562. }
  12563. /**
  12564. * Converts `value` to a string. An empty string is returned for `null`
  12565. * and `undefined` values. The sign of `-0` is preserved.
  12566. *
  12567. * @static
  12568. * @memberOf _
  12569. * @since 4.0.0
  12570. * @category Lang
  12571. * @param {*} value The value to convert.
  12572. * @returns {string} Returns the converted string.
  12573. * @example
  12574. *
  12575. * _.toString(null);
  12576. * // => ''
  12577. *
  12578. * _.toString(-0);
  12579. * // => '-0'
  12580. *
  12581. * _.toString([1, 2, 3]);
  12582. * // => '1,2,3'
  12583. */
  12584. function toString(value) {
  12585. return value == null ? '' : baseToString(value);
  12586. }
  12587. /*------------------------------------------------------------------------*/
  12588. /**
  12589. * Assigns own enumerable string keyed properties of source objects to the
  12590. * destination object. Source objects are applied from left to right.
  12591. * Subsequent sources overwrite property assignments of previous sources.
  12592. *
  12593. * **Note:** This method mutates `object` and is loosely based on
  12594. * [`Object.assign`](https://mdn.io/Object/assign).
  12595. *
  12596. * @static
  12597. * @memberOf _
  12598. * @since 0.10.0
  12599. * @category Object
  12600. * @param {Object} object The destination object.
  12601. * @param {...Object} [sources] The source objects.
  12602. * @returns {Object} Returns `object`.
  12603. * @see _.assignIn
  12604. * @example
  12605. *
  12606. * function Foo() {
  12607. * this.a = 1;
  12608. * }
  12609. *
  12610. * function Bar() {
  12611. * this.c = 3;
  12612. * }
  12613. *
  12614. * Foo.prototype.b = 2;
  12615. * Bar.prototype.d = 4;
  12616. *
  12617. * _.assign({ 'a': 0 }, new Foo, new Bar);
  12618. * // => { 'a': 1, 'c': 3 }
  12619. */
  12620. var assign = createAssigner(function(object, source) {
  12621. if (isPrototype(source) || isArrayLike(source)) {
  12622. copyObject(source, keys(source), object);
  12623. return;
  12624. }
  12625. for (var key in source) {
  12626. if (hasOwnProperty.call(source, key)) {
  12627. assignValue(object, key, source[key]);
  12628. }
  12629. }
  12630. });
  12631. /**
  12632. * This method is like `_.assign` except that it iterates over own and
  12633. * inherited source properties.
  12634. *
  12635. * **Note:** This method mutates `object`.
  12636. *
  12637. * @static
  12638. * @memberOf _
  12639. * @since 4.0.0
  12640. * @alias extend
  12641. * @category Object
  12642. * @param {Object} object The destination object.
  12643. * @param {...Object} [sources] The source objects.
  12644. * @returns {Object} Returns `object`.
  12645. * @see _.assign
  12646. * @example
  12647. *
  12648. * function Foo() {
  12649. * this.a = 1;
  12650. * }
  12651. *
  12652. * function Bar() {
  12653. * this.c = 3;
  12654. * }
  12655. *
  12656. * Foo.prototype.b = 2;
  12657. * Bar.prototype.d = 4;
  12658. *
  12659. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  12660. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  12661. */
  12662. var assignIn = createAssigner(function(object, source) {
  12663. copyObject(source, keysIn(source), object);
  12664. });
  12665. /**
  12666. * This method is like `_.assignIn` except that it accepts `customizer`
  12667. * which is invoked to produce the assigned values. If `customizer` returns
  12668. * `undefined`, assignment is handled by the method instead. The `customizer`
  12669. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  12670. *
  12671. * **Note:** This method mutates `object`.
  12672. *
  12673. * @static
  12674. * @memberOf _
  12675. * @since 4.0.0
  12676. * @alias extendWith
  12677. * @category Object
  12678. * @param {Object} object The destination object.
  12679. * @param {...Object} sources The source objects.
  12680. * @param {Function} [customizer] The function to customize assigned values.
  12681. * @returns {Object} Returns `object`.
  12682. * @see _.assignWith
  12683. * @example
  12684. *
  12685. * function customizer(objValue, srcValue) {
  12686. * return _.isUndefined(objValue) ? srcValue : objValue;
  12687. * }
  12688. *
  12689. * var defaults = _.partialRight(_.assignInWith, customizer);
  12690. *
  12691. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12692. * // => { 'a': 1, 'b': 2 }
  12693. */
  12694. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  12695. copyObject(source, keysIn(source), object, customizer);
  12696. });
  12697. /**
  12698. * This method is like `_.assign` except that it accepts `customizer`
  12699. * which is invoked to produce the assigned values. If `customizer` returns
  12700. * `undefined`, assignment is handled by the method instead. The `customizer`
  12701. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  12702. *
  12703. * **Note:** This method mutates `object`.
  12704. *
  12705. * @static
  12706. * @memberOf _
  12707. * @since 4.0.0
  12708. * @category Object
  12709. * @param {Object} object The destination object.
  12710. * @param {...Object} sources The source objects.
  12711. * @param {Function} [customizer] The function to customize assigned values.
  12712. * @returns {Object} Returns `object`.
  12713. * @see _.assignInWith
  12714. * @example
  12715. *
  12716. * function customizer(objValue, srcValue) {
  12717. * return _.isUndefined(objValue) ? srcValue : objValue;
  12718. * }
  12719. *
  12720. * var defaults = _.partialRight(_.assignWith, customizer);
  12721. *
  12722. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12723. * // => { 'a': 1, 'b': 2 }
  12724. */
  12725. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  12726. copyObject(source, keys(source), object, customizer);
  12727. });
  12728. /**
  12729. * Creates an array of values corresponding to `paths` of `object`.
  12730. *
  12731. * @static
  12732. * @memberOf _
  12733. * @since 1.0.0
  12734. * @category Object
  12735. * @param {Object} object The object to iterate over.
  12736. * @param {...(string|string[])} [paths] The property paths to pick.
  12737. * @returns {Array} Returns the picked values.
  12738. * @example
  12739. *
  12740. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  12741. *
  12742. * _.at(object, ['a[0].b.c', 'a[1]']);
  12743. * // => [3, 4]
  12744. */
  12745. var at = flatRest(baseAt);
  12746. /**
  12747. * Creates an object that inherits from the `prototype` object. If a
  12748. * `properties` object is given, its own enumerable string keyed properties
  12749. * are assigned to the created object.
  12750. *
  12751. * @static
  12752. * @memberOf _
  12753. * @since 2.3.0
  12754. * @category Object
  12755. * @param {Object} prototype The object to inherit from.
  12756. * @param {Object} [properties] The properties to assign to the object.
  12757. * @returns {Object} Returns the new object.
  12758. * @example
  12759. *
  12760. * function Shape() {
  12761. * this.x = 0;
  12762. * this.y = 0;
  12763. * }
  12764. *
  12765. * function Circle() {
  12766. * Shape.call(this);
  12767. * }
  12768. *
  12769. * Circle.prototype = _.create(Shape.prototype, {
  12770. * 'constructor': Circle
  12771. * });
  12772. *
  12773. * var circle = new Circle;
  12774. * circle instanceof Circle;
  12775. * // => true
  12776. *
  12777. * circle instanceof Shape;
  12778. * // => true
  12779. */
  12780. function create(prototype, properties) {
  12781. var result = baseCreate(prototype);
  12782. return properties == null ? result : baseAssign(result, properties);
  12783. }
  12784. /**
  12785. * Assigns own and inherited enumerable string keyed properties of source
  12786. * objects to the destination object for all destination properties that
  12787. * resolve to `undefined`. Source objects are applied from left to right.
  12788. * Once a property is set, additional values of the same property are ignored.
  12789. *
  12790. * **Note:** This method mutates `object`.
  12791. *
  12792. * @static
  12793. * @since 0.1.0
  12794. * @memberOf _
  12795. * @category Object
  12796. * @param {Object} object The destination object.
  12797. * @param {...Object} [sources] The source objects.
  12798. * @returns {Object} Returns `object`.
  12799. * @see _.defaultsDeep
  12800. * @example
  12801. *
  12802. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12803. * // => { 'a': 1, 'b': 2 }
  12804. */
  12805. var defaults = baseRest(function(args) {
  12806. args.push(undefined, customDefaultsAssignIn);
  12807. return apply(assignInWith, undefined, args);
  12808. });
  12809. /**
  12810. * This method is like `_.defaults` except that it recursively assigns
  12811. * default properties.
  12812. *
  12813. * **Note:** This method mutates `object`.
  12814. *
  12815. * @static
  12816. * @memberOf _
  12817. * @since 3.10.0
  12818. * @category Object
  12819. * @param {Object} object The destination object.
  12820. * @param {...Object} [sources] The source objects.
  12821. * @returns {Object} Returns `object`.
  12822. * @see _.defaults
  12823. * @example
  12824. *
  12825. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  12826. * // => { 'a': { 'b': 2, 'c': 3 } }
  12827. */
  12828. var defaultsDeep = baseRest(function(args) {
  12829. args.push(undefined, customDefaultsMerge);
  12830. return apply(mergeWith, undefined, args);
  12831. });
  12832. /**
  12833. * This method is like `_.find` except that it returns the key of the first
  12834. * element `predicate` returns truthy for instead of the element itself.
  12835. *
  12836. * @static
  12837. * @memberOf _
  12838. * @since 1.1.0
  12839. * @category Object
  12840. * @param {Object} object The object to inspect.
  12841. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12842. * @returns {string|undefined} Returns the key of the matched element,
  12843. * else `undefined`.
  12844. * @example
  12845. *
  12846. * var users = {
  12847. * 'barney': { 'age': 36, 'active': true },
  12848. * 'fred': { 'age': 40, 'active': false },
  12849. * 'pebbles': { 'age': 1, 'active': true }
  12850. * };
  12851. *
  12852. * _.findKey(users, function(o) { return o.age < 40; });
  12853. * // => 'barney' (iteration order is not guaranteed)
  12854. *
  12855. * // The `_.matches` iteratee shorthand.
  12856. * _.findKey(users, { 'age': 1, 'active': true });
  12857. * // => 'pebbles'
  12858. *
  12859. * // The `_.matchesProperty` iteratee shorthand.
  12860. * _.findKey(users, ['active', false]);
  12861. * // => 'fred'
  12862. *
  12863. * // The `_.property` iteratee shorthand.
  12864. * _.findKey(users, 'active');
  12865. * // => 'barney'
  12866. */
  12867. function findKey(object, predicate) {
  12868. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  12869. }
  12870. /**
  12871. * This method is like `_.findKey` except that it iterates over elements of
  12872. * a collection in the opposite order.
  12873. *
  12874. * @static
  12875. * @memberOf _
  12876. * @since 2.0.0
  12877. * @category Object
  12878. * @param {Object} object The object to inspect.
  12879. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12880. * @returns {string|undefined} Returns the key of the matched element,
  12881. * else `undefined`.
  12882. * @example
  12883. *
  12884. * var users = {
  12885. * 'barney': { 'age': 36, 'active': true },
  12886. * 'fred': { 'age': 40, 'active': false },
  12887. * 'pebbles': { 'age': 1, 'active': true }
  12888. * };
  12889. *
  12890. * _.findLastKey(users, function(o) { return o.age < 40; });
  12891. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  12892. *
  12893. * // The `_.matches` iteratee shorthand.
  12894. * _.findLastKey(users, { 'age': 36, 'active': true });
  12895. * // => 'barney'
  12896. *
  12897. * // The `_.matchesProperty` iteratee shorthand.
  12898. * _.findLastKey(users, ['active', false]);
  12899. * // => 'fred'
  12900. *
  12901. * // The `_.property` iteratee shorthand.
  12902. * _.findLastKey(users, 'active');
  12903. * // => 'pebbles'
  12904. */
  12905. function findLastKey(object, predicate) {
  12906. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  12907. }
  12908. /**
  12909. * Iterates over own and inherited enumerable string keyed properties of an
  12910. * object and invokes `iteratee` for each property. The iteratee is invoked
  12911. * with three arguments: (value, key, object). Iteratee functions may exit
  12912. * iteration early by explicitly returning `false`.
  12913. *
  12914. * @static
  12915. * @memberOf _
  12916. * @since 0.3.0
  12917. * @category Object
  12918. * @param {Object} object The object to iterate over.
  12919. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12920. * @returns {Object} Returns `object`.
  12921. * @see _.forInRight
  12922. * @example
  12923. *
  12924. * function Foo() {
  12925. * this.a = 1;
  12926. * this.b = 2;
  12927. * }
  12928. *
  12929. * Foo.prototype.c = 3;
  12930. *
  12931. * _.forIn(new Foo, function(value, key) {
  12932. * console.log(key);
  12933. * });
  12934. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  12935. */
  12936. function forIn(object, iteratee) {
  12937. return object == null
  12938. ? object
  12939. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  12940. }
  12941. /**
  12942. * This method is like `_.forIn` except that it iterates over properties of
  12943. * `object` in the opposite order.
  12944. *
  12945. * @static
  12946. * @memberOf _
  12947. * @since 2.0.0
  12948. * @category Object
  12949. * @param {Object} object The object to iterate over.
  12950. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12951. * @returns {Object} Returns `object`.
  12952. * @see _.forIn
  12953. * @example
  12954. *
  12955. * function Foo() {
  12956. * this.a = 1;
  12957. * this.b = 2;
  12958. * }
  12959. *
  12960. * Foo.prototype.c = 3;
  12961. *
  12962. * _.forInRight(new Foo, function(value, key) {
  12963. * console.log(key);
  12964. * });
  12965. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  12966. */
  12967. function forInRight(object, iteratee) {
  12968. return object == null
  12969. ? object
  12970. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  12971. }
  12972. /**
  12973. * Iterates over own enumerable string keyed properties of an object and
  12974. * invokes `iteratee` for each property. The iteratee is invoked with three
  12975. * arguments: (value, key, object). Iteratee functions may exit iteration
  12976. * early by explicitly returning `false`.
  12977. *
  12978. * @static
  12979. * @memberOf _
  12980. * @since 0.3.0
  12981. * @category Object
  12982. * @param {Object} object The object to iterate over.
  12983. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12984. * @returns {Object} Returns `object`.
  12985. * @see _.forOwnRight
  12986. * @example
  12987. *
  12988. * function Foo() {
  12989. * this.a = 1;
  12990. * this.b = 2;
  12991. * }
  12992. *
  12993. * Foo.prototype.c = 3;
  12994. *
  12995. * _.forOwn(new Foo, function(value, key) {
  12996. * console.log(key);
  12997. * });
  12998. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  12999. */
  13000. function forOwn(object, iteratee) {
  13001. return object && baseForOwn(object, getIteratee(iteratee, 3));
  13002. }
  13003. /**
  13004. * This method is like `_.forOwn` except that it iterates over properties of
  13005. * `object` in the opposite order.
  13006. *
  13007. * @static
  13008. * @memberOf _
  13009. * @since 2.0.0
  13010. * @category Object
  13011. * @param {Object} object The object to iterate over.
  13012. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13013. * @returns {Object} Returns `object`.
  13014. * @see _.forOwn
  13015. * @example
  13016. *
  13017. * function Foo() {
  13018. * this.a = 1;
  13019. * this.b = 2;
  13020. * }
  13021. *
  13022. * Foo.prototype.c = 3;
  13023. *
  13024. * _.forOwnRight(new Foo, function(value, key) {
  13025. * console.log(key);
  13026. * });
  13027. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  13028. */
  13029. function forOwnRight(object, iteratee) {
  13030. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  13031. }
  13032. /**
  13033. * Creates an array of function property names from own enumerable properties
  13034. * of `object`.
  13035. *
  13036. * @static
  13037. * @since 0.1.0
  13038. * @memberOf _
  13039. * @category Object
  13040. * @param {Object} object The object to inspect.
  13041. * @returns {Array} Returns the function names.
  13042. * @see _.functionsIn
  13043. * @example
  13044. *
  13045. * function Foo() {
  13046. * this.a = _.constant('a');
  13047. * this.b = _.constant('b');
  13048. * }
  13049. *
  13050. * Foo.prototype.c = _.constant('c');
  13051. *
  13052. * _.functions(new Foo);
  13053. * // => ['a', 'b']
  13054. */
  13055. function functions(object) {
  13056. return object == null ? [] : baseFunctions(object, keys(object));
  13057. }
  13058. /**
  13059. * Creates an array of function property names from own and inherited
  13060. * enumerable properties of `object`.
  13061. *
  13062. * @static
  13063. * @memberOf _
  13064. * @since 4.0.0
  13065. * @category Object
  13066. * @param {Object} object The object to inspect.
  13067. * @returns {Array} Returns the function names.
  13068. * @see _.functions
  13069. * @example
  13070. *
  13071. * function Foo() {
  13072. * this.a = _.constant('a');
  13073. * this.b = _.constant('b');
  13074. * }
  13075. *
  13076. * Foo.prototype.c = _.constant('c');
  13077. *
  13078. * _.functionsIn(new Foo);
  13079. * // => ['a', 'b', 'c']
  13080. */
  13081. function functionsIn(object) {
  13082. return object == null ? [] : baseFunctions(object, keysIn(object));
  13083. }
  13084. /**
  13085. * Gets the value at `path` of `object`. If the resolved value is
  13086. * `undefined`, the `defaultValue` is returned in its place.
  13087. *
  13088. * @static
  13089. * @memberOf _
  13090. * @since 3.7.0
  13091. * @category Object
  13092. * @param {Object} object The object to query.
  13093. * @param {Array|string} path The path of the property to get.
  13094. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13095. * @returns {*} Returns the resolved value.
  13096. * @example
  13097. *
  13098. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13099. *
  13100. * _.get(object, 'a[0].b.c');
  13101. * // => 3
  13102. *
  13103. * _.get(object, ['a', '0', 'b', 'c']);
  13104. * // => 3
  13105. *
  13106. * _.get(object, 'a.b.c', 'default');
  13107. * // => 'default'
  13108. */
  13109. function get(object, path, defaultValue) {
  13110. var result = object == null ? undefined : baseGet(object, path);
  13111. return result === undefined ? defaultValue : result;
  13112. }
  13113. /**
  13114. * Checks if `path` is a direct property of `object`.
  13115. *
  13116. * @static
  13117. * @since 0.1.0
  13118. * @memberOf _
  13119. * @category Object
  13120. * @param {Object} object The object to query.
  13121. * @param {Array|string} path The path to check.
  13122. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13123. * @example
  13124. *
  13125. * var object = { 'a': { 'b': 2 } };
  13126. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  13127. *
  13128. * _.has(object, 'a');
  13129. * // => true
  13130. *
  13131. * _.has(object, 'a.b');
  13132. * // => true
  13133. *
  13134. * _.has(object, ['a', 'b']);
  13135. * // => true
  13136. *
  13137. * _.has(other, 'a');
  13138. * // => false
  13139. */
  13140. function has(object, path) {
  13141. return object != null && hasPath(object, path, baseHas);
  13142. }
  13143. /**
  13144. * Checks if `path` is a direct or inherited property of `object`.
  13145. *
  13146. * @static
  13147. * @memberOf _
  13148. * @since 4.0.0
  13149. * @category Object
  13150. * @param {Object} object The object to query.
  13151. * @param {Array|string} path The path to check.
  13152. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13153. * @example
  13154. *
  13155. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  13156. *
  13157. * _.hasIn(object, 'a');
  13158. * // => true
  13159. *
  13160. * _.hasIn(object, 'a.b');
  13161. * // => true
  13162. *
  13163. * _.hasIn(object, ['a', 'b']);
  13164. * // => true
  13165. *
  13166. * _.hasIn(object, 'b');
  13167. * // => false
  13168. */
  13169. function hasIn(object, path) {
  13170. return object != null && hasPath(object, path, baseHasIn);
  13171. }
  13172. /**
  13173. * Creates an object composed of the inverted keys and values of `object`.
  13174. * If `object` contains duplicate values, subsequent values overwrite
  13175. * property assignments of previous values.
  13176. *
  13177. * @static
  13178. * @memberOf _
  13179. * @since 0.7.0
  13180. * @category Object
  13181. * @param {Object} object The object to invert.
  13182. * @returns {Object} Returns the new inverted object.
  13183. * @example
  13184. *
  13185. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13186. *
  13187. * _.invert(object);
  13188. * // => { '1': 'c', '2': 'b' }
  13189. */
  13190. var invert = createInverter(function(result, value, key) {
  13191. result[value] = key;
  13192. }, constant(identity));
  13193. /**
  13194. * This method is like `_.invert` except that the inverted object is generated
  13195. * from the results of running each element of `object` thru `iteratee`. The
  13196. * corresponding inverted value of each inverted key is an array of keys
  13197. * responsible for generating the inverted value. The iteratee is invoked
  13198. * with one argument: (value).
  13199. *
  13200. * @static
  13201. * @memberOf _
  13202. * @since 4.1.0
  13203. * @category Object
  13204. * @param {Object} object The object to invert.
  13205. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13206. * @returns {Object} Returns the new inverted object.
  13207. * @example
  13208. *
  13209. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13210. *
  13211. * _.invertBy(object);
  13212. * // => { '1': ['a', 'c'], '2': ['b'] }
  13213. *
  13214. * _.invertBy(object, function(value) {
  13215. * return 'group' + value;
  13216. * });
  13217. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  13218. */
  13219. var invertBy = createInverter(function(result, value, key) {
  13220. if (hasOwnProperty.call(result, value)) {
  13221. result[value].push(key);
  13222. } else {
  13223. result[value] = [key];
  13224. }
  13225. }, getIteratee);
  13226. /**
  13227. * Invokes the method at `path` of `object`.
  13228. *
  13229. * @static
  13230. * @memberOf _
  13231. * @since 4.0.0
  13232. * @category Object
  13233. * @param {Object} object The object to query.
  13234. * @param {Array|string} path The path of the method to invoke.
  13235. * @param {...*} [args] The arguments to invoke the method with.
  13236. * @returns {*} Returns the result of the invoked method.
  13237. * @example
  13238. *
  13239. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  13240. *
  13241. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  13242. * // => [2, 3]
  13243. */
  13244. var invoke = baseRest(baseInvoke);
  13245. /**
  13246. * Creates an array of the own enumerable property names of `object`.
  13247. *
  13248. * **Note:** Non-object values are coerced to objects. See the
  13249. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  13250. * for more details.
  13251. *
  13252. * @static
  13253. * @since 0.1.0
  13254. * @memberOf _
  13255. * @category Object
  13256. * @param {Object} object The object to query.
  13257. * @returns {Array} Returns the array of property names.
  13258. * @example
  13259. *
  13260. * function Foo() {
  13261. * this.a = 1;
  13262. * this.b = 2;
  13263. * }
  13264. *
  13265. * Foo.prototype.c = 3;
  13266. *
  13267. * _.keys(new Foo);
  13268. * // => ['a', 'b'] (iteration order is not guaranteed)
  13269. *
  13270. * _.keys('hi');
  13271. * // => ['0', '1']
  13272. */
  13273. function keys(object) {
  13274. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  13275. }
  13276. /**
  13277. * Creates an array of the own and inherited enumerable property names of `object`.
  13278. *
  13279. * **Note:** Non-object values are coerced to objects.
  13280. *
  13281. * @static
  13282. * @memberOf _
  13283. * @since 3.0.0
  13284. * @category Object
  13285. * @param {Object} object The object to query.
  13286. * @returns {Array} Returns the array of property names.
  13287. * @example
  13288. *
  13289. * function Foo() {
  13290. * this.a = 1;
  13291. * this.b = 2;
  13292. * }
  13293. *
  13294. * Foo.prototype.c = 3;
  13295. *
  13296. * _.keysIn(new Foo);
  13297. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  13298. */
  13299. function keysIn(object) {
  13300. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  13301. }
  13302. /**
  13303. * The opposite of `_.mapValues`; this method creates an object with the
  13304. * same values as `object` and keys generated by running each own enumerable
  13305. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  13306. * with three arguments: (value, key, object).
  13307. *
  13308. * @static
  13309. * @memberOf _
  13310. * @since 3.8.0
  13311. * @category Object
  13312. * @param {Object} object The object to iterate over.
  13313. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13314. * @returns {Object} Returns the new mapped object.
  13315. * @see _.mapValues
  13316. * @example
  13317. *
  13318. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  13319. * return key + value;
  13320. * });
  13321. * // => { 'a1': 1, 'b2': 2 }
  13322. */
  13323. function mapKeys(object, iteratee) {
  13324. var result = {};
  13325. iteratee = getIteratee(iteratee, 3);
  13326. baseForOwn(object, function(value, key, object) {
  13327. baseAssignValue(result, iteratee(value, key, object), value);
  13328. });
  13329. return result;
  13330. }
  13331. /**
  13332. * Creates an object with the same keys as `object` and values generated
  13333. * by running each own enumerable string keyed property of `object` thru
  13334. * `iteratee`. The iteratee is invoked with three arguments:
  13335. * (value, key, object).
  13336. *
  13337. * @static
  13338. * @memberOf _
  13339. * @since 2.4.0
  13340. * @category Object
  13341. * @param {Object} object The object to iterate over.
  13342. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13343. * @returns {Object} Returns the new mapped object.
  13344. * @see _.mapKeys
  13345. * @example
  13346. *
  13347. * var users = {
  13348. * 'fred': { 'user': 'fred', 'age': 40 },
  13349. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  13350. * };
  13351. *
  13352. * _.mapValues(users, function(o) { return o.age; });
  13353. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  13354. *
  13355. * // The `_.property` iteratee shorthand.
  13356. * _.mapValues(users, 'age');
  13357. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  13358. */
  13359. function mapValues(object, iteratee) {
  13360. var result = {};
  13361. iteratee = getIteratee(iteratee, 3);
  13362. baseForOwn(object, function(value, key, object) {
  13363. baseAssignValue(result, key, iteratee(value, key, object));
  13364. });
  13365. return result;
  13366. }
  13367. /**
  13368. * This method is like `_.assign` except that it recursively merges own and
  13369. * inherited enumerable string keyed properties of source objects into the
  13370. * destination object. Source properties that resolve to `undefined` are
  13371. * skipped if a destination value exists. Array and plain object properties
  13372. * are merged recursively. Other objects and value types are overridden by
  13373. * assignment. Source objects are applied from left to right. Subsequent
  13374. * sources overwrite property assignments of previous sources.
  13375. *
  13376. * **Note:** This method mutates `object`.
  13377. *
  13378. * @static
  13379. * @memberOf _
  13380. * @since 0.5.0
  13381. * @category Object
  13382. * @param {Object} object The destination object.
  13383. * @param {...Object} [sources] The source objects.
  13384. * @returns {Object} Returns `object`.
  13385. * @example
  13386. *
  13387. * var object = {
  13388. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  13389. * };
  13390. *
  13391. * var other = {
  13392. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  13393. * };
  13394. *
  13395. * _.merge(object, other);
  13396. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  13397. */
  13398. var merge = createAssigner(function(object, source, srcIndex) {
  13399. baseMerge(object, source, srcIndex);
  13400. });
  13401. /**
  13402. * This method is like `_.merge` except that it accepts `customizer` which
  13403. * is invoked to produce the merged values of the destination and source
  13404. * properties. If `customizer` returns `undefined`, merging is handled by the
  13405. * method instead. The `customizer` is invoked with six arguments:
  13406. * (objValue, srcValue, key, object, source, stack).
  13407. *
  13408. * **Note:** This method mutates `object`.
  13409. *
  13410. * @static
  13411. * @memberOf _
  13412. * @since 4.0.0
  13413. * @category Object
  13414. * @param {Object} object The destination object.
  13415. * @param {...Object} sources The source objects.
  13416. * @param {Function} customizer The function to customize assigned values.
  13417. * @returns {Object} Returns `object`.
  13418. * @example
  13419. *
  13420. * function customizer(objValue, srcValue) {
  13421. * if (_.isArray(objValue)) {
  13422. * return objValue.concat(srcValue);
  13423. * }
  13424. * }
  13425. *
  13426. * var object = { 'a': [1], 'b': [2] };
  13427. * var other = { 'a': [3], 'b': [4] };
  13428. *
  13429. * _.mergeWith(object, other, customizer);
  13430. * // => { 'a': [1, 3], 'b': [2, 4] }
  13431. */
  13432. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  13433. baseMerge(object, source, srcIndex, customizer);
  13434. });
  13435. /**
  13436. * The opposite of `_.pick`; this method creates an object composed of the
  13437. * own and inherited enumerable property paths of `object` that are not omitted.
  13438. *
  13439. * **Note:** This method is considerably slower than `_.pick`.
  13440. *
  13441. * @static
  13442. * @since 0.1.0
  13443. * @memberOf _
  13444. * @category Object
  13445. * @param {Object} object The source object.
  13446. * @param {...(string|string[])} [paths] The property paths to omit.
  13447. * @returns {Object} Returns the new object.
  13448. * @example
  13449. *
  13450. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13451. *
  13452. * _.omit(object, ['a', 'c']);
  13453. * // => { 'b': '2' }
  13454. */
  13455. var omit = flatRest(function(object, paths) {
  13456. var result = {};
  13457. if (object == null) {
  13458. return result;
  13459. }
  13460. var isDeep = false;
  13461. paths = arrayMap(paths, function(path) {
  13462. path = castPath(path, object);
  13463. isDeep || (isDeep = path.length > 1);
  13464. return path;
  13465. });
  13466. copyObject(object, getAllKeysIn(object), result);
  13467. if (isDeep) {
  13468. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  13469. }
  13470. var length = paths.length;
  13471. while (length--) {
  13472. baseUnset(result, paths[length]);
  13473. }
  13474. return result;
  13475. });
  13476. /**
  13477. * The opposite of `_.pickBy`; this method creates an object composed of
  13478. * the own and inherited enumerable string keyed properties of `object` that
  13479. * `predicate` doesn't return truthy for. The predicate is invoked with two
  13480. * arguments: (value, key).
  13481. *
  13482. * @static
  13483. * @memberOf _
  13484. * @since 4.0.0
  13485. * @category Object
  13486. * @param {Object} object The source object.
  13487. * @param {Function} [predicate=_.identity] The function invoked per property.
  13488. * @returns {Object} Returns the new object.
  13489. * @example
  13490. *
  13491. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13492. *
  13493. * _.omitBy(object, _.isNumber);
  13494. * // => { 'b': '2' }
  13495. */
  13496. function omitBy(object, predicate) {
  13497. return pickBy(object, negate(getIteratee(predicate)));
  13498. }
  13499. /**
  13500. * Creates an object composed of the picked `object` properties.
  13501. *
  13502. * @static
  13503. * @since 0.1.0
  13504. * @memberOf _
  13505. * @category Object
  13506. * @param {Object} object The source object.
  13507. * @param {...(string|string[])} [paths] The property paths to pick.
  13508. * @returns {Object} Returns the new object.
  13509. * @example
  13510. *
  13511. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13512. *
  13513. * _.pick(object, ['a', 'c']);
  13514. * // => { 'a': 1, 'c': 3 }
  13515. */
  13516. var pick = flatRest(function(object, paths) {
  13517. return object == null ? {} : basePick(object, paths);
  13518. });
  13519. /**
  13520. * Creates an object composed of the `object` properties `predicate` returns
  13521. * truthy for. The predicate is invoked with two arguments: (value, key).
  13522. *
  13523. * @static
  13524. * @memberOf _
  13525. * @since 4.0.0
  13526. * @category Object
  13527. * @param {Object} object The source object.
  13528. * @param {Function} [predicate=_.identity] The function invoked per property.
  13529. * @returns {Object} Returns the new object.
  13530. * @example
  13531. *
  13532. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13533. *
  13534. * _.pickBy(object, _.isNumber);
  13535. * // => { 'a': 1, 'c': 3 }
  13536. */
  13537. function pickBy(object, predicate) {
  13538. if (object == null) {
  13539. return {};
  13540. }
  13541. var props = arrayMap(getAllKeysIn(object), function(prop) {
  13542. return [prop];
  13543. });
  13544. predicate = getIteratee(predicate);
  13545. return basePickBy(object, props, function(value, path) {
  13546. return predicate(value, path[0]);
  13547. });
  13548. }
  13549. /**
  13550. * This method is like `_.get` except that if the resolved value is a
  13551. * function it's invoked with the `this` binding of its parent object and
  13552. * its result is returned.
  13553. *
  13554. * @static
  13555. * @since 0.1.0
  13556. * @memberOf _
  13557. * @category Object
  13558. * @param {Object} object The object to query.
  13559. * @param {Array|string} path The path of the property to resolve.
  13560. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13561. * @returns {*} Returns the resolved value.
  13562. * @example
  13563. *
  13564. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  13565. *
  13566. * _.result(object, 'a[0].b.c1');
  13567. * // => 3
  13568. *
  13569. * _.result(object, 'a[0].b.c2');
  13570. * // => 4
  13571. *
  13572. * _.result(object, 'a[0].b.c3', 'default');
  13573. * // => 'default'
  13574. *
  13575. * _.result(object, 'a[0].b.c3', _.constant('default'));
  13576. * // => 'default'
  13577. */
  13578. function result(object, path, defaultValue) {
  13579. path = castPath(path, object);
  13580. var index = -1,
  13581. length = path.length;
  13582. // Ensure the loop is entered when path is empty.
  13583. if (!length) {
  13584. length = 1;
  13585. object = undefined;
  13586. }
  13587. while (++index < length) {
  13588. var value = object == null ? undefined : object[toKey(path[index])];
  13589. if (value === undefined) {
  13590. index = length;
  13591. value = defaultValue;
  13592. }
  13593. object = isFunction(value) ? value.call(object) : value;
  13594. }
  13595. return object;
  13596. }
  13597. /**
  13598. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  13599. * it's created. Arrays are created for missing index properties while objects
  13600. * are created for all other missing properties. Use `_.setWith` to customize
  13601. * `path` creation.
  13602. *
  13603. * **Note:** This method mutates `object`.
  13604. *
  13605. * @static
  13606. * @memberOf _
  13607. * @since 3.7.0
  13608. * @category Object
  13609. * @param {Object} object The object to modify.
  13610. * @param {Array|string} path The path of the property to set.
  13611. * @param {*} value The value to set.
  13612. * @returns {Object} Returns `object`.
  13613. * @example
  13614. *
  13615. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13616. *
  13617. * _.set(object, 'a[0].b.c', 4);
  13618. * console.log(object.a[0].b.c);
  13619. * // => 4
  13620. *
  13621. * _.set(object, ['x', '0', 'y', 'z'], 5);
  13622. * console.log(object.x[0].y.z);
  13623. * // => 5
  13624. */
  13625. function set(object, path, value) {
  13626. return object == null ? object : baseSet(object, path, value);
  13627. }
  13628. /**
  13629. * This method is like `_.set` except that it accepts `customizer` which is
  13630. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  13631. * path creation is handled by the method instead. The `customizer` is invoked
  13632. * with three arguments: (nsValue, key, nsObject).
  13633. *
  13634. * **Note:** This method mutates `object`.
  13635. *
  13636. * @static
  13637. * @memberOf _
  13638. * @since 4.0.0
  13639. * @category Object
  13640. * @param {Object} object The object to modify.
  13641. * @param {Array|string} path The path of the property to set.
  13642. * @param {*} value The value to set.
  13643. * @param {Function} [customizer] The function to customize assigned values.
  13644. * @returns {Object} Returns `object`.
  13645. * @example
  13646. *
  13647. * var object = {};
  13648. *
  13649. * _.setWith(object, '[0][1]', 'a', Object);
  13650. * // => { '0': { '1': 'a' } }
  13651. */
  13652. function setWith(object, path, value, customizer) {
  13653. customizer = typeof customizer == 'function' ? customizer : undefined;
  13654. return object == null ? object : baseSet(object, path, value, customizer);
  13655. }
  13656. /**
  13657. * Creates an array of own enumerable string keyed-value pairs for `object`
  13658. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  13659. * entries are returned.
  13660. *
  13661. * @static
  13662. * @memberOf _
  13663. * @since 4.0.0
  13664. * @alias entries
  13665. * @category Object
  13666. * @param {Object} object The object to query.
  13667. * @returns {Array} Returns the key-value pairs.
  13668. * @example
  13669. *
  13670. * function Foo() {
  13671. * this.a = 1;
  13672. * this.b = 2;
  13673. * }
  13674. *
  13675. * Foo.prototype.c = 3;
  13676. *
  13677. * _.toPairs(new Foo);
  13678. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  13679. */
  13680. var toPairs = createToPairs(keys);
  13681. /**
  13682. * Creates an array of own and inherited enumerable string keyed-value pairs
  13683. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  13684. * or set, its entries are returned.
  13685. *
  13686. * @static
  13687. * @memberOf _
  13688. * @since 4.0.0
  13689. * @alias entriesIn
  13690. * @category Object
  13691. * @param {Object} object The object to query.
  13692. * @returns {Array} Returns the key-value pairs.
  13693. * @example
  13694. *
  13695. * function Foo() {
  13696. * this.a = 1;
  13697. * this.b = 2;
  13698. * }
  13699. *
  13700. * Foo.prototype.c = 3;
  13701. *
  13702. * _.toPairsIn(new Foo);
  13703. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  13704. */
  13705. var toPairsIn = createToPairs(keysIn);
  13706. /**
  13707. * An alternative to `_.reduce`; this method transforms `object` to a new
  13708. * `accumulator` object which is the result of running each of its own
  13709. * enumerable string keyed properties thru `iteratee`, with each invocation
  13710. * potentially mutating the `accumulator` object. If `accumulator` is not
  13711. * provided, a new object with the same `[[Prototype]]` will be used. The
  13712. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  13713. * Iteratee functions may exit iteration early by explicitly returning `false`.
  13714. *
  13715. * @static
  13716. * @memberOf _
  13717. * @since 1.3.0
  13718. * @category Object
  13719. * @param {Object} object The object to iterate over.
  13720. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13721. * @param {*} [accumulator] The custom accumulator value.
  13722. * @returns {*} Returns the accumulated value.
  13723. * @example
  13724. *
  13725. * _.transform([2, 3, 4], function(result, n) {
  13726. * result.push(n *= n);
  13727. * return n % 2 == 0;
  13728. * }, []);
  13729. * // => [4, 9]
  13730. *
  13731. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  13732. * (result[value] || (result[value] = [])).push(key);
  13733. * }, {});
  13734. * // => { '1': ['a', 'c'], '2': ['b'] }
  13735. */
  13736. function transform(object, iteratee, accumulator) {
  13737. var isArr = isArray(object),
  13738. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  13739. iteratee = getIteratee(iteratee, 4);
  13740. if (accumulator == null) {
  13741. var Ctor = object && object.constructor;
  13742. if (isArrLike) {
  13743. accumulator = isArr ? new Ctor : [];
  13744. }
  13745. else if (isObject(object)) {
  13746. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  13747. }
  13748. else {
  13749. accumulator = {};
  13750. }
  13751. }
  13752. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  13753. return iteratee(accumulator, value, index, object);
  13754. });
  13755. return accumulator;
  13756. }
  13757. /**
  13758. * Removes the property at `path` of `object`.
  13759. *
  13760. * **Note:** This method mutates `object`.
  13761. *
  13762. * @static
  13763. * @memberOf _
  13764. * @since 4.0.0
  13765. * @category Object
  13766. * @param {Object} object The object to modify.
  13767. * @param {Array|string} path The path of the property to unset.
  13768. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  13769. * @example
  13770. *
  13771. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  13772. * _.unset(object, 'a[0].b.c');
  13773. * // => true
  13774. *
  13775. * console.log(object);
  13776. * // => { 'a': [{ 'b': {} }] };
  13777. *
  13778. * _.unset(object, ['a', '0', 'b', 'c']);
  13779. * // => true
  13780. *
  13781. * console.log(object);
  13782. * // => { 'a': [{ 'b': {} }] };
  13783. */
  13784. function unset(object, path) {
  13785. return object == null ? true : baseUnset(object, path);
  13786. }
  13787. /**
  13788. * This method is like `_.set` except that accepts `updater` to produce the
  13789. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  13790. * is invoked with one argument: (value).
  13791. *
  13792. * **Note:** This method mutates `object`.
  13793. *
  13794. * @static
  13795. * @memberOf _
  13796. * @since 4.6.0
  13797. * @category Object
  13798. * @param {Object} object The object to modify.
  13799. * @param {Array|string} path The path of the property to set.
  13800. * @param {Function} updater The function to produce the updated value.
  13801. * @returns {Object} Returns `object`.
  13802. * @example
  13803. *
  13804. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13805. *
  13806. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  13807. * console.log(object.a[0].b.c);
  13808. * // => 9
  13809. *
  13810. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  13811. * console.log(object.x[0].y.z);
  13812. * // => 0
  13813. */
  13814. function update(object, path, updater) {
  13815. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  13816. }
  13817. /**
  13818. * This method is like `_.update` except that it accepts `customizer` which is
  13819. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  13820. * path creation is handled by the method instead. The `customizer` is invoked
  13821. * with three arguments: (nsValue, key, nsObject).
  13822. *
  13823. * **Note:** This method mutates `object`.
  13824. *
  13825. * @static
  13826. * @memberOf _
  13827. * @since 4.6.0
  13828. * @category Object
  13829. * @param {Object} object The object to modify.
  13830. * @param {Array|string} path The path of the property to set.
  13831. * @param {Function} updater The function to produce the updated value.
  13832. * @param {Function} [customizer] The function to customize assigned values.
  13833. * @returns {Object} Returns `object`.
  13834. * @example
  13835. *
  13836. * var object = {};
  13837. *
  13838. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  13839. * // => { '0': { '1': 'a' } }
  13840. */
  13841. function updateWith(object, path, updater, customizer) {
  13842. customizer = typeof customizer == 'function' ? customizer : undefined;
  13843. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  13844. }
  13845. /**
  13846. * Creates an array of the own enumerable string keyed property values of `object`.
  13847. *
  13848. * **Note:** Non-object values are coerced to objects.
  13849. *
  13850. * @static
  13851. * @since 0.1.0
  13852. * @memberOf _
  13853. * @category Object
  13854. * @param {Object} object The object to query.
  13855. * @returns {Array} Returns the array of property values.
  13856. * @example
  13857. *
  13858. * function Foo() {
  13859. * this.a = 1;
  13860. * this.b = 2;
  13861. * }
  13862. *
  13863. * Foo.prototype.c = 3;
  13864. *
  13865. * _.values(new Foo);
  13866. * // => [1, 2] (iteration order is not guaranteed)
  13867. *
  13868. * _.values('hi');
  13869. * // => ['h', 'i']
  13870. */
  13871. function values(object) {
  13872. return object == null ? [] : baseValues(object, keys(object));
  13873. }
  13874. /**
  13875. * Creates an array of the own and inherited enumerable string keyed property
  13876. * values of `object`.
  13877. *
  13878. * **Note:** Non-object values are coerced to objects.
  13879. *
  13880. * @static
  13881. * @memberOf _
  13882. * @since 3.0.0
  13883. * @category Object
  13884. * @param {Object} object The object to query.
  13885. * @returns {Array} Returns the array of property values.
  13886. * @example
  13887. *
  13888. * function Foo() {
  13889. * this.a = 1;
  13890. * this.b = 2;
  13891. * }
  13892. *
  13893. * Foo.prototype.c = 3;
  13894. *
  13895. * _.valuesIn(new Foo);
  13896. * // => [1, 2, 3] (iteration order is not guaranteed)
  13897. */
  13898. function valuesIn(object) {
  13899. return object == null ? [] : baseValues(object, keysIn(object));
  13900. }
  13901. /*------------------------------------------------------------------------*/
  13902. /**
  13903. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  13904. *
  13905. * @static
  13906. * @memberOf _
  13907. * @since 4.0.0
  13908. * @category Number
  13909. * @param {number} number The number to clamp.
  13910. * @param {number} [lower] The lower bound.
  13911. * @param {number} upper The upper bound.
  13912. * @returns {number} Returns the clamped number.
  13913. * @example
  13914. *
  13915. * _.clamp(-10, -5, 5);
  13916. * // => -5
  13917. *
  13918. * _.clamp(10, -5, 5);
  13919. * // => 5
  13920. */
  13921. function clamp(number, lower, upper) {
  13922. if (upper === undefined) {
  13923. upper = lower;
  13924. lower = undefined;
  13925. }
  13926. if (upper !== undefined) {
  13927. upper = toNumber(upper);
  13928. upper = upper === upper ? upper : 0;
  13929. }
  13930. if (lower !== undefined) {
  13931. lower = toNumber(lower);
  13932. lower = lower === lower ? lower : 0;
  13933. }
  13934. return baseClamp(toNumber(number), lower, upper);
  13935. }
  13936. /**
  13937. * Checks if `n` is between `start` and up to, but not including, `end`. If
  13938. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  13939. * If `start` is greater than `end` the params are swapped to support
  13940. * negative ranges.
  13941. *
  13942. * @static
  13943. * @memberOf _
  13944. * @since 3.3.0
  13945. * @category Number
  13946. * @param {number} number The number to check.
  13947. * @param {number} [start=0] The start of the range.
  13948. * @param {number} end The end of the range.
  13949. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  13950. * @see _.range, _.rangeRight
  13951. * @example
  13952. *
  13953. * _.inRange(3, 2, 4);
  13954. * // => true
  13955. *
  13956. * _.inRange(4, 8);
  13957. * // => true
  13958. *
  13959. * _.inRange(4, 2);
  13960. * // => false
  13961. *
  13962. * _.inRange(2, 2);
  13963. * // => false
  13964. *
  13965. * _.inRange(1.2, 2);
  13966. * // => true
  13967. *
  13968. * _.inRange(5.2, 4);
  13969. * // => false
  13970. *
  13971. * _.inRange(-3, -2, -6);
  13972. * // => true
  13973. */
  13974. function inRange(number, start, end) {
  13975. start = toFinite(start);
  13976. if (end === undefined) {
  13977. end = start;
  13978. start = 0;
  13979. } else {
  13980. end = toFinite(end);
  13981. }
  13982. number = toNumber(number);
  13983. return baseInRange(number, start, end);
  13984. }
  13985. /**
  13986. * Produces a random number between the inclusive `lower` and `upper` bounds.
  13987. * If only one argument is provided a number between `0` and the given number
  13988. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  13989. * floats, a floating-point number is returned instead of an integer.
  13990. *
  13991. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  13992. * floating-point values which can produce unexpected results.
  13993. *
  13994. * @static
  13995. * @memberOf _
  13996. * @since 0.7.0
  13997. * @category Number
  13998. * @param {number} [lower=0] The lower bound.
  13999. * @param {number} [upper=1] The upper bound.
  14000. * @param {boolean} [floating] Specify returning a floating-point number.
  14001. * @returns {number} Returns the random number.
  14002. * @example
  14003. *
  14004. * _.random(0, 5);
  14005. * // => an integer between 0 and 5
  14006. *
  14007. * _.random(5);
  14008. * // => also an integer between 0 and 5
  14009. *
  14010. * _.random(5, true);
  14011. * // => a floating-point number between 0 and 5
  14012. *
  14013. * _.random(1.2, 5.2);
  14014. * // => a floating-point number between 1.2 and 5.2
  14015. */
  14016. function random(lower, upper, floating) {
  14017. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  14018. upper = floating = undefined;
  14019. }
  14020. if (floating === undefined) {
  14021. if (typeof upper == 'boolean') {
  14022. floating = upper;
  14023. upper = undefined;
  14024. }
  14025. else if (typeof lower == 'boolean') {
  14026. floating = lower;
  14027. lower = undefined;
  14028. }
  14029. }
  14030. if (lower === undefined && upper === undefined) {
  14031. lower = 0;
  14032. upper = 1;
  14033. }
  14034. else {
  14035. lower = toFinite(lower);
  14036. if (upper === undefined) {
  14037. upper = lower;
  14038. lower = 0;
  14039. } else {
  14040. upper = toFinite(upper);
  14041. }
  14042. }
  14043. if (lower > upper) {
  14044. var temp = lower;
  14045. lower = upper;
  14046. upper = temp;
  14047. }
  14048. if (floating || lower % 1 || upper % 1) {
  14049. var rand = nativeRandom();
  14050. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  14051. }
  14052. return baseRandom(lower, upper);
  14053. }
  14054. /*------------------------------------------------------------------------*/
  14055. /**
  14056. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  14057. *
  14058. * @static
  14059. * @memberOf _
  14060. * @since 3.0.0
  14061. * @category String
  14062. * @param {string} [string=''] The string to convert.
  14063. * @returns {string} Returns the camel cased string.
  14064. * @example
  14065. *
  14066. * _.camelCase('Foo Bar');
  14067. * // => 'fooBar'
  14068. *
  14069. * _.camelCase('--foo-bar--');
  14070. * // => 'fooBar'
  14071. *
  14072. * _.camelCase('__FOO_BAR__');
  14073. * // => 'fooBar'
  14074. */
  14075. var camelCase = createCompounder(function(result, word, index) {
  14076. word = word.toLowerCase();
  14077. return result + (index ? capitalize(word) : word);
  14078. });
  14079. /**
  14080. * Converts the first character of `string` to upper case and the remaining
  14081. * to lower case.
  14082. *
  14083. * @static
  14084. * @memberOf _
  14085. * @since 3.0.0
  14086. * @category String
  14087. * @param {string} [string=''] The string to capitalize.
  14088. * @returns {string} Returns the capitalized string.
  14089. * @example
  14090. *
  14091. * _.capitalize('FRED');
  14092. * // => 'Fred'
  14093. */
  14094. function capitalize(string) {
  14095. return upperFirst(toString(string).toLowerCase());
  14096. }
  14097. /**
  14098. * Deburrs `string` by converting
  14099. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  14100. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  14101. * letters to basic Latin letters and removing
  14102. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  14103. *
  14104. * @static
  14105. * @memberOf _
  14106. * @since 3.0.0
  14107. * @category String
  14108. * @param {string} [string=''] The string to deburr.
  14109. * @returns {string} Returns the deburred string.
  14110. * @example
  14111. *
  14112. * _.deburr('déjà vu');
  14113. * // => 'deja vu'
  14114. */
  14115. function deburr(string) {
  14116. string = toString(string);
  14117. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  14118. }
  14119. /**
  14120. * Checks if `string` ends with the given target string.
  14121. *
  14122. * @static
  14123. * @memberOf _
  14124. * @since 3.0.0
  14125. * @category String
  14126. * @param {string} [string=''] The string to inspect.
  14127. * @param {string} [target] The string to search for.
  14128. * @param {number} [position=string.length] The position to search up to.
  14129. * @returns {boolean} Returns `true` if `string` ends with `target`,
  14130. * else `false`.
  14131. * @example
  14132. *
  14133. * _.endsWith('abc', 'c');
  14134. * // => true
  14135. *
  14136. * _.endsWith('abc', 'b');
  14137. * // => false
  14138. *
  14139. * _.endsWith('abc', 'b', 2);
  14140. * // => true
  14141. */
  14142. function endsWith(string, target, position) {
  14143. string = toString(string);
  14144. target = baseToString(target);
  14145. var length = string.length;
  14146. position = position === undefined
  14147. ? length
  14148. : baseClamp(toInteger(position), 0, length);
  14149. var end = position;
  14150. position -= target.length;
  14151. return position >= 0 && string.slice(position, end) == target;
  14152. }
  14153. /**
  14154. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  14155. * corresponding HTML entities.
  14156. *
  14157. * **Note:** No other characters are escaped. To escape additional
  14158. * characters use a third-party library like [_he_](https://mths.be/he).
  14159. *
  14160. * Though the ">" character is escaped for symmetry, characters like
  14161. * ">" and "/" don't need escaping in HTML and have no special meaning
  14162. * unless they're part of a tag or unquoted attribute value. See
  14163. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  14164. * (under "semi-related fun fact") for more details.
  14165. *
  14166. * When working with HTML you should always
  14167. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  14168. * XSS vectors.
  14169. *
  14170. * @static
  14171. * @since 0.1.0
  14172. * @memberOf _
  14173. * @category String
  14174. * @param {string} [string=''] The string to escape.
  14175. * @returns {string} Returns the escaped string.
  14176. * @example
  14177. *
  14178. * _.escape('fred, barney, & pebbles');
  14179. * // => 'fred, barney, &amp; pebbles'
  14180. */
  14181. function escape(string) {
  14182. string = toString(string);
  14183. return (string && reHasUnescapedHtml.test(string))
  14184. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  14185. : string;
  14186. }
  14187. /**
  14188. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  14189. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  14190. *
  14191. * @static
  14192. * @memberOf _
  14193. * @since 3.0.0
  14194. * @category String
  14195. * @param {string} [string=''] The string to escape.
  14196. * @returns {string} Returns the escaped string.
  14197. * @example
  14198. *
  14199. * _.escapeRegExp('[lodash](https://lodash.com/)');
  14200. * // => '\[lodash\]\(https://lodash\.com/\)'
  14201. */
  14202. function escapeRegExp(string) {
  14203. string = toString(string);
  14204. return (string && reHasRegExpChar.test(string))
  14205. ? string.replace(reRegExpChar, '\\$&')
  14206. : string;
  14207. }
  14208. /**
  14209. * Converts `string` to
  14210. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  14211. *
  14212. * @static
  14213. * @memberOf _
  14214. * @since 3.0.0
  14215. * @category String
  14216. * @param {string} [string=''] The string to convert.
  14217. * @returns {string} Returns the kebab cased string.
  14218. * @example
  14219. *
  14220. * _.kebabCase('Foo Bar');
  14221. * // => 'foo-bar'
  14222. *
  14223. * _.kebabCase('fooBar');
  14224. * // => 'foo-bar'
  14225. *
  14226. * _.kebabCase('__FOO_BAR__');
  14227. * // => 'foo-bar'
  14228. */
  14229. var kebabCase = createCompounder(function(result, word, index) {
  14230. return result + (index ? '-' : '') + word.toLowerCase();
  14231. });
  14232. /**
  14233. * Converts `string`, as space separated words, to lower case.
  14234. *
  14235. * @static
  14236. * @memberOf _
  14237. * @since 4.0.0
  14238. * @category String
  14239. * @param {string} [string=''] The string to convert.
  14240. * @returns {string} Returns the lower cased string.
  14241. * @example
  14242. *
  14243. * _.lowerCase('--Foo-Bar--');
  14244. * // => 'foo bar'
  14245. *
  14246. * _.lowerCase('fooBar');
  14247. * // => 'foo bar'
  14248. *
  14249. * _.lowerCase('__FOO_BAR__');
  14250. * // => 'foo bar'
  14251. */
  14252. var lowerCase = createCompounder(function(result, word, index) {
  14253. return result + (index ? ' ' : '') + word.toLowerCase();
  14254. });
  14255. /**
  14256. * Converts the first character of `string` to lower case.
  14257. *
  14258. * @static
  14259. * @memberOf _
  14260. * @since 4.0.0
  14261. * @category String
  14262. * @param {string} [string=''] The string to convert.
  14263. * @returns {string} Returns the converted string.
  14264. * @example
  14265. *
  14266. * _.lowerFirst('Fred');
  14267. * // => 'fred'
  14268. *
  14269. * _.lowerFirst('FRED');
  14270. * // => 'fRED'
  14271. */
  14272. var lowerFirst = createCaseFirst('toLowerCase');
  14273. /**
  14274. * Pads `string` on the left and right sides if it's shorter than `length`.
  14275. * Padding characters are truncated if they can't be evenly divided by `length`.
  14276. *
  14277. * @static
  14278. * @memberOf _
  14279. * @since 3.0.0
  14280. * @category String
  14281. * @param {string} [string=''] The string to pad.
  14282. * @param {number} [length=0] The padding length.
  14283. * @param {string} [chars=' '] The string used as padding.
  14284. * @returns {string} Returns the padded string.
  14285. * @example
  14286. *
  14287. * _.pad('abc', 8);
  14288. * // => ' abc '
  14289. *
  14290. * _.pad('abc', 8, '_-');
  14291. * // => '_-abc_-_'
  14292. *
  14293. * _.pad('abc', 3);
  14294. * // => 'abc'
  14295. */
  14296. function pad(string, length, chars) {
  14297. string = toString(string);
  14298. length = toInteger(length);
  14299. var strLength = length ? stringSize(string) : 0;
  14300. if (!length || strLength >= length) {
  14301. return string;
  14302. }
  14303. var mid = (length - strLength) / 2;
  14304. return (
  14305. createPadding(nativeFloor(mid), chars) +
  14306. string +
  14307. createPadding(nativeCeil(mid), chars)
  14308. );
  14309. }
  14310. /**
  14311. * Pads `string` on the right side if it's shorter than `length`. Padding
  14312. * characters are truncated if they exceed `length`.
  14313. *
  14314. * @static
  14315. * @memberOf _
  14316. * @since 4.0.0
  14317. * @category String
  14318. * @param {string} [string=''] The string to pad.
  14319. * @param {number} [length=0] The padding length.
  14320. * @param {string} [chars=' '] The string used as padding.
  14321. * @returns {string} Returns the padded string.
  14322. * @example
  14323. *
  14324. * _.padEnd('abc', 6);
  14325. * // => 'abc '
  14326. *
  14327. * _.padEnd('abc', 6, '_-');
  14328. * // => 'abc_-_'
  14329. *
  14330. * _.padEnd('abc', 3);
  14331. * // => 'abc'
  14332. */
  14333. function padEnd(string, length, chars) {
  14334. string = toString(string);
  14335. length = toInteger(length);
  14336. var strLength = length ? stringSize(string) : 0;
  14337. return (length && strLength < length)
  14338. ? (string + createPadding(length - strLength, chars))
  14339. : string;
  14340. }
  14341. /**
  14342. * Pads `string` on the left side if it's shorter than `length`. Padding
  14343. * characters are truncated if they exceed `length`.
  14344. *
  14345. * @static
  14346. * @memberOf _
  14347. * @since 4.0.0
  14348. * @category String
  14349. * @param {string} [string=''] The string to pad.
  14350. * @param {number} [length=0] The padding length.
  14351. * @param {string} [chars=' '] The string used as padding.
  14352. * @returns {string} Returns the padded string.
  14353. * @example
  14354. *
  14355. * _.padStart('abc', 6);
  14356. * // => ' abc'
  14357. *
  14358. * _.padStart('abc', 6, '_-');
  14359. * // => '_-_abc'
  14360. *
  14361. * _.padStart('abc', 3);
  14362. * // => 'abc'
  14363. */
  14364. function padStart(string, length, chars) {
  14365. string = toString(string);
  14366. length = toInteger(length);
  14367. var strLength = length ? stringSize(string) : 0;
  14368. return (length && strLength < length)
  14369. ? (createPadding(length - strLength, chars) + string)
  14370. : string;
  14371. }
  14372. /**
  14373. * Converts `string` to an integer of the specified radix. If `radix` is
  14374. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  14375. * hexadecimal, in which case a `radix` of `16` is used.
  14376. *
  14377. * **Note:** This method aligns with the
  14378. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  14379. *
  14380. * @static
  14381. * @memberOf _
  14382. * @since 1.1.0
  14383. * @category String
  14384. * @param {string} string The string to convert.
  14385. * @param {number} [radix=10] The radix to interpret `value` by.
  14386. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14387. * @returns {number} Returns the converted integer.
  14388. * @example
  14389. *
  14390. * _.parseInt('08');
  14391. * // => 8
  14392. *
  14393. * _.map(['6', '08', '10'], _.parseInt);
  14394. * // => [6, 8, 10]
  14395. */
  14396. function parseInt(string, radix, guard) {
  14397. if (guard || radix == null) {
  14398. radix = 0;
  14399. } else if (radix) {
  14400. radix = +radix;
  14401. }
  14402. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  14403. }
  14404. /**
  14405. * Repeats the given string `n` times.
  14406. *
  14407. * @static
  14408. * @memberOf _
  14409. * @since 3.0.0
  14410. * @category String
  14411. * @param {string} [string=''] The string to repeat.
  14412. * @param {number} [n=1] The number of times to repeat the string.
  14413. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14414. * @returns {string} Returns the repeated string.
  14415. * @example
  14416. *
  14417. * _.repeat('*', 3);
  14418. * // => '***'
  14419. *
  14420. * _.repeat('abc', 2);
  14421. * // => 'abcabc'
  14422. *
  14423. * _.repeat('abc', 0);
  14424. * // => ''
  14425. */
  14426. function repeat(string, n, guard) {
  14427. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  14428. n = 1;
  14429. } else {
  14430. n = toInteger(n);
  14431. }
  14432. return baseRepeat(toString(string), n);
  14433. }
  14434. /**
  14435. * Replaces matches for `pattern` in `string` with `replacement`.
  14436. *
  14437. * **Note:** This method is based on
  14438. * [`String#replace`](https://mdn.io/String/replace).
  14439. *
  14440. * @static
  14441. * @memberOf _
  14442. * @since 4.0.0
  14443. * @category String
  14444. * @param {string} [string=''] The string to modify.
  14445. * @param {RegExp|string} pattern The pattern to replace.
  14446. * @param {Function|string} replacement The match replacement.
  14447. * @returns {string} Returns the modified string.
  14448. * @example
  14449. *
  14450. * _.replace('Hi Fred', 'Fred', 'Barney');
  14451. * // => 'Hi Barney'
  14452. */
  14453. function replace() {
  14454. var args = arguments,
  14455. string = toString(args[0]);
  14456. return args.length < 3 ? string : string.replace(args[1], args[2]);
  14457. }
  14458. /**
  14459. * Converts `string` to
  14460. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  14461. *
  14462. * @static
  14463. * @memberOf _
  14464. * @since 3.0.0
  14465. * @category String
  14466. * @param {string} [string=''] The string to convert.
  14467. * @returns {string} Returns the snake cased string.
  14468. * @example
  14469. *
  14470. * _.snakeCase('Foo Bar');
  14471. * // => 'foo_bar'
  14472. *
  14473. * _.snakeCase('fooBar');
  14474. * // => 'foo_bar'
  14475. *
  14476. * _.snakeCase('--FOO-BAR--');
  14477. * // => 'foo_bar'
  14478. */
  14479. var snakeCase = createCompounder(function(result, word, index) {
  14480. return result + (index ? '_' : '') + word.toLowerCase();
  14481. });
  14482. /**
  14483. * Splits `string` by `separator`.
  14484. *
  14485. * **Note:** This method is based on
  14486. * [`String#split`](https://mdn.io/String/split).
  14487. *
  14488. * @static
  14489. * @memberOf _
  14490. * @since 4.0.0
  14491. * @category String
  14492. * @param {string} [string=''] The string to split.
  14493. * @param {RegExp|string} separator The separator pattern to split by.
  14494. * @param {number} [limit] The length to truncate results to.
  14495. * @returns {Array} Returns the string segments.
  14496. * @example
  14497. *
  14498. * _.split('a-b-c', '-', 2);
  14499. * // => ['a', 'b']
  14500. */
  14501. function split(string, separator, limit) {
  14502. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  14503. separator = limit = undefined;
  14504. }
  14505. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  14506. if (!limit) {
  14507. return [];
  14508. }
  14509. string = toString(string);
  14510. if (string && (
  14511. typeof separator == 'string' ||
  14512. (separator != null && !isRegExp(separator))
  14513. )) {
  14514. separator = baseToString(separator);
  14515. if (!separator && hasUnicode(string)) {
  14516. return castSlice(stringToArray(string), 0, limit);
  14517. }
  14518. }
  14519. return string.split(separator, limit);
  14520. }
  14521. /**
  14522. * Converts `string` to
  14523. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  14524. *
  14525. * @static
  14526. * @memberOf _
  14527. * @since 3.1.0
  14528. * @category String
  14529. * @param {string} [string=''] The string to convert.
  14530. * @returns {string} Returns the start cased string.
  14531. * @example
  14532. *
  14533. * _.startCase('--foo-bar--');
  14534. * // => 'Foo Bar'
  14535. *
  14536. * _.startCase('fooBar');
  14537. * // => 'Foo Bar'
  14538. *
  14539. * _.startCase('__FOO_BAR__');
  14540. * // => 'FOO BAR'
  14541. */
  14542. var startCase = createCompounder(function(result, word, index) {
  14543. return result + (index ? ' ' : '') + upperFirst(word);
  14544. });
  14545. /**
  14546. * Checks if `string` starts with the given target string.
  14547. *
  14548. * @static
  14549. * @memberOf _
  14550. * @since 3.0.0
  14551. * @category String
  14552. * @param {string} [string=''] The string to inspect.
  14553. * @param {string} [target] The string to search for.
  14554. * @param {number} [position=0] The position to search from.
  14555. * @returns {boolean} Returns `true` if `string` starts with `target`,
  14556. * else `false`.
  14557. * @example
  14558. *
  14559. * _.startsWith('abc', 'a');
  14560. * // => true
  14561. *
  14562. * _.startsWith('abc', 'b');
  14563. * // => false
  14564. *
  14565. * _.startsWith('abc', 'b', 1);
  14566. * // => true
  14567. */
  14568. function startsWith(string, target, position) {
  14569. string = toString(string);
  14570. position = position == null
  14571. ? 0
  14572. : baseClamp(toInteger(position), 0, string.length);
  14573. target = baseToString(target);
  14574. return string.slice(position, position + target.length) == target;
  14575. }
  14576. /**
  14577. * Creates a compiled template function that can interpolate data properties
  14578. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  14579. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  14580. * properties may be accessed as free variables in the template. If a setting
  14581. * object is given, it takes precedence over `_.templateSettings` values.
  14582. *
  14583. * **Note:** In the development build `_.template` utilizes
  14584. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  14585. * for easier debugging.
  14586. *
  14587. * For more information on precompiling templates see
  14588. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  14589. *
  14590. * For more information on Chrome extension sandboxes see
  14591. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  14592. *
  14593. * @static
  14594. * @since 0.1.0
  14595. * @memberOf _
  14596. * @category String
  14597. * @param {string} [string=''] The template string.
  14598. * @param {Object} [options={}] The options object.
  14599. * @param {RegExp} [options.escape=_.templateSettings.escape]
  14600. * The HTML "escape" delimiter.
  14601. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  14602. * The "evaluate" delimiter.
  14603. * @param {Object} [options.imports=_.templateSettings.imports]
  14604. * An object to import into the template as free variables.
  14605. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  14606. * The "interpolate" delimiter.
  14607. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  14608. * The sourceURL of the compiled template.
  14609. * @param {string} [options.variable='obj']
  14610. * The data object variable name.
  14611. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14612. * @returns {Function} Returns the compiled template function.
  14613. * @example
  14614. *
  14615. * // Use the "interpolate" delimiter to create a compiled template.
  14616. * var compiled = _.template('hello <%= user %>!');
  14617. * compiled({ 'user': 'fred' });
  14618. * // => 'hello fred!'
  14619. *
  14620. * // Use the HTML "escape" delimiter to escape data property values.
  14621. * var compiled = _.template('<b><%- value %></b>');
  14622. * compiled({ 'value': '<script>' });
  14623. * // => '<b>&lt;script&gt;</b>'
  14624. *
  14625. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  14626. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  14627. * compiled({ 'users': ['fred', 'barney'] });
  14628. * // => '<li>fred</li><li>barney</li>'
  14629. *
  14630. * // Use the internal `print` function in "evaluate" delimiters.
  14631. * var compiled = _.template('<% print("hello " + user); %>!');
  14632. * compiled({ 'user': 'barney' });
  14633. * // => 'hello barney!'
  14634. *
  14635. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  14636. * // Disable support by replacing the "interpolate" delimiter.
  14637. * var compiled = _.template('hello ${ user }!');
  14638. * compiled({ 'user': 'pebbles' });
  14639. * // => 'hello pebbles!'
  14640. *
  14641. * // Use backslashes to treat delimiters as plain text.
  14642. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  14643. * compiled({ 'value': 'ignored' });
  14644. * // => '<%- value %>'
  14645. *
  14646. * // Use the `imports` option to import `jQuery` as `jq`.
  14647. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  14648. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  14649. * compiled({ 'users': ['fred', 'barney'] });
  14650. * // => '<li>fred</li><li>barney</li>'
  14651. *
  14652. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  14653. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  14654. * compiled(data);
  14655. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  14656. *
  14657. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  14658. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  14659. * compiled.source;
  14660. * // => function(data) {
  14661. * // var __t, __p = '';
  14662. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  14663. * // return __p;
  14664. * // }
  14665. *
  14666. * // Use custom template delimiters.
  14667. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  14668. * var compiled = _.template('hello {{ user }}!');
  14669. * compiled({ 'user': 'mustache' });
  14670. * // => 'hello mustache!'
  14671. *
  14672. * // Use the `source` property to inline compiled templates for meaningful
  14673. * // line numbers in error messages and stack traces.
  14674. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  14675. * var JST = {\
  14676. * "main": ' + _.template(mainText).source + '\
  14677. * };\
  14678. * ');
  14679. */
  14680. function template(string, options, guard) {
  14681. // Based on John Resig's `tmpl` implementation
  14682. // (http://ejohn.org/blog/javascript-micro-templating/)
  14683. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  14684. var settings = lodash.templateSettings;
  14685. if (guard && isIterateeCall(string, options, guard)) {
  14686. options = undefined;
  14687. }
  14688. string = toString(string);
  14689. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  14690. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  14691. importsKeys = keys(imports),
  14692. importsValues = baseValues(imports, importsKeys);
  14693. var isEscaping,
  14694. isEvaluating,
  14695. index = 0,
  14696. interpolate = options.interpolate || reNoMatch,
  14697. source = "__p += '";
  14698. // Compile the regexp to match each delimiter.
  14699. var reDelimiters = RegExp(
  14700. (options.escape || reNoMatch).source + '|' +
  14701. interpolate.source + '|' +
  14702. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  14703. (options.evaluate || reNoMatch).source + '|$'
  14704. , 'g');
  14705. // Use a sourceURL for easier debugging.
  14706. var sourceURL = '//# sourceURL=' +
  14707. ('sourceURL' in options
  14708. ? options.sourceURL
  14709. : ('lodash.templateSources[' + (++templateCounter) + ']')
  14710. ) + '\n';
  14711. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  14712. interpolateValue || (interpolateValue = esTemplateValue);
  14713. // Escape characters that can't be included in string literals.
  14714. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  14715. // Replace delimiters with snippets.
  14716. if (escapeValue) {
  14717. isEscaping = true;
  14718. source += "' +\n__e(" + escapeValue + ") +\n'";
  14719. }
  14720. if (evaluateValue) {
  14721. isEvaluating = true;
  14722. source += "';\n" + evaluateValue + ";\n__p += '";
  14723. }
  14724. if (interpolateValue) {
  14725. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  14726. }
  14727. index = offset + match.length;
  14728. // The JS engine embedded in Adobe products needs `match` returned in
  14729. // order to produce the correct `offset` value.
  14730. return match;
  14731. });
  14732. source += "';\n";
  14733. // If `variable` is not specified wrap a with-statement around the generated
  14734. // code to add the data object to the top of the scope chain.
  14735. var variable = options.variable;
  14736. if (!variable) {
  14737. source = 'with (obj) {\n' + source + '\n}\n';
  14738. }
  14739. // Cleanup code by stripping empty strings.
  14740. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  14741. .replace(reEmptyStringMiddle, '$1')
  14742. .replace(reEmptyStringTrailing, '$1;');
  14743. // Frame code as the function body.
  14744. source = 'function(' + (variable || 'obj') + ') {\n' +
  14745. (variable
  14746. ? ''
  14747. : 'obj || (obj = {});\n'
  14748. ) +
  14749. "var __t, __p = ''" +
  14750. (isEscaping
  14751. ? ', __e = _.escape'
  14752. : ''
  14753. ) +
  14754. (isEvaluating
  14755. ? ', __j = Array.prototype.join;\n' +
  14756. "function print() { __p += __j.call(arguments, '') }\n"
  14757. : ';\n'
  14758. ) +
  14759. source +
  14760. 'return __p\n}';
  14761. var result = attempt(function() {
  14762. return Function(importsKeys, sourceURL + 'return ' + source)
  14763. .apply(undefined, importsValues);
  14764. });
  14765. // Provide the compiled function's source by its `toString` method or
  14766. // the `source` property as a convenience for inlining compiled templates.
  14767. result.source = source;
  14768. if (isError(result)) {
  14769. throw result;
  14770. }
  14771. return result;
  14772. }
  14773. /**
  14774. * Converts `string`, as a whole, to lower case just like
  14775. * [String#toLowerCase](https://mdn.io/toLowerCase).
  14776. *
  14777. * @static
  14778. * @memberOf _
  14779. * @since 4.0.0
  14780. * @category String
  14781. * @param {string} [string=''] The string to convert.
  14782. * @returns {string} Returns the lower cased string.
  14783. * @example
  14784. *
  14785. * _.toLower('--Foo-Bar--');
  14786. * // => '--foo-bar--'
  14787. *
  14788. * _.toLower('fooBar');
  14789. * // => 'foobar'
  14790. *
  14791. * _.toLower('__FOO_BAR__');
  14792. * // => '__foo_bar__'
  14793. */
  14794. function toLower(value) {
  14795. return toString(value).toLowerCase();
  14796. }
  14797. /**
  14798. * Converts `string`, as a whole, to upper case just like
  14799. * [String#toUpperCase](https://mdn.io/toUpperCase).
  14800. *
  14801. * @static
  14802. * @memberOf _
  14803. * @since 4.0.0
  14804. * @category String
  14805. * @param {string} [string=''] The string to convert.
  14806. * @returns {string} Returns the upper cased string.
  14807. * @example
  14808. *
  14809. * _.toUpper('--foo-bar--');
  14810. * // => '--FOO-BAR--'
  14811. *
  14812. * _.toUpper('fooBar');
  14813. * // => 'FOOBAR'
  14814. *
  14815. * _.toUpper('__foo_bar__');
  14816. * // => '__FOO_BAR__'
  14817. */
  14818. function toUpper(value) {
  14819. return toString(value).toUpperCase();
  14820. }
  14821. /**
  14822. * Removes leading and trailing whitespace or specified characters from `string`.
  14823. *
  14824. * @static
  14825. * @memberOf _
  14826. * @since 3.0.0
  14827. * @category String
  14828. * @param {string} [string=''] The string to trim.
  14829. * @param {string} [chars=whitespace] The characters to trim.
  14830. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14831. * @returns {string} Returns the trimmed string.
  14832. * @example
  14833. *
  14834. * _.trim(' abc ');
  14835. * // => 'abc'
  14836. *
  14837. * _.trim('-_-abc-_-', '_-');
  14838. * // => 'abc'
  14839. *
  14840. * _.map([' foo ', ' bar '], _.trim);
  14841. * // => ['foo', 'bar']
  14842. */
  14843. function trim(string, chars, guard) {
  14844. string = toString(string);
  14845. if (string && (guard || chars === undefined)) {
  14846. return string.replace(reTrim, '');
  14847. }
  14848. if (!string || !(chars = baseToString(chars))) {
  14849. return string;
  14850. }
  14851. var strSymbols = stringToArray(string),
  14852. chrSymbols = stringToArray(chars),
  14853. start = charsStartIndex(strSymbols, chrSymbols),
  14854. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  14855. return castSlice(strSymbols, start, end).join('');
  14856. }
  14857. /**
  14858. * Removes trailing whitespace or specified characters from `string`.
  14859. *
  14860. * @static
  14861. * @memberOf _
  14862. * @since 4.0.0
  14863. * @category String
  14864. * @param {string} [string=''] The string to trim.
  14865. * @param {string} [chars=whitespace] The characters to trim.
  14866. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14867. * @returns {string} Returns the trimmed string.
  14868. * @example
  14869. *
  14870. * _.trimEnd(' abc ');
  14871. * // => ' abc'
  14872. *
  14873. * _.trimEnd('-_-abc-_-', '_-');
  14874. * // => '-_-abc'
  14875. */
  14876. function trimEnd(string, chars, guard) {
  14877. string = toString(string);
  14878. if (string && (guard || chars === undefined)) {
  14879. return string.replace(reTrimEnd, '');
  14880. }
  14881. if (!string || !(chars = baseToString(chars))) {
  14882. return string;
  14883. }
  14884. var strSymbols = stringToArray(string),
  14885. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  14886. return castSlice(strSymbols, 0, end).join('');
  14887. }
  14888. /**
  14889. * Removes leading whitespace or specified characters from `string`.
  14890. *
  14891. * @static
  14892. * @memberOf _
  14893. * @since 4.0.0
  14894. * @category String
  14895. * @param {string} [string=''] The string to trim.
  14896. * @param {string} [chars=whitespace] The characters to trim.
  14897. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14898. * @returns {string} Returns the trimmed string.
  14899. * @example
  14900. *
  14901. * _.trimStart(' abc ');
  14902. * // => 'abc '
  14903. *
  14904. * _.trimStart('-_-abc-_-', '_-');
  14905. * // => 'abc-_-'
  14906. */
  14907. function trimStart(string, chars, guard) {
  14908. string = toString(string);
  14909. if (string && (guard || chars === undefined)) {
  14910. return string.replace(reTrimStart, '');
  14911. }
  14912. if (!string || !(chars = baseToString(chars))) {
  14913. return string;
  14914. }
  14915. var strSymbols = stringToArray(string),
  14916. start = charsStartIndex(strSymbols, stringToArray(chars));
  14917. return castSlice(strSymbols, start).join('');
  14918. }
  14919. /**
  14920. * Truncates `string` if it's longer than the given maximum string length.
  14921. * The last characters of the truncated string are replaced with the omission
  14922. * string which defaults to "...".
  14923. *
  14924. * @static
  14925. * @memberOf _
  14926. * @since 4.0.0
  14927. * @category String
  14928. * @param {string} [string=''] The string to truncate.
  14929. * @param {Object} [options={}] The options object.
  14930. * @param {number} [options.length=30] The maximum string length.
  14931. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  14932. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  14933. * @returns {string} Returns the truncated string.
  14934. * @example
  14935. *
  14936. * _.truncate('hi-diddly-ho there, neighborino');
  14937. * // => 'hi-diddly-ho there, neighbo...'
  14938. *
  14939. * _.truncate('hi-diddly-ho there, neighborino', {
  14940. * 'length': 24,
  14941. * 'separator': ' '
  14942. * });
  14943. * // => 'hi-diddly-ho there,...'
  14944. *
  14945. * _.truncate('hi-diddly-ho there, neighborino', {
  14946. * 'length': 24,
  14947. * 'separator': /,? +/
  14948. * });
  14949. * // => 'hi-diddly-ho there...'
  14950. *
  14951. * _.truncate('hi-diddly-ho there, neighborino', {
  14952. * 'omission': ' [...]'
  14953. * });
  14954. * // => 'hi-diddly-ho there, neig [...]'
  14955. */
  14956. function truncate(string, options) {
  14957. var length = DEFAULT_TRUNC_LENGTH,
  14958. omission = DEFAULT_TRUNC_OMISSION;
  14959. if (isObject(options)) {
  14960. var separator = 'separator' in options ? options.separator : separator;
  14961. length = 'length' in options ? toInteger(options.length) : length;
  14962. omission = 'omission' in options ? baseToString(options.omission) : omission;
  14963. }
  14964. string = toString(string);
  14965. var strLength = string.length;
  14966. if (hasUnicode(string)) {
  14967. var strSymbols = stringToArray(string);
  14968. strLength = strSymbols.length;
  14969. }
  14970. if (length >= strLength) {
  14971. return string;
  14972. }
  14973. var end = length - stringSize(omission);
  14974. if (end < 1) {
  14975. return omission;
  14976. }
  14977. var result = strSymbols
  14978. ? castSlice(strSymbols, 0, end).join('')
  14979. : string.slice(0, end);
  14980. if (separator === undefined) {
  14981. return result + omission;
  14982. }
  14983. if (strSymbols) {
  14984. end += (result.length - end);
  14985. }
  14986. if (isRegExp(separator)) {
  14987. if (string.slice(end).search(separator)) {
  14988. var match,
  14989. substring = result;
  14990. if (!separator.global) {
  14991. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  14992. }
  14993. separator.lastIndex = 0;
  14994. while ((match = separator.exec(substring))) {
  14995. var newEnd = match.index;
  14996. }
  14997. result = result.slice(0, newEnd === undefined ? end : newEnd);
  14998. }
  14999. } else if (string.indexOf(baseToString(separator), end) != end) {
  15000. var index = result.lastIndexOf(separator);
  15001. if (index > -1) {
  15002. result = result.slice(0, index);
  15003. }
  15004. }
  15005. return result + omission;
  15006. }
  15007. /**
  15008. * The inverse of `_.escape`; this method converts the HTML entities
  15009. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  15010. * their corresponding characters.
  15011. *
  15012. * **Note:** No other HTML entities are unescaped. To unescape additional
  15013. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  15014. *
  15015. * @static
  15016. * @memberOf _
  15017. * @since 0.6.0
  15018. * @category String
  15019. * @param {string} [string=''] The string to unescape.
  15020. * @returns {string} Returns the unescaped string.
  15021. * @example
  15022. *
  15023. * _.unescape('fred, barney, &amp; pebbles');
  15024. * // => 'fred, barney, & pebbles'
  15025. */
  15026. function unescape(string) {
  15027. string = toString(string);
  15028. return (string && reHasEscapedHtml.test(string))
  15029. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  15030. : string;
  15031. }
  15032. /**
  15033. * Converts `string`, as space separated words, to upper case.
  15034. *
  15035. * @static
  15036. * @memberOf _
  15037. * @since 4.0.0
  15038. * @category String
  15039. * @param {string} [string=''] The string to convert.
  15040. * @returns {string} Returns the upper cased string.
  15041. * @example
  15042. *
  15043. * _.upperCase('--foo-bar');
  15044. * // => 'FOO BAR'
  15045. *
  15046. * _.upperCase('fooBar');
  15047. * // => 'FOO BAR'
  15048. *
  15049. * _.upperCase('__foo_bar__');
  15050. * // => 'FOO BAR'
  15051. */
  15052. var upperCase = createCompounder(function(result, word, index) {
  15053. return result + (index ? ' ' : '') + word.toUpperCase();
  15054. });
  15055. /**
  15056. * Converts the first character of `string` to upper case.
  15057. *
  15058. * @static
  15059. * @memberOf _
  15060. * @since 4.0.0
  15061. * @category String
  15062. * @param {string} [string=''] The string to convert.
  15063. * @returns {string} Returns the converted string.
  15064. * @example
  15065. *
  15066. * _.upperFirst('fred');
  15067. * // => 'Fred'
  15068. *
  15069. * _.upperFirst('FRED');
  15070. * // => 'FRED'
  15071. */
  15072. var upperFirst = createCaseFirst('toUpperCase');
  15073. /**
  15074. * Splits `string` into an array of its words.
  15075. *
  15076. * @static
  15077. * @memberOf _
  15078. * @since 3.0.0
  15079. * @category String
  15080. * @param {string} [string=''] The string to inspect.
  15081. * @param {RegExp|string} [pattern] The pattern to match words.
  15082. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15083. * @returns {Array} Returns the words of `string`.
  15084. * @example
  15085. *
  15086. * _.words('fred, barney, & pebbles');
  15087. * // => ['fred', 'barney', 'pebbles']
  15088. *
  15089. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  15090. * // => ['fred', 'barney', '&', 'pebbles']
  15091. */
  15092. function words(string, pattern, guard) {
  15093. string = toString(string);
  15094. pattern = guard ? undefined : pattern;
  15095. if (pattern === undefined) {
  15096. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  15097. }
  15098. return string.match(pattern) || [];
  15099. }
  15100. /*------------------------------------------------------------------------*/
  15101. /**
  15102. * Attempts to invoke `func`, returning either the result or the caught error
  15103. * object. Any additional arguments are provided to `func` when it's invoked.
  15104. *
  15105. * @static
  15106. * @memberOf _
  15107. * @since 3.0.0
  15108. * @category Util
  15109. * @param {Function} func The function to attempt.
  15110. * @param {...*} [args] The arguments to invoke `func` with.
  15111. * @returns {*} Returns the `func` result or error object.
  15112. * @example
  15113. *
  15114. * // Avoid throwing errors for invalid selectors.
  15115. * var elements = _.attempt(function(selector) {
  15116. * return document.querySelectorAll(selector);
  15117. * }, '>_>');
  15118. *
  15119. * if (_.isError(elements)) {
  15120. * elements = [];
  15121. * }
  15122. */
  15123. var attempt = baseRest(function(func, args) {
  15124. try {
  15125. return apply(func, undefined, args);
  15126. } catch (e) {
  15127. return isError(e) ? e : new Error(e);
  15128. }
  15129. });
  15130. /**
  15131. * Binds methods of an object to the object itself, overwriting the existing
  15132. * method.
  15133. *
  15134. * **Note:** This method doesn't set the "length" property of bound functions.
  15135. *
  15136. * @static
  15137. * @since 0.1.0
  15138. * @memberOf _
  15139. * @category Util
  15140. * @param {Object} object The object to bind and assign the bound methods to.
  15141. * @param {...(string|string[])} methodNames The object method names to bind.
  15142. * @returns {Object} Returns `object`.
  15143. * @example
  15144. *
  15145. * var view = {
  15146. * 'label': 'docs',
  15147. * 'click': function() {
  15148. * console.log('clicked ' + this.label);
  15149. * }
  15150. * };
  15151. *
  15152. * _.bindAll(view, ['click']);
  15153. * jQuery(element).on('click', view.click);
  15154. * // => Logs 'clicked docs' when clicked.
  15155. */
  15156. var bindAll = flatRest(function(object, methodNames) {
  15157. arrayEach(methodNames, function(key) {
  15158. key = toKey(key);
  15159. baseAssignValue(object, key, bind(object[key], object));
  15160. });
  15161. return object;
  15162. });
  15163. /**
  15164. * Creates a function that iterates over `pairs` and invokes the corresponding
  15165. * function of the first predicate to return truthy. The predicate-function
  15166. * pairs are invoked with the `this` binding and arguments of the created
  15167. * function.
  15168. *
  15169. * @static
  15170. * @memberOf _
  15171. * @since 4.0.0
  15172. * @category Util
  15173. * @param {Array} pairs The predicate-function pairs.
  15174. * @returns {Function} Returns the new composite function.
  15175. * @example
  15176. *
  15177. * var func = _.cond([
  15178. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  15179. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  15180. * [_.stubTrue, _.constant('no match')]
  15181. * ]);
  15182. *
  15183. * func({ 'a': 1, 'b': 2 });
  15184. * // => 'matches A'
  15185. *
  15186. * func({ 'a': 0, 'b': 1 });
  15187. * // => 'matches B'
  15188. *
  15189. * func({ 'a': '1', 'b': '2' });
  15190. * // => 'no match'
  15191. */
  15192. function cond(pairs) {
  15193. var length = pairs == null ? 0 : pairs.length,
  15194. toIteratee = getIteratee();
  15195. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  15196. if (typeof pair[1] != 'function') {
  15197. throw new TypeError(FUNC_ERROR_TEXT);
  15198. }
  15199. return [toIteratee(pair[0]), pair[1]];
  15200. });
  15201. return baseRest(function(args) {
  15202. var index = -1;
  15203. while (++index < length) {
  15204. var pair = pairs[index];
  15205. if (apply(pair[0], this, args)) {
  15206. return apply(pair[1], this, args);
  15207. }
  15208. }
  15209. });
  15210. }
  15211. /**
  15212. * Creates a function that invokes the predicate properties of `source` with
  15213. * the corresponding property values of a given object, returning `true` if
  15214. * all predicates return truthy, else `false`.
  15215. *
  15216. * **Note:** The created function is equivalent to `_.conformsTo` with
  15217. * `source` partially applied.
  15218. *
  15219. * @static
  15220. * @memberOf _
  15221. * @since 4.0.0
  15222. * @category Util
  15223. * @param {Object} source The object of property predicates to conform to.
  15224. * @returns {Function} Returns the new spec function.
  15225. * @example
  15226. *
  15227. * var objects = [
  15228. * { 'a': 2, 'b': 1 },
  15229. * { 'a': 1, 'b': 2 }
  15230. * ];
  15231. *
  15232. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  15233. * // => [{ 'a': 1, 'b': 2 }]
  15234. */
  15235. function conforms(source) {
  15236. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  15237. }
  15238. /**
  15239. * Creates a function that returns `value`.
  15240. *
  15241. * @static
  15242. * @memberOf _
  15243. * @since 2.4.0
  15244. * @category Util
  15245. * @param {*} value The value to return from the new function.
  15246. * @returns {Function} Returns the new constant function.
  15247. * @example
  15248. *
  15249. * var objects = _.times(2, _.constant({ 'a': 1 }));
  15250. *
  15251. * console.log(objects);
  15252. * // => [{ 'a': 1 }, { 'a': 1 }]
  15253. *
  15254. * console.log(objects[0] === objects[1]);
  15255. * // => true
  15256. */
  15257. function constant(value) {
  15258. return function() {
  15259. return value;
  15260. };
  15261. }
  15262. /**
  15263. * Checks `value` to determine whether a default value should be returned in
  15264. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  15265. * or `undefined`.
  15266. *
  15267. * @static
  15268. * @memberOf _
  15269. * @since 4.14.0
  15270. * @category Util
  15271. * @param {*} value The value to check.
  15272. * @param {*} defaultValue The default value.
  15273. * @returns {*} Returns the resolved value.
  15274. * @example
  15275. *
  15276. * _.defaultTo(1, 10);
  15277. * // => 1
  15278. *
  15279. * _.defaultTo(undefined, 10);
  15280. * // => 10
  15281. */
  15282. function defaultTo(value, defaultValue) {
  15283. return (value == null || value !== value) ? defaultValue : value;
  15284. }
  15285. /**
  15286. * Creates a function that returns the result of invoking the given functions
  15287. * with the `this` binding of the created function, where each successive
  15288. * invocation is supplied the return value of the previous.
  15289. *
  15290. * @static
  15291. * @memberOf _
  15292. * @since 3.0.0
  15293. * @category Util
  15294. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  15295. * @returns {Function} Returns the new composite function.
  15296. * @see _.flowRight
  15297. * @example
  15298. *
  15299. * function square(n) {
  15300. * return n * n;
  15301. * }
  15302. *
  15303. * var addSquare = _.flow([_.add, square]);
  15304. * addSquare(1, 2);
  15305. * // => 9
  15306. */
  15307. var flow = createFlow();
  15308. /**
  15309. * This method is like `_.flow` except that it creates a function that
  15310. * invokes the given functions from right to left.
  15311. *
  15312. * @static
  15313. * @since 3.0.0
  15314. * @memberOf _
  15315. * @category Util
  15316. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  15317. * @returns {Function} Returns the new composite function.
  15318. * @see _.flow
  15319. * @example
  15320. *
  15321. * function square(n) {
  15322. * return n * n;
  15323. * }
  15324. *
  15325. * var addSquare = _.flowRight([square, _.add]);
  15326. * addSquare(1, 2);
  15327. * // => 9
  15328. */
  15329. var flowRight = createFlow(true);
  15330. /**
  15331. * This method returns the first argument it receives.
  15332. *
  15333. * @static
  15334. * @since 0.1.0
  15335. * @memberOf _
  15336. * @category Util
  15337. * @param {*} value Any value.
  15338. * @returns {*} Returns `value`.
  15339. * @example
  15340. *
  15341. * var object = { 'a': 1 };
  15342. *
  15343. * console.log(_.identity(object) === object);
  15344. * // => true
  15345. */
  15346. function identity(value) {
  15347. return value;
  15348. }
  15349. /**
  15350. * Creates a function that invokes `func` with the arguments of the created
  15351. * function. If `func` is a property name, the created function returns the
  15352. * property value for a given element. If `func` is an array or object, the
  15353. * created function returns `true` for elements that contain the equivalent
  15354. * source properties, otherwise it returns `false`.
  15355. *
  15356. * @static
  15357. * @since 4.0.0
  15358. * @memberOf _
  15359. * @category Util
  15360. * @param {*} [func=_.identity] The value to convert to a callback.
  15361. * @returns {Function} Returns the callback.
  15362. * @example
  15363. *
  15364. * var users = [
  15365. * { 'user': 'barney', 'age': 36, 'active': true },
  15366. * { 'user': 'fred', 'age': 40, 'active': false }
  15367. * ];
  15368. *
  15369. * // The `_.matches` iteratee shorthand.
  15370. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  15371. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  15372. *
  15373. * // The `_.matchesProperty` iteratee shorthand.
  15374. * _.filter(users, _.iteratee(['user', 'fred']));
  15375. * // => [{ 'user': 'fred', 'age': 40 }]
  15376. *
  15377. * // The `_.property` iteratee shorthand.
  15378. * _.map(users, _.iteratee('user'));
  15379. * // => ['barney', 'fred']
  15380. *
  15381. * // Create custom iteratee shorthands.
  15382. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  15383. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  15384. * return func.test(string);
  15385. * };
  15386. * });
  15387. *
  15388. * _.filter(['abc', 'def'], /ef/);
  15389. * // => ['def']
  15390. */
  15391. function iteratee(func) {
  15392. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  15393. }
  15394. /**
  15395. * Creates a function that performs a partial deep comparison between a given
  15396. * object and `source`, returning `true` if the given object has equivalent
  15397. * property values, else `false`.
  15398. *
  15399. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  15400. * partially applied.
  15401. *
  15402. * Partial comparisons will match empty array and empty object `source`
  15403. * values against any array or object value, respectively. See `_.isEqual`
  15404. * for a list of supported value comparisons.
  15405. *
  15406. * @static
  15407. * @memberOf _
  15408. * @since 3.0.0
  15409. * @category Util
  15410. * @param {Object} source The object of property values to match.
  15411. * @returns {Function} Returns the new spec function.
  15412. * @example
  15413. *
  15414. * var objects = [
  15415. * { 'a': 1, 'b': 2, 'c': 3 },
  15416. * { 'a': 4, 'b': 5, 'c': 6 }
  15417. * ];
  15418. *
  15419. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  15420. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  15421. */
  15422. function matches(source) {
  15423. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  15424. }
  15425. /**
  15426. * Creates a function that performs a partial deep comparison between the
  15427. * value at `path` of a given object to `srcValue`, returning `true` if the
  15428. * object value is equivalent, else `false`.
  15429. *
  15430. * **Note:** Partial comparisons will match empty array and empty object
  15431. * `srcValue` values against any array or object value, respectively. See
  15432. * `_.isEqual` for a list of supported value comparisons.
  15433. *
  15434. * @static
  15435. * @memberOf _
  15436. * @since 3.2.0
  15437. * @category Util
  15438. * @param {Array|string} path The path of the property to get.
  15439. * @param {*} srcValue The value to match.
  15440. * @returns {Function} Returns the new spec function.
  15441. * @example
  15442. *
  15443. * var objects = [
  15444. * { 'a': 1, 'b': 2, 'c': 3 },
  15445. * { 'a': 4, 'b': 5, 'c': 6 }
  15446. * ];
  15447. *
  15448. * _.find(objects, _.matchesProperty('a', 4));
  15449. * // => { 'a': 4, 'b': 5, 'c': 6 }
  15450. */
  15451. function matchesProperty(path, srcValue) {
  15452. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  15453. }
  15454. /**
  15455. * Creates a function that invokes the method at `path` of a given object.
  15456. * Any additional arguments are provided to the invoked method.
  15457. *
  15458. * @static
  15459. * @memberOf _
  15460. * @since 3.7.0
  15461. * @category Util
  15462. * @param {Array|string} path The path of the method to invoke.
  15463. * @param {...*} [args] The arguments to invoke the method with.
  15464. * @returns {Function} Returns the new invoker function.
  15465. * @example
  15466. *
  15467. * var objects = [
  15468. * { 'a': { 'b': _.constant(2) } },
  15469. * { 'a': { 'b': _.constant(1) } }
  15470. * ];
  15471. *
  15472. * _.map(objects, _.method('a.b'));
  15473. * // => [2, 1]
  15474. *
  15475. * _.map(objects, _.method(['a', 'b']));
  15476. * // => [2, 1]
  15477. */
  15478. var method = baseRest(function(path, args) {
  15479. return function(object) {
  15480. return baseInvoke(object, path, args);
  15481. };
  15482. });
  15483. /**
  15484. * The opposite of `_.method`; this method creates a function that invokes
  15485. * the method at a given path of `object`. Any additional arguments are
  15486. * provided to the invoked method.
  15487. *
  15488. * @static
  15489. * @memberOf _
  15490. * @since 3.7.0
  15491. * @category Util
  15492. * @param {Object} object The object to query.
  15493. * @param {...*} [args] The arguments to invoke the method with.
  15494. * @returns {Function} Returns the new invoker function.
  15495. * @example
  15496. *
  15497. * var array = _.times(3, _.constant),
  15498. * object = { 'a': array, 'b': array, 'c': array };
  15499. *
  15500. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  15501. * // => [2, 0]
  15502. *
  15503. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  15504. * // => [2, 0]
  15505. */
  15506. var methodOf = baseRest(function(object, args) {
  15507. return function(path) {
  15508. return baseInvoke(object, path, args);
  15509. };
  15510. });
  15511. /**
  15512. * Adds all own enumerable string keyed function properties of a source
  15513. * object to the destination object. If `object` is a function, then methods
  15514. * are added to its prototype as well.
  15515. *
  15516. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  15517. * avoid conflicts caused by modifying the original.
  15518. *
  15519. * @static
  15520. * @since 0.1.0
  15521. * @memberOf _
  15522. * @category Util
  15523. * @param {Function|Object} [object=lodash] The destination object.
  15524. * @param {Object} source The object of functions to add.
  15525. * @param {Object} [options={}] The options object.
  15526. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  15527. * @returns {Function|Object} Returns `object`.
  15528. * @example
  15529. *
  15530. * function vowels(string) {
  15531. * return _.filter(string, function(v) {
  15532. * return /[aeiou]/i.test(v);
  15533. * });
  15534. * }
  15535. *
  15536. * _.mixin({ 'vowels': vowels });
  15537. * _.vowels('fred');
  15538. * // => ['e']
  15539. *
  15540. * _('fred').vowels().value();
  15541. * // => ['e']
  15542. *
  15543. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  15544. * _('fred').vowels();
  15545. * // => ['e']
  15546. */
  15547. function mixin(object, source, options) {
  15548. var props = keys(source),
  15549. methodNames = baseFunctions(source, props);
  15550. if (options == null &&
  15551. !(isObject(source) && (methodNames.length || !props.length))) {
  15552. options = source;
  15553. source = object;
  15554. object = this;
  15555. methodNames = baseFunctions(source, keys(source));
  15556. }
  15557. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  15558. isFunc = isFunction(object);
  15559. arrayEach(methodNames, function(methodName) {
  15560. var func = source[methodName];
  15561. object[methodName] = func;
  15562. if (isFunc) {
  15563. object.prototype[methodName] = function() {
  15564. var chainAll = this.__chain__;
  15565. if (chain || chainAll) {
  15566. var result = object(this.__wrapped__),
  15567. actions = result.__actions__ = copyArray(this.__actions__);
  15568. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  15569. result.__chain__ = chainAll;
  15570. return result;
  15571. }
  15572. return func.apply(object, arrayPush([this.value()], arguments));
  15573. };
  15574. }
  15575. });
  15576. return object;
  15577. }
  15578. /**
  15579. * Reverts the `_` variable to its previous value and returns a reference to
  15580. * the `lodash` function.
  15581. *
  15582. * @static
  15583. * @since 0.1.0
  15584. * @memberOf _
  15585. * @category Util
  15586. * @returns {Function} Returns the `lodash` function.
  15587. * @example
  15588. *
  15589. * var lodash = _.noConflict();
  15590. */
  15591. function noConflict() {
  15592. if (root._ === this) {
  15593. root._ = oldDash;
  15594. }
  15595. return this;
  15596. }
  15597. /**
  15598. * This method returns `undefined`.
  15599. *
  15600. * @static
  15601. * @memberOf _
  15602. * @since 2.3.0
  15603. * @category Util
  15604. * @example
  15605. *
  15606. * _.times(2, _.noop);
  15607. * // => [undefined, undefined]
  15608. */
  15609. function noop() {
  15610. // No operation performed.
  15611. }
  15612. /**
  15613. * Creates a function that gets the argument at index `n`. If `n` is negative,
  15614. * the nth argument from the end is returned.
  15615. *
  15616. * @static
  15617. * @memberOf _
  15618. * @since 4.0.0
  15619. * @category Util
  15620. * @param {number} [n=0] The index of the argument to return.
  15621. * @returns {Function} Returns the new pass-thru function.
  15622. * @example
  15623. *
  15624. * var func = _.nthArg(1);
  15625. * func('a', 'b', 'c', 'd');
  15626. * // => 'b'
  15627. *
  15628. * var func = _.nthArg(-2);
  15629. * func('a', 'b', 'c', 'd');
  15630. * // => 'c'
  15631. */
  15632. function nthArg(n) {
  15633. n = toInteger(n);
  15634. return baseRest(function(args) {
  15635. return baseNth(args, n);
  15636. });
  15637. }
  15638. /**
  15639. * Creates a function that invokes `iteratees` with the arguments it receives
  15640. * and returns their results.
  15641. *
  15642. * @static
  15643. * @memberOf _
  15644. * @since 4.0.0
  15645. * @category Util
  15646. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  15647. * The iteratees to invoke.
  15648. * @returns {Function} Returns the new function.
  15649. * @example
  15650. *
  15651. * var func = _.over([Math.max, Math.min]);
  15652. *
  15653. * func(1, 2, 3, 4);
  15654. * // => [4, 1]
  15655. */
  15656. var over = createOver(arrayMap);
  15657. /**
  15658. * Creates a function that checks if **all** of the `predicates` return
  15659. * truthy when invoked with the arguments it receives.
  15660. *
  15661. * @static
  15662. * @memberOf _
  15663. * @since 4.0.0
  15664. * @category Util
  15665. * @param {...(Function|Function[])} [predicates=[_.identity]]
  15666. * The predicates to check.
  15667. * @returns {Function} Returns the new function.
  15668. * @example
  15669. *
  15670. * var func = _.overEvery([Boolean, isFinite]);
  15671. *
  15672. * func('1');
  15673. * // => true
  15674. *
  15675. * func(null);
  15676. * // => false
  15677. *
  15678. * func(NaN);
  15679. * // => false
  15680. */
  15681. var overEvery = createOver(arrayEvery);
  15682. /**
  15683. * Creates a function that checks if **any** of the `predicates` return
  15684. * truthy when invoked with the arguments it receives.
  15685. *
  15686. * @static
  15687. * @memberOf _
  15688. * @since 4.0.0
  15689. * @category Util
  15690. * @param {...(Function|Function[])} [predicates=[_.identity]]
  15691. * The predicates to check.
  15692. * @returns {Function} Returns the new function.
  15693. * @example
  15694. *
  15695. * var func = _.overSome([Boolean, isFinite]);
  15696. *
  15697. * func('1');
  15698. * // => true
  15699. *
  15700. * func(null);
  15701. * // => true
  15702. *
  15703. * func(NaN);
  15704. * // => false
  15705. */
  15706. var overSome = createOver(arraySome);
  15707. /**
  15708. * Creates a function that returns the value at `path` of a given object.
  15709. *
  15710. * @static
  15711. * @memberOf _
  15712. * @since 2.4.0
  15713. * @category Util
  15714. * @param {Array|string} path The path of the property to get.
  15715. * @returns {Function} Returns the new accessor function.
  15716. * @example
  15717. *
  15718. * var objects = [
  15719. * { 'a': { 'b': 2 } },
  15720. * { 'a': { 'b': 1 } }
  15721. * ];
  15722. *
  15723. * _.map(objects, _.property('a.b'));
  15724. * // => [2, 1]
  15725. *
  15726. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  15727. * // => [1, 2]
  15728. */
  15729. function property(path) {
  15730. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  15731. }
  15732. /**
  15733. * The opposite of `_.property`; this method creates a function that returns
  15734. * the value at a given path of `object`.
  15735. *
  15736. * @static
  15737. * @memberOf _
  15738. * @since 3.0.0
  15739. * @category Util
  15740. * @param {Object} object The object to query.
  15741. * @returns {Function} Returns the new accessor function.
  15742. * @example
  15743. *
  15744. * var array = [0, 1, 2],
  15745. * object = { 'a': array, 'b': array, 'c': array };
  15746. *
  15747. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  15748. * // => [2, 0]
  15749. *
  15750. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  15751. * // => [2, 0]
  15752. */
  15753. function propertyOf(object) {
  15754. return function(path) {
  15755. return object == null ? undefined : baseGet(object, path);
  15756. };
  15757. }
  15758. /**
  15759. * Creates an array of numbers (positive and/or negative) progressing from
  15760. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  15761. * `start` is specified without an `end` or `step`. If `end` is not specified,
  15762. * it's set to `start` with `start` then set to `0`.
  15763. *
  15764. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  15765. * floating-point values which can produce unexpected results.
  15766. *
  15767. * @static
  15768. * @since 0.1.0
  15769. * @memberOf _
  15770. * @category Util
  15771. * @param {number} [start=0] The start of the range.
  15772. * @param {number} end The end of the range.
  15773. * @param {number} [step=1] The value to increment or decrement by.
  15774. * @returns {Array} Returns the range of numbers.
  15775. * @see _.inRange, _.rangeRight
  15776. * @example
  15777. *
  15778. * _.range(4);
  15779. * // => [0, 1, 2, 3]
  15780. *
  15781. * _.range(-4);
  15782. * // => [0, -1, -2, -3]
  15783. *
  15784. * _.range(1, 5);
  15785. * // => [1, 2, 3, 4]
  15786. *
  15787. * _.range(0, 20, 5);
  15788. * // => [0, 5, 10, 15]
  15789. *
  15790. * _.range(0, -4, -1);
  15791. * // => [0, -1, -2, -3]
  15792. *
  15793. * _.range(1, 4, 0);
  15794. * // => [1, 1, 1]
  15795. *
  15796. * _.range(0);
  15797. * // => []
  15798. */
  15799. var range = createRange();
  15800. /**
  15801. * This method is like `_.range` except that it populates values in
  15802. * descending order.
  15803. *
  15804. * @static
  15805. * @memberOf _
  15806. * @since 4.0.0
  15807. * @category Util
  15808. * @param {number} [start=0] The start of the range.
  15809. * @param {number} end The end of the range.
  15810. * @param {number} [step=1] The value to increment or decrement by.
  15811. * @returns {Array} Returns the range of numbers.
  15812. * @see _.inRange, _.range
  15813. * @example
  15814. *
  15815. * _.rangeRight(4);
  15816. * // => [3, 2, 1, 0]
  15817. *
  15818. * _.rangeRight(-4);
  15819. * // => [-3, -2, -1, 0]
  15820. *
  15821. * _.rangeRight(1, 5);
  15822. * // => [4, 3, 2, 1]
  15823. *
  15824. * _.rangeRight(0, 20, 5);
  15825. * // => [15, 10, 5, 0]
  15826. *
  15827. * _.rangeRight(0, -4, -1);
  15828. * // => [-3, -2, -1, 0]
  15829. *
  15830. * _.rangeRight(1, 4, 0);
  15831. * // => [1, 1, 1]
  15832. *
  15833. * _.rangeRight(0);
  15834. * // => []
  15835. */
  15836. var rangeRight = createRange(true);
  15837. /**
  15838. * This method returns a new empty array.
  15839. *
  15840. * @static
  15841. * @memberOf _
  15842. * @since 4.13.0
  15843. * @category Util
  15844. * @returns {Array} Returns the new empty array.
  15845. * @example
  15846. *
  15847. * var arrays = _.times(2, _.stubArray);
  15848. *
  15849. * console.log(arrays);
  15850. * // => [[], []]
  15851. *
  15852. * console.log(arrays[0] === arrays[1]);
  15853. * // => false
  15854. */
  15855. function stubArray() {
  15856. return [];
  15857. }
  15858. /**
  15859. * This method returns `false`.
  15860. *
  15861. * @static
  15862. * @memberOf _
  15863. * @since 4.13.0
  15864. * @category Util
  15865. * @returns {boolean} Returns `false`.
  15866. * @example
  15867. *
  15868. * _.times(2, _.stubFalse);
  15869. * // => [false, false]
  15870. */
  15871. function stubFalse() {
  15872. return false;
  15873. }
  15874. /**
  15875. * This method returns a new empty object.
  15876. *
  15877. * @static
  15878. * @memberOf _
  15879. * @since 4.13.0
  15880. * @category Util
  15881. * @returns {Object} Returns the new empty object.
  15882. * @example
  15883. *
  15884. * var objects = _.times(2, _.stubObject);
  15885. *
  15886. * console.log(objects);
  15887. * // => [{}, {}]
  15888. *
  15889. * console.log(objects[0] === objects[1]);
  15890. * // => false
  15891. */
  15892. function stubObject() {
  15893. return {};
  15894. }
  15895. /**
  15896. * This method returns an empty string.
  15897. *
  15898. * @static
  15899. * @memberOf _
  15900. * @since 4.13.0
  15901. * @category Util
  15902. * @returns {string} Returns the empty string.
  15903. * @example
  15904. *
  15905. * _.times(2, _.stubString);
  15906. * // => ['', '']
  15907. */
  15908. function stubString() {
  15909. return '';
  15910. }
  15911. /**
  15912. * This method returns `true`.
  15913. *
  15914. * @static
  15915. * @memberOf _
  15916. * @since 4.13.0
  15917. * @category Util
  15918. * @returns {boolean} Returns `true`.
  15919. * @example
  15920. *
  15921. * _.times(2, _.stubTrue);
  15922. * // => [true, true]
  15923. */
  15924. function stubTrue() {
  15925. return true;
  15926. }
  15927. /**
  15928. * Invokes the iteratee `n` times, returning an array of the results of
  15929. * each invocation. The iteratee is invoked with one argument; (index).
  15930. *
  15931. * @static
  15932. * @since 0.1.0
  15933. * @memberOf _
  15934. * @category Util
  15935. * @param {number} n The number of times to invoke `iteratee`.
  15936. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  15937. * @returns {Array} Returns the array of results.
  15938. * @example
  15939. *
  15940. * _.times(3, String);
  15941. * // => ['0', '1', '2']
  15942. *
  15943. * _.times(4, _.constant(0));
  15944. * // => [0, 0, 0, 0]
  15945. */
  15946. function times(n, iteratee) {
  15947. n = toInteger(n);
  15948. if (n < 1 || n > MAX_SAFE_INTEGER) {
  15949. return [];
  15950. }
  15951. var index = MAX_ARRAY_LENGTH,
  15952. length = nativeMin(n, MAX_ARRAY_LENGTH);
  15953. iteratee = getIteratee(iteratee);
  15954. n -= MAX_ARRAY_LENGTH;
  15955. var result = baseTimes(length, iteratee);
  15956. while (++index < n) {
  15957. iteratee(index);
  15958. }
  15959. return result;
  15960. }
  15961. /**
  15962. * Converts `value` to a property path array.
  15963. *
  15964. * @static
  15965. * @memberOf _
  15966. * @since 4.0.0
  15967. * @category Util
  15968. * @param {*} value The value to convert.
  15969. * @returns {Array} Returns the new property path array.
  15970. * @example
  15971. *
  15972. * _.toPath('a.b.c');
  15973. * // => ['a', 'b', 'c']
  15974. *
  15975. * _.toPath('a[0].b.c');
  15976. * // => ['a', '0', 'b', 'c']
  15977. */
  15978. function toPath(value) {
  15979. if (isArray(value)) {
  15980. return arrayMap(value, toKey);
  15981. }
  15982. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  15983. }
  15984. /**
  15985. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  15986. *
  15987. * @static
  15988. * @since 0.1.0
  15989. * @memberOf _
  15990. * @category Util
  15991. * @param {string} [prefix=''] The value to prefix the ID with.
  15992. * @returns {string} Returns the unique ID.
  15993. * @example
  15994. *
  15995. * _.uniqueId('contact_');
  15996. * // => 'contact_104'
  15997. *
  15998. * _.uniqueId();
  15999. * // => '105'
  16000. */
  16001. function uniqueId(prefix) {
  16002. var id = ++idCounter;
  16003. return toString(prefix) + id;
  16004. }
  16005. /*------------------------------------------------------------------------*/
  16006. /**
  16007. * Adds two numbers.
  16008. *
  16009. * @static
  16010. * @memberOf _
  16011. * @since 3.4.0
  16012. * @category Math
  16013. * @param {number} augend The first number in an addition.
  16014. * @param {number} addend The second number in an addition.
  16015. * @returns {number} Returns the total.
  16016. * @example
  16017. *
  16018. * _.add(6, 4);
  16019. * // => 10
  16020. */
  16021. var add = createMathOperation(function(augend, addend) {
  16022. return augend + addend;
  16023. }, 0);
  16024. /**
  16025. * Computes `number` rounded up to `precision`.
  16026. *
  16027. * @static
  16028. * @memberOf _
  16029. * @since 3.10.0
  16030. * @category Math
  16031. * @param {number} number The number to round up.
  16032. * @param {number} [precision=0] The precision to round up to.
  16033. * @returns {number} Returns the rounded up number.
  16034. * @example
  16035. *
  16036. * _.ceil(4.006);
  16037. * // => 5
  16038. *
  16039. * _.ceil(6.004, 2);
  16040. * // => 6.01
  16041. *
  16042. * _.ceil(6040, -2);
  16043. * // => 6100
  16044. */
  16045. var ceil = createRound('ceil');
  16046. /**
  16047. * Divide two numbers.
  16048. *
  16049. * @static
  16050. * @memberOf _
  16051. * @since 4.7.0
  16052. * @category Math
  16053. * @param {number} dividend The first number in a division.
  16054. * @param {number} divisor The second number in a division.
  16055. * @returns {number} Returns the quotient.
  16056. * @example
  16057. *
  16058. * _.divide(6, 4);
  16059. * // => 1.5
  16060. */
  16061. var divide = createMathOperation(function(dividend, divisor) {
  16062. return dividend / divisor;
  16063. }, 1);
  16064. /**
  16065. * Computes `number` rounded down to `precision`.
  16066. *
  16067. * @static
  16068. * @memberOf _
  16069. * @since 3.10.0
  16070. * @category Math
  16071. * @param {number} number The number to round down.
  16072. * @param {number} [precision=0] The precision to round down to.
  16073. * @returns {number} Returns the rounded down number.
  16074. * @example
  16075. *
  16076. * _.floor(4.006);
  16077. * // => 4
  16078. *
  16079. * _.floor(0.046, 2);
  16080. * // => 0.04
  16081. *
  16082. * _.floor(4060, -2);
  16083. * // => 4000
  16084. */
  16085. var floor = createRound('floor');
  16086. /**
  16087. * Computes the maximum value of `array`. If `array` is empty or falsey,
  16088. * `undefined` is returned.
  16089. *
  16090. * @static
  16091. * @since 0.1.0
  16092. * @memberOf _
  16093. * @category Math
  16094. * @param {Array} array The array to iterate over.
  16095. * @returns {*} Returns the maximum value.
  16096. * @example
  16097. *
  16098. * _.max([4, 2, 8, 6]);
  16099. * // => 8
  16100. *
  16101. * _.max([]);
  16102. * // => undefined
  16103. */
  16104. function max(array) {
  16105. return (array && array.length)
  16106. ? baseExtremum(array, identity, baseGt)
  16107. : undefined;
  16108. }
  16109. /**
  16110. * This method is like `_.max` except that it accepts `iteratee` which is
  16111. * invoked for each element in `array` to generate the criterion by which
  16112. * the value is ranked. The iteratee is invoked with one argument: (value).
  16113. *
  16114. * @static
  16115. * @memberOf _
  16116. * @since 4.0.0
  16117. * @category Math
  16118. * @param {Array} array The array to iterate over.
  16119. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16120. * @returns {*} Returns the maximum value.
  16121. * @example
  16122. *
  16123. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16124. *
  16125. * _.maxBy(objects, function(o) { return o.n; });
  16126. * // => { 'n': 2 }
  16127. *
  16128. * // The `_.property` iteratee shorthand.
  16129. * _.maxBy(objects, 'n');
  16130. * // => { 'n': 2 }
  16131. */
  16132. function maxBy(array, iteratee) {
  16133. return (array && array.length)
  16134. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  16135. : undefined;
  16136. }
  16137. /**
  16138. * Computes the mean of the values in `array`.
  16139. *
  16140. * @static
  16141. * @memberOf _
  16142. * @since 4.0.0
  16143. * @category Math
  16144. * @param {Array} array The array to iterate over.
  16145. * @returns {number} Returns the mean.
  16146. * @example
  16147. *
  16148. * _.mean([4, 2, 8, 6]);
  16149. * // => 5
  16150. */
  16151. function mean(array) {
  16152. return baseMean(array, identity);
  16153. }
  16154. /**
  16155. * This method is like `_.mean` except that it accepts `iteratee` which is
  16156. * invoked for each element in `array` to generate the value to be averaged.
  16157. * The iteratee is invoked with one argument: (value).
  16158. *
  16159. * @static
  16160. * @memberOf _
  16161. * @since 4.7.0
  16162. * @category Math
  16163. * @param {Array} array The array to iterate over.
  16164. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16165. * @returns {number} Returns the mean.
  16166. * @example
  16167. *
  16168. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16169. *
  16170. * _.meanBy(objects, function(o) { return o.n; });
  16171. * // => 5
  16172. *
  16173. * // The `_.property` iteratee shorthand.
  16174. * _.meanBy(objects, 'n');
  16175. * // => 5
  16176. */
  16177. function meanBy(array, iteratee) {
  16178. return baseMean(array, getIteratee(iteratee, 2));
  16179. }
  16180. /**
  16181. * Computes the minimum value of `array`. If `array` is empty or falsey,
  16182. * `undefined` is returned.
  16183. *
  16184. * @static
  16185. * @since 0.1.0
  16186. * @memberOf _
  16187. * @category Math
  16188. * @param {Array} array The array to iterate over.
  16189. * @returns {*} Returns the minimum value.
  16190. * @example
  16191. *
  16192. * _.min([4, 2, 8, 6]);
  16193. * // => 2
  16194. *
  16195. * _.min([]);
  16196. * // => undefined
  16197. */
  16198. function min(array) {
  16199. return (array && array.length)
  16200. ? baseExtremum(array, identity, baseLt)
  16201. : undefined;
  16202. }
  16203. /**
  16204. * This method is like `_.min` except that it accepts `iteratee` which is
  16205. * invoked for each element in `array` to generate the criterion by which
  16206. * the value is ranked. The iteratee is invoked with one argument: (value).
  16207. *
  16208. * @static
  16209. * @memberOf _
  16210. * @since 4.0.0
  16211. * @category Math
  16212. * @param {Array} array The array to iterate over.
  16213. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16214. * @returns {*} Returns the minimum value.
  16215. * @example
  16216. *
  16217. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16218. *
  16219. * _.minBy(objects, function(o) { return o.n; });
  16220. * // => { 'n': 1 }
  16221. *
  16222. * // The `_.property` iteratee shorthand.
  16223. * _.minBy(objects, 'n');
  16224. * // => { 'n': 1 }
  16225. */
  16226. function minBy(array, iteratee) {
  16227. return (array && array.length)
  16228. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  16229. : undefined;
  16230. }
  16231. /**
  16232. * Multiply two numbers.
  16233. *
  16234. * @static
  16235. * @memberOf _
  16236. * @since 4.7.0
  16237. * @category Math
  16238. * @param {number} multiplier The first number in a multiplication.
  16239. * @param {number} multiplicand The second number in a multiplication.
  16240. * @returns {number} Returns the product.
  16241. * @example
  16242. *
  16243. * _.multiply(6, 4);
  16244. * // => 24
  16245. */
  16246. var multiply = createMathOperation(function(multiplier, multiplicand) {
  16247. return multiplier * multiplicand;
  16248. }, 1);
  16249. /**
  16250. * Computes `number` rounded to `precision`.
  16251. *
  16252. * @static
  16253. * @memberOf _
  16254. * @since 3.10.0
  16255. * @category Math
  16256. * @param {number} number The number to round.
  16257. * @param {number} [precision=0] The precision to round to.
  16258. * @returns {number} Returns the rounded number.
  16259. * @example
  16260. *
  16261. * _.round(4.006);
  16262. * // => 4
  16263. *
  16264. * _.round(4.006, 2);
  16265. * // => 4.01
  16266. *
  16267. * _.round(4060, -2);
  16268. * // => 4100
  16269. */
  16270. var round = createRound('round');
  16271. /**
  16272. * Subtract two numbers.
  16273. *
  16274. * @static
  16275. * @memberOf _
  16276. * @since 4.0.0
  16277. * @category Math
  16278. * @param {number} minuend The first number in a subtraction.
  16279. * @param {number} subtrahend The second number in a subtraction.
  16280. * @returns {number} Returns the difference.
  16281. * @example
  16282. *
  16283. * _.subtract(6, 4);
  16284. * // => 2
  16285. */
  16286. var subtract = createMathOperation(function(minuend, subtrahend) {
  16287. return minuend - subtrahend;
  16288. }, 0);
  16289. /**
  16290. * Computes the sum of the values in `array`.
  16291. *
  16292. * @static
  16293. * @memberOf _
  16294. * @since 3.4.0
  16295. * @category Math
  16296. * @param {Array} array The array to iterate over.
  16297. * @returns {number} Returns the sum.
  16298. * @example
  16299. *
  16300. * _.sum([4, 2, 8, 6]);
  16301. * // => 20
  16302. */
  16303. function sum(array) {
  16304. return (array && array.length)
  16305. ? baseSum(array, identity)
  16306. : 0;
  16307. }
  16308. /**
  16309. * This method is like `_.sum` except that it accepts `iteratee` which is
  16310. * invoked for each element in `array` to generate the value to be summed.
  16311. * The iteratee is invoked with one argument: (value).
  16312. *
  16313. * @static
  16314. * @memberOf _
  16315. * @since 4.0.0
  16316. * @category Math
  16317. * @param {Array} array The array to iterate over.
  16318. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16319. * @returns {number} Returns the sum.
  16320. * @example
  16321. *
  16322. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16323. *
  16324. * _.sumBy(objects, function(o) { return o.n; });
  16325. * // => 20
  16326. *
  16327. * // The `_.property` iteratee shorthand.
  16328. * _.sumBy(objects, 'n');
  16329. * // => 20
  16330. */
  16331. function sumBy(array, iteratee) {
  16332. return (array && array.length)
  16333. ? baseSum(array, getIteratee(iteratee, 2))
  16334. : 0;
  16335. }
  16336. /*------------------------------------------------------------------------*/
  16337. // Add methods that return wrapped values in chain sequences.
  16338. lodash.after = after;
  16339. lodash.ary = ary;
  16340. lodash.assign = assign;
  16341. lodash.assignIn = assignIn;
  16342. lodash.assignInWith = assignInWith;
  16343. lodash.assignWith = assignWith;
  16344. lodash.at = at;
  16345. lodash.before = before;
  16346. lodash.bind = bind;
  16347. lodash.bindAll = bindAll;
  16348. lodash.bindKey = bindKey;
  16349. lodash.castArray = castArray;
  16350. lodash.chain = chain;
  16351. lodash.chunk = chunk;
  16352. lodash.compact = compact;
  16353. lodash.concat = concat;
  16354. lodash.cond = cond;
  16355. lodash.conforms = conforms;
  16356. lodash.constant = constant;
  16357. lodash.countBy = countBy;
  16358. lodash.create = create;
  16359. lodash.curry = curry;
  16360. lodash.curryRight = curryRight;
  16361. lodash.debounce = debounce;
  16362. lodash.defaults = defaults;
  16363. lodash.defaultsDeep = defaultsDeep;
  16364. lodash.defer = defer;
  16365. lodash.delay = delay;
  16366. lodash.difference = difference;
  16367. lodash.differenceBy = differenceBy;
  16368. lodash.differenceWith = differenceWith;
  16369. lodash.drop = drop;
  16370. lodash.dropRight = dropRight;
  16371. lodash.dropRightWhile = dropRightWhile;
  16372. lodash.dropWhile = dropWhile;
  16373. lodash.fill = fill;
  16374. lodash.filter = filter;
  16375. lodash.flatMap = flatMap;
  16376. lodash.flatMapDeep = flatMapDeep;
  16377. lodash.flatMapDepth = flatMapDepth;
  16378. lodash.flatten = flatten;
  16379. lodash.flattenDeep = flattenDeep;
  16380. lodash.flattenDepth = flattenDepth;
  16381. lodash.flip = flip;
  16382. lodash.flow = flow;
  16383. lodash.flowRight = flowRight;
  16384. lodash.fromPairs = fromPairs;
  16385. lodash.functions = functions;
  16386. lodash.functionsIn = functionsIn;
  16387. lodash.groupBy = groupBy;
  16388. lodash.initial = initial;
  16389. lodash.intersection = intersection;
  16390. lodash.intersectionBy = intersectionBy;
  16391. lodash.intersectionWith = intersectionWith;
  16392. lodash.invert = invert;
  16393. lodash.invertBy = invertBy;
  16394. lodash.invokeMap = invokeMap;
  16395. lodash.iteratee = iteratee;
  16396. lodash.keyBy = keyBy;
  16397. lodash.keys = keys;
  16398. lodash.keysIn = keysIn;
  16399. lodash.map = map;
  16400. lodash.mapKeys = mapKeys;
  16401. lodash.mapValues = mapValues;
  16402. lodash.matches = matches;
  16403. lodash.matchesProperty = matchesProperty;
  16404. lodash.memoize = memoize;
  16405. lodash.merge = merge;
  16406. lodash.mergeWith = mergeWith;
  16407. lodash.method = method;
  16408. lodash.methodOf = methodOf;
  16409. lodash.mixin = mixin;
  16410. lodash.negate = negate;
  16411. lodash.nthArg = nthArg;
  16412. lodash.omit = omit;
  16413. lodash.omitBy = omitBy;
  16414. lodash.once = once;
  16415. lodash.orderBy = orderBy;
  16416. lodash.over = over;
  16417. lodash.overArgs = overArgs;
  16418. lodash.overEvery = overEvery;
  16419. lodash.overSome = overSome;
  16420. lodash.partial = partial;
  16421. lodash.partialRight = partialRight;
  16422. lodash.partition = partition;
  16423. lodash.pick = pick;
  16424. lodash.pickBy = pickBy;
  16425. lodash.property = property;
  16426. lodash.propertyOf = propertyOf;
  16427. lodash.pull = pull;
  16428. lodash.pullAll = pullAll;
  16429. lodash.pullAllBy = pullAllBy;
  16430. lodash.pullAllWith = pullAllWith;
  16431. lodash.pullAt = pullAt;
  16432. lodash.range = range;
  16433. lodash.rangeRight = rangeRight;
  16434. lodash.rearg = rearg;
  16435. lodash.reject = reject;
  16436. lodash.remove = remove;
  16437. lodash.rest = rest;
  16438. lodash.reverse = reverse;
  16439. lodash.sampleSize = sampleSize;
  16440. lodash.set = set;
  16441. lodash.setWith = setWith;
  16442. lodash.shuffle = shuffle;
  16443. lodash.slice = slice;
  16444. lodash.sortBy = sortBy;
  16445. lodash.sortedUniq = sortedUniq;
  16446. lodash.sortedUniqBy = sortedUniqBy;
  16447. lodash.split = split;
  16448. lodash.spread = spread;
  16449. lodash.tail = tail;
  16450. lodash.take = take;
  16451. lodash.takeRight = takeRight;
  16452. lodash.takeRightWhile = takeRightWhile;
  16453. lodash.takeWhile = takeWhile;
  16454. lodash.tap = tap;
  16455. lodash.throttle = throttle;
  16456. lodash.thru = thru;
  16457. lodash.toArray = toArray;
  16458. lodash.toPairs = toPairs;
  16459. lodash.toPairsIn = toPairsIn;
  16460. lodash.toPath = toPath;
  16461. lodash.toPlainObject = toPlainObject;
  16462. lodash.transform = transform;
  16463. lodash.unary = unary;
  16464. lodash.union = union;
  16465. lodash.unionBy = unionBy;
  16466. lodash.unionWith = unionWith;
  16467. lodash.uniq = uniq;
  16468. lodash.uniqBy = uniqBy;
  16469. lodash.uniqWith = uniqWith;
  16470. lodash.unset = unset;
  16471. lodash.unzip = unzip;
  16472. lodash.unzipWith = unzipWith;
  16473. lodash.update = update;
  16474. lodash.updateWith = updateWith;
  16475. lodash.values = values;
  16476. lodash.valuesIn = valuesIn;
  16477. lodash.without = without;
  16478. lodash.words = words;
  16479. lodash.wrap = wrap;
  16480. lodash.xor = xor;
  16481. lodash.xorBy = xorBy;
  16482. lodash.xorWith = xorWith;
  16483. lodash.zip = zip;
  16484. lodash.zipObject = zipObject;
  16485. lodash.zipObjectDeep = zipObjectDeep;
  16486. lodash.zipWith = zipWith;
  16487. // Add aliases.
  16488. lodash.entries = toPairs;
  16489. lodash.entriesIn = toPairsIn;
  16490. lodash.extend = assignIn;
  16491. lodash.extendWith = assignInWith;
  16492. // Add methods to `lodash.prototype`.
  16493. mixin(lodash, lodash);
  16494. /*------------------------------------------------------------------------*/
  16495. // Add methods that return unwrapped values in chain sequences.
  16496. lodash.add = add;
  16497. lodash.attempt = attempt;
  16498. lodash.camelCase = camelCase;
  16499. lodash.capitalize = capitalize;
  16500. lodash.ceil = ceil;
  16501. lodash.clamp = clamp;
  16502. lodash.clone = clone;
  16503. lodash.cloneDeep = cloneDeep;
  16504. lodash.cloneDeepWith = cloneDeepWith;
  16505. lodash.cloneWith = cloneWith;
  16506. lodash.conformsTo = conformsTo;
  16507. lodash.deburr = deburr;
  16508. lodash.defaultTo = defaultTo;
  16509. lodash.divide = divide;
  16510. lodash.endsWith = endsWith;
  16511. lodash.eq = eq;
  16512. lodash.escape = escape;
  16513. lodash.escapeRegExp = escapeRegExp;
  16514. lodash.every = every;
  16515. lodash.find = find;
  16516. lodash.findIndex = findIndex;
  16517. lodash.findKey = findKey;
  16518. lodash.findLast = findLast;
  16519. lodash.findLastIndex = findLastIndex;
  16520. lodash.findLastKey = findLastKey;
  16521. lodash.floor = floor;
  16522. lodash.forEach = forEach;
  16523. lodash.forEachRight = forEachRight;
  16524. lodash.forIn = forIn;
  16525. lodash.forInRight = forInRight;
  16526. lodash.forOwn = forOwn;
  16527. lodash.forOwnRight = forOwnRight;
  16528. lodash.get = get;
  16529. lodash.gt = gt;
  16530. lodash.gte = gte;
  16531. lodash.has = has;
  16532. lodash.hasIn = hasIn;
  16533. lodash.head = head;
  16534. lodash.identity = identity;
  16535. lodash.includes = includes;
  16536. lodash.indexOf = indexOf;
  16537. lodash.inRange = inRange;
  16538. lodash.invoke = invoke;
  16539. lodash.isArguments = isArguments;
  16540. lodash.isArray = isArray;
  16541. lodash.isArrayBuffer = isArrayBuffer;
  16542. lodash.isArrayLike = isArrayLike;
  16543. lodash.isArrayLikeObject = isArrayLikeObject;
  16544. lodash.isBoolean = isBoolean;
  16545. lodash.isBuffer = isBuffer;
  16546. lodash.isDate = isDate;
  16547. lodash.isElement = isElement;
  16548. lodash.isEmpty = isEmpty;
  16549. lodash.isEqual = isEqual;
  16550. lodash.isEqualWith = isEqualWith;
  16551. lodash.isError = isError;
  16552. lodash.isFinite = isFinite;
  16553. lodash.isFunction = isFunction;
  16554. lodash.isInteger = isInteger;
  16555. lodash.isLength = isLength;
  16556. lodash.isMap = isMap;
  16557. lodash.isMatch = isMatch;
  16558. lodash.isMatchWith = isMatchWith;
  16559. lodash.isNaN = isNaN;
  16560. lodash.isNative = isNative;
  16561. lodash.isNil = isNil;
  16562. lodash.isNull = isNull;
  16563. lodash.isNumber = isNumber;
  16564. lodash.isObject = isObject;
  16565. lodash.isObjectLike = isObjectLike;
  16566. lodash.isPlainObject = isPlainObject;
  16567. lodash.isRegExp = isRegExp;
  16568. lodash.isSafeInteger = isSafeInteger;
  16569. lodash.isSet = isSet;
  16570. lodash.isString = isString;
  16571. lodash.isSymbol = isSymbol;
  16572. lodash.isTypedArray = isTypedArray;
  16573. lodash.isUndefined = isUndefined;
  16574. lodash.isWeakMap = isWeakMap;
  16575. lodash.isWeakSet = isWeakSet;
  16576. lodash.join = join;
  16577. lodash.kebabCase = kebabCase;
  16578. lodash.last = last;
  16579. lodash.lastIndexOf = lastIndexOf;
  16580. lodash.lowerCase = lowerCase;
  16581. lodash.lowerFirst = lowerFirst;
  16582. lodash.lt = lt;
  16583. lodash.lte = lte;
  16584. lodash.max = max;
  16585. lodash.maxBy = maxBy;
  16586. lodash.mean = mean;
  16587. lodash.meanBy = meanBy;
  16588. lodash.min = min;
  16589. lodash.minBy = minBy;
  16590. lodash.stubArray = stubArray;
  16591. lodash.stubFalse = stubFalse;
  16592. lodash.stubObject = stubObject;
  16593. lodash.stubString = stubString;
  16594. lodash.stubTrue = stubTrue;
  16595. lodash.multiply = multiply;
  16596. lodash.nth = nth;
  16597. lodash.noConflict = noConflict;
  16598. lodash.noop = noop;
  16599. lodash.now = now;
  16600. lodash.pad = pad;
  16601. lodash.padEnd = padEnd;
  16602. lodash.padStart = padStart;
  16603. lodash.parseInt = parseInt;
  16604. lodash.random = random;
  16605. lodash.reduce = reduce;
  16606. lodash.reduceRight = reduceRight;
  16607. lodash.repeat = repeat;
  16608. lodash.replace = replace;
  16609. lodash.result = result;
  16610. lodash.round = round;
  16611. lodash.runInContext = runInContext;
  16612. lodash.sample = sample;
  16613. lodash.size = size;
  16614. lodash.snakeCase = snakeCase;
  16615. lodash.some = some;
  16616. lodash.sortedIndex = sortedIndex;
  16617. lodash.sortedIndexBy = sortedIndexBy;
  16618. lodash.sortedIndexOf = sortedIndexOf;
  16619. lodash.sortedLastIndex = sortedLastIndex;
  16620. lodash.sortedLastIndexBy = sortedLastIndexBy;
  16621. lodash.sortedLastIndexOf = sortedLastIndexOf;
  16622. lodash.startCase = startCase;
  16623. lodash.startsWith = startsWith;
  16624. lodash.subtract = subtract;
  16625. lodash.sum = sum;
  16626. lodash.sumBy = sumBy;
  16627. lodash.template = template;
  16628. lodash.times = times;
  16629. lodash.toFinite = toFinite;
  16630. lodash.toInteger = toInteger;
  16631. lodash.toLength = toLength;
  16632. lodash.toLower = toLower;
  16633. lodash.toNumber = toNumber;
  16634. lodash.toSafeInteger = toSafeInteger;
  16635. lodash.toString = toString;
  16636. lodash.toUpper = toUpper;
  16637. lodash.trim = trim;
  16638. lodash.trimEnd = trimEnd;
  16639. lodash.trimStart = trimStart;
  16640. lodash.truncate = truncate;
  16641. lodash.unescape = unescape;
  16642. lodash.uniqueId = uniqueId;
  16643. lodash.upperCase = upperCase;
  16644. lodash.upperFirst = upperFirst;
  16645. // Add aliases.
  16646. lodash.each = forEach;
  16647. lodash.eachRight = forEachRight;
  16648. lodash.first = head;
  16649. mixin(lodash, (function() {
  16650. var source = {};
  16651. baseForOwn(lodash, function(func, methodName) {
  16652. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  16653. source[methodName] = func;
  16654. }
  16655. });
  16656. return source;
  16657. }()), { 'chain': false });
  16658. /*------------------------------------------------------------------------*/
  16659. /**
  16660. * The semantic version number.
  16661. *
  16662. * @static
  16663. * @memberOf _
  16664. * @type {string}
  16665. */
  16666. lodash.VERSION = VERSION;
  16667. // Assign default placeholders.
  16668. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  16669. lodash[methodName].placeholder = lodash;
  16670. });
  16671. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  16672. arrayEach(['drop', 'take'], function(methodName, index) {
  16673. LazyWrapper.prototype[methodName] = function(n) {
  16674. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  16675. var result = (this.__filtered__ && !index)
  16676. ? new LazyWrapper(this)
  16677. : this.clone();
  16678. if (result.__filtered__) {
  16679. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  16680. } else {
  16681. result.__views__.push({
  16682. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  16683. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  16684. });
  16685. }
  16686. return result;
  16687. };
  16688. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  16689. return this.reverse()[methodName](n).reverse();
  16690. };
  16691. });
  16692. // Add `LazyWrapper` methods that accept an `iteratee` value.
  16693. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  16694. var type = index + 1,
  16695. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  16696. LazyWrapper.prototype[methodName] = function(iteratee) {
  16697. var result = this.clone();
  16698. result.__iteratees__.push({
  16699. 'iteratee': getIteratee(iteratee, 3),
  16700. 'type': type
  16701. });
  16702. result.__filtered__ = result.__filtered__ || isFilter;
  16703. return result;
  16704. };
  16705. });
  16706. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  16707. arrayEach(['head', 'last'], function(methodName, index) {
  16708. var takeName = 'take' + (index ? 'Right' : '');
  16709. LazyWrapper.prototype[methodName] = function() {
  16710. return this[takeName](1).value()[0];
  16711. };
  16712. });
  16713. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  16714. arrayEach(['initial', 'tail'], function(methodName, index) {
  16715. var dropName = 'drop' + (index ? '' : 'Right');
  16716. LazyWrapper.prototype[methodName] = function() {
  16717. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  16718. };
  16719. });
  16720. LazyWrapper.prototype.compact = function() {
  16721. return this.filter(identity);
  16722. };
  16723. LazyWrapper.prototype.find = function(predicate) {
  16724. return this.filter(predicate).head();
  16725. };
  16726. LazyWrapper.prototype.findLast = function(predicate) {
  16727. return this.reverse().find(predicate);
  16728. };
  16729. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  16730. if (typeof path == 'function') {
  16731. return new LazyWrapper(this);
  16732. }
  16733. return this.map(function(value) {
  16734. return baseInvoke(value, path, args);
  16735. });
  16736. });
  16737. LazyWrapper.prototype.reject = function(predicate) {
  16738. return this.filter(negate(getIteratee(predicate)));
  16739. };
  16740. LazyWrapper.prototype.slice = function(start, end) {
  16741. start = toInteger(start);
  16742. var result = this;
  16743. if (result.__filtered__ && (start > 0 || end < 0)) {
  16744. return new LazyWrapper(result);
  16745. }
  16746. if (start < 0) {
  16747. result = result.takeRight(-start);
  16748. } else if (start) {
  16749. result = result.drop(start);
  16750. }
  16751. if (end !== undefined) {
  16752. end = toInteger(end);
  16753. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  16754. }
  16755. return result;
  16756. };
  16757. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  16758. return this.reverse().takeWhile(predicate).reverse();
  16759. };
  16760. LazyWrapper.prototype.toArray = function() {
  16761. return this.take(MAX_ARRAY_LENGTH);
  16762. };
  16763. // Add `LazyWrapper` methods to `lodash.prototype`.
  16764. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  16765. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  16766. isTaker = /^(?:head|last)$/.test(methodName),
  16767. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  16768. retUnwrapped = isTaker || /^find/.test(methodName);
  16769. if (!lodashFunc) {
  16770. return;
  16771. }
  16772. lodash.prototype[methodName] = function() {
  16773. var value = this.__wrapped__,
  16774. args = isTaker ? [1] : arguments,
  16775. isLazy = value instanceof LazyWrapper,
  16776. iteratee = args[0],
  16777. useLazy = isLazy || isArray(value);
  16778. var interceptor = function(value) {
  16779. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  16780. return (isTaker && chainAll) ? result[0] : result;
  16781. };
  16782. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  16783. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  16784. isLazy = useLazy = false;
  16785. }
  16786. var chainAll = this.__chain__,
  16787. isHybrid = !!this.__actions__.length,
  16788. isUnwrapped = retUnwrapped && !chainAll,
  16789. onlyLazy = isLazy && !isHybrid;
  16790. if (!retUnwrapped && useLazy) {
  16791. value = onlyLazy ? value : new LazyWrapper(this);
  16792. var result = func.apply(value, args);
  16793. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  16794. return new LodashWrapper(result, chainAll);
  16795. }
  16796. if (isUnwrapped && onlyLazy) {
  16797. return func.apply(this, args);
  16798. }
  16799. result = this.thru(interceptor);
  16800. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  16801. };
  16802. });
  16803. // Add `Array` methods to `lodash.prototype`.
  16804. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  16805. var func = arrayProto[methodName],
  16806. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  16807. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  16808. lodash.prototype[methodName] = function() {
  16809. var args = arguments;
  16810. if (retUnwrapped && !this.__chain__) {
  16811. var value = this.value();
  16812. return func.apply(isArray(value) ? value : [], args);
  16813. }
  16814. return this[chainName](function(value) {
  16815. return func.apply(isArray(value) ? value : [], args);
  16816. });
  16817. };
  16818. });
  16819. // Map minified method names to their real names.
  16820. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  16821. var lodashFunc = lodash[methodName];
  16822. if (lodashFunc) {
  16823. var key = (lodashFunc.name + ''),
  16824. names = realNames[key] || (realNames[key] = []);
  16825. names.push({ 'name': methodName, 'func': lodashFunc });
  16826. }
  16827. });
  16828. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  16829. 'name': 'wrapper',
  16830. 'func': undefined
  16831. }];
  16832. // Add methods to `LazyWrapper`.
  16833. LazyWrapper.prototype.clone = lazyClone;
  16834. LazyWrapper.prototype.reverse = lazyReverse;
  16835. LazyWrapper.prototype.value = lazyValue;
  16836. // Add chain sequence methods to the `lodash` wrapper.
  16837. lodash.prototype.at = wrapperAt;
  16838. lodash.prototype.chain = wrapperChain;
  16839. lodash.prototype.commit = wrapperCommit;
  16840. lodash.prototype.next = wrapperNext;
  16841. lodash.prototype.plant = wrapperPlant;
  16842. lodash.prototype.reverse = wrapperReverse;
  16843. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  16844. // Add lazy aliases.
  16845. lodash.prototype.first = lodash.prototype.head;
  16846. if (symIterator) {
  16847. lodash.prototype[symIterator] = wrapperToIterator;
  16848. }
  16849. return lodash;
  16850. });
  16851. /*--------------------------------------------------------------------------*/
  16852. // Export lodash.
  16853. var _ = runInContext();
  16854. // Some AMD build optimizers, like r.js, check for condition patterns like:
  16855. if (true) {
  16856. // Expose Lodash on the global object to prevent errors when Lodash is
  16857. // loaded by a script tag in the presence of an AMD loader.
  16858. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  16859. // Use `_.noConflict` to remove Lodash from the global object.
  16860. root._ = _;
  16861. // Define as an anonymous module so, through path mapping, it can be
  16862. // referenced as the "underscore" module.
  16863. !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
  16864. return _;
  16865. }.call(exports, __webpack_require__, exports, module),
  16866. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16867. }
  16868. // Check for `exports` after `define` in case a build optimizer adds it.
  16869. else if (freeModule) {
  16870. // Export for Node.js.
  16871. (freeModule.exports = _)._ = _;
  16872. // Export for CommonJS support.
  16873. freeExports._ = _;
  16874. }
  16875. else {
  16876. // Export to the global object.
  16877. root._ = _;
  16878. }
  16879. }.call(this));
  16880. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(13)(module)))
  16881. /***/ }),
  16882. /* 13 */
  16883. /***/ (function(module, exports) {
  16884. module.exports = function(module) {
  16885. if(!module.webpackPolyfill) {
  16886. module.deprecate = function() {};
  16887. module.paths = [];
  16888. // module.parent = undefined by default
  16889. if(!module.children) module.children = [];
  16890. Object.defineProperty(module, "loaded", {
  16891. enumerable: true,
  16892. get: function() {
  16893. return module.l;
  16894. }
  16895. });
  16896. Object.defineProperty(module, "id", {
  16897. enumerable: true,
  16898. get: function() {
  16899. return module.i;
  16900. }
  16901. });
  16902. module.webpackPolyfill = 1;
  16903. }
  16904. return module;
  16905. };
  16906. /***/ }),
  16907. /* 14 */
  16908. /***/ (function(module, exports, __webpack_require__) {
  16909. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  16910. * jQuery JavaScript Library v3.2.1
  16911. * https://jquery.com/
  16912. *
  16913. * Includes Sizzle.js
  16914. * https://sizzlejs.com/
  16915. *
  16916. * Copyright JS Foundation and other contributors
  16917. * Released under the MIT license
  16918. * https://jquery.org/license
  16919. *
  16920. * Date: 2017-03-20T18:59Z
  16921. */
  16922. ( function( global, factory ) {
  16923. "use strict";
  16924. if ( typeof module === "object" && typeof module.exports === "object" ) {
  16925. // For CommonJS and CommonJS-like environments where a proper `window`
  16926. // is present, execute the factory and get jQuery.
  16927. // For environments that do not have a `window` with a `document`
  16928. // (such as Node.js), expose a factory as module.exports.
  16929. // This accentuates the need for the creation of a real `window`.
  16930. // e.g. var jQuery = require("jquery")(window);
  16931. // See ticket #14549 for more info.
  16932. module.exports = global.document ?
  16933. factory( global, true ) :
  16934. function( w ) {
  16935. if ( !w.document ) {
  16936. throw new Error( "jQuery requires a window with a document" );
  16937. }
  16938. return factory( w );
  16939. };
  16940. } else {
  16941. factory( global );
  16942. }
  16943. // Pass this if window is not defined yet
  16944. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  16945. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  16946. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  16947. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  16948. // enough that all such attempts are guarded in a try block.
  16949. "use strict";
  16950. var arr = [];
  16951. var document = window.document;
  16952. var getProto = Object.getPrototypeOf;
  16953. var slice = arr.slice;
  16954. var concat = arr.concat;
  16955. var push = arr.push;
  16956. var indexOf = arr.indexOf;
  16957. var class2type = {};
  16958. var toString = class2type.toString;
  16959. var hasOwn = class2type.hasOwnProperty;
  16960. var fnToString = hasOwn.toString;
  16961. var ObjectFunctionString = fnToString.call( Object );
  16962. var support = {};
  16963. function DOMEval( code, doc ) {
  16964. doc = doc || document;
  16965. var script = doc.createElement( "script" );
  16966. script.text = code;
  16967. doc.head.appendChild( script ).parentNode.removeChild( script );
  16968. }
  16969. /* global Symbol */
  16970. // Defining this global in .eslintrc.json would create a danger of using the global
  16971. // unguarded in another place, it seems safer to define global only for this module
  16972. var
  16973. version = "3.2.1",
  16974. // Define a local copy of jQuery
  16975. jQuery = function( selector, context ) {
  16976. // The jQuery object is actually just the init constructor 'enhanced'
  16977. // Need init if jQuery is called (just allow error to be thrown if not included)
  16978. return new jQuery.fn.init( selector, context );
  16979. },
  16980. // Support: Android <=4.0 only
  16981. // Make sure we trim BOM and NBSP
  16982. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  16983. // Matches dashed string for camelizing
  16984. rmsPrefix = /^-ms-/,
  16985. rdashAlpha = /-([a-z])/g,
  16986. // Used by jQuery.camelCase as callback to replace()
  16987. fcamelCase = function( all, letter ) {
  16988. return letter.toUpperCase();
  16989. };
  16990. jQuery.fn = jQuery.prototype = {
  16991. // The current version of jQuery being used
  16992. jquery: version,
  16993. constructor: jQuery,
  16994. // The default length of a jQuery object is 0
  16995. length: 0,
  16996. toArray: function() {
  16997. return slice.call( this );
  16998. },
  16999. // Get the Nth element in the matched element set OR
  17000. // Get the whole matched element set as a clean array
  17001. get: function( num ) {
  17002. // Return all the elements in a clean array
  17003. if ( num == null ) {
  17004. return slice.call( this );
  17005. }
  17006. // Return just the one element from the set
  17007. return num < 0 ? this[ num + this.length ] : this[ num ];
  17008. },
  17009. // Take an array of elements and push it onto the stack
  17010. // (returning the new matched element set)
  17011. pushStack: function( elems ) {
  17012. // Build a new jQuery matched element set
  17013. var ret = jQuery.merge( this.constructor(), elems );
  17014. // Add the old object onto the stack (as a reference)
  17015. ret.prevObject = this;
  17016. // Return the newly-formed element set
  17017. return ret;
  17018. },
  17019. // Execute a callback for every element in the matched set.
  17020. each: function( callback ) {
  17021. return jQuery.each( this, callback );
  17022. },
  17023. map: function( callback ) {
  17024. return this.pushStack( jQuery.map( this, function( elem, i ) {
  17025. return callback.call( elem, i, elem );
  17026. } ) );
  17027. },
  17028. slice: function() {
  17029. return this.pushStack( slice.apply( this, arguments ) );
  17030. },
  17031. first: function() {
  17032. return this.eq( 0 );
  17033. },
  17034. last: function() {
  17035. return this.eq( -1 );
  17036. },
  17037. eq: function( i ) {
  17038. var len = this.length,
  17039. j = +i + ( i < 0 ? len : 0 );
  17040. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  17041. },
  17042. end: function() {
  17043. return this.prevObject || this.constructor();
  17044. },
  17045. // For internal use only.
  17046. // Behaves like an Array's method, not like a jQuery method.
  17047. push: push,
  17048. sort: arr.sort,
  17049. splice: arr.splice
  17050. };
  17051. jQuery.extend = jQuery.fn.extend = function() {
  17052. var options, name, src, copy, copyIsArray, clone,
  17053. target = arguments[ 0 ] || {},
  17054. i = 1,
  17055. length = arguments.length,
  17056. deep = false;
  17057. // Handle a deep copy situation
  17058. if ( typeof target === "boolean" ) {
  17059. deep = target;
  17060. // Skip the boolean and the target
  17061. target = arguments[ i ] || {};
  17062. i++;
  17063. }
  17064. // Handle case when target is a string or something (possible in deep copy)
  17065. if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
  17066. target = {};
  17067. }
  17068. // Extend jQuery itself if only one argument is passed
  17069. if ( i === length ) {
  17070. target = this;
  17071. i--;
  17072. }
  17073. for ( ; i < length; i++ ) {
  17074. // Only deal with non-null/undefined values
  17075. if ( ( options = arguments[ i ] ) != null ) {
  17076. // Extend the base object
  17077. for ( name in options ) {
  17078. src = target[ name ];
  17079. copy = options[ name ];
  17080. // Prevent never-ending loop
  17081. if ( target === copy ) {
  17082. continue;
  17083. }
  17084. // Recurse if we're merging plain objects or arrays
  17085. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  17086. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  17087. if ( copyIsArray ) {
  17088. copyIsArray = false;
  17089. clone = src && Array.isArray( src ) ? src : [];
  17090. } else {
  17091. clone = src && jQuery.isPlainObject( src ) ? src : {};
  17092. }
  17093. // Never move original objects, clone them
  17094. target[ name ] = jQuery.extend( deep, clone, copy );
  17095. // Don't bring in undefined values
  17096. } else if ( copy !== undefined ) {
  17097. target[ name ] = copy;
  17098. }
  17099. }
  17100. }
  17101. }
  17102. // Return the modified object
  17103. return target;
  17104. };
  17105. jQuery.extend( {
  17106. // Unique for each copy of jQuery on the page
  17107. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  17108. // Assume jQuery is ready without the ready module
  17109. isReady: true,
  17110. error: function( msg ) {
  17111. throw new Error( msg );
  17112. },
  17113. noop: function() {},
  17114. isFunction: function( obj ) {
  17115. return jQuery.type( obj ) === "function";
  17116. },
  17117. isWindow: function( obj ) {
  17118. return obj != null && obj === obj.window;
  17119. },
  17120. isNumeric: function( obj ) {
  17121. // As of jQuery 3.0, isNumeric is limited to
  17122. // strings and numbers (primitives or objects)
  17123. // that can be coerced to finite numbers (gh-2662)
  17124. var type = jQuery.type( obj );
  17125. return ( type === "number" || type === "string" ) &&
  17126. // parseFloat NaNs numeric-cast false positives ("")
  17127. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  17128. // subtraction forces infinities to NaN
  17129. !isNaN( obj - parseFloat( obj ) );
  17130. },
  17131. isPlainObject: function( obj ) {
  17132. var proto, Ctor;
  17133. // Detect obvious negatives
  17134. // Use toString instead of jQuery.type to catch host objects
  17135. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  17136. return false;
  17137. }
  17138. proto = getProto( obj );
  17139. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  17140. if ( !proto ) {
  17141. return true;
  17142. }
  17143. // Objects with prototype are plain iff they were constructed by a global Object function
  17144. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  17145. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  17146. },
  17147. isEmptyObject: function( obj ) {
  17148. /* eslint-disable no-unused-vars */
  17149. // See https://github.com/eslint/eslint/issues/6125
  17150. var name;
  17151. for ( name in obj ) {
  17152. return false;
  17153. }
  17154. return true;
  17155. },
  17156. type: function( obj ) {
  17157. if ( obj == null ) {
  17158. return obj + "";
  17159. }
  17160. // Support: Android <=2.3 only (functionish RegExp)
  17161. return typeof obj === "object" || typeof obj === "function" ?
  17162. class2type[ toString.call( obj ) ] || "object" :
  17163. typeof obj;
  17164. },
  17165. // Evaluates a script in a global context
  17166. globalEval: function( code ) {
  17167. DOMEval( code );
  17168. },
  17169. // Convert dashed to camelCase; used by the css and data modules
  17170. // Support: IE <=9 - 11, Edge 12 - 13
  17171. // Microsoft forgot to hump their vendor prefix (#9572)
  17172. camelCase: function( string ) {
  17173. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  17174. },
  17175. each: function( obj, callback ) {
  17176. var length, i = 0;
  17177. if ( isArrayLike( obj ) ) {
  17178. length = obj.length;
  17179. for ( ; i < length; i++ ) {
  17180. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  17181. break;
  17182. }
  17183. }
  17184. } else {
  17185. for ( i in obj ) {
  17186. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  17187. break;
  17188. }
  17189. }
  17190. }
  17191. return obj;
  17192. },
  17193. // Support: Android <=4.0 only
  17194. trim: function( text ) {
  17195. return text == null ?
  17196. "" :
  17197. ( text + "" ).replace( rtrim, "" );
  17198. },
  17199. // results is for internal usage only
  17200. makeArray: function( arr, results ) {
  17201. var ret = results || [];
  17202. if ( arr != null ) {
  17203. if ( isArrayLike( Object( arr ) ) ) {
  17204. jQuery.merge( ret,
  17205. typeof arr === "string" ?
  17206. [ arr ] : arr
  17207. );
  17208. } else {
  17209. push.call( ret, arr );
  17210. }
  17211. }
  17212. return ret;
  17213. },
  17214. inArray: function( elem, arr, i ) {
  17215. return arr == null ? -1 : indexOf.call( arr, elem, i );
  17216. },
  17217. // Support: Android <=4.0 only, PhantomJS 1 only
  17218. // push.apply(_, arraylike) throws on ancient WebKit
  17219. merge: function( first, second ) {
  17220. var len = +second.length,
  17221. j = 0,
  17222. i = first.length;
  17223. for ( ; j < len; j++ ) {
  17224. first[ i++ ] = second[ j ];
  17225. }
  17226. first.length = i;
  17227. return first;
  17228. },
  17229. grep: function( elems, callback, invert ) {
  17230. var callbackInverse,
  17231. matches = [],
  17232. i = 0,
  17233. length = elems.length,
  17234. callbackExpect = !invert;
  17235. // Go through the array, only saving the items
  17236. // that pass the validator function
  17237. for ( ; i < length; i++ ) {
  17238. callbackInverse = !callback( elems[ i ], i );
  17239. if ( callbackInverse !== callbackExpect ) {
  17240. matches.push( elems[ i ] );
  17241. }
  17242. }
  17243. return matches;
  17244. },
  17245. // arg is for internal usage only
  17246. map: function( elems, callback, arg ) {
  17247. var length, value,
  17248. i = 0,
  17249. ret = [];
  17250. // Go through the array, translating each of the items to their new values
  17251. if ( isArrayLike( elems ) ) {
  17252. length = elems.length;
  17253. for ( ; i < length; i++ ) {
  17254. value = callback( elems[ i ], i, arg );
  17255. if ( value != null ) {
  17256. ret.push( value );
  17257. }
  17258. }
  17259. // Go through every key on the object,
  17260. } else {
  17261. for ( i in elems ) {
  17262. value = callback( elems[ i ], i, arg );
  17263. if ( value != null ) {
  17264. ret.push( value );
  17265. }
  17266. }
  17267. }
  17268. // Flatten any nested arrays
  17269. return concat.apply( [], ret );
  17270. },
  17271. // A global GUID counter for objects
  17272. guid: 1,
  17273. // Bind a function to a context, optionally partially applying any
  17274. // arguments.
  17275. proxy: function( fn, context ) {
  17276. var tmp, args, proxy;
  17277. if ( typeof context === "string" ) {
  17278. tmp = fn[ context ];
  17279. context = fn;
  17280. fn = tmp;
  17281. }
  17282. // Quick check to determine if target is callable, in the spec
  17283. // this throws a TypeError, but we will just return undefined.
  17284. if ( !jQuery.isFunction( fn ) ) {
  17285. return undefined;
  17286. }
  17287. // Simulated bind
  17288. args = slice.call( arguments, 2 );
  17289. proxy = function() {
  17290. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  17291. };
  17292. // Set the guid of unique handler to the same of original handler, so it can be removed
  17293. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  17294. return proxy;
  17295. },
  17296. now: Date.now,
  17297. // jQuery.support is not used in Core but other projects attach their
  17298. // properties to it so it needs to exist.
  17299. support: support
  17300. } );
  17301. if ( typeof Symbol === "function" ) {
  17302. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  17303. }
  17304. // Populate the class2type map
  17305. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  17306. function( i, name ) {
  17307. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  17308. } );
  17309. function isArrayLike( obj ) {
  17310. // Support: real iOS 8.2 only (not reproducible in simulator)
  17311. // `in` check used to prevent JIT error (gh-2145)
  17312. // hasOwn isn't used here due to false negatives
  17313. // regarding Nodelist length in IE
  17314. var length = !!obj && "length" in obj && obj.length,
  17315. type = jQuery.type( obj );
  17316. if ( type === "function" || jQuery.isWindow( obj ) ) {
  17317. return false;
  17318. }
  17319. return type === "array" || length === 0 ||
  17320. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  17321. }
  17322. var Sizzle =
  17323. /*!
  17324. * Sizzle CSS Selector Engine v2.3.3
  17325. * https://sizzlejs.com/
  17326. *
  17327. * Copyright jQuery Foundation and other contributors
  17328. * Released under the MIT license
  17329. * http://jquery.org/license
  17330. *
  17331. * Date: 2016-08-08
  17332. */
  17333. (function( window ) {
  17334. var i,
  17335. support,
  17336. Expr,
  17337. getText,
  17338. isXML,
  17339. tokenize,
  17340. compile,
  17341. select,
  17342. outermostContext,
  17343. sortInput,
  17344. hasDuplicate,
  17345. // Local document vars
  17346. setDocument,
  17347. document,
  17348. docElem,
  17349. documentIsHTML,
  17350. rbuggyQSA,
  17351. rbuggyMatches,
  17352. matches,
  17353. contains,
  17354. // Instance-specific data
  17355. expando = "sizzle" + 1 * new Date(),
  17356. preferredDoc = window.document,
  17357. dirruns = 0,
  17358. done = 0,
  17359. classCache = createCache(),
  17360. tokenCache = createCache(),
  17361. compilerCache = createCache(),
  17362. sortOrder = function( a, b ) {
  17363. if ( a === b ) {
  17364. hasDuplicate = true;
  17365. }
  17366. return 0;
  17367. },
  17368. // Instance methods
  17369. hasOwn = ({}).hasOwnProperty,
  17370. arr = [],
  17371. pop = arr.pop,
  17372. push_native = arr.push,
  17373. push = arr.push,
  17374. slice = arr.slice,
  17375. // Use a stripped-down indexOf as it's faster than native
  17376. // https://jsperf.com/thor-indexof-vs-for/5
  17377. indexOf = function( list, elem ) {
  17378. var i = 0,
  17379. len = list.length;
  17380. for ( ; i < len; i++ ) {
  17381. if ( list[i] === elem ) {
  17382. return i;
  17383. }
  17384. }
  17385. return -1;
  17386. },
  17387. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  17388. // Regular expressions
  17389. // http://www.w3.org/TR/css3-selectors/#whitespace
  17390. whitespace = "[\\x20\\t\\r\\n\\f]",
  17391. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  17392. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  17393. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  17394. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  17395. // Operator (capture 2)
  17396. "*([*^$|!~]?=)" + whitespace +
  17397. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  17398. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  17399. "*\\]",
  17400. pseudos = ":(" + identifier + ")(?:\\((" +
  17401. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  17402. // 1. quoted (capture 3; capture 4 or capture 5)
  17403. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  17404. // 2. simple (capture 6)
  17405. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  17406. // 3. anything else (capture 2)
  17407. ".*" +
  17408. ")\\)|)",
  17409. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  17410. rwhitespace = new RegExp( whitespace + "+", "g" ),
  17411. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  17412. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  17413. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  17414. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  17415. rpseudo = new RegExp( pseudos ),
  17416. ridentifier = new RegExp( "^" + identifier + "$" ),
  17417. matchExpr = {
  17418. "ID": new RegExp( "^#(" + identifier + ")" ),
  17419. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  17420. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  17421. "ATTR": new RegExp( "^" + attributes ),
  17422. "PSEUDO": new RegExp( "^" + pseudos ),
  17423. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  17424. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  17425. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  17426. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  17427. // For use in libraries implementing .is()
  17428. // We use this for POS matching in `select`
  17429. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  17430. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  17431. },
  17432. rinputs = /^(?:input|select|textarea|button)$/i,
  17433. rheader = /^h\d$/i,
  17434. rnative = /^[^{]+\{\s*\[native \w/,
  17435. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  17436. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  17437. rsibling = /[+~]/,
  17438. // CSS escapes
  17439. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  17440. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  17441. funescape = function( _, escaped, escapedWhitespace ) {
  17442. var high = "0x" + escaped - 0x10000;
  17443. // NaN means non-codepoint
  17444. // Support: Firefox<24
  17445. // Workaround erroneous numeric interpretation of +"0x"
  17446. return high !== high || escapedWhitespace ?
  17447. escaped :
  17448. high < 0 ?
  17449. // BMP codepoint
  17450. String.fromCharCode( high + 0x10000 ) :
  17451. // Supplemental Plane codepoint (surrogate pair)
  17452. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  17453. },
  17454. // CSS string/identifier serialization
  17455. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  17456. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  17457. fcssescape = function( ch, asCodePoint ) {
  17458. if ( asCodePoint ) {
  17459. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  17460. if ( ch === "\0" ) {
  17461. return "\uFFFD";
  17462. }
  17463. // Control characters and (dependent upon position) numbers get escaped as code points
  17464. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  17465. }
  17466. // Other potentially-special ASCII characters get backslash-escaped
  17467. return "\\" + ch;
  17468. },
  17469. // Used for iframes
  17470. // See setDocument()
  17471. // Removing the function wrapper causes a "Permission Denied"
  17472. // error in IE
  17473. unloadHandler = function() {
  17474. setDocument();
  17475. },
  17476. disabledAncestor = addCombinator(
  17477. function( elem ) {
  17478. return elem.disabled === true && ("form" in elem || "label" in elem);
  17479. },
  17480. { dir: "parentNode", next: "legend" }
  17481. );
  17482. // Optimize for push.apply( _, NodeList )
  17483. try {
  17484. push.apply(
  17485. (arr = slice.call( preferredDoc.childNodes )),
  17486. preferredDoc.childNodes
  17487. );
  17488. // Support: Android<4.0
  17489. // Detect silently failing push.apply
  17490. arr[ preferredDoc.childNodes.length ].nodeType;
  17491. } catch ( e ) {
  17492. push = { apply: arr.length ?
  17493. // Leverage slice if possible
  17494. function( target, els ) {
  17495. push_native.apply( target, slice.call(els) );
  17496. } :
  17497. // Support: IE<9
  17498. // Otherwise append directly
  17499. function( target, els ) {
  17500. var j = target.length,
  17501. i = 0;
  17502. // Can't trust NodeList.length
  17503. while ( (target[j++] = els[i++]) ) {}
  17504. target.length = j - 1;
  17505. }
  17506. };
  17507. }
  17508. function Sizzle( selector, context, results, seed ) {
  17509. var m, i, elem, nid, match, groups, newSelector,
  17510. newContext = context && context.ownerDocument,
  17511. // nodeType defaults to 9, since context defaults to document
  17512. nodeType = context ? context.nodeType : 9;
  17513. results = results || [];
  17514. // Return early from calls with invalid selector or context
  17515. if ( typeof selector !== "string" || !selector ||
  17516. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  17517. return results;
  17518. }
  17519. // Try to shortcut find operations (as opposed to filters) in HTML documents
  17520. if ( !seed ) {
  17521. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  17522. setDocument( context );
  17523. }
  17524. context = context || document;
  17525. if ( documentIsHTML ) {
  17526. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  17527. // (excepting DocumentFragment context, where the methods don't exist)
  17528. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  17529. // ID selector
  17530. if ( (m = match[1]) ) {
  17531. // Document context
  17532. if ( nodeType === 9 ) {
  17533. if ( (elem = context.getElementById( m )) ) {
  17534. // Support: IE, Opera, Webkit
  17535. // TODO: identify versions
  17536. // getElementById can match elements by name instead of ID
  17537. if ( elem.id === m ) {
  17538. results.push( elem );
  17539. return results;
  17540. }
  17541. } else {
  17542. return results;
  17543. }
  17544. // Element context
  17545. } else {
  17546. // Support: IE, Opera, Webkit
  17547. // TODO: identify versions
  17548. // getElementById can match elements by name instead of ID
  17549. if ( newContext && (elem = newContext.getElementById( m )) &&
  17550. contains( context, elem ) &&
  17551. elem.id === m ) {
  17552. results.push( elem );
  17553. return results;
  17554. }
  17555. }
  17556. // Type selector
  17557. } else if ( match[2] ) {
  17558. push.apply( results, context.getElementsByTagName( selector ) );
  17559. return results;
  17560. // Class selector
  17561. } else if ( (m = match[3]) && support.getElementsByClassName &&
  17562. context.getElementsByClassName ) {
  17563. push.apply( results, context.getElementsByClassName( m ) );
  17564. return results;
  17565. }
  17566. }
  17567. // Take advantage of querySelectorAll
  17568. if ( support.qsa &&
  17569. !compilerCache[ selector + " " ] &&
  17570. (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  17571. if ( nodeType !== 1 ) {
  17572. newContext = context;
  17573. newSelector = selector;
  17574. // qSA looks outside Element context, which is not what we want
  17575. // Thanks to Andrew Dupont for this workaround technique
  17576. // Support: IE <=8
  17577. // Exclude object elements
  17578. } else if ( context.nodeName.toLowerCase() !== "object" ) {
  17579. // Capture the context ID, setting it first if necessary
  17580. if ( (nid = context.getAttribute( "id" )) ) {
  17581. nid = nid.replace( rcssescape, fcssescape );
  17582. } else {
  17583. context.setAttribute( "id", (nid = expando) );
  17584. }
  17585. // Prefix every selector in the list
  17586. groups = tokenize( selector );
  17587. i = groups.length;
  17588. while ( i-- ) {
  17589. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  17590. }
  17591. newSelector = groups.join( "," );
  17592. // Expand context for sibling selectors
  17593. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  17594. context;
  17595. }
  17596. if ( newSelector ) {
  17597. try {
  17598. push.apply( results,
  17599. newContext.querySelectorAll( newSelector )
  17600. );
  17601. return results;
  17602. } catch ( qsaError ) {
  17603. } finally {
  17604. if ( nid === expando ) {
  17605. context.removeAttribute( "id" );
  17606. }
  17607. }
  17608. }
  17609. }
  17610. }
  17611. }
  17612. // All others
  17613. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  17614. }
  17615. /**
  17616. * Create key-value caches of limited size
  17617. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  17618. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  17619. * deleting the oldest entry
  17620. */
  17621. function createCache() {
  17622. var keys = [];
  17623. function cache( key, value ) {
  17624. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  17625. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  17626. // Only keep the most recent entries
  17627. delete cache[ keys.shift() ];
  17628. }
  17629. return (cache[ key + " " ] = value);
  17630. }
  17631. return cache;
  17632. }
  17633. /**
  17634. * Mark a function for special use by Sizzle
  17635. * @param {Function} fn The function to mark
  17636. */
  17637. function markFunction( fn ) {
  17638. fn[ expando ] = true;
  17639. return fn;
  17640. }
  17641. /**
  17642. * Support testing using an element
  17643. * @param {Function} fn Passed the created element and returns a boolean result
  17644. */
  17645. function assert( fn ) {
  17646. var el = document.createElement("fieldset");
  17647. try {
  17648. return !!fn( el );
  17649. } catch (e) {
  17650. return false;
  17651. } finally {
  17652. // Remove from its parent by default
  17653. if ( el.parentNode ) {
  17654. el.parentNode.removeChild( el );
  17655. }
  17656. // release memory in IE
  17657. el = null;
  17658. }
  17659. }
  17660. /**
  17661. * Adds the same handler for all of the specified attrs
  17662. * @param {String} attrs Pipe-separated list of attributes
  17663. * @param {Function} handler The method that will be applied
  17664. */
  17665. function addHandle( attrs, handler ) {
  17666. var arr = attrs.split("|"),
  17667. i = arr.length;
  17668. while ( i-- ) {
  17669. Expr.attrHandle[ arr[i] ] = handler;
  17670. }
  17671. }
  17672. /**
  17673. * Checks document order of two siblings
  17674. * @param {Element} a
  17675. * @param {Element} b
  17676. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  17677. */
  17678. function siblingCheck( a, b ) {
  17679. var cur = b && a,
  17680. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  17681. a.sourceIndex - b.sourceIndex;
  17682. // Use IE sourceIndex if available on both nodes
  17683. if ( diff ) {
  17684. return diff;
  17685. }
  17686. // Check if b follows a
  17687. if ( cur ) {
  17688. while ( (cur = cur.nextSibling) ) {
  17689. if ( cur === b ) {
  17690. return -1;
  17691. }
  17692. }
  17693. }
  17694. return a ? 1 : -1;
  17695. }
  17696. /**
  17697. * Returns a function to use in pseudos for input types
  17698. * @param {String} type
  17699. */
  17700. function createInputPseudo( type ) {
  17701. return function( elem ) {
  17702. var name = elem.nodeName.toLowerCase();
  17703. return name === "input" && elem.type === type;
  17704. };
  17705. }
  17706. /**
  17707. * Returns a function to use in pseudos for buttons
  17708. * @param {String} type
  17709. */
  17710. function createButtonPseudo( type ) {
  17711. return function( elem ) {
  17712. var name = elem.nodeName.toLowerCase();
  17713. return (name === "input" || name === "button") && elem.type === type;
  17714. };
  17715. }
  17716. /**
  17717. * Returns a function to use in pseudos for :enabled/:disabled
  17718. * @param {Boolean} disabled true for :disabled; false for :enabled
  17719. */
  17720. function createDisabledPseudo( disabled ) {
  17721. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  17722. return function( elem ) {
  17723. // Only certain elements can match :enabled or :disabled
  17724. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  17725. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  17726. if ( "form" in elem ) {
  17727. // Check for inherited disabledness on relevant non-disabled elements:
  17728. // * listed form-associated elements in a disabled fieldset
  17729. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  17730. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  17731. // * option elements in a disabled optgroup
  17732. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  17733. // All such elements have a "form" property.
  17734. if ( elem.parentNode && elem.disabled === false ) {
  17735. // Option elements defer to a parent optgroup if present
  17736. if ( "label" in elem ) {
  17737. if ( "label" in elem.parentNode ) {
  17738. return elem.parentNode.disabled === disabled;
  17739. } else {
  17740. return elem.disabled === disabled;
  17741. }
  17742. }
  17743. // Support: IE 6 - 11
  17744. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  17745. return elem.isDisabled === disabled ||
  17746. // Where there is no isDisabled, check manually
  17747. /* jshint -W018 */
  17748. elem.isDisabled !== !disabled &&
  17749. disabledAncestor( elem ) === disabled;
  17750. }
  17751. return elem.disabled === disabled;
  17752. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  17753. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  17754. // even exist on them, let alone have a boolean value.
  17755. } else if ( "label" in elem ) {
  17756. return elem.disabled === disabled;
  17757. }
  17758. // Remaining elements are neither :enabled nor :disabled
  17759. return false;
  17760. };
  17761. }
  17762. /**
  17763. * Returns a function to use in pseudos for positionals
  17764. * @param {Function} fn
  17765. */
  17766. function createPositionalPseudo( fn ) {
  17767. return markFunction(function( argument ) {
  17768. argument = +argument;
  17769. return markFunction(function( seed, matches ) {
  17770. var j,
  17771. matchIndexes = fn( [], seed.length, argument ),
  17772. i = matchIndexes.length;
  17773. // Match elements found at the specified indexes
  17774. while ( i-- ) {
  17775. if ( seed[ (j = matchIndexes[i]) ] ) {
  17776. seed[j] = !(matches[j] = seed[j]);
  17777. }
  17778. }
  17779. });
  17780. });
  17781. }
  17782. /**
  17783. * Checks a node for validity as a Sizzle context
  17784. * @param {Element|Object=} context
  17785. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  17786. */
  17787. function testContext( context ) {
  17788. return context && typeof context.getElementsByTagName !== "undefined" && context;
  17789. }
  17790. // Expose support vars for convenience
  17791. support = Sizzle.support = {};
  17792. /**
  17793. * Detects XML nodes
  17794. * @param {Element|Object} elem An element or a document
  17795. * @returns {Boolean} True iff elem is a non-HTML XML node
  17796. */
  17797. isXML = Sizzle.isXML = function( elem ) {
  17798. // documentElement is verified for cases where it doesn't yet exist
  17799. // (such as loading iframes in IE - #4833)
  17800. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  17801. return documentElement ? documentElement.nodeName !== "HTML" : false;
  17802. };
  17803. /**
  17804. * Sets document-related variables once based on the current document
  17805. * @param {Element|Object} [doc] An element or document object to use to set the document
  17806. * @returns {Object} Returns the current document
  17807. */
  17808. setDocument = Sizzle.setDocument = function( node ) {
  17809. var hasCompare, subWindow,
  17810. doc = node ? node.ownerDocument || node : preferredDoc;
  17811. // Return early if doc is invalid or already selected
  17812. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  17813. return document;
  17814. }
  17815. // Update global variables
  17816. document = doc;
  17817. docElem = document.documentElement;
  17818. documentIsHTML = !isXML( document );
  17819. // Support: IE 9-11, Edge
  17820. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  17821. if ( preferredDoc !== document &&
  17822. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  17823. // Support: IE 11, Edge
  17824. if ( subWindow.addEventListener ) {
  17825. subWindow.addEventListener( "unload", unloadHandler, false );
  17826. // Support: IE 9 - 10 only
  17827. } else if ( subWindow.attachEvent ) {
  17828. subWindow.attachEvent( "onunload", unloadHandler );
  17829. }
  17830. }
  17831. /* Attributes
  17832. ---------------------------------------------------------------------- */
  17833. // Support: IE<8
  17834. // Verify that getAttribute really returns attributes and not properties
  17835. // (excepting IE8 booleans)
  17836. support.attributes = assert(function( el ) {
  17837. el.className = "i";
  17838. return !el.getAttribute("className");
  17839. });
  17840. /* getElement(s)By*
  17841. ---------------------------------------------------------------------- */
  17842. // Check if getElementsByTagName("*") returns only elements
  17843. support.getElementsByTagName = assert(function( el ) {
  17844. el.appendChild( document.createComment("") );
  17845. return !el.getElementsByTagName("*").length;
  17846. });
  17847. // Support: IE<9
  17848. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  17849. // Support: IE<10
  17850. // Check if getElementById returns elements by name
  17851. // The broken getElementById methods don't pick up programmatically-set names,
  17852. // so use a roundabout getElementsByName test
  17853. support.getById = assert(function( el ) {
  17854. docElem.appendChild( el ).id = expando;
  17855. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  17856. });
  17857. // ID filter and find
  17858. if ( support.getById ) {
  17859. Expr.filter["ID"] = function( id ) {
  17860. var attrId = id.replace( runescape, funescape );
  17861. return function( elem ) {
  17862. return elem.getAttribute("id") === attrId;
  17863. };
  17864. };
  17865. Expr.find["ID"] = function( id, context ) {
  17866. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  17867. var elem = context.getElementById( id );
  17868. return elem ? [ elem ] : [];
  17869. }
  17870. };
  17871. } else {
  17872. Expr.filter["ID"] = function( id ) {
  17873. var attrId = id.replace( runescape, funescape );
  17874. return function( elem ) {
  17875. var node = typeof elem.getAttributeNode !== "undefined" &&
  17876. elem.getAttributeNode("id");
  17877. return node && node.value === attrId;
  17878. };
  17879. };
  17880. // Support: IE 6 - 7 only
  17881. // getElementById is not reliable as a find shortcut
  17882. Expr.find["ID"] = function( id, context ) {
  17883. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  17884. var node, i, elems,
  17885. elem = context.getElementById( id );
  17886. if ( elem ) {
  17887. // Verify the id attribute
  17888. node = elem.getAttributeNode("id");
  17889. if ( node && node.value === id ) {
  17890. return [ elem ];
  17891. }
  17892. // Fall back on getElementsByName
  17893. elems = context.getElementsByName( id );
  17894. i = 0;
  17895. while ( (elem = elems[i++]) ) {
  17896. node = elem.getAttributeNode("id");
  17897. if ( node && node.value === id ) {
  17898. return [ elem ];
  17899. }
  17900. }
  17901. }
  17902. return [];
  17903. }
  17904. };
  17905. }
  17906. // Tag
  17907. Expr.find["TAG"] = support.getElementsByTagName ?
  17908. function( tag, context ) {
  17909. if ( typeof context.getElementsByTagName !== "undefined" ) {
  17910. return context.getElementsByTagName( tag );
  17911. // DocumentFragment nodes don't have gEBTN
  17912. } else if ( support.qsa ) {
  17913. return context.querySelectorAll( tag );
  17914. }
  17915. } :
  17916. function( tag, context ) {
  17917. var elem,
  17918. tmp = [],
  17919. i = 0,
  17920. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  17921. results = context.getElementsByTagName( tag );
  17922. // Filter out possible comments
  17923. if ( tag === "*" ) {
  17924. while ( (elem = results[i++]) ) {
  17925. if ( elem.nodeType === 1 ) {
  17926. tmp.push( elem );
  17927. }
  17928. }
  17929. return tmp;
  17930. }
  17931. return results;
  17932. };
  17933. // Class
  17934. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  17935. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  17936. return context.getElementsByClassName( className );
  17937. }
  17938. };
  17939. /* QSA/matchesSelector
  17940. ---------------------------------------------------------------------- */
  17941. // QSA and matchesSelector support
  17942. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  17943. rbuggyMatches = [];
  17944. // qSa(:focus) reports false when true (Chrome 21)
  17945. // We allow this because of a bug in IE8/9 that throws an error
  17946. // whenever `document.activeElement` is accessed on an iframe
  17947. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  17948. // See https://bugs.jquery.com/ticket/13378
  17949. rbuggyQSA = [];
  17950. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  17951. // Build QSA regex
  17952. // Regex strategy adopted from Diego Perini
  17953. assert(function( el ) {
  17954. // Select is set to empty string on purpose
  17955. // This is to test IE's treatment of not explicitly
  17956. // setting a boolean content attribute,
  17957. // since its presence should be enough
  17958. // https://bugs.jquery.com/ticket/12359
  17959. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  17960. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  17961. "<option selected=''></option></select>";
  17962. // Support: IE8, Opera 11-12.16
  17963. // Nothing should be selected when empty strings follow ^= or $= or *=
  17964. // The test attribute must be unknown in Opera but "safe" for WinRT
  17965. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  17966. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  17967. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  17968. }
  17969. // Support: IE8
  17970. // Boolean attributes and "value" are not treated correctly
  17971. if ( !el.querySelectorAll("[selected]").length ) {
  17972. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  17973. }
  17974. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  17975. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  17976. rbuggyQSA.push("~=");
  17977. }
  17978. // Webkit/Opera - :checked should return selected option elements
  17979. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  17980. // IE8 throws error here and will not see later tests
  17981. if ( !el.querySelectorAll(":checked").length ) {
  17982. rbuggyQSA.push(":checked");
  17983. }
  17984. // Support: Safari 8+, iOS 8+
  17985. // https://bugs.webkit.org/show_bug.cgi?id=136851
  17986. // In-page `selector#id sibling-combinator selector` fails
  17987. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  17988. rbuggyQSA.push(".#.+[+~]");
  17989. }
  17990. });
  17991. assert(function( el ) {
  17992. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  17993. "<select disabled='disabled'><option/></select>";
  17994. // Support: Windows 8 Native Apps
  17995. // The type and name attributes are restricted during .innerHTML assignment
  17996. var input = document.createElement("input");
  17997. input.setAttribute( "type", "hidden" );
  17998. el.appendChild( input ).setAttribute( "name", "D" );
  17999. // Support: IE8
  18000. // Enforce case-sensitivity of name attribute
  18001. if ( el.querySelectorAll("[name=d]").length ) {
  18002. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  18003. }
  18004. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  18005. // IE8 throws error here and will not see later tests
  18006. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  18007. rbuggyQSA.push( ":enabled", ":disabled" );
  18008. }
  18009. // Support: IE9-11+
  18010. // IE's :disabled selector does not pick up the children of disabled fieldsets
  18011. docElem.appendChild( el ).disabled = true;
  18012. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  18013. rbuggyQSA.push( ":enabled", ":disabled" );
  18014. }
  18015. // Opera 10-11 does not throw on post-comma invalid pseudos
  18016. el.querySelectorAll("*,:x");
  18017. rbuggyQSA.push(",.*:");
  18018. });
  18019. }
  18020. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  18021. docElem.webkitMatchesSelector ||
  18022. docElem.mozMatchesSelector ||
  18023. docElem.oMatchesSelector ||
  18024. docElem.msMatchesSelector) )) ) {
  18025. assert(function( el ) {
  18026. // Check to see if it's possible to do matchesSelector
  18027. // on a disconnected node (IE 9)
  18028. support.disconnectedMatch = matches.call( el, "*" );
  18029. // This should fail with an exception
  18030. // Gecko does not error, returns false instead
  18031. matches.call( el, "[s!='']:x" );
  18032. rbuggyMatches.push( "!=", pseudos );
  18033. });
  18034. }
  18035. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  18036. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  18037. /* Contains
  18038. ---------------------------------------------------------------------- */
  18039. hasCompare = rnative.test( docElem.compareDocumentPosition );
  18040. // Element contains another
  18041. // Purposefully self-exclusive
  18042. // As in, an element does not contain itself
  18043. contains = hasCompare || rnative.test( docElem.contains ) ?
  18044. function( a, b ) {
  18045. var adown = a.nodeType === 9 ? a.documentElement : a,
  18046. bup = b && b.parentNode;
  18047. return a === bup || !!( bup && bup.nodeType === 1 && (
  18048. adown.contains ?
  18049. adown.contains( bup ) :
  18050. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  18051. ));
  18052. } :
  18053. function( a, b ) {
  18054. if ( b ) {
  18055. while ( (b = b.parentNode) ) {
  18056. if ( b === a ) {
  18057. return true;
  18058. }
  18059. }
  18060. }
  18061. return false;
  18062. };
  18063. /* Sorting
  18064. ---------------------------------------------------------------------- */
  18065. // Document order sorting
  18066. sortOrder = hasCompare ?
  18067. function( a, b ) {
  18068. // Flag for duplicate removal
  18069. if ( a === b ) {
  18070. hasDuplicate = true;
  18071. return 0;
  18072. }
  18073. // Sort on method existence if only one input has compareDocumentPosition
  18074. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  18075. if ( compare ) {
  18076. return compare;
  18077. }
  18078. // Calculate position if both inputs belong to the same document
  18079. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  18080. a.compareDocumentPosition( b ) :
  18081. // Otherwise we know they are disconnected
  18082. 1;
  18083. // Disconnected nodes
  18084. if ( compare & 1 ||
  18085. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  18086. // Choose the first element that is related to our preferred document
  18087. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  18088. return -1;
  18089. }
  18090. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  18091. return 1;
  18092. }
  18093. // Maintain original order
  18094. return sortInput ?
  18095. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  18096. 0;
  18097. }
  18098. return compare & 4 ? -1 : 1;
  18099. } :
  18100. function( a, b ) {
  18101. // Exit early if the nodes are identical
  18102. if ( a === b ) {
  18103. hasDuplicate = true;
  18104. return 0;
  18105. }
  18106. var cur,
  18107. i = 0,
  18108. aup = a.parentNode,
  18109. bup = b.parentNode,
  18110. ap = [ a ],
  18111. bp = [ b ];
  18112. // Parentless nodes are either documents or disconnected
  18113. if ( !aup || !bup ) {
  18114. return a === document ? -1 :
  18115. b === document ? 1 :
  18116. aup ? -1 :
  18117. bup ? 1 :
  18118. sortInput ?
  18119. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  18120. 0;
  18121. // If the nodes are siblings, we can do a quick check
  18122. } else if ( aup === bup ) {
  18123. return siblingCheck( a, b );
  18124. }
  18125. // Otherwise we need full lists of their ancestors for comparison
  18126. cur = a;
  18127. while ( (cur = cur.parentNode) ) {
  18128. ap.unshift( cur );
  18129. }
  18130. cur = b;
  18131. while ( (cur = cur.parentNode) ) {
  18132. bp.unshift( cur );
  18133. }
  18134. // Walk down the tree looking for a discrepancy
  18135. while ( ap[i] === bp[i] ) {
  18136. i++;
  18137. }
  18138. return i ?
  18139. // Do a sibling check if the nodes have a common ancestor
  18140. siblingCheck( ap[i], bp[i] ) :
  18141. // Otherwise nodes in our document sort first
  18142. ap[i] === preferredDoc ? -1 :
  18143. bp[i] === preferredDoc ? 1 :
  18144. 0;
  18145. };
  18146. return document;
  18147. };
  18148. Sizzle.matches = function( expr, elements ) {
  18149. return Sizzle( expr, null, null, elements );
  18150. };
  18151. Sizzle.matchesSelector = function( elem, expr ) {
  18152. // Set document vars if needed
  18153. if ( ( elem.ownerDocument || elem ) !== document ) {
  18154. setDocument( elem );
  18155. }
  18156. // Make sure that attribute selectors are quoted
  18157. expr = expr.replace( rattributeQuotes, "='$1']" );
  18158. if ( support.matchesSelector && documentIsHTML &&
  18159. !compilerCache[ expr + " " ] &&
  18160. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  18161. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  18162. try {
  18163. var ret = matches.call( elem, expr );
  18164. // IE 9's matchesSelector returns false on disconnected nodes
  18165. if ( ret || support.disconnectedMatch ||
  18166. // As well, disconnected nodes are said to be in a document
  18167. // fragment in IE 9
  18168. elem.document && elem.document.nodeType !== 11 ) {
  18169. return ret;
  18170. }
  18171. } catch (e) {}
  18172. }
  18173. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  18174. };
  18175. Sizzle.contains = function( context, elem ) {
  18176. // Set document vars if needed
  18177. if ( ( context.ownerDocument || context ) !== document ) {
  18178. setDocument( context );
  18179. }
  18180. return contains( context, elem );
  18181. };
  18182. Sizzle.attr = function( elem, name ) {
  18183. // Set document vars if needed
  18184. if ( ( elem.ownerDocument || elem ) !== document ) {
  18185. setDocument( elem );
  18186. }
  18187. var fn = Expr.attrHandle[ name.toLowerCase() ],
  18188. // Don't get fooled by Object.prototype properties (jQuery #13807)
  18189. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  18190. fn( elem, name, !documentIsHTML ) :
  18191. undefined;
  18192. return val !== undefined ?
  18193. val :
  18194. support.attributes || !documentIsHTML ?
  18195. elem.getAttribute( name ) :
  18196. (val = elem.getAttributeNode(name)) && val.specified ?
  18197. val.value :
  18198. null;
  18199. };
  18200. Sizzle.escape = function( sel ) {
  18201. return (sel + "").replace( rcssescape, fcssescape );
  18202. };
  18203. Sizzle.error = function( msg ) {
  18204. throw new Error( "Syntax error, unrecognized expression: " + msg );
  18205. };
  18206. /**
  18207. * Document sorting and removing duplicates
  18208. * @param {ArrayLike} results
  18209. */
  18210. Sizzle.uniqueSort = function( results ) {
  18211. var elem,
  18212. duplicates = [],
  18213. j = 0,
  18214. i = 0;
  18215. // Unless we *know* we can detect duplicates, assume their presence
  18216. hasDuplicate = !support.detectDuplicates;
  18217. sortInput = !support.sortStable && results.slice( 0 );
  18218. results.sort( sortOrder );
  18219. if ( hasDuplicate ) {
  18220. while ( (elem = results[i++]) ) {
  18221. if ( elem === results[ i ] ) {
  18222. j = duplicates.push( i );
  18223. }
  18224. }
  18225. while ( j-- ) {
  18226. results.splice( duplicates[ j ], 1 );
  18227. }
  18228. }
  18229. // Clear input after sorting to release objects
  18230. // See https://github.com/jquery/sizzle/pull/225
  18231. sortInput = null;
  18232. return results;
  18233. };
  18234. /**
  18235. * Utility function for retrieving the text value of an array of DOM nodes
  18236. * @param {Array|Element} elem
  18237. */
  18238. getText = Sizzle.getText = function( elem ) {
  18239. var node,
  18240. ret = "",
  18241. i = 0,
  18242. nodeType = elem.nodeType;
  18243. if ( !nodeType ) {
  18244. // If no nodeType, this is expected to be an array
  18245. while ( (node = elem[i++]) ) {
  18246. // Do not traverse comment nodes
  18247. ret += getText( node );
  18248. }
  18249. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  18250. // Use textContent for elements
  18251. // innerText usage removed for consistency of new lines (jQuery #11153)
  18252. if ( typeof elem.textContent === "string" ) {
  18253. return elem.textContent;
  18254. } else {
  18255. // Traverse its children
  18256. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  18257. ret += getText( elem );
  18258. }
  18259. }
  18260. } else if ( nodeType === 3 || nodeType === 4 ) {
  18261. return elem.nodeValue;
  18262. }
  18263. // Do not include comment or processing instruction nodes
  18264. return ret;
  18265. };
  18266. Expr = Sizzle.selectors = {
  18267. // Can be adjusted by the user
  18268. cacheLength: 50,
  18269. createPseudo: markFunction,
  18270. match: matchExpr,
  18271. attrHandle: {},
  18272. find: {},
  18273. relative: {
  18274. ">": { dir: "parentNode", first: true },
  18275. " ": { dir: "parentNode" },
  18276. "+": { dir: "previousSibling", first: true },
  18277. "~": { dir: "previousSibling" }
  18278. },
  18279. preFilter: {
  18280. "ATTR": function( match ) {
  18281. match[1] = match[1].replace( runescape, funescape );
  18282. // Move the given value to match[3] whether quoted or unquoted
  18283. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  18284. if ( match[2] === "~=" ) {
  18285. match[3] = " " + match[3] + " ";
  18286. }
  18287. return match.slice( 0, 4 );
  18288. },
  18289. "CHILD": function( match ) {
  18290. /* matches from matchExpr["CHILD"]
  18291. 1 type (only|nth|...)
  18292. 2 what (child|of-type)
  18293. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  18294. 4 xn-component of xn+y argument ([+-]?\d*n|)
  18295. 5 sign of xn-component
  18296. 6 x of xn-component
  18297. 7 sign of y-component
  18298. 8 y of y-component
  18299. */
  18300. match[1] = match[1].toLowerCase();
  18301. if ( match[1].slice( 0, 3 ) === "nth" ) {
  18302. // nth-* requires argument
  18303. if ( !match[3] ) {
  18304. Sizzle.error( match[0] );
  18305. }
  18306. // numeric x and y parameters for Expr.filter.CHILD
  18307. // remember that false/true cast respectively to 0/1
  18308. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  18309. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  18310. // other types prohibit arguments
  18311. } else if ( match[3] ) {
  18312. Sizzle.error( match[0] );
  18313. }
  18314. return match;
  18315. },
  18316. "PSEUDO": function( match ) {
  18317. var excess,
  18318. unquoted = !match[6] && match[2];
  18319. if ( matchExpr["CHILD"].test( match[0] ) ) {
  18320. return null;
  18321. }
  18322. // Accept quoted arguments as-is
  18323. if ( match[3] ) {
  18324. match[2] = match[4] || match[5] || "";
  18325. // Strip excess characters from unquoted arguments
  18326. } else if ( unquoted && rpseudo.test( unquoted ) &&
  18327. // Get excess from tokenize (recursively)
  18328. (excess = tokenize( unquoted, true )) &&
  18329. // advance to the next closing parenthesis
  18330. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  18331. // excess is a negative index
  18332. match[0] = match[0].slice( 0, excess );
  18333. match[2] = unquoted.slice( 0, excess );
  18334. }
  18335. // Return only captures needed by the pseudo filter method (type and argument)
  18336. return match.slice( 0, 3 );
  18337. }
  18338. },
  18339. filter: {
  18340. "TAG": function( nodeNameSelector ) {
  18341. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  18342. return nodeNameSelector === "*" ?
  18343. function() { return true; } :
  18344. function( elem ) {
  18345. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  18346. };
  18347. },
  18348. "CLASS": function( className ) {
  18349. var pattern = classCache[ className + " " ];
  18350. return pattern ||
  18351. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  18352. classCache( className, function( elem ) {
  18353. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  18354. });
  18355. },
  18356. "ATTR": function( name, operator, check ) {
  18357. return function( elem ) {
  18358. var result = Sizzle.attr( elem, name );
  18359. if ( result == null ) {
  18360. return operator === "!=";
  18361. }
  18362. if ( !operator ) {
  18363. return true;
  18364. }
  18365. result += "";
  18366. return operator === "=" ? result === check :
  18367. operator === "!=" ? result !== check :
  18368. operator === "^=" ? check && result.indexOf( check ) === 0 :
  18369. operator === "*=" ? check && result.indexOf( check ) > -1 :
  18370. operator === "$=" ? check && result.slice( -check.length ) === check :
  18371. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  18372. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  18373. false;
  18374. };
  18375. },
  18376. "CHILD": function( type, what, argument, first, last ) {
  18377. var simple = type.slice( 0, 3 ) !== "nth",
  18378. forward = type.slice( -4 ) !== "last",
  18379. ofType = what === "of-type";
  18380. return first === 1 && last === 0 ?
  18381. // Shortcut for :nth-*(n)
  18382. function( elem ) {
  18383. return !!elem.parentNode;
  18384. } :
  18385. function( elem, context, xml ) {
  18386. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  18387. dir = simple !== forward ? "nextSibling" : "previousSibling",
  18388. parent = elem.parentNode,
  18389. name = ofType && elem.nodeName.toLowerCase(),
  18390. useCache = !xml && !ofType,
  18391. diff = false;
  18392. if ( parent ) {
  18393. // :(first|last|only)-(child|of-type)
  18394. if ( simple ) {
  18395. while ( dir ) {
  18396. node = elem;
  18397. while ( (node = node[ dir ]) ) {
  18398. if ( ofType ?
  18399. node.nodeName.toLowerCase() === name :
  18400. node.nodeType === 1 ) {
  18401. return false;
  18402. }
  18403. }
  18404. // Reverse direction for :only-* (if we haven't yet done so)
  18405. start = dir = type === "only" && !start && "nextSibling";
  18406. }
  18407. return true;
  18408. }
  18409. start = [ forward ? parent.firstChild : parent.lastChild ];
  18410. // non-xml :nth-child(...) stores cache data on `parent`
  18411. if ( forward && useCache ) {
  18412. // Seek `elem` from a previously-cached index
  18413. // ...in a gzip-friendly way
  18414. node = parent;
  18415. outerCache = node[ expando ] || (node[ expando ] = {});
  18416. // Support: IE <9 only
  18417. // Defend against cloned attroperties (jQuery gh-1709)
  18418. uniqueCache = outerCache[ node.uniqueID ] ||
  18419. (outerCache[ node.uniqueID ] = {});
  18420. cache = uniqueCache[ type ] || [];
  18421. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  18422. diff = nodeIndex && cache[ 2 ];
  18423. node = nodeIndex && parent.childNodes[ nodeIndex ];
  18424. while ( (node = ++nodeIndex && node && node[ dir ] ||
  18425. // Fallback to seeking `elem` from the start
  18426. (diff = nodeIndex = 0) || start.pop()) ) {
  18427. // When found, cache indexes on `parent` and break
  18428. if ( node.nodeType === 1 && ++diff && node === elem ) {
  18429. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  18430. break;
  18431. }
  18432. }
  18433. } else {
  18434. // Use previously-cached element index if available
  18435. if ( useCache ) {
  18436. // ...in a gzip-friendly way
  18437. node = elem;
  18438. outerCache = node[ expando ] || (node[ expando ] = {});
  18439. // Support: IE <9 only
  18440. // Defend against cloned attroperties (jQuery gh-1709)
  18441. uniqueCache = outerCache[ node.uniqueID ] ||
  18442. (outerCache[ node.uniqueID ] = {});
  18443. cache = uniqueCache[ type ] || [];
  18444. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  18445. diff = nodeIndex;
  18446. }
  18447. // xml :nth-child(...)
  18448. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  18449. if ( diff === false ) {
  18450. // Use the same loop as above to seek `elem` from the start
  18451. while ( (node = ++nodeIndex && node && node[ dir ] ||
  18452. (diff = nodeIndex = 0) || start.pop()) ) {
  18453. if ( ( ofType ?
  18454. node.nodeName.toLowerCase() === name :
  18455. node.nodeType === 1 ) &&
  18456. ++diff ) {
  18457. // Cache the index of each encountered element
  18458. if ( useCache ) {
  18459. outerCache = node[ expando ] || (node[ expando ] = {});
  18460. // Support: IE <9 only
  18461. // Defend against cloned attroperties (jQuery gh-1709)
  18462. uniqueCache = outerCache[ node.uniqueID ] ||
  18463. (outerCache[ node.uniqueID ] = {});
  18464. uniqueCache[ type ] = [ dirruns, diff ];
  18465. }
  18466. if ( node === elem ) {
  18467. break;
  18468. }
  18469. }
  18470. }
  18471. }
  18472. }
  18473. // Incorporate the offset, then check against cycle size
  18474. diff -= last;
  18475. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  18476. }
  18477. };
  18478. },
  18479. "PSEUDO": function( pseudo, argument ) {
  18480. // pseudo-class names are case-insensitive
  18481. // http://www.w3.org/TR/selectors/#pseudo-classes
  18482. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  18483. // Remember that setFilters inherits from pseudos
  18484. var args,
  18485. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  18486. Sizzle.error( "unsupported pseudo: " + pseudo );
  18487. // The user may use createPseudo to indicate that
  18488. // arguments are needed to create the filter function
  18489. // just as Sizzle does
  18490. if ( fn[ expando ] ) {
  18491. return fn( argument );
  18492. }
  18493. // But maintain support for old signatures
  18494. if ( fn.length > 1 ) {
  18495. args = [ pseudo, pseudo, "", argument ];
  18496. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  18497. markFunction(function( seed, matches ) {
  18498. var idx,
  18499. matched = fn( seed, argument ),
  18500. i = matched.length;
  18501. while ( i-- ) {
  18502. idx = indexOf( seed, matched[i] );
  18503. seed[ idx ] = !( matches[ idx ] = matched[i] );
  18504. }
  18505. }) :
  18506. function( elem ) {
  18507. return fn( elem, 0, args );
  18508. };
  18509. }
  18510. return fn;
  18511. }
  18512. },
  18513. pseudos: {
  18514. // Potentially complex pseudos
  18515. "not": markFunction(function( selector ) {
  18516. // Trim the selector passed to compile
  18517. // to avoid treating leading and trailing
  18518. // spaces as combinators
  18519. var input = [],
  18520. results = [],
  18521. matcher = compile( selector.replace( rtrim, "$1" ) );
  18522. return matcher[ expando ] ?
  18523. markFunction(function( seed, matches, context, xml ) {
  18524. var elem,
  18525. unmatched = matcher( seed, null, xml, [] ),
  18526. i = seed.length;
  18527. // Match elements unmatched by `matcher`
  18528. while ( i-- ) {
  18529. if ( (elem = unmatched[i]) ) {
  18530. seed[i] = !(matches[i] = elem);
  18531. }
  18532. }
  18533. }) :
  18534. function( elem, context, xml ) {
  18535. input[0] = elem;
  18536. matcher( input, null, xml, results );
  18537. // Don't keep the element (issue #299)
  18538. input[0] = null;
  18539. return !results.pop();
  18540. };
  18541. }),
  18542. "has": markFunction(function( selector ) {
  18543. return function( elem ) {
  18544. return Sizzle( selector, elem ).length > 0;
  18545. };
  18546. }),
  18547. "contains": markFunction(function( text ) {
  18548. text = text.replace( runescape, funescape );
  18549. return function( elem ) {
  18550. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  18551. };
  18552. }),
  18553. // "Whether an element is represented by a :lang() selector
  18554. // is based solely on the element's language value
  18555. // being equal to the identifier C,
  18556. // or beginning with the identifier C immediately followed by "-".
  18557. // The matching of C against the element's language value is performed case-insensitively.
  18558. // The identifier C does not have to be a valid language name."
  18559. // http://www.w3.org/TR/selectors/#lang-pseudo
  18560. "lang": markFunction( function( lang ) {
  18561. // lang value must be a valid identifier
  18562. if ( !ridentifier.test(lang || "") ) {
  18563. Sizzle.error( "unsupported lang: " + lang );
  18564. }
  18565. lang = lang.replace( runescape, funescape ).toLowerCase();
  18566. return function( elem ) {
  18567. var elemLang;
  18568. do {
  18569. if ( (elemLang = documentIsHTML ?
  18570. elem.lang :
  18571. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  18572. elemLang = elemLang.toLowerCase();
  18573. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  18574. }
  18575. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  18576. return false;
  18577. };
  18578. }),
  18579. // Miscellaneous
  18580. "target": function( elem ) {
  18581. var hash = window.location && window.location.hash;
  18582. return hash && hash.slice( 1 ) === elem.id;
  18583. },
  18584. "root": function( elem ) {
  18585. return elem === docElem;
  18586. },
  18587. "focus": function( elem ) {
  18588. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  18589. },
  18590. // Boolean properties
  18591. "enabled": createDisabledPseudo( false ),
  18592. "disabled": createDisabledPseudo( true ),
  18593. "checked": function( elem ) {
  18594. // In CSS3, :checked should return both checked and selected elements
  18595. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  18596. var nodeName = elem.nodeName.toLowerCase();
  18597. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  18598. },
  18599. "selected": function( elem ) {
  18600. // Accessing this property makes selected-by-default
  18601. // options in Safari work properly
  18602. if ( elem.parentNode ) {
  18603. elem.parentNode.selectedIndex;
  18604. }
  18605. return elem.selected === true;
  18606. },
  18607. // Contents
  18608. "empty": function( elem ) {
  18609. // http://www.w3.org/TR/selectors/#empty-pseudo
  18610. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  18611. // but not by others (comment: 8; processing instruction: 7; etc.)
  18612. // nodeType < 6 works because attributes (2) do not appear as children
  18613. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  18614. if ( elem.nodeType < 6 ) {
  18615. return false;
  18616. }
  18617. }
  18618. return true;
  18619. },
  18620. "parent": function( elem ) {
  18621. return !Expr.pseudos["empty"]( elem );
  18622. },
  18623. // Element/input types
  18624. "header": function( elem ) {
  18625. return rheader.test( elem.nodeName );
  18626. },
  18627. "input": function( elem ) {
  18628. return rinputs.test( elem.nodeName );
  18629. },
  18630. "button": function( elem ) {
  18631. var name = elem.nodeName.toLowerCase();
  18632. return name === "input" && elem.type === "button" || name === "button";
  18633. },
  18634. "text": function( elem ) {
  18635. var attr;
  18636. return elem.nodeName.toLowerCase() === "input" &&
  18637. elem.type === "text" &&
  18638. // Support: IE<8
  18639. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  18640. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  18641. },
  18642. // Position-in-collection
  18643. "first": createPositionalPseudo(function() {
  18644. return [ 0 ];
  18645. }),
  18646. "last": createPositionalPseudo(function( matchIndexes, length ) {
  18647. return [ length - 1 ];
  18648. }),
  18649. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18650. return [ argument < 0 ? argument + length : argument ];
  18651. }),
  18652. "even": createPositionalPseudo(function( matchIndexes, length ) {
  18653. var i = 0;
  18654. for ( ; i < length; i += 2 ) {
  18655. matchIndexes.push( i );
  18656. }
  18657. return matchIndexes;
  18658. }),
  18659. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  18660. var i = 1;
  18661. for ( ; i < length; i += 2 ) {
  18662. matchIndexes.push( i );
  18663. }
  18664. return matchIndexes;
  18665. }),
  18666. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18667. var i = argument < 0 ? argument + length : argument;
  18668. for ( ; --i >= 0; ) {
  18669. matchIndexes.push( i );
  18670. }
  18671. return matchIndexes;
  18672. }),
  18673. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  18674. var i = argument < 0 ? argument + length : argument;
  18675. for ( ; ++i < length; ) {
  18676. matchIndexes.push( i );
  18677. }
  18678. return matchIndexes;
  18679. })
  18680. }
  18681. };
  18682. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  18683. // Add button/input type pseudos
  18684. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  18685. Expr.pseudos[ i ] = createInputPseudo( i );
  18686. }
  18687. for ( i in { submit: true, reset: true } ) {
  18688. Expr.pseudos[ i ] = createButtonPseudo( i );
  18689. }
  18690. // Easy API for creating new setFilters
  18691. function setFilters() {}
  18692. setFilters.prototype = Expr.filters = Expr.pseudos;
  18693. Expr.setFilters = new setFilters();
  18694. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  18695. var matched, match, tokens, type,
  18696. soFar, groups, preFilters,
  18697. cached = tokenCache[ selector + " " ];
  18698. if ( cached ) {
  18699. return parseOnly ? 0 : cached.slice( 0 );
  18700. }
  18701. soFar = selector;
  18702. groups = [];
  18703. preFilters = Expr.preFilter;
  18704. while ( soFar ) {
  18705. // Comma and first run
  18706. if ( !matched || (match = rcomma.exec( soFar )) ) {
  18707. if ( match ) {
  18708. // Don't consume trailing commas as valid
  18709. soFar = soFar.slice( match[0].length ) || soFar;
  18710. }
  18711. groups.push( (tokens = []) );
  18712. }
  18713. matched = false;
  18714. // Combinators
  18715. if ( (match = rcombinators.exec( soFar )) ) {
  18716. matched = match.shift();
  18717. tokens.push({
  18718. value: matched,
  18719. // Cast descendant combinators to space
  18720. type: match[0].replace( rtrim, " " )
  18721. });
  18722. soFar = soFar.slice( matched.length );
  18723. }
  18724. // Filters
  18725. for ( type in Expr.filter ) {
  18726. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  18727. (match = preFilters[ type ]( match ))) ) {
  18728. matched = match.shift();
  18729. tokens.push({
  18730. value: matched,
  18731. type: type,
  18732. matches: match
  18733. });
  18734. soFar = soFar.slice( matched.length );
  18735. }
  18736. }
  18737. if ( !matched ) {
  18738. break;
  18739. }
  18740. }
  18741. // Return the length of the invalid excess
  18742. // if we're just parsing
  18743. // Otherwise, throw an error or return tokens
  18744. return parseOnly ?
  18745. soFar.length :
  18746. soFar ?
  18747. Sizzle.error( selector ) :
  18748. // Cache the tokens
  18749. tokenCache( selector, groups ).slice( 0 );
  18750. };
  18751. function toSelector( tokens ) {
  18752. var i = 0,
  18753. len = tokens.length,
  18754. selector = "";
  18755. for ( ; i < len; i++ ) {
  18756. selector += tokens[i].value;
  18757. }
  18758. return selector;
  18759. }
  18760. function addCombinator( matcher, combinator, base ) {
  18761. var dir = combinator.dir,
  18762. skip = combinator.next,
  18763. key = skip || dir,
  18764. checkNonElements = base && key === "parentNode",
  18765. doneName = done++;
  18766. return combinator.first ?
  18767. // Check against closest ancestor/preceding element
  18768. function( elem, context, xml ) {
  18769. while ( (elem = elem[ dir ]) ) {
  18770. if ( elem.nodeType === 1 || checkNonElements ) {
  18771. return matcher( elem, context, xml );
  18772. }
  18773. }
  18774. return false;
  18775. } :
  18776. // Check against all ancestor/preceding elements
  18777. function( elem, context, xml ) {
  18778. var oldCache, uniqueCache, outerCache,
  18779. newCache = [ dirruns, doneName ];
  18780. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  18781. if ( xml ) {
  18782. while ( (elem = elem[ dir ]) ) {
  18783. if ( elem.nodeType === 1 || checkNonElements ) {
  18784. if ( matcher( elem, context, xml ) ) {
  18785. return true;
  18786. }
  18787. }
  18788. }
  18789. } else {
  18790. while ( (elem = elem[ dir ]) ) {
  18791. if ( elem.nodeType === 1 || checkNonElements ) {
  18792. outerCache = elem[ expando ] || (elem[ expando ] = {});
  18793. // Support: IE <9 only
  18794. // Defend against cloned attroperties (jQuery gh-1709)
  18795. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  18796. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  18797. elem = elem[ dir ] || elem;
  18798. } else if ( (oldCache = uniqueCache[ key ]) &&
  18799. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  18800. // Assign to newCache so results back-propagate to previous elements
  18801. return (newCache[ 2 ] = oldCache[ 2 ]);
  18802. } else {
  18803. // Reuse newcache so results back-propagate to previous elements
  18804. uniqueCache[ key ] = newCache;
  18805. // A match means we're done; a fail means we have to keep checking
  18806. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  18807. return true;
  18808. }
  18809. }
  18810. }
  18811. }
  18812. }
  18813. return false;
  18814. };
  18815. }
  18816. function elementMatcher( matchers ) {
  18817. return matchers.length > 1 ?
  18818. function( elem, context, xml ) {
  18819. var i = matchers.length;
  18820. while ( i-- ) {
  18821. if ( !matchers[i]( elem, context, xml ) ) {
  18822. return false;
  18823. }
  18824. }
  18825. return true;
  18826. } :
  18827. matchers[0];
  18828. }
  18829. function multipleContexts( selector, contexts, results ) {
  18830. var i = 0,
  18831. len = contexts.length;
  18832. for ( ; i < len; i++ ) {
  18833. Sizzle( selector, contexts[i], results );
  18834. }
  18835. return results;
  18836. }
  18837. function condense( unmatched, map, filter, context, xml ) {
  18838. var elem,
  18839. newUnmatched = [],
  18840. i = 0,
  18841. len = unmatched.length,
  18842. mapped = map != null;
  18843. for ( ; i < len; i++ ) {
  18844. if ( (elem = unmatched[i]) ) {
  18845. if ( !filter || filter( elem, context, xml ) ) {
  18846. newUnmatched.push( elem );
  18847. if ( mapped ) {
  18848. map.push( i );
  18849. }
  18850. }
  18851. }
  18852. }
  18853. return newUnmatched;
  18854. }
  18855. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  18856. if ( postFilter && !postFilter[ expando ] ) {
  18857. postFilter = setMatcher( postFilter );
  18858. }
  18859. if ( postFinder && !postFinder[ expando ] ) {
  18860. postFinder = setMatcher( postFinder, postSelector );
  18861. }
  18862. return markFunction(function( seed, results, context, xml ) {
  18863. var temp, i, elem,
  18864. preMap = [],
  18865. postMap = [],
  18866. preexisting = results.length,
  18867. // Get initial elements from seed or context
  18868. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  18869. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  18870. matcherIn = preFilter && ( seed || !selector ) ?
  18871. condense( elems, preMap, preFilter, context, xml ) :
  18872. elems,
  18873. matcherOut = matcher ?
  18874. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  18875. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  18876. // ...intermediate processing is necessary
  18877. [] :
  18878. // ...otherwise use results directly
  18879. results :
  18880. matcherIn;
  18881. // Find primary matches
  18882. if ( matcher ) {
  18883. matcher( matcherIn, matcherOut, context, xml );
  18884. }
  18885. // Apply postFilter
  18886. if ( postFilter ) {
  18887. temp = condense( matcherOut, postMap );
  18888. postFilter( temp, [], context, xml );
  18889. // Un-match failing elements by moving them back to matcherIn
  18890. i = temp.length;
  18891. while ( i-- ) {
  18892. if ( (elem = temp[i]) ) {
  18893. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  18894. }
  18895. }
  18896. }
  18897. if ( seed ) {
  18898. if ( postFinder || preFilter ) {
  18899. if ( postFinder ) {
  18900. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  18901. temp = [];
  18902. i = matcherOut.length;
  18903. while ( i-- ) {
  18904. if ( (elem = matcherOut[i]) ) {
  18905. // Restore matcherIn since elem is not yet a final match
  18906. temp.push( (matcherIn[i] = elem) );
  18907. }
  18908. }
  18909. postFinder( null, (matcherOut = []), temp, xml );
  18910. }
  18911. // Move matched elements from seed to results to keep them synchronized
  18912. i = matcherOut.length;
  18913. while ( i-- ) {
  18914. if ( (elem = matcherOut[i]) &&
  18915. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  18916. seed[temp] = !(results[temp] = elem);
  18917. }
  18918. }
  18919. }
  18920. // Add elements to results, through postFinder if defined
  18921. } else {
  18922. matcherOut = condense(
  18923. matcherOut === results ?
  18924. matcherOut.splice( preexisting, matcherOut.length ) :
  18925. matcherOut
  18926. );
  18927. if ( postFinder ) {
  18928. postFinder( null, results, matcherOut, xml );
  18929. } else {
  18930. push.apply( results, matcherOut );
  18931. }
  18932. }
  18933. });
  18934. }
  18935. function matcherFromTokens( tokens ) {
  18936. var checkContext, matcher, j,
  18937. len = tokens.length,
  18938. leadingRelative = Expr.relative[ tokens[0].type ],
  18939. implicitRelative = leadingRelative || Expr.relative[" "],
  18940. i = leadingRelative ? 1 : 0,
  18941. // The foundational matcher ensures that elements are reachable from top-level context(s)
  18942. matchContext = addCombinator( function( elem ) {
  18943. return elem === checkContext;
  18944. }, implicitRelative, true ),
  18945. matchAnyContext = addCombinator( function( elem ) {
  18946. return indexOf( checkContext, elem ) > -1;
  18947. }, implicitRelative, true ),
  18948. matchers = [ function( elem, context, xml ) {
  18949. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  18950. (checkContext = context).nodeType ?
  18951. matchContext( elem, context, xml ) :
  18952. matchAnyContext( elem, context, xml ) );
  18953. // Avoid hanging onto element (issue #299)
  18954. checkContext = null;
  18955. return ret;
  18956. } ];
  18957. for ( ; i < len; i++ ) {
  18958. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  18959. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  18960. } else {
  18961. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  18962. // Return special upon seeing a positional matcher
  18963. if ( matcher[ expando ] ) {
  18964. // Find the next relative operator (if any) for proper handling
  18965. j = ++i;
  18966. for ( ; j < len; j++ ) {
  18967. if ( Expr.relative[ tokens[j].type ] ) {
  18968. break;
  18969. }
  18970. }
  18971. return setMatcher(
  18972. i > 1 && elementMatcher( matchers ),
  18973. i > 1 && toSelector(
  18974. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  18975. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  18976. ).replace( rtrim, "$1" ),
  18977. matcher,
  18978. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  18979. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  18980. j < len && toSelector( tokens )
  18981. );
  18982. }
  18983. matchers.push( matcher );
  18984. }
  18985. }
  18986. return elementMatcher( matchers );
  18987. }
  18988. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  18989. var bySet = setMatchers.length > 0,
  18990. byElement = elementMatchers.length > 0,
  18991. superMatcher = function( seed, context, xml, results, outermost ) {
  18992. var elem, j, matcher,
  18993. matchedCount = 0,
  18994. i = "0",
  18995. unmatched = seed && [],
  18996. setMatched = [],
  18997. contextBackup = outermostContext,
  18998. // We must always have either seed elements or outermost context
  18999. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  19000. // Use integer dirruns iff this is the outermost matcher
  19001. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  19002. len = elems.length;
  19003. if ( outermost ) {
  19004. outermostContext = context === document || context || outermost;
  19005. }
  19006. // Add elements passing elementMatchers directly to results
  19007. // Support: IE<9, Safari
  19008. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  19009. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  19010. if ( byElement && elem ) {
  19011. j = 0;
  19012. if ( !context && elem.ownerDocument !== document ) {
  19013. setDocument( elem );
  19014. xml = !documentIsHTML;
  19015. }
  19016. while ( (matcher = elementMatchers[j++]) ) {
  19017. if ( matcher( elem, context || document, xml) ) {
  19018. results.push( elem );
  19019. break;
  19020. }
  19021. }
  19022. if ( outermost ) {
  19023. dirruns = dirrunsUnique;
  19024. }
  19025. }
  19026. // Track unmatched elements for set filters
  19027. if ( bySet ) {
  19028. // They will have gone through all possible matchers
  19029. if ( (elem = !matcher && elem) ) {
  19030. matchedCount--;
  19031. }
  19032. // Lengthen the array for every element, matched or not
  19033. if ( seed ) {
  19034. unmatched.push( elem );
  19035. }
  19036. }
  19037. }
  19038. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  19039. // makes the latter nonnegative.
  19040. matchedCount += i;
  19041. // Apply set filters to unmatched elements
  19042. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  19043. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  19044. // no element matchers and no seed.
  19045. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  19046. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  19047. // numerically zero.
  19048. if ( bySet && i !== matchedCount ) {
  19049. j = 0;
  19050. while ( (matcher = setMatchers[j++]) ) {
  19051. matcher( unmatched, setMatched, context, xml );
  19052. }
  19053. if ( seed ) {
  19054. // Reintegrate element matches to eliminate the need for sorting
  19055. if ( matchedCount > 0 ) {
  19056. while ( i-- ) {
  19057. if ( !(unmatched[i] || setMatched[i]) ) {
  19058. setMatched[i] = pop.call( results );
  19059. }
  19060. }
  19061. }
  19062. // Discard index placeholder values to get only actual matches
  19063. setMatched = condense( setMatched );
  19064. }
  19065. // Add matches to results
  19066. push.apply( results, setMatched );
  19067. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  19068. if ( outermost && !seed && setMatched.length > 0 &&
  19069. ( matchedCount + setMatchers.length ) > 1 ) {
  19070. Sizzle.uniqueSort( results );
  19071. }
  19072. }
  19073. // Override manipulation of globals by nested matchers
  19074. if ( outermost ) {
  19075. dirruns = dirrunsUnique;
  19076. outermostContext = contextBackup;
  19077. }
  19078. return unmatched;
  19079. };
  19080. return bySet ?
  19081. markFunction( superMatcher ) :
  19082. superMatcher;
  19083. }
  19084. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  19085. var i,
  19086. setMatchers = [],
  19087. elementMatchers = [],
  19088. cached = compilerCache[ selector + " " ];
  19089. if ( !cached ) {
  19090. // Generate a function of recursive functions that can be used to check each element
  19091. if ( !match ) {
  19092. match = tokenize( selector );
  19093. }
  19094. i = match.length;
  19095. while ( i-- ) {
  19096. cached = matcherFromTokens( match[i] );
  19097. if ( cached[ expando ] ) {
  19098. setMatchers.push( cached );
  19099. } else {
  19100. elementMatchers.push( cached );
  19101. }
  19102. }
  19103. // Cache the compiled function
  19104. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  19105. // Save selector and tokenization
  19106. cached.selector = selector;
  19107. }
  19108. return cached;
  19109. };
  19110. /**
  19111. * A low-level selection function that works with Sizzle's compiled
  19112. * selector functions
  19113. * @param {String|Function} selector A selector or a pre-compiled
  19114. * selector function built with Sizzle.compile
  19115. * @param {Element} context
  19116. * @param {Array} [results]
  19117. * @param {Array} [seed] A set of elements to match against
  19118. */
  19119. select = Sizzle.select = function( selector, context, results, seed ) {
  19120. var i, tokens, token, type, find,
  19121. compiled = typeof selector === "function" && selector,
  19122. match = !seed && tokenize( (selector = compiled.selector || selector) );
  19123. results = results || [];
  19124. // Try to minimize operations if there is only one selector in the list and no seed
  19125. // (the latter of which guarantees us context)
  19126. if ( match.length === 1 ) {
  19127. // Reduce context if the leading compound selector is an ID
  19128. tokens = match[0] = match[0].slice( 0 );
  19129. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  19130. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  19131. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  19132. if ( !context ) {
  19133. return results;
  19134. // Precompiled matchers will still verify ancestry, so step up a level
  19135. } else if ( compiled ) {
  19136. context = context.parentNode;
  19137. }
  19138. selector = selector.slice( tokens.shift().value.length );
  19139. }
  19140. // Fetch a seed set for right-to-left matching
  19141. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  19142. while ( i-- ) {
  19143. token = tokens[i];
  19144. // Abort if we hit a combinator
  19145. if ( Expr.relative[ (type = token.type) ] ) {
  19146. break;
  19147. }
  19148. if ( (find = Expr.find[ type ]) ) {
  19149. // Search, expanding context for leading sibling combinators
  19150. if ( (seed = find(
  19151. token.matches[0].replace( runescape, funescape ),
  19152. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  19153. )) ) {
  19154. // If seed is empty or no tokens remain, we can return early
  19155. tokens.splice( i, 1 );
  19156. selector = seed.length && toSelector( tokens );
  19157. if ( !selector ) {
  19158. push.apply( results, seed );
  19159. return results;
  19160. }
  19161. break;
  19162. }
  19163. }
  19164. }
  19165. }
  19166. // Compile and execute a filtering function if one is not provided
  19167. // Provide `match` to avoid retokenization if we modified the selector above
  19168. ( compiled || compile( selector, match ) )(
  19169. seed,
  19170. context,
  19171. !documentIsHTML,
  19172. results,
  19173. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  19174. );
  19175. return results;
  19176. };
  19177. // One-time assignments
  19178. // Sort stability
  19179. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  19180. // Support: Chrome 14-35+
  19181. // Always assume duplicates if they aren't passed to the comparison function
  19182. support.detectDuplicates = !!hasDuplicate;
  19183. // Initialize against the default document
  19184. setDocument();
  19185. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  19186. // Detached nodes confoundingly follow *each other*
  19187. support.sortDetached = assert(function( el ) {
  19188. // Should return 1, but returns 4 (following)
  19189. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  19190. });
  19191. // Support: IE<8
  19192. // Prevent attribute/property "interpolation"
  19193. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  19194. if ( !assert(function( el ) {
  19195. el.innerHTML = "<a href='#'></a>";
  19196. return el.firstChild.getAttribute("href") === "#" ;
  19197. }) ) {
  19198. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  19199. if ( !isXML ) {
  19200. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  19201. }
  19202. });
  19203. }
  19204. // Support: IE<9
  19205. // Use defaultValue in place of getAttribute("value")
  19206. if ( !support.attributes || !assert(function( el ) {
  19207. el.innerHTML = "<input/>";
  19208. el.firstChild.setAttribute( "value", "" );
  19209. return el.firstChild.getAttribute( "value" ) === "";
  19210. }) ) {
  19211. addHandle( "value", function( elem, name, isXML ) {
  19212. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  19213. return elem.defaultValue;
  19214. }
  19215. });
  19216. }
  19217. // Support: IE<9
  19218. // Use getAttributeNode to fetch booleans when getAttribute lies
  19219. if ( !assert(function( el ) {
  19220. return el.getAttribute("disabled") == null;
  19221. }) ) {
  19222. addHandle( booleans, function( elem, name, isXML ) {
  19223. var val;
  19224. if ( !isXML ) {
  19225. return elem[ name ] === true ? name.toLowerCase() :
  19226. (val = elem.getAttributeNode( name )) && val.specified ?
  19227. val.value :
  19228. null;
  19229. }
  19230. });
  19231. }
  19232. return Sizzle;
  19233. })( window );
  19234. jQuery.find = Sizzle;
  19235. jQuery.expr = Sizzle.selectors;
  19236. // Deprecated
  19237. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  19238. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  19239. jQuery.text = Sizzle.getText;
  19240. jQuery.isXMLDoc = Sizzle.isXML;
  19241. jQuery.contains = Sizzle.contains;
  19242. jQuery.escapeSelector = Sizzle.escape;
  19243. var dir = function( elem, dir, until ) {
  19244. var matched = [],
  19245. truncate = until !== undefined;
  19246. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  19247. if ( elem.nodeType === 1 ) {
  19248. if ( truncate && jQuery( elem ).is( until ) ) {
  19249. break;
  19250. }
  19251. matched.push( elem );
  19252. }
  19253. }
  19254. return matched;
  19255. };
  19256. var siblings = function( n, elem ) {
  19257. var matched = [];
  19258. for ( ; n; n = n.nextSibling ) {
  19259. if ( n.nodeType === 1 && n !== elem ) {
  19260. matched.push( n );
  19261. }
  19262. }
  19263. return matched;
  19264. };
  19265. var rneedsContext = jQuery.expr.match.needsContext;
  19266. function nodeName( elem, name ) {
  19267. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  19268. };
  19269. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  19270. var risSimple = /^.[^:#\[\.,]*$/;
  19271. // Implement the identical functionality for filter and not
  19272. function winnow( elements, qualifier, not ) {
  19273. if ( jQuery.isFunction( qualifier ) ) {
  19274. return jQuery.grep( elements, function( elem, i ) {
  19275. return !!qualifier.call( elem, i, elem ) !== not;
  19276. } );
  19277. }
  19278. // Single element
  19279. if ( qualifier.nodeType ) {
  19280. return jQuery.grep( elements, function( elem ) {
  19281. return ( elem === qualifier ) !== not;
  19282. } );
  19283. }
  19284. // Arraylike of elements (jQuery, arguments, Array)
  19285. if ( typeof qualifier !== "string" ) {
  19286. return jQuery.grep( elements, function( elem ) {
  19287. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  19288. } );
  19289. }
  19290. // Simple selector that can be filtered directly, removing non-Elements
  19291. if ( risSimple.test( qualifier ) ) {
  19292. return jQuery.filter( qualifier, elements, not );
  19293. }
  19294. // Complex selector, compare the two sets, removing non-Elements
  19295. qualifier = jQuery.filter( qualifier, elements );
  19296. return jQuery.grep( elements, function( elem ) {
  19297. return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
  19298. } );
  19299. }
  19300. jQuery.filter = function( expr, elems, not ) {
  19301. var elem = elems[ 0 ];
  19302. if ( not ) {
  19303. expr = ":not(" + expr + ")";
  19304. }
  19305. if ( elems.length === 1 && elem.nodeType === 1 ) {
  19306. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  19307. }
  19308. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  19309. return elem.nodeType === 1;
  19310. } ) );
  19311. };
  19312. jQuery.fn.extend( {
  19313. find: function( selector ) {
  19314. var i, ret,
  19315. len = this.length,
  19316. self = this;
  19317. if ( typeof selector !== "string" ) {
  19318. return this.pushStack( jQuery( selector ).filter( function() {
  19319. for ( i = 0; i < len; i++ ) {
  19320. if ( jQuery.contains( self[ i ], this ) ) {
  19321. return true;
  19322. }
  19323. }
  19324. } ) );
  19325. }
  19326. ret = this.pushStack( [] );
  19327. for ( i = 0; i < len; i++ ) {
  19328. jQuery.find( selector, self[ i ], ret );
  19329. }
  19330. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  19331. },
  19332. filter: function( selector ) {
  19333. return this.pushStack( winnow( this, selector || [], false ) );
  19334. },
  19335. not: function( selector ) {
  19336. return this.pushStack( winnow( this, selector || [], true ) );
  19337. },
  19338. is: function( selector ) {
  19339. return !!winnow(
  19340. this,
  19341. // If this is a positional/relative selector, check membership in the returned set
  19342. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  19343. typeof selector === "string" && rneedsContext.test( selector ) ?
  19344. jQuery( selector ) :
  19345. selector || [],
  19346. false
  19347. ).length;
  19348. }
  19349. } );
  19350. // Initialize a jQuery object
  19351. // A central reference to the root jQuery(document)
  19352. var rootjQuery,
  19353. // A simple way to check for HTML strings
  19354. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  19355. // Strict HTML recognition (#11290: must start with <)
  19356. // Shortcut simple #id case for speed
  19357. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  19358. init = jQuery.fn.init = function( selector, context, root ) {
  19359. var match, elem;
  19360. // HANDLE: $(""), $(null), $(undefined), $(false)
  19361. if ( !selector ) {
  19362. return this;
  19363. }
  19364. // Method init() accepts an alternate rootjQuery
  19365. // so migrate can support jQuery.sub (gh-2101)
  19366. root = root || rootjQuery;
  19367. // Handle HTML strings
  19368. if ( typeof selector === "string" ) {
  19369. if ( selector[ 0 ] === "<" &&
  19370. selector[ selector.length - 1 ] === ">" &&
  19371. selector.length >= 3 ) {
  19372. // Assume that strings that start and end with <> are HTML and skip the regex check
  19373. match = [ null, selector, null ];
  19374. } else {
  19375. match = rquickExpr.exec( selector );
  19376. }
  19377. // Match html or make sure no context is specified for #id
  19378. if ( match && ( match[ 1 ] || !context ) ) {
  19379. // HANDLE: $(html) -> $(array)
  19380. if ( match[ 1 ] ) {
  19381. context = context instanceof jQuery ? context[ 0 ] : context;
  19382. // Option to run scripts is true for back-compat
  19383. // Intentionally let the error be thrown if parseHTML is not present
  19384. jQuery.merge( this, jQuery.parseHTML(
  19385. match[ 1 ],
  19386. context && context.nodeType ? context.ownerDocument || context : document,
  19387. true
  19388. ) );
  19389. // HANDLE: $(html, props)
  19390. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  19391. for ( match in context ) {
  19392. // Properties of context are called as methods if possible
  19393. if ( jQuery.isFunction( this[ match ] ) ) {
  19394. this[ match ]( context[ match ] );
  19395. // ...and otherwise set as attributes
  19396. } else {
  19397. this.attr( match, context[ match ] );
  19398. }
  19399. }
  19400. }
  19401. return this;
  19402. // HANDLE: $(#id)
  19403. } else {
  19404. elem = document.getElementById( match[ 2 ] );
  19405. if ( elem ) {
  19406. // Inject the element directly into the jQuery object
  19407. this[ 0 ] = elem;
  19408. this.length = 1;
  19409. }
  19410. return this;
  19411. }
  19412. // HANDLE: $(expr, $(...))
  19413. } else if ( !context || context.jquery ) {
  19414. return ( context || root ).find( selector );
  19415. // HANDLE: $(expr, context)
  19416. // (which is just equivalent to: $(context).find(expr)
  19417. } else {
  19418. return this.constructor( context ).find( selector );
  19419. }
  19420. // HANDLE: $(DOMElement)
  19421. } else if ( selector.nodeType ) {
  19422. this[ 0 ] = selector;
  19423. this.length = 1;
  19424. return this;
  19425. // HANDLE: $(function)
  19426. // Shortcut for document ready
  19427. } else if ( jQuery.isFunction( selector ) ) {
  19428. return root.ready !== undefined ?
  19429. root.ready( selector ) :
  19430. // Execute immediately if ready is not present
  19431. selector( jQuery );
  19432. }
  19433. return jQuery.makeArray( selector, this );
  19434. };
  19435. // Give the init function the jQuery prototype for later instantiation
  19436. init.prototype = jQuery.fn;
  19437. // Initialize central reference
  19438. rootjQuery = jQuery( document );
  19439. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  19440. // Methods guaranteed to produce a unique set when starting from a unique set
  19441. guaranteedUnique = {
  19442. children: true,
  19443. contents: true,
  19444. next: true,
  19445. prev: true
  19446. };
  19447. jQuery.fn.extend( {
  19448. has: function( target ) {
  19449. var targets = jQuery( target, this ),
  19450. l = targets.length;
  19451. return this.filter( function() {
  19452. var i = 0;
  19453. for ( ; i < l; i++ ) {
  19454. if ( jQuery.contains( this, targets[ i ] ) ) {
  19455. return true;
  19456. }
  19457. }
  19458. } );
  19459. },
  19460. closest: function( selectors, context ) {
  19461. var cur,
  19462. i = 0,
  19463. l = this.length,
  19464. matched = [],
  19465. targets = typeof selectors !== "string" && jQuery( selectors );
  19466. // Positional selectors never match, since there's no _selection_ context
  19467. if ( !rneedsContext.test( selectors ) ) {
  19468. for ( ; i < l; i++ ) {
  19469. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  19470. // Always skip document fragments
  19471. if ( cur.nodeType < 11 && ( targets ?
  19472. targets.index( cur ) > -1 :
  19473. // Don't pass non-elements to Sizzle
  19474. cur.nodeType === 1 &&
  19475. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  19476. matched.push( cur );
  19477. break;
  19478. }
  19479. }
  19480. }
  19481. }
  19482. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  19483. },
  19484. // Determine the position of an element within the set
  19485. index: function( elem ) {
  19486. // No argument, return index in parent
  19487. if ( !elem ) {
  19488. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  19489. }
  19490. // Index in selector
  19491. if ( typeof elem === "string" ) {
  19492. return indexOf.call( jQuery( elem ), this[ 0 ] );
  19493. }
  19494. // Locate the position of the desired element
  19495. return indexOf.call( this,
  19496. // If it receives a jQuery object, the first element is used
  19497. elem.jquery ? elem[ 0 ] : elem
  19498. );
  19499. },
  19500. add: function( selector, context ) {
  19501. return this.pushStack(
  19502. jQuery.uniqueSort(
  19503. jQuery.merge( this.get(), jQuery( selector, context ) )
  19504. )
  19505. );
  19506. },
  19507. addBack: function( selector ) {
  19508. return this.add( selector == null ?
  19509. this.prevObject : this.prevObject.filter( selector )
  19510. );
  19511. }
  19512. } );
  19513. function sibling( cur, dir ) {
  19514. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  19515. return cur;
  19516. }
  19517. jQuery.each( {
  19518. parent: function( elem ) {
  19519. var parent = elem.parentNode;
  19520. return parent && parent.nodeType !== 11 ? parent : null;
  19521. },
  19522. parents: function( elem ) {
  19523. return dir( elem, "parentNode" );
  19524. },
  19525. parentsUntil: function( elem, i, until ) {
  19526. return dir( elem, "parentNode", until );
  19527. },
  19528. next: function( elem ) {
  19529. return sibling( elem, "nextSibling" );
  19530. },
  19531. prev: function( elem ) {
  19532. return sibling( elem, "previousSibling" );
  19533. },
  19534. nextAll: function( elem ) {
  19535. return dir( elem, "nextSibling" );
  19536. },
  19537. prevAll: function( elem ) {
  19538. return dir( elem, "previousSibling" );
  19539. },
  19540. nextUntil: function( elem, i, until ) {
  19541. return dir( elem, "nextSibling", until );
  19542. },
  19543. prevUntil: function( elem, i, until ) {
  19544. return dir( elem, "previousSibling", until );
  19545. },
  19546. siblings: function( elem ) {
  19547. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  19548. },
  19549. children: function( elem ) {
  19550. return siblings( elem.firstChild );
  19551. },
  19552. contents: function( elem ) {
  19553. if ( nodeName( elem, "iframe" ) ) {
  19554. return elem.contentDocument;
  19555. }
  19556. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  19557. // Treat the template element as a regular one in browsers that
  19558. // don't support it.
  19559. if ( nodeName( elem, "template" ) ) {
  19560. elem = elem.content || elem;
  19561. }
  19562. return jQuery.merge( [], elem.childNodes );
  19563. }
  19564. }, function( name, fn ) {
  19565. jQuery.fn[ name ] = function( until, selector ) {
  19566. var matched = jQuery.map( this, fn, until );
  19567. if ( name.slice( -5 ) !== "Until" ) {
  19568. selector = until;
  19569. }
  19570. if ( selector && typeof selector === "string" ) {
  19571. matched = jQuery.filter( selector, matched );
  19572. }
  19573. if ( this.length > 1 ) {
  19574. // Remove duplicates
  19575. if ( !guaranteedUnique[ name ] ) {
  19576. jQuery.uniqueSort( matched );
  19577. }
  19578. // Reverse order for parents* and prev-derivatives
  19579. if ( rparentsprev.test( name ) ) {
  19580. matched.reverse();
  19581. }
  19582. }
  19583. return this.pushStack( matched );
  19584. };
  19585. } );
  19586. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  19587. // Convert String-formatted options into Object-formatted ones
  19588. function createOptions( options ) {
  19589. var object = {};
  19590. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  19591. object[ flag ] = true;
  19592. } );
  19593. return object;
  19594. }
  19595. /*
  19596. * Create a callback list using the following parameters:
  19597. *
  19598. * options: an optional list of space-separated options that will change how
  19599. * the callback list behaves or a more traditional option object
  19600. *
  19601. * By default a callback list will act like an event callback list and can be
  19602. * "fired" multiple times.
  19603. *
  19604. * Possible options:
  19605. *
  19606. * once: will ensure the callback list can only be fired once (like a Deferred)
  19607. *
  19608. * memory: will keep track of previous values and will call any callback added
  19609. * after the list has been fired right away with the latest "memorized"
  19610. * values (like a Deferred)
  19611. *
  19612. * unique: will ensure a callback can only be added once (no duplicate in the list)
  19613. *
  19614. * stopOnFalse: interrupt callings when a callback returns false
  19615. *
  19616. */
  19617. jQuery.Callbacks = function( options ) {
  19618. // Convert options from String-formatted to Object-formatted if needed
  19619. // (we check in cache first)
  19620. options = typeof options === "string" ?
  19621. createOptions( options ) :
  19622. jQuery.extend( {}, options );
  19623. var // Flag to know if list is currently firing
  19624. firing,
  19625. // Last fire value for non-forgettable lists
  19626. memory,
  19627. // Flag to know if list was already fired
  19628. fired,
  19629. // Flag to prevent firing
  19630. locked,
  19631. // Actual callback list
  19632. list = [],
  19633. // Queue of execution data for repeatable lists
  19634. queue = [],
  19635. // Index of currently firing callback (modified by add/remove as needed)
  19636. firingIndex = -1,
  19637. // Fire callbacks
  19638. fire = function() {
  19639. // Enforce single-firing
  19640. locked = locked || options.once;
  19641. // Execute callbacks for all pending executions,
  19642. // respecting firingIndex overrides and runtime changes
  19643. fired = firing = true;
  19644. for ( ; queue.length; firingIndex = -1 ) {
  19645. memory = queue.shift();
  19646. while ( ++firingIndex < list.length ) {
  19647. // Run callback and check for early termination
  19648. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  19649. options.stopOnFalse ) {
  19650. // Jump to end and forget the data so .add doesn't re-fire
  19651. firingIndex = list.length;
  19652. memory = false;
  19653. }
  19654. }
  19655. }
  19656. // Forget the data if we're done with it
  19657. if ( !options.memory ) {
  19658. memory = false;
  19659. }
  19660. firing = false;
  19661. // Clean up if we're done firing for good
  19662. if ( locked ) {
  19663. // Keep an empty list if we have data for future add calls
  19664. if ( memory ) {
  19665. list = [];
  19666. // Otherwise, this object is spent
  19667. } else {
  19668. list = "";
  19669. }
  19670. }
  19671. },
  19672. // Actual Callbacks object
  19673. self = {
  19674. // Add a callback or a collection of callbacks to the list
  19675. add: function() {
  19676. if ( list ) {
  19677. // If we have memory from a past run, we should fire after adding
  19678. if ( memory && !firing ) {
  19679. firingIndex = list.length - 1;
  19680. queue.push( memory );
  19681. }
  19682. ( function add( args ) {
  19683. jQuery.each( args, function( _, arg ) {
  19684. if ( jQuery.isFunction( arg ) ) {
  19685. if ( !options.unique || !self.has( arg ) ) {
  19686. list.push( arg );
  19687. }
  19688. } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
  19689. // Inspect recursively
  19690. add( arg );
  19691. }
  19692. } );
  19693. } )( arguments );
  19694. if ( memory && !firing ) {
  19695. fire();
  19696. }
  19697. }
  19698. return this;
  19699. },
  19700. // Remove a callback from the list
  19701. remove: function() {
  19702. jQuery.each( arguments, function( _, arg ) {
  19703. var index;
  19704. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  19705. list.splice( index, 1 );
  19706. // Handle firing indexes
  19707. if ( index <= firingIndex ) {
  19708. firingIndex--;
  19709. }
  19710. }
  19711. } );
  19712. return this;
  19713. },
  19714. // Check if a given callback is in the list.
  19715. // If no argument is given, return whether or not list has callbacks attached.
  19716. has: function( fn ) {
  19717. return fn ?
  19718. jQuery.inArray( fn, list ) > -1 :
  19719. list.length > 0;
  19720. },
  19721. // Remove all callbacks from the list
  19722. empty: function() {
  19723. if ( list ) {
  19724. list = [];
  19725. }
  19726. return this;
  19727. },
  19728. // Disable .fire and .add
  19729. // Abort any current/pending executions
  19730. // Clear all callbacks and values
  19731. disable: function() {
  19732. locked = queue = [];
  19733. list = memory = "";
  19734. return this;
  19735. },
  19736. disabled: function() {
  19737. return !list;
  19738. },
  19739. // Disable .fire
  19740. // Also disable .add unless we have memory (since it would have no effect)
  19741. // Abort any pending executions
  19742. lock: function() {
  19743. locked = queue = [];
  19744. if ( !memory && !firing ) {
  19745. list = memory = "";
  19746. }
  19747. return this;
  19748. },
  19749. locked: function() {
  19750. return !!locked;
  19751. },
  19752. // Call all callbacks with the given context and arguments
  19753. fireWith: function( context, args ) {
  19754. if ( !locked ) {
  19755. args = args || [];
  19756. args = [ context, args.slice ? args.slice() : args ];
  19757. queue.push( args );
  19758. if ( !firing ) {
  19759. fire();
  19760. }
  19761. }
  19762. return this;
  19763. },
  19764. // Call all the callbacks with the given arguments
  19765. fire: function() {
  19766. self.fireWith( this, arguments );
  19767. return this;
  19768. },
  19769. // To know if the callbacks have already been called at least once
  19770. fired: function() {
  19771. return !!fired;
  19772. }
  19773. };
  19774. return self;
  19775. };
  19776. function Identity( v ) {
  19777. return v;
  19778. }
  19779. function Thrower( ex ) {
  19780. throw ex;
  19781. }
  19782. function adoptValue( value, resolve, reject, noValue ) {
  19783. var method;
  19784. try {
  19785. // Check for promise aspect first to privilege synchronous behavior
  19786. if ( value && jQuery.isFunction( ( method = value.promise ) ) ) {
  19787. method.call( value ).done( resolve ).fail( reject );
  19788. // Other thenables
  19789. } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) {
  19790. method.call( value, resolve, reject );
  19791. // Other non-thenables
  19792. } else {
  19793. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  19794. // * false: [ value ].slice( 0 ) => resolve( value )
  19795. // * true: [ value ].slice( 1 ) => resolve()
  19796. resolve.apply( undefined, [ value ].slice( noValue ) );
  19797. }
  19798. // For Promises/A+, convert exceptions into rejections
  19799. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  19800. // Deferred#then to conditionally suppress rejection.
  19801. } catch ( value ) {
  19802. // Support: Android 4.0 only
  19803. // Strict mode functions invoked without .call/.apply get global-object context
  19804. reject.apply( undefined, [ value ] );
  19805. }
  19806. }
  19807. jQuery.extend( {
  19808. Deferred: function( func ) {
  19809. var tuples = [
  19810. // action, add listener, callbacks,
  19811. // ... .then handlers, argument index, [final state]
  19812. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  19813. jQuery.Callbacks( "memory" ), 2 ],
  19814. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  19815. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  19816. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  19817. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  19818. ],
  19819. state = "pending",
  19820. promise = {
  19821. state: function() {
  19822. return state;
  19823. },
  19824. always: function() {
  19825. deferred.done( arguments ).fail( arguments );
  19826. return this;
  19827. },
  19828. "catch": function( fn ) {
  19829. return promise.then( null, fn );
  19830. },
  19831. // Keep pipe for back-compat
  19832. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  19833. var fns = arguments;
  19834. return jQuery.Deferred( function( newDefer ) {
  19835. jQuery.each( tuples, function( i, tuple ) {
  19836. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  19837. var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  19838. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  19839. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  19840. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  19841. deferred[ tuple[ 1 ] ]( function() {
  19842. var returned = fn && fn.apply( this, arguments );
  19843. if ( returned && jQuery.isFunction( returned.promise ) ) {
  19844. returned.promise()
  19845. .progress( newDefer.notify )
  19846. .done( newDefer.resolve )
  19847. .fail( newDefer.reject );
  19848. } else {
  19849. newDefer[ tuple[ 0 ] + "With" ](
  19850. this,
  19851. fn ? [ returned ] : arguments
  19852. );
  19853. }
  19854. } );
  19855. } );
  19856. fns = null;
  19857. } ).promise();
  19858. },
  19859. then: function( onFulfilled, onRejected, onProgress ) {
  19860. var maxDepth = 0;
  19861. function resolve( depth, deferred, handler, special ) {
  19862. return function() {
  19863. var that = this,
  19864. args = arguments,
  19865. mightThrow = function() {
  19866. var returned, then;
  19867. // Support: Promises/A+ section 2.3.3.3.3
  19868. // https://promisesaplus.com/#point-59
  19869. // Ignore double-resolution attempts
  19870. if ( depth < maxDepth ) {
  19871. return;
  19872. }
  19873. returned = handler.apply( that, args );
  19874. // Support: Promises/A+ section 2.3.1
  19875. // https://promisesaplus.com/#point-48
  19876. if ( returned === deferred.promise() ) {
  19877. throw new TypeError( "Thenable self-resolution" );
  19878. }
  19879. // Support: Promises/A+ sections 2.3.3.1, 3.5
  19880. // https://promisesaplus.com/#point-54
  19881. // https://promisesaplus.com/#point-75
  19882. // Retrieve `then` only once
  19883. then = returned &&
  19884. // Support: Promises/A+ section 2.3.4
  19885. // https://promisesaplus.com/#point-64
  19886. // Only check objects and functions for thenability
  19887. ( typeof returned === "object" ||
  19888. typeof returned === "function" ) &&
  19889. returned.then;
  19890. // Handle a returned thenable
  19891. if ( jQuery.isFunction( then ) ) {
  19892. // Special processors (notify) just wait for resolution
  19893. if ( special ) {
  19894. then.call(
  19895. returned,
  19896. resolve( maxDepth, deferred, Identity, special ),
  19897. resolve( maxDepth, deferred, Thrower, special )
  19898. );
  19899. // Normal processors (resolve) also hook into progress
  19900. } else {
  19901. // ...and disregard older resolution values
  19902. maxDepth++;
  19903. then.call(
  19904. returned,
  19905. resolve( maxDepth, deferred, Identity, special ),
  19906. resolve( maxDepth, deferred, Thrower, special ),
  19907. resolve( maxDepth, deferred, Identity,
  19908. deferred.notifyWith )
  19909. );
  19910. }
  19911. // Handle all other returned values
  19912. } else {
  19913. // Only substitute handlers pass on context
  19914. // and multiple values (non-spec behavior)
  19915. if ( handler !== Identity ) {
  19916. that = undefined;
  19917. args = [ returned ];
  19918. }
  19919. // Process the value(s)
  19920. // Default process is resolve
  19921. ( special || deferred.resolveWith )( that, args );
  19922. }
  19923. },
  19924. // Only normal processors (resolve) catch and reject exceptions
  19925. process = special ?
  19926. mightThrow :
  19927. function() {
  19928. try {
  19929. mightThrow();
  19930. } catch ( e ) {
  19931. if ( jQuery.Deferred.exceptionHook ) {
  19932. jQuery.Deferred.exceptionHook( e,
  19933. process.stackTrace );
  19934. }
  19935. // Support: Promises/A+ section 2.3.3.3.4.1
  19936. // https://promisesaplus.com/#point-61
  19937. // Ignore post-resolution exceptions
  19938. if ( depth + 1 >= maxDepth ) {
  19939. // Only substitute handlers pass on context
  19940. // and multiple values (non-spec behavior)
  19941. if ( handler !== Thrower ) {
  19942. that = undefined;
  19943. args = [ e ];
  19944. }
  19945. deferred.rejectWith( that, args );
  19946. }
  19947. }
  19948. };
  19949. // Support: Promises/A+ section 2.3.3.3.1
  19950. // https://promisesaplus.com/#point-57
  19951. // Re-resolve promises immediately to dodge false rejection from
  19952. // subsequent errors
  19953. if ( depth ) {
  19954. process();
  19955. } else {
  19956. // Call an optional hook to record the stack, in case of exception
  19957. // since it's otherwise lost when execution goes async
  19958. if ( jQuery.Deferred.getStackHook ) {
  19959. process.stackTrace = jQuery.Deferred.getStackHook();
  19960. }
  19961. window.setTimeout( process );
  19962. }
  19963. };
  19964. }
  19965. return jQuery.Deferred( function( newDefer ) {
  19966. // progress_handlers.add( ... )
  19967. tuples[ 0 ][ 3 ].add(
  19968. resolve(
  19969. 0,
  19970. newDefer,
  19971. jQuery.isFunction( onProgress ) ?
  19972. onProgress :
  19973. Identity,
  19974. newDefer.notifyWith
  19975. )
  19976. );
  19977. // fulfilled_handlers.add( ... )
  19978. tuples[ 1 ][ 3 ].add(
  19979. resolve(
  19980. 0,
  19981. newDefer,
  19982. jQuery.isFunction( onFulfilled ) ?
  19983. onFulfilled :
  19984. Identity
  19985. )
  19986. );
  19987. // rejected_handlers.add( ... )
  19988. tuples[ 2 ][ 3 ].add(
  19989. resolve(
  19990. 0,
  19991. newDefer,
  19992. jQuery.isFunction( onRejected ) ?
  19993. onRejected :
  19994. Thrower
  19995. )
  19996. );
  19997. } ).promise();
  19998. },
  19999. // Get a promise for this deferred
  20000. // If obj is provided, the promise aspect is added to the object
  20001. promise: function( obj ) {
  20002. return obj != null ? jQuery.extend( obj, promise ) : promise;
  20003. }
  20004. },
  20005. deferred = {};
  20006. // Add list-specific methods
  20007. jQuery.each( tuples, function( i, tuple ) {
  20008. var list = tuple[ 2 ],
  20009. stateString = tuple[ 5 ];
  20010. // promise.progress = list.add
  20011. // promise.done = list.add
  20012. // promise.fail = list.add
  20013. promise[ tuple[ 1 ] ] = list.add;
  20014. // Handle state
  20015. if ( stateString ) {
  20016. list.add(
  20017. function() {
  20018. // state = "resolved" (i.e., fulfilled)
  20019. // state = "rejected"
  20020. state = stateString;
  20021. },
  20022. // rejected_callbacks.disable
  20023. // fulfilled_callbacks.disable
  20024. tuples[ 3 - i ][ 2 ].disable,
  20025. // progress_callbacks.lock
  20026. tuples[ 0 ][ 2 ].lock
  20027. );
  20028. }
  20029. // progress_handlers.fire
  20030. // fulfilled_handlers.fire
  20031. // rejected_handlers.fire
  20032. list.add( tuple[ 3 ].fire );
  20033. // deferred.notify = function() { deferred.notifyWith(...) }
  20034. // deferred.resolve = function() { deferred.resolveWith(...) }
  20035. // deferred.reject = function() { deferred.rejectWith(...) }
  20036. deferred[ tuple[ 0 ] ] = function() {
  20037. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  20038. return this;
  20039. };
  20040. // deferred.notifyWith = list.fireWith
  20041. // deferred.resolveWith = list.fireWith
  20042. // deferred.rejectWith = list.fireWith
  20043. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  20044. } );
  20045. // Make the deferred a promise
  20046. promise.promise( deferred );
  20047. // Call given func if any
  20048. if ( func ) {
  20049. func.call( deferred, deferred );
  20050. }
  20051. // All done!
  20052. return deferred;
  20053. },
  20054. // Deferred helper
  20055. when: function( singleValue ) {
  20056. var
  20057. // count of uncompleted subordinates
  20058. remaining = arguments.length,
  20059. // count of unprocessed arguments
  20060. i = remaining,
  20061. // subordinate fulfillment data
  20062. resolveContexts = Array( i ),
  20063. resolveValues = slice.call( arguments ),
  20064. // the master Deferred
  20065. master = jQuery.Deferred(),
  20066. // subordinate callback factory
  20067. updateFunc = function( i ) {
  20068. return function( value ) {
  20069. resolveContexts[ i ] = this;
  20070. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  20071. if ( !( --remaining ) ) {
  20072. master.resolveWith( resolveContexts, resolveValues );
  20073. }
  20074. };
  20075. };
  20076. // Single- and empty arguments are adopted like Promise.resolve
  20077. if ( remaining <= 1 ) {
  20078. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  20079. !remaining );
  20080. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  20081. if ( master.state() === "pending" ||
  20082. jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  20083. return master.then();
  20084. }
  20085. }
  20086. // Multiple arguments are aggregated like Promise.all array elements
  20087. while ( i-- ) {
  20088. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  20089. }
  20090. return master.promise();
  20091. }
  20092. } );
  20093. // These usually indicate a programmer mistake during development,
  20094. // warn about them ASAP rather than swallowing them by default.
  20095. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  20096. jQuery.Deferred.exceptionHook = function( error, stack ) {
  20097. // Support: IE 8 - 9 only
  20098. // Console exists when dev tools are open, which can happen at any time
  20099. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  20100. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  20101. }
  20102. };
  20103. jQuery.readyException = function( error ) {
  20104. window.setTimeout( function() {
  20105. throw error;
  20106. } );
  20107. };
  20108. // The deferred used on DOM ready
  20109. var readyList = jQuery.Deferred();
  20110. jQuery.fn.ready = function( fn ) {
  20111. readyList
  20112. .then( fn )
  20113. // Wrap jQuery.readyException in a function so that the lookup
  20114. // happens at the time of error handling instead of callback
  20115. // registration.
  20116. .catch( function( error ) {
  20117. jQuery.readyException( error );
  20118. } );
  20119. return this;
  20120. };
  20121. jQuery.extend( {
  20122. // Is the DOM ready to be used? Set to true once it occurs.
  20123. isReady: false,
  20124. // A counter to track how many items to wait for before
  20125. // the ready event fires. See #6781
  20126. readyWait: 1,
  20127. // Handle when the DOM is ready
  20128. ready: function( wait ) {
  20129. // Abort if there are pending holds or we're already ready
  20130. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  20131. return;
  20132. }
  20133. // Remember that the DOM is ready
  20134. jQuery.isReady = true;
  20135. // If a normal DOM Ready event fired, decrement, and wait if need be
  20136. if ( wait !== true && --jQuery.readyWait > 0 ) {
  20137. return;
  20138. }
  20139. // If there are functions bound, to execute
  20140. readyList.resolveWith( document, [ jQuery ] );
  20141. }
  20142. } );
  20143. jQuery.ready.then = readyList.then;
  20144. // The ready event handler and self cleanup method
  20145. function completed() {
  20146. document.removeEventListener( "DOMContentLoaded", completed );
  20147. window.removeEventListener( "load", completed );
  20148. jQuery.ready();
  20149. }
  20150. // Catch cases where $(document).ready() is called
  20151. // after the browser event has already occurred.
  20152. // Support: IE <=9 - 10 only
  20153. // Older IE sometimes signals "interactive" too soon
  20154. if ( document.readyState === "complete" ||
  20155. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  20156. // Handle it asynchronously to allow scripts the opportunity to delay ready
  20157. window.setTimeout( jQuery.ready );
  20158. } else {
  20159. // Use the handy event callback
  20160. document.addEventListener( "DOMContentLoaded", completed );
  20161. // A fallback to window.onload, that will always work
  20162. window.addEventListener( "load", completed );
  20163. }
  20164. // Multifunctional method to get and set values of a collection
  20165. // The value/s can optionally be executed if it's a function
  20166. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  20167. var i = 0,
  20168. len = elems.length,
  20169. bulk = key == null;
  20170. // Sets many values
  20171. if ( jQuery.type( key ) === "object" ) {
  20172. chainable = true;
  20173. for ( i in key ) {
  20174. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  20175. }
  20176. // Sets one value
  20177. } else if ( value !== undefined ) {
  20178. chainable = true;
  20179. if ( !jQuery.isFunction( value ) ) {
  20180. raw = true;
  20181. }
  20182. if ( bulk ) {
  20183. // Bulk operations run against the entire set
  20184. if ( raw ) {
  20185. fn.call( elems, value );
  20186. fn = null;
  20187. // ...except when executing function values
  20188. } else {
  20189. bulk = fn;
  20190. fn = function( elem, key, value ) {
  20191. return bulk.call( jQuery( elem ), value );
  20192. };
  20193. }
  20194. }
  20195. if ( fn ) {
  20196. for ( ; i < len; i++ ) {
  20197. fn(
  20198. elems[ i ], key, raw ?
  20199. value :
  20200. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  20201. );
  20202. }
  20203. }
  20204. }
  20205. if ( chainable ) {
  20206. return elems;
  20207. }
  20208. // Gets
  20209. if ( bulk ) {
  20210. return fn.call( elems );
  20211. }
  20212. return len ? fn( elems[ 0 ], key ) : emptyGet;
  20213. };
  20214. var acceptData = function( owner ) {
  20215. // Accepts only:
  20216. // - Node
  20217. // - Node.ELEMENT_NODE
  20218. // - Node.DOCUMENT_NODE
  20219. // - Object
  20220. // - Any
  20221. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  20222. };
  20223. function Data() {
  20224. this.expando = jQuery.expando + Data.uid++;
  20225. }
  20226. Data.uid = 1;
  20227. Data.prototype = {
  20228. cache: function( owner ) {
  20229. // Check if the owner object already has a cache
  20230. var value = owner[ this.expando ];
  20231. // If not, create one
  20232. if ( !value ) {
  20233. value = {};
  20234. // We can accept data for non-element nodes in modern browsers,
  20235. // but we should not, see #8335.
  20236. // Always return an empty object.
  20237. if ( acceptData( owner ) ) {
  20238. // If it is a node unlikely to be stringify-ed or looped over
  20239. // use plain assignment
  20240. if ( owner.nodeType ) {
  20241. owner[ this.expando ] = value;
  20242. // Otherwise secure it in a non-enumerable property
  20243. // configurable must be true to allow the property to be
  20244. // deleted when data is removed
  20245. } else {
  20246. Object.defineProperty( owner, this.expando, {
  20247. value: value,
  20248. configurable: true
  20249. } );
  20250. }
  20251. }
  20252. }
  20253. return value;
  20254. },
  20255. set: function( owner, data, value ) {
  20256. var prop,
  20257. cache = this.cache( owner );
  20258. // Handle: [ owner, key, value ] args
  20259. // Always use camelCase key (gh-2257)
  20260. if ( typeof data === "string" ) {
  20261. cache[ jQuery.camelCase( data ) ] = value;
  20262. // Handle: [ owner, { properties } ] args
  20263. } else {
  20264. // Copy the properties one-by-one to the cache object
  20265. for ( prop in data ) {
  20266. cache[ jQuery.camelCase( prop ) ] = data[ prop ];
  20267. }
  20268. }
  20269. return cache;
  20270. },
  20271. get: function( owner, key ) {
  20272. return key === undefined ?
  20273. this.cache( owner ) :
  20274. // Always use camelCase key (gh-2257)
  20275. owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
  20276. },
  20277. access: function( owner, key, value ) {
  20278. // In cases where either:
  20279. //
  20280. // 1. No key was specified
  20281. // 2. A string key was specified, but no value provided
  20282. //
  20283. // Take the "read" path and allow the get method to determine
  20284. // which value to return, respectively either:
  20285. //
  20286. // 1. The entire cache object
  20287. // 2. The data stored at the key
  20288. //
  20289. if ( key === undefined ||
  20290. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  20291. return this.get( owner, key );
  20292. }
  20293. // When the key is not a string, or both a key and value
  20294. // are specified, set or extend (existing objects) with either:
  20295. //
  20296. // 1. An object of properties
  20297. // 2. A key and value
  20298. //
  20299. this.set( owner, key, value );
  20300. // Since the "set" path can have two possible entry points
  20301. // return the expected data based on which path was taken[*]
  20302. return value !== undefined ? value : key;
  20303. },
  20304. remove: function( owner, key ) {
  20305. var i,
  20306. cache = owner[ this.expando ];
  20307. if ( cache === undefined ) {
  20308. return;
  20309. }
  20310. if ( key !== undefined ) {
  20311. // Support array or space separated string of keys
  20312. if ( Array.isArray( key ) ) {
  20313. // If key is an array of keys...
  20314. // We always set camelCase keys, so remove that.
  20315. key = key.map( jQuery.camelCase );
  20316. } else {
  20317. key = jQuery.camelCase( key );
  20318. // If a key with the spaces exists, use it.
  20319. // Otherwise, create an array by matching non-whitespace
  20320. key = key in cache ?
  20321. [ key ] :
  20322. ( key.match( rnothtmlwhite ) || [] );
  20323. }
  20324. i = key.length;
  20325. while ( i-- ) {
  20326. delete cache[ key[ i ] ];
  20327. }
  20328. }
  20329. // Remove the expando if there's no more data
  20330. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  20331. // Support: Chrome <=35 - 45
  20332. // Webkit & Blink performance suffers when deleting properties
  20333. // from DOM nodes, so set to undefined instead
  20334. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  20335. if ( owner.nodeType ) {
  20336. owner[ this.expando ] = undefined;
  20337. } else {
  20338. delete owner[ this.expando ];
  20339. }
  20340. }
  20341. },
  20342. hasData: function( owner ) {
  20343. var cache = owner[ this.expando ];
  20344. return cache !== undefined && !jQuery.isEmptyObject( cache );
  20345. }
  20346. };
  20347. var dataPriv = new Data();
  20348. var dataUser = new Data();
  20349. // Implementation Summary
  20350. //
  20351. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  20352. // 2. Improve the module's maintainability by reducing the storage
  20353. // paths to a single mechanism.
  20354. // 3. Use the same single mechanism to support "private" and "user" data.
  20355. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  20356. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  20357. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  20358. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  20359. rmultiDash = /[A-Z]/g;
  20360. function getData( data ) {
  20361. if ( data === "true" ) {
  20362. return true;
  20363. }
  20364. if ( data === "false" ) {
  20365. return false;
  20366. }
  20367. if ( data === "null" ) {
  20368. return null;
  20369. }
  20370. // Only convert to a number if it doesn't change the string
  20371. if ( data === +data + "" ) {
  20372. return +data;
  20373. }
  20374. if ( rbrace.test( data ) ) {
  20375. return JSON.parse( data );
  20376. }
  20377. return data;
  20378. }
  20379. function dataAttr( elem, key, data ) {
  20380. var name;
  20381. // If nothing was found internally, try to fetch any
  20382. // data from the HTML5 data-* attribute
  20383. if ( data === undefined && elem.nodeType === 1 ) {
  20384. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  20385. data = elem.getAttribute( name );
  20386. if ( typeof data === "string" ) {
  20387. try {
  20388. data = getData( data );
  20389. } catch ( e ) {}
  20390. // Make sure we set the data so it isn't changed later
  20391. dataUser.set( elem, key, data );
  20392. } else {
  20393. data = undefined;
  20394. }
  20395. }
  20396. return data;
  20397. }
  20398. jQuery.extend( {
  20399. hasData: function( elem ) {
  20400. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  20401. },
  20402. data: function( elem, name, data ) {
  20403. return dataUser.access( elem, name, data );
  20404. },
  20405. removeData: function( elem, name ) {
  20406. dataUser.remove( elem, name );
  20407. },
  20408. // TODO: Now that all calls to _data and _removeData have been replaced
  20409. // with direct calls to dataPriv methods, these can be deprecated.
  20410. _data: function( elem, name, data ) {
  20411. return dataPriv.access( elem, name, data );
  20412. },
  20413. _removeData: function( elem, name ) {
  20414. dataPriv.remove( elem, name );
  20415. }
  20416. } );
  20417. jQuery.fn.extend( {
  20418. data: function( key, value ) {
  20419. var i, name, data,
  20420. elem = this[ 0 ],
  20421. attrs = elem && elem.attributes;
  20422. // Gets all values
  20423. if ( key === undefined ) {
  20424. if ( this.length ) {
  20425. data = dataUser.get( elem );
  20426. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  20427. i = attrs.length;
  20428. while ( i-- ) {
  20429. // Support: IE 11 only
  20430. // The attrs elements can be null (#14894)
  20431. if ( attrs[ i ] ) {
  20432. name = attrs[ i ].name;
  20433. if ( name.indexOf( "data-" ) === 0 ) {
  20434. name = jQuery.camelCase( name.slice( 5 ) );
  20435. dataAttr( elem, name, data[ name ] );
  20436. }
  20437. }
  20438. }
  20439. dataPriv.set( elem, "hasDataAttrs", true );
  20440. }
  20441. }
  20442. return data;
  20443. }
  20444. // Sets multiple values
  20445. if ( typeof key === "object" ) {
  20446. return this.each( function() {
  20447. dataUser.set( this, key );
  20448. } );
  20449. }
  20450. return access( this, function( value ) {
  20451. var data;
  20452. // The calling jQuery object (element matches) is not empty
  20453. // (and therefore has an element appears at this[ 0 ]) and the
  20454. // `value` parameter was not undefined. An empty jQuery object
  20455. // will result in `undefined` for elem = this[ 0 ] which will
  20456. // throw an exception if an attempt to read a data cache is made.
  20457. if ( elem && value === undefined ) {
  20458. // Attempt to get data from the cache
  20459. // The key will always be camelCased in Data
  20460. data = dataUser.get( elem, key );
  20461. if ( data !== undefined ) {
  20462. return data;
  20463. }
  20464. // Attempt to "discover" the data in
  20465. // HTML5 custom data-* attrs
  20466. data = dataAttr( elem, key );
  20467. if ( data !== undefined ) {
  20468. return data;
  20469. }
  20470. // We tried really hard, but the data doesn't exist.
  20471. return;
  20472. }
  20473. // Set the data...
  20474. this.each( function() {
  20475. // We always store the camelCased key
  20476. dataUser.set( this, key, value );
  20477. } );
  20478. }, null, value, arguments.length > 1, null, true );
  20479. },
  20480. removeData: function( key ) {
  20481. return this.each( function() {
  20482. dataUser.remove( this, key );
  20483. } );
  20484. }
  20485. } );
  20486. jQuery.extend( {
  20487. queue: function( elem, type, data ) {
  20488. var queue;
  20489. if ( elem ) {
  20490. type = ( type || "fx" ) + "queue";
  20491. queue = dataPriv.get( elem, type );
  20492. // Speed up dequeue by getting out quickly if this is just a lookup
  20493. if ( data ) {
  20494. if ( !queue || Array.isArray( data ) ) {
  20495. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  20496. } else {
  20497. queue.push( data );
  20498. }
  20499. }
  20500. return queue || [];
  20501. }
  20502. },
  20503. dequeue: function( elem, type ) {
  20504. type = type || "fx";
  20505. var queue = jQuery.queue( elem, type ),
  20506. startLength = queue.length,
  20507. fn = queue.shift(),
  20508. hooks = jQuery._queueHooks( elem, type ),
  20509. next = function() {
  20510. jQuery.dequeue( elem, type );
  20511. };
  20512. // If the fx queue is dequeued, always remove the progress sentinel
  20513. if ( fn === "inprogress" ) {
  20514. fn = queue.shift();
  20515. startLength--;
  20516. }
  20517. if ( fn ) {
  20518. // Add a progress sentinel to prevent the fx queue from being
  20519. // automatically dequeued
  20520. if ( type === "fx" ) {
  20521. queue.unshift( "inprogress" );
  20522. }
  20523. // Clear up the last queue stop function
  20524. delete hooks.stop;
  20525. fn.call( elem, next, hooks );
  20526. }
  20527. if ( !startLength && hooks ) {
  20528. hooks.empty.fire();
  20529. }
  20530. },
  20531. // Not public - generate a queueHooks object, or return the current one
  20532. _queueHooks: function( elem, type ) {
  20533. var key = type + "queueHooks";
  20534. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  20535. empty: jQuery.Callbacks( "once memory" ).add( function() {
  20536. dataPriv.remove( elem, [ type + "queue", key ] );
  20537. } )
  20538. } );
  20539. }
  20540. } );
  20541. jQuery.fn.extend( {
  20542. queue: function( type, data ) {
  20543. var setter = 2;
  20544. if ( typeof type !== "string" ) {
  20545. data = type;
  20546. type = "fx";
  20547. setter--;
  20548. }
  20549. if ( arguments.length < setter ) {
  20550. return jQuery.queue( this[ 0 ], type );
  20551. }
  20552. return data === undefined ?
  20553. this :
  20554. this.each( function() {
  20555. var queue = jQuery.queue( this, type, data );
  20556. // Ensure a hooks for this queue
  20557. jQuery._queueHooks( this, type );
  20558. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  20559. jQuery.dequeue( this, type );
  20560. }
  20561. } );
  20562. },
  20563. dequeue: function( type ) {
  20564. return this.each( function() {
  20565. jQuery.dequeue( this, type );
  20566. } );
  20567. },
  20568. clearQueue: function( type ) {
  20569. return this.queue( type || "fx", [] );
  20570. },
  20571. // Get a promise resolved when queues of a certain type
  20572. // are emptied (fx is the type by default)
  20573. promise: function( type, obj ) {
  20574. var tmp,
  20575. count = 1,
  20576. defer = jQuery.Deferred(),
  20577. elements = this,
  20578. i = this.length,
  20579. resolve = function() {
  20580. if ( !( --count ) ) {
  20581. defer.resolveWith( elements, [ elements ] );
  20582. }
  20583. };
  20584. if ( typeof type !== "string" ) {
  20585. obj = type;
  20586. type = undefined;
  20587. }
  20588. type = type || "fx";
  20589. while ( i-- ) {
  20590. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  20591. if ( tmp && tmp.empty ) {
  20592. count++;
  20593. tmp.empty.add( resolve );
  20594. }
  20595. }
  20596. resolve();
  20597. return defer.promise( obj );
  20598. }
  20599. } );
  20600. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  20601. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  20602. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  20603. var isHiddenWithinTree = function( elem, el ) {
  20604. // isHiddenWithinTree might be called from jQuery#filter function;
  20605. // in that case, element will be second argument
  20606. elem = el || elem;
  20607. // Inline style trumps all
  20608. return elem.style.display === "none" ||
  20609. elem.style.display === "" &&
  20610. // Otherwise, check computed style
  20611. // Support: Firefox <=43 - 45
  20612. // Disconnected elements can have computed display: none, so first confirm that elem is
  20613. // in the document.
  20614. jQuery.contains( elem.ownerDocument, elem ) &&
  20615. jQuery.css( elem, "display" ) === "none";
  20616. };
  20617. var swap = function( elem, options, callback, args ) {
  20618. var ret, name,
  20619. old = {};
  20620. // Remember the old values, and insert the new ones
  20621. for ( name in options ) {
  20622. old[ name ] = elem.style[ name ];
  20623. elem.style[ name ] = options[ name ];
  20624. }
  20625. ret = callback.apply( elem, args || [] );
  20626. // Revert the old values
  20627. for ( name in options ) {
  20628. elem.style[ name ] = old[ name ];
  20629. }
  20630. return ret;
  20631. };
  20632. function adjustCSS( elem, prop, valueParts, tween ) {
  20633. var adjusted,
  20634. scale = 1,
  20635. maxIterations = 20,
  20636. currentValue = tween ?
  20637. function() {
  20638. return tween.cur();
  20639. } :
  20640. function() {
  20641. return jQuery.css( elem, prop, "" );
  20642. },
  20643. initial = currentValue(),
  20644. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  20645. // Starting value computation is required for potential unit mismatches
  20646. initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  20647. rcssNum.exec( jQuery.css( elem, prop ) );
  20648. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  20649. // Trust units reported by jQuery.css
  20650. unit = unit || initialInUnit[ 3 ];
  20651. // Make sure we update the tween properties later on
  20652. valueParts = valueParts || [];
  20653. // Iteratively approximate from a nonzero starting point
  20654. initialInUnit = +initial || 1;
  20655. do {
  20656. // If previous iteration zeroed out, double until we get *something*.
  20657. // Use string for doubling so we don't accidentally see scale as unchanged below
  20658. scale = scale || ".5";
  20659. // Adjust and apply
  20660. initialInUnit = initialInUnit / scale;
  20661. jQuery.style( elem, prop, initialInUnit + unit );
  20662. // Update scale, tolerating zero or NaN from tween.cur()
  20663. // Break the loop if scale is unchanged or perfect, or if we've just had enough.
  20664. } while (
  20665. scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
  20666. );
  20667. }
  20668. if ( valueParts ) {
  20669. initialInUnit = +initialInUnit || +initial || 0;
  20670. // Apply relative offset (+=/-=) if specified
  20671. adjusted = valueParts[ 1 ] ?
  20672. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  20673. +valueParts[ 2 ];
  20674. if ( tween ) {
  20675. tween.unit = unit;
  20676. tween.start = initialInUnit;
  20677. tween.end = adjusted;
  20678. }
  20679. }
  20680. return adjusted;
  20681. }
  20682. var defaultDisplayMap = {};
  20683. function getDefaultDisplay( elem ) {
  20684. var temp,
  20685. doc = elem.ownerDocument,
  20686. nodeName = elem.nodeName,
  20687. display = defaultDisplayMap[ nodeName ];
  20688. if ( display ) {
  20689. return display;
  20690. }
  20691. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  20692. display = jQuery.css( temp, "display" );
  20693. temp.parentNode.removeChild( temp );
  20694. if ( display === "none" ) {
  20695. display = "block";
  20696. }
  20697. defaultDisplayMap[ nodeName ] = display;
  20698. return display;
  20699. }
  20700. function showHide( elements, show ) {
  20701. var display, elem,
  20702. values = [],
  20703. index = 0,
  20704. length = elements.length;
  20705. // Determine new display value for elements that need to change
  20706. for ( ; index < length; index++ ) {
  20707. elem = elements[ index ];
  20708. if ( !elem.style ) {
  20709. continue;
  20710. }
  20711. display = elem.style.display;
  20712. if ( show ) {
  20713. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  20714. // check is required in this first loop unless we have a nonempty display value (either
  20715. // inline or about-to-be-restored)
  20716. if ( display === "none" ) {
  20717. values[ index ] = dataPriv.get( elem, "display" ) || null;
  20718. if ( !values[ index ] ) {
  20719. elem.style.display = "";
  20720. }
  20721. }
  20722. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  20723. values[ index ] = getDefaultDisplay( elem );
  20724. }
  20725. } else {
  20726. if ( display !== "none" ) {
  20727. values[ index ] = "none";
  20728. // Remember what we're overwriting
  20729. dataPriv.set( elem, "display", display );
  20730. }
  20731. }
  20732. }
  20733. // Set the display of the elements in a second loop to avoid constant reflow
  20734. for ( index = 0; index < length; index++ ) {
  20735. if ( values[ index ] != null ) {
  20736. elements[ index ].style.display = values[ index ];
  20737. }
  20738. }
  20739. return elements;
  20740. }
  20741. jQuery.fn.extend( {
  20742. show: function() {
  20743. return showHide( this, true );
  20744. },
  20745. hide: function() {
  20746. return showHide( this );
  20747. },
  20748. toggle: function( state ) {
  20749. if ( typeof state === "boolean" ) {
  20750. return state ? this.show() : this.hide();
  20751. }
  20752. return this.each( function() {
  20753. if ( isHiddenWithinTree( this ) ) {
  20754. jQuery( this ).show();
  20755. } else {
  20756. jQuery( this ).hide();
  20757. }
  20758. } );
  20759. }
  20760. } );
  20761. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  20762. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
  20763. var rscriptType = ( /^$|\/(?:java|ecma)script/i );
  20764. // We have to close these tags to support XHTML (#13200)
  20765. var wrapMap = {
  20766. // Support: IE <=9 only
  20767. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  20768. // XHTML parsers do not magically insert elements in the
  20769. // same way that tag soup parsers do. So we cannot shorten
  20770. // this by omitting <tbody> or other required elements.
  20771. thead: [ 1, "<table>", "</table>" ],
  20772. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  20773. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  20774. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  20775. _default: [ 0, "", "" ]
  20776. };
  20777. // Support: IE <=9 only
  20778. wrapMap.optgroup = wrapMap.option;
  20779. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  20780. wrapMap.th = wrapMap.td;
  20781. function getAll( context, tag ) {
  20782. // Support: IE <=9 - 11 only
  20783. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  20784. var ret;
  20785. if ( typeof context.getElementsByTagName !== "undefined" ) {
  20786. ret = context.getElementsByTagName( tag || "*" );
  20787. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  20788. ret = context.querySelectorAll( tag || "*" );
  20789. } else {
  20790. ret = [];
  20791. }
  20792. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  20793. return jQuery.merge( [ context ], ret );
  20794. }
  20795. return ret;
  20796. }
  20797. // Mark scripts as having already been evaluated
  20798. function setGlobalEval( elems, refElements ) {
  20799. var i = 0,
  20800. l = elems.length;
  20801. for ( ; i < l; i++ ) {
  20802. dataPriv.set(
  20803. elems[ i ],
  20804. "globalEval",
  20805. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  20806. );
  20807. }
  20808. }
  20809. var rhtml = /<|&#?\w+;/;
  20810. function buildFragment( elems, context, scripts, selection, ignored ) {
  20811. var elem, tmp, tag, wrap, contains, j,
  20812. fragment = context.createDocumentFragment(),
  20813. nodes = [],
  20814. i = 0,
  20815. l = elems.length;
  20816. for ( ; i < l; i++ ) {
  20817. elem = elems[ i ];
  20818. if ( elem || elem === 0 ) {
  20819. // Add nodes directly
  20820. if ( jQuery.type( elem ) === "object" ) {
  20821. // Support: Android <=4.0 only, PhantomJS 1 only
  20822. // push.apply(_, arraylike) throws on ancient WebKit
  20823. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  20824. // Convert non-html into a text node
  20825. } else if ( !rhtml.test( elem ) ) {
  20826. nodes.push( context.createTextNode( elem ) );
  20827. // Convert html into DOM nodes
  20828. } else {
  20829. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  20830. // Deserialize a standard representation
  20831. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  20832. wrap = wrapMap[ tag ] || wrapMap._default;
  20833. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  20834. // Descend through wrappers to the right content
  20835. j = wrap[ 0 ];
  20836. while ( j-- ) {
  20837. tmp = tmp.lastChild;
  20838. }
  20839. // Support: Android <=4.0 only, PhantomJS 1 only
  20840. // push.apply(_, arraylike) throws on ancient WebKit
  20841. jQuery.merge( nodes, tmp.childNodes );
  20842. // Remember the top-level container
  20843. tmp = fragment.firstChild;
  20844. // Ensure the created nodes are orphaned (#12392)
  20845. tmp.textContent = "";
  20846. }
  20847. }
  20848. }
  20849. // Remove wrapper from fragment
  20850. fragment.textContent = "";
  20851. i = 0;
  20852. while ( ( elem = nodes[ i++ ] ) ) {
  20853. // Skip elements already in the context collection (trac-4087)
  20854. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  20855. if ( ignored ) {
  20856. ignored.push( elem );
  20857. }
  20858. continue;
  20859. }
  20860. contains = jQuery.contains( elem.ownerDocument, elem );
  20861. // Append to fragment
  20862. tmp = getAll( fragment.appendChild( elem ), "script" );
  20863. // Preserve script evaluation history
  20864. if ( contains ) {
  20865. setGlobalEval( tmp );
  20866. }
  20867. // Capture executables
  20868. if ( scripts ) {
  20869. j = 0;
  20870. while ( ( elem = tmp[ j++ ] ) ) {
  20871. if ( rscriptType.test( elem.type || "" ) ) {
  20872. scripts.push( elem );
  20873. }
  20874. }
  20875. }
  20876. }
  20877. return fragment;
  20878. }
  20879. ( function() {
  20880. var fragment = document.createDocumentFragment(),
  20881. div = fragment.appendChild( document.createElement( "div" ) ),
  20882. input = document.createElement( "input" );
  20883. // Support: Android 4.0 - 4.3 only
  20884. // Check state lost if the name is set (#11217)
  20885. // Support: Windows Web Apps (WWA)
  20886. // `name` and `type` must use .setAttribute for WWA (#14901)
  20887. input.setAttribute( "type", "radio" );
  20888. input.setAttribute( "checked", "checked" );
  20889. input.setAttribute( "name", "t" );
  20890. div.appendChild( input );
  20891. // Support: Android <=4.1 only
  20892. // Older WebKit doesn't clone checked state correctly in fragments
  20893. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  20894. // Support: IE <=11 only
  20895. // Make sure textarea (and checkbox) defaultValue is properly cloned
  20896. div.innerHTML = "<textarea>x</textarea>";
  20897. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  20898. } )();
  20899. var documentElement = document.documentElement;
  20900. var
  20901. rkeyEvent = /^key/,
  20902. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  20903. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  20904. function returnTrue() {
  20905. return true;
  20906. }
  20907. function returnFalse() {
  20908. return false;
  20909. }
  20910. // Support: IE <=9 only
  20911. // See #13393 for more info
  20912. function safeActiveElement() {
  20913. try {
  20914. return document.activeElement;
  20915. } catch ( err ) { }
  20916. }
  20917. function on( elem, types, selector, data, fn, one ) {
  20918. var origFn, type;
  20919. // Types can be a map of types/handlers
  20920. if ( typeof types === "object" ) {
  20921. // ( types-Object, selector, data )
  20922. if ( typeof selector !== "string" ) {
  20923. // ( types-Object, data )
  20924. data = data || selector;
  20925. selector = undefined;
  20926. }
  20927. for ( type in types ) {
  20928. on( elem, type, selector, data, types[ type ], one );
  20929. }
  20930. return elem;
  20931. }
  20932. if ( data == null && fn == null ) {
  20933. // ( types, fn )
  20934. fn = selector;
  20935. data = selector = undefined;
  20936. } else if ( fn == null ) {
  20937. if ( typeof selector === "string" ) {
  20938. // ( types, selector, fn )
  20939. fn = data;
  20940. data = undefined;
  20941. } else {
  20942. // ( types, data, fn )
  20943. fn = data;
  20944. data = selector;
  20945. selector = undefined;
  20946. }
  20947. }
  20948. if ( fn === false ) {
  20949. fn = returnFalse;
  20950. } else if ( !fn ) {
  20951. return elem;
  20952. }
  20953. if ( one === 1 ) {
  20954. origFn = fn;
  20955. fn = function( event ) {
  20956. // Can use an empty set, since event contains the info
  20957. jQuery().off( event );
  20958. return origFn.apply( this, arguments );
  20959. };
  20960. // Use same guid so caller can remove using origFn
  20961. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  20962. }
  20963. return elem.each( function() {
  20964. jQuery.event.add( this, types, fn, data, selector );
  20965. } );
  20966. }
  20967. /*
  20968. * Helper functions for managing events -- not part of the public interface.
  20969. * Props to Dean Edwards' addEvent library for many of the ideas.
  20970. */
  20971. jQuery.event = {
  20972. global: {},
  20973. add: function( elem, types, handler, data, selector ) {
  20974. var handleObjIn, eventHandle, tmp,
  20975. events, t, handleObj,
  20976. special, handlers, type, namespaces, origType,
  20977. elemData = dataPriv.get( elem );
  20978. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  20979. if ( !elemData ) {
  20980. return;
  20981. }
  20982. // Caller can pass in an object of custom data in lieu of the handler
  20983. if ( handler.handler ) {
  20984. handleObjIn = handler;
  20985. handler = handleObjIn.handler;
  20986. selector = handleObjIn.selector;
  20987. }
  20988. // Ensure that invalid selectors throw exceptions at attach time
  20989. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  20990. if ( selector ) {
  20991. jQuery.find.matchesSelector( documentElement, selector );
  20992. }
  20993. // Make sure that the handler has a unique ID, used to find/remove it later
  20994. if ( !handler.guid ) {
  20995. handler.guid = jQuery.guid++;
  20996. }
  20997. // Init the element's event structure and main handler, if this is the first
  20998. if ( !( events = elemData.events ) ) {
  20999. events = elemData.events = {};
  21000. }
  21001. if ( !( eventHandle = elemData.handle ) ) {
  21002. eventHandle = elemData.handle = function( e ) {
  21003. // Discard the second event of a jQuery.event.trigger() and
  21004. // when an event is called after a page has unloaded
  21005. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  21006. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  21007. };
  21008. }
  21009. // Handle multiple events separated by a space
  21010. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  21011. t = types.length;
  21012. while ( t-- ) {
  21013. tmp = rtypenamespace.exec( types[ t ] ) || [];
  21014. type = origType = tmp[ 1 ];
  21015. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  21016. // There *must* be a type, no attaching namespace-only handlers
  21017. if ( !type ) {
  21018. continue;
  21019. }
  21020. // If event changes its type, use the special event handlers for the changed type
  21021. special = jQuery.event.special[ type ] || {};
  21022. // If selector defined, determine special event api type, otherwise given type
  21023. type = ( selector ? special.delegateType : special.bindType ) || type;
  21024. // Update special based on newly reset type
  21025. special = jQuery.event.special[ type ] || {};
  21026. // handleObj is passed to all event handlers
  21027. handleObj = jQuery.extend( {
  21028. type: type,
  21029. origType: origType,
  21030. data: data,
  21031. handler: handler,
  21032. guid: handler.guid,
  21033. selector: selector,
  21034. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  21035. namespace: namespaces.join( "." )
  21036. }, handleObjIn );
  21037. // Init the event handler queue if we're the first
  21038. if ( !( handlers = events[ type ] ) ) {
  21039. handlers = events[ type ] = [];
  21040. handlers.delegateCount = 0;
  21041. // Only use addEventListener if the special events handler returns false
  21042. if ( !special.setup ||
  21043. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  21044. if ( elem.addEventListener ) {
  21045. elem.addEventListener( type, eventHandle );
  21046. }
  21047. }
  21048. }
  21049. if ( special.add ) {
  21050. special.add.call( elem, handleObj );
  21051. if ( !handleObj.handler.guid ) {
  21052. handleObj.handler.guid = handler.guid;
  21053. }
  21054. }
  21055. // Add to the element's handler list, delegates in front
  21056. if ( selector ) {
  21057. handlers.splice( handlers.delegateCount++, 0, handleObj );
  21058. } else {
  21059. handlers.push( handleObj );
  21060. }
  21061. // Keep track of which events have ever been used, for event optimization
  21062. jQuery.event.global[ type ] = true;
  21063. }
  21064. },
  21065. // Detach an event or set of events from an element
  21066. remove: function( elem, types, handler, selector, mappedTypes ) {
  21067. var j, origCount, tmp,
  21068. events, t, handleObj,
  21069. special, handlers, type, namespaces, origType,
  21070. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  21071. if ( !elemData || !( events = elemData.events ) ) {
  21072. return;
  21073. }
  21074. // Once for each type.namespace in types; type may be omitted
  21075. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  21076. t = types.length;
  21077. while ( t-- ) {
  21078. tmp = rtypenamespace.exec( types[ t ] ) || [];
  21079. type = origType = tmp[ 1 ];
  21080. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  21081. // Unbind all events (on this namespace, if provided) for the element
  21082. if ( !type ) {
  21083. for ( type in events ) {
  21084. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  21085. }
  21086. continue;
  21087. }
  21088. special = jQuery.event.special[ type ] || {};
  21089. type = ( selector ? special.delegateType : special.bindType ) || type;
  21090. handlers = events[ type ] || [];
  21091. tmp = tmp[ 2 ] &&
  21092. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  21093. // Remove matching events
  21094. origCount = j = handlers.length;
  21095. while ( j-- ) {
  21096. handleObj = handlers[ j ];
  21097. if ( ( mappedTypes || origType === handleObj.origType ) &&
  21098. ( !handler || handler.guid === handleObj.guid ) &&
  21099. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  21100. ( !selector || selector === handleObj.selector ||
  21101. selector === "**" && handleObj.selector ) ) {
  21102. handlers.splice( j, 1 );
  21103. if ( handleObj.selector ) {
  21104. handlers.delegateCount--;
  21105. }
  21106. if ( special.remove ) {
  21107. special.remove.call( elem, handleObj );
  21108. }
  21109. }
  21110. }
  21111. // Remove generic event handler if we removed something and no more handlers exist
  21112. // (avoids potential for endless recursion during removal of special event handlers)
  21113. if ( origCount && !handlers.length ) {
  21114. if ( !special.teardown ||
  21115. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  21116. jQuery.removeEvent( elem, type, elemData.handle );
  21117. }
  21118. delete events[ type ];
  21119. }
  21120. }
  21121. // Remove data and the expando if it's no longer used
  21122. if ( jQuery.isEmptyObject( events ) ) {
  21123. dataPriv.remove( elem, "handle events" );
  21124. }
  21125. },
  21126. dispatch: function( nativeEvent ) {
  21127. // Make a writable jQuery.Event from the native event object
  21128. var event = jQuery.event.fix( nativeEvent );
  21129. var i, j, ret, matched, handleObj, handlerQueue,
  21130. args = new Array( arguments.length ),
  21131. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  21132. special = jQuery.event.special[ event.type ] || {};
  21133. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  21134. args[ 0 ] = event;
  21135. for ( i = 1; i < arguments.length; i++ ) {
  21136. args[ i ] = arguments[ i ];
  21137. }
  21138. event.delegateTarget = this;
  21139. // Call the preDispatch hook for the mapped type, and let it bail if desired
  21140. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  21141. return;
  21142. }
  21143. // Determine handlers
  21144. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  21145. // Run delegates first; they may want to stop propagation beneath us
  21146. i = 0;
  21147. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  21148. event.currentTarget = matched.elem;
  21149. j = 0;
  21150. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  21151. !event.isImmediatePropagationStopped() ) {
  21152. // Triggered event must either 1) have no namespace, or 2) have namespace(s)
  21153. // a subset or equal to those in the bound event (both can have no namespace).
  21154. if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
  21155. event.handleObj = handleObj;
  21156. event.data = handleObj.data;
  21157. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  21158. handleObj.handler ).apply( matched.elem, args );
  21159. if ( ret !== undefined ) {
  21160. if ( ( event.result = ret ) === false ) {
  21161. event.preventDefault();
  21162. event.stopPropagation();
  21163. }
  21164. }
  21165. }
  21166. }
  21167. }
  21168. // Call the postDispatch hook for the mapped type
  21169. if ( special.postDispatch ) {
  21170. special.postDispatch.call( this, event );
  21171. }
  21172. return event.result;
  21173. },
  21174. handlers: function( event, handlers ) {
  21175. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  21176. handlerQueue = [],
  21177. delegateCount = handlers.delegateCount,
  21178. cur = event.target;
  21179. // Find delegate handlers
  21180. if ( delegateCount &&
  21181. // Support: IE <=9
  21182. // Black-hole SVG <use> instance trees (trac-13180)
  21183. cur.nodeType &&
  21184. // Support: Firefox <=42
  21185. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  21186. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  21187. // Support: IE 11 only
  21188. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  21189. !( event.type === "click" && event.button >= 1 ) ) {
  21190. for ( ; cur !== this; cur = cur.parentNode || this ) {
  21191. // Don't check non-elements (#13208)
  21192. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  21193. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  21194. matchedHandlers = [];
  21195. matchedSelectors = {};
  21196. for ( i = 0; i < delegateCount; i++ ) {
  21197. handleObj = handlers[ i ];
  21198. // Don't conflict with Object.prototype properties (#13203)
  21199. sel = handleObj.selector + " ";
  21200. if ( matchedSelectors[ sel ] === undefined ) {
  21201. matchedSelectors[ sel ] = handleObj.needsContext ?
  21202. jQuery( sel, this ).index( cur ) > -1 :
  21203. jQuery.find( sel, this, null, [ cur ] ).length;
  21204. }
  21205. if ( matchedSelectors[ sel ] ) {
  21206. matchedHandlers.push( handleObj );
  21207. }
  21208. }
  21209. if ( matchedHandlers.length ) {
  21210. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  21211. }
  21212. }
  21213. }
  21214. }
  21215. // Add the remaining (directly-bound) handlers
  21216. cur = this;
  21217. if ( delegateCount < handlers.length ) {
  21218. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  21219. }
  21220. return handlerQueue;
  21221. },
  21222. addProp: function( name, hook ) {
  21223. Object.defineProperty( jQuery.Event.prototype, name, {
  21224. enumerable: true,
  21225. configurable: true,
  21226. get: jQuery.isFunction( hook ) ?
  21227. function() {
  21228. if ( this.originalEvent ) {
  21229. return hook( this.originalEvent );
  21230. }
  21231. } :
  21232. function() {
  21233. if ( this.originalEvent ) {
  21234. return this.originalEvent[ name ];
  21235. }
  21236. },
  21237. set: function( value ) {
  21238. Object.defineProperty( this, name, {
  21239. enumerable: true,
  21240. configurable: true,
  21241. writable: true,
  21242. value: value
  21243. } );
  21244. }
  21245. } );
  21246. },
  21247. fix: function( originalEvent ) {
  21248. return originalEvent[ jQuery.expando ] ?
  21249. originalEvent :
  21250. new jQuery.Event( originalEvent );
  21251. },
  21252. special: {
  21253. load: {
  21254. // Prevent triggered image.load events from bubbling to window.load
  21255. noBubble: true
  21256. },
  21257. focus: {
  21258. // Fire native event if possible so blur/focus sequence is correct
  21259. trigger: function() {
  21260. if ( this !== safeActiveElement() && this.focus ) {
  21261. this.focus();
  21262. return false;
  21263. }
  21264. },
  21265. delegateType: "focusin"
  21266. },
  21267. blur: {
  21268. trigger: function() {
  21269. if ( this === safeActiveElement() && this.blur ) {
  21270. this.blur();
  21271. return false;
  21272. }
  21273. },
  21274. delegateType: "focusout"
  21275. },
  21276. click: {
  21277. // For checkbox, fire native event so checked state will be right
  21278. trigger: function() {
  21279. if ( this.type === "checkbox" && this.click && nodeName( this, "input" ) ) {
  21280. this.click();
  21281. return false;
  21282. }
  21283. },
  21284. // For cross-browser consistency, don't fire native .click() on links
  21285. _default: function( event ) {
  21286. return nodeName( event.target, "a" );
  21287. }
  21288. },
  21289. beforeunload: {
  21290. postDispatch: function( event ) {
  21291. // Support: Firefox 20+
  21292. // Firefox doesn't alert if the returnValue field is not set.
  21293. if ( event.result !== undefined && event.originalEvent ) {
  21294. event.originalEvent.returnValue = event.result;
  21295. }
  21296. }
  21297. }
  21298. }
  21299. };
  21300. jQuery.removeEvent = function( elem, type, handle ) {
  21301. // This "if" is needed for plain objects
  21302. if ( elem.removeEventListener ) {
  21303. elem.removeEventListener( type, handle );
  21304. }
  21305. };
  21306. jQuery.Event = function( src, props ) {
  21307. // Allow instantiation without the 'new' keyword
  21308. if ( !( this instanceof jQuery.Event ) ) {
  21309. return new jQuery.Event( src, props );
  21310. }
  21311. // Event object
  21312. if ( src && src.type ) {
  21313. this.originalEvent = src;
  21314. this.type = src.type;
  21315. // Events bubbling up the document may have been marked as prevented
  21316. // by a handler lower down the tree; reflect the correct value.
  21317. this.isDefaultPrevented = src.defaultPrevented ||
  21318. src.defaultPrevented === undefined &&
  21319. // Support: Android <=2.3 only
  21320. src.returnValue === false ?
  21321. returnTrue :
  21322. returnFalse;
  21323. // Create target properties
  21324. // Support: Safari <=6 - 7 only
  21325. // Target should not be a text node (#504, #13143)
  21326. this.target = ( src.target && src.target.nodeType === 3 ) ?
  21327. src.target.parentNode :
  21328. src.target;
  21329. this.currentTarget = src.currentTarget;
  21330. this.relatedTarget = src.relatedTarget;
  21331. // Event type
  21332. } else {
  21333. this.type = src;
  21334. }
  21335. // Put explicitly provided properties onto the event object
  21336. if ( props ) {
  21337. jQuery.extend( this, props );
  21338. }
  21339. // Create a timestamp if incoming event doesn't have one
  21340. this.timeStamp = src && src.timeStamp || jQuery.now();
  21341. // Mark it as fixed
  21342. this[ jQuery.expando ] = true;
  21343. };
  21344. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  21345. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  21346. jQuery.Event.prototype = {
  21347. constructor: jQuery.Event,
  21348. isDefaultPrevented: returnFalse,
  21349. isPropagationStopped: returnFalse,
  21350. isImmediatePropagationStopped: returnFalse,
  21351. isSimulated: false,
  21352. preventDefault: function() {
  21353. var e = this.originalEvent;
  21354. this.isDefaultPrevented = returnTrue;
  21355. if ( e && !this.isSimulated ) {
  21356. e.preventDefault();
  21357. }
  21358. },
  21359. stopPropagation: function() {
  21360. var e = this.originalEvent;
  21361. this.isPropagationStopped = returnTrue;
  21362. if ( e && !this.isSimulated ) {
  21363. e.stopPropagation();
  21364. }
  21365. },
  21366. stopImmediatePropagation: function() {
  21367. var e = this.originalEvent;
  21368. this.isImmediatePropagationStopped = returnTrue;
  21369. if ( e && !this.isSimulated ) {
  21370. e.stopImmediatePropagation();
  21371. }
  21372. this.stopPropagation();
  21373. }
  21374. };
  21375. // Includes all common event props including KeyEvent and MouseEvent specific props
  21376. jQuery.each( {
  21377. altKey: true,
  21378. bubbles: true,
  21379. cancelable: true,
  21380. changedTouches: true,
  21381. ctrlKey: true,
  21382. detail: true,
  21383. eventPhase: true,
  21384. metaKey: true,
  21385. pageX: true,
  21386. pageY: true,
  21387. shiftKey: true,
  21388. view: true,
  21389. "char": true,
  21390. charCode: true,
  21391. key: true,
  21392. keyCode: true,
  21393. button: true,
  21394. buttons: true,
  21395. clientX: true,
  21396. clientY: true,
  21397. offsetX: true,
  21398. offsetY: true,
  21399. pointerId: true,
  21400. pointerType: true,
  21401. screenX: true,
  21402. screenY: true,
  21403. targetTouches: true,
  21404. toElement: true,
  21405. touches: true,
  21406. which: function( event ) {
  21407. var button = event.button;
  21408. // Add which for key events
  21409. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  21410. return event.charCode != null ? event.charCode : event.keyCode;
  21411. }
  21412. // Add which for click: 1 === left; 2 === middle; 3 === right
  21413. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  21414. if ( button & 1 ) {
  21415. return 1;
  21416. }
  21417. if ( button & 2 ) {
  21418. return 3;
  21419. }
  21420. if ( button & 4 ) {
  21421. return 2;
  21422. }
  21423. return 0;
  21424. }
  21425. return event.which;
  21426. }
  21427. }, jQuery.event.addProp );
  21428. // Create mouseenter/leave events using mouseover/out and event-time checks
  21429. // so that event delegation works in jQuery.
  21430. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  21431. //
  21432. // Support: Safari 7 only
  21433. // Safari sends mouseenter too often; see:
  21434. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  21435. // for the description of the bug (it existed in older Chrome versions as well).
  21436. jQuery.each( {
  21437. mouseenter: "mouseover",
  21438. mouseleave: "mouseout",
  21439. pointerenter: "pointerover",
  21440. pointerleave: "pointerout"
  21441. }, function( orig, fix ) {
  21442. jQuery.event.special[ orig ] = {
  21443. delegateType: fix,
  21444. bindType: fix,
  21445. handle: function( event ) {
  21446. var ret,
  21447. target = this,
  21448. related = event.relatedTarget,
  21449. handleObj = event.handleObj;
  21450. // For mouseenter/leave call the handler if related is outside the target.
  21451. // NB: No relatedTarget if the mouse left/entered the browser window
  21452. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  21453. event.type = handleObj.origType;
  21454. ret = handleObj.handler.apply( this, arguments );
  21455. event.type = fix;
  21456. }
  21457. return ret;
  21458. }
  21459. };
  21460. } );
  21461. jQuery.fn.extend( {
  21462. on: function( types, selector, data, fn ) {
  21463. return on( this, types, selector, data, fn );
  21464. },
  21465. one: function( types, selector, data, fn ) {
  21466. return on( this, types, selector, data, fn, 1 );
  21467. },
  21468. off: function( types, selector, fn ) {
  21469. var handleObj, type;
  21470. if ( types && types.preventDefault && types.handleObj ) {
  21471. // ( event ) dispatched jQuery.Event
  21472. handleObj = types.handleObj;
  21473. jQuery( types.delegateTarget ).off(
  21474. handleObj.namespace ?
  21475. handleObj.origType + "." + handleObj.namespace :
  21476. handleObj.origType,
  21477. handleObj.selector,
  21478. handleObj.handler
  21479. );
  21480. return this;
  21481. }
  21482. if ( typeof types === "object" ) {
  21483. // ( types-object [, selector] )
  21484. for ( type in types ) {
  21485. this.off( type, selector, types[ type ] );
  21486. }
  21487. return this;
  21488. }
  21489. if ( selector === false || typeof selector === "function" ) {
  21490. // ( types [, fn] )
  21491. fn = selector;
  21492. selector = undefined;
  21493. }
  21494. if ( fn === false ) {
  21495. fn = returnFalse;
  21496. }
  21497. return this.each( function() {
  21498. jQuery.event.remove( this, types, fn, selector );
  21499. } );
  21500. }
  21501. } );
  21502. var
  21503. /* eslint-disable max-len */
  21504. // See https://github.com/eslint/eslint/issues/3229
  21505. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  21506. /* eslint-enable */
  21507. // Support: IE <=10 - 11, Edge 12 - 13
  21508. // In IE/Edge using regex groups here causes severe slowdowns.
  21509. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  21510. rnoInnerhtml = /<script|<style|<link/i,
  21511. // checked="checked" or checked
  21512. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  21513. rscriptTypeMasked = /^true\/(.*)/,
  21514. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  21515. // Prefer a tbody over its parent table for containing new rows
  21516. function manipulationTarget( elem, content ) {
  21517. if ( nodeName( elem, "table" ) &&
  21518. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  21519. return jQuery( ">tbody", elem )[ 0 ] || elem;
  21520. }
  21521. return elem;
  21522. }
  21523. // Replace/restore the type attribute of script elements for safe DOM manipulation
  21524. function disableScript( elem ) {
  21525. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  21526. return elem;
  21527. }
  21528. function restoreScript( elem ) {
  21529. var match = rscriptTypeMasked.exec( elem.type );
  21530. if ( match ) {
  21531. elem.type = match[ 1 ];
  21532. } else {
  21533. elem.removeAttribute( "type" );
  21534. }
  21535. return elem;
  21536. }
  21537. function cloneCopyEvent( src, dest ) {
  21538. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  21539. if ( dest.nodeType !== 1 ) {
  21540. return;
  21541. }
  21542. // 1. Copy private data: events, handlers, etc.
  21543. if ( dataPriv.hasData( src ) ) {
  21544. pdataOld = dataPriv.access( src );
  21545. pdataCur = dataPriv.set( dest, pdataOld );
  21546. events = pdataOld.events;
  21547. if ( events ) {
  21548. delete pdataCur.handle;
  21549. pdataCur.events = {};
  21550. for ( type in events ) {
  21551. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  21552. jQuery.event.add( dest, type, events[ type ][ i ] );
  21553. }
  21554. }
  21555. }
  21556. }
  21557. // 2. Copy user data
  21558. if ( dataUser.hasData( src ) ) {
  21559. udataOld = dataUser.access( src );
  21560. udataCur = jQuery.extend( {}, udataOld );
  21561. dataUser.set( dest, udataCur );
  21562. }
  21563. }
  21564. // Fix IE bugs, see support tests
  21565. function fixInput( src, dest ) {
  21566. var nodeName = dest.nodeName.toLowerCase();
  21567. // Fails to persist the checked state of a cloned checkbox or radio button.
  21568. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  21569. dest.checked = src.checked;
  21570. // Fails to return the selected option to the default selected state when cloning options
  21571. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  21572. dest.defaultValue = src.defaultValue;
  21573. }
  21574. }
  21575. function domManip( collection, args, callback, ignored ) {
  21576. // Flatten any nested arrays
  21577. args = concat.apply( [], args );
  21578. var fragment, first, scripts, hasScripts, node, doc,
  21579. i = 0,
  21580. l = collection.length,
  21581. iNoClone = l - 1,
  21582. value = args[ 0 ],
  21583. isFunction = jQuery.isFunction( value );
  21584. // We can't cloneNode fragments that contain checked, in WebKit
  21585. if ( isFunction ||
  21586. ( l > 1 && typeof value === "string" &&
  21587. !support.checkClone && rchecked.test( value ) ) ) {
  21588. return collection.each( function( index ) {
  21589. var self = collection.eq( index );
  21590. if ( isFunction ) {
  21591. args[ 0 ] = value.call( this, index, self.html() );
  21592. }
  21593. domManip( self, args, callback, ignored );
  21594. } );
  21595. }
  21596. if ( l ) {
  21597. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  21598. first = fragment.firstChild;
  21599. if ( fragment.childNodes.length === 1 ) {
  21600. fragment = first;
  21601. }
  21602. // Require either new content or an interest in ignored elements to invoke the callback
  21603. if ( first || ignored ) {
  21604. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  21605. hasScripts = scripts.length;
  21606. // Use the original fragment for the last item
  21607. // instead of the first because it can end up
  21608. // being emptied incorrectly in certain situations (#8070).
  21609. for ( ; i < l; i++ ) {
  21610. node = fragment;
  21611. if ( i !== iNoClone ) {
  21612. node = jQuery.clone( node, true, true );
  21613. // Keep references to cloned scripts for later restoration
  21614. if ( hasScripts ) {
  21615. // Support: Android <=4.0 only, PhantomJS 1 only
  21616. // push.apply(_, arraylike) throws on ancient WebKit
  21617. jQuery.merge( scripts, getAll( node, "script" ) );
  21618. }
  21619. }
  21620. callback.call( collection[ i ], node, i );
  21621. }
  21622. if ( hasScripts ) {
  21623. doc = scripts[ scripts.length - 1 ].ownerDocument;
  21624. // Reenable scripts
  21625. jQuery.map( scripts, restoreScript );
  21626. // Evaluate executable scripts on first document insertion
  21627. for ( i = 0; i < hasScripts; i++ ) {
  21628. node = scripts[ i ];
  21629. if ( rscriptType.test( node.type || "" ) &&
  21630. !dataPriv.access( node, "globalEval" ) &&
  21631. jQuery.contains( doc, node ) ) {
  21632. if ( node.src ) {
  21633. // Optional AJAX dependency, but won't run scripts if not present
  21634. if ( jQuery._evalUrl ) {
  21635. jQuery._evalUrl( node.src );
  21636. }
  21637. } else {
  21638. DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
  21639. }
  21640. }
  21641. }
  21642. }
  21643. }
  21644. }
  21645. return collection;
  21646. }
  21647. function remove( elem, selector, keepData ) {
  21648. var node,
  21649. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  21650. i = 0;
  21651. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  21652. if ( !keepData && node.nodeType === 1 ) {
  21653. jQuery.cleanData( getAll( node ) );
  21654. }
  21655. if ( node.parentNode ) {
  21656. if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
  21657. setGlobalEval( getAll( node, "script" ) );
  21658. }
  21659. node.parentNode.removeChild( node );
  21660. }
  21661. }
  21662. return elem;
  21663. }
  21664. jQuery.extend( {
  21665. htmlPrefilter: function( html ) {
  21666. return html.replace( rxhtmlTag, "<$1></$2>" );
  21667. },
  21668. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  21669. var i, l, srcElements, destElements,
  21670. clone = elem.cloneNode( true ),
  21671. inPage = jQuery.contains( elem.ownerDocument, elem );
  21672. // Fix IE cloning issues
  21673. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  21674. !jQuery.isXMLDoc( elem ) ) {
  21675. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  21676. destElements = getAll( clone );
  21677. srcElements = getAll( elem );
  21678. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  21679. fixInput( srcElements[ i ], destElements[ i ] );
  21680. }
  21681. }
  21682. // Copy the events from the original to the clone
  21683. if ( dataAndEvents ) {
  21684. if ( deepDataAndEvents ) {
  21685. srcElements = srcElements || getAll( elem );
  21686. destElements = destElements || getAll( clone );
  21687. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  21688. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  21689. }
  21690. } else {
  21691. cloneCopyEvent( elem, clone );
  21692. }
  21693. }
  21694. // Preserve script evaluation history
  21695. destElements = getAll( clone, "script" );
  21696. if ( destElements.length > 0 ) {
  21697. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  21698. }
  21699. // Return the cloned set
  21700. return clone;
  21701. },
  21702. cleanData: function( elems ) {
  21703. var data, elem, type,
  21704. special = jQuery.event.special,
  21705. i = 0;
  21706. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  21707. if ( acceptData( elem ) ) {
  21708. if ( ( data = elem[ dataPriv.expando ] ) ) {
  21709. if ( data.events ) {
  21710. for ( type in data.events ) {
  21711. if ( special[ type ] ) {
  21712. jQuery.event.remove( elem, type );
  21713. // This is a shortcut to avoid jQuery.event.remove's overhead
  21714. } else {
  21715. jQuery.removeEvent( elem, type, data.handle );
  21716. }
  21717. }
  21718. }
  21719. // Support: Chrome <=35 - 45+
  21720. // Assign undefined instead of using delete, see Data#remove
  21721. elem[ dataPriv.expando ] = undefined;
  21722. }
  21723. if ( elem[ dataUser.expando ] ) {
  21724. // Support: Chrome <=35 - 45+
  21725. // Assign undefined instead of using delete, see Data#remove
  21726. elem[ dataUser.expando ] = undefined;
  21727. }
  21728. }
  21729. }
  21730. }
  21731. } );
  21732. jQuery.fn.extend( {
  21733. detach: function( selector ) {
  21734. return remove( this, selector, true );
  21735. },
  21736. remove: function( selector ) {
  21737. return remove( this, selector );
  21738. },
  21739. text: function( value ) {
  21740. return access( this, function( value ) {
  21741. return value === undefined ?
  21742. jQuery.text( this ) :
  21743. this.empty().each( function() {
  21744. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  21745. this.textContent = value;
  21746. }
  21747. } );
  21748. }, null, value, arguments.length );
  21749. },
  21750. append: function() {
  21751. return domManip( this, arguments, function( elem ) {
  21752. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  21753. var target = manipulationTarget( this, elem );
  21754. target.appendChild( elem );
  21755. }
  21756. } );
  21757. },
  21758. prepend: function() {
  21759. return domManip( this, arguments, function( elem ) {
  21760. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  21761. var target = manipulationTarget( this, elem );
  21762. target.insertBefore( elem, target.firstChild );
  21763. }
  21764. } );
  21765. },
  21766. before: function() {
  21767. return domManip( this, arguments, function( elem ) {
  21768. if ( this.parentNode ) {
  21769. this.parentNode.insertBefore( elem, this );
  21770. }
  21771. } );
  21772. },
  21773. after: function() {
  21774. return domManip( this, arguments, function( elem ) {
  21775. if ( this.parentNode ) {
  21776. this.parentNode.insertBefore( elem, this.nextSibling );
  21777. }
  21778. } );
  21779. },
  21780. empty: function() {
  21781. var elem,
  21782. i = 0;
  21783. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  21784. if ( elem.nodeType === 1 ) {
  21785. // Prevent memory leaks
  21786. jQuery.cleanData( getAll( elem, false ) );
  21787. // Remove any remaining nodes
  21788. elem.textContent = "";
  21789. }
  21790. }
  21791. return this;
  21792. },
  21793. clone: function( dataAndEvents, deepDataAndEvents ) {
  21794. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  21795. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  21796. return this.map( function() {
  21797. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  21798. } );
  21799. },
  21800. html: function( value ) {
  21801. return access( this, function( value ) {
  21802. var elem = this[ 0 ] || {},
  21803. i = 0,
  21804. l = this.length;
  21805. if ( value === undefined && elem.nodeType === 1 ) {
  21806. return elem.innerHTML;
  21807. }
  21808. // See if we can take a shortcut and just use innerHTML
  21809. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  21810. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  21811. value = jQuery.htmlPrefilter( value );
  21812. try {
  21813. for ( ; i < l; i++ ) {
  21814. elem = this[ i ] || {};
  21815. // Remove element nodes and prevent memory leaks
  21816. if ( elem.nodeType === 1 ) {
  21817. jQuery.cleanData( getAll( elem, false ) );
  21818. elem.innerHTML = value;
  21819. }
  21820. }
  21821. elem = 0;
  21822. // If using innerHTML throws an exception, use the fallback method
  21823. } catch ( e ) {}
  21824. }
  21825. if ( elem ) {
  21826. this.empty().append( value );
  21827. }
  21828. }, null, value, arguments.length );
  21829. },
  21830. replaceWith: function() {
  21831. var ignored = [];
  21832. // Make the changes, replacing each non-ignored context element with the new content
  21833. return domManip( this, arguments, function( elem ) {
  21834. var parent = this.parentNode;
  21835. if ( jQuery.inArray( this, ignored ) < 0 ) {
  21836. jQuery.cleanData( getAll( this ) );
  21837. if ( parent ) {
  21838. parent.replaceChild( elem, this );
  21839. }
  21840. }
  21841. // Force callback invocation
  21842. }, ignored );
  21843. }
  21844. } );
  21845. jQuery.each( {
  21846. appendTo: "append",
  21847. prependTo: "prepend",
  21848. insertBefore: "before",
  21849. insertAfter: "after",
  21850. replaceAll: "replaceWith"
  21851. }, function( name, original ) {
  21852. jQuery.fn[ name ] = function( selector ) {
  21853. var elems,
  21854. ret = [],
  21855. insert = jQuery( selector ),
  21856. last = insert.length - 1,
  21857. i = 0;
  21858. for ( ; i <= last; i++ ) {
  21859. elems = i === last ? this : this.clone( true );
  21860. jQuery( insert[ i ] )[ original ]( elems );
  21861. // Support: Android <=4.0 only, PhantomJS 1 only
  21862. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  21863. push.apply( ret, elems.get() );
  21864. }
  21865. return this.pushStack( ret );
  21866. };
  21867. } );
  21868. var rmargin = ( /^margin/ );
  21869. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  21870. var getStyles = function( elem ) {
  21871. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  21872. // IE throws on elements created in popups
  21873. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  21874. var view = elem.ownerDocument.defaultView;
  21875. if ( !view || !view.opener ) {
  21876. view = window;
  21877. }
  21878. return view.getComputedStyle( elem );
  21879. };
  21880. ( function() {
  21881. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  21882. // so they're executed at the same time to save the second computation.
  21883. function computeStyleTests() {
  21884. // This is a singleton, we need to execute it only once
  21885. if ( !div ) {
  21886. return;
  21887. }
  21888. div.style.cssText =
  21889. "box-sizing:border-box;" +
  21890. "position:relative;display:block;" +
  21891. "margin:auto;border:1px;padding:1px;" +
  21892. "top:1%;width:50%";
  21893. div.innerHTML = "";
  21894. documentElement.appendChild( container );
  21895. var divStyle = window.getComputedStyle( div );
  21896. pixelPositionVal = divStyle.top !== "1%";
  21897. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  21898. reliableMarginLeftVal = divStyle.marginLeft === "2px";
  21899. boxSizingReliableVal = divStyle.width === "4px";
  21900. // Support: Android 4.0 - 4.3 only
  21901. // Some styles come back with percentage values, even though they shouldn't
  21902. div.style.marginRight = "50%";
  21903. pixelMarginRightVal = divStyle.marginRight === "4px";
  21904. documentElement.removeChild( container );
  21905. // Nullify the div so it wouldn't be stored in the memory and
  21906. // it will also be a sign that checks already performed
  21907. div = null;
  21908. }
  21909. var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
  21910. container = document.createElement( "div" ),
  21911. div = document.createElement( "div" );
  21912. // Finish early in limited (non-browser) environments
  21913. if ( !div.style ) {
  21914. return;
  21915. }
  21916. // Support: IE <=9 - 11 only
  21917. // Style of cloned element affects source element cloned (#8908)
  21918. div.style.backgroundClip = "content-box";
  21919. div.cloneNode( true ).style.backgroundClip = "";
  21920. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  21921. container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
  21922. "padding:0;margin-top:1px;position:absolute";
  21923. container.appendChild( div );
  21924. jQuery.extend( support, {
  21925. pixelPosition: function() {
  21926. computeStyleTests();
  21927. return pixelPositionVal;
  21928. },
  21929. boxSizingReliable: function() {
  21930. computeStyleTests();
  21931. return boxSizingReliableVal;
  21932. },
  21933. pixelMarginRight: function() {
  21934. computeStyleTests();
  21935. return pixelMarginRightVal;
  21936. },
  21937. reliableMarginLeft: function() {
  21938. computeStyleTests();
  21939. return reliableMarginLeftVal;
  21940. }
  21941. } );
  21942. } )();
  21943. function curCSS( elem, name, computed ) {
  21944. var width, minWidth, maxWidth, ret,
  21945. // Support: Firefox 51+
  21946. // Retrieving style before computed somehow
  21947. // fixes an issue with getting wrong values
  21948. // on detached elements
  21949. style = elem.style;
  21950. computed = computed || getStyles( elem );
  21951. // getPropertyValue is needed for:
  21952. // .css('filter') (IE 9 only, #12537)
  21953. // .css('--customProperty) (#3144)
  21954. if ( computed ) {
  21955. ret = computed.getPropertyValue( name ) || computed[ name ];
  21956. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  21957. ret = jQuery.style( elem, name );
  21958. }
  21959. // A tribute to the "awesome hack by Dean Edwards"
  21960. // Android Browser returns percentage for some values,
  21961. // but width seems to be reliably pixels.
  21962. // This is against the CSSOM draft spec:
  21963. // https://drafts.csswg.org/cssom/#resolved-values
  21964. if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  21965. // Remember the original values
  21966. width = style.width;
  21967. minWidth = style.minWidth;
  21968. maxWidth = style.maxWidth;
  21969. // Put in the new values to get a computed value out
  21970. style.minWidth = style.maxWidth = style.width = ret;
  21971. ret = computed.width;
  21972. // Revert the changed values
  21973. style.width = width;
  21974. style.minWidth = minWidth;
  21975. style.maxWidth = maxWidth;
  21976. }
  21977. }
  21978. return ret !== undefined ?
  21979. // Support: IE <=9 - 11 only
  21980. // IE returns zIndex value as an integer.
  21981. ret + "" :
  21982. ret;
  21983. }
  21984. function addGetHookIf( conditionFn, hookFn ) {
  21985. // Define the hook, we'll check on the first run if it's really needed.
  21986. return {
  21987. get: function() {
  21988. if ( conditionFn() ) {
  21989. // Hook not needed (or it's not possible to use it due
  21990. // to missing dependency), remove it.
  21991. delete this.get;
  21992. return;
  21993. }
  21994. // Hook needed; redefine it so that the support test is not executed again.
  21995. return ( this.get = hookFn ).apply( this, arguments );
  21996. }
  21997. };
  21998. }
  21999. var
  22000. // Swappable if display is none or starts with table
  22001. // except "table", "table-cell", or "table-caption"
  22002. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  22003. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  22004. rcustomProp = /^--/,
  22005. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  22006. cssNormalTransform = {
  22007. letterSpacing: "0",
  22008. fontWeight: "400"
  22009. },
  22010. cssPrefixes = [ "Webkit", "Moz", "ms" ],
  22011. emptyStyle = document.createElement( "div" ).style;
  22012. // Return a css property mapped to a potentially vendor prefixed property
  22013. function vendorPropName( name ) {
  22014. // Shortcut for names that are not vendor prefixed
  22015. if ( name in emptyStyle ) {
  22016. return name;
  22017. }
  22018. // Check for vendor prefixed names
  22019. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  22020. i = cssPrefixes.length;
  22021. while ( i-- ) {
  22022. name = cssPrefixes[ i ] + capName;
  22023. if ( name in emptyStyle ) {
  22024. return name;
  22025. }
  22026. }
  22027. }
  22028. // Return a property mapped along what jQuery.cssProps suggests or to
  22029. // a vendor prefixed property.
  22030. function finalPropName( name ) {
  22031. var ret = jQuery.cssProps[ name ];
  22032. if ( !ret ) {
  22033. ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
  22034. }
  22035. return ret;
  22036. }
  22037. function setPositiveNumber( elem, value, subtract ) {
  22038. // Any relative (+/-) values have already been
  22039. // normalized at this point
  22040. var matches = rcssNum.exec( value );
  22041. return matches ?
  22042. // Guard against undefined "subtract", e.g., when used as in cssHooks
  22043. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  22044. value;
  22045. }
  22046. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  22047. var i,
  22048. val = 0;
  22049. // If we already have the right measurement, avoid augmentation
  22050. if ( extra === ( isBorderBox ? "border" : "content" ) ) {
  22051. i = 4;
  22052. // Otherwise initialize for horizontal or vertical properties
  22053. } else {
  22054. i = name === "width" ? 1 : 0;
  22055. }
  22056. for ( ; i < 4; i += 2 ) {
  22057. // Both box models exclude margin, so add it if we want it
  22058. if ( extra === "margin" ) {
  22059. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  22060. }
  22061. if ( isBorderBox ) {
  22062. // border-box includes padding, so remove it if we want content
  22063. if ( extra === "content" ) {
  22064. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  22065. }
  22066. // At this point, extra isn't border nor margin, so remove border
  22067. if ( extra !== "margin" ) {
  22068. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  22069. }
  22070. } else {
  22071. // At this point, extra isn't content, so add padding
  22072. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  22073. // At this point, extra isn't content nor padding, so add border
  22074. if ( extra !== "padding" ) {
  22075. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  22076. }
  22077. }
  22078. }
  22079. return val;
  22080. }
  22081. function getWidthOrHeight( elem, name, extra ) {
  22082. // Start with computed style
  22083. var valueIsBorderBox,
  22084. styles = getStyles( elem ),
  22085. val = curCSS( elem, name, styles ),
  22086. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  22087. // Computed unit is not pixels. Stop here and return.
  22088. if ( rnumnonpx.test( val ) ) {
  22089. return val;
  22090. }
  22091. // Check for style in case a browser which returns unreliable values
  22092. // for getComputedStyle silently falls back to the reliable elem.style
  22093. valueIsBorderBox = isBorderBox &&
  22094. ( support.boxSizingReliable() || val === elem.style[ name ] );
  22095. // Fall back to offsetWidth/Height when value is "auto"
  22096. // This happens for inline elements with no explicit setting (gh-3571)
  22097. if ( val === "auto" ) {
  22098. val = elem[ "offset" + name[ 0 ].toUpperCase() + name.slice( 1 ) ];
  22099. }
  22100. // Normalize "", auto, and prepare for extra
  22101. val = parseFloat( val ) || 0;
  22102. // Use the active box-sizing model to add/subtract irrelevant styles
  22103. return ( val +
  22104. augmentWidthOrHeight(
  22105. elem,
  22106. name,
  22107. extra || ( isBorderBox ? "border" : "content" ),
  22108. valueIsBorderBox,
  22109. styles
  22110. )
  22111. ) + "px";
  22112. }
  22113. jQuery.extend( {
  22114. // Add in style property hooks for overriding the default
  22115. // behavior of getting and setting a style property
  22116. cssHooks: {
  22117. opacity: {
  22118. get: function( elem, computed ) {
  22119. if ( computed ) {
  22120. // We should always get a number back from opacity
  22121. var ret = curCSS( elem, "opacity" );
  22122. return ret === "" ? "1" : ret;
  22123. }
  22124. }
  22125. }
  22126. },
  22127. // Don't automatically add "px" to these possibly-unitless properties
  22128. cssNumber: {
  22129. "animationIterationCount": true,
  22130. "columnCount": true,
  22131. "fillOpacity": true,
  22132. "flexGrow": true,
  22133. "flexShrink": true,
  22134. "fontWeight": true,
  22135. "lineHeight": true,
  22136. "opacity": true,
  22137. "order": true,
  22138. "orphans": true,
  22139. "widows": true,
  22140. "zIndex": true,
  22141. "zoom": true
  22142. },
  22143. // Add in properties whose names you wish to fix before
  22144. // setting or getting the value
  22145. cssProps: {
  22146. "float": "cssFloat"
  22147. },
  22148. // Get and set the style property on a DOM Node
  22149. style: function( elem, name, value, extra ) {
  22150. // Don't set styles on text and comment nodes
  22151. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  22152. return;
  22153. }
  22154. // Make sure that we're working with the right name
  22155. var ret, type, hooks,
  22156. origName = jQuery.camelCase( name ),
  22157. isCustomProp = rcustomProp.test( name ),
  22158. style = elem.style;
  22159. // Make sure that we're working with the right name. We don't
  22160. // want to query the value if it is a CSS custom property
  22161. // since they are user-defined.
  22162. if ( !isCustomProp ) {
  22163. name = finalPropName( origName );
  22164. }
  22165. // Gets hook for the prefixed version, then unprefixed version
  22166. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  22167. // Check if we're setting a value
  22168. if ( value !== undefined ) {
  22169. type = typeof value;
  22170. // Convert "+=" or "-=" to relative numbers (#7345)
  22171. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  22172. value = adjustCSS( elem, name, ret );
  22173. // Fixes bug #9237
  22174. type = "number";
  22175. }
  22176. // Make sure that null and NaN values aren't set (#7116)
  22177. if ( value == null || value !== value ) {
  22178. return;
  22179. }
  22180. // If a number was passed in, add the unit (except for certain CSS properties)
  22181. if ( type === "number" ) {
  22182. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  22183. }
  22184. // background-* props affect original clone's values
  22185. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  22186. style[ name ] = "inherit";
  22187. }
  22188. // If a hook was provided, use that value, otherwise just set the specified value
  22189. if ( !hooks || !( "set" in hooks ) ||
  22190. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  22191. if ( isCustomProp ) {
  22192. style.setProperty( name, value );
  22193. } else {
  22194. style[ name ] = value;
  22195. }
  22196. }
  22197. } else {
  22198. // If a hook was provided get the non-computed value from there
  22199. if ( hooks && "get" in hooks &&
  22200. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  22201. return ret;
  22202. }
  22203. // Otherwise just get the value from the style object
  22204. return style[ name ];
  22205. }
  22206. },
  22207. css: function( elem, name, extra, styles ) {
  22208. var val, num, hooks,
  22209. origName = jQuery.camelCase( name ),
  22210. isCustomProp = rcustomProp.test( name );
  22211. // Make sure that we're working with the right name. We don't
  22212. // want to modify the value if it is a CSS custom property
  22213. // since they are user-defined.
  22214. if ( !isCustomProp ) {
  22215. name = finalPropName( origName );
  22216. }
  22217. // Try prefixed name followed by the unprefixed name
  22218. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  22219. // If a hook was provided get the computed value from there
  22220. if ( hooks && "get" in hooks ) {
  22221. val = hooks.get( elem, true, extra );
  22222. }
  22223. // Otherwise, if a way to get the computed value exists, use that
  22224. if ( val === undefined ) {
  22225. val = curCSS( elem, name, styles );
  22226. }
  22227. // Convert "normal" to computed value
  22228. if ( val === "normal" && name in cssNormalTransform ) {
  22229. val = cssNormalTransform[ name ];
  22230. }
  22231. // Make numeric if forced or a qualifier was provided and val looks numeric
  22232. if ( extra === "" || extra ) {
  22233. num = parseFloat( val );
  22234. return extra === true || isFinite( num ) ? num || 0 : val;
  22235. }
  22236. return val;
  22237. }
  22238. } );
  22239. jQuery.each( [ "height", "width" ], function( i, name ) {
  22240. jQuery.cssHooks[ name ] = {
  22241. get: function( elem, computed, extra ) {
  22242. if ( computed ) {
  22243. // Certain elements can have dimension info if we invisibly show them
  22244. // but it must have a current display style that would benefit
  22245. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  22246. // Support: Safari 8+
  22247. // Table columns in Safari have non-zero offsetWidth & zero
  22248. // getBoundingClientRect().width unless display is changed.
  22249. // Support: IE <=11 only
  22250. // Running getBoundingClientRect on a disconnected node
  22251. // in IE throws an error.
  22252. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  22253. swap( elem, cssShow, function() {
  22254. return getWidthOrHeight( elem, name, extra );
  22255. } ) :
  22256. getWidthOrHeight( elem, name, extra );
  22257. }
  22258. },
  22259. set: function( elem, value, extra ) {
  22260. var matches,
  22261. styles = extra && getStyles( elem ),
  22262. subtract = extra && augmentWidthOrHeight(
  22263. elem,
  22264. name,
  22265. extra,
  22266. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  22267. styles
  22268. );
  22269. // Convert to pixels if value adjustment is needed
  22270. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  22271. ( matches[ 3 ] || "px" ) !== "px" ) {
  22272. elem.style[ name ] = value;
  22273. value = jQuery.css( elem, name );
  22274. }
  22275. return setPositiveNumber( elem, value, subtract );
  22276. }
  22277. };
  22278. } );
  22279. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  22280. function( elem, computed ) {
  22281. if ( computed ) {
  22282. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  22283. elem.getBoundingClientRect().left -
  22284. swap( elem, { marginLeft: 0 }, function() {
  22285. return elem.getBoundingClientRect().left;
  22286. } )
  22287. ) + "px";
  22288. }
  22289. }
  22290. );
  22291. // These hooks are used by animate to expand properties
  22292. jQuery.each( {
  22293. margin: "",
  22294. padding: "",
  22295. border: "Width"
  22296. }, function( prefix, suffix ) {
  22297. jQuery.cssHooks[ prefix + suffix ] = {
  22298. expand: function( value ) {
  22299. var i = 0,
  22300. expanded = {},
  22301. // Assumes a single number if not a string
  22302. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  22303. for ( ; i < 4; i++ ) {
  22304. expanded[ prefix + cssExpand[ i ] + suffix ] =
  22305. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  22306. }
  22307. return expanded;
  22308. }
  22309. };
  22310. if ( !rmargin.test( prefix ) ) {
  22311. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  22312. }
  22313. } );
  22314. jQuery.fn.extend( {
  22315. css: function( name, value ) {
  22316. return access( this, function( elem, name, value ) {
  22317. var styles, len,
  22318. map = {},
  22319. i = 0;
  22320. if ( Array.isArray( name ) ) {
  22321. styles = getStyles( elem );
  22322. len = name.length;
  22323. for ( ; i < len; i++ ) {
  22324. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  22325. }
  22326. return map;
  22327. }
  22328. return value !== undefined ?
  22329. jQuery.style( elem, name, value ) :
  22330. jQuery.css( elem, name );
  22331. }, name, value, arguments.length > 1 );
  22332. }
  22333. } );
  22334. function Tween( elem, options, prop, end, easing ) {
  22335. return new Tween.prototype.init( elem, options, prop, end, easing );
  22336. }
  22337. jQuery.Tween = Tween;
  22338. Tween.prototype = {
  22339. constructor: Tween,
  22340. init: function( elem, options, prop, end, easing, unit ) {
  22341. this.elem = elem;
  22342. this.prop = prop;
  22343. this.easing = easing || jQuery.easing._default;
  22344. this.options = options;
  22345. this.start = this.now = this.cur();
  22346. this.end = end;
  22347. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  22348. },
  22349. cur: function() {
  22350. var hooks = Tween.propHooks[ this.prop ];
  22351. return hooks && hooks.get ?
  22352. hooks.get( this ) :
  22353. Tween.propHooks._default.get( this );
  22354. },
  22355. run: function( percent ) {
  22356. var eased,
  22357. hooks = Tween.propHooks[ this.prop ];
  22358. if ( this.options.duration ) {
  22359. this.pos = eased = jQuery.easing[ this.easing ](
  22360. percent, this.options.duration * percent, 0, 1, this.options.duration
  22361. );
  22362. } else {
  22363. this.pos = eased = percent;
  22364. }
  22365. this.now = ( this.end - this.start ) * eased + this.start;
  22366. if ( this.options.step ) {
  22367. this.options.step.call( this.elem, this.now, this );
  22368. }
  22369. if ( hooks && hooks.set ) {
  22370. hooks.set( this );
  22371. } else {
  22372. Tween.propHooks._default.set( this );
  22373. }
  22374. return this;
  22375. }
  22376. };
  22377. Tween.prototype.init.prototype = Tween.prototype;
  22378. Tween.propHooks = {
  22379. _default: {
  22380. get: function( tween ) {
  22381. var result;
  22382. // Use a property on the element directly when it is not a DOM element,
  22383. // or when there is no matching style property that exists.
  22384. if ( tween.elem.nodeType !== 1 ||
  22385. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  22386. return tween.elem[ tween.prop ];
  22387. }
  22388. // Passing an empty string as a 3rd parameter to .css will automatically
  22389. // attempt a parseFloat and fallback to a string if the parse fails.
  22390. // Simple values such as "10px" are parsed to Float;
  22391. // complex values such as "rotate(1rad)" are returned as-is.
  22392. result = jQuery.css( tween.elem, tween.prop, "" );
  22393. // Empty strings, null, undefined and "auto" are converted to 0.
  22394. return !result || result === "auto" ? 0 : result;
  22395. },
  22396. set: function( tween ) {
  22397. // Use step hook for back compat.
  22398. // Use cssHook if its there.
  22399. // Use .style if available and use plain properties where available.
  22400. if ( jQuery.fx.step[ tween.prop ] ) {
  22401. jQuery.fx.step[ tween.prop ]( tween );
  22402. } else if ( tween.elem.nodeType === 1 &&
  22403. ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
  22404. jQuery.cssHooks[ tween.prop ] ) ) {
  22405. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  22406. } else {
  22407. tween.elem[ tween.prop ] = tween.now;
  22408. }
  22409. }
  22410. }
  22411. };
  22412. // Support: IE <=9 only
  22413. // Panic based approach to setting things on disconnected nodes
  22414. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  22415. set: function( tween ) {
  22416. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  22417. tween.elem[ tween.prop ] = tween.now;
  22418. }
  22419. }
  22420. };
  22421. jQuery.easing = {
  22422. linear: function( p ) {
  22423. return p;
  22424. },
  22425. swing: function( p ) {
  22426. return 0.5 - Math.cos( p * Math.PI ) / 2;
  22427. },
  22428. _default: "swing"
  22429. };
  22430. jQuery.fx = Tween.prototype.init;
  22431. // Back compat <1.8 extension point
  22432. jQuery.fx.step = {};
  22433. var
  22434. fxNow, inProgress,
  22435. rfxtypes = /^(?:toggle|show|hide)$/,
  22436. rrun = /queueHooks$/;
  22437. function schedule() {
  22438. if ( inProgress ) {
  22439. if ( document.hidden === false && window.requestAnimationFrame ) {
  22440. window.requestAnimationFrame( schedule );
  22441. } else {
  22442. window.setTimeout( schedule, jQuery.fx.interval );
  22443. }
  22444. jQuery.fx.tick();
  22445. }
  22446. }
  22447. // Animations created synchronously will run synchronously
  22448. function createFxNow() {
  22449. window.setTimeout( function() {
  22450. fxNow = undefined;
  22451. } );
  22452. return ( fxNow = jQuery.now() );
  22453. }
  22454. // Generate parameters to create a standard animation
  22455. function genFx( type, includeWidth ) {
  22456. var which,
  22457. i = 0,
  22458. attrs = { height: type };
  22459. // If we include width, step value is 1 to do all cssExpand values,
  22460. // otherwise step value is 2 to skip over Left and Right
  22461. includeWidth = includeWidth ? 1 : 0;
  22462. for ( ; i < 4; i += 2 - includeWidth ) {
  22463. which = cssExpand[ i ];
  22464. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  22465. }
  22466. if ( includeWidth ) {
  22467. attrs.opacity = attrs.width = type;
  22468. }
  22469. return attrs;
  22470. }
  22471. function createTween( value, prop, animation ) {
  22472. var tween,
  22473. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  22474. index = 0,
  22475. length = collection.length;
  22476. for ( ; index < length; index++ ) {
  22477. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  22478. // We're done with this property
  22479. return tween;
  22480. }
  22481. }
  22482. }
  22483. function defaultPrefilter( elem, props, opts ) {
  22484. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  22485. isBox = "width" in props || "height" in props,
  22486. anim = this,
  22487. orig = {},
  22488. style = elem.style,
  22489. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  22490. dataShow = dataPriv.get( elem, "fxshow" );
  22491. // Queue-skipping animations hijack the fx hooks
  22492. if ( !opts.queue ) {
  22493. hooks = jQuery._queueHooks( elem, "fx" );
  22494. if ( hooks.unqueued == null ) {
  22495. hooks.unqueued = 0;
  22496. oldfire = hooks.empty.fire;
  22497. hooks.empty.fire = function() {
  22498. if ( !hooks.unqueued ) {
  22499. oldfire();
  22500. }
  22501. };
  22502. }
  22503. hooks.unqueued++;
  22504. anim.always( function() {
  22505. // Ensure the complete handler is called before this completes
  22506. anim.always( function() {
  22507. hooks.unqueued--;
  22508. if ( !jQuery.queue( elem, "fx" ).length ) {
  22509. hooks.empty.fire();
  22510. }
  22511. } );
  22512. } );
  22513. }
  22514. // Detect show/hide animations
  22515. for ( prop in props ) {
  22516. value = props[ prop ];
  22517. if ( rfxtypes.test( value ) ) {
  22518. delete props[ prop ];
  22519. toggle = toggle || value === "toggle";
  22520. if ( value === ( hidden ? "hide" : "show" ) ) {
  22521. // Pretend to be hidden if this is a "show" and
  22522. // there is still data from a stopped show/hide
  22523. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  22524. hidden = true;
  22525. // Ignore all other no-op show/hide data
  22526. } else {
  22527. continue;
  22528. }
  22529. }
  22530. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  22531. }
  22532. }
  22533. // Bail out if this is a no-op like .hide().hide()
  22534. propTween = !jQuery.isEmptyObject( props );
  22535. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  22536. return;
  22537. }
  22538. // Restrict "overflow" and "display" styles during box animations
  22539. if ( isBox && elem.nodeType === 1 ) {
  22540. // Support: IE <=9 - 11, Edge 12 - 13
  22541. // Record all 3 overflow attributes because IE does not infer the shorthand
  22542. // from identically-valued overflowX and overflowY
  22543. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  22544. // Identify a display type, preferring old show/hide data over the CSS cascade
  22545. restoreDisplay = dataShow && dataShow.display;
  22546. if ( restoreDisplay == null ) {
  22547. restoreDisplay = dataPriv.get( elem, "display" );
  22548. }
  22549. display = jQuery.css( elem, "display" );
  22550. if ( display === "none" ) {
  22551. if ( restoreDisplay ) {
  22552. display = restoreDisplay;
  22553. } else {
  22554. // Get nonempty value(s) by temporarily forcing visibility
  22555. showHide( [ elem ], true );
  22556. restoreDisplay = elem.style.display || restoreDisplay;
  22557. display = jQuery.css( elem, "display" );
  22558. showHide( [ elem ] );
  22559. }
  22560. }
  22561. // Animate inline elements as inline-block
  22562. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  22563. if ( jQuery.css( elem, "float" ) === "none" ) {
  22564. // Restore the original display value at the end of pure show/hide animations
  22565. if ( !propTween ) {
  22566. anim.done( function() {
  22567. style.display = restoreDisplay;
  22568. } );
  22569. if ( restoreDisplay == null ) {
  22570. display = style.display;
  22571. restoreDisplay = display === "none" ? "" : display;
  22572. }
  22573. }
  22574. style.display = "inline-block";
  22575. }
  22576. }
  22577. }
  22578. if ( opts.overflow ) {
  22579. style.overflow = "hidden";
  22580. anim.always( function() {
  22581. style.overflow = opts.overflow[ 0 ];
  22582. style.overflowX = opts.overflow[ 1 ];
  22583. style.overflowY = opts.overflow[ 2 ];
  22584. } );
  22585. }
  22586. // Implement show/hide animations
  22587. propTween = false;
  22588. for ( prop in orig ) {
  22589. // General show/hide setup for this element animation
  22590. if ( !propTween ) {
  22591. if ( dataShow ) {
  22592. if ( "hidden" in dataShow ) {
  22593. hidden = dataShow.hidden;
  22594. }
  22595. } else {
  22596. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  22597. }
  22598. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  22599. if ( toggle ) {
  22600. dataShow.hidden = !hidden;
  22601. }
  22602. // Show elements before animating them
  22603. if ( hidden ) {
  22604. showHide( [ elem ], true );
  22605. }
  22606. /* eslint-disable no-loop-func */
  22607. anim.done( function() {
  22608. /* eslint-enable no-loop-func */
  22609. // The final step of a "hide" animation is actually hiding the element
  22610. if ( !hidden ) {
  22611. showHide( [ elem ] );
  22612. }
  22613. dataPriv.remove( elem, "fxshow" );
  22614. for ( prop in orig ) {
  22615. jQuery.style( elem, prop, orig[ prop ] );
  22616. }
  22617. } );
  22618. }
  22619. // Per-property setup
  22620. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  22621. if ( !( prop in dataShow ) ) {
  22622. dataShow[ prop ] = propTween.start;
  22623. if ( hidden ) {
  22624. propTween.end = propTween.start;
  22625. propTween.start = 0;
  22626. }
  22627. }
  22628. }
  22629. }
  22630. function propFilter( props, specialEasing ) {
  22631. var index, name, easing, value, hooks;
  22632. // camelCase, specialEasing and expand cssHook pass
  22633. for ( index in props ) {
  22634. name = jQuery.camelCase( index );
  22635. easing = specialEasing[ name ];
  22636. value = props[ index ];
  22637. if ( Array.isArray( value ) ) {
  22638. easing = value[ 1 ];
  22639. value = props[ index ] = value[ 0 ];
  22640. }
  22641. if ( index !== name ) {
  22642. props[ name ] = value;
  22643. delete props[ index ];
  22644. }
  22645. hooks = jQuery.cssHooks[ name ];
  22646. if ( hooks && "expand" in hooks ) {
  22647. value = hooks.expand( value );
  22648. delete props[ name ];
  22649. // Not quite $.extend, this won't overwrite existing keys.
  22650. // Reusing 'index' because we have the correct "name"
  22651. for ( index in value ) {
  22652. if ( !( index in props ) ) {
  22653. props[ index ] = value[ index ];
  22654. specialEasing[ index ] = easing;
  22655. }
  22656. }
  22657. } else {
  22658. specialEasing[ name ] = easing;
  22659. }
  22660. }
  22661. }
  22662. function Animation( elem, properties, options ) {
  22663. var result,
  22664. stopped,
  22665. index = 0,
  22666. length = Animation.prefilters.length,
  22667. deferred = jQuery.Deferred().always( function() {
  22668. // Don't match elem in the :animated selector
  22669. delete tick.elem;
  22670. } ),
  22671. tick = function() {
  22672. if ( stopped ) {
  22673. return false;
  22674. }
  22675. var currentTime = fxNow || createFxNow(),
  22676. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  22677. // Support: Android 2.3 only
  22678. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  22679. temp = remaining / animation.duration || 0,
  22680. percent = 1 - temp,
  22681. index = 0,
  22682. length = animation.tweens.length;
  22683. for ( ; index < length; index++ ) {
  22684. animation.tweens[ index ].run( percent );
  22685. }
  22686. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  22687. // If there's more to do, yield
  22688. if ( percent < 1 && length ) {
  22689. return remaining;
  22690. }
  22691. // If this was an empty animation, synthesize a final progress notification
  22692. if ( !length ) {
  22693. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  22694. }
  22695. // Resolve the animation and report its conclusion
  22696. deferred.resolveWith( elem, [ animation ] );
  22697. return false;
  22698. },
  22699. animation = deferred.promise( {
  22700. elem: elem,
  22701. props: jQuery.extend( {}, properties ),
  22702. opts: jQuery.extend( true, {
  22703. specialEasing: {},
  22704. easing: jQuery.easing._default
  22705. }, options ),
  22706. originalProperties: properties,
  22707. originalOptions: options,
  22708. startTime: fxNow || createFxNow(),
  22709. duration: options.duration,
  22710. tweens: [],
  22711. createTween: function( prop, end ) {
  22712. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  22713. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  22714. animation.tweens.push( tween );
  22715. return tween;
  22716. },
  22717. stop: function( gotoEnd ) {
  22718. var index = 0,
  22719. // If we are going to the end, we want to run all the tweens
  22720. // otherwise we skip this part
  22721. length = gotoEnd ? animation.tweens.length : 0;
  22722. if ( stopped ) {
  22723. return this;
  22724. }
  22725. stopped = true;
  22726. for ( ; index < length; index++ ) {
  22727. animation.tweens[ index ].run( 1 );
  22728. }
  22729. // Resolve when we played the last frame; otherwise, reject
  22730. if ( gotoEnd ) {
  22731. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  22732. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  22733. } else {
  22734. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  22735. }
  22736. return this;
  22737. }
  22738. } ),
  22739. props = animation.props;
  22740. propFilter( props, animation.opts.specialEasing );
  22741. for ( ; index < length; index++ ) {
  22742. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  22743. if ( result ) {
  22744. if ( jQuery.isFunction( result.stop ) ) {
  22745. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  22746. jQuery.proxy( result.stop, result );
  22747. }
  22748. return result;
  22749. }
  22750. }
  22751. jQuery.map( props, createTween, animation );
  22752. if ( jQuery.isFunction( animation.opts.start ) ) {
  22753. animation.opts.start.call( elem, animation );
  22754. }
  22755. // Attach callbacks from options
  22756. animation
  22757. .progress( animation.opts.progress )
  22758. .done( animation.opts.done, animation.opts.complete )
  22759. .fail( animation.opts.fail )
  22760. .always( animation.opts.always );
  22761. jQuery.fx.timer(
  22762. jQuery.extend( tick, {
  22763. elem: elem,
  22764. anim: animation,
  22765. queue: animation.opts.queue
  22766. } )
  22767. );
  22768. return animation;
  22769. }
  22770. jQuery.Animation = jQuery.extend( Animation, {
  22771. tweeners: {
  22772. "*": [ function( prop, value ) {
  22773. var tween = this.createTween( prop, value );
  22774. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  22775. return tween;
  22776. } ]
  22777. },
  22778. tweener: function( props, callback ) {
  22779. if ( jQuery.isFunction( props ) ) {
  22780. callback = props;
  22781. props = [ "*" ];
  22782. } else {
  22783. props = props.match( rnothtmlwhite );
  22784. }
  22785. var prop,
  22786. index = 0,
  22787. length = props.length;
  22788. for ( ; index < length; index++ ) {
  22789. prop = props[ index ];
  22790. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  22791. Animation.tweeners[ prop ].unshift( callback );
  22792. }
  22793. },
  22794. prefilters: [ defaultPrefilter ],
  22795. prefilter: function( callback, prepend ) {
  22796. if ( prepend ) {
  22797. Animation.prefilters.unshift( callback );
  22798. } else {
  22799. Animation.prefilters.push( callback );
  22800. }
  22801. }
  22802. } );
  22803. jQuery.speed = function( speed, easing, fn ) {
  22804. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  22805. complete: fn || !fn && easing ||
  22806. jQuery.isFunction( speed ) && speed,
  22807. duration: speed,
  22808. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  22809. };
  22810. // Go to the end state if fx are off
  22811. if ( jQuery.fx.off ) {
  22812. opt.duration = 0;
  22813. } else {
  22814. if ( typeof opt.duration !== "number" ) {
  22815. if ( opt.duration in jQuery.fx.speeds ) {
  22816. opt.duration = jQuery.fx.speeds[ opt.duration ];
  22817. } else {
  22818. opt.duration = jQuery.fx.speeds._default;
  22819. }
  22820. }
  22821. }
  22822. // Normalize opt.queue - true/undefined/null -> "fx"
  22823. if ( opt.queue == null || opt.queue === true ) {
  22824. opt.queue = "fx";
  22825. }
  22826. // Queueing
  22827. opt.old = opt.complete;
  22828. opt.complete = function() {
  22829. if ( jQuery.isFunction( opt.old ) ) {
  22830. opt.old.call( this );
  22831. }
  22832. if ( opt.queue ) {
  22833. jQuery.dequeue( this, opt.queue );
  22834. }
  22835. };
  22836. return opt;
  22837. };
  22838. jQuery.fn.extend( {
  22839. fadeTo: function( speed, to, easing, callback ) {
  22840. // Show any hidden elements after setting opacity to 0
  22841. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  22842. // Animate to the value specified
  22843. .end().animate( { opacity: to }, speed, easing, callback );
  22844. },
  22845. animate: function( prop, speed, easing, callback ) {
  22846. var empty = jQuery.isEmptyObject( prop ),
  22847. optall = jQuery.speed( speed, easing, callback ),
  22848. doAnimation = function() {
  22849. // Operate on a copy of prop so per-property easing won't be lost
  22850. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  22851. // Empty animations, or finishing resolves immediately
  22852. if ( empty || dataPriv.get( this, "finish" ) ) {
  22853. anim.stop( true );
  22854. }
  22855. };
  22856. doAnimation.finish = doAnimation;
  22857. return empty || optall.queue === false ?
  22858. this.each( doAnimation ) :
  22859. this.queue( optall.queue, doAnimation );
  22860. },
  22861. stop: function( type, clearQueue, gotoEnd ) {
  22862. var stopQueue = function( hooks ) {
  22863. var stop = hooks.stop;
  22864. delete hooks.stop;
  22865. stop( gotoEnd );
  22866. };
  22867. if ( typeof type !== "string" ) {
  22868. gotoEnd = clearQueue;
  22869. clearQueue = type;
  22870. type = undefined;
  22871. }
  22872. if ( clearQueue && type !== false ) {
  22873. this.queue( type || "fx", [] );
  22874. }
  22875. return this.each( function() {
  22876. var dequeue = true,
  22877. index = type != null && type + "queueHooks",
  22878. timers = jQuery.timers,
  22879. data = dataPriv.get( this );
  22880. if ( index ) {
  22881. if ( data[ index ] && data[ index ].stop ) {
  22882. stopQueue( data[ index ] );
  22883. }
  22884. } else {
  22885. for ( index in data ) {
  22886. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  22887. stopQueue( data[ index ] );
  22888. }
  22889. }
  22890. }
  22891. for ( index = timers.length; index--; ) {
  22892. if ( timers[ index ].elem === this &&
  22893. ( type == null || timers[ index ].queue === type ) ) {
  22894. timers[ index ].anim.stop( gotoEnd );
  22895. dequeue = false;
  22896. timers.splice( index, 1 );
  22897. }
  22898. }
  22899. // Start the next in the queue if the last step wasn't forced.
  22900. // Timers currently will call their complete callbacks, which
  22901. // will dequeue but only if they were gotoEnd.
  22902. if ( dequeue || !gotoEnd ) {
  22903. jQuery.dequeue( this, type );
  22904. }
  22905. } );
  22906. },
  22907. finish: function( type ) {
  22908. if ( type !== false ) {
  22909. type = type || "fx";
  22910. }
  22911. return this.each( function() {
  22912. var index,
  22913. data = dataPriv.get( this ),
  22914. queue = data[ type + "queue" ],
  22915. hooks = data[ type + "queueHooks" ],
  22916. timers = jQuery.timers,
  22917. length = queue ? queue.length : 0;
  22918. // Enable finishing flag on private data
  22919. data.finish = true;
  22920. // Empty the queue first
  22921. jQuery.queue( this, type, [] );
  22922. if ( hooks && hooks.stop ) {
  22923. hooks.stop.call( this, true );
  22924. }
  22925. // Look for any active animations, and finish them
  22926. for ( index = timers.length; index--; ) {
  22927. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  22928. timers[ index ].anim.stop( true );
  22929. timers.splice( index, 1 );
  22930. }
  22931. }
  22932. // Look for any animations in the old queue and finish them
  22933. for ( index = 0; index < length; index++ ) {
  22934. if ( queue[ index ] && queue[ index ].finish ) {
  22935. queue[ index ].finish.call( this );
  22936. }
  22937. }
  22938. // Turn off finishing flag
  22939. delete data.finish;
  22940. } );
  22941. }
  22942. } );
  22943. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  22944. var cssFn = jQuery.fn[ name ];
  22945. jQuery.fn[ name ] = function( speed, easing, callback ) {
  22946. return speed == null || typeof speed === "boolean" ?
  22947. cssFn.apply( this, arguments ) :
  22948. this.animate( genFx( name, true ), speed, easing, callback );
  22949. };
  22950. } );
  22951. // Generate shortcuts for custom animations
  22952. jQuery.each( {
  22953. slideDown: genFx( "show" ),
  22954. slideUp: genFx( "hide" ),
  22955. slideToggle: genFx( "toggle" ),
  22956. fadeIn: { opacity: "show" },
  22957. fadeOut: { opacity: "hide" },
  22958. fadeToggle: { opacity: "toggle" }
  22959. }, function( name, props ) {
  22960. jQuery.fn[ name ] = function( speed, easing, callback ) {
  22961. return this.animate( props, speed, easing, callback );
  22962. };
  22963. } );
  22964. jQuery.timers = [];
  22965. jQuery.fx.tick = function() {
  22966. var timer,
  22967. i = 0,
  22968. timers = jQuery.timers;
  22969. fxNow = jQuery.now();
  22970. for ( ; i < timers.length; i++ ) {
  22971. timer = timers[ i ];
  22972. // Run the timer and safely remove it when done (allowing for external removal)
  22973. if ( !timer() && timers[ i ] === timer ) {
  22974. timers.splice( i--, 1 );
  22975. }
  22976. }
  22977. if ( !timers.length ) {
  22978. jQuery.fx.stop();
  22979. }
  22980. fxNow = undefined;
  22981. };
  22982. jQuery.fx.timer = function( timer ) {
  22983. jQuery.timers.push( timer );
  22984. jQuery.fx.start();
  22985. };
  22986. jQuery.fx.interval = 13;
  22987. jQuery.fx.start = function() {
  22988. if ( inProgress ) {
  22989. return;
  22990. }
  22991. inProgress = true;
  22992. schedule();
  22993. };
  22994. jQuery.fx.stop = function() {
  22995. inProgress = null;
  22996. };
  22997. jQuery.fx.speeds = {
  22998. slow: 600,
  22999. fast: 200,
  23000. // Default speed
  23001. _default: 400
  23002. };
  23003. // Based off of the plugin by Clint Helfers, with permission.
  23004. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  23005. jQuery.fn.delay = function( time, type ) {
  23006. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  23007. type = type || "fx";
  23008. return this.queue( type, function( next, hooks ) {
  23009. var timeout = window.setTimeout( next, time );
  23010. hooks.stop = function() {
  23011. window.clearTimeout( timeout );
  23012. };
  23013. } );
  23014. };
  23015. ( function() {
  23016. var input = document.createElement( "input" ),
  23017. select = document.createElement( "select" ),
  23018. opt = select.appendChild( document.createElement( "option" ) );
  23019. input.type = "checkbox";
  23020. // Support: Android <=4.3 only
  23021. // Default value for a checkbox should be "on"
  23022. support.checkOn = input.value !== "";
  23023. // Support: IE <=11 only
  23024. // Must access selectedIndex to make default options select
  23025. support.optSelected = opt.selected;
  23026. // Support: IE <=11 only
  23027. // An input loses its value after becoming a radio
  23028. input = document.createElement( "input" );
  23029. input.value = "t";
  23030. input.type = "radio";
  23031. support.radioValue = input.value === "t";
  23032. } )();
  23033. var boolHook,
  23034. attrHandle = jQuery.expr.attrHandle;
  23035. jQuery.fn.extend( {
  23036. attr: function( name, value ) {
  23037. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  23038. },
  23039. removeAttr: function( name ) {
  23040. return this.each( function() {
  23041. jQuery.removeAttr( this, name );
  23042. } );
  23043. }
  23044. } );
  23045. jQuery.extend( {
  23046. attr: function( elem, name, value ) {
  23047. var ret, hooks,
  23048. nType = elem.nodeType;
  23049. // Don't get/set attributes on text, comment and attribute nodes
  23050. if ( nType === 3 || nType === 8 || nType === 2 ) {
  23051. return;
  23052. }
  23053. // Fallback to prop when attributes are not supported
  23054. if ( typeof elem.getAttribute === "undefined" ) {
  23055. return jQuery.prop( elem, name, value );
  23056. }
  23057. // Attribute hooks are determined by the lowercase version
  23058. // Grab necessary hook if one is defined
  23059. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  23060. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  23061. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  23062. }
  23063. if ( value !== undefined ) {
  23064. if ( value === null ) {
  23065. jQuery.removeAttr( elem, name );
  23066. return;
  23067. }
  23068. if ( hooks && "set" in hooks &&
  23069. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  23070. return ret;
  23071. }
  23072. elem.setAttribute( name, value + "" );
  23073. return value;
  23074. }
  23075. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  23076. return ret;
  23077. }
  23078. ret = jQuery.find.attr( elem, name );
  23079. // Non-existent attributes return null, we normalize to undefined
  23080. return ret == null ? undefined : ret;
  23081. },
  23082. attrHooks: {
  23083. type: {
  23084. set: function( elem, value ) {
  23085. if ( !support.radioValue && value === "radio" &&
  23086. nodeName( elem, "input" ) ) {
  23087. var val = elem.value;
  23088. elem.setAttribute( "type", value );
  23089. if ( val ) {
  23090. elem.value = val;
  23091. }
  23092. return value;
  23093. }
  23094. }
  23095. }
  23096. },
  23097. removeAttr: function( elem, value ) {
  23098. var name,
  23099. i = 0,
  23100. // Attribute names can contain non-HTML whitespace characters
  23101. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  23102. attrNames = value && value.match( rnothtmlwhite );
  23103. if ( attrNames && elem.nodeType === 1 ) {
  23104. while ( ( name = attrNames[ i++ ] ) ) {
  23105. elem.removeAttribute( name );
  23106. }
  23107. }
  23108. }
  23109. } );
  23110. // Hooks for boolean attributes
  23111. boolHook = {
  23112. set: function( elem, value, name ) {
  23113. if ( value === false ) {
  23114. // Remove boolean attributes when set to false
  23115. jQuery.removeAttr( elem, name );
  23116. } else {
  23117. elem.setAttribute( name, name );
  23118. }
  23119. return name;
  23120. }
  23121. };
  23122. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  23123. var getter = attrHandle[ name ] || jQuery.find.attr;
  23124. attrHandle[ name ] = function( elem, name, isXML ) {
  23125. var ret, handle,
  23126. lowercaseName = name.toLowerCase();
  23127. if ( !isXML ) {
  23128. // Avoid an infinite loop by temporarily removing this function from the getter
  23129. handle = attrHandle[ lowercaseName ];
  23130. attrHandle[ lowercaseName ] = ret;
  23131. ret = getter( elem, name, isXML ) != null ?
  23132. lowercaseName :
  23133. null;
  23134. attrHandle[ lowercaseName ] = handle;
  23135. }
  23136. return ret;
  23137. };
  23138. } );
  23139. var rfocusable = /^(?:input|select|textarea|button)$/i,
  23140. rclickable = /^(?:a|area)$/i;
  23141. jQuery.fn.extend( {
  23142. prop: function( name, value ) {
  23143. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  23144. },
  23145. removeProp: function( name ) {
  23146. return this.each( function() {
  23147. delete this[ jQuery.propFix[ name ] || name ];
  23148. } );
  23149. }
  23150. } );
  23151. jQuery.extend( {
  23152. prop: function( elem, name, value ) {
  23153. var ret, hooks,
  23154. nType = elem.nodeType;
  23155. // Don't get/set properties on text, comment and attribute nodes
  23156. if ( nType === 3 || nType === 8 || nType === 2 ) {
  23157. return;
  23158. }
  23159. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  23160. // Fix name and attach hooks
  23161. name = jQuery.propFix[ name ] || name;
  23162. hooks = jQuery.propHooks[ name ];
  23163. }
  23164. if ( value !== undefined ) {
  23165. if ( hooks && "set" in hooks &&
  23166. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  23167. return ret;
  23168. }
  23169. return ( elem[ name ] = value );
  23170. }
  23171. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  23172. return ret;
  23173. }
  23174. return elem[ name ];
  23175. },
  23176. propHooks: {
  23177. tabIndex: {
  23178. get: function( elem ) {
  23179. // Support: IE <=9 - 11 only
  23180. // elem.tabIndex doesn't always return the
  23181. // correct value when it hasn't been explicitly set
  23182. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  23183. // Use proper attribute retrieval(#12072)
  23184. var tabindex = jQuery.find.attr( elem, "tabindex" );
  23185. if ( tabindex ) {
  23186. return parseInt( tabindex, 10 );
  23187. }
  23188. if (
  23189. rfocusable.test( elem.nodeName ) ||
  23190. rclickable.test( elem.nodeName ) &&
  23191. elem.href
  23192. ) {
  23193. return 0;
  23194. }
  23195. return -1;
  23196. }
  23197. }
  23198. },
  23199. propFix: {
  23200. "for": "htmlFor",
  23201. "class": "className"
  23202. }
  23203. } );
  23204. // Support: IE <=11 only
  23205. // Accessing the selectedIndex property
  23206. // forces the browser to respect setting selected
  23207. // on the option
  23208. // The getter ensures a default option is selected
  23209. // when in an optgroup
  23210. // eslint rule "no-unused-expressions" is disabled for this code
  23211. // since it considers such accessions noop
  23212. if ( !support.optSelected ) {
  23213. jQuery.propHooks.selected = {
  23214. get: function( elem ) {
  23215. /* eslint no-unused-expressions: "off" */
  23216. var parent = elem.parentNode;
  23217. if ( parent && parent.parentNode ) {
  23218. parent.parentNode.selectedIndex;
  23219. }
  23220. return null;
  23221. },
  23222. set: function( elem ) {
  23223. /* eslint no-unused-expressions: "off" */
  23224. var parent = elem.parentNode;
  23225. if ( parent ) {
  23226. parent.selectedIndex;
  23227. if ( parent.parentNode ) {
  23228. parent.parentNode.selectedIndex;
  23229. }
  23230. }
  23231. }
  23232. };
  23233. }
  23234. jQuery.each( [
  23235. "tabIndex",
  23236. "readOnly",
  23237. "maxLength",
  23238. "cellSpacing",
  23239. "cellPadding",
  23240. "rowSpan",
  23241. "colSpan",
  23242. "useMap",
  23243. "frameBorder",
  23244. "contentEditable"
  23245. ], function() {
  23246. jQuery.propFix[ this.toLowerCase() ] = this;
  23247. } );
  23248. // Strip and collapse whitespace according to HTML spec
  23249. // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
  23250. function stripAndCollapse( value ) {
  23251. var tokens = value.match( rnothtmlwhite ) || [];
  23252. return tokens.join( " " );
  23253. }
  23254. function getClass( elem ) {
  23255. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  23256. }
  23257. jQuery.fn.extend( {
  23258. addClass: function( value ) {
  23259. var classes, elem, cur, curValue, clazz, j, finalValue,
  23260. i = 0;
  23261. if ( jQuery.isFunction( value ) ) {
  23262. return this.each( function( j ) {
  23263. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  23264. } );
  23265. }
  23266. if ( typeof value === "string" && value ) {
  23267. classes = value.match( rnothtmlwhite ) || [];
  23268. while ( ( elem = this[ i++ ] ) ) {
  23269. curValue = getClass( elem );
  23270. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  23271. if ( cur ) {
  23272. j = 0;
  23273. while ( ( clazz = classes[ j++ ] ) ) {
  23274. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  23275. cur += clazz + " ";
  23276. }
  23277. }
  23278. // Only assign if different to avoid unneeded rendering.
  23279. finalValue = stripAndCollapse( cur );
  23280. if ( curValue !== finalValue ) {
  23281. elem.setAttribute( "class", finalValue );
  23282. }
  23283. }
  23284. }
  23285. }
  23286. return this;
  23287. },
  23288. removeClass: function( value ) {
  23289. var classes, elem, cur, curValue, clazz, j, finalValue,
  23290. i = 0;
  23291. if ( jQuery.isFunction( value ) ) {
  23292. return this.each( function( j ) {
  23293. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  23294. } );
  23295. }
  23296. if ( !arguments.length ) {
  23297. return this.attr( "class", "" );
  23298. }
  23299. if ( typeof value === "string" && value ) {
  23300. classes = value.match( rnothtmlwhite ) || [];
  23301. while ( ( elem = this[ i++ ] ) ) {
  23302. curValue = getClass( elem );
  23303. // This expression is here for better compressibility (see addClass)
  23304. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  23305. if ( cur ) {
  23306. j = 0;
  23307. while ( ( clazz = classes[ j++ ] ) ) {
  23308. // Remove *all* instances
  23309. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  23310. cur = cur.replace( " " + clazz + " ", " " );
  23311. }
  23312. }
  23313. // Only assign if different to avoid unneeded rendering.
  23314. finalValue = stripAndCollapse( cur );
  23315. if ( curValue !== finalValue ) {
  23316. elem.setAttribute( "class", finalValue );
  23317. }
  23318. }
  23319. }
  23320. }
  23321. return this;
  23322. },
  23323. toggleClass: function( value, stateVal ) {
  23324. var type = typeof value;
  23325. if ( typeof stateVal === "boolean" && type === "string" ) {
  23326. return stateVal ? this.addClass( value ) : this.removeClass( value );
  23327. }
  23328. if ( jQuery.isFunction( value ) ) {
  23329. return this.each( function( i ) {
  23330. jQuery( this ).toggleClass(
  23331. value.call( this, i, getClass( this ), stateVal ),
  23332. stateVal
  23333. );
  23334. } );
  23335. }
  23336. return this.each( function() {
  23337. var className, i, self, classNames;
  23338. if ( type === "string" ) {
  23339. // Toggle individual class names
  23340. i = 0;
  23341. self = jQuery( this );
  23342. classNames = value.match( rnothtmlwhite ) || [];
  23343. while ( ( className = classNames[ i++ ] ) ) {
  23344. // Check each className given, space separated list
  23345. if ( self.hasClass( className ) ) {
  23346. self.removeClass( className );
  23347. } else {
  23348. self.addClass( className );
  23349. }
  23350. }
  23351. // Toggle whole class name
  23352. } else if ( value === undefined || type === "boolean" ) {
  23353. className = getClass( this );
  23354. if ( className ) {
  23355. // Store className if set
  23356. dataPriv.set( this, "__className__", className );
  23357. }
  23358. // If the element has a class name or if we're passed `false`,
  23359. // then remove the whole classname (if there was one, the above saved it).
  23360. // Otherwise bring back whatever was previously saved (if anything),
  23361. // falling back to the empty string if nothing was stored.
  23362. if ( this.setAttribute ) {
  23363. this.setAttribute( "class",
  23364. className || value === false ?
  23365. "" :
  23366. dataPriv.get( this, "__className__" ) || ""
  23367. );
  23368. }
  23369. }
  23370. } );
  23371. },
  23372. hasClass: function( selector ) {
  23373. var className, elem,
  23374. i = 0;
  23375. className = " " + selector + " ";
  23376. while ( ( elem = this[ i++ ] ) ) {
  23377. if ( elem.nodeType === 1 &&
  23378. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  23379. return true;
  23380. }
  23381. }
  23382. return false;
  23383. }
  23384. } );
  23385. var rreturn = /\r/g;
  23386. jQuery.fn.extend( {
  23387. val: function( value ) {
  23388. var hooks, ret, isFunction,
  23389. elem = this[ 0 ];
  23390. if ( !arguments.length ) {
  23391. if ( elem ) {
  23392. hooks = jQuery.valHooks[ elem.type ] ||
  23393. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  23394. if ( hooks &&
  23395. "get" in hooks &&
  23396. ( ret = hooks.get( elem, "value" ) ) !== undefined
  23397. ) {
  23398. return ret;
  23399. }
  23400. ret = elem.value;
  23401. // Handle most common string cases
  23402. if ( typeof ret === "string" ) {
  23403. return ret.replace( rreturn, "" );
  23404. }
  23405. // Handle cases where value is null/undef or number
  23406. return ret == null ? "" : ret;
  23407. }
  23408. return;
  23409. }
  23410. isFunction = jQuery.isFunction( value );
  23411. return this.each( function( i ) {
  23412. var val;
  23413. if ( this.nodeType !== 1 ) {
  23414. return;
  23415. }
  23416. if ( isFunction ) {
  23417. val = value.call( this, i, jQuery( this ).val() );
  23418. } else {
  23419. val = value;
  23420. }
  23421. // Treat null/undefined as ""; convert numbers to string
  23422. if ( val == null ) {
  23423. val = "";
  23424. } else if ( typeof val === "number" ) {
  23425. val += "";
  23426. } else if ( Array.isArray( val ) ) {
  23427. val = jQuery.map( val, function( value ) {
  23428. return value == null ? "" : value + "";
  23429. } );
  23430. }
  23431. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  23432. // If set returns undefined, fall back to normal setting
  23433. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  23434. this.value = val;
  23435. }
  23436. } );
  23437. }
  23438. } );
  23439. jQuery.extend( {
  23440. valHooks: {
  23441. option: {
  23442. get: function( elem ) {
  23443. var val = jQuery.find.attr( elem, "value" );
  23444. return val != null ?
  23445. val :
  23446. // Support: IE <=10 - 11 only
  23447. // option.text throws exceptions (#14686, #14858)
  23448. // Strip and collapse whitespace
  23449. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  23450. stripAndCollapse( jQuery.text( elem ) );
  23451. }
  23452. },
  23453. select: {
  23454. get: function( elem ) {
  23455. var value, option, i,
  23456. options = elem.options,
  23457. index = elem.selectedIndex,
  23458. one = elem.type === "select-one",
  23459. values = one ? null : [],
  23460. max = one ? index + 1 : options.length;
  23461. if ( index < 0 ) {
  23462. i = max;
  23463. } else {
  23464. i = one ? index : 0;
  23465. }
  23466. // Loop through all the selected options
  23467. for ( ; i < max; i++ ) {
  23468. option = options[ i ];
  23469. // Support: IE <=9 only
  23470. // IE8-9 doesn't update selected after form reset (#2551)
  23471. if ( ( option.selected || i === index ) &&
  23472. // Don't return options that are disabled or in a disabled optgroup
  23473. !option.disabled &&
  23474. ( !option.parentNode.disabled ||
  23475. !nodeName( option.parentNode, "optgroup" ) ) ) {
  23476. // Get the specific value for the option
  23477. value = jQuery( option ).val();
  23478. // We don't need an array for one selects
  23479. if ( one ) {
  23480. return value;
  23481. }
  23482. // Multi-Selects return an array
  23483. values.push( value );
  23484. }
  23485. }
  23486. return values;
  23487. },
  23488. set: function( elem, value ) {
  23489. var optionSet, option,
  23490. options = elem.options,
  23491. values = jQuery.makeArray( value ),
  23492. i = options.length;
  23493. while ( i-- ) {
  23494. option = options[ i ];
  23495. /* eslint-disable no-cond-assign */
  23496. if ( option.selected =
  23497. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  23498. ) {
  23499. optionSet = true;
  23500. }
  23501. /* eslint-enable no-cond-assign */
  23502. }
  23503. // Force browsers to behave consistently when non-matching value is set
  23504. if ( !optionSet ) {
  23505. elem.selectedIndex = -1;
  23506. }
  23507. return values;
  23508. }
  23509. }
  23510. }
  23511. } );
  23512. // Radios and checkboxes getter/setter
  23513. jQuery.each( [ "radio", "checkbox" ], function() {
  23514. jQuery.valHooks[ this ] = {
  23515. set: function( elem, value ) {
  23516. if ( Array.isArray( value ) ) {
  23517. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  23518. }
  23519. }
  23520. };
  23521. if ( !support.checkOn ) {
  23522. jQuery.valHooks[ this ].get = function( elem ) {
  23523. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  23524. };
  23525. }
  23526. } );
  23527. // Return jQuery for attributes-only inclusion
  23528. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
  23529. jQuery.extend( jQuery.event, {
  23530. trigger: function( event, data, elem, onlyHandlers ) {
  23531. var i, cur, tmp, bubbleType, ontype, handle, special,
  23532. eventPath = [ elem || document ],
  23533. type = hasOwn.call( event, "type" ) ? event.type : event,
  23534. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  23535. cur = tmp = elem = elem || document;
  23536. // Don't do events on text and comment nodes
  23537. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  23538. return;
  23539. }
  23540. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  23541. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  23542. return;
  23543. }
  23544. if ( type.indexOf( "." ) > -1 ) {
  23545. // Namespaced trigger; create a regexp to match event type in handle()
  23546. namespaces = type.split( "." );
  23547. type = namespaces.shift();
  23548. namespaces.sort();
  23549. }
  23550. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  23551. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  23552. event = event[ jQuery.expando ] ?
  23553. event :
  23554. new jQuery.Event( type, typeof event === "object" && event );
  23555. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  23556. event.isTrigger = onlyHandlers ? 2 : 3;
  23557. event.namespace = namespaces.join( "." );
  23558. event.rnamespace = event.namespace ?
  23559. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  23560. null;
  23561. // Clean up the event in case it is being reused
  23562. event.result = undefined;
  23563. if ( !event.target ) {
  23564. event.target = elem;
  23565. }
  23566. // Clone any incoming data and prepend the event, creating the handler arg list
  23567. data = data == null ?
  23568. [ event ] :
  23569. jQuery.makeArray( data, [ event ] );
  23570. // Allow special events to draw outside the lines
  23571. special = jQuery.event.special[ type ] || {};
  23572. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  23573. return;
  23574. }
  23575. // Determine event propagation path in advance, per W3C events spec (#9951)
  23576. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  23577. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  23578. bubbleType = special.delegateType || type;
  23579. if ( !rfocusMorph.test( bubbleType + type ) ) {
  23580. cur = cur.parentNode;
  23581. }
  23582. for ( ; cur; cur = cur.parentNode ) {
  23583. eventPath.push( cur );
  23584. tmp = cur;
  23585. }
  23586. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  23587. if ( tmp === ( elem.ownerDocument || document ) ) {
  23588. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  23589. }
  23590. }
  23591. // Fire handlers on the event path
  23592. i = 0;
  23593. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  23594. event.type = i > 1 ?
  23595. bubbleType :
  23596. special.bindType || type;
  23597. // jQuery handler
  23598. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  23599. dataPriv.get( cur, "handle" );
  23600. if ( handle ) {
  23601. handle.apply( cur, data );
  23602. }
  23603. // Native handler
  23604. handle = ontype && cur[ ontype ];
  23605. if ( handle && handle.apply && acceptData( cur ) ) {
  23606. event.result = handle.apply( cur, data );
  23607. if ( event.result === false ) {
  23608. event.preventDefault();
  23609. }
  23610. }
  23611. }
  23612. event.type = type;
  23613. // If nobody prevented the default action, do it now
  23614. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  23615. if ( ( !special._default ||
  23616. special._default.apply( eventPath.pop(), data ) === false ) &&
  23617. acceptData( elem ) ) {
  23618. // Call a native DOM method on the target with the same name as the event.
  23619. // Don't do default actions on window, that's where global variables be (#6170)
  23620. if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
  23621. // Don't re-trigger an onFOO event when we call its FOO() method
  23622. tmp = elem[ ontype ];
  23623. if ( tmp ) {
  23624. elem[ ontype ] = null;
  23625. }
  23626. // Prevent re-triggering of the same event, since we already bubbled it above
  23627. jQuery.event.triggered = type;
  23628. elem[ type ]();
  23629. jQuery.event.triggered = undefined;
  23630. if ( tmp ) {
  23631. elem[ ontype ] = tmp;
  23632. }
  23633. }
  23634. }
  23635. }
  23636. return event.result;
  23637. },
  23638. // Piggyback on a donor event to simulate a different one
  23639. // Used only for `focus(in | out)` events
  23640. simulate: function( type, elem, event ) {
  23641. var e = jQuery.extend(
  23642. new jQuery.Event(),
  23643. event,
  23644. {
  23645. type: type,
  23646. isSimulated: true
  23647. }
  23648. );
  23649. jQuery.event.trigger( e, null, elem );
  23650. }
  23651. } );
  23652. jQuery.fn.extend( {
  23653. trigger: function( type, data ) {
  23654. return this.each( function() {
  23655. jQuery.event.trigger( type, data, this );
  23656. } );
  23657. },
  23658. triggerHandler: function( type, data ) {
  23659. var elem = this[ 0 ];
  23660. if ( elem ) {
  23661. return jQuery.event.trigger( type, data, elem, true );
  23662. }
  23663. }
  23664. } );
  23665. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  23666. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  23667. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  23668. function( i, name ) {
  23669. // Handle event binding
  23670. jQuery.fn[ name ] = function( data, fn ) {
  23671. return arguments.length > 0 ?
  23672. this.on( name, null, data, fn ) :
  23673. this.trigger( name );
  23674. };
  23675. } );
  23676. jQuery.fn.extend( {
  23677. hover: function( fnOver, fnOut ) {
  23678. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  23679. }
  23680. } );
  23681. support.focusin = "onfocusin" in window;
  23682. // Support: Firefox <=44
  23683. // Firefox doesn't have focus(in | out) events
  23684. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  23685. //
  23686. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  23687. // focus(in | out) events fire after focus & blur events,
  23688. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  23689. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  23690. if ( !support.focusin ) {
  23691. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  23692. // Attach a single capturing handler on the document while someone wants focusin/focusout
  23693. var handler = function( event ) {
  23694. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  23695. };
  23696. jQuery.event.special[ fix ] = {
  23697. setup: function() {
  23698. var doc = this.ownerDocument || this,
  23699. attaches = dataPriv.access( doc, fix );
  23700. if ( !attaches ) {
  23701. doc.addEventListener( orig, handler, true );
  23702. }
  23703. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  23704. },
  23705. teardown: function() {
  23706. var doc = this.ownerDocument || this,
  23707. attaches = dataPriv.access( doc, fix ) - 1;
  23708. if ( !attaches ) {
  23709. doc.removeEventListener( orig, handler, true );
  23710. dataPriv.remove( doc, fix );
  23711. } else {
  23712. dataPriv.access( doc, fix, attaches );
  23713. }
  23714. }
  23715. };
  23716. } );
  23717. }
  23718. var location = window.location;
  23719. var nonce = jQuery.now();
  23720. var rquery = ( /\?/ );
  23721. // Cross-browser xml parsing
  23722. jQuery.parseXML = function( data ) {
  23723. var xml;
  23724. if ( !data || typeof data !== "string" ) {
  23725. return null;
  23726. }
  23727. // Support: IE 9 - 11 only
  23728. // IE throws on parseFromString with invalid input.
  23729. try {
  23730. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  23731. } catch ( e ) {
  23732. xml = undefined;
  23733. }
  23734. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  23735. jQuery.error( "Invalid XML: " + data );
  23736. }
  23737. return xml;
  23738. };
  23739. var
  23740. rbracket = /\[\]$/,
  23741. rCRLF = /\r?\n/g,
  23742. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  23743. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  23744. function buildParams( prefix, obj, traditional, add ) {
  23745. var name;
  23746. if ( Array.isArray( obj ) ) {
  23747. // Serialize array item.
  23748. jQuery.each( obj, function( i, v ) {
  23749. if ( traditional || rbracket.test( prefix ) ) {
  23750. // Treat each array item as a scalar.
  23751. add( prefix, v );
  23752. } else {
  23753. // Item is non-scalar (array or object), encode its numeric index.
  23754. buildParams(
  23755. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  23756. v,
  23757. traditional,
  23758. add
  23759. );
  23760. }
  23761. } );
  23762. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  23763. // Serialize object item.
  23764. for ( name in obj ) {
  23765. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  23766. }
  23767. } else {
  23768. // Serialize scalar item.
  23769. add( prefix, obj );
  23770. }
  23771. }
  23772. // Serialize an array of form elements or a set of
  23773. // key/values into a query string
  23774. jQuery.param = function( a, traditional ) {
  23775. var prefix,
  23776. s = [],
  23777. add = function( key, valueOrFunction ) {
  23778. // If value is a function, invoke it and use its return value
  23779. var value = jQuery.isFunction( valueOrFunction ) ?
  23780. valueOrFunction() :
  23781. valueOrFunction;
  23782. s[ s.length ] = encodeURIComponent( key ) + "=" +
  23783. encodeURIComponent( value == null ? "" : value );
  23784. };
  23785. // If an array was passed in, assume that it is an array of form elements.
  23786. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  23787. // Serialize the form elements
  23788. jQuery.each( a, function() {
  23789. add( this.name, this.value );
  23790. } );
  23791. } else {
  23792. // If traditional, encode the "old" way (the way 1.3.2 or older
  23793. // did it), otherwise encode params recursively.
  23794. for ( prefix in a ) {
  23795. buildParams( prefix, a[ prefix ], traditional, add );
  23796. }
  23797. }
  23798. // Return the resulting serialization
  23799. return s.join( "&" );
  23800. };
  23801. jQuery.fn.extend( {
  23802. serialize: function() {
  23803. return jQuery.param( this.serializeArray() );
  23804. },
  23805. serializeArray: function() {
  23806. return this.map( function() {
  23807. // Can add propHook for "elements" to filter or add form elements
  23808. var elements = jQuery.prop( this, "elements" );
  23809. return elements ? jQuery.makeArray( elements ) : this;
  23810. } )
  23811. .filter( function() {
  23812. var type = this.type;
  23813. // Use .is( ":disabled" ) so that fieldset[disabled] works
  23814. return this.name && !jQuery( this ).is( ":disabled" ) &&
  23815. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  23816. ( this.checked || !rcheckableType.test( type ) );
  23817. } )
  23818. .map( function( i, elem ) {
  23819. var val = jQuery( this ).val();
  23820. if ( val == null ) {
  23821. return null;
  23822. }
  23823. if ( Array.isArray( val ) ) {
  23824. return jQuery.map( val, function( val ) {
  23825. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  23826. } );
  23827. }
  23828. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  23829. } ).get();
  23830. }
  23831. } );
  23832. var
  23833. r20 = /%20/g,
  23834. rhash = /#.*$/,
  23835. rantiCache = /([?&])_=[^&]*/,
  23836. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  23837. // #7653, #8125, #8152: local protocol detection
  23838. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  23839. rnoContent = /^(?:GET|HEAD)$/,
  23840. rprotocol = /^\/\//,
  23841. /* Prefilters
  23842. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  23843. * 2) These are called:
  23844. * - BEFORE asking for a transport
  23845. * - AFTER param serialization (s.data is a string if s.processData is true)
  23846. * 3) key is the dataType
  23847. * 4) the catchall symbol "*" can be used
  23848. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  23849. */
  23850. prefilters = {},
  23851. /* Transports bindings
  23852. * 1) key is the dataType
  23853. * 2) the catchall symbol "*" can be used
  23854. * 3) selection will start with transport dataType and THEN go to "*" if needed
  23855. */
  23856. transports = {},
  23857. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  23858. allTypes = "*/".concat( "*" ),
  23859. // Anchor tag for parsing the document origin
  23860. originAnchor = document.createElement( "a" );
  23861. originAnchor.href = location.href;
  23862. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  23863. function addToPrefiltersOrTransports( structure ) {
  23864. // dataTypeExpression is optional and defaults to "*"
  23865. return function( dataTypeExpression, func ) {
  23866. if ( typeof dataTypeExpression !== "string" ) {
  23867. func = dataTypeExpression;
  23868. dataTypeExpression = "*";
  23869. }
  23870. var dataType,
  23871. i = 0,
  23872. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  23873. if ( jQuery.isFunction( func ) ) {
  23874. // For each dataType in the dataTypeExpression
  23875. while ( ( dataType = dataTypes[ i++ ] ) ) {
  23876. // Prepend if requested
  23877. if ( dataType[ 0 ] === "+" ) {
  23878. dataType = dataType.slice( 1 ) || "*";
  23879. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  23880. // Otherwise append
  23881. } else {
  23882. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  23883. }
  23884. }
  23885. }
  23886. };
  23887. }
  23888. // Base inspection function for prefilters and transports
  23889. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  23890. var inspected = {},
  23891. seekingTransport = ( structure === transports );
  23892. function inspect( dataType ) {
  23893. var selected;
  23894. inspected[ dataType ] = true;
  23895. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  23896. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  23897. if ( typeof dataTypeOrTransport === "string" &&
  23898. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  23899. options.dataTypes.unshift( dataTypeOrTransport );
  23900. inspect( dataTypeOrTransport );
  23901. return false;
  23902. } else if ( seekingTransport ) {
  23903. return !( selected = dataTypeOrTransport );
  23904. }
  23905. } );
  23906. return selected;
  23907. }
  23908. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  23909. }
  23910. // A special extend for ajax options
  23911. // that takes "flat" options (not to be deep extended)
  23912. // Fixes #9887
  23913. function ajaxExtend( target, src ) {
  23914. var key, deep,
  23915. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  23916. for ( key in src ) {
  23917. if ( src[ key ] !== undefined ) {
  23918. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  23919. }
  23920. }
  23921. if ( deep ) {
  23922. jQuery.extend( true, target, deep );
  23923. }
  23924. return target;
  23925. }
  23926. /* Handles responses to an ajax request:
  23927. * - finds the right dataType (mediates between content-type and expected dataType)
  23928. * - returns the corresponding response
  23929. */
  23930. function ajaxHandleResponses( s, jqXHR, responses ) {
  23931. var ct, type, finalDataType, firstDataType,
  23932. contents = s.contents,
  23933. dataTypes = s.dataTypes;
  23934. // Remove auto dataType and get content-type in the process
  23935. while ( dataTypes[ 0 ] === "*" ) {
  23936. dataTypes.shift();
  23937. if ( ct === undefined ) {
  23938. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  23939. }
  23940. }
  23941. // Check if we're dealing with a known content-type
  23942. if ( ct ) {
  23943. for ( type in contents ) {
  23944. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  23945. dataTypes.unshift( type );
  23946. break;
  23947. }
  23948. }
  23949. }
  23950. // Check to see if we have a response for the expected dataType
  23951. if ( dataTypes[ 0 ] in responses ) {
  23952. finalDataType = dataTypes[ 0 ];
  23953. } else {
  23954. // Try convertible dataTypes
  23955. for ( type in responses ) {
  23956. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  23957. finalDataType = type;
  23958. break;
  23959. }
  23960. if ( !firstDataType ) {
  23961. firstDataType = type;
  23962. }
  23963. }
  23964. // Or just use first one
  23965. finalDataType = finalDataType || firstDataType;
  23966. }
  23967. // If we found a dataType
  23968. // We add the dataType to the list if needed
  23969. // and return the corresponding response
  23970. if ( finalDataType ) {
  23971. if ( finalDataType !== dataTypes[ 0 ] ) {
  23972. dataTypes.unshift( finalDataType );
  23973. }
  23974. return responses[ finalDataType ];
  23975. }
  23976. }
  23977. /* Chain conversions given the request and the original response
  23978. * Also sets the responseXXX fields on the jqXHR instance
  23979. */
  23980. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  23981. var conv2, current, conv, tmp, prev,
  23982. converters = {},
  23983. // Work with a copy of dataTypes in case we need to modify it for conversion
  23984. dataTypes = s.dataTypes.slice();
  23985. // Create converters map with lowercased keys
  23986. if ( dataTypes[ 1 ] ) {
  23987. for ( conv in s.converters ) {
  23988. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  23989. }
  23990. }
  23991. current = dataTypes.shift();
  23992. // Convert to each sequential dataType
  23993. while ( current ) {
  23994. if ( s.responseFields[ current ] ) {
  23995. jqXHR[ s.responseFields[ current ] ] = response;
  23996. }
  23997. // Apply the dataFilter if provided
  23998. if ( !prev && isSuccess && s.dataFilter ) {
  23999. response = s.dataFilter( response, s.dataType );
  24000. }
  24001. prev = current;
  24002. current = dataTypes.shift();
  24003. if ( current ) {
  24004. // There's only work to do if current dataType is non-auto
  24005. if ( current === "*" ) {
  24006. current = prev;
  24007. // Convert response if prev dataType is non-auto and differs from current
  24008. } else if ( prev !== "*" && prev !== current ) {
  24009. // Seek a direct converter
  24010. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  24011. // If none found, seek a pair
  24012. if ( !conv ) {
  24013. for ( conv2 in converters ) {
  24014. // If conv2 outputs current
  24015. tmp = conv2.split( " " );
  24016. if ( tmp[ 1 ] === current ) {
  24017. // If prev can be converted to accepted input
  24018. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  24019. converters[ "* " + tmp[ 0 ] ];
  24020. if ( conv ) {
  24021. // Condense equivalence converters
  24022. if ( conv === true ) {
  24023. conv = converters[ conv2 ];
  24024. // Otherwise, insert the intermediate dataType
  24025. } else if ( converters[ conv2 ] !== true ) {
  24026. current = tmp[ 0 ];
  24027. dataTypes.unshift( tmp[ 1 ] );
  24028. }
  24029. break;
  24030. }
  24031. }
  24032. }
  24033. }
  24034. // Apply converter (if not an equivalence)
  24035. if ( conv !== true ) {
  24036. // Unless errors are allowed to bubble, catch and return them
  24037. if ( conv && s.throws ) {
  24038. response = conv( response );
  24039. } else {
  24040. try {
  24041. response = conv( response );
  24042. } catch ( e ) {
  24043. return {
  24044. state: "parsererror",
  24045. error: conv ? e : "No conversion from " + prev + " to " + current
  24046. };
  24047. }
  24048. }
  24049. }
  24050. }
  24051. }
  24052. }
  24053. return { state: "success", data: response };
  24054. }
  24055. jQuery.extend( {
  24056. // Counter for holding the number of active queries
  24057. active: 0,
  24058. // Last-Modified header cache for next request
  24059. lastModified: {},
  24060. etag: {},
  24061. ajaxSettings: {
  24062. url: location.href,
  24063. type: "GET",
  24064. isLocal: rlocalProtocol.test( location.protocol ),
  24065. global: true,
  24066. processData: true,
  24067. async: true,
  24068. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  24069. /*
  24070. timeout: 0,
  24071. data: null,
  24072. dataType: null,
  24073. username: null,
  24074. password: null,
  24075. cache: null,
  24076. throws: false,
  24077. traditional: false,
  24078. headers: {},
  24079. */
  24080. accepts: {
  24081. "*": allTypes,
  24082. text: "text/plain",
  24083. html: "text/html",
  24084. xml: "application/xml, text/xml",
  24085. json: "application/json, text/javascript"
  24086. },
  24087. contents: {
  24088. xml: /\bxml\b/,
  24089. html: /\bhtml/,
  24090. json: /\bjson\b/
  24091. },
  24092. responseFields: {
  24093. xml: "responseXML",
  24094. text: "responseText",
  24095. json: "responseJSON"
  24096. },
  24097. // Data converters
  24098. // Keys separate source (or catchall "*") and destination types with a single space
  24099. converters: {
  24100. // Convert anything to text
  24101. "* text": String,
  24102. // Text to html (true = no transformation)
  24103. "text html": true,
  24104. // Evaluate text as a json expression
  24105. "text json": JSON.parse,
  24106. // Parse text as xml
  24107. "text xml": jQuery.parseXML
  24108. },
  24109. // For options that shouldn't be deep extended:
  24110. // you can add your own custom options here if
  24111. // and when you create one that shouldn't be
  24112. // deep extended (see ajaxExtend)
  24113. flatOptions: {
  24114. url: true,
  24115. context: true
  24116. }
  24117. },
  24118. // Creates a full fledged settings object into target
  24119. // with both ajaxSettings and settings fields.
  24120. // If target is omitted, writes into ajaxSettings.
  24121. ajaxSetup: function( target, settings ) {
  24122. return settings ?
  24123. // Building a settings object
  24124. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  24125. // Extending ajaxSettings
  24126. ajaxExtend( jQuery.ajaxSettings, target );
  24127. },
  24128. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  24129. ajaxTransport: addToPrefiltersOrTransports( transports ),
  24130. // Main method
  24131. ajax: function( url, options ) {
  24132. // If url is an object, simulate pre-1.5 signature
  24133. if ( typeof url === "object" ) {
  24134. options = url;
  24135. url = undefined;
  24136. }
  24137. // Force options to be an object
  24138. options = options || {};
  24139. var transport,
  24140. // URL without anti-cache param
  24141. cacheURL,
  24142. // Response headers
  24143. responseHeadersString,
  24144. responseHeaders,
  24145. // timeout handle
  24146. timeoutTimer,
  24147. // Url cleanup var
  24148. urlAnchor,
  24149. // Request state (becomes false upon send and true upon completion)
  24150. completed,
  24151. // To know if global events are to be dispatched
  24152. fireGlobals,
  24153. // Loop variable
  24154. i,
  24155. // uncached part of the url
  24156. uncached,
  24157. // Create the final options object
  24158. s = jQuery.ajaxSetup( {}, options ),
  24159. // Callbacks context
  24160. callbackContext = s.context || s,
  24161. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  24162. globalEventContext = s.context &&
  24163. ( callbackContext.nodeType || callbackContext.jquery ) ?
  24164. jQuery( callbackContext ) :
  24165. jQuery.event,
  24166. // Deferreds
  24167. deferred = jQuery.Deferred(),
  24168. completeDeferred = jQuery.Callbacks( "once memory" ),
  24169. // Status-dependent callbacks
  24170. statusCode = s.statusCode || {},
  24171. // Headers (they are sent all at once)
  24172. requestHeaders = {},
  24173. requestHeadersNames = {},
  24174. // Default abort message
  24175. strAbort = "canceled",
  24176. // Fake xhr
  24177. jqXHR = {
  24178. readyState: 0,
  24179. // Builds headers hashtable if needed
  24180. getResponseHeader: function( key ) {
  24181. var match;
  24182. if ( completed ) {
  24183. if ( !responseHeaders ) {
  24184. responseHeaders = {};
  24185. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  24186. responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
  24187. }
  24188. }
  24189. match = responseHeaders[ key.toLowerCase() ];
  24190. }
  24191. return match == null ? null : match;
  24192. },
  24193. // Raw string
  24194. getAllResponseHeaders: function() {
  24195. return completed ? responseHeadersString : null;
  24196. },
  24197. // Caches the header
  24198. setRequestHeader: function( name, value ) {
  24199. if ( completed == null ) {
  24200. name = requestHeadersNames[ name.toLowerCase() ] =
  24201. requestHeadersNames[ name.toLowerCase() ] || name;
  24202. requestHeaders[ name ] = value;
  24203. }
  24204. return this;
  24205. },
  24206. // Overrides response content-type header
  24207. overrideMimeType: function( type ) {
  24208. if ( completed == null ) {
  24209. s.mimeType = type;
  24210. }
  24211. return this;
  24212. },
  24213. // Status-dependent callbacks
  24214. statusCode: function( map ) {
  24215. var code;
  24216. if ( map ) {
  24217. if ( completed ) {
  24218. // Execute the appropriate callbacks
  24219. jqXHR.always( map[ jqXHR.status ] );
  24220. } else {
  24221. // Lazy-add the new callbacks in a way that preserves old ones
  24222. for ( code in map ) {
  24223. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  24224. }
  24225. }
  24226. }
  24227. return this;
  24228. },
  24229. // Cancel the request
  24230. abort: function( statusText ) {
  24231. var finalText = statusText || strAbort;
  24232. if ( transport ) {
  24233. transport.abort( finalText );
  24234. }
  24235. done( 0, finalText );
  24236. return this;
  24237. }
  24238. };
  24239. // Attach deferreds
  24240. deferred.promise( jqXHR );
  24241. // Add protocol if not provided (prefilters might expect it)
  24242. // Handle falsy url in the settings object (#10093: consistency with old signature)
  24243. // We also use the url parameter if available
  24244. s.url = ( ( url || s.url || location.href ) + "" )
  24245. .replace( rprotocol, location.protocol + "//" );
  24246. // Alias method option to type as per ticket #12004
  24247. s.type = options.method || options.type || s.method || s.type;
  24248. // Extract dataTypes list
  24249. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  24250. // A cross-domain request is in order when the origin doesn't match the current origin.
  24251. if ( s.crossDomain == null ) {
  24252. urlAnchor = document.createElement( "a" );
  24253. // Support: IE <=8 - 11, Edge 12 - 13
  24254. // IE throws exception on accessing the href property if url is malformed,
  24255. // e.g. http://example.com:80x/
  24256. try {
  24257. urlAnchor.href = s.url;
  24258. // Support: IE <=8 - 11 only
  24259. // Anchor's host property isn't correctly set when s.url is relative
  24260. urlAnchor.href = urlAnchor.href;
  24261. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  24262. urlAnchor.protocol + "//" + urlAnchor.host;
  24263. } catch ( e ) {
  24264. // If there is an error parsing the URL, assume it is crossDomain,
  24265. // it can be rejected by the transport if it is invalid
  24266. s.crossDomain = true;
  24267. }
  24268. }
  24269. // Convert data if not already a string
  24270. if ( s.data && s.processData && typeof s.data !== "string" ) {
  24271. s.data = jQuery.param( s.data, s.traditional );
  24272. }
  24273. // Apply prefilters
  24274. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  24275. // If request was aborted inside a prefilter, stop there
  24276. if ( completed ) {
  24277. return jqXHR;
  24278. }
  24279. // We can fire global events as of now if asked to
  24280. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  24281. fireGlobals = jQuery.event && s.global;
  24282. // Watch for a new set of requests
  24283. if ( fireGlobals && jQuery.active++ === 0 ) {
  24284. jQuery.event.trigger( "ajaxStart" );
  24285. }
  24286. // Uppercase the type
  24287. s.type = s.type.toUpperCase();
  24288. // Determine if request has content
  24289. s.hasContent = !rnoContent.test( s.type );
  24290. // Save the URL in case we're toying with the If-Modified-Since
  24291. // and/or If-None-Match header later on
  24292. // Remove hash to simplify url manipulation
  24293. cacheURL = s.url.replace( rhash, "" );
  24294. // More options handling for requests with no content
  24295. if ( !s.hasContent ) {
  24296. // Remember the hash so we can put it back
  24297. uncached = s.url.slice( cacheURL.length );
  24298. // If data is available, append data to url
  24299. if ( s.data ) {
  24300. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  24301. // #9682: remove data so that it's not used in an eventual retry
  24302. delete s.data;
  24303. }
  24304. // Add or update anti-cache param if needed
  24305. if ( s.cache === false ) {
  24306. cacheURL = cacheURL.replace( rantiCache, "$1" );
  24307. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  24308. }
  24309. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  24310. s.url = cacheURL + uncached;
  24311. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  24312. } else if ( s.data && s.processData &&
  24313. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  24314. s.data = s.data.replace( r20, "+" );
  24315. }
  24316. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  24317. if ( s.ifModified ) {
  24318. if ( jQuery.lastModified[ cacheURL ] ) {
  24319. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  24320. }
  24321. if ( jQuery.etag[ cacheURL ] ) {
  24322. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  24323. }
  24324. }
  24325. // Set the correct header, if data is being sent
  24326. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  24327. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  24328. }
  24329. // Set the Accepts header for the server, depending on the dataType
  24330. jqXHR.setRequestHeader(
  24331. "Accept",
  24332. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  24333. s.accepts[ s.dataTypes[ 0 ] ] +
  24334. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  24335. s.accepts[ "*" ]
  24336. );
  24337. // Check for headers option
  24338. for ( i in s.headers ) {
  24339. jqXHR.setRequestHeader( i, s.headers[ i ] );
  24340. }
  24341. // Allow custom headers/mimetypes and early abort
  24342. if ( s.beforeSend &&
  24343. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  24344. // Abort if not done already and return
  24345. return jqXHR.abort();
  24346. }
  24347. // Aborting is no longer a cancellation
  24348. strAbort = "abort";
  24349. // Install callbacks on deferreds
  24350. completeDeferred.add( s.complete );
  24351. jqXHR.done( s.success );
  24352. jqXHR.fail( s.error );
  24353. // Get transport
  24354. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  24355. // If no transport, we auto-abort
  24356. if ( !transport ) {
  24357. done( -1, "No Transport" );
  24358. } else {
  24359. jqXHR.readyState = 1;
  24360. // Send global event
  24361. if ( fireGlobals ) {
  24362. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  24363. }
  24364. // If request was aborted inside ajaxSend, stop there
  24365. if ( completed ) {
  24366. return jqXHR;
  24367. }
  24368. // Timeout
  24369. if ( s.async && s.timeout > 0 ) {
  24370. timeoutTimer = window.setTimeout( function() {
  24371. jqXHR.abort( "timeout" );
  24372. }, s.timeout );
  24373. }
  24374. try {
  24375. completed = false;
  24376. transport.send( requestHeaders, done );
  24377. } catch ( e ) {
  24378. // Rethrow post-completion exceptions
  24379. if ( completed ) {
  24380. throw e;
  24381. }
  24382. // Propagate others as results
  24383. done( -1, e );
  24384. }
  24385. }
  24386. // Callback for when everything is done
  24387. function done( status, nativeStatusText, responses, headers ) {
  24388. var isSuccess, success, error, response, modified,
  24389. statusText = nativeStatusText;
  24390. // Ignore repeat invocations
  24391. if ( completed ) {
  24392. return;
  24393. }
  24394. completed = true;
  24395. // Clear timeout if it exists
  24396. if ( timeoutTimer ) {
  24397. window.clearTimeout( timeoutTimer );
  24398. }
  24399. // Dereference transport for early garbage collection
  24400. // (no matter how long the jqXHR object will be used)
  24401. transport = undefined;
  24402. // Cache response headers
  24403. responseHeadersString = headers || "";
  24404. // Set readyState
  24405. jqXHR.readyState = status > 0 ? 4 : 0;
  24406. // Determine if successful
  24407. isSuccess = status >= 200 && status < 300 || status === 304;
  24408. // Get response data
  24409. if ( responses ) {
  24410. response = ajaxHandleResponses( s, jqXHR, responses );
  24411. }
  24412. // Convert no matter what (that way responseXXX fields are always set)
  24413. response = ajaxConvert( s, response, jqXHR, isSuccess );
  24414. // If successful, handle type chaining
  24415. if ( isSuccess ) {
  24416. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  24417. if ( s.ifModified ) {
  24418. modified = jqXHR.getResponseHeader( "Last-Modified" );
  24419. if ( modified ) {
  24420. jQuery.lastModified[ cacheURL ] = modified;
  24421. }
  24422. modified = jqXHR.getResponseHeader( "etag" );
  24423. if ( modified ) {
  24424. jQuery.etag[ cacheURL ] = modified;
  24425. }
  24426. }
  24427. // if no content
  24428. if ( status === 204 || s.type === "HEAD" ) {
  24429. statusText = "nocontent";
  24430. // if not modified
  24431. } else if ( status === 304 ) {
  24432. statusText = "notmodified";
  24433. // If we have data, let's convert it
  24434. } else {
  24435. statusText = response.state;
  24436. success = response.data;
  24437. error = response.error;
  24438. isSuccess = !error;
  24439. }
  24440. } else {
  24441. // Extract error from statusText and normalize for non-aborts
  24442. error = statusText;
  24443. if ( status || !statusText ) {
  24444. statusText = "error";
  24445. if ( status < 0 ) {
  24446. status = 0;
  24447. }
  24448. }
  24449. }
  24450. // Set data for the fake xhr object
  24451. jqXHR.status = status;
  24452. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  24453. // Success/Error
  24454. if ( isSuccess ) {
  24455. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  24456. } else {
  24457. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  24458. }
  24459. // Status-dependent callbacks
  24460. jqXHR.statusCode( statusCode );
  24461. statusCode = undefined;
  24462. if ( fireGlobals ) {
  24463. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  24464. [ jqXHR, s, isSuccess ? success : error ] );
  24465. }
  24466. // Complete
  24467. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  24468. if ( fireGlobals ) {
  24469. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  24470. // Handle the global AJAX counter
  24471. if ( !( --jQuery.active ) ) {
  24472. jQuery.event.trigger( "ajaxStop" );
  24473. }
  24474. }
  24475. }
  24476. return jqXHR;
  24477. },
  24478. getJSON: function( url, data, callback ) {
  24479. return jQuery.get( url, data, callback, "json" );
  24480. },
  24481. getScript: function( url, callback ) {
  24482. return jQuery.get( url, undefined, callback, "script" );
  24483. }
  24484. } );
  24485. jQuery.each( [ "get", "post" ], function( i, method ) {
  24486. jQuery[ method ] = function( url, data, callback, type ) {
  24487. // Shift arguments if data argument was omitted
  24488. if ( jQuery.isFunction( data ) ) {
  24489. type = type || callback;
  24490. callback = data;
  24491. data = undefined;
  24492. }
  24493. // The url can be an options object (which then must have .url)
  24494. return jQuery.ajax( jQuery.extend( {
  24495. url: url,
  24496. type: method,
  24497. dataType: type,
  24498. data: data,
  24499. success: callback
  24500. }, jQuery.isPlainObject( url ) && url ) );
  24501. };
  24502. } );
  24503. jQuery._evalUrl = function( url ) {
  24504. return jQuery.ajax( {
  24505. url: url,
  24506. // Make this explicit, since user can override this through ajaxSetup (#11264)
  24507. type: "GET",
  24508. dataType: "script",
  24509. cache: true,
  24510. async: false,
  24511. global: false,
  24512. "throws": true
  24513. } );
  24514. };
  24515. jQuery.fn.extend( {
  24516. wrapAll: function( html ) {
  24517. var wrap;
  24518. if ( this[ 0 ] ) {
  24519. if ( jQuery.isFunction( html ) ) {
  24520. html = html.call( this[ 0 ] );
  24521. }
  24522. // The elements to wrap the target around
  24523. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  24524. if ( this[ 0 ].parentNode ) {
  24525. wrap.insertBefore( this[ 0 ] );
  24526. }
  24527. wrap.map( function() {
  24528. var elem = this;
  24529. while ( elem.firstElementChild ) {
  24530. elem = elem.firstElementChild;
  24531. }
  24532. return elem;
  24533. } ).append( this );
  24534. }
  24535. return this;
  24536. },
  24537. wrapInner: function( html ) {
  24538. if ( jQuery.isFunction( html ) ) {
  24539. return this.each( function( i ) {
  24540. jQuery( this ).wrapInner( html.call( this, i ) );
  24541. } );
  24542. }
  24543. return this.each( function() {
  24544. var self = jQuery( this ),
  24545. contents = self.contents();
  24546. if ( contents.length ) {
  24547. contents.wrapAll( html );
  24548. } else {
  24549. self.append( html );
  24550. }
  24551. } );
  24552. },
  24553. wrap: function( html ) {
  24554. var isFunction = jQuery.isFunction( html );
  24555. return this.each( function( i ) {
  24556. jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
  24557. } );
  24558. },
  24559. unwrap: function( selector ) {
  24560. this.parent( selector ).not( "body" ).each( function() {
  24561. jQuery( this ).replaceWith( this.childNodes );
  24562. } );
  24563. return this;
  24564. }
  24565. } );
  24566. jQuery.expr.pseudos.hidden = function( elem ) {
  24567. return !jQuery.expr.pseudos.visible( elem );
  24568. };
  24569. jQuery.expr.pseudos.visible = function( elem ) {
  24570. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  24571. };
  24572. jQuery.ajaxSettings.xhr = function() {
  24573. try {
  24574. return new window.XMLHttpRequest();
  24575. } catch ( e ) {}
  24576. };
  24577. var xhrSuccessStatus = {
  24578. // File protocol always yields status code 0, assume 200
  24579. 0: 200,
  24580. // Support: IE <=9 only
  24581. // #1450: sometimes IE returns 1223 when it should be 204
  24582. 1223: 204
  24583. },
  24584. xhrSupported = jQuery.ajaxSettings.xhr();
  24585. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  24586. support.ajax = xhrSupported = !!xhrSupported;
  24587. jQuery.ajaxTransport( function( options ) {
  24588. var callback, errorCallback;
  24589. // Cross domain only allowed if supported through XMLHttpRequest
  24590. if ( support.cors || xhrSupported && !options.crossDomain ) {
  24591. return {
  24592. send: function( headers, complete ) {
  24593. var i,
  24594. xhr = options.xhr();
  24595. xhr.open(
  24596. options.type,
  24597. options.url,
  24598. options.async,
  24599. options.username,
  24600. options.password
  24601. );
  24602. // Apply custom fields if provided
  24603. if ( options.xhrFields ) {
  24604. for ( i in options.xhrFields ) {
  24605. xhr[ i ] = options.xhrFields[ i ];
  24606. }
  24607. }
  24608. // Override mime type if needed
  24609. if ( options.mimeType && xhr.overrideMimeType ) {
  24610. xhr.overrideMimeType( options.mimeType );
  24611. }
  24612. // X-Requested-With header
  24613. // For cross-domain requests, seeing as conditions for a preflight are
  24614. // akin to a jigsaw puzzle, we simply never set it to be sure.
  24615. // (it can always be set on a per-request basis or even using ajaxSetup)
  24616. // For same-domain requests, won't change header if already provided.
  24617. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  24618. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  24619. }
  24620. // Set headers
  24621. for ( i in headers ) {
  24622. xhr.setRequestHeader( i, headers[ i ] );
  24623. }
  24624. // Callback
  24625. callback = function( type ) {
  24626. return function() {
  24627. if ( callback ) {
  24628. callback = errorCallback = xhr.onload =
  24629. xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
  24630. if ( type === "abort" ) {
  24631. xhr.abort();
  24632. } else if ( type === "error" ) {
  24633. // Support: IE <=9 only
  24634. // On a manual native abort, IE9 throws
  24635. // errors on any property access that is not readyState
  24636. if ( typeof xhr.status !== "number" ) {
  24637. complete( 0, "error" );
  24638. } else {
  24639. complete(
  24640. // File: protocol always yields status 0; see #8605, #14207
  24641. xhr.status,
  24642. xhr.statusText
  24643. );
  24644. }
  24645. } else {
  24646. complete(
  24647. xhrSuccessStatus[ xhr.status ] || xhr.status,
  24648. xhr.statusText,
  24649. // Support: IE <=9 only
  24650. // IE9 has no XHR2 but throws on binary (trac-11426)
  24651. // For XHR2 non-text, let the caller handle it (gh-2498)
  24652. ( xhr.responseType || "text" ) !== "text" ||
  24653. typeof xhr.responseText !== "string" ?
  24654. { binary: xhr.response } :
  24655. { text: xhr.responseText },
  24656. xhr.getAllResponseHeaders()
  24657. );
  24658. }
  24659. }
  24660. };
  24661. };
  24662. // Listen to events
  24663. xhr.onload = callback();
  24664. errorCallback = xhr.onerror = callback( "error" );
  24665. // Support: IE 9 only
  24666. // Use onreadystatechange to replace onabort
  24667. // to handle uncaught aborts
  24668. if ( xhr.onabort !== undefined ) {
  24669. xhr.onabort = errorCallback;
  24670. } else {
  24671. xhr.onreadystatechange = function() {
  24672. // Check readyState before timeout as it changes
  24673. if ( xhr.readyState === 4 ) {
  24674. // Allow onerror to be called first,
  24675. // but that will not handle a native abort
  24676. // Also, save errorCallback to a variable
  24677. // as xhr.onerror cannot be accessed
  24678. window.setTimeout( function() {
  24679. if ( callback ) {
  24680. errorCallback();
  24681. }
  24682. } );
  24683. }
  24684. };
  24685. }
  24686. // Create the abort callback
  24687. callback = callback( "abort" );
  24688. try {
  24689. // Do send the request (this may raise an exception)
  24690. xhr.send( options.hasContent && options.data || null );
  24691. } catch ( e ) {
  24692. // #14683: Only rethrow if this hasn't been notified as an error yet
  24693. if ( callback ) {
  24694. throw e;
  24695. }
  24696. }
  24697. },
  24698. abort: function() {
  24699. if ( callback ) {
  24700. callback();
  24701. }
  24702. }
  24703. };
  24704. }
  24705. } );
  24706. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  24707. jQuery.ajaxPrefilter( function( s ) {
  24708. if ( s.crossDomain ) {
  24709. s.contents.script = false;
  24710. }
  24711. } );
  24712. // Install script dataType
  24713. jQuery.ajaxSetup( {
  24714. accepts: {
  24715. script: "text/javascript, application/javascript, " +
  24716. "application/ecmascript, application/x-ecmascript"
  24717. },
  24718. contents: {
  24719. script: /\b(?:java|ecma)script\b/
  24720. },
  24721. converters: {
  24722. "text script": function( text ) {
  24723. jQuery.globalEval( text );
  24724. return text;
  24725. }
  24726. }
  24727. } );
  24728. // Handle cache's special case and crossDomain
  24729. jQuery.ajaxPrefilter( "script", function( s ) {
  24730. if ( s.cache === undefined ) {
  24731. s.cache = false;
  24732. }
  24733. if ( s.crossDomain ) {
  24734. s.type = "GET";
  24735. }
  24736. } );
  24737. // Bind script tag hack transport
  24738. jQuery.ajaxTransport( "script", function( s ) {
  24739. // This transport only deals with cross domain requests
  24740. if ( s.crossDomain ) {
  24741. var script, callback;
  24742. return {
  24743. send: function( _, complete ) {
  24744. script = jQuery( "<script>" ).prop( {
  24745. charset: s.scriptCharset,
  24746. src: s.url
  24747. } ).on(
  24748. "load error",
  24749. callback = function( evt ) {
  24750. script.remove();
  24751. callback = null;
  24752. if ( evt ) {
  24753. complete( evt.type === "error" ? 404 : 200, evt.type );
  24754. }
  24755. }
  24756. );
  24757. // Use native DOM manipulation to avoid our domManip AJAX trickery
  24758. document.head.appendChild( script[ 0 ] );
  24759. },
  24760. abort: function() {
  24761. if ( callback ) {
  24762. callback();
  24763. }
  24764. }
  24765. };
  24766. }
  24767. } );
  24768. var oldCallbacks = [],
  24769. rjsonp = /(=)\?(?=&|$)|\?\?/;
  24770. // Default jsonp settings
  24771. jQuery.ajaxSetup( {
  24772. jsonp: "callback",
  24773. jsonpCallback: function() {
  24774. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  24775. this[ callback ] = true;
  24776. return callback;
  24777. }
  24778. } );
  24779. // Detect, normalize options and install callbacks for jsonp requests
  24780. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  24781. var callbackName, overwritten, responseContainer,
  24782. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  24783. "url" :
  24784. typeof s.data === "string" &&
  24785. ( s.contentType || "" )
  24786. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  24787. rjsonp.test( s.data ) && "data"
  24788. );
  24789. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  24790. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  24791. // Get callback name, remembering preexisting value associated with it
  24792. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  24793. s.jsonpCallback() :
  24794. s.jsonpCallback;
  24795. // Insert callback into url or form data
  24796. if ( jsonProp ) {
  24797. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  24798. } else if ( s.jsonp !== false ) {
  24799. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  24800. }
  24801. // Use data converter to retrieve json after script execution
  24802. s.converters[ "script json" ] = function() {
  24803. if ( !responseContainer ) {
  24804. jQuery.error( callbackName + " was not called" );
  24805. }
  24806. return responseContainer[ 0 ];
  24807. };
  24808. // Force json dataType
  24809. s.dataTypes[ 0 ] = "json";
  24810. // Install callback
  24811. overwritten = window[ callbackName ];
  24812. window[ callbackName ] = function() {
  24813. responseContainer = arguments;
  24814. };
  24815. // Clean-up function (fires after converters)
  24816. jqXHR.always( function() {
  24817. // If previous value didn't exist - remove it
  24818. if ( overwritten === undefined ) {
  24819. jQuery( window ).removeProp( callbackName );
  24820. // Otherwise restore preexisting value
  24821. } else {
  24822. window[ callbackName ] = overwritten;
  24823. }
  24824. // Save back as free
  24825. if ( s[ callbackName ] ) {
  24826. // Make sure that re-using the options doesn't screw things around
  24827. s.jsonpCallback = originalSettings.jsonpCallback;
  24828. // Save the callback name for future use
  24829. oldCallbacks.push( callbackName );
  24830. }
  24831. // Call if it was a function and we have a response
  24832. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  24833. overwritten( responseContainer[ 0 ] );
  24834. }
  24835. responseContainer = overwritten = undefined;
  24836. } );
  24837. // Delegate to script
  24838. return "script";
  24839. }
  24840. } );
  24841. // Support: Safari 8 only
  24842. // In Safari 8 documents created via document.implementation.createHTMLDocument
  24843. // collapse sibling forms: the second one becomes a child of the first one.
  24844. // Because of that, this security measure has to be disabled in Safari 8.
  24845. // https://bugs.webkit.org/show_bug.cgi?id=137337
  24846. support.createHTMLDocument = ( function() {
  24847. var body = document.implementation.createHTMLDocument( "" ).body;
  24848. body.innerHTML = "<form></form><form></form>";
  24849. return body.childNodes.length === 2;
  24850. } )();
  24851. // Argument "data" should be string of html
  24852. // context (optional): If specified, the fragment will be created in this context,
  24853. // defaults to document
  24854. // keepScripts (optional): If true, will include scripts passed in the html string
  24855. jQuery.parseHTML = function( data, context, keepScripts ) {
  24856. if ( typeof data !== "string" ) {
  24857. return [];
  24858. }
  24859. if ( typeof context === "boolean" ) {
  24860. keepScripts = context;
  24861. context = false;
  24862. }
  24863. var base, parsed, scripts;
  24864. if ( !context ) {
  24865. // Stop scripts or inline event handlers from being executed immediately
  24866. // by using document.implementation
  24867. if ( support.createHTMLDocument ) {
  24868. context = document.implementation.createHTMLDocument( "" );
  24869. // Set the base href for the created document
  24870. // so any parsed elements with URLs
  24871. // are based on the document's URL (gh-2965)
  24872. base = context.createElement( "base" );
  24873. base.href = document.location.href;
  24874. context.head.appendChild( base );
  24875. } else {
  24876. context = document;
  24877. }
  24878. }
  24879. parsed = rsingleTag.exec( data );
  24880. scripts = !keepScripts && [];
  24881. // Single tag
  24882. if ( parsed ) {
  24883. return [ context.createElement( parsed[ 1 ] ) ];
  24884. }
  24885. parsed = buildFragment( [ data ], context, scripts );
  24886. if ( scripts && scripts.length ) {
  24887. jQuery( scripts ).remove();
  24888. }
  24889. return jQuery.merge( [], parsed.childNodes );
  24890. };
  24891. /**
  24892. * Load a url into a page
  24893. */
  24894. jQuery.fn.load = function( url, params, callback ) {
  24895. var selector, type, response,
  24896. self = this,
  24897. off = url.indexOf( " " );
  24898. if ( off > -1 ) {
  24899. selector = stripAndCollapse( url.slice( off ) );
  24900. url = url.slice( 0, off );
  24901. }
  24902. // If it's a function
  24903. if ( jQuery.isFunction( params ) ) {
  24904. // We assume that it's the callback
  24905. callback = params;
  24906. params = undefined;
  24907. // Otherwise, build a param string
  24908. } else if ( params && typeof params === "object" ) {
  24909. type = "POST";
  24910. }
  24911. // If we have elements to modify, make the request
  24912. if ( self.length > 0 ) {
  24913. jQuery.ajax( {
  24914. url: url,
  24915. // If "type" variable is undefined, then "GET" method will be used.
  24916. // Make value of this field explicit since
  24917. // user can override it through ajaxSetup method
  24918. type: type || "GET",
  24919. dataType: "html",
  24920. data: params
  24921. } ).done( function( responseText ) {
  24922. // Save response for use in complete callback
  24923. response = arguments;
  24924. self.html( selector ?
  24925. // If a selector was specified, locate the right elements in a dummy div
  24926. // Exclude scripts to avoid IE 'Permission Denied' errors
  24927. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  24928. // Otherwise use the full result
  24929. responseText );
  24930. // If the request succeeds, this function gets "data", "status", "jqXHR"
  24931. // but they are ignored because response was set above.
  24932. // If it fails, this function gets "jqXHR", "status", "error"
  24933. } ).always( callback && function( jqXHR, status ) {
  24934. self.each( function() {
  24935. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  24936. } );
  24937. } );
  24938. }
  24939. return this;
  24940. };
  24941. // Attach a bunch of functions for handling common AJAX events
  24942. jQuery.each( [
  24943. "ajaxStart",
  24944. "ajaxStop",
  24945. "ajaxComplete",
  24946. "ajaxError",
  24947. "ajaxSuccess",
  24948. "ajaxSend"
  24949. ], function( i, type ) {
  24950. jQuery.fn[ type ] = function( fn ) {
  24951. return this.on( type, fn );
  24952. };
  24953. } );
  24954. jQuery.expr.pseudos.animated = function( elem ) {
  24955. return jQuery.grep( jQuery.timers, function( fn ) {
  24956. return elem === fn.elem;
  24957. } ).length;
  24958. };
  24959. jQuery.offset = {
  24960. setOffset: function( elem, options, i ) {
  24961. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  24962. position = jQuery.css( elem, "position" ),
  24963. curElem = jQuery( elem ),
  24964. props = {};
  24965. // Set position first, in-case top/left are set even on static elem
  24966. if ( position === "static" ) {
  24967. elem.style.position = "relative";
  24968. }
  24969. curOffset = curElem.offset();
  24970. curCSSTop = jQuery.css( elem, "top" );
  24971. curCSSLeft = jQuery.css( elem, "left" );
  24972. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  24973. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  24974. // Need to be able to calculate position if either
  24975. // top or left is auto and position is either absolute or fixed
  24976. if ( calculatePosition ) {
  24977. curPosition = curElem.position();
  24978. curTop = curPosition.top;
  24979. curLeft = curPosition.left;
  24980. } else {
  24981. curTop = parseFloat( curCSSTop ) || 0;
  24982. curLeft = parseFloat( curCSSLeft ) || 0;
  24983. }
  24984. if ( jQuery.isFunction( options ) ) {
  24985. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  24986. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  24987. }
  24988. if ( options.top != null ) {
  24989. props.top = ( options.top - curOffset.top ) + curTop;
  24990. }
  24991. if ( options.left != null ) {
  24992. props.left = ( options.left - curOffset.left ) + curLeft;
  24993. }
  24994. if ( "using" in options ) {
  24995. options.using.call( elem, props );
  24996. } else {
  24997. curElem.css( props );
  24998. }
  24999. }
  25000. };
  25001. jQuery.fn.extend( {
  25002. offset: function( options ) {
  25003. // Preserve chaining for setter
  25004. if ( arguments.length ) {
  25005. return options === undefined ?
  25006. this :
  25007. this.each( function( i ) {
  25008. jQuery.offset.setOffset( this, options, i );
  25009. } );
  25010. }
  25011. var doc, docElem, rect, win,
  25012. elem = this[ 0 ];
  25013. if ( !elem ) {
  25014. return;
  25015. }
  25016. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  25017. // Support: IE <=11 only
  25018. // Running getBoundingClientRect on a
  25019. // disconnected node in IE throws an error
  25020. if ( !elem.getClientRects().length ) {
  25021. return { top: 0, left: 0 };
  25022. }
  25023. rect = elem.getBoundingClientRect();
  25024. doc = elem.ownerDocument;
  25025. docElem = doc.documentElement;
  25026. win = doc.defaultView;
  25027. return {
  25028. top: rect.top + win.pageYOffset - docElem.clientTop,
  25029. left: rect.left + win.pageXOffset - docElem.clientLeft
  25030. };
  25031. },
  25032. position: function() {
  25033. if ( !this[ 0 ] ) {
  25034. return;
  25035. }
  25036. var offsetParent, offset,
  25037. elem = this[ 0 ],
  25038. parentOffset = { top: 0, left: 0 };
  25039. // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
  25040. // because it is its only offset parent
  25041. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  25042. // Assume getBoundingClientRect is there when computed position is fixed
  25043. offset = elem.getBoundingClientRect();
  25044. } else {
  25045. // Get *real* offsetParent
  25046. offsetParent = this.offsetParent();
  25047. // Get correct offsets
  25048. offset = this.offset();
  25049. if ( !nodeName( offsetParent[ 0 ], "html" ) ) {
  25050. parentOffset = offsetParent.offset();
  25051. }
  25052. // Add offsetParent borders
  25053. parentOffset = {
  25054. top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ),
  25055. left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true )
  25056. };
  25057. }
  25058. // Subtract parent offsets and element margins
  25059. return {
  25060. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  25061. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  25062. };
  25063. },
  25064. // This method will return documentElement in the following cases:
  25065. // 1) For the element inside the iframe without offsetParent, this method will return
  25066. // documentElement of the parent window
  25067. // 2) For the hidden or detached element
  25068. // 3) For body or html element, i.e. in case of the html node - it will return itself
  25069. //
  25070. // but those exceptions were never presented as a real life use-cases
  25071. // and might be considered as more preferable results.
  25072. //
  25073. // This logic, however, is not guaranteed and can change at any point in the future
  25074. offsetParent: function() {
  25075. return this.map( function() {
  25076. var offsetParent = this.offsetParent;
  25077. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  25078. offsetParent = offsetParent.offsetParent;
  25079. }
  25080. return offsetParent || documentElement;
  25081. } );
  25082. }
  25083. } );
  25084. // Create scrollLeft and scrollTop methods
  25085. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  25086. var top = "pageYOffset" === prop;
  25087. jQuery.fn[ method ] = function( val ) {
  25088. return access( this, function( elem, method, val ) {
  25089. // Coalesce documents and windows
  25090. var win;
  25091. if ( jQuery.isWindow( elem ) ) {
  25092. win = elem;
  25093. } else if ( elem.nodeType === 9 ) {
  25094. win = elem.defaultView;
  25095. }
  25096. if ( val === undefined ) {
  25097. return win ? win[ prop ] : elem[ method ];
  25098. }
  25099. if ( win ) {
  25100. win.scrollTo(
  25101. !top ? val : win.pageXOffset,
  25102. top ? val : win.pageYOffset
  25103. );
  25104. } else {
  25105. elem[ method ] = val;
  25106. }
  25107. }, method, val, arguments.length );
  25108. };
  25109. } );
  25110. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  25111. // Add the top/left cssHooks using jQuery.fn.position
  25112. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  25113. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  25114. // getComputedStyle returns percent when specified for top/left/bottom/right;
  25115. // rather than make the css module depend on the offset module, just check for it here
  25116. jQuery.each( [ "top", "left" ], function( i, prop ) {
  25117. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  25118. function( elem, computed ) {
  25119. if ( computed ) {
  25120. computed = curCSS( elem, prop );
  25121. // If curCSS returns percentage, fallback to offset
  25122. return rnumnonpx.test( computed ) ?
  25123. jQuery( elem ).position()[ prop ] + "px" :
  25124. computed;
  25125. }
  25126. }
  25127. );
  25128. } );
  25129. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  25130. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  25131. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  25132. function( defaultExtra, funcName ) {
  25133. // Margin is only for outerHeight, outerWidth
  25134. jQuery.fn[ funcName ] = function( margin, value ) {
  25135. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  25136. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  25137. return access( this, function( elem, type, value ) {
  25138. var doc;
  25139. if ( jQuery.isWindow( elem ) ) {
  25140. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  25141. return funcName.indexOf( "outer" ) === 0 ?
  25142. elem[ "inner" + name ] :
  25143. elem.document.documentElement[ "client" + name ];
  25144. }
  25145. // Get document width or height
  25146. if ( elem.nodeType === 9 ) {
  25147. doc = elem.documentElement;
  25148. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  25149. // whichever is greatest
  25150. return Math.max(
  25151. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  25152. elem.body[ "offset" + name ], doc[ "offset" + name ],
  25153. doc[ "client" + name ]
  25154. );
  25155. }
  25156. return value === undefined ?
  25157. // Get width or height on the element, requesting but not forcing parseFloat
  25158. jQuery.css( elem, type, extra ) :
  25159. // Set width or height on the element
  25160. jQuery.style( elem, type, value, extra );
  25161. }, type, chainable ? margin : undefined, chainable );
  25162. };
  25163. } );
  25164. } );
  25165. jQuery.fn.extend( {
  25166. bind: function( types, data, fn ) {
  25167. return this.on( types, null, data, fn );
  25168. },
  25169. unbind: function( types, fn ) {
  25170. return this.off( types, null, fn );
  25171. },
  25172. delegate: function( selector, types, data, fn ) {
  25173. return this.on( types, selector, data, fn );
  25174. },
  25175. undelegate: function( selector, types, fn ) {
  25176. // ( namespace ) or ( selector, types [, fn] )
  25177. return arguments.length === 1 ?
  25178. this.off( selector, "**" ) :
  25179. this.off( types, selector || "**", fn );
  25180. }
  25181. } );
  25182. jQuery.holdReady = function( hold ) {
  25183. if ( hold ) {
  25184. jQuery.readyWait++;
  25185. } else {
  25186. jQuery.ready( true );
  25187. }
  25188. };
  25189. jQuery.isArray = Array.isArray;
  25190. jQuery.parseJSON = JSON.parse;
  25191. jQuery.nodeName = nodeName;
  25192. // Register as a named AMD module, since jQuery can be concatenated with other
  25193. // files that may use define, but not via a proper concatenation script that
  25194. // understands anonymous AMD modules. A named AMD is safest and most robust
  25195. // way to register. Lowercase jquery is used because AMD module names are
  25196. // derived from file names, and jQuery is normally delivered in a lowercase
  25197. // file name. Do this after creating the global so that if an AMD module wants
  25198. // to call noConflict to hide this version of jQuery, it will work.
  25199. // Note that for maximum portability, libraries that are not jQuery should
  25200. // declare themselves as anonymous modules, and avoid setting a global if an
  25201. // AMD loader is present. jQuery is a special case. For more information, see
  25202. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  25203. if ( true ) {
  25204. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
  25205. return jQuery;
  25206. }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  25207. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  25208. }
  25209. var
  25210. // Map over jQuery in case of overwrite
  25211. _jQuery = window.jQuery,
  25212. // Map over the $ in case of overwrite
  25213. _$ = window.$;
  25214. jQuery.noConflict = function( deep ) {
  25215. if ( window.$ === jQuery ) {
  25216. window.$ = _$;
  25217. }
  25218. if ( deep && window.jQuery === jQuery ) {
  25219. window.jQuery = _jQuery;
  25220. }
  25221. return jQuery;
  25222. };
  25223. // Expose jQuery and $ identifiers, even in AMD
  25224. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  25225. // and CommonJS for browser emulators (#13566)
  25226. if ( !noGlobal ) {
  25227. window.jQuery = window.$ = jQuery;
  25228. }
  25229. return jQuery;
  25230. } );
  25231. /***/ }),
  25232. /* 15 */
  25233. /***/ (function(module, exports) {
  25234. /*!
  25235. * Bootstrap v3.3.7 (http://getbootstrap.com)
  25236. * Copyright 2011-2016 Twitter, Inc.
  25237. * Licensed under the MIT license
  25238. */
  25239. if (typeof jQuery === 'undefined') {
  25240. throw new Error('Bootstrap\'s JavaScript requires jQuery')
  25241. }
  25242. +function ($) {
  25243. 'use strict';
  25244. var version = $.fn.jquery.split(' ')[0].split('.')
  25245. if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 3)) {
  25246. throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4')
  25247. }
  25248. }(jQuery);
  25249. /* ========================================================================
  25250. * Bootstrap: transition.js v3.3.7
  25251. * http://getbootstrap.com/javascript/#transitions
  25252. * ========================================================================
  25253. * Copyright 2011-2016 Twitter, Inc.
  25254. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25255. * ======================================================================== */
  25256. +function ($) {
  25257. 'use strict';
  25258. // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  25259. // ============================================================
  25260. function transitionEnd() {
  25261. var el = document.createElement('bootstrap')
  25262. var transEndEventNames = {
  25263. WebkitTransition : 'webkitTransitionEnd',
  25264. MozTransition : 'transitionend',
  25265. OTransition : 'oTransitionEnd otransitionend',
  25266. transition : 'transitionend'
  25267. }
  25268. for (var name in transEndEventNames) {
  25269. if (el.style[name] !== undefined) {
  25270. return { end: transEndEventNames[name] }
  25271. }
  25272. }
  25273. return false // explicit for ie8 ( ._.)
  25274. }
  25275. // http://blog.alexmaccaw.com/css-transitions
  25276. $.fn.emulateTransitionEnd = function (duration) {
  25277. var called = false
  25278. var $el = this
  25279. $(this).one('bsTransitionEnd', function () { called = true })
  25280. var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
  25281. setTimeout(callback, duration)
  25282. return this
  25283. }
  25284. $(function () {
  25285. $.support.transition = transitionEnd()
  25286. if (!$.support.transition) return
  25287. $.event.special.bsTransitionEnd = {
  25288. bindType: $.support.transition.end,
  25289. delegateType: $.support.transition.end,
  25290. handle: function (e) {
  25291. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
  25292. }
  25293. }
  25294. })
  25295. }(jQuery);
  25296. /* ========================================================================
  25297. * Bootstrap: alert.js v3.3.7
  25298. * http://getbootstrap.com/javascript/#alerts
  25299. * ========================================================================
  25300. * Copyright 2011-2016 Twitter, Inc.
  25301. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25302. * ======================================================================== */
  25303. +function ($) {
  25304. 'use strict';
  25305. // ALERT CLASS DEFINITION
  25306. // ======================
  25307. var dismiss = '[data-dismiss="alert"]'
  25308. var Alert = function (el) {
  25309. $(el).on('click', dismiss, this.close)
  25310. }
  25311. Alert.VERSION = '3.3.7'
  25312. Alert.TRANSITION_DURATION = 150
  25313. Alert.prototype.close = function (e) {
  25314. var $this = $(this)
  25315. var selector = $this.attr('data-target')
  25316. if (!selector) {
  25317. selector = $this.attr('href')
  25318. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  25319. }
  25320. var $parent = $(selector === '#' ? [] : selector)
  25321. if (e) e.preventDefault()
  25322. if (!$parent.length) {
  25323. $parent = $this.closest('.alert')
  25324. }
  25325. $parent.trigger(e = $.Event('close.bs.alert'))
  25326. if (e.isDefaultPrevented()) return
  25327. $parent.removeClass('in')
  25328. function removeElement() {
  25329. // detach from parent, fire event then clean up data
  25330. $parent.detach().trigger('closed.bs.alert').remove()
  25331. }
  25332. $.support.transition && $parent.hasClass('fade') ?
  25333. $parent
  25334. .one('bsTransitionEnd', removeElement)
  25335. .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
  25336. removeElement()
  25337. }
  25338. // ALERT PLUGIN DEFINITION
  25339. // =======================
  25340. function Plugin(option) {
  25341. return this.each(function () {
  25342. var $this = $(this)
  25343. var data = $this.data('bs.alert')
  25344. if (!data) $this.data('bs.alert', (data = new Alert(this)))
  25345. if (typeof option == 'string') data[option].call($this)
  25346. })
  25347. }
  25348. var old = $.fn.alert
  25349. $.fn.alert = Plugin
  25350. $.fn.alert.Constructor = Alert
  25351. // ALERT NO CONFLICT
  25352. // =================
  25353. $.fn.alert.noConflict = function () {
  25354. $.fn.alert = old
  25355. return this
  25356. }
  25357. // ALERT DATA-API
  25358. // ==============
  25359. $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
  25360. }(jQuery);
  25361. /* ========================================================================
  25362. * Bootstrap: button.js v3.3.7
  25363. * http://getbootstrap.com/javascript/#buttons
  25364. * ========================================================================
  25365. * Copyright 2011-2016 Twitter, Inc.
  25366. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25367. * ======================================================================== */
  25368. +function ($) {
  25369. 'use strict';
  25370. // BUTTON PUBLIC CLASS DEFINITION
  25371. // ==============================
  25372. var Button = function (element, options) {
  25373. this.$element = $(element)
  25374. this.options = $.extend({}, Button.DEFAULTS, options)
  25375. this.isLoading = false
  25376. }
  25377. Button.VERSION = '3.3.7'
  25378. Button.DEFAULTS = {
  25379. loadingText: 'loading...'
  25380. }
  25381. Button.prototype.setState = function (state) {
  25382. var d = 'disabled'
  25383. var $el = this.$element
  25384. var val = $el.is('input') ? 'val' : 'html'
  25385. var data = $el.data()
  25386. state += 'Text'
  25387. if (data.resetText == null) $el.data('resetText', $el[val]())
  25388. // push to event loop to allow forms to submit
  25389. setTimeout($.proxy(function () {
  25390. $el[val](data[state] == null ? this.options[state] : data[state])
  25391. if (state == 'loadingText') {
  25392. this.isLoading = true
  25393. $el.addClass(d).attr(d, d).prop(d, true)
  25394. } else if (this.isLoading) {
  25395. this.isLoading = false
  25396. $el.removeClass(d).removeAttr(d).prop(d, false)
  25397. }
  25398. }, this), 0)
  25399. }
  25400. Button.prototype.toggle = function () {
  25401. var changed = true
  25402. var $parent = this.$element.closest('[data-toggle="buttons"]')
  25403. if ($parent.length) {
  25404. var $input = this.$element.find('input')
  25405. if ($input.prop('type') == 'radio') {
  25406. if ($input.prop('checked')) changed = false
  25407. $parent.find('.active').removeClass('active')
  25408. this.$element.addClass('active')
  25409. } else if ($input.prop('type') == 'checkbox') {
  25410. if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
  25411. this.$element.toggleClass('active')
  25412. }
  25413. $input.prop('checked', this.$element.hasClass('active'))
  25414. if (changed) $input.trigger('change')
  25415. } else {
  25416. this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
  25417. this.$element.toggleClass('active')
  25418. }
  25419. }
  25420. // BUTTON PLUGIN DEFINITION
  25421. // ========================
  25422. function Plugin(option) {
  25423. return this.each(function () {
  25424. var $this = $(this)
  25425. var data = $this.data('bs.button')
  25426. var options = typeof option == 'object' && option
  25427. if (!data) $this.data('bs.button', (data = new Button(this, options)))
  25428. if (option == 'toggle') data.toggle()
  25429. else if (option) data.setState(option)
  25430. })
  25431. }
  25432. var old = $.fn.button
  25433. $.fn.button = Plugin
  25434. $.fn.button.Constructor = Button
  25435. // BUTTON NO CONFLICT
  25436. // ==================
  25437. $.fn.button.noConflict = function () {
  25438. $.fn.button = old
  25439. return this
  25440. }
  25441. // BUTTON DATA-API
  25442. // ===============
  25443. $(document)
  25444. .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
  25445. var $btn = $(e.target).closest('.btn')
  25446. Plugin.call($btn, 'toggle')
  25447. if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) {
  25448. // Prevent double click on radios, and the double selections (so cancellation) on checkboxes
  25449. e.preventDefault()
  25450. // The target component still receive the focus
  25451. if ($btn.is('input,button')) $btn.trigger('focus')
  25452. else $btn.find('input:visible,button:visible').first().trigger('focus')
  25453. }
  25454. })
  25455. .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
  25456. $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
  25457. })
  25458. }(jQuery);
  25459. /* ========================================================================
  25460. * Bootstrap: carousel.js v3.3.7
  25461. * http://getbootstrap.com/javascript/#carousel
  25462. * ========================================================================
  25463. * Copyright 2011-2016 Twitter, Inc.
  25464. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25465. * ======================================================================== */
  25466. +function ($) {
  25467. 'use strict';
  25468. // CAROUSEL CLASS DEFINITION
  25469. // =========================
  25470. var Carousel = function (element, options) {
  25471. this.$element = $(element)
  25472. this.$indicators = this.$element.find('.carousel-indicators')
  25473. this.options = options
  25474. this.paused = null
  25475. this.sliding = null
  25476. this.interval = null
  25477. this.$active = null
  25478. this.$items = null
  25479. this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
  25480. this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
  25481. .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
  25482. .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
  25483. }
  25484. Carousel.VERSION = '3.3.7'
  25485. Carousel.TRANSITION_DURATION = 600
  25486. Carousel.DEFAULTS = {
  25487. interval: 5000,
  25488. pause: 'hover',
  25489. wrap: true,
  25490. keyboard: true
  25491. }
  25492. Carousel.prototype.keydown = function (e) {
  25493. if (/input|textarea/i.test(e.target.tagName)) return
  25494. switch (e.which) {
  25495. case 37: this.prev(); break
  25496. case 39: this.next(); break
  25497. default: return
  25498. }
  25499. e.preventDefault()
  25500. }
  25501. Carousel.prototype.cycle = function (e) {
  25502. e || (this.paused = false)
  25503. this.interval && clearInterval(this.interval)
  25504. this.options.interval
  25505. && !this.paused
  25506. && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
  25507. return this
  25508. }
  25509. Carousel.prototype.getItemIndex = function (item) {
  25510. this.$items = item.parent().children('.item')
  25511. return this.$items.index(item || this.$active)
  25512. }
  25513. Carousel.prototype.getItemForDirection = function (direction, active) {
  25514. var activeIndex = this.getItemIndex(active)
  25515. var willWrap = (direction == 'prev' && activeIndex === 0)
  25516. || (direction == 'next' && activeIndex == (this.$items.length - 1))
  25517. if (willWrap && !this.options.wrap) return active
  25518. var delta = direction == 'prev' ? -1 : 1
  25519. var itemIndex = (activeIndex + delta) % this.$items.length
  25520. return this.$items.eq(itemIndex)
  25521. }
  25522. Carousel.prototype.to = function (pos) {
  25523. var that = this
  25524. var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
  25525. if (pos > (this.$items.length - 1) || pos < 0) return
  25526. if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
  25527. if (activeIndex == pos) return this.pause().cycle()
  25528. return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos))
  25529. }
  25530. Carousel.prototype.pause = function (e) {
  25531. e || (this.paused = true)
  25532. if (this.$element.find('.next, .prev').length && $.support.transition) {
  25533. this.$element.trigger($.support.transition.end)
  25534. this.cycle(true)
  25535. }
  25536. this.interval = clearInterval(this.interval)
  25537. return this
  25538. }
  25539. Carousel.prototype.next = function () {
  25540. if (this.sliding) return
  25541. return this.slide('next')
  25542. }
  25543. Carousel.prototype.prev = function () {
  25544. if (this.sliding) return
  25545. return this.slide('prev')
  25546. }
  25547. Carousel.prototype.slide = function (type, next) {
  25548. var $active = this.$element.find('.item.active')
  25549. var $next = next || this.getItemForDirection(type, $active)
  25550. var isCycling = this.interval
  25551. var direction = type == 'next' ? 'left' : 'right'
  25552. var that = this
  25553. if ($next.hasClass('active')) return (this.sliding = false)
  25554. var relatedTarget = $next[0]
  25555. var slideEvent = $.Event('slide.bs.carousel', {
  25556. relatedTarget: relatedTarget,
  25557. direction: direction
  25558. })
  25559. this.$element.trigger(slideEvent)
  25560. if (slideEvent.isDefaultPrevented()) return
  25561. this.sliding = true
  25562. isCycling && this.pause()
  25563. if (this.$indicators.length) {
  25564. this.$indicators.find('.active').removeClass('active')
  25565. var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
  25566. $nextIndicator && $nextIndicator.addClass('active')
  25567. }
  25568. var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
  25569. if ($.support.transition && this.$element.hasClass('slide')) {
  25570. $next.addClass(type)
  25571. $next[0].offsetWidth // force reflow
  25572. $active.addClass(direction)
  25573. $next.addClass(direction)
  25574. $active
  25575. .one('bsTransitionEnd', function () {
  25576. $next.removeClass([type, direction].join(' ')).addClass('active')
  25577. $active.removeClass(['active', direction].join(' '))
  25578. that.sliding = false
  25579. setTimeout(function () {
  25580. that.$element.trigger(slidEvent)
  25581. }, 0)
  25582. })
  25583. .emulateTransitionEnd(Carousel.TRANSITION_DURATION)
  25584. } else {
  25585. $active.removeClass('active')
  25586. $next.addClass('active')
  25587. this.sliding = false
  25588. this.$element.trigger(slidEvent)
  25589. }
  25590. isCycling && this.cycle()
  25591. return this
  25592. }
  25593. // CAROUSEL PLUGIN DEFINITION
  25594. // ==========================
  25595. function Plugin(option) {
  25596. return this.each(function () {
  25597. var $this = $(this)
  25598. var data = $this.data('bs.carousel')
  25599. var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
  25600. var action = typeof option == 'string' ? option : options.slide
  25601. if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
  25602. if (typeof option == 'number') data.to(option)
  25603. else if (action) data[action]()
  25604. else if (options.interval) data.pause().cycle()
  25605. })
  25606. }
  25607. var old = $.fn.carousel
  25608. $.fn.carousel = Plugin
  25609. $.fn.carousel.Constructor = Carousel
  25610. // CAROUSEL NO CONFLICT
  25611. // ====================
  25612. $.fn.carousel.noConflict = function () {
  25613. $.fn.carousel = old
  25614. return this
  25615. }
  25616. // CAROUSEL DATA-API
  25617. // =================
  25618. var clickHandler = function (e) {
  25619. var href
  25620. var $this = $(this)
  25621. var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
  25622. if (!$target.hasClass('carousel')) return
  25623. var options = $.extend({}, $target.data(), $this.data())
  25624. var slideIndex = $this.attr('data-slide-to')
  25625. if (slideIndex) options.interval = false
  25626. Plugin.call($target, options)
  25627. if (slideIndex) {
  25628. $target.data('bs.carousel').to(slideIndex)
  25629. }
  25630. e.preventDefault()
  25631. }
  25632. $(document)
  25633. .on('click.bs.carousel.data-api', '[data-slide]', clickHandler)
  25634. .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)
  25635. $(window).on('load', function () {
  25636. $('[data-ride="carousel"]').each(function () {
  25637. var $carousel = $(this)
  25638. Plugin.call($carousel, $carousel.data())
  25639. })
  25640. })
  25641. }(jQuery);
  25642. /* ========================================================================
  25643. * Bootstrap: collapse.js v3.3.7
  25644. * http://getbootstrap.com/javascript/#collapse
  25645. * ========================================================================
  25646. * Copyright 2011-2016 Twitter, Inc.
  25647. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25648. * ======================================================================== */
  25649. /* jshint latedef: false */
  25650. +function ($) {
  25651. 'use strict';
  25652. // COLLAPSE PUBLIC CLASS DEFINITION
  25653. // ================================
  25654. var Collapse = function (element, options) {
  25655. this.$element = $(element)
  25656. this.options = $.extend({}, Collapse.DEFAULTS, options)
  25657. this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
  25658. '[data-toggle="collapse"][data-target="#' + element.id + '"]')
  25659. this.transitioning = null
  25660. if (this.options.parent) {
  25661. this.$parent = this.getParent()
  25662. } else {
  25663. this.addAriaAndCollapsedClass(this.$element, this.$trigger)
  25664. }
  25665. if (this.options.toggle) this.toggle()
  25666. }
  25667. Collapse.VERSION = '3.3.7'
  25668. Collapse.TRANSITION_DURATION = 350
  25669. Collapse.DEFAULTS = {
  25670. toggle: true
  25671. }
  25672. Collapse.prototype.dimension = function () {
  25673. var hasWidth = this.$element.hasClass('width')
  25674. return hasWidth ? 'width' : 'height'
  25675. }
  25676. Collapse.prototype.show = function () {
  25677. if (this.transitioning || this.$element.hasClass('in')) return
  25678. var activesData
  25679. var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')
  25680. if (actives && actives.length) {
  25681. activesData = actives.data('bs.collapse')
  25682. if (activesData && activesData.transitioning) return
  25683. }
  25684. var startEvent = $.Event('show.bs.collapse')
  25685. this.$element.trigger(startEvent)
  25686. if (startEvent.isDefaultPrevented()) return
  25687. if (actives && actives.length) {
  25688. Plugin.call(actives, 'hide')
  25689. activesData || actives.data('bs.collapse', null)
  25690. }
  25691. var dimension = this.dimension()
  25692. this.$element
  25693. .removeClass('collapse')
  25694. .addClass('collapsing')[dimension](0)
  25695. .attr('aria-expanded', true)
  25696. this.$trigger
  25697. .removeClass('collapsed')
  25698. .attr('aria-expanded', true)
  25699. this.transitioning = 1
  25700. var complete = function () {
  25701. this.$element
  25702. .removeClass('collapsing')
  25703. .addClass('collapse in')[dimension]('')
  25704. this.transitioning = 0
  25705. this.$element
  25706. .trigger('shown.bs.collapse')
  25707. }
  25708. if (!$.support.transition) return complete.call(this)
  25709. var scrollSize = $.camelCase(['scroll', dimension].join('-'))
  25710. this.$element
  25711. .one('bsTransitionEnd', $.proxy(complete, this))
  25712. .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])
  25713. }
  25714. Collapse.prototype.hide = function () {
  25715. if (this.transitioning || !this.$element.hasClass('in')) return
  25716. var startEvent = $.Event('hide.bs.collapse')
  25717. this.$element.trigger(startEvent)
  25718. if (startEvent.isDefaultPrevented()) return
  25719. var dimension = this.dimension()
  25720. this.$element[dimension](this.$element[dimension]())[0].offsetHeight
  25721. this.$element
  25722. .addClass('collapsing')
  25723. .removeClass('collapse in')
  25724. .attr('aria-expanded', false)
  25725. this.$trigger
  25726. .addClass('collapsed')
  25727. .attr('aria-expanded', false)
  25728. this.transitioning = 1
  25729. var complete = function () {
  25730. this.transitioning = 0
  25731. this.$element
  25732. .removeClass('collapsing')
  25733. .addClass('collapse')
  25734. .trigger('hidden.bs.collapse')
  25735. }
  25736. if (!$.support.transition) return complete.call(this)
  25737. this.$element
  25738. [dimension](0)
  25739. .one('bsTransitionEnd', $.proxy(complete, this))
  25740. .emulateTransitionEnd(Collapse.TRANSITION_DURATION)
  25741. }
  25742. Collapse.prototype.toggle = function () {
  25743. this[this.$element.hasClass('in') ? 'hide' : 'show']()
  25744. }
  25745. Collapse.prototype.getParent = function () {
  25746. return $(this.options.parent)
  25747. .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]')
  25748. .each($.proxy(function (i, element) {
  25749. var $element = $(element)
  25750. this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)
  25751. }, this))
  25752. .end()
  25753. }
  25754. Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
  25755. var isOpen = $element.hasClass('in')
  25756. $element.attr('aria-expanded', isOpen)
  25757. $trigger
  25758. .toggleClass('collapsed', !isOpen)
  25759. .attr('aria-expanded', isOpen)
  25760. }
  25761. function getTargetFromTrigger($trigger) {
  25762. var href
  25763. var target = $trigger.attr('data-target')
  25764. || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
  25765. return $(target)
  25766. }
  25767. // COLLAPSE PLUGIN DEFINITION
  25768. // ==========================
  25769. function Plugin(option) {
  25770. return this.each(function () {
  25771. var $this = $(this)
  25772. var data = $this.data('bs.collapse')
  25773. var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
  25774. if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false
  25775. if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
  25776. if (typeof option == 'string') data[option]()
  25777. })
  25778. }
  25779. var old = $.fn.collapse
  25780. $.fn.collapse = Plugin
  25781. $.fn.collapse.Constructor = Collapse
  25782. // COLLAPSE NO CONFLICT
  25783. // ====================
  25784. $.fn.collapse.noConflict = function () {
  25785. $.fn.collapse = old
  25786. return this
  25787. }
  25788. // COLLAPSE DATA-API
  25789. // =================
  25790. $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
  25791. var $this = $(this)
  25792. if (!$this.attr('data-target')) e.preventDefault()
  25793. var $target = getTargetFromTrigger($this)
  25794. var data = $target.data('bs.collapse')
  25795. var option = data ? 'toggle' : $this.data()
  25796. Plugin.call($target, option)
  25797. })
  25798. }(jQuery);
  25799. /* ========================================================================
  25800. * Bootstrap: dropdown.js v3.3.7
  25801. * http://getbootstrap.com/javascript/#dropdowns
  25802. * ========================================================================
  25803. * Copyright 2011-2016 Twitter, Inc.
  25804. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25805. * ======================================================================== */
  25806. +function ($) {
  25807. 'use strict';
  25808. // DROPDOWN CLASS DEFINITION
  25809. // =========================
  25810. var backdrop = '.dropdown-backdrop'
  25811. var toggle = '[data-toggle="dropdown"]'
  25812. var Dropdown = function (element) {
  25813. $(element).on('click.bs.dropdown', this.toggle)
  25814. }
  25815. Dropdown.VERSION = '3.3.7'
  25816. function getParent($this) {
  25817. var selector = $this.attr('data-target')
  25818. if (!selector) {
  25819. selector = $this.attr('href')
  25820. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  25821. }
  25822. var $parent = selector && $(selector)
  25823. return $parent && $parent.length ? $parent : $this.parent()
  25824. }
  25825. function clearMenus(e) {
  25826. if (e && e.which === 3) return
  25827. $(backdrop).remove()
  25828. $(toggle).each(function () {
  25829. var $this = $(this)
  25830. var $parent = getParent($this)
  25831. var relatedTarget = { relatedTarget: this }
  25832. if (!$parent.hasClass('open')) return
  25833. if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
  25834. $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
  25835. if (e.isDefaultPrevented()) return
  25836. $this.attr('aria-expanded', 'false')
  25837. $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
  25838. })
  25839. }
  25840. Dropdown.prototype.toggle = function (e) {
  25841. var $this = $(this)
  25842. if ($this.is('.disabled, :disabled')) return
  25843. var $parent = getParent($this)
  25844. var isActive = $parent.hasClass('open')
  25845. clearMenus()
  25846. if (!isActive) {
  25847. if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
  25848. // if mobile we use a backdrop because click events don't delegate
  25849. $(document.createElement('div'))
  25850. .addClass('dropdown-backdrop')
  25851. .insertAfter($(this))
  25852. .on('click', clearMenus)
  25853. }
  25854. var relatedTarget = { relatedTarget: this }
  25855. $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
  25856. if (e.isDefaultPrevented()) return
  25857. $this
  25858. .trigger('focus')
  25859. .attr('aria-expanded', 'true')
  25860. $parent
  25861. .toggleClass('open')
  25862. .trigger($.Event('shown.bs.dropdown', relatedTarget))
  25863. }
  25864. return false
  25865. }
  25866. Dropdown.prototype.keydown = function (e) {
  25867. if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
  25868. var $this = $(this)
  25869. e.preventDefault()
  25870. e.stopPropagation()
  25871. if ($this.is('.disabled, :disabled')) return
  25872. var $parent = getParent($this)
  25873. var isActive = $parent.hasClass('open')
  25874. if (!isActive && e.which != 27 || isActive && e.which == 27) {
  25875. if (e.which == 27) $parent.find(toggle).trigger('focus')
  25876. return $this.trigger('click')
  25877. }
  25878. var desc = ' li:not(.disabled):visible a'
  25879. var $items = $parent.find('.dropdown-menu' + desc)
  25880. if (!$items.length) return
  25881. var index = $items.index(e.target)
  25882. if (e.which == 38 && index > 0) index-- // up
  25883. if (e.which == 40 && index < $items.length - 1) index++ // down
  25884. if (!~index) index = 0
  25885. $items.eq(index).trigger('focus')
  25886. }
  25887. // DROPDOWN PLUGIN DEFINITION
  25888. // ==========================
  25889. function Plugin(option) {
  25890. return this.each(function () {
  25891. var $this = $(this)
  25892. var data = $this.data('bs.dropdown')
  25893. if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
  25894. if (typeof option == 'string') data[option].call($this)
  25895. })
  25896. }
  25897. var old = $.fn.dropdown
  25898. $.fn.dropdown = Plugin
  25899. $.fn.dropdown.Constructor = Dropdown
  25900. // DROPDOWN NO CONFLICT
  25901. // ====================
  25902. $.fn.dropdown.noConflict = function () {
  25903. $.fn.dropdown = old
  25904. return this
  25905. }
  25906. // APPLY TO STANDARD DROPDOWN ELEMENTS
  25907. // ===================================
  25908. $(document)
  25909. .on('click.bs.dropdown.data-api', clearMenus)
  25910. .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
  25911. .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
  25912. .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
  25913. .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
  25914. }(jQuery);
  25915. /* ========================================================================
  25916. * Bootstrap: modal.js v3.3.7
  25917. * http://getbootstrap.com/javascript/#modals
  25918. * ========================================================================
  25919. * Copyright 2011-2016 Twitter, Inc.
  25920. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25921. * ======================================================================== */
  25922. +function ($) {
  25923. 'use strict';
  25924. // MODAL CLASS DEFINITION
  25925. // ======================
  25926. var Modal = function (element, options) {
  25927. this.options = options
  25928. this.$body = $(document.body)
  25929. this.$element = $(element)
  25930. this.$dialog = this.$element.find('.modal-dialog')
  25931. this.$backdrop = null
  25932. this.isShown = null
  25933. this.originalBodyPad = null
  25934. this.scrollbarWidth = 0
  25935. this.ignoreBackdropClick = false
  25936. if (this.options.remote) {
  25937. this.$element
  25938. .find('.modal-content')
  25939. .load(this.options.remote, $.proxy(function () {
  25940. this.$element.trigger('loaded.bs.modal')
  25941. }, this))
  25942. }
  25943. }
  25944. Modal.VERSION = '3.3.7'
  25945. Modal.TRANSITION_DURATION = 300
  25946. Modal.BACKDROP_TRANSITION_DURATION = 150
  25947. Modal.DEFAULTS = {
  25948. backdrop: true,
  25949. keyboard: true,
  25950. show: true
  25951. }
  25952. Modal.prototype.toggle = function (_relatedTarget) {
  25953. return this.isShown ? this.hide() : this.show(_relatedTarget)
  25954. }
  25955. Modal.prototype.show = function (_relatedTarget) {
  25956. var that = this
  25957. var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
  25958. this.$element.trigger(e)
  25959. if (this.isShown || e.isDefaultPrevented()) return
  25960. this.isShown = true
  25961. this.checkScrollbar()
  25962. this.setScrollbar()
  25963. this.$body.addClass('modal-open')
  25964. this.escape()
  25965. this.resize()
  25966. this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
  25967. this.$dialog.on('mousedown.dismiss.bs.modal', function () {
  25968. that.$element.one('mouseup.dismiss.bs.modal', function (e) {
  25969. if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
  25970. })
  25971. })
  25972. this.backdrop(function () {
  25973. var transition = $.support.transition && that.$element.hasClass('fade')
  25974. if (!that.$element.parent().length) {
  25975. that.$element.appendTo(that.$body) // don't move modals dom position
  25976. }
  25977. that.$element
  25978. .show()
  25979. .scrollTop(0)
  25980. that.adjustDialog()
  25981. if (transition) {
  25982. that.$element[0].offsetWidth // force reflow
  25983. }
  25984. that.$element.addClass('in')
  25985. that.enforceFocus()
  25986. var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
  25987. transition ?
  25988. that.$dialog // wait for modal to slide in
  25989. .one('bsTransitionEnd', function () {
  25990. that.$element.trigger('focus').trigger(e)
  25991. })
  25992. .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
  25993. that.$element.trigger('focus').trigger(e)
  25994. })
  25995. }
  25996. Modal.prototype.hide = function (e) {
  25997. if (e) e.preventDefault()
  25998. e = $.Event('hide.bs.modal')
  25999. this.$element.trigger(e)
  26000. if (!this.isShown || e.isDefaultPrevented()) return
  26001. this.isShown = false
  26002. this.escape()
  26003. this.resize()
  26004. $(document).off('focusin.bs.modal')
  26005. this.$element
  26006. .removeClass('in')
  26007. .off('click.dismiss.bs.modal')
  26008. .off('mouseup.dismiss.bs.modal')
  26009. this.$dialog.off('mousedown.dismiss.bs.modal')
  26010. $.support.transition && this.$element.hasClass('fade') ?
  26011. this.$element
  26012. .one('bsTransitionEnd', $.proxy(this.hideModal, this))
  26013. .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
  26014. this.hideModal()
  26015. }
  26016. Modal.prototype.enforceFocus = function () {
  26017. $(document)
  26018. .off('focusin.bs.modal') // guard against infinite focus loop
  26019. .on('focusin.bs.modal', $.proxy(function (e) {
  26020. if (document !== e.target &&
  26021. this.$element[0] !== e.target &&
  26022. !this.$element.has(e.target).length) {
  26023. this.$element.trigger('focus')
  26024. }
  26025. }, this))
  26026. }
  26027. Modal.prototype.escape = function () {
  26028. if (this.isShown && this.options.keyboard) {
  26029. this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
  26030. e.which == 27 && this.hide()
  26031. }, this))
  26032. } else if (!this.isShown) {
  26033. this.$element.off('keydown.dismiss.bs.modal')
  26034. }
  26035. }
  26036. Modal.prototype.resize = function () {
  26037. if (this.isShown) {
  26038. $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
  26039. } else {
  26040. $(window).off('resize.bs.modal')
  26041. }
  26042. }
  26043. Modal.prototype.hideModal = function () {
  26044. var that = this
  26045. this.$element.hide()
  26046. this.backdrop(function () {
  26047. that.$body.removeClass('modal-open')
  26048. that.resetAdjustments()
  26049. that.resetScrollbar()
  26050. that.$element.trigger('hidden.bs.modal')
  26051. })
  26052. }
  26053. Modal.prototype.removeBackdrop = function () {
  26054. this.$backdrop && this.$backdrop.remove()
  26055. this.$backdrop = null
  26056. }
  26057. Modal.prototype.backdrop = function (callback) {
  26058. var that = this
  26059. var animate = this.$element.hasClass('fade') ? 'fade' : ''
  26060. if (this.isShown && this.options.backdrop) {
  26061. var doAnimate = $.support.transition && animate
  26062. this.$backdrop = $(document.createElement('div'))
  26063. .addClass('modal-backdrop ' + animate)
  26064. .appendTo(this.$body)
  26065. this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
  26066. if (this.ignoreBackdropClick) {
  26067. this.ignoreBackdropClick = false
  26068. return
  26069. }
  26070. if (e.target !== e.currentTarget) return
  26071. this.options.backdrop == 'static'
  26072. ? this.$element[0].focus()
  26073. : this.hide()
  26074. }, this))
  26075. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  26076. this.$backdrop.addClass('in')
  26077. if (!callback) return
  26078. doAnimate ?
  26079. this.$backdrop
  26080. .one('bsTransitionEnd', callback)
  26081. .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
  26082. callback()
  26083. } else if (!this.isShown && this.$backdrop) {
  26084. this.$backdrop.removeClass('in')
  26085. var callbackRemove = function () {
  26086. that.removeBackdrop()
  26087. callback && callback()
  26088. }
  26089. $.support.transition && this.$element.hasClass('fade') ?
  26090. this.$backdrop
  26091. .one('bsTransitionEnd', callbackRemove)
  26092. .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
  26093. callbackRemove()
  26094. } else if (callback) {
  26095. callback()
  26096. }
  26097. }
  26098. // these following methods are used to handle overflowing modals
  26099. Modal.prototype.handleUpdate = function () {
  26100. this.adjustDialog()
  26101. }
  26102. Modal.prototype.adjustDialog = function () {
  26103. var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
  26104. this.$element.css({
  26105. paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
  26106. paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
  26107. })
  26108. }
  26109. Modal.prototype.resetAdjustments = function () {
  26110. this.$element.css({
  26111. paddingLeft: '',
  26112. paddingRight: ''
  26113. })
  26114. }
  26115. Modal.prototype.checkScrollbar = function () {
  26116. var fullWindowWidth = window.innerWidth
  26117. if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
  26118. var documentElementRect = document.documentElement.getBoundingClientRect()
  26119. fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
  26120. }
  26121. this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
  26122. this.scrollbarWidth = this.measureScrollbar()
  26123. }
  26124. Modal.prototype.setScrollbar = function () {
  26125. var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
  26126. this.originalBodyPad = document.body.style.paddingRight || ''
  26127. if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
  26128. }
  26129. Modal.prototype.resetScrollbar = function () {
  26130. this.$body.css('padding-right', this.originalBodyPad)
  26131. }
  26132. Modal.prototype.measureScrollbar = function () { // thx walsh
  26133. var scrollDiv = document.createElement('div')
  26134. scrollDiv.className = 'modal-scrollbar-measure'
  26135. this.$body.append(scrollDiv)
  26136. var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
  26137. this.$body[0].removeChild(scrollDiv)
  26138. return scrollbarWidth
  26139. }
  26140. // MODAL PLUGIN DEFINITION
  26141. // =======================
  26142. function Plugin(option, _relatedTarget) {
  26143. return this.each(function () {
  26144. var $this = $(this)
  26145. var data = $this.data('bs.modal')
  26146. var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
  26147. if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
  26148. if (typeof option == 'string') data[option](_relatedTarget)
  26149. else if (options.show) data.show(_relatedTarget)
  26150. })
  26151. }
  26152. var old = $.fn.modal
  26153. $.fn.modal = Plugin
  26154. $.fn.modal.Constructor = Modal
  26155. // MODAL NO CONFLICT
  26156. // =================
  26157. $.fn.modal.noConflict = function () {
  26158. $.fn.modal = old
  26159. return this
  26160. }
  26161. // MODAL DATA-API
  26162. // ==============
  26163. $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
  26164. var $this = $(this)
  26165. var href = $this.attr('href')
  26166. var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
  26167. var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
  26168. if ($this.is('a')) e.preventDefault()
  26169. $target.one('show.bs.modal', function (showEvent) {
  26170. if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
  26171. $target.one('hidden.bs.modal', function () {
  26172. $this.is(':visible') && $this.trigger('focus')
  26173. })
  26174. })
  26175. Plugin.call($target, option, this)
  26176. })
  26177. }(jQuery);
  26178. /* ========================================================================
  26179. * Bootstrap: tooltip.js v3.3.7
  26180. * http://getbootstrap.com/javascript/#tooltip
  26181. * Inspired by the original jQuery.tipsy by Jason Frame
  26182. * ========================================================================
  26183. * Copyright 2011-2016 Twitter, Inc.
  26184. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26185. * ======================================================================== */
  26186. +function ($) {
  26187. 'use strict';
  26188. // TOOLTIP PUBLIC CLASS DEFINITION
  26189. // ===============================
  26190. var Tooltip = function (element, options) {
  26191. this.type = null
  26192. this.options = null
  26193. this.enabled = null
  26194. this.timeout = null
  26195. this.hoverState = null
  26196. this.$element = null
  26197. this.inState = null
  26198. this.init('tooltip', element, options)
  26199. }
  26200. Tooltip.VERSION = '3.3.7'
  26201. Tooltip.TRANSITION_DURATION = 150
  26202. Tooltip.DEFAULTS = {
  26203. animation: true,
  26204. placement: 'top',
  26205. selector: false,
  26206. template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  26207. trigger: 'hover focus',
  26208. title: '',
  26209. delay: 0,
  26210. html: false,
  26211. container: false,
  26212. viewport: {
  26213. selector: 'body',
  26214. padding: 0
  26215. }
  26216. }
  26217. Tooltip.prototype.init = function (type, element, options) {
  26218. this.enabled = true
  26219. this.type = type
  26220. this.$element = $(element)
  26221. this.options = this.getOptions(options)
  26222. this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
  26223. this.inState = { click: false, hover: false, focus: false }
  26224. if (this.$element[0] instanceof document.constructor && !this.options.selector) {
  26225. throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
  26226. }
  26227. var triggers = this.options.trigger.split(' ')
  26228. for (var i = triggers.length; i--;) {
  26229. var trigger = triggers[i]
  26230. if (trigger == 'click') {
  26231. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  26232. } else if (trigger != 'manual') {
  26233. var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
  26234. var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
  26235. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  26236. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  26237. }
  26238. }
  26239. this.options.selector ?
  26240. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  26241. this.fixTitle()
  26242. }
  26243. Tooltip.prototype.getDefaults = function () {
  26244. return Tooltip.DEFAULTS
  26245. }
  26246. Tooltip.prototype.getOptions = function (options) {
  26247. options = $.extend({}, this.getDefaults(), this.$element.data(), options)
  26248. if (options.delay && typeof options.delay == 'number') {
  26249. options.delay = {
  26250. show: options.delay,
  26251. hide: options.delay
  26252. }
  26253. }
  26254. return options
  26255. }
  26256. Tooltip.prototype.getDelegateOptions = function () {
  26257. var options = {}
  26258. var defaults = this.getDefaults()
  26259. this._options && $.each(this._options, function (key, value) {
  26260. if (defaults[key] != value) options[key] = value
  26261. })
  26262. return options
  26263. }
  26264. Tooltip.prototype.enter = function (obj) {
  26265. var self = obj instanceof this.constructor ?
  26266. obj : $(obj.currentTarget).data('bs.' + this.type)
  26267. if (!self) {
  26268. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  26269. $(obj.currentTarget).data('bs.' + this.type, self)
  26270. }
  26271. if (obj instanceof $.Event) {
  26272. self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
  26273. }
  26274. if (self.tip().hasClass('in') || self.hoverState == 'in') {
  26275. self.hoverState = 'in'
  26276. return
  26277. }
  26278. clearTimeout(self.timeout)
  26279. self.hoverState = 'in'
  26280. if (!self.options.delay || !self.options.delay.show) return self.show()
  26281. self.timeout = setTimeout(function () {
  26282. if (self.hoverState == 'in') self.show()
  26283. }, self.options.delay.show)
  26284. }
  26285. Tooltip.prototype.isInStateTrue = function () {
  26286. for (var key in this.inState) {
  26287. if (this.inState[key]) return true
  26288. }
  26289. return false
  26290. }
  26291. Tooltip.prototype.leave = function (obj) {
  26292. var self = obj instanceof this.constructor ?
  26293. obj : $(obj.currentTarget).data('bs.' + this.type)
  26294. if (!self) {
  26295. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  26296. $(obj.currentTarget).data('bs.' + this.type, self)
  26297. }
  26298. if (obj instanceof $.Event) {
  26299. self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
  26300. }
  26301. if (self.isInStateTrue()) return
  26302. clearTimeout(self.timeout)
  26303. self.hoverState = 'out'
  26304. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  26305. self.timeout = setTimeout(function () {
  26306. if (self.hoverState == 'out') self.hide()
  26307. }, self.options.delay.hide)
  26308. }
  26309. Tooltip.prototype.show = function () {
  26310. var e = $.Event('show.bs.' + this.type)
  26311. if (this.hasContent() && this.enabled) {
  26312. this.$element.trigger(e)
  26313. var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
  26314. if (e.isDefaultPrevented() || !inDom) return
  26315. var that = this
  26316. var $tip = this.tip()
  26317. var tipId = this.getUID(this.type)
  26318. this.setContent()
  26319. $tip.attr('id', tipId)
  26320. this.$element.attr('aria-describedby', tipId)
  26321. if (this.options.animation) $tip.addClass('fade')
  26322. var placement = typeof this.options.placement == 'function' ?
  26323. this.options.placement.call(this, $tip[0], this.$element[0]) :
  26324. this.options.placement
  26325. var autoToken = /\s?auto?\s?/i
  26326. var autoPlace = autoToken.test(placement)
  26327. if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
  26328. $tip
  26329. .detach()
  26330. .css({ top: 0, left: 0, display: 'block' })
  26331. .addClass(placement)
  26332. .data('bs.' + this.type, this)
  26333. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
  26334. this.$element.trigger('inserted.bs.' + this.type)
  26335. var pos = this.getPosition()
  26336. var actualWidth = $tip[0].offsetWidth
  26337. var actualHeight = $tip[0].offsetHeight
  26338. if (autoPlace) {
  26339. var orgPlacement = placement
  26340. var viewportDim = this.getPosition(this.$viewport)
  26341. placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
  26342. placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
  26343. placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
  26344. placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
  26345. placement
  26346. $tip
  26347. .removeClass(orgPlacement)
  26348. .addClass(placement)
  26349. }
  26350. var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
  26351. this.applyPlacement(calculatedOffset, placement)
  26352. var complete = function () {
  26353. var prevHoverState = that.hoverState
  26354. that.$element.trigger('shown.bs.' + that.type)
  26355. that.hoverState = null
  26356. if (prevHoverState == 'out') that.leave(that)
  26357. }
  26358. $.support.transition && this.$tip.hasClass('fade') ?
  26359. $tip
  26360. .one('bsTransitionEnd', complete)
  26361. .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
  26362. complete()
  26363. }
  26364. }
  26365. Tooltip.prototype.applyPlacement = function (offset, placement) {
  26366. var $tip = this.tip()
  26367. var width = $tip[0].offsetWidth
  26368. var height = $tip[0].offsetHeight
  26369. // manually read margins because getBoundingClientRect includes difference
  26370. var marginTop = parseInt($tip.css('margin-top'), 10)
  26371. var marginLeft = parseInt($tip.css('margin-left'), 10)
  26372. // we must check for NaN for ie 8/9
  26373. if (isNaN(marginTop)) marginTop = 0
  26374. if (isNaN(marginLeft)) marginLeft = 0
  26375. offset.top += marginTop
  26376. offset.left += marginLeft
  26377. // $.fn.offset doesn't round pixel values
  26378. // so we use setOffset directly with our own function B-0
  26379. $.offset.setOffset($tip[0], $.extend({
  26380. using: function (props) {
  26381. $tip.css({
  26382. top: Math.round(props.top),
  26383. left: Math.round(props.left)
  26384. })
  26385. }
  26386. }, offset), 0)
  26387. $tip.addClass('in')
  26388. // check to see if placing tip in new offset caused the tip to resize itself
  26389. var actualWidth = $tip[0].offsetWidth
  26390. var actualHeight = $tip[0].offsetHeight
  26391. if (placement == 'top' && actualHeight != height) {
  26392. offset.top = offset.top + height - actualHeight
  26393. }
  26394. var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
  26395. if (delta.left) offset.left += delta.left
  26396. else offset.top += delta.top
  26397. var isVertical = /top|bottom/.test(placement)
  26398. var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
  26399. var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
  26400. $tip.offset(offset)
  26401. this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
  26402. }
  26403. Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
  26404. this.arrow()
  26405. .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
  26406. .css(isVertical ? 'top' : 'left', '')
  26407. }
  26408. Tooltip.prototype.setContent = function () {
  26409. var $tip = this.tip()
  26410. var title = this.getTitle()
  26411. $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  26412. $tip.removeClass('fade in top bottom left right')
  26413. }
  26414. Tooltip.prototype.hide = function (callback) {
  26415. var that = this
  26416. var $tip = $(this.$tip)
  26417. var e = $.Event('hide.bs.' + this.type)
  26418. function complete() {
  26419. if (that.hoverState != 'in') $tip.detach()
  26420. if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
  26421. that.$element
  26422. .removeAttr('aria-describedby')
  26423. .trigger('hidden.bs.' + that.type)
  26424. }
  26425. callback && callback()
  26426. }
  26427. this.$element.trigger(e)
  26428. if (e.isDefaultPrevented()) return
  26429. $tip.removeClass('in')
  26430. $.support.transition && $tip.hasClass('fade') ?
  26431. $tip
  26432. .one('bsTransitionEnd', complete)
  26433. .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
  26434. complete()
  26435. this.hoverState = null
  26436. return this
  26437. }
  26438. Tooltip.prototype.fixTitle = function () {
  26439. var $e = this.$element
  26440. if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
  26441. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  26442. }
  26443. }
  26444. Tooltip.prototype.hasContent = function () {
  26445. return this.getTitle()
  26446. }
  26447. Tooltip.prototype.getPosition = function ($element) {
  26448. $element = $element || this.$element
  26449. var el = $element[0]
  26450. var isBody = el.tagName == 'BODY'
  26451. var elRect = el.getBoundingClientRect()
  26452. if (elRect.width == null) {
  26453. // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
  26454. elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
  26455. }
  26456. var isSvg = window.SVGElement && el instanceof window.SVGElement
  26457. // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
  26458. // See https://github.com/twbs/bootstrap/issues/20280
  26459. var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
  26460. var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
  26461. var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
  26462. return $.extend({}, elRect, scroll, outerDims, elOffset)
  26463. }
  26464. Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
  26465. return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  26466. placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  26467. placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
  26468. /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
  26469. }
  26470. Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
  26471. var delta = { top: 0, left: 0 }
  26472. if (!this.$viewport) return delta
  26473. var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
  26474. var viewportDimensions = this.getPosition(this.$viewport)
  26475. if (/right|left/.test(placement)) {
  26476. var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
  26477. var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
  26478. if (topEdgeOffset < viewportDimensions.top) { // top overflow
  26479. delta.top = viewportDimensions.top - topEdgeOffset
  26480. } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
  26481. delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
  26482. }
  26483. } else {
  26484. var leftEdgeOffset = pos.left - viewportPadding
  26485. var rightEdgeOffset = pos.left + viewportPadding + actualWidth
  26486. if (leftEdgeOffset < viewportDimensions.left) { // left overflow
  26487. delta.left = viewportDimensions.left - leftEdgeOffset
  26488. } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
  26489. delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
  26490. }
  26491. }
  26492. return delta
  26493. }
  26494. Tooltip.prototype.getTitle = function () {
  26495. var title
  26496. var $e = this.$element
  26497. var o = this.options
  26498. title = $e.attr('data-original-title')
  26499. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  26500. return title
  26501. }
  26502. Tooltip.prototype.getUID = function (prefix) {
  26503. do prefix += ~~(Math.random() * 1000000)
  26504. while (document.getElementById(prefix))
  26505. return prefix
  26506. }
  26507. Tooltip.prototype.tip = function () {
  26508. if (!this.$tip) {
  26509. this.$tip = $(this.options.template)
  26510. if (this.$tip.length != 1) {
  26511. throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
  26512. }
  26513. }
  26514. return this.$tip
  26515. }
  26516. Tooltip.prototype.arrow = function () {
  26517. return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
  26518. }
  26519. Tooltip.prototype.enable = function () {
  26520. this.enabled = true
  26521. }
  26522. Tooltip.prototype.disable = function () {
  26523. this.enabled = false
  26524. }
  26525. Tooltip.prototype.toggleEnabled = function () {
  26526. this.enabled = !this.enabled
  26527. }
  26528. Tooltip.prototype.toggle = function (e) {
  26529. var self = this
  26530. if (e) {
  26531. self = $(e.currentTarget).data('bs.' + this.type)
  26532. if (!self) {
  26533. self = new this.constructor(e.currentTarget, this.getDelegateOptions())
  26534. $(e.currentTarget).data('bs.' + this.type, self)
  26535. }
  26536. }
  26537. if (e) {
  26538. self.inState.click = !self.inState.click
  26539. if (self.isInStateTrue()) self.enter(self)
  26540. else self.leave(self)
  26541. } else {
  26542. self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  26543. }
  26544. }
  26545. Tooltip.prototype.destroy = function () {
  26546. var that = this
  26547. clearTimeout(this.timeout)
  26548. this.hide(function () {
  26549. that.$element.off('.' + that.type).removeData('bs.' + that.type)
  26550. if (that.$tip) {
  26551. that.$tip.detach()
  26552. }
  26553. that.$tip = null
  26554. that.$arrow = null
  26555. that.$viewport = null
  26556. that.$element = null
  26557. })
  26558. }
  26559. // TOOLTIP PLUGIN DEFINITION
  26560. // =========================
  26561. function Plugin(option) {
  26562. return this.each(function () {
  26563. var $this = $(this)
  26564. var data = $this.data('bs.tooltip')
  26565. var options = typeof option == 'object' && option
  26566. if (!data && /destroy|hide/.test(option)) return
  26567. if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
  26568. if (typeof option == 'string') data[option]()
  26569. })
  26570. }
  26571. var old = $.fn.tooltip
  26572. $.fn.tooltip = Plugin
  26573. $.fn.tooltip.Constructor = Tooltip
  26574. // TOOLTIP NO CONFLICT
  26575. // ===================
  26576. $.fn.tooltip.noConflict = function () {
  26577. $.fn.tooltip = old
  26578. return this
  26579. }
  26580. }(jQuery);
  26581. /* ========================================================================
  26582. * Bootstrap: popover.js v3.3.7
  26583. * http://getbootstrap.com/javascript/#popovers
  26584. * ========================================================================
  26585. * Copyright 2011-2016 Twitter, Inc.
  26586. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26587. * ======================================================================== */
  26588. +function ($) {
  26589. 'use strict';
  26590. // POPOVER PUBLIC CLASS DEFINITION
  26591. // ===============================
  26592. var Popover = function (element, options) {
  26593. this.init('popover', element, options)
  26594. }
  26595. if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
  26596. Popover.VERSION = '3.3.7'
  26597. Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
  26598. placement: 'right',
  26599. trigger: 'click',
  26600. content: '',
  26601. template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  26602. })
  26603. // NOTE: POPOVER EXTENDS tooltip.js
  26604. // ================================
  26605. Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
  26606. Popover.prototype.constructor = Popover
  26607. Popover.prototype.getDefaults = function () {
  26608. return Popover.DEFAULTS
  26609. }
  26610. Popover.prototype.setContent = function () {
  26611. var $tip = this.tip()
  26612. var title = this.getTitle()
  26613. var content = this.getContent()
  26614. $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
  26615. $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
  26616. this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
  26617. ](content)
  26618. $tip.removeClass('fade top bottom left right in')
  26619. // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
  26620. // this manually by checking the contents.
  26621. if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
  26622. }
  26623. Popover.prototype.hasContent = function () {
  26624. return this.getTitle() || this.getContent()
  26625. }
  26626. Popover.prototype.getContent = function () {
  26627. var $e = this.$element
  26628. var o = this.options
  26629. return $e.attr('data-content')
  26630. || (typeof o.content == 'function' ?
  26631. o.content.call($e[0]) :
  26632. o.content)
  26633. }
  26634. Popover.prototype.arrow = function () {
  26635. return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  26636. }
  26637. // POPOVER PLUGIN DEFINITION
  26638. // =========================
  26639. function Plugin(option) {
  26640. return this.each(function () {
  26641. var $this = $(this)
  26642. var data = $this.data('bs.popover')
  26643. var options = typeof option == 'object' && option
  26644. if (!data && /destroy|hide/.test(option)) return
  26645. if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
  26646. if (typeof option == 'string') data[option]()
  26647. })
  26648. }
  26649. var old = $.fn.popover
  26650. $.fn.popover = Plugin
  26651. $.fn.popover.Constructor = Popover
  26652. // POPOVER NO CONFLICT
  26653. // ===================
  26654. $.fn.popover.noConflict = function () {
  26655. $.fn.popover = old
  26656. return this
  26657. }
  26658. }(jQuery);
  26659. /* ========================================================================
  26660. * Bootstrap: scrollspy.js v3.3.7
  26661. * http://getbootstrap.com/javascript/#scrollspy
  26662. * ========================================================================
  26663. * Copyright 2011-2016 Twitter, Inc.
  26664. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26665. * ======================================================================== */
  26666. +function ($) {
  26667. 'use strict';
  26668. // SCROLLSPY CLASS DEFINITION
  26669. // ==========================
  26670. function ScrollSpy(element, options) {
  26671. this.$body = $(document.body)
  26672. this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)
  26673. this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
  26674. this.selector = (this.options.target || '') + ' .nav li > a'
  26675. this.offsets = []
  26676. this.targets = []
  26677. this.activeTarget = null
  26678. this.scrollHeight = 0
  26679. this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))
  26680. this.refresh()
  26681. this.process()
  26682. }
  26683. ScrollSpy.VERSION = '3.3.7'
  26684. ScrollSpy.DEFAULTS = {
  26685. offset: 10
  26686. }
  26687. ScrollSpy.prototype.getScrollHeight = function () {
  26688. return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
  26689. }
  26690. ScrollSpy.prototype.refresh = function () {
  26691. var that = this
  26692. var offsetMethod = 'offset'
  26693. var offsetBase = 0
  26694. this.offsets = []
  26695. this.targets = []
  26696. this.scrollHeight = this.getScrollHeight()
  26697. if (!$.isWindow(this.$scrollElement[0])) {
  26698. offsetMethod = 'position'
  26699. offsetBase = this.$scrollElement.scrollTop()
  26700. }
  26701. this.$body
  26702. .find(this.selector)
  26703. .map(function () {
  26704. var $el = $(this)
  26705. var href = $el.data('target') || $el.attr('href')
  26706. var $href = /^#./.test(href) && $(href)
  26707. return ($href
  26708. && $href.length
  26709. && $href.is(':visible')
  26710. && [[$href[offsetMethod]().top + offsetBase, href]]) || null
  26711. })
  26712. .sort(function (a, b) { return a[0] - b[0] })
  26713. .each(function () {
  26714. that.offsets.push(this[0])
  26715. that.targets.push(this[1])
  26716. })
  26717. }
  26718. ScrollSpy.prototype.process = function () {
  26719. var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
  26720. var scrollHeight = this.getScrollHeight()
  26721. var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
  26722. var offsets = this.offsets
  26723. var targets = this.targets
  26724. var activeTarget = this.activeTarget
  26725. var i
  26726. if (this.scrollHeight != scrollHeight) {
  26727. this.refresh()
  26728. }
  26729. if (scrollTop >= maxScroll) {
  26730. return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
  26731. }
  26732. if (activeTarget && scrollTop < offsets[0]) {
  26733. this.activeTarget = null
  26734. return this.clear()
  26735. }
  26736. for (i = offsets.length; i--;) {
  26737. activeTarget != targets[i]
  26738. && scrollTop >= offsets[i]
  26739. && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1])
  26740. && this.activate(targets[i])
  26741. }
  26742. }
  26743. ScrollSpy.prototype.activate = function (target) {
  26744. this.activeTarget = target
  26745. this.clear()
  26746. var selector = this.selector +
  26747. '[data-target="' + target + '"],' +
  26748. this.selector + '[href="' + target + '"]'
  26749. var active = $(selector)
  26750. .parents('li')
  26751. .addClass('active')
  26752. if (active.parent('.dropdown-menu').length) {
  26753. active = active
  26754. .closest('li.dropdown')
  26755. .addClass('active')
  26756. }
  26757. active.trigger('activate.bs.scrollspy')
  26758. }
  26759. ScrollSpy.prototype.clear = function () {
  26760. $(this.selector)
  26761. .parentsUntil(this.options.target, '.active')
  26762. .removeClass('active')
  26763. }
  26764. // SCROLLSPY PLUGIN DEFINITION
  26765. // ===========================
  26766. function Plugin(option) {
  26767. return this.each(function () {
  26768. var $this = $(this)
  26769. var data = $this.data('bs.scrollspy')
  26770. var options = typeof option == 'object' && option
  26771. if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
  26772. if (typeof option == 'string') data[option]()
  26773. })
  26774. }
  26775. var old = $.fn.scrollspy
  26776. $.fn.scrollspy = Plugin
  26777. $.fn.scrollspy.Constructor = ScrollSpy
  26778. // SCROLLSPY NO CONFLICT
  26779. // =====================
  26780. $.fn.scrollspy.noConflict = function () {
  26781. $.fn.scrollspy = old
  26782. return this
  26783. }
  26784. // SCROLLSPY DATA-API
  26785. // ==================
  26786. $(window).on('load.bs.scrollspy.data-api', function () {
  26787. $('[data-spy="scroll"]').each(function () {
  26788. var $spy = $(this)
  26789. Plugin.call($spy, $spy.data())
  26790. })
  26791. })
  26792. }(jQuery);
  26793. /* ========================================================================
  26794. * Bootstrap: tab.js v3.3.7
  26795. * http://getbootstrap.com/javascript/#tabs
  26796. * ========================================================================
  26797. * Copyright 2011-2016 Twitter, Inc.
  26798. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26799. * ======================================================================== */
  26800. +function ($) {
  26801. 'use strict';
  26802. // TAB CLASS DEFINITION
  26803. // ====================
  26804. var Tab = function (element) {
  26805. // jscs:disable requireDollarBeforejQueryAssignment
  26806. this.element = $(element)
  26807. // jscs:enable requireDollarBeforejQueryAssignment
  26808. }
  26809. Tab.VERSION = '3.3.7'
  26810. Tab.TRANSITION_DURATION = 150
  26811. Tab.prototype.show = function () {
  26812. var $this = this.element
  26813. var $ul = $this.closest('ul:not(.dropdown-menu)')
  26814. var selector = $this.data('target')
  26815. if (!selector) {
  26816. selector = $this.attr('href')
  26817. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  26818. }
  26819. if ($this.parent('li').hasClass('active')) return
  26820. var $previous = $ul.find('.active:last a')
  26821. var hideEvent = $.Event('hide.bs.tab', {
  26822. relatedTarget: $this[0]
  26823. })
  26824. var showEvent = $.Event('show.bs.tab', {
  26825. relatedTarget: $previous[0]
  26826. })
  26827. $previous.trigger(hideEvent)
  26828. $this.trigger(showEvent)
  26829. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
  26830. var $target = $(selector)
  26831. this.activate($this.closest('li'), $ul)
  26832. this.activate($target, $target.parent(), function () {
  26833. $previous.trigger({
  26834. type: 'hidden.bs.tab',
  26835. relatedTarget: $this[0]
  26836. })
  26837. $this.trigger({
  26838. type: 'shown.bs.tab',
  26839. relatedTarget: $previous[0]
  26840. })
  26841. })
  26842. }
  26843. Tab.prototype.activate = function (element, container, callback) {
  26844. var $active = container.find('> .active')
  26845. var transition = callback
  26846. && $.support.transition
  26847. && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
  26848. function next() {
  26849. $active
  26850. .removeClass('active')
  26851. .find('> .dropdown-menu > .active')
  26852. .removeClass('active')
  26853. .end()
  26854. .find('[data-toggle="tab"]')
  26855. .attr('aria-expanded', false)
  26856. element
  26857. .addClass('active')
  26858. .find('[data-toggle="tab"]')
  26859. .attr('aria-expanded', true)
  26860. if (transition) {
  26861. element[0].offsetWidth // reflow for transition
  26862. element.addClass('in')
  26863. } else {
  26864. element.removeClass('fade')
  26865. }
  26866. if (element.parent('.dropdown-menu').length) {
  26867. element
  26868. .closest('li.dropdown')
  26869. .addClass('active')
  26870. .end()
  26871. .find('[data-toggle="tab"]')
  26872. .attr('aria-expanded', true)
  26873. }
  26874. callback && callback()
  26875. }
  26876. $active.length && transition ?
  26877. $active
  26878. .one('bsTransitionEnd', next)
  26879. .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
  26880. next()
  26881. $active.removeClass('in')
  26882. }
  26883. // TAB PLUGIN DEFINITION
  26884. // =====================
  26885. function Plugin(option) {
  26886. return this.each(function () {
  26887. var $this = $(this)
  26888. var data = $this.data('bs.tab')
  26889. if (!data) $this.data('bs.tab', (data = new Tab(this)))
  26890. if (typeof option == 'string') data[option]()
  26891. })
  26892. }
  26893. var old = $.fn.tab
  26894. $.fn.tab = Plugin
  26895. $.fn.tab.Constructor = Tab
  26896. // TAB NO CONFLICT
  26897. // ===============
  26898. $.fn.tab.noConflict = function () {
  26899. $.fn.tab = old
  26900. return this
  26901. }
  26902. // TAB DATA-API
  26903. // ============
  26904. var clickHandler = function (e) {
  26905. e.preventDefault()
  26906. Plugin.call($(this), 'show')
  26907. }
  26908. $(document)
  26909. .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
  26910. .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
  26911. }(jQuery);
  26912. /* ========================================================================
  26913. * Bootstrap: affix.js v3.3.7
  26914. * http://getbootstrap.com/javascript/#affix
  26915. * ========================================================================
  26916. * Copyright 2011-2016 Twitter, Inc.
  26917. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  26918. * ======================================================================== */
  26919. +function ($) {
  26920. 'use strict';
  26921. // AFFIX CLASS DEFINITION
  26922. // ======================
  26923. var Affix = function (element, options) {
  26924. this.options = $.extend({}, Affix.DEFAULTS, options)
  26925. this.$target = $(this.options.target)
  26926. .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
  26927. .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
  26928. this.$element = $(element)
  26929. this.affixed = null
  26930. this.unpin = null
  26931. this.pinnedOffset = null
  26932. this.checkPosition()
  26933. }
  26934. Affix.VERSION = '3.3.7'
  26935. Affix.RESET = 'affix affix-top affix-bottom'
  26936. Affix.DEFAULTS = {
  26937. offset: 0,
  26938. target: window
  26939. }
  26940. Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
  26941. var scrollTop = this.$target.scrollTop()
  26942. var position = this.$element.offset()
  26943. var targetHeight = this.$target.height()
  26944. if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false
  26945. if (this.affixed == 'bottom') {
  26946. if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
  26947. return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
  26948. }
  26949. var initializing = this.affixed == null
  26950. var colliderTop = initializing ? scrollTop : position.top
  26951. var colliderHeight = initializing ? targetHeight : height
  26952. if (offsetTop != null && scrollTop <= offsetTop) return 'top'
  26953. if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
  26954. return false
  26955. }
  26956. Affix.prototype.getPinnedOffset = function () {
  26957. if (this.pinnedOffset) return this.pinnedOffset
  26958. this.$element.removeClass(Affix.RESET).addClass('affix')
  26959. var scrollTop = this.$target.scrollTop()
  26960. var position = this.$element.offset()
  26961. return (this.pinnedOffset = position.top - scrollTop)
  26962. }
  26963. Affix.prototype.checkPositionWithEventLoop = function () {
  26964. setTimeout($.proxy(this.checkPosition, this), 1)
  26965. }
  26966. Affix.prototype.checkPosition = function () {
  26967. if (!this.$element.is(':visible')) return
  26968. var height = this.$element.height()
  26969. var offset = this.options.offset
  26970. var offsetTop = offset.top
  26971. var offsetBottom = offset.bottom
  26972. var scrollHeight = Math.max($(document).height(), $(document.body).height())
  26973. if (typeof offset != 'object') offsetBottom = offsetTop = offset
  26974. if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
  26975. if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
  26976. var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)
  26977. if (this.affixed != affix) {
  26978. if (this.unpin != null) this.$element.css('top', '')
  26979. var affixType = 'affix' + (affix ? '-' + affix : '')
  26980. var e = $.Event(affixType + '.bs.affix')
  26981. this.$element.trigger(e)
  26982. if (e.isDefaultPrevented()) return
  26983. this.affixed = affix
  26984. this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
  26985. this.$element
  26986. .removeClass(Affix.RESET)
  26987. .addClass(affixType)
  26988. .trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
  26989. }
  26990. if (affix == 'bottom') {
  26991. this.$element.offset({
  26992. top: scrollHeight - height - offsetBottom
  26993. })
  26994. }
  26995. }
  26996. // AFFIX PLUGIN DEFINITION
  26997. // =======================
  26998. function Plugin(option) {
  26999. return this.each(function () {
  27000. var $this = $(this)
  27001. var data = $this.data('bs.affix')
  27002. var options = typeof option == 'object' && option
  27003. if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
  27004. if (typeof option == 'string') data[option]()
  27005. })
  27006. }
  27007. var old = $.fn.affix
  27008. $.fn.affix = Plugin
  27009. $.fn.affix.Constructor = Affix
  27010. // AFFIX NO CONFLICT
  27011. // =================
  27012. $.fn.affix.noConflict = function () {
  27013. $.fn.affix = old
  27014. return this
  27015. }
  27016. // AFFIX DATA-API
  27017. // ==============
  27018. $(window).on('load', function () {
  27019. $('[data-spy="affix"]').each(function () {
  27020. var $spy = $(this)
  27021. var data = $spy.data()
  27022. data.offset = data.offset || {}
  27023. if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
  27024. if (data.offsetTop != null) data.offset.top = data.offsetTop
  27025. Plugin.call($spy, data)
  27026. })
  27027. })
  27028. }(jQuery);
  27029. /***/ }),
  27030. /* 16 */
  27031. /***/ (function(module, exports, __webpack_require__) {
  27032. module.exports = __webpack_require__(17);
  27033. /***/ }),
  27034. /* 17 */
  27035. /***/ (function(module, exports, __webpack_require__) {
  27036. "use strict";
  27037. var utils = __webpack_require__(0);
  27038. var bind = __webpack_require__(3);
  27039. var Axios = __webpack_require__(19);
  27040. var defaults = __webpack_require__(1);
  27041. /**
  27042. * Create an instance of Axios
  27043. *
  27044. * @param {Object} defaultConfig The default config for the instance
  27045. * @return {Axios} A new instance of Axios
  27046. */
  27047. function createInstance(defaultConfig) {
  27048. var context = new Axios(defaultConfig);
  27049. var instance = bind(Axios.prototype.request, context);
  27050. // Copy axios.prototype to instance
  27051. utils.extend(instance, Axios.prototype, context);
  27052. // Copy context to instance
  27053. utils.extend(instance, context);
  27054. return instance;
  27055. }
  27056. // Create the default instance to be exported
  27057. var axios = createInstance(defaults);
  27058. // Expose Axios class to allow class inheritance
  27059. axios.Axios = Axios;
  27060. // Factory for creating new instances
  27061. axios.create = function create(instanceConfig) {
  27062. return createInstance(utils.merge(defaults, instanceConfig));
  27063. };
  27064. // Expose Cancel & CancelToken
  27065. axios.Cancel = __webpack_require__(7);
  27066. axios.CancelToken = __webpack_require__(34);
  27067. axios.isCancel = __webpack_require__(6);
  27068. // Expose all/spread
  27069. axios.all = function all(promises) {
  27070. return Promise.all(promises);
  27071. };
  27072. axios.spread = __webpack_require__(35);
  27073. module.exports = axios;
  27074. // Allow use of default import syntax in TypeScript
  27075. module.exports.default = axios;
  27076. /***/ }),
  27077. /* 18 */
  27078. /***/ (function(module, exports) {
  27079. /*!
  27080. * Determine if an object is a Buffer
  27081. *
  27082. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  27083. * @license MIT
  27084. */
  27085. // The _isBuffer check is for Safari 5-7 support, because it's missing
  27086. // Object.prototype.constructor. Remove this eventually
  27087. module.exports = function (obj) {
  27088. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  27089. }
  27090. function isBuffer (obj) {
  27091. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  27092. }
  27093. // For Node v0.10 support. Remove this eventually.
  27094. function isSlowBuffer (obj) {
  27095. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  27096. }
  27097. /***/ }),
  27098. /* 19 */
  27099. /***/ (function(module, exports, __webpack_require__) {
  27100. "use strict";
  27101. var defaults = __webpack_require__(1);
  27102. var utils = __webpack_require__(0);
  27103. var InterceptorManager = __webpack_require__(29);
  27104. var dispatchRequest = __webpack_require__(30);
  27105. var isAbsoluteURL = __webpack_require__(32);
  27106. var combineURLs = __webpack_require__(33);
  27107. /**
  27108. * Create a new instance of Axios
  27109. *
  27110. * @param {Object} instanceConfig The default config for the instance
  27111. */
  27112. function Axios(instanceConfig) {
  27113. this.defaults = instanceConfig;
  27114. this.interceptors = {
  27115. request: new InterceptorManager(),
  27116. response: new InterceptorManager()
  27117. };
  27118. }
  27119. /**
  27120. * Dispatch a request
  27121. *
  27122. * @param {Object} config The config specific for this request (merged with this.defaults)
  27123. */
  27124. Axios.prototype.request = function request(config) {
  27125. /*eslint no-param-reassign:0*/
  27126. // Allow for axios('example/url'[, config]) a la fetch API
  27127. if (typeof config === 'string') {
  27128. config = utils.merge({
  27129. url: arguments[0]
  27130. }, arguments[1]);
  27131. }
  27132. config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
  27133. config.method = config.method.toLowerCase();
  27134. // Support baseURL config
  27135. if (config.baseURL && !isAbsoluteURL(config.url)) {
  27136. config.url = combineURLs(config.baseURL, config.url);
  27137. }
  27138. // Hook up interceptors middleware
  27139. var chain = [dispatchRequest, undefined];
  27140. var promise = Promise.resolve(config);
  27141. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  27142. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  27143. });
  27144. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  27145. chain.push(interceptor.fulfilled, interceptor.rejected);
  27146. });
  27147. while (chain.length) {
  27148. promise = promise.then(chain.shift(), chain.shift());
  27149. }
  27150. return promise;
  27151. };
  27152. // Provide aliases for supported request methods
  27153. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  27154. /*eslint func-names:0*/
  27155. Axios.prototype[method] = function(url, config) {
  27156. return this.request(utils.merge(config || {}, {
  27157. method: method,
  27158. url: url
  27159. }));
  27160. };
  27161. });
  27162. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  27163. /*eslint func-names:0*/
  27164. Axios.prototype[method] = function(url, data, config) {
  27165. return this.request(utils.merge(config || {}, {
  27166. method: method,
  27167. url: url,
  27168. data: data
  27169. }));
  27170. };
  27171. });
  27172. module.exports = Axios;
  27173. /***/ }),
  27174. /* 20 */
  27175. /***/ (function(module, exports) {
  27176. // shim for using process in browser
  27177. var process = module.exports = {};
  27178. // cached from whatever global is present so that test runners that stub it
  27179. // don't break things. But we need to wrap it in a try catch in case it is
  27180. // wrapped in strict mode code which doesn't define any globals. It's inside a
  27181. // function because try/catches deoptimize in certain engines.
  27182. var cachedSetTimeout;
  27183. var cachedClearTimeout;
  27184. function defaultSetTimout() {
  27185. throw new Error('setTimeout has not been defined');
  27186. }
  27187. function defaultClearTimeout () {
  27188. throw new Error('clearTimeout has not been defined');
  27189. }
  27190. (function () {
  27191. try {
  27192. if (typeof setTimeout === 'function') {
  27193. cachedSetTimeout = setTimeout;
  27194. } else {
  27195. cachedSetTimeout = defaultSetTimout;
  27196. }
  27197. } catch (e) {
  27198. cachedSetTimeout = defaultSetTimout;
  27199. }
  27200. try {
  27201. if (typeof clearTimeout === 'function') {
  27202. cachedClearTimeout = clearTimeout;
  27203. } else {
  27204. cachedClearTimeout = defaultClearTimeout;
  27205. }
  27206. } catch (e) {
  27207. cachedClearTimeout = defaultClearTimeout;
  27208. }
  27209. } ())
  27210. function runTimeout(fun) {
  27211. if (cachedSetTimeout === setTimeout) {
  27212. //normal enviroments in sane situations
  27213. return setTimeout(fun, 0);
  27214. }
  27215. // if setTimeout wasn't available but was latter defined
  27216. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  27217. cachedSetTimeout = setTimeout;
  27218. return setTimeout(fun, 0);
  27219. }
  27220. try {
  27221. // when when somebody has screwed with setTimeout but no I.E. maddness
  27222. return cachedSetTimeout(fun, 0);
  27223. } catch(e){
  27224. try {
  27225. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  27226. return cachedSetTimeout.call(null, fun, 0);
  27227. } catch(e){
  27228. // 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
  27229. return cachedSetTimeout.call(this, fun, 0);
  27230. }
  27231. }
  27232. }
  27233. function runClearTimeout(marker) {
  27234. if (cachedClearTimeout === clearTimeout) {
  27235. //normal enviroments in sane situations
  27236. return clearTimeout(marker);
  27237. }
  27238. // if clearTimeout wasn't available but was latter defined
  27239. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  27240. cachedClearTimeout = clearTimeout;
  27241. return clearTimeout(marker);
  27242. }
  27243. try {
  27244. // when when somebody has screwed with setTimeout but no I.E. maddness
  27245. return cachedClearTimeout(marker);
  27246. } catch (e){
  27247. try {
  27248. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  27249. return cachedClearTimeout.call(null, marker);
  27250. } catch (e){
  27251. // 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.
  27252. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  27253. return cachedClearTimeout.call(this, marker);
  27254. }
  27255. }
  27256. }
  27257. var queue = [];
  27258. var draining = false;
  27259. var currentQueue;
  27260. var queueIndex = -1;
  27261. function cleanUpNextTick() {
  27262. if (!draining || !currentQueue) {
  27263. return;
  27264. }
  27265. draining = false;
  27266. if (currentQueue.length) {
  27267. queue = currentQueue.concat(queue);
  27268. } else {
  27269. queueIndex = -1;
  27270. }
  27271. if (queue.length) {
  27272. drainQueue();
  27273. }
  27274. }
  27275. function drainQueue() {
  27276. if (draining) {
  27277. return;
  27278. }
  27279. var timeout = runTimeout(cleanUpNextTick);
  27280. draining = true;
  27281. var len = queue.length;
  27282. while(len) {
  27283. currentQueue = queue;
  27284. queue = [];
  27285. while (++queueIndex < len) {
  27286. if (currentQueue) {
  27287. currentQueue[queueIndex].run();
  27288. }
  27289. }
  27290. queueIndex = -1;
  27291. len = queue.length;
  27292. }
  27293. currentQueue = null;
  27294. draining = false;
  27295. runClearTimeout(timeout);
  27296. }
  27297. process.nextTick = function (fun) {
  27298. var args = new Array(arguments.length - 1);
  27299. if (arguments.length > 1) {
  27300. for (var i = 1; i < arguments.length; i++) {
  27301. args[i - 1] = arguments[i];
  27302. }
  27303. }
  27304. queue.push(new Item(fun, args));
  27305. if (queue.length === 1 && !draining) {
  27306. runTimeout(drainQueue);
  27307. }
  27308. };
  27309. // v8 likes predictible objects
  27310. function Item(fun, array) {
  27311. this.fun = fun;
  27312. this.array = array;
  27313. }
  27314. Item.prototype.run = function () {
  27315. this.fun.apply(null, this.array);
  27316. };
  27317. process.title = 'browser';
  27318. process.browser = true;
  27319. process.env = {};
  27320. process.argv = [];
  27321. process.version = ''; // empty string to avoid regexp issues
  27322. process.versions = {};
  27323. function noop() {}
  27324. process.on = noop;
  27325. process.addListener = noop;
  27326. process.once = noop;
  27327. process.off = noop;
  27328. process.removeListener = noop;
  27329. process.removeAllListeners = noop;
  27330. process.emit = noop;
  27331. process.prependListener = noop;
  27332. process.prependOnceListener = noop;
  27333. process.listeners = function (name) { return [] }
  27334. process.binding = function (name) {
  27335. throw new Error('process.binding is not supported');
  27336. };
  27337. process.cwd = function () { return '/' };
  27338. process.chdir = function (dir) {
  27339. throw new Error('process.chdir is not supported');
  27340. };
  27341. process.umask = function() { return 0; };
  27342. /***/ }),
  27343. /* 21 */
  27344. /***/ (function(module, exports, __webpack_require__) {
  27345. "use strict";
  27346. var utils = __webpack_require__(0);
  27347. module.exports = function normalizeHeaderName(headers, normalizedName) {
  27348. utils.forEach(headers, function processHeader(value, name) {
  27349. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  27350. headers[normalizedName] = value;
  27351. delete headers[name];
  27352. }
  27353. });
  27354. };
  27355. /***/ }),
  27356. /* 22 */
  27357. /***/ (function(module, exports, __webpack_require__) {
  27358. "use strict";
  27359. var createError = __webpack_require__(5);
  27360. /**
  27361. * Resolve or reject a Promise based on response status.
  27362. *
  27363. * @param {Function} resolve A function that resolves the promise.
  27364. * @param {Function} reject A function that rejects the promise.
  27365. * @param {object} response The response.
  27366. */
  27367. module.exports = function settle(resolve, reject, response) {
  27368. var validateStatus = response.config.validateStatus;
  27369. // Note: status is not exposed by XDomainRequest
  27370. if (!response.status || !validateStatus || validateStatus(response.status)) {
  27371. resolve(response);
  27372. } else {
  27373. reject(createError(
  27374. 'Request failed with status code ' + response.status,
  27375. response.config,
  27376. null,
  27377. response.request,
  27378. response
  27379. ));
  27380. }
  27381. };
  27382. /***/ }),
  27383. /* 23 */
  27384. /***/ (function(module, exports, __webpack_require__) {
  27385. "use strict";
  27386. /**
  27387. * Update an Error with the specified config, error code, and response.
  27388. *
  27389. * @param {Error} error The error to update.
  27390. * @param {Object} config The config.
  27391. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  27392. * @param {Object} [request] The request.
  27393. * @param {Object} [response] The response.
  27394. * @returns {Error} The error.
  27395. */
  27396. module.exports = function enhanceError(error, config, code, request, response) {
  27397. error.config = config;
  27398. if (code) {
  27399. error.code = code;
  27400. }
  27401. error.request = request;
  27402. error.response = response;
  27403. return error;
  27404. };
  27405. /***/ }),
  27406. /* 24 */
  27407. /***/ (function(module, exports, __webpack_require__) {
  27408. "use strict";
  27409. var utils = __webpack_require__(0);
  27410. function encode(val) {
  27411. return encodeURIComponent(val).
  27412. replace(/%40/gi, '@').
  27413. replace(/%3A/gi, ':').
  27414. replace(/%24/g, '$').
  27415. replace(/%2C/gi, ',').
  27416. replace(/%20/g, '+').
  27417. replace(/%5B/gi, '[').
  27418. replace(/%5D/gi, ']');
  27419. }
  27420. /**
  27421. * Build a URL by appending params to the end
  27422. *
  27423. * @param {string} url The base of the url (e.g., http://www.google.com)
  27424. * @param {object} [params] The params to be appended
  27425. * @returns {string} The formatted url
  27426. */
  27427. module.exports = function buildURL(url, params, paramsSerializer) {
  27428. /*eslint no-param-reassign:0*/
  27429. if (!params) {
  27430. return url;
  27431. }
  27432. var serializedParams;
  27433. if (paramsSerializer) {
  27434. serializedParams = paramsSerializer(params);
  27435. } else if (utils.isURLSearchParams(params)) {
  27436. serializedParams = params.toString();
  27437. } else {
  27438. var parts = [];
  27439. utils.forEach(params, function serialize(val, key) {
  27440. if (val === null || typeof val === 'undefined') {
  27441. return;
  27442. }
  27443. if (utils.isArray(val)) {
  27444. key = key + '[]';
  27445. }
  27446. if (!utils.isArray(val)) {
  27447. val = [val];
  27448. }
  27449. utils.forEach(val, function parseValue(v) {
  27450. if (utils.isDate(v)) {
  27451. v = v.toISOString();
  27452. } else if (utils.isObject(v)) {
  27453. v = JSON.stringify(v);
  27454. }
  27455. parts.push(encode(key) + '=' + encode(v));
  27456. });
  27457. });
  27458. serializedParams = parts.join('&');
  27459. }
  27460. if (serializedParams) {
  27461. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  27462. }
  27463. return url;
  27464. };
  27465. /***/ }),
  27466. /* 25 */
  27467. /***/ (function(module, exports, __webpack_require__) {
  27468. "use strict";
  27469. var utils = __webpack_require__(0);
  27470. /**
  27471. * Parse headers into an object
  27472. *
  27473. * ```
  27474. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  27475. * Content-Type: application/json
  27476. * Connection: keep-alive
  27477. * Transfer-Encoding: chunked
  27478. * ```
  27479. *
  27480. * @param {String} headers Headers needing to be parsed
  27481. * @returns {Object} Headers parsed into an object
  27482. */
  27483. module.exports = function parseHeaders(headers) {
  27484. var parsed = {};
  27485. var key;
  27486. var val;
  27487. var i;
  27488. if (!headers) { return parsed; }
  27489. utils.forEach(headers.split('\n'), function parser(line) {
  27490. i = line.indexOf(':');
  27491. key = utils.trim(line.substr(0, i)).toLowerCase();
  27492. val = utils.trim(line.substr(i + 1));
  27493. if (key) {
  27494. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  27495. }
  27496. });
  27497. return parsed;
  27498. };
  27499. /***/ }),
  27500. /* 26 */
  27501. /***/ (function(module, exports, __webpack_require__) {
  27502. "use strict";
  27503. var utils = __webpack_require__(0);
  27504. module.exports = (
  27505. utils.isStandardBrowserEnv() ?
  27506. // Standard browser envs have full support of the APIs needed to test
  27507. // whether the request URL is of the same origin as current location.
  27508. (function standardBrowserEnv() {
  27509. var msie = /(msie|trident)/i.test(navigator.userAgent);
  27510. var urlParsingNode = document.createElement('a');
  27511. var originURL;
  27512. /**
  27513. * Parse a URL to discover it's components
  27514. *
  27515. * @param {String} url The URL to be parsed
  27516. * @returns {Object}
  27517. */
  27518. function resolveURL(url) {
  27519. var href = url;
  27520. if (msie) {
  27521. // IE needs attribute set twice to normalize properties
  27522. urlParsingNode.setAttribute('href', href);
  27523. href = urlParsingNode.href;
  27524. }
  27525. urlParsingNode.setAttribute('href', href);
  27526. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  27527. return {
  27528. href: urlParsingNode.href,
  27529. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  27530. host: urlParsingNode.host,
  27531. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  27532. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  27533. hostname: urlParsingNode.hostname,
  27534. port: urlParsingNode.port,
  27535. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  27536. urlParsingNode.pathname :
  27537. '/' + urlParsingNode.pathname
  27538. };
  27539. }
  27540. originURL = resolveURL(window.location.href);
  27541. /**
  27542. * Determine if a URL shares the same origin as the current location
  27543. *
  27544. * @param {String} requestURL The URL to test
  27545. * @returns {boolean} True if URL shares the same origin, otherwise false
  27546. */
  27547. return function isURLSameOrigin(requestURL) {
  27548. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  27549. return (parsed.protocol === originURL.protocol &&
  27550. parsed.host === originURL.host);
  27551. };
  27552. })() :
  27553. // Non standard browser envs (web workers, react-native) lack needed support.
  27554. (function nonStandardBrowserEnv() {
  27555. return function isURLSameOrigin() {
  27556. return true;
  27557. };
  27558. })()
  27559. );
  27560. /***/ }),
  27561. /* 27 */
  27562. /***/ (function(module, exports, __webpack_require__) {
  27563. "use strict";
  27564. // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
  27565. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  27566. function E() {
  27567. this.message = 'String contains an invalid character';
  27568. }
  27569. E.prototype = new Error;
  27570. E.prototype.code = 5;
  27571. E.prototype.name = 'InvalidCharacterError';
  27572. function btoa(input) {
  27573. var str = String(input);
  27574. var output = '';
  27575. for (
  27576. // initialize result and counter
  27577. var block, charCode, idx = 0, map = chars;
  27578. // if the next str index does not exist:
  27579. // change the mapping table to "="
  27580. // check if d has no fractional digits
  27581. str.charAt(idx | 0) || (map = '=', idx % 1);
  27582. // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
  27583. output += map.charAt(63 & block >> 8 - idx % 1 * 8)
  27584. ) {
  27585. charCode = str.charCodeAt(idx += 3 / 4);
  27586. if (charCode > 0xFF) {
  27587. throw new E();
  27588. }
  27589. block = block << 8 | charCode;
  27590. }
  27591. return output;
  27592. }
  27593. module.exports = btoa;
  27594. /***/ }),
  27595. /* 28 */
  27596. /***/ (function(module, exports, __webpack_require__) {
  27597. "use strict";
  27598. var utils = __webpack_require__(0);
  27599. module.exports = (
  27600. utils.isStandardBrowserEnv() ?
  27601. // Standard browser envs support document.cookie
  27602. (function standardBrowserEnv() {
  27603. return {
  27604. write: function write(name, value, expires, path, domain, secure) {
  27605. var cookie = [];
  27606. cookie.push(name + '=' + encodeURIComponent(value));
  27607. if (utils.isNumber(expires)) {
  27608. cookie.push('expires=' + new Date(expires).toGMTString());
  27609. }
  27610. if (utils.isString(path)) {
  27611. cookie.push('path=' + path);
  27612. }
  27613. if (utils.isString(domain)) {
  27614. cookie.push('domain=' + domain);
  27615. }
  27616. if (secure === true) {
  27617. cookie.push('secure');
  27618. }
  27619. document.cookie = cookie.join('; ');
  27620. },
  27621. read: function read(name) {
  27622. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  27623. return (match ? decodeURIComponent(match[3]) : null);
  27624. },
  27625. remove: function remove(name) {
  27626. this.write(name, '', Date.now() - 86400000);
  27627. }
  27628. };
  27629. })() :
  27630. // Non standard browser env (web workers, react-native) lack needed support.
  27631. (function nonStandardBrowserEnv() {
  27632. return {
  27633. write: function write() {},
  27634. read: function read() { return null; },
  27635. remove: function remove() {}
  27636. };
  27637. })()
  27638. );
  27639. /***/ }),
  27640. /* 29 */
  27641. /***/ (function(module, exports, __webpack_require__) {
  27642. "use strict";
  27643. var utils = __webpack_require__(0);
  27644. function InterceptorManager() {
  27645. this.handlers = [];
  27646. }
  27647. /**
  27648. * Add a new interceptor to the stack
  27649. *
  27650. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  27651. * @param {Function} rejected The function to handle `reject` for a `Promise`
  27652. *
  27653. * @return {Number} An ID used to remove interceptor later
  27654. */
  27655. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  27656. this.handlers.push({
  27657. fulfilled: fulfilled,
  27658. rejected: rejected
  27659. });
  27660. return this.handlers.length - 1;
  27661. };
  27662. /**
  27663. * Remove an interceptor from the stack
  27664. *
  27665. * @param {Number} id The ID that was returned by `use`
  27666. */
  27667. InterceptorManager.prototype.eject = function eject(id) {
  27668. if (this.handlers[id]) {
  27669. this.handlers[id] = null;
  27670. }
  27671. };
  27672. /**
  27673. * Iterate over all the registered interceptors
  27674. *
  27675. * This method is particularly useful for skipping over any
  27676. * interceptors that may have become `null` calling `eject`.
  27677. *
  27678. * @param {Function} fn The function to call for each interceptor
  27679. */
  27680. InterceptorManager.prototype.forEach = function forEach(fn) {
  27681. utils.forEach(this.handlers, function forEachHandler(h) {
  27682. if (h !== null) {
  27683. fn(h);
  27684. }
  27685. });
  27686. };
  27687. module.exports = InterceptorManager;
  27688. /***/ }),
  27689. /* 30 */
  27690. /***/ (function(module, exports, __webpack_require__) {
  27691. "use strict";
  27692. var utils = __webpack_require__(0);
  27693. var transformData = __webpack_require__(31);
  27694. var isCancel = __webpack_require__(6);
  27695. var defaults = __webpack_require__(1);
  27696. /**
  27697. * Throws a `Cancel` if cancellation has been requested.
  27698. */
  27699. function throwIfCancellationRequested(config) {
  27700. if (config.cancelToken) {
  27701. config.cancelToken.throwIfRequested();
  27702. }
  27703. }
  27704. /**
  27705. * Dispatch a request to the server using the configured adapter.
  27706. *
  27707. * @param {object} config The config that is to be used for the request
  27708. * @returns {Promise} The Promise to be fulfilled
  27709. */
  27710. module.exports = function dispatchRequest(config) {
  27711. throwIfCancellationRequested(config);
  27712. // Ensure headers exist
  27713. config.headers = config.headers || {};
  27714. // Transform request data
  27715. config.data = transformData(
  27716. config.data,
  27717. config.headers,
  27718. config.transformRequest
  27719. );
  27720. // Flatten headers
  27721. config.headers = utils.merge(
  27722. config.headers.common || {},
  27723. config.headers[config.method] || {},
  27724. config.headers || {}
  27725. );
  27726. utils.forEach(
  27727. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  27728. function cleanHeaderConfig(method) {
  27729. delete config.headers[method];
  27730. }
  27731. );
  27732. var adapter = config.adapter || defaults.adapter;
  27733. return adapter(config).then(function onAdapterResolution(response) {
  27734. throwIfCancellationRequested(config);
  27735. // Transform response data
  27736. response.data = transformData(
  27737. response.data,
  27738. response.headers,
  27739. config.transformResponse
  27740. );
  27741. return response;
  27742. }, function onAdapterRejection(reason) {
  27743. if (!isCancel(reason)) {
  27744. throwIfCancellationRequested(config);
  27745. // Transform response data
  27746. if (reason && reason.response) {
  27747. reason.response.data = transformData(
  27748. reason.response.data,
  27749. reason.response.headers,
  27750. config.transformResponse
  27751. );
  27752. }
  27753. }
  27754. return Promise.reject(reason);
  27755. });
  27756. };
  27757. /***/ }),
  27758. /* 31 */
  27759. /***/ (function(module, exports, __webpack_require__) {
  27760. "use strict";
  27761. var utils = __webpack_require__(0);
  27762. /**
  27763. * Transform the data for a request or a response
  27764. *
  27765. * @param {Object|String} data The data to be transformed
  27766. * @param {Array} headers The headers for the request or response
  27767. * @param {Array|Function} fns A single function or Array of functions
  27768. * @returns {*} The resulting transformed data
  27769. */
  27770. module.exports = function transformData(data, headers, fns) {
  27771. /*eslint no-param-reassign:0*/
  27772. utils.forEach(fns, function transform(fn) {
  27773. data = fn(data, headers);
  27774. });
  27775. return data;
  27776. };
  27777. /***/ }),
  27778. /* 32 */
  27779. /***/ (function(module, exports, __webpack_require__) {
  27780. "use strict";
  27781. /**
  27782. * Determines whether the specified URL is absolute
  27783. *
  27784. * @param {string} url The URL to test
  27785. * @returns {boolean} True if the specified URL is absolute, otherwise false
  27786. */
  27787. module.exports = function isAbsoluteURL(url) {
  27788. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  27789. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  27790. // by any combination of letters, digits, plus, period, or hyphen.
  27791. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  27792. };
  27793. /***/ }),
  27794. /* 33 */
  27795. /***/ (function(module, exports, __webpack_require__) {
  27796. "use strict";
  27797. /**
  27798. * Creates a new URL by combining the specified URLs
  27799. *
  27800. * @param {string} baseURL The base URL
  27801. * @param {string} relativeURL The relative URL
  27802. * @returns {string} The combined URL
  27803. */
  27804. module.exports = function combineURLs(baseURL, relativeURL) {
  27805. return relativeURL
  27806. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  27807. : baseURL;
  27808. };
  27809. /***/ }),
  27810. /* 34 */
  27811. /***/ (function(module, exports, __webpack_require__) {
  27812. "use strict";
  27813. var Cancel = __webpack_require__(7);
  27814. /**
  27815. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  27816. *
  27817. * @class
  27818. * @param {Function} executor The executor function.
  27819. */
  27820. function CancelToken(executor) {
  27821. if (typeof executor !== 'function') {
  27822. throw new TypeError('executor must be a function.');
  27823. }
  27824. var resolvePromise;
  27825. this.promise = new Promise(function promiseExecutor(resolve) {
  27826. resolvePromise = resolve;
  27827. });
  27828. var token = this;
  27829. executor(function cancel(message) {
  27830. if (token.reason) {
  27831. // Cancellation has already been requested
  27832. return;
  27833. }
  27834. token.reason = new Cancel(message);
  27835. resolvePromise(token.reason);
  27836. });
  27837. }
  27838. /**
  27839. * Throws a `Cancel` if cancellation has been requested.
  27840. */
  27841. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  27842. if (this.reason) {
  27843. throw this.reason;
  27844. }
  27845. };
  27846. /**
  27847. * Returns an object that contains a new `CancelToken` and a function that, when called,
  27848. * cancels the `CancelToken`.
  27849. */
  27850. CancelToken.source = function source() {
  27851. var cancel;
  27852. var token = new CancelToken(function executor(c) {
  27853. cancel = c;
  27854. });
  27855. return {
  27856. token: token,
  27857. cancel: cancel
  27858. };
  27859. };
  27860. module.exports = CancelToken;
  27861. /***/ }),
  27862. /* 35 */
  27863. /***/ (function(module, exports, __webpack_require__) {
  27864. "use strict";
  27865. /**
  27866. * Syntactic sugar for invoking a function and expanding an array for arguments.
  27867. *
  27868. * Common use case would be to use `Function.prototype.apply`.
  27869. *
  27870. * ```js
  27871. * function f(x, y, z) {}
  27872. * var args = [1, 2, 3];
  27873. * f.apply(null, args);
  27874. * ```
  27875. *
  27876. * With `spread` this example can be re-written.
  27877. *
  27878. * ```js
  27879. * spread(function(x, y, z) {})([1, 2, 3]);
  27880. * ```
  27881. *
  27882. * @param {Function} callback
  27883. * @returns {Function}
  27884. */
  27885. module.exports = function spread(callback) {
  27886. return function wrap(arr) {
  27887. return callback.apply(null, arr);
  27888. };
  27889. };
  27890. /***/ }),
  27891. /* 36 */
  27892. /***/ (function(module, exports) {
  27893. var asyncGenerator = function () {
  27894. function AwaitValue(value) {
  27895. this.value = value;
  27896. }
  27897. function AsyncGenerator(gen) {
  27898. var front, back;
  27899. function send(key, arg) {
  27900. return new Promise(function (resolve, reject) {
  27901. var request = {
  27902. key: key,
  27903. arg: arg,
  27904. resolve: resolve,
  27905. reject: reject,
  27906. next: null
  27907. };
  27908. if (back) {
  27909. back = back.next = request;
  27910. } else {
  27911. front = back = request;
  27912. resume(key, arg);
  27913. }
  27914. });
  27915. }
  27916. function resume(key, arg) {
  27917. try {
  27918. var result = gen[key](arg);
  27919. var value = result.value;
  27920. if (value instanceof AwaitValue) {
  27921. Promise.resolve(value.value).then(function (arg) {
  27922. resume("next", arg);
  27923. }, function (arg) {
  27924. resume("throw", arg);
  27925. });
  27926. } else {
  27927. settle(result.done ? "return" : "normal", result.value);
  27928. }
  27929. } catch (err) {
  27930. settle("throw", err);
  27931. }
  27932. }
  27933. function settle(type, value) {
  27934. switch (type) {
  27935. case "return":
  27936. front.resolve({
  27937. value: value,
  27938. done: true
  27939. });
  27940. break;
  27941. case "throw":
  27942. front.reject(value);
  27943. break;
  27944. default:
  27945. front.resolve({
  27946. value: value,
  27947. done: false
  27948. });
  27949. break;
  27950. }
  27951. front = front.next;
  27952. if (front) {
  27953. resume(front.key, front.arg);
  27954. } else {
  27955. back = null;
  27956. }
  27957. }
  27958. this._invoke = send;
  27959. if (typeof gen.return !== "function") {
  27960. this.return = undefined;
  27961. }
  27962. }
  27963. if (typeof Symbol === "function" && Symbol.asyncIterator) {
  27964. AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
  27965. return this;
  27966. };
  27967. }
  27968. AsyncGenerator.prototype.next = function (arg) {
  27969. return this._invoke("next", arg);
  27970. };
  27971. AsyncGenerator.prototype.throw = function (arg) {
  27972. return this._invoke("throw", arg);
  27973. };
  27974. AsyncGenerator.prototype.return = function (arg) {
  27975. return this._invoke("return", arg);
  27976. };
  27977. return {
  27978. wrap: function (fn) {
  27979. return function () {
  27980. return new AsyncGenerator(fn.apply(this, arguments));
  27981. };
  27982. },
  27983. await: function (value) {
  27984. return new AwaitValue(value);
  27985. }
  27986. };
  27987. }();
  27988. var classCallCheck = function (instance, Constructor) {
  27989. if (!(instance instanceof Constructor)) {
  27990. throw new TypeError("Cannot call a class as a function");
  27991. }
  27992. };
  27993. var createClass = function () {
  27994. function defineProperties(target, props) {
  27995. for (var i = 0; i < props.length; i++) {
  27996. var descriptor = props[i];
  27997. descriptor.enumerable = descriptor.enumerable || false;
  27998. descriptor.configurable = true;
  27999. if ("value" in descriptor) descriptor.writable = true;
  28000. Object.defineProperty(target, descriptor.key, descriptor);
  28001. }
  28002. }
  28003. return function (Constructor, protoProps, staticProps) {
  28004. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  28005. if (staticProps) defineProperties(Constructor, staticProps);
  28006. return Constructor;
  28007. };
  28008. }();
  28009. var _extends = Object.assign || function (target) {
  28010. for (var i = 1; i < arguments.length; i++) {
  28011. var source = arguments[i];
  28012. for (var key in source) {
  28013. if (Object.prototype.hasOwnProperty.call(source, key)) {
  28014. target[key] = source[key];
  28015. }
  28016. }
  28017. }
  28018. return target;
  28019. };
  28020. var inherits = function (subClass, superClass) {
  28021. if (typeof superClass !== "function" && superClass !== null) {
  28022. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  28023. }
  28024. subClass.prototype = Object.create(superClass && superClass.prototype, {
  28025. constructor: {
  28026. value: subClass,
  28027. enumerable: false,
  28028. writable: true,
  28029. configurable: true
  28030. }
  28031. });
  28032. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  28033. };
  28034. var possibleConstructorReturn = function (self, call) {
  28035. if (!self) {
  28036. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  28037. }
  28038. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  28039. };
  28040. var Connector = function () {
  28041. function Connector(options) {
  28042. classCallCheck(this, Connector);
  28043. this._defaultOptions = {
  28044. auth: {
  28045. headers: {}
  28046. },
  28047. authEndpoint: '/broadcasting/auth',
  28048. broadcaster: 'pusher',
  28049. csrfToken: null,
  28050. host: null,
  28051. key: null,
  28052. namespace: 'App.Events'
  28053. };
  28054. this.setOptions(options);
  28055. this.connect();
  28056. }
  28057. createClass(Connector, [{
  28058. key: 'setOptions',
  28059. value: function setOptions(options) {
  28060. this.options = _extends(this._defaultOptions, options);
  28061. if (this.csrfToken()) {
  28062. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  28063. }
  28064. return options;
  28065. }
  28066. }, {
  28067. key: 'csrfToken',
  28068. value: function csrfToken() {
  28069. var selector = void 0;
  28070. if (window && window['Laravel'] && window['Laravel'].csrfToken) {
  28071. return window['Laravel'].csrfToken;
  28072. } else if (this.options.csrfToken) {
  28073. return this.options.csrfToken;
  28074. } else if (typeof document !== 'undefined' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  28075. return selector.getAttribute('content');
  28076. }
  28077. return null;
  28078. }
  28079. }]);
  28080. return Connector;
  28081. }();
  28082. var Channel = function () {
  28083. function Channel() {
  28084. classCallCheck(this, Channel);
  28085. }
  28086. createClass(Channel, [{
  28087. key: 'notification',
  28088. value: function notification(callback) {
  28089. return this.listen('.Illuminate.Notifications.Events.BroadcastNotificationCreated', callback);
  28090. }
  28091. }, {
  28092. key: 'listenForWhisper',
  28093. value: function listenForWhisper(event, callback) {
  28094. return this.listen('.client-' + event, callback);
  28095. }
  28096. }]);
  28097. return Channel;
  28098. }();
  28099. var EventFormatter = function () {
  28100. function EventFormatter(namespace) {
  28101. classCallCheck(this, EventFormatter);
  28102. this.setNamespace(namespace);
  28103. }
  28104. createClass(EventFormatter, [{
  28105. key: 'format',
  28106. value: function format(event) {
  28107. if (this.namespace) {
  28108. if (event.charAt(0) != '\\' && event.charAt(0) != '.') {
  28109. event = this.namespace + '.' + event;
  28110. } else {
  28111. event = event.substr(1);
  28112. }
  28113. }
  28114. return event.replace(/\./g, '\\');
  28115. }
  28116. }, {
  28117. key: 'setNamespace',
  28118. value: function setNamespace(value) {
  28119. this.namespace = value;
  28120. }
  28121. }]);
  28122. return EventFormatter;
  28123. }();
  28124. var PusherChannel = function (_Channel) {
  28125. inherits(PusherChannel, _Channel);
  28126. function PusherChannel(pusher, name, options) {
  28127. classCallCheck(this, PusherChannel);
  28128. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  28129. _this.name = name;
  28130. _this.pusher = pusher;
  28131. _this.options = options;
  28132. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  28133. _this.subscribe();
  28134. return _this;
  28135. }
  28136. createClass(PusherChannel, [{
  28137. key: 'subscribe',
  28138. value: function subscribe() {
  28139. this.subscription = this.pusher.subscribe(this.name);
  28140. }
  28141. }, {
  28142. key: 'unsubscribe',
  28143. value: function unsubscribe() {
  28144. this.pusher.unsubscribe(this.name);
  28145. }
  28146. }, {
  28147. key: 'listen',
  28148. value: function listen(event, callback) {
  28149. this.on(this.eventFormatter.format(event), callback);
  28150. return this;
  28151. }
  28152. }, {
  28153. key: 'stopListening',
  28154. value: function stopListening(event) {
  28155. this.subscription.unbind(this.eventFormatter.format(event));
  28156. return this;
  28157. }
  28158. }, {
  28159. key: 'on',
  28160. value: function on(event, callback) {
  28161. this.subscription.bind(event, callback);
  28162. return this;
  28163. }
  28164. }]);
  28165. return PusherChannel;
  28166. }(Channel);
  28167. var PusherPrivateChannel = function (_PusherChannel) {
  28168. inherits(PusherPrivateChannel, _PusherChannel);
  28169. function PusherPrivateChannel() {
  28170. classCallCheck(this, PusherPrivateChannel);
  28171. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  28172. }
  28173. createClass(PusherPrivateChannel, [{
  28174. key: 'whisper',
  28175. value: function whisper(eventName, data) {
  28176. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  28177. return this;
  28178. }
  28179. }]);
  28180. return PusherPrivateChannel;
  28181. }(PusherChannel);
  28182. var PusherPresenceChannel = function (_PusherChannel) {
  28183. inherits(PusherPresenceChannel, _PusherChannel);
  28184. function PusherPresenceChannel() {
  28185. classCallCheck(this, PusherPresenceChannel);
  28186. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  28187. }
  28188. createClass(PusherPresenceChannel, [{
  28189. key: 'here',
  28190. value: function here(callback) {
  28191. this.on('pusher:subscription_succeeded', function (data) {
  28192. callback(Object.keys(data.members).map(function (k) {
  28193. return data.members[k];
  28194. }));
  28195. });
  28196. return this;
  28197. }
  28198. }, {
  28199. key: 'joining',
  28200. value: function joining(callback) {
  28201. this.on('pusher:member_added', function (member) {
  28202. callback(member.info);
  28203. });
  28204. return this;
  28205. }
  28206. }, {
  28207. key: 'leaving',
  28208. value: function leaving(callback) {
  28209. this.on('pusher:member_removed', function (member) {
  28210. callback(member.info);
  28211. });
  28212. return this;
  28213. }
  28214. }, {
  28215. key: 'whisper',
  28216. value: function whisper(eventName, data) {
  28217. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  28218. return this;
  28219. }
  28220. }]);
  28221. return PusherPresenceChannel;
  28222. }(PusherChannel);
  28223. var SocketIoChannel = function (_Channel) {
  28224. inherits(SocketIoChannel, _Channel);
  28225. function SocketIoChannel(socket, name, options) {
  28226. classCallCheck(this, SocketIoChannel);
  28227. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  28228. _this.events = {};
  28229. _this.name = name;
  28230. _this.socket = socket;
  28231. _this.options = options;
  28232. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  28233. _this.subscribe();
  28234. _this.configureReconnector();
  28235. return _this;
  28236. }
  28237. createClass(SocketIoChannel, [{
  28238. key: 'subscribe',
  28239. value: function subscribe() {
  28240. this.socket.emit('subscribe', {
  28241. channel: this.name,
  28242. auth: this.options.auth || {}
  28243. });
  28244. }
  28245. }, {
  28246. key: 'unsubscribe',
  28247. value: function unsubscribe() {
  28248. this.unbind();
  28249. this.socket.emit('unsubscribe', {
  28250. channel: this.name,
  28251. auth: this.options.auth || {}
  28252. });
  28253. }
  28254. }, {
  28255. key: 'listen',
  28256. value: function listen(event, callback) {
  28257. this.on(this.eventFormatter.format(event), callback);
  28258. return this;
  28259. }
  28260. }, {
  28261. key: 'on',
  28262. value: function on(event, callback) {
  28263. var _this2 = this;
  28264. var listener = function listener(channel, data) {
  28265. if (_this2.name == channel) {
  28266. callback(data);
  28267. }
  28268. };
  28269. this.socket.on(event, listener);
  28270. this.bind(event, listener);
  28271. }
  28272. }, {
  28273. key: 'configureReconnector',
  28274. value: function configureReconnector() {
  28275. var _this3 = this;
  28276. var listener = function listener() {
  28277. _this3.subscribe();
  28278. };
  28279. this.socket.on('reconnect', listener);
  28280. this.bind('reconnect', listener);
  28281. }
  28282. }, {
  28283. key: 'bind',
  28284. value: function bind(event, callback) {
  28285. this.events[event] = this.events[event] || [];
  28286. this.events[event].push(callback);
  28287. }
  28288. }, {
  28289. key: 'unbind',
  28290. value: function unbind() {
  28291. var _this4 = this;
  28292. Object.keys(this.events).forEach(function (event) {
  28293. _this4.events[event].forEach(function (callback) {
  28294. _this4.socket.removeListener(event, callback);
  28295. });
  28296. delete _this4.events[event];
  28297. });
  28298. }
  28299. }]);
  28300. return SocketIoChannel;
  28301. }(Channel);
  28302. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  28303. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  28304. function SocketIoPrivateChannel() {
  28305. classCallCheck(this, SocketIoPrivateChannel);
  28306. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  28307. }
  28308. createClass(SocketIoPrivateChannel, [{
  28309. key: 'whisper',
  28310. value: function whisper(eventName, data) {
  28311. this.socket.emit('client event', {
  28312. channel: this.name,
  28313. event: 'client-' + eventName,
  28314. data: data
  28315. });
  28316. return this;
  28317. }
  28318. }]);
  28319. return SocketIoPrivateChannel;
  28320. }(SocketIoChannel);
  28321. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  28322. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  28323. function SocketIoPresenceChannel() {
  28324. classCallCheck(this, SocketIoPresenceChannel);
  28325. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  28326. }
  28327. createClass(SocketIoPresenceChannel, [{
  28328. key: 'here',
  28329. value: function here(callback) {
  28330. this.on('presence:subscribed', function (members) {
  28331. callback(members.map(function (m) {
  28332. return m.user_info;
  28333. }));
  28334. });
  28335. return this;
  28336. }
  28337. }, {
  28338. key: 'joining',
  28339. value: function joining(callback) {
  28340. this.on('presence:joining', function (member) {
  28341. return callback(member.user_info);
  28342. });
  28343. return this;
  28344. }
  28345. }, {
  28346. key: 'leaving',
  28347. value: function leaving(callback) {
  28348. this.on('presence:leaving', function (member) {
  28349. return callback(member.user_info);
  28350. });
  28351. return this;
  28352. }
  28353. }]);
  28354. return SocketIoPresenceChannel;
  28355. }(SocketIoPrivateChannel);
  28356. var PusherConnector = function (_Connector) {
  28357. inherits(PusherConnector, _Connector);
  28358. function PusherConnector() {
  28359. var _ref;
  28360. classCallCheck(this, PusherConnector);
  28361. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  28362. args[_key] = arguments[_key];
  28363. }
  28364. var _this = possibleConstructorReturn(this, (_ref = PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).call.apply(_ref, [this].concat(args)));
  28365. _this.channels = {};
  28366. return _this;
  28367. }
  28368. createClass(PusherConnector, [{
  28369. key: 'connect',
  28370. value: function connect() {
  28371. this.pusher = new Pusher(this.options.key, this.options);
  28372. }
  28373. }, {
  28374. key: 'listen',
  28375. value: function listen(name, event, callback) {
  28376. return this.channel(name).listen(event, callback);
  28377. }
  28378. }, {
  28379. key: 'channel',
  28380. value: function channel(name) {
  28381. if (!this.channels[name]) {
  28382. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  28383. }
  28384. return this.channels[name];
  28385. }
  28386. }, {
  28387. key: 'privateChannel',
  28388. value: function privateChannel(name) {
  28389. if (!this.channels['private-' + name]) {
  28390. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  28391. }
  28392. return this.channels['private-' + name];
  28393. }
  28394. }, {
  28395. key: 'presenceChannel',
  28396. value: function presenceChannel(name) {
  28397. if (!this.channels['presence-' + name]) {
  28398. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  28399. }
  28400. return this.channels['presence-' + name];
  28401. }
  28402. }, {
  28403. key: 'leave',
  28404. value: function leave(name) {
  28405. var _this2 = this;
  28406. var channels = [name, 'private-' + name, 'presence-' + name];
  28407. channels.forEach(function (name, index) {
  28408. if (_this2.channels[name]) {
  28409. _this2.channels[name].unsubscribe();
  28410. delete _this2.channels[name];
  28411. }
  28412. });
  28413. }
  28414. }, {
  28415. key: 'socketId',
  28416. value: function socketId() {
  28417. return this.pusher.connection.socket_id;
  28418. }
  28419. }]);
  28420. return PusherConnector;
  28421. }(Connector);
  28422. var SocketIoConnector = function (_Connector) {
  28423. inherits(SocketIoConnector, _Connector);
  28424. function SocketIoConnector() {
  28425. var _ref;
  28426. classCallCheck(this, SocketIoConnector);
  28427. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  28428. args[_key] = arguments[_key];
  28429. }
  28430. var _this = possibleConstructorReturn(this, (_ref = SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).call.apply(_ref, [this].concat(args)));
  28431. _this.channels = {};
  28432. return _this;
  28433. }
  28434. createClass(SocketIoConnector, [{
  28435. key: 'connect',
  28436. value: function connect() {
  28437. this.socket = io(this.options.host, this.options);
  28438. return this.socket;
  28439. }
  28440. }, {
  28441. key: 'listen',
  28442. value: function listen(name, event, callback) {
  28443. return this.channel(name).listen(event, callback);
  28444. }
  28445. }, {
  28446. key: 'channel',
  28447. value: function channel(name) {
  28448. if (!this.channels[name]) {
  28449. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  28450. }
  28451. return this.channels[name];
  28452. }
  28453. }, {
  28454. key: 'privateChannel',
  28455. value: function privateChannel(name) {
  28456. if (!this.channels['private-' + name]) {
  28457. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  28458. }
  28459. return this.channels['private-' + name];
  28460. }
  28461. }, {
  28462. key: 'presenceChannel',
  28463. value: function presenceChannel(name) {
  28464. if (!this.channels['presence-' + name]) {
  28465. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  28466. }
  28467. return this.channels['presence-' + name];
  28468. }
  28469. }, {
  28470. key: 'leave',
  28471. value: function leave(name) {
  28472. var _this2 = this;
  28473. var channels = [name, 'private-' + name, 'presence-' + name];
  28474. channels.forEach(function (name) {
  28475. if (_this2.channels[name]) {
  28476. _this2.channels[name].unsubscribe();
  28477. delete _this2.channels[name];
  28478. }
  28479. });
  28480. }
  28481. }, {
  28482. key: 'socketId',
  28483. value: function socketId() {
  28484. return this.socket.id;
  28485. }
  28486. }]);
  28487. return SocketIoConnector;
  28488. }(Connector);
  28489. var Echo = function () {
  28490. function Echo(options) {
  28491. classCallCheck(this, Echo);
  28492. this.options = options;
  28493. if (typeof Vue === 'function' && Vue.http) {
  28494. this.registerVueRequestInterceptor();
  28495. }
  28496. if (typeof axios === 'function') {
  28497. this.registerAxiosRequestInterceptor();
  28498. }
  28499. if (typeof jQuery === 'function') {
  28500. this.registerjQueryAjaxSetup();
  28501. }
  28502. if (this.options.broadcaster == 'pusher') {
  28503. this.connector = new PusherConnector(this.options);
  28504. } else if (this.options.broadcaster == 'socket.io') {
  28505. this.connector = new SocketIoConnector(this.options);
  28506. }
  28507. }
  28508. createClass(Echo, [{
  28509. key: 'registerVueRequestInterceptor',
  28510. value: function registerVueRequestInterceptor() {
  28511. var _this = this;
  28512. Vue.http.interceptors.push(function (request, next) {
  28513. if (_this.socketId()) {
  28514. request.headers.set('X-Socket-ID', _this.socketId());
  28515. }
  28516. next();
  28517. });
  28518. }
  28519. }, {
  28520. key: 'registerAxiosRequestInterceptor',
  28521. value: function registerAxiosRequestInterceptor() {
  28522. var _this2 = this;
  28523. axios.interceptors.request.use(function (config) {
  28524. if (_this2.socketId()) {
  28525. config.headers['X-Socket-Id'] = _this2.socketId();
  28526. }
  28527. return config;
  28528. });
  28529. }
  28530. }, {
  28531. key: 'registerjQueryAjaxSetup',
  28532. value: function registerjQueryAjaxSetup() {
  28533. var _this3 = this;
  28534. if (typeof jQuery.ajax != 'undefined') {
  28535. jQuery.ajaxSetup({
  28536. beforeSend: function beforeSend(xhr) {
  28537. if (_this3.socketId()) {
  28538. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  28539. }
  28540. }
  28541. });
  28542. }
  28543. }
  28544. }, {
  28545. key: 'listen',
  28546. value: function listen(channel, event, callback) {
  28547. return this.connector.listen(channel, event, callback);
  28548. }
  28549. }, {
  28550. key: 'channel',
  28551. value: function channel(_channel) {
  28552. return this.connector.channel(_channel);
  28553. }
  28554. }, {
  28555. key: 'private',
  28556. value: function _private(channel) {
  28557. return this.connector.privateChannel(channel);
  28558. }
  28559. }, {
  28560. key: 'join',
  28561. value: function join(channel) {
  28562. return this.connector.presenceChannel(channel);
  28563. }
  28564. }, {
  28565. key: 'leave',
  28566. value: function leave(channel) {
  28567. this.connector.leave(channel);
  28568. }
  28569. }, {
  28570. key: 'socketId',
  28571. value: function socketId() {
  28572. return this.connector.socketId();
  28573. }
  28574. }]);
  28575. return Echo;
  28576. }();
  28577. module.exports = Echo;
  28578. /***/ }),
  28579. /* 37 */
  28580. /***/ (function(module, exports, __webpack_require__) {
  28581. /*!
  28582. * Pusher JavaScript Library v4.1.0
  28583. * https://pusher.com/
  28584. *
  28585. * Copyright 2017, Pusher
  28586. * Released under the MIT licence.
  28587. */
  28588. (function webpackUniversalModuleDefinition(root, factory) {
  28589. if(true)
  28590. module.exports = factory();
  28591. else if(typeof define === 'function' && define.amd)
  28592. define([], factory);
  28593. else if(typeof exports === 'object')
  28594. exports["Pusher"] = factory();
  28595. else
  28596. root["Pusher"] = factory();
  28597. })(this, function() {
  28598. return /******/ (function(modules) { // webpackBootstrap
  28599. /******/ // The module cache
  28600. /******/ var installedModules = {};
  28601. /******/ // The require function
  28602. /******/ function __webpack_require__(moduleId) {
  28603. /******/ // Check if module is in cache
  28604. /******/ if(installedModules[moduleId])
  28605. /******/ return installedModules[moduleId].exports;
  28606. /******/ // Create a new module (and put it into the cache)
  28607. /******/ var module = installedModules[moduleId] = {
  28608. /******/ exports: {},
  28609. /******/ id: moduleId,
  28610. /******/ loaded: false
  28611. /******/ };
  28612. /******/ // Execute the module function
  28613. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  28614. /******/ // Flag the module as loaded
  28615. /******/ module.loaded = true;
  28616. /******/ // Return the exports of the module
  28617. /******/ return module.exports;
  28618. /******/ }
  28619. /******/ // expose the modules object (__webpack_modules__)
  28620. /******/ __webpack_require__.m = modules;
  28621. /******/ // expose the module cache
  28622. /******/ __webpack_require__.c = installedModules;
  28623. /******/ // __webpack_public_path__
  28624. /******/ __webpack_require__.p = "";
  28625. /******/ // Load entry module and return exports
  28626. /******/ return __webpack_require__(0);
  28627. /******/ })
  28628. /************************************************************************/
  28629. /******/ ([
  28630. /* 0 */
  28631. /***/ (function(module, exports, __webpack_require__) {
  28632. "use strict";
  28633. var pusher_1 = __webpack_require__(1);
  28634. module.exports = pusher_1["default"];
  28635. /***/ }),
  28636. /* 1 */
  28637. /***/ (function(module, exports, __webpack_require__) {
  28638. "use strict";
  28639. var runtime_1 = __webpack_require__(2);
  28640. var Collections = __webpack_require__(9);
  28641. var dispatcher_1 = __webpack_require__(23);
  28642. var timeline_1 = __webpack_require__(38);
  28643. var level_1 = __webpack_require__(39);
  28644. var StrategyBuilder = __webpack_require__(40);
  28645. var timers_1 = __webpack_require__(12);
  28646. var defaults_1 = __webpack_require__(5);
  28647. var DefaultConfig = __webpack_require__(62);
  28648. var logger_1 = __webpack_require__(8);
  28649. var factory_1 = __webpack_require__(42);
  28650. var Pusher = (function () {
  28651. function Pusher(app_key, options) {
  28652. var _this = this;
  28653. checkAppKey(app_key);
  28654. options = options || {};
  28655. this.key = app_key;
  28656. this.config = Collections.extend(DefaultConfig.getGlobalConfig(), options.cluster ? DefaultConfig.getClusterConfig(options.cluster) : {}, options);
  28657. this.channels = factory_1["default"].createChannels();
  28658. this.global_emitter = new dispatcher_1["default"]();
  28659. this.sessionID = Math.floor(Math.random() * 1000000000);
  28660. this.timeline = new timeline_1["default"](this.key, this.sessionID, {
  28661. cluster: this.config.cluster,
  28662. features: Pusher.getClientFeatures(),
  28663. params: this.config.timelineParams || {},
  28664. limit: 50,
  28665. level: level_1["default"].INFO,
  28666. version: defaults_1["default"].VERSION
  28667. });
  28668. if (!this.config.disableStats) {
  28669. this.timelineSender = factory_1["default"].createTimelineSender(this.timeline, {
  28670. host: this.config.statsHost,
  28671. path: "/timeline/v2/" + runtime_1["default"].TimelineTransport.name
  28672. });
  28673. }
  28674. var getStrategy = function (options) {
  28675. var config = Collections.extend({}, _this.config, options);
  28676. return StrategyBuilder.build(runtime_1["default"].getDefaultStrategy(config), config);
  28677. };
  28678. this.connection = factory_1["default"].createConnectionManager(this.key, Collections.extend({ getStrategy: getStrategy,
  28679. timeline: this.timeline,
  28680. activityTimeout: this.config.activity_timeout,
  28681. pongTimeout: this.config.pong_timeout,
  28682. unavailableTimeout: this.config.unavailable_timeout
  28683. }, this.config, { encrypted: this.isEncrypted() }));
  28684. this.connection.bind('connected', function () {
  28685. _this.subscribeAll();
  28686. if (_this.timelineSender) {
  28687. _this.timelineSender.send(_this.connection.isEncrypted());
  28688. }
  28689. });
  28690. this.connection.bind('message', function (params) {
  28691. var internal = (params.event.indexOf('pusher_internal:') === 0);
  28692. if (params.channel) {
  28693. var channel = _this.channel(params.channel);
  28694. if (channel) {
  28695. channel.handleEvent(params.event, params.data);
  28696. }
  28697. }
  28698. if (!internal) {
  28699. _this.global_emitter.emit(params.event, params.data);
  28700. }
  28701. });
  28702. this.connection.bind('connecting', function () {
  28703. _this.channels.disconnect();
  28704. });
  28705. this.connection.bind('disconnected', function () {
  28706. _this.channels.disconnect();
  28707. });
  28708. this.connection.bind('error', function (err) {
  28709. logger_1["default"].warn('Error', err);
  28710. });
  28711. Pusher.instances.push(this);
  28712. this.timeline.info({ instances: Pusher.instances.length });
  28713. if (Pusher.isReady) {
  28714. this.connect();
  28715. }
  28716. }
  28717. Pusher.ready = function () {
  28718. Pusher.isReady = true;
  28719. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  28720. Pusher.instances[i].connect();
  28721. }
  28722. };
  28723. Pusher.log = function (message) {
  28724. if (Pusher.logToConsole && (window).console && (window).console.log) {
  28725. (window).console.log(message);
  28726. }
  28727. };
  28728. Pusher.getClientFeatures = function () {
  28729. return Collections.keys(Collections.filterObject({ "ws": runtime_1["default"].Transports.ws }, function (t) { return t.isSupported({}); }));
  28730. };
  28731. Pusher.prototype.channel = function (name) {
  28732. return this.channels.find(name);
  28733. };
  28734. Pusher.prototype.allChannels = function () {
  28735. return this.channels.all();
  28736. };
  28737. Pusher.prototype.connect = function () {
  28738. this.connection.connect();
  28739. if (this.timelineSender) {
  28740. if (!this.timelineSenderTimer) {
  28741. var encrypted = this.connection.isEncrypted();
  28742. var timelineSender = this.timelineSender;
  28743. this.timelineSenderTimer = new timers_1.PeriodicTimer(60000, function () {
  28744. timelineSender.send(encrypted);
  28745. });
  28746. }
  28747. }
  28748. };
  28749. Pusher.prototype.disconnect = function () {
  28750. this.connection.disconnect();
  28751. if (this.timelineSenderTimer) {
  28752. this.timelineSenderTimer.ensureAborted();
  28753. this.timelineSenderTimer = null;
  28754. }
  28755. };
  28756. Pusher.prototype.bind = function (event_name, callback, context) {
  28757. this.global_emitter.bind(event_name, callback, context);
  28758. return this;
  28759. };
  28760. Pusher.prototype.unbind = function (event_name, callback, context) {
  28761. this.global_emitter.unbind(event_name, callback, context);
  28762. return this;
  28763. };
  28764. Pusher.prototype.bind_global = function (callback) {
  28765. this.global_emitter.bind_global(callback);
  28766. return this;
  28767. };
  28768. Pusher.prototype.unbind_global = function (callback) {
  28769. this.global_emitter.unbind_global(callback);
  28770. return this;
  28771. };
  28772. Pusher.prototype.unbind_all = function (callback) {
  28773. this.global_emitter.unbind_all();
  28774. return this;
  28775. };
  28776. Pusher.prototype.subscribeAll = function () {
  28777. var channelName;
  28778. for (channelName in this.channels.channels) {
  28779. if (this.channels.channels.hasOwnProperty(channelName)) {
  28780. this.subscribe(channelName);
  28781. }
  28782. }
  28783. };
  28784. Pusher.prototype.subscribe = function (channel_name) {
  28785. var channel = this.channels.add(channel_name, this);
  28786. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  28787. channel.reinstateSubscription();
  28788. }
  28789. else if (!channel.subscriptionPending && this.connection.state === "connected") {
  28790. channel.subscribe();
  28791. }
  28792. return channel;
  28793. };
  28794. Pusher.prototype.unsubscribe = function (channel_name) {
  28795. var channel = this.channels.find(channel_name);
  28796. if (channel && channel.subscriptionPending) {
  28797. channel.cancelSubscription();
  28798. }
  28799. else {
  28800. channel = this.channels.remove(channel_name);
  28801. if (channel && this.connection.state === "connected") {
  28802. channel.unsubscribe();
  28803. }
  28804. }
  28805. };
  28806. Pusher.prototype.send_event = function (event_name, data, channel) {
  28807. return this.connection.send_event(event_name, data, channel);
  28808. };
  28809. Pusher.prototype.isEncrypted = function () {
  28810. if (runtime_1["default"].getProtocol() === "https:") {
  28811. return true;
  28812. }
  28813. else {
  28814. return Boolean(this.config.encrypted);
  28815. }
  28816. };
  28817. Pusher.instances = [];
  28818. Pusher.isReady = false;
  28819. Pusher.logToConsole = false;
  28820. Pusher.Runtime = runtime_1["default"];
  28821. Pusher.ScriptReceivers = runtime_1["default"].ScriptReceivers;
  28822. Pusher.DependenciesReceivers = runtime_1["default"].DependenciesReceivers;
  28823. Pusher.auth_callbacks = runtime_1["default"].auth_callbacks;
  28824. return Pusher;
  28825. }());
  28826. exports.__esModule = true;
  28827. exports["default"] = Pusher;
  28828. function checkAppKey(key) {
  28829. if (key === null || key === undefined) {
  28830. throw "You must pass your app key when you instantiate Pusher.";
  28831. }
  28832. }
  28833. runtime_1["default"].setup(Pusher);
  28834. /***/ }),
  28835. /* 2 */
  28836. /***/ (function(module, exports, __webpack_require__) {
  28837. "use strict";
  28838. var dependencies_1 = __webpack_require__(3);
  28839. var xhr_auth_1 = __webpack_require__(7);
  28840. var jsonp_auth_1 = __webpack_require__(14);
  28841. var script_request_1 = __webpack_require__(15);
  28842. var jsonp_request_1 = __webpack_require__(16);
  28843. var script_receiver_factory_1 = __webpack_require__(4);
  28844. var jsonp_timeline_1 = __webpack_require__(17);
  28845. var transports_1 = __webpack_require__(18);
  28846. var net_info_1 = __webpack_require__(25);
  28847. var default_strategy_1 = __webpack_require__(26);
  28848. var transport_connection_initializer_1 = __webpack_require__(27);
  28849. var http_1 = __webpack_require__(28);
  28850. var Runtime = {
  28851. nextAuthCallbackID: 1,
  28852. auth_callbacks: {},
  28853. ScriptReceivers: script_receiver_factory_1.ScriptReceivers,
  28854. DependenciesReceivers: dependencies_1.DependenciesReceivers,
  28855. getDefaultStrategy: default_strategy_1["default"],
  28856. Transports: transports_1["default"],
  28857. transportConnectionInitializer: transport_connection_initializer_1["default"],
  28858. HTTPFactory: http_1["default"],
  28859. TimelineTransport: jsonp_timeline_1["default"],
  28860. getXHRAPI: function () {
  28861. return window.XMLHttpRequest;
  28862. },
  28863. getWebSocketAPI: function () {
  28864. return window.WebSocket || window.MozWebSocket;
  28865. },
  28866. setup: function (PusherClass) {
  28867. var _this = this;
  28868. window.Pusher = PusherClass;
  28869. var initializeOnDocumentBody = function () {
  28870. _this.onDocumentBody(PusherClass.ready);
  28871. };
  28872. if (!window.JSON) {
  28873. dependencies_1.Dependencies.load("json2", {}, initializeOnDocumentBody);
  28874. }
  28875. else {
  28876. initializeOnDocumentBody();
  28877. }
  28878. },
  28879. getDocument: function () {
  28880. return document;
  28881. },
  28882. getProtocol: function () {
  28883. return this.getDocument().location.protocol;
  28884. },
  28885. getAuthorizers: function () {
  28886. return { ajax: xhr_auth_1["default"], jsonp: jsonp_auth_1["default"] };
  28887. },
  28888. onDocumentBody: function (callback) {
  28889. var _this = this;
  28890. if (document.body) {
  28891. callback();
  28892. }
  28893. else {
  28894. setTimeout(function () {
  28895. _this.onDocumentBody(callback);
  28896. }, 0);
  28897. }
  28898. },
  28899. createJSONPRequest: function (url, data) {
  28900. return new jsonp_request_1["default"](url, data);
  28901. },
  28902. createScriptRequest: function (src) {
  28903. return new script_request_1["default"](src);
  28904. },
  28905. getLocalStorage: function () {
  28906. try {
  28907. return window.localStorage;
  28908. }
  28909. catch (e) {
  28910. return undefined;
  28911. }
  28912. },
  28913. createXHR: function () {
  28914. if (this.getXHRAPI()) {
  28915. return this.createXMLHttpRequest();
  28916. }
  28917. else {
  28918. return this.createMicrosoftXHR();
  28919. }
  28920. },
  28921. createXMLHttpRequest: function () {
  28922. var Constructor = this.getXHRAPI();
  28923. return new Constructor();
  28924. },
  28925. createMicrosoftXHR: function () {
  28926. return new ActiveXObject("Microsoft.XMLHTTP");
  28927. },
  28928. getNetwork: function () {
  28929. return net_info_1.Network;
  28930. },
  28931. createWebSocket: function (url) {
  28932. var Constructor = this.getWebSocketAPI();
  28933. return new Constructor(url);
  28934. },
  28935. createSocketRequest: function (method, url) {
  28936. if (this.isXHRSupported()) {
  28937. return this.HTTPFactory.createXHR(method, url);
  28938. }
  28939. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  28940. return this.HTTPFactory.createXDR(method, url);
  28941. }
  28942. else {
  28943. throw "Cross-origin HTTP requests are not supported";
  28944. }
  28945. },
  28946. isXHRSupported: function () {
  28947. var Constructor = this.getXHRAPI();
  28948. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  28949. },
  28950. isXDRSupported: function (encrypted) {
  28951. var protocol = encrypted ? "https:" : "http:";
  28952. var documentProtocol = this.getProtocol();
  28953. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  28954. },
  28955. addUnloadListener: function (listener) {
  28956. if (window.addEventListener !== undefined) {
  28957. window.addEventListener("unload", listener, false);
  28958. }
  28959. else if (window.attachEvent !== undefined) {
  28960. window.attachEvent("onunload", listener);
  28961. }
  28962. },
  28963. removeUnloadListener: function (listener) {
  28964. if (window.addEventListener !== undefined) {
  28965. window.removeEventListener("unload", listener, false);
  28966. }
  28967. else if (window.detachEvent !== undefined) {
  28968. window.detachEvent("onunload", listener);
  28969. }
  28970. }
  28971. };
  28972. exports.__esModule = true;
  28973. exports["default"] = Runtime;
  28974. /***/ }),
  28975. /* 3 */
  28976. /***/ (function(module, exports, __webpack_require__) {
  28977. "use strict";
  28978. var script_receiver_factory_1 = __webpack_require__(4);
  28979. var defaults_1 = __webpack_require__(5);
  28980. var dependency_loader_1 = __webpack_require__(6);
  28981. exports.DependenciesReceivers = new script_receiver_factory_1.ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  28982. exports.Dependencies = new dependency_loader_1["default"]({
  28983. cdn_http: defaults_1["default"].cdn_http,
  28984. cdn_https: defaults_1["default"].cdn_https,
  28985. version: defaults_1["default"].VERSION,
  28986. suffix: defaults_1["default"].dependency_suffix,
  28987. receivers: exports.DependenciesReceivers
  28988. });
  28989. /***/ }),
  28990. /* 4 */
  28991. /***/ (function(module, exports) {
  28992. "use strict";
  28993. var ScriptReceiverFactory = (function () {
  28994. function ScriptReceiverFactory(prefix, name) {
  28995. this.lastId = 0;
  28996. this.prefix = prefix;
  28997. this.name = name;
  28998. }
  28999. ScriptReceiverFactory.prototype.create = function (callback) {
  29000. this.lastId++;
  29001. var number = this.lastId;
  29002. var id = this.prefix + number;
  29003. var name = this.name + "[" + number + "]";
  29004. var called = false;
  29005. var callbackWrapper = function () {
  29006. if (!called) {
  29007. callback.apply(null, arguments);
  29008. called = true;
  29009. }
  29010. };
  29011. this[number] = callbackWrapper;
  29012. return { number: number, id: id, name: name, callback: callbackWrapper };
  29013. };
  29014. ScriptReceiverFactory.prototype.remove = function (receiver) {
  29015. delete this[receiver.number];
  29016. };
  29017. return ScriptReceiverFactory;
  29018. }());
  29019. exports.ScriptReceiverFactory = ScriptReceiverFactory;
  29020. exports.ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  29021. /***/ }),
  29022. /* 5 */
  29023. /***/ (function(module, exports) {
  29024. "use strict";
  29025. var Defaults = {
  29026. VERSION: "4.1.0",
  29027. PROTOCOL: 7,
  29028. host: 'ws.pusherapp.com',
  29029. ws_port: 80,
  29030. wss_port: 443,
  29031. sockjs_host: 'sockjs.pusher.com',
  29032. sockjs_http_port: 80,
  29033. sockjs_https_port: 443,
  29034. sockjs_path: "/pusher",
  29035. stats_host: 'stats.pusher.com',
  29036. channel_auth_endpoint: '/pusher/auth',
  29037. channel_auth_transport: 'ajax',
  29038. activity_timeout: 120000,
  29039. pong_timeout: 30000,
  29040. unavailable_timeout: 10000,
  29041. cdn_http: 'http://js.pusher.com',
  29042. cdn_https: 'https://js.pusher.com',
  29043. dependency_suffix: ''
  29044. };
  29045. exports.__esModule = true;
  29046. exports["default"] = Defaults;
  29047. /***/ }),
  29048. /* 6 */
  29049. /***/ (function(module, exports, __webpack_require__) {
  29050. "use strict";
  29051. var script_receiver_factory_1 = __webpack_require__(4);
  29052. var runtime_1 = __webpack_require__(2);
  29053. var DependencyLoader = (function () {
  29054. function DependencyLoader(options) {
  29055. this.options = options;
  29056. this.receivers = options.receivers || script_receiver_factory_1.ScriptReceivers;
  29057. this.loading = {};
  29058. }
  29059. DependencyLoader.prototype.load = function (name, options, callback) {
  29060. var self = this;
  29061. if (self.loading[name] && self.loading[name].length > 0) {
  29062. self.loading[name].push(callback);
  29063. }
  29064. else {
  29065. self.loading[name] = [callback];
  29066. var request = runtime_1["default"].createScriptRequest(self.getPath(name, options));
  29067. var receiver = self.receivers.create(function (error) {
  29068. self.receivers.remove(receiver);
  29069. if (self.loading[name]) {
  29070. var callbacks = self.loading[name];
  29071. delete self.loading[name];
  29072. var successCallback = function (wasSuccessful) {
  29073. if (!wasSuccessful) {
  29074. request.cleanup();
  29075. }
  29076. };
  29077. for (var i = 0; i < callbacks.length; i++) {
  29078. callbacks[i](error, successCallback);
  29079. }
  29080. }
  29081. });
  29082. request.send(receiver);
  29083. }
  29084. };
  29085. DependencyLoader.prototype.getRoot = function (options) {
  29086. var cdn;
  29087. var protocol = runtime_1["default"].getDocument().location.protocol;
  29088. if ((options && options.encrypted) || protocol === "https:") {
  29089. cdn = this.options.cdn_https;
  29090. }
  29091. else {
  29092. cdn = this.options.cdn_http;
  29093. }
  29094. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  29095. };
  29096. DependencyLoader.prototype.getPath = function (name, options) {
  29097. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  29098. };
  29099. ;
  29100. return DependencyLoader;
  29101. }());
  29102. exports.__esModule = true;
  29103. exports["default"] = DependencyLoader;
  29104. /***/ }),
  29105. /* 7 */
  29106. /***/ (function(module, exports, __webpack_require__) {
  29107. "use strict";
  29108. var logger_1 = __webpack_require__(8);
  29109. var runtime_1 = __webpack_require__(2);
  29110. var ajax = function (context, socketId, callback) {
  29111. var self = this, xhr;
  29112. xhr = runtime_1["default"].createXHR();
  29113. xhr.open("POST", self.options.authEndpoint, true);
  29114. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  29115. for (var headerName in this.authOptions.headers) {
  29116. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  29117. }
  29118. xhr.onreadystatechange = function () {
  29119. if (xhr.readyState === 4) {
  29120. if (xhr.status === 200) {
  29121. var data, parsed = false;
  29122. try {
  29123. data = JSON.parse(xhr.responseText);
  29124. parsed = true;
  29125. }
  29126. catch (e) {
  29127. callback(true, 'JSON returned from webapp was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  29128. }
  29129. if (parsed) {
  29130. callback(false, data);
  29131. }
  29132. }
  29133. else {
  29134. logger_1["default"].warn("Couldn't get auth info from your webapp", xhr.status);
  29135. callback(true, xhr.status);
  29136. }
  29137. }
  29138. };
  29139. xhr.send(this.composeQuery(socketId));
  29140. return xhr;
  29141. };
  29142. exports.__esModule = true;
  29143. exports["default"] = ajax;
  29144. /***/ }),
  29145. /* 8 */
  29146. /***/ (function(module, exports, __webpack_require__) {
  29147. "use strict";
  29148. var collections_1 = __webpack_require__(9);
  29149. var pusher_1 = __webpack_require__(1);
  29150. var Logger = {
  29151. debug: function () {
  29152. var args = [];
  29153. for (var _i = 0; _i < arguments.length; _i++) {
  29154. args[_i - 0] = arguments[_i];
  29155. }
  29156. if (!pusher_1["default"].log) {
  29157. return;
  29158. }
  29159. pusher_1["default"].log(collections_1.stringify.apply(this, arguments));
  29160. },
  29161. warn: function () {
  29162. var args = [];
  29163. for (var _i = 0; _i < arguments.length; _i++) {
  29164. args[_i - 0] = arguments[_i];
  29165. }
  29166. var message = collections_1.stringify.apply(this, arguments);
  29167. if ((window).console) {
  29168. if ((window).console.warn) {
  29169. (window).console.warn(message);
  29170. }
  29171. else if ((window).console.log) {
  29172. (window).console.log(message);
  29173. }
  29174. }
  29175. if (pusher_1["default"].log) {
  29176. pusher_1["default"].log(message);
  29177. }
  29178. }
  29179. };
  29180. exports.__esModule = true;
  29181. exports["default"] = Logger;
  29182. /***/ }),
  29183. /* 9 */
  29184. /***/ (function(module, exports, __webpack_require__) {
  29185. "use strict";
  29186. var base64_1 = __webpack_require__(10);
  29187. var util_1 = __webpack_require__(11);
  29188. function extend(target) {
  29189. var sources = [];
  29190. for (var _i = 1; _i < arguments.length; _i++) {
  29191. sources[_i - 1] = arguments[_i];
  29192. }
  29193. for (var i = 0; i < sources.length; i++) {
  29194. var extensions = sources[i];
  29195. for (var property in extensions) {
  29196. if (extensions[property] && extensions[property].constructor &&
  29197. extensions[property].constructor === Object) {
  29198. target[property] = extend(target[property] || {}, extensions[property]);
  29199. }
  29200. else {
  29201. target[property] = extensions[property];
  29202. }
  29203. }
  29204. }
  29205. return target;
  29206. }
  29207. exports.extend = extend;
  29208. function stringify() {
  29209. var m = ["Pusher"];
  29210. for (var i = 0; i < arguments.length; i++) {
  29211. if (typeof arguments[i] === "string") {
  29212. m.push(arguments[i]);
  29213. }
  29214. else {
  29215. m.push(safeJSONStringify(arguments[i]));
  29216. }
  29217. }
  29218. return m.join(" : ");
  29219. }
  29220. exports.stringify = stringify;
  29221. function arrayIndexOf(array, item) {
  29222. var nativeIndexOf = Array.prototype.indexOf;
  29223. if (array === null) {
  29224. return -1;
  29225. }
  29226. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  29227. return array.indexOf(item);
  29228. }
  29229. for (var i = 0, l = array.length; i < l; i++) {
  29230. if (array[i] === item) {
  29231. return i;
  29232. }
  29233. }
  29234. return -1;
  29235. }
  29236. exports.arrayIndexOf = arrayIndexOf;
  29237. function objectApply(object, f) {
  29238. for (var key in object) {
  29239. if (Object.prototype.hasOwnProperty.call(object, key)) {
  29240. f(object[key], key, object);
  29241. }
  29242. }
  29243. }
  29244. exports.objectApply = objectApply;
  29245. function keys(object) {
  29246. var keys = [];
  29247. objectApply(object, function (_, key) {
  29248. keys.push(key);
  29249. });
  29250. return keys;
  29251. }
  29252. exports.keys = keys;
  29253. function values(object) {
  29254. var values = [];
  29255. objectApply(object, function (value) {
  29256. values.push(value);
  29257. });
  29258. return values;
  29259. }
  29260. exports.values = values;
  29261. function apply(array, f, context) {
  29262. for (var i = 0; i < array.length; i++) {
  29263. f.call(context || (window), array[i], i, array);
  29264. }
  29265. }
  29266. exports.apply = apply;
  29267. function map(array, f) {
  29268. var result = [];
  29269. for (var i = 0; i < array.length; i++) {
  29270. result.push(f(array[i], i, array, result));
  29271. }
  29272. return result;
  29273. }
  29274. exports.map = map;
  29275. function mapObject(object, f) {
  29276. var result = {};
  29277. objectApply(object, function (value, key) {
  29278. result[key] = f(value);
  29279. });
  29280. return result;
  29281. }
  29282. exports.mapObject = mapObject;
  29283. function filter(array, test) {
  29284. test = test || function (value) { return !!value; };
  29285. var result = [];
  29286. for (var i = 0; i < array.length; i++) {
  29287. if (test(array[i], i, array, result)) {
  29288. result.push(array[i]);
  29289. }
  29290. }
  29291. return result;
  29292. }
  29293. exports.filter = filter;
  29294. function filterObject(object, test) {
  29295. var result = {};
  29296. objectApply(object, function (value, key) {
  29297. if ((test && test(value, key, object, result)) || Boolean(value)) {
  29298. result[key] = value;
  29299. }
  29300. });
  29301. return result;
  29302. }
  29303. exports.filterObject = filterObject;
  29304. function flatten(object) {
  29305. var result = [];
  29306. objectApply(object, function (value, key) {
  29307. result.push([key, value]);
  29308. });
  29309. return result;
  29310. }
  29311. exports.flatten = flatten;
  29312. function any(array, test) {
  29313. for (var i = 0; i < array.length; i++) {
  29314. if (test(array[i], i, array)) {
  29315. return true;
  29316. }
  29317. }
  29318. return false;
  29319. }
  29320. exports.any = any;
  29321. function all(array, test) {
  29322. for (var i = 0; i < array.length; i++) {
  29323. if (!test(array[i], i, array)) {
  29324. return false;
  29325. }
  29326. }
  29327. return true;
  29328. }
  29329. exports.all = all;
  29330. function encodeParamsObject(data) {
  29331. return mapObject(data, function (value) {
  29332. if (typeof value === "object") {
  29333. value = safeJSONStringify(value);
  29334. }
  29335. return encodeURIComponent(base64_1["default"](value.toString()));
  29336. });
  29337. }
  29338. exports.encodeParamsObject = encodeParamsObject;
  29339. function buildQueryString(data) {
  29340. var params = filterObject(data, function (value) {
  29341. return value !== undefined;
  29342. });
  29343. var query = map(flatten(encodeParamsObject(params)), util_1["default"].method("join", "=")).join("&");
  29344. return query;
  29345. }
  29346. exports.buildQueryString = buildQueryString;
  29347. function decycleObject(object) {
  29348. var objects = [], paths = [];
  29349. return (function derez(value, path) {
  29350. var i, name, nu;
  29351. switch (typeof value) {
  29352. case 'object':
  29353. if (!value) {
  29354. return null;
  29355. }
  29356. for (i = 0; i < objects.length; i += 1) {
  29357. if (objects[i] === value) {
  29358. return { $ref: paths[i] };
  29359. }
  29360. }
  29361. objects.push(value);
  29362. paths.push(path);
  29363. if (Object.prototype.toString.apply(value) === '[object Array]') {
  29364. nu = [];
  29365. for (i = 0; i < value.length; i += 1) {
  29366. nu[i] = derez(value[i], path + '[' + i + ']');
  29367. }
  29368. }
  29369. else {
  29370. nu = {};
  29371. for (name in value) {
  29372. if (Object.prototype.hasOwnProperty.call(value, name)) {
  29373. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  29374. }
  29375. }
  29376. }
  29377. return nu;
  29378. case 'number':
  29379. case 'string':
  29380. case 'boolean':
  29381. return value;
  29382. }
  29383. }(object, '$'));
  29384. }
  29385. exports.decycleObject = decycleObject;
  29386. function safeJSONStringify(source) {
  29387. try {
  29388. return JSON.stringify(source);
  29389. }
  29390. catch (e) {
  29391. return JSON.stringify(decycleObject(source));
  29392. }
  29393. }
  29394. exports.safeJSONStringify = safeJSONStringify;
  29395. /***/ }),
  29396. /* 10 */
  29397. /***/ (function(module, exports, __webpack_require__) {
  29398. "use strict";
  29399. function encode(s) {
  29400. return btoa(utob(s));
  29401. }
  29402. exports.__esModule = true;
  29403. exports["default"] = encode;
  29404. var fromCharCode = String.fromCharCode;
  29405. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  29406. var b64tab = {};
  29407. for (var i = 0, l = b64chars.length; i < l; i++) {
  29408. b64tab[b64chars.charAt(i)] = i;
  29409. }
  29410. var cb_utob = function (c) {
  29411. var cc = c.charCodeAt(0);
  29412. return cc < 0x80 ? c
  29413. : cc < 0x800 ? fromCharCode(0xc0 | (cc >>> 6)) +
  29414. fromCharCode(0x80 | (cc & 0x3f))
  29415. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  29416. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  29417. fromCharCode(0x80 | (cc & 0x3f));
  29418. };
  29419. var utob = function (u) {
  29420. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  29421. };
  29422. var cb_encode = function (ccc) {
  29423. var padlen = [0, 2, 1][ccc.length % 3];
  29424. var ord = ccc.charCodeAt(0) << 16
  29425. | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
  29426. | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0));
  29427. var chars = [
  29428. b64chars.charAt(ord >>> 18),
  29429. b64chars.charAt((ord >>> 12) & 63),
  29430. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  29431. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  29432. ];
  29433. return chars.join('');
  29434. };
  29435. var btoa = (window).btoa || function (b) {
  29436. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  29437. };
  29438. /***/ }),
  29439. /* 11 */
  29440. /***/ (function(module, exports, __webpack_require__) {
  29441. "use strict";
  29442. var timers_1 = __webpack_require__(12);
  29443. var Util = {
  29444. now: function () {
  29445. if (Date.now) {
  29446. return Date.now();
  29447. }
  29448. else {
  29449. return new Date().valueOf();
  29450. }
  29451. },
  29452. defer: function (callback) {
  29453. return new timers_1.OneOffTimer(0, callback);
  29454. },
  29455. method: function (name) {
  29456. var args = [];
  29457. for (var _i = 1; _i < arguments.length; _i++) {
  29458. args[_i - 1] = arguments[_i];
  29459. }
  29460. var boundArguments = Array.prototype.slice.call(arguments, 1);
  29461. return function (object) {
  29462. return object[name].apply(object, boundArguments.concat(arguments));
  29463. };
  29464. }
  29465. };
  29466. exports.__esModule = true;
  29467. exports["default"] = Util;
  29468. /***/ }),
  29469. /* 12 */
  29470. /***/ (function(module, exports, __webpack_require__) {
  29471. "use strict";
  29472. var __extends = (this && this.__extends) || function (d, b) {
  29473. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29474. function __() { this.constructor = d; }
  29475. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29476. };
  29477. var abstract_timer_1 = __webpack_require__(13);
  29478. function clearTimeout(timer) {
  29479. (window).clearTimeout(timer);
  29480. }
  29481. function clearInterval(timer) {
  29482. (window).clearInterval(timer);
  29483. }
  29484. var OneOffTimer = (function (_super) {
  29485. __extends(OneOffTimer, _super);
  29486. function OneOffTimer(delay, callback) {
  29487. _super.call(this, setTimeout, clearTimeout, delay, function (timer) {
  29488. callback();
  29489. return null;
  29490. });
  29491. }
  29492. return OneOffTimer;
  29493. }(abstract_timer_1["default"]));
  29494. exports.OneOffTimer = OneOffTimer;
  29495. var PeriodicTimer = (function (_super) {
  29496. __extends(PeriodicTimer, _super);
  29497. function PeriodicTimer(delay, callback) {
  29498. _super.call(this, setInterval, clearInterval, delay, function (timer) {
  29499. callback();
  29500. return timer;
  29501. });
  29502. }
  29503. return PeriodicTimer;
  29504. }(abstract_timer_1["default"]));
  29505. exports.PeriodicTimer = PeriodicTimer;
  29506. /***/ }),
  29507. /* 13 */
  29508. /***/ (function(module, exports) {
  29509. "use strict";
  29510. var Timer = (function () {
  29511. function Timer(set, clear, delay, callback) {
  29512. var _this = this;
  29513. this.clear = clear;
  29514. this.timer = set(function () {
  29515. if (_this.timer) {
  29516. _this.timer = callback(_this.timer);
  29517. }
  29518. }, delay);
  29519. }
  29520. Timer.prototype.isRunning = function () {
  29521. return this.timer !== null;
  29522. };
  29523. Timer.prototype.ensureAborted = function () {
  29524. if (this.timer) {
  29525. this.clear(this.timer);
  29526. this.timer = null;
  29527. }
  29528. };
  29529. return Timer;
  29530. }());
  29531. exports.__esModule = true;
  29532. exports["default"] = Timer;
  29533. /***/ }),
  29534. /* 14 */
  29535. /***/ (function(module, exports, __webpack_require__) {
  29536. "use strict";
  29537. var logger_1 = __webpack_require__(8);
  29538. var jsonp = function (context, socketId, callback) {
  29539. if (this.authOptions.headers !== undefined) {
  29540. logger_1["default"].warn("Warn", "To send headers with the auth request, you must use AJAX, rather than JSONP.");
  29541. }
  29542. var callbackName = context.nextAuthCallbackID.toString();
  29543. context.nextAuthCallbackID++;
  29544. var document = context.getDocument();
  29545. var script = document.createElement("script");
  29546. context.auth_callbacks[callbackName] = function (data) {
  29547. callback(false, data);
  29548. };
  29549. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  29550. script.src = this.options.authEndpoint +
  29551. '?callback=' +
  29552. encodeURIComponent(callback_name) +
  29553. '&' +
  29554. this.composeQuery(socketId);
  29555. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  29556. head.insertBefore(script, head.firstChild);
  29557. };
  29558. exports.__esModule = true;
  29559. exports["default"] = jsonp;
  29560. /***/ }),
  29561. /* 15 */
  29562. /***/ (function(module, exports) {
  29563. "use strict";
  29564. var ScriptRequest = (function () {
  29565. function ScriptRequest(src) {
  29566. this.src = src;
  29567. }
  29568. ScriptRequest.prototype.send = function (receiver) {
  29569. var self = this;
  29570. var errorString = "Error loading " + self.src;
  29571. self.script = document.createElement("script");
  29572. self.script.id = receiver.id;
  29573. self.script.src = self.src;
  29574. self.script.type = "text/javascript";
  29575. self.script.charset = "UTF-8";
  29576. if (self.script.addEventListener) {
  29577. self.script.onerror = function () {
  29578. receiver.callback(errorString);
  29579. };
  29580. self.script.onload = function () {
  29581. receiver.callback(null);
  29582. };
  29583. }
  29584. else {
  29585. self.script.onreadystatechange = function () {
  29586. if (self.script.readyState === 'loaded' ||
  29587. self.script.readyState === 'complete') {
  29588. receiver.callback(null);
  29589. }
  29590. };
  29591. }
  29592. if (self.script.async === undefined && document.attachEvent &&
  29593. /opera/i.test(navigator.userAgent)) {
  29594. self.errorScript = document.createElement("script");
  29595. self.errorScript.id = receiver.id + "_error";
  29596. self.errorScript.text = receiver.name + "('" + errorString + "');";
  29597. self.script.async = self.errorScript.async = false;
  29598. }
  29599. else {
  29600. self.script.async = true;
  29601. }
  29602. var head = document.getElementsByTagName('head')[0];
  29603. head.insertBefore(self.script, head.firstChild);
  29604. if (self.errorScript) {
  29605. head.insertBefore(self.errorScript, self.script.nextSibling);
  29606. }
  29607. };
  29608. ScriptRequest.prototype.cleanup = function () {
  29609. if (this.script) {
  29610. this.script.onload = this.script.onerror = null;
  29611. this.script.onreadystatechange = null;
  29612. }
  29613. if (this.script && this.script.parentNode) {
  29614. this.script.parentNode.removeChild(this.script);
  29615. }
  29616. if (this.errorScript && this.errorScript.parentNode) {
  29617. this.errorScript.parentNode.removeChild(this.errorScript);
  29618. }
  29619. this.script = null;
  29620. this.errorScript = null;
  29621. };
  29622. return ScriptRequest;
  29623. }());
  29624. exports.__esModule = true;
  29625. exports["default"] = ScriptRequest;
  29626. /***/ }),
  29627. /* 16 */
  29628. /***/ (function(module, exports, __webpack_require__) {
  29629. "use strict";
  29630. var Collections = __webpack_require__(9);
  29631. var runtime_1 = __webpack_require__(2);
  29632. var JSONPRequest = (function () {
  29633. function JSONPRequest(url, data) {
  29634. this.url = url;
  29635. this.data = data;
  29636. }
  29637. JSONPRequest.prototype.send = function (receiver) {
  29638. if (this.request) {
  29639. return;
  29640. }
  29641. var query = Collections.buildQueryString(this.data);
  29642. var url = this.url + "/" + receiver.number + "?" + query;
  29643. this.request = runtime_1["default"].createScriptRequest(url);
  29644. this.request.send(receiver);
  29645. };
  29646. JSONPRequest.prototype.cleanup = function () {
  29647. if (this.request) {
  29648. this.request.cleanup();
  29649. }
  29650. };
  29651. return JSONPRequest;
  29652. }());
  29653. exports.__esModule = true;
  29654. exports["default"] = JSONPRequest;
  29655. /***/ }),
  29656. /* 17 */
  29657. /***/ (function(module, exports, __webpack_require__) {
  29658. "use strict";
  29659. var runtime_1 = __webpack_require__(2);
  29660. var script_receiver_factory_1 = __webpack_require__(4);
  29661. var getAgent = function (sender, encrypted) {
  29662. return function (data, callback) {
  29663. var scheme = "http" + (encrypted ? "s" : "") + "://";
  29664. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  29665. var request = runtime_1["default"].createJSONPRequest(url, data);
  29666. var receiver = runtime_1["default"].ScriptReceivers.create(function (error, result) {
  29667. script_receiver_factory_1.ScriptReceivers.remove(receiver);
  29668. request.cleanup();
  29669. if (result && result.host) {
  29670. sender.host = result.host;
  29671. }
  29672. if (callback) {
  29673. callback(error, result);
  29674. }
  29675. });
  29676. request.send(receiver);
  29677. };
  29678. };
  29679. var jsonp = {
  29680. name: 'jsonp',
  29681. getAgent: getAgent
  29682. };
  29683. exports.__esModule = true;
  29684. exports["default"] = jsonp;
  29685. /***/ }),
  29686. /* 18 */
  29687. /***/ (function(module, exports, __webpack_require__) {
  29688. "use strict";
  29689. var transports_1 = __webpack_require__(19);
  29690. var transport_1 = __webpack_require__(21);
  29691. var URLSchemes = __webpack_require__(20);
  29692. var runtime_1 = __webpack_require__(2);
  29693. var dependencies_1 = __webpack_require__(3);
  29694. var Collections = __webpack_require__(9);
  29695. var SockJSTransport = new transport_1["default"]({
  29696. file: "sockjs",
  29697. urls: URLSchemes.sockjs,
  29698. handlesActivityChecks: true,
  29699. supportsPing: false,
  29700. isSupported: function () {
  29701. return true;
  29702. },
  29703. isInitialized: function () {
  29704. return window.SockJS !== undefined;
  29705. },
  29706. getSocket: function (url, options) {
  29707. return new window.SockJS(url, null, {
  29708. js_path: dependencies_1.Dependencies.getPath("sockjs", {
  29709. encrypted: options.encrypted
  29710. }),
  29711. ignore_null_origin: options.ignoreNullOrigin
  29712. });
  29713. },
  29714. beforeOpen: function (socket, path) {
  29715. socket.send(JSON.stringify({
  29716. path: path
  29717. }));
  29718. }
  29719. });
  29720. var xdrConfiguration = {
  29721. isSupported: function (environment) {
  29722. var yes = runtime_1["default"].isXDRSupported(environment.encrypted);
  29723. return yes;
  29724. }
  29725. };
  29726. var XDRStreamingTransport = new transport_1["default"](Collections.extend({}, transports_1.streamingConfiguration, xdrConfiguration));
  29727. var XDRPollingTransport = new transport_1["default"](Collections.extend({}, transports_1.pollingConfiguration, xdrConfiguration));
  29728. transports_1["default"].xdr_streaming = XDRStreamingTransport;
  29729. transports_1["default"].xdr_polling = XDRPollingTransport;
  29730. transports_1["default"].sockjs = SockJSTransport;
  29731. exports.__esModule = true;
  29732. exports["default"] = transports_1["default"];
  29733. /***/ }),
  29734. /* 19 */
  29735. /***/ (function(module, exports, __webpack_require__) {
  29736. "use strict";
  29737. var URLSchemes = __webpack_require__(20);
  29738. var transport_1 = __webpack_require__(21);
  29739. var Collections = __webpack_require__(9);
  29740. var runtime_1 = __webpack_require__(2);
  29741. var WSTransport = new transport_1["default"]({
  29742. urls: URLSchemes.ws,
  29743. handlesActivityChecks: false,
  29744. supportsPing: false,
  29745. isInitialized: function () {
  29746. return Boolean(runtime_1["default"].getWebSocketAPI());
  29747. },
  29748. isSupported: function () {
  29749. return Boolean(runtime_1["default"].getWebSocketAPI());
  29750. },
  29751. getSocket: function (url) {
  29752. return runtime_1["default"].createWebSocket(url);
  29753. }
  29754. });
  29755. var httpConfiguration = {
  29756. urls: URLSchemes.http,
  29757. handlesActivityChecks: false,
  29758. supportsPing: true,
  29759. isInitialized: function () {
  29760. return true;
  29761. }
  29762. };
  29763. exports.streamingConfiguration = Collections.extend({ getSocket: function (url) {
  29764. return runtime_1["default"].HTTPFactory.createStreamingSocket(url);
  29765. }
  29766. }, httpConfiguration);
  29767. exports.pollingConfiguration = Collections.extend({ getSocket: function (url) {
  29768. return runtime_1["default"].HTTPFactory.createPollingSocket(url);
  29769. }
  29770. }, httpConfiguration);
  29771. var xhrConfiguration = {
  29772. isSupported: function () {
  29773. return runtime_1["default"].isXHRSupported();
  29774. }
  29775. };
  29776. var XHRStreamingTransport = new transport_1["default"](Collections.extend({}, exports.streamingConfiguration, xhrConfiguration));
  29777. var XHRPollingTransport = new transport_1["default"](Collections.extend({}, exports.pollingConfiguration, xhrConfiguration));
  29778. var Transports = {
  29779. ws: WSTransport,
  29780. xhr_streaming: XHRStreamingTransport,
  29781. xhr_polling: XHRPollingTransport
  29782. };
  29783. exports.__esModule = true;
  29784. exports["default"] = Transports;
  29785. /***/ }),
  29786. /* 20 */
  29787. /***/ (function(module, exports, __webpack_require__) {
  29788. "use strict";
  29789. var defaults_1 = __webpack_require__(5);
  29790. function getGenericURL(baseScheme, params, path) {
  29791. var scheme = baseScheme + (params.encrypted ? "s" : "");
  29792. var host = params.encrypted ? params.hostEncrypted : params.hostUnencrypted;
  29793. return scheme + "://" + host + path;
  29794. }
  29795. function getGenericPath(key, queryString) {
  29796. var path = "/app/" + key;
  29797. var query = "?protocol=" + defaults_1["default"].PROTOCOL +
  29798. "&client=js" +
  29799. "&version=" + defaults_1["default"].VERSION +
  29800. (queryString ? ("&" + queryString) : "");
  29801. return path + query;
  29802. }
  29803. exports.ws = {
  29804. getInitial: function (key, params) {
  29805. return getGenericURL("ws", params, getGenericPath(key, "flash=false"));
  29806. }
  29807. };
  29808. exports.http = {
  29809. getInitial: function (key, params) {
  29810. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  29811. return getGenericURL("http", params, path);
  29812. }
  29813. };
  29814. exports.sockjs = {
  29815. getInitial: function (key, params) {
  29816. return getGenericURL("http", params, params.httpPath || "/pusher");
  29817. },
  29818. getPath: function (key, params) {
  29819. return getGenericPath(key);
  29820. }
  29821. };
  29822. /***/ }),
  29823. /* 21 */
  29824. /***/ (function(module, exports, __webpack_require__) {
  29825. "use strict";
  29826. var transport_connection_1 = __webpack_require__(22);
  29827. var Transport = (function () {
  29828. function Transport(hooks) {
  29829. this.hooks = hooks;
  29830. }
  29831. Transport.prototype.isSupported = function (environment) {
  29832. return this.hooks.isSupported(environment);
  29833. };
  29834. Transport.prototype.createConnection = function (name, priority, key, options) {
  29835. return new transport_connection_1["default"](this.hooks, name, priority, key, options);
  29836. };
  29837. return Transport;
  29838. }());
  29839. exports.__esModule = true;
  29840. exports["default"] = Transport;
  29841. /***/ }),
  29842. /* 22 */
  29843. /***/ (function(module, exports, __webpack_require__) {
  29844. "use strict";
  29845. var __extends = (this && this.__extends) || function (d, b) {
  29846. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29847. function __() { this.constructor = d; }
  29848. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29849. };
  29850. var util_1 = __webpack_require__(11);
  29851. var Collections = __webpack_require__(9);
  29852. var dispatcher_1 = __webpack_require__(23);
  29853. var logger_1 = __webpack_require__(8);
  29854. var runtime_1 = __webpack_require__(2);
  29855. var TransportConnection = (function (_super) {
  29856. __extends(TransportConnection, _super);
  29857. function TransportConnection(hooks, name, priority, key, options) {
  29858. _super.call(this);
  29859. this.initialize = runtime_1["default"].transportConnectionInitializer;
  29860. this.hooks = hooks;
  29861. this.name = name;
  29862. this.priority = priority;
  29863. this.key = key;
  29864. this.options = options;
  29865. this.state = "new";
  29866. this.timeline = options.timeline;
  29867. this.activityTimeout = options.activityTimeout;
  29868. this.id = this.timeline.generateUniqueID();
  29869. }
  29870. TransportConnection.prototype.handlesActivityChecks = function () {
  29871. return Boolean(this.hooks.handlesActivityChecks);
  29872. };
  29873. TransportConnection.prototype.supportsPing = function () {
  29874. return Boolean(this.hooks.supportsPing);
  29875. };
  29876. TransportConnection.prototype.connect = function () {
  29877. var _this = this;
  29878. if (this.socket || this.state !== "initialized") {
  29879. return false;
  29880. }
  29881. var url = this.hooks.urls.getInitial(this.key, this.options);
  29882. try {
  29883. this.socket = this.hooks.getSocket(url, this.options);
  29884. }
  29885. catch (e) {
  29886. util_1["default"].defer(function () {
  29887. _this.onError(e);
  29888. _this.changeState("closed");
  29889. });
  29890. return false;
  29891. }
  29892. this.bindListeners();
  29893. logger_1["default"].debug("Connecting", { transport: this.name, url: url });
  29894. this.changeState("connecting");
  29895. return true;
  29896. };
  29897. TransportConnection.prototype.close = function () {
  29898. if (this.socket) {
  29899. this.socket.close();
  29900. return true;
  29901. }
  29902. else {
  29903. return false;
  29904. }
  29905. };
  29906. TransportConnection.prototype.send = function (data) {
  29907. var _this = this;
  29908. if (this.state === "open") {
  29909. util_1["default"].defer(function () {
  29910. if (_this.socket) {
  29911. _this.socket.send(data);
  29912. }
  29913. });
  29914. return true;
  29915. }
  29916. else {
  29917. return false;
  29918. }
  29919. };
  29920. TransportConnection.prototype.ping = function () {
  29921. if (this.state === "open" && this.supportsPing()) {
  29922. this.socket.ping();
  29923. }
  29924. };
  29925. TransportConnection.prototype.onOpen = function () {
  29926. if (this.hooks.beforeOpen) {
  29927. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  29928. }
  29929. this.changeState("open");
  29930. this.socket.onopen = undefined;
  29931. };
  29932. TransportConnection.prototype.onError = function (error) {
  29933. this.emit("error", { type: 'WebSocketError', error: error });
  29934. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  29935. };
  29936. TransportConnection.prototype.onClose = function (closeEvent) {
  29937. if (closeEvent) {
  29938. this.changeState("closed", {
  29939. code: closeEvent.code,
  29940. reason: closeEvent.reason,
  29941. wasClean: closeEvent.wasClean
  29942. });
  29943. }
  29944. else {
  29945. this.changeState("closed");
  29946. }
  29947. this.unbindListeners();
  29948. this.socket = undefined;
  29949. };
  29950. TransportConnection.prototype.onMessage = function (message) {
  29951. this.emit("message", message);
  29952. };
  29953. TransportConnection.prototype.onActivity = function () {
  29954. this.emit("activity");
  29955. };
  29956. TransportConnection.prototype.bindListeners = function () {
  29957. var _this = this;
  29958. this.socket.onopen = function () {
  29959. _this.onOpen();
  29960. };
  29961. this.socket.onerror = function (error) {
  29962. _this.onError(error);
  29963. };
  29964. this.socket.onclose = function (closeEvent) {
  29965. _this.onClose(closeEvent);
  29966. };
  29967. this.socket.onmessage = function (message) {
  29968. _this.onMessage(message);
  29969. };
  29970. if (this.supportsPing()) {
  29971. this.socket.onactivity = function () { _this.onActivity(); };
  29972. }
  29973. };
  29974. TransportConnection.prototype.unbindListeners = function () {
  29975. if (this.socket) {
  29976. this.socket.onopen = undefined;
  29977. this.socket.onerror = undefined;
  29978. this.socket.onclose = undefined;
  29979. this.socket.onmessage = undefined;
  29980. if (this.supportsPing()) {
  29981. this.socket.onactivity = undefined;
  29982. }
  29983. }
  29984. };
  29985. TransportConnection.prototype.changeState = function (state, params) {
  29986. this.state = state;
  29987. this.timeline.info(this.buildTimelineMessage({
  29988. state: state,
  29989. params: params
  29990. }));
  29991. this.emit(state, params);
  29992. };
  29993. TransportConnection.prototype.buildTimelineMessage = function (message) {
  29994. return Collections.extend({ cid: this.id }, message);
  29995. };
  29996. return TransportConnection;
  29997. }(dispatcher_1["default"]));
  29998. exports.__esModule = true;
  29999. exports["default"] = TransportConnection;
  30000. /***/ }),
  30001. /* 23 */
  30002. /***/ (function(module, exports, __webpack_require__) {
  30003. "use strict";
  30004. var Collections = __webpack_require__(9);
  30005. var callback_registry_1 = __webpack_require__(24);
  30006. var Dispatcher = (function () {
  30007. function Dispatcher(failThrough) {
  30008. this.callbacks = new callback_registry_1["default"]();
  30009. this.global_callbacks = [];
  30010. this.failThrough = failThrough;
  30011. }
  30012. Dispatcher.prototype.bind = function (eventName, callback, context) {
  30013. this.callbacks.add(eventName, callback, context);
  30014. return this;
  30015. };
  30016. Dispatcher.prototype.bind_global = function (callback) {
  30017. this.global_callbacks.push(callback);
  30018. return this;
  30019. };
  30020. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  30021. this.callbacks.remove(eventName, callback, context);
  30022. return this;
  30023. };
  30024. Dispatcher.prototype.unbind_global = function (callback) {
  30025. if (!callback) {
  30026. this.global_callbacks = [];
  30027. return this;
  30028. }
  30029. this.global_callbacks = Collections.filter(this.global_callbacks || [], function (c) { return c !== callback; });
  30030. return this;
  30031. };
  30032. Dispatcher.prototype.unbind_all = function () {
  30033. this.unbind();
  30034. this.unbind_global();
  30035. return this;
  30036. };
  30037. Dispatcher.prototype.emit = function (eventName, data) {
  30038. var i;
  30039. for (i = 0; i < this.global_callbacks.length; i++) {
  30040. this.global_callbacks[i](eventName, data);
  30041. }
  30042. var callbacks = this.callbacks.get(eventName);
  30043. if (callbacks && callbacks.length > 0) {
  30044. for (i = 0; i < callbacks.length; i++) {
  30045. callbacks[i].fn.call(callbacks[i].context || (window), data);
  30046. }
  30047. }
  30048. else if (this.failThrough) {
  30049. this.failThrough(eventName, data);
  30050. }
  30051. return this;
  30052. };
  30053. return Dispatcher;
  30054. }());
  30055. exports.__esModule = true;
  30056. exports["default"] = Dispatcher;
  30057. /***/ }),
  30058. /* 24 */
  30059. /***/ (function(module, exports, __webpack_require__) {
  30060. "use strict";
  30061. var Collections = __webpack_require__(9);
  30062. var CallbackRegistry = (function () {
  30063. function CallbackRegistry() {
  30064. this._callbacks = {};
  30065. }
  30066. CallbackRegistry.prototype.get = function (name) {
  30067. return this._callbacks[prefix(name)];
  30068. };
  30069. CallbackRegistry.prototype.add = function (name, callback, context) {
  30070. var prefixedEventName = prefix(name);
  30071. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  30072. this._callbacks[prefixedEventName].push({
  30073. fn: callback,
  30074. context: context
  30075. });
  30076. };
  30077. CallbackRegistry.prototype.remove = function (name, callback, context) {
  30078. if (!name && !callback && !context) {
  30079. this._callbacks = {};
  30080. return;
  30081. }
  30082. var names = name ? [prefix(name)] : Collections.keys(this._callbacks);
  30083. if (callback || context) {
  30084. this.removeCallback(names, callback, context);
  30085. }
  30086. else {
  30087. this.removeAllCallbacks(names);
  30088. }
  30089. };
  30090. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  30091. Collections.apply(names, function (name) {
  30092. this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function (binding) {
  30093. return (callback && callback !== binding.fn) ||
  30094. (context && context !== binding.context);
  30095. });
  30096. if (this._callbacks[name].length === 0) {
  30097. delete this._callbacks[name];
  30098. }
  30099. }, this);
  30100. };
  30101. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  30102. Collections.apply(names, function (name) {
  30103. delete this._callbacks[name];
  30104. }, this);
  30105. };
  30106. return CallbackRegistry;
  30107. }());
  30108. exports.__esModule = true;
  30109. exports["default"] = CallbackRegistry;
  30110. function prefix(name) {
  30111. return "_" + name;
  30112. }
  30113. /***/ }),
  30114. /* 25 */
  30115. /***/ (function(module, exports, __webpack_require__) {
  30116. "use strict";
  30117. var __extends = (this && this.__extends) || function (d, b) {
  30118. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30119. function __() { this.constructor = d; }
  30120. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30121. };
  30122. var dispatcher_1 = __webpack_require__(23);
  30123. var NetInfo = (function (_super) {
  30124. __extends(NetInfo, _super);
  30125. function NetInfo() {
  30126. _super.call(this);
  30127. var self = this;
  30128. if (window.addEventListener !== undefined) {
  30129. window.addEventListener("online", function () {
  30130. self.emit('online');
  30131. }, false);
  30132. window.addEventListener("offline", function () {
  30133. self.emit('offline');
  30134. }, false);
  30135. }
  30136. }
  30137. NetInfo.prototype.isOnline = function () {
  30138. if (window.navigator.onLine === undefined) {
  30139. return true;
  30140. }
  30141. else {
  30142. return window.navigator.onLine;
  30143. }
  30144. };
  30145. return NetInfo;
  30146. }(dispatcher_1["default"]));
  30147. exports.NetInfo = NetInfo;
  30148. exports.Network = new NetInfo();
  30149. /***/ }),
  30150. /* 26 */
  30151. /***/ (function(module, exports) {
  30152. "use strict";
  30153. var getDefaultStrategy = function (config) {
  30154. var wsStrategy;
  30155. if (config.encrypted) {
  30156. wsStrategy = [
  30157. ":best_connected_ever",
  30158. ":ws_loop",
  30159. [":delayed", 2000, [":http_fallback_loop"]]
  30160. ];
  30161. }
  30162. else {
  30163. wsStrategy = [
  30164. ":best_connected_ever",
  30165. ":ws_loop",
  30166. [":delayed", 2000, [":wss_loop"]],
  30167. [":delayed", 5000, [":http_fallback_loop"]]
  30168. ];
  30169. }
  30170. return [
  30171. [":def", "ws_options", {
  30172. hostUnencrypted: config.wsHost + ":" + config.wsPort,
  30173. hostEncrypted: config.wsHost + ":" + config.wssPort
  30174. }],
  30175. [":def", "wss_options", [":extend", ":ws_options", {
  30176. encrypted: true
  30177. }]],
  30178. [":def", "sockjs_options", {
  30179. hostUnencrypted: config.httpHost + ":" + config.httpPort,
  30180. hostEncrypted: config.httpHost + ":" + config.httpsPort,
  30181. httpPath: config.httpPath
  30182. }],
  30183. [":def", "timeouts", {
  30184. loop: true,
  30185. timeout: 15000,
  30186. timeoutLimit: 60000
  30187. }],
  30188. [":def", "ws_manager", [":transport_manager", {
  30189. lives: 2,
  30190. minPingDelay: 10000,
  30191. maxPingDelay: config.activity_timeout
  30192. }]],
  30193. [":def", "streaming_manager", [":transport_manager", {
  30194. lives: 2,
  30195. minPingDelay: 10000,
  30196. maxPingDelay: config.activity_timeout
  30197. }]],
  30198. [":def_transport", "ws", "ws", 3, ":ws_options", ":ws_manager"],
  30199. [":def_transport", "wss", "ws", 3, ":wss_options", ":ws_manager"],
  30200. [":def_transport", "sockjs", "sockjs", 1, ":sockjs_options"],
  30201. [":def_transport", "xhr_streaming", "xhr_streaming", 1, ":sockjs_options", ":streaming_manager"],
  30202. [":def_transport", "xdr_streaming", "xdr_streaming", 1, ":sockjs_options", ":streaming_manager"],
  30203. [":def_transport", "xhr_polling", "xhr_polling", 1, ":sockjs_options"],
  30204. [":def_transport", "xdr_polling", "xdr_polling", 1, ":sockjs_options"],
  30205. [":def", "ws_loop", [":sequential", ":timeouts", ":ws"]],
  30206. [":def", "wss_loop", [":sequential", ":timeouts", ":wss"]],
  30207. [":def", "sockjs_loop", [":sequential", ":timeouts", ":sockjs"]],
  30208. [":def", "streaming_loop", [":sequential", ":timeouts",
  30209. [":if", [":is_supported", ":xhr_streaming"],
  30210. ":xhr_streaming",
  30211. ":xdr_streaming"
  30212. ]
  30213. ]],
  30214. [":def", "polling_loop", [":sequential", ":timeouts",
  30215. [":if", [":is_supported", ":xhr_polling"],
  30216. ":xhr_polling",
  30217. ":xdr_polling"
  30218. ]
  30219. ]],
  30220. [":def", "http_loop", [":if", [":is_supported", ":streaming_loop"], [
  30221. ":best_connected_ever",
  30222. ":streaming_loop",
  30223. [":delayed", 4000, [":polling_loop"]]
  30224. ], [
  30225. ":polling_loop"
  30226. ]]],
  30227. [":def", "http_fallback_loop",
  30228. [":if", [":is_supported", ":http_loop"], [
  30229. ":http_loop"
  30230. ], [
  30231. ":sockjs_loop"
  30232. ]]
  30233. ],
  30234. [":def", "strategy",
  30235. [":cached", 1800000,
  30236. [":first_connected",
  30237. [":if", [":is_supported", ":ws"],
  30238. wsStrategy,
  30239. ":http_fallback_loop"
  30240. ]
  30241. ]
  30242. ]
  30243. ]
  30244. ];
  30245. };
  30246. exports.__esModule = true;
  30247. exports["default"] = getDefaultStrategy;
  30248. /***/ }),
  30249. /* 27 */
  30250. /***/ (function(module, exports, __webpack_require__) {
  30251. "use strict";
  30252. var dependencies_1 = __webpack_require__(3);
  30253. function default_1() {
  30254. var self = this;
  30255. self.timeline.info(self.buildTimelineMessage({
  30256. transport: self.name + (self.options.encrypted ? "s" : "")
  30257. }));
  30258. if (self.hooks.isInitialized()) {
  30259. self.changeState("initialized");
  30260. }
  30261. else if (self.hooks.file) {
  30262. self.changeState("initializing");
  30263. dependencies_1.Dependencies.load(self.hooks.file, { encrypted: self.options.encrypted }, function (error, callback) {
  30264. if (self.hooks.isInitialized()) {
  30265. self.changeState("initialized");
  30266. callback(true);
  30267. }
  30268. else {
  30269. if (error) {
  30270. self.onError(error);
  30271. }
  30272. self.onClose();
  30273. callback(false);
  30274. }
  30275. });
  30276. }
  30277. else {
  30278. self.onClose();
  30279. }
  30280. }
  30281. exports.__esModule = true;
  30282. exports["default"] = default_1;
  30283. /***/ }),
  30284. /* 28 */
  30285. /***/ (function(module, exports, __webpack_require__) {
  30286. "use strict";
  30287. var http_xdomain_request_1 = __webpack_require__(29);
  30288. var http_1 = __webpack_require__(31);
  30289. http_1["default"].createXDR = function (method, url) {
  30290. return this.createRequest(http_xdomain_request_1["default"], method, url);
  30291. };
  30292. exports.__esModule = true;
  30293. exports["default"] = http_1["default"];
  30294. /***/ }),
  30295. /* 29 */
  30296. /***/ (function(module, exports, __webpack_require__) {
  30297. "use strict";
  30298. var Errors = __webpack_require__(30);
  30299. var hooks = {
  30300. getRequest: function (socket) {
  30301. var xdr = new window.XDomainRequest();
  30302. xdr.ontimeout = function () {
  30303. socket.emit("error", new Errors.RequestTimedOut());
  30304. socket.close();
  30305. };
  30306. xdr.onerror = function (e) {
  30307. socket.emit("error", e);
  30308. socket.close();
  30309. };
  30310. xdr.onprogress = function () {
  30311. if (xdr.responseText && xdr.responseText.length > 0) {
  30312. socket.onChunk(200, xdr.responseText);
  30313. }
  30314. };
  30315. xdr.onload = function () {
  30316. if (xdr.responseText && xdr.responseText.length > 0) {
  30317. socket.onChunk(200, xdr.responseText);
  30318. }
  30319. socket.emit("finished", 200);
  30320. socket.close();
  30321. };
  30322. return xdr;
  30323. },
  30324. abortRequest: function (xdr) {
  30325. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  30326. xdr.abort();
  30327. }
  30328. };
  30329. exports.__esModule = true;
  30330. exports["default"] = hooks;
  30331. /***/ }),
  30332. /* 30 */
  30333. /***/ (function(module, exports) {
  30334. "use strict";
  30335. var __extends = (this && this.__extends) || function (d, b) {
  30336. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30337. function __() { this.constructor = d; }
  30338. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30339. };
  30340. var BadEventName = (function (_super) {
  30341. __extends(BadEventName, _super);
  30342. function BadEventName() {
  30343. _super.apply(this, arguments);
  30344. }
  30345. return BadEventName;
  30346. }(Error));
  30347. exports.BadEventName = BadEventName;
  30348. var RequestTimedOut = (function (_super) {
  30349. __extends(RequestTimedOut, _super);
  30350. function RequestTimedOut() {
  30351. _super.apply(this, arguments);
  30352. }
  30353. return RequestTimedOut;
  30354. }(Error));
  30355. exports.RequestTimedOut = RequestTimedOut;
  30356. var TransportPriorityTooLow = (function (_super) {
  30357. __extends(TransportPriorityTooLow, _super);
  30358. function TransportPriorityTooLow() {
  30359. _super.apply(this, arguments);
  30360. }
  30361. return TransportPriorityTooLow;
  30362. }(Error));
  30363. exports.TransportPriorityTooLow = TransportPriorityTooLow;
  30364. var TransportClosed = (function (_super) {
  30365. __extends(TransportClosed, _super);
  30366. function TransportClosed() {
  30367. _super.apply(this, arguments);
  30368. }
  30369. return TransportClosed;
  30370. }(Error));
  30371. exports.TransportClosed = TransportClosed;
  30372. var UnsupportedTransport = (function (_super) {
  30373. __extends(UnsupportedTransport, _super);
  30374. function UnsupportedTransport() {
  30375. _super.apply(this, arguments);
  30376. }
  30377. return UnsupportedTransport;
  30378. }(Error));
  30379. exports.UnsupportedTransport = UnsupportedTransport;
  30380. var UnsupportedStrategy = (function (_super) {
  30381. __extends(UnsupportedStrategy, _super);
  30382. function UnsupportedStrategy() {
  30383. _super.apply(this, arguments);
  30384. }
  30385. return UnsupportedStrategy;
  30386. }(Error));
  30387. exports.UnsupportedStrategy = UnsupportedStrategy;
  30388. /***/ }),
  30389. /* 31 */
  30390. /***/ (function(module, exports, __webpack_require__) {
  30391. "use strict";
  30392. var http_request_1 = __webpack_require__(32);
  30393. var http_socket_1 = __webpack_require__(33);
  30394. var http_streaming_socket_1 = __webpack_require__(35);
  30395. var http_polling_socket_1 = __webpack_require__(36);
  30396. var http_xhr_request_1 = __webpack_require__(37);
  30397. var HTTP = {
  30398. createStreamingSocket: function (url) {
  30399. return this.createSocket(http_streaming_socket_1["default"], url);
  30400. },
  30401. createPollingSocket: function (url) {
  30402. return this.createSocket(http_polling_socket_1["default"], url);
  30403. },
  30404. createSocket: function (hooks, url) {
  30405. return new http_socket_1["default"](hooks, url);
  30406. },
  30407. createXHR: function (method, url) {
  30408. return this.createRequest(http_xhr_request_1["default"], method, url);
  30409. },
  30410. createRequest: function (hooks, method, url) {
  30411. return new http_request_1["default"](hooks, method, url);
  30412. }
  30413. };
  30414. exports.__esModule = true;
  30415. exports["default"] = HTTP;
  30416. /***/ }),
  30417. /* 32 */
  30418. /***/ (function(module, exports, __webpack_require__) {
  30419. "use strict";
  30420. var __extends = (this && this.__extends) || function (d, b) {
  30421. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30422. function __() { this.constructor = d; }
  30423. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30424. };
  30425. var runtime_1 = __webpack_require__(2);
  30426. var dispatcher_1 = __webpack_require__(23);
  30427. var MAX_BUFFER_LENGTH = 256 * 1024;
  30428. var HTTPRequest = (function (_super) {
  30429. __extends(HTTPRequest, _super);
  30430. function HTTPRequest(hooks, method, url) {
  30431. _super.call(this);
  30432. this.hooks = hooks;
  30433. this.method = method;
  30434. this.url = url;
  30435. }
  30436. HTTPRequest.prototype.start = function (payload) {
  30437. var _this = this;
  30438. this.position = 0;
  30439. this.xhr = this.hooks.getRequest(this);
  30440. this.unloader = function () {
  30441. _this.close();
  30442. };
  30443. runtime_1["default"].addUnloadListener(this.unloader);
  30444. this.xhr.open(this.method, this.url, true);
  30445. if (this.xhr.setRequestHeader) {
  30446. this.xhr.setRequestHeader("Content-Type", "application/json");
  30447. }
  30448. this.xhr.send(payload);
  30449. };
  30450. HTTPRequest.prototype.close = function () {
  30451. if (this.unloader) {
  30452. runtime_1["default"].removeUnloadListener(this.unloader);
  30453. this.unloader = null;
  30454. }
  30455. if (this.xhr) {
  30456. this.hooks.abortRequest(this.xhr);
  30457. this.xhr = null;
  30458. }
  30459. };
  30460. HTTPRequest.prototype.onChunk = function (status, data) {
  30461. while (true) {
  30462. var chunk = this.advanceBuffer(data);
  30463. if (chunk) {
  30464. this.emit("chunk", { status: status, data: chunk });
  30465. }
  30466. else {
  30467. break;
  30468. }
  30469. }
  30470. if (this.isBufferTooLong(data)) {
  30471. this.emit("buffer_too_long");
  30472. }
  30473. };
  30474. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  30475. var unreadData = buffer.slice(this.position);
  30476. var endOfLinePosition = unreadData.indexOf("\n");
  30477. if (endOfLinePosition !== -1) {
  30478. this.position += endOfLinePosition + 1;
  30479. return unreadData.slice(0, endOfLinePosition);
  30480. }
  30481. else {
  30482. return null;
  30483. }
  30484. };
  30485. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  30486. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  30487. };
  30488. return HTTPRequest;
  30489. }(dispatcher_1["default"]));
  30490. exports.__esModule = true;
  30491. exports["default"] = HTTPRequest;
  30492. /***/ }),
  30493. /* 33 */
  30494. /***/ (function(module, exports, __webpack_require__) {
  30495. "use strict";
  30496. var state_1 = __webpack_require__(34);
  30497. var util_1 = __webpack_require__(11);
  30498. var runtime_1 = __webpack_require__(2);
  30499. var autoIncrement = 1;
  30500. var HTTPSocket = (function () {
  30501. function HTTPSocket(hooks, url) {
  30502. this.hooks = hooks;
  30503. this.session = randomNumber(1000) + "/" + randomString(8);
  30504. this.location = getLocation(url);
  30505. this.readyState = state_1["default"].CONNECTING;
  30506. this.openStream();
  30507. }
  30508. HTTPSocket.prototype.send = function (payload) {
  30509. return this.sendRaw(JSON.stringify([payload]));
  30510. };
  30511. HTTPSocket.prototype.ping = function () {
  30512. this.hooks.sendHeartbeat(this);
  30513. };
  30514. HTTPSocket.prototype.close = function (code, reason) {
  30515. this.onClose(code, reason, true);
  30516. };
  30517. HTTPSocket.prototype.sendRaw = function (payload) {
  30518. if (this.readyState === state_1["default"].OPEN) {
  30519. try {
  30520. runtime_1["default"].createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  30521. return true;
  30522. }
  30523. catch (e) {
  30524. return false;
  30525. }
  30526. }
  30527. else {
  30528. return false;
  30529. }
  30530. };
  30531. HTTPSocket.prototype.reconnect = function () {
  30532. this.closeStream();
  30533. this.openStream();
  30534. };
  30535. ;
  30536. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  30537. this.closeStream();
  30538. this.readyState = state_1["default"].CLOSED;
  30539. if (this.onclose) {
  30540. this.onclose({
  30541. code: code,
  30542. reason: reason,
  30543. wasClean: wasClean
  30544. });
  30545. }
  30546. };
  30547. HTTPSocket.prototype.onChunk = function (chunk) {
  30548. if (chunk.status !== 200) {
  30549. return;
  30550. }
  30551. if (this.readyState === state_1["default"].OPEN) {
  30552. this.onActivity();
  30553. }
  30554. var payload;
  30555. var type = chunk.data.slice(0, 1);
  30556. switch (type) {
  30557. case 'o':
  30558. payload = JSON.parse(chunk.data.slice(1) || '{}');
  30559. this.onOpen(payload);
  30560. break;
  30561. case 'a':
  30562. payload = JSON.parse(chunk.data.slice(1) || '[]');
  30563. for (var i = 0; i < payload.length; i++) {
  30564. this.onEvent(payload[i]);
  30565. }
  30566. break;
  30567. case 'm':
  30568. payload = JSON.parse(chunk.data.slice(1) || 'null');
  30569. this.onEvent(payload);
  30570. break;
  30571. case 'h':
  30572. this.hooks.onHeartbeat(this);
  30573. break;
  30574. case 'c':
  30575. payload = JSON.parse(chunk.data.slice(1) || '[]');
  30576. this.onClose(payload[0], payload[1], true);
  30577. break;
  30578. }
  30579. };
  30580. HTTPSocket.prototype.onOpen = function (options) {
  30581. if (this.readyState === state_1["default"].CONNECTING) {
  30582. if (options && options.hostname) {
  30583. this.location.base = replaceHost(this.location.base, options.hostname);
  30584. }
  30585. this.readyState = state_1["default"].OPEN;
  30586. if (this.onopen) {
  30587. this.onopen();
  30588. }
  30589. }
  30590. else {
  30591. this.onClose(1006, "Server lost session", true);
  30592. }
  30593. };
  30594. HTTPSocket.prototype.onEvent = function (event) {
  30595. if (this.readyState === state_1["default"].OPEN && this.onmessage) {
  30596. this.onmessage({ data: event });
  30597. }
  30598. };
  30599. HTTPSocket.prototype.onActivity = function () {
  30600. if (this.onactivity) {
  30601. this.onactivity();
  30602. }
  30603. };
  30604. HTTPSocket.prototype.onError = function (error) {
  30605. if (this.onerror) {
  30606. this.onerror(error);
  30607. }
  30608. };
  30609. HTTPSocket.prototype.openStream = function () {
  30610. var _this = this;
  30611. this.stream = runtime_1["default"].createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  30612. this.stream.bind("chunk", function (chunk) {
  30613. _this.onChunk(chunk);
  30614. });
  30615. this.stream.bind("finished", function (status) {
  30616. _this.hooks.onFinished(_this, status);
  30617. });
  30618. this.stream.bind("buffer_too_long", function () {
  30619. _this.reconnect();
  30620. });
  30621. try {
  30622. this.stream.start();
  30623. }
  30624. catch (error) {
  30625. util_1["default"].defer(function () {
  30626. _this.onError(error);
  30627. _this.onClose(1006, "Could not start streaming", false);
  30628. });
  30629. }
  30630. };
  30631. HTTPSocket.prototype.closeStream = function () {
  30632. if (this.stream) {
  30633. this.stream.unbind_all();
  30634. this.stream.close();
  30635. this.stream = null;
  30636. }
  30637. };
  30638. return HTTPSocket;
  30639. }());
  30640. function getLocation(url) {
  30641. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  30642. return {
  30643. base: parts[1],
  30644. queryString: parts[2]
  30645. };
  30646. }
  30647. function getSendURL(url, session) {
  30648. return url.base + "/" + session + "/xhr_send";
  30649. }
  30650. function getUniqueURL(url) {
  30651. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  30652. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  30653. }
  30654. function replaceHost(url, hostname) {
  30655. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  30656. return urlParts[1] + hostname + urlParts[3];
  30657. }
  30658. function randomNumber(max) {
  30659. return Math.floor(Math.random() * max);
  30660. }
  30661. function randomString(length) {
  30662. var result = [];
  30663. for (var i = 0; i < length; i++) {
  30664. result.push(randomNumber(32).toString(32));
  30665. }
  30666. return result.join('');
  30667. }
  30668. exports.__esModule = true;
  30669. exports["default"] = HTTPSocket;
  30670. /***/ }),
  30671. /* 34 */
  30672. /***/ (function(module, exports) {
  30673. "use strict";
  30674. var State;
  30675. (function (State) {
  30676. State[State["CONNECTING"] = 0] = "CONNECTING";
  30677. State[State["OPEN"] = 1] = "OPEN";
  30678. State[State["CLOSED"] = 3] = "CLOSED";
  30679. })(State || (State = {}));
  30680. exports.__esModule = true;
  30681. exports["default"] = State;
  30682. /***/ }),
  30683. /* 35 */
  30684. /***/ (function(module, exports) {
  30685. "use strict";
  30686. var hooks = {
  30687. getReceiveURL: function (url, session) {
  30688. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  30689. },
  30690. onHeartbeat: function (socket) {
  30691. socket.sendRaw("[]");
  30692. },
  30693. sendHeartbeat: function (socket) {
  30694. socket.sendRaw("[]");
  30695. },
  30696. onFinished: function (socket, status) {
  30697. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  30698. }
  30699. };
  30700. exports.__esModule = true;
  30701. exports["default"] = hooks;
  30702. /***/ }),
  30703. /* 36 */
  30704. /***/ (function(module, exports) {
  30705. "use strict";
  30706. var hooks = {
  30707. getReceiveURL: function (url, session) {
  30708. return url.base + "/" + session + "/xhr" + url.queryString;
  30709. },
  30710. onHeartbeat: function () {
  30711. },
  30712. sendHeartbeat: function (socket) {
  30713. socket.sendRaw("[]");
  30714. },
  30715. onFinished: function (socket, status) {
  30716. if (status === 200) {
  30717. socket.reconnect();
  30718. }
  30719. else {
  30720. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  30721. }
  30722. }
  30723. };
  30724. exports.__esModule = true;
  30725. exports["default"] = hooks;
  30726. /***/ }),
  30727. /* 37 */
  30728. /***/ (function(module, exports, __webpack_require__) {
  30729. "use strict";
  30730. var runtime_1 = __webpack_require__(2);
  30731. var hooks = {
  30732. getRequest: function (socket) {
  30733. var Constructor = runtime_1["default"].getXHRAPI();
  30734. var xhr = new Constructor();
  30735. xhr.onreadystatechange = xhr.onprogress = function () {
  30736. switch (xhr.readyState) {
  30737. case 3:
  30738. if (xhr.responseText && xhr.responseText.length > 0) {
  30739. socket.onChunk(xhr.status, xhr.responseText);
  30740. }
  30741. break;
  30742. case 4:
  30743. if (xhr.responseText && xhr.responseText.length > 0) {
  30744. socket.onChunk(xhr.status, xhr.responseText);
  30745. }
  30746. socket.emit("finished", xhr.status);
  30747. socket.close();
  30748. break;
  30749. }
  30750. };
  30751. return xhr;
  30752. },
  30753. abortRequest: function (xhr) {
  30754. xhr.onreadystatechange = null;
  30755. xhr.abort();
  30756. }
  30757. };
  30758. exports.__esModule = true;
  30759. exports["default"] = hooks;
  30760. /***/ }),
  30761. /* 38 */
  30762. /***/ (function(module, exports, __webpack_require__) {
  30763. "use strict";
  30764. var Collections = __webpack_require__(9);
  30765. var util_1 = __webpack_require__(11);
  30766. var level_1 = __webpack_require__(39);
  30767. var Timeline = (function () {
  30768. function Timeline(key, session, options) {
  30769. this.key = key;
  30770. this.session = session;
  30771. this.events = [];
  30772. this.options = options || {};
  30773. this.sent = 0;
  30774. this.uniqueID = 0;
  30775. }
  30776. Timeline.prototype.log = function (level, event) {
  30777. if (level <= this.options.level) {
  30778. this.events.push(Collections.extend({}, event, { timestamp: util_1["default"].now() }));
  30779. if (this.options.limit && this.events.length > this.options.limit) {
  30780. this.events.shift();
  30781. }
  30782. }
  30783. };
  30784. Timeline.prototype.error = function (event) {
  30785. this.log(level_1["default"].ERROR, event);
  30786. };
  30787. Timeline.prototype.info = function (event) {
  30788. this.log(level_1["default"].INFO, event);
  30789. };
  30790. Timeline.prototype.debug = function (event) {
  30791. this.log(level_1["default"].DEBUG, event);
  30792. };
  30793. Timeline.prototype.isEmpty = function () {
  30794. return this.events.length === 0;
  30795. };
  30796. Timeline.prototype.send = function (sendfn, callback) {
  30797. var _this = this;
  30798. var data = Collections.extend({
  30799. session: this.session,
  30800. bundle: this.sent + 1,
  30801. key: this.key,
  30802. lib: "js",
  30803. version: this.options.version,
  30804. cluster: this.options.cluster,
  30805. features: this.options.features,
  30806. timeline: this.events
  30807. }, this.options.params);
  30808. this.events = [];
  30809. sendfn(data, function (error, result) {
  30810. if (!error) {
  30811. _this.sent++;
  30812. }
  30813. if (callback) {
  30814. callback(error, result);
  30815. }
  30816. });
  30817. return true;
  30818. };
  30819. Timeline.prototype.generateUniqueID = function () {
  30820. this.uniqueID++;
  30821. return this.uniqueID;
  30822. };
  30823. return Timeline;
  30824. }());
  30825. exports.__esModule = true;
  30826. exports["default"] = Timeline;
  30827. /***/ }),
  30828. /* 39 */
  30829. /***/ (function(module, exports) {
  30830. "use strict";
  30831. var TimelineLevel;
  30832. (function (TimelineLevel) {
  30833. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  30834. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  30835. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  30836. })(TimelineLevel || (TimelineLevel = {}));
  30837. exports.__esModule = true;
  30838. exports["default"] = TimelineLevel;
  30839. /***/ }),
  30840. /* 40 */
  30841. /***/ (function(module, exports, __webpack_require__) {
  30842. "use strict";
  30843. var Collections = __webpack_require__(9);
  30844. var util_1 = __webpack_require__(11);
  30845. var transport_manager_1 = __webpack_require__(41);
  30846. var Errors = __webpack_require__(30);
  30847. var transport_strategy_1 = __webpack_require__(55);
  30848. var sequential_strategy_1 = __webpack_require__(56);
  30849. var best_connected_ever_strategy_1 = __webpack_require__(57);
  30850. var cached_strategy_1 = __webpack_require__(58);
  30851. var delayed_strategy_1 = __webpack_require__(59);
  30852. var if_strategy_1 = __webpack_require__(60);
  30853. var first_connected_strategy_1 = __webpack_require__(61);
  30854. var runtime_1 = __webpack_require__(2);
  30855. var Transports = runtime_1["default"].Transports;
  30856. exports.build = function (scheme, options) {
  30857. var context = Collections.extend({}, globalContext, options);
  30858. return evaluate(scheme, context)[1].strategy;
  30859. };
  30860. var UnsupportedStrategy = {
  30861. isSupported: function () {
  30862. return false;
  30863. },
  30864. connect: function (_, callback) {
  30865. var deferred = util_1["default"].defer(function () {
  30866. callback(new Errors.UnsupportedStrategy());
  30867. });
  30868. return {
  30869. abort: function () {
  30870. deferred.ensureAborted();
  30871. },
  30872. forceMinPriority: function () { }
  30873. };
  30874. }
  30875. };
  30876. function returnWithOriginalContext(f) {
  30877. return function (context) {
  30878. return [f.apply(this, arguments), context];
  30879. };
  30880. }
  30881. var globalContext = {
  30882. extend: function (context, first, second) {
  30883. return [Collections.extend({}, first, second), context];
  30884. },
  30885. def: function (context, name, value) {
  30886. if (context[name] !== undefined) {
  30887. throw "Redefining symbol " + name;
  30888. }
  30889. context[name] = value;
  30890. return [undefined, context];
  30891. },
  30892. def_transport: function (context, name, type, priority, options, manager) {
  30893. var transportClass = Transports[type];
  30894. if (!transportClass) {
  30895. throw new Errors.UnsupportedTransport(type);
  30896. }
  30897. var enabled = (!context.enabledTransports ||
  30898. Collections.arrayIndexOf(context.enabledTransports, name) !== -1) &&
  30899. (!context.disabledTransports ||
  30900. Collections.arrayIndexOf(context.disabledTransports, name) === -1);
  30901. var transport;
  30902. if (enabled) {
  30903. transport = new transport_strategy_1["default"](name, priority, manager ? manager.getAssistant(transportClass) : transportClass, Collections.extend({
  30904. key: context.key,
  30905. encrypted: context.encrypted,
  30906. timeline: context.timeline,
  30907. ignoreNullOrigin: context.ignoreNullOrigin
  30908. }, options));
  30909. }
  30910. else {
  30911. transport = UnsupportedStrategy;
  30912. }
  30913. var newContext = context.def(context, name, transport)[1];
  30914. newContext.Transports = context.Transports || {};
  30915. newContext.Transports[name] = transport;
  30916. return [undefined, newContext];
  30917. },
  30918. transport_manager: returnWithOriginalContext(function (_, options) {
  30919. return new transport_manager_1["default"](options);
  30920. }),
  30921. sequential: returnWithOriginalContext(function (_, options) {
  30922. var strategies = Array.prototype.slice.call(arguments, 2);
  30923. return new sequential_strategy_1["default"](strategies, options);
  30924. }),
  30925. cached: returnWithOriginalContext(function (context, ttl, strategy) {
  30926. return new cached_strategy_1["default"](strategy, context.Transports, {
  30927. ttl: ttl,
  30928. timeline: context.timeline,
  30929. encrypted: context.encrypted
  30930. });
  30931. }),
  30932. first_connected: returnWithOriginalContext(function (_, strategy) {
  30933. return new first_connected_strategy_1["default"](strategy);
  30934. }),
  30935. best_connected_ever: returnWithOriginalContext(function () {
  30936. var strategies = Array.prototype.slice.call(arguments, 1);
  30937. return new best_connected_ever_strategy_1["default"](strategies);
  30938. }),
  30939. delayed: returnWithOriginalContext(function (_, delay, strategy) {
  30940. return new delayed_strategy_1["default"](strategy, { delay: delay });
  30941. }),
  30942. "if": returnWithOriginalContext(function (_, test, trueBranch, falseBranch) {
  30943. return new if_strategy_1["default"](test, trueBranch, falseBranch);
  30944. }),
  30945. is_supported: returnWithOriginalContext(function (_, strategy) {
  30946. return function () {
  30947. return strategy.isSupported();
  30948. };
  30949. })
  30950. };
  30951. function isSymbol(expression) {
  30952. return (typeof expression === "string") && expression.charAt(0) === ":";
  30953. }
  30954. function getSymbolValue(expression, context) {
  30955. return context[expression.slice(1)];
  30956. }
  30957. function evaluateListOfExpressions(expressions, context) {
  30958. if (expressions.length === 0) {
  30959. return [[], context];
  30960. }
  30961. var head = evaluate(expressions[0], context);
  30962. var tail = evaluateListOfExpressions(expressions.slice(1), head[1]);
  30963. return [[head[0]].concat(tail[0]), tail[1]];
  30964. }
  30965. function evaluateString(expression, context) {
  30966. if (!isSymbol(expression)) {
  30967. return [expression, context];
  30968. }
  30969. var value = getSymbolValue(expression, context);
  30970. if (value === undefined) {
  30971. throw "Undefined symbol " + expression;
  30972. }
  30973. return [value, context];
  30974. }
  30975. function evaluateArray(expression, context) {
  30976. if (isSymbol(expression[0])) {
  30977. var f = getSymbolValue(expression[0], context);
  30978. if (expression.length > 1) {
  30979. if (typeof f !== "function") {
  30980. throw "Calling non-function " + expression[0];
  30981. }
  30982. var args = [Collections.extend({}, context)].concat(Collections.map(expression.slice(1), function (arg) {
  30983. return evaluate(arg, Collections.extend({}, context))[0];
  30984. }));
  30985. return f.apply(this, args);
  30986. }
  30987. else {
  30988. return [f, context];
  30989. }
  30990. }
  30991. else {
  30992. return evaluateListOfExpressions(expression, context);
  30993. }
  30994. }
  30995. function evaluate(expression, context) {
  30996. if (typeof expression === "string") {
  30997. return evaluateString(expression, context);
  30998. }
  30999. else if (typeof expression === "object") {
  31000. if (expression instanceof Array && expression.length > 0) {
  31001. return evaluateArray(expression, context);
  31002. }
  31003. }
  31004. return [expression, context];
  31005. }
  31006. /***/ }),
  31007. /* 41 */
  31008. /***/ (function(module, exports, __webpack_require__) {
  31009. "use strict";
  31010. var factory_1 = __webpack_require__(42);
  31011. var TransportManager = (function () {
  31012. function TransportManager(options) {
  31013. this.options = options || {};
  31014. this.livesLeft = this.options.lives || Infinity;
  31015. }
  31016. TransportManager.prototype.getAssistant = function (transport) {
  31017. return factory_1["default"].createAssistantToTheTransportManager(this, transport, {
  31018. minPingDelay: this.options.minPingDelay,
  31019. maxPingDelay: this.options.maxPingDelay
  31020. });
  31021. };
  31022. TransportManager.prototype.isAlive = function () {
  31023. return this.livesLeft > 0;
  31024. };
  31025. TransportManager.prototype.reportDeath = function () {
  31026. this.livesLeft -= 1;
  31027. };
  31028. return TransportManager;
  31029. }());
  31030. exports.__esModule = true;
  31031. exports["default"] = TransportManager;
  31032. /***/ }),
  31033. /* 42 */
  31034. /***/ (function(module, exports, __webpack_require__) {
  31035. "use strict";
  31036. var assistant_to_the_transport_manager_1 = __webpack_require__(43);
  31037. var handshake_1 = __webpack_require__(44);
  31038. var pusher_authorizer_1 = __webpack_require__(47);
  31039. var timeline_sender_1 = __webpack_require__(48);
  31040. var presence_channel_1 = __webpack_require__(49);
  31041. var private_channel_1 = __webpack_require__(50);
  31042. var channel_1 = __webpack_require__(51);
  31043. var connection_manager_1 = __webpack_require__(53);
  31044. var channels_1 = __webpack_require__(54);
  31045. var Factory = {
  31046. createChannels: function () {
  31047. return new channels_1["default"]();
  31048. },
  31049. createConnectionManager: function (key, options) {
  31050. return new connection_manager_1["default"](key, options);
  31051. },
  31052. createChannel: function (name, pusher) {
  31053. return new channel_1["default"](name, pusher);
  31054. },
  31055. createPrivateChannel: function (name, pusher) {
  31056. return new private_channel_1["default"](name, pusher);
  31057. },
  31058. createPresenceChannel: function (name, pusher) {
  31059. return new presence_channel_1["default"](name, pusher);
  31060. },
  31061. createTimelineSender: function (timeline, options) {
  31062. return new timeline_sender_1["default"](timeline, options);
  31063. },
  31064. createAuthorizer: function (channel, options) {
  31065. if (options.authorizer) {
  31066. return options.authorizer(channel, options);
  31067. }
  31068. return new pusher_authorizer_1["default"](channel, options);
  31069. },
  31070. createHandshake: function (transport, callback) {
  31071. return new handshake_1["default"](transport, callback);
  31072. },
  31073. createAssistantToTheTransportManager: function (manager, transport, options) {
  31074. return new assistant_to_the_transport_manager_1["default"](manager, transport, options);
  31075. }
  31076. };
  31077. exports.__esModule = true;
  31078. exports["default"] = Factory;
  31079. /***/ }),
  31080. /* 43 */
  31081. /***/ (function(module, exports, __webpack_require__) {
  31082. "use strict";
  31083. var util_1 = __webpack_require__(11);
  31084. var Collections = __webpack_require__(9);
  31085. var AssistantToTheTransportManager = (function () {
  31086. function AssistantToTheTransportManager(manager, transport, options) {
  31087. this.manager = manager;
  31088. this.transport = transport;
  31089. this.minPingDelay = options.minPingDelay;
  31090. this.maxPingDelay = options.maxPingDelay;
  31091. this.pingDelay = undefined;
  31092. }
  31093. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  31094. var _this = this;
  31095. options = Collections.extend({}, options, {
  31096. activityTimeout: this.pingDelay
  31097. });
  31098. var connection = this.transport.createConnection(name, priority, key, options);
  31099. var openTimestamp = null;
  31100. var onOpen = function () {
  31101. connection.unbind("open", onOpen);
  31102. connection.bind("closed", onClosed);
  31103. openTimestamp = util_1["default"].now();
  31104. };
  31105. var onClosed = function (closeEvent) {
  31106. connection.unbind("closed", onClosed);
  31107. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  31108. _this.manager.reportDeath();
  31109. }
  31110. else if (!closeEvent.wasClean && openTimestamp) {
  31111. var lifespan = util_1["default"].now() - openTimestamp;
  31112. if (lifespan < 2 * _this.maxPingDelay) {
  31113. _this.manager.reportDeath();
  31114. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  31115. }
  31116. }
  31117. };
  31118. connection.bind("open", onOpen);
  31119. return connection;
  31120. };
  31121. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  31122. return this.manager.isAlive() && this.transport.isSupported(environment);
  31123. };
  31124. return AssistantToTheTransportManager;
  31125. }());
  31126. exports.__esModule = true;
  31127. exports["default"] = AssistantToTheTransportManager;
  31128. /***/ }),
  31129. /* 44 */
  31130. /***/ (function(module, exports, __webpack_require__) {
  31131. "use strict";
  31132. var Collections = __webpack_require__(9);
  31133. var Protocol = __webpack_require__(45);
  31134. var connection_1 = __webpack_require__(46);
  31135. var Handshake = (function () {
  31136. function Handshake(transport, callback) {
  31137. this.transport = transport;
  31138. this.callback = callback;
  31139. this.bindListeners();
  31140. }
  31141. Handshake.prototype.close = function () {
  31142. this.unbindListeners();
  31143. this.transport.close();
  31144. };
  31145. Handshake.prototype.bindListeners = function () {
  31146. var _this = this;
  31147. this.onMessage = function (m) {
  31148. _this.unbindListeners();
  31149. var result;
  31150. try {
  31151. result = Protocol.processHandshake(m);
  31152. }
  31153. catch (e) {
  31154. _this.finish("error", { error: e });
  31155. _this.transport.close();
  31156. return;
  31157. }
  31158. if (result.action === "connected") {
  31159. _this.finish("connected", {
  31160. connection: new connection_1["default"](result.id, _this.transport),
  31161. activityTimeout: result.activityTimeout
  31162. });
  31163. }
  31164. else {
  31165. _this.finish(result.action, { error: result.error });
  31166. _this.transport.close();
  31167. }
  31168. };
  31169. this.onClosed = function (closeEvent) {
  31170. _this.unbindListeners();
  31171. var action = Protocol.getCloseAction(closeEvent) || "backoff";
  31172. var error = Protocol.getCloseError(closeEvent);
  31173. _this.finish(action, { error: error });
  31174. };
  31175. this.transport.bind("message", this.onMessage);
  31176. this.transport.bind("closed", this.onClosed);
  31177. };
  31178. Handshake.prototype.unbindListeners = function () {
  31179. this.transport.unbind("message", this.onMessage);
  31180. this.transport.unbind("closed", this.onClosed);
  31181. };
  31182. Handshake.prototype.finish = function (action, params) {
  31183. this.callback(Collections.extend({ transport: this.transport, action: action }, params));
  31184. };
  31185. return Handshake;
  31186. }());
  31187. exports.__esModule = true;
  31188. exports["default"] = Handshake;
  31189. /***/ }),
  31190. /* 45 */
  31191. /***/ (function(module, exports) {
  31192. "use strict";
  31193. exports.decodeMessage = function (message) {
  31194. try {
  31195. var params = JSON.parse(message.data);
  31196. if (typeof params.data === 'string') {
  31197. try {
  31198. params.data = JSON.parse(params.data);
  31199. }
  31200. catch (e) {
  31201. if (!(e instanceof SyntaxError)) {
  31202. throw e;
  31203. }
  31204. }
  31205. }
  31206. return params;
  31207. }
  31208. catch (e) {
  31209. throw { type: 'MessageParseError', error: e, data: message.data };
  31210. }
  31211. };
  31212. exports.encodeMessage = function (message) {
  31213. return JSON.stringify(message);
  31214. };
  31215. exports.processHandshake = function (message) {
  31216. message = exports.decodeMessage(message);
  31217. if (message.event === "pusher:connection_established") {
  31218. if (!message.data.activity_timeout) {
  31219. throw "No activity timeout specified in handshake";
  31220. }
  31221. return {
  31222. action: "connected",
  31223. id: message.data.socket_id,
  31224. activityTimeout: message.data.activity_timeout * 1000
  31225. };
  31226. }
  31227. else if (message.event === "pusher:error") {
  31228. return {
  31229. action: this.getCloseAction(message.data),
  31230. error: this.getCloseError(message.data)
  31231. };
  31232. }
  31233. else {
  31234. throw "Invalid handshake";
  31235. }
  31236. };
  31237. exports.getCloseAction = function (closeEvent) {
  31238. if (closeEvent.code < 4000) {
  31239. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  31240. return "backoff";
  31241. }
  31242. else {
  31243. return null;
  31244. }
  31245. }
  31246. else if (closeEvent.code === 4000) {
  31247. return "ssl_only";
  31248. }
  31249. else if (closeEvent.code < 4100) {
  31250. return "refused";
  31251. }
  31252. else if (closeEvent.code < 4200) {
  31253. return "backoff";
  31254. }
  31255. else if (closeEvent.code < 4300) {
  31256. return "retry";
  31257. }
  31258. else {
  31259. return "refused";
  31260. }
  31261. };
  31262. exports.getCloseError = function (closeEvent) {
  31263. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  31264. return {
  31265. type: 'PusherError',
  31266. data: {
  31267. code: closeEvent.code,
  31268. message: closeEvent.reason || closeEvent.message
  31269. }
  31270. };
  31271. }
  31272. else {
  31273. return null;
  31274. }
  31275. };
  31276. /***/ }),
  31277. /* 46 */
  31278. /***/ (function(module, exports, __webpack_require__) {
  31279. "use strict";
  31280. var __extends = (this && this.__extends) || function (d, b) {
  31281. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31282. function __() { this.constructor = d; }
  31283. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31284. };
  31285. var Collections = __webpack_require__(9);
  31286. var dispatcher_1 = __webpack_require__(23);
  31287. var Protocol = __webpack_require__(45);
  31288. var logger_1 = __webpack_require__(8);
  31289. var Connection = (function (_super) {
  31290. __extends(Connection, _super);
  31291. function Connection(id, transport) {
  31292. _super.call(this);
  31293. this.id = id;
  31294. this.transport = transport;
  31295. this.activityTimeout = transport.activityTimeout;
  31296. this.bindListeners();
  31297. }
  31298. Connection.prototype.handlesActivityChecks = function () {
  31299. return this.transport.handlesActivityChecks();
  31300. };
  31301. Connection.prototype.send = function (data) {
  31302. return this.transport.send(data);
  31303. };
  31304. Connection.prototype.send_event = function (name, data, channel) {
  31305. var message = { event: name, data: data };
  31306. if (channel) {
  31307. message.channel = channel;
  31308. }
  31309. logger_1["default"].debug('Event sent', message);
  31310. return this.send(Protocol.encodeMessage(message));
  31311. };
  31312. Connection.prototype.ping = function () {
  31313. if (this.transport.supportsPing()) {
  31314. this.transport.ping();
  31315. }
  31316. else {
  31317. this.send_event('pusher:ping', {});
  31318. }
  31319. };
  31320. Connection.prototype.close = function () {
  31321. this.transport.close();
  31322. };
  31323. Connection.prototype.bindListeners = function () {
  31324. var _this = this;
  31325. var listeners = {
  31326. message: function (m) {
  31327. var message;
  31328. try {
  31329. message = Protocol.decodeMessage(m);
  31330. }
  31331. catch (e) {
  31332. _this.emit('error', {
  31333. type: 'MessageParseError',
  31334. error: e,
  31335. data: m.data
  31336. });
  31337. }
  31338. if (message !== undefined) {
  31339. logger_1["default"].debug('Event recd', message);
  31340. switch (message.event) {
  31341. case 'pusher:error':
  31342. _this.emit('error', { type: 'PusherError', data: message.data });
  31343. break;
  31344. case 'pusher:ping':
  31345. _this.emit("ping");
  31346. break;
  31347. case 'pusher:pong':
  31348. _this.emit("pong");
  31349. break;
  31350. }
  31351. _this.emit('message', message);
  31352. }
  31353. },
  31354. activity: function () {
  31355. _this.emit("activity");
  31356. },
  31357. error: function (error) {
  31358. _this.emit("error", { type: "WebSocketError", error: error });
  31359. },
  31360. closed: function (closeEvent) {
  31361. unbindListeners();
  31362. if (closeEvent && closeEvent.code) {
  31363. _this.handleCloseEvent(closeEvent);
  31364. }
  31365. _this.transport = null;
  31366. _this.emit("closed");
  31367. }
  31368. };
  31369. var unbindListeners = function () {
  31370. Collections.objectApply(listeners, function (listener, event) {
  31371. _this.transport.unbind(event, listener);
  31372. });
  31373. };
  31374. Collections.objectApply(listeners, function (listener, event) {
  31375. _this.transport.bind(event, listener);
  31376. });
  31377. };
  31378. Connection.prototype.handleCloseEvent = function (closeEvent) {
  31379. var action = Protocol.getCloseAction(closeEvent);
  31380. var error = Protocol.getCloseError(closeEvent);
  31381. if (error) {
  31382. this.emit('error', error);
  31383. }
  31384. if (action) {
  31385. this.emit(action);
  31386. }
  31387. };
  31388. return Connection;
  31389. }(dispatcher_1["default"]));
  31390. exports.__esModule = true;
  31391. exports["default"] = Connection;
  31392. /***/ }),
  31393. /* 47 */
  31394. /***/ (function(module, exports, __webpack_require__) {
  31395. "use strict";
  31396. var runtime_1 = __webpack_require__(2);
  31397. var PusherAuthorizer = (function () {
  31398. function PusherAuthorizer(channel, options) {
  31399. this.channel = channel;
  31400. var authTransport = options.authTransport;
  31401. if (typeof runtime_1["default"].getAuthorizers()[authTransport] === "undefined") {
  31402. throw "'" + authTransport + "' is not a recognized auth transport";
  31403. }
  31404. this.type = authTransport;
  31405. this.options = options;
  31406. this.authOptions = (options || {}).auth || {};
  31407. }
  31408. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  31409. var query = 'socket_id=' + encodeURIComponent(socketId) +
  31410. '&channel_name=' + encodeURIComponent(this.channel.name);
  31411. for (var i in this.authOptions.params) {
  31412. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  31413. }
  31414. return query;
  31415. };
  31416. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  31417. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime_1["default"].getAuthorizers();
  31418. return PusherAuthorizer.authorizers[this.type].call(this, runtime_1["default"], socketId, callback);
  31419. };
  31420. return PusherAuthorizer;
  31421. }());
  31422. exports.__esModule = true;
  31423. exports["default"] = PusherAuthorizer;
  31424. /***/ }),
  31425. /* 48 */
  31426. /***/ (function(module, exports, __webpack_require__) {
  31427. "use strict";
  31428. var runtime_1 = __webpack_require__(2);
  31429. var TimelineSender = (function () {
  31430. function TimelineSender(timeline, options) {
  31431. this.timeline = timeline;
  31432. this.options = options || {};
  31433. }
  31434. TimelineSender.prototype.send = function (encrypted, callback) {
  31435. if (this.timeline.isEmpty()) {
  31436. return;
  31437. }
  31438. this.timeline.send(runtime_1["default"].TimelineTransport.getAgent(this, encrypted), callback);
  31439. };
  31440. return TimelineSender;
  31441. }());
  31442. exports.__esModule = true;
  31443. exports["default"] = TimelineSender;
  31444. /***/ }),
  31445. /* 49 */
  31446. /***/ (function(module, exports, __webpack_require__) {
  31447. "use strict";
  31448. var __extends = (this && this.__extends) || function (d, b) {
  31449. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31450. function __() { this.constructor = d; }
  31451. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31452. };
  31453. var private_channel_1 = __webpack_require__(50);
  31454. var logger_1 = __webpack_require__(8);
  31455. var members_1 = __webpack_require__(52);
  31456. var PresenceChannel = (function (_super) {
  31457. __extends(PresenceChannel, _super);
  31458. function PresenceChannel(name, pusher) {
  31459. _super.call(this, name, pusher);
  31460. this.members = new members_1["default"]();
  31461. }
  31462. PresenceChannel.prototype.authorize = function (socketId, callback) {
  31463. var _this = this;
  31464. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  31465. if (!error) {
  31466. if (authData.channel_data === undefined) {
  31467. logger_1["default"].warn("Invalid auth response for channel '" +
  31468. _this.name +
  31469. "', expected 'channel_data' field");
  31470. callback("Invalid auth response");
  31471. return;
  31472. }
  31473. var channelData = JSON.parse(authData.channel_data);
  31474. _this.members.setMyID(channelData.user_id);
  31475. }
  31476. callback(error, authData);
  31477. });
  31478. };
  31479. PresenceChannel.prototype.handleEvent = function (event, data) {
  31480. switch (event) {
  31481. case "pusher_internal:subscription_succeeded":
  31482. this.subscriptionPending = false;
  31483. this.subscribed = true;
  31484. if (this.subscriptionCancelled) {
  31485. this.pusher.unsubscribe(this.name);
  31486. }
  31487. else {
  31488. this.members.onSubscription(data);
  31489. this.emit("pusher:subscription_succeeded", this.members);
  31490. }
  31491. break;
  31492. case "pusher_internal:member_added":
  31493. var addedMember = this.members.addMember(data);
  31494. this.emit('pusher:member_added', addedMember);
  31495. break;
  31496. case "pusher_internal:member_removed":
  31497. var removedMember = this.members.removeMember(data);
  31498. if (removedMember) {
  31499. this.emit('pusher:member_removed', removedMember);
  31500. }
  31501. break;
  31502. default:
  31503. private_channel_1["default"].prototype.handleEvent.call(this, event, data);
  31504. }
  31505. };
  31506. PresenceChannel.prototype.disconnect = function () {
  31507. this.members.reset();
  31508. _super.prototype.disconnect.call(this);
  31509. };
  31510. return PresenceChannel;
  31511. }(private_channel_1["default"]));
  31512. exports.__esModule = true;
  31513. exports["default"] = PresenceChannel;
  31514. /***/ }),
  31515. /* 50 */
  31516. /***/ (function(module, exports, __webpack_require__) {
  31517. "use strict";
  31518. var __extends = (this && this.__extends) || function (d, b) {
  31519. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31520. function __() { this.constructor = d; }
  31521. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31522. };
  31523. var factory_1 = __webpack_require__(42);
  31524. var channel_1 = __webpack_require__(51);
  31525. var PrivateChannel = (function (_super) {
  31526. __extends(PrivateChannel, _super);
  31527. function PrivateChannel() {
  31528. _super.apply(this, arguments);
  31529. }
  31530. PrivateChannel.prototype.authorize = function (socketId, callback) {
  31531. var authorizer = factory_1["default"].createAuthorizer(this, this.pusher.config);
  31532. return authorizer.authorize(socketId, callback);
  31533. };
  31534. return PrivateChannel;
  31535. }(channel_1["default"]));
  31536. exports.__esModule = true;
  31537. exports["default"] = PrivateChannel;
  31538. /***/ }),
  31539. /* 51 */
  31540. /***/ (function(module, exports, __webpack_require__) {
  31541. "use strict";
  31542. var __extends = (this && this.__extends) || function (d, b) {
  31543. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31544. function __() { this.constructor = d; }
  31545. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31546. };
  31547. var dispatcher_1 = __webpack_require__(23);
  31548. var Errors = __webpack_require__(30);
  31549. var logger_1 = __webpack_require__(8);
  31550. var Channel = (function (_super) {
  31551. __extends(Channel, _super);
  31552. function Channel(name, pusher) {
  31553. _super.call(this, function (event, data) {
  31554. logger_1["default"].debug('No callbacks on ' + name + ' for ' + event);
  31555. });
  31556. this.name = name;
  31557. this.pusher = pusher;
  31558. this.subscribed = false;
  31559. this.subscriptionPending = false;
  31560. this.subscriptionCancelled = false;
  31561. }
  31562. Channel.prototype.authorize = function (socketId, callback) {
  31563. return callback(false, {});
  31564. };
  31565. Channel.prototype.trigger = function (event, data) {
  31566. if (event.indexOf("client-") !== 0) {
  31567. throw new Errors.BadEventName("Event '" + event + "' does not start with 'client-'");
  31568. }
  31569. return this.pusher.send_event(event, data, this.name);
  31570. };
  31571. Channel.prototype.disconnect = function () {
  31572. this.subscribed = false;
  31573. };
  31574. Channel.prototype.handleEvent = function (event, data) {
  31575. if (event.indexOf("pusher_internal:") === 0) {
  31576. if (event === "pusher_internal:subscription_succeeded") {
  31577. this.subscriptionPending = false;
  31578. this.subscribed = true;
  31579. if (this.subscriptionCancelled) {
  31580. this.pusher.unsubscribe(this.name);
  31581. }
  31582. else {
  31583. this.emit("pusher:subscription_succeeded", data);
  31584. }
  31585. }
  31586. }
  31587. else {
  31588. this.emit(event, data);
  31589. }
  31590. };
  31591. Channel.prototype.subscribe = function () {
  31592. var _this = this;
  31593. if (this.subscribed) {
  31594. return;
  31595. }
  31596. this.subscriptionPending = true;
  31597. this.subscriptionCancelled = false;
  31598. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  31599. if (error) {
  31600. _this.handleEvent('pusher:subscription_error', data);
  31601. }
  31602. else {
  31603. _this.pusher.send_event('pusher:subscribe', {
  31604. auth: data.auth,
  31605. channel_data: data.channel_data,
  31606. channel: _this.name
  31607. });
  31608. }
  31609. });
  31610. };
  31611. Channel.prototype.unsubscribe = function () {
  31612. this.subscribed = false;
  31613. this.pusher.send_event('pusher:unsubscribe', {
  31614. channel: this.name
  31615. });
  31616. };
  31617. Channel.prototype.cancelSubscription = function () {
  31618. this.subscriptionCancelled = true;
  31619. };
  31620. Channel.prototype.reinstateSubscription = function () {
  31621. this.subscriptionCancelled = false;
  31622. };
  31623. return Channel;
  31624. }(dispatcher_1["default"]));
  31625. exports.__esModule = true;
  31626. exports["default"] = Channel;
  31627. /***/ }),
  31628. /* 52 */
  31629. /***/ (function(module, exports, __webpack_require__) {
  31630. "use strict";
  31631. var Collections = __webpack_require__(9);
  31632. var Members = (function () {
  31633. function Members() {
  31634. this.reset();
  31635. }
  31636. Members.prototype.get = function (id) {
  31637. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  31638. return {
  31639. id: id,
  31640. info: this.members[id]
  31641. };
  31642. }
  31643. else {
  31644. return null;
  31645. }
  31646. };
  31647. Members.prototype.each = function (callback) {
  31648. var _this = this;
  31649. Collections.objectApply(this.members, function (member, id) {
  31650. callback(_this.get(id));
  31651. });
  31652. };
  31653. Members.prototype.setMyID = function (id) {
  31654. this.myID = id;
  31655. };
  31656. Members.prototype.onSubscription = function (subscriptionData) {
  31657. this.members = subscriptionData.presence.hash;
  31658. this.count = subscriptionData.presence.count;
  31659. this.me = this.get(this.myID);
  31660. };
  31661. Members.prototype.addMember = function (memberData) {
  31662. if (this.get(memberData.user_id) === null) {
  31663. this.count++;
  31664. }
  31665. this.members[memberData.user_id] = memberData.user_info;
  31666. return this.get(memberData.user_id);
  31667. };
  31668. Members.prototype.removeMember = function (memberData) {
  31669. var member = this.get(memberData.user_id);
  31670. if (member) {
  31671. delete this.members[memberData.user_id];
  31672. this.count--;
  31673. }
  31674. return member;
  31675. };
  31676. Members.prototype.reset = function () {
  31677. this.members = {};
  31678. this.count = 0;
  31679. this.myID = null;
  31680. this.me = null;
  31681. };
  31682. return Members;
  31683. }());
  31684. exports.__esModule = true;
  31685. exports["default"] = Members;
  31686. /***/ }),
  31687. /* 53 */
  31688. /***/ (function(module, exports, __webpack_require__) {
  31689. "use strict";
  31690. var __extends = (this && this.__extends) || function (d, b) {
  31691. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31692. function __() { this.constructor = d; }
  31693. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31694. };
  31695. var dispatcher_1 = __webpack_require__(23);
  31696. var timers_1 = __webpack_require__(12);
  31697. var logger_1 = __webpack_require__(8);
  31698. var Collections = __webpack_require__(9);
  31699. var runtime_1 = __webpack_require__(2);
  31700. var ConnectionManager = (function (_super) {
  31701. __extends(ConnectionManager, _super);
  31702. function ConnectionManager(key, options) {
  31703. var _this = this;
  31704. _super.call(this);
  31705. this.key = key;
  31706. this.options = options || {};
  31707. this.state = "initialized";
  31708. this.connection = null;
  31709. this.encrypted = !!options.encrypted;
  31710. this.timeline = this.options.timeline;
  31711. this.connectionCallbacks = this.buildConnectionCallbacks();
  31712. this.errorCallbacks = this.buildErrorCallbacks();
  31713. this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
  31714. var Network = runtime_1["default"].getNetwork();
  31715. Network.bind("online", function () {
  31716. _this.timeline.info({ netinfo: "online" });
  31717. if (_this.state === "connecting" || _this.state === "unavailable") {
  31718. _this.retryIn(0);
  31719. }
  31720. });
  31721. Network.bind("offline", function () {
  31722. _this.timeline.info({ netinfo: "offline" });
  31723. if (_this.connection) {
  31724. _this.sendActivityCheck();
  31725. }
  31726. });
  31727. this.updateStrategy();
  31728. }
  31729. ConnectionManager.prototype.connect = function () {
  31730. if (this.connection || this.runner) {
  31731. return;
  31732. }
  31733. if (!this.strategy.isSupported()) {
  31734. this.updateState("failed");
  31735. return;
  31736. }
  31737. this.updateState("connecting");
  31738. this.startConnecting();
  31739. this.setUnavailableTimer();
  31740. };
  31741. ;
  31742. ConnectionManager.prototype.send = function (data) {
  31743. if (this.connection) {
  31744. return this.connection.send(data);
  31745. }
  31746. else {
  31747. return false;
  31748. }
  31749. };
  31750. ;
  31751. ConnectionManager.prototype.send_event = function (name, data, channel) {
  31752. if (this.connection) {
  31753. return this.connection.send_event(name, data, channel);
  31754. }
  31755. else {
  31756. return false;
  31757. }
  31758. };
  31759. ;
  31760. ConnectionManager.prototype.disconnect = function () {
  31761. this.disconnectInternally();
  31762. this.updateState("disconnected");
  31763. };
  31764. ;
  31765. ConnectionManager.prototype.isEncrypted = function () {
  31766. return this.encrypted;
  31767. };
  31768. ;
  31769. ConnectionManager.prototype.startConnecting = function () {
  31770. var _this = this;
  31771. var callback = function (error, handshake) {
  31772. if (error) {
  31773. _this.runner = _this.strategy.connect(0, callback);
  31774. }
  31775. else {
  31776. if (handshake.action === "error") {
  31777. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  31778. _this.timeline.error({ handshakeError: handshake.error });
  31779. }
  31780. else {
  31781. _this.abortConnecting();
  31782. _this.handshakeCallbacks[handshake.action](handshake);
  31783. }
  31784. }
  31785. };
  31786. this.runner = this.strategy.connect(0, callback);
  31787. };
  31788. ;
  31789. ConnectionManager.prototype.abortConnecting = function () {
  31790. if (this.runner) {
  31791. this.runner.abort();
  31792. this.runner = null;
  31793. }
  31794. };
  31795. ;
  31796. ConnectionManager.prototype.disconnectInternally = function () {
  31797. this.abortConnecting();
  31798. this.clearRetryTimer();
  31799. this.clearUnavailableTimer();
  31800. if (this.connection) {
  31801. var connection = this.abandonConnection();
  31802. connection.close();
  31803. }
  31804. };
  31805. ;
  31806. ConnectionManager.prototype.updateStrategy = function () {
  31807. this.strategy = this.options.getStrategy({
  31808. key: this.key,
  31809. timeline: this.timeline,
  31810. encrypted: this.encrypted
  31811. });
  31812. };
  31813. ;
  31814. ConnectionManager.prototype.retryIn = function (delay) {
  31815. var _this = this;
  31816. this.timeline.info({ action: "retry", delay: delay });
  31817. if (delay > 0) {
  31818. this.emit("connecting_in", Math.round(delay / 1000));
  31819. }
  31820. this.retryTimer = new timers_1.OneOffTimer(delay || 0, function () {
  31821. _this.disconnectInternally();
  31822. _this.connect();
  31823. });
  31824. };
  31825. ;
  31826. ConnectionManager.prototype.clearRetryTimer = function () {
  31827. if (this.retryTimer) {
  31828. this.retryTimer.ensureAborted();
  31829. this.retryTimer = null;
  31830. }
  31831. };
  31832. ;
  31833. ConnectionManager.prototype.setUnavailableTimer = function () {
  31834. var _this = this;
  31835. this.unavailableTimer = new timers_1.OneOffTimer(this.options.unavailableTimeout, function () {
  31836. _this.updateState("unavailable");
  31837. });
  31838. };
  31839. ;
  31840. ConnectionManager.prototype.clearUnavailableTimer = function () {
  31841. if (this.unavailableTimer) {
  31842. this.unavailableTimer.ensureAborted();
  31843. }
  31844. };
  31845. ;
  31846. ConnectionManager.prototype.sendActivityCheck = function () {
  31847. var _this = this;
  31848. this.stopActivityCheck();
  31849. this.connection.ping();
  31850. this.activityTimer = new timers_1.OneOffTimer(this.options.pongTimeout, function () {
  31851. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  31852. _this.retryIn(0);
  31853. });
  31854. };
  31855. ;
  31856. ConnectionManager.prototype.resetActivityCheck = function () {
  31857. var _this = this;
  31858. this.stopActivityCheck();
  31859. if (!this.connection.handlesActivityChecks()) {
  31860. this.activityTimer = new timers_1.OneOffTimer(this.activityTimeout, function () {
  31861. _this.sendActivityCheck();
  31862. });
  31863. }
  31864. };
  31865. ;
  31866. ConnectionManager.prototype.stopActivityCheck = function () {
  31867. if (this.activityTimer) {
  31868. this.activityTimer.ensureAborted();
  31869. }
  31870. };
  31871. ;
  31872. ConnectionManager.prototype.buildConnectionCallbacks = function () {
  31873. var _this = this;
  31874. return {
  31875. message: function (message) {
  31876. _this.resetActivityCheck();
  31877. _this.emit('message', message);
  31878. },
  31879. ping: function () {
  31880. _this.send_event('pusher:pong', {});
  31881. },
  31882. activity: function () {
  31883. _this.resetActivityCheck();
  31884. },
  31885. error: function (error) {
  31886. _this.emit("error", { type: "WebSocketError", error: error });
  31887. },
  31888. closed: function () {
  31889. _this.abandonConnection();
  31890. if (_this.shouldRetry()) {
  31891. _this.retryIn(1000);
  31892. }
  31893. }
  31894. };
  31895. };
  31896. ;
  31897. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  31898. var _this = this;
  31899. return Collections.extend({}, errorCallbacks, {
  31900. connected: function (handshake) {
  31901. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  31902. _this.clearUnavailableTimer();
  31903. _this.setConnection(handshake.connection);
  31904. _this.socket_id = _this.connection.id;
  31905. _this.updateState("connected", { socket_id: _this.socket_id });
  31906. }
  31907. });
  31908. };
  31909. ;
  31910. ConnectionManager.prototype.buildErrorCallbacks = function () {
  31911. var _this = this;
  31912. var withErrorEmitted = function (callback) {
  31913. return function (result) {
  31914. if (result.error) {
  31915. _this.emit("error", { type: "WebSocketError", error: result.error });
  31916. }
  31917. callback(result);
  31918. };
  31919. };
  31920. return {
  31921. ssl_only: withErrorEmitted(function () {
  31922. _this.encrypted = true;
  31923. _this.updateStrategy();
  31924. _this.retryIn(0);
  31925. }),
  31926. refused: withErrorEmitted(function () {
  31927. _this.disconnect();
  31928. }),
  31929. backoff: withErrorEmitted(function () {
  31930. _this.retryIn(1000);
  31931. }),
  31932. retry: withErrorEmitted(function () {
  31933. _this.retryIn(0);
  31934. })
  31935. };
  31936. };
  31937. ;
  31938. ConnectionManager.prototype.setConnection = function (connection) {
  31939. this.connection = connection;
  31940. for (var event in this.connectionCallbacks) {
  31941. this.connection.bind(event, this.connectionCallbacks[event]);
  31942. }
  31943. this.resetActivityCheck();
  31944. };
  31945. ;
  31946. ConnectionManager.prototype.abandonConnection = function () {
  31947. if (!this.connection) {
  31948. return;
  31949. }
  31950. this.stopActivityCheck();
  31951. for (var event in this.connectionCallbacks) {
  31952. this.connection.unbind(event, this.connectionCallbacks[event]);
  31953. }
  31954. var connection = this.connection;
  31955. this.connection = null;
  31956. return connection;
  31957. };
  31958. ConnectionManager.prototype.updateState = function (newState, data) {
  31959. var previousState = this.state;
  31960. this.state = newState;
  31961. if (previousState !== newState) {
  31962. var newStateDescription = newState;
  31963. if (newStateDescription === "connected") {
  31964. newStateDescription += " with new socket ID " + data.socket_id;
  31965. }
  31966. logger_1["default"].debug('State changed', previousState + ' -> ' + newStateDescription);
  31967. this.timeline.info({ state: newState, params: data });
  31968. this.emit('state_change', { previous: previousState, current: newState });
  31969. this.emit(newState, data);
  31970. }
  31971. };
  31972. ConnectionManager.prototype.shouldRetry = function () {
  31973. return this.state === "connecting" || this.state === "connected";
  31974. };
  31975. return ConnectionManager;
  31976. }(dispatcher_1["default"]));
  31977. exports.__esModule = true;
  31978. exports["default"] = ConnectionManager;
  31979. /***/ }),
  31980. /* 54 */
  31981. /***/ (function(module, exports, __webpack_require__) {
  31982. "use strict";
  31983. var Collections = __webpack_require__(9);
  31984. var factory_1 = __webpack_require__(42);
  31985. var Channels = (function () {
  31986. function Channels() {
  31987. this.channels = {};
  31988. }
  31989. Channels.prototype.add = function (name, pusher) {
  31990. if (!this.channels[name]) {
  31991. this.channels[name] = createChannel(name, pusher);
  31992. }
  31993. return this.channels[name];
  31994. };
  31995. Channels.prototype.all = function () {
  31996. return Collections.values(this.channels);
  31997. };
  31998. Channels.prototype.find = function (name) {
  31999. return this.channels[name];
  32000. };
  32001. Channels.prototype.remove = function (name) {
  32002. var channel = this.channels[name];
  32003. delete this.channels[name];
  32004. return channel;
  32005. };
  32006. Channels.prototype.disconnect = function () {
  32007. Collections.objectApply(this.channels, function (channel) {
  32008. channel.disconnect();
  32009. });
  32010. };
  32011. return Channels;
  32012. }());
  32013. exports.__esModule = true;
  32014. exports["default"] = Channels;
  32015. function createChannel(name, pusher) {
  32016. if (name.indexOf('private-') === 0) {
  32017. return factory_1["default"].createPrivateChannel(name, pusher);
  32018. }
  32019. else if (name.indexOf('presence-') === 0) {
  32020. return factory_1["default"].createPresenceChannel(name, pusher);
  32021. }
  32022. else {
  32023. return factory_1["default"].createChannel(name, pusher);
  32024. }
  32025. }
  32026. /***/ }),
  32027. /* 55 */
  32028. /***/ (function(module, exports, __webpack_require__) {
  32029. "use strict";
  32030. var factory_1 = __webpack_require__(42);
  32031. var util_1 = __webpack_require__(11);
  32032. var Errors = __webpack_require__(30);
  32033. var Collections = __webpack_require__(9);
  32034. var TransportStrategy = (function () {
  32035. function TransportStrategy(name, priority, transport, options) {
  32036. this.name = name;
  32037. this.priority = priority;
  32038. this.transport = transport;
  32039. this.options = options || {};
  32040. }
  32041. TransportStrategy.prototype.isSupported = function () {
  32042. return this.transport.isSupported({
  32043. encrypted: this.options.encrypted
  32044. });
  32045. };
  32046. TransportStrategy.prototype.connect = function (minPriority, callback) {
  32047. var _this = this;
  32048. if (!this.isSupported()) {
  32049. return failAttempt(new Errors.UnsupportedStrategy(), callback);
  32050. }
  32051. else if (this.priority < minPriority) {
  32052. return failAttempt(new Errors.TransportPriorityTooLow(), callback);
  32053. }
  32054. var connected = false;
  32055. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  32056. var handshake = null;
  32057. var onInitialized = function () {
  32058. transport.unbind("initialized", onInitialized);
  32059. transport.connect();
  32060. };
  32061. var onOpen = function () {
  32062. handshake = factory_1["default"].createHandshake(transport, function (result) {
  32063. connected = true;
  32064. unbindListeners();
  32065. callback(null, result);
  32066. });
  32067. };
  32068. var onError = function (error) {
  32069. unbindListeners();
  32070. callback(error);
  32071. };
  32072. var onClosed = function () {
  32073. unbindListeners();
  32074. var serializedTransport;
  32075. serializedTransport = Collections.safeJSONStringify(transport);
  32076. callback(new Errors.TransportClosed(serializedTransport));
  32077. };
  32078. var unbindListeners = function () {
  32079. transport.unbind("initialized", onInitialized);
  32080. transport.unbind("open", onOpen);
  32081. transport.unbind("error", onError);
  32082. transport.unbind("closed", onClosed);
  32083. };
  32084. transport.bind("initialized", onInitialized);
  32085. transport.bind("open", onOpen);
  32086. transport.bind("error", onError);
  32087. transport.bind("closed", onClosed);
  32088. transport.initialize();
  32089. return {
  32090. abort: function () {
  32091. if (connected) {
  32092. return;
  32093. }
  32094. unbindListeners();
  32095. if (handshake) {
  32096. handshake.close();
  32097. }
  32098. else {
  32099. transport.close();
  32100. }
  32101. },
  32102. forceMinPriority: function (p) {
  32103. if (connected) {
  32104. return;
  32105. }
  32106. if (_this.priority < p) {
  32107. if (handshake) {
  32108. handshake.close();
  32109. }
  32110. else {
  32111. transport.close();
  32112. }
  32113. }
  32114. }
  32115. };
  32116. };
  32117. return TransportStrategy;
  32118. }());
  32119. exports.__esModule = true;
  32120. exports["default"] = TransportStrategy;
  32121. function failAttempt(error, callback) {
  32122. util_1["default"].defer(function () {
  32123. callback(error);
  32124. });
  32125. return {
  32126. abort: function () { },
  32127. forceMinPriority: function () { }
  32128. };
  32129. }
  32130. /***/ }),
  32131. /* 56 */
  32132. /***/ (function(module, exports, __webpack_require__) {
  32133. "use strict";
  32134. var Collections = __webpack_require__(9);
  32135. var util_1 = __webpack_require__(11);
  32136. var timers_1 = __webpack_require__(12);
  32137. var SequentialStrategy = (function () {
  32138. function SequentialStrategy(strategies, options) {
  32139. this.strategies = strategies;
  32140. this.loop = Boolean(options.loop);
  32141. this.failFast = Boolean(options.failFast);
  32142. this.timeout = options.timeout;
  32143. this.timeoutLimit = options.timeoutLimit;
  32144. }
  32145. SequentialStrategy.prototype.isSupported = function () {
  32146. return Collections.any(this.strategies, util_1["default"].method("isSupported"));
  32147. };
  32148. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  32149. var _this = this;
  32150. var strategies = this.strategies;
  32151. var current = 0;
  32152. var timeout = this.timeout;
  32153. var runner = null;
  32154. var tryNextStrategy = function (error, handshake) {
  32155. if (handshake) {
  32156. callback(null, handshake);
  32157. }
  32158. else {
  32159. current = current + 1;
  32160. if (_this.loop) {
  32161. current = current % strategies.length;
  32162. }
  32163. if (current < strategies.length) {
  32164. if (timeout) {
  32165. timeout = timeout * 2;
  32166. if (_this.timeoutLimit) {
  32167. timeout = Math.min(timeout, _this.timeoutLimit);
  32168. }
  32169. }
  32170. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  32171. }
  32172. else {
  32173. callback(true);
  32174. }
  32175. }
  32176. };
  32177. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  32178. return {
  32179. abort: function () {
  32180. runner.abort();
  32181. },
  32182. forceMinPriority: function (p) {
  32183. minPriority = p;
  32184. if (runner) {
  32185. runner.forceMinPriority(p);
  32186. }
  32187. }
  32188. };
  32189. };
  32190. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  32191. var timer = null;
  32192. var runner = null;
  32193. if (options.timeout > 0) {
  32194. timer = new timers_1.OneOffTimer(options.timeout, function () {
  32195. runner.abort();
  32196. callback(true);
  32197. });
  32198. }
  32199. runner = strategy.connect(minPriority, function (error, handshake) {
  32200. if (error && timer && timer.isRunning() && !options.failFast) {
  32201. return;
  32202. }
  32203. if (timer) {
  32204. timer.ensureAborted();
  32205. }
  32206. callback(error, handshake);
  32207. });
  32208. return {
  32209. abort: function () {
  32210. if (timer) {
  32211. timer.ensureAborted();
  32212. }
  32213. runner.abort();
  32214. },
  32215. forceMinPriority: function (p) {
  32216. runner.forceMinPriority(p);
  32217. }
  32218. };
  32219. };
  32220. return SequentialStrategy;
  32221. }());
  32222. exports.__esModule = true;
  32223. exports["default"] = SequentialStrategy;
  32224. /***/ }),
  32225. /* 57 */
  32226. /***/ (function(module, exports, __webpack_require__) {
  32227. "use strict";
  32228. var Collections = __webpack_require__(9);
  32229. var util_1 = __webpack_require__(11);
  32230. var BestConnectedEverStrategy = (function () {
  32231. function BestConnectedEverStrategy(strategies) {
  32232. this.strategies = strategies;
  32233. }
  32234. BestConnectedEverStrategy.prototype.isSupported = function () {
  32235. return Collections.any(this.strategies, util_1["default"].method("isSupported"));
  32236. };
  32237. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  32238. return connect(this.strategies, minPriority, function (i, runners) {
  32239. return function (error, handshake) {
  32240. runners[i].error = error;
  32241. if (error) {
  32242. if (allRunnersFailed(runners)) {
  32243. callback(true);
  32244. }
  32245. return;
  32246. }
  32247. Collections.apply(runners, function (runner) {
  32248. runner.forceMinPriority(handshake.transport.priority);
  32249. });
  32250. callback(null, handshake);
  32251. };
  32252. });
  32253. };
  32254. return BestConnectedEverStrategy;
  32255. }());
  32256. exports.__esModule = true;
  32257. exports["default"] = BestConnectedEverStrategy;
  32258. function connect(strategies, minPriority, callbackBuilder) {
  32259. var runners = Collections.map(strategies, function (strategy, i, _, rs) {
  32260. return strategy.connect(minPriority, callbackBuilder(i, rs));
  32261. });
  32262. return {
  32263. abort: function () {
  32264. Collections.apply(runners, abortRunner);
  32265. },
  32266. forceMinPriority: function (p) {
  32267. Collections.apply(runners, function (runner) {
  32268. runner.forceMinPriority(p);
  32269. });
  32270. }
  32271. };
  32272. }
  32273. function allRunnersFailed(runners) {
  32274. return Collections.all(runners, function (runner) {
  32275. return Boolean(runner.error);
  32276. });
  32277. }
  32278. function abortRunner(runner) {
  32279. if (!runner.error && !runner.aborted) {
  32280. runner.abort();
  32281. runner.aborted = true;
  32282. }
  32283. }
  32284. /***/ }),
  32285. /* 58 */
  32286. /***/ (function(module, exports, __webpack_require__) {
  32287. "use strict";
  32288. var util_1 = __webpack_require__(11);
  32289. var runtime_1 = __webpack_require__(2);
  32290. var sequential_strategy_1 = __webpack_require__(56);
  32291. var Collections = __webpack_require__(9);
  32292. var CachedStrategy = (function () {
  32293. function CachedStrategy(strategy, transports, options) {
  32294. this.strategy = strategy;
  32295. this.transports = transports;
  32296. this.ttl = options.ttl || 1800 * 1000;
  32297. this.encrypted = options.encrypted;
  32298. this.timeline = options.timeline;
  32299. }
  32300. CachedStrategy.prototype.isSupported = function () {
  32301. return this.strategy.isSupported();
  32302. };
  32303. CachedStrategy.prototype.connect = function (minPriority, callback) {
  32304. var encrypted = this.encrypted;
  32305. var info = fetchTransportCache(encrypted);
  32306. var strategies = [this.strategy];
  32307. if (info && info.timestamp + this.ttl >= util_1["default"].now()) {
  32308. var transport = this.transports[info.transport];
  32309. if (transport) {
  32310. this.timeline.info({
  32311. cached: true,
  32312. transport: info.transport,
  32313. latency: info.latency
  32314. });
  32315. strategies.push(new sequential_strategy_1["default"]([transport], {
  32316. timeout: info.latency * 2 + 1000,
  32317. failFast: true
  32318. }));
  32319. }
  32320. }
  32321. var startTimestamp = util_1["default"].now();
  32322. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  32323. if (error) {
  32324. flushTransportCache(encrypted);
  32325. if (strategies.length > 0) {
  32326. startTimestamp = util_1["default"].now();
  32327. runner = strategies.pop().connect(minPriority, cb);
  32328. }
  32329. else {
  32330. callback(error);
  32331. }
  32332. }
  32333. else {
  32334. storeTransportCache(encrypted, handshake.transport.name, util_1["default"].now() - startTimestamp);
  32335. callback(null, handshake);
  32336. }
  32337. });
  32338. return {
  32339. abort: function () {
  32340. runner.abort();
  32341. },
  32342. forceMinPriority: function (p) {
  32343. minPriority = p;
  32344. if (runner) {
  32345. runner.forceMinPriority(p);
  32346. }
  32347. }
  32348. };
  32349. };
  32350. return CachedStrategy;
  32351. }());
  32352. exports.__esModule = true;
  32353. exports["default"] = CachedStrategy;
  32354. function getTransportCacheKey(encrypted) {
  32355. return "pusherTransport" + (encrypted ? "Encrypted" : "Unencrypted");
  32356. }
  32357. function fetchTransportCache(encrypted) {
  32358. var storage = runtime_1["default"].getLocalStorage();
  32359. if (storage) {
  32360. try {
  32361. var serializedCache = storage[getTransportCacheKey(encrypted)];
  32362. if (serializedCache) {
  32363. return JSON.parse(serializedCache);
  32364. }
  32365. }
  32366. catch (e) {
  32367. flushTransportCache(encrypted);
  32368. }
  32369. }
  32370. return null;
  32371. }
  32372. function storeTransportCache(encrypted, transport, latency) {
  32373. var storage = runtime_1["default"].getLocalStorage();
  32374. if (storage) {
  32375. try {
  32376. storage[getTransportCacheKey(encrypted)] = Collections.safeJSONStringify({
  32377. timestamp: util_1["default"].now(),
  32378. transport: transport,
  32379. latency: latency
  32380. });
  32381. }
  32382. catch (e) {
  32383. }
  32384. }
  32385. }
  32386. function flushTransportCache(encrypted) {
  32387. var storage = runtime_1["default"].getLocalStorage();
  32388. if (storage) {
  32389. try {
  32390. delete storage[getTransportCacheKey(encrypted)];
  32391. }
  32392. catch (e) {
  32393. }
  32394. }
  32395. }
  32396. /***/ }),
  32397. /* 59 */
  32398. /***/ (function(module, exports, __webpack_require__) {
  32399. "use strict";
  32400. var timers_1 = __webpack_require__(12);
  32401. var DelayedStrategy = (function () {
  32402. function DelayedStrategy(strategy, _a) {
  32403. var number = _a.delay;
  32404. this.strategy = strategy;
  32405. this.options = { delay: number };
  32406. }
  32407. DelayedStrategy.prototype.isSupported = function () {
  32408. return this.strategy.isSupported();
  32409. };
  32410. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  32411. var strategy = this.strategy;
  32412. var runner;
  32413. var timer = new timers_1.OneOffTimer(this.options.delay, function () {
  32414. runner = strategy.connect(minPriority, callback);
  32415. });
  32416. return {
  32417. abort: function () {
  32418. timer.ensureAborted();
  32419. if (runner) {
  32420. runner.abort();
  32421. }
  32422. },
  32423. forceMinPriority: function (p) {
  32424. minPriority = p;
  32425. if (runner) {
  32426. runner.forceMinPriority(p);
  32427. }
  32428. }
  32429. };
  32430. };
  32431. return DelayedStrategy;
  32432. }());
  32433. exports.__esModule = true;
  32434. exports["default"] = DelayedStrategy;
  32435. /***/ }),
  32436. /* 60 */
  32437. /***/ (function(module, exports) {
  32438. "use strict";
  32439. var IfStrategy = (function () {
  32440. function IfStrategy(test, trueBranch, falseBranch) {
  32441. this.test = test;
  32442. this.trueBranch = trueBranch;
  32443. this.falseBranch = falseBranch;
  32444. }
  32445. IfStrategy.prototype.isSupported = function () {
  32446. var branch = this.test() ? this.trueBranch : this.falseBranch;
  32447. return branch.isSupported();
  32448. };
  32449. IfStrategy.prototype.connect = function (minPriority, callback) {
  32450. var branch = this.test() ? this.trueBranch : this.falseBranch;
  32451. return branch.connect(minPriority, callback);
  32452. };
  32453. return IfStrategy;
  32454. }());
  32455. exports.__esModule = true;
  32456. exports["default"] = IfStrategy;
  32457. /***/ }),
  32458. /* 61 */
  32459. /***/ (function(module, exports) {
  32460. "use strict";
  32461. var FirstConnectedStrategy = (function () {
  32462. function FirstConnectedStrategy(strategy) {
  32463. this.strategy = strategy;
  32464. }
  32465. FirstConnectedStrategy.prototype.isSupported = function () {
  32466. return this.strategy.isSupported();
  32467. };
  32468. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  32469. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  32470. if (handshake) {
  32471. runner.abort();
  32472. }
  32473. callback(error, handshake);
  32474. });
  32475. return runner;
  32476. };
  32477. return FirstConnectedStrategy;
  32478. }());
  32479. exports.__esModule = true;
  32480. exports["default"] = FirstConnectedStrategy;
  32481. /***/ }),
  32482. /* 62 */
  32483. /***/ (function(module, exports, __webpack_require__) {
  32484. "use strict";
  32485. var defaults_1 = __webpack_require__(5);
  32486. exports.getGlobalConfig = function () {
  32487. return {
  32488. wsHost: defaults_1["default"].host,
  32489. wsPort: defaults_1["default"].ws_port,
  32490. wssPort: defaults_1["default"].wss_port,
  32491. httpHost: defaults_1["default"].sockjs_host,
  32492. httpPort: defaults_1["default"].sockjs_http_port,
  32493. httpsPort: defaults_1["default"].sockjs_https_port,
  32494. httpPath: defaults_1["default"].sockjs_path,
  32495. statsHost: defaults_1["default"].stats_host,
  32496. authEndpoint: defaults_1["default"].channel_auth_endpoint,
  32497. authTransport: defaults_1["default"].channel_auth_transport,
  32498. activity_timeout: defaults_1["default"].activity_timeout,
  32499. pong_timeout: defaults_1["default"].pong_timeout,
  32500. unavailable_timeout: defaults_1["default"].unavailable_timeout
  32501. };
  32502. };
  32503. exports.getClusterConfig = function (clusterName) {
  32504. return {
  32505. wsHost: "ws-" + clusterName + ".pusher.com",
  32506. httpHost: "sockjs-" + clusterName + ".pusher.com"
  32507. };
  32508. };
  32509. /***/ })
  32510. /******/ ])
  32511. });
  32512. ;
  32513. /***/ }),
  32514. /* 38 */
  32515. /***/ (function(module, exports, __webpack_require__) {
  32516. "use strict";
  32517. /* WEBPACK VAR INJECTION */(function(global) {/*!
  32518. * Vue.js v2.3.4
  32519. * (c) 2014-2017 Evan You
  32520. * Released under the MIT License.
  32521. */
  32522. /* */
  32523. // these helpers produces better vm code in JS engines due to their
  32524. // explicitness and function inlining
  32525. function isUndef (v) {
  32526. return v === undefined || v === null
  32527. }
  32528. function isDef (v) {
  32529. return v !== undefined && v !== null
  32530. }
  32531. function isTrue (v) {
  32532. return v === true
  32533. }
  32534. function isFalse (v) {
  32535. return v === false
  32536. }
  32537. /**
  32538. * Check if value is primitive
  32539. */
  32540. function isPrimitive (value) {
  32541. return typeof value === 'string' || typeof value === 'number'
  32542. }
  32543. /**
  32544. * Quick object check - this is primarily used to tell
  32545. * Objects from primitive values when we know the value
  32546. * is a JSON-compliant type.
  32547. */
  32548. function isObject (obj) {
  32549. return obj !== null && typeof obj === 'object'
  32550. }
  32551. var _toString = Object.prototype.toString;
  32552. /**
  32553. * Strict object type check. Only returns true
  32554. * for plain JavaScript objects.
  32555. */
  32556. function isPlainObject (obj) {
  32557. return _toString.call(obj) === '[object Object]'
  32558. }
  32559. function isRegExp (v) {
  32560. return _toString.call(v) === '[object RegExp]'
  32561. }
  32562. /**
  32563. * Convert a value to a string that is actually rendered.
  32564. */
  32565. function toString (val) {
  32566. return val == null
  32567. ? ''
  32568. : typeof val === 'object'
  32569. ? JSON.stringify(val, null, 2)
  32570. : String(val)
  32571. }
  32572. /**
  32573. * Convert a input value to a number for persistence.
  32574. * If the conversion fails, return original string.
  32575. */
  32576. function toNumber (val) {
  32577. var n = parseFloat(val);
  32578. return isNaN(n) ? val : n
  32579. }
  32580. /**
  32581. * Make a map and return a function for checking if a key
  32582. * is in that map.
  32583. */
  32584. function makeMap (
  32585. str,
  32586. expectsLowerCase
  32587. ) {
  32588. var map = Object.create(null);
  32589. var list = str.split(',');
  32590. for (var i = 0; i < list.length; i++) {
  32591. map[list[i]] = true;
  32592. }
  32593. return expectsLowerCase
  32594. ? function (val) { return map[val.toLowerCase()]; }
  32595. : function (val) { return map[val]; }
  32596. }
  32597. /**
  32598. * Check if a tag is a built-in tag.
  32599. */
  32600. var isBuiltInTag = makeMap('slot,component', true);
  32601. /**
  32602. * Remove an item from an array
  32603. */
  32604. function remove (arr, item) {
  32605. if (arr.length) {
  32606. var index = arr.indexOf(item);
  32607. if (index > -1) {
  32608. return arr.splice(index, 1)
  32609. }
  32610. }
  32611. }
  32612. /**
  32613. * Check whether the object has the property.
  32614. */
  32615. var hasOwnProperty = Object.prototype.hasOwnProperty;
  32616. function hasOwn (obj, key) {
  32617. return hasOwnProperty.call(obj, key)
  32618. }
  32619. /**
  32620. * Create a cached version of a pure function.
  32621. */
  32622. function cached (fn) {
  32623. var cache = Object.create(null);
  32624. return (function cachedFn (str) {
  32625. var hit = cache[str];
  32626. return hit || (cache[str] = fn(str))
  32627. })
  32628. }
  32629. /**
  32630. * Camelize a hyphen-delimited string.
  32631. */
  32632. var camelizeRE = /-(\w)/g;
  32633. var camelize = cached(function (str) {
  32634. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  32635. });
  32636. /**
  32637. * Capitalize a string.
  32638. */
  32639. var capitalize = cached(function (str) {
  32640. return str.charAt(0).toUpperCase() + str.slice(1)
  32641. });
  32642. /**
  32643. * Hyphenate a camelCase string.
  32644. */
  32645. var hyphenateRE = /([^-])([A-Z])/g;
  32646. var hyphenate = cached(function (str) {
  32647. return str
  32648. .replace(hyphenateRE, '$1-$2')
  32649. .replace(hyphenateRE, '$1-$2')
  32650. .toLowerCase()
  32651. });
  32652. /**
  32653. * Simple bind, faster than native
  32654. */
  32655. function bind (fn, ctx) {
  32656. function boundFn (a) {
  32657. var l = arguments.length;
  32658. return l
  32659. ? l > 1
  32660. ? fn.apply(ctx, arguments)
  32661. : fn.call(ctx, a)
  32662. : fn.call(ctx)
  32663. }
  32664. // record original fn length
  32665. boundFn._length = fn.length;
  32666. return boundFn
  32667. }
  32668. /**
  32669. * Convert an Array-like object to a real Array.
  32670. */
  32671. function toArray (list, start) {
  32672. start = start || 0;
  32673. var i = list.length - start;
  32674. var ret = new Array(i);
  32675. while (i--) {
  32676. ret[i] = list[i + start];
  32677. }
  32678. return ret
  32679. }
  32680. /**
  32681. * Mix properties into target object.
  32682. */
  32683. function extend (to, _from) {
  32684. for (var key in _from) {
  32685. to[key] = _from[key];
  32686. }
  32687. return to
  32688. }
  32689. /**
  32690. * Merge an Array of Objects into a single Object.
  32691. */
  32692. function toObject (arr) {
  32693. var res = {};
  32694. for (var i = 0; i < arr.length; i++) {
  32695. if (arr[i]) {
  32696. extend(res, arr[i]);
  32697. }
  32698. }
  32699. return res
  32700. }
  32701. /**
  32702. * Perform no operation.
  32703. */
  32704. function noop () {}
  32705. /**
  32706. * Always return false.
  32707. */
  32708. var no = function () { return false; };
  32709. /**
  32710. * Return same value
  32711. */
  32712. var identity = function (_) { return _; };
  32713. /**
  32714. * Generate a static keys string from compiler modules.
  32715. */
  32716. function genStaticKeys (modules) {
  32717. return modules.reduce(function (keys, m) {
  32718. return keys.concat(m.staticKeys || [])
  32719. }, []).join(',')
  32720. }
  32721. /**
  32722. * Check if two values are loosely equal - that is,
  32723. * if they are plain objects, do they have the same shape?
  32724. */
  32725. function looseEqual (a, b) {
  32726. var isObjectA = isObject(a);
  32727. var isObjectB = isObject(b);
  32728. if (isObjectA && isObjectB) {
  32729. try {
  32730. return JSON.stringify(a) === JSON.stringify(b)
  32731. } catch (e) {
  32732. // possible circular reference
  32733. return a === b
  32734. }
  32735. } else if (!isObjectA && !isObjectB) {
  32736. return String(a) === String(b)
  32737. } else {
  32738. return false
  32739. }
  32740. }
  32741. function looseIndexOf (arr, val) {
  32742. for (var i = 0; i < arr.length; i++) {
  32743. if (looseEqual(arr[i], val)) { return i }
  32744. }
  32745. return -1
  32746. }
  32747. /**
  32748. * Ensure a function is called only once.
  32749. */
  32750. function once (fn) {
  32751. var called = false;
  32752. return function () {
  32753. if (!called) {
  32754. called = true;
  32755. fn.apply(this, arguments);
  32756. }
  32757. }
  32758. }
  32759. var SSR_ATTR = 'data-server-rendered';
  32760. var ASSET_TYPES = [
  32761. 'component',
  32762. 'directive',
  32763. 'filter'
  32764. ];
  32765. var LIFECYCLE_HOOKS = [
  32766. 'beforeCreate',
  32767. 'created',
  32768. 'beforeMount',
  32769. 'mounted',
  32770. 'beforeUpdate',
  32771. 'updated',
  32772. 'beforeDestroy',
  32773. 'destroyed',
  32774. 'activated',
  32775. 'deactivated'
  32776. ];
  32777. /* */
  32778. var config = ({
  32779. /**
  32780. * Option merge strategies (used in core/util/options)
  32781. */
  32782. optionMergeStrategies: Object.create(null),
  32783. /**
  32784. * Whether to suppress warnings.
  32785. */
  32786. silent: false,
  32787. /**
  32788. * Show production mode tip message on boot?
  32789. */
  32790. productionTip: "development" !== 'production',
  32791. /**
  32792. * Whether to enable devtools
  32793. */
  32794. devtools: "development" !== 'production',
  32795. /**
  32796. * Whether to record perf
  32797. */
  32798. performance: false,
  32799. /**
  32800. * Error handler for watcher errors
  32801. */
  32802. errorHandler: null,
  32803. /**
  32804. * Ignore certain custom elements
  32805. */
  32806. ignoredElements: [],
  32807. /**
  32808. * Custom user key aliases for v-on
  32809. */
  32810. keyCodes: Object.create(null),
  32811. /**
  32812. * Check if a tag is reserved so that it cannot be registered as a
  32813. * component. This is platform-dependent and may be overwritten.
  32814. */
  32815. isReservedTag: no,
  32816. /**
  32817. * Check if an attribute is reserved so that it cannot be used as a component
  32818. * prop. This is platform-dependent and may be overwritten.
  32819. */
  32820. isReservedAttr: no,
  32821. /**
  32822. * Check if a tag is an unknown element.
  32823. * Platform-dependent.
  32824. */
  32825. isUnknownElement: no,
  32826. /**
  32827. * Get the namespace of an element
  32828. */
  32829. getTagNamespace: noop,
  32830. /**
  32831. * Parse the real tag name for the specific platform.
  32832. */
  32833. parsePlatformTagName: identity,
  32834. /**
  32835. * Check if an attribute must be bound using property, e.g. value
  32836. * Platform-dependent.
  32837. */
  32838. mustUseProp: no,
  32839. /**
  32840. * Exposed for legacy reasons
  32841. */
  32842. _lifecycleHooks: LIFECYCLE_HOOKS
  32843. });
  32844. /* */
  32845. var emptyObject = Object.freeze({});
  32846. /**
  32847. * Check if a string starts with $ or _
  32848. */
  32849. function isReserved (str) {
  32850. var c = (str + '').charCodeAt(0);
  32851. return c === 0x24 || c === 0x5F
  32852. }
  32853. /**
  32854. * Define a property.
  32855. */
  32856. function def (obj, key, val, enumerable) {
  32857. Object.defineProperty(obj, key, {
  32858. value: val,
  32859. enumerable: !!enumerable,
  32860. writable: true,
  32861. configurable: true
  32862. });
  32863. }
  32864. /**
  32865. * Parse simple path.
  32866. */
  32867. var bailRE = /[^\w.$]/;
  32868. function parsePath (path) {
  32869. if (bailRE.test(path)) {
  32870. return
  32871. }
  32872. var segments = path.split('.');
  32873. return function (obj) {
  32874. for (var i = 0; i < segments.length; i++) {
  32875. if (!obj) { return }
  32876. obj = obj[segments[i]];
  32877. }
  32878. return obj
  32879. }
  32880. }
  32881. /* */
  32882. var warn = noop;
  32883. var tip = noop;
  32884. var formatComponentName = (null); // work around flow check
  32885. if (true) {
  32886. var hasConsole = typeof console !== 'undefined';
  32887. var classifyRE = /(?:^|[-_])(\w)/g;
  32888. var classify = function (str) { return str
  32889. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  32890. .replace(/[-_]/g, ''); };
  32891. warn = function (msg, vm) {
  32892. if (hasConsole && (!config.silent)) {
  32893. console.error("[Vue warn]: " + msg + (
  32894. vm ? generateComponentTrace(vm) : ''
  32895. ));
  32896. }
  32897. };
  32898. tip = function (msg, vm) {
  32899. if (hasConsole && (!config.silent)) {
  32900. console.warn("[Vue tip]: " + msg + (
  32901. vm ? generateComponentTrace(vm) : ''
  32902. ));
  32903. }
  32904. };
  32905. formatComponentName = function (vm, includeFile) {
  32906. if (vm.$root === vm) {
  32907. return '<Root>'
  32908. }
  32909. var name = typeof vm === 'string'
  32910. ? vm
  32911. : typeof vm === 'function' && vm.options
  32912. ? vm.options.name
  32913. : vm._isVue
  32914. ? vm.$options.name || vm.$options._componentTag
  32915. : vm.name;
  32916. var file = vm._isVue && vm.$options.__file;
  32917. if (!name && file) {
  32918. var match = file.match(/([^/\\]+)\.vue$/);
  32919. name = match && match[1];
  32920. }
  32921. return (
  32922. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  32923. (file && includeFile !== false ? (" at " + file) : '')
  32924. )
  32925. };
  32926. var repeat = function (str, n) {
  32927. var res = '';
  32928. while (n) {
  32929. if (n % 2 === 1) { res += str; }
  32930. if (n > 1) { str += str; }
  32931. n >>= 1;
  32932. }
  32933. return res
  32934. };
  32935. var generateComponentTrace = function (vm) {
  32936. if (vm._isVue && vm.$parent) {
  32937. var tree = [];
  32938. var currentRecursiveSequence = 0;
  32939. while (vm) {
  32940. if (tree.length > 0) {
  32941. var last = tree[tree.length - 1];
  32942. if (last.constructor === vm.constructor) {
  32943. currentRecursiveSequence++;
  32944. vm = vm.$parent;
  32945. continue
  32946. } else if (currentRecursiveSequence > 0) {
  32947. tree[tree.length - 1] = [last, currentRecursiveSequence];
  32948. currentRecursiveSequence = 0;
  32949. }
  32950. }
  32951. tree.push(vm);
  32952. vm = vm.$parent;
  32953. }
  32954. return '\n\nfound in\n\n' + tree
  32955. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  32956. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  32957. : formatComponentName(vm))); })
  32958. .join('\n')
  32959. } else {
  32960. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  32961. }
  32962. };
  32963. }
  32964. /* */
  32965. function handleError (err, vm, info) {
  32966. if (config.errorHandler) {
  32967. config.errorHandler.call(null, err, vm, info);
  32968. } else {
  32969. if (true) {
  32970. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  32971. }
  32972. /* istanbul ignore else */
  32973. if (inBrowser && typeof console !== 'undefined') {
  32974. console.error(err);
  32975. } else {
  32976. throw err
  32977. }
  32978. }
  32979. }
  32980. /* */
  32981. /* globals MutationObserver */
  32982. // can we use __proto__?
  32983. var hasProto = '__proto__' in {};
  32984. // Browser environment sniffing
  32985. var inBrowser = typeof window !== 'undefined';
  32986. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  32987. var isIE = UA && /msie|trident/.test(UA);
  32988. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  32989. var isEdge = UA && UA.indexOf('edge/') > 0;
  32990. var isAndroid = UA && UA.indexOf('android') > 0;
  32991. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  32992. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  32993. var supportsPassive = false;
  32994. if (inBrowser) {
  32995. try {
  32996. var opts = {};
  32997. Object.defineProperty(opts, 'passive', ({
  32998. get: function get () {
  32999. /* istanbul ignore next */
  33000. supportsPassive = true;
  33001. }
  33002. } )); // https://github.com/facebook/flow/issues/285
  33003. window.addEventListener('test-passive', null, opts);
  33004. } catch (e) {}
  33005. }
  33006. // this needs to be lazy-evaled because vue may be required before
  33007. // vue-server-renderer can set VUE_ENV
  33008. var _isServer;
  33009. var isServerRendering = function () {
  33010. if (_isServer === undefined) {
  33011. /* istanbul ignore if */
  33012. if (!inBrowser && typeof global !== 'undefined') {
  33013. // detect presence of vue-server-renderer and avoid
  33014. // Webpack shimming the process
  33015. _isServer = global['process'].env.VUE_ENV === 'server';
  33016. } else {
  33017. _isServer = false;
  33018. }
  33019. }
  33020. return _isServer
  33021. };
  33022. // detect devtools
  33023. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  33024. /* istanbul ignore next */
  33025. function isNative (Ctor) {
  33026. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  33027. }
  33028. var hasSymbol =
  33029. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  33030. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  33031. /**
  33032. * Defer a task to execute it asynchronously.
  33033. */
  33034. var nextTick = (function () {
  33035. var callbacks = [];
  33036. var pending = false;
  33037. var timerFunc;
  33038. function nextTickHandler () {
  33039. pending = false;
  33040. var copies = callbacks.slice(0);
  33041. callbacks.length = 0;
  33042. for (var i = 0; i < copies.length; i++) {
  33043. copies[i]();
  33044. }
  33045. }
  33046. // the nextTick behavior leverages the microtask queue, which can be accessed
  33047. // via either native Promise.then or MutationObserver.
  33048. // MutationObserver has wider support, however it is seriously bugged in
  33049. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  33050. // completely stops working after triggering a few times... so, if native
  33051. // Promise is available, we will use it:
  33052. /* istanbul ignore if */
  33053. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  33054. var p = Promise.resolve();
  33055. var logError = function (err) { console.error(err); };
  33056. timerFunc = function () {
  33057. p.then(nextTickHandler).catch(logError);
  33058. // in problematic UIWebViews, Promise.then doesn't completely break, but
  33059. // it can get stuck in a weird state where callbacks are pushed into the
  33060. // microtask queue but the queue isn't being flushed, until the browser
  33061. // needs to do some other work, e.g. handle a timer. Therefore we can
  33062. // "force" the microtask queue to be flushed by adding an empty timer.
  33063. if (isIOS) { setTimeout(noop); }
  33064. };
  33065. } else if (typeof MutationObserver !== 'undefined' && (
  33066. isNative(MutationObserver) ||
  33067. // PhantomJS and iOS 7.x
  33068. MutationObserver.toString() === '[object MutationObserverConstructor]'
  33069. )) {
  33070. // use MutationObserver where native Promise is not available,
  33071. // e.g. PhantomJS IE11, iOS7, Android 4.4
  33072. var counter = 1;
  33073. var observer = new MutationObserver(nextTickHandler);
  33074. var textNode = document.createTextNode(String(counter));
  33075. observer.observe(textNode, {
  33076. characterData: true
  33077. });
  33078. timerFunc = function () {
  33079. counter = (counter + 1) % 2;
  33080. textNode.data = String(counter);
  33081. };
  33082. } else {
  33083. // fallback to setTimeout
  33084. /* istanbul ignore next */
  33085. timerFunc = function () {
  33086. setTimeout(nextTickHandler, 0);
  33087. };
  33088. }
  33089. return function queueNextTick (cb, ctx) {
  33090. var _resolve;
  33091. callbacks.push(function () {
  33092. if (cb) {
  33093. try {
  33094. cb.call(ctx);
  33095. } catch (e) {
  33096. handleError(e, ctx, 'nextTick');
  33097. }
  33098. } else if (_resolve) {
  33099. _resolve(ctx);
  33100. }
  33101. });
  33102. if (!pending) {
  33103. pending = true;
  33104. timerFunc();
  33105. }
  33106. if (!cb && typeof Promise !== 'undefined') {
  33107. return new Promise(function (resolve, reject) {
  33108. _resolve = resolve;
  33109. })
  33110. }
  33111. }
  33112. })();
  33113. var _Set;
  33114. /* istanbul ignore if */
  33115. if (typeof Set !== 'undefined' && isNative(Set)) {
  33116. // use native Set when available.
  33117. _Set = Set;
  33118. } else {
  33119. // a non-standard Set polyfill that only works with primitive keys.
  33120. _Set = (function () {
  33121. function Set () {
  33122. this.set = Object.create(null);
  33123. }
  33124. Set.prototype.has = function has (key) {
  33125. return this.set[key] === true
  33126. };
  33127. Set.prototype.add = function add (key) {
  33128. this.set[key] = true;
  33129. };
  33130. Set.prototype.clear = function clear () {
  33131. this.set = Object.create(null);
  33132. };
  33133. return Set;
  33134. }());
  33135. }
  33136. /* */
  33137. var uid = 0;
  33138. /**
  33139. * A dep is an observable that can have multiple
  33140. * directives subscribing to it.
  33141. */
  33142. var Dep = function Dep () {
  33143. this.id = uid++;
  33144. this.subs = [];
  33145. };
  33146. Dep.prototype.addSub = function addSub (sub) {
  33147. this.subs.push(sub);
  33148. };
  33149. Dep.prototype.removeSub = function removeSub (sub) {
  33150. remove(this.subs, sub);
  33151. };
  33152. Dep.prototype.depend = function depend () {
  33153. if (Dep.target) {
  33154. Dep.target.addDep(this);
  33155. }
  33156. };
  33157. Dep.prototype.notify = function notify () {
  33158. // stabilize the subscriber list first
  33159. var subs = this.subs.slice();
  33160. for (var i = 0, l = subs.length; i < l; i++) {
  33161. subs[i].update();
  33162. }
  33163. };
  33164. // the current target watcher being evaluated.
  33165. // this is globally unique because there could be only one
  33166. // watcher being evaluated at any time.
  33167. Dep.target = null;
  33168. var targetStack = [];
  33169. function pushTarget (_target) {
  33170. if (Dep.target) { targetStack.push(Dep.target); }
  33171. Dep.target = _target;
  33172. }
  33173. function popTarget () {
  33174. Dep.target = targetStack.pop();
  33175. }
  33176. /*
  33177. * not type checking this file because flow doesn't play well with
  33178. * dynamically accessing methods on Array prototype
  33179. */
  33180. var arrayProto = Array.prototype;
  33181. var arrayMethods = Object.create(arrayProto);[
  33182. 'push',
  33183. 'pop',
  33184. 'shift',
  33185. 'unshift',
  33186. 'splice',
  33187. 'sort',
  33188. 'reverse'
  33189. ]
  33190. .forEach(function (method) {
  33191. // cache original method
  33192. var original = arrayProto[method];
  33193. def(arrayMethods, method, function mutator () {
  33194. var arguments$1 = arguments;
  33195. // avoid leaking arguments:
  33196. // http://jsperf.com/closure-with-arguments
  33197. var i = arguments.length;
  33198. var args = new Array(i);
  33199. while (i--) {
  33200. args[i] = arguments$1[i];
  33201. }
  33202. var result = original.apply(this, args);
  33203. var ob = this.__ob__;
  33204. var inserted;
  33205. switch (method) {
  33206. case 'push':
  33207. inserted = args;
  33208. break
  33209. case 'unshift':
  33210. inserted = args;
  33211. break
  33212. case 'splice':
  33213. inserted = args.slice(2);
  33214. break
  33215. }
  33216. if (inserted) { ob.observeArray(inserted); }
  33217. // notify change
  33218. ob.dep.notify();
  33219. return result
  33220. });
  33221. });
  33222. /* */
  33223. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  33224. /**
  33225. * By default, when a reactive property is set, the new value is
  33226. * also converted to become reactive. However when passing down props,
  33227. * we don't want to force conversion because the value may be a nested value
  33228. * under a frozen data structure. Converting it would defeat the optimization.
  33229. */
  33230. var observerState = {
  33231. shouldConvert: true,
  33232. isSettingProps: false
  33233. };
  33234. /**
  33235. * Observer class that are attached to each observed
  33236. * object. Once attached, the observer converts target
  33237. * object's property keys into getter/setters that
  33238. * collect dependencies and dispatches updates.
  33239. */
  33240. var Observer = function Observer (value) {
  33241. this.value = value;
  33242. this.dep = new Dep();
  33243. this.vmCount = 0;
  33244. def(value, '__ob__', this);
  33245. if (Array.isArray(value)) {
  33246. var augment = hasProto
  33247. ? protoAugment
  33248. : copyAugment;
  33249. augment(value, arrayMethods, arrayKeys);
  33250. this.observeArray(value);
  33251. } else {
  33252. this.walk(value);
  33253. }
  33254. };
  33255. /**
  33256. * Walk through each property and convert them into
  33257. * getter/setters. This method should only be called when
  33258. * value type is Object.
  33259. */
  33260. Observer.prototype.walk = function walk (obj) {
  33261. var keys = Object.keys(obj);
  33262. for (var i = 0; i < keys.length; i++) {
  33263. defineReactive$$1(obj, keys[i], obj[keys[i]]);
  33264. }
  33265. };
  33266. /**
  33267. * Observe a list of Array items.
  33268. */
  33269. Observer.prototype.observeArray = function observeArray (items) {
  33270. for (var i = 0, l = items.length; i < l; i++) {
  33271. observe(items[i]);
  33272. }
  33273. };
  33274. // helpers
  33275. /**
  33276. * Augment an target Object or Array by intercepting
  33277. * the prototype chain using __proto__
  33278. */
  33279. function protoAugment (target, src) {
  33280. /* eslint-disable no-proto */
  33281. target.__proto__ = src;
  33282. /* eslint-enable no-proto */
  33283. }
  33284. /**
  33285. * Augment an target Object or Array by defining
  33286. * hidden properties.
  33287. */
  33288. /* istanbul ignore next */
  33289. function copyAugment (target, src, keys) {
  33290. for (var i = 0, l = keys.length; i < l; i++) {
  33291. var key = keys[i];
  33292. def(target, key, src[key]);
  33293. }
  33294. }
  33295. /**
  33296. * Attempt to create an observer instance for a value,
  33297. * returns the new observer if successfully observed,
  33298. * or the existing observer if the value already has one.
  33299. */
  33300. function observe (value, asRootData) {
  33301. if (!isObject(value)) {
  33302. return
  33303. }
  33304. var ob;
  33305. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  33306. ob = value.__ob__;
  33307. } else if (
  33308. observerState.shouldConvert &&
  33309. !isServerRendering() &&
  33310. (Array.isArray(value) || isPlainObject(value)) &&
  33311. Object.isExtensible(value) &&
  33312. !value._isVue
  33313. ) {
  33314. ob = new Observer(value);
  33315. }
  33316. if (asRootData && ob) {
  33317. ob.vmCount++;
  33318. }
  33319. return ob
  33320. }
  33321. /**
  33322. * Define a reactive property on an Object.
  33323. */
  33324. function defineReactive$$1 (
  33325. obj,
  33326. key,
  33327. val,
  33328. customSetter
  33329. ) {
  33330. var dep = new Dep();
  33331. var property = Object.getOwnPropertyDescriptor(obj, key);
  33332. if (property && property.configurable === false) {
  33333. return
  33334. }
  33335. // cater for pre-defined getter/setters
  33336. var getter = property && property.get;
  33337. var setter = property && property.set;
  33338. var childOb = observe(val);
  33339. Object.defineProperty(obj, key, {
  33340. enumerable: true,
  33341. configurable: true,
  33342. get: function reactiveGetter () {
  33343. var value = getter ? getter.call(obj) : val;
  33344. if (Dep.target) {
  33345. dep.depend();
  33346. if (childOb) {
  33347. childOb.dep.depend();
  33348. }
  33349. if (Array.isArray(value)) {
  33350. dependArray(value);
  33351. }
  33352. }
  33353. return value
  33354. },
  33355. set: function reactiveSetter (newVal) {
  33356. var value = getter ? getter.call(obj) : val;
  33357. /* eslint-disable no-self-compare */
  33358. if (newVal === value || (newVal !== newVal && value !== value)) {
  33359. return
  33360. }
  33361. /* eslint-enable no-self-compare */
  33362. if ("development" !== 'production' && customSetter) {
  33363. customSetter();
  33364. }
  33365. if (setter) {
  33366. setter.call(obj, newVal);
  33367. } else {
  33368. val = newVal;
  33369. }
  33370. childOb = observe(newVal);
  33371. dep.notify();
  33372. }
  33373. });
  33374. }
  33375. /**
  33376. * Set a property on an object. Adds the new property and
  33377. * triggers change notification if the property doesn't
  33378. * already exist.
  33379. */
  33380. function set (target, key, val) {
  33381. if (Array.isArray(target) && typeof key === 'number') {
  33382. target.length = Math.max(target.length, key);
  33383. target.splice(key, 1, val);
  33384. return val
  33385. }
  33386. if (hasOwn(target, key)) {
  33387. target[key] = val;
  33388. return val
  33389. }
  33390. var ob = (target ).__ob__;
  33391. if (target._isVue || (ob && ob.vmCount)) {
  33392. "development" !== 'production' && warn(
  33393. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  33394. 'at runtime - declare it upfront in the data option.'
  33395. );
  33396. return val
  33397. }
  33398. if (!ob) {
  33399. target[key] = val;
  33400. return val
  33401. }
  33402. defineReactive$$1(ob.value, key, val);
  33403. ob.dep.notify();
  33404. return val
  33405. }
  33406. /**
  33407. * Delete a property and trigger change if necessary.
  33408. */
  33409. function del (target, key) {
  33410. if (Array.isArray(target) && typeof key === 'number') {
  33411. target.splice(key, 1);
  33412. return
  33413. }
  33414. var ob = (target ).__ob__;
  33415. if (target._isVue || (ob && ob.vmCount)) {
  33416. "development" !== 'production' && warn(
  33417. 'Avoid deleting properties on a Vue instance or its root $data ' +
  33418. '- just set it to null.'
  33419. );
  33420. return
  33421. }
  33422. if (!hasOwn(target, key)) {
  33423. return
  33424. }
  33425. delete target[key];
  33426. if (!ob) {
  33427. return
  33428. }
  33429. ob.dep.notify();
  33430. }
  33431. /**
  33432. * Collect dependencies on array elements when the array is touched, since
  33433. * we cannot intercept array element access like property getters.
  33434. */
  33435. function dependArray (value) {
  33436. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  33437. e = value[i];
  33438. e && e.__ob__ && e.__ob__.dep.depend();
  33439. if (Array.isArray(e)) {
  33440. dependArray(e);
  33441. }
  33442. }
  33443. }
  33444. /* */
  33445. /**
  33446. * Option overwriting strategies are functions that handle
  33447. * how to merge a parent option value and a child option
  33448. * value into the final value.
  33449. */
  33450. var strats = config.optionMergeStrategies;
  33451. /**
  33452. * Options with restrictions
  33453. */
  33454. if (true) {
  33455. strats.el = strats.propsData = function (parent, child, vm, key) {
  33456. if (!vm) {
  33457. warn(
  33458. "option \"" + key + "\" can only be used during instance " +
  33459. 'creation with the `new` keyword.'
  33460. );
  33461. }
  33462. return defaultStrat(parent, child)
  33463. };
  33464. }
  33465. /**
  33466. * Helper that recursively merges two data objects together.
  33467. */
  33468. function mergeData (to, from) {
  33469. if (!from) { return to }
  33470. var key, toVal, fromVal;
  33471. var keys = Object.keys(from);
  33472. for (var i = 0; i < keys.length; i++) {
  33473. key = keys[i];
  33474. toVal = to[key];
  33475. fromVal = from[key];
  33476. if (!hasOwn(to, key)) {
  33477. set(to, key, fromVal);
  33478. } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
  33479. mergeData(toVal, fromVal);
  33480. }
  33481. }
  33482. return to
  33483. }
  33484. /**
  33485. * Data
  33486. */
  33487. strats.data = function (
  33488. parentVal,
  33489. childVal,
  33490. vm
  33491. ) {
  33492. if (!vm) {
  33493. // in a Vue.extend merge, both should be functions
  33494. if (!childVal) {
  33495. return parentVal
  33496. }
  33497. if (typeof childVal !== 'function') {
  33498. "development" !== 'production' && warn(
  33499. 'The "data" option should be a function ' +
  33500. 'that returns a per-instance value in component ' +
  33501. 'definitions.',
  33502. vm
  33503. );
  33504. return parentVal
  33505. }
  33506. if (!parentVal) {
  33507. return childVal
  33508. }
  33509. // when parentVal & childVal are both present,
  33510. // we need to return a function that returns the
  33511. // merged result of both functions... no need to
  33512. // check if parentVal is a function here because
  33513. // it has to be a function to pass previous merges.
  33514. return function mergedDataFn () {
  33515. return mergeData(
  33516. childVal.call(this),
  33517. parentVal.call(this)
  33518. )
  33519. }
  33520. } else if (parentVal || childVal) {
  33521. return function mergedInstanceDataFn () {
  33522. // instance merge
  33523. var instanceData = typeof childVal === 'function'
  33524. ? childVal.call(vm)
  33525. : childVal;
  33526. var defaultData = typeof parentVal === 'function'
  33527. ? parentVal.call(vm)
  33528. : undefined;
  33529. if (instanceData) {
  33530. return mergeData(instanceData, defaultData)
  33531. } else {
  33532. return defaultData
  33533. }
  33534. }
  33535. }
  33536. };
  33537. /**
  33538. * Hooks and props are merged as arrays.
  33539. */
  33540. function mergeHook (
  33541. parentVal,
  33542. childVal
  33543. ) {
  33544. return childVal
  33545. ? parentVal
  33546. ? parentVal.concat(childVal)
  33547. : Array.isArray(childVal)
  33548. ? childVal
  33549. : [childVal]
  33550. : parentVal
  33551. }
  33552. LIFECYCLE_HOOKS.forEach(function (hook) {
  33553. strats[hook] = mergeHook;
  33554. });
  33555. /**
  33556. * Assets
  33557. *
  33558. * When a vm is present (instance creation), we need to do
  33559. * a three-way merge between constructor options, instance
  33560. * options and parent options.
  33561. */
  33562. function mergeAssets (parentVal, childVal) {
  33563. var res = Object.create(parentVal || null);
  33564. return childVal
  33565. ? extend(res, childVal)
  33566. : res
  33567. }
  33568. ASSET_TYPES.forEach(function (type) {
  33569. strats[type + 's'] = mergeAssets;
  33570. });
  33571. /**
  33572. * Watchers.
  33573. *
  33574. * Watchers hashes should not overwrite one
  33575. * another, so we merge them as arrays.
  33576. */
  33577. strats.watch = function (parentVal, childVal) {
  33578. /* istanbul ignore if */
  33579. if (!childVal) { return Object.create(parentVal || null) }
  33580. if (!parentVal) { return childVal }
  33581. var ret = {};
  33582. extend(ret, parentVal);
  33583. for (var key in childVal) {
  33584. var parent = ret[key];
  33585. var child = childVal[key];
  33586. if (parent && !Array.isArray(parent)) {
  33587. parent = [parent];
  33588. }
  33589. ret[key] = parent
  33590. ? parent.concat(child)
  33591. : [child];
  33592. }
  33593. return ret
  33594. };
  33595. /**
  33596. * Other object hashes.
  33597. */
  33598. strats.props =
  33599. strats.methods =
  33600. strats.computed = function (parentVal, childVal) {
  33601. if (!childVal) { return Object.create(parentVal || null) }
  33602. if (!parentVal) { return childVal }
  33603. var ret = Object.create(null);
  33604. extend(ret, parentVal);
  33605. extend(ret, childVal);
  33606. return ret
  33607. };
  33608. /**
  33609. * Default strategy.
  33610. */
  33611. var defaultStrat = function (parentVal, childVal) {
  33612. return childVal === undefined
  33613. ? parentVal
  33614. : childVal
  33615. };
  33616. /**
  33617. * Validate component names
  33618. */
  33619. function checkComponents (options) {
  33620. for (var key in options.components) {
  33621. var lower = key.toLowerCase();
  33622. if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
  33623. warn(
  33624. 'Do not use built-in or reserved HTML elements as component ' +
  33625. 'id: ' + key
  33626. );
  33627. }
  33628. }
  33629. }
  33630. /**
  33631. * Ensure all props option syntax are normalized into the
  33632. * Object-based format.
  33633. */
  33634. function normalizeProps (options) {
  33635. var props = options.props;
  33636. if (!props) { return }
  33637. var res = {};
  33638. var i, val, name;
  33639. if (Array.isArray(props)) {
  33640. i = props.length;
  33641. while (i--) {
  33642. val = props[i];
  33643. if (typeof val === 'string') {
  33644. name = camelize(val);
  33645. res[name] = { type: null };
  33646. } else if (true) {
  33647. warn('props must be strings when using array syntax.');
  33648. }
  33649. }
  33650. } else if (isPlainObject(props)) {
  33651. for (var key in props) {
  33652. val = props[key];
  33653. name = camelize(key);
  33654. res[name] = isPlainObject(val)
  33655. ? val
  33656. : { type: val };
  33657. }
  33658. }
  33659. options.props = res;
  33660. }
  33661. /**
  33662. * Normalize raw function directives into object format.
  33663. */
  33664. function normalizeDirectives (options) {
  33665. var dirs = options.directives;
  33666. if (dirs) {
  33667. for (var key in dirs) {
  33668. var def = dirs[key];
  33669. if (typeof def === 'function') {
  33670. dirs[key] = { bind: def, update: def };
  33671. }
  33672. }
  33673. }
  33674. }
  33675. /**
  33676. * Merge two option objects into a new one.
  33677. * Core utility used in both instantiation and inheritance.
  33678. */
  33679. function mergeOptions (
  33680. parent,
  33681. child,
  33682. vm
  33683. ) {
  33684. if (true) {
  33685. checkComponents(child);
  33686. }
  33687. if (typeof child === 'function') {
  33688. child = child.options;
  33689. }
  33690. normalizeProps(child);
  33691. normalizeDirectives(child);
  33692. var extendsFrom = child.extends;
  33693. if (extendsFrom) {
  33694. parent = mergeOptions(parent, extendsFrom, vm);
  33695. }
  33696. if (child.mixins) {
  33697. for (var i = 0, l = child.mixins.length; i < l; i++) {
  33698. parent = mergeOptions(parent, child.mixins[i], vm);
  33699. }
  33700. }
  33701. var options = {};
  33702. var key;
  33703. for (key in parent) {
  33704. mergeField(key);
  33705. }
  33706. for (key in child) {
  33707. if (!hasOwn(parent, key)) {
  33708. mergeField(key);
  33709. }
  33710. }
  33711. function mergeField (key) {
  33712. var strat = strats[key] || defaultStrat;
  33713. options[key] = strat(parent[key], child[key], vm, key);
  33714. }
  33715. return options
  33716. }
  33717. /**
  33718. * Resolve an asset.
  33719. * This function is used because child instances need access
  33720. * to assets defined in its ancestor chain.
  33721. */
  33722. function resolveAsset (
  33723. options,
  33724. type,
  33725. id,
  33726. warnMissing
  33727. ) {
  33728. /* istanbul ignore if */
  33729. if (typeof id !== 'string') {
  33730. return
  33731. }
  33732. var assets = options[type];
  33733. // check local registration variations first
  33734. if (hasOwn(assets, id)) { return assets[id] }
  33735. var camelizedId = camelize(id);
  33736. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  33737. var PascalCaseId = capitalize(camelizedId);
  33738. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  33739. // fallback to prototype chain
  33740. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  33741. if ("development" !== 'production' && warnMissing && !res) {
  33742. warn(
  33743. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  33744. options
  33745. );
  33746. }
  33747. return res
  33748. }
  33749. /* */
  33750. function validateProp (
  33751. key,
  33752. propOptions,
  33753. propsData,
  33754. vm
  33755. ) {
  33756. var prop = propOptions[key];
  33757. var absent = !hasOwn(propsData, key);
  33758. var value = propsData[key];
  33759. // handle boolean props
  33760. if (isType(Boolean, prop.type)) {
  33761. if (absent && !hasOwn(prop, 'default')) {
  33762. value = false;
  33763. } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
  33764. value = true;
  33765. }
  33766. }
  33767. // check default value
  33768. if (value === undefined) {
  33769. value = getPropDefaultValue(vm, prop, key);
  33770. // since the default value is a fresh copy,
  33771. // make sure to observe it.
  33772. var prevShouldConvert = observerState.shouldConvert;
  33773. observerState.shouldConvert = true;
  33774. observe(value);
  33775. observerState.shouldConvert = prevShouldConvert;
  33776. }
  33777. if (true) {
  33778. assertProp(prop, key, value, vm, absent);
  33779. }
  33780. return value
  33781. }
  33782. /**
  33783. * Get the default value of a prop.
  33784. */
  33785. function getPropDefaultValue (vm, prop, key) {
  33786. // no default, return undefined
  33787. if (!hasOwn(prop, 'default')) {
  33788. return undefined
  33789. }
  33790. var def = prop.default;
  33791. // warn against non-factory defaults for Object & Array
  33792. if ("development" !== 'production' && isObject(def)) {
  33793. warn(
  33794. 'Invalid default value for prop "' + key + '": ' +
  33795. 'Props with type Object/Array must use a factory function ' +
  33796. 'to return the default value.',
  33797. vm
  33798. );
  33799. }
  33800. // the raw prop value was also undefined from previous render,
  33801. // return previous default value to avoid unnecessary watcher trigger
  33802. if (vm && vm.$options.propsData &&
  33803. vm.$options.propsData[key] === undefined &&
  33804. vm._props[key] !== undefined
  33805. ) {
  33806. return vm._props[key]
  33807. }
  33808. // call factory function for non-Function types
  33809. // a value is Function if its prototype is function even across different execution context
  33810. return typeof def === 'function' && getType(prop.type) !== 'Function'
  33811. ? def.call(vm)
  33812. : def
  33813. }
  33814. /**
  33815. * Assert whether a prop is valid.
  33816. */
  33817. function assertProp (
  33818. prop,
  33819. name,
  33820. value,
  33821. vm,
  33822. absent
  33823. ) {
  33824. if (prop.required && absent) {
  33825. warn(
  33826. 'Missing required prop: "' + name + '"',
  33827. vm
  33828. );
  33829. return
  33830. }
  33831. if (value == null && !prop.required) {
  33832. return
  33833. }
  33834. var type = prop.type;
  33835. var valid = !type || type === true;
  33836. var expectedTypes = [];
  33837. if (type) {
  33838. if (!Array.isArray(type)) {
  33839. type = [type];
  33840. }
  33841. for (var i = 0; i < type.length && !valid; i++) {
  33842. var assertedType = assertType(value, type[i]);
  33843. expectedTypes.push(assertedType.expectedType || '');
  33844. valid = assertedType.valid;
  33845. }
  33846. }
  33847. if (!valid) {
  33848. warn(
  33849. 'Invalid prop: type check failed for prop "' + name + '".' +
  33850. ' Expected ' + expectedTypes.map(capitalize).join(', ') +
  33851. ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
  33852. vm
  33853. );
  33854. return
  33855. }
  33856. var validator = prop.validator;
  33857. if (validator) {
  33858. if (!validator(value)) {
  33859. warn(
  33860. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  33861. vm
  33862. );
  33863. }
  33864. }
  33865. }
  33866. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  33867. function assertType (value, type) {
  33868. var valid;
  33869. var expectedType = getType(type);
  33870. if (simpleCheckRE.test(expectedType)) {
  33871. valid = typeof value === expectedType.toLowerCase();
  33872. } else if (expectedType === 'Object') {
  33873. valid = isPlainObject(value);
  33874. } else if (expectedType === 'Array') {
  33875. valid = Array.isArray(value);
  33876. } else {
  33877. valid = value instanceof type;
  33878. }
  33879. return {
  33880. valid: valid,
  33881. expectedType: expectedType
  33882. }
  33883. }
  33884. /**
  33885. * Use function string name to check built-in types,
  33886. * because a simple equality check will fail when running
  33887. * across different vms / iframes.
  33888. */
  33889. function getType (fn) {
  33890. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  33891. return match ? match[1] : ''
  33892. }
  33893. function isType (type, fn) {
  33894. if (!Array.isArray(fn)) {
  33895. return getType(fn) === getType(type)
  33896. }
  33897. for (var i = 0, len = fn.length; i < len; i++) {
  33898. if (getType(fn[i]) === getType(type)) {
  33899. return true
  33900. }
  33901. }
  33902. /* istanbul ignore next */
  33903. return false
  33904. }
  33905. /* */
  33906. var mark;
  33907. var measure;
  33908. if (true) {
  33909. var perf = inBrowser && window.performance;
  33910. /* istanbul ignore if */
  33911. if (
  33912. perf &&
  33913. perf.mark &&
  33914. perf.measure &&
  33915. perf.clearMarks &&
  33916. perf.clearMeasures
  33917. ) {
  33918. mark = function (tag) { return perf.mark(tag); };
  33919. measure = function (name, startTag, endTag) {
  33920. perf.measure(name, startTag, endTag);
  33921. perf.clearMarks(startTag);
  33922. perf.clearMarks(endTag);
  33923. perf.clearMeasures(name);
  33924. };
  33925. }
  33926. }
  33927. /* not type checking this file because flow doesn't play well with Proxy */
  33928. var initProxy;
  33929. if (true) {
  33930. var allowedGlobals = makeMap(
  33931. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  33932. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  33933. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  33934. 'require' // for Webpack/Browserify
  33935. );
  33936. var warnNonPresent = function (target, key) {
  33937. warn(
  33938. "Property or method \"" + key + "\" is not defined on the instance but " +
  33939. "referenced during render. Make sure to declare reactive data " +
  33940. "properties in the data option.",
  33941. target
  33942. );
  33943. };
  33944. var hasProxy =
  33945. typeof Proxy !== 'undefined' &&
  33946. Proxy.toString().match(/native code/);
  33947. if (hasProxy) {
  33948. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta');
  33949. config.keyCodes = new Proxy(config.keyCodes, {
  33950. set: function set (target, key, value) {
  33951. if (isBuiltInModifier(key)) {
  33952. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  33953. return false
  33954. } else {
  33955. target[key] = value;
  33956. return true
  33957. }
  33958. }
  33959. });
  33960. }
  33961. var hasHandler = {
  33962. has: function has (target, key) {
  33963. var has = key in target;
  33964. var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
  33965. if (!has && !isAllowed) {
  33966. warnNonPresent(target, key);
  33967. }
  33968. return has || !isAllowed
  33969. }
  33970. };
  33971. var getHandler = {
  33972. get: function get (target, key) {
  33973. if (typeof key === 'string' && !(key in target)) {
  33974. warnNonPresent(target, key);
  33975. }
  33976. return target[key]
  33977. }
  33978. };
  33979. initProxy = function initProxy (vm) {
  33980. if (hasProxy) {
  33981. // determine which proxy handler to use
  33982. var options = vm.$options;
  33983. var handlers = options.render && options.render._withStripped
  33984. ? getHandler
  33985. : hasHandler;
  33986. vm._renderProxy = new Proxy(vm, handlers);
  33987. } else {
  33988. vm._renderProxy = vm;
  33989. }
  33990. };
  33991. }
  33992. /* */
  33993. var VNode = function VNode (
  33994. tag,
  33995. data,
  33996. children,
  33997. text,
  33998. elm,
  33999. context,
  34000. componentOptions
  34001. ) {
  34002. this.tag = tag;
  34003. this.data = data;
  34004. this.children = children;
  34005. this.text = text;
  34006. this.elm = elm;
  34007. this.ns = undefined;
  34008. this.context = context;
  34009. this.functionalContext = undefined;
  34010. this.key = data && data.key;
  34011. this.componentOptions = componentOptions;
  34012. this.componentInstance = undefined;
  34013. this.parent = undefined;
  34014. this.raw = false;
  34015. this.isStatic = false;
  34016. this.isRootInsert = true;
  34017. this.isComment = false;
  34018. this.isCloned = false;
  34019. this.isOnce = false;
  34020. };
  34021. var prototypeAccessors = { child: {} };
  34022. // DEPRECATED: alias for componentInstance for backwards compat.
  34023. /* istanbul ignore next */
  34024. prototypeAccessors.child.get = function () {
  34025. return this.componentInstance
  34026. };
  34027. Object.defineProperties( VNode.prototype, prototypeAccessors );
  34028. var createEmptyVNode = function () {
  34029. var node = new VNode();
  34030. node.text = '';
  34031. node.isComment = true;
  34032. return node
  34033. };
  34034. function createTextVNode (val) {
  34035. return new VNode(undefined, undefined, undefined, String(val))
  34036. }
  34037. // optimized shallow clone
  34038. // used for static nodes and slot nodes because they may be reused across
  34039. // multiple renders, cloning them avoids errors when DOM manipulations rely
  34040. // on their elm reference.
  34041. function cloneVNode (vnode) {
  34042. var cloned = new VNode(
  34043. vnode.tag,
  34044. vnode.data,
  34045. vnode.children,
  34046. vnode.text,
  34047. vnode.elm,
  34048. vnode.context,
  34049. vnode.componentOptions
  34050. );
  34051. cloned.ns = vnode.ns;
  34052. cloned.isStatic = vnode.isStatic;
  34053. cloned.key = vnode.key;
  34054. cloned.isComment = vnode.isComment;
  34055. cloned.isCloned = true;
  34056. return cloned
  34057. }
  34058. function cloneVNodes (vnodes) {
  34059. var len = vnodes.length;
  34060. var res = new Array(len);
  34061. for (var i = 0; i < len; i++) {
  34062. res[i] = cloneVNode(vnodes[i]);
  34063. }
  34064. return res
  34065. }
  34066. /* */
  34067. var normalizeEvent = cached(function (name) {
  34068. var passive = name.charAt(0) === '&';
  34069. name = passive ? name.slice(1) : name;
  34070. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  34071. name = once$$1 ? name.slice(1) : name;
  34072. var capture = name.charAt(0) === '!';
  34073. name = capture ? name.slice(1) : name;
  34074. return {
  34075. name: name,
  34076. once: once$$1,
  34077. capture: capture,
  34078. passive: passive
  34079. }
  34080. });
  34081. function createFnInvoker (fns) {
  34082. function invoker () {
  34083. var arguments$1 = arguments;
  34084. var fns = invoker.fns;
  34085. if (Array.isArray(fns)) {
  34086. for (var i = 0; i < fns.length; i++) {
  34087. fns[i].apply(null, arguments$1);
  34088. }
  34089. } else {
  34090. // return handler return value for single handlers
  34091. return fns.apply(null, arguments)
  34092. }
  34093. }
  34094. invoker.fns = fns;
  34095. return invoker
  34096. }
  34097. function updateListeners (
  34098. on,
  34099. oldOn,
  34100. add,
  34101. remove$$1,
  34102. vm
  34103. ) {
  34104. var name, cur, old, event;
  34105. for (name in on) {
  34106. cur = on[name];
  34107. old = oldOn[name];
  34108. event = normalizeEvent(name);
  34109. if (isUndef(cur)) {
  34110. "development" !== 'production' && warn(
  34111. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  34112. vm
  34113. );
  34114. } else if (isUndef(old)) {
  34115. if (isUndef(cur.fns)) {
  34116. cur = on[name] = createFnInvoker(cur);
  34117. }
  34118. add(event.name, cur, event.once, event.capture, event.passive);
  34119. } else if (cur !== old) {
  34120. old.fns = cur;
  34121. on[name] = old;
  34122. }
  34123. }
  34124. for (name in oldOn) {
  34125. if (isUndef(on[name])) {
  34126. event = normalizeEvent(name);
  34127. remove$$1(event.name, oldOn[name], event.capture);
  34128. }
  34129. }
  34130. }
  34131. /* */
  34132. function mergeVNodeHook (def, hookKey, hook) {
  34133. var invoker;
  34134. var oldHook = def[hookKey];
  34135. function wrappedHook () {
  34136. hook.apply(this, arguments);
  34137. // important: remove merged hook to ensure it's called only once
  34138. // and prevent memory leak
  34139. remove(invoker.fns, wrappedHook);
  34140. }
  34141. if (isUndef(oldHook)) {
  34142. // no existing hook
  34143. invoker = createFnInvoker([wrappedHook]);
  34144. } else {
  34145. /* istanbul ignore if */
  34146. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  34147. // already a merged invoker
  34148. invoker = oldHook;
  34149. invoker.fns.push(wrappedHook);
  34150. } else {
  34151. // existing plain hook
  34152. invoker = createFnInvoker([oldHook, wrappedHook]);
  34153. }
  34154. }
  34155. invoker.merged = true;
  34156. def[hookKey] = invoker;
  34157. }
  34158. /* */
  34159. function extractPropsFromVNodeData (
  34160. data,
  34161. Ctor,
  34162. tag
  34163. ) {
  34164. // we are only extracting raw values here.
  34165. // validation and default values are handled in the child
  34166. // component itself.
  34167. var propOptions = Ctor.options.props;
  34168. if (isUndef(propOptions)) {
  34169. return
  34170. }
  34171. var res = {};
  34172. var attrs = data.attrs;
  34173. var props = data.props;
  34174. if (isDef(attrs) || isDef(props)) {
  34175. for (var key in propOptions) {
  34176. var altKey = hyphenate(key);
  34177. if (true) {
  34178. var keyInLowerCase = key.toLowerCase();
  34179. if (
  34180. key !== keyInLowerCase &&
  34181. attrs && hasOwn(attrs, keyInLowerCase)
  34182. ) {
  34183. tip(
  34184. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  34185. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  34186. " \"" + key + "\". " +
  34187. "Note that HTML attributes are case-insensitive and camelCased " +
  34188. "props need to use their kebab-case equivalents when using in-DOM " +
  34189. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  34190. );
  34191. }
  34192. }
  34193. checkProp(res, props, key, altKey, true) ||
  34194. checkProp(res, attrs, key, altKey, false);
  34195. }
  34196. }
  34197. return res
  34198. }
  34199. function checkProp (
  34200. res,
  34201. hash,
  34202. key,
  34203. altKey,
  34204. preserve
  34205. ) {
  34206. if (isDef(hash)) {
  34207. if (hasOwn(hash, key)) {
  34208. res[key] = hash[key];
  34209. if (!preserve) {
  34210. delete hash[key];
  34211. }
  34212. return true
  34213. } else if (hasOwn(hash, altKey)) {
  34214. res[key] = hash[altKey];
  34215. if (!preserve) {
  34216. delete hash[altKey];
  34217. }
  34218. return true
  34219. }
  34220. }
  34221. return false
  34222. }
  34223. /* */
  34224. // The template compiler attempts to minimize the need for normalization by
  34225. // statically analyzing the template at compile time.
  34226. //
  34227. // For plain HTML markup, normalization can be completely skipped because the
  34228. // generated render function is guaranteed to return Array<VNode>. There are
  34229. // two cases where extra normalization is needed:
  34230. // 1. When the children contains components - because a functional component
  34231. // may return an Array instead of a single root. In this case, just a simple
  34232. // normalization is needed - if any child is an Array, we flatten the whole
  34233. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  34234. // because functional components already normalize their own children.
  34235. function simpleNormalizeChildren (children) {
  34236. for (var i = 0; i < children.length; i++) {
  34237. if (Array.isArray(children[i])) {
  34238. return Array.prototype.concat.apply([], children)
  34239. }
  34240. }
  34241. return children
  34242. }
  34243. // 2. When the children contains constructs that always generated nested Arrays,
  34244. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  34245. // with hand-written render functions / JSX. In such cases a full normalization
  34246. // is needed to cater to all possible types of children values.
  34247. function normalizeChildren (children) {
  34248. return isPrimitive(children)
  34249. ? [createTextVNode(children)]
  34250. : Array.isArray(children)
  34251. ? normalizeArrayChildren(children)
  34252. : undefined
  34253. }
  34254. function isTextNode (node) {
  34255. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  34256. }
  34257. function normalizeArrayChildren (children, nestedIndex) {
  34258. var res = [];
  34259. var i, c, last;
  34260. for (i = 0; i < children.length; i++) {
  34261. c = children[i];
  34262. if (isUndef(c) || typeof c === 'boolean') { continue }
  34263. last = res[res.length - 1];
  34264. // nested
  34265. if (Array.isArray(c)) {
  34266. res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
  34267. } else if (isPrimitive(c)) {
  34268. if (isTextNode(last)) {
  34269. // merge adjacent text nodes
  34270. // this is necessary for SSR hydration because text nodes are
  34271. // essentially merged when rendered to HTML strings
  34272. (last).text += String(c);
  34273. } else if (c !== '') {
  34274. // convert primitive to vnode
  34275. res.push(createTextVNode(c));
  34276. }
  34277. } else {
  34278. if (isTextNode(c) && isTextNode(last)) {
  34279. // merge adjacent text nodes
  34280. res[res.length - 1] = createTextVNode(last.text + c.text);
  34281. } else {
  34282. // default key for nested array children (likely generated by v-for)
  34283. if (isTrue(children._isVList) &&
  34284. isDef(c.tag) &&
  34285. isUndef(c.key) &&
  34286. isDef(nestedIndex)) {
  34287. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  34288. }
  34289. res.push(c);
  34290. }
  34291. }
  34292. }
  34293. return res
  34294. }
  34295. /* */
  34296. function ensureCtor (comp, base) {
  34297. return isObject(comp)
  34298. ? base.extend(comp)
  34299. : comp
  34300. }
  34301. function resolveAsyncComponent (
  34302. factory,
  34303. baseCtor,
  34304. context
  34305. ) {
  34306. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  34307. return factory.errorComp
  34308. }
  34309. if (isDef(factory.resolved)) {
  34310. return factory.resolved
  34311. }
  34312. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  34313. return factory.loadingComp
  34314. }
  34315. if (isDef(factory.contexts)) {
  34316. // already pending
  34317. factory.contexts.push(context);
  34318. } else {
  34319. var contexts = factory.contexts = [context];
  34320. var sync = true;
  34321. var forceRender = function () {
  34322. for (var i = 0, l = contexts.length; i < l; i++) {
  34323. contexts[i].$forceUpdate();
  34324. }
  34325. };
  34326. var resolve = once(function (res) {
  34327. // cache resolved
  34328. factory.resolved = ensureCtor(res, baseCtor);
  34329. // invoke callbacks only if this is not a synchronous resolve
  34330. // (async resolves are shimmed as synchronous during SSR)
  34331. if (!sync) {
  34332. forceRender();
  34333. }
  34334. });
  34335. var reject = once(function (reason) {
  34336. "development" !== 'production' && warn(
  34337. "Failed to resolve async component: " + (String(factory)) +
  34338. (reason ? ("\nReason: " + reason) : '')
  34339. );
  34340. if (isDef(factory.errorComp)) {
  34341. factory.error = true;
  34342. forceRender();
  34343. }
  34344. });
  34345. var res = factory(resolve, reject);
  34346. if (isObject(res)) {
  34347. if (typeof res.then === 'function') {
  34348. // () => Promise
  34349. if (isUndef(factory.resolved)) {
  34350. res.then(resolve, reject);
  34351. }
  34352. } else if (isDef(res.component) && typeof res.component.then === 'function') {
  34353. res.component.then(resolve, reject);
  34354. if (isDef(res.error)) {
  34355. factory.errorComp = ensureCtor(res.error, baseCtor);
  34356. }
  34357. if (isDef(res.loading)) {
  34358. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  34359. if (res.delay === 0) {
  34360. factory.loading = true;
  34361. } else {
  34362. setTimeout(function () {
  34363. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  34364. factory.loading = true;
  34365. forceRender();
  34366. }
  34367. }, res.delay || 200);
  34368. }
  34369. }
  34370. if (isDef(res.timeout)) {
  34371. setTimeout(function () {
  34372. if (isUndef(factory.resolved)) {
  34373. reject(
  34374. true
  34375. ? ("timeout (" + (res.timeout) + "ms)")
  34376. : null
  34377. );
  34378. }
  34379. }, res.timeout);
  34380. }
  34381. }
  34382. }
  34383. sync = false;
  34384. // return in case resolved synchronously
  34385. return factory.loading
  34386. ? factory.loadingComp
  34387. : factory.resolved
  34388. }
  34389. }
  34390. /* */
  34391. function getFirstComponentChild (children) {
  34392. if (Array.isArray(children)) {
  34393. for (var i = 0; i < children.length; i++) {
  34394. var c = children[i];
  34395. if (isDef(c) && isDef(c.componentOptions)) {
  34396. return c
  34397. }
  34398. }
  34399. }
  34400. }
  34401. /* */
  34402. /* */
  34403. function initEvents (vm) {
  34404. vm._events = Object.create(null);
  34405. vm._hasHookEvent = false;
  34406. // init parent attached events
  34407. var listeners = vm.$options._parentListeners;
  34408. if (listeners) {
  34409. updateComponentListeners(vm, listeners);
  34410. }
  34411. }
  34412. var target;
  34413. function add (event, fn, once$$1) {
  34414. if (once$$1) {
  34415. target.$once(event, fn);
  34416. } else {
  34417. target.$on(event, fn);
  34418. }
  34419. }
  34420. function remove$1 (event, fn) {
  34421. target.$off(event, fn);
  34422. }
  34423. function updateComponentListeners (
  34424. vm,
  34425. listeners,
  34426. oldListeners
  34427. ) {
  34428. target = vm;
  34429. updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
  34430. }
  34431. function eventsMixin (Vue) {
  34432. var hookRE = /^hook:/;
  34433. Vue.prototype.$on = function (event, fn) {
  34434. var this$1 = this;
  34435. var vm = this;
  34436. if (Array.isArray(event)) {
  34437. for (var i = 0, l = event.length; i < l; i++) {
  34438. this$1.$on(event[i], fn);
  34439. }
  34440. } else {
  34441. (vm._events[event] || (vm._events[event] = [])).push(fn);
  34442. // optimize hook:event cost by using a boolean flag marked at registration
  34443. // instead of a hash lookup
  34444. if (hookRE.test(event)) {
  34445. vm._hasHookEvent = true;
  34446. }
  34447. }
  34448. return vm
  34449. };
  34450. Vue.prototype.$once = function (event, fn) {
  34451. var vm = this;
  34452. function on () {
  34453. vm.$off(event, on);
  34454. fn.apply(vm, arguments);
  34455. }
  34456. on.fn = fn;
  34457. vm.$on(event, on);
  34458. return vm
  34459. };
  34460. Vue.prototype.$off = function (event, fn) {
  34461. var this$1 = this;
  34462. var vm = this;
  34463. // all
  34464. if (!arguments.length) {
  34465. vm._events = Object.create(null);
  34466. return vm
  34467. }
  34468. // array of events
  34469. if (Array.isArray(event)) {
  34470. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  34471. this$1.$off(event[i$1], fn);
  34472. }
  34473. return vm
  34474. }
  34475. // specific event
  34476. var cbs = vm._events[event];
  34477. if (!cbs) {
  34478. return vm
  34479. }
  34480. if (arguments.length === 1) {
  34481. vm._events[event] = null;
  34482. return vm
  34483. }
  34484. // specific handler
  34485. var cb;
  34486. var i = cbs.length;
  34487. while (i--) {
  34488. cb = cbs[i];
  34489. if (cb === fn || cb.fn === fn) {
  34490. cbs.splice(i, 1);
  34491. break
  34492. }
  34493. }
  34494. return vm
  34495. };
  34496. Vue.prototype.$emit = function (event) {
  34497. var vm = this;
  34498. if (true) {
  34499. var lowerCaseEvent = event.toLowerCase();
  34500. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  34501. tip(
  34502. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  34503. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  34504. "Note that HTML attributes are case-insensitive and you cannot use " +
  34505. "v-on to listen to camelCase events when using in-DOM templates. " +
  34506. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  34507. );
  34508. }
  34509. }
  34510. var cbs = vm._events[event];
  34511. if (cbs) {
  34512. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  34513. var args = toArray(arguments, 1);
  34514. for (var i = 0, l = cbs.length; i < l; i++) {
  34515. cbs[i].apply(vm, args);
  34516. }
  34517. }
  34518. return vm
  34519. };
  34520. }
  34521. /* */
  34522. /**
  34523. * Runtime helper for resolving raw children VNodes into a slot object.
  34524. */
  34525. function resolveSlots (
  34526. children,
  34527. context
  34528. ) {
  34529. var slots = {};
  34530. if (!children) {
  34531. return slots
  34532. }
  34533. var defaultSlot = [];
  34534. for (var i = 0, l = children.length; i < l; i++) {
  34535. var child = children[i];
  34536. // named slots should only be respected if the vnode was rendered in the
  34537. // same context.
  34538. if ((child.context === context || child.functionalContext === context) &&
  34539. child.data && child.data.slot != null
  34540. ) {
  34541. var name = child.data.slot;
  34542. var slot = (slots[name] || (slots[name] = []));
  34543. if (child.tag === 'template') {
  34544. slot.push.apply(slot, child.children);
  34545. } else {
  34546. slot.push(child);
  34547. }
  34548. } else {
  34549. defaultSlot.push(child);
  34550. }
  34551. }
  34552. // ignore whitespace
  34553. if (!defaultSlot.every(isWhitespace)) {
  34554. slots.default = defaultSlot;
  34555. }
  34556. return slots
  34557. }
  34558. function isWhitespace (node) {
  34559. return node.isComment || node.text === ' '
  34560. }
  34561. function resolveScopedSlots (
  34562. fns, // see flow/vnode
  34563. res
  34564. ) {
  34565. res = res || {};
  34566. for (var i = 0; i < fns.length; i++) {
  34567. if (Array.isArray(fns[i])) {
  34568. resolveScopedSlots(fns[i], res);
  34569. } else {
  34570. res[fns[i].key] = fns[i].fn;
  34571. }
  34572. }
  34573. return res
  34574. }
  34575. /* */
  34576. var activeInstance = null;
  34577. function initLifecycle (vm) {
  34578. var options = vm.$options;
  34579. // locate first non-abstract parent
  34580. var parent = options.parent;
  34581. if (parent && !options.abstract) {
  34582. while (parent.$options.abstract && parent.$parent) {
  34583. parent = parent.$parent;
  34584. }
  34585. parent.$children.push(vm);
  34586. }
  34587. vm.$parent = parent;
  34588. vm.$root = parent ? parent.$root : vm;
  34589. vm.$children = [];
  34590. vm.$refs = {};
  34591. vm._watcher = null;
  34592. vm._inactive = null;
  34593. vm._directInactive = false;
  34594. vm._isMounted = false;
  34595. vm._isDestroyed = false;
  34596. vm._isBeingDestroyed = false;
  34597. }
  34598. function lifecycleMixin (Vue) {
  34599. Vue.prototype._update = function (vnode, hydrating) {
  34600. var vm = this;
  34601. if (vm._isMounted) {
  34602. callHook(vm, 'beforeUpdate');
  34603. }
  34604. var prevEl = vm.$el;
  34605. var prevVnode = vm._vnode;
  34606. var prevActiveInstance = activeInstance;
  34607. activeInstance = vm;
  34608. vm._vnode = vnode;
  34609. // Vue.prototype.__patch__ is injected in entry points
  34610. // based on the rendering backend used.
  34611. if (!prevVnode) {
  34612. // initial render
  34613. vm.$el = vm.__patch__(
  34614. vm.$el, vnode, hydrating, false /* removeOnly */,
  34615. vm.$options._parentElm,
  34616. vm.$options._refElm
  34617. );
  34618. } else {
  34619. // updates
  34620. vm.$el = vm.__patch__(prevVnode, vnode);
  34621. }
  34622. activeInstance = prevActiveInstance;
  34623. // update __vue__ reference
  34624. if (prevEl) {
  34625. prevEl.__vue__ = null;
  34626. }
  34627. if (vm.$el) {
  34628. vm.$el.__vue__ = vm;
  34629. }
  34630. // if parent is an HOC, update its $el as well
  34631. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  34632. vm.$parent.$el = vm.$el;
  34633. }
  34634. // updated hook is called by the scheduler to ensure that children are
  34635. // updated in a parent's updated hook.
  34636. };
  34637. Vue.prototype.$forceUpdate = function () {
  34638. var vm = this;
  34639. if (vm._watcher) {
  34640. vm._watcher.update();
  34641. }
  34642. };
  34643. Vue.prototype.$destroy = function () {
  34644. var vm = this;
  34645. if (vm._isBeingDestroyed) {
  34646. return
  34647. }
  34648. callHook(vm, 'beforeDestroy');
  34649. vm._isBeingDestroyed = true;
  34650. // remove self from parent
  34651. var parent = vm.$parent;
  34652. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  34653. remove(parent.$children, vm);
  34654. }
  34655. // teardown watchers
  34656. if (vm._watcher) {
  34657. vm._watcher.teardown();
  34658. }
  34659. var i = vm._watchers.length;
  34660. while (i--) {
  34661. vm._watchers[i].teardown();
  34662. }
  34663. // remove reference from data ob
  34664. // frozen object may not have observer.
  34665. if (vm._data.__ob__) {
  34666. vm._data.__ob__.vmCount--;
  34667. }
  34668. // call the last hook...
  34669. vm._isDestroyed = true;
  34670. // invoke destroy hooks on current rendered tree
  34671. vm.__patch__(vm._vnode, null);
  34672. // fire destroyed hook
  34673. callHook(vm, 'destroyed');
  34674. // turn off all instance listeners.
  34675. vm.$off();
  34676. // remove __vue__ reference
  34677. if (vm.$el) {
  34678. vm.$el.__vue__ = null;
  34679. }
  34680. // remove reference to DOM nodes (prevents leak)
  34681. vm.$options._parentElm = vm.$options._refElm = null;
  34682. };
  34683. }
  34684. function mountComponent (
  34685. vm,
  34686. el,
  34687. hydrating
  34688. ) {
  34689. vm.$el = el;
  34690. if (!vm.$options.render) {
  34691. vm.$options.render = createEmptyVNode;
  34692. if (true) {
  34693. /* istanbul ignore if */
  34694. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  34695. vm.$options.el || el) {
  34696. warn(
  34697. 'You are using the runtime-only build of Vue where the template ' +
  34698. 'compiler is not available. Either pre-compile the templates into ' +
  34699. 'render functions, or use the compiler-included build.',
  34700. vm
  34701. );
  34702. } else {
  34703. warn(
  34704. 'Failed to mount component: template or render function not defined.',
  34705. vm
  34706. );
  34707. }
  34708. }
  34709. }
  34710. callHook(vm, 'beforeMount');
  34711. var updateComponent;
  34712. /* istanbul ignore if */
  34713. if ("development" !== 'production' && config.performance && mark) {
  34714. updateComponent = function () {
  34715. var name = vm._name;
  34716. var id = vm._uid;
  34717. var startTag = "vue-perf-start:" + id;
  34718. var endTag = "vue-perf-end:" + id;
  34719. mark(startTag);
  34720. var vnode = vm._render();
  34721. mark(endTag);
  34722. measure((name + " render"), startTag, endTag);
  34723. mark(startTag);
  34724. vm._update(vnode, hydrating);
  34725. mark(endTag);
  34726. measure((name + " patch"), startTag, endTag);
  34727. };
  34728. } else {
  34729. updateComponent = function () {
  34730. vm._update(vm._render(), hydrating);
  34731. };
  34732. }
  34733. vm._watcher = new Watcher(vm, updateComponent, noop);
  34734. hydrating = false;
  34735. // manually mounted instance, call mounted on self
  34736. // mounted is called for render-created child components in its inserted hook
  34737. if (vm.$vnode == null) {
  34738. vm._isMounted = true;
  34739. callHook(vm, 'mounted');
  34740. }
  34741. return vm
  34742. }
  34743. function updateChildComponent (
  34744. vm,
  34745. propsData,
  34746. listeners,
  34747. parentVnode,
  34748. renderChildren
  34749. ) {
  34750. // determine whether component has slot children
  34751. // we need to do this before overwriting $options._renderChildren
  34752. var hasChildren = !!(
  34753. renderChildren || // has new static slots
  34754. vm.$options._renderChildren || // has old static slots
  34755. parentVnode.data.scopedSlots || // has new scoped slots
  34756. vm.$scopedSlots !== emptyObject // has old scoped slots
  34757. );
  34758. vm.$options._parentVnode = parentVnode;
  34759. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  34760. if (vm._vnode) { // update child tree's parent
  34761. vm._vnode.parent = parentVnode;
  34762. }
  34763. vm.$options._renderChildren = renderChildren;
  34764. // update props
  34765. if (propsData && vm.$options.props) {
  34766. observerState.shouldConvert = false;
  34767. if (true) {
  34768. observerState.isSettingProps = true;
  34769. }
  34770. var props = vm._props;
  34771. var propKeys = vm.$options._propKeys || [];
  34772. for (var i = 0; i < propKeys.length; i++) {
  34773. var key = propKeys[i];
  34774. props[key] = validateProp(key, vm.$options.props, propsData, vm);
  34775. }
  34776. observerState.shouldConvert = true;
  34777. if (true) {
  34778. observerState.isSettingProps = false;
  34779. }
  34780. // keep a copy of raw propsData
  34781. vm.$options.propsData = propsData;
  34782. }
  34783. // update listeners
  34784. if (listeners) {
  34785. var oldListeners = vm.$options._parentListeners;
  34786. vm.$options._parentListeners = listeners;
  34787. updateComponentListeners(vm, listeners, oldListeners);
  34788. }
  34789. // resolve slots + force update if has children
  34790. if (hasChildren) {
  34791. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  34792. vm.$forceUpdate();
  34793. }
  34794. }
  34795. function isInInactiveTree (vm) {
  34796. while (vm && (vm = vm.$parent)) {
  34797. if (vm._inactive) { return true }
  34798. }
  34799. return false
  34800. }
  34801. function activateChildComponent (vm, direct) {
  34802. if (direct) {
  34803. vm._directInactive = false;
  34804. if (isInInactiveTree(vm)) {
  34805. return
  34806. }
  34807. } else if (vm._directInactive) {
  34808. return
  34809. }
  34810. if (vm._inactive || vm._inactive === null) {
  34811. vm._inactive = false;
  34812. for (var i = 0; i < vm.$children.length; i++) {
  34813. activateChildComponent(vm.$children[i]);
  34814. }
  34815. callHook(vm, 'activated');
  34816. }
  34817. }
  34818. function deactivateChildComponent (vm, direct) {
  34819. if (direct) {
  34820. vm._directInactive = true;
  34821. if (isInInactiveTree(vm)) {
  34822. return
  34823. }
  34824. }
  34825. if (!vm._inactive) {
  34826. vm._inactive = true;
  34827. for (var i = 0; i < vm.$children.length; i++) {
  34828. deactivateChildComponent(vm.$children[i]);
  34829. }
  34830. callHook(vm, 'deactivated');
  34831. }
  34832. }
  34833. function callHook (vm, hook) {
  34834. var handlers = vm.$options[hook];
  34835. if (handlers) {
  34836. for (var i = 0, j = handlers.length; i < j; i++) {
  34837. try {
  34838. handlers[i].call(vm);
  34839. } catch (e) {
  34840. handleError(e, vm, (hook + " hook"));
  34841. }
  34842. }
  34843. }
  34844. if (vm._hasHookEvent) {
  34845. vm.$emit('hook:' + hook);
  34846. }
  34847. }
  34848. /* */
  34849. var MAX_UPDATE_COUNT = 100;
  34850. var queue = [];
  34851. var activatedChildren = [];
  34852. var has = {};
  34853. var circular = {};
  34854. var waiting = false;
  34855. var flushing = false;
  34856. var index = 0;
  34857. /**
  34858. * Reset the scheduler's state.
  34859. */
  34860. function resetSchedulerState () {
  34861. index = queue.length = activatedChildren.length = 0;
  34862. has = {};
  34863. if (true) {
  34864. circular = {};
  34865. }
  34866. waiting = flushing = false;
  34867. }
  34868. /**
  34869. * Flush both queues and run the watchers.
  34870. */
  34871. function flushSchedulerQueue () {
  34872. flushing = true;
  34873. var watcher, id;
  34874. // Sort queue before flush.
  34875. // This ensures that:
  34876. // 1. Components are updated from parent to child. (because parent is always
  34877. // created before the child)
  34878. // 2. A component's user watchers are run before its render watcher (because
  34879. // user watchers are created before the render watcher)
  34880. // 3. If a component is destroyed during a parent component's watcher run,
  34881. // its watchers can be skipped.
  34882. queue.sort(function (a, b) { return a.id - b.id; });
  34883. // do not cache length because more watchers might be pushed
  34884. // as we run existing watchers
  34885. for (index = 0; index < queue.length; index++) {
  34886. watcher = queue[index];
  34887. id = watcher.id;
  34888. has[id] = null;
  34889. watcher.run();
  34890. // in dev build, check and stop circular updates.
  34891. if ("development" !== 'production' && has[id] != null) {
  34892. circular[id] = (circular[id] || 0) + 1;
  34893. if (circular[id] > MAX_UPDATE_COUNT) {
  34894. warn(
  34895. 'You may have an infinite update loop ' + (
  34896. watcher.user
  34897. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  34898. : "in a component render function."
  34899. ),
  34900. watcher.vm
  34901. );
  34902. break
  34903. }
  34904. }
  34905. }
  34906. // keep copies of post queues before resetting state
  34907. var activatedQueue = activatedChildren.slice();
  34908. var updatedQueue = queue.slice();
  34909. resetSchedulerState();
  34910. // call component updated and activated hooks
  34911. callActivatedHooks(activatedQueue);
  34912. callUpdateHooks(updatedQueue);
  34913. // devtool hook
  34914. /* istanbul ignore if */
  34915. if (devtools && config.devtools) {
  34916. devtools.emit('flush');
  34917. }
  34918. }
  34919. function callUpdateHooks (queue) {
  34920. var i = queue.length;
  34921. while (i--) {
  34922. var watcher = queue[i];
  34923. var vm = watcher.vm;
  34924. if (vm._watcher === watcher && vm._isMounted) {
  34925. callHook(vm, 'updated');
  34926. }
  34927. }
  34928. }
  34929. /**
  34930. * Queue a kept-alive component that was activated during patch.
  34931. * The queue will be processed after the entire tree has been patched.
  34932. */
  34933. function queueActivatedComponent (vm) {
  34934. // setting _inactive to false here so that a render function can
  34935. // rely on checking whether it's in an inactive tree (e.g. router-view)
  34936. vm._inactive = false;
  34937. activatedChildren.push(vm);
  34938. }
  34939. function callActivatedHooks (queue) {
  34940. for (var i = 0; i < queue.length; i++) {
  34941. queue[i]._inactive = true;
  34942. activateChildComponent(queue[i], true /* true */);
  34943. }
  34944. }
  34945. /**
  34946. * Push a watcher into the watcher queue.
  34947. * Jobs with duplicate IDs will be skipped unless it's
  34948. * pushed when the queue is being flushed.
  34949. */
  34950. function queueWatcher (watcher) {
  34951. var id = watcher.id;
  34952. if (has[id] == null) {
  34953. has[id] = true;
  34954. if (!flushing) {
  34955. queue.push(watcher);
  34956. } else {
  34957. // if already flushing, splice the watcher based on its id
  34958. // if already past its id, it will be run next immediately.
  34959. var i = queue.length - 1;
  34960. while (i > index && queue[i].id > watcher.id) {
  34961. i--;
  34962. }
  34963. queue.splice(i + 1, 0, watcher);
  34964. }
  34965. // queue the flush
  34966. if (!waiting) {
  34967. waiting = true;
  34968. nextTick(flushSchedulerQueue);
  34969. }
  34970. }
  34971. }
  34972. /* */
  34973. var uid$2 = 0;
  34974. /**
  34975. * A watcher parses an expression, collects dependencies,
  34976. * and fires callback when the expression value changes.
  34977. * This is used for both the $watch() api and directives.
  34978. */
  34979. var Watcher = function Watcher (
  34980. vm,
  34981. expOrFn,
  34982. cb,
  34983. options
  34984. ) {
  34985. this.vm = vm;
  34986. vm._watchers.push(this);
  34987. // options
  34988. if (options) {
  34989. this.deep = !!options.deep;
  34990. this.user = !!options.user;
  34991. this.lazy = !!options.lazy;
  34992. this.sync = !!options.sync;
  34993. } else {
  34994. this.deep = this.user = this.lazy = this.sync = false;
  34995. }
  34996. this.cb = cb;
  34997. this.id = ++uid$2; // uid for batching
  34998. this.active = true;
  34999. this.dirty = this.lazy; // for lazy watchers
  35000. this.deps = [];
  35001. this.newDeps = [];
  35002. this.depIds = new _Set();
  35003. this.newDepIds = new _Set();
  35004. this.expression = true
  35005. ? expOrFn.toString()
  35006. : '';
  35007. // parse expression for getter
  35008. if (typeof expOrFn === 'function') {
  35009. this.getter = expOrFn;
  35010. } else {
  35011. this.getter = parsePath(expOrFn);
  35012. if (!this.getter) {
  35013. this.getter = function () {};
  35014. "development" !== 'production' && warn(
  35015. "Failed watching path: \"" + expOrFn + "\" " +
  35016. 'Watcher only accepts simple dot-delimited paths. ' +
  35017. 'For full control, use a function instead.',
  35018. vm
  35019. );
  35020. }
  35021. }
  35022. this.value = this.lazy
  35023. ? undefined
  35024. : this.get();
  35025. };
  35026. /**
  35027. * Evaluate the getter, and re-collect dependencies.
  35028. */
  35029. Watcher.prototype.get = function get () {
  35030. pushTarget(this);
  35031. var value;
  35032. var vm = this.vm;
  35033. if (this.user) {
  35034. try {
  35035. value = this.getter.call(vm, vm);
  35036. } catch (e) {
  35037. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  35038. }
  35039. } else {
  35040. value = this.getter.call(vm, vm);
  35041. }
  35042. // "touch" every property so they are all tracked as
  35043. // dependencies for deep watching
  35044. if (this.deep) {
  35045. traverse(value);
  35046. }
  35047. popTarget();
  35048. this.cleanupDeps();
  35049. return value
  35050. };
  35051. /**
  35052. * Add a dependency to this directive.
  35053. */
  35054. Watcher.prototype.addDep = function addDep (dep) {
  35055. var id = dep.id;
  35056. if (!this.newDepIds.has(id)) {
  35057. this.newDepIds.add(id);
  35058. this.newDeps.push(dep);
  35059. if (!this.depIds.has(id)) {
  35060. dep.addSub(this);
  35061. }
  35062. }
  35063. };
  35064. /**
  35065. * Clean up for dependency collection.
  35066. */
  35067. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  35068. var this$1 = this;
  35069. var i = this.deps.length;
  35070. while (i--) {
  35071. var dep = this$1.deps[i];
  35072. if (!this$1.newDepIds.has(dep.id)) {
  35073. dep.removeSub(this$1);
  35074. }
  35075. }
  35076. var tmp = this.depIds;
  35077. this.depIds = this.newDepIds;
  35078. this.newDepIds = tmp;
  35079. this.newDepIds.clear();
  35080. tmp = this.deps;
  35081. this.deps = this.newDeps;
  35082. this.newDeps = tmp;
  35083. this.newDeps.length = 0;
  35084. };
  35085. /**
  35086. * Subscriber interface.
  35087. * Will be called when a dependency changes.
  35088. */
  35089. Watcher.prototype.update = function update () {
  35090. /* istanbul ignore else */
  35091. if (this.lazy) {
  35092. this.dirty = true;
  35093. } else if (this.sync) {
  35094. this.run();
  35095. } else {
  35096. queueWatcher(this);
  35097. }
  35098. };
  35099. /**
  35100. * Scheduler job interface.
  35101. * Will be called by the scheduler.
  35102. */
  35103. Watcher.prototype.run = function run () {
  35104. if (this.active) {
  35105. var value = this.get();
  35106. if (
  35107. value !== this.value ||
  35108. // Deep watchers and watchers on Object/Arrays should fire even
  35109. // when the value is the same, because the value may
  35110. // have mutated.
  35111. isObject(value) ||
  35112. this.deep
  35113. ) {
  35114. // set new value
  35115. var oldValue = this.value;
  35116. this.value = value;
  35117. if (this.user) {
  35118. try {
  35119. this.cb.call(this.vm, value, oldValue);
  35120. } catch (e) {
  35121. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  35122. }
  35123. } else {
  35124. this.cb.call(this.vm, value, oldValue);
  35125. }
  35126. }
  35127. }
  35128. };
  35129. /**
  35130. * Evaluate the value of the watcher.
  35131. * This only gets called for lazy watchers.
  35132. */
  35133. Watcher.prototype.evaluate = function evaluate () {
  35134. this.value = this.get();
  35135. this.dirty = false;
  35136. };
  35137. /**
  35138. * Depend on all deps collected by this watcher.
  35139. */
  35140. Watcher.prototype.depend = function depend () {
  35141. var this$1 = this;
  35142. var i = this.deps.length;
  35143. while (i--) {
  35144. this$1.deps[i].depend();
  35145. }
  35146. };
  35147. /**
  35148. * Remove self from all dependencies' subscriber list.
  35149. */
  35150. Watcher.prototype.teardown = function teardown () {
  35151. var this$1 = this;
  35152. if (this.active) {
  35153. // remove self from vm's watcher list
  35154. // this is a somewhat expensive operation so we skip it
  35155. // if the vm is being destroyed.
  35156. if (!this.vm._isBeingDestroyed) {
  35157. remove(this.vm._watchers, this);
  35158. }
  35159. var i = this.deps.length;
  35160. while (i--) {
  35161. this$1.deps[i].removeSub(this$1);
  35162. }
  35163. this.active = false;
  35164. }
  35165. };
  35166. /**
  35167. * Recursively traverse an object to evoke all converted
  35168. * getters, so that every nested property inside the object
  35169. * is collected as a "deep" dependency.
  35170. */
  35171. var seenObjects = new _Set();
  35172. function traverse (val) {
  35173. seenObjects.clear();
  35174. _traverse(val, seenObjects);
  35175. }
  35176. function _traverse (val, seen) {
  35177. var i, keys;
  35178. var isA = Array.isArray(val);
  35179. if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
  35180. return
  35181. }
  35182. if (val.__ob__) {
  35183. var depId = val.__ob__.dep.id;
  35184. if (seen.has(depId)) {
  35185. return
  35186. }
  35187. seen.add(depId);
  35188. }
  35189. if (isA) {
  35190. i = val.length;
  35191. while (i--) { _traverse(val[i], seen); }
  35192. } else {
  35193. keys = Object.keys(val);
  35194. i = keys.length;
  35195. while (i--) { _traverse(val[keys[i]], seen); }
  35196. }
  35197. }
  35198. /* */
  35199. var sharedPropertyDefinition = {
  35200. enumerable: true,
  35201. configurable: true,
  35202. get: noop,
  35203. set: noop
  35204. };
  35205. function proxy (target, sourceKey, key) {
  35206. sharedPropertyDefinition.get = function proxyGetter () {
  35207. return this[sourceKey][key]
  35208. };
  35209. sharedPropertyDefinition.set = function proxySetter (val) {
  35210. this[sourceKey][key] = val;
  35211. };
  35212. Object.defineProperty(target, key, sharedPropertyDefinition);
  35213. }
  35214. function initState (vm) {
  35215. vm._watchers = [];
  35216. var opts = vm.$options;
  35217. if (opts.props) { initProps(vm, opts.props); }
  35218. if (opts.methods) { initMethods(vm, opts.methods); }
  35219. if (opts.data) {
  35220. initData(vm);
  35221. } else {
  35222. observe(vm._data = {}, true /* asRootData */);
  35223. }
  35224. if (opts.computed) { initComputed(vm, opts.computed); }
  35225. if (opts.watch) { initWatch(vm, opts.watch); }
  35226. }
  35227. var isReservedProp = {
  35228. key: 1,
  35229. ref: 1,
  35230. slot: 1
  35231. };
  35232. function initProps (vm, propsOptions) {
  35233. var propsData = vm.$options.propsData || {};
  35234. var props = vm._props = {};
  35235. // cache prop keys so that future props updates can iterate using Array
  35236. // instead of dynamic object key enumeration.
  35237. var keys = vm.$options._propKeys = [];
  35238. var isRoot = !vm.$parent;
  35239. // root instance props should be converted
  35240. observerState.shouldConvert = isRoot;
  35241. var loop = function ( key ) {
  35242. keys.push(key);
  35243. var value = validateProp(key, propsOptions, propsData, vm);
  35244. /* istanbul ignore else */
  35245. if (true) {
  35246. if (isReservedProp[key] || config.isReservedAttr(key)) {
  35247. warn(
  35248. ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
  35249. vm
  35250. );
  35251. }
  35252. defineReactive$$1(props, key, value, function () {
  35253. if (vm.$parent && !observerState.isSettingProps) {
  35254. warn(
  35255. "Avoid mutating a prop directly since the value will be " +
  35256. "overwritten whenever the parent component re-renders. " +
  35257. "Instead, use a data or computed property based on the prop's " +
  35258. "value. Prop being mutated: \"" + key + "\"",
  35259. vm
  35260. );
  35261. }
  35262. });
  35263. } else {
  35264. defineReactive$$1(props, key, value);
  35265. }
  35266. // static props are already proxied on the component's prototype
  35267. // during Vue.extend(). We only need to proxy props defined at
  35268. // instantiation here.
  35269. if (!(key in vm)) {
  35270. proxy(vm, "_props", key);
  35271. }
  35272. };
  35273. for (var key in propsOptions) loop( key );
  35274. observerState.shouldConvert = true;
  35275. }
  35276. function initData (vm) {
  35277. var data = vm.$options.data;
  35278. data = vm._data = typeof data === 'function'
  35279. ? getData(data, vm)
  35280. : data || {};
  35281. if (!isPlainObject(data)) {
  35282. data = {};
  35283. "development" !== 'production' && warn(
  35284. 'data functions should return an object:\n' +
  35285. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  35286. vm
  35287. );
  35288. }
  35289. // proxy data on instance
  35290. var keys = Object.keys(data);
  35291. var props = vm.$options.props;
  35292. var i = keys.length;
  35293. while (i--) {
  35294. if (props && hasOwn(props, keys[i])) {
  35295. "development" !== 'production' && warn(
  35296. "The data property \"" + (keys[i]) + "\" is already declared as a prop. " +
  35297. "Use prop default value instead.",
  35298. vm
  35299. );
  35300. } else if (!isReserved(keys[i])) {
  35301. proxy(vm, "_data", keys[i]);
  35302. }
  35303. }
  35304. // observe data
  35305. observe(data, true /* asRootData */);
  35306. }
  35307. function getData (data, vm) {
  35308. try {
  35309. return data.call(vm)
  35310. } catch (e) {
  35311. handleError(e, vm, "data()");
  35312. return {}
  35313. }
  35314. }
  35315. var computedWatcherOptions = { lazy: true };
  35316. function initComputed (vm, computed) {
  35317. var watchers = vm._computedWatchers = Object.create(null);
  35318. for (var key in computed) {
  35319. var userDef = computed[key];
  35320. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  35321. if (true) {
  35322. if (getter === undefined) {
  35323. warn(
  35324. ("No getter function has been defined for computed property \"" + key + "\"."),
  35325. vm
  35326. );
  35327. getter = noop;
  35328. }
  35329. }
  35330. // create internal watcher for the computed property.
  35331. watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions);
  35332. // component-defined computed properties are already defined on the
  35333. // component prototype. We only need to define computed properties defined
  35334. // at instantiation here.
  35335. if (!(key in vm)) {
  35336. defineComputed(vm, key, userDef);
  35337. } else if (true) {
  35338. if (key in vm.$data) {
  35339. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  35340. } else if (vm.$options.props && key in vm.$options.props) {
  35341. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  35342. }
  35343. }
  35344. }
  35345. }
  35346. function defineComputed (target, key, userDef) {
  35347. if (typeof userDef === 'function') {
  35348. sharedPropertyDefinition.get = createComputedGetter(key);
  35349. sharedPropertyDefinition.set = noop;
  35350. } else {
  35351. sharedPropertyDefinition.get = userDef.get
  35352. ? userDef.cache !== false
  35353. ? createComputedGetter(key)
  35354. : userDef.get
  35355. : noop;
  35356. sharedPropertyDefinition.set = userDef.set
  35357. ? userDef.set
  35358. : noop;
  35359. }
  35360. Object.defineProperty(target, key, sharedPropertyDefinition);
  35361. }
  35362. function createComputedGetter (key) {
  35363. return function computedGetter () {
  35364. var watcher = this._computedWatchers && this._computedWatchers[key];
  35365. if (watcher) {
  35366. if (watcher.dirty) {
  35367. watcher.evaluate();
  35368. }
  35369. if (Dep.target) {
  35370. watcher.depend();
  35371. }
  35372. return watcher.value
  35373. }
  35374. }
  35375. }
  35376. function initMethods (vm, methods) {
  35377. var props = vm.$options.props;
  35378. for (var key in methods) {
  35379. vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
  35380. if (true) {
  35381. if (methods[key] == null) {
  35382. warn(
  35383. "method \"" + key + "\" has an undefined value in the component definition. " +
  35384. "Did you reference the function correctly?",
  35385. vm
  35386. );
  35387. }
  35388. if (props && hasOwn(props, key)) {
  35389. warn(
  35390. ("method \"" + key + "\" has already been defined as a prop."),
  35391. vm
  35392. );
  35393. }
  35394. }
  35395. }
  35396. }
  35397. function initWatch (vm, watch) {
  35398. for (var key in watch) {
  35399. var handler = watch[key];
  35400. if (Array.isArray(handler)) {
  35401. for (var i = 0; i < handler.length; i++) {
  35402. createWatcher(vm, key, handler[i]);
  35403. }
  35404. } else {
  35405. createWatcher(vm, key, handler);
  35406. }
  35407. }
  35408. }
  35409. function createWatcher (vm, key, handler) {
  35410. var options;
  35411. if (isPlainObject(handler)) {
  35412. options = handler;
  35413. handler = handler.handler;
  35414. }
  35415. if (typeof handler === 'string') {
  35416. handler = vm[handler];
  35417. }
  35418. vm.$watch(key, handler, options);
  35419. }
  35420. function stateMixin (Vue) {
  35421. // flow somehow has problems with directly declared definition object
  35422. // when using Object.defineProperty, so we have to procedurally build up
  35423. // the object here.
  35424. var dataDef = {};
  35425. dataDef.get = function () { return this._data };
  35426. var propsDef = {};
  35427. propsDef.get = function () { return this._props };
  35428. if (true) {
  35429. dataDef.set = function (newData) {
  35430. warn(
  35431. 'Avoid replacing instance root $data. ' +
  35432. 'Use nested data properties instead.',
  35433. this
  35434. );
  35435. };
  35436. propsDef.set = function () {
  35437. warn("$props is readonly.", this);
  35438. };
  35439. }
  35440. Object.defineProperty(Vue.prototype, '$data', dataDef);
  35441. Object.defineProperty(Vue.prototype, '$props', propsDef);
  35442. Vue.prototype.$set = set;
  35443. Vue.prototype.$delete = del;
  35444. Vue.prototype.$watch = function (
  35445. expOrFn,
  35446. cb,
  35447. options
  35448. ) {
  35449. var vm = this;
  35450. options = options || {};
  35451. options.user = true;
  35452. var watcher = new Watcher(vm, expOrFn, cb, options);
  35453. if (options.immediate) {
  35454. cb.call(vm, watcher.value);
  35455. }
  35456. return function unwatchFn () {
  35457. watcher.teardown();
  35458. }
  35459. };
  35460. }
  35461. /* */
  35462. function initProvide (vm) {
  35463. var provide = vm.$options.provide;
  35464. if (provide) {
  35465. vm._provided = typeof provide === 'function'
  35466. ? provide.call(vm)
  35467. : provide;
  35468. }
  35469. }
  35470. function initInjections (vm) {
  35471. var result = resolveInject(vm.$options.inject, vm);
  35472. if (result) {
  35473. Object.keys(result).forEach(function (key) {
  35474. /* istanbul ignore else */
  35475. if (true) {
  35476. defineReactive$$1(vm, key, result[key], function () {
  35477. warn(
  35478. "Avoid mutating an injected value directly since the changes will be " +
  35479. "overwritten whenever the provided component re-renders. " +
  35480. "injection being mutated: \"" + key + "\"",
  35481. vm
  35482. );
  35483. });
  35484. } else {
  35485. defineReactive$$1(vm, key, result[key]);
  35486. }
  35487. });
  35488. }
  35489. }
  35490. function resolveInject (inject, vm) {
  35491. if (inject) {
  35492. // inject is :any because flow is not smart enough to figure out cached
  35493. // isArray here
  35494. var isArray = Array.isArray(inject);
  35495. var result = Object.create(null);
  35496. var keys = isArray
  35497. ? inject
  35498. : hasSymbol
  35499. ? Reflect.ownKeys(inject)
  35500. : Object.keys(inject);
  35501. for (var i = 0; i < keys.length; i++) {
  35502. var key = keys[i];
  35503. var provideKey = isArray ? key : inject[key];
  35504. var source = vm;
  35505. while (source) {
  35506. if (source._provided && provideKey in source._provided) {
  35507. result[key] = source._provided[provideKey];
  35508. break
  35509. }
  35510. source = source.$parent;
  35511. }
  35512. }
  35513. return result
  35514. }
  35515. }
  35516. /* */
  35517. function createFunctionalComponent (
  35518. Ctor,
  35519. propsData,
  35520. data,
  35521. context,
  35522. children
  35523. ) {
  35524. var props = {};
  35525. var propOptions = Ctor.options.props;
  35526. if (isDef(propOptions)) {
  35527. for (var key in propOptions) {
  35528. props[key] = validateProp(key, propOptions, propsData || {});
  35529. }
  35530. } else {
  35531. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  35532. if (isDef(data.props)) { mergeProps(props, data.props); }
  35533. }
  35534. // ensure the createElement function in functional components
  35535. // gets a unique context - this is necessary for correct named slot check
  35536. var _context = Object.create(context);
  35537. var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
  35538. var vnode = Ctor.options.render.call(null, h, {
  35539. data: data,
  35540. props: props,
  35541. children: children,
  35542. parent: context,
  35543. listeners: data.on || {},
  35544. injections: resolveInject(Ctor.options.inject, context),
  35545. slots: function () { return resolveSlots(children, context); }
  35546. });
  35547. if (vnode instanceof VNode) {
  35548. vnode.functionalContext = context;
  35549. vnode.functionalOptions = Ctor.options;
  35550. if (data.slot) {
  35551. (vnode.data || (vnode.data = {})).slot = data.slot;
  35552. }
  35553. }
  35554. return vnode
  35555. }
  35556. function mergeProps (to, from) {
  35557. for (var key in from) {
  35558. to[camelize(key)] = from[key];
  35559. }
  35560. }
  35561. /* */
  35562. // hooks to be invoked on component VNodes during patch
  35563. var componentVNodeHooks = {
  35564. init: function init (
  35565. vnode,
  35566. hydrating,
  35567. parentElm,
  35568. refElm
  35569. ) {
  35570. if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
  35571. var child = vnode.componentInstance = createComponentInstanceForVnode(
  35572. vnode,
  35573. activeInstance,
  35574. parentElm,
  35575. refElm
  35576. );
  35577. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  35578. } else if (vnode.data.keepAlive) {
  35579. // kept-alive components, treat as a patch
  35580. var mountedNode = vnode; // work around flow
  35581. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  35582. }
  35583. },
  35584. prepatch: function prepatch (oldVnode, vnode) {
  35585. var options = vnode.componentOptions;
  35586. var child = vnode.componentInstance = oldVnode.componentInstance;
  35587. updateChildComponent(
  35588. child,
  35589. options.propsData, // updated props
  35590. options.listeners, // updated listeners
  35591. vnode, // new parent vnode
  35592. options.children // new children
  35593. );
  35594. },
  35595. insert: function insert (vnode) {
  35596. var context = vnode.context;
  35597. var componentInstance = vnode.componentInstance;
  35598. if (!componentInstance._isMounted) {
  35599. componentInstance._isMounted = true;
  35600. callHook(componentInstance, 'mounted');
  35601. }
  35602. if (vnode.data.keepAlive) {
  35603. if (context._isMounted) {
  35604. // vue-router#1212
  35605. // During updates, a kept-alive component's child components may
  35606. // change, so directly walking the tree here may call activated hooks
  35607. // on incorrect children. Instead we push them into a queue which will
  35608. // be processed after the whole patch process ended.
  35609. queueActivatedComponent(componentInstance);
  35610. } else {
  35611. activateChildComponent(componentInstance, true /* direct */);
  35612. }
  35613. }
  35614. },
  35615. destroy: function destroy (vnode) {
  35616. var componentInstance = vnode.componentInstance;
  35617. if (!componentInstance._isDestroyed) {
  35618. if (!vnode.data.keepAlive) {
  35619. componentInstance.$destroy();
  35620. } else {
  35621. deactivateChildComponent(componentInstance, true /* direct */);
  35622. }
  35623. }
  35624. }
  35625. };
  35626. var hooksToMerge = Object.keys(componentVNodeHooks);
  35627. function createComponent (
  35628. Ctor,
  35629. data,
  35630. context,
  35631. children,
  35632. tag
  35633. ) {
  35634. if (isUndef(Ctor)) {
  35635. return
  35636. }
  35637. var baseCtor = context.$options._base;
  35638. // plain options object: turn it into a constructor
  35639. if (isObject(Ctor)) {
  35640. Ctor = baseCtor.extend(Ctor);
  35641. }
  35642. // if at this stage it's not a constructor or an async component factory,
  35643. // reject.
  35644. if (typeof Ctor !== 'function') {
  35645. if (true) {
  35646. warn(("Invalid Component definition: " + (String(Ctor))), context);
  35647. }
  35648. return
  35649. }
  35650. // async component
  35651. if (isUndef(Ctor.cid)) {
  35652. Ctor = resolveAsyncComponent(Ctor, baseCtor, context);
  35653. if (Ctor === undefined) {
  35654. // return nothing if this is indeed an async component
  35655. // wait for the callback to trigger parent update.
  35656. return
  35657. }
  35658. }
  35659. // resolve constructor options in case global mixins are applied after
  35660. // component constructor creation
  35661. resolveConstructorOptions(Ctor);
  35662. data = data || {};
  35663. // transform component v-model data into props & events
  35664. if (isDef(data.model)) {
  35665. transformModel(Ctor.options, data);
  35666. }
  35667. // extract props
  35668. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  35669. // functional component
  35670. if (isTrue(Ctor.options.functional)) {
  35671. return createFunctionalComponent(Ctor, propsData, data, context, children)
  35672. }
  35673. // extract listeners, since these needs to be treated as
  35674. // child component listeners instead of DOM listeners
  35675. var listeners = data.on;
  35676. // replace with listeners with .native modifier
  35677. data.on = data.nativeOn;
  35678. if (isTrue(Ctor.options.abstract)) {
  35679. // abstract components do not keep anything
  35680. // other than props & listeners
  35681. data = {};
  35682. }
  35683. // merge component management hooks onto the placeholder node
  35684. mergeHooks(data);
  35685. // return a placeholder vnode
  35686. var name = Ctor.options.name || tag;
  35687. var vnode = new VNode(
  35688. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  35689. data, undefined, undefined, undefined, context,
  35690. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }
  35691. );
  35692. return vnode
  35693. }
  35694. function createComponentInstanceForVnode (
  35695. vnode, // we know it's MountedComponentVNode but flow doesn't
  35696. parent, // activeInstance in lifecycle state
  35697. parentElm,
  35698. refElm
  35699. ) {
  35700. var vnodeComponentOptions = vnode.componentOptions;
  35701. var options = {
  35702. _isComponent: true,
  35703. parent: parent,
  35704. propsData: vnodeComponentOptions.propsData,
  35705. _componentTag: vnodeComponentOptions.tag,
  35706. _parentVnode: vnode,
  35707. _parentListeners: vnodeComponentOptions.listeners,
  35708. _renderChildren: vnodeComponentOptions.children,
  35709. _parentElm: parentElm || null,
  35710. _refElm: refElm || null
  35711. };
  35712. // check inline-template render functions
  35713. var inlineTemplate = vnode.data.inlineTemplate;
  35714. if (isDef(inlineTemplate)) {
  35715. options.render = inlineTemplate.render;
  35716. options.staticRenderFns = inlineTemplate.staticRenderFns;
  35717. }
  35718. return new vnodeComponentOptions.Ctor(options)
  35719. }
  35720. function mergeHooks (data) {
  35721. if (!data.hook) {
  35722. data.hook = {};
  35723. }
  35724. for (var i = 0; i < hooksToMerge.length; i++) {
  35725. var key = hooksToMerge[i];
  35726. var fromParent = data.hook[key];
  35727. var ours = componentVNodeHooks[key];
  35728. data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
  35729. }
  35730. }
  35731. function mergeHook$1 (one, two) {
  35732. return function (a, b, c, d) {
  35733. one(a, b, c, d);
  35734. two(a, b, c, d);
  35735. }
  35736. }
  35737. // transform component v-model info (value and callback) into
  35738. // prop and event handler respectively.
  35739. function transformModel (options, data) {
  35740. var prop = (options.model && options.model.prop) || 'value';
  35741. var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
  35742. var on = data.on || (data.on = {});
  35743. if (isDef(on[event])) {
  35744. on[event] = [data.model.callback].concat(on[event]);
  35745. } else {
  35746. on[event] = data.model.callback;
  35747. }
  35748. }
  35749. /* */
  35750. var SIMPLE_NORMALIZE = 1;
  35751. var ALWAYS_NORMALIZE = 2;
  35752. // wrapper function for providing a more flexible interface
  35753. // without getting yelled at by flow
  35754. function createElement (
  35755. context,
  35756. tag,
  35757. data,
  35758. children,
  35759. normalizationType,
  35760. alwaysNormalize
  35761. ) {
  35762. if (Array.isArray(data) || isPrimitive(data)) {
  35763. normalizationType = children;
  35764. children = data;
  35765. data = undefined;
  35766. }
  35767. if (isTrue(alwaysNormalize)) {
  35768. normalizationType = ALWAYS_NORMALIZE;
  35769. }
  35770. return _createElement(context, tag, data, children, normalizationType)
  35771. }
  35772. function _createElement (
  35773. context,
  35774. tag,
  35775. data,
  35776. children,
  35777. normalizationType
  35778. ) {
  35779. if (isDef(data) && isDef((data).__ob__)) {
  35780. "development" !== 'production' && warn(
  35781. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  35782. 'Always create fresh vnode data objects in each render!',
  35783. context
  35784. );
  35785. return createEmptyVNode()
  35786. }
  35787. if (!tag) {
  35788. // in case of component :is set to falsy value
  35789. return createEmptyVNode()
  35790. }
  35791. // support single function children as default scoped slot
  35792. if (Array.isArray(children) &&
  35793. typeof children[0] === 'function'
  35794. ) {
  35795. data = data || {};
  35796. data.scopedSlots = { default: children[0] };
  35797. children.length = 0;
  35798. }
  35799. if (normalizationType === ALWAYS_NORMALIZE) {
  35800. children = normalizeChildren(children);
  35801. } else if (normalizationType === SIMPLE_NORMALIZE) {
  35802. children = simpleNormalizeChildren(children);
  35803. }
  35804. var vnode, ns;
  35805. if (typeof tag === 'string') {
  35806. var Ctor;
  35807. ns = config.getTagNamespace(tag);
  35808. if (config.isReservedTag(tag)) {
  35809. // platform built-in elements
  35810. vnode = new VNode(
  35811. config.parsePlatformTagName(tag), data, children,
  35812. undefined, undefined, context
  35813. );
  35814. } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  35815. // component
  35816. vnode = createComponent(Ctor, data, context, children, tag);
  35817. } else {
  35818. // unknown or unlisted namespaced elements
  35819. // check at runtime because it may get assigned a namespace when its
  35820. // parent normalizes children
  35821. vnode = new VNode(
  35822. tag, data, children,
  35823. undefined, undefined, context
  35824. );
  35825. }
  35826. } else {
  35827. // direct component options / constructor
  35828. vnode = createComponent(tag, data, context, children);
  35829. }
  35830. if (isDef(vnode)) {
  35831. if (ns) { applyNS(vnode, ns); }
  35832. return vnode
  35833. } else {
  35834. return createEmptyVNode()
  35835. }
  35836. }
  35837. function applyNS (vnode, ns) {
  35838. vnode.ns = ns;
  35839. if (vnode.tag === 'foreignObject') {
  35840. // use default namespace inside foreignObject
  35841. return
  35842. }
  35843. if (isDef(vnode.children)) {
  35844. for (var i = 0, l = vnode.children.length; i < l; i++) {
  35845. var child = vnode.children[i];
  35846. if (isDef(child.tag) && isUndef(child.ns)) {
  35847. applyNS(child, ns);
  35848. }
  35849. }
  35850. }
  35851. }
  35852. /* */
  35853. /**
  35854. * Runtime helper for rendering v-for lists.
  35855. */
  35856. function renderList (
  35857. val,
  35858. render
  35859. ) {
  35860. var ret, i, l, keys, key;
  35861. if (Array.isArray(val) || typeof val === 'string') {
  35862. ret = new Array(val.length);
  35863. for (i = 0, l = val.length; i < l; i++) {
  35864. ret[i] = render(val[i], i);
  35865. }
  35866. } else if (typeof val === 'number') {
  35867. ret = new Array(val);
  35868. for (i = 0; i < val; i++) {
  35869. ret[i] = render(i + 1, i);
  35870. }
  35871. } else if (isObject(val)) {
  35872. keys = Object.keys(val);
  35873. ret = new Array(keys.length);
  35874. for (i = 0, l = keys.length; i < l; i++) {
  35875. key = keys[i];
  35876. ret[i] = render(val[key], key, i);
  35877. }
  35878. }
  35879. if (isDef(ret)) {
  35880. (ret)._isVList = true;
  35881. }
  35882. return ret
  35883. }
  35884. /* */
  35885. /**
  35886. * Runtime helper for rendering <slot>
  35887. */
  35888. function renderSlot (
  35889. name,
  35890. fallback,
  35891. props,
  35892. bindObject
  35893. ) {
  35894. var scopedSlotFn = this.$scopedSlots[name];
  35895. if (scopedSlotFn) { // scoped slot
  35896. props = props || {};
  35897. if (bindObject) {
  35898. extend(props, bindObject);
  35899. }
  35900. return scopedSlotFn(props) || fallback
  35901. } else {
  35902. var slotNodes = this.$slots[name];
  35903. // warn duplicate slot usage
  35904. if (slotNodes && "development" !== 'production') {
  35905. slotNodes._rendered && warn(
  35906. "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
  35907. "- this will likely cause render errors.",
  35908. this
  35909. );
  35910. slotNodes._rendered = true;
  35911. }
  35912. return slotNodes || fallback
  35913. }
  35914. }
  35915. /* */
  35916. /**
  35917. * Runtime helper for resolving filters
  35918. */
  35919. function resolveFilter (id) {
  35920. return resolveAsset(this.$options, 'filters', id, true) || identity
  35921. }
  35922. /* */
  35923. /**
  35924. * Runtime helper for checking keyCodes from config.
  35925. */
  35926. function checkKeyCodes (
  35927. eventKeyCode,
  35928. key,
  35929. builtInAlias
  35930. ) {
  35931. var keyCodes = config.keyCodes[key] || builtInAlias;
  35932. if (Array.isArray(keyCodes)) {
  35933. return keyCodes.indexOf(eventKeyCode) === -1
  35934. } else {
  35935. return keyCodes !== eventKeyCode
  35936. }
  35937. }
  35938. /* */
  35939. /**
  35940. * Runtime helper for merging v-bind="object" into a VNode's data.
  35941. */
  35942. function bindObjectProps (
  35943. data,
  35944. tag,
  35945. value,
  35946. asProp
  35947. ) {
  35948. if (value) {
  35949. if (!isObject(value)) {
  35950. "development" !== 'production' && warn(
  35951. 'v-bind without argument expects an Object or Array value',
  35952. this
  35953. );
  35954. } else {
  35955. if (Array.isArray(value)) {
  35956. value = toObject(value);
  35957. }
  35958. var hash;
  35959. for (var key in value) {
  35960. if (key === 'class' || key === 'style') {
  35961. hash = data;
  35962. } else {
  35963. var type = data.attrs && data.attrs.type;
  35964. hash = asProp || config.mustUseProp(tag, type, key)
  35965. ? data.domProps || (data.domProps = {})
  35966. : data.attrs || (data.attrs = {});
  35967. }
  35968. if (!(key in hash)) {
  35969. hash[key] = value[key];
  35970. }
  35971. }
  35972. }
  35973. }
  35974. return data
  35975. }
  35976. /* */
  35977. /**
  35978. * Runtime helper for rendering static trees.
  35979. */
  35980. function renderStatic (
  35981. index,
  35982. isInFor
  35983. ) {
  35984. var tree = this._staticTrees[index];
  35985. // if has already-rendered static tree and not inside v-for,
  35986. // we can reuse the same tree by doing a shallow clone.
  35987. if (tree && !isInFor) {
  35988. return Array.isArray(tree)
  35989. ? cloneVNodes(tree)
  35990. : cloneVNode(tree)
  35991. }
  35992. // otherwise, render a fresh tree.
  35993. tree = this._staticTrees[index] =
  35994. this.$options.staticRenderFns[index].call(this._renderProxy);
  35995. markStatic(tree, ("__static__" + index), false);
  35996. return tree
  35997. }
  35998. /**
  35999. * Runtime helper for v-once.
  36000. * Effectively it means marking the node as static with a unique key.
  36001. */
  36002. function markOnce (
  36003. tree,
  36004. index,
  36005. key
  36006. ) {
  36007. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  36008. return tree
  36009. }
  36010. function markStatic (
  36011. tree,
  36012. key,
  36013. isOnce
  36014. ) {
  36015. if (Array.isArray(tree)) {
  36016. for (var i = 0; i < tree.length; i++) {
  36017. if (tree[i] && typeof tree[i] !== 'string') {
  36018. markStaticNode(tree[i], (key + "_" + i), isOnce);
  36019. }
  36020. }
  36021. } else {
  36022. markStaticNode(tree, key, isOnce);
  36023. }
  36024. }
  36025. function markStaticNode (node, key, isOnce) {
  36026. node.isStatic = true;
  36027. node.key = key;
  36028. node.isOnce = isOnce;
  36029. }
  36030. /* */
  36031. function initRender (vm) {
  36032. vm._vnode = null; // the root of the child tree
  36033. vm._staticTrees = null;
  36034. var parentVnode = vm.$vnode = vm.$options._parentVnode; // the placeholder node in parent tree
  36035. var renderContext = parentVnode && parentVnode.context;
  36036. vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
  36037. vm.$scopedSlots = emptyObject;
  36038. // bind the createElement fn to this instance
  36039. // so that we get proper render context inside it.
  36040. // args order: tag, data, children, normalizationType, alwaysNormalize
  36041. // internal version is used by render functions compiled from templates
  36042. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  36043. // normalization is always applied for the public version, used in
  36044. // user-written render functions.
  36045. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  36046. }
  36047. function renderMixin (Vue) {
  36048. Vue.prototype.$nextTick = function (fn) {
  36049. return nextTick(fn, this)
  36050. };
  36051. Vue.prototype._render = function () {
  36052. var vm = this;
  36053. var ref = vm.$options;
  36054. var render = ref.render;
  36055. var staticRenderFns = ref.staticRenderFns;
  36056. var _parentVnode = ref._parentVnode;
  36057. if (vm._isMounted) {
  36058. // clone slot nodes on re-renders
  36059. for (var key in vm.$slots) {
  36060. vm.$slots[key] = cloneVNodes(vm.$slots[key]);
  36061. }
  36062. }
  36063. vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject;
  36064. if (staticRenderFns && !vm._staticTrees) {
  36065. vm._staticTrees = [];
  36066. }
  36067. // set parent vnode. this allows render functions to have access
  36068. // to the data on the placeholder node.
  36069. vm.$vnode = _parentVnode;
  36070. // render self
  36071. var vnode;
  36072. try {
  36073. vnode = render.call(vm._renderProxy, vm.$createElement);
  36074. } catch (e) {
  36075. handleError(e, vm, "render function");
  36076. // return error render result,
  36077. // or previous vnode to prevent render error causing blank component
  36078. /* istanbul ignore else */
  36079. if (true) {
  36080. vnode = vm.$options.renderError
  36081. ? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)
  36082. : vm._vnode;
  36083. } else {
  36084. vnode = vm._vnode;
  36085. }
  36086. }
  36087. // return empty vnode in case the render function errored out
  36088. if (!(vnode instanceof VNode)) {
  36089. if ("development" !== 'production' && Array.isArray(vnode)) {
  36090. warn(
  36091. 'Multiple root nodes returned from render function. Render function ' +
  36092. 'should return a single root node.',
  36093. vm
  36094. );
  36095. }
  36096. vnode = createEmptyVNode();
  36097. }
  36098. // set parent
  36099. vnode.parent = _parentVnode;
  36100. return vnode
  36101. };
  36102. // internal render helpers.
  36103. // these are exposed on the instance prototype to reduce generated render
  36104. // code size.
  36105. Vue.prototype._o = markOnce;
  36106. Vue.prototype._n = toNumber;
  36107. Vue.prototype._s = toString;
  36108. Vue.prototype._l = renderList;
  36109. Vue.prototype._t = renderSlot;
  36110. Vue.prototype._q = looseEqual;
  36111. Vue.prototype._i = looseIndexOf;
  36112. Vue.prototype._m = renderStatic;
  36113. Vue.prototype._f = resolveFilter;
  36114. Vue.prototype._k = checkKeyCodes;
  36115. Vue.prototype._b = bindObjectProps;
  36116. Vue.prototype._v = createTextVNode;
  36117. Vue.prototype._e = createEmptyVNode;
  36118. Vue.prototype._u = resolveScopedSlots;
  36119. }
  36120. /* */
  36121. var uid$1 = 0;
  36122. function initMixin (Vue) {
  36123. Vue.prototype._init = function (options) {
  36124. var vm = this;
  36125. // a uid
  36126. vm._uid = uid$1++;
  36127. var startTag, endTag;
  36128. /* istanbul ignore if */
  36129. if ("development" !== 'production' && config.performance && mark) {
  36130. startTag = "vue-perf-init:" + (vm._uid);
  36131. endTag = "vue-perf-end:" + (vm._uid);
  36132. mark(startTag);
  36133. }
  36134. // a flag to avoid this being observed
  36135. vm._isVue = true;
  36136. // merge options
  36137. if (options && options._isComponent) {
  36138. // optimize internal component instantiation
  36139. // since dynamic options merging is pretty slow, and none of the
  36140. // internal component options needs special treatment.
  36141. initInternalComponent(vm, options);
  36142. } else {
  36143. vm.$options = mergeOptions(
  36144. resolveConstructorOptions(vm.constructor),
  36145. options || {},
  36146. vm
  36147. );
  36148. }
  36149. /* istanbul ignore else */
  36150. if (true) {
  36151. initProxy(vm);
  36152. } else {
  36153. vm._renderProxy = vm;
  36154. }
  36155. // expose real self
  36156. vm._self = vm;
  36157. initLifecycle(vm);
  36158. initEvents(vm);
  36159. initRender(vm);
  36160. callHook(vm, 'beforeCreate');
  36161. initInjections(vm); // resolve injections before data/props
  36162. initState(vm);
  36163. initProvide(vm); // resolve provide after data/props
  36164. callHook(vm, 'created');
  36165. /* istanbul ignore if */
  36166. if ("development" !== 'production' && config.performance && mark) {
  36167. vm._name = formatComponentName(vm, false);
  36168. mark(endTag);
  36169. measure(((vm._name) + " init"), startTag, endTag);
  36170. }
  36171. if (vm.$options.el) {
  36172. vm.$mount(vm.$options.el);
  36173. }
  36174. };
  36175. }
  36176. function initInternalComponent (vm, options) {
  36177. var opts = vm.$options = Object.create(vm.constructor.options);
  36178. // doing this because it's faster than dynamic enumeration.
  36179. opts.parent = options.parent;
  36180. opts.propsData = options.propsData;
  36181. opts._parentVnode = options._parentVnode;
  36182. opts._parentListeners = options._parentListeners;
  36183. opts._renderChildren = options._renderChildren;
  36184. opts._componentTag = options._componentTag;
  36185. opts._parentElm = options._parentElm;
  36186. opts._refElm = options._refElm;
  36187. if (options.render) {
  36188. opts.render = options.render;
  36189. opts.staticRenderFns = options.staticRenderFns;
  36190. }
  36191. }
  36192. function resolveConstructorOptions (Ctor) {
  36193. var options = Ctor.options;
  36194. if (Ctor.super) {
  36195. var superOptions = resolveConstructorOptions(Ctor.super);
  36196. var cachedSuperOptions = Ctor.superOptions;
  36197. if (superOptions !== cachedSuperOptions) {
  36198. // super option changed,
  36199. // need to resolve new options.
  36200. Ctor.superOptions = superOptions;
  36201. // check if there are any late-modified/attached options (#4976)
  36202. var modifiedOptions = resolveModifiedOptions(Ctor);
  36203. // update base extend options
  36204. if (modifiedOptions) {
  36205. extend(Ctor.extendOptions, modifiedOptions);
  36206. }
  36207. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  36208. if (options.name) {
  36209. options.components[options.name] = Ctor;
  36210. }
  36211. }
  36212. }
  36213. return options
  36214. }
  36215. function resolveModifiedOptions (Ctor) {
  36216. var modified;
  36217. var latest = Ctor.options;
  36218. var extended = Ctor.extendOptions;
  36219. var sealed = Ctor.sealedOptions;
  36220. for (var key in latest) {
  36221. if (latest[key] !== sealed[key]) {
  36222. if (!modified) { modified = {}; }
  36223. modified[key] = dedupe(latest[key], extended[key], sealed[key]);
  36224. }
  36225. }
  36226. return modified
  36227. }
  36228. function dedupe (latest, extended, sealed) {
  36229. // compare latest and sealed to ensure lifecycle hooks won't be duplicated
  36230. // between merges
  36231. if (Array.isArray(latest)) {
  36232. var res = [];
  36233. sealed = Array.isArray(sealed) ? sealed : [sealed];
  36234. extended = Array.isArray(extended) ? extended : [extended];
  36235. for (var i = 0; i < latest.length; i++) {
  36236. // push original options and not sealed options to exclude duplicated options
  36237. if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) {
  36238. res.push(latest[i]);
  36239. }
  36240. }
  36241. return res
  36242. } else {
  36243. return latest
  36244. }
  36245. }
  36246. function Vue$3 (options) {
  36247. if ("development" !== 'production' &&
  36248. !(this instanceof Vue$3)
  36249. ) {
  36250. warn('Vue is a constructor and should be called with the `new` keyword');
  36251. }
  36252. this._init(options);
  36253. }
  36254. initMixin(Vue$3);
  36255. stateMixin(Vue$3);
  36256. eventsMixin(Vue$3);
  36257. lifecycleMixin(Vue$3);
  36258. renderMixin(Vue$3);
  36259. /* */
  36260. function initUse (Vue) {
  36261. Vue.use = function (plugin) {
  36262. /* istanbul ignore if */
  36263. if (plugin.installed) {
  36264. return this
  36265. }
  36266. // additional parameters
  36267. var args = toArray(arguments, 1);
  36268. args.unshift(this);
  36269. if (typeof plugin.install === 'function') {
  36270. plugin.install.apply(plugin, args);
  36271. } else if (typeof plugin === 'function') {
  36272. plugin.apply(null, args);
  36273. }
  36274. plugin.installed = true;
  36275. return this
  36276. };
  36277. }
  36278. /* */
  36279. function initMixin$1 (Vue) {
  36280. Vue.mixin = function (mixin) {
  36281. this.options = mergeOptions(this.options, mixin);
  36282. return this
  36283. };
  36284. }
  36285. /* */
  36286. function initExtend (Vue) {
  36287. /**
  36288. * Each instance constructor, including Vue, has a unique
  36289. * cid. This enables us to create wrapped "child
  36290. * constructors" for prototypal inheritance and cache them.
  36291. */
  36292. Vue.cid = 0;
  36293. var cid = 1;
  36294. /**
  36295. * Class inheritance
  36296. */
  36297. Vue.extend = function (extendOptions) {
  36298. extendOptions = extendOptions || {};
  36299. var Super = this;
  36300. var SuperId = Super.cid;
  36301. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  36302. if (cachedCtors[SuperId]) {
  36303. return cachedCtors[SuperId]
  36304. }
  36305. var name = extendOptions.name || Super.options.name;
  36306. if (true) {
  36307. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  36308. warn(
  36309. 'Invalid component name: "' + name + '". Component names ' +
  36310. 'can only contain alphanumeric characters and the hyphen, ' +
  36311. 'and must start with a letter.'
  36312. );
  36313. }
  36314. }
  36315. var Sub = function VueComponent (options) {
  36316. this._init(options);
  36317. };
  36318. Sub.prototype = Object.create(Super.prototype);
  36319. Sub.prototype.constructor = Sub;
  36320. Sub.cid = cid++;
  36321. Sub.options = mergeOptions(
  36322. Super.options,
  36323. extendOptions
  36324. );
  36325. Sub['super'] = Super;
  36326. // For props and computed properties, we define the proxy getters on
  36327. // the Vue instances at extension time, on the extended prototype. This
  36328. // avoids Object.defineProperty calls for each instance created.
  36329. if (Sub.options.props) {
  36330. initProps$1(Sub);
  36331. }
  36332. if (Sub.options.computed) {
  36333. initComputed$1(Sub);
  36334. }
  36335. // allow further extension/mixin/plugin usage
  36336. Sub.extend = Super.extend;
  36337. Sub.mixin = Super.mixin;
  36338. Sub.use = Super.use;
  36339. // create asset registers, so extended classes
  36340. // can have their private assets too.
  36341. ASSET_TYPES.forEach(function (type) {
  36342. Sub[type] = Super[type];
  36343. });
  36344. // enable recursive self-lookup
  36345. if (name) {
  36346. Sub.options.components[name] = Sub;
  36347. }
  36348. // keep a reference to the super options at extension time.
  36349. // later at instantiation we can check if Super's options have
  36350. // been updated.
  36351. Sub.superOptions = Super.options;
  36352. Sub.extendOptions = extendOptions;
  36353. Sub.sealedOptions = extend({}, Sub.options);
  36354. // cache constructor
  36355. cachedCtors[SuperId] = Sub;
  36356. return Sub
  36357. };
  36358. }
  36359. function initProps$1 (Comp) {
  36360. var props = Comp.options.props;
  36361. for (var key in props) {
  36362. proxy(Comp.prototype, "_props", key);
  36363. }
  36364. }
  36365. function initComputed$1 (Comp) {
  36366. var computed = Comp.options.computed;
  36367. for (var key in computed) {
  36368. defineComputed(Comp.prototype, key, computed[key]);
  36369. }
  36370. }
  36371. /* */
  36372. function initAssetRegisters (Vue) {
  36373. /**
  36374. * Create asset registration methods.
  36375. */
  36376. ASSET_TYPES.forEach(function (type) {
  36377. Vue[type] = function (
  36378. id,
  36379. definition
  36380. ) {
  36381. if (!definition) {
  36382. return this.options[type + 's'][id]
  36383. } else {
  36384. /* istanbul ignore if */
  36385. if (true) {
  36386. if (type === 'component' && config.isReservedTag(id)) {
  36387. warn(
  36388. 'Do not use built-in or reserved HTML elements as component ' +
  36389. 'id: ' + id
  36390. );
  36391. }
  36392. }
  36393. if (type === 'component' && isPlainObject(definition)) {
  36394. definition.name = definition.name || id;
  36395. definition = this.options._base.extend(definition);
  36396. }
  36397. if (type === 'directive' && typeof definition === 'function') {
  36398. definition = { bind: definition, update: definition };
  36399. }
  36400. this.options[type + 's'][id] = definition;
  36401. return definition
  36402. }
  36403. };
  36404. });
  36405. }
  36406. /* */
  36407. var patternTypes = [String, RegExp];
  36408. function getComponentName (opts) {
  36409. return opts && (opts.Ctor.options.name || opts.tag)
  36410. }
  36411. function matches (pattern, name) {
  36412. if (typeof pattern === 'string') {
  36413. return pattern.split(',').indexOf(name) > -1
  36414. } else if (isRegExp(pattern)) {
  36415. return pattern.test(name)
  36416. }
  36417. /* istanbul ignore next */
  36418. return false
  36419. }
  36420. function pruneCache (cache, current, filter) {
  36421. for (var key in cache) {
  36422. var cachedNode = cache[key];
  36423. if (cachedNode) {
  36424. var name = getComponentName(cachedNode.componentOptions);
  36425. if (name && !filter(name)) {
  36426. if (cachedNode !== current) {
  36427. pruneCacheEntry(cachedNode);
  36428. }
  36429. cache[key] = null;
  36430. }
  36431. }
  36432. }
  36433. }
  36434. function pruneCacheEntry (vnode) {
  36435. if (vnode) {
  36436. vnode.componentInstance.$destroy();
  36437. }
  36438. }
  36439. var KeepAlive = {
  36440. name: 'keep-alive',
  36441. abstract: true,
  36442. props: {
  36443. include: patternTypes,
  36444. exclude: patternTypes
  36445. },
  36446. created: function created () {
  36447. this.cache = Object.create(null);
  36448. },
  36449. destroyed: function destroyed () {
  36450. var this$1 = this;
  36451. for (var key in this$1.cache) {
  36452. pruneCacheEntry(this$1.cache[key]);
  36453. }
  36454. },
  36455. watch: {
  36456. include: function include (val) {
  36457. pruneCache(this.cache, this._vnode, function (name) { return matches(val, name); });
  36458. },
  36459. exclude: function exclude (val) {
  36460. pruneCache(this.cache, this._vnode, function (name) { return !matches(val, name); });
  36461. }
  36462. },
  36463. render: function render () {
  36464. var vnode = getFirstComponentChild(this.$slots.default);
  36465. var componentOptions = vnode && vnode.componentOptions;
  36466. if (componentOptions) {
  36467. // check pattern
  36468. var name = getComponentName(componentOptions);
  36469. if (name && (
  36470. (this.include && !matches(this.include, name)) ||
  36471. (this.exclude && matches(this.exclude, name))
  36472. )) {
  36473. return vnode
  36474. }
  36475. var key = vnode.key == null
  36476. // same constructor may get registered as different local components
  36477. // so cid alone is not enough (#3269)
  36478. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  36479. : vnode.key;
  36480. if (this.cache[key]) {
  36481. vnode.componentInstance = this.cache[key].componentInstance;
  36482. } else {
  36483. this.cache[key] = vnode;
  36484. }
  36485. vnode.data.keepAlive = true;
  36486. }
  36487. return vnode
  36488. }
  36489. };
  36490. var builtInComponents = {
  36491. KeepAlive: KeepAlive
  36492. };
  36493. /* */
  36494. function initGlobalAPI (Vue) {
  36495. // config
  36496. var configDef = {};
  36497. configDef.get = function () { return config; };
  36498. if (true) {
  36499. configDef.set = function () {
  36500. warn(
  36501. 'Do not replace the Vue.config object, set individual fields instead.'
  36502. );
  36503. };
  36504. }
  36505. Object.defineProperty(Vue, 'config', configDef);
  36506. // exposed util methods.
  36507. // NOTE: these are not considered part of the public API - avoid relying on
  36508. // them unless you are aware of the risk.
  36509. Vue.util = {
  36510. warn: warn,
  36511. extend: extend,
  36512. mergeOptions: mergeOptions,
  36513. defineReactive: defineReactive$$1
  36514. };
  36515. Vue.set = set;
  36516. Vue.delete = del;
  36517. Vue.nextTick = nextTick;
  36518. Vue.options = Object.create(null);
  36519. ASSET_TYPES.forEach(function (type) {
  36520. Vue.options[type + 's'] = Object.create(null);
  36521. });
  36522. // this is used to identify the "base" constructor to extend all plain-object
  36523. // components with in Weex's multi-instance scenarios.
  36524. Vue.options._base = Vue;
  36525. extend(Vue.options.components, builtInComponents);
  36526. initUse(Vue);
  36527. initMixin$1(Vue);
  36528. initExtend(Vue);
  36529. initAssetRegisters(Vue);
  36530. }
  36531. initGlobalAPI(Vue$3);
  36532. Object.defineProperty(Vue$3.prototype, '$isServer', {
  36533. get: isServerRendering
  36534. });
  36535. Object.defineProperty(Vue$3.prototype, '$ssrContext', {
  36536. get: function get () {
  36537. /* istanbul ignore next */
  36538. return this.$vnode.ssrContext
  36539. }
  36540. });
  36541. Vue$3.version = '2.3.4';
  36542. /* */
  36543. // these are reserved for web because they are directly compiled away
  36544. // during template compilation
  36545. var isReservedAttr = makeMap('style,class');
  36546. // attributes that should be using props for binding
  36547. var acceptValue = makeMap('input,textarea,option,select');
  36548. var mustUseProp = function (tag, type, attr) {
  36549. return (
  36550. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  36551. (attr === 'selected' && tag === 'option') ||
  36552. (attr === 'checked' && tag === 'input') ||
  36553. (attr === 'muted' && tag === 'video')
  36554. )
  36555. };
  36556. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  36557. var isBooleanAttr = makeMap(
  36558. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  36559. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  36560. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  36561. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  36562. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  36563. 'truespeed,typemustmatch,visible'
  36564. );
  36565. var xlinkNS = 'http://www.w3.org/1999/xlink';
  36566. var isXlink = function (name) {
  36567. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  36568. };
  36569. var getXlinkProp = function (name) {
  36570. return isXlink(name) ? name.slice(6, name.length) : ''
  36571. };
  36572. var isFalsyAttrValue = function (val) {
  36573. return val == null || val === false
  36574. };
  36575. /* */
  36576. function genClassForVnode (vnode) {
  36577. var data = vnode.data;
  36578. var parentNode = vnode;
  36579. var childNode = vnode;
  36580. while (isDef(childNode.componentInstance)) {
  36581. childNode = childNode.componentInstance._vnode;
  36582. if (childNode.data) {
  36583. data = mergeClassData(childNode.data, data);
  36584. }
  36585. }
  36586. while (isDef(parentNode = parentNode.parent)) {
  36587. if (parentNode.data) {
  36588. data = mergeClassData(data, parentNode.data);
  36589. }
  36590. }
  36591. return genClassFromData(data)
  36592. }
  36593. function mergeClassData (child, parent) {
  36594. return {
  36595. staticClass: concat(child.staticClass, parent.staticClass),
  36596. class: isDef(child.class)
  36597. ? [child.class, parent.class]
  36598. : parent.class
  36599. }
  36600. }
  36601. function genClassFromData (data) {
  36602. var dynamicClass = data.class;
  36603. var staticClass = data.staticClass;
  36604. if (isDef(staticClass) || isDef(dynamicClass)) {
  36605. return concat(staticClass, stringifyClass(dynamicClass))
  36606. }
  36607. /* istanbul ignore next */
  36608. return ''
  36609. }
  36610. function concat (a, b) {
  36611. return a ? b ? (a + ' ' + b) : a : (b || '')
  36612. }
  36613. function stringifyClass (value) {
  36614. if (isUndef(value)) {
  36615. return ''
  36616. }
  36617. if (typeof value === 'string') {
  36618. return value
  36619. }
  36620. var res = '';
  36621. if (Array.isArray(value)) {
  36622. var stringified;
  36623. for (var i = 0, l = value.length; i < l; i++) {
  36624. if (isDef(value[i])) {
  36625. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  36626. res += stringified + ' ';
  36627. }
  36628. }
  36629. }
  36630. return res.slice(0, -1)
  36631. }
  36632. if (isObject(value)) {
  36633. for (var key in value) {
  36634. if (value[key]) { res += key + ' '; }
  36635. }
  36636. return res.slice(0, -1)
  36637. }
  36638. /* istanbul ignore next */
  36639. return res
  36640. }
  36641. /* */
  36642. var namespaceMap = {
  36643. svg: 'http://www.w3.org/2000/svg',
  36644. math: 'http://www.w3.org/1998/Math/MathML'
  36645. };
  36646. var isHTMLTag = makeMap(
  36647. 'html,body,base,head,link,meta,style,title,' +
  36648. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  36649. 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' +
  36650. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  36651. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  36652. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  36653. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  36654. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  36655. 'output,progress,select,textarea,' +
  36656. 'details,dialog,menu,menuitem,summary,' +
  36657. 'content,element,shadow,template'
  36658. );
  36659. // this map is intentionally selective, only covering SVG elements that may
  36660. // contain child elements.
  36661. var isSVG = makeMap(
  36662. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  36663. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  36664. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  36665. true
  36666. );
  36667. var isPreTag = function (tag) { return tag === 'pre'; };
  36668. var isReservedTag = function (tag) {
  36669. return isHTMLTag(tag) || isSVG(tag)
  36670. };
  36671. function getTagNamespace (tag) {
  36672. if (isSVG(tag)) {
  36673. return 'svg'
  36674. }
  36675. // basic support for MathML
  36676. // note it doesn't support other MathML elements being component roots
  36677. if (tag === 'math') {
  36678. return 'math'
  36679. }
  36680. }
  36681. var unknownElementCache = Object.create(null);
  36682. function isUnknownElement (tag) {
  36683. /* istanbul ignore if */
  36684. if (!inBrowser) {
  36685. return true
  36686. }
  36687. if (isReservedTag(tag)) {
  36688. return false
  36689. }
  36690. tag = tag.toLowerCase();
  36691. /* istanbul ignore if */
  36692. if (unknownElementCache[tag] != null) {
  36693. return unknownElementCache[tag]
  36694. }
  36695. var el = document.createElement(tag);
  36696. if (tag.indexOf('-') > -1) {
  36697. // http://stackoverflow.com/a/28210364/1070244
  36698. return (unknownElementCache[tag] = (
  36699. el.constructor === window.HTMLUnknownElement ||
  36700. el.constructor === window.HTMLElement
  36701. ))
  36702. } else {
  36703. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  36704. }
  36705. }
  36706. /* */
  36707. /**
  36708. * Query an element selector if it's not an element already.
  36709. */
  36710. function query (el) {
  36711. if (typeof el === 'string') {
  36712. var selected = document.querySelector(el);
  36713. if (!selected) {
  36714. "development" !== 'production' && warn(
  36715. 'Cannot find element: ' + el
  36716. );
  36717. return document.createElement('div')
  36718. }
  36719. return selected
  36720. } else {
  36721. return el
  36722. }
  36723. }
  36724. /* */
  36725. function createElement$1 (tagName, vnode) {
  36726. var elm = document.createElement(tagName);
  36727. if (tagName !== 'select') {
  36728. return elm
  36729. }
  36730. // false or null will remove the attribute but undefined will not
  36731. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  36732. elm.setAttribute('multiple', 'multiple');
  36733. }
  36734. return elm
  36735. }
  36736. function createElementNS (namespace, tagName) {
  36737. return document.createElementNS(namespaceMap[namespace], tagName)
  36738. }
  36739. function createTextNode (text) {
  36740. return document.createTextNode(text)
  36741. }
  36742. function createComment (text) {
  36743. return document.createComment(text)
  36744. }
  36745. function insertBefore (parentNode, newNode, referenceNode) {
  36746. parentNode.insertBefore(newNode, referenceNode);
  36747. }
  36748. function removeChild (node, child) {
  36749. node.removeChild(child);
  36750. }
  36751. function appendChild (node, child) {
  36752. node.appendChild(child);
  36753. }
  36754. function parentNode (node) {
  36755. return node.parentNode
  36756. }
  36757. function nextSibling (node) {
  36758. return node.nextSibling
  36759. }
  36760. function tagName (node) {
  36761. return node.tagName
  36762. }
  36763. function setTextContent (node, text) {
  36764. node.textContent = text;
  36765. }
  36766. function setAttribute (node, key, val) {
  36767. node.setAttribute(key, val);
  36768. }
  36769. var nodeOps = Object.freeze({
  36770. createElement: createElement$1,
  36771. createElementNS: createElementNS,
  36772. createTextNode: createTextNode,
  36773. createComment: createComment,
  36774. insertBefore: insertBefore,
  36775. removeChild: removeChild,
  36776. appendChild: appendChild,
  36777. parentNode: parentNode,
  36778. nextSibling: nextSibling,
  36779. tagName: tagName,
  36780. setTextContent: setTextContent,
  36781. setAttribute: setAttribute
  36782. });
  36783. /* */
  36784. var ref = {
  36785. create: function create (_, vnode) {
  36786. registerRef(vnode);
  36787. },
  36788. update: function update (oldVnode, vnode) {
  36789. if (oldVnode.data.ref !== vnode.data.ref) {
  36790. registerRef(oldVnode, true);
  36791. registerRef(vnode);
  36792. }
  36793. },
  36794. destroy: function destroy (vnode) {
  36795. registerRef(vnode, true);
  36796. }
  36797. };
  36798. function registerRef (vnode, isRemoval) {
  36799. var key = vnode.data.ref;
  36800. if (!key) { return }
  36801. var vm = vnode.context;
  36802. var ref = vnode.componentInstance || vnode.elm;
  36803. var refs = vm.$refs;
  36804. if (isRemoval) {
  36805. if (Array.isArray(refs[key])) {
  36806. remove(refs[key], ref);
  36807. } else if (refs[key] === ref) {
  36808. refs[key] = undefined;
  36809. }
  36810. } else {
  36811. if (vnode.data.refInFor) {
  36812. if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) {
  36813. refs[key].push(ref);
  36814. } else {
  36815. refs[key] = [ref];
  36816. }
  36817. } else {
  36818. refs[key] = ref;
  36819. }
  36820. }
  36821. }
  36822. /**
  36823. * Virtual DOM patching algorithm based on Snabbdom by
  36824. * Simon Friis Vindum (@paldepind)
  36825. * Licensed under the MIT License
  36826. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  36827. *
  36828. * modified by Evan You (@yyx990803)
  36829. *
  36830. /*
  36831. * Not type-checking this because this file is perf-critical and the cost
  36832. * of making flow understand it is not worth it.
  36833. */
  36834. var emptyNode = new VNode('', {}, []);
  36835. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  36836. function sameVnode (a, b) {
  36837. return (
  36838. a.key === b.key &&
  36839. a.tag === b.tag &&
  36840. a.isComment === b.isComment &&
  36841. isDef(a.data) === isDef(b.data) &&
  36842. sameInputType(a, b)
  36843. )
  36844. }
  36845. // Some browsers do not support dynamically changing type for <input>
  36846. // so they need to be treated as different nodes
  36847. function sameInputType (a, b) {
  36848. if (a.tag !== 'input') { return true }
  36849. var i;
  36850. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  36851. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  36852. return typeA === typeB
  36853. }
  36854. function createKeyToOldIdx (children, beginIdx, endIdx) {
  36855. var i, key;
  36856. var map = {};
  36857. for (i = beginIdx; i <= endIdx; ++i) {
  36858. key = children[i].key;
  36859. if (isDef(key)) { map[key] = i; }
  36860. }
  36861. return map
  36862. }
  36863. function createPatchFunction (backend) {
  36864. var i, j;
  36865. var cbs = {};
  36866. var modules = backend.modules;
  36867. var nodeOps = backend.nodeOps;
  36868. for (i = 0; i < hooks.length; ++i) {
  36869. cbs[hooks[i]] = [];
  36870. for (j = 0; j < modules.length; ++j) {
  36871. if (isDef(modules[j][hooks[i]])) {
  36872. cbs[hooks[i]].push(modules[j][hooks[i]]);
  36873. }
  36874. }
  36875. }
  36876. function emptyNodeAt (elm) {
  36877. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  36878. }
  36879. function createRmCb (childElm, listeners) {
  36880. function remove$$1 () {
  36881. if (--remove$$1.listeners === 0) {
  36882. removeNode(childElm);
  36883. }
  36884. }
  36885. remove$$1.listeners = listeners;
  36886. return remove$$1
  36887. }
  36888. function removeNode (el) {
  36889. var parent = nodeOps.parentNode(el);
  36890. // element may have already been removed due to v-html / v-text
  36891. if (isDef(parent)) {
  36892. nodeOps.removeChild(parent, el);
  36893. }
  36894. }
  36895. var inPre = 0;
  36896. function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) {
  36897. vnode.isRootInsert = !nested; // for transition enter check
  36898. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  36899. return
  36900. }
  36901. var data = vnode.data;
  36902. var children = vnode.children;
  36903. var tag = vnode.tag;
  36904. if (isDef(tag)) {
  36905. if (true) {
  36906. if (data && data.pre) {
  36907. inPre++;
  36908. }
  36909. if (
  36910. !inPre &&
  36911. !vnode.ns &&
  36912. !(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) &&
  36913. config.isUnknownElement(tag)
  36914. ) {
  36915. warn(
  36916. 'Unknown custom element: <' + tag + '> - did you ' +
  36917. 'register the component correctly? For recursive components, ' +
  36918. 'make sure to provide the "name" option.',
  36919. vnode.context
  36920. );
  36921. }
  36922. }
  36923. vnode.elm = vnode.ns
  36924. ? nodeOps.createElementNS(vnode.ns, tag)
  36925. : nodeOps.createElement(tag, vnode);
  36926. setScope(vnode);
  36927. /* istanbul ignore if */
  36928. {
  36929. createChildren(vnode, children, insertedVnodeQueue);
  36930. if (isDef(data)) {
  36931. invokeCreateHooks(vnode, insertedVnodeQueue);
  36932. }
  36933. insert(parentElm, vnode.elm, refElm);
  36934. }
  36935. if ("development" !== 'production' && data && data.pre) {
  36936. inPre--;
  36937. }
  36938. } else if (isTrue(vnode.isComment)) {
  36939. vnode.elm = nodeOps.createComment(vnode.text);
  36940. insert(parentElm, vnode.elm, refElm);
  36941. } else {
  36942. vnode.elm = nodeOps.createTextNode(vnode.text);
  36943. insert(parentElm, vnode.elm, refElm);
  36944. }
  36945. }
  36946. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  36947. var i = vnode.data;
  36948. if (isDef(i)) {
  36949. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  36950. if (isDef(i = i.hook) && isDef(i = i.init)) {
  36951. i(vnode, false /* hydrating */, parentElm, refElm);
  36952. }
  36953. // after calling the init hook, if the vnode is a child component
  36954. // it should've created a child instance and mounted it. the child
  36955. // component also has set the placeholder vnode's elm.
  36956. // in that case we can just return the element and be done.
  36957. if (isDef(vnode.componentInstance)) {
  36958. initComponent(vnode, insertedVnodeQueue);
  36959. if (isTrue(isReactivated)) {
  36960. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  36961. }
  36962. return true
  36963. }
  36964. }
  36965. }
  36966. function initComponent (vnode, insertedVnodeQueue) {
  36967. if (isDef(vnode.data.pendingInsert)) {
  36968. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  36969. vnode.data.pendingInsert = null;
  36970. }
  36971. vnode.elm = vnode.componentInstance.$el;
  36972. if (isPatchable(vnode)) {
  36973. invokeCreateHooks(vnode, insertedVnodeQueue);
  36974. setScope(vnode);
  36975. } else {
  36976. // empty component root.
  36977. // skip all element-related modules except for ref (#3455)
  36978. registerRef(vnode);
  36979. // make sure to invoke the insert hook
  36980. insertedVnodeQueue.push(vnode);
  36981. }
  36982. }
  36983. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  36984. var i;
  36985. // hack for #4339: a reactivated component with inner transition
  36986. // does not trigger because the inner node's created hooks are not called
  36987. // again. It's not ideal to involve module-specific logic in here but
  36988. // there doesn't seem to be a better way to do it.
  36989. var innerNode = vnode;
  36990. while (innerNode.componentInstance) {
  36991. innerNode = innerNode.componentInstance._vnode;
  36992. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  36993. for (i = 0; i < cbs.activate.length; ++i) {
  36994. cbs.activate[i](emptyNode, innerNode);
  36995. }
  36996. insertedVnodeQueue.push(innerNode);
  36997. break
  36998. }
  36999. }
  37000. // unlike a newly created component,
  37001. // a reactivated keep-alive component doesn't insert itself
  37002. insert(parentElm, vnode.elm, refElm);
  37003. }
  37004. function insert (parent, elm, ref) {
  37005. if (isDef(parent)) {
  37006. if (isDef(ref)) {
  37007. if (ref.parentNode === parent) {
  37008. nodeOps.insertBefore(parent, elm, ref);
  37009. }
  37010. } else {
  37011. nodeOps.appendChild(parent, elm);
  37012. }
  37013. }
  37014. }
  37015. function createChildren (vnode, children, insertedVnodeQueue) {
  37016. if (Array.isArray(children)) {
  37017. for (var i = 0; i < children.length; ++i) {
  37018. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
  37019. }
  37020. } else if (isPrimitive(vnode.text)) {
  37021. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
  37022. }
  37023. }
  37024. function isPatchable (vnode) {
  37025. while (vnode.componentInstance) {
  37026. vnode = vnode.componentInstance._vnode;
  37027. }
  37028. return isDef(vnode.tag)
  37029. }
  37030. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  37031. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  37032. cbs.create[i$1](emptyNode, vnode);
  37033. }
  37034. i = vnode.data.hook; // Reuse variable
  37035. if (isDef(i)) {
  37036. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  37037. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  37038. }
  37039. }
  37040. // set scope id attribute for scoped CSS.
  37041. // this is implemented as a special case to avoid the overhead
  37042. // of going through the normal attribute patching process.
  37043. function setScope (vnode) {
  37044. var i;
  37045. var ancestor = vnode;
  37046. while (ancestor) {
  37047. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  37048. nodeOps.setAttribute(vnode.elm, i, '');
  37049. }
  37050. ancestor = ancestor.parent;
  37051. }
  37052. // for slot content they should also get the scopeId from the host instance.
  37053. if (isDef(i = activeInstance) &&
  37054. i !== vnode.context &&
  37055. isDef(i = i.$options._scopeId)
  37056. ) {
  37057. nodeOps.setAttribute(vnode.elm, i, '');
  37058. }
  37059. }
  37060. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  37061. for (; startIdx <= endIdx; ++startIdx) {
  37062. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm);
  37063. }
  37064. }
  37065. function invokeDestroyHook (vnode) {
  37066. var i, j;
  37067. var data = vnode.data;
  37068. if (isDef(data)) {
  37069. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  37070. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  37071. }
  37072. if (isDef(i = vnode.children)) {
  37073. for (j = 0; j < vnode.children.length; ++j) {
  37074. invokeDestroyHook(vnode.children[j]);
  37075. }
  37076. }
  37077. }
  37078. function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
  37079. for (; startIdx <= endIdx; ++startIdx) {
  37080. var ch = vnodes[startIdx];
  37081. if (isDef(ch)) {
  37082. if (isDef(ch.tag)) {
  37083. removeAndInvokeRemoveHook(ch);
  37084. invokeDestroyHook(ch);
  37085. } else { // Text node
  37086. removeNode(ch.elm);
  37087. }
  37088. }
  37089. }
  37090. }
  37091. function removeAndInvokeRemoveHook (vnode, rm) {
  37092. if (isDef(rm) || isDef(vnode.data)) {
  37093. var i;
  37094. var listeners = cbs.remove.length + 1;
  37095. if (isDef(rm)) {
  37096. // we have a recursively passed down rm callback
  37097. // increase the listeners count
  37098. rm.listeners += listeners;
  37099. } else {
  37100. // directly removing
  37101. rm = createRmCb(vnode.elm, listeners);
  37102. }
  37103. // recursively invoke hooks on child component root node
  37104. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  37105. removeAndInvokeRemoveHook(i, rm);
  37106. }
  37107. for (i = 0; i < cbs.remove.length; ++i) {
  37108. cbs.remove[i](vnode, rm);
  37109. }
  37110. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  37111. i(vnode, rm);
  37112. } else {
  37113. rm();
  37114. }
  37115. } else {
  37116. removeNode(vnode.elm);
  37117. }
  37118. }
  37119. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  37120. var oldStartIdx = 0;
  37121. var newStartIdx = 0;
  37122. var oldEndIdx = oldCh.length - 1;
  37123. var oldStartVnode = oldCh[0];
  37124. var oldEndVnode = oldCh[oldEndIdx];
  37125. var newEndIdx = newCh.length - 1;
  37126. var newStartVnode = newCh[0];
  37127. var newEndVnode = newCh[newEndIdx];
  37128. var oldKeyToIdx, idxInOld, elmToMove, refElm;
  37129. // removeOnly is a special flag used only by <transition-group>
  37130. // to ensure removed elements stay in correct relative positions
  37131. // during leaving transitions
  37132. var canMove = !removeOnly;
  37133. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  37134. if (isUndef(oldStartVnode)) {
  37135. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  37136. } else if (isUndef(oldEndVnode)) {
  37137. oldEndVnode = oldCh[--oldEndIdx];
  37138. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  37139. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
  37140. oldStartVnode = oldCh[++oldStartIdx];
  37141. newStartVnode = newCh[++newStartIdx];
  37142. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  37143. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
  37144. oldEndVnode = oldCh[--oldEndIdx];
  37145. newEndVnode = newCh[--newEndIdx];
  37146. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  37147. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
  37148. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  37149. oldStartVnode = oldCh[++oldStartIdx];
  37150. newEndVnode = newCh[--newEndIdx];
  37151. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  37152. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
  37153. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  37154. oldEndVnode = oldCh[--oldEndIdx];
  37155. newStartVnode = newCh[++newStartIdx];
  37156. } else {
  37157. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  37158. idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
  37159. if (isUndef(idxInOld)) { // New element
  37160. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  37161. newStartVnode = newCh[++newStartIdx];
  37162. } else {
  37163. elmToMove = oldCh[idxInOld];
  37164. /* istanbul ignore if */
  37165. if ("development" !== 'production' && !elmToMove) {
  37166. warn(
  37167. 'It seems there are duplicate keys that is causing an update error. ' +
  37168. 'Make sure each v-for item has a unique key.'
  37169. );
  37170. }
  37171. if (sameVnode(elmToMove, newStartVnode)) {
  37172. patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
  37173. oldCh[idxInOld] = undefined;
  37174. canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm);
  37175. newStartVnode = newCh[++newStartIdx];
  37176. } else {
  37177. // same key but different element. treat as new element
  37178. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  37179. newStartVnode = newCh[++newStartIdx];
  37180. }
  37181. }
  37182. }
  37183. }
  37184. if (oldStartIdx > oldEndIdx) {
  37185. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  37186. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  37187. } else if (newStartIdx > newEndIdx) {
  37188. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  37189. }
  37190. }
  37191. function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
  37192. if (oldVnode === vnode) {
  37193. return
  37194. }
  37195. // reuse element for static trees.
  37196. // note we only do this if the vnode is cloned -
  37197. // if the new node is not cloned it means the render functions have been
  37198. // reset by the hot-reload-api and we need to do a proper re-render.
  37199. if (isTrue(vnode.isStatic) &&
  37200. isTrue(oldVnode.isStatic) &&
  37201. vnode.key === oldVnode.key &&
  37202. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  37203. ) {
  37204. vnode.elm = oldVnode.elm;
  37205. vnode.componentInstance = oldVnode.componentInstance;
  37206. return
  37207. }
  37208. var i;
  37209. var data = vnode.data;
  37210. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  37211. i(oldVnode, vnode);
  37212. }
  37213. var elm = vnode.elm = oldVnode.elm;
  37214. var oldCh = oldVnode.children;
  37215. var ch = vnode.children;
  37216. if (isDef(data) && isPatchable(vnode)) {
  37217. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  37218. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  37219. }
  37220. if (isUndef(vnode.text)) {
  37221. if (isDef(oldCh) && isDef(ch)) {
  37222. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  37223. } else if (isDef(ch)) {
  37224. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  37225. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  37226. } else if (isDef(oldCh)) {
  37227. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  37228. } else if (isDef(oldVnode.text)) {
  37229. nodeOps.setTextContent(elm, '');
  37230. }
  37231. } else if (oldVnode.text !== vnode.text) {
  37232. nodeOps.setTextContent(elm, vnode.text);
  37233. }
  37234. if (isDef(data)) {
  37235. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  37236. }
  37237. }
  37238. function invokeInsertHook (vnode, queue, initial) {
  37239. // delay insert hooks for component root nodes, invoke them after the
  37240. // element is really inserted
  37241. if (isTrue(initial) && isDef(vnode.parent)) {
  37242. vnode.parent.data.pendingInsert = queue;
  37243. } else {
  37244. for (var i = 0; i < queue.length; ++i) {
  37245. queue[i].data.hook.insert(queue[i]);
  37246. }
  37247. }
  37248. }
  37249. var bailed = false;
  37250. // list of modules that can skip create hook during hydration because they
  37251. // are already rendered on the client or has no need for initialization
  37252. var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key');
  37253. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  37254. function hydrate (elm, vnode, insertedVnodeQueue) {
  37255. if (true) {
  37256. if (!assertNodeMatch(elm, vnode)) {
  37257. return false
  37258. }
  37259. }
  37260. vnode.elm = elm;
  37261. var tag = vnode.tag;
  37262. var data = vnode.data;
  37263. var children = vnode.children;
  37264. if (isDef(data)) {
  37265. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  37266. if (isDef(i = vnode.componentInstance)) {
  37267. // child component. it should have hydrated its own tree.
  37268. initComponent(vnode, insertedVnodeQueue);
  37269. return true
  37270. }
  37271. }
  37272. if (isDef(tag)) {
  37273. if (isDef(children)) {
  37274. // empty element, allow client to pick up and populate children
  37275. if (!elm.hasChildNodes()) {
  37276. createChildren(vnode, children, insertedVnodeQueue);
  37277. } else {
  37278. var childrenMatch = true;
  37279. var childNode = elm.firstChild;
  37280. for (var i$1 = 0; i$1 < children.length; i$1++) {
  37281. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
  37282. childrenMatch = false;
  37283. break
  37284. }
  37285. childNode = childNode.nextSibling;
  37286. }
  37287. // if childNode is not null, it means the actual childNodes list is
  37288. // longer than the virtual children list.
  37289. if (!childrenMatch || childNode) {
  37290. if ("development" !== 'production' &&
  37291. typeof console !== 'undefined' &&
  37292. !bailed
  37293. ) {
  37294. bailed = true;
  37295. console.warn('Parent: ', elm);
  37296. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  37297. }
  37298. return false
  37299. }
  37300. }
  37301. }
  37302. if (isDef(data)) {
  37303. for (var key in data) {
  37304. if (!isRenderedModule(key)) {
  37305. invokeCreateHooks(vnode, insertedVnodeQueue);
  37306. break
  37307. }
  37308. }
  37309. }
  37310. } else if (elm.data !== vnode.text) {
  37311. elm.data = vnode.text;
  37312. }
  37313. return true
  37314. }
  37315. function assertNodeMatch (node, vnode) {
  37316. if (isDef(vnode.tag)) {
  37317. return (
  37318. vnode.tag.indexOf('vue-component') === 0 ||
  37319. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  37320. )
  37321. } else {
  37322. return node.nodeType === (vnode.isComment ? 8 : 3)
  37323. }
  37324. }
  37325. return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) {
  37326. if (isUndef(vnode)) {
  37327. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  37328. return
  37329. }
  37330. var isInitialPatch = false;
  37331. var insertedVnodeQueue = [];
  37332. if (isUndef(oldVnode)) {
  37333. // empty mount (likely as component), create new root element
  37334. isInitialPatch = true;
  37335. createElm(vnode, insertedVnodeQueue, parentElm, refElm);
  37336. } else {
  37337. var isRealElement = isDef(oldVnode.nodeType);
  37338. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  37339. // patch existing root node
  37340. patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
  37341. } else {
  37342. if (isRealElement) {
  37343. // mounting to a real element
  37344. // check if this is server-rendered content and if we can perform
  37345. // a successful hydration.
  37346. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  37347. oldVnode.removeAttribute(SSR_ATTR);
  37348. hydrating = true;
  37349. }
  37350. if (isTrue(hydrating)) {
  37351. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  37352. invokeInsertHook(vnode, insertedVnodeQueue, true);
  37353. return oldVnode
  37354. } else if (true) {
  37355. warn(
  37356. 'The client-side rendered virtual DOM tree is not matching ' +
  37357. 'server-rendered content. This is likely caused by incorrect ' +
  37358. 'HTML markup, for example nesting block-level elements inside ' +
  37359. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  37360. 'full client-side render.'
  37361. );
  37362. }
  37363. }
  37364. // either not server-rendered, or hydration failed.
  37365. // create an empty node and replace it
  37366. oldVnode = emptyNodeAt(oldVnode);
  37367. }
  37368. // replacing existing element
  37369. var oldElm = oldVnode.elm;
  37370. var parentElm$1 = nodeOps.parentNode(oldElm);
  37371. createElm(
  37372. vnode,
  37373. insertedVnodeQueue,
  37374. // extremely rare edge case: do not insert if old element is in a
  37375. // leaving transition. Only happens when combining transition +
  37376. // keep-alive + HOCs. (#4590)
  37377. oldElm._leaveCb ? null : parentElm$1,
  37378. nodeOps.nextSibling(oldElm)
  37379. );
  37380. if (isDef(vnode.parent)) {
  37381. // component root element replaced.
  37382. // update parent placeholder node element, recursively
  37383. var ancestor = vnode.parent;
  37384. while (ancestor) {
  37385. ancestor.elm = vnode.elm;
  37386. ancestor = ancestor.parent;
  37387. }
  37388. if (isPatchable(vnode)) {
  37389. for (var i = 0; i < cbs.create.length; ++i) {
  37390. cbs.create[i](emptyNode, vnode.parent);
  37391. }
  37392. }
  37393. }
  37394. if (isDef(parentElm$1)) {
  37395. removeVnodes(parentElm$1, [oldVnode], 0, 0);
  37396. } else if (isDef(oldVnode.tag)) {
  37397. invokeDestroyHook(oldVnode);
  37398. }
  37399. }
  37400. }
  37401. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  37402. return vnode.elm
  37403. }
  37404. }
  37405. /* */
  37406. var directives = {
  37407. create: updateDirectives,
  37408. update: updateDirectives,
  37409. destroy: function unbindDirectives (vnode) {
  37410. updateDirectives(vnode, emptyNode);
  37411. }
  37412. };
  37413. function updateDirectives (oldVnode, vnode) {
  37414. if (oldVnode.data.directives || vnode.data.directives) {
  37415. _update(oldVnode, vnode);
  37416. }
  37417. }
  37418. function _update (oldVnode, vnode) {
  37419. var isCreate = oldVnode === emptyNode;
  37420. var isDestroy = vnode === emptyNode;
  37421. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  37422. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  37423. var dirsWithInsert = [];
  37424. var dirsWithPostpatch = [];
  37425. var key, oldDir, dir;
  37426. for (key in newDirs) {
  37427. oldDir = oldDirs[key];
  37428. dir = newDirs[key];
  37429. if (!oldDir) {
  37430. // new directive, bind
  37431. callHook$1(dir, 'bind', vnode, oldVnode);
  37432. if (dir.def && dir.def.inserted) {
  37433. dirsWithInsert.push(dir);
  37434. }
  37435. } else {
  37436. // existing directive, update
  37437. dir.oldValue = oldDir.value;
  37438. callHook$1(dir, 'update', vnode, oldVnode);
  37439. if (dir.def && dir.def.componentUpdated) {
  37440. dirsWithPostpatch.push(dir);
  37441. }
  37442. }
  37443. }
  37444. if (dirsWithInsert.length) {
  37445. var callInsert = function () {
  37446. for (var i = 0; i < dirsWithInsert.length; i++) {
  37447. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  37448. }
  37449. };
  37450. if (isCreate) {
  37451. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert);
  37452. } else {
  37453. callInsert();
  37454. }
  37455. }
  37456. if (dirsWithPostpatch.length) {
  37457. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () {
  37458. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  37459. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  37460. }
  37461. });
  37462. }
  37463. if (!isCreate) {
  37464. for (key in oldDirs) {
  37465. if (!newDirs[key]) {
  37466. // no longer present, unbind
  37467. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  37468. }
  37469. }
  37470. }
  37471. }
  37472. var emptyModifiers = Object.create(null);
  37473. function normalizeDirectives$1 (
  37474. dirs,
  37475. vm
  37476. ) {
  37477. var res = Object.create(null);
  37478. if (!dirs) {
  37479. return res
  37480. }
  37481. var i, dir;
  37482. for (i = 0; i < dirs.length; i++) {
  37483. dir = dirs[i];
  37484. if (!dir.modifiers) {
  37485. dir.modifiers = emptyModifiers;
  37486. }
  37487. res[getRawDirName(dir)] = dir;
  37488. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  37489. }
  37490. return res
  37491. }
  37492. function getRawDirName (dir) {
  37493. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  37494. }
  37495. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  37496. var fn = dir.def && dir.def[hook];
  37497. if (fn) {
  37498. try {
  37499. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  37500. } catch (e) {
  37501. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  37502. }
  37503. }
  37504. }
  37505. var baseModules = [
  37506. ref,
  37507. directives
  37508. ];
  37509. /* */
  37510. function updateAttrs (oldVnode, vnode) {
  37511. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  37512. return
  37513. }
  37514. var key, cur, old;
  37515. var elm = vnode.elm;
  37516. var oldAttrs = oldVnode.data.attrs || {};
  37517. var attrs = vnode.data.attrs || {};
  37518. // clone observed objects, as the user probably wants to mutate it
  37519. if (isDef(attrs.__ob__)) {
  37520. attrs = vnode.data.attrs = extend({}, attrs);
  37521. }
  37522. for (key in attrs) {
  37523. cur = attrs[key];
  37524. old = oldAttrs[key];
  37525. if (old !== cur) {
  37526. setAttr(elm, key, cur);
  37527. }
  37528. }
  37529. // #4391: in IE9, setting type can reset value for input[type=radio]
  37530. /* istanbul ignore if */
  37531. if (isIE9 && attrs.value !== oldAttrs.value) {
  37532. setAttr(elm, 'value', attrs.value);
  37533. }
  37534. for (key in oldAttrs) {
  37535. if (isUndef(attrs[key])) {
  37536. if (isXlink(key)) {
  37537. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  37538. } else if (!isEnumeratedAttr(key)) {
  37539. elm.removeAttribute(key);
  37540. }
  37541. }
  37542. }
  37543. }
  37544. function setAttr (el, key, value) {
  37545. if (isBooleanAttr(key)) {
  37546. // set attribute for blank value
  37547. // e.g. <option disabled>Select one</option>
  37548. if (isFalsyAttrValue(value)) {
  37549. el.removeAttribute(key);
  37550. } else {
  37551. el.setAttribute(key, key);
  37552. }
  37553. } else if (isEnumeratedAttr(key)) {
  37554. el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
  37555. } else if (isXlink(key)) {
  37556. if (isFalsyAttrValue(value)) {
  37557. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  37558. } else {
  37559. el.setAttributeNS(xlinkNS, key, value);
  37560. }
  37561. } else {
  37562. if (isFalsyAttrValue(value)) {
  37563. el.removeAttribute(key);
  37564. } else {
  37565. el.setAttribute(key, value);
  37566. }
  37567. }
  37568. }
  37569. var attrs = {
  37570. create: updateAttrs,
  37571. update: updateAttrs
  37572. };
  37573. /* */
  37574. function updateClass (oldVnode, vnode) {
  37575. var el = vnode.elm;
  37576. var data = vnode.data;
  37577. var oldData = oldVnode.data;
  37578. if (
  37579. isUndef(data.staticClass) &&
  37580. isUndef(data.class) && (
  37581. isUndef(oldData) || (
  37582. isUndef(oldData.staticClass) &&
  37583. isUndef(oldData.class)
  37584. )
  37585. )
  37586. ) {
  37587. return
  37588. }
  37589. var cls = genClassForVnode(vnode);
  37590. // handle transition classes
  37591. var transitionClass = el._transitionClasses;
  37592. if (isDef(transitionClass)) {
  37593. cls = concat(cls, stringifyClass(transitionClass));
  37594. }
  37595. // set the class
  37596. if (cls !== el._prevClass) {
  37597. el.setAttribute('class', cls);
  37598. el._prevClass = cls;
  37599. }
  37600. }
  37601. var klass = {
  37602. create: updateClass,
  37603. update: updateClass
  37604. };
  37605. /* */
  37606. var validDivisionCharRE = /[\w).+\-_$\]]/;
  37607. function parseFilters (exp) {
  37608. var inSingle = false;
  37609. var inDouble = false;
  37610. var inTemplateString = false;
  37611. var inRegex = false;
  37612. var curly = 0;
  37613. var square = 0;
  37614. var paren = 0;
  37615. var lastFilterIndex = 0;
  37616. var c, prev, i, expression, filters;
  37617. for (i = 0; i < exp.length; i++) {
  37618. prev = c;
  37619. c = exp.charCodeAt(i);
  37620. if (inSingle) {
  37621. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  37622. } else if (inDouble) {
  37623. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  37624. } else if (inTemplateString) {
  37625. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  37626. } else if (inRegex) {
  37627. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  37628. } else if (
  37629. c === 0x7C && // pipe
  37630. exp.charCodeAt(i + 1) !== 0x7C &&
  37631. exp.charCodeAt(i - 1) !== 0x7C &&
  37632. !curly && !square && !paren
  37633. ) {
  37634. if (expression === undefined) {
  37635. // first filter, end of expression
  37636. lastFilterIndex = i + 1;
  37637. expression = exp.slice(0, i).trim();
  37638. } else {
  37639. pushFilter();
  37640. }
  37641. } else {
  37642. switch (c) {
  37643. case 0x22: inDouble = true; break // "
  37644. case 0x27: inSingle = true; break // '
  37645. case 0x60: inTemplateString = true; break // `
  37646. case 0x28: paren++; break // (
  37647. case 0x29: paren--; break // )
  37648. case 0x5B: square++; break // [
  37649. case 0x5D: square--; break // ]
  37650. case 0x7B: curly++; break // {
  37651. case 0x7D: curly--; break // }
  37652. }
  37653. if (c === 0x2f) { // /
  37654. var j = i - 1;
  37655. var p = (void 0);
  37656. // find first non-whitespace prev char
  37657. for (; j >= 0; j--) {
  37658. p = exp.charAt(j);
  37659. if (p !== ' ') { break }
  37660. }
  37661. if (!p || !validDivisionCharRE.test(p)) {
  37662. inRegex = true;
  37663. }
  37664. }
  37665. }
  37666. }
  37667. if (expression === undefined) {
  37668. expression = exp.slice(0, i).trim();
  37669. } else if (lastFilterIndex !== 0) {
  37670. pushFilter();
  37671. }
  37672. function pushFilter () {
  37673. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  37674. lastFilterIndex = i + 1;
  37675. }
  37676. if (filters) {
  37677. for (i = 0; i < filters.length; i++) {
  37678. expression = wrapFilter(expression, filters[i]);
  37679. }
  37680. }
  37681. return expression
  37682. }
  37683. function wrapFilter (exp, filter) {
  37684. var i = filter.indexOf('(');
  37685. if (i < 0) {
  37686. // _f: resolveFilter
  37687. return ("_f(\"" + filter + "\")(" + exp + ")")
  37688. } else {
  37689. var name = filter.slice(0, i);
  37690. var args = filter.slice(i + 1);
  37691. return ("_f(\"" + name + "\")(" + exp + "," + args)
  37692. }
  37693. }
  37694. /* */
  37695. function baseWarn (msg) {
  37696. console.error(("[Vue compiler]: " + msg));
  37697. }
  37698. function pluckModuleFunction (
  37699. modules,
  37700. key
  37701. ) {
  37702. return modules
  37703. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  37704. : []
  37705. }
  37706. function addProp (el, name, value) {
  37707. (el.props || (el.props = [])).push({ name: name, value: value });
  37708. }
  37709. function addAttr (el, name, value) {
  37710. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  37711. }
  37712. function addDirective (
  37713. el,
  37714. name,
  37715. rawName,
  37716. value,
  37717. arg,
  37718. modifiers
  37719. ) {
  37720. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  37721. }
  37722. function addHandler (
  37723. el,
  37724. name,
  37725. value,
  37726. modifiers,
  37727. important,
  37728. warn
  37729. ) {
  37730. // warn prevent and passive modifier
  37731. /* istanbul ignore if */
  37732. if (
  37733. "development" !== 'production' && warn &&
  37734. modifiers && modifiers.prevent && modifiers.passive
  37735. ) {
  37736. warn(
  37737. 'passive and prevent can\'t be used together. ' +
  37738. 'Passive handler can\'t prevent default event.'
  37739. );
  37740. }
  37741. // check capture modifier
  37742. if (modifiers && modifiers.capture) {
  37743. delete modifiers.capture;
  37744. name = '!' + name; // mark the event as captured
  37745. }
  37746. if (modifiers && modifiers.once) {
  37747. delete modifiers.once;
  37748. name = '~' + name; // mark the event as once
  37749. }
  37750. /* istanbul ignore if */
  37751. if (modifiers && modifiers.passive) {
  37752. delete modifiers.passive;
  37753. name = '&' + name; // mark the event as passive
  37754. }
  37755. var events;
  37756. if (modifiers && modifiers.native) {
  37757. delete modifiers.native;
  37758. events = el.nativeEvents || (el.nativeEvents = {});
  37759. } else {
  37760. events = el.events || (el.events = {});
  37761. }
  37762. var newHandler = { value: value, modifiers: modifiers };
  37763. var handlers = events[name];
  37764. /* istanbul ignore if */
  37765. if (Array.isArray(handlers)) {
  37766. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  37767. } else if (handlers) {
  37768. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  37769. } else {
  37770. events[name] = newHandler;
  37771. }
  37772. }
  37773. function getBindingAttr (
  37774. el,
  37775. name,
  37776. getStatic
  37777. ) {
  37778. var dynamicValue =
  37779. getAndRemoveAttr(el, ':' + name) ||
  37780. getAndRemoveAttr(el, 'v-bind:' + name);
  37781. if (dynamicValue != null) {
  37782. return parseFilters(dynamicValue)
  37783. } else if (getStatic !== false) {
  37784. var staticValue = getAndRemoveAttr(el, name);
  37785. if (staticValue != null) {
  37786. return JSON.stringify(staticValue)
  37787. }
  37788. }
  37789. }
  37790. function getAndRemoveAttr (el, name) {
  37791. var val;
  37792. if ((val = el.attrsMap[name]) != null) {
  37793. var list = el.attrsList;
  37794. for (var i = 0, l = list.length; i < l; i++) {
  37795. if (list[i].name === name) {
  37796. list.splice(i, 1);
  37797. break
  37798. }
  37799. }
  37800. }
  37801. return val
  37802. }
  37803. /* */
  37804. /**
  37805. * Cross-platform code generation for component v-model
  37806. */
  37807. function genComponentModel (
  37808. el,
  37809. value,
  37810. modifiers
  37811. ) {
  37812. var ref = modifiers || {};
  37813. var number = ref.number;
  37814. var trim = ref.trim;
  37815. var baseValueExpression = '$$v';
  37816. var valueExpression = baseValueExpression;
  37817. if (trim) {
  37818. valueExpression =
  37819. "(typeof " + baseValueExpression + " === 'string'" +
  37820. "? " + baseValueExpression + ".trim()" +
  37821. ": " + baseValueExpression + ")";
  37822. }
  37823. if (number) {
  37824. valueExpression = "_n(" + valueExpression + ")";
  37825. }
  37826. var assignment = genAssignmentCode(value, valueExpression);
  37827. el.model = {
  37828. value: ("(" + value + ")"),
  37829. expression: ("\"" + value + "\""),
  37830. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  37831. };
  37832. }
  37833. /**
  37834. * Cross-platform codegen helper for generating v-model value assignment code.
  37835. */
  37836. function genAssignmentCode (
  37837. value,
  37838. assignment
  37839. ) {
  37840. var modelRs = parseModel(value);
  37841. if (modelRs.idx === null) {
  37842. return (value + "=" + assignment)
  37843. } else {
  37844. return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" +
  37845. "if (!Array.isArray($$exp)){" +
  37846. value + "=" + assignment + "}" +
  37847. "else{$$exp.splice($$idx, 1, " + assignment + ")}"
  37848. }
  37849. }
  37850. /**
  37851. * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
  37852. *
  37853. * for loop possible cases:
  37854. *
  37855. * - test
  37856. * - test[idx]
  37857. * - test[test1[idx]]
  37858. * - test["a"][idx]
  37859. * - xxx.test[a[a].test1[idx]]
  37860. * - test.xxx.a["asa"][test1[idx]]
  37861. *
  37862. */
  37863. var len;
  37864. var str;
  37865. var chr;
  37866. var index$1;
  37867. var expressionPos;
  37868. var expressionEndPos;
  37869. function parseModel (val) {
  37870. str = val;
  37871. len = str.length;
  37872. index$1 = expressionPos = expressionEndPos = 0;
  37873. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  37874. return {
  37875. exp: val,
  37876. idx: null
  37877. }
  37878. }
  37879. while (!eof()) {
  37880. chr = next();
  37881. /* istanbul ignore if */
  37882. if (isStringStart(chr)) {
  37883. parseString(chr);
  37884. } else if (chr === 0x5B) {
  37885. parseBracket(chr);
  37886. }
  37887. }
  37888. return {
  37889. exp: val.substring(0, expressionPos),
  37890. idx: val.substring(expressionPos + 1, expressionEndPos)
  37891. }
  37892. }
  37893. function next () {
  37894. return str.charCodeAt(++index$1)
  37895. }
  37896. function eof () {
  37897. return index$1 >= len
  37898. }
  37899. function isStringStart (chr) {
  37900. return chr === 0x22 || chr === 0x27
  37901. }
  37902. function parseBracket (chr) {
  37903. var inBracket = 1;
  37904. expressionPos = index$1;
  37905. while (!eof()) {
  37906. chr = next();
  37907. if (isStringStart(chr)) {
  37908. parseString(chr);
  37909. continue
  37910. }
  37911. if (chr === 0x5B) { inBracket++; }
  37912. if (chr === 0x5D) { inBracket--; }
  37913. if (inBracket === 0) {
  37914. expressionEndPos = index$1;
  37915. break
  37916. }
  37917. }
  37918. }
  37919. function parseString (chr) {
  37920. var stringQuote = chr;
  37921. while (!eof()) {
  37922. chr = next();
  37923. if (chr === stringQuote) {
  37924. break
  37925. }
  37926. }
  37927. }
  37928. /* */
  37929. var warn$1;
  37930. // in some cases, the event used has to be determined at runtime
  37931. // so we used some reserved tokens during compile.
  37932. var RANGE_TOKEN = '__r';
  37933. var CHECKBOX_RADIO_TOKEN = '__c';
  37934. function model (
  37935. el,
  37936. dir,
  37937. _warn
  37938. ) {
  37939. warn$1 = _warn;
  37940. var value = dir.value;
  37941. var modifiers = dir.modifiers;
  37942. var tag = el.tag;
  37943. var type = el.attrsMap.type;
  37944. if (true) {
  37945. var dynamicType = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  37946. if (tag === 'input' && dynamicType) {
  37947. warn$1(
  37948. "<input :type=\"" + dynamicType + "\" v-model=\"" + value + "\">:\n" +
  37949. "v-model does not support dynamic input types. Use v-if branches instead."
  37950. );
  37951. }
  37952. // inputs with type="file" are read only and setting the input's
  37953. // value will throw an error.
  37954. if (tag === 'input' && type === 'file') {
  37955. warn$1(
  37956. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  37957. "File inputs are read only. Use a v-on:change listener instead."
  37958. );
  37959. }
  37960. }
  37961. if (tag === 'select') {
  37962. genSelect(el, value, modifiers);
  37963. } else if (tag === 'input' && type === 'checkbox') {
  37964. genCheckboxModel(el, value, modifiers);
  37965. } else if (tag === 'input' && type === 'radio') {
  37966. genRadioModel(el, value, modifiers);
  37967. } else if (tag === 'input' || tag === 'textarea') {
  37968. genDefaultModel(el, value, modifiers);
  37969. } else if (!config.isReservedTag(tag)) {
  37970. genComponentModel(el, value, modifiers);
  37971. // component v-model doesn't need extra runtime
  37972. return false
  37973. } else if (true) {
  37974. warn$1(
  37975. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  37976. "v-model is not supported on this element type. " +
  37977. 'If you are working with contenteditable, it\'s recommended to ' +
  37978. 'wrap a library dedicated for that purpose inside a custom component.'
  37979. );
  37980. }
  37981. // ensure runtime directive metadata
  37982. return true
  37983. }
  37984. function genCheckboxModel (
  37985. el,
  37986. value,
  37987. modifiers
  37988. ) {
  37989. var number = modifiers && modifiers.number;
  37990. var valueBinding = getBindingAttr(el, 'value') || 'null';
  37991. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  37992. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  37993. addProp(el, 'checked',
  37994. "Array.isArray(" + value + ")" +
  37995. "?_i(" + value + "," + valueBinding + ")>-1" + (
  37996. trueValueBinding === 'true'
  37997. ? (":(" + value + ")")
  37998. : (":_q(" + value + "," + trueValueBinding + ")")
  37999. )
  38000. );
  38001. addHandler(el, CHECKBOX_RADIO_TOKEN,
  38002. "var $$a=" + value + "," +
  38003. '$$el=$event.target,' +
  38004. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  38005. 'if(Array.isArray($$a)){' +
  38006. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  38007. '$$i=_i($$a,$$v);' +
  38008. "if($$c){$$i<0&&(" + value + "=$$a.concat($$v))}" +
  38009. "else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
  38010. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  38011. null, true
  38012. );
  38013. }
  38014. function genRadioModel (
  38015. el,
  38016. value,
  38017. modifiers
  38018. ) {
  38019. var number = modifiers && modifiers.number;
  38020. var valueBinding = getBindingAttr(el, 'value') || 'null';
  38021. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  38022. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  38023. addHandler(el, CHECKBOX_RADIO_TOKEN, genAssignmentCode(value, valueBinding), null, true);
  38024. }
  38025. function genSelect (
  38026. el,
  38027. value,
  38028. modifiers
  38029. ) {
  38030. var number = modifiers && modifiers.number;
  38031. var selectedVal = "Array.prototype.filter" +
  38032. ".call($event.target.options,function(o){return o.selected})" +
  38033. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  38034. "return " + (number ? '_n(val)' : 'val') + "})";
  38035. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  38036. var code = "var $$selectedVal = " + selectedVal + ";";
  38037. code = code + " " + (genAssignmentCode(value, assignment));
  38038. addHandler(el, 'change', code, null, true);
  38039. }
  38040. function genDefaultModel (
  38041. el,
  38042. value,
  38043. modifiers
  38044. ) {
  38045. var type = el.attrsMap.type;
  38046. var ref = modifiers || {};
  38047. var lazy = ref.lazy;
  38048. var number = ref.number;
  38049. var trim = ref.trim;
  38050. var needCompositionGuard = !lazy && type !== 'range';
  38051. var event = lazy
  38052. ? 'change'
  38053. : type === 'range'
  38054. ? RANGE_TOKEN
  38055. : 'input';
  38056. var valueExpression = '$event.target.value';
  38057. if (trim) {
  38058. valueExpression = "$event.target.value.trim()";
  38059. }
  38060. if (number) {
  38061. valueExpression = "_n(" + valueExpression + ")";
  38062. }
  38063. var code = genAssignmentCode(value, valueExpression);
  38064. if (needCompositionGuard) {
  38065. code = "if($event.target.composing)return;" + code;
  38066. }
  38067. addProp(el, 'value', ("(" + value + ")"));
  38068. addHandler(el, event, code, null, true);
  38069. if (trim || number || type === 'number') {
  38070. addHandler(el, 'blur', '$forceUpdate()');
  38071. }
  38072. }
  38073. /* */
  38074. // normalize v-model event tokens that can only be determined at runtime.
  38075. // it's important to place the event as the first in the array because
  38076. // the whole point is ensuring the v-model callback gets called before
  38077. // user-attached handlers.
  38078. function normalizeEvents (on) {
  38079. var event;
  38080. /* istanbul ignore if */
  38081. if (isDef(on[RANGE_TOKEN])) {
  38082. // IE input[type=range] only supports `change` event
  38083. event = isIE ? 'change' : 'input';
  38084. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  38085. delete on[RANGE_TOKEN];
  38086. }
  38087. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  38088. // Chrome fires microtasks in between click/change, leads to #4521
  38089. event = isChrome ? 'click' : 'change';
  38090. on[event] = [].concat(on[CHECKBOX_RADIO_TOKEN], on[event] || []);
  38091. delete on[CHECKBOX_RADIO_TOKEN];
  38092. }
  38093. }
  38094. var target$1;
  38095. function add$1 (
  38096. event,
  38097. handler,
  38098. once$$1,
  38099. capture,
  38100. passive
  38101. ) {
  38102. if (once$$1) {
  38103. var oldHandler = handler;
  38104. var _target = target$1; // save current target element in closure
  38105. handler = function (ev) {
  38106. var res = arguments.length === 1
  38107. ? oldHandler(ev)
  38108. : oldHandler.apply(null, arguments);
  38109. if (res !== null) {
  38110. remove$2(event, handler, capture, _target);
  38111. }
  38112. };
  38113. }
  38114. target$1.addEventListener(
  38115. event,
  38116. handler,
  38117. supportsPassive
  38118. ? { capture: capture, passive: passive }
  38119. : capture
  38120. );
  38121. }
  38122. function remove$2 (
  38123. event,
  38124. handler,
  38125. capture,
  38126. _target
  38127. ) {
  38128. (_target || target$1).removeEventListener(event, handler, capture);
  38129. }
  38130. function updateDOMListeners (oldVnode, vnode) {
  38131. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  38132. return
  38133. }
  38134. var on = vnode.data.on || {};
  38135. var oldOn = oldVnode.data.on || {};
  38136. target$1 = vnode.elm;
  38137. normalizeEvents(on);
  38138. updateListeners(on, oldOn, add$1, remove$2, vnode.context);
  38139. }
  38140. var events = {
  38141. create: updateDOMListeners,
  38142. update: updateDOMListeners
  38143. };
  38144. /* */
  38145. function updateDOMProps (oldVnode, vnode) {
  38146. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  38147. return
  38148. }
  38149. var key, cur;
  38150. var elm = vnode.elm;
  38151. var oldProps = oldVnode.data.domProps || {};
  38152. var props = vnode.data.domProps || {};
  38153. // clone observed objects, as the user probably wants to mutate it
  38154. if (isDef(props.__ob__)) {
  38155. props = vnode.data.domProps = extend({}, props);
  38156. }
  38157. for (key in oldProps) {
  38158. if (isUndef(props[key])) {
  38159. elm[key] = '';
  38160. }
  38161. }
  38162. for (key in props) {
  38163. cur = props[key];
  38164. // ignore children if the node has textContent or innerHTML,
  38165. // as these will throw away existing DOM nodes and cause removal errors
  38166. // on subsequent patches (#3360)
  38167. if (key === 'textContent' || key === 'innerHTML') {
  38168. if (vnode.children) { vnode.children.length = 0; }
  38169. if (cur === oldProps[key]) { continue }
  38170. }
  38171. if (key === 'value') {
  38172. // store value as _value as well since
  38173. // non-string values will be stringified
  38174. elm._value = cur;
  38175. // avoid resetting cursor position when value is the same
  38176. var strCur = isUndef(cur) ? '' : String(cur);
  38177. if (shouldUpdateValue(elm, vnode, strCur)) {
  38178. elm.value = strCur;
  38179. }
  38180. } else {
  38181. elm[key] = cur;
  38182. }
  38183. }
  38184. }
  38185. // check platforms/web/util/attrs.js acceptValue
  38186. function shouldUpdateValue (
  38187. elm,
  38188. vnode,
  38189. checkVal
  38190. ) {
  38191. return (!elm.composing && (
  38192. vnode.tag === 'option' ||
  38193. isDirty(elm, checkVal) ||
  38194. isInputChanged(elm, checkVal)
  38195. ))
  38196. }
  38197. function isDirty (elm, checkVal) {
  38198. // return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value
  38199. return document.activeElement !== elm && elm.value !== checkVal
  38200. }
  38201. function isInputChanged (elm, newVal) {
  38202. var value = elm.value;
  38203. var modifiers = elm._vModifiers; // injected by v-model runtime
  38204. if ((isDef(modifiers) && modifiers.number) || elm.type === 'number') {
  38205. return toNumber(value) !== toNumber(newVal)
  38206. }
  38207. if (isDef(modifiers) && modifiers.trim) {
  38208. return value.trim() !== newVal.trim()
  38209. }
  38210. return value !== newVal
  38211. }
  38212. var domProps = {
  38213. create: updateDOMProps,
  38214. update: updateDOMProps
  38215. };
  38216. /* */
  38217. var parseStyleText = cached(function (cssText) {
  38218. var res = {};
  38219. var listDelimiter = /;(?![^(]*\))/g;
  38220. var propertyDelimiter = /:(.+)/;
  38221. cssText.split(listDelimiter).forEach(function (item) {
  38222. if (item) {
  38223. var tmp = item.split(propertyDelimiter);
  38224. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  38225. }
  38226. });
  38227. return res
  38228. });
  38229. // merge static and dynamic style data on the same vnode
  38230. function normalizeStyleData (data) {
  38231. var style = normalizeStyleBinding(data.style);
  38232. // static style is pre-processed into an object during compilation
  38233. // and is always a fresh object, so it's safe to merge into it
  38234. return data.staticStyle
  38235. ? extend(data.staticStyle, style)
  38236. : style
  38237. }
  38238. // normalize possible array / string values into Object
  38239. function normalizeStyleBinding (bindingStyle) {
  38240. if (Array.isArray(bindingStyle)) {
  38241. return toObject(bindingStyle)
  38242. }
  38243. if (typeof bindingStyle === 'string') {
  38244. return parseStyleText(bindingStyle)
  38245. }
  38246. return bindingStyle
  38247. }
  38248. /**
  38249. * parent component style should be after child's
  38250. * so that parent component's style could override it
  38251. */
  38252. function getStyle (vnode, checkChild) {
  38253. var res = {};
  38254. var styleData;
  38255. if (checkChild) {
  38256. var childNode = vnode;
  38257. while (childNode.componentInstance) {
  38258. childNode = childNode.componentInstance._vnode;
  38259. if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
  38260. extend(res, styleData);
  38261. }
  38262. }
  38263. }
  38264. if ((styleData = normalizeStyleData(vnode.data))) {
  38265. extend(res, styleData);
  38266. }
  38267. var parentNode = vnode;
  38268. while ((parentNode = parentNode.parent)) {
  38269. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  38270. extend(res, styleData);
  38271. }
  38272. }
  38273. return res
  38274. }
  38275. /* */
  38276. var cssVarRE = /^--/;
  38277. var importantRE = /\s*!important$/;
  38278. var setProp = function (el, name, val) {
  38279. /* istanbul ignore if */
  38280. if (cssVarRE.test(name)) {
  38281. el.style.setProperty(name, val);
  38282. } else if (importantRE.test(val)) {
  38283. el.style.setProperty(name, val.replace(importantRE, ''), 'important');
  38284. } else {
  38285. var normalizedName = normalize(name);
  38286. if (Array.isArray(val)) {
  38287. // Support values array created by autoprefixer, e.g.
  38288. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  38289. // Set them one by one, and the browser will only set those it can recognize
  38290. for (var i = 0, len = val.length; i < len; i++) {
  38291. el.style[normalizedName] = val[i];
  38292. }
  38293. } else {
  38294. el.style[normalizedName] = val;
  38295. }
  38296. }
  38297. };
  38298. var prefixes = ['Webkit', 'Moz', 'ms'];
  38299. var testEl;
  38300. var normalize = cached(function (prop) {
  38301. testEl = testEl || document.createElement('div');
  38302. prop = camelize(prop);
  38303. if (prop !== 'filter' && (prop in testEl.style)) {
  38304. return prop
  38305. }
  38306. var upper = prop.charAt(0).toUpperCase() + prop.slice(1);
  38307. for (var i = 0; i < prefixes.length; i++) {
  38308. var prefixed = prefixes[i] + upper;
  38309. if (prefixed in testEl.style) {
  38310. return prefixed
  38311. }
  38312. }
  38313. });
  38314. function updateStyle (oldVnode, vnode) {
  38315. var data = vnode.data;
  38316. var oldData = oldVnode.data;
  38317. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  38318. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  38319. ) {
  38320. return
  38321. }
  38322. var cur, name;
  38323. var el = vnode.elm;
  38324. var oldStaticStyle = oldData.staticStyle;
  38325. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  38326. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  38327. var oldStyle = oldStaticStyle || oldStyleBinding;
  38328. var style = normalizeStyleBinding(vnode.data.style) || {};
  38329. // store normalized style under a different key for next diff
  38330. // make sure to clone it if it's reactive, since the user likley wants
  38331. // to mutate it.
  38332. vnode.data.normalizedStyle = isDef(style.__ob__)
  38333. ? extend({}, style)
  38334. : style;
  38335. var newStyle = getStyle(vnode, true);
  38336. for (name in oldStyle) {
  38337. if (isUndef(newStyle[name])) {
  38338. setProp(el, name, '');
  38339. }
  38340. }
  38341. for (name in newStyle) {
  38342. cur = newStyle[name];
  38343. if (cur !== oldStyle[name]) {
  38344. // ie9 setting to null has no effect, must use empty string
  38345. setProp(el, name, cur == null ? '' : cur);
  38346. }
  38347. }
  38348. }
  38349. var style = {
  38350. create: updateStyle,
  38351. update: updateStyle
  38352. };
  38353. /* */
  38354. /**
  38355. * Add class with compatibility for SVG since classList is not supported on
  38356. * SVG elements in IE
  38357. */
  38358. function addClass (el, cls) {
  38359. /* istanbul ignore if */
  38360. if (!cls || !(cls = cls.trim())) {
  38361. return
  38362. }
  38363. /* istanbul ignore else */
  38364. if (el.classList) {
  38365. if (cls.indexOf(' ') > -1) {
  38366. cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); });
  38367. } else {
  38368. el.classList.add(cls);
  38369. }
  38370. } else {
  38371. var cur = " " + (el.getAttribute('class') || '') + " ";
  38372. if (cur.indexOf(' ' + cls + ' ') < 0) {
  38373. el.setAttribute('class', (cur + cls).trim());
  38374. }
  38375. }
  38376. }
  38377. /**
  38378. * Remove class with compatibility for SVG since classList is not supported on
  38379. * SVG elements in IE
  38380. */
  38381. function removeClass (el, cls) {
  38382. /* istanbul ignore if */
  38383. if (!cls || !(cls = cls.trim())) {
  38384. return
  38385. }
  38386. /* istanbul ignore else */
  38387. if (el.classList) {
  38388. if (cls.indexOf(' ') > -1) {
  38389. cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
  38390. } else {
  38391. el.classList.remove(cls);
  38392. }
  38393. } else {
  38394. var cur = " " + (el.getAttribute('class') || '') + " ";
  38395. var tar = ' ' + cls + ' ';
  38396. while (cur.indexOf(tar) >= 0) {
  38397. cur = cur.replace(tar, ' ');
  38398. }
  38399. el.setAttribute('class', cur.trim());
  38400. }
  38401. }
  38402. /* */
  38403. function resolveTransition (def$$1) {
  38404. if (!def$$1) {
  38405. return
  38406. }
  38407. /* istanbul ignore else */
  38408. if (typeof def$$1 === 'object') {
  38409. var res = {};
  38410. if (def$$1.css !== false) {
  38411. extend(res, autoCssTransition(def$$1.name || 'v'));
  38412. }
  38413. extend(res, def$$1);
  38414. return res
  38415. } else if (typeof def$$1 === 'string') {
  38416. return autoCssTransition(def$$1)
  38417. }
  38418. }
  38419. var autoCssTransition = cached(function (name) {
  38420. return {
  38421. enterClass: (name + "-enter"),
  38422. enterToClass: (name + "-enter-to"),
  38423. enterActiveClass: (name + "-enter-active"),
  38424. leaveClass: (name + "-leave"),
  38425. leaveToClass: (name + "-leave-to"),
  38426. leaveActiveClass: (name + "-leave-active")
  38427. }
  38428. });
  38429. var hasTransition = inBrowser && !isIE9;
  38430. var TRANSITION = 'transition';
  38431. var ANIMATION = 'animation';
  38432. // Transition property/event sniffing
  38433. var transitionProp = 'transition';
  38434. var transitionEndEvent = 'transitionend';
  38435. var animationProp = 'animation';
  38436. var animationEndEvent = 'animationend';
  38437. if (hasTransition) {
  38438. /* istanbul ignore if */
  38439. if (window.ontransitionend === undefined &&
  38440. window.onwebkittransitionend !== undefined
  38441. ) {
  38442. transitionProp = 'WebkitTransition';
  38443. transitionEndEvent = 'webkitTransitionEnd';
  38444. }
  38445. if (window.onanimationend === undefined &&
  38446. window.onwebkitanimationend !== undefined
  38447. ) {
  38448. animationProp = 'WebkitAnimation';
  38449. animationEndEvent = 'webkitAnimationEnd';
  38450. }
  38451. }
  38452. // binding to window is necessary to make hot reload work in IE in strict mode
  38453. var raf = inBrowser && window.requestAnimationFrame
  38454. ? window.requestAnimationFrame.bind(window)
  38455. : setTimeout;
  38456. function nextFrame (fn) {
  38457. raf(function () {
  38458. raf(fn);
  38459. });
  38460. }
  38461. function addTransitionClass (el, cls) {
  38462. (el._transitionClasses || (el._transitionClasses = [])).push(cls);
  38463. addClass(el, cls);
  38464. }
  38465. function removeTransitionClass (el, cls) {
  38466. if (el._transitionClasses) {
  38467. remove(el._transitionClasses, cls);
  38468. }
  38469. removeClass(el, cls);
  38470. }
  38471. function whenTransitionEnds (
  38472. el,
  38473. expectedType,
  38474. cb
  38475. ) {
  38476. var ref = getTransitionInfo(el, expectedType);
  38477. var type = ref.type;
  38478. var timeout = ref.timeout;
  38479. var propCount = ref.propCount;
  38480. if (!type) { return cb() }
  38481. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  38482. var ended = 0;
  38483. var end = function () {
  38484. el.removeEventListener(event, onEnd);
  38485. cb();
  38486. };
  38487. var onEnd = function (e) {
  38488. if (e.target === el) {
  38489. if (++ended >= propCount) {
  38490. end();
  38491. }
  38492. }
  38493. };
  38494. setTimeout(function () {
  38495. if (ended < propCount) {
  38496. end();
  38497. }
  38498. }, timeout + 1);
  38499. el.addEventListener(event, onEnd);
  38500. }
  38501. var transformRE = /\b(transform|all)(,|$)/;
  38502. function getTransitionInfo (el, expectedType) {
  38503. var styles = window.getComputedStyle(el);
  38504. var transitionDelays = styles[transitionProp + 'Delay'].split(', ');
  38505. var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
  38506. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  38507. var animationDelays = styles[animationProp + 'Delay'].split(', ');
  38508. var animationDurations = styles[animationProp + 'Duration'].split(', ');
  38509. var animationTimeout = getTimeout(animationDelays, animationDurations);
  38510. var type;
  38511. var timeout = 0;
  38512. var propCount = 0;
  38513. /* istanbul ignore if */
  38514. if (expectedType === TRANSITION) {
  38515. if (transitionTimeout > 0) {
  38516. type = TRANSITION;
  38517. timeout = transitionTimeout;
  38518. propCount = transitionDurations.length;
  38519. }
  38520. } else if (expectedType === ANIMATION) {
  38521. if (animationTimeout > 0) {
  38522. type = ANIMATION;
  38523. timeout = animationTimeout;
  38524. propCount = animationDurations.length;
  38525. }
  38526. } else {
  38527. timeout = Math.max(transitionTimeout, animationTimeout);
  38528. type = timeout > 0
  38529. ? transitionTimeout > animationTimeout
  38530. ? TRANSITION
  38531. : ANIMATION
  38532. : null;
  38533. propCount = type
  38534. ? type === TRANSITION
  38535. ? transitionDurations.length
  38536. : animationDurations.length
  38537. : 0;
  38538. }
  38539. var hasTransform =
  38540. type === TRANSITION &&
  38541. transformRE.test(styles[transitionProp + 'Property']);
  38542. return {
  38543. type: type,
  38544. timeout: timeout,
  38545. propCount: propCount,
  38546. hasTransform: hasTransform
  38547. }
  38548. }
  38549. function getTimeout (delays, durations) {
  38550. /* istanbul ignore next */
  38551. while (delays.length < durations.length) {
  38552. delays = delays.concat(delays);
  38553. }
  38554. return Math.max.apply(null, durations.map(function (d, i) {
  38555. return toMs(d) + toMs(delays[i])
  38556. }))
  38557. }
  38558. function toMs (s) {
  38559. return Number(s.slice(0, -1)) * 1000
  38560. }
  38561. /* */
  38562. function enter (vnode, toggleDisplay) {
  38563. var el = vnode.elm;
  38564. // call leave callback now
  38565. if (isDef(el._leaveCb)) {
  38566. el._leaveCb.cancelled = true;
  38567. el._leaveCb();
  38568. }
  38569. var data = resolveTransition(vnode.data.transition);
  38570. if (isUndef(data)) {
  38571. return
  38572. }
  38573. /* istanbul ignore if */
  38574. if (isDef(el._enterCb) || el.nodeType !== 1) {
  38575. return
  38576. }
  38577. var css = data.css;
  38578. var type = data.type;
  38579. var enterClass = data.enterClass;
  38580. var enterToClass = data.enterToClass;
  38581. var enterActiveClass = data.enterActiveClass;
  38582. var appearClass = data.appearClass;
  38583. var appearToClass = data.appearToClass;
  38584. var appearActiveClass = data.appearActiveClass;
  38585. var beforeEnter = data.beforeEnter;
  38586. var enter = data.enter;
  38587. var afterEnter = data.afterEnter;
  38588. var enterCancelled = data.enterCancelled;
  38589. var beforeAppear = data.beforeAppear;
  38590. var appear = data.appear;
  38591. var afterAppear = data.afterAppear;
  38592. var appearCancelled = data.appearCancelled;
  38593. var duration = data.duration;
  38594. // activeInstance will always be the <transition> component managing this
  38595. // transition. One edge case to check is when the <transition> is placed
  38596. // as the root node of a child component. In that case we need to check
  38597. // <transition>'s parent for appear check.
  38598. var context = activeInstance;
  38599. var transitionNode = activeInstance.$vnode;
  38600. while (transitionNode && transitionNode.parent) {
  38601. transitionNode = transitionNode.parent;
  38602. context = transitionNode.context;
  38603. }
  38604. var isAppear = !context._isMounted || !vnode.isRootInsert;
  38605. if (isAppear && !appear && appear !== '') {
  38606. return
  38607. }
  38608. var startClass = isAppear && appearClass
  38609. ? appearClass
  38610. : enterClass;
  38611. var activeClass = isAppear && appearActiveClass
  38612. ? appearActiveClass
  38613. : enterActiveClass;
  38614. var toClass = isAppear && appearToClass
  38615. ? appearToClass
  38616. : enterToClass;
  38617. var beforeEnterHook = isAppear
  38618. ? (beforeAppear || beforeEnter)
  38619. : beforeEnter;
  38620. var enterHook = isAppear
  38621. ? (typeof appear === 'function' ? appear : enter)
  38622. : enter;
  38623. var afterEnterHook = isAppear
  38624. ? (afterAppear || afterEnter)
  38625. : afterEnter;
  38626. var enterCancelledHook = isAppear
  38627. ? (appearCancelled || enterCancelled)
  38628. : enterCancelled;
  38629. var explicitEnterDuration = toNumber(
  38630. isObject(duration)
  38631. ? duration.enter
  38632. : duration
  38633. );
  38634. if ("development" !== 'production' && explicitEnterDuration != null) {
  38635. checkDuration(explicitEnterDuration, 'enter', vnode);
  38636. }
  38637. var expectsCSS = css !== false && !isIE9;
  38638. var userWantsControl = getHookArgumentsLength(enterHook);
  38639. var cb = el._enterCb = once(function () {
  38640. if (expectsCSS) {
  38641. removeTransitionClass(el, toClass);
  38642. removeTransitionClass(el, activeClass);
  38643. }
  38644. if (cb.cancelled) {
  38645. if (expectsCSS) {
  38646. removeTransitionClass(el, startClass);
  38647. }
  38648. enterCancelledHook && enterCancelledHook(el);
  38649. } else {
  38650. afterEnterHook && afterEnterHook(el);
  38651. }
  38652. el._enterCb = null;
  38653. });
  38654. if (!vnode.data.show) {
  38655. // remove pending leave element on enter by injecting an insert hook
  38656. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
  38657. var parent = el.parentNode;
  38658. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  38659. if (pendingNode &&
  38660. pendingNode.tag === vnode.tag &&
  38661. pendingNode.elm._leaveCb
  38662. ) {
  38663. pendingNode.elm._leaveCb();
  38664. }
  38665. enterHook && enterHook(el, cb);
  38666. });
  38667. }
  38668. // start enter transition
  38669. beforeEnterHook && beforeEnterHook(el);
  38670. if (expectsCSS) {
  38671. addTransitionClass(el, startClass);
  38672. addTransitionClass(el, activeClass);
  38673. nextFrame(function () {
  38674. addTransitionClass(el, toClass);
  38675. removeTransitionClass(el, startClass);
  38676. if (!cb.cancelled && !userWantsControl) {
  38677. if (isValidDuration(explicitEnterDuration)) {
  38678. setTimeout(cb, explicitEnterDuration);
  38679. } else {
  38680. whenTransitionEnds(el, type, cb);
  38681. }
  38682. }
  38683. });
  38684. }
  38685. if (vnode.data.show) {
  38686. toggleDisplay && toggleDisplay();
  38687. enterHook && enterHook(el, cb);
  38688. }
  38689. if (!expectsCSS && !userWantsControl) {
  38690. cb();
  38691. }
  38692. }
  38693. function leave (vnode, rm) {
  38694. var el = vnode.elm;
  38695. // call enter callback now
  38696. if (isDef(el._enterCb)) {
  38697. el._enterCb.cancelled = true;
  38698. el._enterCb();
  38699. }
  38700. var data = resolveTransition(vnode.data.transition);
  38701. if (isUndef(data)) {
  38702. return rm()
  38703. }
  38704. /* istanbul ignore if */
  38705. if (isDef(el._leaveCb) || el.nodeType !== 1) {
  38706. return
  38707. }
  38708. var css = data.css;
  38709. var type = data.type;
  38710. var leaveClass = data.leaveClass;
  38711. var leaveToClass = data.leaveToClass;
  38712. var leaveActiveClass = data.leaveActiveClass;
  38713. var beforeLeave = data.beforeLeave;
  38714. var leave = data.leave;
  38715. var afterLeave = data.afterLeave;
  38716. var leaveCancelled = data.leaveCancelled;
  38717. var delayLeave = data.delayLeave;
  38718. var duration = data.duration;
  38719. var expectsCSS = css !== false && !isIE9;
  38720. var userWantsControl = getHookArgumentsLength(leave);
  38721. var explicitLeaveDuration = toNumber(
  38722. isObject(duration)
  38723. ? duration.leave
  38724. : duration
  38725. );
  38726. if ("development" !== 'production' && isDef(explicitLeaveDuration)) {
  38727. checkDuration(explicitLeaveDuration, 'leave', vnode);
  38728. }
  38729. var cb = el._leaveCb = once(function () {
  38730. if (el.parentNode && el.parentNode._pending) {
  38731. el.parentNode._pending[vnode.key] = null;
  38732. }
  38733. if (expectsCSS) {
  38734. removeTransitionClass(el, leaveToClass);
  38735. removeTransitionClass(el, leaveActiveClass);
  38736. }
  38737. if (cb.cancelled) {
  38738. if (expectsCSS) {
  38739. removeTransitionClass(el, leaveClass);
  38740. }
  38741. leaveCancelled && leaveCancelled(el);
  38742. } else {
  38743. rm();
  38744. afterLeave && afterLeave(el);
  38745. }
  38746. el._leaveCb = null;
  38747. });
  38748. if (delayLeave) {
  38749. delayLeave(performLeave);
  38750. } else {
  38751. performLeave();
  38752. }
  38753. function performLeave () {
  38754. // the delayed leave may have already been cancelled
  38755. if (cb.cancelled) {
  38756. return
  38757. }
  38758. // record leaving element
  38759. if (!vnode.data.show) {
  38760. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  38761. }
  38762. beforeLeave && beforeLeave(el);
  38763. if (expectsCSS) {
  38764. addTransitionClass(el, leaveClass);
  38765. addTransitionClass(el, leaveActiveClass);
  38766. nextFrame(function () {
  38767. addTransitionClass(el, leaveToClass);
  38768. removeTransitionClass(el, leaveClass);
  38769. if (!cb.cancelled && !userWantsControl) {
  38770. if (isValidDuration(explicitLeaveDuration)) {
  38771. setTimeout(cb, explicitLeaveDuration);
  38772. } else {
  38773. whenTransitionEnds(el, type, cb);
  38774. }
  38775. }
  38776. });
  38777. }
  38778. leave && leave(el, cb);
  38779. if (!expectsCSS && !userWantsControl) {
  38780. cb();
  38781. }
  38782. }
  38783. }
  38784. // only used in dev mode
  38785. function checkDuration (val, name, vnode) {
  38786. if (typeof val !== 'number') {
  38787. warn(
  38788. "<transition> explicit " + name + " duration is not a valid number - " +
  38789. "got " + (JSON.stringify(val)) + ".",
  38790. vnode.context
  38791. );
  38792. } else if (isNaN(val)) {
  38793. warn(
  38794. "<transition> explicit " + name + " duration is NaN - " +
  38795. 'the duration expression might be incorrect.',
  38796. vnode.context
  38797. );
  38798. }
  38799. }
  38800. function isValidDuration (val) {
  38801. return typeof val === 'number' && !isNaN(val)
  38802. }
  38803. /**
  38804. * Normalize a transition hook's argument length. The hook may be:
  38805. * - a merged hook (invoker) with the original in .fns
  38806. * - a wrapped component method (check ._length)
  38807. * - a plain function (.length)
  38808. */
  38809. function getHookArgumentsLength (fn) {
  38810. if (isUndef(fn)) {
  38811. return false
  38812. }
  38813. var invokerFns = fn.fns;
  38814. if (isDef(invokerFns)) {
  38815. // invoker
  38816. return getHookArgumentsLength(
  38817. Array.isArray(invokerFns)
  38818. ? invokerFns[0]
  38819. : invokerFns
  38820. )
  38821. } else {
  38822. return (fn._length || fn.length) > 1
  38823. }
  38824. }
  38825. function _enter (_, vnode) {
  38826. if (vnode.data.show !== true) {
  38827. enter(vnode);
  38828. }
  38829. }
  38830. var transition = inBrowser ? {
  38831. create: _enter,
  38832. activate: _enter,
  38833. remove: function remove$$1 (vnode, rm) {
  38834. /* istanbul ignore else */
  38835. if (vnode.data.show !== true) {
  38836. leave(vnode, rm);
  38837. } else {
  38838. rm();
  38839. }
  38840. }
  38841. } : {};
  38842. var platformModules = [
  38843. attrs,
  38844. klass,
  38845. events,
  38846. domProps,
  38847. style,
  38848. transition
  38849. ];
  38850. /* */
  38851. // the directive module should be applied last, after all
  38852. // built-in modules have been applied.
  38853. var modules = platformModules.concat(baseModules);
  38854. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  38855. /**
  38856. * Not type checking this file because flow doesn't like attaching
  38857. * properties to Elements.
  38858. */
  38859. /* istanbul ignore if */
  38860. if (isIE9) {
  38861. // http://www.matts411.com/post/internet-explorer-9-oninput/
  38862. document.addEventListener('selectionchange', function () {
  38863. var el = document.activeElement;
  38864. if (el && el.vmodel) {
  38865. trigger(el, 'input');
  38866. }
  38867. });
  38868. }
  38869. var model$1 = {
  38870. inserted: function inserted (el, binding, vnode) {
  38871. if (vnode.tag === 'select') {
  38872. var cb = function () {
  38873. setSelected(el, binding, vnode.context);
  38874. };
  38875. cb();
  38876. /* istanbul ignore if */
  38877. if (isIE || isEdge) {
  38878. setTimeout(cb, 0);
  38879. }
  38880. } else if (vnode.tag === 'textarea' || el.type === 'text' || el.type === 'password') {
  38881. el._vModifiers = binding.modifiers;
  38882. if (!binding.modifiers.lazy) {
  38883. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  38884. // switching focus before confirming composition choice
  38885. // this also fixes the issue where some browsers e.g. iOS Chrome
  38886. // fires "change" instead of "input" on autocomplete.
  38887. el.addEventListener('change', onCompositionEnd);
  38888. if (!isAndroid) {
  38889. el.addEventListener('compositionstart', onCompositionStart);
  38890. el.addEventListener('compositionend', onCompositionEnd);
  38891. }
  38892. /* istanbul ignore if */
  38893. if (isIE9) {
  38894. el.vmodel = true;
  38895. }
  38896. }
  38897. }
  38898. },
  38899. componentUpdated: function componentUpdated (el, binding, vnode) {
  38900. if (vnode.tag === 'select') {
  38901. setSelected(el, binding, vnode.context);
  38902. // in case the options rendered by v-for have changed,
  38903. // it's possible that the value is out-of-sync with the rendered options.
  38904. // detect such cases and filter out values that no longer has a matching
  38905. // option in the DOM.
  38906. var needReset = el.multiple
  38907. ? binding.value.some(function (v) { return hasNoMatchingOption(v, el.options); })
  38908. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options);
  38909. if (needReset) {
  38910. trigger(el, 'change');
  38911. }
  38912. }
  38913. }
  38914. };
  38915. function setSelected (el, binding, vm) {
  38916. var value = binding.value;
  38917. var isMultiple = el.multiple;
  38918. if (isMultiple && !Array.isArray(value)) {
  38919. "development" !== 'production' && warn(
  38920. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  38921. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  38922. vm
  38923. );
  38924. return
  38925. }
  38926. var selected, option;
  38927. for (var i = 0, l = el.options.length; i < l; i++) {
  38928. option = el.options[i];
  38929. if (isMultiple) {
  38930. selected = looseIndexOf(value, getValue(option)) > -1;
  38931. if (option.selected !== selected) {
  38932. option.selected = selected;
  38933. }
  38934. } else {
  38935. if (looseEqual(getValue(option), value)) {
  38936. if (el.selectedIndex !== i) {
  38937. el.selectedIndex = i;
  38938. }
  38939. return
  38940. }
  38941. }
  38942. }
  38943. if (!isMultiple) {
  38944. el.selectedIndex = -1;
  38945. }
  38946. }
  38947. function hasNoMatchingOption (value, options) {
  38948. for (var i = 0, l = options.length; i < l; i++) {
  38949. if (looseEqual(getValue(options[i]), value)) {
  38950. return false
  38951. }
  38952. }
  38953. return true
  38954. }
  38955. function getValue (option) {
  38956. return '_value' in option
  38957. ? option._value
  38958. : option.value
  38959. }
  38960. function onCompositionStart (e) {
  38961. e.target.composing = true;
  38962. }
  38963. function onCompositionEnd (e) {
  38964. // prevent triggering an input event for no reason
  38965. if (!e.target.composing) { return }
  38966. e.target.composing = false;
  38967. trigger(e.target, 'input');
  38968. }
  38969. function trigger (el, type) {
  38970. var e = document.createEvent('HTMLEvents');
  38971. e.initEvent(type, true, true);
  38972. el.dispatchEvent(e);
  38973. }
  38974. /* */
  38975. // recursively search for possible transition defined inside the component root
  38976. function locateNode (vnode) {
  38977. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  38978. ? locateNode(vnode.componentInstance._vnode)
  38979. : vnode
  38980. }
  38981. var show = {
  38982. bind: function bind (el, ref, vnode) {
  38983. var value = ref.value;
  38984. vnode = locateNode(vnode);
  38985. var transition = vnode.data && vnode.data.transition;
  38986. var originalDisplay = el.__vOriginalDisplay =
  38987. el.style.display === 'none' ? '' : el.style.display;
  38988. if (value && transition && !isIE9) {
  38989. vnode.data.show = true;
  38990. enter(vnode, function () {
  38991. el.style.display = originalDisplay;
  38992. });
  38993. } else {
  38994. el.style.display = value ? originalDisplay : 'none';
  38995. }
  38996. },
  38997. update: function update (el, ref, vnode) {
  38998. var value = ref.value;
  38999. var oldValue = ref.oldValue;
  39000. /* istanbul ignore if */
  39001. if (value === oldValue) { return }
  39002. vnode = locateNode(vnode);
  39003. var transition = vnode.data && vnode.data.transition;
  39004. if (transition && !isIE9) {
  39005. vnode.data.show = true;
  39006. if (value) {
  39007. enter(vnode, function () {
  39008. el.style.display = el.__vOriginalDisplay;
  39009. });
  39010. } else {
  39011. leave(vnode, function () {
  39012. el.style.display = 'none';
  39013. });
  39014. }
  39015. } else {
  39016. el.style.display = value ? el.__vOriginalDisplay : 'none';
  39017. }
  39018. },
  39019. unbind: function unbind (
  39020. el,
  39021. binding,
  39022. vnode,
  39023. oldVnode,
  39024. isDestroy
  39025. ) {
  39026. if (!isDestroy) {
  39027. el.style.display = el.__vOriginalDisplay;
  39028. }
  39029. }
  39030. };
  39031. var platformDirectives = {
  39032. model: model$1,
  39033. show: show
  39034. };
  39035. /* */
  39036. // Provides transition support for a single element/component.
  39037. // supports transition mode (out-in / in-out)
  39038. var transitionProps = {
  39039. name: String,
  39040. appear: Boolean,
  39041. css: Boolean,
  39042. mode: String,
  39043. type: String,
  39044. enterClass: String,
  39045. leaveClass: String,
  39046. enterToClass: String,
  39047. leaveToClass: String,
  39048. enterActiveClass: String,
  39049. leaveActiveClass: String,
  39050. appearClass: String,
  39051. appearActiveClass: String,
  39052. appearToClass: String,
  39053. duration: [Number, String, Object]
  39054. };
  39055. // in case the child is also an abstract component, e.g. <keep-alive>
  39056. // we want to recursively retrieve the real component to be rendered
  39057. function getRealChild (vnode) {
  39058. var compOptions = vnode && vnode.componentOptions;
  39059. if (compOptions && compOptions.Ctor.options.abstract) {
  39060. return getRealChild(getFirstComponentChild(compOptions.children))
  39061. } else {
  39062. return vnode
  39063. }
  39064. }
  39065. function extractTransitionData (comp) {
  39066. var data = {};
  39067. var options = comp.$options;
  39068. // props
  39069. for (var key in options.propsData) {
  39070. data[key] = comp[key];
  39071. }
  39072. // events.
  39073. // extract listeners and pass them directly to the transition methods
  39074. var listeners = options._parentListeners;
  39075. for (var key$1 in listeners) {
  39076. data[camelize(key$1)] = listeners[key$1];
  39077. }
  39078. return data
  39079. }
  39080. function placeholder (h, rawChild) {
  39081. if (/\d-keep-alive$/.test(rawChild.tag)) {
  39082. return h('keep-alive', {
  39083. props: rawChild.componentOptions.propsData
  39084. })
  39085. }
  39086. }
  39087. function hasParentTransition (vnode) {
  39088. while ((vnode = vnode.parent)) {
  39089. if (vnode.data.transition) {
  39090. return true
  39091. }
  39092. }
  39093. }
  39094. function isSameChild (child, oldChild) {
  39095. return oldChild.key === child.key && oldChild.tag === child.tag
  39096. }
  39097. var Transition = {
  39098. name: 'transition',
  39099. props: transitionProps,
  39100. abstract: true,
  39101. render: function render (h) {
  39102. var this$1 = this;
  39103. var children = this.$slots.default;
  39104. if (!children) {
  39105. return
  39106. }
  39107. // filter out text nodes (possible whitespaces)
  39108. children = children.filter(function (c) { return c.tag; });
  39109. /* istanbul ignore if */
  39110. if (!children.length) {
  39111. return
  39112. }
  39113. // warn multiple elements
  39114. if ("development" !== 'production' && children.length > 1) {
  39115. warn(
  39116. '<transition> can only be used on a single element. Use ' +
  39117. '<transition-group> for lists.',
  39118. this.$parent
  39119. );
  39120. }
  39121. var mode = this.mode;
  39122. // warn invalid mode
  39123. if ("development" !== 'production' &&
  39124. mode && mode !== 'in-out' && mode !== 'out-in'
  39125. ) {
  39126. warn(
  39127. 'invalid <transition> mode: ' + mode,
  39128. this.$parent
  39129. );
  39130. }
  39131. var rawChild = children[0];
  39132. // if this is a component root node and the component's
  39133. // parent container node also has transition, skip.
  39134. if (hasParentTransition(this.$vnode)) {
  39135. return rawChild
  39136. }
  39137. // apply transition data to child
  39138. // use getRealChild() to ignore abstract components e.g. keep-alive
  39139. var child = getRealChild(rawChild);
  39140. /* istanbul ignore if */
  39141. if (!child) {
  39142. return rawChild
  39143. }
  39144. if (this._leaving) {
  39145. return placeholder(h, rawChild)
  39146. }
  39147. // ensure a key that is unique to the vnode type and to this transition
  39148. // component instance. This key will be used to remove pending leaving nodes
  39149. // during entering.
  39150. var id = "__transition-" + (this._uid) + "-";
  39151. child.key = child.key == null
  39152. ? id + child.tag
  39153. : isPrimitive(child.key)
  39154. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  39155. : child.key;
  39156. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  39157. var oldRawChild = this._vnode;
  39158. var oldChild = getRealChild(oldRawChild);
  39159. // mark v-show
  39160. // so that the transition module can hand over the control to the directive
  39161. if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
  39162. child.data.show = true;
  39163. }
  39164. if (oldChild && oldChild.data && !isSameChild(child, oldChild)) {
  39165. // replace old child transition data with fresh one
  39166. // important for dynamic transitions!
  39167. var oldData = oldChild && (oldChild.data.transition = extend({}, data));
  39168. // handle transition mode
  39169. if (mode === 'out-in') {
  39170. // return placeholder node and queue update when leave finishes
  39171. this._leaving = true;
  39172. mergeVNodeHook(oldData, 'afterLeave', function () {
  39173. this$1._leaving = false;
  39174. this$1.$forceUpdate();
  39175. });
  39176. return placeholder(h, rawChild)
  39177. } else if (mode === 'in-out') {
  39178. var delayedLeave;
  39179. var performLeave = function () { delayedLeave(); };
  39180. mergeVNodeHook(data, 'afterEnter', performLeave);
  39181. mergeVNodeHook(data, 'enterCancelled', performLeave);
  39182. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  39183. }
  39184. }
  39185. return rawChild
  39186. }
  39187. };
  39188. /* */
  39189. // Provides transition support for list items.
  39190. // supports move transitions using the FLIP technique.
  39191. // Because the vdom's children update algorithm is "unstable" - i.e.
  39192. // it doesn't guarantee the relative positioning of removed elements,
  39193. // we force transition-group to update its children into two passes:
  39194. // in the first pass, we remove all nodes that need to be removed,
  39195. // triggering their leaving transition; in the second pass, we insert/move
  39196. // into the final desired state. This way in the second pass removed
  39197. // nodes will remain where they should be.
  39198. var props = extend({
  39199. tag: String,
  39200. moveClass: String
  39201. }, transitionProps);
  39202. delete props.mode;
  39203. var TransitionGroup = {
  39204. props: props,
  39205. render: function render (h) {
  39206. var tag = this.tag || this.$vnode.data.tag || 'span';
  39207. var map = Object.create(null);
  39208. var prevChildren = this.prevChildren = this.children;
  39209. var rawChildren = this.$slots.default || [];
  39210. var children = this.children = [];
  39211. var transitionData = extractTransitionData(this);
  39212. for (var i = 0; i < rawChildren.length; i++) {
  39213. var c = rawChildren[i];
  39214. if (c.tag) {
  39215. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  39216. children.push(c);
  39217. map[c.key] = c
  39218. ;(c.data || (c.data = {})).transition = transitionData;
  39219. } else if (true) {
  39220. var opts = c.componentOptions;
  39221. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  39222. warn(("<transition-group> children must be keyed: <" + name + ">"));
  39223. }
  39224. }
  39225. }
  39226. if (prevChildren) {
  39227. var kept = [];
  39228. var removed = [];
  39229. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  39230. var c$1 = prevChildren[i$1];
  39231. c$1.data.transition = transitionData;
  39232. c$1.data.pos = c$1.elm.getBoundingClientRect();
  39233. if (map[c$1.key]) {
  39234. kept.push(c$1);
  39235. } else {
  39236. removed.push(c$1);
  39237. }
  39238. }
  39239. this.kept = h(tag, null, kept);
  39240. this.removed = removed;
  39241. }
  39242. return h(tag, null, children)
  39243. },
  39244. beforeUpdate: function beforeUpdate () {
  39245. // force removing pass
  39246. this.__patch__(
  39247. this._vnode,
  39248. this.kept,
  39249. false, // hydrating
  39250. true // removeOnly (!important, avoids unnecessary moves)
  39251. );
  39252. this._vnode = this.kept;
  39253. },
  39254. updated: function updated () {
  39255. var children = this.prevChildren;
  39256. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  39257. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  39258. return
  39259. }
  39260. // we divide the work into three loops to avoid mixing DOM reads and writes
  39261. // in each iteration - which helps prevent layout thrashing.
  39262. children.forEach(callPendingCbs);
  39263. children.forEach(recordPosition);
  39264. children.forEach(applyTranslation);
  39265. // force reflow to put everything in position
  39266. var body = document.body;
  39267. var f = body.offsetHeight; // eslint-disable-line
  39268. children.forEach(function (c) {
  39269. if (c.data.moved) {
  39270. var el = c.elm;
  39271. var s = el.style;
  39272. addTransitionClass(el, moveClass);
  39273. s.transform = s.WebkitTransform = s.transitionDuration = '';
  39274. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  39275. if (!e || /transform$/.test(e.propertyName)) {
  39276. el.removeEventListener(transitionEndEvent, cb);
  39277. el._moveCb = null;
  39278. removeTransitionClass(el, moveClass);
  39279. }
  39280. });
  39281. }
  39282. });
  39283. },
  39284. methods: {
  39285. hasMove: function hasMove (el, moveClass) {
  39286. /* istanbul ignore if */
  39287. if (!hasTransition) {
  39288. return false
  39289. }
  39290. if (this._hasMove != null) {
  39291. return this._hasMove
  39292. }
  39293. // Detect whether an element with the move class applied has
  39294. // CSS transitions. Since the element may be inside an entering
  39295. // transition at this very moment, we make a clone of it and remove
  39296. // all other transition classes applied to ensure only the move class
  39297. // is applied.
  39298. var clone = el.cloneNode();
  39299. if (el._transitionClasses) {
  39300. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  39301. }
  39302. addClass(clone, moveClass);
  39303. clone.style.display = 'none';
  39304. this.$el.appendChild(clone);
  39305. var info = getTransitionInfo(clone);
  39306. this.$el.removeChild(clone);
  39307. return (this._hasMove = info.hasTransform)
  39308. }
  39309. }
  39310. };
  39311. function callPendingCbs (c) {
  39312. /* istanbul ignore if */
  39313. if (c.elm._moveCb) {
  39314. c.elm._moveCb();
  39315. }
  39316. /* istanbul ignore if */
  39317. if (c.elm._enterCb) {
  39318. c.elm._enterCb();
  39319. }
  39320. }
  39321. function recordPosition (c) {
  39322. c.data.newPos = c.elm.getBoundingClientRect();
  39323. }
  39324. function applyTranslation (c) {
  39325. var oldPos = c.data.pos;
  39326. var newPos = c.data.newPos;
  39327. var dx = oldPos.left - newPos.left;
  39328. var dy = oldPos.top - newPos.top;
  39329. if (dx || dy) {
  39330. c.data.moved = true;
  39331. var s = c.elm.style;
  39332. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  39333. s.transitionDuration = '0s';
  39334. }
  39335. }
  39336. var platformComponents = {
  39337. Transition: Transition,
  39338. TransitionGroup: TransitionGroup
  39339. };
  39340. /* */
  39341. // install platform specific utils
  39342. Vue$3.config.mustUseProp = mustUseProp;
  39343. Vue$3.config.isReservedTag = isReservedTag;
  39344. Vue$3.config.isReservedAttr = isReservedAttr;
  39345. Vue$3.config.getTagNamespace = getTagNamespace;
  39346. Vue$3.config.isUnknownElement = isUnknownElement;
  39347. // install platform runtime directives & components
  39348. extend(Vue$3.options.directives, platformDirectives);
  39349. extend(Vue$3.options.components, platformComponents);
  39350. // install platform patch function
  39351. Vue$3.prototype.__patch__ = inBrowser ? patch : noop;
  39352. // public mount method
  39353. Vue$3.prototype.$mount = function (
  39354. el,
  39355. hydrating
  39356. ) {
  39357. el = el && inBrowser ? query(el) : undefined;
  39358. return mountComponent(this, el, hydrating)
  39359. };
  39360. // devtools global hook
  39361. /* istanbul ignore next */
  39362. setTimeout(function () {
  39363. if (config.devtools) {
  39364. if (devtools) {
  39365. devtools.emit('init', Vue$3);
  39366. } else if ("development" !== 'production' && isChrome) {
  39367. console[console.info ? 'info' : 'log'](
  39368. 'Download the Vue Devtools extension for a better development experience:\n' +
  39369. 'https://github.com/vuejs/vue-devtools'
  39370. );
  39371. }
  39372. }
  39373. if ("development" !== 'production' &&
  39374. config.productionTip !== false &&
  39375. inBrowser && typeof console !== 'undefined'
  39376. ) {
  39377. console[console.info ? 'info' : 'log'](
  39378. "You are running Vue in development mode.\n" +
  39379. "Make sure to turn on production mode when deploying for production.\n" +
  39380. "See more tips at https://vuejs.org/guide/deployment.html"
  39381. );
  39382. }
  39383. }, 0);
  39384. /* */
  39385. // check whether current browser encodes a char inside attribute values
  39386. function shouldDecode (content, encoded) {
  39387. var div = document.createElement('div');
  39388. div.innerHTML = "<div a=\"" + content + "\">";
  39389. return div.innerHTML.indexOf(encoded) > 0
  39390. }
  39391. // #3663
  39392. // IE encodes newlines inside attribute values while other browsers don't
  39393. var shouldDecodeNewlines = inBrowser ? shouldDecode('\n', '&#10;') : false;
  39394. /* */
  39395. var isUnaryTag = makeMap(
  39396. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  39397. 'link,meta,param,source,track,wbr'
  39398. );
  39399. // Elements that you can, intentionally, leave open
  39400. // (and which close themselves)
  39401. var canBeLeftOpenTag = makeMap(
  39402. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  39403. );
  39404. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  39405. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  39406. var isNonPhrasingTag = makeMap(
  39407. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  39408. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  39409. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  39410. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  39411. 'title,tr,track'
  39412. );
  39413. /* */
  39414. var decoder;
  39415. function decode (html) {
  39416. decoder = decoder || document.createElement('div');
  39417. decoder.innerHTML = html;
  39418. return decoder.textContent
  39419. }
  39420. /**
  39421. * Not type-checking this file because it's mostly vendor code.
  39422. */
  39423. /*!
  39424. * HTML Parser By John Resig (ejohn.org)
  39425. * Modified by Juriy "kangax" Zaytsev
  39426. * Original code by Erik Arvidsson, Mozilla Public License
  39427. * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
  39428. */
  39429. // Regular Expressions for parsing tags and attributes
  39430. var singleAttrIdentifier = /([^\s"'<>/=]+)/;
  39431. var singleAttrAssign = /(?:=)/;
  39432. var singleAttrValues = [
  39433. // attr value double quotes
  39434. /"([^"]*)"+/.source,
  39435. // attr value, single quotes
  39436. /'([^']*)'+/.source,
  39437. // attr value, no quotes
  39438. /([^\s"'=<>`]+)/.source
  39439. ];
  39440. var attribute = new RegExp(
  39441. '^\\s*' + singleAttrIdentifier.source +
  39442. '(?:\\s*(' + singleAttrAssign.source + ')' +
  39443. '\\s*(?:' + singleAttrValues.join('|') + '))?'
  39444. );
  39445. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  39446. // but for Vue templates we can enforce a simple charset
  39447. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  39448. var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
  39449. var startTagOpen = new RegExp('^<' + qnameCapture);
  39450. var startTagClose = /^\s*(\/?)>/;
  39451. var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
  39452. var doctype = /^<!DOCTYPE [^>]+>/i;
  39453. var comment = /^<!--/;
  39454. var conditionalComment = /^<!\[/;
  39455. var IS_REGEX_CAPTURING_BROKEN = false;
  39456. 'x'.replace(/x(.)?/g, function (m, g) {
  39457. IS_REGEX_CAPTURING_BROKEN = g === '';
  39458. });
  39459. // Special Elements (can contain anything)
  39460. var isPlainTextElement = makeMap('script,style,textarea', true);
  39461. var reCache = {};
  39462. var decodingMap = {
  39463. '&lt;': '<',
  39464. '&gt;': '>',
  39465. '&quot;': '"',
  39466. '&amp;': '&',
  39467. '&#10;': '\n'
  39468. };
  39469. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  39470. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g;
  39471. function decodeAttr (value, shouldDecodeNewlines) {
  39472. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  39473. return value.replace(re, function (match) { return decodingMap[match]; })
  39474. }
  39475. function parseHTML (html, options) {
  39476. var stack = [];
  39477. var expectHTML = options.expectHTML;
  39478. var isUnaryTag$$1 = options.isUnaryTag || no;
  39479. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  39480. var index = 0;
  39481. var last, lastTag;
  39482. while (html) {
  39483. last = html;
  39484. // Make sure we're not in a plaintext content element like script/style
  39485. if (!lastTag || !isPlainTextElement(lastTag)) {
  39486. var textEnd = html.indexOf('<');
  39487. if (textEnd === 0) {
  39488. // Comment:
  39489. if (comment.test(html)) {
  39490. var commentEnd = html.indexOf('-->');
  39491. if (commentEnd >= 0) {
  39492. advance(commentEnd + 3);
  39493. continue
  39494. }
  39495. }
  39496. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  39497. if (conditionalComment.test(html)) {
  39498. var conditionalEnd = html.indexOf(']>');
  39499. if (conditionalEnd >= 0) {
  39500. advance(conditionalEnd + 2);
  39501. continue
  39502. }
  39503. }
  39504. // Doctype:
  39505. var doctypeMatch = html.match(doctype);
  39506. if (doctypeMatch) {
  39507. advance(doctypeMatch[0].length);
  39508. continue
  39509. }
  39510. // End tag:
  39511. var endTagMatch = html.match(endTag);
  39512. if (endTagMatch) {
  39513. var curIndex = index;
  39514. advance(endTagMatch[0].length);
  39515. parseEndTag(endTagMatch[1], curIndex, index);
  39516. continue
  39517. }
  39518. // Start tag:
  39519. var startTagMatch = parseStartTag();
  39520. if (startTagMatch) {
  39521. handleStartTag(startTagMatch);
  39522. continue
  39523. }
  39524. }
  39525. var text = (void 0), rest$1 = (void 0), next = (void 0);
  39526. if (textEnd >= 0) {
  39527. rest$1 = html.slice(textEnd);
  39528. while (
  39529. !endTag.test(rest$1) &&
  39530. !startTagOpen.test(rest$1) &&
  39531. !comment.test(rest$1) &&
  39532. !conditionalComment.test(rest$1)
  39533. ) {
  39534. // < in plain text, be forgiving and treat it as text
  39535. next = rest$1.indexOf('<', 1);
  39536. if (next < 0) { break }
  39537. textEnd += next;
  39538. rest$1 = html.slice(textEnd);
  39539. }
  39540. text = html.substring(0, textEnd);
  39541. advance(textEnd);
  39542. }
  39543. if (textEnd < 0) {
  39544. text = html;
  39545. html = '';
  39546. }
  39547. if (options.chars && text) {
  39548. options.chars(text);
  39549. }
  39550. } else {
  39551. var stackedTag = lastTag.toLowerCase();
  39552. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  39553. var endTagLength = 0;
  39554. var rest = html.replace(reStackedTag, function (all, text, endTag) {
  39555. endTagLength = endTag.length;
  39556. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  39557. text = text
  39558. .replace(/<!--([\s\S]*?)-->/g, '$1')
  39559. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  39560. }
  39561. if (options.chars) {
  39562. options.chars(text);
  39563. }
  39564. return ''
  39565. });
  39566. index += html.length - rest.length;
  39567. html = rest;
  39568. parseEndTag(stackedTag, index - endTagLength, index);
  39569. }
  39570. if (html === last) {
  39571. options.chars && options.chars(html);
  39572. if ("development" !== 'production' && !stack.length && options.warn) {
  39573. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  39574. }
  39575. break
  39576. }
  39577. }
  39578. // Clean up any remaining tags
  39579. parseEndTag();
  39580. function advance (n) {
  39581. index += n;
  39582. html = html.substring(n);
  39583. }
  39584. function parseStartTag () {
  39585. var start = html.match(startTagOpen);
  39586. if (start) {
  39587. var match = {
  39588. tagName: start[1],
  39589. attrs: [],
  39590. start: index
  39591. };
  39592. advance(start[0].length);
  39593. var end, attr;
  39594. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  39595. advance(attr[0].length);
  39596. match.attrs.push(attr);
  39597. }
  39598. if (end) {
  39599. match.unarySlash = end[1];
  39600. advance(end[0].length);
  39601. match.end = index;
  39602. return match
  39603. }
  39604. }
  39605. }
  39606. function handleStartTag (match) {
  39607. var tagName = match.tagName;
  39608. var unarySlash = match.unarySlash;
  39609. if (expectHTML) {
  39610. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  39611. parseEndTag(lastTag);
  39612. }
  39613. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  39614. parseEndTag(tagName);
  39615. }
  39616. }
  39617. var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
  39618. var l = match.attrs.length;
  39619. var attrs = new Array(l);
  39620. for (var i = 0; i < l; i++) {
  39621. var args = match.attrs[i];
  39622. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  39623. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  39624. if (args[3] === '') { delete args[3]; }
  39625. if (args[4] === '') { delete args[4]; }
  39626. if (args[5] === '') { delete args[5]; }
  39627. }
  39628. var value = args[3] || args[4] || args[5] || '';
  39629. attrs[i] = {
  39630. name: args[1],
  39631. value: decodeAttr(
  39632. value,
  39633. options.shouldDecodeNewlines
  39634. )
  39635. };
  39636. }
  39637. if (!unary) {
  39638. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  39639. lastTag = tagName;
  39640. }
  39641. if (options.start) {
  39642. options.start(tagName, attrs, unary, match.start, match.end);
  39643. }
  39644. }
  39645. function parseEndTag (tagName, start, end) {
  39646. var pos, lowerCasedTagName;
  39647. if (start == null) { start = index; }
  39648. if (end == null) { end = index; }
  39649. if (tagName) {
  39650. lowerCasedTagName = tagName.toLowerCase();
  39651. }
  39652. // Find the closest opened tag of the same type
  39653. if (tagName) {
  39654. for (pos = stack.length - 1; pos >= 0; pos--) {
  39655. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  39656. break
  39657. }
  39658. }
  39659. } else {
  39660. // If no tag name is provided, clean shop
  39661. pos = 0;
  39662. }
  39663. if (pos >= 0) {
  39664. // Close all the open elements, up the stack
  39665. for (var i = stack.length - 1; i >= pos; i--) {
  39666. if ("development" !== 'production' &&
  39667. (i > pos || !tagName) &&
  39668. options.warn
  39669. ) {
  39670. options.warn(
  39671. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  39672. );
  39673. }
  39674. if (options.end) {
  39675. options.end(stack[i].tag, start, end);
  39676. }
  39677. }
  39678. // Remove the open elements from the stack
  39679. stack.length = pos;
  39680. lastTag = pos && stack[pos - 1].tag;
  39681. } else if (lowerCasedTagName === 'br') {
  39682. if (options.start) {
  39683. options.start(tagName, [], true, start, end);
  39684. }
  39685. } else if (lowerCasedTagName === 'p') {
  39686. if (options.start) {
  39687. options.start(tagName, [], false, start, end);
  39688. }
  39689. if (options.end) {
  39690. options.end(tagName, start, end);
  39691. }
  39692. }
  39693. }
  39694. }
  39695. /* */
  39696. var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
  39697. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  39698. var buildRegex = cached(function (delimiters) {
  39699. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  39700. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  39701. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  39702. });
  39703. function parseText (
  39704. text,
  39705. delimiters
  39706. ) {
  39707. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  39708. if (!tagRE.test(text)) {
  39709. return
  39710. }
  39711. var tokens = [];
  39712. var lastIndex = tagRE.lastIndex = 0;
  39713. var match, index;
  39714. while ((match = tagRE.exec(text))) {
  39715. index = match.index;
  39716. // push text token
  39717. if (index > lastIndex) {
  39718. tokens.push(JSON.stringify(text.slice(lastIndex, index)));
  39719. }
  39720. // tag token
  39721. var exp = parseFilters(match[1].trim());
  39722. tokens.push(("_s(" + exp + ")"));
  39723. lastIndex = index + match[0].length;
  39724. }
  39725. if (lastIndex < text.length) {
  39726. tokens.push(JSON.stringify(text.slice(lastIndex)));
  39727. }
  39728. return tokens.join('+')
  39729. }
  39730. /* */
  39731. var onRE = /^@|^v-on:/;
  39732. var dirRE = /^v-|^@|^:/;
  39733. var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
  39734. var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
  39735. var argRE = /:(.*)$/;
  39736. var bindRE = /^:|^v-bind:/;
  39737. var modifierRE = /\.[^.]+/g;
  39738. var decodeHTMLCached = cached(decode);
  39739. // configurable state
  39740. var warn$2;
  39741. var delimiters;
  39742. var transforms;
  39743. var preTransforms;
  39744. var postTransforms;
  39745. var platformIsPreTag;
  39746. var platformMustUseProp;
  39747. var platformGetTagNamespace;
  39748. /**
  39749. * Convert HTML string to AST.
  39750. */
  39751. function parse (
  39752. template,
  39753. options
  39754. ) {
  39755. warn$2 = options.warn || baseWarn;
  39756. platformGetTagNamespace = options.getTagNamespace || no;
  39757. platformMustUseProp = options.mustUseProp || no;
  39758. platformIsPreTag = options.isPreTag || no;
  39759. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  39760. transforms = pluckModuleFunction(options.modules, 'transformNode');
  39761. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  39762. delimiters = options.delimiters;
  39763. var stack = [];
  39764. var preserveWhitespace = options.preserveWhitespace !== false;
  39765. var root;
  39766. var currentParent;
  39767. var inVPre = false;
  39768. var inPre = false;
  39769. var warned = false;
  39770. function warnOnce (msg) {
  39771. if (!warned) {
  39772. warned = true;
  39773. warn$2(msg);
  39774. }
  39775. }
  39776. function endPre (element) {
  39777. // check pre state
  39778. if (element.pre) {
  39779. inVPre = false;
  39780. }
  39781. if (platformIsPreTag(element.tag)) {
  39782. inPre = false;
  39783. }
  39784. }
  39785. parseHTML(template, {
  39786. warn: warn$2,
  39787. expectHTML: options.expectHTML,
  39788. isUnaryTag: options.isUnaryTag,
  39789. canBeLeftOpenTag: options.canBeLeftOpenTag,
  39790. shouldDecodeNewlines: options.shouldDecodeNewlines,
  39791. start: function start (tag, attrs, unary) {
  39792. // check namespace.
  39793. // inherit parent ns if there is one
  39794. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  39795. // handle IE svg bug
  39796. /* istanbul ignore if */
  39797. if (isIE && ns === 'svg') {
  39798. attrs = guardIESVGBug(attrs);
  39799. }
  39800. var element = {
  39801. type: 1,
  39802. tag: tag,
  39803. attrsList: attrs,
  39804. attrsMap: makeAttrsMap(attrs),
  39805. parent: currentParent,
  39806. children: []
  39807. };
  39808. if (ns) {
  39809. element.ns = ns;
  39810. }
  39811. if (isForbiddenTag(element) && !isServerRendering()) {
  39812. element.forbidden = true;
  39813. "development" !== 'production' && warn$2(
  39814. 'Templates should only be responsible for mapping the state to the ' +
  39815. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  39816. "<" + tag + ">" + ', as they will not be parsed.'
  39817. );
  39818. }
  39819. // apply pre-transforms
  39820. for (var i = 0; i < preTransforms.length; i++) {
  39821. preTransforms[i](element, options);
  39822. }
  39823. if (!inVPre) {
  39824. processPre(element);
  39825. if (element.pre) {
  39826. inVPre = true;
  39827. }
  39828. }
  39829. if (platformIsPreTag(element.tag)) {
  39830. inPre = true;
  39831. }
  39832. if (inVPre) {
  39833. processRawAttrs(element);
  39834. } else {
  39835. processFor(element);
  39836. processIf(element);
  39837. processOnce(element);
  39838. processKey(element);
  39839. // determine whether this is a plain element after
  39840. // removing structural attributes
  39841. element.plain = !element.key && !attrs.length;
  39842. processRef(element);
  39843. processSlot(element);
  39844. processComponent(element);
  39845. for (var i$1 = 0; i$1 < transforms.length; i$1++) {
  39846. transforms[i$1](element, options);
  39847. }
  39848. processAttrs(element);
  39849. }
  39850. function checkRootConstraints (el) {
  39851. if (true) {
  39852. if (el.tag === 'slot' || el.tag === 'template') {
  39853. warnOnce(
  39854. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  39855. 'contain multiple nodes.'
  39856. );
  39857. }
  39858. if (el.attrsMap.hasOwnProperty('v-for')) {
  39859. warnOnce(
  39860. 'Cannot use v-for on stateful component root element because ' +
  39861. 'it renders multiple elements.'
  39862. );
  39863. }
  39864. }
  39865. }
  39866. // tree management
  39867. if (!root) {
  39868. root = element;
  39869. checkRootConstraints(root);
  39870. } else if (!stack.length) {
  39871. // allow root elements with v-if, v-else-if and v-else
  39872. if (root.if && (element.elseif || element.else)) {
  39873. checkRootConstraints(element);
  39874. addIfCondition(root, {
  39875. exp: element.elseif,
  39876. block: element
  39877. });
  39878. } else if (true) {
  39879. warnOnce(
  39880. "Component template should contain exactly one root element. " +
  39881. "If you are using v-if on multiple elements, " +
  39882. "use v-else-if to chain them instead."
  39883. );
  39884. }
  39885. }
  39886. if (currentParent && !element.forbidden) {
  39887. if (element.elseif || element.else) {
  39888. processIfConditions(element, currentParent);
  39889. } else if (element.slotScope) { // scoped slot
  39890. currentParent.plain = false;
  39891. var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  39892. } else {
  39893. currentParent.children.push(element);
  39894. element.parent = currentParent;
  39895. }
  39896. }
  39897. if (!unary) {
  39898. currentParent = element;
  39899. stack.push(element);
  39900. } else {
  39901. endPre(element);
  39902. }
  39903. // apply post-transforms
  39904. for (var i$2 = 0; i$2 < postTransforms.length; i$2++) {
  39905. postTransforms[i$2](element, options);
  39906. }
  39907. },
  39908. end: function end () {
  39909. // remove trailing whitespace
  39910. var element = stack[stack.length - 1];
  39911. var lastNode = element.children[element.children.length - 1];
  39912. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  39913. element.children.pop();
  39914. }
  39915. // pop stack
  39916. stack.length -= 1;
  39917. currentParent = stack[stack.length - 1];
  39918. endPre(element);
  39919. },
  39920. chars: function chars (text) {
  39921. if (!currentParent) {
  39922. if (true) {
  39923. if (text === template) {
  39924. warnOnce(
  39925. 'Component template requires a root element, rather than just text.'
  39926. );
  39927. } else if ((text = text.trim())) {
  39928. warnOnce(
  39929. ("text \"" + text + "\" outside root element will be ignored.")
  39930. );
  39931. }
  39932. }
  39933. return
  39934. }
  39935. // IE textarea placeholder bug
  39936. /* istanbul ignore if */
  39937. if (isIE &&
  39938. currentParent.tag === 'textarea' &&
  39939. currentParent.attrsMap.placeholder === text
  39940. ) {
  39941. return
  39942. }
  39943. var children = currentParent.children;
  39944. text = inPre || text.trim()
  39945. ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
  39946. // only preserve whitespace if its not right after a starting tag
  39947. : preserveWhitespace && children.length ? ' ' : '';
  39948. if (text) {
  39949. var expression;
  39950. if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
  39951. children.push({
  39952. type: 2,
  39953. expression: expression,
  39954. text: text
  39955. });
  39956. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  39957. children.push({
  39958. type: 3,
  39959. text: text
  39960. });
  39961. }
  39962. }
  39963. }
  39964. });
  39965. return root
  39966. }
  39967. function processPre (el) {
  39968. if (getAndRemoveAttr(el, 'v-pre') != null) {
  39969. el.pre = true;
  39970. }
  39971. }
  39972. function processRawAttrs (el) {
  39973. var l = el.attrsList.length;
  39974. if (l) {
  39975. var attrs = el.attrs = new Array(l);
  39976. for (var i = 0; i < l; i++) {
  39977. attrs[i] = {
  39978. name: el.attrsList[i].name,
  39979. value: JSON.stringify(el.attrsList[i].value)
  39980. };
  39981. }
  39982. } else if (!el.pre) {
  39983. // non root node in pre blocks with no attributes
  39984. el.plain = true;
  39985. }
  39986. }
  39987. function processKey (el) {
  39988. var exp = getBindingAttr(el, 'key');
  39989. if (exp) {
  39990. if ("development" !== 'production' && el.tag === 'template') {
  39991. warn$2("<template> cannot be keyed. Place the key on real elements instead.");
  39992. }
  39993. el.key = exp;
  39994. }
  39995. }
  39996. function processRef (el) {
  39997. var ref = getBindingAttr(el, 'ref');
  39998. if (ref) {
  39999. el.ref = ref;
  40000. el.refInFor = checkInFor(el);
  40001. }
  40002. }
  40003. function processFor (el) {
  40004. var exp;
  40005. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  40006. var inMatch = exp.match(forAliasRE);
  40007. if (!inMatch) {
  40008. "development" !== 'production' && warn$2(
  40009. ("Invalid v-for expression: " + exp)
  40010. );
  40011. return
  40012. }
  40013. el.for = inMatch[2].trim();
  40014. var alias = inMatch[1].trim();
  40015. var iteratorMatch = alias.match(forIteratorRE);
  40016. if (iteratorMatch) {
  40017. el.alias = iteratorMatch[1].trim();
  40018. el.iterator1 = iteratorMatch[2].trim();
  40019. if (iteratorMatch[3]) {
  40020. el.iterator2 = iteratorMatch[3].trim();
  40021. }
  40022. } else {
  40023. el.alias = alias;
  40024. }
  40025. }
  40026. }
  40027. function processIf (el) {
  40028. var exp = getAndRemoveAttr(el, 'v-if');
  40029. if (exp) {
  40030. el.if = exp;
  40031. addIfCondition(el, {
  40032. exp: exp,
  40033. block: el
  40034. });
  40035. } else {
  40036. if (getAndRemoveAttr(el, 'v-else') != null) {
  40037. el.else = true;
  40038. }
  40039. var elseif = getAndRemoveAttr(el, 'v-else-if');
  40040. if (elseif) {
  40041. el.elseif = elseif;
  40042. }
  40043. }
  40044. }
  40045. function processIfConditions (el, parent) {
  40046. var prev = findPrevElement(parent.children);
  40047. if (prev && prev.if) {
  40048. addIfCondition(prev, {
  40049. exp: el.elseif,
  40050. block: el
  40051. });
  40052. } else if (true) {
  40053. warn$2(
  40054. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  40055. "used on element <" + (el.tag) + "> without corresponding v-if."
  40056. );
  40057. }
  40058. }
  40059. function findPrevElement (children) {
  40060. var i = children.length;
  40061. while (i--) {
  40062. if (children[i].type === 1) {
  40063. return children[i]
  40064. } else {
  40065. if ("development" !== 'production' && children[i].text !== ' ') {
  40066. warn$2(
  40067. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  40068. "will be ignored."
  40069. );
  40070. }
  40071. children.pop();
  40072. }
  40073. }
  40074. }
  40075. function addIfCondition (el, condition) {
  40076. if (!el.ifConditions) {
  40077. el.ifConditions = [];
  40078. }
  40079. el.ifConditions.push(condition);
  40080. }
  40081. function processOnce (el) {
  40082. var once$$1 = getAndRemoveAttr(el, 'v-once');
  40083. if (once$$1 != null) {
  40084. el.once = true;
  40085. }
  40086. }
  40087. function processSlot (el) {
  40088. if (el.tag === 'slot') {
  40089. el.slotName = getBindingAttr(el, 'name');
  40090. if ("development" !== 'production' && el.key) {
  40091. warn$2(
  40092. "`key` does not work on <slot> because slots are abstract outlets " +
  40093. "and can possibly expand into multiple elements. " +
  40094. "Use the key on a wrapping element instead."
  40095. );
  40096. }
  40097. } else {
  40098. var slotTarget = getBindingAttr(el, 'slot');
  40099. if (slotTarget) {
  40100. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  40101. }
  40102. if (el.tag === 'template') {
  40103. el.slotScope = getAndRemoveAttr(el, 'scope');
  40104. }
  40105. }
  40106. }
  40107. function processComponent (el) {
  40108. var binding;
  40109. if ((binding = getBindingAttr(el, 'is'))) {
  40110. el.component = binding;
  40111. }
  40112. if (getAndRemoveAttr(el, 'inline-template') != null) {
  40113. el.inlineTemplate = true;
  40114. }
  40115. }
  40116. function processAttrs (el) {
  40117. var list = el.attrsList;
  40118. var i, l, name, rawName, value, modifiers, isProp;
  40119. for (i = 0, l = list.length; i < l; i++) {
  40120. name = rawName = list[i].name;
  40121. value = list[i].value;
  40122. if (dirRE.test(name)) {
  40123. // mark element as dynamic
  40124. el.hasBindings = true;
  40125. // modifiers
  40126. modifiers = parseModifiers(name);
  40127. if (modifiers) {
  40128. name = name.replace(modifierRE, '');
  40129. }
  40130. if (bindRE.test(name)) { // v-bind
  40131. name = name.replace(bindRE, '');
  40132. value = parseFilters(value);
  40133. isProp = false;
  40134. if (modifiers) {
  40135. if (modifiers.prop) {
  40136. isProp = true;
  40137. name = camelize(name);
  40138. if (name === 'innerHtml') { name = 'innerHTML'; }
  40139. }
  40140. if (modifiers.camel) {
  40141. name = camelize(name);
  40142. }
  40143. if (modifiers.sync) {
  40144. addHandler(
  40145. el,
  40146. ("update:" + (camelize(name))),
  40147. genAssignmentCode(value, "$event")
  40148. );
  40149. }
  40150. }
  40151. if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  40152. addProp(el, name, value);
  40153. } else {
  40154. addAttr(el, name, value);
  40155. }
  40156. } else if (onRE.test(name)) { // v-on
  40157. name = name.replace(onRE, '');
  40158. addHandler(el, name, value, modifiers, false, warn$2);
  40159. } else { // normal directives
  40160. name = name.replace(dirRE, '');
  40161. // parse arg
  40162. var argMatch = name.match(argRE);
  40163. var arg = argMatch && argMatch[1];
  40164. if (arg) {
  40165. name = name.slice(0, -(arg.length + 1));
  40166. }
  40167. addDirective(el, name, rawName, value, arg, modifiers);
  40168. if ("development" !== 'production' && name === 'model') {
  40169. checkForAliasModel(el, value);
  40170. }
  40171. }
  40172. } else {
  40173. // literal attribute
  40174. if (true) {
  40175. var expression = parseText(value, delimiters);
  40176. if (expression) {
  40177. warn$2(
  40178. name + "=\"" + value + "\": " +
  40179. 'Interpolation inside attributes has been removed. ' +
  40180. 'Use v-bind or the colon shorthand instead. For example, ' +
  40181. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  40182. );
  40183. }
  40184. }
  40185. addAttr(el, name, JSON.stringify(value));
  40186. }
  40187. }
  40188. }
  40189. function checkInFor (el) {
  40190. var parent = el;
  40191. while (parent) {
  40192. if (parent.for !== undefined) {
  40193. return true
  40194. }
  40195. parent = parent.parent;
  40196. }
  40197. return false
  40198. }
  40199. function parseModifiers (name) {
  40200. var match = name.match(modifierRE);
  40201. if (match) {
  40202. var ret = {};
  40203. match.forEach(function (m) { ret[m.slice(1)] = true; });
  40204. return ret
  40205. }
  40206. }
  40207. function makeAttrsMap (attrs) {
  40208. var map = {};
  40209. for (var i = 0, l = attrs.length; i < l; i++) {
  40210. if (
  40211. "development" !== 'production' &&
  40212. map[attrs[i].name] && !isIE && !isEdge
  40213. ) {
  40214. warn$2('duplicate attribute: ' + attrs[i].name);
  40215. }
  40216. map[attrs[i].name] = attrs[i].value;
  40217. }
  40218. return map
  40219. }
  40220. // for script (e.g. type="x/template") or style, do not decode content
  40221. function isTextTag (el) {
  40222. return el.tag === 'script' || el.tag === 'style'
  40223. }
  40224. function isForbiddenTag (el) {
  40225. return (
  40226. el.tag === 'style' ||
  40227. (el.tag === 'script' && (
  40228. !el.attrsMap.type ||
  40229. el.attrsMap.type === 'text/javascript'
  40230. ))
  40231. )
  40232. }
  40233. var ieNSBug = /^xmlns:NS\d+/;
  40234. var ieNSPrefix = /^NS\d+:/;
  40235. /* istanbul ignore next */
  40236. function guardIESVGBug (attrs) {
  40237. var res = [];
  40238. for (var i = 0; i < attrs.length; i++) {
  40239. var attr = attrs[i];
  40240. if (!ieNSBug.test(attr.name)) {
  40241. attr.name = attr.name.replace(ieNSPrefix, '');
  40242. res.push(attr);
  40243. }
  40244. }
  40245. return res
  40246. }
  40247. function checkForAliasModel (el, value) {
  40248. var _el = el;
  40249. while (_el) {
  40250. if (_el.for && _el.alias === value) {
  40251. warn$2(
  40252. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  40253. "You are binding v-model directly to a v-for iteration alias. " +
  40254. "This will not be able to modify the v-for source array because " +
  40255. "writing to the alias is like modifying a function local variable. " +
  40256. "Consider using an array of objects and use v-model on an object property instead."
  40257. );
  40258. }
  40259. _el = _el.parent;
  40260. }
  40261. }
  40262. /* */
  40263. var isStaticKey;
  40264. var isPlatformReservedTag;
  40265. var genStaticKeysCached = cached(genStaticKeys$1);
  40266. /**
  40267. * Goal of the optimizer: walk the generated template AST tree
  40268. * and detect sub-trees that are purely static, i.e. parts of
  40269. * the DOM that never needs to change.
  40270. *
  40271. * Once we detect these sub-trees, we can:
  40272. *
  40273. * 1. Hoist them into constants, so that we no longer need to
  40274. * create fresh nodes for them on each re-render;
  40275. * 2. Completely skip them in the patching process.
  40276. */
  40277. function optimize (root, options) {
  40278. if (!root) { return }
  40279. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  40280. isPlatformReservedTag = options.isReservedTag || no;
  40281. // first pass: mark all non-static nodes.
  40282. markStatic$1(root);
  40283. // second pass: mark static roots.
  40284. markStaticRoots(root, false);
  40285. }
  40286. function genStaticKeys$1 (keys) {
  40287. return makeMap(
  40288. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  40289. (keys ? ',' + keys : '')
  40290. )
  40291. }
  40292. function markStatic$1 (node) {
  40293. node.static = isStatic(node);
  40294. if (node.type === 1) {
  40295. // do not make component slot content static. this avoids
  40296. // 1. components not able to mutate slot nodes
  40297. // 2. static slot content fails for hot-reloading
  40298. if (
  40299. !isPlatformReservedTag(node.tag) &&
  40300. node.tag !== 'slot' &&
  40301. node.attrsMap['inline-template'] == null
  40302. ) {
  40303. return
  40304. }
  40305. for (var i = 0, l = node.children.length; i < l; i++) {
  40306. var child = node.children[i];
  40307. markStatic$1(child);
  40308. if (!child.static) {
  40309. node.static = false;
  40310. }
  40311. }
  40312. }
  40313. }
  40314. function markStaticRoots (node, isInFor) {
  40315. if (node.type === 1) {
  40316. if (node.static || node.once) {
  40317. node.staticInFor = isInFor;
  40318. }
  40319. // For a node to qualify as a static root, it should have children that
  40320. // are not just static text. Otherwise the cost of hoisting out will
  40321. // outweigh the benefits and it's better off to just always render it fresh.
  40322. if (node.static && node.children.length && !(
  40323. node.children.length === 1 &&
  40324. node.children[0].type === 3
  40325. )) {
  40326. node.staticRoot = true;
  40327. return
  40328. } else {
  40329. node.staticRoot = false;
  40330. }
  40331. if (node.children) {
  40332. for (var i = 0, l = node.children.length; i < l; i++) {
  40333. markStaticRoots(node.children[i], isInFor || !!node.for);
  40334. }
  40335. }
  40336. if (node.ifConditions) {
  40337. walkThroughConditionsBlocks(node.ifConditions, isInFor);
  40338. }
  40339. }
  40340. }
  40341. function walkThroughConditionsBlocks (conditionBlocks, isInFor) {
  40342. for (var i = 1, len = conditionBlocks.length; i < len; i++) {
  40343. markStaticRoots(conditionBlocks[i].block, isInFor);
  40344. }
  40345. }
  40346. function isStatic (node) {
  40347. if (node.type === 2) { // expression
  40348. return false
  40349. }
  40350. if (node.type === 3) { // text
  40351. return true
  40352. }
  40353. return !!(node.pre || (
  40354. !node.hasBindings && // no dynamic bindings
  40355. !node.if && !node.for && // not v-if or v-for or v-else
  40356. !isBuiltInTag(node.tag) && // not a built-in
  40357. isPlatformReservedTag(node.tag) && // not a component
  40358. !isDirectChildOfTemplateFor(node) &&
  40359. Object.keys(node).every(isStaticKey)
  40360. ))
  40361. }
  40362. function isDirectChildOfTemplateFor (node) {
  40363. while (node.parent) {
  40364. node = node.parent;
  40365. if (node.tag !== 'template') {
  40366. return false
  40367. }
  40368. if (node.for) {
  40369. return true
  40370. }
  40371. }
  40372. return false
  40373. }
  40374. /* */
  40375. var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  40376. var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
  40377. // keyCode aliases
  40378. var keyCodes = {
  40379. esc: 27,
  40380. tab: 9,
  40381. enter: 13,
  40382. space: 32,
  40383. up: 38,
  40384. left: 37,
  40385. right: 39,
  40386. down: 40,
  40387. 'delete': [8, 46]
  40388. };
  40389. // #4868: modifiers that prevent the execution of the listener
  40390. // need to explicitly return null so that we can determine whether to remove
  40391. // the listener for .once
  40392. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  40393. var modifierCode = {
  40394. stop: '$event.stopPropagation();',
  40395. prevent: '$event.preventDefault();',
  40396. self: genGuard("$event.target !== $event.currentTarget"),
  40397. ctrl: genGuard("!$event.ctrlKey"),
  40398. shift: genGuard("!$event.shiftKey"),
  40399. alt: genGuard("!$event.altKey"),
  40400. meta: genGuard("!$event.metaKey"),
  40401. left: genGuard("'button' in $event && $event.button !== 0"),
  40402. middle: genGuard("'button' in $event && $event.button !== 1"),
  40403. right: genGuard("'button' in $event && $event.button !== 2")
  40404. };
  40405. function genHandlers (
  40406. events,
  40407. isNative,
  40408. warn
  40409. ) {
  40410. var res = isNative ? 'nativeOn:{' : 'on:{';
  40411. for (var name in events) {
  40412. var handler = events[name];
  40413. // #5330: warn click.right, since right clicks do not actually fire click events.
  40414. if ("development" !== 'production' &&
  40415. name === 'click' &&
  40416. handler && handler.modifiers && handler.modifiers.right
  40417. ) {
  40418. warn(
  40419. "Use \"contextmenu\" instead of \"click.right\" since right clicks " +
  40420. "do not actually fire \"click\" events."
  40421. );
  40422. }
  40423. res += "\"" + name + "\":" + (genHandler(name, handler)) + ",";
  40424. }
  40425. return res.slice(0, -1) + '}'
  40426. }
  40427. function genHandler (
  40428. name,
  40429. handler
  40430. ) {
  40431. if (!handler) {
  40432. return 'function(){}'
  40433. }
  40434. if (Array.isArray(handler)) {
  40435. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  40436. }
  40437. var isMethodPath = simplePathRE.test(handler.value);
  40438. var isFunctionExpression = fnExpRE.test(handler.value);
  40439. if (!handler.modifiers) {
  40440. return isMethodPath || isFunctionExpression
  40441. ? handler.value
  40442. : ("function($event){" + (handler.value) + "}") // inline statement
  40443. } else {
  40444. var code = '';
  40445. var genModifierCode = '';
  40446. var keys = [];
  40447. for (var key in handler.modifiers) {
  40448. if (modifierCode[key]) {
  40449. genModifierCode += modifierCode[key];
  40450. // left/right
  40451. if (keyCodes[key]) {
  40452. keys.push(key);
  40453. }
  40454. } else {
  40455. keys.push(key);
  40456. }
  40457. }
  40458. if (keys.length) {
  40459. code += genKeyFilter(keys);
  40460. }
  40461. // Make sure modifiers like prevent and stop get executed after key filtering
  40462. if (genModifierCode) {
  40463. code += genModifierCode;
  40464. }
  40465. var handlerCode = isMethodPath
  40466. ? handler.value + '($event)'
  40467. : isFunctionExpression
  40468. ? ("(" + (handler.value) + ")($event)")
  40469. : handler.value;
  40470. return ("function($event){" + code + handlerCode + "}")
  40471. }
  40472. }
  40473. function genKeyFilter (keys) {
  40474. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  40475. }
  40476. function genFilterCode (key) {
  40477. var keyVal = parseInt(key, 10);
  40478. if (keyVal) {
  40479. return ("$event.keyCode!==" + keyVal)
  40480. }
  40481. var alias = keyCodes[key];
  40482. return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
  40483. }
  40484. /* */
  40485. function bind$1 (el, dir) {
  40486. el.wrapData = function (code) {
  40487. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")")
  40488. };
  40489. }
  40490. /* */
  40491. var baseDirectives = {
  40492. bind: bind$1,
  40493. cloak: noop
  40494. };
  40495. /* */
  40496. // configurable state
  40497. var warn$3;
  40498. var transforms$1;
  40499. var dataGenFns;
  40500. var platformDirectives$1;
  40501. var isPlatformReservedTag$1;
  40502. var staticRenderFns;
  40503. var onceCount;
  40504. var currentOptions;
  40505. function generate (
  40506. ast,
  40507. options
  40508. ) {
  40509. // save previous staticRenderFns so generate calls can be nested
  40510. var prevStaticRenderFns = staticRenderFns;
  40511. var currentStaticRenderFns = staticRenderFns = [];
  40512. var prevOnceCount = onceCount;
  40513. onceCount = 0;
  40514. currentOptions = options;
  40515. warn$3 = options.warn || baseWarn;
  40516. transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
  40517. dataGenFns = pluckModuleFunction(options.modules, 'genData');
  40518. platformDirectives$1 = options.directives || {};
  40519. isPlatformReservedTag$1 = options.isReservedTag || no;
  40520. var code = ast ? genElement(ast) : '_c("div")';
  40521. staticRenderFns = prevStaticRenderFns;
  40522. onceCount = prevOnceCount;
  40523. return {
  40524. render: ("with(this){return " + code + "}"),
  40525. staticRenderFns: currentStaticRenderFns
  40526. }
  40527. }
  40528. function genElement (el) {
  40529. if (el.staticRoot && !el.staticProcessed) {
  40530. return genStatic(el)
  40531. } else if (el.once && !el.onceProcessed) {
  40532. return genOnce(el)
  40533. } else if (el.for && !el.forProcessed) {
  40534. return genFor(el)
  40535. } else if (el.if && !el.ifProcessed) {
  40536. return genIf(el)
  40537. } else if (el.tag === 'template' && !el.slotTarget) {
  40538. return genChildren(el) || 'void 0'
  40539. } else if (el.tag === 'slot') {
  40540. return genSlot(el)
  40541. } else {
  40542. // component or element
  40543. var code;
  40544. if (el.component) {
  40545. code = genComponent(el.component, el);
  40546. } else {
  40547. var data = el.plain ? undefined : genData(el);
  40548. var children = el.inlineTemplate ? null : genChildren(el, true);
  40549. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  40550. }
  40551. // module transforms
  40552. for (var i = 0; i < transforms$1.length; i++) {
  40553. code = transforms$1[i](el, code);
  40554. }
  40555. return code
  40556. }
  40557. }
  40558. // hoist static sub-trees out
  40559. function genStatic (el) {
  40560. el.staticProcessed = true;
  40561. staticRenderFns.push(("with(this){return " + (genElement(el)) + "}"));
  40562. return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  40563. }
  40564. // v-once
  40565. function genOnce (el) {
  40566. el.onceProcessed = true;
  40567. if (el.if && !el.ifProcessed) {
  40568. return genIf(el)
  40569. } else if (el.staticInFor) {
  40570. var key = '';
  40571. var parent = el.parent;
  40572. while (parent) {
  40573. if (parent.for) {
  40574. key = parent.key;
  40575. break
  40576. }
  40577. parent = parent.parent;
  40578. }
  40579. if (!key) {
  40580. "development" !== 'production' && warn$3(
  40581. "v-once can only be used inside v-for that is keyed. "
  40582. );
  40583. return genElement(el)
  40584. }
  40585. return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")")
  40586. } else {
  40587. return genStatic(el)
  40588. }
  40589. }
  40590. function genIf (el) {
  40591. el.ifProcessed = true; // avoid recursion
  40592. return genIfConditions(el.ifConditions.slice())
  40593. }
  40594. function genIfConditions (conditions) {
  40595. if (!conditions.length) {
  40596. return '_e()'
  40597. }
  40598. var condition = conditions.shift();
  40599. if (condition.exp) {
  40600. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions)))
  40601. } else {
  40602. return ("" + (genTernaryExp(condition.block)))
  40603. }
  40604. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  40605. function genTernaryExp (el) {
  40606. return el.once ? genOnce(el) : genElement(el)
  40607. }
  40608. }
  40609. function genFor (el) {
  40610. var exp = el.for;
  40611. var alias = el.alias;
  40612. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  40613. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  40614. if (
  40615. "development" !== 'production' &&
  40616. maybeComponent(el) && el.tag !== 'slot' && el.tag !== 'template' && !el.key
  40617. ) {
  40618. warn$3(
  40619. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  40620. "v-for should have explicit keys. " +
  40621. "See https://vuejs.org/guide/list.html#key for more info.",
  40622. true /* tip */
  40623. );
  40624. }
  40625. el.forProcessed = true; // avoid recursion
  40626. return "_l((" + exp + ")," +
  40627. "function(" + alias + iterator1 + iterator2 + "){" +
  40628. "return " + (genElement(el)) +
  40629. '})'
  40630. }
  40631. function genData (el) {
  40632. var data = '{';
  40633. // directives first.
  40634. // directives may mutate the el's other properties before they are generated.
  40635. var dirs = genDirectives(el);
  40636. if (dirs) { data += dirs + ','; }
  40637. // key
  40638. if (el.key) {
  40639. data += "key:" + (el.key) + ",";
  40640. }
  40641. // ref
  40642. if (el.ref) {
  40643. data += "ref:" + (el.ref) + ",";
  40644. }
  40645. if (el.refInFor) {
  40646. data += "refInFor:true,";
  40647. }
  40648. // pre
  40649. if (el.pre) {
  40650. data += "pre:true,";
  40651. }
  40652. // record original tag name for components using "is" attribute
  40653. if (el.component) {
  40654. data += "tag:\"" + (el.tag) + "\",";
  40655. }
  40656. // module data generation functions
  40657. for (var i = 0; i < dataGenFns.length; i++) {
  40658. data += dataGenFns[i](el);
  40659. }
  40660. // attributes
  40661. if (el.attrs) {
  40662. data += "attrs:{" + (genProps(el.attrs)) + "},";
  40663. }
  40664. // DOM props
  40665. if (el.props) {
  40666. data += "domProps:{" + (genProps(el.props)) + "},";
  40667. }
  40668. // event handlers
  40669. if (el.events) {
  40670. data += (genHandlers(el.events, false, warn$3)) + ",";
  40671. }
  40672. if (el.nativeEvents) {
  40673. data += (genHandlers(el.nativeEvents, true, warn$3)) + ",";
  40674. }
  40675. // slot target
  40676. if (el.slotTarget) {
  40677. data += "slot:" + (el.slotTarget) + ",";
  40678. }
  40679. // scoped slots
  40680. if (el.scopedSlots) {
  40681. data += (genScopedSlots(el.scopedSlots)) + ",";
  40682. }
  40683. // component v-model
  40684. if (el.model) {
  40685. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  40686. }
  40687. // inline-template
  40688. if (el.inlineTemplate) {
  40689. var inlineTemplate = genInlineTemplate(el);
  40690. if (inlineTemplate) {
  40691. data += inlineTemplate + ",";
  40692. }
  40693. }
  40694. data = data.replace(/,$/, '') + '}';
  40695. // v-bind data wrap
  40696. if (el.wrapData) {
  40697. data = el.wrapData(data);
  40698. }
  40699. return data
  40700. }
  40701. function genDirectives (el) {
  40702. var dirs = el.directives;
  40703. if (!dirs) { return }
  40704. var res = 'directives:[';
  40705. var hasRuntime = false;
  40706. var i, l, dir, needRuntime;
  40707. for (i = 0, l = dirs.length; i < l; i++) {
  40708. dir = dirs[i];
  40709. needRuntime = true;
  40710. var gen = platformDirectives$1[dir.name] || baseDirectives[dir.name];
  40711. if (gen) {
  40712. // compile-time directive that manipulates AST.
  40713. // returns true if it also needs a runtime counterpart.
  40714. needRuntime = !!gen(el, dir, warn$3);
  40715. }
  40716. if (needRuntime) {
  40717. hasRuntime = true;
  40718. 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))) : '') + "},";
  40719. }
  40720. }
  40721. if (hasRuntime) {
  40722. return res.slice(0, -1) + ']'
  40723. }
  40724. }
  40725. function genInlineTemplate (el) {
  40726. var ast = el.children[0];
  40727. if ("development" !== 'production' && (
  40728. el.children.length > 1 || ast.type !== 1
  40729. )) {
  40730. warn$3('Inline-template components must have exactly one child element.');
  40731. }
  40732. if (ast.type === 1) {
  40733. var inlineRenderFns = generate(ast, currentOptions);
  40734. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  40735. }
  40736. }
  40737. function genScopedSlots (slots) {
  40738. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "])")
  40739. }
  40740. function genScopedSlot (key, el) {
  40741. if (el.for && !el.forProcessed) {
  40742. return genForScopedSlot(key, el)
  40743. }
  40744. return "{key:" + key + ",fn:function(" + (String(el.attrsMap.scope)) + "){" +
  40745. "return " + (el.tag === 'template'
  40746. ? genChildren(el) || 'void 0'
  40747. : genElement(el)) + "}}"
  40748. }
  40749. function genForScopedSlot (key, el) {
  40750. var exp = el.for;
  40751. var alias = el.alias;
  40752. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  40753. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  40754. el.forProcessed = true; // avoid recursion
  40755. return "_l((" + exp + ")," +
  40756. "function(" + alias + iterator1 + iterator2 + "){" +
  40757. "return " + (genScopedSlot(key, el)) +
  40758. '})'
  40759. }
  40760. function genChildren (el, checkSkip) {
  40761. var children = el.children;
  40762. if (children.length) {
  40763. var el$1 = children[0];
  40764. // optimize single v-for
  40765. if (children.length === 1 &&
  40766. el$1.for &&
  40767. el$1.tag !== 'template' &&
  40768. el$1.tag !== 'slot'
  40769. ) {
  40770. return genElement(el$1)
  40771. }
  40772. var normalizationType = checkSkip ? getNormalizationType(children) : 0;
  40773. return ("[" + (children.map(genNode).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
  40774. }
  40775. }
  40776. // determine the normalization needed for the children array.
  40777. // 0: no normalization needed
  40778. // 1: simple normalization needed (possible 1-level deep nested array)
  40779. // 2: full normalization needed
  40780. function getNormalizationType (children) {
  40781. var res = 0;
  40782. for (var i = 0; i < children.length; i++) {
  40783. var el = children[i];
  40784. if (el.type !== 1) {
  40785. continue
  40786. }
  40787. if (needsNormalization(el) ||
  40788. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  40789. res = 2;
  40790. break
  40791. }
  40792. if (maybeComponent(el) ||
  40793. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  40794. res = 1;
  40795. }
  40796. }
  40797. return res
  40798. }
  40799. function needsNormalization (el) {
  40800. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  40801. }
  40802. function maybeComponent (el) {
  40803. return !isPlatformReservedTag$1(el.tag)
  40804. }
  40805. function genNode (node) {
  40806. if (node.type === 1) {
  40807. return genElement(node)
  40808. } else {
  40809. return genText(node)
  40810. }
  40811. }
  40812. function genText (text) {
  40813. return ("_v(" + (text.type === 2
  40814. ? text.expression // no need for () because already wrapped in _s()
  40815. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  40816. }
  40817. function genSlot (el) {
  40818. var slotName = el.slotName || '"default"';
  40819. var children = genChildren(el);
  40820. var res = "_t(" + slotName + (children ? ("," + children) : '');
  40821. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  40822. var bind$$1 = el.attrsMap['v-bind'];
  40823. if ((attrs || bind$$1) && !children) {
  40824. res += ",null";
  40825. }
  40826. if (attrs) {
  40827. res += "," + attrs;
  40828. }
  40829. if (bind$$1) {
  40830. res += (attrs ? '' : ',null') + "," + bind$$1;
  40831. }
  40832. return res + ')'
  40833. }
  40834. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  40835. function genComponent (componentName, el) {
  40836. var children = el.inlineTemplate ? null : genChildren(el, true);
  40837. return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")")
  40838. }
  40839. function genProps (props) {
  40840. var res = '';
  40841. for (var i = 0; i < props.length; i++) {
  40842. var prop = props[i];
  40843. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  40844. }
  40845. return res.slice(0, -1)
  40846. }
  40847. // #3895, #4268
  40848. function transformSpecialNewlines (text) {
  40849. return text
  40850. .replace(/\u2028/g, '\\u2028')
  40851. .replace(/\u2029/g, '\\u2029')
  40852. }
  40853. /* */
  40854. // these keywords should not appear inside expressions, but operators like
  40855. // typeof, instanceof and in are allowed
  40856. var prohibitedKeywordRE = new RegExp('\\b' + (
  40857. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  40858. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  40859. 'extends,finally,continue,debugger,function,arguments'
  40860. ).split(',').join('\\b|\\b') + '\\b');
  40861. // these unary operators should not be used as property/method names
  40862. var unaryOperatorsRE = new RegExp('\\b' + (
  40863. 'delete,typeof,void'
  40864. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  40865. // check valid identifier for v-for
  40866. var identRE = /[A-Za-z_$][\w$]*/;
  40867. // strip strings in expressions
  40868. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  40869. // detect problematic expressions in a template
  40870. function detectErrors (ast) {
  40871. var errors = [];
  40872. if (ast) {
  40873. checkNode(ast, errors);
  40874. }
  40875. return errors
  40876. }
  40877. function checkNode (node, errors) {
  40878. if (node.type === 1) {
  40879. for (var name in node.attrsMap) {
  40880. if (dirRE.test(name)) {
  40881. var value = node.attrsMap[name];
  40882. if (value) {
  40883. if (name === 'v-for') {
  40884. checkFor(node, ("v-for=\"" + value + "\""), errors);
  40885. } else if (onRE.test(name)) {
  40886. checkEvent(value, (name + "=\"" + value + "\""), errors);
  40887. } else {
  40888. checkExpression(value, (name + "=\"" + value + "\""), errors);
  40889. }
  40890. }
  40891. }
  40892. }
  40893. if (node.children) {
  40894. for (var i = 0; i < node.children.length; i++) {
  40895. checkNode(node.children[i], errors);
  40896. }
  40897. }
  40898. } else if (node.type === 2) {
  40899. checkExpression(node.expression, node.text, errors);
  40900. }
  40901. }
  40902. function checkEvent (exp, text, errors) {
  40903. var stipped = exp.replace(stripStringRE, '');
  40904. var keywordMatch = stipped.match(unaryOperatorsRE);
  40905. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  40906. errors.push(
  40907. "avoid using JavaScript unary operator as property name: " +
  40908. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  40909. );
  40910. }
  40911. checkExpression(exp, text, errors);
  40912. }
  40913. function checkFor (node, text, errors) {
  40914. checkExpression(node.for || '', text, errors);
  40915. checkIdentifier(node.alias, 'v-for alias', text, errors);
  40916. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  40917. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  40918. }
  40919. function checkIdentifier (ident, type, text, errors) {
  40920. if (typeof ident === 'string' && !identRE.test(ident)) {
  40921. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  40922. }
  40923. }
  40924. function checkExpression (exp, text, errors) {
  40925. try {
  40926. new Function(("return " + exp));
  40927. } catch (e) {
  40928. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  40929. if (keywordMatch) {
  40930. errors.push(
  40931. "avoid using JavaScript keyword as property name: " +
  40932. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  40933. );
  40934. } else {
  40935. errors.push(("invalid expression: " + (text.trim())));
  40936. }
  40937. }
  40938. }
  40939. /* */
  40940. function baseCompile (
  40941. template,
  40942. options
  40943. ) {
  40944. var ast = parse(template.trim(), options);
  40945. optimize(ast, options);
  40946. var code = generate(ast, options);
  40947. return {
  40948. ast: ast,
  40949. render: code.render,
  40950. staticRenderFns: code.staticRenderFns
  40951. }
  40952. }
  40953. function makeFunction (code, errors) {
  40954. try {
  40955. return new Function(code)
  40956. } catch (err) {
  40957. errors.push({ err: err, code: code });
  40958. return noop
  40959. }
  40960. }
  40961. function createCompiler (baseOptions) {
  40962. var functionCompileCache = Object.create(null);
  40963. function compile (
  40964. template,
  40965. options
  40966. ) {
  40967. var finalOptions = Object.create(baseOptions);
  40968. var errors = [];
  40969. var tips = [];
  40970. finalOptions.warn = function (msg, tip$$1) {
  40971. (tip$$1 ? tips : errors).push(msg);
  40972. };
  40973. if (options) {
  40974. // merge custom modules
  40975. if (options.modules) {
  40976. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  40977. }
  40978. // merge custom directives
  40979. if (options.directives) {
  40980. finalOptions.directives = extend(
  40981. Object.create(baseOptions.directives),
  40982. options.directives
  40983. );
  40984. }
  40985. // copy other options
  40986. for (var key in options) {
  40987. if (key !== 'modules' && key !== 'directives') {
  40988. finalOptions[key] = options[key];
  40989. }
  40990. }
  40991. }
  40992. var compiled = baseCompile(template, finalOptions);
  40993. if (true) {
  40994. errors.push.apply(errors, detectErrors(compiled.ast));
  40995. }
  40996. compiled.errors = errors;
  40997. compiled.tips = tips;
  40998. return compiled
  40999. }
  41000. function compileToFunctions (
  41001. template,
  41002. options,
  41003. vm
  41004. ) {
  41005. options = options || {};
  41006. /* istanbul ignore if */
  41007. if (true) {
  41008. // detect possible CSP restriction
  41009. try {
  41010. new Function('return 1');
  41011. } catch (e) {
  41012. if (e.toString().match(/unsafe-eval|CSP/)) {
  41013. warn(
  41014. 'It seems you are using the standalone build of Vue.js in an ' +
  41015. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  41016. 'The template compiler cannot work in this environment. Consider ' +
  41017. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  41018. 'templates into render functions.'
  41019. );
  41020. }
  41021. }
  41022. }
  41023. // check cache
  41024. var key = options.delimiters
  41025. ? String(options.delimiters) + template
  41026. : template;
  41027. if (functionCompileCache[key]) {
  41028. return functionCompileCache[key]
  41029. }
  41030. // compile
  41031. var compiled = compile(template, options);
  41032. // check compilation errors/tips
  41033. if (true) {
  41034. if (compiled.errors && compiled.errors.length) {
  41035. warn(
  41036. "Error compiling template:\n\n" + template + "\n\n" +
  41037. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  41038. vm
  41039. );
  41040. }
  41041. if (compiled.tips && compiled.tips.length) {
  41042. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  41043. }
  41044. }
  41045. // turn code into functions
  41046. var res = {};
  41047. var fnGenErrors = [];
  41048. res.render = makeFunction(compiled.render, fnGenErrors);
  41049. var l = compiled.staticRenderFns.length;
  41050. res.staticRenderFns = new Array(l);
  41051. for (var i = 0; i < l; i++) {
  41052. res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors);
  41053. }
  41054. // check function generation errors.
  41055. // this should only happen if there is a bug in the compiler itself.
  41056. // mostly for codegen development use
  41057. /* istanbul ignore if */
  41058. if (true) {
  41059. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  41060. warn(
  41061. "Failed to generate render function:\n\n" +
  41062. fnGenErrors.map(function (ref) {
  41063. var err = ref.err;
  41064. var code = ref.code;
  41065. return ((err.toString()) + " in\n\n" + code + "\n");
  41066. }).join('\n'),
  41067. vm
  41068. );
  41069. }
  41070. }
  41071. return (functionCompileCache[key] = res)
  41072. }
  41073. return {
  41074. compile: compile,
  41075. compileToFunctions: compileToFunctions
  41076. }
  41077. }
  41078. /* */
  41079. function transformNode (el, options) {
  41080. var warn = options.warn || baseWarn;
  41081. var staticClass = getAndRemoveAttr(el, 'class');
  41082. if ("development" !== 'production' && staticClass) {
  41083. var expression = parseText(staticClass, options.delimiters);
  41084. if (expression) {
  41085. warn(
  41086. "class=\"" + staticClass + "\": " +
  41087. 'Interpolation inside attributes has been removed. ' +
  41088. 'Use v-bind or the colon shorthand instead. For example, ' +
  41089. 'instead of <div class="{{ val }}">, use <div :class="val">.'
  41090. );
  41091. }
  41092. }
  41093. if (staticClass) {
  41094. el.staticClass = JSON.stringify(staticClass);
  41095. }
  41096. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  41097. if (classBinding) {
  41098. el.classBinding = classBinding;
  41099. }
  41100. }
  41101. function genData$1 (el) {
  41102. var data = '';
  41103. if (el.staticClass) {
  41104. data += "staticClass:" + (el.staticClass) + ",";
  41105. }
  41106. if (el.classBinding) {
  41107. data += "class:" + (el.classBinding) + ",";
  41108. }
  41109. return data
  41110. }
  41111. var klass$1 = {
  41112. staticKeys: ['staticClass'],
  41113. transformNode: transformNode,
  41114. genData: genData$1
  41115. };
  41116. /* */
  41117. function transformNode$1 (el, options) {
  41118. var warn = options.warn || baseWarn;
  41119. var staticStyle = getAndRemoveAttr(el, 'style');
  41120. if (staticStyle) {
  41121. /* istanbul ignore if */
  41122. if (true) {
  41123. var expression = parseText(staticStyle, options.delimiters);
  41124. if (expression) {
  41125. warn(
  41126. "style=\"" + staticStyle + "\": " +
  41127. 'Interpolation inside attributes has been removed. ' +
  41128. 'Use v-bind or the colon shorthand instead. For example, ' +
  41129. 'instead of <div style="{{ val }}">, use <div :style="val">.'
  41130. );
  41131. }
  41132. }
  41133. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  41134. }
  41135. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  41136. if (styleBinding) {
  41137. el.styleBinding = styleBinding;
  41138. }
  41139. }
  41140. function genData$2 (el) {
  41141. var data = '';
  41142. if (el.staticStyle) {
  41143. data += "staticStyle:" + (el.staticStyle) + ",";
  41144. }
  41145. if (el.styleBinding) {
  41146. data += "style:(" + (el.styleBinding) + "),";
  41147. }
  41148. return data
  41149. }
  41150. var style$1 = {
  41151. staticKeys: ['staticStyle'],
  41152. transformNode: transformNode$1,
  41153. genData: genData$2
  41154. };
  41155. var modules$1 = [
  41156. klass$1,
  41157. style$1
  41158. ];
  41159. /* */
  41160. function text (el, dir) {
  41161. if (dir.value) {
  41162. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
  41163. }
  41164. }
  41165. /* */
  41166. function html (el, dir) {
  41167. if (dir.value) {
  41168. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
  41169. }
  41170. }
  41171. var directives$1 = {
  41172. model: model,
  41173. text: text,
  41174. html: html
  41175. };
  41176. /* */
  41177. var baseOptions = {
  41178. expectHTML: true,
  41179. modules: modules$1,
  41180. directives: directives$1,
  41181. isPreTag: isPreTag,
  41182. isUnaryTag: isUnaryTag,
  41183. mustUseProp: mustUseProp,
  41184. canBeLeftOpenTag: canBeLeftOpenTag,
  41185. isReservedTag: isReservedTag,
  41186. getTagNamespace: getTagNamespace,
  41187. staticKeys: genStaticKeys(modules$1)
  41188. };
  41189. var ref$1 = createCompiler(baseOptions);
  41190. var compileToFunctions = ref$1.compileToFunctions;
  41191. /* */
  41192. var idToTemplate = cached(function (id) {
  41193. var el = query(id);
  41194. return el && el.innerHTML
  41195. });
  41196. var mount = Vue$3.prototype.$mount;
  41197. Vue$3.prototype.$mount = function (
  41198. el,
  41199. hydrating
  41200. ) {
  41201. el = el && query(el);
  41202. /* istanbul ignore if */
  41203. if (el === document.body || el === document.documentElement) {
  41204. "development" !== 'production' && warn(
  41205. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  41206. );
  41207. return this
  41208. }
  41209. var options = this.$options;
  41210. // resolve template/el and convert to render function
  41211. if (!options.render) {
  41212. var template = options.template;
  41213. if (template) {
  41214. if (typeof template === 'string') {
  41215. if (template.charAt(0) === '#') {
  41216. template = idToTemplate(template);
  41217. /* istanbul ignore if */
  41218. if ("development" !== 'production' && !template) {
  41219. warn(
  41220. ("Template element not found or is empty: " + (options.template)),
  41221. this
  41222. );
  41223. }
  41224. }
  41225. } else if (template.nodeType) {
  41226. template = template.innerHTML;
  41227. } else {
  41228. if (true) {
  41229. warn('invalid template option:' + template, this);
  41230. }
  41231. return this
  41232. }
  41233. } else if (el) {
  41234. template = getOuterHTML(el);
  41235. }
  41236. if (template) {
  41237. /* istanbul ignore if */
  41238. if ("development" !== 'production' && config.performance && mark) {
  41239. mark('compile');
  41240. }
  41241. var ref = compileToFunctions(template, {
  41242. shouldDecodeNewlines: shouldDecodeNewlines,
  41243. delimiters: options.delimiters
  41244. }, this);
  41245. var render = ref.render;
  41246. var staticRenderFns = ref.staticRenderFns;
  41247. options.render = render;
  41248. options.staticRenderFns = staticRenderFns;
  41249. /* istanbul ignore if */
  41250. if ("development" !== 'production' && config.performance && mark) {
  41251. mark('compile end');
  41252. measure(((this._name) + " compile"), 'compile', 'compile end');
  41253. }
  41254. }
  41255. }
  41256. return mount.call(this, el, hydrating)
  41257. };
  41258. /**
  41259. * Get outerHTML of elements, taking care
  41260. * of SVG elements in IE as well.
  41261. */
  41262. function getOuterHTML (el) {
  41263. if (el.outerHTML) {
  41264. return el.outerHTML
  41265. } else {
  41266. var container = document.createElement('div');
  41267. container.appendChild(el.cloneNode(true));
  41268. return container.innerHTML
  41269. }
  41270. }
  41271. Vue$3.compile = compileToFunctions;
  41272. module.exports = Vue$3;
  41273. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
  41274. /***/ }),
  41275. /* 39 */,
  41276. /* 40 */,
  41277. /* 41 */,
  41278. /* 42 */,
  41279. /* 43 */,
  41280. /* 44 */,
  41281. /* 45 */
  41282. /***/ (function(module, exports) {
  41283. // removed by extract-text-webpack-plugin
  41284. /***/ }),
  41285. /* 46 */,
  41286. /* 47 */,
  41287. /* 48 */,
  41288. /* 49 */,
  41289. /* 50 */,
  41290. /* 51 */,
  41291. /* 52 */,
  41292. /* 53 */,
  41293. /* 54 */,
  41294. /* 55 */,
  41295. /* 56 */
  41296. /***/ (function(module, exports, __webpack_require__) {
  41297. var disposed = false
  41298. var Component = __webpack_require__(8)(
  41299. /* script */
  41300. __webpack_require__(57),
  41301. /* template */
  41302. __webpack_require__(58),
  41303. /* styles */
  41304. null,
  41305. /* scopeId */
  41306. null,
  41307. /* moduleIdentifier (server only) */
  41308. null
  41309. )
  41310. Component.options.__file = "/Users/aaronpk/Code/spy30/resources/assets/js/components/TweetQueue.vue"
  41311. 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.")}
  41312. if (Component.options.functional) {console.error("[vue-loader] TweetQueue.vue: functional components are not supported with templates, they should use render functions.")}
  41313. /* hot reload */
  41314. if (false) {(function () {
  41315. var hotAPI = require("vue-hot-reload-api")
  41316. hotAPI.install(require("vue"), false)
  41317. if (!hotAPI.compatible) return
  41318. module.hot.accept()
  41319. if (!module.hot.data) {
  41320. hotAPI.createRecord("data-v-1798c0a1", Component.options)
  41321. } else {
  41322. hotAPI.reload("data-v-1798c0a1", Component.options)
  41323. }
  41324. module.hot.dispose(function (data) {
  41325. disposed = true
  41326. })
  41327. })()}
  41328. module.exports = Component.exports
  41329. /***/ }),
  41330. /* 57 */
  41331. /***/ (function(module, exports) {
  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. //
  41357. module.exports = {
  41358. data: function data() {
  41359. return {
  41360. queue: [],
  41361. tweet: {},
  41362. show: false
  41363. };
  41364. },
  41365. methods: {
  41366. loadQueue: function loadQueue() {
  41367. $.get('/dashboard/queue', function (tweets) {
  41368. var _this = this;
  41369. for (var i in tweets.queue) {
  41370. this.queue.push(tweets.queue[i]);
  41371. }
  41372. // Listen for new items on the queue
  41373. Echo.channel('tweet-queue').listen('NewTweetEvent', function (e) {
  41374. if (_this.findTweetInQueue(e.tweet_id) === false) {
  41375. _this.queue.push(e);
  41376. // If the new tweet is one that timed out, dismiss it
  41377. if (_this.show && _this.tweet.tweet_id == e.tweet_id) {
  41378. _this.tweet = {};
  41379. _this.show = false;
  41380. }
  41381. }
  41382. }).listen('TweetClaimedEvent', function (e) {
  41383. _this.removeTweetFromQueue(e.tweet_id);
  41384. });
  41385. }.bind(this));
  41386. },
  41387. dashboardPing: function dashboardPing() {
  41388. setTimeout(function () {
  41389. $.get('/dashboard/ping', function () {
  41390. this.dashboardPing();
  41391. }.bind(this));
  41392. }.bind(this), 15000);
  41393. },
  41394. findTweetInQueue: function findTweetInQueue(tweet_id) {
  41395. var queueIndex = false;
  41396. for (var i in this.queue) {
  41397. if (parseInt(this.queue[i].tweet_id) == parseInt(tweet_id)) {
  41398. queueIndex = i;
  41399. }
  41400. }
  41401. return queueIndex;
  41402. },
  41403. removeTweetFromQueue: function removeTweetFromQueue(tweet_id) {
  41404. var queueIndex = this.findTweetInQueue(tweet_id);
  41405. if (queueIndex !== false) {
  41406. var removed = this.queue.splice(queueIndex, 1);
  41407. return removed[0];
  41408. }
  41409. },
  41410. clickedTweet: function clickedTweet(tweet_index) {
  41411. // If another tweet was already open, dismiss that first
  41412. if (this.show) {
  41413. this.dismissTweet();
  41414. }
  41415. var tweet_data = this.queue[tweet_index];
  41416. var tweet_id = tweet_data.tweet_id;
  41417. if (tweet_data) {
  41418. // Mark this as claimed
  41419. $.post('/dashboard/claim-tweet', {
  41420. tweet_id: tweet_id
  41421. }, function (response) {});
  41422. this.removeTweetFromQueue(tweet_id);
  41423. // Load in the scorecard viewer
  41424. this.tweet = tweet_data;
  41425. this.show = true;
  41426. } else {
  41427. console.log("Tweet not found: " + tweet_id);
  41428. }
  41429. },
  41430. dismissTweet: function dismissTweet() {
  41431. this.queue.push(this.tweet);
  41432. // Mark as un-claimed
  41433. $.post('/dashboard/claim-tweet', {
  41434. tweet_id: this.tweet.tweet_id,
  41435. status: 'unclaimed'
  41436. }, function (response) {});
  41437. this.tweet = {};
  41438. this.show = false;
  41439. },
  41440. completedTweet: function completedTweet() {
  41441. this.tweet = {};
  41442. this.show = false;
  41443. }
  41444. },
  41445. created: function created() {
  41446. this.loadQueue();
  41447. this.dashboardPing();
  41448. }
  41449. };
  41450. /***/ }),
  41451. /* 58 */
  41452. /***/ (function(module, exports, __webpack_require__) {
  41453. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41454. return _c('div', {
  41455. staticClass: "container"
  41456. }, [_c('div', {
  41457. staticClass: "row"
  41458. }, [_c('div', {
  41459. staticClass: "col-xs-4 col-md-4"
  41460. }, [_c('div', {
  41461. staticClass: "panel panel-default"
  41462. }, [_c('div', {
  41463. staticClass: "panel-heading"
  41464. }, [_vm._v("Queue")]), _vm._v(" "), _c('div', {
  41465. staticClass: "panel-body tweet-queue"
  41466. }, _vm._l((_vm.queue), function(tweet, index) {
  41467. return _c('div', {
  41468. staticClass: "tweet",
  41469. on: {
  41470. "click": function($event) {
  41471. _vm.clickedTweet(index)
  41472. }
  41473. }
  41474. }, [_c('div', {
  41475. staticClass: "mission"
  41476. }, [_vm._v(_vm._s(tweet.mission))]), _vm._v(" "), _c('div', {
  41477. staticClass: "profile"
  41478. }, [_c('img', {
  41479. style: ('border-color: #' + tweet.team_color),
  41480. attrs: {
  41481. "src": tweet.player_photo
  41482. }
  41483. }), _vm._v(" "), _c('span', [_vm._v("@" + _vm._s(tweet.player_username))])]), _vm._v(" "), _c('div', {
  41484. staticClass: "text"
  41485. }, [_vm._v(_vm._s(tweet.text))])])
  41486. }))])]), _vm._v(" "), _c('div', {
  41487. staticClass: "col-xs-8 col-md-8"
  41488. }, [_c('scorecard', {
  41489. attrs: {
  41490. "show": _vm.show,
  41491. "tweet": _vm.tweet
  41492. },
  41493. on: {
  41494. "update:show": function($event) {
  41495. _vm.show = $event
  41496. },
  41497. "dismiss": _vm.dismissTweet,
  41498. "complete": _vm.completedTweet
  41499. }
  41500. })], 1)])])
  41501. },staticRenderFns: []}
  41502. module.exports.render._withStripped = true
  41503. if (false) {
  41504. module.hot.accept()
  41505. if (module.hot.data) {
  41506. require("vue-hot-reload-api").rerender("data-v-1798c0a1", module.exports)
  41507. }
  41508. }
  41509. /***/ }),
  41510. /* 59 */
  41511. /***/ (function(module, exports, __webpack_require__) {
  41512. var disposed = false
  41513. var Component = __webpack_require__(8)(
  41514. /* script */
  41515. __webpack_require__(61),
  41516. /* template */
  41517. __webpack_require__(60),
  41518. /* styles */
  41519. null,
  41520. /* scopeId */
  41521. null,
  41522. /* moduleIdentifier (server only) */
  41523. null
  41524. )
  41525. Component.options.__file = "/Users/aaronpk/Code/spy30/resources/assets/js/components/Scorecard.vue"
  41526. 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.")}
  41527. if (Component.options.functional) {console.error("[vue-loader] Scorecard.vue: functional components are not supported with templates, they should use render functions.")}
  41528. /* hot reload */
  41529. if (false) {(function () {
  41530. var hotAPI = require("vue-hot-reload-api")
  41531. hotAPI.install(require("vue"), false)
  41532. if (!hotAPI.compatible) return
  41533. module.hot.accept()
  41534. if (!module.hot.data) {
  41535. hotAPI.createRecord("data-v-1098d79e", Component.options)
  41536. } else {
  41537. hotAPI.reload("data-v-1098d79e", Component.options)
  41538. }
  41539. module.hot.dispose(function (data) {
  41540. disposed = true
  41541. })
  41542. })()}
  41543. module.exports = Component.exports
  41544. /***/ }),
  41545. /* 60 */
  41546. /***/ (function(module, exports, __webpack_require__) {
  41547. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41548. return (_vm.show) ? _c('div', {
  41549. staticClass: "panel panel-default scorecard"
  41550. }, [_c('div', {
  41551. staticClass: "panel-heading"
  41552. }, [_c('div', {
  41553. staticClass: "team"
  41554. }, [_c('span', {
  41555. staticClass: "team-icon",
  41556. style: ('background-color: #' + _vm.tweet.team_color)
  41557. }), _vm._v(" "), _c('span', {
  41558. staticClass: "team-name"
  41559. }, [_vm._v(_vm._s(_vm.tweet.team_name))])]), _vm._v(" "), _c('h2', [_vm._v(_vm._s(_vm.tweet.mission))]), _vm._v(" "), _c('button', {
  41560. staticClass: "close",
  41561. attrs: {
  41562. "type": "button"
  41563. },
  41564. on: {
  41565. "click": _vm.dismiss
  41566. }
  41567. }, [_c('span', [_vm._v("×")])])]), _vm._v(" "), _c('div', {
  41568. staticClass: "panel-body"
  41569. }, [_c('div', {
  41570. staticClass: "row"
  41571. }, [_c('div', {
  41572. staticClass: "col-md-8"
  41573. }, [_c('div', {
  41574. staticClass: "profile"
  41575. }, [_c('img', {
  41576. style: ('border-color: #' + _vm.tweet.team_color),
  41577. attrs: {
  41578. "src": _vm.tweet.player_photo
  41579. }
  41580. }), _vm._v(" "), _c('span', [_c('a', {
  41581. attrs: {
  41582. "href": 'https://twitter.com/' + _vm.tweet.player_username
  41583. }
  41584. }, [_vm._v("@" + _vm._s(_vm.tweet.player_username))])])]), _vm._v(" "), _c('div', {
  41585. staticClass: "tweet"
  41586. }, [_c('div', {
  41587. staticClass: "text"
  41588. }, [_vm._v(_vm._s(_vm.tweet.text))]), _vm._v(" "), (_vm.tweet.photos) ? _c('div', [(_vm.tweet.photos) ? _c('div', {
  41589. class: 'multi-photo photos-' + _vm.tweet.photos.length
  41590. }, _vm._l((_vm.tweet.photos), function(img) {
  41591. return _c('div', {
  41592. staticClass: "photo",
  41593. style: ('background-image:url(' + img + ')'),
  41594. attrs: {
  41595. "data-featherlight": img
  41596. }
  41597. }, [_c('img', {
  41598. attrs: {
  41599. "src": img
  41600. }
  41601. })])
  41602. })) : _vm._e(), _vm._v(" "), _c('div', {
  41603. staticClass: "multi-photo-clear"
  41604. })]) : _vm._e()]), _vm._v(" "), (_vm.showReplyBox) ? _c('div', {
  41605. staticClass: "tweet-reply"
  41606. }, [_c('div', {
  41607. staticClass: "top"
  41608. }, [_c('textarea', {
  41609. directives: [{
  41610. name: "model",
  41611. rawName: "v-model",
  41612. value: (_vm.replyText),
  41613. expression: "replyText"
  41614. }],
  41615. staticClass: "form-control",
  41616. staticStyle: {
  41617. "margin-bottom": "4px"
  41618. },
  41619. attrs: {
  41620. "rows": "2",
  41621. "disabled": _vm.replyInProgress
  41622. },
  41623. domProps: {
  41624. "value": (_vm.replyText)
  41625. },
  41626. on: {
  41627. "input": function($event) {
  41628. if ($event.target.composing) { return; }
  41629. _vm.replyText = $event.target.value
  41630. }
  41631. }
  41632. })]), _vm._v(" "), _c('div', {
  41633. staticClass: "bottom"
  41634. }, [_c('div', {
  41635. staticClass: "fill"
  41636. }), _vm._v(" "), _c('img', {
  41637. attrs: {
  41638. "src": "/twitter.ico",
  41639. "width": "16"
  41640. }
  41641. }), _vm._v(" "), _c('div', {
  41642. staticClass: "remaining-chars"
  41643. }, [_vm._v(_vm._s(_vm.replyTextCharsRemaining))]), _vm._v(" "), _c('button', {
  41644. staticClass: "btn btn-primary",
  41645. attrs: {
  41646. "disabled": _vm.isTweetReplyDisabled
  41647. },
  41648. on: {
  41649. "click": _vm.sendReply
  41650. }
  41651. }, [_vm._v("Reply")])])]) : _vm._e(), _vm._v(" "), _c('div', {
  41652. staticClass: "tweet-actions"
  41653. }, [_c('button', {
  41654. staticClass: "btn btn-success",
  41655. attrs: {
  41656. "type": "button",
  41657. "disabled": _vm.isAcceptDisabled
  41658. },
  41659. on: {
  41660. "click": _vm.scoreTweet
  41661. }
  41662. }, [_vm._v("Accept")]), _vm._v(" "), _c('button', {
  41663. staticClass: "btn btn-danger",
  41664. attrs: {
  41665. "type": "button"
  41666. },
  41667. on: {
  41668. "click": _vm.rejectTweet
  41669. }
  41670. }, [_vm._v("Reject")])])]), _vm._v(" "), _c('div', {
  41671. staticClass: "col-md-4"
  41672. }, [(_vm.tweet.mission_id == 1) ? [_c('p', {
  41673. staticClass: "instructions"
  41674. }, [_vm._v("\n The photo must show the sign with the transit line\n ")]), _vm._v(" "), _c('div', {
  41675. staticClass: "form-group"
  41676. }, [_c('select', {
  41677. directives: [{
  41678. name: "model",
  41679. rawName: "v-model",
  41680. value: (_vm.selectedTransitLine),
  41681. expression: "selectedTransitLine"
  41682. }],
  41683. staticClass: "form-control",
  41684. on: {
  41685. "change": function($event) {
  41686. var $$selectedVal = Array.prototype.filter.call($event.target.options, function(o) {
  41687. return o.selected
  41688. }).map(function(o) {
  41689. var val = "_value" in o ? o._value : o.value;
  41690. return val
  41691. });
  41692. _vm.selectedTransitLine = $event.target.multiple ? $$selectedVal : $$selectedVal[0]
  41693. }
  41694. }
  41695. }, [_c('option', {
  41696. attrs: {
  41697. "value": ""
  41698. }
  41699. }), _vm._v(" "), _vm._l((_vm.lines), function(line) {
  41700. return _c('option', {
  41701. domProps: {
  41702. "value": line.id
  41703. }
  41704. }, [_vm._v(_vm._s(line.name))])
  41705. })], 2)]), _vm._v(" "), _c('div', {
  41706. staticClass: "form-group"
  41707. }, [_c('input', {
  41708. directives: [{
  41709. name: "model",
  41710. rawName: "v-model",
  41711. value: (_vm.selectedNonTrimetLine),
  41712. expression: "selectedNonTrimetLine"
  41713. }],
  41714. staticClass: "form-control",
  41715. attrs: {
  41716. "type": "text",
  41717. "placeholder": "Non-Trimet Line"
  41718. },
  41719. domProps: {
  41720. "value": (_vm.selectedNonTrimetLine)
  41721. },
  41722. on: {
  41723. "input": function($event) {
  41724. if ($event.target.composing) { return; }
  41725. _vm.selectedNonTrimetLine = $event.target.value
  41726. }
  41727. }
  41728. })])] : _vm._e(), _vm._v(" "), (_vm.tweet.mission_id == 2) ? [_vm._m(0), _vm._v(" "), _c('div', {
  41729. staticClass: "form-group"
  41730. }, [_c('select', {
  41731. directives: [{
  41732. name: "model",
  41733. rawName: "v-model",
  41734. value: (_vm.selectedTransitCenter),
  41735. expression: "selectedTransitCenter"
  41736. }],
  41737. staticClass: "form-control",
  41738. on: {
  41739. "change": function($event) {
  41740. var $$selectedVal = Array.prototype.filter.call($event.target.options, function(o) {
  41741. return o.selected
  41742. }).map(function(o) {
  41743. var val = "_value" in o ? o._value : o.value;
  41744. return val
  41745. });
  41746. _vm.selectedTransitCenter = $event.target.multiple ? $$selectedVal : $$selectedVal[0]
  41747. }
  41748. }
  41749. }, [_c('option', {
  41750. attrs: {
  41751. "value": ""
  41752. }
  41753. }), _vm._v(" "), _vm._l((_vm.centers), function(stop) {
  41754. return _c('option', {
  41755. domProps: {
  41756. "value": stop.id
  41757. }
  41758. }, [_vm._v(_vm._s(stop.name))])
  41759. })], 2)]), _vm._v(" "), _c('div', {
  41760. staticClass: "form-group"
  41761. }, [_c('div', {
  41762. staticClass: "checkbox"
  41763. }, [_c('label', [_c('input', {
  41764. directives: [{
  41765. name: "model",
  41766. rawName: "v-model",
  41767. value: (_vm.selectedPhotoHasAnotherTeam),
  41768. expression: "selectedPhotoHasAnotherTeam"
  41769. }],
  41770. attrs: {
  41771. "type": "checkbox"
  41772. },
  41773. domProps: {
  41774. "checked": Array.isArray(_vm.selectedPhotoHasAnotherTeam) ? _vm._i(_vm.selectedPhotoHasAnotherTeam, null) > -1 : (_vm.selectedPhotoHasAnotherTeam)
  41775. },
  41776. on: {
  41777. "__c": function($event) {
  41778. var $$a = _vm.selectedPhotoHasAnotherTeam,
  41779. $$el = $event.target,
  41780. $$c = $$el.checked ? (true) : (false);
  41781. if (Array.isArray($$a)) {
  41782. var $$v = null,
  41783. $$i = _vm._i($$a, $$v);
  41784. if ($$c) {
  41785. $$i < 0 && (_vm.selectedPhotoHasAnotherTeam = $$a.concat($$v))
  41786. } else {
  41787. $$i > -1 && (_vm.selectedPhotoHasAnotherTeam = $$a.slice(0, $$i).concat($$a.slice($$i + 1)))
  41788. }
  41789. } else {
  41790. _vm.selectedPhotoHasAnotherTeam = $$c
  41791. }
  41792. }
  41793. }
  41794. }), _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', {
  41795. staticClass: "instructions"
  41796. }, [_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', {
  41797. staticClass: "form-group"
  41798. }, [_c('label', [_c('input', {
  41799. directives: [{
  41800. name: "model",
  41801. rawName: "v-model",
  41802. value: (_vm.selectedM5Singing),
  41803. expression: "selectedM5Singing"
  41804. }],
  41805. attrs: {
  41806. "type": "checkbox"
  41807. },
  41808. domProps: {
  41809. "checked": Array.isArray(_vm.selectedM5Singing) ? _vm._i(_vm.selectedM5Singing, null) > -1 : (_vm.selectedM5Singing)
  41810. },
  41811. on: {
  41812. "__c": function($event) {
  41813. var $$a = _vm.selectedM5Singing,
  41814. $$el = $event.target,
  41815. $$c = $$el.checked ? (true) : (false);
  41816. if (Array.isArray($$a)) {
  41817. var $$v = null,
  41818. $$i = _vm._i($$a, $$v);
  41819. if ($$c) {
  41820. $$i < 0 && (_vm.selectedM5Singing = $$a.concat($$v))
  41821. } else {
  41822. $$i > -1 && (_vm.selectedM5Singing = $$a.slice(0, $$i).concat($$a.slice($$i + 1)))
  41823. }
  41824. } else {
  41825. _vm.selectedM5Singing = $$c
  41826. }
  41827. }
  41828. }
  41829. }), _vm._v("\n Singing\n ")]), _vm._v(" "), _c('br'), _vm._v(" "), _c('label', [_c('input', {
  41830. directives: [{
  41831. name: "model",
  41832. rawName: "v-model",
  41833. value: (_vm.selectedM5Tipping),
  41834. expression: "selectedM5Tipping"
  41835. }],
  41836. attrs: {
  41837. "type": "checkbox"
  41838. },
  41839. domProps: {
  41840. "checked": Array.isArray(_vm.selectedM5Tipping) ? _vm._i(_vm.selectedM5Tipping, null) > -1 : (_vm.selectedM5Tipping)
  41841. },
  41842. on: {
  41843. "__c": function($event) {
  41844. var $$a = _vm.selectedM5Tipping,
  41845. $$el = $event.target,
  41846. $$c = $$el.checked ? (true) : (false);
  41847. if (Array.isArray($$a)) {
  41848. var $$v = null,
  41849. $$i = _vm._i($$a, $$v);
  41850. if ($$c) {
  41851. $$i < 0 && (_vm.selectedM5Tipping = $$a.concat($$v))
  41852. } else {
  41853. $$i > -1 && (_vm.selectedM5Tipping = $$a.slice(0, $$i).concat($$a.slice($$i + 1)))
  41854. }
  41855. } else {
  41856. _vm.selectedM5Tipping = $$c
  41857. }
  41858. }
  41859. }
  41860. }), _vm._v("\n Tipping the driver\n ")])])] : _vm._e(), _vm._v(" "), (_vm.tweet.mission_id == 6) ? [_c('p', {
  41861. staticClass: "instructions"
  41862. }, [_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', {
  41863. staticClass: "instructions"
  41864. }, [_vm._v("\n Accept a photo that completes one of the below documents:\n ")]), _vm._v(" "), _c('div', {
  41865. staticClass: "form-group"
  41866. }, _vm._l((_vm.documents), function(doc) {
  41867. return _c('div', {
  41868. staticClass: "radio"
  41869. }, [_c('label', [_c('input', {
  41870. directives: [{
  41871. name: "model",
  41872. rawName: "v-model",
  41873. value: (_vm.selectedDocument),
  41874. expression: "selectedDocument"
  41875. }],
  41876. attrs: {
  41877. "type": "radio",
  41878. "name": "selectedDocument"
  41879. },
  41880. domProps: {
  41881. "value": doc.id,
  41882. "checked": _vm._q(_vm.selectedDocument, doc.id)
  41883. },
  41884. on: {
  41885. "__c": function($event) {
  41886. _vm.selectedDocument = doc.id
  41887. }
  41888. }
  41889. }), _vm._v("\n " + _vm._s(doc.description) + "\n ")])])
  41890. }))] : _vm._e()], 2)])])]) : _vm._e()
  41891. },staticRenderFns: [function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41892. return _c('p', {
  41893. staticClass: "instructions"
  41894. }, [_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!")])])])
  41895. },function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41896. return _c('p', {
  41897. staticClass: "instructions"
  41898. }, [_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!")])])])
  41899. },function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  41900. return _c('p', {
  41901. staticClass: "instructions"
  41902. }, [_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")])])])
  41903. }]}
  41904. module.exports.render._withStripped = true
  41905. if (false) {
  41906. module.hot.accept()
  41907. if (module.hot.data) {
  41908. require("vue-hot-reload-api").rerender("data-v-1098d79e", module.exports)
  41909. }
  41910. }
  41911. /***/ }),
  41912. /* 61 */
  41913. /***/ (function(module, exports) {
  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. //
  42062. //
  42063. //
  42064. //
  42065. //
  42066. //
  42067. //
  42068. //
  42069. //
  42070. //
  42071. //
  42072. //
  42073. //
  42074. //
  42075. //
  42076. //
  42077. //
  42078. //
  42079. module.exports = {
  42080. props: ['show', 'tweet'],
  42081. data: function data() {
  42082. return {
  42083. documents: [],
  42084. centers: [],
  42085. lines: [],
  42086. replyText: '',
  42087. replyTextCharsRemaining: 140,
  42088. replyInProgress: false,
  42089. showReplyBox: true,
  42090. selectedDocument: null,
  42091. selectedTransitCenter: null,
  42092. selectedTransitLine: null,
  42093. selectedNonTrimetLine: '',
  42094. selectedPhotoHasAnotherTeam: false,
  42095. selectedM5Singing: false,
  42096. selectedM5Tipping: false
  42097. };
  42098. },
  42099. computed: {
  42100. isAcceptDisabled: function isAcceptDisabled() {
  42101. if (this.show) {
  42102. switch (this.tweet.mission_id) {
  42103. case 1:
  42104. return this.selectedTransitLine == null && this.selectedNonTrimetLine == '';
  42105. case 2:
  42106. return this.selectedTransitCenter == null;
  42107. case 3:
  42108. case 4:
  42109. case 6:
  42110. // Nothing to check
  42111. return false;
  42112. case 5:
  42113. return this.selectedM5Singing == false && this.selectedM5Tipping == false;
  42114. case 7:
  42115. return this.selectedDocument == null;
  42116. default:
  42117. return true;
  42118. }
  42119. } else {
  42120. return true;
  42121. }
  42122. },
  42123. isTweetReplyDisabled: function isTweetReplyDisabled() {
  42124. return this.replyText == '' || this.replyInProgress || this.replyTextCharsRemaining < 0;
  42125. }
  42126. },
  42127. methods: {
  42128. clearState: function clearState() {
  42129. this.selectedDocument = null;
  42130. this.selectedTransitCenter = null;
  42131. this.selectedTransitLine = null;
  42132. this.selectedNonTrimetLine = '';
  42133. this.selectedPhotoHasAnotherTeam = false;
  42134. this.selectedM5Singing = false;
  42135. this.selectedM5Tipping = false;
  42136. this.replyText = '';
  42137. this.showReplyBox = true;
  42138. },
  42139. dismiss: function dismiss() {
  42140. this.clearState();
  42141. this.$emit('dismiss');
  42142. },
  42143. rejectTweet: function rejectTweet() {
  42144. $.post("/dashboard/reject-tweet", {
  42145. tweet_id: this.tweet.tweet_id
  42146. }, function () {
  42147. this.clearState();
  42148. this.$emit('complete');
  42149. }.bind(this));
  42150. },
  42151. scoreTweet: function scoreTweet() {
  42152. var score_data = {};
  42153. switch (this.tweet.mission_id) {
  42154. case 1:
  42155. score_data['m1_complete'] = 1;
  42156. score_data['m1_transit_line_id'] = this.selectedTransitLine;
  42157. score_data['m1_non_trimet'] = this.selectedNonTrimetLine;
  42158. break;
  42159. case 2:
  42160. score_data['m2_complete'] = this.selectedTransitCenter ? 1 : 0;
  42161. score_data['m2_transit_center_id'] = this.selectedTransitCenter;
  42162. score_data['m2_with_other_team'] = this.selectedPhotoHasAnotherTeam ? 1 : 0;
  42163. break;
  42164. case 3:
  42165. score_data['m3_complete'] = 1;
  42166. break;
  42167. case 4:
  42168. score_data['m4_complete'] = 1;
  42169. break;
  42170. case 5:
  42171. score_data['m5_complete'] = this.selectedM5Singing ? 1 : 0;
  42172. score_data['m5_tip'] = this.selectedM5Tipping ? 1 : 0;
  42173. break;
  42174. case 6:
  42175. score_data['m6_complete'] = 1;
  42176. break;
  42177. case 7:
  42178. score_data['m7_document_id'] = this.selectedDocument;
  42179. break;
  42180. }
  42181. $.post("/dashboard/score-tweet", {
  42182. tweet_id: this.tweet.tweet_id,
  42183. score_data: score_data
  42184. }, function () {
  42185. this.clearState();
  42186. this.$emit('complete');
  42187. }.bind(this));
  42188. },
  42189. sendReply: function sendReply() {
  42190. this.replyInProgress = true;
  42191. $.post("/dashboard/reply", {
  42192. tweet_id: this.tweet.tweet_id,
  42193. text: this.replyText
  42194. }, function (response) {
  42195. if (response.result == "ok") {
  42196. this.replyText = '';
  42197. }
  42198. this.replyInProgress = false;
  42199. }.bind(this));
  42200. // setTimeout(function(){ this.replyInProgress = false; this.showReplyBox = false; }.bind(this), 1000);
  42201. }
  42202. },
  42203. watch: {
  42204. // https://vuejs.org/v2/guide/computed.html#Watchers
  42205. show: function show(val) {
  42206. if (val) {
  42207. // https://vuejs.org/v2/guide/reactivity.html#Async-Update-Queue
  42208. Vue.nextTick(function () {
  42209. $(".multi-photo .photo").featherlight();
  42210. }.bind(this));
  42211. }
  42212. },
  42213. replyText: function replyText(val) {
  42214. this.replyTextCharsRemaining = 140 - twitter.getTweetLength(val);
  42215. }
  42216. },
  42217. created: function created() {
  42218. $.get("/dashboard/dropdowns", function (response) {
  42219. this.centers = response.transit_centers;
  42220. this.lines = response.transit_lines;
  42221. this.documents = response.documents;
  42222. }.bind(this));
  42223. }
  42224. };
  42225. /***/ }),
  42226. /* 62 */,
  42227. /* 63 */,
  42228. /* 64 */
  42229. /***/ (function(module, exports) {
  42230. /**
  42231. * Featherlight - ultra slim jQuery lightbox
  42232. * Version 1.7.6 - http://noelboss.github.io/featherlight/
  42233. *
  42234. * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com)
  42235. * MIT Licensed.
  42236. **/
  42237. !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(
  42238. /***/ }),
  42239. /* 65 */
  42240. /***/ (function(module, exports, __webpack_require__) {
  42241. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function() {
  42242. if (typeof twttr === "undefined" || twttr === null) {
  42243. var twttr = {};
  42244. }
  42245. twttr.txt = {};
  42246. twttr.txt.regexen = {};
  42247. var HTML_ENTITIES = {
  42248. '&': '&amp;',
  42249. '>': '&gt;',
  42250. '<': '&lt;',
  42251. '"': '&quot;',
  42252. "'": '&#39;'
  42253. };
  42254. // HTML escaping
  42255. twttr.txt.htmlEscape = function(text) {
  42256. return text && text.replace(/[&"'><]/g, function(character) {
  42257. return HTML_ENTITIES[character];
  42258. });
  42259. };
  42260. // Builds a RegExp
  42261. function regexSupplant(regex, flags) {
  42262. flags = flags || "";
  42263. if (typeof regex !== "string") {
  42264. if (regex.global && flags.indexOf("g") < 0) {
  42265. flags += "g";
  42266. }
  42267. if (regex.ignoreCase && flags.indexOf("i") < 0) {
  42268. flags += "i";
  42269. }
  42270. if (regex.multiline && flags.indexOf("m") < 0) {
  42271. flags += "m";
  42272. }
  42273. regex = regex.source;
  42274. }
  42275. return new RegExp(regex.replace(/#\{(\w+)\}/g, function(match, name) {
  42276. var newRegex = twttr.txt.regexen[name] || "";
  42277. if (typeof newRegex !== "string") {
  42278. newRegex = newRegex.source;
  42279. }
  42280. return newRegex;
  42281. }), flags);
  42282. }
  42283. twttr.txt.regexSupplant = regexSupplant;
  42284. // simple string interpolation
  42285. function stringSupplant(str, values) {
  42286. return str.replace(/#\{(\w+)\}/g, function(match, name) {
  42287. return values[name] || "";
  42288. });
  42289. }
  42290. twttr.txt.stringSupplant = stringSupplant;
  42291. twttr.txt.regexen.spaces_group = /\x09-\x0D\x20\x85\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000/;
  42292. twttr.txt.regexen.spaces = regexSupplant(/[#{spaces_group}]/);
  42293. twttr.txt.regexen.invalid_chars_group = /\uFFFE\uFEFF\uFFFF\u202A-\u202E/;
  42294. twttr.txt.regexen.invalid_chars = regexSupplant(/[#{invalid_chars_group}]/);
  42295. twttr.txt.regexen.punct = /\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$/;
  42296. twttr.txt.regexen.rtl_chars = /[\u0600-\u06FF]|[\u0750-\u077F]|[\u0590-\u05FF]|[\uFE70-\uFEFF]/mg;
  42297. twttr.txt.regexen.non_bmp_code_pairs = /[\uD800-\uDBFF][\uDC00-\uDFFF]/mg;
  42298. twttr.txt.regexen.latinAccentChars = /\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u024F\u0253\u0254\u0256\u0257\u0259\u025B\u0263\u0268\u026F\u0272\u0289\u028B\u02BB\u0300-\u036F\u1E00-\u1EFF/;
  42299. // Generated from unicode_regex/unicode_regex_groups.scala, same as objective c's \p{L}\p{M}
  42300. twttr.txt.regexen.bmpLetterAndMarks = /A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u052f\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07ca-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0-\u08b2\u08e4-\u0963\u0971-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09f0\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a70-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0c00-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c81-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0cf1\u0cf2\u0d01-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u103f\u1050-\u108f\u109a-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16f1-\u16f8\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u180b-\u180d\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191e\u1920-\u192b\u1930-\u193b\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f\u1aa7\u1ab0-\u1abe\u1b00-\u1b4b\u1b6b-\u1b73\u1b80-\u1baf\u1bba-\u1bf3\u1c00-\u1c37\u1c4d-\u1c4f\u1c5a-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1cf8\u1cf9\u1d00-\u1df5\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u20d0-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2183\u2184\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005\u3006\u302a-\u302f\u3031-\u3035\u303b\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua672\ua674-\ua67d\ua67f-\ua69d\ua69f-\ua6e5\ua6f0\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua7ad\ua7b0\ua7b1\ua7f7-\ua
  42301. twttr.txt.regexen.astralLetterAndMarks = /\ud800[\udc00-\udc0b\udc0d-\udc26\udc28-\udc3a\udc3c\udc3d\udc3f-\udc4d\udc50-\udc5d\udc80-\udcfa\uddfd\ude80-\ude9c\udea0-\uded0\udee0\udf00-\udf1f\udf30-\udf40\udf42-\udf49\udf50-\udf7a\udf80-\udf9d\udfa0-\udfc3\udfc8-\udfcf]|\ud801[\udc00-\udc9d\udd00-\udd27\udd30-\udd63\ude00-\udf36\udf40-\udf55\udf60-\udf67]|\ud802[\udc00-\udc05\udc08\udc0a-\udc35\udc37\udc38\udc3c\udc3f-\udc55\udc60-\udc76\udc80-\udc9e\udd00-\udd15\udd20-\udd39\udd80-\uddb7\uddbe\uddbf\ude00-\ude03\ude05\ude06\ude0c-\ude13\ude15-\ude17\ude19-\ude33\ude38-\ude3a\ude3f\ude60-\ude7c\ude80-\ude9c\udec0-\udec7\udec9-\udee6\udf00-\udf35\udf40-\udf55\udf60-\udf72\udf80-\udf91]|\ud803[\udc00-\udc48]|\ud804[\udc00-\udc46\udc7f-\udcba\udcd0-\udce8\udd00-\udd34\udd50-\udd73\udd76\udd80-\uddc4\uddda\ude00-\ude11\ude13-\ude37\udeb0-\udeea\udf01-\udf03\udf05-\udf0c\udf0f\udf10\udf13-\udf28\udf2a-\udf30\udf32\udf33\udf35-\udf39\udf3c-\udf44\udf47\udf48\udf4b-\udf4d\udf57\udf5d-\udf63\udf66-\udf6c\udf70-\udf74]|\ud805[\udc80-\udcc5\udcc7\udd80-\uddb5\uddb8-\uddc0\ude00-\ude40\ude44\ude80-\udeb7]|\ud806[\udca0-\udcdf\udcff\udec0-\udef8]|\ud808[\udc00-\udf98]|\ud80c[\udc00-\udfff]|\ud80d[\udc00-\udc2e]|\ud81a[\udc00-\ude38\ude40-\ude5e\uded0-\udeed\udef0-\udef4\udf00-\udf36\udf40-\udf43\udf63-\udf77\udf7d-\udf8f]|\ud81b[\udf00-\udf44\udf50-\udf7e\udf8f-\udf9f]|\ud82c[\udc00\udc01]|\ud82f[\udc00-\udc6a\udc70-\udc7c\udc80-\udc88\udc90-\udc99\udc9d\udc9e]|\ud834[\udd65-\udd69\udd6d-\udd72\udd7b-\udd82\udd85-\udd8b\uddaa-\uddad\ude42-\ude44]|\ud835[\udc00-\udc54\udc56-\udc9c\udc9e\udc9f\udca2\udca5\udca6\udca9-\udcac\udcae-\udcb9\udcbb\udcbd-\udcc3\udcc5-\udd05\udd07-\udd0a\udd0d-\udd14\udd16-\udd1c\udd1e-\udd39\udd3b-\udd3e\udd40-\udd44\udd46\udd4a-\udd50\udd52-\udea5\udea8-\udec0\udec2-\udeda\udedc-\udefa\udefc-\udf14\udf16-\udf34\udf36-\udf4e\udf50-\udf6e\udf70-\udf88\udf8a-\udfa8\udfaa-\udfc2\udfc4-\udfcb]|\ud83a[\udc00-\udcc4\udcd0-\udcd6]|\ud83b[\ude00-\ude03\ude05-\ude1f\ude21\ude22\ude24\ude27\ude29-\ude32\ude34-\ude37\ude39\ude3b\ude42\ude47\ude49\ude4b\ude4d-\ude4f\ude51\ude52\ude54\ude57\ude59\ude5b\ude5d\ude5f\ude61\ude62\ude64\ude67-\ude6a\ude6c-\ude72\ude74-\ude77\ude79-\ude7c\ude7e\ude80-\ude89\ude8b-\ude9b\udea1-\udea3\udea5-\udea9\udeab-\udebb]|\ud840[\udc00-\udfff]|\ud841[\udc00-\udfff]|\ud842[\udc00-\udfff]|\ud843[\udc00-\udfff]|\ud844[\udc00-\udfff]|\ud845[\udc00-\udfff]|\ud846[\udc00-\udfff]|\ud847[\udc00-\udfff]|\ud848[\udc00-\udfff]|\ud849[\udc00-\udfff]|\ud84a[\udc00-\udfff]|\ud84b[\udc00-\udfff]|\ud84c[\udc00-\udfff]|\ud84d[\udc00-\udfff]|\ud84e[\udc00-\udfff]|\ud84f[\udc00-\udfff]|\ud850[\udc00-\udfff]|\ud851[\udc00-\udfff]|\ud852[\udc00-\udfff]|\ud853[\udc00-\udfff]|\ud854[\udc00-\udfff]|\ud855[\udc00-\udfff]|\ud856[\udc00-\udfff]|\ud857[\udc00-\udfff]|\ud858[\udc00-\udfff]|\ud859[\udc00-\udfff]|\ud85a[\udc00-\udfff]|\ud85b[\udc00-\udfff]|\ud85c[\udc00-\udfff]|\ud85d[\udc00-\udfff]|\ud85e[\udc00-\udfff]|\ud85f[\udc00-\udfff]|\ud860[\udc00-\udfff]|\ud861[\udc00-\udfff]|\ud862[\udc00-\udfff]|\ud863[\udc00-\udfff]|\ud864[\udc00-\udfff]|\ud865[\udc00-\udfff]|\ud866[\udc00-\udfff]|\ud867[\udc00-\udfff]|\ud868[\udc00-\udfff]|\ud869[\udc00-\uded6\udf00-\udfff]|\ud86a[\udc00-\udfff]|\ud86b[\udc00-\udfff]|\ud86c[\udc00-\udfff]|\ud86d[\udc00-\udf34\udf40-\udfff]|\ud86e[\udc00-\udc1d]|\ud87e[\udc00-\ude1d]|\udb40[\udd00-\uddef]/;
  42302. // Generated from unicode_regex/unicode_regex_groups.scala, same as objective c's \p{Nd}
  42303. twttr.txt.regexen.bmpNumerals = /0-9\u0660-\u0669\u06f0-\u06f9\u07c0-\u07c9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0de6-\u0def\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u1090-\u1099\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\u1a80-\u1a89\u1a90-\u1a99\u1b50-\u1b59\u1bb0-\u1bb9\u1c40-\u1c49\u1c50-\u1c59\ua620-\ua629\ua8d0-\ua8d9\ua900-\ua909\ua9d0-\ua9d9\ua9f0-\ua9f9\uaa50-\uaa59\uabf0-\uabf9\uff10-\uff19/;
  42304. twttr.txt.regexen.astralNumerals = /\ud801[\udca0-\udca9]|\ud804[\udc66-\udc6f\udcf0-\udcf9\udd36-\udd3f\uddd0-\uddd9\udef0-\udef9]|\ud805[\udcd0-\udcd9\ude50-\ude59\udec0-\udec9]|\ud806[\udce0-\udce9]|\ud81a[\ude60-\ude69\udf50-\udf59]|\ud835[\udfce-\udfff]/;
  42305. twttr.txt.regexen.hashtagSpecialChars = /_\u200c\u200d\ua67e\u05be\u05f3\u05f4\uff5e\u301c\u309b\u309c\u30a0\u30fb\u3003\u0f0b\u0f0c\xb7/;
  42306. // A hashtag must contain at least one unicode letter or mark, as well as numbers, underscores, and select special characters.
  42307. twttr.txt.regexen.hashSigns = /[##]/;
  42308. twttr.txt.regexen.hashtagAlpha = regexSupplant(/(?:[#{bmpLetterAndMarks}]|(?=#{non_bmp_code_pairs})(?:#{astralLetterAndMarks}))/);
  42309. twttr.txt.regexen.hashtagAlphaNumeric = regexSupplant(/(?:[#{bmpLetterAndMarks}#{bmpNumerals}#{hashtagSpecialChars}]|(?=#{non_bmp_code_pairs})(?:#{astralLetterAndMarks}|#{astralNumerals}))/);
  42310. twttr.txt.regexen.endHashtagMatch = regexSupplant(/^(?:#{hashSigns}|:\/\/)/);
  42311. twttr.txt.regexen.codePoint = /(?:[^\uD800-\uDFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF])/;
  42312. twttr.txt.regexen.hashtagBoundary = regexSupplant(/(?:^|\uFE0E|\uFE0F|$|(?!#{hashtagAlphaNumeric}|&)#{codePoint})/);
  42313. twttr.txt.regexen.validHashtag = regexSupplant(/(#{hashtagBoundary})(#{hashSigns})(?!\uFE0F|\u20E3)(#{hashtagAlphaNumeric}*#{hashtagAlpha}#{hashtagAlphaNumeric}*)/gi);
  42314. // Mention related regex collection
  42315. twttr.txt.regexen.validMentionPrecedingChars = /(?:^|[^a-zA-Z0-9_!#$%&*@@]|(?:^|[^a-zA-Z0-9_+~.-])(?:rt|RT|rT|Rt):?)/;
  42316. twttr.txt.regexen.atSigns = /[@@]/;
  42317. twttr.txt.regexen.validMentionOrList = regexSupplant(
  42318. '(#{validMentionPrecedingChars})' + // $1: Preceding character
  42319. '(#{atSigns})' + // $2: At mark
  42320. '([a-zA-Z0-9_]{1,20})' + // $3: Screen name
  42321. '(\/[a-zA-Z][a-zA-Z0-9_\-]{0,24})?' // $4: List (optional)
  42322. , 'g');
  42323. twttr.txt.regexen.validReply = regexSupplant(/^(?:#{spaces})*#{atSigns}([a-zA-Z0-9_]{1,20})/);
  42324. twttr.txt.regexen.endMentionMatch = regexSupplant(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/\/)/);
  42325. // URL related regex collection
  42326. twttr.txt.regexen.validUrlPrecedingChars = regexSupplant(/(?:[^A-Za-z0-9@@$###{invalid_chars_group}]|^)/);
  42327. twttr.txt.regexen.invalidUrlWithoutProtocolPrecedingChars = /[-_.\/]$/;
  42328. twttr.txt.regexen.invalidDomainChars = stringSupplant("#{punct}#{spaces_group}#{invalid_chars_group}", twttr.txt.regexen);
  42329. twttr.txt.regexen.validDomainChars = regexSupplant(/[^#{invalidDomainChars}]/);
  42330. twttr.txt.regexen.validSubdomain = regexSupplant(/(?:(?:#{validDomainChars}(?:[_-]|#{validDomainChars})*)?#{validDomainChars}\.)/);
  42331. twttr.txt.regexen.validDomainName = regexSupplant(/(?:(?:#{validDomainChars}(?:-|#{validDomainChars})*)?#{validDomainChars}\.)/);
  42332. twttr.txt.regexen.validGTLD = regexSupplant(RegExp(
  42333. '(?:(?:' +
  42334. '삼성|닷컴|닷넷|香格里拉|餐厅|食品|飞利浦|電訊盈科|集团|通販|购物|谷歌|诺基亚|联通|网络|网站|网店|网址|组织机构|移动|珠宝|点看|游戏|淡马锡|机构|書籍|时尚|新闻|政府|' +
  42335. '政务|手表|手机|我爱你|慈善|微博|广东|工行|家電|娱乐|天主教|大拿|大众汽车|在线|嘉里大酒店|嘉里|商标|商店|商城|公益|公司|八卦|健康|信息|佛山|企业|中文网|中信|世界|' +
  42336. 'ポイント|ファッション|セール|ストア|コム|グーグル|クラウド|みんな|คอม|संगठन|नेट|कॉम|همراه|موقع|موبايلي|كوم|كاثوليك|عرب|شبكة|' +
  42337. 'بيتك|بازار|العليان|ارامكو|اتصالات|ابوظبي|קום|сайт|рус|орг|онлайн|москва|ком|католик|дети|' +
  42338. 'zuerich|zone|zippo|zip|zero|zara|zappos|yun|youtube|you|yokohama|yoga|yodobashi|yandex|yamaxun|' +
  42339. 'yahoo|yachts|xyz|xxx|xperia|xin|xihuan|xfinity|xerox|xbox|wtf|wtc|wow|world|works|work|woodside|' +
  42340. 'wolterskluwer|wme|winners|wine|windows|win|williamhill|wiki|wien|whoswho|weir|weibo|wedding|wed|' +
  42341. 'website|weber|webcam|weatherchannel|weather|watches|watch|warman|wanggou|wang|walter|walmart|' +
  42342. 'wales|vuelos|voyage|voto|voting|vote|volvo|volkswagen|vodka|vlaanderen|vivo|viva|vistaprint|' +
  42343. 'vista|vision|visa|virgin|vip|vin|villas|viking|vig|video|viajes|vet|versicherung|' +
  42344. 'vermögensberatung|vermögensberater|verisign|ventures|vegas|vanguard|vana|vacations|ups|uol|uno|' +
  42345. 'university|unicom|uconnect|ubs|ubank|tvs|tushu|tunes|tui|tube|trv|trust|travelersinsurance|' +
  42346. 'travelers|travelchannel|travel|training|trading|trade|toys|toyota|town|tours|total|toshiba|' +
  42347. 'toray|top|tools|tokyo|today|tmall|tkmaxx|tjx|tjmaxx|tirol|tires|tips|tiffany|tienda|tickets|' +
  42348. 'tiaa|theatre|theater|thd|teva|tennis|temasek|telefonica|telecity|tel|technology|tech|team|tdk|' +
  42349. 'tci|taxi|tax|tattoo|tatar|tatamotors|target|taobao|talk|taipei|tab|systems|symantec|sydney|' +
  42350. 'swiss|swiftcover|swatch|suzuki|surgery|surf|support|supply|supplies|sucks|style|study|studio|' +
  42351. 'stream|store|storage|stockholm|stcgroup|stc|statoil|statefarm|statebank|starhub|star|staples|' +
  42352. 'stada|srt|srl|spreadbetting|spot|spiegel|space|soy|sony|song|solutions|solar|sohu|software|' +
  42353. 'softbank|social|soccer|sncf|smile|smart|sling|skype|sky|skin|ski|site|singles|sina|silk|shriram|' +
  42354. 'showtime|show|shouji|shopping|shop|shoes|shiksha|shia|shell|shaw|sharp|shangrila|sfr|sexy|sex|' +
  42355. 'sew|seven|ses|services|sener|select|seek|security|secure|seat|search|scot|scor|scjohnson|' +
  42356. 'science|schwarz|schule|school|scholarships|schmidt|schaeffler|scb|sca|sbs|sbi|saxo|save|sas|' +
  42357. 'sarl|sapo|sap|sanofi|sandvikcoromant|sandvik|samsung|samsclub|salon|sale|sakura|safety|safe|' +
  42358. 'saarland|ryukyu|rwe|run|ruhr|rugby|rsvp|room|rogers|rodeo|rocks|rocher|rmit|rip|rio|ril|' +
  42359. 'rightathome|ricoh|richardli|rich|rexroth|reviews|review|restaurant|rest|republican|report|' +
  42360. 'repair|rentals|rent|ren|reliance|reit|reisen|reise|rehab|redumbrella|redstone|red|recipes|' +
  42361. 'realty|realtor|realestate|read|raid|radio|racing|qvc|quest|quebec|qpon|pwc|pub|prudential|pru|' +
  42362. 'protection|property|properties|promo|progressive|prof|productions|prod|pro|prime|press|praxi|' +
  42363. 'pramerica|post|porn|politie|poker|pohl|pnc|plus|plumbing|playstation|play|place|pizza|pioneer|' +
  42364. 'pink|ping|pin|pid|pictures|pictet|pics|piaget|physio|photos|photography|photo|phone|philips|phd|' +
  42365. 'pharmacy|pfizer|pet|pccw|pay|passagens|party|parts|partners|pars|paris|panerai|panasonic|' +
  42366. 'pamperedchef|page|ovh|ott|otsuka|osaka|origins|orientexpress|organic|org|orange|oracle|open|ooo|' +
  42367. 'onyourside|online|onl|ong|one|omega|ollo|oldnavy|olayangroup|olayan|okinawa|office|off|observer|' +
  42368. 'obi|nyc|ntt|nrw|nra|nowtv|nowruz|now|norton|northwesternmutual|nokia|nissay|nissan|ninja|nikon|' +
  42369. 'nike|nico|nhk|ngo|nfl|nexus|nextdirect|next|news|newholland|new|neustar|network|netflix|netbank|' +
  42370. 'net|nec|nba|navy|natura|nationwide|name|nagoya|nadex|nab|mutuelle|mutual|museum|mtr|mtpc|mtn|' +
  42371. 'msd|movistar|movie|mov|motorcycles|moto|moscow|mortgage|mormon|mopar|montblanc|monster|money|' +
  42372. 'monash|mom|moi|moe|moda|mobily|mobile|mobi|mma|mls|mlb|mitsubishi|mit|mint|mini|mil|microsoft|' +
  42373. 'miami|metlife|merckmsd|meo|menu|men|memorial|meme|melbourne|meet|media|med|mckinsey|mcdonalds|' +
  42374. 'mcd|mba|mattel|maserati|marshalls|marriott|markets|marketing|market|map|mango|management|man|' +
  42375. 'makeup|maison|maif|madrid|macys|luxury|luxe|lupin|lundbeck|ltda|ltd|lplfinancial|lpl|love|lotto|' +
  42376. 'lotte|london|lol|loft|locus|locker|loans|loan|lixil|living|live|lipsy|link|linde|lincoln|limo|' +
  42377. 'limited|lilly|like|lighting|lifestyle|lifeinsurance|life|lidl|liaison|lgbt|lexus|lego|legal|' +
  42378. 'lefrak|leclerc|lease|lds|lawyer|law|latrobe|latino|lat|lasalle|lanxess|landrover|land|lancome|' +
  42379. 'lancia|lancaster|lamer|lamborghini|ladbrokes|lacaixa|kyoto|kuokgroup|kred|krd|kpn|kpmg|kosher|' +
  42380. 'komatsu|koeln|kiwi|kitchen|kindle|kinder|kim|kia|kfh|kerryproperties|kerrylogistics|kerryhotels|' +
  42381. 'kddi|kaufen|juniper|juegos|jprs|jpmorgan|joy|jot|joburg|jobs|jnj|jmp|jll|jlc|jio|jewelry|jetzt|' +
  42382. 'jeep|jcp|jcb|java|jaguar|iwc|iveco|itv|itau|istanbul|ist|ismaili|iselect|irish|ipiranga|' +
  42383. 'investments|intuit|international|intel|int|insure|insurance|institute|ink|ing|info|infiniti|' +
  42384. 'industries|immobilien|immo|imdb|imamat|ikano|iinet|ifm|ieee|icu|ice|icbc|ibm|hyundai|hyatt|' +
  42385. 'hughes|htc|hsbc|how|house|hotmail|hotels|hoteles|hot|hosting|host|hospital|horse|honeywell|' +
  42386. 'honda|homesense|homes|homegoods|homedepot|holiday|holdings|hockey|hkt|hiv|hitachi|hisamitsu|' +
  42387. 'hiphop|hgtv|hermes|here|helsinki|help|healthcare|health|hdfcbank|hdfc|hbo|haus|hangout|hamburg|' +
  42388. 'hair|guru|guitars|guide|guge|gucci|guardian|group|grocery|gripe|green|gratis|graphics|grainger|' +
  42389. 'gov|got|gop|google|goog|goodyear|goodhands|goo|golf|goldpoint|gold|godaddy|gmx|gmo|gmbh|gmail|' +
  42390. 'globo|global|gle|glass|glade|giving|gives|gifts|gift|ggee|george|genting|gent|gea|gdn|gbiz|' +
  42391. 'garden|gap|games|game|gallup|gallo|gallery|gal|fyi|futbol|furniture|fund|fun|fujixerox|fujitsu|' +
  42392. 'ftr|frontier|frontdoor|frogans|frl|fresenius|free|fox|foundation|forum|forsale|forex|ford|' +
  42393. 'football|foodnetwork|food|foo|fly|flsmidth|flowers|florist|flir|flights|flickr|fitness|fit|' +
  42394. 'fishing|fish|firmdale|firestone|fire|financial|finance|final|film|fido|fidelity|fiat|ferrero|' +
  42395. 'ferrari|feedback|fedex|fast|fashion|farmers|farm|fans|fan|family|faith|fairwinds|fail|fage|' +
  42396. 'extraspace|express|exposed|expert|exchange|everbank|events|eus|eurovision|etisalat|esurance|' +
  42397. 'estate|esq|erni|ericsson|equipment|epson|epost|enterprises|engineering|engineer|energy|emerck|' +
  42398. 'email|education|edu|edeka|eco|eat|earth|dvr|dvag|durban|dupont|duns|dunlop|duck|dubai|dtv|drive|' +
  42399. 'download|dot|doosan|domains|doha|dog|dodge|doctor|docs|dnp|diy|dish|discover|discount|directory|' +
  42400. 'direct|digital|diet|diamonds|dhl|dev|design|desi|dentist|dental|democrat|delta|deloitte|dell|' +
  42401. 'delivery|degree|deals|dealer|deal|dds|dclk|day|datsun|dating|date|data|dance|dad|dabur|cyou|' +
  42402. 'cymru|cuisinella|csc|cruises|cruise|crs|crown|cricket|creditunion|creditcard|credit|courses|' +
  42403. 'coupons|coupon|country|corsica|coop|cool|cookingchannel|cooking|contractors|contact|consulting|' +
  42404. 'construction|condos|comsec|computer|compare|company|community|commbank|comcast|com|cologne|' +
  42405. 'college|coffee|codes|coach|clubmed|club|cloud|clothing|clinique|clinic|click|cleaning|claims|' +
  42406. 'cityeats|city|citic|citi|citadel|cisco|circle|cipriani|church|chrysler|chrome|christmas|chloe|' +
  42407. 'chintai|cheap|chat|chase|channel|chanel|cfd|cfa|cern|ceo|center|ceb|cbs|cbre|cbn|cba|catholic|' +
  42408. 'catering|cat|casino|cash|caseih|case|casa|cartier|cars|careers|career|care|cards|caravan|car|' +
  42409. 'capitalone|capital|capetown|canon|cancerresearch|camp|camera|cam|calvinklein|call|cal|cafe|cab|' +
  42410. 'bzh|buzz|buy|business|builders|build|bugatti|budapest|brussels|brother|broker|broadway|' +
  42411. 'bridgestone|bradesco|box|boutique|bot|boston|bostik|bosch|boots|booking|book|boo|bond|bom|bofa|' +
  42412. 'boehringer|boats|bnpparibas|bnl|bmw|bms|blue|bloomberg|blog|blockbuster|blanco|blackfriday|' +
  42413. 'black|biz|bio|bingo|bing|bike|bid|bible|bharti|bet|bestbuy|best|berlin|bentley|beer|beauty|' +
  42414. 'beats|bcn|bcg|bbva|bbt|bbc|bayern|bauhaus|basketball|baseball|bargains|barefoot|barclays|' +
  42415. 'barclaycard|barcelona|bar|bank|band|bananarepublic|banamex|baidu|baby|azure|axa|aws|avianca|' +
  42416. 'autos|auto|author|auspost|audio|audible|audi|auction|attorney|athleta|associates|asia|asda|arte|' +
  42417. 'art|arpa|army|archi|aramco|arab|aquarelle|apple|app|apartments|aol|anz|anquan|android|analytics|' +
  42418. 'amsterdam|amica|amfam|amex|americanfamily|americanexpress|alstom|alsace|ally|allstate|allfinanz|' +
  42419. 'alipay|alibaba|alfaromeo|akdn|airtel|airforce|airbus|aigo|aig|agency|agakhan|africa|afl|' +
  42420. 'afamilycompany|aetna|aero|aeg|adult|ads|adac|actor|active|aco|accountants|accountant|accenture|' +
  42421. 'academy|abudhabi|abogado|able|abc|abbvie|abbott|abb|abarth|aarp|aaa|onion' +
  42422. ')(?=[^0-9a-zA-Z@]|$))'));
  42423. twttr.txt.regexen.validCCTLD = regexSupplant(RegExp(
  42424. '(?:(?:' +
  42425. '한국|香港|澳門|新加坡|台灣|台湾|中國|中国|გე|ไทย|ලංකා|ഭാരതം|ಭಾರತ|భారత్|சிங்கப்பூர்|இலங்கை|இந்தியா|ଭାରତ|ભારત|ਭਾਰਤ|' +
  42426. 'ভাৰত|ভারত|বাংলা|भारोत|भारतम्|भारत|ڀارت|پاکستان|مليسيا|مصر|قطر|فلسطين|عمان|عراق|سورية|سودان|تونس|' +
  42427. 'بھارت|بارت|ایران|امارات|المغرب|السعودية|الجزائر|الاردن|հայ|қаз|укр|срб|рф|мон|мкд|ею|бел|бг|ελ|' +
  42428. 'zw|zm|za|yt|ye|ws|wf|vu|vn|vi|vg|ve|vc|va|uz|uy|us|um|uk|ug|ua|tz|tw|tv|tt|tr|tp|to|tn|tm|tl|tk|' +
  42429. 'tj|th|tg|tf|td|tc|sz|sy|sx|sv|su|st|ss|sr|so|sn|sm|sl|sk|sj|si|sh|sg|se|sd|sc|sb|sa|rw|ru|rs|ro|' +
  42430. 're|qa|py|pw|pt|ps|pr|pn|pm|pl|pk|ph|pg|pf|pe|pa|om|nz|nu|nr|np|no|nl|ni|ng|nf|ne|nc|na|mz|my|mx|' +
  42431. 'mw|mv|mu|mt|ms|mr|mq|mp|mo|mn|mm|ml|mk|mh|mg|mf|me|md|mc|ma|ly|lv|lu|lt|ls|lr|lk|li|lc|lb|la|kz|' +
  42432. 'ky|kw|kr|kp|kn|km|ki|kh|kg|ke|jp|jo|jm|je|it|is|ir|iq|io|in|im|il|ie|id|hu|ht|hr|hn|hm|hk|gy|gw|' +
  42433. 'gu|gt|gs|gr|gq|gp|gn|gm|gl|gi|gh|gg|gf|ge|gd|gb|ga|fr|fo|fm|fk|fj|fi|eu|et|es|er|eh|eg|ee|ec|dz|' +
  42434. 'do|dm|dk|dj|de|cz|cy|cx|cw|cv|cu|cr|co|cn|cm|cl|ck|ci|ch|cg|cf|cd|cc|ca|bz|by|bw|bv|bt|bs|br|bq|' +
  42435. 'bo|bn|bm|bl|bj|bi|bh|bg|bf|be|bd|bb|ba|az|ax|aw|au|at|as|ar|aq|ao|an|am|al|ai|ag|af|ae|ad|ac' +
  42436. ')(?=[^0-9a-zA-Z@]|$))'));
  42437. twttr.txt.regexen.validPunycode = /(?:xn--[0-9a-z]+)/;
  42438. twttr.txt.regexen.validSpecialCCTLD = /(?:(?:co|tv)(?=[^0-9a-zA-Z@]|$))/;
  42439. twttr.txt.regexen.validDomain = regexSupplant(/(?:#{validSubdomain}*#{validDomainName}(?:#{validGTLD}|#{validCCTLD}|#{validPunycode}))/);
  42440. twttr.txt.regexen.validAsciiDomain = regexSupplant(/(?:(?:[\-a-z0-9#{latinAccentChars}]+)\.)+(?:#{validGTLD}|#{validCCTLD}|#{validPunycode})/gi);
  42441. twttr.txt.regexen.invalidShortDomain = regexSupplant(/^#{validDomainName}#{validCCTLD}$/i);
  42442. twttr.txt.regexen.validSpecialShortDomain = regexSupplant(/^#{validDomainName}#{validSpecialCCTLD}$/i);
  42443. twttr.txt.regexen.validPortNumber = /[0-9]+/;
  42444. twttr.txt.regexen.cyrillicLettersAndMarks = /\u0400-\u04FF/;
  42445. twttr.txt.regexen.validGeneralUrlPathChars = regexSupplant(/[a-z#{cyrillicLettersAndMarks}0-9!\*';:=\+,\.\$\/%#\[\]\-_~@\|&#{latinAccentChars}]/i);
  42446. // Allow URL paths to contain up to two nested levels of balanced parens
  42447. // 1. Used in Wikipedia URLs like /Primer_(film)
  42448. // 2. Used in IIS sessions like /S(dfd346)/
  42449. // 3. Used in Rdio URLs like /track/We_Up_(Album_Version_(Edited))/
  42450. twttr.txt.regexen.validUrlBalancedParens = regexSupplant(
  42451. '\\(' +
  42452. '(?:' +
  42453. '#{validGeneralUrlPathChars}+' +
  42454. '|' +
  42455. // allow one nested level of balanced parentheses
  42456. '(?:' +
  42457. '#{validGeneralUrlPathChars}*' +
  42458. '\\(' +
  42459. '#{validGeneralUrlPathChars}+' +
  42460. '\\)' +
  42461. '#{validGeneralUrlPathChars}*' +
  42462. ')' +
  42463. ')' +
  42464. '\\)'
  42465. , 'i');
  42466. // Valid end-of-path chracters (so /foo. does not gobble the period).
  42467. // 1. Allow =&# for empty URL parameters and other URL-join artifacts
  42468. twttr.txt.regexen.validUrlPathEndingChars = regexSupplant(/[\+\-a-z#{cyrillicLettersAndMarks}0-9=_#\/#{latinAccentChars}]|(?:#{validUrlBalancedParens})/i);
  42469. // Allow @ in a url, but only in the middle. Catch things like http://example.com/@user/
  42470. twttr.txt.regexen.validUrlPath = regexSupplant('(?:' +
  42471. '(?:' +
  42472. '#{validGeneralUrlPathChars}*' +
  42473. '(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*' +
  42474. '#{validUrlPathEndingChars}'+
  42475. ')|(?:@#{validGeneralUrlPathChars}+\/)'+
  42476. ')', 'i');
  42477. twttr.txt.regexen.validUrlQueryChars = /[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i;
  42478. twttr.txt.regexen.validUrlQueryEndingChars = /[a-z0-9_&=#\/]/i;
  42479. twttr.txt.regexen.extractUrl = regexSupplant(
  42480. '(' + // $1 total match
  42481. '(#{validUrlPrecedingChars})' + // $2 Preceeding chracter
  42482. '(' + // $3 URL
  42483. '(https?:\\/\\/)?' + // $4 Protocol (optional)
  42484. '(#{validDomain})' + // $5 Domain(s)
  42485. '(?::(#{validPortNumber}))?' + // $6 Port number (optional)
  42486. '(\\/#{validUrlPath}*)?' + // $7 URL Path
  42487. '(\\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?' + // $8 Query String
  42488. ')' +
  42489. ')'
  42490. , 'gi');
  42491. twttr.txt.regexen.validTcoUrl = /^https?:\/\/t\.co\/[a-z0-9]+/i;
  42492. twttr.txt.regexen.urlHasProtocol = /^https?:\/\//i;
  42493. twttr.txt.regexen.urlHasHttps = /^https:\/\//i;
  42494. // cashtag related regex
  42495. twttr.txt.regexen.cashtag = /[a-z]{1,6}(?:[._][a-z]{1,2})?/i;
  42496. twttr.txt.regexen.validCashtag = regexSupplant('(^|#{spaces})(\\$)(#{cashtag})(?=$|\\s|[#{punct}])', 'gi');
  42497. // These URL validation pattern strings are based on the ABNF from RFC 3986
  42498. twttr.txt.regexen.validateUrlUnreserved = /[a-z\u0400-\u04FF0-9\-._~]/i;
  42499. twttr.txt.regexen.validateUrlPctEncoded = /(?:%[0-9a-f]{2})/i;
  42500. twttr.txt.regexen.validateUrlSubDelims = /[!$&'()*+,;=]/i;
  42501. twttr.txt.regexen.validateUrlPchar = regexSupplant('(?:' +
  42502. '#{validateUrlUnreserved}|' +
  42503. '#{validateUrlPctEncoded}|' +
  42504. '#{validateUrlSubDelims}|' +
  42505. '[:|@]' +
  42506. ')', 'i');
  42507. twttr.txt.regexen.validateUrlScheme = /(?:[a-z][a-z0-9+\-.]*)/i;
  42508. twttr.txt.regexen.validateUrlUserinfo = regexSupplant('(?:' +
  42509. '#{validateUrlUnreserved}|' +
  42510. '#{validateUrlPctEncoded}|' +
  42511. '#{validateUrlSubDelims}|' +
  42512. ':' +
  42513. ')*', 'i');
  42514. twttr.txt.regexen.validateUrlDecOctet = /(?:[0-9]|(?:[1-9][0-9])|(?:1[0-9]{2})|(?:2[0-4][0-9])|(?:25[0-5]))/i;
  42515. twttr.txt.regexen.validateUrlIpv4 = regexSupplant(/(?:#{validateUrlDecOctet}(?:\.#{validateUrlDecOctet}){3})/i);
  42516. // Punting on real IPv6 validation for now
  42517. twttr.txt.regexen.validateUrlIpv6 = /(?:\[[a-f0-9:\.]+\])/i;
  42518. // Also punting on IPvFuture for now
  42519. twttr.txt.regexen.validateUrlIp = regexSupplant('(?:' +
  42520. '#{validateUrlIpv4}|' +
  42521. '#{validateUrlIpv6}' +
  42522. ')', 'i');
  42523. // This is more strict than the rfc specifies
  42524. twttr.txt.regexen.validateUrlSubDomainSegment = /(?:[a-z0-9](?:[a-z0-9_\-]*[a-z0-9])?)/i;
  42525. twttr.txt.regexen.validateUrlDomainSegment = /(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?)/i;
  42526. twttr.txt.regexen.validateUrlDomainTld = /(?:[a-z](?:[a-z0-9\-]*[a-z0-9])?)/i;
  42527. twttr.txt.regexen.validateUrlDomain = regexSupplant(/(?:(?:#{validateUrlSubDomainSegment}\.)*(?:#{validateUrlDomainSegment}\.)#{validateUrlDomainTld})/i);
  42528. twttr.txt.regexen.validateUrlHost = regexSupplant('(?:' +
  42529. '#{validateUrlIp}|' +
  42530. '#{validateUrlDomain}' +
  42531. ')', 'i');
  42532. // Unencoded internationalized domains - this doesn't check for invalid UTF-8 sequences
  42533. twttr.txt.regexen.validateUrlUnicodeSubDomainSegment = /(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9_\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i;
  42534. twttr.txt.regexen.validateUrlUnicodeDomainSegment = /(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i;
  42535. twttr.txt.regexen.validateUrlUnicodeDomainTld = /(?:(?:[a-z]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i;
  42536. twttr.txt.regexen.validateUrlUnicodeDomain = regexSupplant(/(?:(?:#{validateUrlUnicodeSubDomainSegment}\.)*(?:#{validateUrlUnicodeDomainSegment}\.)#{validateUrlUnicodeDomainTld})/i);
  42537. twttr.txt.regexen.validateUrlUnicodeHost = regexSupplant('(?:' +
  42538. '#{validateUrlIp}|' +
  42539. '#{validateUrlUnicodeDomain}' +
  42540. ')', 'i');
  42541. twttr.txt.regexen.validateUrlPort = /[0-9]{1,5}/;
  42542. twttr.txt.regexen.validateUrlUnicodeAuthority = regexSupplant(
  42543. '(?:(#{validateUrlUserinfo})@)?' + // $1 userinfo
  42544. '(#{validateUrlUnicodeHost})' + // $2 host
  42545. '(?::(#{validateUrlPort}))?' //$3 port
  42546. , "i");
  42547. twttr.txt.regexen.validateUrlAuthority = regexSupplant(
  42548. '(?:(#{validateUrlUserinfo})@)?' + // $1 userinfo
  42549. '(#{validateUrlHost})' + // $2 host
  42550. '(?::(#{validateUrlPort}))?' // $3 port
  42551. , "i");
  42552. twttr.txt.regexen.validateUrlPath = regexSupplant(/(\/#{validateUrlPchar}*)*/i);
  42553. twttr.txt.regexen.validateUrlQuery = regexSupplant(/(#{validateUrlPchar}|\/|\?)*/i);
  42554. twttr.txt.regexen.validateUrlFragment = regexSupplant(/(#{validateUrlPchar}|\/|\?)*/i);
  42555. // Modified version of RFC 3986 Appendix B
  42556. twttr.txt.regexen.validateUrlUnencoded = regexSupplant(
  42557. '^' + // Full URL
  42558. '(?:' +
  42559. '([^:/?#]+):\\/\\/' + // $1 Scheme
  42560. ')?' +
  42561. '([^/?#]*)' + // $2 Authority
  42562. '([^?#]*)' + // $3 Path
  42563. '(?:' +
  42564. '\\?([^#]*)' + // $4 Query
  42565. ')?' +
  42566. '(?:' +
  42567. '#(.*)' + // $5 Fragment
  42568. ')?$'
  42569. , "i");
  42570. // Default CSS class for auto-linked lists (along with the url class)
  42571. var DEFAULT_LIST_CLASS = "tweet-url list-slug";
  42572. // Default CSS class for auto-linked usernames (along with the url class)
  42573. var DEFAULT_USERNAME_CLASS = "tweet-url username";
  42574. // Default CSS class for auto-linked hashtags (along with the url class)
  42575. var DEFAULT_HASHTAG_CLASS = "tweet-url hashtag";
  42576. // Default CSS class for auto-linked cashtags (along with the url class)
  42577. var DEFAULT_CASHTAG_CLASS = "tweet-url cashtag";
  42578. // Options which should not be passed as HTML attributes
  42579. var OPTIONS_NOT_ATTRIBUTES = {'urlClass':true, 'listClass':true, 'usernameClass':true, 'hashtagClass':true, 'cashtagClass':true,
  42580. 'usernameUrlBase':true, 'listUrlBase':true, 'hashtagUrlBase':true, 'cashtagUrlBase':true,
  42581. 'usernameUrlBlock':true, 'listUrlBlock':true, 'hashtagUrlBlock':true, 'linkUrlBlock':true,
  42582. 'usernameIncludeSymbol':true, 'suppressLists':true, 'suppressNoFollow':true, 'targetBlank':true,
  42583. 'suppressDataScreenName':true, 'urlEntities':true, 'symbolTag':true, 'textWithSymbolTag':true, 'urlTarget':true,
  42584. 'invisibleTagAttrs':true, 'linkAttributeBlock':true, 'linkTextBlock': true, 'htmlEscapeNonEntities': true
  42585. };
  42586. var BOOLEAN_ATTRIBUTES = {'disabled':true, 'readonly':true, 'multiple':true, 'checked':true};
  42587. // Simple object cloning function for simple objects
  42588. function clone(o) {
  42589. var r = {};
  42590. for (var k in o) {
  42591. if (o.hasOwnProperty(k)) {
  42592. r[k] = o[k];
  42593. }
  42594. }
  42595. return r;
  42596. }
  42597. twttr.txt.tagAttrs = function(attributes) {
  42598. var htmlAttrs = "";
  42599. for (var k in attributes) {
  42600. var v = attributes[k];
  42601. if (BOOLEAN_ATTRIBUTES[k]) {
  42602. v = v ? k : null;
  42603. }
  42604. if (v == null) continue;
  42605. htmlAttrs += " " + twttr.txt.htmlEscape(k) + "=\"" + twttr.txt.htmlEscape(v.toString()) + "\"";
  42606. }
  42607. return htmlAttrs;
  42608. };
  42609. twttr.txt.linkToText = function(entity, text, attributes, options) {
  42610. if (!options.suppressNoFollow) {
  42611. attributes.rel = "nofollow";
  42612. }
  42613. // if linkAttributeBlock is specified, call it to modify the attributes
  42614. if (options.linkAttributeBlock) {
  42615. options.linkAttributeBlock(entity, attributes);
  42616. }
  42617. // if linkTextBlock is specified, call it to get a new/modified link text
  42618. if (options.linkTextBlock) {
  42619. text = options.linkTextBlock(entity, text);
  42620. }
  42621. var d = {
  42622. text: text,
  42623. attr: twttr.txt.tagAttrs(attributes)
  42624. };
  42625. return stringSupplant("<a#{attr}>#{text}</a>", d);
  42626. };
  42627. twttr.txt.linkToTextWithSymbol = function(entity, symbol, text, attributes, options) {
  42628. var taggedSymbol = options.symbolTag ? "<" + options.symbolTag + ">" + symbol + "</"+ options.symbolTag + ">" : symbol;
  42629. text = twttr.txt.htmlEscape(text);
  42630. var taggedText = options.textWithSymbolTag ? "<" + options.textWithSymbolTag + ">" + text + "</"+ options.textWithSymbolTag + ">" : text;
  42631. if (options.usernameIncludeSymbol || !symbol.match(twttr.txt.regexen.atSigns)) {
  42632. return twttr.txt.linkToText(entity, taggedSymbol + taggedText, attributes, options);
  42633. } else {
  42634. return taggedSymbol + twttr.txt.linkToText(entity, taggedText, attributes, options);
  42635. }
  42636. };
  42637. twttr.txt.linkToHashtag = function(entity, text, options) {
  42638. var hash = text.substring(entity.indices[0], entity.indices[0] + 1);
  42639. var hashtag = twttr.txt.htmlEscape(entity.hashtag);
  42640. var attrs = clone(options.htmlAttrs || {});
  42641. attrs.href = options.hashtagUrlBase + hashtag;
  42642. attrs.title = "#" + hashtag;
  42643. attrs["class"] = options.hashtagClass;
  42644. if (hashtag.charAt(0).match(twttr.txt.regexen.rtl_chars)){
  42645. attrs["class"] += " rtl";
  42646. }
  42647. if (options.targetBlank) {
  42648. attrs.target = '_blank';
  42649. }
  42650. return twttr.txt.linkToTextWithSymbol(entity, hash, hashtag, attrs, options);
  42651. };
  42652. twttr.txt.linkToCashtag = function(entity, text, options) {
  42653. var cashtag = twttr.txt.htmlEscape(entity.cashtag);
  42654. var attrs = clone(options.htmlAttrs || {});
  42655. attrs.href = options.cashtagUrlBase + cashtag;
  42656. attrs.title = "$" + cashtag;
  42657. attrs["class"] = options.cashtagClass;
  42658. if (options.targetBlank) {
  42659. attrs.target = '_blank';
  42660. }
  42661. return twttr.txt.linkToTextWithSymbol(entity, "$", cashtag, attrs, options);
  42662. };
  42663. twttr.txt.linkToMentionAndList = function(entity, text, options) {
  42664. var at = text.substring(entity.indices[0], entity.indices[0] + 1);
  42665. var user = twttr.txt.htmlEscape(entity.screenName);
  42666. var slashListname = twttr.txt.htmlEscape(entity.listSlug);
  42667. var isList = entity.listSlug && !options.suppressLists;
  42668. var attrs = clone(options.htmlAttrs || {});
  42669. attrs["class"] = (isList ? options.listClass : options.usernameClass);
  42670. attrs.href = isList ? options.listUrlBase + user + slashListname : options.usernameUrlBase + user;
  42671. if (!isList && !options.suppressDataScreenName) {
  42672. attrs['data-screen-name'] = user;
  42673. }
  42674. if (options.targetBlank) {
  42675. attrs.target = '_blank';
  42676. }
  42677. return twttr.txt.linkToTextWithSymbol(entity, at, isList ? user + slashListname : user, attrs, options);
  42678. };
  42679. twttr.txt.linkToUrl = function(entity, text, options) {
  42680. var url = entity.url;
  42681. var displayUrl = url;
  42682. var linkText = twttr.txt.htmlEscape(displayUrl);
  42683. // If the caller passed a urlEntities object (provided by a Twitter API
  42684. // response with include_entities=true), we use that to render the display_url
  42685. // for each URL instead of it's underlying t.co URL.
  42686. var urlEntity = (options.urlEntities && options.urlEntities[url]) || entity;
  42687. if (urlEntity.display_url) {
  42688. linkText = twttr.txt.linkTextWithEntity(urlEntity, options);
  42689. }
  42690. var attrs = clone(options.htmlAttrs || {});
  42691. if (!url.match(twttr.txt.regexen.urlHasProtocol)) {
  42692. url = "http://" + url;
  42693. }
  42694. attrs.href = url;
  42695. if (options.targetBlank) {
  42696. attrs.target = '_blank';
  42697. }
  42698. // set class only if urlClass is specified.
  42699. if (options.urlClass) {
  42700. attrs["class"] = options.urlClass;
  42701. }
  42702. // set target only if urlTarget is specified.
  42703. if (options.urlTarget) {
  42704. attrs.target = options.urlTarget;
  42705. }
  42706. if (!options.title && urlEntity.display_url) {
  42707. attrs.title = urlEntity.expanded_url;
  42708. }
  42709. return twttr.txt.linkToText(entity, linkText, attrs, options);
  42710. };
  42711. twttr.txt.linkTextWithEntity = function (entity, options) {
  42712. var displayUrl = entity.display_url;
  42713. var expandedUrl = entity.expanded_url;
  42714. // Goal: If a user copies and pastes a tweet containing t.co'ed link, the resulting paste
  42715. // should contain the full original URL (expanded_url), not the display URL.
  42716. //
  42717. // Method: Whenever possible, we actually emit HTML that contains expanded_url, and use
  42718. // font-size:0 to hide those parts that should not be displayed (because they are not part of display_url).
  42719. // Elements with font-size:0 get copied even though they are not visible.
  42720. // Note that display:none doesn't work here. Elements with display:none don't get copied.
  42721. //
  42722. // Additionally, we want to *display* ellipses, but we don't want them copied. To make this happen we
  42723. // wrap the ellipses in a tco-ellipsis class and provide an onCopy handler that sets display:none on
  42724. // everything with the tco-ellipsis class.
  42725. //
  42726. // Exception: pic.twitter.com images, for which expandedUrl = "https://twitter.com/#!/username/status/1234/photo/1
  42727. // For those URLs, display_url is not a substring of expanded_url, so we don't do anything special to render the elided parts.
  42728. // For a pic.twitter.com URL, the only elided part will be the "https://", so this is fine.
  42729. var displayUrlSansEllipses = displayUrl.replace(/…/g, ""); // We have to disregard ellipses for matching
  42730. // Note: we currently only support eliding parts of the URL at the beginning or the end.
  42731. // Eventually we may want to elide parts of the URL in the *middle*. If so, this code will
  42732. // become more complicated. We will probably want to create a regexp out of display URL,
  42733. // replacing every ellipsis with a ".*".
  42734. if (expandedUrl.indexOf(displayUrlSansEllipses) != -1) {
  42735. var displayUrlIndex = expandedUrl.indexOf(displayUrlSansEllipses);
  42736. var v = {
  42737. displayUrlSansEllipses: displayUrlSansEllipses,
  42738. // Portion of expandedUrl that precedes the displayUrl substring
  42739. beforeDisplayUrl: expandedUrl.substr(0, displayUrlIndex),
  42740. // Portion of expandedUrl that comes after displayUrl
  42741. afterDisplayUrl: expandedUrl.substr(displayUrlIndex + displayUrlSansEllipses.length),
  42742. precedingEllipsis: displayUrl.match(/^…/) ? "…" : "",
  42743. followingEllipsis: displayUrl.match(/…$/) ? "…" : ""
  42744. };
  42745. for (var k in v) {
  42746. if (v.hasOwnProperty(k)) {
  42747. v[k] = twttr.txt.htmlEscape(v[k]);
  42748. }
  42749. }
  42750. // As an example: The user tweets "hi http://longdomainname.com/foo"
  42751. // This gets shortened to "hi http://t.co/xyzabc", with display_url = "…nname.com/foo"
  42752. // This will get rendered as:
  42753. // <span class='tco-ellipsis'> <!-- This stuff should get displayed but not copied -->
  42754. // …
  42755. // <!-- There's a chance the onCopy event handler might not fire. In case that happens,
  42756. // we include an &nbsp; here so that the … doesn't bump up against the URL and ruin it.
  42757. // The &nbsp; is inside the tco-ellipsis span so that when the onCopy handler *does*
  42758. // fire, it doesn't get copied. Otherwise the copied text would have two spaces in a row,
  42759. // e.g. "hi http://longdomainname.com/foo".
  42760. // <span style='font-size:0'>&nbsp;</span>
  42761. // </span>
  42762. // <span style='font-size:0'> <!-- This stuff should get copied but not displayed -->
  42763. // http://longdomai
  42764. // </span>
  42765. // <span class='js-display-url'> <!-- This stuff should get displayed *and* copied -->
  42766. // nname.com/foo
  42767. // </span>
  42768. // <span class='tco-ellipsis'> <!-- This stuff should get displayed but not copied -->
  42769. // <span style='font-size:0'>&nbsp;</span>
  42770. // …
  42771. // </span>
  42772. v['invisible'] = options.invisibleTagAttrs;
  42773. return stringSupplant("<span class='tco-ellipsis'>#{precedingEllipsis}<span #{invisible}>&nbsp;</span></span><span #{invisible}>#{beforeDisplayUrl}</span><span class='js-display-url'>#{displayUrlSansEllipses}</span><span #{invisible}>#{afterDisplayUrl}</span><span class='tco-ellipsis'><span #{invisible}>&nbsp;</span>#{followingEllipsis}</span>", v);
  42774. }
  42775. return displayUrl;
  42776. };
  42777. twttr.txt.autoLinkEntities = function(text, entities, options) {
  42778. options = clone(options || {});
  42779. options.hashtagClass = options.hashtagClass || DEFAULT_HASHTAG_CLASS;
  42780. options.hashtagUrlBase = options.hashtagUrlBase || "https://twitter.com/#!/search?q=%23";
  42781. options.cashtagClass = options.cashtagClass || DEFAULT_CASHTAG_CLASS;
  42782. options.cashtagUrlBase = options.cashtagUrlBase || "https://twitter.com/#!/search?q=%24";
  42783. options.listClass = options.listClass || DEFAULT_LIST_CLASS;
  42784. options.usernameClass = options.usernameClass || DEFAULT_USERNAME_CLASS;
  42785. options.usernameUrlBase = options.usernameUrlBase || "https://twitter.com/";
  42786. options.listUrlBase = options.listUrlBase || "https://twitter.com/";
  42787. options.htmlAttrs = twttr.txt.extractHtmlAttrsFromOptions(options);
  42788. options.invisibleTagAttrs = options.invisibleTagAttrs || "style='position:absolute;left:-9999px;'";
  42789. // remap url entities to hash
  42790. var urlEntities, i, len;
  42791. if(options.urlEntities) {
  42792. urlEntities = {};
  42793. for(i = 0, len = options.urlEntities.length; i < len; i++) {
  42794. urlEntities[options.urlEntities[i].url] = options.urlEntities[i];
  42795. }
  42796. options.urlEntities = urlEntities;
  42797. }
  42798. var result = "";
  42799. var beginIndex = 0;
  42800. // sort entities by start index
  42801. entities.sort(function(a,b){ return a.indices[0] - b.indices[0]; });
  42802. var nonEntity = options.htmlEscapeNonEntities ? twttr.txt.htmlEscape : function(text) {
  42803. return text;
  42804. };
  42805. for (var i = 0; i < entities.length; i++) {
  42806. var entity = entities[i];
  42807. result += nonEntity(text.substring(beginIndex, entity.indices[0]));
  42808. if (entity.url) {
  42809. result += twttr.txt.linkToUrl(entity, text, options);
  42810. } else if (entity.hashtag) {
  42811. result += twttr.txt.linkToHashtag(entity, text, options);
  42812. } else if (entity.screenName) {
  42813. result += twttr.txt.linkToMentionAndList(entity, text, options);
  42814. } else if (entity.cashtag) {
  42815. result += twttr.txt.linkToCashtag(entity, text, options);
  42816. }
  42817. beginIndex = entity.indices[1];
  42818. }
  42819. result += nonEntity(text.substring(beginIndex, text.length));
  42820. return result;
  42821. };
  42822. twttr.txt.autoLinkWithJSON = function(text, json, options) {
  42823. // map JSON entity to twitter-text entity
  42824. if (json.user_mentions) {
  42825. for (var i = 0; i < json.user_mentions.length; i++) {
  42826. // this is a @mention
  42827. json.user_mentions[i].screenName = json.user_mentions[i].screen_name;
  42828. }
  42829. }
  42830. if (json.hashtags) {
  42831. for (var i = 0; i < json.hashtags.length; i++) {
  42832. // this is a #hashtag
  42833. json.hashtags[i].hashtag = json.hashtags[i].text;
  42834. }
  42835. }
  42836. if (json.symbols) {
  42837. for (var i = 0; i < json.symbols.length; i++) {
  42838. // this is a $CASH tag
  42839. json.symbols[i].cashtag = json.symbols[i].text;
  42840. }
  42841. }
  42842. // concatenate all entities
  42843. var entities = [];
  42844. for (var key in json) {
  42845. entities = entities.concat(json[key]);
  42846. }
  42847. // modify indices to UTF-16
  42848. twttr.txt.modifyIndicesFromUnicodeToUTF16(text, entities);
  42849. return twttr.txt.autoLinkEntities(text, entities, options);
  42850. };
  42851. twttr.txt.extractHtmlAttrsFromOptions = function(options) {
  42852. var htmlAttrs = {};
  42853. for (var k in options) {
  42854. var v = options[k];
  42855. if (OPTIONS_NOT_ATTRIBUTES[k]) continue;
  42856. if (BOOLEAN_ATTRIBUTES[k]) {
  42857. v = v ? k : null;
  42858. }
  42859. if (v == null) continue;
  42860. htmlAttrs[k] = v;
  42861. }
  42862. return htmlAttrs;
  42863. };
  42864. twttr.txt.autoLink = function(text, options) {
  42865. var entities = twttr.txt.extractEntitiesWithIndices(text, {extractUrlsWithoutProtocol: false});
  42866. return twttr.txt.autoLinkEntities(text, entities, options);
  42867. };
  42868. twttr.txt.autoLinkUsernamesOrLists = function(text, options) {
  42869. var entities = twttr.txt.extractMentionsOrListsWithIndices(text);
  42870. return twttr.txt.autoLinkEntities(text, entities, options);
  42871. };
  42872. twttr.txt.autoLinkHashtags = function(text, options) {
  42873. var entities = twttr.txt.extractHashtagsWithIndices(text);
  42874. return twttr.txt.autoLinkEntities(text, entities, options);
  42875. };
  42876. twttr.txt.autoLinkCashtags = function(text, options) {
  42877. var entities = twttr.txt.extractCashtagsWithIndices(text);
  42878. return twttr.txt.autoLinkEntities(text, entities, options);
  42879. };
  42880. twttr.txt.autoLinkUrlsCustom = function(text, options) {
  42881. var entities = twttr.txt.extractUrlsWithIndices(text, {extractUrlsWithoutProtocol: false});
  42882. return twttr.txt.autoLinkEntities(text, entities, options);
  42883. };
  42884. twttr.txt.removeOverlappingEntities = function(entities) {
  42885. entities.sort(function(a,b){ return a.indices[0] - b.indices[0]; });
  42886. var prev = entities[0];
  42887. for (var i = 1; i < entities.length; i++) {
  42888. if (prev.indices[1] > entities[i].indices[0]) {
  42889. entities.splice(i, 1);
  42890. i--;
  42891. } else {
  42892. prev = entities[i];
  42893. }
  42894. }
  42895. };
  42896. twttr.txt.extractEntitiesWithIndices = function(text, options) {
  42897. var entities = twttr.txt.extractUrlsWithIndices(text, options)
  42898. .concat(twttr.txt.extractMentionsOrListsWithIndices(text))
  42899. .concat(twttr.txt.extractHashtagsWithIndices(text, {checkUrlOverlap: false}))
  42900. .concat(twttr.txt.extractCashtagsWithIndices(text));
  42901. if (entities.length == 0) {
  42902. return [];
  42903. }
  42904. twttr.txt.removeOverlappingEntities(entities);
  42905. return entities;
  42906. };
  42907. twttr.txt.extractMentions = function(text) {
  42908. var screenNamesOnly = [],
  42909. screenNamesWithIndices = twttr.txt.extractMentionsWithIndices(text);
  42910. for (var i = 0; i < screenNamesWithIndices.length; i++) {
  42911. var screenName = screenNamesWithIndices[i].screenName;
  42912. screenNamesOnly.push(screenName);
  42913. }
  42914. return screenNamesOnly;
  42915. };
  42916. twttr.txt.extractMentionsWithIndices = function(text) {
  42917. var mentions = [],
  42918. mentionOrList,
  42919. mentionsOrLists = twttr.txt.extractMentionsOrListsWithIndices(text);
  42920. for (var i = 0 ; i < mentionsOrLists.length; i++) {
  42921. mentionOrList = mentionsOrLists[i];
  42922. if (mentionOrList.listSlug == '') {
  42923. mentions.push({
  42924. screenName: mentionOrList.screenName,
  42925. indices: mentionOrList.indices
  42926. });
  42927. }
  42928. }
  42929. return mentions;
  42930. };
  42931. /**
  42932. * Extract list or user mentions.
  42933. * (Presence of listSlug indicates a list)
  42934. */
  42935. twttr.txt.extractMentionsOrListsWithIndices = function(text) {
  42936. if (!text || !text.match(twttr.txt.regexen.atSigns)) {
  42937. return [];
  42938. }
  42939. var possibleNames = [],
  42940. slashListname;
  42941. text.replace(twttr.txt.regexen.validMentionOrList, function(match, before, atSign, screenName, slashListname, offset, chunk) {
  42942. var after = chunk.slice(offset + match.length);
  42943. if (!after.match(twttr.txt.regexen.endMentionMatch)) {
  42944. slashListname = slashListname || '';
  42945. var startPosition = offset + before.length;
  42946. var endPosition = startPosition + screenName.length + slashListname.length + 1;
  42947. possibleNames.push({
  42948. screenName: screenName,
  42949. listSlug: slashListname,
  42950. indices: [startPosition, endPosition]
  42951. });
  42952. }
  42953. });
  42954. return possibleNames;
  42955. };
  42956. twttr.txt.extractReplies = function(text) {
  42957. if (!text) {
  42958. return null;
  42959. }
  42960. var possibleScreenName = text.match(twttr.txt.regexen.validReply);
  42961. if (!possibleScreenName ||
  42962. RegExp.rightContext.match(twttr.txt.regexen.endMentionMatch)) {
  42963. return null;
  42964. }
  42965. return possibleScreenName[1];
  42966. };
  42967. twttr.txt.extractUrls = function(text, options) {
  42968. var urlsOnly = [],
  42969. urlsWithIndices = twttr.txt.extractUrlsWithIndices(text, options);
  42970. for (var i = 0; i < urlsWithIndices.length; i++) {
  42971. urlsOnly.push(urlsWithIndices[i].url);
  42972. }
  42973. return urlsOnly;
  42974. };
  42975. twttr.txt.extractUrlsWithIndices = function(text, options) {
  42976. if (!options) {
  42977. options = {extractUrlsWithoutProtocol: true};
  42978. }
  42979. if (!text || (options.extractUrlsWithoutProtocol ? !text.match(/\./) : !text.match(/:/))) {
  42980. return [];
  42981. }
  42982. var urls = [];
  42983. while (twttr.txt.regexen.extractUrl.exec(text)) {
  42984. var before = RegExp.$2, url = RegExp.$3, protocol = RegExp.$4, domain = RegExp.$5, path = RegExp.$7;
  42985. var endPosition = twttr.txt.regexen.extractUrl.lastIndex,
  42986. startPosition = endPosition - url.length;
  42987. // if protocol is missing and domain contains non-ASCII characters,
  42988. // extract ASCII-only domains.
  42989. if (!protocol) {
  42990. if (!options.extractUrlsWithoutProtocol
  42991. || before.match(twttr.txt.regexen.invalidUrlWithoutProtocolPrecedingChars)) {
  42992. continue;
  42993. }
  42994. var lastUrl = null,
  42995. asciiEndPosition = 0;
  42996. domain.replace(twttr.txt.regexen.validAsciiDomain, function(asciiDomain) {
  42997. var asciiStartPosition = domain.indexOf(asciiDomain, asciiEndPosition);
  42998. asciiEndPosition = asciiStartPosition + asciiDomain.length;
  42999. lastUrl = {
  43000. url: asciiDomain,
  43001. indices: [startPosition + asciiStartPosition, startPosition + asciiEndPosition]
  43002. };
  43003. if (path
  43004. || asciiDomain.match(twttr.txt.regexen.validSpecialShortDomain)
  43005. || !asciiDomain.match(twttr.txt.regexen.invalidShortDomain)) {
  43006. urls.push(lastUrl);
  43007. }
  43008. });
  43009. // no ASCII-only domain found. Skip the entire URL.
  43010. if (lastUrl == null) {
  43011. continue;
  43012. }
  43013. // lastUrl only contains domain. Need to add path and query if they exist.
  43014. if (path) {
  43015. lastUrl.url = url.replace(domain, lastUrl.url);
  43016. lastUrl.indices[1] = endPosition;
  43017. }
  43018. } else {
  43019. // In the case of t.co URLs, don't allow additional path characters.
  43020. if (url.match(twttr.txt.regexen.validTcoUrl)) {
  43021. url = RegExp.lastMatch;
  43022. endPosition = startPosition + url.length;
  43023. }
  43024. urls.push({
  43025. url: url,
  43026. indices: [startPosition, endPosition]
  43027. });
  43028. }
  43029. }
  43030. return urls;
  43031. };
  43032. twttr.txt.extractHashtags = function(text) {
  43033. var hashtagsOnly = [],
  43034. hashtagsWithIndices = twttr.txt.extractHashtagsWithIndices(text);
  43035. for (var i = 0; i < hashtagsWithIndices.length; i++) {
  43036. hashtagsOnly.push(hashtagsWithIndices[i].hashtag);
  43037. }
  43038. return hashtagsOnly;
  43039. };
  43040. twttr.txt.extractHashtagsWithIndices = function(text, options) {
  43041. if (!options) {
  43042. options = {checkUrlOverlap: true};
  43043. }
  43044. if (!text || !text.match(twttr.txt.regexen.hashSigns)) {
  43045. return [];
  43046. }
  43047. var tags = [];
  43048. text.replace(twttr.txt.regexen.validHashtag, function(match, before, hash, hashText, offset, chunk) {
  43049. var after = chunk.slice(offset + match.length);
  43050. if (after.match(twttr.txt.regexen.endHashtagMatch))
  43051. return;
  43052. var startPosition = offset + before.length;
  43053. var endPosition = startPosition + hashText.length + 1;
  43054. tags.push({
  43055. hashtag: hashText,
  43056. indices: [startPosition, endPosition]
  43057. });
  43058. });
  43059. if (options.checkUrlOverlap) {
  43060. // also extract URL entities
  43061. var urls = twttr.txt.extractUrlsWithIndices(text);
  43062. if (urls.length > 0) {
  43063. var entities = tags.concat(urls);
  43064. // remove overlap
  43065. twttr.txt.removeOverlappingEntities(entities);
  43066. // only push back hashtags
  43067. tags = [];
  43068. for (var i = 0; i < entities.length; i++) {
  43069. if (entities[i].hashtag) {
  43070. tags.push(entities[i]);
  43071. }
  43072. }
  43073. }
  43074. }
  43075. return tags;
  43076. };
  43077. twttr.txt.extractCashtags = function(text) {
  43078. var cashtagsOnly = [],
  43079. cashtagsWithIndices = twttr.txt.extractCashtagsWithIndices(text);
  43080. for (var i = 0; i < cashtagsWithIndices.length; i++) {
  43081. cashtagsOnly.push(cashtagsWithIndices[i].cashtag);
  43082. }
  43083. return cashtagsOnly;
  43084. };
  43085. twttr.txt.extractCashtagsWithIndices = function(text) {
  43086. if (!text || text.indexOf("$") == -1) {
  43087. return [];
  43088. }
  43089. var tags = [];
  43090. text.replace(twttr.txt.regexen.validCashtag, function(match, before, dollar, cashtag, offset, chunk) {
  43091. var startPosition = offset + before.length;
  43092. var endPosition = startPosition + cashtag.length + 1;
  43093. tags.push({
  43094. cashtag: cashtag,
  43095. indices: [startPosition, endPosition]
  43096. });
  43097. });
  43098. return tags;
  43099. };
  43100. twttr.txt.modifyIndicesFromUnicodeToUTF16 = function(text, entities) {
  43101. twttr.txt.convertUnicodeIndices(text, entities, false);
  43102. };
  43103. twttr.txt.modifyIndicesFromUTF16ToUnicode = function(text, entities) {
  43104. twttr.txt.convertUnicodeIndices(text, entities, true);
  43105. };
  43106. twttr.txt.getUnicodeTextLength = function(text) {
  43107. return text.replace(twttr.txt.regexen.non_bmp_code_pairs, ' ').length;
  43108. };
  43109. twttr.txt.convertUnicodeIndices = function(text, entities, indicesInUTF16) {
  43110. if (entities.length == 0) {
  43111. return;
  43112. }
  43113. var charIndex = 0;
  43114. var codePointIndex = 0;
  43115. // sort entities by start index
  43116. entities.sort(function(a,b){ return a.indices[0] - b.indices[0]; });
  43117. var entityIndex = 0;
  43118. var entity = entities[0];
  43119. while (charIndex < text.length) {
  43120. if (entity.indices[0] == (indicesInUTF16 ? charIndex : codePointIndex)) {
  43121. var len = entity.indices[1] - entity.indices[0];
  43122. entity.indices[0] = indicesInUTF16 ? codePointIndex : charIndex;
  43123. entity.indices[1] = entity.indices[0] + len;
  43124. entityIndex++;
  43125. if (entityIndex == entities.length) {
  43126. // no more entity
  43127. break;
  43128. }
  43129. entity = entities[entityIndex];
  43130. }
  43131. var c = text.charCodeAt(charIndex);
  43132. if (0xD800 <= c && c <= 0xDBFF && charIndex < text.length - 1) {
  43133. // Found high surrogate char
  43134. c = text.charCodeAt(charIndex + 1);
  43135. if (0xDC00 <= c && c <= 0xDFFF) {
  43136. // Found surrogate pair
  43137. charIndex++;
  43138. }
  43139. }
  43140. codePointIndex++;
  43141. charIndex++;
  43142. }
  43143. };
  43144. // this essentially does text.split(/<|>/)
  43145. // except that won't work in IE, where empty strings are ommitted
  43146. // so "<>".split(/<|>/) => [] in IE, but is ["", "", ""] in all others
  43147. // but "<<".split("<") => ["", "", ""]
  43148. twttr.txt.splitTags = function(text) {
  43149. var firstSplits = text.split("<"),
  43150. secondSplits,
  43151. allSplits = [],
  43152. split;
  43153. for (var i = 0; i < firstSplits.length; i += 1) {
  43154. split = firstSplits[i];
  43155. if (!split) {
  43156. allSplits.push("");
  43157. } else {
  43158. secondSplits = split.split(">");
  43159. for (var j = 0; j < secondSplits.length; j += 1) {
  43160. allSplits.push(secondSplits[j]);
  43161. }
  43162. }
  43163. }
  43164. return allSplits;
  43165. };
  43166. twttr.txt.hitHighlight = function(text, hits, options) {
  43167. var defaultHighlightTag = "em";
  43168. hits = hits || [];
  43169. options = options || {};
  43170. if (hits.length === 0) {
  43171. return text;
  43172. }
  43173. var tagName = options.tag || defaultHighlightTag,
  43174. tags = ["<" + tagName + ">", "</" + tagName + ">"],
  43175. chunks = twttr.txt.splitTags(text),
  43176. i,
  43177. j,
  43178. result = "",
  43179. chunkIndex = 0,
  43180. chunk = chunks[0],
  43181. prevChunksLen = 0,
  43182. chunkCursor = 0,
  43183. startInChunk = false,
  43184. chunkChars = chunk,
  43185. flatHits = [],
  43186. index,
  43187. hit,
  43188. tag,
  43189. placed,
  43190. hitSpot;
  43191. for (i = 0; i < hits.length; i += 1) {
  43192. for (j = 0; j < hits[i].length; j += 1) {
  43193. flatHits.push(hits[i][j]);
  43194. }
  43195. }
  43196. for (index = 0; index < flatHits.length; index += 1) {
  43197. hit = flatHits[index];
  43198. tag = tags[index % 2];
  43199. placed = false;
  43200. while (chunk != null && hit >= prevChunksLen + chunk.length) {
  43201. result += chunkChars.slice(chunkCursor);
  43202. if (startInChunk && hit === prevChunksLen + chunkChars.length) {
  43203. result += tag;
  43204. placed = true;
  43205. }
  43206. if (chunks[chunkIndex + 1]) {
  43207. result += "<" + chunks[chunkIndex + 1] + ">";
  43208. }
  43209. prevChunksLen += chunkChars.length;
  43210. chunkCursor = 0;
  43211. chunkIndex += 2;
  43212. chunk = chunks[chunkIndex];
  43213. chunkChars = chunk;
  43214. startInChunk = false;
  43215. }
  43216. if (!placed && chunk != null) {
  43217. hitSpot = hit - prevChunksLen;
  43218. result += chunkChars.slice(chunkCursor, hitSpot) + tag;
  43219. chunkCursor = hitSpot;
  43220. if (index % 2 === 0) {
  43221. startInChunk = true;
  43222. } else {
  43223. startInChunk = false;
  43224. }
  43225. } else if(!placed) {
  43226. placed = true;
  43227. result += tag;
  43228. }
  43229. }
  43230. if (chunk != null) {
  43231. if (chunkCursor < chunkChars.length) {
  43232. result += chunkChars.slice(chunkCursor);
  43233. }
  43234. for (index = chunkIndex + 1; index < chunks.length; index += 1) {
  43235. result += (index % 2 === 0 ? chunks[index] : "<" + chunks[index] + ">");
  43236. }
  43237. }
  43238. return result;
  43239. };
  43240. var MAX_LENGTH = 140;
  43241. // Returns the length of Tweet text with consideration to t.co URL replacement
  43242. // and chars outside the basic multilingual plane that use 2 UTF16 code points
  43243. twttr.txt.getTweetLength = function(text, options) {
  43244. if (!options) {
  43245. options = {
  43246. // These come from https://api.twitter.com/1.1/help/configuration.json
  43247. // described by https://dev.twitter.com/rest/reference/get/help/configuration
  43248. short_url_length: 23,
  43249. short_url_length_https: 23
  43250. };
  43251. }
  43252. var textLength = twttr.txt.getUnicodeTextLength(text),
  43253. urlsWithIndices = twttr.txt.extractUrlsWithIndices(text);
  43254. twttr.txt.modifyIndicesFromUTF16ToUnicode(text, urlsWithIndices);
  43255. for (var i = 0; i < urlsWithIndices.length; i++) {
  43256. // Subtract the length of the original URL
  43257. textLength += urlsWithIndices[i].indices[0] - urlsWithIndices[i].indices[1];
  43258. // Add 23 characters for URL starting with https://
  43259. // http:// URLs still use https://t.co so they are 23 characters as well
  43260. if (urlsWithIndices[i].url.toLowerCase().match(twttr.txt.regexen.urlHasHttps)) {
  43261. textLength += options.short_url_length_https;
  43262. } else {
  43263. textLength += options.short_url_length;
  43264. }
  43265. }
  43266. return textLength;
  43267. };
  43268. // Check the text for any reason that it may not be valid as a Tweet. This is meant as a pre-validation
  43269. // before posting to api.twitter.com. There are several server-side reasons for Tweets to fail but this pre-validation
  43270. // will allow quicker feedback.
  43271. //
  43272. // Returns false if this text is valid. Otherwise one of the following strings will be returned:
  43273. //
  43274. // "too_long": if the text is too long
  43275. // "empty": if the text is nil or empty
  43276. // "invalid_characters": if the text contains non-Unicode or any of the disallowed Unicode characters
  43277. twttr.txt.isInvalidTweet = function(text) {
  43278. if (!text) {
  43279. return "empty";
  43280. }
  43281. // Determine max length independent of URL length
  43282. if (twttr.txt.getTweetLength(text) > MAX_LENGTH) {
  43283. return "too_long";
  43284. }
  43285. if (twttr.txt.hasInvalidCharacters(text)) {
  43286. return "invalid_characters";
  43287. }
  43288. return false;
  43289. };
  43290. twttr.txt.hasInvalidCharacters = function(text) {
  43291. return twttr.txt.regexen.invalid_chars.test(text);
  43292. };
  43293. twttr.txt.isValidTweetText = function(text) {
  43294. return !twttr.txt.isInvalidTweet(text);
  43295. };
  43296. twttr.txt.isValidUsername = function(username) {
  43297. if (!username) {
  43298. return false;
  43299. }
  43300. var extracted = twttr.txt.extractMentions(username);
  43301. // Should extract the username minus the @ sign, hence the .slice(1)
  43302. return extracted.length === 1 && extracted[0] === username.slice(1);
  43303. };
  43304. var VALID_LIST_RE = regexSupplant(/^#{validMentionOrList}$/);
  43305. twttr.txt.isValidList = function(usernameList) {
  43306. var match = usernameList.match(VALID_LIST_RE);
  43307. // Must have matched and had nothing before or after
  43308. return !!(match && match[1] == "" && match[4]);
  43309. };
  43310. twttr.txt.isValidHashtag = function(hashtag) {
  43311. if (!hashtag) {
  43312. return false;
  43313. }
  43314. var extracted = twttr.txt.extractHashtags(hashtag);
  43315. // Should extract the hashtag minus the # sign, hence the .slice(1)
  43316. return extracted.length === 1 && extracted[0] === hashtag.slice(1);
  43317. };
  43318. twttr.txt.isValidUrl = function(url, unicodeDomains, requireProtocol) {
  43319. if (unicodeDomains == null) {
  43320. unicodeDomains = true;
  43321. }
  43322. if (requireProtocol == null) {
  43323. requireProtocol = true;
  43324. }
  43325. if (!url) {
  43326. return false;
  43327. }
  43328. var urlParts = url.match(twttr.txt.regexen.validateUrlUnencoded);
  43329. if (!urlParts || urlParts[0] !== url) {
  43330. return false;
  43331. }
  43332. var scheme = urlParts[1],
  43333. authority = urlParts[2],
  43334. path = urlParts[3],
  43335. query = urlParts[4],
  43336. fragment = urlParts[5];
  43337. if (!(
  43338. (!requireProtocol || (isValidMatch(scheme, twttr.txt.regexen.validateUrlScheme) && scheme.match(/^https?$/i))) &&
  43339. isValidMatch(path, twttr.txt.regexen.validateUrlPath) &&
  43340. isValidMatch(query, twttr.txt.regexen.validateUrlQuery, true) &&
  43341. isValidMatch(fragment, twttr.txt.regexen.validateUrlFragment, true)
  43342. )) {
  43343. return false;
  43344. }
  43345. return (unicodeDomains && isValidMatch(authority, twttr.txt.regexen.validateUrlUnicodeAuthority)) ||
  43346. (!unicodeDomains && isValidMatch(authority, twttr.txt.regexen.validateUrlAuthority));
  43347. };
  43348. function isValidMatch(string, regex, optional) {
  43349. if (!optional) {
  43350. // RegExp["$&"] is the text of the last match
  43351. // blank strings are ok, but are falsy, so we check stringiness instead of truthiness
  43352. return ((typeof string === "string") && string.match(regex) && RegExp["$&"] === string);
  43353. }
  43354. // RegExp["$&"] is the text of the last match
  43355. return (!string || (string.match(regex) && RegExp["$&"] === string));
  43356. }
  43357. if (typeof module != 'undefined' && module.exports) {
  43358. module.exports = twttr.txt;
  43359. }
  43360. if (true) {
  43361. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (twttr.txt),
  43362. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  43363. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  43364. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  43365. }
  43366. if (typeof window != 'undefined') {
  43367. if (window.twttr) {
  43368. for (var prop in twttr) {
  43369. window.twttr[prop] = twttr[prop];
  43370. }
  43371. } else {
  43372. window.twttr = twttr;
  43373. }
  43374. }
  43375. })();
  43376. /***/ })
  43377. /******/ ]);