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.

7511 lines
215 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. /******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ "./resources/js/components/buckets.riot":
  4. /*!**********************************************!*\
  5. !*** ./resources/js/components/buckets.riot ***!
  6. \**********************************************/
  7. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  8. "use strict";
  9. __webpack_require__.r(__webpack_exports__);
  10. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  11. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  12. /* harmony export */ });
  13. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  14. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);
  15. /* harmony import */ var lodash_remove__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.remove */ "./node_modules/lodash.remove/index.js");
  16. /* harmony import */ var lodash_remove__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_remove__WEBPACK_IMPORTED_MODULE_1__);
  17. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  18. 'css': null,
  19. 'exports': {
  20. state: {
  21. buckets: []
  22. },
  23. onBeforeMount() {
  24. this.fetch()
  25. },
  26. handleClick() {
  27. },
  28. handleDelete(event, bucket) {
  29. event.preventDefault()
  30. axios__WEBPACK_IMPORTED_MODULE_0___default()["delete"]('/api/bucket/' + bucket._id)
  31. .then((response) => {
  32. // removing from buckets
  33. lodash_remove__WEBPACK_IMPORTED_MODULE_1___default()(this.state.buckets, function(b) {
  34. return b._id === bucket._id
  35. })
  36. this.update()
  37. })
  38. },
  39. /**
  40. * getting all buckets
  41. *
  42. *
  43. */
  44. fetch() {
  45. axios__WEBPACK_IMPORTED_MODULE_0___default().get('/api/bucket/', {
  46. params: {
  47. visiblity: this.props.visiblity
  48. }
  49. }).then((response) => {
  50. this.state.buckets = response.data.data
  51. this.update()
  52. })
  53. }
  54. },
  55. 'template': function(
  56. template,
  57. expressionTypes,
  58. bindingTypes,
  59. getComponent
  60. ) {
  61. return template(
  62. '<div class="buckets"><div class="grid"><div expr14="expr14" class="col-12 col-md-4 col-xlg-3"></div></div><div class="grid"><div class="col-12"><div class="buckets__more"><button expr19="expr19" type="button" class="button">\n More\n <svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-arrow-down"/></svg></button></div></div></div></div>',
  63. [
  64. {
  65. 'type': bindingTypes.EACH,
  66. 'getKey': null,
  67. 'condition': null,
  68. 'template': template(
  69. '<article class="panel buckets__item"><div class="bar"><div class="bar__end w-100"><button expr15="expr15" class="button button--transparent"><svg class="icon fill-text-contrast" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-delete"/></svg></button></div></div><div class="panel__body"><a expr16="expr16"><h3 expr17="expr17" class="buckets__title"> </h3><div class="content"><p expr18="expr18"> </p></div></a></div></article>',
  70. [
  71. {
  72. 'redundantAttribute': 'expr15',
  73. 'selector': '[expr15]',
  74. 'expressions': [
  75. {
  76. 'type': expressionTypes.EVENT,
  77. 'name': 'onclick',
  78. 'evaluate': function(
  79. _scope
  80. ) {
  81. return (event) => { _scope.handleDelete(event, _scope.bucket) };
  82. }
  83. }
  84. ]
  85. },
  86. {
  87. 'redundantAttribute': 'expr16',
  88. 'selector': '[expr16]',
  89. 'expressions': [
  90. {
  91. 'type': expressionTypes.ATTRIBUTE,
  92. 'name': 'href',
  93. 'evaluate': function(
  94. _scope
  95. ) {
  96. return [
  97. '/bucket/',
  98. _scope.bucket._id
  99. ].join(
  100. ''
  101. );
  102. }
  103. }
  104. ]
  105. },
  106. {
  107. 'redundantAttribute': 'expr17',
  108. 'selector': '[expr17]',
  109. 'expressions': [
  110. {
  111. 'type': expressionTypes.TEXT,
  112. 'childNodeIndex': 0,
  113. 'evaluate': function(
  114. _scope
  115. ) {
  116. return [
  117. _scope.bucket.title
  118. ].join(
  119. ''
  120. );
  121. }
  122. }
  123. ]
  124. },
  125. {
  126. 'redundantAttribute': 'expr18',
  127. 'selector': '[expr18]',
  128. 'expressions': [
  129. {
  130. 'type': expressionTypes.TEXT,
  131. 'childNodeIndex': 0,
  132. 'evaluate': function(
  133. _scope
  134. ) {
  135. return [
  136. _scope.bucket.description
  137. ].join(
  138. ''
  139. );
  140. }
  141. }
  142. ]
  143. }
  144. ]
  145. ),
  146. 'redundantAttribute': 'expr14',
  147. 'selector': '[expr14]',
  148. 'itemName': 'bucket',
  149. 'indexName': null,
  150. 'evaluate': function(
  151. _scope
  152. ) {
  153. return _scope.state.buckets;
  154. }
  155. },
  156. {
  157. 'redundantAttribute': 'expr19',
  158. 'selector': '[expr19]',
  159. 'expressions': [
  160. {
  161. 'type': expressionTypes.EVENT,
  162. 'name': 'onclick',
  163. 'evaluate': function(
  164. _scope
  165. ) {
  166. return _scope.handleClick;
  167. }
  168. }
  169. ]
  170. }
  171. ]
  172. );
  173. },
  174. 'name': 'app-buckets'
  175. });
  176. /***/ }),
  177. /***/ "./node_modules/axios/index.js":
  178. /*!*************************************!*\
  179. !*** ./node_modules/axios/index.js ***!
  180. \*************************************/
  181. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  182. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  183. /***/ }),
  184. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  185. /*!************************************************!*\
  186. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  187. \************************************************/
  188. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  189. "use strict";
  190. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  191. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  192. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  193. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  194. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  195. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  196. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  197. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  198. module.exports = function xhrAdapter(config) {
  199. return new Promise(function dispatchXhrRequest(resolve, reject) {
  200. var requestData = config.data;
  201. var requestHeaders = config.headers;
  202. var responseType = config.responseType;
  203. if (utils.isFormData(requestData)) {
  204. delete requestHeaders['Content-Type']; // Let the browser set it
  205. }
  206. var request = new XMLHttpRequest();
  207. // HTTP basic authentication
  208. if (config.auth) {
  209. var username = config.auth.username || '';
  210. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  211. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  212. }
  213. var fullPath = buildFullPath(config.baseURL, config.url);
  214. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  215. // Set the request timeout in MS
  216. request.timeout = config.timeout;
  217. function onloadend() {
  218. if (!request) {
  219. return;
  220. }
  221. // Prepare the response
  222. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  223. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  224. request.responseText : request.response;
  225. var response = {
  226. data: responseData,
  227. status: request.status,
  228. statusText: request.statusText,
  229. headers: responseHeaders,
  230. config: config,
  231. request: request
  232. };
  233. settle(resolve, reject, response);
  234. // Clean up request
  235. request = null;
  236. }
  237. if ('onloadend' in request) {
  238. // Use onloadend if available
  239. request.onloadend = onloadend;
  240. } else {
  241. // Listen for ready state to emulate onloadend
  242. request.onreadystatechange = function handleLoad() {
  243. if (!request || request.readyState !== 4) {
  244. return;
  245. }
  246. // The request errored out and we didn't get a response, this will be
  247. // handled by onerror instead
  248. // With one exception: request that using file: protocol, most browsers
  249. // will return status as 0 even though it's a successful request
  250. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  251. return;
  252. }
  253. // readystate handler is calling before onerror or ontimeout handlers,
  254. // so we should call onloadend on the next 'tick'
  255. setTimeout(onloadend);
  256. };
  257. }
  258. // Handle browser request cancellation (as opposed to a manual cancellation)
  259. request.onabort = function handleAbort() {
  260. if (!request) {
  261. return;
  262. }
  263. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  264. // Clean up request
  265. request = null;
  266. };
  267. // Handle low level network errors
  268. request.onerror = function handleError() {
  269. // Real errors are hidden from us by the browser
  270. // onerror should only fire if it's a network error
  271. reject(createError('Network Error', config, null, request));
  272. // Clean up request
  273. request = null;
  274. };
  275. // Handle timeout
  276. request.ontimeout = function handleTimeout() {
  277. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  278. if (config.timeoutErrorMessage) {
  279. timeoutErrorMessage = config.timeoutErrorMessage;
  280. }
  281. reject(createError(
  282. timeoutErrorMessage,
  283. config,
  284. config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
  285. request));
  286. // Clean up request
  287. request = null;
  288. };
  289. // Add xsrf header
  290. // This is only done if running in a standard browser environment.
  291. // Specifically not if we're in a web worker, or react-native.
  292. if (utils.isStandardBrowserEnv()) {
  293. // Add xsrf header
  294. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  295. cookies.read(config.xsrfCookieName) :
  296. undefined;
  297. if (xsrfValue) {
  298. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  299. }
  300. }
  301. // Add headers to the request
  302. if ('setRequestHeader' in request) {
  303. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  304. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  305. // Remove Content-Type if data is undefined
  306. delete requestHeaders[key];
  307. } else {
  308. // Otherwise add header to the request
  309. request.setRequestHeader(key, val);
  310. }
  311. });
  312. }
  313. // Add withCredentials to request if needed
  314. if (!utils.isUndefined(config.withCredentials)) {
  315. request.withCredentials = !!config.withCredentials;
  316. }
  317. // Add responseType to request if needed
  318. if (responseType && responseType !== 'json') {
  319. request.responseType = config.responseType;
  320. }
  321. // Handle progress if needed
  322. if (typeof config.onDownloadProgress === 'function') {
  323. request.addEventListener('progress', config.onDownloadProgress);
  324. }
  325. // Not all browsers support upload events
  326. if (typeof config.onUploadProgress === 'function' && request.upload) {
  327. request.upload.addEventListener('progress', config.onUploadProgress);
  328. }
  329. if (config.cancelToken) {
  330. // Handle cancellation
  331. config.cancelToken.promise.then(function onCanceled(cancel) {
  332. if (!request) {
  333. return;
  334. }
  335. request.abort();
  336. reject(cancel);
  337. // Clean up request
  338. request = null;
  339. });
  340. }
  341. if (!requestData) {
  342. requestData = null;
  343. }
  344. // Send the request
  345. request.send(requestData);
  346. });
  347. };
  348. /***/ }),
  349. /***/ "./node_modules/axios/lib/axios.js":
  350. /*!*****************************************!*\
  351. !*** ./node_modules/axios/lib/axios.js ***!
  352. \*****************************************/
  353. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  354. "use strict";
  355. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  356. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  357. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  358. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  359. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  360. /**
  361. * Create an instance of Axios
  362. *
  363. * @param {Object} defaultConfig The default config for the instance
  364. * @return {Axios} A new instance of Axios
  365. */
  366. function createInstance(defaultConfig) {
  367. var context = new Axios(defaultConfig);
  368. var instance = bind(Axios.prototype.request, context);
  369. // Copy axios.prototype to instance
  370. utils.extend(instance, Axios.prototype, context);
  371. // Copy context to instance
  372. utils.extend(instance, context);
  373. return instance;
  374. }
  375. // Create the default instance to be exported
  376. var axios = createInstance(defaults);
  377. // Expose Axios class to allow class inheritance
  378. axios.Axios = Axios;
  379. // Factory for creating new instances
  380. axios.create = function create(instanceConfig) {
  381. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  382. };
  383. // Expose Cancel & CancelToken
  384. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  385. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  386. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  387. // Expose all/spread
  388. axios.all = function all(promises) {
  389. return Promise.all(promises);
  390. };
  391. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  392. // Expose isAxiosError
  393. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js");
  394. module.exports = axios;
  395. // Allow use of default import syntax in TypeScript
  396. module.exports["default"] = axios;
  397. /***/ }),
  398. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  399. /*!*************************************************!*\
  400. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  401. \*************************************************/
  402. /***/ ((module) => {
  403. "use strict";
  404. /**
  405. * A `Cancel` is an object that is thrown when an operation is canceled.
  406. *
  407. * @class
  408. * @param {string=} message The message.
  409. */
  410. function Cancel(message) {
  411. this.message = message;
  412. }
  413. Cancel.prototype.toString = function toString() {
  414. return 'Cancel' + (this.message ? ': ' + this.message : '');
  415. };
  416. Cancel.prototype.__CANCEL__ = true;
  417. module.exports = Cancel;
  418. /***/ }),
  419. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  420. /*!******************************************************!*\
  421. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  422. \******************************************************/
  423. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  424. "use strict";
  425. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  426. /**
  427. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  428. *
  429. * @class
  430. * @param {Function} executor The executor function.
  431. */
  432. function CancelToken(executor) {
  433. if (typeof executor !== 'function') {
  434. throw new TypeError('executor must be a function.');
  435. }
  436. var resolvePromise;
  437. this.promise = new Promise(function promiseExecutor(resolve) {
  438. resolvePromise = resolve;
  439. });
  440. var token = this;
  441. executor(function cancel(message) {
  442. if (token.reason) {
  443. // Cancellation has already been requested
  444. return;
  445. }
  446. token.reason = new Cancel(message);
  447. resolvePromise(token.reason);
  448. });
  449. }
  450. /**
  451. * Throws a `Cancel` if cancellation has been requested.
  452. */
  453. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  454. if (this.reason) {
  455. throw this.reason;
  456. }
  457. };
  458. /**
  459. * Returns an object that contains a new `CancelToken` and a function that, when called,
  460. * cancels the `CancelToken`.
  461. */
  462. CancelToken.source = function source() {
  463. var cancel;
  464. var token = new CancelToken(function executor(c) {
  465. cancel = c;
  466. });
  467. return {
  468. token: token,
  469. cancel: cancel
  470. };
  471. };
  472. module.exports = CancelToken;
  473. /***/ }),
  474. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  475. /*!***************************************************!*\
  476. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  477. \***************************************************/
  478. /***/ ((module) => {
  479. "use strict";
  480. module.exports = function isCancel(value) {
  481. return !!(value && value.__CANCEL__);
  482. };
  483. /***/ }),
  484. /***/ "./node_modules/axios/lib/core/Axios.js":
  485. /*!**********************************************!*\
  486. !*** ./node_modules/axios/lib/core/Axios.js ***!
  487. \**********************************************/
  488. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  489. "use strict";
  490. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  491. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  492. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  493. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  494. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  495. var validator = __webpack_require__(/*! ../helpers/validator */ "./node_modules/axios/lib/helpers/validator.js");
  496. var validators = validator.validators;
  497. /**
  498. * Create a new instance of Axios
  499. *
  500. * @param {Object} instanceConfig The default config for the instance
  501. */
  502. function Axios(instanceConfig) {
  503. this.defaults = instanceConfig;
  504. this.interceptors = {
  505. request: new InterceptorManager(),
  506. response: new InterceptorManager()
  507. };
  508. }
  509. /**
  510. * Dispatch a request
  511. *
  512. * @param {Object} config The config specific for this request (merged with this.defaults)
  513. */
  514. Axios.prototype.request = function request(config) {
  515. /*eslint no-param-reassign:0*/
  516. // Allow for axios('example/url'[, config]) a la fetch API
  517. if (typeof config === 'string') {
  518. config = arguments[1] || {};
  519. config.url = arguments[0];
  520. } else {
  521. config = config || {};
  522. }
  523. config = mergeConfig(this.defaults, config);
  524. // Set config.method
  525. if (config.method) {
  526. config.method = config.method.toLowerCase();
  527. } else if (this.defaults.method) {
  528. config.method = this.defaults.method.toLowerCase();
  529. } else {
  530. config.method = 'get';
  531. }
  532. var transitional = config.transitional;
  533. if (transitional !== undefined) {
  534. validator.assertOptions(transitional, {
  535. silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
  536. forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
  537. clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0')
  538. }, false);
  539. }
  540. // filter out skipped interceptors
  541. var requestInterceptorChain = [];
  542. var synchronousRequestInterceptors = true;
  543. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  544. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  545. return;
  546. }
  547. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  548. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  549. });
  550. var responseInterceptorChain = [];
  551. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  552. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  553. });
  554. var promise;
  555. if (!synchronousRequestInterceptors) {
  556. var chain = [dispatchRequest, undefined];
  557. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  558. chain = chain.concat(responseInterceptorChain);
  559. promise = Promise.resolve(config);
  560. while (chain.length) {
  561. promise = promise.then(chain.shift(), chain.shift());
  562. }
  563. return promise;
  564. }
  565. var newConfig = config;
  566. while (requestInterceptorChain.length) {
  567. var onFulfilled = requestInterceptorChain.shift();
  568. var onRejected = requestInterceptorChain.shift();
  569. try {
  570. newConfig = onFulfilled(newConfig);
  571. } catch (error) {
  572. onRejected(error);
  573. break;
  574. }
  575. }
  576. try {
  577. promise = dispatchRequest(newConfig);
  578. } catch (error) {
  579. return Promise.reject(error);
  580. }
  581. while (responseInterceptorChain.length) {
  582. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  583. }
  584. return promise;
  585. };
  586. Axios.prototype.getUri = function getUri(config) {
  587. config = mergeConfig(this.defaults, config);
  588. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  589. };
  590. // Provide aliases for supported request methods
  591. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  592. /*eslint func-names:0*/
  593. Axios.prototype[method] = function(url, config) {
  594. return this.request(mergeConfig(config || {}, {
  595. method: method,
  596. url: url,
  597. data: (config || {}).data
  598. }));
  599. };
  600. });
  601. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  602. /*eslint func-names:0*/
  603. Axios.prototype[method] = function(url, data, config) {
  604. return this.request(mergeConfig(config || {}, {
  605. method: method,
  606. url: url,
  607. data: data
  608. }));
  609. };
  610. });
  611. module.exports = Axios;
  612. /***/ }),
  613. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  614. /*!***********************************************************!*\
  615. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  616. \***********************************************************/
  617. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  618. "use strict";
  619. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  620. function InterceptorManager() {
  621. this.handlers = [];
  622. }
  623. /**
  624. * Add a new interceptor to the stack
  625. *
  626. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  627. * @param {Function} rejected The function to handle `reject` for a `Promise`
  628. *
  629. * @return {Number} An ID used to remove interceptor later
  630. */
  631. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  632. this.handlers.push({
  633. fulfilled: fulfilled,
  634. rejected: rejected,
  635. synchronous: options ? options.synchronous : false,
  636. runWhen: options ? options.runWhen : null
  637. });
  638. return this.handlers.length - 1;
  639. };
  640. /**
  641. * Remove an interceptor from the stack
  642. *
  643. * @param {Number} id The ID that was returned by `use`
  644. */
  645. InterceptorManager.prototype.eject = function eject(id) {
  646. if (this.handlers[id]) {
  647. this.handlers[id] = null;
  648. }
  649. };
  650. /**
  651. * Iterate over all the registered interceptors
  652. *
  653. * This method is particularly useful for skipping over any
  654. * interceptors that may have become `null` calling `eject`.
  655. *
  656. * @param {Function} fn The function to call for each interceptor
  657. */
  658. InterceptorManager.prototype.forEach = function forEach(fn) {
  659. utils.forEach(this.handlers, function forEachHandler(h) {
  660. if (h !== null) {
  661. fn(h);
  662. }
  663. });
  664. };
  665. module.exports = InterceptorManager;
  666. /***/ }),
  667. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  668. /*!******************************************************!*\
  669. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  670. \******************************************************/
  671. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  672. "use strict";
  673. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  674. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  675. /**
  676. * Creates a new URL by combining the baseURL with the requestedURL,
  677. * only when the requestedURL is not already an absolute URL.
  678. * If the requestURL is absolute, this function returns the requestedURL untouched.
  679. *
  680. * @param {string} baseURL The base URL
  681. * @param {string} requestedURL Absolute or relative URL to combine
  682. * @returns {string} The combined full path
  683. */
  684. module.exports = function buildFullPath(baseURL, requestedURL) {
  685. if (baseURL && !isAbsoluteURL(requestedURL)) {
  686. return combineURLs(baseURL, requestedURL);
  687. }
  688. return requestedURL;
  689. };
  690. /***/ }),
  691. /***/ "./node_modules/axios/lib/core/createError.js":
  692. /*!****************************************************!*\
  693. !*** ./node_modules/axios/lib/core/createError.js ***!
  694. \****************************************************/
  695. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  696. "use strict";
  697. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  698. /**
  699. * Create an Error with the specified message, config, error code, request and response.
  700. *
  701. * @param {string} message The error message.
  702. * @param {Object} config The config.
  703. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  704. * @param {Object} [request] The request.
  705. * @param {Object} [response] The response.
  706. * @returns {Error} The created error.
  707. */
  708. module.exports = function createError(message, config, code, request, response) {
  709. var error = new Error(message);
  710. return enhanceError(error, config, code, request, response);
  711. };
  712. /***/ }),
  713. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  714. /*!********************************************************!*\
  715. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  716. \********************************************************/
  717. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  718. "use strict";
  719. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  720. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  721. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  722. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  723. /**
  724. * Throws a `Cancel` if cancellation has been requested.
  725. */
  726. function throwIfCancellationRequested(config) {
  727. if (config.cancelToken) {
  728. config.cancelToken.throwIfRequested();
  729. }
  730. }
  731. /**
  732. * Dispatch a request to the server using the configured adapter.
  733. *
  734. * @param {object} config The config that is to be used for the request
  735. * @returns {Promise} The Promise to be fulfilled
  736. */
  737. module.exports = function dispatchRequest(config) {
  738. throwIfCancellationRequested(config);
  739. // Ensure headers exist
  740. config.headers = config.headers || {};
  741. // Transform request data
  742. config.data = transformData.call(
  743. config,
  744. config.data,
  745. config.headers,
  746. config.transformRequest
  747. );
  748. // Flatten headers
  749. config.headers = utils.merge(
  750. config.headers.common || {},
  751. config.headers[config.method] || {},
  752. config.headers
  753. );
  754. utils.forEach(
  755. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  756. function cleanHeaderConfig(method) {
  757. delete config.headers[method];
  758. }
  759. );
  760. var adapter = config.adapter || defaults.adapter;
  761. return adapter(config).then(function onAdapterResolution(response) {
  762. throwIfCancellationRequested(config);
  763. // Transform response data
  764. response.data = transformData.call(
  765. config,
  766. response.data,
  767. response.headers,
  768. config.transformResponse
  769. );
  770. return response;
  771. }, function onAdapterRejection(reason) {
  772. if (!isCancel(reason)) {
  773. throwIfCancellationRequested(config);
  774. // Transform response data
  775. if (reason && reason.response) {
  776. reason.response.data = transformData.call(
  777. config,
  778. reason.response.data,
  779. reason.response.headers,
  780. config.transformResponse
  781. );
  782. }
  783. }
  784. return Promise.reject(reason);
  785. });
  786. };
  787. /***/ }),
  788. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  789. /*!*****************************************************!*\
  790. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  791. \*****************************************************/
  792. /***/ ((module) => {
  793. "use strict";
  794. /**
  795. * Update an Error with the specified config, error code, and response.
  796. *
  797. * @param {Error} error The error to update.
  798. * @param {Object} config The config.
  799. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  800. * @param {Object} [request] The request.
  801. * @param {Object} [response] The response.
  802. * @returns {Error} The error.
  803. */
  804. module.exports = function enhanceError(error, config, code, request, response) {
  805. error.config = config;
  806. if (code) {
  807. error.code = code;
  808. }
  809. error.request = request;
  810. error.response = response;
  811. error.isAxiosError = true;
  812. error.toJSON = function toJSON() {
  813. return {
  814. // Standard
  815. message: this.message,
  816. name: this.name,
  817. // Microsoft
  818. description: this.description,
  819. number: this.number,
  820. // Mozilla
  821. fileName: this.fileName,
  822. lineNumber: this.lineNumber,
  823. columnNumber: this.columnNumber,
  824. stack: this.stack,
  825. // Axios
  826. config: this.config,
  827. code: this.code
  828. };
  829. };
  830. return error;
  831. };
  832. /***/ }),
  833. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  834. /*!****************************************************!*\
  835. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  836. \****************************************************/
  837. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  838. "use strict";
  839. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  840. /**
  841. * Config-specific merge-function which creates a new config-object
  842. * by merging two configuration objects together.
  843. *
  844. * @param {Object} config1
  845. * @param {Object} config2
  846. * @returns {Object} New object resulting from merging config2 to config1
  847. */
  848. module.exports = function mergeConfig(config1, config2) {
  849. // eslint-disable-next-line no-param-reassign
  850. config2 = config2 || {};
  851. var config = {};
  852. var valueFromConfig2Keys = ['url', 'method', 'data'];
  853. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  854. var defaultToConfig2Keys = [
  855. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  856. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  857. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  858. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  859. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  860. ];
  861. var directMergeKeys = ['validateStatus'];
  862. function getMergedValue(target, source) {
  863. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  864. return utils.merge(target, source);
  865. } else if (utils.isPlainObject(source)) {
  866. return utils.merge({}, source);
  867. } else if (utils.isArray(source)) {
  868. return source.slice();
  869. }
  870. return source;
  871. }
  872. function mergeDeepProperties(prop) {
  873. if (!utils.isUndefined(config2[prop])) {
  874. config[prop] = getMergedValue(config1[prop], config2[prop]);
  875. } else if (!utils.isUndefined(config1[prop])) {
  876. config[prop] = getMergedValue(undefined, config1[prop]);
  877. }
  878. }
  879. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  880. if (!utils.isUndefined(config2[prop])) {
  881. config[prop] = getMergedValue(undefined, config2[prop]);
  882. }
  883. });
  884. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  885. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  886. if (!utils.isUndefined(config2[prop])) {
  887. config[prop] = getMergedValue(undefined, config2[prop]);
  888. } else if (!utils.isUndefined(config1[prop])) {
  889. config[prop] = getMergedValue(undefined, config1[prop]);
  890. }
  891. });
  892. utils.forEach(directMergeKeys, function merge(prop) {
  893. if (prop in config2) {
  894. config[prop] = getMergedValue(config1[prop], config2[prop]);
  895. } else if (prop in config1) {
  896. config[prop] = getMergedValue(undefined, config1[prop]);
  897. }
  898. });
  899. var axiosKeys = valueFromConfig2Keys
  900. .concat(mergeDeepPropertiesKeys)
  901. .concat(defaultToConfig2Keys)
  902. .concat(directMergeKeys);
  903. var otherKeys = Object
  904. .keys(config1)
  905. .concat(Object.keys(config2))
  906. .filter(function filterAxiosKeys(key) {
  907. return axiosKeys.indexOf(key) === -1;
  908. });
  909. utils.forEach(otherKeys, mergeDeepProperties);
  910. return config;
  911. };
  912. /***/ }),
  913. /***/ "./node_modules/axios/lib/core/settle.js":
  914. /*!***********************************************!*\
  915. !*** ./node_modules/axios/lib/core/settle.js ***!
  916. \***********************************************/
  917. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  918. "use strict";
  919. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  920. /**
  921. * Resolve or reject a Promise based on response status.
  922. *
  923. * @param {Function} resolve A function that resolves the promise.
  924. * @param {Function} reject A function that rejects the promise.
  925. * @param {object} response The response.
  926. */
  927. module.exports = function settle(resolve, reject, response) {
  928. var validateStatus = response.config.validateStatus;
  929. if (!response.status || !validateStatus || validateStatus(response.status)) {
  930. resolve(response);
  931. } else {
  932. reject(createError(
  933. 'Request failed with status code ' + response.status,
  934. response.config,
  935. null,
  936. response.request,
  937. response
  938. ));
  939. }
  940. };
  941. /***/ }),
  942. /***/ "./node_modules/axios/lib/core/transformData.js":
  943. /*!******************************************************!*\
  944. !*** ./node_modules/axios/lib/core/transformData.js ***!
  945. \******************************************************/
  946. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  947. "use strict";
  948. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  949. var defaults = __webpack_require__(/*! ./../defaults */ "./node_modules/axios/lib/defaults.js");
  950. /**
  951. * Transform the data for a request or a response
  952. *
  953. * @param {Object|String} data The data to be transformed
  954. * @param {Array} headers The headers for the request or response
  955. * @param {Array|Function} fns A single function or Array of functions
  956. * @returns {*} The resulting transformed data
  957. */
  958. module.exports = function transformData(data, headers, fns) {
  959. var context = this || defaults;
  960. /*eslint no-param-reassign:0*/
  961. utils.forEach(fns, function transform(fn) {
  962. data = fn.call(context, data, headers);
  963. });
  964. return data;
  965. };
  966. /***/ }),
  967. /***/ "./node_modules/axios/lib/defaults.js":
  968. /*!********************************************!*\
  969. !*** ./node_modules/axios/lib/defaults.js ***!
  970. \********************************************/
  971. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  972. "use strict";
  973. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
  974. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  975. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  976. var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  977. var DEFAULT_CONTENT_TYPE = {
  978. 'Content-Type': 'application/x-www-form-urlencoded'
  979. };
  980. function setContentTypeIfUnset(headers, value) {
  981. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  982. headers['Content-Type'] = value;
  983. }
  984. }
  985. function getDefaultAdapter() {
  986. var adapter;
  987. if (typeof XMLHttpRequest !== 'undefined') {
  988. // For browsers use XHR adapter
  989. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  990. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  991. // For node use HTTP adapter
  992. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  993. }
  994. return adapter;
  995. }
  996. function stringifySafely(rawValue, parser, encoder) {
  997. if (utils.isString(rawValue)) {
  998. try {
  999. (parser || JSON.parse)(rawValue);
  1000. return utils.trim(rawValue);
  1001. } catch (e) {
  1002. if (e.name !== 'SyntaxError') {
  1003. throw e;
  1004. }
  1005. }
  1006. }
  1007. return (encoder || JSON.stringify)(rawValue);
  1008. }
  1009. var defaults = {
  1010. transitional: {
  1011. silentJSONParsing: true,
  1012. forcedJSONParsing: true,
  1013. clarifyTimeoutError: false
  1014. },
  1015. adapter: getDefaultAdapter(),
  1016. transformRequest: [function transformRequest(data, headers) {
  1017. normalizeHeaderName(headers, 'Accept');
  1018. normalizeHeaderName(headers, 'Content-Type');
  1019. if (utils.isFormData(data) ||
  1020. utils.isArrayBuffer(data) ||
  1021. utils.isBuffer(data) ||
  1022. utils.isStream(data) ||
  1023. utils.isFile(data) ||
  1024. utils.isBlob(data)
  1025. ) {
  1026. return data;
  1027. }
  1028. if (utils.isArrayBufferView(data)) {
  1029. return data.buffer;
  1030. }
  1031. if (utils.isURLSearchParams(data)) {
  1032. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  1033. return data.toString();
  1034. }
  1035. if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
  1036. setContentTypeIfUnset(headers, 'application/json');
  1037. return stringifySafely(data);
  1038. }
  1039. return data;
  1040. }],
  1041. transformResponse: [function transformResponse(data) {
  1042. var transitional = this.transitional;
  1043. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  1044. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  1045. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  1046. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  1047. try {
  1048. return JSON.parse(data);
  1049. } catch (e) {
  1050. if (strictJSONParsing) {
  1051. if (e.name === 'SyntaxError') {
  1052. throw enhanceError(e, this, 'E_JSON_PARSE');
  1053. }
  1054. throw e;
  1055. }
  1056. }
  1057. }
  1058. return data;
  1059. }],
  1060. /**
  1061. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1062. * timeout is not created.
  1063. */
  1064. timeout: 0,
  1065. xsrfCookieName: 'XSRF-TOKEN',
  1066. xsrfHeaderName: 'X-XSRF-TOKEN',
  1067. maxContentLength: -1,
  1068. maxBodyLength: -1,
  1069. validateStatus: function validateStatus(status) {
  1070. return status >= 200 && status < 300;
  1071. }
  1072. };
  1073. defaults.headers = {
  1074. common: {
  1075. 'Accept': 'application/json, text/plain, */*'
  1076. }
  1077. };
  1078. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  1079. defaults.headers[method] = {};
  1080. });
  1081. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1082. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  1083. });
  1084. module.exports = defaults;
  1085. /***/ }),
  1086. /***/ "./node_modules/axios/lib/helpers/bind.js":
  1087. /*!************************************************!*\
  1088. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  1089. \************************************************/
  1090. /***/ ((module) => {
  1091. "use strict";
  1092. module.exports = function bind(fn, thisArg) {
  1093. return function wrap() {
  1094. var args = new Array(arguments.length);
  1095. for (var i = 0; i < args.length; i++) {
  1096. args[i] = arguments[i];
  1097. }
  1098. return fn.apply(thisArg, args);
  1099. };
  1100. };
  1101. /***/ }),
  1102. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  1103. /*!****************************************************!*\
  1104. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  1105. \****************************************************/
  1106. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1107. "use strict";
  1108. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1109. function encode(val) {
  1110. return encodeURIComponent(val).
  1111. replace(/%3A/gi, ':').
  1112. replace(/%24/g, '$').
  1113. replace(/%2C/gi, ',').
  1114. replace(/%20/g, '+').
  1115. replace(/%5B/gi, '[').
  1116. replace(/%5D/gi, ']');
  1117. }
  1118. /**
  1119. * Build a URL by appending params to the end
  1120. *
  1121. * @param {string} url The base of the url (e.g., http://www.google.com)
  1122. * @param {object} [params] The params to be appended
  1123. * @returns {string} The formatted url
  1124. */
  1125. module.exports = function buildURL(url, params, paramsSerializer) {
  1126. /*eslint no-param-reassign:0*/
  1127. if (!params) {
  1128. return url;
  1129. }
  1130. var serializedParams;
  1131. if (paramsSerializer) {
  1132. serializedParams = paramsSerializer(params);
  1133. } else if (utils.isURLSearchParams(params)) {
  1134. serializedParams = params.toString();
  1135. } else {
  1136. var parts = [];
  1137. utils.forEach(params, function serialize(val, key) {
  1138. if (val === null || typeof val === 'undefined') {
  1139. return;
  1140. }
  1141. if (utils.isArray(val)) {
  1142. key = key + '[]';
  1143. } else {
  1144. val = [val];
  1145. }
  1146. utils.forEach(val, function parseValue(v) {
  1147. if (utils.isDate(v)) {
  1148. v = v.toISOString();
  1149. } else if (utils.isObject(v)) {
  1150. v = JSON.stringify(v);
  1151. }
  1152. parts.push(encode(key) + '=' + encode(v));
  1153. });
  1154. });
  1155. serializedParams = parts.join('&');
  1156. }
  1157. if (serializedParams) {
  1158. var hashmarkIndex = url.indexOf('#');
  1159. if (hashmarkIndex !== -1) {
  1160. url = url.slice(0, hashmarkIndex);
  1161. }
  1162. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1163. }
  1164. return url;
  1165. };
  1166. /***/ }),
  1167. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  1168. /*!*******************************************************!*\
  1169. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  1170. \*******************************************************/
  1171. /***/ ((module) => {
  1172. "use strict";
  1173. /**
  1174. * Creates a new URL by combining the specified URLs
  1175. *
  1176. * @param {string} baseURL The base URL
  1177. * @param {string} relativeURL The relative URL
  1178. * @returns {string} The combined URL
  1179. */
  1180. module.exports = function combineURLs(baseURL, relativeURL) {
  1181. return relativeURL
  1182. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1183. : baseURL;
  1184. };
  1185. /***/ }),
  1186. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1187. /*!***************************************************!*\
  1188. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1189. \***************************************************/
  1190. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1191. "use strict";
  1192. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1193. module.exports = (
  1194. utils.isStandardBrowserEnv() ?
  1195. // Standard browser envs support document.cookie
  1196. (function standardBrowserEnv() {
  1197. return {
  1198. write: function write(name, value, expires, path, domain, secure) {
  1199. var cookie = [];
  1200. cookie.push(name + '=' + encodeURIComponent(value));
  1201. if (utils.isNumber(expires)) {
  1202. cookie.push('expires=' + new Date(expires).toGMTString());
  1203. }
  1204. if (utils.isString(path)) {
  1205. cookie.push('path=' + path);
  1206. }
  1207. if (utils.isString(domain)) {
  1208. cookie.push('domain=' + domain);
  1209. }
  1210. if (secure === true) {
  1211. cookie.push('secure');
  1212. }
  1213. document.cookie = cookie.join('; ');
  1214. },
  1215. read: function read(name) {
  1216. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1217. return (match ? decodeURIComponent(match[3]) : null);
  1218. },
  1219. remove: function remove(name) {
  1220. this.write(name, '', Date.now() - 86400000);
  1221. }
  1222. };
  1223. })() :
  1224. // Non standard browser env (web workers, react-native) lack needed support.
  1225. (function nonStandardBrowserEnv() {
  1226. return {
  1227. write: function write() {},
  1228. read: function read() { return null; },
  1229. remove: function remove() {}
  1230. };
  1231. })()
  1232. );
  1233. /***/ }),
  1234. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1235. /*!*********************************************************!*\
  1236. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1237. \*********************************************************/
  1238. /***/ ((module) => {
  1239. "use strict";
  1240. /**
  1241. * Determines whether the specified URL is absolute
  1242. *
  1243. * @param {string} url The URL to test
  1244. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1245. */
  1246. module.exports = function isAbsoluteURL(url) {
  1247. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1248. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1249. // by any combination of letters, digits, plus, period, or hyphen.
  1250. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1251. };
  1252. /***/ }),
  1253. /***/ "./node_modules/axios/lib/helpers/isAxiosError.js":
  1254. /*!********************************************************!*\
  1255. !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
  1256. \********************************************************/
  1257. /***/ ((module) => {
  1258. "use strict";
  1259. /**
  1260. * Determines whether the payload is an error thrown by Axios
  1261. *
  1262. * @param {*} payload The value to test
  1263. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1264. */
  1265. module.exports = function isAxiosError(payload) {
  1266. return (typeof payload === 'object') && (payload.isAxiosError === true);
  1267. };
  1268. /***/ }),
  1269. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1270. /*!***********************************************************!*\
  1271. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1272. \***********************************************************/
  1273. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1274. "use strict";
  1275. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1276. module.exports = (
  1277. utils.isStandardBrowserEnv() ?
  1278. // Standard browser envs have full support of the APIs needed to test
  1279. // whether the request URL is of the same origin as current location.
  1280. (function standardBrowserEnv() {
  1281. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1282. var urlParsingNode = document.createElement('a');
  1283. var originURL;
  1284. /**
  1285. * Parse a URL to discover it's components
  1286. *
  1287. * @param {String} url The URL to be parsed
  1288. * @returns {Object}
  1289. */
  1290. function resolveURL(url) {
  1291. var href = url;
  1292. if (msie) {
  1293. // IE needs attribute set twice to normalize properties
  1294. urlParsingNode.setAttribute('href', href);
  1295. href = urlParsingNode.href;
  1296. }
  1297. urlParsingNode.setAttribute('href', href);
  1298. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1299. return {
  1300. href: urlParsingNode.href,
  1301. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1302. host: urlParsingNode.host,
  1303. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1304. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1305. hostname: urlParsingNode.hostname,
  1306. port: urlParsingNode.port,
  1307. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1308. urlParsingNode.pathname :
  1309. '/' + urlParsingNode.pathname
  1310. };
  1311. }
  1312. originURL = resolveURL(window.location.href);
  1313. /**
  1314. * Determine if a URL shares the same origin as the current location
  1315. *
  1316. * @param {String} requestURL The URL to test
  1317. * @returns {boolean} True if URL shares the same origin, otherwise false
  1318. */
  1319. return function isURLSameOrigin(requestURL) {
  1320. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1321. return (parsed.protocol === originURL.protocol &&
  1322. parsed.host === originURL.host);
  1323. };
  1324. })() :
  1325. // Non standard browser envs (web workers, react-native) lack needed support.
  1326. (function nonStandardBrowserEnv() {
  1327. return function isURLSameOrigin() {
  1328. return true;
  1329. };
  1330. })()
  1331. );
  1332. /***/ }),
  1333. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1334. /*!***************************************************************!*\
  1335. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1336. \***************************************************************/
  1337. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1338. "use strict";
  1339. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1340. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1341. utils.forEach(headers, function processHeader(value, name) {
  1342. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1343. headers[normalizedName] = value;
  1344. delete headers[name];
  1345. }
  1346. });
  1347. };
  1348. /***/ }),
  1349. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1350. /*!********************************************************!*\
  1351. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1352. \********************************************************/
  1353. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1354. "use strict";
  1355. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1356. // Headers whose duplicates are ignored by node
  1357. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1358. var ignoreDuplicateOf = [
  1359. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1360. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1361. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1362. 'referer', 'retry-after', 'user-agent'
  1363. ];
  1364. /**
  1365. * Parse headers into an object
  1366. *
  1367. * ```
  1368. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1369. * Content-Type: application/json
  1370. * Connection: keep-alive
  1371. * Transfer-Encoding: chunked
  1372. * ```
  1373. *
  1374. * @param {String} headers Headers needing to be parsed
  1375. * @returns {Object} Headers parsed into an object
  1376. */
  1377. module.exports = function parseHeaders(headers) {
  1378. var parsed = {};
  1379. var key;
  1380. var val;
  1381. var i;
  1382. if (!headers) { return parsed; }
  1383. utils.forEach(headers.split('\n'), function parser(line) {
  1384. i = line.indexOf(':');
  1385. key = utils.trim(line.substr(0, i)).toLowerCase();
  1386. val = utils.trim(line.substr(i + 1));
  1387. if (key) {
  1388. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1389. return;
  1390. }
  1391. if (key === 'set-cookie') {
  1392. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1393. } else {
  1394. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1395. }
  1396. }
  1397. });
  1398. return parsed;
  1399. };
  1400. /***/ }),
  1401. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1402. /*!**************************************************!*\
  1403. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1404. \**************************************************/
  1405. /***/ ((module) => {
  1406. "use strict";
  1407. /**
  1408. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1409. *
  1410. * Common use case would be to use `Function.prototype.apply`.
  1411. *
  1412. * ```js
  1413. * function f(x, y, z) {}
  1414. * var args = [1, 2, 3];
  1415. * f.apply(null, args);
  1416. * ```
  1417. *
  1418. * With `spread` this example can be re-written.
  1419. *
  1420. * ```js
  1421. * spread(function(x, y, z) {})([1, 2, 3]);
  1422. * ```
  1423. *
  1424. * @param {Function} callback
  1425. * @returns {Function}
  1426. */
  1427. module.exports = function spread(callback) {
  1428. return function wrap(arr) {
  1429. return callback.apply(null, arr);
  1430. };
  1431. };
  1432. /***/ }),
  1433. /***/ "./node_modules/axios/lib/helpers/validator.js":
  1434. /*!*****************************************************!*\
  1435. !*** ./node_modules/axios/lib/helpers/validator.js ***!
  1436. \*****************************************************/
  1437. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1438. "use strict";
  1439. var pkg = __webpack_require__(/*! ./../../package.json */ "./node_modules/axios/package.json");
  1440. var validators = {};
  1441. // eslint-disable-next-line func-names
  1442. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  1443. validators[type] = function validator(thing) {
  1444. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  1445. };
  1446. });
  1447. var deprecatedWarnings = {};
  1448. var currentVerArr = pkg.version.split('.');
  1449. /**
  1450. * Compare package versions
  1451. * @param {string} version
  1452. * @param {string?} thanVersion
  1453. * @returns {boolean}
  1454. */
  1455. function isOlderVersion(version, thanVersion) {
  1456. var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr;
  1457. var destVer = version.split('.');
  1458. for (var i = 0; i < 3; i++) {
  1459. if (pkgVersionArr[i] > destVer[i]) {
  1460. return true;
  1461. } else if (pkgVersionArr[i] < destVer[i]) {
  1462. return false;
  1463. }
  1464. }
  1465. return false;
  1466. }
  1467. /**
  1468. * Transitional option validator
  1469. * @param {function|boolean?} validator
  1470. * @param {string?} version
  1471. * @param {string} message
  1472. * @returns {function}
  1473. */
  1474. validators.transitional = function transitional(validator, version, message) {
  1475. var isDeprecated = version && isOlderVersion(version);
  1476. function formatMessage(opt, desc) {
  1477. return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  1478. }
  1479. // eslint-disable-next-line func-names
  1480. return function(value, opt, opts) {
  1481. if (validator === false) {
  1482. throw new Error(formatMessage(opt, ' has been removed in ' + version));
  1483. }
  1484. if (isDeprecated && !deprecatedWarnings[opt]) {
  1485. deprecatedWarnings[opt] = true;
  1486. // eslint-disable-next-line no-console
  1487. console.warn(
  1488. formatMessage(
  1489. opt,
  1490. ' has been deprecated since v' + version + ' and will be removed in the near future'
  1491. )
  1492. );
  1493. }
  1494. return validator ? validator(value, opt, opts) : true;
  1495. };
  1496. };
  1497. /**
  1498. * Assert object's properties type
  1499. * @param {object} options
  1500. * @param {object} schema
  1501. * @param {boolean?} allowUnknown
  1502. */
  1503. function assertOptions(options, schema, allowUnknown) {
  1504. if (typeof options !== 'object') {
  1505. throw new TypeError('options must be an object');
  1506. }
  1507. var keys = Object.keys(options);
  1508. var i = keys.length;
  1509. while (i-- > 0) {
  1510. var opt = keys[i];
  1511. var validator = schema[opt];
  1512. if (validator) {
  1513. var value = options[opt];
  1514. var result = value === undefined || validator(value, opt, options);
  1515. if (result !== true) {
  1516. throw new TypeError('option ' + opt + ' must be ' + result);
  1517. }
  1518. continue;
  1519. }
  1520. if (allowUnknown !== true) {
  1521. throw Error('Unknown option ' + opt);
  1522. }
  1523. }
  1524. }
  1525. module.exports = {
  1526. isOlderVersion: isOlderVersion,
  1527. assertOptions: assertOptions,
  1528. validators: validators
  1529. };
  1530. /***/ }),
  1531. /***/ "./node_modules/axios/lib/utils.js":
  1532. /*!*****************************************!*\
  1533. !*** ./node_modules/axios/lib/utils.js ***!
  1534. \*****************************************/
  1535. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1536. "use strict";
  1537. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1538. // utils is a library of generic helper functions non-specific to axios
  1539. var toString = Object.prototype.toString;
  1540. /**
  1541. * Determine if a value is an Array
  1542. *
  1543. * @param {Object} val The value to test
  1544. * @returns {boolean} True if value is an Array, otherwise false
  1545. */
  1546. function isArray(val) {
  1547. return toString.call(val) === '[object Array]';
  1548. }
  1549. /**
  1550. * Determine if a value is undefined
  1551. *
  1552. * @param {Object} val The value to test
  1553. * @returns {boolean} True if the value is undefined, otherwise false
  1554. */
  1555. function isUndefined(val) {
  1556. return typeof val === 'undefined';
  1557. }
  1558. /**
  1559. * Determine if a value is a Buffer
  1560. *
  1561. * @param {Object} val The value to test
  1562. * @returns {boolean} True if value is a Buffer, otherwise false
  1563. */
  1564. function isBuffer(val) {
  1565. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1566. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1567. }
  1568. /**
  1569. * Determine if a value is an ArrayBuffer
  1570. *
  1571. * @param {Object} val The value to test
  1572. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1573. */
  1574. function isArrayBuffer(val) {
  1575. return toString.call(val) === '[object ArrayBuffer]';
  1576. }
  1577. /**
  1578. * Determine if a value is a FormData
  1579. *
  1580. * @param {Object} val The value to test
  1581. * @returns {boolean} True if value is an FormData, otherwise false
  1582. */
  1583. function isFormData(val) {
  1584. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1585. }
  1586. /**
  1587. * Determine if a value is a view on an ArrayBuffer
  1588. *
  1589. * @param {Object} val The value to test
  1590. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1591. */
  1592. function isArrayBufferView(val) {
  1593. var result;
  1594. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1595. result = ArrayBuffer.isView(val);
  1596. } else {
  1597. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1598. }
  1599. return result;
  1600. }
  1601. /**
  1602. * Determine if a value is a String
  1603. *
  1604. * @param {Object} val The value to test
  1605. * @returns {boolean} True if value is a String, otherwise false
  1606. */
  1607. function isString(val) {
  1608. return typeof val === 'string';
  1609. }
  1610. /**
  1611. * Determine if a value is a Number
  1612. *
  1613. * @param {Object} val The value to test
  1614. * @returns {boolean} True if value is a Number, otherwise false
  1615. */
  1616. function isNumber(val) {
  1617. return typeof val === 'number';
  1618. }
  1619. /**
  1620. * Determine if a value is an Object
  1621. *
  1622. * @param {Object} val The value to test
  1623. * @returns {boolean} True if value is an Object, otherwise false
  1624. */
  1625. function isObject(val) {
  1626. return val !== null && typeof val === 'object';
  1627. }
  1628. /**
  1629. * Determine if a value is a plain Object
  1630. *
  1631. * @param {Object} val The value to test
  1632. * @return {boolean} True if value is a plain Object, otherwise false
  1633. */
  1634. function isPlainObject(val) {
  1635. if (toString.call(val) !== '[object Object]') {
  1636. return false;
  1637. }
  1638. var prototype = Object.getPrototypeOf(val);
  1639. return prototype === null || prototype === Object.prototype;
  1640. }
  1641. /**
  1642. * Determine if a value is a Date
  1643. *
  1644. * @param {Object} val The value to test
  1645. * @returns {boolean} True if value is a Date, otherwise false
  1646. */
  1647. function isDate(val) {
  1648. return toString.call(val) === '[object Date]';
  1649. }
  1650. /**
  1651. * Determine if a value is a File
  1652. *
  1653. * @param {Object} val The value to test
  1654. * @returns {boolean} True if value is a File, otherwise false
  1655. */
  1656. function isFile(val) {
  1657. return toString.call(val) === '[object File]';
  1658. }
  1659. /**
  1660. * Determine if a value is a Blob
  1661. *
  1662. * @param {Object} val The value to test
  1663. * @returns {boolean} True if value is a Blob, otherwise false
  1664. */
  1665. function isBlob(val) {
  1666. return toString.call(val) === '[object Blob]';
  1667. }
  1668. /**
  1669. * Determine if a value is a Function
  1670. *
  1671. * @param {Object} val The value to test
  1672. * @returns {boolean} True if value is a Function, otherwise false
  1673. */
  1674. function isFunction(val) {
  1675. return toString.call(val) === '[object Function]';
  1676. }
  1677. /**
  1678. * Determine if a value is a Stream
  1679. *
  1680. * @param {Object} val The value to test
  1681. * @returns {boolean} True if value is a Stream, otherwise false
  1682. */
  1683. function isStream(val) {
  1684. return isObject(val) && isFunction(val.pipe);
  1685. }
  1686. /**
  1687. * Determine if a value is a URLSearchParams object
  1688. *
  1689. * @param {Object} val The value to test
  1690. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1691. */
  1692. function isURLSearchParams(val) {
  1693. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1694. }
  1695. /**
  1696. * Trim excess whitespace off the beginning and end of a string
  1697. *
  1698. * @param {String} str The String to trim
  1699. * @returns {String} The String freed of excess whitespace
  1700. */
  1701. function trim(str) {
  1702. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  1703. }
  1704. /**
  1705. * Determine if we're running in a standard browser environment
  1706. *
  1707. * This allows axios to run in a web worker, and react-native.
  1708. * Both environments support XMLHttpRequest, but not fully standard globals.
  1709. *
  1710. * web workers:
  1711. * typeof window -> undefined
  1712. * typeof document -> undefined
  1713. *
  1714. * react-native:
  1715. * navigator.product -> 'ReactNative'
  1716. * nativescript
  1717. * navigator.product -> 'NativeScript' or 'NS'
  1718. */
  1719. function isStandardBrowserEnv() {
  1720. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1721. navigator.product === 'NativeScript' ||
  1722. navigator.product === 'NS')) {
  1723. return false;
  1724. }
  1725. return (
  1726. typeof window !== 'undefined' &&
  1727. typeof document !== 'undefined'
  1728. );
  1729. }
  1730. /**
  1731. * Iterate over an Array or an Object invoking a function for each item.
  1732. *
  1733. * If `obj` is an Array callback will be called passing
  1734. * the value, index, and complete array for each item.
  1735. *
  1736. * If 'obj' is an Object callback will be called passing
  1737. * the value, key, and complete object for each property.
  1738. *
  1739. * @param {Object|Array} obj The object to iterate
  1740. * @param {Function} fn The callback to invoke for each item
  1741. */
  1742. function forEach(obj, fn) {
  1743. // Don't bother if no value provided
  1744. if (obj === null || typeof obj === 'undefined') {
  1745. return;
  1746. }
  1747. // Force an array if not already something iterable
  1748. if (typeof obj !== 'object') {
  1749. /*eslint no-param-reassign:0*/
  1750. obj = [obj];
  1751. }
  1752. if (isArray(obj)) {
  1753. // Iterate over array values
  1754. for (var i = 0, l = obj.length; i < l; i++) {
  1755. fn.call(null, obj[i], i, obj);
  1756. }
  1757. } else {
  1758. // Iterate over object keys
  1759. for (var key in obj) {
  1760. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1761. fn.call(null, obj[key], key, obj);
  1762. }
  1763. }
  1764. }
  1765. }
  1766. /**
  1767. * Accepts varargs expecting each argument to be an object, then
  1768. * immutably merges the properties of each object and returns result.
  1769. *
  1770. * When multiple objects contain the same key the later object in
  1771. * the arguments list will take precedence.
  1772. *
  1773. * Example:
  1774. *
  1775. * ```js
  1776. * var result = merge({foo: 123}, {foo: 456});
  1777. * console.log(result.foo); // outputs 456
  1778. * ```
  1779. *
  1780. * @param {Object} obj1 Object to merge
  1781. * @returns {Object} Result of all merge properties
  1782. */
  1783. function merge(/* obj1, obj2, obj3, ... */) {
  1784. var result = {};
  1785. function assignValue(val, key) {
  1786. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1787. result[key] = merge(result[key], val);
  1788. } else if (isPlainObject(val)) {
  1789. result[key] = merge({}, val);
  1790. } else if (isArray(val)) {
  1791. result[key] = val.slice();
  1792. } else {
  1793. result[key] = val;
  1794. }
  1795. }
  1796. for (var i = 0, l = arguments.length; i < l; i++) {
  1797. forEach(arguments[i], assignValue);
  1798. }
  1799. return result;
  1800. }
  1801. /**
  1802. * Extends object a by mutably adding to it the properties of object b.
  1803. *
  1804. * @param {Object} a The object to be extended
  1805. * @param {Object} b The object to copy properties from
  1806. * @param {Object} thisArg The object to bind function to
  1807. * @return {Object} The resulting value of object a
  1808. */
  1809. function extend(a, b, thisArg) {
  1810. forEach(b, function assignValue(val, key) {
  1811. if (thisArg && typeof val === 'function') {
  1812. a[key] = bind(val, thisArg);
  1813. } else {
  1814. a[key] = val;
  1815. }
  1816. });
  1817. return a;
  1818. }
  1819. /**
  1820. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  1821. *
  1822. * @param {string} content with BOM
  1823. * @return {string} content value without BOM
  1824. */
  1825. function stripBOM(content) {
  1826. if (content.charCodeAt(0) === 0xFEFF) {
  1827. content = content.slice(1);
  1828. }
  1829. return content;
  1830. }
  1831. module.exports = {
  1832. isArray: isArray,
  1833. isArrayBuffer: isArrayBuffer,
  1834. isBuffer: isBuffer,
  1835. isFormData: isFormData,
  1836. isArrayBufferView: isArrayBufferView,
  1837. isString: isString,
  1838. isNumber: isNumber,
  1839. isObject: isObject,
  1840. isPlainObject: isPlainObject,
  1841. isUndefined: isUndefined,
  1842. isDate: isDate,
  1843. isFile: isFile,
  1844. isBlob: isBlob,
  1845. isFunction: isFunction,
  1846. isStream: isStream,
  1847. isURLSearchParams: isURLSearchParams,
  1848. isStandardBrowserEnv: isStandardBrowserEnv,
  1849. forEach: forEach,
  1850. merge: merge,
  1851. extend: extend,
  1852. trim: trim,
  1853. stripBOM: stripBOM
  1854. };
  1855. /***/ }),
  1856. /***/ "./node_modules/lodash.remove/index.js":
  1857. /*!*********************************************!*\
  1858. !*** ./node_modules/lodash.remove/index.js ***!
  1859. \*********************************************/
  1860. /***/ ((module, exports, __webpack_require__) => {
  1861. /* module decorator */ module = __webpack_require__.nmd(module);
  1862. /**
  1863. * lodash (Custom Build) <https://lodash.com/>
  1864. * Build: `lodash modularize exports="npm" -o ./`
  1865. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1866. * Released under MIT license <https://lodash.com/license>
  1867. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1868. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1869. */
  1870. /** Used as the size to enable large array optimizations. */
  1871. var LARGE_ARRAY_SIZE = 200;
  1872. /** Used as the `TypeError` message for "Functions" methods. */
  1873. var FUNC_ERROR_TEXT = 'Expected a function';
  1874. /** Used to stand-in for `undefined` hash values. */
  1875. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1876. /** Used to compose bitmasks for comparison styles. */
  1877. var UNORDERED_COMPARE_FLAG = 1,
  1878. PARTIAL_COMPARE_FLAG = 2;
  1879. /** Used as references for various `Number` constants. */
  1880. var INFINITY = 1 / 0,
  1881. MAX_SAFE_INTEGER = 9007199254740991;
  1882. /** `Object#toString` result references. */
  1883. var argsTag = '[object Arguments]',
  1884. arrayTag = '[object Array]',
  1885. boolTag = '[object Boolean]',
  1886. dateTag = '[object Date]',
  1887. errorTag = '[object Error]',
  1888. funcTag = '[object Function]',
  1889. genTag = '[object GeneratorFunction]',
  1890. mapTag = '[object Map]',
  1891. numberTag = '[object Number]',
  1892. objectTag = '[object Object]',
  1893. promiseTag = '[object Promise]',
  1894. regexpTag = '[object RegExp]',
  1895. setTag = '[object Set]',
  1896. stringTag = '[object String]',
  1897. symbolTag = '[object Symbol]',
  1898. weakMapTag = '[object WeakMap]';
  1899. var arrayBufferTag = '[object ArrayBuffer]',
  1900. dataViewTag = '[object DataView]',
  1901. float32Tag = '[object Float32Array]',
  1902. float64Tag = '[object Float64Array]',
  1903. int8Tag = '[object Int8Array]',
  1904. int16Tag = '[object Int16Array]',
  1905. int32Tag = '[object Int32Array]',
  1906. uint8Tag = '[object Uint8Array]',
  1907. uint8ClampedTag = '[object Uint8ClampedArray]',
  1908. uint16Tag = '[object Uint16Array]',
  1909. uint32Tag = '[object Uint32Array]';
  1910. /** Used to match property names within property paths. */
  1911. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  1912. reIsPlainProp = /^\w*$/,
  1913. reLeadingDot = /^\./,
  1914. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  1915. /**
  1916. * Used to match `RegExp`
  1917. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1918. */
  1919. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  1920. /** Used to match backslashes in property paths. */
  1921. var reEscapeChar = /\\(\\)?/g;
  1922. /** Used to detect host constructors (Safari). */
  1923. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1924. /** Used to detect unsigned integer values. */
  1925. var reIsUint = /^(?:0|[1-9]\d*)$/;
  1926. /** Used to identify `toStringTag` values of typed arrays. */
  1927. var typedArrayTags = {};
  1928. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1929. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1930. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1931. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1932. typedArrayTags[uint32Tag] = true;
  1933. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1934. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1935. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  1936. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  1937. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  1938. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  1939. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  1940. typedArrayTags[weakMapTag] = false;
  1941. /** Detect free variable `global` from Node.js. */
  1942. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  1943. /** Detect free variable `self`. */
  1944. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1945. /** Used as a reference to the global object. */
  1946. var root = freeGlobal || freeSelf || Function('return this')();
  1947. /** Detect free variable `exports`. */
  1948. var freeExports = true && exports && !exports.nodeType && exports;
  1949. /** Detect free variable `module`. */
  1950. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  1951. /** Detect the popular CommonJS extension `module.exports`. */
  1952. var moduleExports = freeModule && freeModule.exports === freeExports;
  1953. /** Detect free variable `process` from Node.js. */
  1954. var freeProcess = moduleExports && freeGlobal.process;
  1955. /** Used to access faster Node.js helpers. */
  1956. var nodeUtil = (function() {
  1957. try {
  1958. return freeProcess && freeProcess.binding('util');
  1959. } catch (e) {}
  1960. }());
  1961. /* Node.js helper references. */
  1962. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  1963. /**
  1964. * A specialized version of `_.some` for arrays without support for iteratee
  1965. * shorthands.
  1966. *
  1967. * @private
  1968. * @param {Array} [array] The array to iterate over.
  1969. * @param {Function} predicate The function invoked per iteration.
  1970. * @returns {boolean} Returns `true` if any element passes the predicate check,
  1971. * else `false`.
  1972. */
  1973. function arraySome(array, predicate) {
  1974. var index = -1,
  1975. length = array ? array.length : 0;
  1976. while (++index < length) {
  1977. if (predicate(array[index], index, array)) {
  1978. return true;
  1979. }
  1980. }
  1981. return false;
  1982. }
  1983. /**
  1984. * The base implementation of `_.property` without support for deep paths.
  1985. *
  1986. * @private
  1987. * @param {string} key The key of the property to get.
  1988. * @returns {Function} Returns the new accessor function.
  1989. */
  1990. function baseProperty(key) {
  1991. return function(object) {
  1992. return object == null ? undefined : object[key];
  1993. };
  1994. }
  1995. /**
  1996. * The base implementation of `_.times` without support for iteratee shorthands
  1997. * or max array length checks.
  1998. *
  1999. * @private
  2000. * @param {number} n The number of times to invoke `iteratee`.
  2001. * @param {Function} iteratee The function invoked per iteration.
  2002. * @returns {Array} Returns the array of results.
  2003. */
  2004. function baseTimes(n, iteratee) {
  2005. var index = -1,
  2006. result = Array(n);
  2007. while (++index < n) {
  2008. result[index] = iteratee(index);
  2009. }
  2010. return result;
  2011. }
  2012. /**
  2013. * The base implementation of `_.unary` without support for storing metadata.
  2014. *
  2015. * @private
  2016. * @param {Function} func The function to cap arguments for.
  2017. * @returns {Function} Returns the new capped function.
  2018. */
  2019. function baseUnary(func) {
  2020. return function(value) {
  2021. return func(value);
  2022. };
  2023. }
  2024. /**
  2025. * Gets the value at `key` of `object`.
  2026. *
  2027. * @private
  2028. * @param {Object} [object] The object to query.
  2029. * @param {string} key The key of the property to get.
  2030. * @returns {*} Returns the property value.
  2031. */
  2032. function getValue(object, key) {
  2033. return object == null ? undefined : object[key];
  2034. }
  2035. /**
  2036. * Checks if `value` is a host object in IE < 9.
  2037. *
  2038. * @private
  2039. * @param {*} value The value to check.
  2040. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  2041. */
  2042. function isHostObject(value) {
  2043. // Many host objects are `Object` objects that can coerce to strings
  2044. // despite having improperly defined `toString` methods.
  2045. var result = false;
  2046. if (value != null && typeof value.toString != 'function') {
  2047. try {
  2048. result = !!(value + '');
  2049. } catch (e) {}
  2050. }
  2051. return result;
  2052. }
  2053. /**
  2054. * Converts `map` to its key-value pairs.
  2055. *
  2056. * @private
  2057. * @param {Object} map The map to convert.
  2058. * @returns {Array} Returns the key-value pairs.
  2059. */
  2060. function mapToArray(map) {
  2061. var index = -1,
  2062. result = Array(map.size);
  2063. map.forEach(function(value, key) {
  2064. result[++index] = [key, value];
  2065. });
  2066. return result;
  2067. }
  2068. /**
  2069. * Creates a unary function that invokes `func` with its argument transformed.
  2070. *
  2071. * @private
  2072. * @param {Function} func The function to wrap.
  2073. * @param {Function} transform The argument transform.
  2074. * @returns {Function} Returns the new function.
  2075. */
  2076. function overArg(func, transform) {
  2077. return function(arg) {
  2078. return func(transform(arg));
  2079. };
  2080. }
  2081. /**
  2082. * Converts `set` to an array of its values.
  2083. *
  2084. * @private
  2085. * @param {Object} set The set to convert.
  2086. * @returns {Array} Returns the values.
  2087. */
  2088. function setToArray(set) {
  2089. var index = -1,
  2090. result = Array(set.size);
  2091. set.forEach(function(value) {
  2092. result[++index] = value;
  2093. });
  2094. return result;
  2095. }
  2096. /** Used for built-in method references. */
  2097. var arrayProto = Array.prototype,
  2098. funcProto = Function.prototype,
  2099. objectProto = Object.prototype;
  2100. /** Used to detect overreaching core-js shims. */
  2101. var coreJsData = root['__core-js_shared__'];
  2102. /** Used to detect methods masquerading as native. */
  2103. var maskSrcKey = (function() {
  2104. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2105. return uid ? ('Symbol(src)_1.' + uid) : '';
  2106. }());
  2107. /** Used to resolve the decompiled source of functions. */
  2108. var funcToString = funcProto.toString;
  2109. /** Used to check objects for own properties. */
  2110. var hasOwnProperty = objectProto.hasOwnProperty;
  2111. /**
  2112. * Used to resolve the
  2113. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2114. * of values.
  2115. */
  2116. var objectToString = objectProto.toString;
  2117. /** Used to detect if a method is native. */
  2118. var reIsNative = RegExp('^' +
  2119. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2120. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2121. );
  2122. /** Built-in value references. */
  2123. var Symbol = root.Symbol,
  2124. Uint8Array = root.Uint8Array,
  2125. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2126. splice = arrayProto.splice;
  2127. /* Built-in method references for those with the same name as other `lodash` methods. */
  2128. var nativeKeys = overArg(Object.keys, Object);
  2129. /* Built-in method references that are verified to be native. */
  2130. var DataView = getNative(root, 'DataView'),
  2131. Map = getNative(root, 'Map'),
  2132. Promise = getNative(root, 'Promise'),
  2133. Set = getNative(root, 'Set'),
  2134. WeakMap = getNative(root, 'WeakMap'),
  2135. nativeCreate = getNative(Object, 'create');
  2136. /** Used to detect maps, sets, and weakmaps. */
  2137. var dataViewCtorString = toSource(DataView),
  2138. mapCtorString = toSource(Map),
  2139. promiseCtorString = toSource(Promise),
  2140. setCtorString = toSource(Set),
  2141. weakMapCtorString = toSource(WeakMap);
  2142. /** Used to convert symbols to primitives and strings. */
  2143. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2144. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2145. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2146. /**
  2147. * Creates a hash object.
  2148. *
  2149. * @private
  2150. * @constructor
  2151. * @param {Array} [entries] The key-value pairs to cache.
  2152. */
  2153. function Hash(entries) {
  2154. var index = -1,
  2155. length = entries ? entries.length : 0;
  2156. this.clear();
  2157. while (++index < length) {
  2158. var entry = entries[index];
  2159. this.set(entry[0], entry[1]);
  2160. }
  2161. }
  2162. /**
  2163. * Removes all key-value entries from the hash.
  2164. *
  2165. * @private
  2166. * @name clear
  2167. * @memberOf Hash
  2168. */
  2169. function hashClear() {
  2170. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  2171. }
  2172. /**
  2173. * Removes `key` and its value from the hash.
  2174. *
  2175. * @private
  2176. * @name delete
  2177. * @memberOf Hash
  2178. * @param {Object} hash The hash to modify.
  2179. * @param {string} key The key of the value to remove.
  2180. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2181. */
  2182. function hashDelete(key) {
  2183. return this.has(key) && delete this.__data__[key];
  2184. }
  2185. /**
  2186. * Gets the hash value for `key`.
  2187. *
  2188. * @private
  2189. * @name get
  2190. * @memberOf Hash
  2191. * @param {string} key The key of the value to get.
  2192. * @returns {*} Returns the entry value.
  2193. */
  2194. function hashGet(key) {
  2195. var data = this.__data__;
  2196. if (nativeCreate) {
  2197. var result = data[key];
  2198. return result === HASH_UNDEFINED ? undefined : result;
  2199. }
  2200. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  2201. }
  2202. /**
  2203. * Checks if a hash value for `key` exists.
  2204. *
  2205. * @private
  2206. * @name has
  2207. * @memberOf Hash
  2208. * @param {string} key The key of the entry to check.
  2209. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2210. */
  2211. function hashHas(key) {
  2212. var data = this.__data__;
  2213. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  2214. }
  2215. /**
  2216. * Sets the hash `key` to `value`.
  2217. *
  2218. * @private
  2219. * @name set
  2220. * @memberOf Hash
  2221. * @param {string} key The key of the value to set.
  2222. * @param {*} value The value to set.
  2223. * @returns {Object} Returns the hash instance.
  2224. */
  2225. function hashSet(key, value) {
  2226. var data = this.__data__;
  2227. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  2228. return this;
  2229. }
  2230. // Add methods to `Hash`.
  2231. Hash.prototype.clear = hashClear;
  2232. Hash.prototype['delete'] = hashDelete;
  2233. Hash.prototype.get = hashGet;
  2234. Hash.prototype.has = hashHas;
  2235. Hash.prototype.set = hashSet;
  2236. /**
  2237. * Creates an list cache object.
  2238. *
  2239. * @private
  2240. * @constructor
  2241. * @param {Array} [entries] The key-value pairs to cache.
  2242. */
  2243. function ListCache(entries) {
  2244. var index = -1,
  2245. length = entries ? entries.length : 0;
  2246. this.clear();
  2247. while (++index < length) {
  2248. var entry = entries[index];
  2249. this.set(entry[0], entry[1]);
  2250. }
  2251. }
  2252. /**
  2253. * Removes all key-value entries from the list cache.
  2254. *
  2255. * @private
  2256. * @name clear
  2257. * @memberOf ListCache
  2258. */
  2259. function listCacheClear() {
  2260. this.__data__ = [];
  2261. }
  2262. /**
  2263. * Removes `key` and its value from the list cache.
  2264. *
  2265. * @private
  2266. * @name delete
  2267. * @memberOf ListCache
  2268. * @param {string} key The key of the value to remove.
  2269. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2270. */
  2271. function listCacheDelete(key) {
  2272. var data = this.__data__,
  2273. index = assocIndexOf(data, key);
  2274. if (index < 0) {
  2275. return false;
  2276. }
  2277. var lastIndex = data.length - 1;
  2278. if (index == lastIndex) {
  2279. data.pop();
  2280. } else {
  2281. splice.call(data, index, 1);
  2282. }
  2283. return true;
  2284. }
  2285. /**
  2286. * Gets the list cache value for `key`.
  2287. *
  2288. * @private
  2289. * @name get
  2290. * @memberOf ListCache
  2291. * @param {string} key The key of the value to get.
  2292. * @returns {*} Returns the entry value.
  2293. */
  2294. function listCacheGet(key) {
  2295. var data = this.__data__,
  2296. index = assocIndexOf(data, key);
  2297. return index < 0 ? undefined : data[index][1];
  2298. }
  2299. /**
  2300. * Checks if a list cache value for `key` exists.
  2301. *
  2302. * @private
  2303. * @name has
  2304. * @memberOf ListCache
  2305. * @param {string} key The key of the entry to check.
  2306. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2307. */
  2308. function listCacheHas(key) {
  2309. return assocIndexOf(this.__data__, key) > -1;
  2310. }
  2311. /**
  2312. * Sets the list cache `key` to `value`.
  2313. *
  2314. * @private
  2315. * @name set
  2316. * @memberOf ListCache
  2317. * @param {string} key The key of the value to set.
  2318. * @param {*} value The value to set.
  2319. * @returns {Object} Returns the list cache instance.
  2320. */
  2321. function listCacheSet(key, value) {
  2322. var data = this.__data__,
  2323. index = assocIndexOf(data, key);
  2324. if (index < 0) {
  2325. data.push([key, value]);
  2326. } else {
  2327. data[index][1] = value;
  2328. }
  2329. return this;
  2330. }
  2331. // Add methods to `ListCache`.
  2332. ListCache.prototype.clear = listCacheClear;
  2333. ListCache.prototype['delete'] = listCacheDelete;
  2334. ListCache.prototype.get = listCacheGet;
  2335. ListCache.prototype.has = listCacheHas;
  2336. ListCache.prototype.set = listCacheSet;
  2337. /**
  2338. * Creates a map cache object to store key-value pairs.
  2339. *
  2340. * @private
  2341. * @constructor
  2342. * @param {Array} [entries] The key-value pairs to cache.
  2343. */
  2344. function MapCache(entries) {
  2345. var index = -1,
  2346. length = entries ? entries.length : 0;
  2347. this.clear();
  2348. while (++index < length) {
  2349. var entry = entries[index];
  2350. this.set(entry[0], entry[1]);
  2351. }
  2352. }
  2353. /**
  2354. * Removes all key-value entries from the map.
  2355. *
  2356. * @private
  2357. * @name clear
  2358. * @memberOf MapCache
  2359. */
  2360. function mapCacheClear() {
  2361. this.__data__ = {
  2362. 'hash': new Hash,
  2363. 'map': new (Map || ListCache),
  2364. 'string': new Hash
  2365. };
  2366. }
  2367. /**
  2368. * Removes `key` and its value from the map.
  2369. *
  2370. * @private
  2371. * @name delete
  2372. * @memberOf MapCache
  2373. * @param {string} key The key of the value to remove.
  2374. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2375. */
  2376. function mapCacheDelete(key) {
  2377. return getMapData(this, key)['delete'](key);
  2378. }
  2379. /**
  2380. * Gets the map value for `key`.
  2381. *
  2382. * @private
  2383. * @name get
  2384. * @memberOf MapCache
  2385. * @param {string} key The key of the value to get.
  2386. * @returns {*} Returns the entry value.
  2387. */
  2388. function mapCacheGet(key) {
  2389. return getMapData(this, key).get(key);
  2390. }
  2391. /**
  2392. * Checks if a map value for `key` exists.
  2393. *
  2394. * @private
  2395. * @name has
  2396. * @memberOf MapCache
  2397. * @param {string} key The key of the entry to check.
  2398. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2399. */
  2400. function mapCacheHas(key) {
  2401. return getMapData(this, key).has(key);
  2402. }
  2403. /**
  2404. * Sets the map `key` to `value`.
  2405. *
  2406. * @private
  2407. * @name set
  2408. * @memberOf MapCache
  2409. * @param {string} key The key of the value to set.
  2410. * @param {*} value The value to set.
  2411. * @returns {Object} Returns the map cache instance.
  2412. */
  2413. function mapCacheSet(key, value) {
  2414. getMapData(this, key).set(key, value);
  2415. return this;
  2416. }
  2417. // Add methods to `MapCache`.
  2418. MapCache.prototype.clear = mapCacheClear;
  2419. MapCache.prototype['delete'] = mapCacheDelete;
  2420. MapCache.prototype.get = mapCacheGet;
  2421. MapCache.prototype.has = mapCacheHas;
  2422. MapCache.prototype.set = mapCacheSet;
  2423. /**
  2424. *
  2425. * Creates an array cache object to store unique values.
  2426. *
  2427. * @private
  2428. * @constructor
  2429. * @param {Array} [values] The values to cache.
  2430. */
  2431. function SetCache(values) {
  2432. var index = -1,
  2433. length = values ? values.length : 0;
  2434. this.__data__ = new MapCache;
  2435. while (++index < length) {
  2436. this.add(values[index]);
  2437. }
  2438. }
  2439. /**
  2440. * Adds `value` to the array cache.
  2441. *
  2442. * @private
  2443. * @name add
  2444. * @memberOf SetCache
  2445. * @alias push
  2446. * @param {*} value The value to cache.
  2447. * @returns {Object} Returns the cache instance.
  2448. */
  2449. function setCacheAdd(value) {
  2450. this.__data__.set(value, HASH_UNDEFINED);
  2451. return this;
  2452. }
  2453. /**
  2454. * Checks if `value` is in the array cache.
  2455. *
  2456. * @private
  2457. * @name has
  2458. * @memberOf SetCache
  2459. * @param {*} value The value to search for.
  2460. * @returns {number} Returns `true` if `value` is found, else `false`.
  2461. */
  2462. function setCacheHas(value) {
  2463. return this.__data__.has(value);
  2464. }
  2465. // Add methods to `SetCache`.
  2466. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  2467. SetCache.prototype.has = setCacheHas;
  2468. /**
  2469. * Creates a stack cache object to store key-value pairs.
  2470. *
  2471. * @private
  2472. * @constructor
  2473. * @param {Array} [entries] The key-value pairs to cache.
  2474. */
  2475. function Stack(entries) {
  2476. this.__data__ = new ListCache(entries);
  2477. }
  2478. /**
  2479. * Removes all key-value entries from the stack.
  2480. *
  2481. * @private
  2482. * @name clear
  2483. * @memberOf Stack
  2484. */
  2485. function stackClear() {
  2486. this.__data__ = new ListCache;
  2487. }
  2488. /**
  2489. * Removes `key` and its value from the stack.
  2490. *
  2491. * @private
  2492. * @name delete
  2493. * @memberOf Stack
  2494. * @param {string} key The key of the value to remove.
  2495. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2496. */
  2497. function stackDelete(key) {
  2498. return this.__data__['delete'](key);
  2499. }
  2500. /**
  2501. * Gets the stack value for `key`.
  2502. *
  2503. * @private
  2504. * @name get
  2505. * @memberOf Stack
  2506. * @param {string} key The key of the value to get.
  2507. * @returns {*} Returns the entry value.
  2508. */
  2509. function stackGet(key) {
  2510. return this.__data__.get(key);
  2511. }
  2512. /**
  2513. * Checks if a stack value for `key` exists.
  2514. *
  2515. * @private
  2516. * @name has
  2517. * @memberOf Stack
  2518. * @param {string} key The key of the entry to check.
  2519. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2520. */
  2521. function stackHas(key) {
  2522. return this.__data__.has(key);
  2523. }
  2524. /**
  2525. * Sets the stack `key` to `value`.
  2526. *
  2527. * @private
  2528. * @name set
  2529. * @memberOf Stack
  2530. * @param {string} key The key of the value to set.
  2531. * @param {*} value The value to set.
  2532. * @returns {Object} Returns the stack cache instance.
  2533. */
  2534. function stackSet(key, value) {
  2535. var cache = this.__data__;
  2536. if (cache instanceof ListCache) {
  2537. var pairs = cache.__data__;
  2538. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  2539. pairs.push([key, value]);
  2540. return this;
  2541. }
  2542. cache = this.__data__ = new MapCache(pairs);
  2543. }
  2544. cache.set(key, value);
  2545. return this;
  2546. }
  2547. // Add methods to `Stack`.
  2548. Stack.prototype.clear = stackClear;
  2549. Stack.prototype['delete'] = stackDelete;
  2550. Stack.prototype.get = stackGet;
  2551. Stack.prototype.has = stackHas;
  2552. Stack.prototype.set = stackSet;
  2553. /**
  2554. * Creates an array of the enumerable property names of the array-like `value`.
  2555. *
  2556. * @private
  2557. * @param {*} value The value to query.
  2558. * @param {boolean} inherited Specify returning inherited property names.
  2559. * @returns {Array} Returns the array of property names.
  2560. */
  2561. function arrayLikeKeys(value, inherited) {
  2562. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  2563. // Safari 9 makes `arguments.length` enumerable in strict mode.
  2564. var result = (isArray(value) || isArguments(value))
  2565. ? baseTimes(value.length, String)
  2566. : [];
  2567. var length = result.length,
  2568. skipIndexes = !!length;
  2569. for (var key in value) {
  2570. if ((inherited || hasOwnProperty.call(value, key)) &&
  2571. !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
  2572. result.push(key);
  2573. }
  2574. }
  2575. return result;
  2576. }
  2577. /**
  2578. * Gets the index at which the `key` is found in `array` of key-value pairs.
  2579. *
  2580. * @private
  2581. * @param {Array} array The array to inspect.
  2582. * @param {*} key The key to search for.
  2583. * @returns {number} Returns the index of the matched value, else `-1`.
  2584. */
  2585. function assocIndexOf(array, key) {
  2586. var length = array.length;
  2587. while (length--) {
  2588. if (eq(array[length][0], key)) {
  2589. return length;
  2590. }
  2591. }
  2592. return -1;
  2593. }
  2594. /**
  2595. * The base implementation of `_.get` without support for default values.
  2596. *
  2597. * @private
  2598. * @param {Object} object The object to query.
  2599. * @param {Array|string} path The path of the property to get.
  2600. * @returns {*} Returns the resolved value.
  2601. */
  2602. function baseGet(object, path) {
  2603. path = isKey(path, object) ? [path] : castPath(path);
  2604. var index = 0,
  2605. length = path.length;
  2606. while (object != null && index < length) {
  2607. object = object[toKey(path[index++])];
  2608. }
  2609. return (index && index == length) ? object : undefined;
  2610. }
  2611. /**
  2612. * The base implementation of `getTag`.
  2613. *
  2614. * @private
  2615. * @param {*} value The value to query.
  2616. * @returns {string} Returns the `toStringTag`.
  2617. */
  2618. function baseGetTag(value) {
  2619. return objectToString.call(value);
  2620. }
  2621. /**
  2622. * The base implementation of `_.hasIn` without support for deep paths.
  2623. *
  2624. * @private
  2625. * @param {Object} [object] The object to query.
  2626. * @param {Array|string} key The key to check.
  2627. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  2628. */
  2629. function baseHasIn(object, key) {
  2630. return object != null && key in Object(object);
  2631. }
  2632. /**
  2633. * The base implementation of `_.isEqual` which supports partial comparisons
  2634. * and tracks traversed objects.
  2635. *
  2636. * @private
  2637. * @param {*} value The value to compare.
  2638. * @param {*} other The other value to compare.
  2639. * @param {Function} [customizer] The function to customize comparisons.
  2640. * @param {boolean} [bitmask] The bitmask of comparison flags.
  2641. * The bitmask may be composed of the following flags:
  2642. * 1 - Unordered comparison
  2643. * 2 - Partial comparison
  2644. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  2645. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2646. */
  2647. function baseIsEqual(value, other, customizer, bitmask, stack) {
  2648. if (value === other) {
  2649. return true;
  2650. }
  2651. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  2652. return value !== value && other !== other;
  2653. }
  2654. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  2655. }
  2656. /**
  2657. * A specialized version of `baseIsEqual` for arrays and objects which performs
  2658. * deep comparisons and tracks traversed objects enabling objects with circular
  2659. * references to be compared.
  2660. *
  2661. * @private
  2662. * @param {Object} object The object to compare.
  2663. * @param {Object} other The other object to compare.
  2664. * @param {Function} equalFunc The function to determine equivalents of values.
  2665. * @param {Function} [customizer] The function to customize comparisons.
  2666. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  2667. * for more details.
  2668. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  2669. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  2670. */
  2671. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  2672. var objIsArr = isArray(object),
  2673. othIsArr = isArray(other),
  2674. objTag = arrayTag,
  2675. othTag = arrayTag;
  2676. if (!objIsArr) {
  2677. objTag = getTag(object);
  2678. objTag = objTag == argsTag ? objectTag : objTag;
  2679. }
  2680. if (!othIsArr) {
  2681. othTag = getTag(other);
  2682. othTag = othTag == argsTag ? objectTag : othTag;
  2683. }
  2684. var objIsObj = objTag == objectTag && !isHostObject(object),
  2685. othIsObj = othTag == objectTag && !isHostObject(other),
  2686. isSameTag = objTag == othTag;
  2687. if (isSameTag && !objIsObj) {
  2688. stack || (stack = new Stack);
  2689. return (objIsArr || isTypedArray(object))
  2690. ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
  2691. : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  2692. }
  2693. if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
  2694. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  2695. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  2696. if (objIsWrapped || othIsWrapped) {
  2697. var objUnwrapped = objIsWrapped ? object.value() : object,
  2698. othUnwrapped = othIsWrapped ? other.value() : other;
  2699. stack || (stack = new Stack);
  2700. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  2701. }
  2702. }
  2703. if (!isSameTag) {
  2704. return false;
  2705. }
  2706. stack || (stack = new Stack);
  2707. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  2708. }
  2709. /**
  2710. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  2711. *
  2712. * @private
  2713. * @param {Object} object The object to inspect.
  2714. * @param {Object} source The object of property values to match.
  2715. * @param {Array} matchData The property names, values, and compare flags to match.
  2716. * @param {Function} [customizer] The function to customize comparisons.
  2717. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  2718. */
  2719. function baseIsMatch(object, source, matchData, customizer) {
  2720. var index = matchData.length,
  2721. length = index,
  2722. noCustomizer = !customizer;
  2723. if (object == null) {
  2724. return !length;
  2725. }
  2726. object = Object(object);
  2727. while (index--) {
  2728. var data = matchData[index];
  2729. if ((noCustomizer && data[2])
  2730. ? data[1] !== object[data[0]]
  2731. : !(data[0] in object)
  2732. ) {
  2733. return false;
  2734. }
  2735. }
  2736. while (++index < length) {
  2737. data = matchData[index];
  2738. var key = data[0],
  2739. objValue = object[key],
  2740. srcValue = data[1];
  2741. if (noCustomizer && data[2]) {
  2742. if (objValue === undefined && !(key in object)) {
  2743. return false;
  2744. }
  2745. } else {
  2746. var stack = new Stack;
  2747. if (customizer) {
  2748. var result = customizer(objValue, srcValue, key, object, source, stack);
  2749. }
  2750. if (!(result === undefined
  2751. ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
  2752. : result
  2753. )) {
  2754. return false;
  2755. }
  2756. }
  2757. }
  2758. return true;
  2759. }
  2760. /**
  2761. * The base implementation of `_.isNative` without bad shim checks.
  2762. *
  2763. * @private
  2764. * @param {*} value The value to check.
  2765. * @returns {boolean} Returns `true` if `value` is a native function,
  2766. * else `false`.
  2767. */
  2768. function baseIsNative(value) {
  2769. if (!isObject(value) || isMasked(value)) {
  2770. return false;
  2771. }
  2772. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  2773. return pattern.test(toSource(value));
  2774. }
  2775. /**
  2776. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  2777. *
  2778. * @private
  2779. * @param {*} value The value to check.
  2780. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  2781. */
  2782. function baseIsTypedArray(value) {
  2783. return isObjectLike(value) &&
  2784. isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  2785. }
  2786. /**
  2787. * The base implementation of `_.iteratee`.
  2788. *
  2789. * @private
  2790. * @param {*} [value=_.identity] The value to convert to an iteratee.
  2791. * @returns {Function} Returns the iteratee.
  2792. */
  2793. function baseIteratee(value) {
  2794. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  2795. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  2796. if (typeof value == 'function') {
  2797. return value;
  2798. }
  2799. if (value == null) {
  2800. return identity;
  2801. }
  2802. if (typeof value == 'object') {
  2803. return isArray(value)
  2804. ? baseMatchesProperty(value[0], value[1])
  2805. : baseMatches(value);
  2806. }
  2807. return property(value);
  2808. }
  2809. /**
  2810. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  2811. *
  2812. * @private
  2813. * @param {Object} object The object to query.
  2814. * @returns {Array} Returns the array of property names.
  2815. */
  2816. function baseKeys(object) {
  2817. if (!isPrototype(object)) {
  2818. return nativeKeys(object);
  2819. }
  2820. var result = [];
  2821. for (var key in Object(object)) {
  2822. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  2823. result.push(key);
  2824. }
  2825. }
  2826. return result;
  2827. }
  2828. /**
  2829. * The base implementation of `_.matches` which doesn't clone `source`.
  2830. *
  2831. * @private
  2832. * @param {Object} source The object of property values to match.
  2833. * @returns {Function} Returns the new spec function.
  2834. */
  2835. function baseMatches(source) {
  2836. var matchData = getMatchData(source);
  2837. if (matchData.length == 1 && matchData[0][2]) {
  2838. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  2839. }
  2840. return function(object) {
  2841. return object === source || baseIsMatch(object, source, matchData);
  2842. };
  2843. }
  2844. /**
  2845. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  2846. *
  2847. * @private
  2848. * @param {string} path The path of the property to get.
  2849. * @param {*} srcValue The value to match.
  2850. * @returns {Function} Returns the new spec function.
  2851. */
  2852. function baseMatchesProperty(path, srcValue) {
  2853. if (isKey(path) && isStrictComparable(srcValue)) {
  2854. return matchesStrictComparable(toKey(path), srcValue);
  2855. }
  2856. return function(object) {
  2857. var objValue = get(object, path);
  2858. return (objValue === undefined && objValue === srcValue)
  2859. ? hasIn(object, path)
  2860. : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
  2861. };
  2862. }
  2863. /**
  2864. * A specialized version of `baseProperty` which supports deep paths.
  2865. *
  2866. * @private
  2867. * @param {Array|string} path The path of the property to get.
  2868. * @returns {Function} Returns the new accessor function.
  2869. */
  2870. function basePropertyDeep(path) {
  2871. return function(object) {
  2872. return baseGet(object, path);
  2873. };
  2874. }
  2875. /**
  2876. * The base implementation of `_.pullAt` without support for individual
  2877. * indexes or capturing the removed elements.
  2878. *
  2879. * @private
  2880. * @param {Array} array The array to modify.
  2881. * @param {number[]} indexes The indexes of elements to remove.
  2882. * @returns {Array} Returns `array`.
  2883. */
  2884. function basePullAt(array, indexes) {
  2885. var length = array ? indexes.length : 0,
  2886. lastIndex = length - 1;
  2887. while (length--) {
  2888. var index = indexes[length];
  2889. if (length == lastIndex || index !== previous) {
  2890. var previous = index;
  2891. if (isIndex(index)) {
  2892. splice.call(array, index, 1);
  2893. }
  2894. else if (!isKey(index, array)) {
  2895. var path = castPath(index),
  2896. object = parent(array, path);
  2897. if (object != null) {
  2898. delete object[toKey(last(path))];
  2899. }
  2900. }
  2901. else {
  2902. delete array[toKey(index)];
  2903. }
  2904. }
  2905. }
  2906. return array;
  2907. }
  2908. /**
  2909. * The base implementation of `_.slice` without an iteratee call guard.
  2910. *
  2911. * @private
  2912. * @param {Array} array The array to slice.
  2913. * @param {number} [start=0] The start position.
  2914. * @param {number} [end=array.length] The end position.
  2915. * @returns {Array} Returns the slice of `array`.
  2916. */
  2917. function baseSlice(array, start, end) {
  2918. var index = -1,
  2919. length = array.length;
  2920. if (start < 0) {
  2921. start = -start > length ? 0 : (length + start);
  2922. }
  2923. end = end > length ? length : end;
  2924. if (end < 0) {
  2925. end += length;
  2926. }
  2927. length = start > end ? 0 : ((end - start) >>> 0);
  2928. start >>>= 0;
  2929. var result = Array(length);
  2930. while (++index < length) {
  2931. result[index] = array[index + start];
  2932. }
  2933. return result;
  2934. }
  2935. /**
  2936. * The base implementation of `_.toString` which doesn't convert nullish
  2937. * values to empty strings.
  2938. *
  2939. * @private
  2940. * @param {*} value The value to process.
  2941. * @returns {string} Returns the string.
  2942. */
  2943. function baseToString(value) {
  2944. // Exit early for strings to avoid a performance hit in some environments.
  2945. if (typeof value == 'string') {
  2946. return value;
  2947. }
  2948. if (isSymbol(value)) {
  2949. return symbolToString ? symbolToString.call(value) : '';
  2950. }
  2951. var result = (value + '');
  2952. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  2953. }
  2954. /**
  2955. * Casts `value` to a path array if it's not one.
  2956. *
  2957. * @private
  2958. * @param {*} value The value to inspect.
  2959. * @returns {Array} Returns the cast property path array.
  2960. */
  2961. function castPath(value) {
  2962. return isArray(value) ? value : stringToPath(value);
  2963. }
  2964. /**
  2965. * A specialized version of `baseIsEqualDeep` for arrays with support for
  2966. * partial deep comparisons.
  2967. *
  2968. * @private
  2969. * @param {Array} array The array to compare.
  2970. * @param {Array} other The other array to compare.
  2971. * @param {Function} equalFunc The function to determine equivalents of values.
  2972. * @param {Function} customizer The function to customize comparisons.
  2973. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  2974. * for more details.
  2975. * @param {Object} stack Tracks traversed `array` and `other` objects.
  2976. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  2977. */
  2978. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  2979. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  2980. arrLength = array.length,
  2981. othLength = other.length;
  2982. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  2983. return false;
  2984. }
  2985. // Assume cyclic values are equal.
  2986. var stacked = stack.get(array);
  2987. if (stacked && stack.get(other)) {
  2988. return stacked == other;
  2989. }
  2990. var index = -1,
  2991. result = true,
  2992. seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
  2993. stack.set(array, other);
  2994. stack.set(other, array);
  2995. // Ignore non-index properties.
  2996. while (++index < arrLength) {
  2997. var arrValue = array[index],
  2998. othValue = other[index];
  2999. if (customizer) {
  3000. var compared = isPartial
  3001. ? customizer(othValue, arrValue, index, other, array, stack)
  3002. : customizer(arrValue, othValue, index, array, other, stack);
  3003. }
  3004. if (compared !== undefined) {
  3005. if (compared) {
  3006. continue;
  3007. }
  3008. result = false;
  3009. break;
  3010. }
  3011. // Recursively compare arrays (susceptible to call stack limits).
  3012. if (seen) {
  3013. if (!arraySome(other, function(othValue, othIndex) {
  3014. if (!seen.has(othIndex) &&
  3015. (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  3016. return seen.add(othIndex);
  3017. }
  3018. })) {
  3019. result = false;
  3020. break;
  3021. }
  3022. } else if (!(
  3023. arrValue === othValue ||
  3024. equalFunc(arrValue, othValue, customizer, bitmask, stack)
  3025. )) {
  3026. result = false;
  3027. break;
  3028. }
  3029. }
  3030. stack['delete'](array);
  3031. stack['delete'](other);
  3032. return result;
  3033. }
  3034. /**
  3035. * A specialized version of `baseIsEqualDeep` for comparing objects of
  3036. * the same `toStringTag`.
  3037. *
  3038. * **Note:** This function only supports comparing values with tags of
  3039. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  3040. *
  3041. * @private
  3042. * @param {Object} object The object to compare.
  3043. * @param {Object} other The other object to compare.
  3044. * @param {string} tag The `toStringTag` of the objects to compare.
  3045. * @param {Function} equalFunc The function to determine equivalents of values.
  3046. * @param {Function} customizer The function to customize comparisons.
  3047. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3048. * for more details.
  3049. * @param {Object} stack Tracks traversed `object` and `other` objects.
  3050. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3051. */
  3052. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  3053. switch (tag) {
  3054. case dataViewTag:
  3055. if ((object.byteLength != other.byteLength) ||
  3056. (object.byteOffset != other.byteOffset)) {
  3057. return false;
  3058. }
  3059. object = object.buffer;
  3060. other = other.buffer;
  3061. case arrayBufferTag:
  3062. if ((object.byteLength != other.byteLength) ||
  3063. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  3064. return false;
  3065. }
  3066. return true;
  3067. case boolTag:
  3068. case dateTag:
  3069. case numberTag:
  3070. // Coerce booleans to `1` or `0` and dates to milliseconds.
  3071. // Invalid dates are coerced to `NaN`.
  3072. return eq(+object, +other);
  3073. case errorTag:
  3074. return object.name == other.name && object.message == other.message;
  3075. case regexpTag:
  3076. case stringTag:
  3077. // Coerce regexes to strings and treat strings, primitives and objects,
  3078. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  3079. // for more details.
  3080. return object == (other + '');
  3081. case mapTag:
  3082. var convert = mapToArray;
  3083. case setTag:
  3084. var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
  3085. convert || (convert = setToArray);
  3086. if (object.size != other.size && !isPartial) {
  3087. return false;
  3088. }
  3089. // Assume cyclic values are equal.
  3090. var stacked = stack.get(object);
  3091. if (stacked) {
  3092. return stacked == other;
  3093. }
  3094. bitmask |= UNORDERED_COMPARE_FLAG;
  3095. // Recursively compare objects (susceptible to call stack limits).
  3096. stack.set(object, other);
  3097. var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  3098. stack['delete'](object);
  3099. return result;
  3100. case symbolTag:
  3101. if (symbolValueOf) {
  3102. return symbolValueOf.call(object) == symbolValueOf.call(other);
  3103. }
  3104. }
  3105. return false;
  3106. }
  3107. /**
  3108. * A specialized version of `baseIsEqualDeep` for objects with support for
  3109. * partial deep comparisons.
  3110. *
  3111. * @private
  3112. * @param {Object} object The object to compare.
  3113. * @param {Object} other The other object to compare.
  3114. * @param {Function} equalFunc The function to determine equivalents of values.
  3115. * @param {Function} customizer The function to customize comparisons.
  3116. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3117. * for more details.
  3118. * @param {Object} stack Tracks traversed `object` and `other` objects.
  3119. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3120. */
  3121. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  3122. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  3123. objProps = keys(object),
  3124. objLength = objProps.length,
  3125. othProps = keys(other),
  3126. othLength = othProps.length;
  3127. if (objLength != othLength && !isPartial) {
  3128. return false;
  3129. }
  3130. var index = objLength;
  3131. while (index--) {
  3132. var key = objProps[index];
  3133. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  3134. return false;
  3135. }
  3136. }
  3137. // Assume cyclic values are equal.
  3138. var stacked = stack.get(object);
  3139. if (stacked && stack.get(other)) {
  3140. return stacked == other;
  3141. }
  3142. var result = true;
  3143. stack.set(object, other);
  3144. stack.set(other, object);
  3145. var skipCtor = isPartial;
  3146. while (++index < objLength) {
  3147. key = objProps[index];
  3148. var objValue = object[key],
  3149. othValue = other[key];
  3150. if (customizer) {
  3151. var compared = isPartial
  3152. ? customizer(othValue, objValue, key, other, object, stack)
  3153. : customizer(objValue, othValue, key, object, other, stack);
  3154. }
  3155. // Recursively compare objects (susceptible to call stack limits).
  3156. if (!(compared === undefined
  3157. ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
  3158. : compared
  3159. )) {
  3160. result = false;
  3161. break;
  3162. }
  3163. skipCtor || (skipCtor = key == 'constructor');
  3164. }
  3165. if (result && !skipCtor) {
  3166. var objCtor = object.constructor,
  3167. othCtor = other.constructor;
  3168. // Non `Object` object instances with different constructors are not equal.
  3169. if (objCtor != othCtor &&
  3170. ('constructor' in object && 'constructor' in other) &&
  3171. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  3172. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  3173. result = false;
  3174. }
  3175. }
  3176. stack['delete'](object);
  3177. stack['delete'](other);
  3178. return result;
  3179. }
  3180. /**
  3181. * Gets the data for `map`.
  3182. *
  3183. * @private
  3184. * @param {Object} map The map to query.
  3185. * @param {string} key The reference key.
  3186. * @returns {*} Returns the map data.
  3187. */
  3188. function getMapData(map, key) {
  3189. var data = map.__data__;
  3190. return isKeyable(key)
  3191. ? data[typeof key == 'string' ? 'string' : 'hash']
  3192. : data.map;
  3193. }
  3194. /**
  3195. * Gets the property names, values, and compare flags of `object`.
  3196. *
  3197. * @private
  3198. * @param {Object} object The object to query.
  3199. * @returns {Array} Returns the match data of `object`.
  3200. */
  3201. function getMatchData(object) {
  3202. var result = keys(object),
  3203. length = result.length;
  3204. while (length--) {
  3205. var key = result[length],
  3206. value = object[key];
  3207. result[length] = [key, value, isStrictComparable(value)];
  3208. }
  3209. return result;
  3210. }
  3211. /**
  3212. * Gets the native function at `key` of `object`.
  3213. *
  3214. * @private
  3215. * @param {Object} object The object to query.
  3216. * @param {string} key The key of the method to get.
  3217. * @returns {*} Returns the function if it's native, else `undefined`.
  3218. */
  3219. function getNative(object, key) {
  3220. var value = getValue(object, key);
  3221. return baseIsNative(value) ? value : undefined;
  3222. }
  3223. /**
  3224. * Gets the `toStringTag` of `value`.
  3225. *
  3226. * @private
  3227. * @param {*} value The value to query.
  3228. * @returns {string} Returns the `toStringTag`.
  3229. */
  3230. var getTag = baseGetTag;
  3231. // Fallback for data views, maps, sets, and weak maps in IE 11,
  3232. // for data views in Edge < 14, and promises in Node.js.
  3233. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  3234. (Map && getTag(new Map) != mapTag) ||
  3235. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  3236. (Set && getTag(new Set) != setTag) ||
  3237. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  3238. getTag = function(value) {
  3239. var result = objectToString.call(value),
  3240. Ctor = result == objectTag ? value.constructor : undefined,
  3241. ctorString = Ctor ? toSource(Ctor) : undefined;
  3242. if (ctorString) {
  3243. switch (ctorString) {
  3244. case dataViewCtorString: return dataViewTag;
  3245. case mapCtorString: return mapTag;
  3246. case promiseCtorString: return promiseTag;
  3247. case setCtorString: return setTag;
  3248. case weakMapCtorString: return weakMapTag;
  3249. }
  3250. }
  3251. return result;
  3252. };
  3253. }
  3254. /**
  3255. * Checks if `path` exists on `object`.
  3256. *
  3257. * @private
  3258. * @param {Object} object The object to query.
  3259. * @param {Array|string} path The path to check.
  3260. * @param {Function} hasFunc The function to check properties.
  3261. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  3262. */
  3263. function hasPath(object, path, hasFunc) {
  3264. path = isKey(path, object) ? [path] : castPath(path);
  3265. var result,
  3266. index = -1,
  3267. length = path.length;
  3268. while (++index < length) {
  3269. var key = toKey(path[index]);
  3270. if (!(result = object != null && hasFunc(object, key))) {
  3271. break;
  3272. }
  3273. object = object[key];
  3274. }
  3275. if (result) {
  3276. return result;
  3277. }
  3278. var length = object ? object.length : 0;
  3279. return !!length && isLength(length) && isIndex(key, length) &&
  3280. (isArray(object) || isArguments(object));
  3281. }
  3282. /**
  3283. * Checks if `value` is a valid array-like index.
  3284. *
  3285. * @private
  3286. * @param {*} value The value to check.
  3287. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  3288. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  3289. */
  3290. function isIndex(value, length) {
  3291. length = length == null ? MAX_SAFE_INTEGER : length;
  3292. return !!length &&
  3293. (typeof value == 'number' || reIsUint.test(value)) &&
  3294. (value > -1 && value % 1 == 0 && value < length);
  3295. }
  3296. /**
  3297. * Checks if `value` is a property name and not a property path.
  3298. *
  3299. * @private
  3300. * @param {*} value The value to check.
  3301. * @param {Object} [object] The object to query keys on.
  3302. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  3303. */
  3304. function isKey(value, object) {
  3305. if (isArray(value)) {
  3306. return false;
  3307. }
  3308. var type = typeof value;
  3309. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  3310. value == null || isSymbol(value)) {
  3311. return true;
  3312. }
  3313. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  3314. (object != null && value in Object(object));
  3315. }
  3316. /**
  3317. * Checks if `value` is suitable for use as unique object key.
  3318. *
  3319. * @private
  3320. * @param {*} value The value to check.
  3321. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  3322. */
  3323. function isKeyable(value) {
  3324. var type = typeof value;
  3325. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  3326. ? (value !== '__proto__')
  3327. : (value === null);
  3328. }
  3329. /**
  3330. * Checks if `func` has its source masked.
  3331. *
  3332. * @private
  3333. * @param {Function} func The function to check.
  3334. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  3335. */
  3336. function isMasked(func) {
  3337. return !!maskSrcKey && (maskSrcKey in func);
  3338. }
  3339. /**
  3340. * Checks if `value` is likely a prototype object.
  3341. *
  3342. * @private
  3343. * @param {*} value The value to check.
  3344. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  3345. */
  3346. function isPrototype(value) {
  3347. var Ctor = value && value.constructor,
  3348. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  3349. return value === proto;
  3350. }
  3351. /**
  3352. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  3353. *
  3354. * @private
  3355. * @param {*} value The value to check.
  3356. * @returns {boolean} Returns `true` if `value` if suitable for strict
  3357. * equality comparisons, else `false`.
  3358. */
  3359. function isStrictComparable(value) {
  3360. return value === value && !isObject(value);
  3361. }
  3362. /**
  3363. * A specialized version of `matchesProperty` for source values suitable
  3364. * for strict equality comparisons, i.e. `===`.
  3365. *
  3366. * @private
  3367. * @param {string} key The key of the property to get.
  3368. * @param {*} srcValue The value to match.
  3369. * @returns {Function} Returns the new spec function.
  3370. */
  3371. function matchesStrictComparable(key, srcValue) {
  3372. return function(object) {
  3373. if (object == null) {
  3374. return false;
  3375. }
  3376. return object[key] === srcValue &&
  3377. (srcValue !== undefined || (key in Object(object)));
  3378. };
  3379. }
  3380. /**
  3381. * Gets the parent value at `path` of `object`.
  3382. *
  3383. * @private
  3384. * @param {Object} object The object to query.
  3385. * @param {Array} path The path to get the parent value of.
  3386. * @returns {*} Returns the parent value.
  3387. */
  3388. function parent(object, path) {
  3389. return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  3390. }
  3391. /**
  3392. * Converts `string` to a property path array.
  3393. *
  3394. * @private
  3395. * @param {string} string The string to convert.
  3396. * @returns {Array} Returns the property path array.
  3397. */
  3398. var stringToPath = memoize(function(string) {
  3399. string = toString(string);
  3400. var result = [];
  3401. if (reLeadingDot.test(string)) {
  3402. result.push('');
  3403. }
  3404. string.replace(rePropName, function(match, number, quote, string) {
  3405. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  3406. });
  3407. return result;
  3408. });
  3409. /**
  3410. * Converts `value` to a string key if it's not a string or symbol.
  3411. *
  3412. * @private
  3413. * @param {*} value The value to inspect.
  3414. * @returns {string|symbol} Returns the key.
  3415. */
  3416. function toKey(value) {
  3417. if (typeof value == 'string' || isSymbol(value)) {
  3418. return value;
  3419. }
  3420. var result = (value + '');
  3421. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  3422. }
  3423. /**
  3424. * Converts `func` to its source code.
  3425. *
  3426. * @private
  3427. * @param {Function} func The function to process.
  3428. * @returns {string} Returns the source code.
  3429. */
  3430. function toSource(func) {
  3431. if (func != null) {
  3432. try {
  3433. return funcToString.call(func);
  3434. } catch (e) {}
  3435. try {
  3436. return (func + '');
  3437. } catch (e) {}
  3438. }
  3439. return '';
  3440. }
  3441. /**
  3442. * Gets the last element of `array`.
  3443. *
  3444. * @static
  3445. * @memberOf _
  3446. * @since 0.1.0
  3447. * @category Array
  3448. * @param {Array} array The array to query.
  3449. * @returns {*} Returns the last element of `array`.
  3450. * @example
  3451. *
  3452. * _.last([1, 2, 3]);
  3453. * // => 3
  3454. */
  3455. function last(array) {
  3456. var length = array ? array.length : 0;
  3457. return length ? array[length - 1] : undefined;
  3458. }
  3459. /**
  3460. * Removes all elements from `array` that `predicate` returns truthy for
  3461. * and returns an array of the removed elements. The predicate is invoked
  3462. * with three arguments: (value, index, array).
  3463. *
  3464. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  3465. * to pull elements from an array by value.
  3466. *
  3467. * @static
  3468. * @memberOf _
  3469. * @since 2.0.0
  3470. * @category Array
  3471. * @param {Array} array The array to modify.
  3472. * @param {Function} [predicate=_.identity]
  3473. * The function invoked per iteration.
  3474. * @returns {Array} Returns the new array of removed elements.
  3475. * @example
  3476. *
  3477. * var array = [1, 2, 3, 4];
  3478. * var evens = _.remove(array, function(n) {
  3479. * return n % 2 == 0;
  3480. * });
  3481. *
  3482. * console.log(array);
  3483. * // => [1, 3]
  3484. *
  3485. * console.log(evens);
  3486. * // => [2, 4]
  3487. */
  3488. function remove(array, predicate) {
  3489. var result = [];
  3490. if (!(array && array.length)) {
  3491. return result;
  3492. }
  3493. var index = -1,
  3494. indexes = [],
  3495. length = array.length;
  3496. predicate = baseIteratee(predicate, 3);
  3497. while (++index < length) {
  3498. var value = array[index];
  3499. if (predicate(value, index, array)) {
  3500. result.push(value);
  3501. indexes.push(index);
  3502. }
  3503. }
  3504. basePullAt(array, indexes);
  3505. return result;
  3506. }
  3507. /**
  3508. * Creates a function that memoizes the result of `func`. If `resolver` is
  3509. * provided, it determines the cache key for storing the result based on the
  3510. * arguments provided to the memoized function. By default, the first argument
  3511. * provided to the memoized function is used as the map cache key. The `func`
  3512. * is invoked with the `this` binding of the memoized function.
  3513. *
  3514. * **Note:** The cache is exposed as the `cache` property on the memoized
  3515. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  3516. * constructor with one whose instances implement the
  3517. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  3518. * method interface of `delete`, `get`, `has`, and `set`.
  3519. *
  3520. * @static
  3521. * @memberOf _
  3522. * @since 0.1.0
  3523. * @category Function
  3524. * @param {Function} func The function to have its output memoized.
  3525. * @param {Function} [resolver] The function to resolve the cache key.
  3526. * @returns {Function} Returns the new memoized function.
  3527. * @example
  3528. *
  3529. * var object = { 'a': 1, 'b': 2 };
  3530. * var other = { 'c': 3, 'd': 4 };
  3531. *
  3532. * var values = _.memoize(_.values);
  3533. * values(object);
  3534. * // => [1, 2]
  3535. *
  3536. * values(other);
  3537. * // => [3, 4]
  3538. *
  3539. * object.a = 2;
  3540. * values(object);
  3541. * // => [1, 2]
  3542. *
  3543. * // Modify the result cache.
  3544. * values.cache.set(object, ['a', 'b']);
  3545. * values(object);
  3546. * // => ['a', 'b']
  3547. *
  3548. * // Replace `_.memoize.Cache`.
  3549. * _.memoize.Cache = WeakMap;
  3550. */
  3551. function memoize(func, resolver) {
  3552. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  3553. throw new TypeError(FUNC_ERROR_TEXT);
  3554. }
  3555. var memoized = function() {
  3556. var args = arguments,
  3557. key = resolver ? resolver.apply(this, args) : args[0],
  3558. cache = memoized.cache;
  3559. if (cache.has(key)) {
  3560. return cache.get(key);
  3561. }
  3562. var result = func.apply(this, args);
  3563. memoized.cache = cache.set(key, result);
  3564. return result;
  3565. };
  3566. memoized.cache = new (memoize.Cache || MapCache);
  3567. return memoized;
  3568. }
  3569. // Assign cache to `_.memoize`.
  3570. memoize.Cache = MapCache;
  3571. /**
  3572. * Performs a
  3573. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3574. * comparison between two values to determine if they are equivalent.
  3575. *
  3576. * @static
  3577. * @memberOf _
  3578. * @since 4.0.0
  3579. * @category Lang
  3580. * @param {*} value The value to compare.
  3581. * @param {*} other The other value to compare.
  3582. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3583. * @example
  3584. *
  3585. * var object = { 'a': 1 };
  3586. * var other = { 'a': 1 };
  3587. *
  3588. * _.eq(object, object);
  3589. * // => true
  3590. *
  3591. * _.eq(object, other);
  3592. * // => false
  3593. *
  3594. * _.eq('a', 'a');
  3595. * // => true
  3596. *
  3597. * _.eq('a', Object('a'));
  3598. * // => false
  3599. *
  3600. * _.eq(NaN, NaN);
  3601. * // => true
  3602. */
  3603. function eq(value, other) {
  3604. return value === other || (value !== value && other !== other);
  3605. }
  3606. /**
  3607. * Checks if `value` is likely an `arguments` object.
  3608. *
  3609. * @static
  3610. * @memberOf _
  3611. * @since 0.1.0
  3612. * @category Lang
  3613. * @param {*} value The value to check.
  3614. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  3615. * else `false`.
  3616. * @example
  3617. *
  3618. * _.isArguments(function() { return arguments; }());
  3619. * // => true
  3620. *
  3621. * _.isArguments([1, 2, 3]);
  3622. * // => false
  3623. */
  3624. function isArguments(value) {
  3625. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  3626. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  3627. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  3628. }
  3629. /**
  3630. * Checks if `value` is classified as an `Array` object.
  3631. *
  3632. * @static
  3633. * @memberOf _
  3634. * @since 0.1.0
  3635. * @category Lang
  3636. * @param {*} value The value to check.
  3637. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  3638. * @example
  3639. *
  3640. * _.isArray([1, 2, 3]);
  3641. * // => true
  3642. *
  3643. * _.isArray(document.body.children);
  3644. * // => false
  3645. *
  3646. * _.isArray('abc');
  3647. * // => false
  3648. *
  3649. * _.isArray(_.noop);
  3650. * // => false
  3651. */
  3652. var isArray = Array.isArray;
  3653. /**
  3654. * Checks if `value` is array-like. A value is considered array-like if it's
  3655. * not a function and has a `value.length` that's an integer greater than or
  3656. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  3657. *
  3658. * @static
  3659. * @memberOf _
  3660. * @since 4.0.0
  3661. * @category Lang
  3662. * @param {*} value The value to check.
  3663. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  3664. * @example
  3665. *
  3666. * _.isArrayLike([1, 2, 3]);
  3667. * // => true
  3668. *
  3669. * _.isArrayLike(document.body.children);
  3670. * // => true
  3671. *
  3672. * _.isArrayLike('abc');
  3673. * // => true
  3674. *
  3675. * _.isArrayLike(_.noop);
  3676. * // => false
  3677. */
  3678. function isArrayLike(value) {
  3679. return value != null && isLength(value.length) && !isFunction(value);
  3680. }
  3681. /**
  3682. * This method is like `_.isArrayLike` except that it also checks if `value`
  3683. * is an object.
  3684. *
  3685. * @static
  3686. * @memberOf _
  3687. * @since 4.0.0
  3688. * @category Lang
  3689. * @param {*} value The value to check.
  3690. * @returns {boolean} Returns `true` if `value` is an array-like object,
  3691. * else `false`.
  3692. * @example
  3693. *
  3694. * _.isArrayLikeObject([1, 2, 3]);
  3695. * // => true
  3696. *
  3697. * _.isArrayLikeObject(document.body.children);
  3698. * // => true
  3699. *
  3700. * _.isArrayLikeObject('abc');
  3701. * // => false
  3702. *
  3703. * _.isArrayLikeObject(_.noop);
  3704. * // => false
  3705. */
  3706. function isArrayLikeObject(value) {
  3707. return isObjectLike(value) && isArrayLike(value);
  3708. }
  3709. /**
  3710. * Checks if `value` is classified as a `Function` object.
  3711. *
  3712. * @static
  3713. * @memberOf _
  3714. * @since 0.1.0
  3715. * @category Lang
  3716. * @param {*} value The value to check.
  3717. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  3718. * @example
  3719. *
  3720. * _.isFunction(_);
  3721. * // => true
  3722. *
  3723. * _.isFunction(/abc/);
  3724. * // => false
  3725. */
  3726. function isFunction(value) {
  3727. // The use of `Object#toString` avoids issues with the `typeof` operator
  3728. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  3729. var tag = isObject(value) ? objectToString.call(value) : '';
  3730. return tag == funcTag || tag == genTag;
  3731. }
  3732. /**
  3733. * Checks if `value` is a valid array-like length.
  3734. *
  3735. * **Note:** This method is loosely based on
  3736. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  3737. *
  3738. * @static
  3739. * @memberOf _
  3740. * @since 4.0.0
  3741. * @category Lang
  3742. * @param {*} value The value to check.
  3743. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  3744. * @example
  3745. *
  3746. * _.isLength(3);
  3747. * // => true
  3748. *
  3749. * _.isLength(Number.MIN_VALUE);
  3750. * // => false
  3751. *
  3752. * _.isLength(Infinity);
  3753. * // => false
  3754. *
  3755. * _.isLength('3');
  3756. * // => false
  3757. */
  3758. function isLength(value) {
  3759. return typeof value == 'number' &&
  3760. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  3761. }
  3762. /**
  3763. * Checks if `value` is the
  3764. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  3765. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  3766. *
  3767. * @static
  3768. * @memberOf _
  3769. * @since 0.1.0
  3770. * @category Lang
  3771. * @param {*} value The value to check.
  3772. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  3773. * @example
  3774. *
  3775. * _.isObject({});
  3776. * // => true
  3777. *
  3778. * _.isObject([1, 2, 3]);
  3779. * // => true
  3780. *
  3781. * _.isObject(_.noop);
  3782. * // => true
  3783. *
  3784. * _.isObject(null);
  3785. * // => false
  3786. */
  3787. function isObject(value) {
  3788. var type = typeof value;
  3789. return !!value && (type == 'object' || type == 'function');
  3790. }
  3791. /**
  3792. * Checks if `value` is object-like. A value is object-like if it's not `null`
  3793. * and has a `typeof` result of "object".
  3794. *
  3795. * @static
  3796. * @memberOf _
  3797. * @since 4.0.0
  3798. * @category Lang
  3799. * @param {*} value The value to check.
  3800. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  3801. * @example
  3802. *
  3803. * _.isObjectLike({});
  3804. * // => true
  3805. *
  3806. * _.isObjectLike([1, 2, 3]);
  3807. * // => true
  3808. *
  3809. * _.isObjectLike(_.noop);
  3810. * // => false
  3811. *
  3812. * _.isObjectLike(null);
  3813. * // => false
  3814. */
  3815. function isObjectLike(value) {
  3816. return !!value && typeof value == 'object';
  3817. }
  3818. /**
  3819. * Checks if `value` is classified as a `Symbol` primitive or object.
  3820. *
  3821. * @static
  3822. * @memberOf _
  3823. * @since 4.0.0
  3824. * @category Lang
  3825. * @param {*} value The value to check.
  3826. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  3827. * @example
  3828. *
  3829. * _.isSymbol(Symbol.iterator);
  3830. * // => true
  3831. *
  3832. * _.isSymbol('abc');
  3833. * // => false
  3834. */
  3835. function isSymbol(value) {
  3836. return typeof value == 'symbol' ||
  3837. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  3838. }
  3839. /**
  3840. * Checks if `value` is classified as a typed array.
  3841. *
  3842. * @static
  3843. * @memberOf _
  3844. * @since 3.0.0
  3845. * @category Lang
  3846. * @param {*} value The value to check.
  3847. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3848. * @example
  3849. *
  3850. * _.isTypedArray(new Uint8Array);
  3851. * // => true
  3852. *
  3853. * _.isTypedArray([]);
  3854. * // => false
  3855. */
  3856. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  3857. /**
  3858. * Converts `value` to a string. An empty string is returned for `null`
  3859. * and `undefined` values. The sign of `-0` is preserved.
  3860. *
  3861. * @static
  3862. * @memberOf _
  3863. * @since 4.0.0
  3864. * @category Lang
  3865. * @param {*} value The value to process.
  3866. * @returns {string} Returns the string.
  3867. * @example
  3868. *
  3869. * _.toString(null);
  3870. * // => ''
  3871. *
  3872. * _.toString(-0);
  3873. * // => '-0'
  3874. *
  3875. * _.toString([1, 2, 3]);
  3876. * // => '1,2,3'
  3877. */
  3878. function toString(value) {
  3879. return value == null ? '' : baseToString(value);
  3880. }
  3881. /**
  3882. * Gets the value at `path` of `object`. If the resolved value is
  3883. * `undefined`, the `defaultValue` is returned in its place.
  3884. *
  3885. * @static
  3886. * @memberOf _
  3887. * @since 3.7.0
  3888. * @category Object
  3889. * @param {Object} object The object to query.
  3890. * @param {Array|string} path The path of the property to get.
  3891. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  3892. * @returns {*} Returns the resolved value.
  3893. * @example
  3894. *
  3895. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  3896. *
  3897. * _.get(object, 'a[0].b.c');
  3898. * // => 3
  3899. *
  3900. * _.get(object, ['a', '0', 'b', 'c']);
  3901. * // => 3
  3902. *
  3903. * _.get(object, 'a.b.c', 'default');
  3904. * // => 'default'
  3905. */
  3906. function get(object, path, defaultValue) {
  3907. var result = object == null ? undefined : baseGet(object, path);
  3908. return result === undefined ? defaultValue : result;
  3909. }
  3910. /**
  3911. * Checks if `path` is a direct or inherited property of `object`.
  3912. *
  3913. * @static
  3914. * @memberOf _
  3915. * @since 4.0.0
  3916. * @category Object
  3917. * @param {Object} object The object to query.
  3918. * @param {Array|string} path The path to check.
  3919. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  3920. * @example
  3921. *
  3922. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  3923. *
  3924. * _.hasIn(object, 'a');
  3925. * // => true
  3926. *
  3927. * _.hasIn(object, 'a.b');
  3928. * // => true
  3929. *
  3930. * _.hasIn(object, ['a', 'b']);
  3931. * // => true
  3932. *
  3933. * _.hasIn(object, 'b');
  3934. * // => false
  3935. */
  3936. function hasIn(object, path) {
  3937. return object != null && hasPath(object, path, baseHasIn);
  3938. }
  3939. /**
  3940. * Creates an array of the own enumerable property names of `object`.
  3941. *
  3942. * **Note:** Non-object values are coerced to objects. See the
  3943. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  3944. * for more details.
  3945. *
  3946. * @static
  3947. * @since 0.1.0
  3948. * @memberOf _
  3949. * @category Object
  3950. * @param {Object} object The object to query.
  3951. * @returns {Array} Returns the array of property names.
  3952. * @example
  3953. *
  3954. * function Foo() {
  3955. * this.a = 1;
  3956. * this.b = 2;
  3957. * }
  3958. *
  3959. * Foo.prototype.c = 3;
  3960. *
  3961. * _.keys(new Foo);
  3962. * // => ['a', 'b'] (iteration order is not guaranteed)
  3963. *
  3964. * _.keys('hi');
  3965. * // => ['0', '1']
  3966. */
  3967. function keys(object) {
  3968. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  3969. }
  3970. /**
  3971. * This method returns the first argument it receives.
  3972. *
  3973. * @static
  3974. * @since 0.1.0
  3975. * @memberOf _
  3976. * @category Util
  3977. * @param {*} value Any value.
  3978. * @returns {*} Returns `value`.
  3979. * @example
  3980. *
  3981. * var object = { 'a': 1 };
  3982. *
  3983. * console.log(_.identity(object) === object);
  3984. * // => true
  3985. */
  3986. function identity(value) {
  3987. return value;
  3988. }
  3989. /**
  3990. * Creates a function that returns the value at `path` of a given object.
  3991. *
  3992. * @static
  3993. * @memberOf _
  3994. * @since 2.4.0
  3995. * @category Util
  3996. * @param {Array|string} path The path of the property to get.
  3997. * @returns {Function} Returns the new accessor function.
  3998. * @example
  3999. *
  4000. * var objects = [
  4001. * { 'a': { 'b': 2 } },
  4002. * { 'a': { 'b': 1 } }
  4003. * ];
  4004. *
  4005. * _.map(objects, _.property('a.b'));
  4006. * // => [2, 1]
  4007. *
  4008. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  4009. * // => [1, 2]
  4010. */
  4011. function property(path) {
  4012. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  4013. }
  4014. module.exports = remove;
  4015. /***/ }),
  4016. /***/ "./node_modules/process/browser.js":
  4017. /*!*****************************************!*\
  4018. !*** ./node_modules/process/browser.js ***!
  4019. \*****************************************/
  4020. /***/ ((module) => {
  4021. // shim for using process in browser
  4022. var process = module.exports = {};
  4023. // cached from whatever global is present so that test runners that stub it
  4024. // don't break things. But we need to wrap it in a try catch in case it is
  4025. // wrapped in strict mode code which doesn't define any globals. It's inside a
  4026. // function because try/catches deoptimize in certain engines.
  4027. var cachedSetTimeout;
  4028. var cachedClearTimeout;
  4029. function defaultSetTimout() {
  4030. throw new Error('setTimeout has not been defined');
  4031. }
  4032. function defaultClearTimeout () {
  4033. throw new Error('clearTimeout has not been defined');
  4034. }
  4035. (function () {
  4036. try {
  4037. if (typeof setTimeout === 'function') {
  4038. cachedSetTimeout = setTimeout;
  4039. } else {
  4040. cachedSetTimeout = defaultSetTimout;
  4041. }
  4042. } catch (e) {
  4043. cachedSetTimeout = defaultSetTimout;
  4044. }
  4045. try {
  4046. if (typeof clearTimeout === 'function') {
  4047. cachedClearTimeout = clearTimeout;
  4048. } else {
  4049. cachedClearTimeout = defaultClearTimeout;
  4050. }
  4051. } catch (e) {
  4052. cachedClearTimeout = defaultClearTimeout;
  4053. }
  4054. } ())
  4055. function runTimeout(fun) {
  4056. if (cachedSetTimeout === setTimeout) {
  4057. //normal enviroments in sane situations
  4058. return setTimeout(fun, 0);
  4059. }
  4060. // if setTimeout wasn't available but was latter defined
  4061. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  4062. cachedSetTimeout = setTimeout;
  4063. return setTimeout(fun, 0);
  4064. }
  4065. try {
  4066. // when when somebody has screwed with setTimeout but no I.E. maddness
  4067. return cachedSetTimeout(fun, 0);
  4068. } catch(e){
  4069. try {
  4070. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4071. return cachedSetTimeout.call(null, fun, 0);
  4072. } catch(e){
  4073. // 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
  4074. return cachedSetTimeout.call(this, fun, 0);
  4075. }
  4076. }
  4077. }
  4078. function runClearTimeout(marker) {
  4079. if (cachedClearTimeout === clearTimeout) {
  4080. //normal enviroments in sane situations
  4081. return clearTimeout(marker);
  4082. }
  4083. // if clearTimeout wasn't available but was latter defined
  4084. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  4085. cachedClearTimeout = clearTimeout;
  4086. return clearTimeout(marker);
  4087. }
  4088. try {
  4089. // when when somebody has screwed with setTimeout but no I.E. maddness
  4090. return cachedClearTimeout(marker);
  4091. } catch (e){
  4092. try {
  4093. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4094. return cachedClearTimeout.call(null, marker);
  4095. } catch (e){
  4096. // 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.
  4097. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  4098. return cachedClearTimeout.call(this, marker);
  4099. }
  4100. }
  4101. }
  4102. var queue = [];
  4103. var draining = false;
  4104. var currentQueue;
  4105. var queueIndex = -1;
  4106. function cleanUpNextTick() {
  4107. if (!draining || !currentQueue) {
  4108. return;
  4109. }
  4110. draining = false;
  4111. if (currentQueue.length) {
  4112. queue = currentQueue.concat(queue);
  4113. } else {
  4114. queueIndex = -1;
  4115. }
  4116. if (queue.length) {
  4117. drainQueue();
  4118. }
  4119. }
  4120. function drainQueue() {
  4121. if (draining) {
  4122. return;
  4123. }
  4124. var timeout = runTimeout(cleanUpNextTick);
  4125. draining = true;
  4126. var len = queue.length;
  4127. while(len) {
  4128. currentQueue = queue;
  4129. queue = [];
  4130. while (++queueIndex < len) {
  4131. if (currentQueue) {
  4132. currentQueue[queueIndex].run();
  4133. }
  4134. }
  4135. queueIndex = -1;
  4136. len = queue.length;
  4137. }
  4138. currentQueue = null;
  4139. draining = false;
  4140. runClearTimeout(timeout);
  4141. }
  4142. process.nextTick = function (fun) {
  4143. var args = new Array(arguments.length - 1);
  4144. if (arguments.length > 1) {
  4145. for (var i = 1; i < arguments.length; i++) {
  4146. args[i - 1] = arguments[i];
  4147. }
  4148. }
  4149. queue.push(new Item(fun, args));
  4150. if (queue.length === 1 && !draining) {
  4151. runTimeout(drainQueue);
  4152. }
  4153. };
  4154. // v8 likes predictible objects
  4155. function Item(fun, array) {
  4156. this.fun = fun;
  4157. this.array = array;
  4158. }
  4159. Item.prototype.run = function () {
  4160. this.fun.apply(null, this.array);
  4161. };
  4162. process.title = 'browser';
  4163. process.browser = true;
  4164. process.env = {};
  4165. process.argv = [];
  4166. process.version = ''; // empty string to avoid regexp issues
  4167. process.versions = {};
  4168. function noop() {}
  4169. process.on = noop;
  4170. process.addListener = noop;
  4171. process.once = noop;
  4172. process.off = noop;
  4173. process.removeListener = noop;
  4174. process.removeAllListeners = noop;
  4175. process.emit = noop;
  4176. process.prependListener = noop;
  4177. process.prependOnceListener = noop;
  4178. process.listeners = function (name) { return [] }
  4179. process.binding = function (name) {
  4180. throw new Error('process.binding is not supported');
  4181. };
  4182. process.cwd = function () { return '/' };
  4183. process.chdir = function (dir) {
  4184. throw new Error('process.chdir is not supported');
  4185. };
  4186. process.umask = function() { return 0; };
  4187. /***/ }),
  4188. /***/ "./node_modules/riot/riot.esm.js":
  4189. /*!***************************************!*\
  4190. !*** ./node_modules/riot/riot.esm.js ***!
  4191. \***************************************/
  4192. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4193. "use strict";
  4194. __webpack_require__.r(__webpack_exports__);
  4195. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4196. /* harmony export */ "__": () => (/* binding */ __),
  4197. /* harmony export */ "component": () => (/* binding */ component),
  4198. /* harmony export */ "install": () => (/* binding */ install),
  4199. /* harmony export */ "mount": () => (/* binding */ mount),
  4200. /* harmony export */ "pure": () => (/* binding */ pure),
  4201. /* harmony export */ "register": () => (/* binding */ register),
  4202. /* harmony export */ "uninstall": () => (/* binding */ uninstall),
  4203. /* harmony export */ "unmount": () => (/* binding */ unmount),
  4204. /* harmony export */ "unregister": () => (/* binding */ unregister),
  4205. /* harmony export */ "version": () => (/* binding */ version),
  4206. /* harmony export */ "withTypes": () => (/* binding */ withTypes)
  4207. /* harmony export */ });
  4208. /* Riot v6.0.3, @license MIT */
  4209. /**
  4210. * Convert a string from camel case to dash-case
  4211. * @param {string} string - probably a component tag name
  4212. * @returns {string} component name normalized
  4213. */
  4214. function camelToDashCase(string) {
  4215. return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
  4216. }
  4217. /**
  4218. * Convert a string containing dashes to camel case
  4219. * @param {string} string - input string
  4220. * @returns {string} my-string -> myString
  4221. */
  4222. function dashToCamelCase(string) {
  4223. return string.replace(/-(\w)/g, (_, c) => c.toUpperCase());
  4224. }
  4225. /**
  4226. * Get all the element attributes as object
  4227. * @param {HTMLElement} element - DOM node we want to parse
  4228. * @returns {Object} all the attributes found as a key value pairs
  4229. */
  4230. function DOMattributesToObject(element) {
  4231. return Array.from(element.attributes).reduce((acc, attribute) => {
  4232. acc[dashToCamelCase(attribute.name)] = attribute.value;
  4233. return acc;
  4234. }, {});
  4235. }
  4236. /**
  4237. * Move all the child nodes from a source tag to another
  4238. * @param {HTMLElement} source - source node
  4239. * @param {HTMLElement} target - target node
  4240. * @returns {undefined} it's a void method ¯\_()_/¯
  4241. */
  4242. // Ignore this helper because it's needed only for svg tags
  4243. function moveChildren(source, target) {
  4244. if (source.firstChild) {
  4245. target.appendChild(source.firstChild);
  4246. moveChildren(source, target);
  4247. }
  4248. }
  4249. /**
  4250. * Remove the child nodes from any DOM node
  4251. * @param {HTMLElement} node - target node
  4252. * @returns {undefined}
  4253. */
  4254. function cleanNode(node) {
  4255. clearChildren(node.childNodes);
  4256. }
  4257. /**
  4258. * Clear multiple children in a node
  4259. * @param {HTMLElement[]} children - direct children nodes
  4260. * @returns {undefined}
  4261. */
  4262. function clearChildren(children) {
  4263. Array.from(children).forEach(removeChild);
  4264. }
  4265. /**
  4266. * Remove a node
  4267. * @param {HTMLElement}node - node to remove
  4268. * @returns {undefined}
  4269. */
  4270. const removeChild = node => node && node.parentNode && node.parentNode.removeChild(node);
  4271. /**
  4272. * Insert before a node
  4273. * @param {HTMLElement} newNode - node to insert
  4274. * @param {HTMLElement} refNode - ref child
  4275. * @returns {undefined}
  4276. */
  4277. const insertBefore = (newNode, refNode) => refNode && refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode);
  4278. /**
  4279. * Replace a node
  4280. * @param {HTMLElement} newNode - new node to add to the DOM
  4281. * @param {HTMLElement} replaced - node to replace
  4282. * @returns {undefined}
  4283. */
  4284. const replaceChild = (newNode, replaced) => replaced && replaced.parentNode && replaced.parentNode.replaceChild(newNode, replaced);
  4285. // Riot.js constants that can be used accross more modules
  4286. const COMPONENTS_IMPLEMENTATION_MAP$1 = new Map(),
  4287. DOM_COMPONENT_INSTANCE_PROPERTY$1 = Symbol('riot-component'),
  4288. PLUGINS_SET$1 = new Set(),
  4289. IS_DIRECTIVE = 'is',
  4290. VALUE_ATTRIBUTE = 'value',
  4291. MOUNT_METHOD_KEY = 'mount',
  4292. UPDATE_METHOD_KEY = 'update',
  4293. UNMOUNT_METHOD_KEY = 'unmount',
  4294. SHOULD_UPDATE_KEY = 'shouldUpdate',
  4295. ON_BEFORE_MOUNT_KEY = 'onBeforeMount',
  4296. ON_MOUNTED_KEY = 'onMounted',
  4297. ON_BEFORE_UPDATE_KEY = 'onBeforeUpdate',
  4298. ON_UPDATED_KEY = 'onUpdated',
  4299. ON_BEFORE_UNMOUNT_KEY = 'onBeforeUnmount',
  4300. ON_UNMOUNTED_KEY = 'onUnmounted',
  4301. PROPS_KEY = 'props',
  4302. STATE_KEY = 'state',
  4303. SLOTS_KEY = 'slots',
  4304. ROOT_KEY = 'root',
  4305. IS_PURE_SYMBOL = Symbol('pure'),
  4306. IS_COMPONENT_UPDATING = Symbol('is_updating'),
  4307. PARENT_KEY_SYMBOL = Symbol('parent'),
  4308. ATTRIBUTES_KEY_SYMBOL = Symbol('attributes'),
  4309. TEMPLATE_KEY_SYMBOL = Symbol('template');
  4310. var globals = /*#__PURE__*/Object.freeze({
  4311. __proto__: null,
  4312. COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP$1,
  4313. DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY$1,
  4314. PLUGINS_SET: PLUGINS_SET$1,
  4315. IS_DIRECTIVE: IS_DIRECTIVE,
  4316. VALUE_ATTRIBUTE: VALUE_ATTRIBUTE,
  4317. MOUNT_METHOD_KEY: MOUNT_METHOD_KEY,
  4318. UPDATE_METHOD_KEY: UPDATE_METHOD_KEY,
  4319. UNMOUNT_METHOD_KEY: UNMOUNT_METHOD_KEY,
  4320. SHOULD_UPDATE_KEY: SHOULD_UPDATE_KEY,
  4321. ON_BEFORE_MOUNT_KEY: ON_BEFORE_MOUNT_KEY,
  4322. ON_MOUNTED_KEY: ON_MOUNTED_KEY,
  4323. ON_BEFORE_UPDATE_KEY: ON_BEFORE_UPDATE_KEY,
  4324. ON_UPDATED_KEY: ON_UPDATED_KEY,
  4325. ON_BEFORE_UNMOUNT_KEY: ON_BEFORE_UNMOUNT_KEY,
  4326. ON_UNMOUNTED_KEY: ON_UNMOUNTED_KEY,
  4327. PROPS_KEY: PROPS_KEY,
  4328. STATE_KEY: STATE_KEY,
  4329. SLOTS_KEY: SLOTS_KEY,
  4330. ROOT_KEY: ROOT_KEY,
  4331. IS_PURE_SYMBOL: IS_PURE_SYMBOL,
  4332. IS_COMPONENT_UPDATING: IS_COMPONENT_UPDATING,
  4333. PARENT_KEY_SYMBOL: PARENT_KEY_SYMBOL,
  4334. ATTRIBUTES_KEY_SYMBOL: ATTRIBUTES_KEY_SYMBOL,
  4335. TEMPLATE_KEY_SYMBOL: TEMPLATE_KEY_SYMBOL
  4336. });
  4337. const EACH = 0;
  4338. const IF = 1;
  4339. const SIMPLE = 2;
  4340. const TAG = 3;
  4341. const SLOT = 4;
  4342. var bindingTypes = {
  4343. EACH,
  4344. IF,
  4345. SIMPLE,
  4346. TAG,
  4347. SLOT
  4348. };
  4349. const ATTRIBUTE = 0;
  4350. const EVENT = 1;
  4351. const TEXT = 2;
  4352. const VALUE = 3;
  4353. var expressionTypes = {
  4354. ATTRIBUTE,
  4355. EVENT,
  4356. TEXT,
  4357. VALUE
  4358. };
  4359. const HEAD_SYMBOL = Symbol('head');
  4360. const TAIL_SYMBOL = Symbol('tail');
  4361. /**
  4362. * Create the <template> fragments text nodes
  4363. * @return {Object} {{head: Text, tail: Text}}
  4364. */
  4365. function createHeadTailPlaceholders() {
  4366. const head = document.createTextNode('');
  4367. const tail = document.createTextNode('');
  4368. head[HEAD_SYMBOL] = true;
  4369. tail[TAIL_SYMBOL] = true;
  4370. return {
  4371. head,
  4372. tail
  4373. };
  4374. }
  4375. /**
  4376. * Create the template meta object in case of <template> fragments
  4377. * @param {TemplateChunk} componentTemplate - template chunk object
  4378. * @returns {Object} the meta property that will be passed to the mount function of the TemplateChunk
  4379. */
  4380. function createTemplateMeta(componentTemplate) {
  4381. const fragment = componentTemplate.dom.cloneNode(true);
  4382. const {
  4383. head,
  4384. tail
  4385. } = createHeadTailPlaceholders();
  4386. return {
  4387. avoidDOMInjection: true,
  4388. fragment,
  4389. head,
  4390. tail,
  4391. children: [head, ...Array.from(fragment.childNodes), tail]
  4392. };
  4393. }
  4394. /**
  4395. * Helper function to set an immutable property
  4396. * @param {Object} source - object where the new property will be set
  4397. * @param {string} key - object key where the new property will be stored
  4398. * @param {*} value - value of the new property
  4399. * @param {Object} options - set the propery overriding the default options
  4400. * @returns {Object} - the original object modified
  4401. */
  4402. function defineProperty(source, key, value, options) {
  4403. if (options === void 0) {
  4404. options = {};
  4405. }
  4406. /* eslint-disable fp/no-mutating-methods */
  4407. Object.defineProperty(source, key, Object.assign({
  4408. value,
  4409. enumerable: false,
  4410. writable: false,
  4411. configurable: true
  4412. }, options));
  4413. /* eslint-enable fp/no-mutating-methods */
  4414. return source;
  4415. }
  4416. /**
  4417. * Define multiple properties on a target object
  4418. * @param {Object} source - object where the new properties will be set
  4419. * @param {Object} properties - object containing as key pair the key + value properties
  4420. * @param {Object} options - set the propery overriding the default options
  4421. * @returns {Object} the original object modified
  4422. */
  4423. function defineProperties(source, properties, options) {
  4424. Object.entries(properties).forEach(_ref => {
  4425. let [key, value] = _ref;
  4426. defineProperty(source, key, value, options);
  4427. });
  4428. return source;
  4429. }
  4430. /**
  4431. * Define default properties if they don't exist on the source object
  4432. * @param {Object} source - object that will receive the default properties
  4433. * @param {Object} defaults - object containing additional optional keys
  4434. * @returns {Object} the original object received enhanced
  4435. */
  4436. function defineDefaults(source, defaults) {
  4437. Object.entries(defaults).forEach(_ref2 => {
  4438. let [key, value] = _ref2;
  4439. if (!source[key]) source[key] = value;
  4440. });
  4441. return source;
  4442. }
  4443. /**
  4444. * Get the current <template> fragment children located in between the head and tail comments
  4445. * @param {Comment} head - head comment node
  4446. * @param {Comment} tail - tail comment node
  4447. * @return {Array[]} children list of the nodes found in this template fragment
  4448. */
  4449. function getFragmentChildren(_ref) {
  4450. let {
  4451. head,
  4452. tail
  4453. } = _ref;
  4454. const nodes = walkNodes([head], head.nextSibling, n => n === tail, false);
  4455. nodes.push(tail);
  4456. return nodes;
  4457. }
  4458. /**
  4459. * Recursive function to walk all the <template> children nodes
  4460. * @param {Array[]} children - children nodes collection
  4461. * @param {ChildNode} node - current node
  4462. * @param {Function} check - exit function check
  4463. * @param {boolean} isFilterActive - filter flag to skip nodes managed by other bindings
  4464. * @returns {Array[]} children list of the nodes found in this template fragment
  4465. */
  4466. function walkNodes(children, node, check, isFilterActive) {
  4467. const {
  4468. nextSibling
  4469. } = node; // filter tail and head nodes together with all the nodes in between
  4470. // this is needed only to fix a really ugly edge case https://github.com/riot/riot/issues/2892
  4471. if (!isFilterActive && !node[HEAD_SYMBOL] && !node[TAIL_SYMBOL]) {
  4472. children.push(node);
  4473. }
  4474. if (!nextSibling || check(node)) return children;
  4475. return walkNodes(children, nextSibling, check, // activate the filters to skip nodes between <template> fragments that will be managed by other bindings
  4476. isFilterActive && !node[TAIL_SYMBOL] || nextSibling[HEAD_SYMBOL]);
  4477. }
  4478. /**
  4479. * Quick type checking
  4480. * @param {*} element - anything
  4481. * @param {string} type - type definition
  4482. * @returns {boolean} true if the type corresponds
  4483. */
  4484. function checkType(element, type) {
  4485. return typeof element === type;
  4486. }
  4487. /**
  4488. * Check if an element is part of an svg
  4489. * @param {HTMLElement} el - element to check
  4490. * @returns {boolean} true if we are in an svg context
  4491. */
  4492. function isSvg(el) {
  4493. const owner = el.ownerSVGElement;
  4494. return !!owner || owner === null;
  4495. }
  4496. /**
  4497. * Check if an element is a template tag
  4498. * @param {HTMLElement} el - element to check
  4499. * @returns {boolean} true if it's a <template>
  4500. */
  4501. function isTemplate(el) {
  4502. return el.tagName.toLowerCase() === 'template';
  4503. }
  4504. /**
  4505. * Check that will be passed if its argument is a function
  4506. * @param {*} value - value to check
  4507. * @returns {boolean} - true if the value is a function
  4508. */
  4509. function isFunction(value) {
  4510. return checkType(value, 'function');
  4511. }
  4512. /**
  4513. * Check if a value is a Boolean
  4514. * @param {*} value - anything
  4515. * @returns {boolean} true only for the value is a boolean
  4516. */
  4517. function isBoolean(value) {
  4518. return checkType(value, 'boolean');
  4519. }
  4520. /**
  4521. * Check if a value is an Object
  4522. * @param {*} value - anything
  4523. * @returns {boolean} true only for the value is an object
  4524. */
  4525. function isObject(value) {
  4526. return !isNil(value) && value.constructor === Object;
  4527. }
  4528. /**
  4529. * Check if a value is null or undefined
  4530. * @param {*} value - anything
  4531. * @returns {boolean} true only for the 'undefined' and 'null' types
  4532. */
  4533. function isNil(value) {
  4534. return value === null || value === undefined;
  4535. }
  4536. /**
  4537. * ISC License
  4538. *
  4539. * Copyright (c) 2020, Andrea Giammarchi, @WebReflection
  4540. *
  4541. * Permission to use, copy, modify, and/or distribute this software for any
  4542. * purpose with or without fee is hereby granted, provided that the above
  4543. * copyright notice and this permission notice appear in all copies.
  4544. *
  4545. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  4546. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  4547. * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  4548. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  4549. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  4550. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  4551. * PERFORMANCE OF THIS SOFTWARE.
  4552. */
  4553. // fork of https://github.com/WebReflection/udomdiff version 1.1.0
  4554. // due to https://github.com/WebReflection/udomdiff/pull/2
  4555. /* eslint-disable */
  4556. /**
  4557. * @param {Node[]} a The list of current/live children
  4558. * @param {Node[]} b The list of future children
  4559. * @param {(entry: Node, action: number) => Node} get
  4560. * The callback invoked per each entry related DOM operation.
  4561. * @param {Node} [before] The optional node used as anchor to insert before.
  4562. * @returns {Node[]} The same list of future children.
  4563. */
  4564. var udomdiff = ((a, b, get, before) => {
  4565. const bLength = b.length;
  4566. let aEnd = a.length;
  4567. let bEnd = bLength;
  4568. let aStart = 0;
  4569. let bStart = 0;
  4570. let map = null;
  4571. while (aStart < aEnd || bStart < bEnd) {
  4572. // append head, tail, or nodes in between: fast path
  4573. if (aEnd === aStart) {
  4574. // we could be in a situation where the rest of nodes that
  4575. // need to be added are not at the end, and in such case
  4576. // the node to `insertBefore`, if the index is more than 0
  4577. // must be retrieved, otherwise it's gonna be the first item.
  4578. const node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd - bStart], 0) : before;
  4579. while (bStart < bEnd) insertBefore(get(b[bStart++], 1), node);
  4580. } // remove head or tail: fast path
  4581. else if (bEnd === bStart) {
  4582. while (aStart < aEnd) {
  4583. // remove the node only if it's unknown or not live
  4584. if (!map || !map.has(a[aStart])) removeChild(get(a[aStart], -1));
  4585. aStart++;
  4586. }
  4587. } // same node: fast path
  4588. else if (a[aStart] === b[bStart]) {
  4589. aStart++;
  4590. bStart++;
  4591. } // same tail: fast path
  4592. else if (a[aEnd - 1] === b[bEnd - 1]) {
  4593. aEnd--;
  4594. bEnd--;
  4595. } // The once here single last swap "fast path" has been removed in v1.1.0
  4596. // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85
  4597. // reverse swap: also fast path
  4598. else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
  4599. // this is a "shrink" operation that could happen in these cases:
  4600. // [1, 2, 3, 4, 5]
  4601. // [1, 4, 3, 2, 5]
  4602. // or asymmetric too
  4603. // [1, 2, 3, 4, 5]
  4604. // [1, 2, 3, 5, 6, 4]
  4605. const node = get(a[--aEnd], -1).nextSibling;
  4606. insertBefore(get(b[bStart++], 1), get(a[aStart++], -1).nextSibling);
  4607. insertBefore(get(b[--bEnd], 1), node); // mark the future index as identical (yeah, it's dirty, but cheap 👍)
  4608. // The main reason to do this, is that when a[aEnd] will be reached,
  4609. // the loop will likely be on the fast path, as identical to b[bEnd].
  4610. // In the best case scenario, the next loop will skip the tail,
  4611. // but in the worst one, this node will be considered as already
  4612. // processed, bailing out pretty quickly from the map index check
  4613. a[aEnd] = b[bEnd];
  4614. } // map based fallback, "slow" path
  4615. else {
  4616. // the map requires an O(bEnd - bStart) operation once
  4617. // to store all future nodes indexes for later purposes.
  4618. // In the worst case scenario, this is a full O(N) cost,
  4619. // and such scenario happens at least when all nodes are different,
  4620. // but also if both first and last items of the lists are different
  4621. if (!map) {
  4622. map = new Map();
  4623. let i = bStart;
  4624. while (i < bEnd) map.set(b[i], i++);
  4625. } // if it's a future node, hence it needs some handling
  4626. if (map.has(a[aStart])) {
  4627. // grab the index of such node, 'cause it might have been processed
  4628. const index = map.get(a[aStart]); // if it's not already processed, look on demand for the next LCS
  4629. if (bStart < index && index < bEnd) {
  4630. let i = aStart; // counts the amount of nodes that are the same in the future
  4631. let sequence = 1;
  4632. while (++i < aEnd && i < bEnd && map.get(a[i]) === index + sequence) sequence++; // effort decision here: if the sequence is longer than replaces
  4633. // needed to reach such sequence, which would brings again this loop
  4634. // to the fast path, prepend the difference before a sequence,
  4635. // and move only the future list index forward, so that aStart
  4636. // and bStart will be aligned again, hence on the fast path.
  4637. // An example considering aStart and bStart are both 0:
  4638. // a: [1, 2, 3, 4]
  4639. // b: [7, 1, 2, 3, 6]
  4640. // this would place 7 before 1 and, from that time on, 1, 2, and 3
  4641. // will be processed at zero cost
  4642. if (sequence > index - bStart) {
  4643. const node = get(a[aStart], 0);
  4644. while (bStart < index) insertBefore(get(b[bStart++], 1), node);
  4645. } // if the effort wasn't good enough, fallback to a replace,
  4646. // moving both source and target indexes forward, hoping that some
  4647. // similar node will be found later on, to go back to the fast path
  4648. else {
  4649. replaceChild(get(b[bStart++], 1), get(a[aStart++], -1));
  4650. }
  4651. } // otherwise move the source forward, 'cause there's nothing to do
  4652. else aStart++;
  4653. } // this node has no meaning in the future list, so it's more than safe
  4654. // to remove it, and check the next live node out instead, meaning
  4655. // that only the live list index should be forwarded
  4656. else removeChild(get(a[aStart++], -1));
  4657. }
  4658. }
  4659. return b;
  4660. });
  4661. const UNMOUNT_SCOPE = Symbol('unmount');
  4662. const EachBinding = {
  4663. // dynamic binding properties
  4664. // childrenMap: null,
  4665. // node: null,
  4666. // root: null,
  4667. // condition: null,
  4668. // evaluate: null,
  4669. // template: null,
  4670. // isTemplateTag: false,
  4671. nodes: [],
  4672. // getKey: null,
  4673. // indexName: null,
  4674. // itemName: null,
  4675. // afterPlaceholder: null,
  4676. // placeholder: null,
  4677. // API methods
  4678. mount(scope, parentScope) {
  4679. return this.update(scope, parentScope);
  4680. },
  4681. update(scope, parentScope) {
  4682. const {
  4683. placeholder,
  4684. nodes,
  4685. childrenMap
  4686. } = this;
  4687. const collection = scope === UNMOUNT_SCOPE ? null : this.evaluate(scope);
  4688. const items = collection ? Array.from(collection) : []; // prepare the diffing
  4689. const {
  4690. newChildrenMap,
  4691. batches,
  4692. futureNodes
  4693. } = createPatch(items, scope, parentScope, this); // patch the DOM only if there are new nodes
  4694. udomdiff(nodes, futureNodes, patch(Array.from(childrenMap.values()), parentScope), placeholder); // trigger the mounts and the updates
  4695. batches.forEach(fn => fn()); // update the children map
  4696. this.childrenMap = newChildrenMap;
  4697. this.nodes = futureNodes; // make sure that the loop edge nodes are marked
  4698. markEdgeNodes(this.nodes);
  4699. return this;
  4700. },
  4701. unmount(scope, parentScope) {
  4702. this.update(UNMOUNT_SCOPE, parentScope);
  4703. return this;
  4704. }
  4705. };
  4706. /**
  4707. * Patch the DOM while diffing
  4708. * @param {any[]} redundant - list of all the children (template, nodes, context) added via each
  4709. * @param {*} parentScope - scope of the parent template
  4710. * @returns {Function} patch function used by domdiff
  4711. */
  4712. function patch(redundant, parentScope) {
  4713. return (item, info) => {
  4714. if (info < 0) {
  4715. // get the last element added to the childrenMap saved previously
  4716. const element = redundant[redundant.length - 1];
  4717. if (element) {
  4718. // get the nodes and the template in stored in the last child of the childrenMap
  4719. const {
  4720. template,
  4721. nodes,
  4722. context
  4723. } = element; // remove the last node (notice <template> tags might have more children nodes)
  4724. nodes.pop(); // notice that we pass null as last argument because
  4725. // the root node and its children will be removed by domdiff
  4726. if (!nodes.length) {
  4727. // we have cleared all the children nodes and we can unmount this template
  4728. redundant.pop();
  4729. template.unmount(context, parentScope, null);
  4730. }
  4731. }
  4732. }
  4733. return item;
  4734. };
  4735. }
  4736. /**
  4737. * Check whether a template must be filtered from a loop
  4738. * @param {Function} condition - filter function
  4739. * @param {Object} context - argument passed to the filter function
  4740. * @returns {boolean} true if this item should be skipped
  4741. */
  4742. function mustFilterItem(condition, context) {
  4743. return condition ? !condition(context) : false;
  4744. }
  4745. /**
  4746. * Extend the scope of the looped template
  4747. * @param {Object} scope - current template scope
  4748. * @param {Object} options - options
  4749. * @param {string} options.itemName - key to identify the looped item in the new context
  4750. * @param {string} options.indexName - key to identify the index of the looped item
  4751. * @param {number} options.index - current index
  4752. * @param {*} options.item - collection item looped
  4753. * @returns {Object} enhanced scope object
  4754. */
  4755. function extendScope(scope, _ref) {
  4756. let {
  4757. itemName,
  4758. indexName,
  4759. index,
  4760. item
  4761. } = _ref;
  4762. defineProperty(scope, itemName, item);
  4763. if (indexName) defineProperty(scope, indexName, index);
  4764. return scope;
  4765. }
  4766. /**
  4767. * Mark the first and last nodes in order to ignore them in case we need to retrieve the <template> fragment nodes
  4768. * @param {Array[]} nodes - each binding nodes list
  4769. * @returns {undefined} void function
  4770. */
  4771. function markEdgeNodes(nodes) {
  4772. const first = nodes[0];
  4773. const last = nodes[nodes.length - 1];
  4774. if (first) first[HEAD_SYMBOL] = true;
  4775. if (last) last[TAIL_SYMBOL] = true;
  4776. }
  4777. /**
  4778. * Loop the current template items
  4779. * @param {Array} items - expression collection value
  4780. * @param {*} scope - template scope
  4781. * @param {*} parentScope - scope of the parent template
  4782. * @param {EachBinding} binding - each binding object instance
  4783. * @returns {Object} data
  4784. * @returns {Map} data.newChildrenMap - a Map containing the new children template structure
  4785. * @returns {Array} data.batches - array containing the template lifecycle functions to trigger
  4786. * @returns {Array} data.futureNodes - array containing the nodes we need to diff
  4787. */
  4788. function createPatch(items, scope, parentScope, binding) {
  4789. const {
  4790. condition,
  4791. template,
  4792. childrenMap,
  4793. itemName,
  4794. getKey,
  4795. indexName,
  4796. root,
  4797. isTemplateTag
  4798. } = binding;
  4799. const newChildrenMap = new Map();
  4800. const batches = [];
  4801. const futureNodes = [];
  4802. items.forEach((item, index) => {
  4803. const context = extendScope(Object.create(scope), {
  4804. itemName,
  4805. indexName,
  4806. index,
  4807. item
  4808. });
  4809. const key = getKey ? getKey(context) : index;
  4810. const oldItem = childrenMap.get(key);
  4811. const nodes = [];
  4812. if (mustFilterItem(condition, context)) {
  4813. return;
  4814. }
  4815. const mustMount = !oldItem;
  4816. const componentTemplate = oldItem ? oldItem.template : template.clone();
  4817. const el = componentTemplate.el || root.cloneNode();
  4818. const meta = isTemplateTag && mustMount ? createTemplateMeta(componentTemplate) : componentTemplate.meta;
  4819. if (mustMount) {
  4820. batches.push(() => componentTemplate.mount(el, context, parentScope, meta));
  4821. } else {
  4822. batches.push(() => componentTemplate.update(context, parentScope));
  4823. } // create the collection of nodes to update or to add
  4824. // in case of template tags we need to add all its children nodes
  4825. if (isTemplateTag) {
  4826. nodes.push(...(mustMount ? meta.children : getFragmentChildren(meta)));
  4827. } else {
  4828. nodes.push(el);
  4829. } // delete the old item from the children map
  4830. childrenMap.delete(key);
  4831. futureNodes.push(...nodes); // update the children map
  4832. newChildrenMap.set(key, {
  4833. nodes,
  4834. template: componentTemplate,
  4835. context,
  4836. index
  4837. });
  4838. });
  4839. return {
  4840. newChildrenMap,
  4841. batches,
  4842. futureNodes
  4843. };
  4844. }
  4845. function create$6(node, _ref2) {
  4846. let {
  4847. evaluate,
  4848. condition,
  4849. itemName,
  4850. indexName,
  4851. getKey,
  4852. template
  4853. } = _ref2;
  4854. const placeholder = document.createTextNode('');
  4855. const root = node.cloneNode();
  4856. insertBefore(placeholder, node);
  4857. removeChild(node);
  4858. return Object.assign({}, EachBinding, {
  4859. childrenMap: new Map(),
  4860. node,
  4861. root,
  4862. condition,
  4863. evaluate,
  4864. isTemplateTag: isTemplate(root),
  4865. template: template.createDOM(node),
  4866. getKey,
  4867. indexName,
  4868. itemName,
  4869. placeholder
  4870. });
  4871. }
  4872. /**
  4873. * Binding responsible for the `if` directive
  4874. */
  4875. const IfBinding = {
  4876. // dynamic binding properties
  4877. // node: null,
  4878. // evaluate: null,
  4879. // isTemplateTag: false,
  4880. // placeholder: null,
  4881. // template: null,
  4882. // API methods
  4883. mount(scope, parentScope) {
  4884. return this.update(scope, parentScope);
  4885. },
  4886. update(scope, parentScope) {
  4887. const value = !!this.evaluate(scope);
  4888. const mustMount = !this.value && value;
  4889. const mustUnmount = this.value && !value;
  4890. const mount = () => {
  4891. const pristine = this.node.cloneNode();
  4892. insertBefore(pristine, this.placeholder);
  4893. this.template = this.template.clone();
  4894. this.template.mount(pristine, scope, parentScope);
  4895. };
  4896. switch (true) {
  4897. case mustMount:
  4898. mount();
  4899. break;
  4900. case mustUnmount:
  4901. this.unmount(scope);
  4902. break;
  4903. default:
  4904. if (value) this.template.update(scope, parentScope);
  4905. }
  4906. this.value = value;
  4907. return this;
  4908. },
  4909. unmount(scope, parentScope) {
  4910. this.template.unmount(scope, parentScope, true);
  4911. return this;
  4912. }
  4913. };
  4914. function create$5(node, _ref) {
  4915. let {
  4916. evaluate,
  4917. template
  4918. } = _ref;
  4919. const placeholder = document.createTextNode('');
  4920. insertBefore(placeholder, node);
  4921. removeChild(node);
  4922. return Object.assign({}, IfBinding, {
  4923. node,
  4924. evaluate,
  4925. placeholder,
  4926. template: template.createDOM(node)
  4927. });
  4928. }
  4929. /**
  4930. * Throw an error with a descriptive message
  4931. * @param { string } message - error message
  4932. * @returns { undefined } hoppla.. at this point the program should stop working
  4933. */
  4934. function panic(message) {
  4935. throw new Error(message);
  4936. }
  4937. /**
  4938. * Returns the memoized (cached) function.
  4939. * // borrowed from https://www.30secondsofcode.org/js/s/memoize
  4940. * @param {Function} fn - function to memoize
  4941. * @returns {Function} memoize function
  4942. */
  4943. function memoize(fn) {
  4944. const cache = new Map();
  4945. const cached = val => {
  4946. return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
  4947. };
  4948. cached.cache = cache;
  4949. return cached;
  4950. }
  4951. /**
  4952. * Evaluate a list of attribute expressions
  4953. * @param {Array} attributes - attribute expressions generated by the riot compiler
  4954. * @returns {Object} key value pairs with the result of the computation
  4955. */
  4956. function evaluateAttributeExpressions(attributes) {
  4957. return attributes.reduce((acc, attribute) => {
  4958. const {
  4959. value,
  4960. type
  4961. } = attribute;
  4962. switch (true) {
  4963. // spread attribute
  4964. case !attribute.name && type === ATTRIBUTE:
  4965. return Object.assign({}, acc, value);
  4966. // value attribute
  4967. case type === VALUE:
  4968. acc.value = attribute.value;
  4969. break;
  4970. // normal attributes
  4971. default:
  4972. acc[dashToCamelCase(attribute.name)] = attribute.value;
  4973. }
  4974. return acc;
  4975. }, {});
  4976. }
  4977. const ElementProto = typeof Element === 'undefined' ? {} : Element.prototype;
  4978. const isNativeHtmlProperty = memoize(name => ElementProto.hasOwnProperty(name)); // eslint-disable-line
  4979. /**
  4980. * Add all the attributes provided
  4981. * @param {HTMLElement} node - target node
  4982. * @param {Object} attributes - object containing the attributes names and values
  4983. * @returns {undefined} sorry it's a void function :(
  4984. */
  4985. function setAllAttributes(node, attributes) {
  4986. Object.entries(attributes).forEach(_ref => {
  4987. let [name, value] = _ref;
  4988. return attributeExpression(node, {
  4989. name
  4990. }, value);
  4991. });
  4992. }
  4993. /**
  4994. * Remove all the attributes provided
  4995. * @param {HTMLElement} node - target node
  4996. * @param {Object} newAttributes - object containing all the new attribute names
  4997. * @param {Object} oldAttributes - object containing all the old attribute names
  4998. * @returns {undefined} sorry it's a void function :(
  4999. */
  5000. function removeAllAttributes(node, newAttributes, oldAttributes) {
  5001. const newKeys = newAttributes ? Object.keys(newAttributes) : [];
  5002. Object.keys(oldAttributes).filter(name => !newKeys.includes(name)).forEach(attribute => node.removeAttribute(attribute));
  5003. }
  5004. /**
  5005. * Check whether the attribute value can be rendered
  5006. * @param {*} value - expression value
  5007. * @returns {boolean} true if we can render this attribute value
  5008. */
  5009. function canRenderAttribute(value) {
  5010. return value === true || ['string', 'number'].includes(typeof value);
  5011. }
  5012. /**
  5013. * Check whether the attribute should be removed
  5014. * @param {*} value - expression value
  5015. * @returns {boolean} boolean - true if the attribute can be removed}
  5016. */
  5017. function shouldRemoveAttribute(value) {
  5018. return !value && value !== 0;
  5019. }
  5020. /**
  5021. * This methods handles the DOM attributes updates
  5022. * @param {HTMLElement} node - target node
  5023. * @param {Object} expression - expression object
  5024. * @param {string} expression.name - attribute name
  5025. * @param {*} value - new expression value
  5026. * @param {*} oldValue - the old expression cached value
  5027. * @returns {undefined}
  5028. */
  5029. function attributeExpression(node, _ref2, value, oldValue) {
  5030. let {
  5031. name
  5032. } = _ref2;
  5033. // is it a spread operator? {...attributes}
  5034. if (!name) {
  5035. if (oldValue) {
  5036. // remove all the old attributes
  5037. removeAllAttributes(node, value, oldValue);
  5038. } // is the value still truthy?
  5039. if (value) {
  5040. setAllAttributes(node, value);
  5041. }
  5042. return;
  5043. } // handle boolean attributes
  5044. if (!isNativeHtmlProperty(name) && (isBoolean(value) || isObject(value) || isFunction(value))) {
  5045. node[name] = value;
  5046. }
  5047. if (shouldRemoveAttribute(value)) {
  5048. node.removeAttribute(name);
  5049. } else if (canRenderAttribute(value)) {
  5050. node.setAttribute(name, normalizeValue(name, value));
  5051. }
  5052. }
  5053. /**
  5054. * Get the value as string
  5055. * @param {string} name - attribute name
  5056. * @param {*} value - user input value
  5057. * @returns {string} input value as string
  5058. */
  5059. function normalizeValue(name, value) {
  5060. // be sure that expressions like selected={ true } will be always rendered as selected='selected'
  5061. return value === true ? name : value;
  5062. }
  5063. const RE_EVENTS_PREFIX = /^on/;
  5064. const getCallbackAndOptions = value => Array.isArray(value) ? value : [value, false]; // see also https://medium.com/@WebReflection/dom-handleevent-a-cross-platform-standard-since-year-2000-5bf17287fd38
  5065. const EventListener = {
  5066. handleEvent(event) {
  5067. this[event.type](event);
  5068. }
  5069. };
  5070. const ListenersWeakMap = new WeakMap();
  5071. const createListener = node => {
  5072. const listener = Object.create(EventListener);
  5073. ListenersWeakMap.set(node, listener);
  5074. return listener;
  5075. };
  5076. /**
  5077. * Set a new event listener
  5078. * @param {HTMLElement} node - target node
  5079. * @param {Object} expression - expression object
  5080. * @param {string} expression.name - event name
  5081. * @param {*} value - new expression value
  5082. * @returns {value} the callback just received
  5083. */
  5084. function eventExpression(node, _ref, value) {
  5085. let {
  5086. name
  5087. } = _ref;
  5088. const normalizedEventName = name.replace(RE_EVENTS_PREFIX, '');
  5089. const eventListener = ListenersWeakMap.get(node) || createListener(node);
  5090. const [callback, options] = getCallbackAndOptions(value);
  5091. const handler = eventListener[normalizedEventName];
  5092. const mustRemoveEvent = handler && !callback;
  5093. const mustAddEvent = callback && !handler;
  5094. if (mustRemoveEvent) {
  5095. node.removeEventListener(normalizedEventName, eventListener);
  5096. }
  5097. if (mustAddEvent) {
  5098. node.addEventListener(normalizedEventName, eventListener, options);
  5099. }
  5100. eventListener[normalizedEventName] = callback;
  5101. }
  5102. /**
  5103. * Normalize the user value in order to render a empty string in case of falsy values
  5104. * @param {*} value - user input value
  5105. * @returns {string} hopefully a string
  5106. */
  5107. function normalizeStringValue(value) {
  5108. return isNil(value) ? '' : value;
  5109. }
  5110. /**
  5111. * Get the the target text node to update or create one from of a comment node
  5112. * @param {HTMLElement} node - any html element containing childNodes
  5113. * @param {number} childNodeIndex - index of the text node in the childNodes list
  5114. * @returns {Text} the text node to update
  5115. */
  5116. const getTextNode = (node, childNodeIndex) => {
  5117. const target = node.childNodes[childNodeIndex];
  5118. if (target.nodeType === Node.COMMENT_NODE) {
  5119. const textNode = document.createTextNode('');
  5120. node.replaceChild(textNode, target);
  5121. return textNode;
  5122. }
  5123. return target;
  5124. };
  5125. /**
  5126. * This methods handles a simple text expression update
  5127. * @param {HTMLElement} node - target node
  5128. * @param {Object} data - expression object
  5129. * @param {*} value - new expression value
  5130. * @returns {undefined}
  5131. */
  5132. function textExpression(node, data, value) {
  5133. node.data = normalizeStringValue(value);
  5134. }
  5135. /**
  5136. * This methods handles the input fileds value updates
  5137. * @param {HTMLElement} node - target node
  5138. * @param {Object} expression - expression object
  5139. * @param {*} value - new expression value
  5140. * @returns {undefined}
  5141. */
  5142. function valueExpression(node, expression, value) {
  5143. node.value = normalizeStringValue(value);
  5144. }
  5145. var expressions = {
  5146. [ATTRIBUTE]: attributeExpression,
  5147. [EVENT]: eventExpression,
  5148. [TEXT]: textExpression,
  5149. [VALUE]: valueExpression
  5150. };
  5151. const Expression = {
  5152. // Static props
  5153. // node: null,
  5154. // value: null,
  5155. // API methods
  5156. /**
  5157. * Mount the expression evaluating its initial value
  5158. * @param {*} scope - argument passed to the expression to evaluate its current values
  5159. * @returns {Expression} self
  5160. */
  5161. mount(scope) {
  5162. // hopefully a pure function
  5163. this.value = this.evaluate(scope); // IO() DOM updates
  5164. apply(this, this.value);
  5165. return this;
  5166. },
  5167. /**
  5168. * Update the expression if its value changed
  5169. * @param {*} scope - argument passed to the expression to evaluate its current values
  5170. * @returns {Expression} self
  5171. */
  5172. update(scope) {
  5173. // pure function
  5174. const value = this.evaluate(scope);
  5175. if (this.value !== value) {
  5176. // IO() DOM updates
  5177. apply(this, value);
  5178. this.value = value;
  5179. }
  5180. return this;
  5181. },
  5182. /**
  5183. * Expression teardown method
  5184. * @returns {Expression} self
  5185. */
  5186. unmount() {
  5187. // unmount only the event handling expressions
  5188. if (this.type === EVENT) apply(this, null);
  5189. return this;
  5190. }
  5191. };
  5192. /**
  5193. * IO() function to handle the DOM updates
  5194. * @param {Expression} expression - expression object
  5195. * @param {*} value - current expression value
  5196. * @returns {undefined}
  5197. */
  5198. function apply(expression, value) {
  5199. return expressions[expression.type](expression.node, expression, value, expression.value);
  5200. }
  5201. function create$4(node, data) {
  5202. return Object.assign({}, Expression, data, {
  5203. node: data.type === TEXT ? getTextNode(node, data.childNodeIndex) : node
  5204. });
  5205. }
  5206. /**
  5207. * Create a flat object having as keys a list of methods that if dispatched will propagate
  5208. * on the whole collection
  5209. * @param {Array} collection - collection to iterate
  5210. * @param {Array<string>} methods - methods to execute on each item of the collection
  5211. * @param {*} context - context returned by the new methods created
  5212. * @returns {Object} a new object to simplify the the nested methods dispatching
  5213. */
  5214. function flattenCollectionMethods(collection, methods, context) {
  5215. return methods.reduce((acc, method) => {
  5216. return Object.assign({}, acc, {
  5217. [method]: scope => {
  5218. return collection.map(item => item[method](scope)) && context;
  5219. }
  5220. });
  5221. }, {});
  5222. }
  5223. function create$3(node, _ref) {
  5224. let {
  5225. expressions
  5226. } = _ref;
  5227. return Object.assign({}, flattenCollectionMethods(expressions.map(expression => create$4(node, expression)), ['mount', 'update', 'unmount']));
  5228. }
  5229. function extendParentScope(attributes, scope, parentScope) {
  5230. if (!attributes || !attributes.length) return parentScope;
  5231. const expressions = attributes.map(attr => Object.assign({}, attr, {
  5232. value: attr.evaluate(scope)
  5233. }));
  5234. return Object.assign(Object.create(parentScope || null), evaluateAttributeExpressions(expressions));
  5235. } // this function is only meant to fix an edge case
  5236. // https://github.com/riot/riot/issues/2842
  5237. const getRealParent = (scope, parentScope) => scope[PARENT_KEY_SYMBOL] || parentScope;
  5238. const SlotBinding = {
  5239. // dynamic binding properties
  5240. // node: null,
  5241. // name: null,
  5242. attributes: [],
  5243. // template: null,
  5244. getTemplateScope(scope, parentScope) {
  5245. return extendParentScope(this.attributes, scope, parentScope);
  5246. },
  5247. // API methods
  5248. mount(scope, parentScope) {
  5249. const templateData = scope.slots ? scope.slots.find(_ref => {
  5250. let {
  5251. id
  5252. } = _ref;
  5253. return id === this.name;
  5254. }) : false;
  5255. const {
  5256. parentNode
  5257. } = this.node;
  5258. const realParent = getRealParent(scope, parentScope);
  5259. this.template = templateData && create(templateData.html, templateData.bindings).createDOM(parentNode);
  5260. if (this.template) {
  5261. cleanNode(this.node);
  5262. this.template.mount(this.node, this.getTemplateScope(scope, realParent), realParent);
  5263. this.template.children = Array.from(this.node.childNodes);
  5264. }
  5265. moveSlotInnerContent(this.node);
  5266. removeChild(this.node);
  5267. return this;
  5268. },
  5269. update(scope, parentScope) {
  5270. if (this.template) {
  5271. const realParent = getRealParent(scope, parentScope);
  5272. this.template.update(this.getTemplateScope(scope, realParent), realParent);
  5273. }
  5274. return this;
  5275. },
  5276. unmount(scope, parentScope, mustRemoveRoot) {
  5277. if (this.template) {
  5278. this.template.unmount(this.getTemplateScope(scope, parentScope), null, mustRemoveRoot);
  5279. }
  5280. return this;
  5281. }
  5282. };
  5283. /**
  5284. * Move the inner content of the slots outside of them
  5285. * @param {HTMLElement} slot - slot node
  5286. * @returns {undefined} it's a void method ¯\_()_/¯
  5287. */
  5288. function moveSlotInnerContent(slot) {
  5289. const child = slot && slot.firstChild;
  5290. if (!child) return;
  5291. insertBefore(child, slot);
  5292. moveSlotInnerContent(slot);
  5293. }
  5294. /**
  5295. * Create a single slot binding
  5296. * @param {HTMLElement} node - slot node
  5297. * @param {string} name - slot id
  5298. * @param {AttributeExpressionData[]} attributes - slot attributes
  5299. * @returns {Object} Slot binding object
  5300. */
  5301. function createSlot(node, _ref2) {
  5302. let {
  5303. name,
  5304. attributes
  5305. } = _ref2;
  5306. return Object.assign({}, SlotBinding, {
  5307. attributes,
  5308. node,
  5309. name
  5310. });
  5311. }
  5312. /**
  5313. * Create a new tag object if it was registered before, otherwise fallback to the simple
  5314. * template chunk
  5315. * @param {Function} component - component factory function
  5316. * @param {Array<Object>} slots - array containing the slots markup
  5317. * @param {Array} attributes - dynamic attributes that will be received by the tag element
  5318. * @returns {TagImplementation|TemplateChunk} a tag implementation or a template chunk as fallback
  5319. */
  5320. function getTag(component, slots, attributes) {
  5321. if (slots === void 0) {
  5322. slots = [];
  5323. }
  5324. if (attributes === void 0) {
  5325. attributes = [];
  5326. }
  5327. // if this tag was registered before we will return its implementation
  5328. if (component) {
  5329. return component({
  5330. slots,
  5331. attributes
  5332. });
  5333. } // otherwise we return a template chunk
  5334. return create(slotsToMarkup(slots), [...slotBindings(slots), {
  5335. // the attributes should be registered as binding
  5336. // if we fallback to a normal template chunk
  5337. expressions: attributes.map(attr => {
  5338. return Object.assign({
  5339. type: ATTRIBUTE
  5340. }, attr);
  5341. })
  5342. }]);
  5343. }
  5344. /**
  5345. * Merge all the slots bindings into a single array
  5346. * @param {Array<Object>} slots - slots collection
  5347. * @returns {Array<Bindings>} flatten bindings array
  5348. */
  5349. function slotBindings(slots) {
  5350. return slots.reduce((acc, _ref) => {
  5351. let {
  5352. bindings
  5353. } = _ref;
  5354. return acc.concat(bindings);
  5355. }, []);
  5356. }
  5357. /**
  5358. * Merge all the slots together in a single markup string
  5359. * @param {Array<Object>} slots - slots collection
  5360. * @returns {string} markup of all the slots in a single string
  5361. */
  5362. function slotsToMarkup(slots) {
  5363. return slots.reduce((acc, slot) => {
  5364. return acc + slot.html;
  5365. }, '');
  5366. }
  5367. const TagBinding = {
  5368. // dynamic binding properties
  5369. // node: null,
  5370. // evaluate: null,
  5371. // name: null,
  5372. // slots: null,
  5373. // tag: null,
  5374. // attributes: null,
  5375. // getComponent: null,
  5376. mount(scope) {
  5377. return this.update(scope);
  5378. },
  5379. update(scope, parentScope) {
  5380. const name = this.evaluate(scope); // simple update
  5381. if (name && name === this.name) {
  5382. this.tag.update(scope);
  5383. } else {
  5384. // unmount the old tag if it exists
  5385. this.unmount(scope, parentScope, true); // mount the new tag
  5386. this.name = name;
  5387. this.tag = getTag(this.getComponent(name), this.slots, this.attributes);
  5388. this.tag.mount(this.node, scope);
  5389. }
  5390. return this;
  5391. },
  5392. unmount(scope, parentScope, keepRootTag) {
  5393. if (this.tag) {
  5394. // keep the root tag
  5395. this.tag.unmount(keepRootTag);
  5396. }
  5397. return this;
  5398. }
  5399. };
  5400. function create$2(node, _ref2) {
  5401. let {
  5402. evaluate,
  5403. getComponent,
  5404. slots,
  5405. attributes
  5406. } = _ref2;
  5407. return Object.assign({}, TagBinding, {
  5408. node,
  5409. evaluate,
  5410. slots,
  5411. attributes,
  5412. getComponent
  5413. });
  5414. }
  5415. var bindings = {
  5416. [IF]: create$5,
  5417. [SIMPLE]: create$3,
  5418. [EACH]: create$6,
  5419. [TAG]: create$2,
  5420. [SLOT]: createSlot
  5421. };
  5422. /**
  5423. * Text expressions in a template tag will get childNodeIndex value normalized
  5424. * depending on the position of the <template> tag offset
  5425. * @param {Expression[]} expressions - riot expressions array
  5426. * @param {number} textExpressionsOffset - offset of the <template> tag
  5427. * @returns {Expression[]} expressions containing the text expressions normalized
  5428. */
  5429. function fixTextExpressionsOffset(expressions, textExpressionsOffset) {
  5430. return expressions.map(e => e.type === TEXT ? Object.assign({}, e, {
  5431. childNodeIndex: e.childNodeIndex + textExpressionsOffset
  5432. }) : e);
  5433. }
  5434. /**
  5435. * Bind a new expression object to a DOM node
  5436. * @param {HTMLElement} root - DOM node where to bind the expression
  5437. * @param {TagBindingData} binding - binding data
  5438. * @param {number|null} templateTagOffset - if it's defined we need to fix the text expressions childNodeIndex offset
  5439. * @returns {Binding} Binding object
  5440. */
  5441. function create$1(root, binding, templateTagOffset) {
  5442. const {
  5443. selector,
  5444. type,
  5445. redundantAttribute,
  5446. expressions
  5447. } = binding; // find the node to apply the bindings
  5448. const node = selector ? root.querySelector(selector) : root; // remove eventually additional attributes created only to select this node
  5449. if (redundantAttribute) node.removeAttribute(redundantAttribute);
  5450. const bindingExpressions = expressions || []; // init the binding
  5451. return (bindings[type] || bindings[SIMPLE])(node, Object.assign({}, binding, {
  5452. expressions: templateTagOffset && !selector ? fixTextExpressionsOffset(bindingExpressions, templateTagOffset) : bindingExpressions
  5453. }));
  5454. }
  5455. function createHTMLTree(html, root) {
  5456. const template = isTemplate(root) ? root : document.createElement('template');
  5457. template.innerHTML = html;
  5458. return template.content;
  5459. } // for svg nodes we need a bit more work
  5460. function createSVGTree(html, container) {
  5461. // create the SVGNode
  5462. const svgNode = container.ownerDocument.importNode(new window.DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${html}</svg>`, 'application/xml').documentElement, true);
  5463. return svgNode;
  5464. }
  5465. /**
  5466. * Create the DOM that will be injected
  5467. * @param {Object} root - DOM node to find out the context where the fragment will be created
  5468. * @param {string} html - DOM to create as string
  5469. * @returns {HTMLDocumentFragment|HTMLElement} a new html fragment
  5470. */
  5471. function createDOMTree(root, html) {
  5472. if (isSvg(root)) return createSVGTree(html, root);
  5473. return createHTMLTree(html, root);
  5474. }
  5475. /**
  5476. * Inject the DOM tree into a target node
  5477. * @param {HTMLElement} el - target element
  5478. * @param {DocumentFragment|SVGElement} dom - dom tree to inject
  5479. * @returns {undefined}
  5480. */
  5481. function injectDOM(el, dom) {
  5482. switch (true) {
  5483. case isSvg(el):
  5484. moveChildren(dom, el);
  5485. break;
  5486. case isTemplate(el):
  5487. el.parentNode.replaceChild(dom, el);
  5488. break;
  5489. default:
  5490. el.appendChild(dom);
  5491. }
  5492. }
  5493. /**
  5494. * Create the Template DOM skeleton
  5495. * @param {HTMLElement} el - root node where the DOM will be injected
  5496. * @param {string|HTMLElement} html - HTML markup or HTMLElement that will be injected into the root node
  5497. * @returns {?DocumentFragment} fragment that will be injected into the root node
  5498. */
  5499. function createTemplateDOM(el, html) {
  5500. return html && (typeof html === 'string' ? createDOMTree(el, html) : html);
  5501. }
  5502. /**
  5503. * Get the offset of the <template> tag
  5504. * @param {HTMLElement} parentNode - template tag parent node
  5505. * @param {HTMLElement} el - the template tag we want to render
  5506. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  5507. * @returns {number} offset of the <template> tag calculated from its siblings DOM nodes
  5508. */
  5509. function getTemplateTagOffset(parentNode, el, meta) {
  5510. const siblings = Array.from(parentNode.childNodes);
  5511. return Math.max(siblings.indexOf(el), siblings.indexOf(meta.head) + 1, 0);
  5512. }
  5513. /**
  5514. * Template Chunk model
  5515. * @type {Object}
  5516. */
  5517. const TemplateChunk = Object.freeze({
  5518. // Static props
  5519. // bindings: null,
  5520. // bindingsData: null,
  5521. // html: null,
  5522. // isTemplateTag: false,
  5523. // fragment: null,
  5524. // children: null,
  5525. // dom: null,
  5526. // el: null,
  5527. /**
  5528. * Create the template DOM structure that will be cloned on each mount
  5529. * @param {HTMLElement} el - the root node
  5530. * @returns {TemplateChunk} self
  5531. */
  5532. createDOM(el) {
  5533. // make sure that the DOM gets created before cloning the template
  5534. this.dom = this.dom || createTemplateDOM(el, this.html) || document.createDocumentFragment();
  5535. return this;
  5536. },
  5537. // API methods
  5538. /**
  5539. * Attach the template to a DOM node
  5540. * @param {HTMLElement} el - target DOM node
  5541. * @param {*} scope - template data
  5542. * @param {*} parentScope - scope of the parent template tag
  5543. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  5544. * @returns {TemplateChunk} self
  5545. */
  5546. mount(el, scope, parentScope, meta) {
  5547. if (meta === void 0) {
  5548. meta = {};
  5549. }
  5550. if (!el) throw new Error('Please provide DOM node to mount properly your template');
  5551. if (this.el) this.unmount(scope); // <template> tags require a bit more work
  5552. // the template fragment might be already created via meta outside of this call
  5553. const {
  5554. fragment,
  5555. children,
  5556. avoidDOMInjection
  5557. } = meta; // <template> bindings of course can not have a root element
  5558. // so we check the parent node to set the query selector bindings
  5559. const {
  5560. parentNode
  5561. } = children ? children[0] : el;
  5562. const isTemplateTag = isTemplate(el);
  5563. const templateTagOffset = isTemplateTag ? getTemplateTagOffset(parentNode, el, meta) : null; // create the DOM if it wasn't created before
  5564. this.createDOM(el); // create the DOM of this template cloning the original DOM structure stored in this instance
  5565. // notice that if a documentFragment was passed (via meta) we will use it instead
  5566. const cloneNode = fragment || this.dom.cloneNode(true); // store root node
  5567. // notice that for template tags the root note will be the parent tag
  5568. this.el = isTemplateTag ? parentNode : el; // create the children array only for the <template> fragments
  5569. this.children = isTemplateTag ? children || Array.from(cloneNode.childNodes) : null; // inject the DOM into the el only if a fragment is available
  5570. if (!avoidDOMInjection && cloneNode) injectDOM(el, cloneNode); // create the bindings
  5571. this.bindings = this.bindingsData.map(binding => create$1(this.el, binding, templateTagOffset));
  5572. this.bindings.forEach(b => b.mount(scope, parentScope)); // store the template meta properties
  5573. this.meta = meta;
  5574. return this;
  5575. },
  5576. /**
  5577. * Update the template with fresh data
  5578. * @param {*} scope - template data
  5579. * @param {*} parentScope - scope of the parent template tag
  5580. * @returns {TemplateChunk} self
  5581. */
  5582. update(scope, parentScope) {
  5583. this.bindings.forEach(b => b.update(scope, parentScope));
  5584. return this;
  5585. },
  5586. /**
  5587. * Remove the template from the node where it was initially mounted
  5588. * @param {*} scope - template data
  5589. * @param {*} parentScope - scope of the parent template tag
  5590. * @param {boolean|null} mustRemoveRoot - if true remove the root element,
  5591. * if false or undefined clean the root tag content, if null don't touch the DOM
  5592. * @returns {TemplateChunk} self
  5593. */
  5594. unmount(scope, parentScope, mustRemoveRoot) {
  5595. if (mustRemoveRoot === void 0) {
  5596. mustRemoveRoot = false;
  5597. }
  5598. const el = this.el;
  5599. if (!el) {
  5600. return this;
  5601. }
  5602. this.bindings.forEach(b => b.unmount(scope, parentScope, mustRemoveRoot));
  5603. switch (true) {
  5604. // pure components should handle the DOM unmount updates by themselves
  5605. // for mustRemoveRoot === null don't touch the DOM
  5606. case el[IS_PURE_SYMBOL] || mustRemoveRoot === null:
  5607. break;
  5608. // if children are declared, clear them
  5609. // applicable for <template> and <slot/> bindings
  5610. case Array.isArray(this.children):
  5611. clearChildren(this.children);
  5612. break;
  5613. // clean the node children only
  5614. case !mustRemoveRoot:
  5615. cleanNode(el);
  5616. break;
  5617. // remove the root node only if the mustRemoveRoot is truly
  5618. case !!mustRemoveRoot:
  5619. removeChild(el);
  5620. break;
  5621. }
  5622. this.el = null;
  5623. return this;
  5624. },
  5625. /**
  5626. * Clone the template chunk
  5627. * @returns {TemplateChunk} a clone of this object resetting the this.el property
  5628. */
  5629. clone() {
  5630. return Object.assign({}, this, {
  5631. meta: {},
  5632. el: null
  5633. });
  5634. }
  5635. });
  5636. /**
  5637. * Create a template chunk wiring also the bindings
  5638. * @param {string|HTMLElement} html - template string
  5639. * @param {BindingData[]} bindings - bindings collection
  5640. * @returns {TemplateChunk} a new TemplateChunk copy
  5641. */
  5642. function create(html, bindings) {
  5643. if (bindings === void 0) {
  5644. bindings = [];
  5645. }
  5646. return Object.assign({}, TemplateChunk, {
  5647. html,
  5648. bindingsData: bindings
  5649. });
  5650. }
  5651. /**
  5652. * Method used to bind expressions to a DOM node
  5653. * @param {string|HTMLElement} html - your static template html structure
  5654. * @param {Array} bindings - list of the expressions to bind to update the markup
  5655. * @returns {TemplateChunk} a new TemplateChunk object having the `update`,`mount`, `unmount` and `clone` methods
  5656. *
  5657. * @example
  5658. *
  5659. * riotDOMBindings
  5660. * .template(
  5661. * `<div expr0><!----></div><div><p expr1><!----><section expr2></section></p>`,
  5662. * [
  5663. * {
  5664. * selector: '[expr0]',
  5665. * redundantAttribute: 'expr0',
  5666. * expressions: [
  5667. * {
  5668. * type: expressionTypes.TEXT,
  5669. * childNodeIndex: 0,
  5670. * evaluate(scope) {
  5671. * return scope.time;
  5672. * },
  5673. * },
  5674. * ],
  5675. * },
  5676. * {
  5677. * selector: '[expr1]',
  5678. * redundantAttribute: 'expr1',
  5679. * expressions: [
  5680. * {
  5681. * type: expressionTypes.TEXT,
  5682. * childNodeIndex: 0,
  5683. * evaluate(scope) {
  5684. * return scope.name;
  5685. * },
  5686. * },
  5687. * {
  5688. * type: 'attribute',
  5689. * name: 'style',
  5690. * evaluate(scope) {
  5691. * return scope.style;
  5692. * },
  5693. * },
  5694. * ],
  5695. * },
  5696. * {
  5697. * selector: '[expr2]',
  5698. * redundantAttribute: 'expr2',
  5699. * type: bindingTypes.IF,
  5700. * evaluate(scope) {
  5701. * return scope.isVisible;
  5702. * },
  5703. * template: riotDOMBindings.template('hello there'),
  5704. * },
  5705. * ]
  5706. * )
  5707. */
  5708. var DOMBindings = /*#__PURE__*/Object.freeze({
  5709. __proto__: null,
  5710. template: create,
  5711. createBinding: create$1,
  5712. createExpression: create$4,
  5713. bindingTypes: bindingTypes,
  5714. expressionTypes: expressionTypes
  5715. });
  5716. function noop() {
  5717. return this;
  5718. }
  5719. /**
  5720. * Autobind the methods of a source object to itself
  5721. * @param {Object} source - probably a riot tag instance
  5722. * @param {Array<string>} methods - list of the methods to autobind
  5723. * @returns {Object} the original object received
  5724. */
  5725. function autobindMethods(source, methods) {
  5726. methods.forEach(method => {
  5727. source[method] = source[method].bind(source);
  5728. });
  5729. return source;
  5730. }
  5731. /**
  5732. * Call the first argument received only if it's a function otherwise return it as it is
  5733. * @param {*} source - anything
  5734. * @returns {*} anything
  5735. */
  5736. function callOrAssign(source) {
  5737. return isFunction(source) ? source.prototype && source.prototype.constructor ? new source() : source() : source;
  5738. }
  5739. /**
  5740. * Converts any DOM node/s to a loopable array
  5741. * @param { HTMLElement|NodeList } els - single html element or a node list
  5742. * @returns { Array } always a loopable object
  5743. */
  5744. function domToArray(els) {
  5745. // can this object be already looped?
  5746. if (!Array.isArray(els)) {
  5747. // is it a node list?
  5748. if (/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(els)) && typeof els.length === 'number') return Array.from(els);else // if it's a single node
  5749. // it will be returned as "array" with one single entry
  5750. return [els];
  5751. } // this object could be looped out of the box
  5752. return els;
  5753. }
  5754. /**
  5755. * Simple helper to find DOM nodes returning them as array like loopable object
  5756. * @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
  5757. * @param { HTMLElement } ctx - context defining where the query will search for the DOM nodes
  5758. * @returns { Array } DOM nodes found as array
  5759. */
  5760. function $(selector, ctx) {
  5761. return domToArray(typeof selector === 'string' ? (ctx || document).querySelectorAll(selector) : selector);
  5762. }
  5763. /**
  5764. * Normalize the return values, in case of a single value we avoid to return an array
  5765. * @param { Array } values - list of values we want to return
  5766. * @returns { Array|string|boolean } either the whole list of values or the single one found
  5767. * @private
  5768. */
  5769. const normalize = values => values.length === 1 ? values[0] : values;
  5770. /**
  5771. * Parse all the nodes received to get/remove/check their attributes
  5772. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  5773. * @param { string|Array } name - name or list of attributes
  5774. * @param { string } method - method that will be used to parse the attributes
  5775. * @returns { Array|string } result of the parsing in a list or a single value
  5776. * @private
  5777. */
  5778. function parseNodes(els, name, method) {
  5779. const names = typeof name === 'string' ? [name] : name;
  5780. return normalize(domToArray(els).map(el => {
  5781. return normalize(names.map(n => el[method](n)));
  5782. }));
  5783. }
  5784. /**
  5785. * Set any attribute on a single or a list of DOM nodes
  5786. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  5787. * @param { string|Object } name - either the name of the attribute to set
  5788. * or a list of properties as object key - value
  5789. * @param { string } value - the new value of the attribute (optional)
  5790. * @returns { HTMLElement|NodeList|Array } the original array of elements passed to this function
  5791. *
  5792. * @example
  5793. *
  5794. * import { set } from 'bianco.attr'
  5795. *
  5796. * const img = document.createElement('img')
  5797. *
  5798. * set(img, 'width', 100)
  5799. *
  5800. * // or also
  5801. * set(img, {
  5802. * width: 300,
  5803. * height: 300
  5804. * })
  5805. *
  5806. */
  5807. function set(els, name, value) {
  5808. const attrs = typeof name === 'object' ? name : {
  5809. [name]: value
  5810. };
  5811. const props = Object.keys(attrs);
  5812. domToArray(els).forEach(el => {
  5813. props.forEach(prop => el.setAttribute(prop, attrs[prop]));
  5814. });
  5815. return els;
  5816. }
  5817. /**
  5818. * Get any attribute from a single or a list of DOM nodes
  5819. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  5820. * @param { string|Array } name - name or list of attributes to get
  5821. * @returns { Array|string } list of the attributes found
  5822. *
  5823. * @example
  5824. *
  5825. * import { get } from 'bianco.attr'
  5826. *
  5827. * const img = document.createElement('img')
  5828. *
  5829. * get(img, 'width') // => '200'
  5830. *
  5831. * // or also
  5832. * get(img, ['width', 'height']) // => ['200', '300']
  5833. *
  5834. * // or also
  5835. * get([img1, img2], ['width', 'height']) // => [['200', '300'], ['500', '200']]
  5836. */
  5837. function get(els, name) {
  5838. return parseNodes(els, name, 'getAttribute');
  5839. }
  5840. const CSS_BY_NAME = new Map();
  5841. const STYLE_NODE_SELECTOR = 'style[riot]'; // memoized curried function
  5842. const getStyleNode = (style => {
  5843. return () => {
  5844. // lazy evaluation:
  5845. // if this function was already called before
  5846. // we return its cached result
  5847. if (style) return style; // create a new style element or use an existing one
  5848. // and cache it internally
  5849. style = $(STYLE_NODE_SELECTOR)[0] || document.createElement('style');
  5850. set(style, 'type', 'text/css');
  5851. /* istanbul ignore next */
  5852. if (!style.parentNode) document.head.appendChild(style);
  5853. return style;
  5854. };
  5855. })();
  5856. /**
  5857. * Object that will be used to inject and manage the css of every tag instance
  5858. */
  5859. var cssManager = {
  5860. CSS_BY_NAME,
  5861. /**
  5862. * Save a tag style to be later injected into DOM
  5863. * @param { string } name - if it's passed we will map the css to a tagname
  5864. * @param { string } css - css string
  5865. * @returns {Object} self
  5866. */
  5867. add(name, css) {
  5868. if (!CSS_BY_NAME.has(name)) {
  5869. CSS_BY_NAME.set(name, css);
  5870. this.inject();
  5871. }
  5872. return this;
  5873. },
  5874. /**
  5875. * Inject all previously saved tag styles into DOM
  5876. * innerHTML seems slow: http://jsperf.com/riot-insert-style
  5877. * @returns {Object} self
  5878. */
  5879. inject() {
  5880. getStyleNode().innerHTML = [...CSS_BY_NAME.values()].join('\n');
  5881. return this;
  5882. },
  5883. /**
  5884. * Remove a tag style from the DOM
  5885. * @param {string} name a registered tagname
  5886. * @returns {Object} self
  5887. */
  5888. remove(name) {
  5889. if (CSS_BY_NAME.has(name)) {
  5890. CSS_BY_NAME.delete(name);
  5891. this.inject();
  5892. }
  5893. return this;
  5894. }
  5895. };
  5896. /**
  5897. * Function to curry any javascript method
  5898. * @param {Function} fn - the target function we want to curry
  5899. * @param {...[args]} acc - initial arguments
  5900. * @returns {Function|*} it will return a function until the target function
  5901. * will receive all of its arguments
  5902. */
  5903. function curry(fn) {
  5904. for (var _len = arguments.length, acc = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5905. acc[_key - 1] = arguments[_key];
  5906. }
  5907. return function () {
  5908. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  5909. args[_key2] = arguments[_key2];
  5910. }
  5911. args = [...acc, ...args];
  5912. return args.length < fn.length ? curry(fn, ...args) : fn(...args);
  5913. };
  5914. }
  5915. /**
  5916. * Get the tag name of any DOM node
  5917. * @param {HTMLElement} element - DOM node we want to inspect
  5918. * @returns {string} name to identify this dom node in riot
  5919. */
  5920. function getName(element) {
  5921. return get(element, IS_DIRECTIVE) || element.tagName.toLowerCase();
  5922. }
  5923. const COMPONENT_CORE_HELPERS = Object.freeze({
  5924. // component helpers
  5925. $(selector) {
  5926. return $(selector, this.root)[0];
  5927. },
  5928. $$(selector) {
  5929. return $(selector, this.root);
  5930. }
  5931. });
  5932. const PURE_COMPONENT_API = Object.freeze({
  5933. [MOUNT_METHOD_KEY]: noop,
  5934. [UPDATE_METHOD_KEY]: noop,
  5935. [UNMOUNT_METHOD_KEY]: noop
  5936. });
  5937. const COMPONENT_LIFECYCLE_METHODS = Object.freeze({
  5938. [SHOULD_UPDATE_KEY]: noop,
  5939. [ON_BEFORE_MOUNT_KEY]: noop,
  5940. [ON_MOUNTED_KEY]: noop,
  5941. [ON_BEFORE_UPDATE_KEY]: noop,
  5942. [ON_UPDATED_KEY]: noop,
  5943. [ON_BEFORE_UNMOUNT_KEY]: noop,
  5944. [ON_UNMOUNTED_KEY]: noop
  5945. });
  5946. const MOCKED_TEMPLATE_INTERFACE = Object.assign({}, PURE_COMPONENT_API, {
  5947. clone: noop,
  5948. createDOM: noop
  5949. });
  5950. /**
  5951. * Performance optimization for the recursive components
  5952. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  5953. * @returns {Object} component like interface
  5954. */
  5955. const memoizedCreateComponent = memoize(createComponent);
  5956. /**
  5957. * Evaluate the component properties either from its real attributes or from its initial user properties
  5958. * @param {HTMLElement} element - component root
  5959. * @param {Object} initialProps - initial props
  5960. * @returns {Object} component props key value pairs
  5961. */
  5962. function evaluateInitialProps(element, initialProps) {
  5963. if (initialProps === void 0) {
  5964. initialProps = {};
  5965. }
  5966. return Object.assign({}, DOMattributesToObject(element), callOrAssign(initialProps));
  5967. }
  5968. /**
  5969. * Bind a DOM node to its component object
  5970. * @param {HTMLElement} node - html node mounted
  5971. * @param {Object} component - Riot.js component object
  5972. * @returns {Object} the component object received as second argument
  5973. */
  5974. const bindDOMNodeToComponentObject = (node, component) => node[DOM_COMPONENT_INSTANCE_PROPERTY$1] = component;
  5975. /**
  5976. * Wrap the Riot.js core API methods using a mapping function
  5977. * @param {Function} mapFunction - lifting function
  5978. * @returns {Object} an object having the { mount, update, unmount } functions
  5979. */
  5980. function createCoreAPIMethods(mapFunction) {
  5981. return [MOUNT_METHOD_KEY, UPDATE_METHOD_KEY, UNMOUNT_METHOD_KEY].reduce((acc, method) => {
  5982. acc[method] = mapFunction(method);
  5983. return acc;
  5984. }, {});
  5985. }
  5986. /**
  5987. * Factory function to create the component templates only once
  5988. * @param {Function} template - component template creation function
  5989. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  5990. * @returns {TemplateChunk} template chunk object
  5991. */
  5992. function componentTemplateFactory(template, componentWrapper) {
  5993. const components = createSubcomponents(componentWrapper.exports ? componentWrapper.exports.components : {});
  5994. return template(create, expressionTypes, bindingTypes, name => {
  5995. // improve support for recursive components
  5996. if (name === componentWrapper.name) return memoizedCreateComponent(componentWrapper); // return the registered components
  5997. return components[name] || COMPONENTS_IMPLEMENTATION_MAP$1.get(name);
  5998. });
  5999. }
  6000. /**
  6001. * Create a pure component
  6002. * @param {Function} pureFactoryFunction - pure component factory function
  6003. * @param {Array} options.slots - component slots
  6004. * @param {Array} options.attributes - component attributes
  6005. * @param {Array} options.template - template factory function
  6006. * @param {Array} options.template - template factory function
  6007. * @param {any} options.props - initial component properties
  6008. * @returns {Object} pure component object
  6009. */
  6010. function createPureComponent(pureFactoryFunction, _ref) {
  6011. let {
  6012. slots,
  6013. attributes,
  6014. props,
  6015. css,
  6016. template
  6017. } = _ref;
  6018. if (template) panic('Pure components can not have html');
  6019. if (css) panic('Pure components do not have css');
  6020. const component = defineDefaults(pureFactoryFunction({
  6021. slots,
  6022. attributes,
  6023. props
  6024. }), PURE_COMPONENT_API);
  6025. return createCoreAPIMethods(method => function () {
  6026. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6027. args[_key] = arguments[_key];
  6028. }
  6029. // intercept the mount calls to bind the DOM node to the pure object created
  6030. // see also https://github.com/riot/riot/issues/2806
  6031. if (method === MOUNT_METHOD_KEY) {
  6032. const [element] = args; // mark this node as pure element
  6033. defineProperty(element, IS_PURE_SYMBOL, true);
  6034. bindDOMNodeToComponentObject(element, component);
  6035. }
  6036. component[method](...args);
  6037. return component;
  6038. });
  6039. }
  6040. /**
  6041. * Create the component interface needed for the @riotjs/dom-bindings tag bindings
  6042. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  6043. * @param {string} componentWrapper.css - component css
  6044. * @param {Function} componentWrapper.template - function that will return the dom-bindings template function
  6045. * @param {Object} componentWrapper.exports - component interface
  6046. * @param {string} componentWrapper.name - component name
  6047. * @returns {Object} component like interface
  6048. */
  6049. function createComponent(componentWrapper) {
  6050. const {
  6051. css,
  6052. template,
  6053. exports,
  6054. name
  6055. } = componentWrapper;
  6056. const templateFn = template ? componentTemplateFactory(template, componentWrapper) : MOCKED_TEMPLATE_INTERFACE;
  6057. return _ref2 => {
  6058. let {
  6059. slots,
  6060. attributes,
  6061. props
  6062. } = _ref2;
  6063. // pure components rendering will be managed by the end user
  6064. if (exports && exports[IS_PURE_SYMBOL]) return createPureComponent(exports, {
  6065. slots,
  6066. attributes,
  6067. props,
  6068. css,
  6069. template
  6070. });
  6071. const componentAPI = callOrAssign(exports) || {};
  6072. const component = defineComponent({
  6073. css,
  6074. template: templateFn,
  6075. componentAPI,
  6076. name
  6077. })({
  6078. slots,
  6079. attributes,
  6080. props
  6081. }); // notice that for the components create via tag binding
  6082. // we need to invert the mount (state/parentScope) arguments
  6083. // the template bindings will only forward the parentScope updates
  6084. // and never deal with the component state
  6085. return {
  6086. mount(element, parentScope, state) {
  6087. return component.mount(element, state, parentScope);
  6088. },
  6089. update(parentScope, state) {
  6090. return component.update(state, parentScope);
  6091. },
  6092. unmount(preserveRoot) {
  6093. return component.unmount(preserveRoot);
  6094. }
  6095. };
  6096. };
  6097. }
  6098. /**
  6099. * Component definition function
  6100. * @param {Object} implementation - the componen implementation will be generated via compiler
  6101. * @param {Object} component - the component initial properties
  6102. * @returns {Object} a new component implementation object
  6103. */
  6104. function defineComponent(_ref3) {
  6105. let {
  6106. css,
  6107. template,
  6108. componentAPI,
  6109. name
  6110. } = _ref3;
  6111. // add the component css into the DOM
  6112. if (css && name) cssManager.add(name, css);
  6113. return curry(enhanceComponentAPI)(defineProperties( // set the component defaults without overriding the original component API
  6114. defineDefaults(componentAPI, Object.assign({}, COMPONENT_LIFECYCLE_METHODS, {
  6115. [PROPS_KEY]: {},
  6116. [STATE_KEY]: {}
  6117. })), Object.assign({
  6118. // defined during the component creation
  6119. [SLOTS_KEY]: null,
  6120. [ROOT_KEY]: null
  6121. }, COMPONENT_CORE_HELPERS, {
  6122. name,
  6123. css,
  6124. template
  6125. })));
  6126. }
  6127. /**
  6128. * Create the bindings to update the component attributes
  6129. * @param {HTMLElement} node - node where we will bind the expressions
  6130. * @param {Array} attributes - list of attribute bindings
  6131. * @returns {TemplateChunk} - template bindings object
  6132. */
  6133. function createAttributeBindings(node, attributes) {
  6134. if (attributes === void 0) {
  6135. attributes = [];
  6136. }
  6137. const expressions = attributes.map(a => create$4(node, a));
  6138. const binding = {};
  6139. return Object.assign(binding, Object.assign({
  6140. expressions
  6141. }, createCoreAPIMethods(method => scope => {
  6142. expressions.forEach(e => e[method](scope));
  6143. return binding;
  6144. })));
  6145. }
  6146. /**
  6147. * Create the subcomponents that can be included inside a tag in runtime
  6148. * @param {Object} components - components imported in runtime
  6149. * @returns {Object} all the components transformed into Riot.Component factory functions
  6150. */
  6151. function createSubcomponents(components) {
  6152. if (components === void 0) {
  6153. components = {};
  6154. }
  6155. return Object.entries(callOrAssign(components)).reduce((acc, _ref4) => {
  6156. let [key, value] = _ref4;
  6157. acc[camelToDashCase(key)] = createComponent(value);
  6158. return acc;
  6159. }, {});
  6160. }
  6161. /**
  6162. * Run the component instance through all the plugins set by the user
  6163. * @param {Object} component - component instance
  6164. * @returns {Object} the component enhanced by the plugins
  6165. */
  6166. function runPlugins(component) {
  6167. return [...PLUGINS_SET$1].reduce((c, fn) => fn(c) || c, component);
  6168. }
  6169. /**
  6170. * Compute the component current state merging it with its previous state
  6171. * @param {Object} oldState - previous state object
  6172. * @param {Object} newState - new state givent to the `update` call
  6173. * @returns {Object} new object state
  6174. */
  6175. function computeState(oldState, newState) {
  6176. return Object.assign({}, oldState, callOrAssign(newState));
  6177. }
  6178. /**
  6179. * Add eventually the "is" attribute to link this DOM node to its css
  6180. * @param {HTMLElement} element - target root node
  6181. * @param {string} name - name of the component mounted
  6182. * @returns {undefined} it's a void function
  6183. */
  6184. function addCssHook(element, name) {
  6185. if (getName(element) !== name) {
  6186. set(element, IS_DIRECTIVE, name);
  6187. }
  6188. }
  6189. /**
  6190. * Component creation factory function that will enhance the user provided API
  6191. * @param {Object} component - a component implementation previously defined
  6192. * @param {Array} options.slots - component slots generated via riot compiler
  6193. * @param {Array} options.attributes - attribute expressions generated via riot compiler
  6194. * @returns {Riot.Component} a riot component instance
  6195. */
  6196. function enhanceComponentAPI(component, _ref5) {
  6197. let {
  6198. slots,
  6199. attributes,
  6200. props
  6201. } = _ref5;
  6202. return autobindMethods(runPlugins(defineProperties(isObject(component) ? Object.create(component) : component, {
  6203. mount(element, state, parentScope) {
  6204. if (state === void 0) {
  6205. state = {};
  6206. }
  6207. // any element mounted passing through this function can't be a pure component
  6208. defineProperty(element, IS_PURE_SYMBOL, false);
  6209. this[PARENT_KEY_SYMBOL] = parentScope;
  6210. this[ATTRIBUTES_KEY_SYMBOL] = createAttributeBindings(element, attributes).mount(parentScope);
  6211. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, evaluateInitialProps(element, props), evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions))));
  6212. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  6213. this[TEMPLATE_KEY_SYMBOL] = this.template.createDOM(element).clone(); // link this object to the DOM node
  6214. bindDOMNodeToComponentObject(element, this); // add eventually the 'is' attribute
  6215. component.name && addCssHook(element, component.name); // define the root element
  6216. defineProperty(this, ROOT_KEY, element); // define the slots array
  6217. defineProperty(this, SLOTS_KEY, slots); // before mount lifecycle event
  6218. this[ON_BEFORE_MOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]); // mount the template
  6219. this[TEMPLATE_KEY_SYMBOL].mount(element, this, parentScope);
  6220. this[ON_MOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6221. return this;
  6222. },
  6223. update(state, parentScope) {
  6224. if (state === void 0) {
  6225. state = {};
  6226. }
  6227. if (parentScope) {
  6228. this[PARENT_KEY_SYMBOL] = parentScope;
  6229. this[ATTRIBUTES_KEY_SYMBOL].update(parentScope);
  6230. }
  6231. const newProps = evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions);
  6232. if (this[SHOULD_UPDATE_KEY](newProps, this[PROPS_KEY]) === false) return;
  6233. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, this[PROPS_KEY], newProps)));
  6234. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  6235. this[ON_BEFORE_UPDATE_KEY](this[PROPS_KEY], this[STATE_KEY]); // avoiding recursive updates
  6236. // see also https://github.com/riot/riot/issues/2895
  6237. if (!this[IS_COMPONENT_UPDATING]) {
  6238. this[IS_COMPONENT_UPDATING] = true;
  6239. this[TEMPLATE_KEY_SYMBOL].update(this, this[PARENT_KEY_SYMBOL]);
  6240. }
  6241. this[ON_UPDATED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6242. this[IS_COMPONENT_UPDATING] = false;
  6243. return this;
  6244. },
  6245. unmount(preserveRoot) {
  6246. this[ON_BEFORE_UNMOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6247. this[ATTRIBUTES_KEY_SYMBOL].unmount(); // if the preserveRoot is null the template html will be left untouched
  6248. // in that case the DOM cleanup will happen differently from a parent node
  6249. this[TEMPLATE_KEY_SYMBOL].unmount(this, this[PARENT_KEY_SYMBOL], preserveRoot === null ? null : !preserveRoot);
  6250. this[ON_UNMOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6251. return this;
  6252. }
  6253. })), Object.keys(component).filter(prop => isFunction(component[prop])));
  6254. }
  6255. /**
  6256. * Component initialization function starting from a DOM node
  6257. * @param {HTMLElement} element - element to upgrade
  6258. * @param {Object} initialProps - initial component properties
  6259. * @param {string} componentName - component id
  6260. * @returns {Object} a new component instance bound to a DOM node
  6261. */
  6262. function mountComponent(element, initialProps, componentName) {
  6263. const name = componentName || getName(element);
  6264. if (!COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component named "${name}" was never registered`);
  6265. const component = COMPONENTS_IMPLEMENTATION_MAP$1.get(name)({
  6266. props: initialProps
  6267. });
  6268. return component.mount(element);
  6269. }
  6270. /**
  6271. * Similar to compose but performs from left-to-right function composition.<br/>
  6272. * {@link https://30secondsofcode.org/function#composeright see also}
  6273. * @param {...[function]} fns) - list of unary function
  6274. * @returns {*} result of the computation
  6275. */
  6276. /**
  6277. * Performs right-to-left function composition.<br/>
  6278. * Use Array.prototype.reduce() to perform right-to-left function composition.<br/>
  6279. * The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
  6280. * {@link https://30secondsofcode.org/function#compose original source code}
  6281. * @param {...[function]} fns) - list of unary function
  6282. * @returns {*} result of the computation
  6283. */
  6284. function compose() {
  6285. for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6286. fns[_key2] = arguments[_key2];
  6287. }
  6288. return fns.reduce((f, g) => function () {
  6289. return f(g(...arguments));
  6290. });
  6291. }
  6292. const {
  6293. DOM_COMPONENT_INSTANCE_PROPERTY,
  6294. COMPONENTS_IMPLEMENTATION_MAP,
  6295. PLUGINS_SET
  6296. } = globals;
  6297. /**
  6298. * Riot public api
  6299. */
  6300. /**
  6301. * Register a custom tag by name
  6302. * @param {string} name - component name
  6303. * @param {Object} implementation - tag implementation
  6304. * @returns {Map} map containing all the components implementations
  6305. */
  6306. function register(name, _ref) {
  6307. let {
  6308. css,
  6309. template,
  6310. exports
  6311. } = _ref;
  6312. if (COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was already registered`);
  6313. COMPONENTS_IMPLEMENTATION_MAP.set(name, createComponent({
  6314. name,
  6315. css,
  6316. template,
  6317. exports
  6318. }));
  6319. return COMPONENTS_IMPLEMENTATION_MAP;
  6320. }
  6321. /**
  6322. * Unregister a riot web component
  6323. * @param {string} name - component name
  6324. * @returns {Map} map containing all the components implementations
  6325. */
  6326. function unregister(name) {
  6327. if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was never registered`);
  6328. COMPONENTS_IMPLEMENTATION_MAP.delete(name);
  6329. cssManager.remove(name);
  6330. return COMPONENTS_IMPLEMENTATION_MAP;
  6331. }
  6332. /**
  6333. * Mounting function that will work only for the components that were globally registered
  6334. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  6335. * @param {Object} initialProps - the initial component properties
  6336. * @param {string} name - optional component name
  6337. * @returns {Array} list of riot components
  6338. */
  6339. function mount(selector, initialProps, name) {
  6340. return $(selector).map(element => mountComponent(element, initialProps, name));
  6341. }
  6342. /**
  6343. * Sweet unmounting helper function for the DOM node mounted manually by the user
  6344. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  6345. * @param {boolean|null} keepRootElement - if true keep the root element
  6346. * @returns {Array} list of nodes unmounted
  6347. */
  6348. function unmount(selector, keepRootElement) {
  6349. return $(selector).map(element => {
  6350. if (element[DOM_COMPONENT_INSTANCE_PROPERTY]) {
  6351. element[DOM_COMPONENT_INSTANCE_PROPERTY].unmount(keepRootElement);
  6352. }
  6353. return element;
  6354. });
  6355. }
  6356. /**
  6357. * Define a riot plugin
  6358. * @param {Function} plugin - function that will receive all the components created
  6359. * @returns {Set} the set containing all the plugins installed
  6360. */
  6361. function install(plugin) {
  6362. if (!isFunction(plugin)) panic('Plugins must be of type function');
  6363. if (PLUGINS_SET.has(plugin)) panic('This plugin was already installed');
  6364. PLUGINS_SET.add(plugin);
  6365. return PLUGINS_SET;
  6366. }
  6367. /**
  6368. * Uninstall a riot plugin
  6369. * @param {Function} plugin - plugin previously installed
  6370. * @returns {Set} the set containing all the plugins installed
  6371. */
  6372. function uninstall(plugin) {
  6373. if (!PLUGINS_SET.has(plugin)) panic('This plugin was never installed');
  6374. PLUGINS_SET.delete(plugin);
  6375. return PLUGINS_SET;
  6376. }
  6377. /**
  6378. * Helper method to create component without relying on the registered ones
  6379. * @param {Object} implementation - component implementation
  6380. * @returns {Function} function that will allow you to mount a riot component on a DOM node
  6381. */
  6382. function component(implementation) {
  6383. return function (el, props, _temp) {
  6384. let {
  6385. slots,
  6386. attributes,
  6387. parentScope
  6388. } = _temp === void 0 ? {} : _temp;
  6389. return compose(c => c.mount(el, parentScope), c => c({
  6390. props,
  6391. slots,
  6392. attributes
  6393. }), createComponent)(implementation);
  6394. };
  6395. }
  6396. /**
  6397. * Lift a riot component Interface into a pure riot object
  6398. * @param {Function} func - RiotPureComponent factory function
  6399. * @returns {Function} the lifted original function received as argument
  6400. */
  6401. function pure(func) {
  6402. if (!isFunction(func)) panic('riot.pure accepts only arguments of type "function"');
  6403. func[IS_PURE_SYMBOL] = true;
  6404. return func;
  6405. }
  6406. /**
  6407. * no-op function needed to add the proper types to your component via typescript
  6408. * @param {Function|Object} component - component default export
  6409. * @returns {Function|Object} returns exactly what it has received
  6410. */
  6411. const withTypes = component => component;
  6412. /** @type {string} current riot version */
  6413. const version = 'v6.0.3'; // expose some internal stuff that might be used from external tools
  6414. const __ = {
  6415. cssManager,
  6416. DOMBindings,
  6417. createComponent,
  6418. defineComponent,
  6419. globals
  6420. };
  6421. /***/ }),
  6422. /***/ "./node_modules/axios/package.json":
  6423. /*!*****************************************!*\
  6424. !*** ./node_modules/axios/package.json ***!
  6425. \*****************************************/
  6426. /***/ ((module) => {
  6427. "use strict";
  6428. module.exports = JSON.parse('{"_from":"axios@^0.21.1","_id":"axios@0.21.4","_inBundle":false,"_integrity":"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"axios@^0.21.1","name":"axios","escapedName":"axios","rawSpec":"^0.21.1","saveSpec":null,"fetchSpec":"^0.21.1"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz","_shasum":"c67b90dc0568e5c1cf2b0b858c43ba28e2eda575","_spec":"axios@^0.21.1","_where":"/home/herrhase/Workspace/herrhase/nano-buckets","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundleDependencies":false,"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"^1.14.0"},"deprecated":false,"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"homepage":"https://axios-http.com","jsdelivr":"dist/axios.min.js","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","unpkg":"dist/axios.min.js","version":"0.21.4"}');
  6429. /***/ })
  6430. /******/ });
  6431. /************************************************************************/
  6432. /******/ // The module cache
  6433. /******/ var __webpack_module_cache__ = {};
  6434. /******/
  6435. /******/ // The require function
  6436. /******/ function __webpack_require__(moduleId) {
  6437. /******/ // Check if module is in cache
  6438. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  6439. /******/ if (cachedModule !== undefined) {
  6440. /******/ return cachedModule.exports;
  6441. /******/ }
  6442. /******/ // Create a new module (and put it into the cache)
  6443. /******/ var module = __webpack_module_cache__[moduleId] = {
  6444. /******/ id: moduleId,
  6445. /******/ loaded: false,
  6446. /******/ exports: {}
  6447. /******/ };
  6448. /******/
  6449. /******/ // Execute the module function
  6450. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  6451. /******/
  6452. /******/ // Flag the module as loaded
  6453. /******/ module.loaded = true;
  6454. /******/
  6455. /******/ // Return the exports of the module
  6456. /******/ return module.exports;
  6457. /******/ }
  6458. /******/
  6459. /************************************************************************/
  6460. /******/ /* webpack/runtime/compat get default export */
  6461. /******/ (() => {
  6462. /******/ // getDefaultExport function for compatibility with non-harmony modules
  6463. /******/ __webpack_require__.n = (module) => {
  6464. /******/ var getter = module && module.__esModule ?
  6465. /******/ () => (module['default']) :
  6466. /******/ () => (module);
  6467. /******/ __webpack_require__.d(getter, { a: getter });
  6468. /******/ return getter;
  6469. /******/ };
  6470. /******/ })();
  6471. /******/
  6472. /******/ /* webpack/runtime/define property getters */
  6473. /******/ (() => {
  6474. /******/ // define getter functions for harmony exports
  6475. /******/ __webpack_require__.d = (exports, definition) => {
  6476. /******/ for(var key in definition) {
  6477. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  6478. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  6479. /******/ }
  6480. /******/ }
  6481. /******/ };
  6482. /******/ })();
  6483. /******/
  6484. /******/ /* webpack/runtime/global */
  6485. /******/ (() => {
  6486. /******/ __webpack_require__.g = (function() {
  6487. /******/ if (typeof globalThis === 'object') return globalThis;
  6488. /******/ try {
  6489. /******/ return this || new Function('return this')();
  6490. /******/ } catch (e) {
  6491. /******/ if (typeof window === 'object') return window;
  6492. /******/ }
  6493. /******/ })();
  6494. /******/ })();
  6495. /******/
  6496. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  6497. /******/ (() => {
  6498. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  6499. /******/ })();
  6500. /******/
  6501. /******/ /* webpack/runtime/make namespace object */
  6502. /******/ (() => {
  6503. /******/ // define __esModule on exports
  6504. /******/ __webpack_require__.r = (exports) => {
  6505. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  6506. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  6507. /******/ }
  6508. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  6509. /******/ };
  6510. /******/ })();
  6511. /******/
  6512. /******/ /* webpack/runtime/node module decorator */
  6513. /******/ (() => {
  6514. /******/ __webpack_require__.nmd = (module) => {
  6515. /******/ module.paths = [];
  6516. /******/ if (!module.children) module.children = [];
  6517. /******/ return module;
  6518. /******/ };
  6519. /******/ })();
  6520. /******/
  6521. /************************************************************************/
  6522. var __webpack_exports__ = {};
  6523. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  6524. (() => {
  6525. "use strict";
  6526. /*!***********************************!*\
  6527. !*** ./resources/js/dashboard.js ***!
  6528. \***********************************/
  6529. __webpack_require__.r(__webpack_exports__);
  6530. /* harmony import */ var riot__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! riot */ "./node_modules/riot/riot.esm.js");
  6531. /* harmony import */ var _components_buckets_riot__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/buckets.riot */ "./resources/js/components/buckets.riot");
  6532. // register components for buckets
  6533. riot__WEBPACK_IMPORTED_MODULE_1__.register('app-buckets', _components_buckets_riot__WEBPACK_IMPORTED_MODULE_0__["default"]);
  6534. riot__WEBPACK_IMPORTED_MODULE_1__.mount('app-buckets');
  6535. })();
  6536. /******/ })()
  6537. ;