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.

9418 lines
271 KiB

  1. /******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ "./resources/js/components/field-error.riot":
  4. /*!**************************************************!*\
  5. !*** ./resources/js/components/field-error.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 default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  14. 'css': null,
  15. 'exports': {
  16. state: {
  17. errors: [
  18. ],
  19. },
  20. /**
  21. *
  22. *
  23. * @param {Object} props [description]
  24. * @param {Object} state [description]
  25. *
  26. */
  27. onMounted(props, state)
  28. {
  29. // getting parent element for entire field
  30. const parent = this.root.closest('.field-group')
  31. // getting current element by name
  32. const element = document.querySelector('[name="' + props.name + '"]')
  33. // getting form
  34. const form = element.closest('form')
  35. // element, form are exists and nofieldupdate is not set
  36. // each change of the element dispatch a event to form validation
  37. if (element && form && !props.nofieldupdate) {
  38. element.addEventListener('input', (event) => {
  39. this.dispatchCustomEvent(event, form, props.name)
  40. })
  41. }
  42. // add custom event to listen to form-validation
  43. this.root.addEventListener('form-validation', (event) => {
  44. this.onFormValidation(event, parent)
  45. })
  46. },
  47. /**
  48. * process form validation triggered by form
  49. *
  50. * @param {Event} event
  51. * @param {Element} parent
  52. *
  53. */
  54. onFormValidation(event, parent)
  55. {
  56. // if detail is a value, set to errors
  57. if (event.detail) {
  58. this.state.errors = event.detail
  59. parent.classList.add('field--error')
  60. parent.classList.remove('field--valid')
  61. } else {
  62. this.state.errors = []
  63. parent.classList.remove('field--error')
  64. parent.classList.add('field--valid')
  65. }
  66. this.update()
  67. },
  68. /**
  69. * create event to send to form validation
  70. *
  71. * @param {Event} event
  72. * @param {Element} form
  73. * @param {string} name
  74. *
  75. */
  76. dispatchCustomEvent(event, form, name)
  77. {
  78. const fieldUpdateEvent = new CustomEvent('field-update', {
  79. 'detail': {
  80. 'name': name,
  81. 'value': event.target.value
  82. }
  83. })
  84. form.dispatchEvent(fieldUpdateEvent)
  85. }
  86. },
  87. 'template': function(
  88. template,
  89. expressionTypes,
  90. bindingTypes,
  91. getComponent
  92. ) {
  93. return template(
  94. '<div expr4="expr4" class="field-error"></div>',
  95. [
  96. {
  97. 'type': bindingTypes.IF,
  98. 'evaluate': function(
  99. _scope
  100. ) {
  101. return _scope.state.errors.length > 0;
  102. },
  103. 'redundantAttribute': 'expr4',
  104. 'selector': '[expr4]',
  105. 'template': template(
  106. '<ul><li expr5="expr5"></li></ul>',
  107. [
  108. {
  109. 'type': bindingTypes.EACH,
  110. 'getKey': null,
  111. 'condition': null,
  112. 'template': template(
  113. ' ',
  114. [
  115. {
  116. 'expressions': [
  117. {
  118. 'type': expressionTypes.TEXT,
  119. 'childNodeIndex': 0,
  120. 'evaluate': function(
  121. _scope
  122. ) {
  123. return [
  124. _scope.error
  125. ].join(
  126. ''
  127. );
  128. }
  129. }
  130. ]
  131. }
  132. ]
  133. ),
  134. 'redundantAttribute': 'expr5',
  135. 'selector': '[expr5]',
  136. 'itemName': 'error',
  137. 'indexName': null,
  138. 'evaluate': function(
  139. _scope
  140. ) {
  141. return _scope.state.errors;
  142. }
  143. }
  144. ]
  145. )
  146. }
  147. ]
  148. );
  149. },
  150. 'name': 'field-error'
  151. });
  152. /***/ }),
  153. /***/ "./resources/js/components/sidebar-button.riot":
  154. /*!*****************************************************!*\
  155. !*** ./resources/js/components/sidebar-button.riot ***!
  156. \*****************************************************/
  157. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  158. "use strict";
  159. __webpack_require__.r(__webpack_exports__);
  160. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  161. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  162. /* harmony export */ });
  163. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  164. 'css': null,
  165. 'exports': {
  166. state: {
  167. element: undefined,
  168. data: []
  169. },
  170. /**
  171. *
  172. *
  173. */
  174. onBeforeMount() {
  175. // getting innerHtml before rendering component
  176. this.content = this.root.innerHTML;
  177. this.root.innerHTML = '';
  178. },
  179. /**
  180. *
  181. *
  182. */
  183. onMounted() {
  184. this.state.element = document.querySelector(this.props.selector)
  185. // adding innerHtml to button
  186. this.$('button').innerHTML = this.content;
  187. },
  188. /**
  189. *
  190. * @param {[type]} event
  191. * @return {[type]}
  192. */
  193. handleClick(event) {
  194. event.preventDefault()
  195. const customEvent = new CustomEvent(this.props.event)
  196. this.state.element.dispatchEvent(customEvent, this.state.data)
  197. }
  198. },
  199. 'template': function(
  200. template,
  201. expressionTypes,
  202. bindingTypes,
  203. getComponent
  204. ) {
  205. return template(
  206. '<button expr0="expr0" class="button m-bottom-0" type="button"></button>',
  207. [
  208. {
  209. 'redundantAttribute': 'expr0',
  210. 'selector': '[expr0]',
  211. 'expressions': [
  212. {
  213. 'type': expressionTypes.EVENT,
  214. 'name': 'onclick',
  215. 'evaluate': function(
  216. _scope
  217. ) {
  218. return (event) => { _scope.handleClick(event) };
  219. }
  220. }
  221. ]
  222. }
  223. ]
  224. );
  225. },
  226. 'name': 'app-sidebar-button'
  227. });
  228. /***/ }),
  229. /***/ "./resources/js/components/users.riot":
  230. /*!********************************************!*\
  231. !*** ./resources/js/components/users.riot ***!
  232. \********************************************/
  233. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  234. "use strict";
  235. __webpack_require__.r(__webpack_exports__);
  236. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  237. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  238. /* harmony export */ });
  239. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  240. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);
  241. /* harmony import */ var lodash_remove__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.remove */ "./node_modules/lodash.remove/index.js");
  242. /* harmony import */ var lodash_remove__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_remove__WEBPACK_IMPORTED_MODULE_1__);
  243. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  244. 'css': null,
  245. 'exports': {
  246. state: {
  247. users: [],
  248. maxLength: 0
  249. },
  250. onBeforeMount() {
  251. this.fetch()
  252. },
  253. handleClick() {
  254. },
  255. handleDelete(event, bucket) {
  256. event.preventDefault()
  257. axios__WEBPACK_IMPORTED_MODULE_0___default().delete('/api/bucket/' + bucket._id)
  258. .then((response) => {
  259. // removing from buckets
  260. lodash_remove__WEBPACK_IMPORTED_MODULE_1___default()(this.state.buckets, function(b) {
  261. return b._id === bucket._id
  262. })
  263. this.update()
  264. })
  265. },
  266. /**
  267. * getting all buckets
  268. *
  269. *
  270. */
  271. fetch() {
  272. axios__WEBPACK_IMPORTED_MODULE_0___default().get('/api/users').then((response) => {
  273. this.state.users = response.data.data
  274. this.update()
  275. })
  276. }
  277. },
  278. 'template': function(
  279. template,
  280. expressionTypes,
  281. bindingTypes,
  282. getComponent
  283. ) {
  284. return template(
  285. '<div class="buckets"><table class="table"><tbody><tr expr6="expr6"></tr></tbody></table><div expr10="expr10" class="grid"></div></div>',
  286. [
  287. {
  288. 'type': bindingTypes.EACH,
  289. 'getKey': null,
  290. 'condition': null,
  291. 'template': template(
  292. '<td expr7="expr7" class="table__td"> </td><td expr8="expr8" class="table__td"> </td><td expr9="expr9" class="table__td"> </td><td class="table__td"><button class="button button--small m-bottom-0 m-right-3"><svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-edit"/></svg></button><button class="button button--small m-bottom-0" type="button"><svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-delete"/></svg></button></td>',
  293. [
  294. {
  295. 'redundantAttribute': 'expr7',
  296. 'selector': '[expr7]',
  297. 'expressions': [
  298. {
  299. 'type': expressionTypes.TEXT,
  300. 'childNodeIndex': 0,
  301. 'evaluate': function(
  302. _scope
  303. ) {
  304. return [
  305. _scope.user.display_name
  306. ].join(
  307. ''
  308. );
  309. }
  310. }
  311. ]
  312. },
  313. {
  314. 'redundantAttribute': 'expr8',
  315. 'selector': '[expr8]',
  316. 'expressions': [
  317. {
  318. 'type': expressionTypes.TEXT,
  319. 'childNodeIndex': 0,
  320. 'evaluate': function(
  321. _scope
  322. ) {
  323. return [
  324. _scope.user.email
  325. ].join(
  326. ''
  327. );
  328. }
  329. }
  330. ]
  331. },
  332. {
  333. 'redundantAttribute': 'expr9',
  334. 'selector': '[expr9]',
  335. 'expressions': [
  336. {
  337. 'type': expressionTypes.TEXT,
  338. 'childNodeIndex': 0,
  339. 'evaluate': function(
  340. _scope
  341. ) {
  342. return [
  343. _scope.user.is_admin
  344. ].join(
  345. ''
  346. );
  347. }
  348. }
  349. ]
  350. }
  351. ]
  352. ),
  353. 'redundantAttribute': 'expr6',
  354. 'selector': '[expr6]',
  355. 'itemName': 'user',
  356. 'indexName': null,
  357. 'evaluate': function(
  358. _scope
  359. ) {
  360. return _scope.state.users;
  361. }
  362. },
  363. {
  364. 'type': bindingTypes.IF,
  365. 'evaluate': function(
  366. _scope
  367. ) {
  368. return _scope.state.maxLength > _scope.state.users.length;
  369. },
  370. 'redundantAttribute': 'expr10',
  371. 'selector': '[expr10]',
  372. 'template': template(
  373. '<div class="col-12"><div class="buckets__more"><button expr11="expr11" 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>',
  374. [
  375. {
  376. 'redundantAttribute': 'expr11',
  377. 'selector': '[expr11]',
  378. 'expressions': [
  379. {
  380. 'type': expressionTypes.EVENT,
  381. 'name': 'onclick',
  382. 'evaluate': function(
  383. _scope
  384. ) {
  385. return _scope.handleClick;
  386. }
  387. }
  388. ]
  389. }
  390. ]
  391. )
  392. }
  393. ]
  394. );
  395. },
  396. 'name': 'app-users'
  397. });
  398. /***/ }),
  399. /***/ "./resources/js/components/users/form.riot":
  400. /*!*************************************************!*\
  401. !*** ./resources/js/components/users/form.riot ***!
  402. \*************************************************/
  403. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  404. "use strict";
  405. __webpack_require__.r(__webpack_exports__);
  406. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  407. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  408. /* harmony export */ });
  409. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  410. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);
  411. /* harmony import */ var riot__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! riot */ "./node_modules/riot/riot.esm.js");
  412. /* harmony import */ var _FormValidator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../FormValidator */ "./resources/js/FormValidator.js");
  413. /* harmony import */ var _field_error_riot__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../field-error.riot */ "./resources/js/components/field-error.riot");
  414. riot__WEBPACK_IMPORTED_MODULE_3__.register('field-error', _field_error_riot__WEBPACK_IMPORTED_MODULE_2__.default)
  415. riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
  416. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  417. 'css': null,
  418. 'exports': {
  419. state: {
  420. user: { }
  421. },
  422. /**
  423. *
  424. *
  425. */
  426. onMounted(props, state) {
  427. this.root.addEventListener('app-users-form-open', (event) => {
  428. this.$('.sidebar').classList.add('sidebar--open')
  429. })
  430. // create form validation
  431. const formValidation = new _FormValidator__WEBPACK_IMPORTED_MODULE_1__.default('#app-users-form', {
  432. 'email': {
  433. 'length': {
  434. 'maximum': 255
  435. },
  436. 'email': true,
  437. 'presence': true
  438. },
  439. 'password': {
  440. 'length': {
  441. 'maximum': 64
  442. },
  443. 'presence': true
  444. }
  445. }, (event, data) => {
  446. this.handleSubmit(event, data)
  447. })
  448. },
  449. handleClose(event)
  450. {
  451. event.preventDefault()
  452. this.$('.sidebar').classList.remove('sidebar--open')
  453. },
  454. /**
  455. *
  456. *
  457. */
  458. handleSubmit(event, data) {
  459. let method = 'post'
  460. if (this.state.user && this.state.user._id) {
  461. method = 'put'
  462. }
  463. axios__WEBPACK_IMPORTED_MODULE_0___default()({
  464. method: method,
  465. url: '/api/users',
  466. data: data
  467. }).then((response) => {
  468. this.state.user = response.data.data
  469. this.update()
  470. })
  471. }
  472. },
  473. 'template': function(
  474. template,
  475. expressionTypes,
  476. bindingTypes,
  477. getComponent
  478. ) {
  479. return template(
  480. '<div class="sidebar"><div class="sidebar__inner"><div class="bar"><div class="bar__main">\n Create User\n </div><div class="bar__end"><button expr18="expr18" class="button button--transparent" type="button"><svg class="icon fill-text-contrast" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-close"/></svg></button></div></div><div class="sidebar__body"><form id="app-users-form" novalidate><div class="field-group"><label class="field-label">\n Display Name\n <input name="display_name" type="text" class="field-text"/></label><field-error expr19="expr19" name="display_name"></field-error></div><div class="field-group"><label class="field-label">\n E-Mail\n <input name="email" type="text" class="field-text"/></label><field-error expr20="expr20" name="email"></field-error></div><div class="field-group"><label class="field-label">\n Password\n <input name="password" type="password" class="field-text"/></label><field-error expr21="expr21" name="password"></field-error></div></form></div><div class="sidebar__footer"><button class="button m-bottom-0" type="submit" form="app-users-form">\n Save\n <svg class="icon fill-success p-left-3" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-check"/></svg></button><button class="button m-bottom-0" type="submit" form="app-users-form">\n Save and Close\n <svg class="icon fill-success p-left-3" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-arrow-right"/></svg></button></div></div></div>',
  481. [
  482. {
  483. 'redundantAttribute': 'expr18',
  484. 'selector': '[expr18]',
  485. 'expressions': [
  486. {
  487. 'type': expressionTypes.EVENT,
  488. 'name': 'onclick',
  489. 'evaluate': function(
  490. _scope
  491. ) {
  492. return (event) => { _scope.handleClose(event) };
  493. }
  494. }
  495. ]
  496. },
  497. {
  498. 'type': bindingTypes.TAG,
  499. 'getComponent': getComponent,
  500. 'evaluate': function(
  501. _scope
  502. ) {
  503. return 'field-error';
  504. },
  505. 'slots': [],
  506. 'attributes': [],
  507. 'redundantAttribute': 'expr19',
  508. 'selector': '[expr19]'
  509. },
  510. {
  511. 'type': bindingTypes.TAG,
  512. 'getComponent': getComponent,
  513. 'evaluate': function(
  514. _scope
  515. ) {
  516. return 'field-error';
  517. },
  518. 'slots': [],
  519. 'attributes': [],
  520. 'redundantAttribute': 'expr20',
  521. 'selector': '[expr20]'
  522. },
  523. {
  524. 'type': bindingTypes.TAG,
  525. 'getComponent': getComponent,
  526. 'evaluate': function(
  527. _scope
  528. ) {
  529. return 'field-error';
  530. },
  531. 'slots': [],
  532. 'attributes': [],
  533. 'redundantAttribute': 'expr21',
  534. 'selector': '[expr21]'
  535. }
  536. ]
  537. );
  538. },
  539. 'name': 'app-users-form'
  540. });
  541. /***/ }),
  542. /***/ "./node_modules/axios/index.js":
  543. /*!*************************************!*\
  544. !*** ./node_modules/axios/index.js ***!
  545. \*************************************/
  546. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  547. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  548. /***/ }),
  549. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  550. /*!************************************************!*\
  551. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  552. \************************************************/
  553. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  554. "use strict";
  555. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  556. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  557. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  558. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  559. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  560. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  561. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  562. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  563. module.exports = function xhrAdapter(config) {
  564. return new Promise(function dispatchXhrRequest(resolve, reject) {
  565. var requestData = config.data;
  566. var requestHeaders = config.headers;
  567. if (utils.isFormData(requestData)) {
  568. delete requestHeaders['Content-Type']; // Let the browser set it
  569. }
  570. var request = new XMLHttpRequest();
  571. // HTTP basic authentication
  572. if (config.auth) {
  573. var username = config.auth.username || '';
  574. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  575. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  576. }
  577. var fullPath = buildFullPath(config.baseURL, config.url);
  578. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  579. // Set the request timeout in MS
  580. request.timeout = config.timeout;
  581. // Listen for ready state
  582. request.onreadystatechange = function handleLoad() {
  583. if (!request || request.readyState !== 4) {
  584. return;
  585. }
  586. // The request errored out and we didn't get a response, this will be
  587. // handled by onerror instead
  588. // With one exception: request that using file: protocol, most browsers
  589. // will return status as 0 even though it's a successful request
  590. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  591. return;
  592. }
  593. // Prepare the response
  594. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  595. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  596. var response = {
  597. data: responseData,
  598. status: request.status,
  599. statusText: request.statusText,
  600. headers: responseHeaders,
  601. config: config,
  602. request: request
  603. };
  604. settle(resolve, reject, response);
  605. // Clean up request
  606. request = null;
  607. };
  608. // Handle browser request cancellation (as opposed to a manual cancellation)
  609. request.onabort = function handleAbort() {
  610. if (!request) {
  611. return;
  612. }
  613. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  614. // Clean up request
  615. request = null;
  616. };
  617. // Handle low level network errors
  618. request.onerror = function handleError() {
  619. // Real errors are hidden from us by the browser
  620. // onerror should only fire if it's a network error
  621. reject(createError('Network Error', config, null, request));
  622. // Clean up request
  623. request = null;
  624. };
  625. // Handle timeout
  626. request.ontimeout = function handleTimeout() {
  627. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  628. if (config.timeoutErrorMessage) {
  629. timeoutErrorMessage = config.timeoutErrorMessage;
  630. }
  631. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  632. request));
  633. // Clean up request
  634. request = null;
  635. };
  636. // Add xsrf header
  637. // This is only done if running in a standard browser environment.
  638. // Specifically not if we're in a web worker, or react-native.
  639. if (utils.isStandardBrowserEnv()) {
  640. // Add xsrf header
  641. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  642. cookies.read(config.xsrfCookieName) :
  643. undefined;
  644. if (xsrfValue) {
  645. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  646. }
  647. }
  648. // Add headers to the request
  649. if ('setRequestHeader' in request) {
  650. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  651. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  652. // Remove Content-Type if data is undefined
  653. delete requestHeaders[key];
  654. } else {
  655. // Otherwise add header to the request
  656. request.setRequestHeader(key, val);
  657. }
  658. });
  659. }
  660. // Add withCredentials to request if needed
  661. if (!utils.isUndefined(config.withCredentials)) {
  662. request.withCredentials = !!config.withCredentials;
  663. }
  664. // Add responseType to request if needed
  665. if (config.responseType) {
  666. try {
  667. request.responseType = config.responseType;
  668. } catch (e) {
  669. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  670. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  671. if (config.responseType !== 'json') {
  672. throw e;
  673. }
  674. }
  675. }
  676. // Handle progress if needed
  677. if (typeof config.onDownloadProgress === 'function') {
  678. request.addEventListener('progress', config.onDownloadProgress);
  679. }
  680. // Not all browsers support upload events
  681. if (typeof config.onUploadProgress === 'function' && request.upload) {
  682. request.upload.addEventListener('progress', config.onUploadProgress);
  683. }
  684. if (config.cancelToken) {
  685. // Handle cancellation
  686. config.cancelToken.promise.then(function onCanceled(cancel) {
  687. if (!request) {
  688. return;
  689. }
  690. request.abort();
  691. reject(cancel);
  692. // Clean up request
  693. request = null;
  694. });
  695. }
  696. if (!requestData) {
  697. requestData = null;
  698. }
  699. // Send the request
  700. request.send(requestData);
  701. });
  702. };
  703. /***/ }),
  704. /***/ "./node_modules/axios/lib/axios.js":
  705. /*!*****************************************!*\
  706. !*** ./node_modules/axios/lib/axios.js ***!
  707. \*****************************************/
  708. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  709. "use strict";
  710. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  711. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  712. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  713. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  714. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  715. /**
  716. * Create an instance of Axios
  717. *
  718. * @param {Object} defaultConfig The default config for the instance
  719. * @return {Axios} A new instance of Axios
  720. */
  721. function createInstance(defaultConfig) {
  722. var context = new Axios(defaultConfig);
  723. var instance = bind(Axios.prototype.request, context);
  724. // Copy axios.prototype to instance
  725. utils.extend(instance, Axios.prototype, context);
  726. // Copy context to instance
  727. utils.extend(instance, context);
  728. return instance;
  729. }
  730. // Create the default instance to be exported
  731. var axios = createInstance(defaults);
  732. // Expose Axios class to allow class inheritance
  733. axios.Axios = Axios;
  734. // Factory for creating new instances
  735. axios.create = function create(instanceConfig) {
  736. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  737. };
  738. // Expose Cancel & CancelToken
  739. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  740. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  741. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  742. // Expose all/spread
  743. axios.all = function all(promises) {
  744. return Promise.all(promises);
  745. };
  746. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  747. // Expose isAxiosError
  748. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js");
  749. module.exports = axios;
  750. // Allow use of default import syntax in TypeScript
  751. module.exports.default = axios;
  752. /***/ }),
  753. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  754. /*!*************************************************!*\
  755. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  756. \*************************************************/
  757. /***/ ((module) => {
  758. "use strict";
  759. /**
  760. * A `Cancel` is an object that is thrown when an operation is canceled.
  761. *
  762. * @class
  763. * @param {string=} message The message.
  764. */
  765. function Cancel(message) {
  766. this.message = message;
  767. }
  768. Cancel.prototype.toString = function toString() {
  769. return 'Cancel' + (this.message ? ': ' + this.message : '');
  770. };
  771. Cancel.prototype.__CANCEL__ = true;
  772. module.exports = Cancel;
  773. /***/ }),
  774. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  775. /*!******************************************************!*\
  776. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  777. \******************************************************/
  778. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  779. "use strict";
  780. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  781. /**
  782. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  783. *
  784. * @class
  785. * @param {Function} executor The executor function.
  786. */
  787. function CancelToken(executor) {
  788. if (typeof executor !== 'function') {
  789. throw new TypeError('executor must be a function.');
  790. }
  791. var resolvePromise;
  792. this.promise = new Promise(function promiseExecutor(resolve) {
  793. resolvePromise = resolve;
  794. });
  795. var token = this;
  796. executor(function cancel(message) {
  797. if (token.reason) {
  798. // Cancellation has already been requested
  799. return;
  800. }
  801. token.reason = new Cancel(message);
  802. resolvePromise(token.reason);
  803. });
  804. }
  805. /**
  806. * Throws a `Cancel` if cancellation has been requested.
  807. */
  808. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  809. if (this.reason) {
  810. throw this.reason;
  811. }
  812. };
  813. /**
  814. * Returns an object that contains a new `CancelToken` and a function that, when called,
  815. * cancels the `CancelToken`.
  816. */
  817. CancelToken.source = function source() {
  818. var cancel;
  819. var token = new CancelToken(function executor(c) {
  820. cancel = c;
  821. });
  822. return {
  823. token: token,
  824. cancel: cancel
  825. };
  826. };
  827. module.exports = CancelToken;
  828. /***/ }),
  829. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  830. /*!***************************************************!*\
  831. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  832. \***************************************************/
  833. /***/ ((module) => {
  834. "use strict";
  835. module.exports = function isCancel(value) {
  836. return !!(value && value.__CANCEL__);
  837. };
  838. /***/ }),
  839. /***/ "./node_modules/axios/lib/core/Axios.js":
  840. /*!**********************************************!*\
  841. !*** ./node_modules/axios/lib/core/Axios.js ***!
  842. \**********************************************/
  843. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  844. "use strict";
  845. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  846. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  847. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  848. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  849. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  850. /**
  851. * Create a new instance of Axios
  852. *
  853. * @param {Object} instanceConfig The default config for the instance
  854. */
  855. function Axios(instanceConfig) {
  856. this.defaults = instanceConfig;
  857. this.interceptors = {
  858. request: new InterceptorManager(),
  859. response: new InterceptorManager()
  860. };
  861. }
  862. /**
  863. * Dispatch a request
  864. *
  865. * @param {Object} config The config specific for this request (merged with this.defaults)
  866. */
  867. Axios.prototype.request = function request(config) {
  868. /*eslint no-param-reassign:0*/
  869. // Allow for axios('example/url'[, config]) a la fetch API
  870. if (typeof config === 'string') {
  871. config = arguments[1] || {};
  872. config.url = arguments[0];
  873. } else {
  874. config = config || {};
  875. }
  876. config = mergeConfig(this.defaults, config);
  877. // Set config.method
  878. if (config.method) {
  879. config.method = config.method.toLowerCase();
  880. } else if (this.defaults.method) {
  881. config.method = this.defaults.method.toLowerCase();
  882. } else {
  883. config.method = 'get';
  884. }
  885. // Hook up interceptors middleware
  886. var chain = [dispatchRequest, undefined];
  887. var promise = Promise.resolve(config);
  888. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  889. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  890. });
  891. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  892. chain.push(interceptor.fulfilled, interceptor.rejected);
  893. });
  894. while (chain.length) {
  895. promise = promise.then(chain.shift(), chain.shift());
  896. }
  897. return promise;
  898. };
  899. Axios.prototype.getUri = function getUri(config) {
  900. config = mergeConfig(this.defaults, config);
  901. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  902. };
  903. // Provide aliases for supported request methods
  904. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  905. /*eslint func-names:0*/
  906. Axios.prototype[method] = function(url, config) {
  907. return this.request(mergeConfig(config || {}, {
  908. method: method,
  909. url: url,
  910. data: (config || {}).data
  911. }));
  912. };
  913. });
  914. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  915. /*eslint func-names:0*/
  916. Axios.prototype[method] = function(url, data, config) {
  917. return this.request(mergeConfig(config || {}, {
  918. method: method,
  919. url: url,
  920. data: data
  921. }));
  922. };
  923. });
  924. module.exports = Axios;
  925. /***/ }),
  926. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  927. /*!***********************************************************!*\
  928. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  929. \***********************************************************/
  930. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  931. "use strict";
  932. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  933. function InterceptorManager() {
  934. this.handlers = [];
  935. }
  936. /**
  937. * Add a new interceptor to the stack
  938. *
  939. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  940. * @param {Function} rejected The function to handle `reject` for a `Promise`
  941. *
  942. * @return {Number} An ID used to remove interceptor later
  943. */
  944. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  945. this.handlers.push({
  946. fulfilled: fulfilled,
  947. rejected: rejected
  948. });
  949. return this.handlers.length - 1;
  950. };
  951. /**
  952. * Remove an interceptor from the stack
  953. *
  954. * @param {Number} id The ID that was returned by `use`
  955. */
  956. InterceptorManager.prototype.eject = function eject(id) {
  957. if (this.handlers[id]) {
  958. this.handlers[id] = null;
  959. }
  960. };
  961. /**
  962. * Iterate over all the registered interceptors
  963. *
  964. * This method is particularly useful for skipping over any
  965. * interceptors that may have become `null` calling `eject`.
  966. *
  967. * @param {Function} fn The function to call for each interceptor
  968. */
  969. InterceptorManager.prototype.forEach = function forEach(fn) {
  970. utils.forEach(this.handlers, function forEachHandler(h) {
  971. if (h !== null) {
  972. fn(h);
  973. }
  974. });
  975. };
  976. module.exports = InterceptorManager;
  977. /***/ }),
  978. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  979. /*!******************************************************!*\
  980. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  981. \******************************************************/
  982. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  983. "use strict";
  984. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  985. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  986. /**
  987. * Creates a new URL by combining the baseURL with the requestedURL,
  988. * only when the requestedURL is not already an absolute URL.
  989. * If the requestURL is absolute, this function returns the requestedURL untouched.
  990. *
  991. * @param {string} baseURL The base URL
  992. * @param {string} requestedURL Absolute or relative URL to combine
  993. * @returns {string} The combined full path
  994. */
  995. module.exports = function buildFullPath(baseURL, requestedURL) {
  996. if (baseURL && !isAbsoluteURL(requestedURL)) {
  997. return combineURLs(baseURL, requestedURL);
  998. }
  999. return requestedURL;
  1000. };
  1001. /***/ }),
  1002. /***/ "./node_modules/axios/lib/core/createError.js":
  1003. /*!****************************************************!*\
  1004. !*** ./node_modules/axios/lib/core/createError.js ***!
  1005. \****************************************************/
  1006. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1007. "use strict";
  1008. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  1009. /**
  1010. * Create an Error with the specified message, config, error code, request and response.
  1011. *
  1012. * @param {string} message The error message.
  1013. * @param {Object} config The config.
  1014. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  1015. * @param {Object} [request] The request.
  1016. * @param {Object} [response] The response.
  1017. * @returns {Error} The created error.
  1018. */
  1019. module.exports = function createError(message, config, code, request, response) {
  1020. var error = new Error(message);
  1021. return enhanceError(error, config, code, request, response);
  1022. };
  1023. /***/ }),
  1024. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  1025. /*!********************************************************!*\
  1026. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  1027. \********************************************************/
  1028. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1029. "use strict";
  1030. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1031. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  1032. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  1033. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  1034. /**
  1035. * Throws a `Cancel` if cancellation has been requested.
  1036. */
  1037. function throwIfCancellationRequested(config) {
  1038. if (config.cancelToken) {
  1039. config.cancelToken.throwIfRequested();
  1040. }
  1041. }
  1042. /**
  1043. * Dispatch a request to the server using the configured adapter.
  1044. *
  1045. * @param {object} config The config that is to be used for the request
  1046. * @returns {Promise} The Promise to be fulfilled
  1047. */
  1048. module.exports = function dispatchRequest(config) {
  1049. throwIfCancellationRequested(config);
  1050. // Ensure headers exist
  1051. config.headers = config.headers || {};
  1052. // Transform request data
  1053. config.data = transformData(
  1054. config.data,
  1055. config.headers,
  1056. config.transformRequest
  1057. );
  1058. // Flatten headers
  1059. config.headers = utils.merge(
  1060. config.headers.common || {},
  1061. config.headers[config.method] || {},
  1062. config.headers
  1063. );
  1064. utils.forEach(
  1065. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  1066. function cleanHeaderConfig(method) {
  1067. delete config.headers[method];
  1068. }
  1069. );
  1070. var adapter = config.adapter || defaults.adapter;
  1071. return adapter(config).then(function onAdapterResolution(response) {
  1072. throwIfCancellationRequested(config);
  1073. // Transform response data
  1074. response.data = transformData(
  1075. response.data,
  1076. response.headers,
  1077. config.transformResponse
  1078. );
  1079. return response;
  1080. }, function onAdapterRejection(reason) {
  1081. if (!isCancel(reason)) {
  1082. throwIfCancellationRequested(config);
  1083. // Transform response data
  1084. if (reason && reason.response) {
  1085. reason.response.data = transformData(
  1086. reason.response.data,
  1087. reason.response.headers,
  1088. config.transformResponse
  1089. );
  1090. }
  1091. }
  1092. return Promise.reject(reason);
  1093. });
  1094. };
  1095. /***/ }),
  1096. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  1097. /*!*****************************************************!*\
  1098. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  1099. \*****************************************************/
  1100. /***/ ((module) => {
  1101. "use strict";
  1102. /**
  1103. * Update an Error with the specified config, error code, and response.
  1104. *
  1105. * @param {Error} error The error to update.
  1106. * @param {Object} config The config.
  1107. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  1108. * @param {Object} [request] The request.
  1109. * @param {Object} [response] The response.
  1110. * @returns {Error} The error.
  1111. */
  1112. module.exports = function enhanceError(error, config, code, request, response) {
  1113. error.config = config;
  1114. if (code) {
  1115. error.code = code;
  1116. }
  1117. error.request = request;
  1118. error.response = response;
  1119. error.isAxiosError = true;
  1120. error.toJSON = function toJSON() {
  1121. return {
  1122. // Standard
  1123. message: this.message,
  1124. name: this.name,
  1125. // Microsoft
  1126. description: this.description,
  1127. number: this.number,
  1128. // Mozilla
  1129. fileName: this.fileName,
  1130. lineNumber: this.lineNumber,
  1131. columnNumber: this.columnNumber,
  1132. stack: this.stack,
  1133. // Axios
  1134. config: this.config,
  1135. code: this.code
  1136. };
  1137. };
  1138. return error;
  1139. };
  1140. /***/ }),
  1141. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  1142. /*!****************************************************!*\
  1143. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  1144. \****************************************************/
  1145. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1146. "use strict";
  1147. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1148. /**
  1149. * Config-specific merge-function which creates a new config-object
  1150. * by merging two configuration objects together.
  1151. *
  1152. * @param {Object} config1
  1153. * @param {Object} config2
  1154. * @returns {Object} New object resulting from merging config2 to config1
  1155. */
  1156. module.exports = function mergeConfig(config1, config2) {
  1157. // eslint-disable-next-line no-param-reassign
  1158. config2 = config2 || {};
  1159. var config = {};
  1160. var valueFromConfig2Keys = ['url', 'method', 'data'];
  1161. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  1162. var defaultToConfig2Keys = [
  1163. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  1164. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  1165. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  1166. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  1167. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  1168. ];
  1169. var directMergeKeys = ['validateStatus'];
  1170. function getMergedValue(target, source) {
  1171. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  1172. return utils.merge(target, source);
  1173. } else if (utils.isPlainObject(source)) {
  1174. return utils.merge({}, source);
  1175. } else if (utils.isArray(source)) {
  1176. return source.slice();
  1177. }
  1178. return source;
  1179. }
  1180. function mergeDeepProperties(prop) {
  1181. if (!utils.isUndefined(config2[prop])) {
  1182. config[prop] = getMergedValue(config1[prop], config2[prop]);
  1183. } else if (!utils.isUndefined(config1[prop])) {
  1184. config[prop] = getMergedValue(undefined, config1[prop]);
  1185. }
  1186. }
  1187. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  1188. if (!utils.isUndefined(config2[prop])) {
  1189. config[prop] = getMergedValue(undefined, config2[prop]);
  1190. }
  1191. });
  1192. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  1193. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  1194. if (!utils.isUndefined(config2[prop])) {
  1195. config[prop] = getMergedValue(undefined, config2[prop]);
  1196. } else if (!utils.isUndefined(config1[prop])) {
  1197. config[prop] = getMergedValue(undefined, config1[prop]);
  1198. }
  1199. });
  1200. utils.forEach(directMergeKeys, function merge(prop) {
  1201. if (prop in config2) {
  1202. config[prop] = getMergedValue(config1[prop], config2[prop]);
  1203. } else if (prop in config1) {
  1204. config[prop] = getMergedValue(undefined, config1[prop]);
  1205. }
  1206. });
  1207. var axiosKeys = valueFromConfig2Keys
  1208. .concat(mergeDeepPropertiesKeys)
  1209. .concat(defaultToConfig2Keys)
  1210. .concat(directMergeKeys);
  1211. var otherKeys = Object
  1212. .keys(config1)
  1213. .concat(Object.keys(config2))
  1214. .filter(function filterAxiosKeys(key) {
  1215. return axiosKeys.indexOf(key) === -1;
  1216. });
  1217. utils.forEach(otherKeys, mergeDeepProperties);
  1218. return config;
  1219. };
  1220. /***/ }),
  1221. /***/ "./node_modules/axios/lib/core/settle.js":
  1222. /*!***********************************************!*\
  1223. !*** ./node_modules/axios/lib/core/settle.js ***!
  1224. \***********************************************/
  1225. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1226. "use strict";
  1227. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  1228. /**
  1229. * Resolve or reject a Promise based on response status.
  1230. *
  1231. * @param {Function} resolve A function that resolves the promise.
  1232. * @param {Function} reject A function that rejects the promise.
  1233. * @param {object} response The response.
  1234. */
  1235. module.exports = function settle(resolve, reject, response) {
  1236. var validateStatus = response.config.validateStatus;
  1237. if (!response.status || !validateStatus || validateStatus(response.status)) {
  1238. resolve(response);
  1239. } else {
  1240. reject(createError(
  1241. 'Request failed with status code ' + response.status,
  1242. response.config,
  1243. null,
  1244. response.request,
  1245. response
  1246. ));
  1247. }
  1248. };
  1249. /***/ }),
  1250. /***/ "./node_modules/axios/lib/core/transformData.js":
  1251. /*!******************************************************!*\
  1252. !*** ./node_modules/axios/lib/core/transformData.js ***!
  1253. \******************************************************/
  1254. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1255. "use strict";
  1256. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1257. /**
  1258. * Transform the data for a request or a response
  1259. *
  1260. * @param {Object|String} data The data to be transformed
  1261. * @param {Array} headers The headers for the request or response
  1262. * @param {Array|Function} fns A single function or Array of functions
  1263. * @returns {*} The resulting transformed data
  1264. */
  1265. module.exports = function transformData(data, headers, fns) {
  1266. /*eslint no-param-reassign:0*/
  1267. utils.forEach(fns, function transform(fn) {
  1268. data = fn(data, headers);
  1269. });
  1270. return data;
  1271. };
  1272. /***/ }),
  1273. /***/ "./node_modules/axios/lib/defaults.js":
  1274. /*!********************************************!*\
  1275. !*** ./node_modules/axios/lib/defaults.js ***!
  1276. \********************************************/
  1277. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1278. "use strict";
  1279. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
  1280. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  1281. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  1282. var DEFAULT_CONTENT_TYPE = {
  1283. 'Content-Type': 'application/x-www-form-urlencoded'
  1284. };
  1285. function setContentTypeIfUnset(headers, value) {
  1286. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  1287. headers['Content-Type'] = value;
  1288. }
  1289. }
  1290. function getDefaultAdapter() {
  1291. var adapter;
  1292. if (typeof XMLHttpRequest !== 'undefined') {
  1293. // For browsers use XHR adapter
  1294. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  1295. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  1296. // For node use HTTP adapter
  1297. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  1298. }
  1299. return adapter;
  1300. }
  1301. var defaults = {
  1302. adapter: getDefaultAdapter(),
  1303. transformRequest: [function transformRequest(data, headers) {
  1304. normalizeHeaderName(headers, 'Accept');
  1305. normalizeHeaderName(headers, 'Content-Type');
  1306. if (utils.isFormData(data) ||
  1307. utils.isArrayBuffer(data) ||
  1308. utils.isBuffer(data) ||
  1309. utils.isStream(data) ||
  1310. utils.isFile(data) ||
  1311. utils.isBlob(data)
  1312. ) {
  1313. return data;
  1314. }
  1315. if (utils.isArrayBufferView(data)) {
  1316. return data.buffer;
  1317. }
  1318. if (utils.isURLSearchParams(data)) {
  1319. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  1320. return data.toString();
  1321. }
  1322. if (utils.isObject(data)) {
  1323. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  1324. return JSON.stringify(data);
  1325. }
  1326. return data;
  1327. }],
  1328. transformResponse: [function transformResponse(data) {
  1329. /*eslint no-param-reassign:0*/
  1330. if (typeof data === 'string') {
  1331. try {
  1332. data = JSON.parse(data);
  1333. } catch (e) { /* Ignore */ }
  1334. }
  1335. return data;
  1336. }],
  1337. /**
  1338. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1339. * timeout is not created.
  1340. */
  1341. timeout: 0,
  1342. xsrfCookieName: 'XSRF-TOKEN',
  1343. xsrfHeaderName: 'X-XSRF-TOKEN',
  1344. maxContentLength: -1,
  1345. maxBodyLength: -1,
  1346. validateStatus: function validateStatus(status) {
  1347. return status >= 200 && status < 300;
  1348. }
  1349. };
  1350. defaults.headers = {
  1351. common: {
  1352. 'Accept': 'application/json, text/plain, */*'
  1353. }
  1354. };
  1355. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  1356. defaults.headers[method] = {};
  1357. });
  1358. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1359. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  1360. });
  1361. module.exports = defaults;
  1362. /***/ }),
  1363. /***/ "./node_modules/axios/lib/helpers/bind.js":
  1364. /*!************************************************!*\
  1365. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  1366. \************************************************/
  1367. /***/ ((module) => {
  1368. "use strict";
  1369. module.exports = function bind(fn, thisArg) {
  1370. return function wrap() {
  1371. var args = new Array(arguments.length);
  1372. for (var i = 0; i < args.length; i++) {
  1373. args[i] = arguments[i];
  1374. }
  1375. return fn.apply(thisArg, args);
  1376. };
  1377. };
  1378. /***/ }),
  1379. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  1380. /*!****************************************************!*\
  1381. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  1382. \****************************************************/
  1383. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1384. "use strict";
  1385. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1386. function encode(val) {
  1387. return encodeURIComponent(val).
  1388. replace(/%3A/gi, ':').
  1389. replace(/%24/g, '$').
  1390. replace(/%2C/gi, ',').
  1391. replace(/%20/g, '+').
  1392. replace(/%5B/gi, '[').
  1393. replace(/%5D/gi, ']');
  1394. }
  1395. /**
  1396. * Build a URL by appending params to the end
  1397. *
  1398. * @param {string} url The base of the url (e.g., http://www.google.com)
  1399. * @param {object} [params] The params to be appended
  1400. * @returns {string} The formatted url
  1401. */
  1402. module.exports = function buildURL(url, params, paramsSerializer) {
  1403. /*eslint no-param-reassign:0*/
  1404. if (!params) {
  1405. return url;
  1406. }
  1407. var serializedParams;
  1408. if (paramsSerializer) {
  1409. serializedParams = paramsSerializer(params);
  1410. } else if (utils.isURLSearchParams(params)) {
  1411. serializedParams = params.toString();
  1412. } else {
  1413. var parts = [];
  1414. utils.forEach(params, function serialize(val, key) {
  1415. if (val === null || typeof val === 'undefined') {
  1416. return;
  1417. }
  1418. if (utils.isArray(val)) {
  1419. key = key + '[]';
  1420. } else {
  1421. val = [val];
  1422. }
  1423. utils.forEach(val, function parseValue(v) {
  1424. if (utils.isDate(v)) {
  1425. v = v.toISOString();
  1426. } else if (utils.isObject(v)) {
  1427. v = JSON.stringify(v);
  1428. }
  1429. parts.push(encode(key) + '=' + encode(v));
  1430. });
  1431. });
  1432. serializedParams = parts.join('&');
  1433. }
  1434. if (serializedParams) {
  1435. var hashmarkIndex = url.indexOf('#');
  1436. if (hashmarkIndex !== -1) {
  1437. url = url.slice(0, hashmarkIndex);
  1438. }
  1439. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1440. }
  1441. return url;
  1442. };
  1443. /***/ }),
  1444. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  1445. /*!*******************************************************!*\
  1446. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  1447. \*******************************************************/
  1448. /***/ ((module) => {
  1449. "use strict";
  1450. /**
  1451. * Creates a new URL by combining the specified URLs
  1452. *
  1453. * @param {string} baseURL The base URL
  1454. * @param {string} relativeURL The relative URL
  1455. * @returns {string} The combined URL
  1456. */
  1457. module.exports = function combineURLs(baseURL, relativeURL) {
  1458. return relativeURL
  1459. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1460. : baseURL;
  1461. };
  1462. /***/ }),
  1463. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1464. /*!***************************************************!*\
  1465. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1466. \***************************************************/
  1467. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1468. "use strict";
  1469. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1470. module.exports = (
  1471. utils.isStandardBrowserEnv() ?
  1472. // Standard browser envs support document.cookie
  1473. (function standardBrowserEnv() {
  1474. return {
  1475. write: function write(name, value, expires, path, domain, secure) {
  1476. var cookie = [];
  1477. cookie.push(name + '=' + encodeURIComponent(value));
  1478. if (utils.isNumber(expires)) {
  1479. cookie.push('expires=' + new Date(expires).toGMTString());
  1480. }
  1481. if (utils.isString(path)) {
  1482. cookie.push('path=' + path);
  1483. }
  1484. if (utils.isString(domain)) {
  1485. cookie.push('domain=' + domain);
  1486. }
  1487. if (secure === true) {
  1488. cookie.push('secure');
  1489. }
  1490. document.cookie = cookie.join('; ');
  1491. },
  1492. read: function read(name) {
  1493. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1494. return (match ? decodeURIComponent(match[3]) : null);
  1495. },
  1496. remove: function remove(name) {
  1497. this.write(name, '', Date.now() - 86400000);
  1498. }
  1499. };
  1500. })() :
  1501. // Non standard browser env (web workers, react-native) lack needed support.
  1502. (function nonStandardBrowserEnv() {
  1503. return {
  1504. write: function write() {},
  1505. read: function read() { return null; },
  1506. remove: function remove() {}
  1507. };
  1508. })()
  1509. );
  1510. /***/ }),
  1511. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1512. /*!*********************************************************!*\
  1513. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1514. \*********************************************************/
  1515. /***/ ((module) => {
  1516. "use strict";
  1517. /**
  1518. * Determines whether the specified URL is absolute
  1519. *
  1520. * @param {string} url The URL to test
  1521. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1522. */
  1523. module.exports = function isAbsoluteURL(url) {
  1524. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1525. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1526. // by any combination of letters, digits, plus, period, or hyphen.
  1527. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1528. };
  1529. /***/ }),
  1530. /***/ "./node_modules/axios/lib/helpers/isAxiosError.js":
  1531. /*!********************************************************!*\
  1532. !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
  1533. \********************************************************/
  1534. /***/ ((module) => {
  1535. "use strict";
  1536. /**
  1537. * Determines whether the payload is an error thrown by Axios
  1538. *
  1539. * @param {*} payload The value to test
  1540. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1541. */
  1542. module.exports = function isAxiosError(payload) {
  1543. return (typeof payload === 'object') && (payload.isAxiosError === true);
  1544. };
  1545. /***/ }),
  1546. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1547. /*!***********************************************************!*\
  1548. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1549. \***********************************************************/
  1550. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1551. "use strict";
  1552. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1553. module.exports = (
  1554. utils.isStandardBrowserEnv() ?
  1555. // Standard browser envs have full support of the APIs needed to test
  1556. // whether the request URL is of the same origin as current location.
  1557. (function standardBrowserEnv() {
  1558. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1559. var urlParsingNode = document.createElement('a');
  1560. var originURL;
  1561. /**
  1562. * Parse a URL to discover it's components
  1563. *
  1564. * @param {String} url The URL to be parsed
  1565. * @returns {Object}
  1566. */
  1567. function resolveURL(url) {
  1568. var href = url;
  1569. if (msie) {
  1570. // IE needs attribute set twice to normalize properties
  1571. urlParsingNode.setAttribute('href', href);
  1572. href = urlParsingNode.href;
  1573. }
  1574. urlParsingNode.setAttribute('href', href);
  1575. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1576. return {
  1577. href: urlParsingNode.href,
  1578. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1579. host: urlParsingNode.host,
  1580. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1581. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1582. hostname: urlParsingNode.hostname,
  1583. port: urlParsingNode.port,
  1584. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1585. urlParsingNode.pathname :
  1586. '/' + urlParsingNode.pathname
  1587. };
  1588. }
  1589. originURL = resolveURL(window.location.href);
  1590. /**
  1591. * Determine if a URL shares the same origin as the current location
  1592. *
  1593. * @param {String} requestURL The URL to test
  1594. * @returns {boolean} True if URL shares the same origin, otherwise false
  1595. */
  1596. return function isURLSameOrigin(requestURL) {
  1597. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1598. return (parsed.protocol === originURL.protocol &&
  1599. parsed.host === originURL.host);
  1600. };
  1601. })() :
  1602. // Non standard browser envs (web workers, react-native) lack needed support.
  1603. (function nonStandardBrowserEnv() {
  1604. return function isURLSameOrigin() {
  1605. return true;
  1606. };
  1607. })()
  1608. );
  1609. /***/ }),
  1610. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1611. /*!***************************************************************!*\
  1612. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1613. \***************************************************************/
  1614. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1615. "use strict";
  1616. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1617. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1618. utils.forEach(headers, function processHeader(value, name) {
  1619. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1620. headers[normalizedName] = value;
  1621. delete headers[name];
  1622. }
  1623. });
  1624. };
  1625. /***/ }),
  1626. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1627. /*!********************************************************!*\
  1628. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1629. \********************************************************/
  1630. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1631. "use strict";
  1632. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1633. // Headers whose duplicates are ignored by node
  1634. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1635. var ignoreDuplicateOf = [
  1636. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1637. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1638. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1639. 'referer', 'retry-after', 'user-agent'
  1640. ];
  1641. /**
  1642. * Parse headers into an object
  1643. *
  1644. * ```
  1645. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1646. * Content-Type: application/json
  1647. * Connection: keep-alive
  1648. * Transfer-Encoding: chunked
  1649. * ```
  1650. *
  1651. * @param {String} headers Headers needing to be parsed
  1652. * @returns {Object} Headers parsed into an object
  1653. */
  1654. module.exports = function parseHeaders(headers) {
  1655. var parsed = {};
  1656. var key;
  1657. var val;
  1658. var i;
  1659. if (!headers) { return parsed; }
  1660. utils.forEach(headers.split('\n'), function parser(line) {
  1661. i = line.indexOf(':');
  1662. key = utils.trim(line.substr(0, i)).toLowerCase();
  1663. val = utils.trim(line.substr(i + 1));
  1664. if (key) {
  1665. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1666. return;
  1667. }
  1668. if (key === 'set-cookie') {
  1669. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1670. } else {
  1671. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1672. }
  1673. }
  1674. });
  1675. return parsed;
  1676. };
  1677. /***/ }),
  1678. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1679. /*!**************************************************!*\
  1680. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1681. \**************************************************/
  1682. /***/ ((module) => {
  1683. "use strict";
  1684. /**
  1685. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1686. *
  1687. * Common use case would be to use `Function.prototype.apply`.
  1688. *
  1689. * ```js
  1690. * function f(x, y, z) {}
  1691. * var args = [1, 2, 3];
  1692. * f.apply(null, args);
  1693. * ```
  1694. *
  1695. * With `spread` this example can be re-written.
  1696. *
  1697. * ```js
  1698. * spread(function(x, y, z) {})([1, 2, 3]);
  1699. * ```
  1700. *
  1701. * @param {Function} callback
  1702. * @returns {Function}
  1703. */
  1704. module.exports = function spread(callback) {
  1705. return function wrap(arr) {
  1706. return callback.apply(null, arr);
  1707. };
  1708. };
  1709. /***/ }),
  1710. /***/ "./node_modules/axios/lib/utils.js":
  1711. /*!*****************************************!*\
  1712. !*** ./node_modules/axios/lib/utils.js ***!
  1713. \*****************************************/
  1714. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1715. "use strict";
  1716. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1717. /*global toString:true*/
  1718. // utils is a library of generic helper functions non-specific to axios
  1719. var toString = Object.prototype.toString;
  1720. /**
  1721. * Determine if a value is an Array
  1722. *
  1723. * @param {Object} val The value to test
  1724. * @returns {boolean} True if value is an Array, otherwise false
  1725. */
  1726. function isArray(val) {
  1727. return toString.call(val) === '[object Array]';
  1728. }
  1729. /**
  1730. * Determine if a value is undefined
  1731. *
  1732. * @param {Object} val The value to test
  1733. * @returns {boolean} True if the value is undefined, otherwise false
  1734. */
  1735. function isUndefined(val) {
  1736. return typeof val === 'undefined';
  1737. }
  1738. /**
  1739. * Determine if a value is a Buffer
  1740. *
  1741. * @param {Object} val The value to test
  1742. * @returns {boolean} True if value is a Buffer, otherwise false
  1743. */
  1744. function isBuffer(val) {
  1745. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1746. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1747. }
  1748. /**
  1749. * Determine if a value is an ArrayBuffer
  1750. *
  1751. * @param {Object} val The value to test
  1752. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1753. */
  1754. function isArrayBuffer(val) {
  1755. return toString.call(val) === '[object ArrayBuffer]';
  1756. }
  1757. /**
  1758. * Determine if a value is a FormData
  1759. *
  1760. * @param {Object} val The value to test
  1761. * @returns {boolean} True if value is an FormData, otherwise false
  1762. */
  1763. function isFormData(val) {
  1764. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1765. }
  1766. /**
  1767. * Determine if a value is a view on an ArrayBuffer
  1768. *
  1769. * @param {Object} val The value to test
  1770. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1771. */
  1772. function isArrayBufferView(val) {
  1773. var result;
  1774. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1775. result = ArrayBuffer.isView(val);
  1776. } else {
  1777. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1778. }
  1779. return result;
  1780. }
  1781. /**
  1782. * Determine if a value is a String
  1783. *
  1784. * @param {Object} val The value to test
  1785. * @returns {boolean} True if value is a String, otherwise false
  1786. */
  1787. function isString(val) {
  1788. return typeof val === 'string';
  1789. }
  1790. /**
  1791. * Determine if a value is a Number
  1792. *
  1793. * @param {Object} val The value to test
  1794. * @returns {boolean} True if value is a Number, otherwise false
  1795. */
  1796. function isNumber(val) {
  1797. return typeof val === 'number';
  1798. }
  1799. /**
  1800. * Determine if a value is an Object
  1801. *
  1802. * @param {Object} val The value to test
  1803. * @returns {boolean} True if value is an Object, otherwise false
  1804. */
  1805. function isObject(val) {
  1806. return val !== null && typeof val === 'object';
  1807. }
  1808. /**
  1809. * Determine if a value is a plain Object
  1810. *
  1811. * @param {Object} val The value to test
  1812. * @return {boolean} True if value is a plain Object, otherwise false
  1813. */
  1814. function isPlainObject(val) {
  1815. if (toString.call(val) !== '[object Object]') {
  1816. return false;
  1817. }
  1818. var prototype = Object.getPrototypeOf(val);
  1819. return prototype === null || prototype === Object.prototype;
  1820. }
  1821. /**
  1822. * Determine if a value is a Date
  1823. *
  1824. * @param {Object} val The value to test
  1825. * @returns {boolean} True if value is a Date, otherwise false
  1826. */
  1827. function isDate(val) {
  1828. return toString.call(val) === '[object Date]';
  1829. }
  1830. /**
  1831. * Determine if a value is a File
  1832. *
  1833. * @param {Object} val The value to test
  1834. * @returns {boolean} True if value is a File, otherwise false
  1835. */
  1836. function isFile(val) {
  1837. return toString.call(val) === '[object File]';
  1838. }
  1839. /**
  1840. * Determine if a value is a Blob
  1841. *
  1842. * @param {Object} val The value to test
  1843. * @returns {boolean} True if value is a Blob, otherwise false
  1844. */
  1845. function isBlob(val) {
  1846. return toString.call(val) === '[object Blob]';
  1847. }
  1848. /**
  1849. * Determine if a value is a Function
  1850. *
  1851. * @param {Object} val The value to test
  1852. * @returns {boolean} True if value is a Function, otherwise false
  1853. */
  1854. function isFunction(val) {
  1855. return toString.call(val) === '[object Function]';
  1856. }
  1857. /**
  1858. * Determine if a value is a Stream
  1859. *
  1860. * @param {Object} val The value to test
  1861. * @returns {boolean} True if value is a Stream, otherwise false
  1862. */
  1863. function isStream(val) {
  1864. return isObject(val) && isFunction(val.pipe);
  1865. }
  1866. /**
  1867. * Determine if a value is a URLSearchParams object
  1868. *
  1869. * @param {Object} val The value to test
  1870. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1871. */
  1872. function isURLSearchParams(val) {
  1873. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1874. }
  1875. /**
  1876. * Trim excess whitespace off the beginning and end of a string
  1877. *
  1878. * @param {String} str The String to trim
  1879. * @returns {String} The String freed of excess whitespace
  1880. */
  1881. function trim(str) {
  1882. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1883. }
  1884. /**
  1885. * Determine if we're running in a standard browser environment
  1886. *
  1887. * This allows axios to run in a web worker, and react-native.
  1888. * Both environments support XMLHttpRequest, but not fully standard globals.
  1889. *
  1890. * web workers:
  1891. * typeof window -> undefined
  1892. * typeof document -> undefined
  1893. *
  1894. * react-native:
  1895. * navigator.product -> 'ReactNative'
  1896. * nativescript
  1897. * navigator.product -> 'NativeScript' or 'NS'
  1898. */
  1899. function isStandardBrowserEnv() {
  1900. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1901. navigator.product === 'NativeScript' ||
  1902. navigator.product === 'NS')) {
  1903. return false;
  1904. }
  1905. return (
  1906. typeof window !== 'undefined' &&
  1907. typeof document !== 'undefined'
  1908. );
  1909. }
  1910. /**
  1911. * Iterate over an Array or an Object invoking a function for each item.
  1912. *
  1913. * If `obj` is an Array callback will be called passing
  1914. * the value, index, and complete array for each item.
  1915. *
  1916. * If 'obj' is an Object callback will be called passing
  1917. * the value, key, and complete object for each property.
  1918. *
  1919. * @param {Object|Array} obj The object to iterate
  1920. * @param {Function} fn The callback to invoke for each item
  1921. */
  1922. function forEach(obj, fn) {
  1923. // Don't bother if no value provided
  1924. if (obj === null || typeof obj === 'undefined') {
  1925. return;
  1926. }
  1927. // Force an array if not already something iterable
  1928. if (typeof obj !== 'object') {
  1929. /*eslint no-param-reassign:0*/
  1930. obj = [obj];
  1931. }
  1932. if (isArray(obj)) {
  1933. // Iterate over array values
  1934. for (var i = 0, l = obj.length; i < l; i++) {
  1935. fn.call(null, obj[i], i, obj);
  1936. }
  1937. } else {
  1938. // Iterate over object keys
  1939. for (var key in obj) {
  1940. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1941. fn.call(null, obj[key], key, obj);
  1942. }
  1943. }
  1944. }
  1945. }
  1946. /**
  1947. * Accepts varargs expecting each argument to be an object, then
  1948. * immutably merges the properties of each object and returns result.
  1949. *
  1950. * When multiple objects contain the same key the later object in
  1951. * the arguments list will take precedence.
  1952. *
  1953. * Example:
  1954. *
  1955. * ```js
  1956. * var result = merge({foo: 123}, {foo: 456});
  1957. * console.log(result.foo); // outputs 456
  1958. * ```
  1959. *
  1960. * @param {Object} obj1 Object to merge
  1961. * @returns {Object} Result of all merge properties
  1962. */
  1963. function merge(/* obj1, obj2, obj3, ... */) {
  1964. var result = {};
  1965. function assignValue(val, key) {
  1966. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1967. result[key] = merge(result[key], val);
  1968. } else if (isPlainObject(val)) {
  1969. result[key] = merge({}, val);
  1970. } else if (isArray(val)) {
  1971. result[key] = val.slice();
  1972. } else {
  1973. result[key] = val;
  1974. }
  1975. }
  1976. for (var i = 0, l = arguments.length; i < l; i++) {
  1977. forEach(arguments[i], assignValue);
  1978. }
  1979. return result;
  1980. }
  1981. /**
  1982. * Extends object a by mutably adding to it the properties of object b.
  1983. *
  1984. * @param {Object} a The object to be extended
  1985. * @param {Object} b The object to copy properties from
  1986. * @param {Object} thisArg The object to bind function to
  1987. * @return {Object} The resulting value of object a
  1988. */
  1989. function extend(a, b, thisArg) {
  1990. forEach(b, function assignValue(val, key) {
  1991. if (thisArg && typeof val === 'function') {
  1992. a[key] = bind(val, thisArg);
  1993. } else {
  1994. a[key] = val;
  1995. }
  1996. });
  1997. return a;
  1998. }
  1999. /**
  2000. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  2001. *
  2002. * @param {string} content with BOM
  2003. * @return {string} content value without BOM
  2004. */
  2005. function stripBOM(content) {
  2006. if (content.charCodeAt(0) === 0xFEFF) {
  2007. content = content.slice(1);
  2008. }
  2009. return content;
  2010. }
  2011. module.exports = {
  2012. isArray: isArray,
  2013. isArrayBuffer: isArrayBuffer,
  2014. isBuffer: isBuffer,
  2015. isFormData: isFormData,
  2016. isArrayBufferView: isArrayBufferView,
  2017. isString: isString,
  2018. isNumber: isNumber,
  2019. isObject: isObject,
  2020. isPlainObject: isPlainObject,
  2021. isUndefined: isUndefined,
  2022. isDate: isDate,
  2023. isFile: isFile,
  2024. isBlob: isBlob,
  2025. isFunction: isFunction,
  2026. isStream: isStream,
  2027. isURLSearchParams: isURLSearchParams,
  2028. isStandardBrowserEnv: isStandardBrowserEnv,
  2029. forEach: forEach,
  2030. merge: merge,
  2031. extend: extend,
  2032. trim: trim,
  2033. stripBOM: stripBOM
  2034. };
  2035. /***/ }),
  2036. /***/ "./resources/js/FormValidator.js":
  2037. /*!***************************************!*\
  2038. !*** ./resources/js/FormValidator.js ***!
  2039. \***************************************/
  2040. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2041. "use strict";
  2042. __webpack_require__.r(__webpack_exports__);
  2043. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2044. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  2045. /* harmony export */ });
  2046. /* harmony import */ var validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! validate.js */ "./node_modules/validate.js/validate.js");
  2047. /* harmony import */ var validate_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(validate_js__WEBPACK_IMPORTED_MODULE_0__);
  2048. /* harmony import */ var form_serialize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! form-serialize */ "./node_modules/form-serialize/index.js");
  2049. /* harmony import */ var form_serialize__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(form_serialize__WEBPACK_IMPORTED_MODULE_1__);
  2050. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2051. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2052. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2053. /**
  2054. * Form Validator with RiotJS Components
  2055. *
  2056. *
  2057. *
  2058. *
  2059. */
  2060. var FormValidator = /*#__PURE__*/function () {
  2061. /**
  2062. *
  2063. * @param {[type]} formSelector [description]
  2064. * @param {[type]} constraits [description]
  2065. */
  2066. function FormValidator(formSelector, constraits, onSuccess) {
  2067. var _this = this;
  2068. _classCallCheck(this, FormValidator);
  2069. // getting selector to find form-element
  2070. this.formSelector = formSelector; // constraits for validate.js
  2071. this.constraits = constraits; // get form and elements
  2072. this.form = document.querySelector(this.formSelector);
  2073. if (!this.form) {
  2074. console.error('FormValidator: form not found, querySelector not found "' + this.formSelector + '"');
  2075. }
  2076. this.elements = this.form.querySelectorAll('field-error'); // adding submit event
  2077. this.form.addEventListener('submit', function (event) {
  2078. _this.onSubmit(event);
  2079. }); // adding event if a element is updated
  2080. this.form.addEventListener('field-update', function (event) {
  2081. _this.onFieldUpdate(event);
  2082. });
  2083. this.onSuccess = onSuccess;
  2084. }
  2085. /**
  2086. *
  2087. * @param {[type]} event [description]
  2088. * @return {[type]} [description]
  2089. */
  2090. _createClass(FormValidator, [{
  2091. key: "onSubmit",
  2092. value: function onSubmit(event) {
  2093. var _this2 = this;
  2094. event.preventDefault();
  2095. var errors = validate_js__WEBPACK_IMPORTED_MODULE_0___default()(form_serialize__WEBPACK_IMPORTED_MODULE_1___default()(event.target, {
  2096. hash: true
  2097. }), this.constraits, {
  2098. fullMessages: false
  2099. });
  2100. if (errors) {
  2101. // send each element a event
  2102. this.elements.forEach(function (element) {
  2103. var elementErrors = false; // check for errors by name
  2104. if (errors[element.attributes.name.nodeValue]) {
  2105. elementErrors = errors[element.attributes.name.nodeValue];
  2106. }
  2107. _this2.dispatchCustomEvent(elementErrors, element);
  2108. });
  2109. } else {
  2110. this.onSuccess(event, form_serialize__WEBPACK_IMPORTED_MODULE_1___default()(event.target, {
  2111. hash: true
  2112. }));
  2113. }
  2114. }
  2115. /**
  2116. *
  2117. *
  2118. * @param {Event} event
  2119. *
  2120. */
  2121. }, {
  2122. key: "onFieldUpdate",
  2123. value: function onFieldUpdate(event) {
  2124. var _this3 = this;
  2125. // workaround, make sure that value for single is undefined if it is empty
  2126. if (event.detail.value == '') {
  2127. event.detail.value = undefined;
  2128. }
  2129. var errors = validate_js__WEBPACK_IMPORTED_MODULE_0___default().single(event.detail.value, this.constraits[event.detail.name]); // search for element by name and dispatch event
  2130. this.elements.forEach(function (element) {
  2131. if (element.attributes.name.nodeValue == event.detail.name) {
  2132. _this3.dispatchCustomEvent(errors, element);
  2133. }
  2134. });
  2135. }
  2136. /**
  2137. * dispatch event to single element
  2138. *
  2139. * @param {Array} errors
  2140. * @param {Element} element
  2141. *
  2142. */
  2143. }, {
  2144. key: "dispatchCustomEvent",
  2145. value: function dispatchCustomEvent(errors, element) {
  2146. var detail = false;
  2147. if (errors) {
  2148. detail = errors;
  2149. }
  2150. var formValidationEvent = new CustomEvent('form-validation', {
  2151. 'detail': detail
  2152. });
  2153. element.dispatchEvent(formValidationEvent);
  2154. }
  2155. }]);
  2156. return FormValidator;
  2157. }();
  2158. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (FormValidator);
  2159. /***/ }),
  2160. /***/ "./node_modules/form-serialize/index.js":
  2161. /*!**********************************************!*\
  2162. !*** ./node_modules/form-serialize/index.js ***!
  2163. \**********************************************/
  2164. /***/ ((module) => {
  2165. // get successful control from form and assemble into object
  2166. // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2
  2167. // types which indicate a submit action and are not successful controls
  2168. // these will be ignored
  2169. var k_r_submitter = /^(?:submit|button|image|reset|file)$/i;
  2170. // node names which could be successful controls
  2171. var k_r_success_contrls = /^(?:input|select|textarea|keygen)/i;
  2172. // Matches bracket notation.
  2173. var brackets = /(\[[^\[\]]*\])/g;
  2174. // serializes form fields
  2175. // @param form MUST be an HTMLForm element
  2176. // @param options is an optional argument to configure the serialization. Default output
  2177. // with no options specified is a url encoded string
  2178. // - hash: [true | false] Configure the output type. If true, the output will
  2179. // be a js object.
  2180. // - serializer: [function] Optional serializer function to override the default one.
  2181. // The function takes 3 arguments (result, key, value) and should return new result
  2182. // hash and url encoded str serializers are provided with this module
  2183. // - disabled: [true | false]. If true serialize disabled fields.
  2184. // - empty: [true | false]. If true serialize empty fields
  2185. function serialize(form, options) {
  2186. if (typeof options != 'object') {
  2187. options = { hash: !!options };
  2188. }
  2189. else if (options.hash === undefined) {
  2190. options.hash = true;
  2191. }
  2192. var result = (options.hash) ? {} : '';
  2193. var serializer = options.serializer || ((options.hash) ? hash_serializer : str_serialize);
  2194. var elements = form && form.elements ? form.elements : [];
  2195. //Object store each radio and set if it's empty or not
  2196. var radio_store = Object.create(null);
  2197. for (var i=0 ; i<elements.length ; ++i) {
  2198. var element = elements[i];
  2199. // ingore disabled fields
  2200. if ((!options.disabled && element.disabled) || !element.name) {
  2201. continue;
  2202. }
  2203. // ignore anyhting that is not considered a success field
  2204. if (!k_r_success_contrls.test(element.nodeName) ||
  2205. k_r_submitter.test(element.type)) {
  2206. continue;
  2207. }
  2208. var key = element.name;
  2209. var val = element.value;
  2210. // we can't just use element.value for checkboxes cause some browsers lie to us
  2211. // they say "on" for value when the box isn't checked
  2212. if ((element.type === 'checkbox' || element.type === 'radio') && !element.checked) {
  2213. val = undefined;
  2214. }
  2215. // If we want empty elements
  2216. if (options.empty) {
  2217. // for checkbox
  2218. if (element.type === 'checkbox' && !element.checked) {
  2219. val = '';
  2220. }
  2221. // for radio
  2222. if (element.type === 'radio') {
  2223. if (!radio_store[element.name] && !element.checked) {
  2224. radio_store[element.name] = false;
  2225. }
  2226. else if (element.checked) {
  2227. radio_store[element.name] = true;
  2228. }
  2229. }
  2230. // if options empty is true, continue only if its radio
  2231. if (val == undefined && element.type == 'radio') {
  2232. continue;
  2233. }
  2234. }
  2235. else {
  2236. // value-less fields are ignored unless options.empty is true
  2237. if (!val) {
  2238. continue;
  2239. }
  2240. }
  2241. // multi select boxes
  2242. if (element.type === 'select-multiple') {
  2243. val = [];
  2244. var selectOptions = element.options;
  2245. var isSelectedOptions = false;
  2246. for (var j=0 ; j<selectOptions.length ; ++j) {
  2247. var option = selectOptions[j];
  2248. var allowedEmpty = options.empty && !option.value;
  2249. var hasValue = (option.value || allowedEmpty);
  2250. if (option.selected && hasValue) {
  2251. isSelectedOptions = true;
  2252. // If using a hash serializer be sure to add the
  2253. // correct notation for an array in the multi-select
  2254. // context. Here the name attribute on the select element
  2255. // might be missing the trailing bracket pair. Both names
  2256. // "foo" and "foo[]" should be arrays.
  2257. if (options.hash && key.slice(key.length - 2) !== '[]') {
  2258. result = serializer(result, key + '[]', option.value);
  2259. }
  2260. else {
  2261. result = serializer(result, key, option.value);
  2262. }
  2263. }
  2264. }
  2265. // Serialize if no selected options and options.empty is true
  2266. if (!isSelectedOptions && options.empty) {
  2267. result = serializer(result, key, '');
  2268. }
  2269. continue;
  2270. }
  2271. result = serializer(result, key, val);
  2272. }
  2273. // Check for all empty radio buttons and serialize them with key=""
  2274. if (options.empty) {
  2275. for (var key in radio_store) {
  2276. if (!radio_store[key]) {
  2277. result = serializer(result, key, '');
  2278. }
  2279. }
  2280. }
  2281. return result;
  2282. }
  2283. function parse_keys(string) {
  2284. var keys = [];
  2285. var prefix = /^([^\[\]]*)/;
  2286. var children = new RegExp(brackets);
  2287. var match = prefix.exec(string);
  2288. if (match[1]) {
  2289. keys.push(match[1]);
  2290. }
  2291. while ((match = children.exec(string)) !== null) {
  2292. keys.push(match[1]);
  2293. }
  2294. return keys;
  2295. }
  2296. function hash_assign(result, keys, value) {
  2297. if (keys.length === 0) {
  2298. result = value;
  2299. return result;
  2300. }
  2301. var key = keys.shift();
  2302. var between = key.match(/^\[(.+?)\]$/);
  2303. if (key === '[]') {
  2304. result = result || [];
  2305. if (Array.isArray(result)) {
  2306. result.push(hash_assign(null, keys, value));
  2307. }
  2308. else {
  2309. // This might be the result of bad name attributes like "[][foo]",
  2310. // in this case the original `result` object will already be
  2311. // assigned to an object literal. Rather than coerce the object to
  2312. // an array, or cause an exception the attribute "_values" is
  2313. // assigned as an array.
  2314. result._values = result._values || [];
  2315. result._values.push(hash_assign(null, keys, value));
  2316. }
  2317. return result;
  2318. }
  2319. // Key is an attribute name and can be assigned directly.
  2320. if (!between) {
  2321. result[key] = hash_assign(result[key], keys, value);
  2322. }
  2323. else {
  2324. var string = between[1];
  2325. // +var converts the variable into a number
  2326. // better than parseInt because it doesn't truncate away trailing
  2327. // letters and actually fails if whole thing is not a number
  2328. var index = +string;
  2329. // If the characters between the brackets is not a number it is an
  2330. // attribute name and can be assigned directly.
  2331. if (isNaN(index)) {
  2332. result = result || {};
  2333. result[string] = hash_assign(result[string], keys, value);
  2334. }
  2335. else {
  2336. result = result || [];
  2337. result[index] = hash_assign(result[index], keys, value);
  2338. }
  2339. }
  2340. return result;
  2341. }
  2342. // Object/hash encoding serializer.
  2343. function hash_serializer(result, key, value) {
  2344. var matches = key.match(brackets);
  2345. // Has brackets? Use the recursive assignment function to walk the keys,
  2346. // construct any missing objects in the result tree and make the assignment
  2347. // at the end of the chain.
  2348. if (matches) {
  2349. var keys = parse_keys(key);
  2350. hash_assign(result, keys, value);
  2351. }
  2352. else {
  2353. // Non bracket notation can make assignments directly.
  2354. var existing = result[key];
  2355. // If the value has been assigned already (for instance when a radio and
  2356. // a checkbox have the same name attribute) convert the previous value
  2357. // into an array before pushing into it.
  2358. //
  2359. // NOTE: If this requirement were removed all hash creation and
  2360. // assignment could go through `hash_assign`.
  2361. if (existing) {
  2362. if (!Array.isArray(existing)) {
  2363. result[key] = [ existing ];
  2364. }
  2365. result[key].push(value);
  2366. }
  2367. else {
  2368. result[key] = value;
  2369. }
  2370. }
  2371. return result;
  2372. }
  2373. // urlform encoding serializer
  2374. function str_serialize(result, key, value) {
  2375. // encode newlines as \r\n cause the html spec says so
  2376. value = value.replace(/(\r)?\n/g, '\r\n');
  2377. value = encodeURIComponent(value);
  2378. // spaces should be '+' rather than '%20'.
  2379. value = value.replace(/%20/g, '+');
  2380. return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value;
  2381. }
  2382. module.exports = serialize;
  2383. /***/ }),
  2384. /***/ "./node_modules/lodash.remove/index.js":
  2385. /*!*********************************************!*\
  2386. !*** ./node_modules/lodash.remove/index.js ***!
  2387. \*********************************************/
  2388. /***/ ((module, exports, __webpack_require__) => {
  2389. /* module decorator */ module = __webpack_require__.nmd(module);
  2390. /**
  2391. * lodash (Custom Build) <https://lodash.com/>
  2392. * Build: `lodash modularize exports="npm" -o ./`
  2393. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  2394. * Released under MIT license <https://lodash.com/license>
  2395. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  2396. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  2397. */
  2398. /** Used as the size to enable large array optimizations. */
  2399. var LARGE_ARRAY_SIZE = 200;
  2400. /** Used as the `TypeError` message for "Functions" methods. */
  2401. var FUNC_ERROR_TEXT = 'Expected a function';
  2402. /** Used to stand-in for `undefined` hash values. */
  2403. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  2404. /** Used to compose bitmasks for comparison styles. */
  2405. var UNORDERED_COMPARE_FLAG = 1,
  2406. PARTIAL_COMPARE_FLAG = 2;
  2407. /** Used as references for various `Number` constants. */
  2408. var INFINITY = 1 / 0,
  2409. MAX_SAFE_INTEGER = 9007199254740991;
  2410. /** `Object#toString` result references. */
  2411. var argsTag = '[object Arguments]',
  2412. arrayTag = '[object Array]',
  2413. boolTag = '[object Boolean]',
  2414. dateTag = '[object Date]',
  2415. errorTag = '[object Error]',
  2416. funcTag = '[object Function]',
  2417. genTag = '[object GeneratorFunction]',
  2418. mapTag = '[object Map]',
  2419. numberTag = '[object Number]',
  2420. objectTag = '[object Object]',
  2421. promiseTag = '[object Promise]',
  2422. regexpTag = '[object RegExp]',
  2423. setTag = '[object Set]',
  2424. stringTag = '[object String]',
  2425. symbolTag = '[object Symbol]',
  2426. weakMapTag = '[object WeakMap]';
  2427. var arrayBufferTag = '[object ArrayBuffer]',
  2428. dataViewTag = '[object DataView]',
  2429. float32Tag = '[object Float32Array]',
  2430. float64Tag = '[object Float64Array]',
  2431. int8Tag = '[object Int8Array]',
  2432. int16Tag = '[object Int16Array]',
  2433. int32Tag = '[object Int32Array]',
  2434. uint8Tag = '[object Uint8Array]',
  2435. uint8ClampedTag = '[object Uint8ClampedArray]',
  2436. uint16Tag = '[object Uint16Array]',
  2437. uint32Tag = '[object Uint32Array]';
  2438. /** Used to match property names within property paths. */
  2439. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  2440. reIsPlainProp = /^\w*$/,
  2441. reLeadingDot = /^\./,
  2442. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  2443. /**
  2444. * Used to match `RegExp`
  2445. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  2446. */
  2447. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  2448. /** Used to match backslashes in property paths. */
  2449. var reEscapeChar = /\\(\\)?/g;
  2450. /** Used to detect host constructors (Safari). */
  2451. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  2452. /** Used to detect unsigned integer values. */
  2453. var reIsUint = /^(?:0|[1-9]\d*)$/;
  2454. /** Used to identify `toStringTag` values of typed arrays. */
  2455. var typedArrayTags = {};
  2456. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  2457. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  2458. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  2459. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  2460. typedArrayTags[uint32Tag] = true;
  2461. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  2462. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  2463. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  2464. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  2465. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  2466. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  2467. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  2468. typedArrayTags[weakMapTag] = false;
  2469. /** Detect free variable `global` from Node.js. */
  2470. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  2471. /** Detect free variable `self`. */
  2472. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  2473. /** Used as a reference to the global object. */
  2474. var root = freeGlobal || freeSelf || Function('return this')();
  2475. /** Detect free variable `exports`. */
  2476. var freeExports = true && exports && !exports.nodeType && exports;
  2477. /** Detect free variable `module`. */
  2478. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  2479. /** Detect the popular CommonJS extension `module.exports`. */
  2480. var moduleExports = freeModule && freeModule.exports === freeExports;
  2481. /** Detect free variable `process` from Node.js. */
  2482. var freeProcess = moduleExports && freeGlobal.process;
  2483. /** Used to access faster Node.js helpers. */
  2484. var nodeUtil = (function() {
  2485. try {
  2486. return freeProcess && freeProcess.binding('util');
  2487. } catch (e) {}
  2488. }());
  2489. /* Node.js helper references. */
  2490. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  2491. /**
  2492. * A specialized version of `_.some` for arrays without support for iteratee
  2493. * shorthands.
  2494. *
  2495. * @private
  2496. * @param {Array} [array] The array to iterate over.
  2497. * @param {Function} predicate The function invoked per iteration.
  2498. * @returns {boolean} Returns `true` if any element passes the predicate check,
  2499. * else `false`.
  2500. */
  2501. function arraySome(array, predicate) {
  2502. var index = -1,
  2503. length = array ? array.length : 0;
  2504. while (++index < length) {
  2505. if (predicate(array[index], index, array)) {
  2506. return true;
  2507. }
  2508. }
  2509. return false;
  2510. }
  2511. /**
  2512. * The base implementation of `_.property` without support for deep paths.
  2513. *
  2514. * @private
  2515. * @param {string} key The key of the property to get.
  2516. * @returns {Function} Returns the new accessor function.
  2517. */
  2518. function baseProperty(key) {
  2519. return function(object) {
  2520. return object == null ? undefined : object[key];
  2521. };
  2522. }
  2523. /**
  2524. * The base implementation of `_.times` without support for iteratee shorthands
  2525. * or max array length checks.
  2526. *
  2527. * @private
  2528. * @param {number} n The number of times to invoke `iteratee`.
  2529. * @param {Function} iteratee The function invoked per iteration.
  2530. * @returns {Array} Returns the array of results.
  2531. */
  2532. function baseTimes(n, iteratee) {
  2533. var index = -1,
  2534. result = Array(n);
  2535. while (++index < n) {
  2536. result[index] = iteratee(index);
  2537. }
  2538. return result;
  2539. }
  2540. /**
  2541. * The base implementation of `_.unary` without support for storing metadata.
  2542. *
  2543. * @private
  2544. * @param {Function} func The function to cap arguments for.
  2545. * @returns {Function} Returns the new capped function.
  2546. */
  2547. function baseUnary(func) {
  2548. return function(value) {
  2549. return func(value);
  2550. };
  2551. }
  2552. /**
  2553. * Gets the value at `key` of `object`.
  2554. *
  2555. * @private
  2556. * @param {Object} [object] The object to query.
  2557. * @param {string} key The key of the property to get.
  2558. * @returns {*} Returns the property value.
  2559. */
  2560. function getValue(object, key) {
  2561. return object == null ? undefined : object[key];
  2562. }
  2563. /**
  2564. * Checks if `value` is a host object in IE < 9.
  2565. *
  2566. * @private
  2567. * @param {*} value The value to check.
  2568. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  2569. */
  2570. function isHostObject(value) {
  2571. // Many host objects are `Object` objects that can coerce to strings
  2572. // despite having improperly defined `toString` methods.
  2573. var result = false;
  2574. if (value != null && typeof value.toString != 'function') {
  2575. try {
  2576. result = !!(value + '');
  2577. } catch (e) {}
  2578. }
  2579. return result;
  2580. }
  2581. /**
  2582. * Converts `map` to its key-value pairs.
  2583. *
  2584. * @private
  2585. * @param {Object} map The map to convert.
  2586. * @returns {Array} Returns the key-value pairs.
  2587. */
  2588. function mapToArray(map) {
  2589. var index = -1,
  2590. result = Array(map.size);
  2591. map.forEach(function(value, key) {
  2592. result[++index] = [key, value];
  2593. });
  2594. return result;
  2595. }
  2596. /**
  2597. * Creates a unary function that invokes `func` with its argument transformed.
  2598. *
  2599. * @private
  2600. * @param {Function} func The function to wrap.
  2601. * @param {Function} transform The argument transform.
  2602. * @returns {Function} Returns the new function.
  2603. */
  2604. function overArg(func, transform) {
  2605. return function(arg) {
  2606. return func(transform(arg));
  2607. };
  2608. }
  2609. /**
  2610. * Converts `set` to an array of its values.
  2611. *
  2612. * @private
  2613. * @param {Object} set The set to convert.
  2614. * @returns {Array} Returns the values.
  2615. */
  2616. function setToArray(set) {
  2617. var index = -1,
  2618. result = Array(set.size);
  2619. set.forEach(function(value) {
  2620. result[++index] = value;
  2621. });
  2622. return result;
  2623. }
  2624. /** Used for built-in method references. */
  2625. var arrayProto = Array.prototype,
  2626. funcProto = Function.prototype,
  2627. objectProto = Object.prototype;
  2628. /** Used to detect overreaching core-js shims. */
  2629. var coreJsData = root['__core-js_shared__'];
  2630. /** Used to detect methods masquerading as native. */
  2631. var maskSrcKey = (function() {
  2632. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2633. return uid ? ('Symbol(src)_1.' + uid) : '';
  2634. }());
  2635. /** Used to resolve the decompiled source of functions. */
  2636. var funcToString = funcProto.toString;
  2637. /** Used to check objects for own properties. */
  2638. var hasOwnProperty = objectProto.hasOwnProperty;
  2639. /**
  2640. * Used to resolve the
  2641. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2642. * of values.
  2643. */
  2644. var objectToString = objectProto.toString;
  2645. /** Used to detect if a method is native. */
  2646. var reIsNative = RegExp('^' +
  2647. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2648. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2649. );
  2650. /** Built-in value references. */
  2651. var Symbol = root.Symbol,
  2652. Uint8Array = root.Uint8Array,
  2653. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2654. splice = arrayProto.splice;
  2655. /* Built-in method references for those with the same name as other `lodash` methods. */
  2656. var nativeKeys = overArg(Object.keys, Object);
  2657. /* Built-in method references that are verified to be native. */
  2658. var DataView = getNative(root, 'DataView'),
  2659. Map = getNative(root, 'Map'),
  2660. Promise = getNative(root, 'Promise'),
  2661. Set = getNative(root, 'Set'),
  2662. WeakMap = getNative(root, 'WeakMap'),
  2663. nativeCreate = getNative(Object, 'create');
  2664. /** Used to detect maps, sets, and weakmaps. */
  2665. var dataViewCtorString = toSource(DataView),
  2666. mapCtorString = toSource(Map),
  2667. promiseCtorString = toSource(Promise),
  2668. setCtorString = toSource(Set),
  2669. weakMapCtorString = toSource(WeakMap);
  2670. /** Used to convert symbols to primitives and strings. */
  2671. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2672. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2673. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2674. /**
  2675. * Creates a hash object.
  2676. *
  2677. * @private
  2678. * @constructor
  2679. * @param {Array} [entries] The key-value pairs to cache.
  2680. */
  2681. function Hash(entries) {
  2682. var index = -1,
  2683. length = entries ? entries.length : 0;
  2684. this.clear();
  2685. while (++index < length) {
  2686. var entry = entries[index];
  2687. this.set(entry[0], entry[1]);
  2688. }
  2689. }
  2690. /**
  2691. * Removes all key-value entries from the hash.
  2692. *
  2693. * @private
  2694. * @name clear
  2695. * @memberOf Hash
  2696. */
  2697. function hashClear() {
  2698. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  2699. }
  2700. /**
  2701. * Removes `key` and its value from the hash.
  2702. *
  2703. * @private
  2704. * @name delete
  2705. * @memberOf Hash
  2706. * @param {Object} hash The hash to modify.
  2707. * @param {string} key The key of the value to remove.
  2708. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2709. */
  2710. function hashDelete(key) {
  2711. return this.has(key) && delete this.__data__[key];
  2712. }
  2713. /**
  2714. * Gets the hash value for `key`.
  2715. *
  2716. * @private
  2717. * @name get
  2718. * @memberOf Hash
  2719. * @param {string} key The key of the value to get.
  2720. * @returns {*} Returns the entry value.
  2721. */
  2722. function hashGet(key) {
  2723. var data = this.__data__;
  2724. if (nativeCreate) {
  2725. var result = data[key];
  2726. return result === HASH_UNDEFINED ? undefined : result;
  2727. }
  2728. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  2729. }
  2730. /**
  2731. * Checks if a hash value for `key` exists.
  2732. *
  2733. * @private
  2734. * @name has
  2735. * @memberOf Hash
  2736. * @param {string} key The key of the entry to check.
  2737. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2738. */
  2739. function hashHas(key) {
  2740. var data = this.__data__;
  2741. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  2742. }
  2743. /**
  2744. * Sets the hash `key` to `value`.
  2745. *
  2746. * @private
  2747. * @name set
  2748. * @memberOf Hash
  2749. * @param {string} key The key of the value to set.
  2750. * @param {*} value The value to set.
  2751. * @returns {Object} Returns the hash instance.
  2752. */
  2753. function hashSet(key, value) {
  2754. var data = this.__data__;
  2755. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  2756. return this;
  2757. }
  2758. // Add methods to `Hash`.
  2759. Hash.prototype.clear = hashClear;
  2760. Hash.prototype['delete'] = hashDelete;
  2761. Hash.prototype.get = hashGet;
  2762. Hash.prototype.has = hashHas;
  2763. Hash.prototype.set = hashSet;
  2764. /**
  2765. * Creates an list cache object.
  2766. *
  2767. * @private
  2768. * @constructor
  2769. * @param {Array} [entries] The key-value pairs to cache.
  2770. */
  2771. function ListCache(entries) {
  2772. var index = -1,
  2773. length = entries ? entries.length : 0;
  2774. this.clear();
  2775. while (++index < length) {
  2776. var entry = entries[index];
  2777. this.set(entry[0], entry[1]);
  2778. }
  2779. }
  2780. /**
  2781. * Removes all key-value entries from the list cache.
  2782. *
  2783. * @private
  2784. * @name clear
  2785. * @memberOf ListCache
  2786. */
  2787. function listCacheClear() {
  2788. this.__data__ = [];
  2789. }
  2790. /**
  2791. * Removes `key` and its value from the list cache.
  2792. *
  2793. * @private
  2794. * @name delete
  2795. * @memberOf ListCache
  2796. * @param {string} key The key of the value to remove.
  2797. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2798. */
  2799. function listCacheDelete(key) {
  2800. var data = this.__data__,
  2801. index = assocIndexOf(data, key);
  2802. if (index < 0) {
  2803. return false;
  2804. }
  2805. var lastIndex = data.length - 1;
  2806. if (index == lastIndex) {
  2807. data.pop();
  2808. } else {
  2809. splice.call(data, index, 1);
  2810. }
  2811. return true;
  2812. }
  2813. /**
  2814. * Gets the list cache value for `key`.
  2815. *
  2816. * @private
  2817. * @name get
  2818. * @memberOf ListCache
  2819. * @param {string} key The key of the value to get.
  2820. * @returns {*} Returns the entry value.
  2821. */
  2822. function listCacheGet(key) {
  2823. var data = this.__data__,
  2824. index = assocIndexOf(data, key);
  2825. return index < 0 ? undefined : data[index][1];
  2826. }
  2827. /**
  2828. * Checks if a list cache value for `key` exists.
  2829. *
  2830. * @private
  2831. * @name has
  2832. * @memberOf ListCache
  2833. * @param {string} key The key of the entry to check.
  2834. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2835. */
  2836. function listCacheHas(key) {
  2837. return assocIndexOf(this.__data__, key) > -1;
  2838. }
  2839. /**
  2840. * Sets the list cache `key` to `value`.
  2841. *
  2842. * @private
  2843. * @name set
  2844. * @memberOf ListCache
  2845. * @param {string} key The key of the value to set.
  2846. * @param {*} value The value to set.
  2847. * @returns {Object} Returns the list cache instance.
  2848. */
  2849. function listCacheSet(key, value) {
  2850. var data = this.__data__,
  2851. index = assocIndexOf(data, key);
  2852. if (index < 0) {
  2853. data.push([key, value]);
  2854. } else {
  2855. data[index][1] = value;
  2856. }
  2857. return this;
  2858. }
  2859. // Add methods to `ListCache`.
  2860. ListCache.prototype.clear = listCacheClear;
  2861. ListCache.prototype['delete'] = listCacheDelete;
  2862. ListCache.prototype.get = listCacheGet;
  2863. ListCache.prototype.has = listCacheHas;
  2864. ListCache.prototype.set = listCacheSet;
  2865. /**
  2866. * Creates a map cache object to store key-value pairs.
  2867. *
  2868. * @private
  2869. * @constructor
  2870. * @param {Array} [entries] The key-value pairs to cache.
  2871. */
  2872. function MapCache(entries) {
  2873. var index = -1,
  2874. length = entries ? entries.length : 0;
  2875. this.clear();
  2876. while (++index < length) {
  2877. var entry = entries[index];
  2878. this.set(entry[0], entry[1]);
  2879. }
  2880. }
  2881. /**
  2882. * Removes all key-value entries from the map.
  2883. *
  2884. * @private
  2885. * @name clear
  2886. * @memberOf MapCache
  2887. */
  2888. function mapCacheClear() {
  2889. this.__data__ = {
  2890. 'hash': new Hash,
  2891. 'map': new (Map || ListCache),
  2892. 'string': new Hash
  2893. };
  2894. }
  2895. /**
  2896. * Removes `key` and its value from the map.
  2897. *
  2898. * @private
  2899. * @name delete
  2900. * @memberOf MapCache
  2901. * @param {string} key The key of the value to remove.
  2902. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2903. */
  2904. function mapCacheDelete(key) {
  2905. return getMapData(this, key)['delete'](key);
  2906. }
  2907. /**
  2908. * Gets the map value for `key`.
  2909. *
  2910. * @private
  2911. * @name get
  2912. * @memberOf MapCache
  2913. * @param {string} key The key of the value to get.
  2914. * @returns {*} Returns the entry value.
  2915. */
  2916. function mapCacheGet(key) {
  2917. return getMapData(this, key).get(key);
  2918. }
  2919. /**
  2920. * Checks if a map value for `key` exists.
  2921. *
  2922. * @private
  2923. * @name has
  2924. * @memberOf MapCache
  2925. * @param {string} key The key of the entry to check.
  2926. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2927. */
  2928. function mapCacheHas(key) {
  2929. return getMapData(this, key).has(key);
  2930. }
  2931. /**
  2932. * Sets the map `key` to `value`.
  2933. *
  2934. * @private
  2935. * @name set
  2936. * @memberOf MapCache
  2937. * @param {string} key The key of the value to set.
  2938. * @param {*} value The value to set.
  2939. * @returns {Object} Returns the map cache instance.
  2940. */
  2941. function mapCacheSet(key, value) {
  2942. getMapData(this, key).set(key, value);
  2943. return this;
  2944. }
  2945. // Add methods to `MapCache`.
  2946. MapCache.prototype.clear = mapCacheClear;
  2947. MapCache.prototype['delete'] = mapCacheDelete;
  2948. MapCache.prototype.get = mapCacheGet;
  2949. MapCache.prototype.has = mapCacheHas;
  2950. MapCache.prototype.set = mapCacheSet;
  2951. /**
  2952. *
  2953. * Creates an array cache object to store unique values.
  2954. *
  2955. * @private
  2956. * @constructor
  2957. * @param {Array} [values] The values to cache.
  2958. */
  2959. function SetCache(values) {
  2960. var index = -1,
  2961. length = values ? values.length : 0;
  2962. this.__data__ = new MapCache;
  2963. while (++index < length) {
  2964. this.add(values[index]);
  2965. }
  2966. }
  2967. /**
  2968. * Adds `value` to the array cache.
  2969. *
  2970. * @private
  2971. * @name add
  2972. * @memberOf SetCache
  2973. * @alias push
  2974. * @param {*} value The value to cache.
  2975. * @returns {Object} Returns the cache instance.
  2976. */
  2977. function setCacheAdd(value) {
  2978. this.__data__.set(value, HASH_UNDEFINED);
  2979. return this;
  2980. }
  2981. /**
  2982. * Checks if `value` is in the array cache.
  2983. *
  2984. * @private
  2985. * @name has
  2986. * @memberOf SetCache
  2987. * @param {*} value The value to search for.
  2988. * @returns {number} Returns `true` if `value` is found, else `false`.
  2989. */
  2990. function setCacheHas(value) {
  2991. return this.__data__.has(value);
  2992. }
  2993. // Add methods to `SetCache`.
  2994. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  2995. SetCache.prototype.has = setCacheHas;
  2996. /**
  2997. * Creates a stack cache object to store key-value pairs.
  2998. *
  2999. * @private
  3000. * @constructor
  3001. * @param {Array} [entries] The key-value pairs to cache.
  3002. */
  3003. function Stack(entries) {
  3004. this.__data__ = new ListCache(entries);
  3005. }
  3006. /**
  3007. * Removes all key-value entries from the stack.
  3008. *
  3009. * @private
  3010. * @name clear
  3011. * @memberOf Stack
  3012. */
  3013. function stackClear() {
  3014. this.__data__ = new ListCache;
  3015. }
  3016. /**
  3017. * Removes `key` and its value from the stack.
  3018. *
  3019. * @private
  3020. * @name delete
  3021. * @memberOf Stack
  3022. * @param {string} key The key of the value to remove.
  3023. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3024. */
  3025. function stackDelete(key) {
  3026. return this.__data__['delete'](key);
  3027. }
  3028. /**
  3029. * Gets the stack value for `key`.
  3030. *
  3031. * @private
  3032. * @name get
  3033. * @memberOf Stack
  3034. * @param {string} key The key of the value to get.
  3035. * @returns {*} Returns the entry value.
  3036. */
  3037. function stackGet(key) {
  3038. return this.__data__.get(key);
  3039. }
  3040. /**
  3041. * Checks if a stack value for `key` exists.
  3042. *
  3043. * @private
  3044. * @name has
  3045. * @memberOf Stack
  3046. * @param {string} key The key of the entry to check.
  3047. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3048. */
  3049. function stackHas(key) {
  3050. return this.__data__.has(key);
  3051. }
  3052. /**
  3053. * Sets the stack `key` to `value`.
  3054. *
  3055. * @private
  3056. * @name set
  3057. * @memberOf Stack
  3058. * @param {string} key The key of the value to set.
  3059. * @param {*} value The value to set.
  3060. * @returns {Object} Returns the stack cache instance.
  3061. */
  3062. function stackSet(key, value) {
  3063. var cache = this.__data__;
  3064. if (cache instanceof ListCache) {
  3065. var pairs = cache.__data__;
  3066. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  3067. pairs.push([key, value]);
  3068. return this;
  3069. }
  3070. cache = this.__data__ = new MapCache(pairs);
  3071. }
  3072. cache.set(key, value);
  3073. return this;
  3074. }
  3075. // Add methods to `Stack`.
  3076. Stack.prototype.clear = stackClear;
  3077. Stack.prototype['delete'] = stackDelete;
  3078. Stack.prototype.get = stackGet;
  3079. Stack.prototype.has = stackHas;
  3080. Stack.prototype.set = stackSet;
  3081. /**
  3082. * Creates an array of the enumerable property names of the array-like `value`.
  3083. *
  3084. * @private
  3085. * @param {*} value The value to query.
  3086. * @param {boolean} inherited Specify returning inherited property names.
  3087. * @returns {Array} Returns the array of property names.
  3088. */
  3089. function arrayLikeKeys(value, inherited) {
  3090. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  3091. // Safari 9 makes `arguments.length` enumerable in strict mode.
  3092. var result = (isArray(value) || isArguments(value))
  3093. ? baseTimes(value.length, String)
  3094. : [];
  3095. var length = result.length,
  3096. skipIndexes = !!length;
  3097. for (var key in value) {
  3098. if ((inherited || hasOwnProperty.call(value, key)) &&
  3099. !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
  3100. result.push(key);
  3101. }
  3102. }
  3103. return result;
  3104. }
  3105. /**
  3106. * Gets the index at which the `key` is found in `array` of key-value pairs.
  3107. *
  3108. * @private
  3109. * @param {Array} array The array to inspect.
  3110. * @param {*} key The key to search for.
  3111. * @returns {number} Returns the index of the matched value, else `-1`.
  3112. */
  3113. function assocIndexOf(array, key) {
  3114. var length = array.length;
  3115. while (length--) {
  3116. if (eq(array[length][0], key)) {
  3117. return length;
  3118. }
  3119. }
  3120. return -1;
  3121. }
  3122. /**
  3123. * The base implementation of `_.get` without support for default values.
  3124. *
  3125. * @private
  3126. * @param {Object} object The object to query.
  3127. * @param {Array|string} path The path of the property to get.
  3128. * @returns {*} Returns the resolved value.
  3129. */
  3130. function baseGet(object, path) {
  3131. path = isKey(path, object) ? [path] : castPath(path);
  3132. var index = 0,
  3133. length = path.length;
  3134. while (object != null && index < length) {
  3135. object = object[toKey(path[index++])];
  3136. }
  3137. return (index && index == length) ? object : undefined;
  3138. }
  3139. /**
  3140. * The base implementation of `getTag`.
  3141. *
  3142. * @private
  3143. * @param {*} value The value to query.
  3144. * @returns {string} Returns the `toStringTag`.
  3145. */
  3146. function baseGetTag(value) {
  3147. return objectToString.call(value);
  3148. }
  3149. /**
  3150. * The base implementation of `_.hasIn` without support for deep paths.
  3151. *
  3152. * @private
  3153. * @param {Object} [object] The object to query.
  3154. * @param {Array|string} key The key to check.
  3155. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3156. */
  3157. function baseHasIn(object, key) {
  3158. return object != null && key in Object(object);
  3159. }
  3160. /**
  3161. * The base implementation of `_.isEqual` which supports partial comparisons
  3162. * and tracks traversed objects.
  3163. *
  3164. * @private
  3165. * @param {*} value The value to compare.
  3166. * @param {*} other The other value to compare.
  3167. * @param {Function} [customizer] The function to customize comparisons.
  3168. * @param {boolean} [bitmask] The bitmask of comparison flags.
  3169. * The bitmask may be composed of the following flags:
  3170. * 1 - Unordered comparison
  3171. * 2 - Partial comparison
  3172. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  3173. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3174. */
  3175. function baseIsEqual(value, other, customizer, bitmask, stack) {
  3176. if (value === other) {
  3177. return true;
  3178. }
  3179. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  3180. return value !== value && other !== other;
  3181. }
  3182. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  3183. }
  3184. /**
  3185. * A specialized version of `baseIsEqual` for arrays and objects which performs
  3186. * deep comparisons and tracks traversed objects enabling objects with circular
  3187. * references to be compared.
  3188. *
  3189. * @private
  3190. * @param {Object} object The object to compare.
  3191. * @param {Object} other The other object to compare.
  3192. * @param {Function} equalFunc The function to determine equivalents of values.
  3193. * @param {Function} [customizer] The function to customize comparisons.
  3194. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  3195. * for more details.
  3196. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  3197. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3198. */
  3199. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  3200. var objIsArr = isArray(object),
  3201. othIsArr = isArray(other),
  3202. objTag = arrayTag,
  3203. othTag = arrayTag;
  3204. if (!objIsArr) {
  3205. objTag = getTag(object);
  3206. objTag = objTag == argsTag ? objectTag : objTag;
  3207. }
  3208. if (!othIsArr) {
  3209. othTag = getTag(other);
  3210. othTag = othTag == argsTag ? objectTag : othTag;
  3211. }
  3212. var objIsObj = objTag == objectTag && !isHostObject(object),
  3213. othIsObj = othTag == objectTag && !isHostObject(other),
  3214. isSameTag = objTag == othTag;
  3215. if (isSameTag && !objIsObj) {
  3216. stack || (stack = new Stack);
  3217. return (objIsArr || isTypedArray(object))
  3218. ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
  3219. : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  3220. }
  3221. if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
  3222. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  3223. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  3224. if (objIsWrapped || othIsWrapped) {
  3225. var objUnwrapped = objIsWrapped ? object.value() : object,
  3226. othUnwrapped = othIsWrapped ? other.value() : other;
  3227. stack || (stack = new Stack);
  3228. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  3229. }
  3230. }
  3231. if (!isSameTag) {
  3232. return false;
  3233. }
  3234. stack || (stack = new Stack);
  3235. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  3236. }
  3237. /**
  3238. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  3239. *
  3240. * @private
  3241. * @param {Object} object The object to inspect.
  3242. * @param {Object} source The object of property values to match.
  3243. * @param {Array} matchData The property names, values, and compare flags to match.
  3244. * @param {Function} [customizer] The function to customize comparisons.
  3245. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  3246. */
  3247. function baseIsMatch(object, source, matchData, customizer) {
  3248. var index = matchData.length,
  3249. length = index,
  3250. noCustomizer = !customizer;
  3251. if (object == null) {
  3252. return !length;
  3253. }
  3254. object = Object(object);
  3255. while (index--) {
  3256. var data = matchData[index];
  3257. if ((noCustomizer && data[2])
  3258. ? data[1] !== object[data[0]]
  3259. : !(data[0] in object)
  3260. ) {
  3261. return false;
  3262. }
  3263. }
  3264. while (++index < length) {
  3265. data = matchData[index];
  3266. var key = data[0],
  3267. objValue = object[key],
  3268. srcValue = data[1];
  3269. if (noCustomizer && data[2]) {
  3270. if (objValue === undefined && !(key in object)) {
  3271. return false;
  3272. }
  3273. } else {
  3274. var stack = new Stack;
  3275. if (customizer) {
  3276. var result = customizer(objValue, srcValue, key, object, source, stack);
  3277. }
  3278. if (!(result === undefined
  3279. ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
  3280. : result
  3281. )) {
  3282. return false;
  3283. }
  3284. }
  3285. }
  3286. return true;
  3287. }
  3288. /**
  3289. * The base implementation of `_.isNative` without bad shim checks.
  3290. *
  3291. * @private
  3292. * @param {*} value The value to check.
  3293. * @returns {boolean} Returns `true` if `value` is a native function,
  3294. * else `false`.
  3295. */
  3296. function baseIsNative(value) {
  3297. if (!isObject(value) || isMasked(value)) {
  3298. return false;
  3299. }
  3300. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  3301. return pattern.test(toSource(value));
  3302. }
  3303. /**
  3304. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  3305. *
  3306. * @private
  3307. * @param {*} value The value to check.
  3308. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3309. */
  3310. function baseIsTypedArray(value) {
  3311. return isObjectLike(value) &&
  3312. isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  3313. }
  3314. /**
  3315. * The base implementation of `_.iteratee`.
  3316. *
  3317. * @private
  3318. * @param {*} [value=_.identity] The value to convert to an iteratee.
  3319. * @returns {Function} Returns the iteratee.
  3320. */
  3321. function baseIteratee(value) {
  3322. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  3323. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  3324. if (typeof value == 'function') {
  3325. return value;
  3326. }
  3327. if (value == null) {
  3328. return identity;
  3329. }
  3330. if (typeof value == 'object') {
  3331. return isArray(value)
  3332. ? baseMatchesProperty(value[0], value[1])
  3333. : baseMatches(value);
  3334. }
  3335. return property(value);
  3336. }
  3337. /**
  3338. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  3339. *
  3340. * @private
  3341. * @param {Object} object The object to query.
  3342. * @returns {Array} Returns the array of property names.
  3343. */
  3344. function baseKeys(object) {
  3345. if (!isPrototype(object)) {
  3346. return nativeKeys(object);
  3347. }
  3348. var result = [];
  3349. for (var key in Object(object)) {
  3350. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  3351. result.push(key);
  3352. }
  3353. }
  3354. return result;
  3355. }
  3356. /**
  3357. * The base implementation of `_.matches` which doesn't clone `source`.
  3358. *
  3359. * @private
  3360. * @param {Object} source The object of property values to match.
  3361. * @returns {Function} Returns the new spec function.
  3362. */
  3363. function baseMatches(source) {
  3364. var matchData = getMatchData(source);
  3365. if (matchData.length == 1 && matchData[0][2]) {
  3366. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  3367. }
  3368. return function(object) {
  3369. return object === source || baseIsMatch(object, source, matchData);
  3370. };
  3371. }
  3372. /**
  3373. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  3374. *
  3375. * @private
  3376. * @param {string} path The path of the property to get.
  3377. * @param {*} srcValue The value to match.
  3378. * @returns {Function} Returns the new spec function.
  3379. */
  3380. function baseMatchesProperty(path, srcValue) {
  3381. if (isKey(path) && isStrictComparable(srcValue)) {
  3382. return matchesStrictComparable(toKey(path), srcValue);
  3383. }
  3384. return function(object) {
  3385. var objValue = get(object, path);
  3386. return (objValue === undefined && objValue === srcValue)
  3387. ? hasIn(object, path)
  3388. : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
  3389. };
  3390. }
  3391. /**
  3392. * A specialized version of `baseProperty` which supports deep paths.
  3393. *
  3394. * @private
  3395. * @param {Array|string} path The path of the property to get.
  3396. * @returns {Function} Returns the new accessor function.
  3397. */
  3398. function basePropertyDeep(path) {
  3399. return function(object) {
  3400. return baseGet(object, path);
  3401. };
  3402. }
  3403. /**
  3404. * The base implementation of `_.pullAt` without support for individual
  3405. * indexes or capturing the removed elements.
  3406. *
  3407. * @private
  3408. * @param {Array} array The array to modify.
  3409. * @param {number[]} indexes The indexes of elements to remove.
  3410. * @returns {Array} Returns `array`.
  3411. */
  3412. function basePullAt(array, indexes) {
  3413. var length = array ? indexes.length : 0,
  3414. lastIndex = length - 1;
  3415. while (length--) {
  3416. var index = indexes[length];
  3417. if (length == lastIndex || index !== previous) {
  3418. var previous = index;
  3419. if (isIndex(index)) {
  3420. splice.call(array, index, 1);
  3421. }
  3422. else if (!isKey(index, array)) {
  3423. var path = castPath(index),
  3424. object = parent(array, path);
  3425. if (object != null) {
  3426. delete object[toKey(last(path))];
  3427. }
  3428. }
  3429. else {
  3430. delete array[toKey(index)];
  3431. }
  3432. }
  3433. }
  3434. return array;
  3435. }
  3436. /**
  3437. * The base implementation of `_.slice` without an iteratee call guard.
  3438. *
  3439. * @private
  3440. * @param {Array} array The array to slice.
  3441. * @param {number} [start=0] The start position.
  3442. * @param {number} [end=array.length] The end position.
  3443. * @returns {Array} Returns the slice of `array`.
  3444. */
  3445. function baseSlice(array, start, end) {
  3446. var index = -1,
  3447. length = array.length;
  3448. if (start < 0) {
  3449. start = -start > length ? 0 : (length + start);
  3450. }
  3451. end = end > length ? length : end;
  3452. if (end < 0) {
  3453. end += length;
  3454. }
  3455. length = start > end ? 0 : ((end - start) >>> 0);
  3456. start >>>= 0;
  3457. var result = Array(length);
  3458. while (++index < length) {
  3459. result[index] = array[index + start];
  3460. }
  3461. return result;
  3462. }
  3463. /**
  3464. * The base implementation of `_.toString` which doesn't convert nullish
  3465. * values to empty strings.
  3466. *
  3467. * @private
  3468. * @param {*} value The value to process.
  3469. * @returns {string} Returns the string.
  3470. */
  3471. function baseToString(value) {
  3472. // Exit early for strings to avoid a performance hit in some environments.
  3473. if (typeof value == 'string') {
  3474. return value;
  3475. }
  3476. if (isSymbol(value)) {
  3477. return symbolToString ? symbolToString.call(value) : '';
  3478. }
  3479. var result = (value + '');
  3480. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  3481. }
  3482. /**
  3483. * Casts `value` to a path array if it's not one.
  3484. *
  3485. * @private
  3486. * @param {*} value The value to inspect.
  3487. * @returns {Array} Returns the cast property path array.
  3488. */
  3489. function castPath(value) {
  3490. return isArray(value) ? value : stringToPath(value);
  3491. }
  3492. /**
  3493. * A specialized version of `baseIsEqualDeep` for arrays with support for
  3494. * partial deep comparisons.
  3495. *
  3496. * @private
  3497. * @param {Array} array The array to compare.
  3498. * @param {Array} other The other array to compare.
  3499. * @param {Function} equalFunc The function to determine equivalents of values.
  3500. * @param {Function} customizer The function to customize comparisons.
  3501. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3502. * for more details.
  3503. * @param {Object} stack Tracks traversed `array` and `other` objects.
  3504. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  3505. */
  3506. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  3507. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  3508. arrLength = array.length,
  3509. othLength = other.length;
  3510. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  3511. return false;
  3512. }
  3513. // Assume cyclic values are equal.
  3514. var stacked = stack.get(array);
  3515. if (stacked && stack.get(other)) {
  3516. return stacked == other;
  3517. }
  3518. var index = -1,
  3519. result = true,
  3520. seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
  3521. stack.set(array, other);
  3522. stack.set(other, array);
  3523. // Ignore non-index properties.
  3524. while (++index < arrLength) {
  3525. var arrValue = array[index],
  3526. othValue = other[index];
  3527. if (customizer) {
  3528. var compared = isPartial
  3529. ? customizer(othValue, arrValue, index, other, array, stack)
  3530. : customizer(arrValue, othValue, index, array, other, stack);
  3531. }
  3532. if (compared !== undefined) {
  3533. if (compared) {
  3534. continue;
  3535. }
  3536. result = false;
  3537. break;
  3538. }
  3539. // Recursively compare arrays (susceptible to call stack limits).
  3540. if (seen) {
  3541. if (!arraySome(other, function(othValue, othIndex) {
  3542. if (!seen.has(othIndex) &&
  3543. (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  3544. return seen.add(othIndex);
  3545. }
  3546. })) {
  3547. result = false;
  3548. break;
  3549. }
  3550. } else if (!(
  3551. arrValue === othValue ||
  3552. equalFunc(arrValue, othValue, customizer, bitmask, stack)
  3553. )) {
  3554. result = false;
  3555. break;
  3556. }
  3557. }
  3558. stack['delete'](array);
  3559. stack['delete'](other);
  3560. return result;
  3561. }
  3562. /**
  3563. * A specialized version of `baseIsEqualDeep` for comparing objects of
  3564. * the same `toStringTag`.
  3565. *
  3566. * **Note:** This function only supports comparing values with tags of
  3567. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  3568. *
  3569. * @private
  3570. * @param {Object} object The object to compare.
  3571. * @param {Object} other The other object to compare.
  3572. * @param {string} tag The `toStringTag` of the objects to compare.
  3573. * @param {Function} equalFunc The function to determine equivalents of values.
  3574. * @param {Function} customizer The function to customize comparisons.
  3575. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3576. * for more details.
  3577. * @param {Object} stack Tracks traversed `object` and `other` objects.
  3578. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3579. */
  3580. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  3581. switch (tag) {
  3582. case dataViewTag:
  3583. if ((object.byteLength != other.byteLength) ||
  3584. (object.byteOffset != other.byteOffset)) {
  3585. return false;
  3586. }
  3587. object = object.buffer;
  3588. other = other.buffer;
  3589. case arrayBufferTag:
  3590. if ((object.byteLength != other.byteLength) ||
  3591. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  3592. return false;
  3593. }
  3594. return true;
  3595. case boolTag:
  3596. case dateTag:
  3597. case numberTag:
  3598. // Coerce booleans to `1` or `0` and dates to milliseconds.
  3599. // Invalid dates are coerced to `NaN`.
  3600. return eq(+object, +other);
  3601. case errorTag:
  3602. return object.name == other.name && object.message == other.message;
  3603. case regexpTag:
  3604. case stringTag:
  3605. // Coerce regexes to strings and treat strings, primitives and objects,
  3606. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  3607. // for more details.
  3608. return object == (other + '');
  3609. case mapTag:
  3610. var convert = mapToArray;
  3611. case setTag:
  3612. var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
  3613. convert || (convert = setToArray);
  3614. if (object.size != other.size && !isPartial) {
  3615. return false;
  3616. }
  3617. // Assume cyclic values are equal.
  3618. var stacked = stack.get(object);
  3619. if (stacked) {
  3620. return stacked == other;
  3621. }
  3622. bitmask |= UNORDERED_COMPARE_FLAG;
  3623. // Recursively compare objects (susceptible to call stack limits).
  3624. stack.set(object, other);
  3625. var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  3626. stack['delete'](object);
  3627. return result;
  3628. case symbolTag:
  3629. if (symbolValueOf) {
  3630. return symbolValueOf.call(object) == symbolValueOf.call(other);
  3631. }
  3632. }
  3633. return false;
  3634. }
  3635. /**
  3636. * A specialized version of `baseIsEqualDeep` for objects with support for
  3637. * partial deep comparisons.
  3638. *
  3639. * @private
  3640. * @param {Object} object The object to compare.
  3641. * @param {Object} other The other object to compare.
  3642. * @param {Function} equalFunc The function to determine equivalents of values.
  3643. * @param {Function} customizer The function to customize comparisons.
  3644. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3645. * for more details.
  3646. * @param {Object} stack Tracks traversed `object` and `other` objects.
  3647. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3648. */
  3649. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  3650. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  3651. objProps = keys(object),
  3652. objLength = objProps.length,
  3653. othProps = keys(other),
  3654. othLength = othProps.length;
  3655. if (objLength != othLength && !isPartial) {
  3656. return false;
  3657. }
  3658. var index = objLength;
  3659. while (index--) {
  3660. var key = objProps[index];
  3661. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  3662. return false;
  3663. }
  3664. }
  3665. // Assume cyclic values are equal.
  3666. var stacked = stack.get(object);
  3667. if (stacked && stack.get(other)) {
  3668. return stacked == other;
  3669. }
  3670. var result = true;
  3671. stack.set(object, other);
  3672. stack.set(other, object);
  3673. var skipCtor = isPartial;
  3674. while (++index < objLength) {
  3675. key = objProps[index];
  3676. var objValue = object[key],
  3677. othValue = other[key];
  3678. if (customizer) {
  3679. var compared = isPartial
  3680. ? customizer(othValue, objValue, key, other, object, stack)
  3681. : customizer(objValue, othValue, key, object, other, stack);
  3682. }
  3683. // Recursively compare objects (susceptible to call stack limits).
  3684. if (!(compared === undefined
  3685. ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
  3686. : compared
  3687. )) {
  3688. result = false;
  3689. break;
  3690. }
  3691. skipCtor || (skipCtor = key == 'constructor');
  3692. }
  3693. if (result && !skipCtor) {
  3694. var objCtor = object.constructor,
  3695. othCtor = other.constructor;
  3696. // Non `Object` object instances with different constructors are not equal.
  3697. if (objCtor != othCtor &&
  3698. ('constructor' in object && 'constructor' in other) &&
  3699. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  3700. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  3701. result = false;
  3702. }
  3703. }
  3704. stack['delete'](object);
  3705. stack['delete'](other);
  3706. return result;
  3707. }
  3708. /**
  3709. * Gets the data for `map`.
  3710. *
  3711. * @private
  3712. * @param {Object} map The map to query.
  3713. * @param {string} key The reference key.
  3714. * @returns {*} Returns the map data.
  3715. */
  3716. function getMapData(map, key) {
  3717. var data = map.__data__;
  3718. return isKeyable(key)
  3719. ? data[typeof key == 'string' ? 'string' : 'hash']
  3720. : data.map;
  3721. }
  3722. /**
  3723. * Gets the property names, values, and compare flags of `object`.
  3724. *
  3725. * @private
  3726. * @param {Object} object The object to query.
  3727. * @returns {Array} Returns the match data of `object`.
  3728. */
  3729. function getMatchData(object) {
  3730. var result = keys(object),
  3731. length = result.length;
  3732. while (length--) {
  3733. var key = result[length],
  3734. value = object[key];
  3735. result[length] = [key, value, isStrictComparable(value)];
  3736. }
  3737. return result;
  3738. }
  3739. /**
  3740. * Gets the native function at `key` of `object`.
  3741. *
  3742. * @private
  3743. * @param {Object} object The object to query.
  3744. * @param {string} key The key of the method to get.
  3745. * @returns {*} Returns the function if it's native, else `undefined`.
  3746. */
  3747. function getNative(object, key) {
  3748. var value = getValue(object, key);
  3749. return baseIsNative(value) ? value : undefined;
  3750. }
  3751. /**
  3752. * Gets the `toStringTag` of `value`.
  3753. *
  3754. * @private
  3755. * @param {*} value The value to query.
  3756. * @returns {string} Returns the `toStringTag`.
  3757. */
  3758. var getTag = baseGetTag;
  3759. // Fallback for data views, maps, sets, and weak maps in IE 11,
  3760. // for data views in Edge < 14, and promises in Node.js.
  3761. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  3762. (Map && getTag(new Map) != mapTag) ||
  3763. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  3764. (Set && getTag(new Set) != setTag) ||
  3765. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  3766. getTag = function(value) {
  3767. var result = objectToString.call(value),
  3768. Ctor = result == objectTag ? value.constructor : undefined,
  3769. ctorString = Ctor ? toSource(Ctor) : undefined;
  3770. if (ctorString) {
  3771. switch (ctorString) {
  3772. case dataViewCtorString: return dataViewTag;
  3773. case mapCtorString: return mapTag;
  3774. case promiseCtorString: return promiseTag;
  3775. case setCtorString: return setTag;
  3776. case weakMapCtorString: return weakMapTag;
  3777. }
  3778. }
  3779. return result;
  3780. };
  3781. }
  3782. /**
  3783. * Checks if `path` exists on `object`.
  3784. *
  3785. * @private
  3786. * @param {Object} object The object to query.
  3787. * @param {Array|string} path The path to check.
  3788. * @param {Function} hasFunc The function to check properties.
  3789. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  3790. */
  3791. function hasPath(object, path, hasFunc) {
  3792. path = isKey(path, object) ? [path] : castPath(path);
  3793. var result,
  3794. index = -1,
  3795. length = path.length;
  3796. while (++index < length) {
  3797. var key = toKey(path[index]);
  3798. if (!(result = object != null && hasFunc(object, key))) {
  3799. break;
  3800. }
  3801. object = object[key];
  3802. }
  3803. if (result) {
  3804. return result;
  3805. }
  3806. var length = object ? object.length : 0;
  3807. return !!length && isLength(length) && isIndex(key, length) &&
  3808. (isArray(object) || isArguments(object));
  3809. }
  3810. /**
  3811. * Checks if `value` is a valid array-like index.
  3812. *
  3813. * @private
  3814. * @param {*} value The value to check.
  3815. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  3816. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  3817. */
  3818. function isIndex(value, length) {
  3819. length = length == null ? MAX_SAFE_INTEGER : length;
  3820. return !!length &&
  3821. (typeof value == 'number' || reIsUint.test(value)) &&
  3822. (value > -1 && value % 1 == 0 && value < length);
  3823. }
  3824. /**
  3825. * Checks if `value` is a property name and not a property path.
  3826. *
  3827. * @private
  3828. * @param {*} value The value to check.
  3829. * @param {Object} [object] The object to query keys on.
  3830. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  3831. */
  3832. function isKey(value, object) {
  3833. if (isArray(value)) {
  3834. return false;
  3835. }
  3836. var type = typeof value;
  3837. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  3838. value == null || isSymbol(value)) {
  3839. return true;
  3840. }
  3841. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  3842. (object != null && value in Object(object));
  3843. }
  3844. /**
  3845. * Checks if `value` is suitable for use as unique object key.
  3846. *
  3847. * @private
  3848. * @param {*} value The value to check.
  3849. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  3850. */
  3851. function isKeyable(value) {
  3852. var type = typeof value;
  3853. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  3854. ? (value !== '__proto__')
  3855. : (value === null);
  3856. }
  3857. /**
  3858. * Checks if `func` has its source masked.
  3859. *
  3860. * @private
  3861. * @param {Function} func The function to check.
  3862. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  3863. */
  3864. function isMasked(func) {
  3865. return !!maskSrcKey && (maskSrcKey in func);
  3866. }
  3867. /**
  3868. * Checks if `value` is likely a prototype object.
  3869. *
  3870. * @private
  3871. * @param {*} value The value to check.
  3872. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  3873. */
  3874. function isPrototype(value) {
  3875. var Ctor = value && value.constructor,
  3876. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  3877. return value === proto;
  3878. }
  3879. /**
  3880. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  3881. *
  3882. * @private
  3883. * @param {*} value The value to check.
  3884. * @returns {boolean} Returns `true` if `value` if suitable for strict
  3885. * equality comparisons, else `false`.
  3886. */
  3887. function isStrictComparable(value) {
  3888. return value === value && !isObject(value);
  3889. }
  3890. /**
  3891. * A specialized version of `matchesProperty` for source values suitable
  3892. * for strict equality comparisons, i.e. `===`.
  3893. *
  3894. * @private
  3895. * @param {string} key The key of the property to get.
  3896. * @param {*} srcValue The value to match.
  3897. * @returns {Function} Returns the new spec function.
  3898. */
  3899. function matchesStrictComparable(key, srcValue) {
  3900. return function(object) {
  3901. if (object == null) {
  3902. return false;
  3903. }
  3904. return object[key] === srcValue &&
  3905. (srcValue !== undefined || (key in Object(object)));
  3906. };
  3907. }
  3908. /**
  3909. * Gets the parent value at `path` of `object`.
  3910. *
  3911. * @private
  3912. * @param {Object} object The object to query.
  3913. * @param {Array} path The path to get the parent value of.
  3914. * @returns {*} Returns the parent value.
  3915. */
  3916. function parent(object, path) {
  3917. return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  3918. }
  3919. /**
  3920. * Converts `string` to a property path array.
  3921. *
  3922. * @private
  3923. * @param {string} string The string to convert.
  3924. * @returns {Array} Returns the property path array.
  3925. */
  3926. var stringToPath = memoize(function(string) {
  3927. string = toString(string);
  3928. var result = [];
  3929. if (reLeadingDot.test(string)) {
  3930. result.push('');
  3931. }
  3932. string.replace(rePropName, function(match, number, quote, string) {
  3933. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  3934. });
  3935. return result;
  3936. });
  3937. /**
  3938. * Converts `value` to a string key if it's not a string or symbol.
  3939. *
  3940. * @private
  3941. * @param {*} value The value to inspect.
  3942. * @returns {string|symbol} Returns the key.
  3943. */
  3944. function toKey(value) {
  3945. if (typeof value == 'string' || isSymbol(value)) {
  3946. return value;
  3947. }
  3948. var result = (value + '');
  3949. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  3950. }
  3951. /**
  3952. * Converts `func` to its source code.
  3953. *
  3954. * @private
  3955. * @param {Function} func The function to process.
  3956. * @returns {string} Returns the source code.
  3957. */
  3958. function toSource(func) {
  3959. if (func != null) {
  3960. try {
  3961. return funcToString.call(func);
  3962. } catch (e) {}
  3963. try {
  3964. return (func + '');
  3965. } catch (e) {}
  3966. }
  3967. return '';
  3968. }
  3969. /**
  3970. * Gets the last element of `array`.
  3971. *
  3972. * @static
  3973. * @memberOf _
  3974. * @since 0.1.0
  3975. * @category Array
  3976. * @param {Array} array The array to query.
  3977. * @returns {*} Returns the last element of `array`.
  3978. * @example
  3979. *
  3980. * _.last([1, 2, 3]);
  3981. * // => 3
  3982. */
  3983. function last(array) {
  3984. var length = array ? array.length : 0;
  3985. return length ? array[length - 1] : undefined;
  3986. }
  3987. /**
  3988. * Removes all elements from `array` that `predicate` returns truthy for
  3989. * and returns an array of the removed elements. The predicate is invoked
  3990. * with three arguments: (value, index, array).
  3991. *
  3992. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  3993. * to pull elements from an array by value.
  3994. *
  3995. * @static
  3996. * @memberOf _
  3997. * @since 2.0.0
  3998. * @category Array
  3999. * @param {Array} array The array to modify.
  4000. * @param {Function} [predicate=_.identity]
  4001. * The function invoked per iteration.
  4002. * @returns {Array} Returns the new array of removed elements.
  4003. * @example
  4004. *
  4005. * var array = [1, 2, 3, 4];
  4006. * var evens = _.remove(array, function(n) {
  4007. * return n % 2 == 0;
  4008. * });
  4009. *
  4010. * console.log(array);
  4011. * // => [1, 3]
  4012. *
  4013. * console.log(evens);
  4014. * // => [2, 4]
  4015. */
  4016. function remove(array, predicate) {
  4017. var result = [];
  4018. if (!(array && array.length)) {
  4019. return result;
  4020. }
  4021. var index = -1,
  4022. indexes = [],
  4023. length = array.length;
  4024. predicate = baseIteratee(predicate, 3);
  4025. while (++index < length) {
  4026. var value = array[index];
  4027. if (predicate(value, index, array)) {
  4028. result.push(value);
  4029. indexes.push(index);
  4030. }
  4031. }
  4032. basePullAt(array, indexes);
  4033. return result;
  4034. }
  4035. /**
  4036. * Creates a function that memoizes the result of `func`. If `resolver` is
  4037. * provided, it determines the cache key for storing the result based on the
  4038. * arguments provided to the memoized function. By default, the first argument
  4039. * provided to the memoized function is used as the map cache key. The `func`
  4040. * is invoked with the `this` binding of the memoized function.
  4041. *
  4042. * **Note:** The cache is exposed as the `cache` property on the memoized
  4043. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  4044. * constructor with one whose instances implement the
  4045. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  4046. * method interface of `delete`, `get`, `has`, and `set`.
  4047. *
  4048. * @static
  4049. * @memberOf _
  4050. * @since 0.1.0
  4051. * @category Function
  4052. * @param {Function} func The function to have its output memoized.
  4053. * @param {Function} [resolver] The function to resolve the cache key.
  4054. * @returns {Function} Returns the new memoized function.
  4055. * @example
  4056. *
  4057. * var object = { 'a': 1, 'b': 2 };
  4058. * var other = { 'c': 3, 'd': 4 };
  4059. *
  4060. * var values = _.memoize(_.values);
  4061. * values(object);
  4062. * // => [1, 2]
  4063. *
  4064. * values(other);
  4065. * // => [3, 4]
  4066. *
  4067. * object.a = 2;
  4068. * values(object);
  4069. * // => [1, 2]
  4070. *
  4071. * // Modify the result cache.
  4072. * values.cache.set(object, ['a', 'b']);
  4073. * values(object);
  4074. * // => ['a', 'b']
  4075. *
  4076. * // Replace `_.memoize.Cache`.
  4077. * _.memoize.Cache = WeakMap;
  4078. */
  4079. function memoize(func, resolver) {
  4080. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  4081. throw new TypeError(FUNC_ERROR_TEXT);
  4082. }
  4083. var memoized = function() {
  4084. var args = arguments,
  4085. key = resolver ? resolver.apply(this, args) : args[0],
  4086. cache = memoized.cache;
  4087. if (cache.has(key)) {
  4088. return cache.get(key);
  4089. }
  4090. var result = func.apply(this, args);
  4091. memoized.cache = cache.set(key, result);
  4092. return result;
  4093. };
  4094. memoized.cache = new (memoize.Cache || MapCache);
  4095. return memoized;
  4096. }
  4097. // Assign cache to `_.memoize`.
  4098. memoize.Cache = MapCache;
  4099. /**
  4100. * Performs a
  4101. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  4102. * comparison between two values to determine if they are equivalent.
  4103. *
  4104. * @static
  4105. * @memberOf _
  4106. * @since 4.0.0
  4107. * @category Lang
  4108. * @param {*} value The value to compare.
  4109. * @param {*} other The other value to compare.
  4110. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  4111. * @example
  4112. *
  4113. * var object = { 'a': 1 };
  4114. * var other = { 'a': 1 };
  4115. *
  4116. * _.eq(object, object);
  4117. * // => true
  4118. *
  4119. * _.eq(object, other);
  4120. * // => false
  4121. *
  4122. * _.eq('a', 'a');
  4123. * // => true
  4124. *
  4125. * _.eq('a', Object('a'));
  4126. * // => false
  4127. *
  4128. * _.eq(NaN, NaN);
  4129. * // => true
  4130. */
  4131. function eq(value, other) {
  4132. return value === other || (value !== value && other !== other);
  4133. }
  4134. /**
  4135. * Checks if `value` is likely an `arguments` object.
  4136. *
  4137. * @static
  4138. * @memberOf _
  4139. * @since 0.1.0
  4140. * @category Lang
  4141. * @param {*} value The value to check.
  4142. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  4143. * else `false`.
  4144. * @example
  4145. *
  4146. * _.isArguments(function() { return arguments; }());
  4147. * // => true
  4148. *
  4149. * _.isArguments([1, 2, 3]);
  4150. * // => false
  4151. */
  4152. function isArguments(value) {
  4153. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  4154. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  4155. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  4156. }
  4157. /**
  4158. * Checks if `value` is classified as an `Array` object.
  4159. *
  4160. * @static
  4161. * @memberOf _
  4162. * @since 0.1.0
  4163. * @category Lang
  4164. * @param {*} value The value to check.
  4165. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  4166. * @example
  4167. *
  4168. * _.isArray([1, 2, 3]);
  4169. * // => true
  4170. *
  4171. * _.isArray(document.body.children);
  4172. * // => false
  4173. *
  4174. * _.isArray('abc');
  4175. * // => false
  4176. *
  4177. * _.isArray(_.noop);
  4178. * // => false
  4179. */
  4180. var isArray = Array.isArray;
  4181. /**
  4182. * Checks if `value` is array-like. A value is considered array-like if it's
  4183. * not a function and has a `value.length` that's an integer greater than or
  4184. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  4185. *
  4186. * @static
  4187. * @memberOf _
  4188. * @since 4.0.0
  4189. * @category Lang
  4190. * @param {*} value The value to check.
  4191. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  4192. * @example
  4193. *
  4194. * _.isArrayLike([1, 2, 3]);
  4195. * // => true
  4196. *
  4197. * _.isArrayLike(document.body.children);
  4198. * // => true
  4199. *
  4200. * _.isArrayLike('abc');
  4201. * // => true
  4202. *
  4203. * _.isArrayLike(_.noop);
  4204. * // => false
  4205. */
  4206. function isArrayLike(value) {
  4207. return value != null && isLength(value.length) && !isFunction(value);
  4208. }
  4209. /**
  4210. * This method is like `_.isArrayLike` except that it also checks if `value`
  4211. * is an object.
  4212. *
  4213. * @static
  4214. * @memberOf _
  4215. * @since 4.0.0
  4216. * @category Lang
  4217. * @param {*} value The value to check.
  4218. * @returns {boolean} Returns `true` if `value` is an array-like object,
  4219. * else `false`.
  4220. * @example
  4221. *
  4222. * _.isArrayLikeObject([1, 2, 3]);
  4223. * // => true
  4224. *
  4225. * _.isArrayLikeObject(document.body.children);
  4226. * // => true
  4227. *
  4228. * _.isArrayLikeObject('abc');
  4229. * // => false
  4230. *
  4231. * _.isArrayLikeObject(_.noop);
  4232. * // => false
  4233. */
  4234. function isArrayLikeObject(value) {
  4235. return isObjectLike(value) && isArrayLike(value);
  4236. }
  4237. /**
  4238. * Checks if `value` is classified as a `Function` object.
  4239. *
  4240. * @static
  4241. * @memberOf _
  4242. * @since 0.1.0
  4243. * @category Lang
  4244. * @param {*} value The value to check.
  4245. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  4246. * @example
  4247. *
  4248. * _.isFunction(_);
  4249. * // => true
  4250. *
  4251. * _.isFunction(/abc/);
  4252. * // => false
  4253. */
  4254. function isFunction(value) {
  4255. // The use of `Object#toString` avoids issues with the `typeof` operator
  4256. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  4257. var tag = isObject(value) ? objectToString.call(value) : '';
  4258. return tag == funcTag || tag == genTag;
  4259. }
  4260. /**
  4261. * Checks if `value` is a valid array-like length.
  4262. *
  4263. * **Note:** This method is loosely based on
  4264. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  4265. *
  4266. * @static
  4267. * @memberOf _
  4268. * @since 4.0.0
  4269. * @category Lang
  4270. * @param {*} value The value to check.
  4271. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  4272. * @example
  4273. *
  4274. * _.isLength(3);
  4275. * // => true
  4276. *
  4277. * _.isLength(Number.MIN_VALUE);
  4278. * // => false
  4279. *
  4280. * _.isLength(Infinity);
  4281. * // => false
  4282. *
  4283. * _.isLength('3');
  4284. * // => false
  4285. */
  4286. function isLength(value) {
  4287. return typeof value == 'number' &&
  4288. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  4289. }
  4290. /**
  4291. * Checks if `value` is the
  4292. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  4293. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4294. *
  4295. * @static
  4296. * @memberOf _
  4297. * @since 0.1.0
  4298. * @category Lang
  4299. * @param {*} value The value to check.
  4300. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4301. * @example
  4302. *
  4303. * _.isObject({});
  4304. * // => true
  4305. *
  4306. * _.isObject([1, 2, 3]);
  4307. * // => true
  4308. *
  4309. * _.isObject(_.noop);
  4310. * // => true
  4311. *
  4312. * _.isObject(null);
  4313. * // => false
  4314. */
  4315. function isObject(value) {
  4316. var type = typeof value;
  4317. return !!value && (type == 'object' || type == 'function');
  4318. }
  4319. /**
  4320. * Checks if `value` is object-like. A value is object-like if it's not `null`
  4321. * and has a `typeof` result of "object".
  4322. *
  4323. * @static
  4324. * @memberOf _
  4325. * @since 4.0.0
  4326. * @category Lang
  4327. * @param {*} value The value to check.
  4328. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  4329. * @example
  4330. *
  4331. * _.isObjectLike({});
  4332. * // => true
  4333. *
  4334. * _.isObjectLike([1, 2, 3]);
  4335. * // => true
  4336. *
  4337. * _.isObjectLike(_.noop);
  4338. * // => false
  4339. *
  4340. * _.isObjectLike(null);
  4341. * // => false
  4342. */
  4343. function isObjectLike(value) {
  4344. return !!value && typeof value == 'object';
  4345. }
  4346. /**
  4347. * Checks if `value` is classified as a `Symbol` primitive or object.
  4348. *
  4349. * @static
  4350. * @memberOf _
  4351. * @since 4.0.0
  4352. * @category Lang
  4353. * @param {*} value The value to check.
  4354. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  4355. * @example
  4356. *
  4357. * _.isSymbol(Symbol.iterator);
  4358. * // => true
  4359. *
  4360. * _.isSymbol('abc');
  4361. * // => false
  4362. */
  4363. function isSymbol(value) {
  4364. return typeof value == 'symbol' ||
  4365. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  4366. }
  4367. /**
  4368. * Checks if `value` is classified as a typed array.
  4369. *
  4370. * @static
  4371. * @memberOf _
  4372. * @since 3.0.0
  4373. * @category Lang
  4374. * @param {*} value The value to check.
  4375. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  4376. * @example
  4377. *
  4378. * _.isTypedArray(new Uint8Array);
  4379. * // => true
  4380. *
  4381. * _.isTypedArray([]);
  4382. * // => false
  4383. */
  4384. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  4385. /**
  4386. * Converts `value` to a string. An empty string is returned for `null`
  4387. * and `undefined` values. The sign of `-0` is preserved.
  4388. *
  4389. * @static
  4390. * @memberOf _
  4391. * @since 4.0.0
  4392. * @category Lang
  4393. * @param {*} value The value to process.
  4394. * @returns {string} Returns the string.
  4395. * @example
  4396. *
  4397. * _.toString(null);
  4398. * // => ''
  4399. *
  4400. * _.toString(-0);
  4401. * // => '-0'
  4402. *
  4403. * _.toString([1, 2, 3]);
  4404. * // => '1,2,3'
  4405. */
  4406. function toString(value) {
  4407. return value == null ? '' : baseToString(value);
  4408. }
  4409. /**
  4410. * Gets the value at `path` of `object`. If the resolved value is
  4411. * `undefined`, the `defaultValue` is returned in its place.
  4412. *
  4413. * @static
  4414. * @memberOf _
  4415. * @since 3.7.0
  4416. * @category Object
  4417. * @param {Object} object The object to query.
  4418. * @param {Array|string} path The path of the property to get.
  4419. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  4420. * @returns {*} Returns the resolved value.
  4421. * @example
  4422. *
  4423. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  4424. *
  4425. * _.get(object, 'a[0].b.c');
  4426. * // => 3
  4427. *
  4428. * _.get(object, ['a', '0', 'b', 'c']);
  4429. * // => 3
  4430. *
  4431. * _.get(object, 'a.b.c', 'default');
  4432. * // => 'default'
  4433. */
  4434. function get(object, path, defaultValue) {
  4435. var result = object == null ? undefined : baseGet(object, path);
  4436. return result === undefined ? defaultValue : result;
  4437. }
  4438. /**
  4439. * Checks if `path` is a direct or inherited property of `object`.
  4440. *
  4441. * @static
  4442. * @memberOf _
  4443. * @since 4.0.0
  4444. * @category Object
  4445. * @param {Object} object The object to query.
  4446. * @param {Array|string} path The path to check.
  4447. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  4448. * @example
  4449. *
  4450. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  4451. *
  4452. * _.hasIn(object, 'a');
  4453. * // => true
  4454. *
  4455. * _.hasIn(object, 'a.b');
  4456. * // => true
  4457. *
  4458. * _.hasIn(object, ['a', 'b']);
  4459. * // => true
  4460. *
  4461. * _.hasIn(object, 'b');
  4462. * // => false
  4463. */
  4464. function hasIn(object, path) {
  4465. return object != null && hasPath(object, path, baseHasIn);
  4466. }
  4467. /**
  4468. * Creates an array of the own enumerable property names of `object`.
  4469. *
  4470. * **Note:** Non-object values are coerced to objects. See the
  4471. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  4472. * for more details.
  4473. *
  4474. * @static
  4475. * @since 0.1.0
  4476. * @memberOf _
  4477. * @category Object
  4478. * @param {Object} object The object to query.
  4479. * @returns {Array} Returns the array of property names.
  4480. * @example
  4481. *
  4482. * function Foo() {
  4483. * this.a = 1;
  4484. * this.b = 2;
  4485. * }
  4486. *
  4487. * Foo.prototype.c = 3;
  4488. *
  4489. * _.keys(new Foo);
  4490. * // => ['a', 'b'] (iteration order is not guaranteed)
  4491. *
  4492. * _.keys('hi');
  4493. * // => ['0', '1']
  4494. */
  4495. function keys(object) {
  4496. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  4497. }
  4498. /**
  4499. * This method returns the first argument it receives.
  4500. *
  4501. * @static
  4502. * @since 0.1.0
  4503. * @memberOf _
  4504. * @category Util
  4505. * @param {*} value Any value.
  4506. * @returns {*} Returns `value`.
  4507. * @example
  4508. *
  4509. * var object = { 'a': 1 };
  4510. *
  4511. * console.log(_.identity(object) === object);
  4512. * // => true
  4513. */
  4514. function identity(value) {
  4515. return value;
  4516. }
  4517. /**
  4518. * Creates a function that returns the value at `path` of a given object.
  4519. *
  4520. * @static
  4521. * @memberOf _
  4522. * @since 2.4.0
  4523. * @category Util
  4524. * @param {Array|string} path The path of the property to get.
  4525. * @returns {Function} Returns the new accessor function.
  4526. * @example
  4527. *
  4528. * var objects = [
  4529. * { 'a': { 'b': 2 } },
  4530. * { 'a': { 'b': 1 } }
  4531. * ];
  4532. *
  4533. * _.map(objects, _.property('a.b'));
  4534. * // => [2, 1]
  4535. *
  4536. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  4537. * // => [1, 2]
  4538. */
  4539. function property(path) {
  4540. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  4541. }
  4542. module.exports = remove;
  4543. /***/ }),
  4544. /***/ "./node_modules/process/browser.js":
  4545. /*!*****************************************!*\
  4546. !*** ./node_modules/process/browser.js ***!
  4547. \*****************************************/
  4548. /***/ ((module) => {
  4549. // shim for using process in browser
  4550. var process = module.exports = {};
  4551. // cached from whatever global is present so that test runners that stub it
  4552. // don't break things. But we need to wrap it in a try catch in case it is
  4553. // wrapped in strict mode code which doesn't define any globals. It's inside a
  4554. // function because try/catches deoptimize in certain engines.
  4555. var cachedSetTimeout;
  4556. var cachedClearTimeout;
  4557. function defaultSetTimout() {
  4558. throw new Error('setTimeout has not been defined');
  4559. }
  4560. function defaultClearTimeout () {
  4561. throw new Error('clearTimeout has not been defined');
  4562. }
  4563. (function () {
  4564. try {
  4565. if (typeof setTimeout === 'function') {
  4566. cachedSetTimeout = setTimeout;
  4567. } else {
  4568. cachedSetTimeout = defaultSetTimout;
  4569. }
  4570. } catch (e) {
  4571. cachedSetTimeout = defaultSetTimout;
  4572. }
  4573. try {
  4574. if (typeof clearTimeout === 'function') {
  4575. cachedClearTimeout = clearTimeout;
  4576. } else {
  4577. cachedClearTimeout = defaultClearTimeout;
  4578. }
  4579. } catch (e) {
  4580. cachedClearTimeout = defaultClearTimeout;
  4581. }
  4582. } ())
  4583. function runTimeout(fun) {
  4584. if (cachedSetTimeout === setTimeout) {
  4585. //normal enviroments in sane situations
  4586. return setTimeout(fun, 0);
  4587. }
  4588. // if setTimeout wasn't available but was latter defined
  4589. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  4590. cachedSetTimeout = setTimeout;
  4591. return setTimeout(fun, 0);
  4592. }
  4593. try {
  4594. // when when somebody has screwed with setTimeout but no I.E. maddness
  4595. return cachedSetTimeout(fun, 0);
  4596. } catch(e){
  4597. try {
  4598. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4599. return cachedSetTimeout.call(null, fun, 0);
  4600. } catch(e){
  4601. // 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
  4602. return cachedSetTimeout.call(this, fun, 0);
  4603. }
  4604. }
  4605. }
  4606. function runClearTimeout(marker) {
  4607. if (cachedClearTimeout === clearTimeout) {
  4608. //normal enviroments in sane situations
  4609. return clearTimeout(marker);
  4610. }
  4611. // if clearTimeout wasn't available but was latter defined
  4612. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  4613. cachedClearTimeout = clearTimeout;
  4614. return clearTimeout(marker);
  4615. }
  4616. try {
  4617. // when when somebody has screwed with setTimeout but no I.E. maddness
  4618. return cachedClearTimeout(marker);
  4619. } catch (e){
  4620. try {
  4621. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4622. return cachedClearTimeout.call(null, marker);
  4623. } catch (e){
  4624. // 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.
  4625. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  4626. return cachedClearTimeout.call(this, marker);
  4627. }
  4628. }
  4629. }
  4630. var queue = [];
  4631. var draining = false;
  4632. var currentQueue;
  4633. var queueIndex = -1;
  4634. function cleanUpNextTick() {
  4635. if (!draining || !currentQueue) {
  4636. return;
  4637. }
  4638. draining = false;
  4639. if (currentQueue.length) {
  4640. queue = currentQueue.concat(queue);
  4641. } else {
  4642. queueIndex = -1;
  4643. }
  4644. if (queue.length) {
  4645. drainQueue();
  4646. }
  4647. }
  4648. function drainQueue() {
  4649. if (draining) {
  4650. return;
  4651. }
  4652. var timeout = runTimeout(cleanUpNextTick);
  4653. draining = true;
  4654. var len = queue.length;
  4655. while(len) {
  4656. currentQueue = queue;
  4657. queue = [];
  4658. while (++queueIndex < len) {
  4659. if (currentQueue) {
  4660. currentQueue[queueIndex].run();
  4661. }
  4662. }
  4663. queueIndex = -1;
  4664. len = queue.length;
  4665. }
  4666. currentQueue = null;
  4667. draining = false;
  4668. runClearTimeout(timeout);
  4669. }
  4670. process.nextTick = function (fun) {
  4671. var args = new Array(arguments.length - 1);
  4672. if (arguments.length > 1) {
  4673. for (var i = 1; i < arguments.length; i++) {
  4674. args[i - 1] = arguments[i];
  4675. }
  4676. }
  4677. queue.push(new Item(fun, args));
  4678. if (queue.length === 1 && !draining) {
  4679. runTimeout(drainQueue);
  4680. }
  4681. };
  4682. // v8 likes predictible objects
  4683. function Item(fun, array) {
  4684. this.fun = fun;
  4685. this.array = array;
  4686. }
  4687. Item.prototype.run = function () {
  4688. this.fun.apply(null, this.array);
  4689. };
  4690. process.title = 'browser';
  4691. process.browser = true;
  4692. process.env = {};
  4693. process.argv = [];
  4694. process.version = ''; // empty string to avoid regexp issues
  4695. process.versions = {};
  4696. function noop() {}
  4697. process.on = noop;
  4698. process.addListener = noop;
  4699. process.once = noop;
  4700. process.off = noop;
  4701. process.removeListener = noop;
  4702. process.removeAllListeners = noop;
  4703. process.emit = noop;
  4704. process.prependListener = noop;
  4705. process.prependOnceListener = noop;
  4706. process.listeners = function (name) { return [] }
  4707. process.binding = function (name) {
  4708. throw new Error('process.binding is not supported');
  4709. };
  4710. process.cwd = function () { return '/' };
  4711. process.chdir = function (dir) {
  4712. throw new Error('process.chdir is not supported');
  4713. };
  4714. process.umask = function() { return 0; };
  4715. /***/ }),
  4716. /***/ "./node_modules/riot/riot.esm.js":
  4717. /*!***************************************!*\
  4718. !*** ./node_modules/riot/riot.esm.js ***!
  4719. \***************************************/
  4720. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4721. "use strict";
  4722. __webpack_require__.r(__webpack_exports__);
  4723. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4724. /* harmony export */ "__": () => (/* binding */ __),
  4725. /* harmony export */ "component": () => (/* binding */ component),
  4726. /* harmony export */ "install": () => (/* binding */ install),
  4727. /* harmony export */ "mount": () => (/* binding */ mount),
  4728. /* harmony export */ "pure": () => (/* binding */ pure),
  4729. /* harmony export */ "register": () => (/* binding */ register),
  4730. /* harmony export */ "uninstall": () => (/* binding */ uninstall),
  4731. /* harmony export */ "unmount": () => (/* binding */ unmount),
  4732. /* harmony export */ "unregister": () => (/* binding */ unregister),
  4733. /* harmony export */ "version": () => (/* binding */ version),
  4734. /* harmony export */ "withTypes": () => (/* binding */ withTypes)
  4735. /* harmony export */ });
  4736. /* Riot v6.0.1, @license MIT */
  4737. /**
  4738. * Convert a string from camel case to dash-case
  4739. * @param {string} string - probably a component tag name
  4740. * @returns {string} component name normalized
  4741. */
  4742. function camelToDashCase(string) {
  4743. return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
  4744. }
  4745. /**
  4746. * Convert a string containing dashes to camel case
  4747. * @param {string} string - input string
  4748. * @returns {string} my-string -> myString
  4749. */
  4750. function dashToCamelCase(string) {
  4751. return string.replace(/-(\w)/g, (_, c) => c.toUpperCase());
  4752. }
  4753. /**
  4754. * Get all the element attributes as object
  4755. * @param {HTMLElement} element - DOM node we want to parse
  4756. * @returns {Object} all the attributes found as a key value pairs
  4757. */
  4758. function DOMattributesToObject(element) {
  4759. return Array.from(element.attributes).reduce((acc, attribute) => {
  4760. acc[dashToCamelCase(attribute.name)] = attribute.value;
  4761. return acc;
  4762. }, {});
  4763. }
  4764. /**
  4765. * Move all the child nodes from a source tag to another
  4766. * @param {HTMLElement} source - source node
  4767. * @param {HTMLElement} target - target node
  4768. * @returns {undefined} it's a void method ¯\_()_/¯
  4769. */
  4770. // Ignore this helper because it's needed only for svg tags
  4771. function moveChildren(source, target) {
  4772. if (source.firstChild) {
  4773. target.appendChild(source.firstChild);
  4774. moveChildren(source, target);
  4775. }
  4776. }
  4777. /**
  4778. * Remove the child nodes from any DOM node
  4779. * @param {HTMLElement} node - target node
  4780. * @returns {undefined}
  4781. */
  4782. function cleanNode(node) {
  4783. clearChildren(node.childNodes);
  4784. }
  4785. /**
  4786. * Clear multiple children in a node
  4787. * @param {HTMLElement[]} children - direct children nodes
  4788. * @returns {undefined}
  4789. */
  4790. function clearChildren(children) {
  4791. Array.from(children).forEach(removeChild);
  4792. }
  4793. /**
  4794. * Remove a node
  4795. * @param {HTMLElement}node - node to remove
  4796. * @returns {undefined}
  4797. */
  4798. const removeChild = node => node && node.parentNode && node.parentNode.removeChild(node);
  4799. /**
  4800. * Insert before a node
  4801. * @param {HTMLElement} newNode - node to insert
  4802. * @param {HTMLElement} refNode - ref child
  4803. * @returns {undefined}
  4804. */
  4805. const insertBefore = (newNode, refNode) => refNode && refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode);
  4806. /**
  4807. * Replace a node
  4808. * @param {HTMLElement} newNode - new node to add to the DOM
  4809. * @param {HTMLElement} replaced - node to replace
  4810. * @returns {undefined}
  4811. */
  4812. const replaceChild = (newNode, replaced) => replaced && replaced.parentNode && replaced.parentNode.replaceChild(newNode, replaced);
  4813. // Riot.js constants that can be used accross more modules
  4814. const COMPONENTS_IMPLEMENTATION_MAP$1 = new Map(),
  4815. DOM_COMPONENT_INSTANCE_PROPERTY$1 = Symbol('riot-component'),
  4816. PLUGINS_SET$1 = new Set(),
  4817. IS_DIRECTIVE = 'is',
  4818. VALUE_ATTRIBUTE = 'value',
  4819. MOUNT_METHOD_KEY = 'mount',
  4820. UPDATE_METHOD_KEY = 'update',
  4821. UNMOUNT_METHOD_KEY = 'unmount',
  4822. SHOULD_UPDATE_KEY = 'shouldUpdate',
  4823. ON_BEFORE_MOUNT_KEY = 'onBeforeMount',
  4824. ON_MOUNTED_KEY = 'onMounted',
  4825. ON_BEFORE_UPDATE_KEY = 'onBeforeUpdate',
  4826. ON_UPDATED_KEY = 'onUpdated',
  4827. ON_BEFORE_UNMOUNT_KEY = 'onBeforeUnmount',
  4828. ON_UNMOUNTED_KEY = 'onUnmounted',
  4829. PROPS_KEY = 'props',
  4830. STATE_KEY = 'state',
  4831. SLOTS_KEY = 'slots',
  4832. ROOT_KEY = 'root',
  4833. IS_PURE_SYMBOL = Symbol('pure'),
  4834. IS_COMPONENT_UPDATING = Symbol('is_updating'),
  4835. PARENT_KEY_SYMBOL = Symbol('parent'),
  4836. ATTRIBUTES_KEY_SYMBOL = Symbol('attributes'),
  4837. TEMPLATE_KEY_SYMBOL = Symbol('template');
  4838. var globals = /*#__PURE__*/Object.freeze({
  4839. __proto__: null,
  4840. COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP$1,
  4841. DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY$1,
  4842. PLUGINS_SET: PLUGINS_SET$1,
  4843. IS_DIRECTIVE: IS_DIRECTIVE,
  4844. VALUE_ATTRIBUTE: VALUE_ATTRIBUTE,
  4845. MOUNT_METHOD_KEY: MOUNT_METHOD_KEY,
  4846. UPDATE_METHOD_KEY: UPDATE_METHOD_KEY,
  4847. UNMOUNT_METHOD_KEY: UNMOUNT_METHOD_KEY,
  4848. SHOULD_UPDATE_KEY: SHOULD_UPDATE_KEY,
  4849. ON_BEFORE_MOUNT_KEY: ON_BEFORE_MOUNT_KEY,
  4850. ON_MOUNTED_KEY: ON_MOUNTED_KEY,
  4851. ON_BEFORE_UPDATE_KEY: ON_BEFORE_UPDATE_KEY,
  4852. ON_UPDATED_KEY: ON_UPDATED_KEY,
  4853. ON_BEFORE_UNMOUNT_KEY: ON_BEFORE_UNMOUNT_KEY,
  4854. ON_UNMOUNTED_KEY: ON_UNMOUNTED_KEY,
  4855. PROPS_KEY: PROPS_KEY,
  4856. STATE_KEY: STATE_KEY,
  4857. SLOTS_KEY: SLOTS_KEY,
  4858. ROOT_KEY: ROOT_KEY,
  4859. IS_PURE_SYMBOL: IS_PURE_SYMBOL,
  4860. IS_COMPONENT_UPDATING: IS_COMPONENT_UPDATING,
  4861. PARENT_KEY_SYMBOL: PARENT_KEY_SYMBOL,
  4862. ATTRIBUTES_KEY_SYMBOL: ATTRIBUTES_KEY_SYMBOL,
  4863. TEMPLATE_KEY_SYMBOL: TEMPLATE_KEY_SYMBOL
  4864. });
  4865. const EACH = 0;
  4866. const IF = 1;
  4867. const SIMPLE = 2;
  4868. const TAG = 3;
  4869. const SLOT = 4;
  4870. var bindingTypes = {
  4871. EACH,
  4872. IF,
  4873. SIMPLE,
  4874. TAG,
  4875. SLOT
  4876. };
  4877. const ATTRIBUTE = 0;
  4878. const EVENT = 1;
  4879. const TEXT = 2;
  4880. const VALUE = 3;
  4881. var expressionTypes = {
  4882. ATTRIBUTE,
  4883. EVENT,
  4884. TEXT,
  4885. VALUE
  4886. };
  4887. const HEAD_SYMBOL = Symbol('head');
  4888. const TAIL_SYMBOL = Symbol('tail');
  4889. /**
  4890. * Create the <template> fragments text nodes
  4891. * @return {Object} {{head: Text, tail: Text}}
  4892. */
  4893. function createHeadTailPlaceholders() {
  4894. const head = document.createTextNode('');
  4895. const tail = document.createTextNode('');
  4896. head[HEAD_SYMBOL] = true;
  4897. tail[TAIL_SYMBOL] = true;
  4898. return {
  4899. head,
  4900. tail
  4901. };
  4902. }
  4903. /**
  4904. * Create the template meta object in case of <template> fragments
  4905. * @param {TemplateChunk} componentTemplate - template chunk object
  4906. * @returns {Object} the meta property that will be passed to the mount function of the TemplateChunk
  4907. */
  4908. function createTemplateMeta(componentTemplate) {
  4909. const fragment = componentTemplate.dom.cloneNode(true);
  4910. const {
  4911. head,
  4912. tail
  4913. } = createHeadTailPlaceholders();
  4914. return {
  4915. avoidDOMInjection: true,
  4916. fragment,
  4917. head,
  4918. tail,
  4919. children: [head, ...Array.from(fragment.childNodes), tail]
  4920. };
  4921. }
  4922. /**
  4923. * Helper function to set an immutable property
  4924. * @param {Object} source - object where the new property will be set
  4925. * @param {string} key - object key where the new property will be stored
  4926. * @param {*} value - value of the new property
  4927. * @param {Object} options - set the propery overriding the default options
  4928. * @returns {Object} - the original object modified
  4929. */
  4930. function defineProperty(source, key, value, options) {
  4931. if (options === void 0) {
  4932. options = {};
  4933. }
  4934. /* eslint-disable fp/no-mutating-methods */
  4935. Object.defineProperty(source, key, Object.assign({
  4936. value,
  4937. enumerable: false,
  4938. writable: false,
  4939. configurable: true
  4940. }, options));
  4941. /* eslint-enable fp/no-mutating-methods */
  4942. return source;
  4943. }
  4944. /**
  4945. * Define multiple properties on a target object
  4946. * @param {Object} source - object where the new properties will be set
  4947. * @param {Object} properties - object containing as key pair the key + value properties
  4948. * @param {Object} options - set the propery overriding the default options
  4949. * @returns {Object} the original object modified
  4950. */
  4951. function defineProperties(source, properties, options) {
  4952. Object.entries(properties).forEach(_ref => {
  4953. let [key, value] = _ref;
  4954. defineProperty(source, key, value, options);
  4955. });
  4956. return source;
  4957. }
  4958. /**
  4959. * Define default properties if they don't exist on the source object
  4960. * @param {Object} source - object that will receive the default properties
  4961. * @param {Object} defaults - object containing additional optional keys
  4962. * @returns {Object} the original object received enhanced
  4963. */
  4964. function defineDefaults(source, defaults) {
  4965. Object.entries(defaults).forEach(_ref2 => {
  4966. let [key, value] = _ref2;
  4967. if (!source[key]) source[key] = value;
  4968. });
  4969. return source;
  4970. }
  4971. /**
  4972. * Get the current <template> fragment children located in between the head and tail comments
  4973. * @param {Comment} head - head comment node
  4974. * @param {Comment} tail - tail comment node
  4975. * @return {Array[]} children list of the nodes found in this template fragment
  4976. */
  4977. function getFragmentChildren(_ref) {
  4978. let {
  4979. head,
  4980. tail
  4981. } = _ref;
  4982. const nodes = walkNodes([head], head.nextSibling, n => n === tail, false);
  4983. nodes.push(tail);
  4984. return nodes;
  4985. }
  4986. /**
  4987. * Recursive function to walk all the <template> children nodes
  4988. * @param {Array[]} children - children nodes collection
  4989. * @param {ChildNode} node - current node
  4990. * @param {Function} check - exit function check
  4991. * @param {boolean} isFilterActive - filter flag to skip nodes managed by other bindings
  4992. * @returns {Array[]} children list of the nodes found in this template fragment
  4993. */
  4994. function walkNodes(children, node, check, isFilterActive) {
  4995. const {
  4996. nextSibling
  4997. } = node; // filter tail and head nodes together with all the nodes in between
  4998. // this is needed only to fix a really ugly edge case https://github.com/riot/riot/issues/2892
  4999. if (!isFilterActive && !node[HEAD_SYMBOL] && !node[TAIL_SYMBOL]) {
  5000. children.push(node);
  5001. }
  5002. if (!nextSibling || check(node)) return children;
  5003. return walkNodes(children, nextSibling, check, // activate the filters to skip nodes between <template> fragments that will be managed by other bindings
  5004. isFilterActive && !node[TAIL_SYMBOL] || nextSibling[HEAD_SYMBOL]);
  5005. }
  5006. /**
  5007. * Quick type checking
  5008. * @param {*} element - anything
  5009. * @param {string} type - type definition
  5010. * @returns {boolean} true if the type corresponds
  5011. */
  5012. function checkType(element, type) {
  5013. return typeof element === type;
  5014. }
  5015. /**
  5016. * Check if an element is part of an svg
  5017. * @param {HTMLElement} el - element to check
  5018. * @returns {boolean} true if we are in an svg context
  5019. */
  5020. function isSvg(el) {
  5021. const owner = el.ownerSVGElement;
  5022. return !!owner || owner === null;
  5023. }
  5024. /**
  5025. * Check if an element is a template tag
  5026. * @param {HTMLElement} el - element to check
  5027. * @returns {boolean} true if it's a <template>
  5028. */
  5029. function isTemplate(el) {
  5030. return el.tagName.toLowerCase() === 'template';
  5031. }
  5032. /**
  5033. * Check that will be passed if its argument is a function
  5034. * @param {*} value - value to check
  5035. * @returns {boolean} - true if the value is a function
  5036. */
  5037. function isFunction(value) {
  5038. return checkType(value, 'function');
  5039. }
  5040. /**
  5041. * Check if a value is a Boolean
  5042. * @param {*} value - anything
  5043. * @returns {boolean} true only for the value is a boolean
  5044. */
  5045. function isBoolean(value) {
  5046. return checkType(value, 'boolean');
  5047. }
  5048. /**
  5049. * Check if a value is an Object
  5050. * @param {*} value - anything
  5051. * @returns {boolean} true only for the value is an object
  5052. */
  5053. function isObject(value) {
  5054. return !isNil(value) && value.constructor === Object;
  5055. }
  5056. /**
  5057. * Check if a value is null or undefined
  5058. * @param {*} value - anything
  5059. * @returns {boolean} true only for the 'undefined' and 'null' types
  5060. */
  5061. function isNil(value) {
  5062. return value === null || value === undefined;
  5063. }
  5064. /**
  5065. * ISC License
  5066. *
  5067. * Copyright (c) 2020, Andrea Giammarchi, @WebReflection
  5068. *
  5069. * Permission to use, copy, modify, and/or distribute this software for any
  5070. * purpose with or without fee is hereby granted, provided that the above
  5071. * copyright notice and this permission notice appear in all copies.
  5072. *
  5073. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  5074. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  5075. * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  5076. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  5077. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  5078. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  5079. * PERFORMANCE OF THIS SOFTWARE.
  5080. */
  5081. // fork of https://github.com/WebReflection/udomdiff version 1.1.0
  5082. // due to https://github.com/WebReflection/udomdiff/pull/2
  5083. /* eslint-disable */
  5084. /**
  5085. * @param {Node[]} a The list of current/live children
  5086. * @param {Node[]} b The list of future children
  5087. * @param {(entry: Node, action: number) => Node} get
  5088. * The callback invoked per each entry related DOM operation.
  5089. * @param {Node} [before] The optional node used as anchor to insert before.
  5090. * @returns {Node[]} The same list of future children.
  5091. */
  5092. var udomdiff = ((a, b, get, before) => {
  5093. const bLength = b.length;
  5094. let aEnd = a.length;
  5095. let bEnd = bLength;
  5096. let aStart = 0;
  5097. let bStart = 0;
  5098. let map = null;
  5099. while (aStart < aEnd || bStart < bEnd) {
  5100. // append head, tail, or nodes in between: fast path
  5101. if (aEnd === aStart) {
  5102. // we could be in a situation where the rest of nodes that
  5103. // need to be added are not at the end, and in such case
  5104. // the node to `insertBefore`, if the index is more than 0
  5105. // must be retrieved, otherwise it's gonna be the first item.
  5106. const node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd - bStart], 0) : before;
  5107. while (bStart < bEnd) insertBefore(get(b[bStart++], 1), node);
  5108. } // remove head or tail: fast path
  5109. else if (bEnd === bStart) {
  5110. while (aStart < aEnd) {
  5111. // remove the node only if it's unknown or not live
  5112. if (!map || !map.has(a[aStart])) removeChild(get(a[aStart], -1));
  5113. aStart++;
  5114. }
  5115. } // same node: fast path
  5116. else if (a[aStart] === b[bStart]) {
  5117. aStart++;
  5118. bStart++;
  5119. } // same tail: fast path
  5120. else if (a[aEnd - 1] === b[bEnd - 1]) {
  5121. aEnd--;
  5122. bEnd--;
  5123. } // The once here single last swap "fast path" has been removed in v1.1.0
  5124. // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85
  5125. // reverse swap: also fast path
  5126. else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
  5127. // this is a "shrink" operation that could happen in these cases:
  5128. // [1, 2, 3, 4, 5]
  5129. // [1, 4, 3, 2, 5]
  5130. // or asymmetric too
  5131. // [1, 2, 3, 4, 5]
  5132. // [1, 2, 3, 5, 6, 4]
  5133. const node = get(a[--aEnd], -1).nextSibling;
  5134. insertBefore(get(b[bStart++], 1), get(a[aStart++], -1).nextSibling);
  5135. insertBefore(get(b[--bEnd], 1), node); // mark the future index as identical (yeah, it's dirty, but cheap 👍)
  5136. // The main reason to do this, is that when a[aEnd] will be reached,
  5137. // the loop will likely be on the fast path, as identical to b[bEnd].
  5138. // In the best case scenario, the next loop will skip the tail,
  5139. // but in the worst one, this node will be considered as already
  5140. // processed, bailing out pretty quickly from the map index check
  5141. a[aEnd] = b[bEnd];
  5142. } // map based fallback, "slow" path
  5143. else {
  5144. // the map requires an O(bEnd - bStart) operation once
  5145. // to store all future nodes indexes for later purposes.
  5146. // In the worst case scenario, this is a full O(N) cost,
  5147. // and such scenario happens at least when all nodes are different,
  5148. // but also if both first and last items of the lists are different
  5149. if (!map) {
  5150. map = new Map();
  5151. let i = bStart;
  5152. while (i < bEnd) map.set(b[i], i++);
  5153. } // if it's a future node, hence it needs some handling
  5154. if (map.has(a[aStart])) {
  5155. // grab the index of such node, 'cause it might have been processed
  5156. const index = map.get(a[aStart]); // if it's not already processed, look on demand for the next LCS
  5157. if (bStart < index && index < bEnd) {
  5158. let i = aStart; // counts the amount of nodes that are the same in the future
  5159. let sequence = 1;
  5160. while (++i < aEnd && i < bEnd && map.get(a[i]) === index + sequence) sequence++; // effort decision here: if the sequence is longer than replaces
  5161. // needed to reach such sequence, which would brings again this loop
  5162. // to the fast path, prepend the difference before a sequence,
  5163. // and move only the future list index forward, so that aStart
  5164. // and bStart will be aligned again, hence on the fast path.
  5165. // An example considering aStart and bStart are both 0:
  5166. // a: [1, 2, 3, 4]
  5167. // b: [7, 1, 2, 3, 6]
  5168. // this would place 7 before 1 and, from that time on, 1, 2, and 3
  5169. // will be processed at zero cost
  5170. if (sequence > index - bStart) {
  5171. const node = get(a[aStart], 0);
  5172. while (bStart < index) insertBefore(get(b[bStart++], 1), node);
  5173. } // if the effort wasn't good enough, fallback to a replace,
  5174. // moving both source and target indexes forward, hoping that some
  5175. // similar node will be found later on, to go back to the fast path
  5176. else {
  5177. replaceChild(get(b[bStart++], 1), get(a[aStart++], -1));
  5178. }
  5179. } // otherwise move the source forward, 'cause there's nothing to do
  5180. else aStart++;
  5181. } // this node has no meaning in the future list, so it's more than safe
  5182. // to remove it, and check the next live node out instead, meaning
  5183. // that only the live list index should be forwarded
  5184. else removeChild(get(a[aStart++], -1));
  5185. }
  5186. }
  5187. return b;
  5188. });
  5189. const UNMOUNT_SCOPE = Symbol('unmount');
  5190. const EachBinding = {
  5191. // dynamic binding properties
  5192. // childrenMap: null,
  5193. // node: null,
  5194. // root: null,
  5195. // condition: null,
  5196. // evaluate: null,
  5197. // template: null,
  5198. // isTemplateTag: false,
  5199. nodes: [],
  5200. // getKey: null,
  5201. // indexName: null,
  5202. // itemName: null,
  5203. // afterPlaceholder: null,
  5204. // placeholder: null,
  5205. // API methods
  5206. mount(scope, parentScope) {
  5207. return this.update(scope, parentScope);
  5208. },
  5209. update(scope, parentScope) {
  5210. const {
  5211. placeholder,
  5212. nodes,
  5213. childrenMap
  5214. } = this;
  5215. const collection = scope === UNMOUNT_SCOPE ? null : this.evaluate(scope);
  5216. const items = collection ? Array.from(collection) : []; // prepare the diffing
  5217. const {
  5218. newChildrenMap,
  5219. batches,
  5220. futureNodes
  5221. } = createPatch(items, scope, parentScope, this); // patch the DOM only if there are new nodes
  5222. udomdiff(nodes, futureNodes, patch(Array.from(childrenMap.values()), parentScope), placeholder); // trigger the mounts and the updates
  5223. batches.forEach(fn => fn()); // update the children map
  5224. this.childrenMap = newChildrenMap;
  5225. this.nodes = futureNodes; // make sure that the loop edge nodes are marked
  5226. markEdgeNodes(this.nodes);
  5227. return this;
  5228. },
  5229. unmount(scope, parentScope) {
  5230. this.update(UNMOUNT_SCOPE, parentScope);
  5231. return this;
  5232. }
  5233. };
  5234. /**
  5235. * Patch the DOM while diffing
  5236. * @param {any[]} redundant - list of all the children (template, nodes, context) added via each
  5237. * @param {*} parentScope - scope of the parent template
  5238. * @returns {Function} patch function used by domdiff
  5239. */
  5240. function patch(redundant, parentScope) {
  5241. return (item, info) => {
  5242. if (info < 0) {
  5243. // get the last element added to the childrenMap saved previously
  5244. const element = redundant[redundant.length - 1];
  5245. if (element) {
  5246. // get the nodes and the template in stored in the last child of the childrenMap
  5247. const {
  5248. template,
  5249. nodes,
  5250. context
  5251. } = element; // remove the last node (notice <template> tags might have more children nodes)
  5252. nodes.pop(); // notice that we pass null as last argument because
  5253. // the root node and its children will be removed by domdiff
  5254. if (!nodes.length) {
  5255. // we have cleared all the children nodes and we can unmount this template
  5256. redundant.pop();
  5257. template.unmount(context, parentScope, null);
  5258. }
  5259. }
  5260. }
  5261. return item;
  5262. };
  5263. }
  5264. /**
  5265. * Check whether a template must be filtered from a loop
  5266. * @param {Function} condition - filter function
  5267. * @param {Object} context - argument passed to the filter function
  5268. * @returns {boolean} true if this item should be skipped
  5269. */
  5270. function mustFilterItem(condition, context) {
  5271. return condition ? !condition(context) : false;
  5272. }
  5273. /**
  5274. * Extend the scope of the looped template
  5275. * @param {Object} scope - current template scope
  5276. * @param {Object} options - options
  5277. * @param {string} options.itemName - key to identify the looped item in the new context
  5278. * @param {string} options.indexName - key to identify the index of the looped item
  5279. * @param {number} options.index - current index
  5280. * @param {*} options.item - collection item looped
  5281. * @returns {Object} enhanced scope object
  5282. */
  5283. function extendScope(scope, _ref) {
  5284. let {
  5285. itemName,
  5286. indexName,
  5287. index,
  5288. item
  5289. } = _ref;
  5290. defineProperty(scope, itemName, item);
  5291. if (indexName) defineProperty(scope, indexName, index);
  5292. return scope;
  5293. }
  5294. /**
  5295. * Mark the first and last nodes in order to ignore them in case we need to retrieve the <template> fragment nodes
  5296. * @param {Array[]} nodes - each binding nodes list
  5297. * @returns {undefined} void function
  5298. */
  5299. function markEdgeNodes(nodes) {
  5300. const first = nodes[0];
  5301. const last = nodes[nodes.length - 1];
  5302. if (first) first[HEAD_SYMBOL] = true;
  5303. if (last) last[TAIL_SYMBOL] = true;
  5304. }
  5305. /**
  5306. * Loop the current template items
  5307. * @param {Array} items - expression collection value
  5308. * @param {*} scope - template scope
  5309. * @param {*} parentScope - scope of the parent template
  5310. * @param {EachBinding} binding - each binding object instance
  5311. * @returns {Object} data
  5312. * @returns {Map} data.newChildrenMap - a Map containing the new children template structure
  5313. * @returns {Array} data.batches - array containing the template lifecycle functions to trigger
  5314. * @returns {Array} data.futureNodes - array containing the nodes we need to diff
  5315. */
  5316. function createPatch(items, scope, parentScope, binding) {
  5317. const {
  5318. condition,
  5319. template,
  5320. childrenMap,
  5321. itemName,
  5322. getKey,
  5323. indexName,
  5324. root,
  5325. isTemplateTag
  5326. } = binding;
  5327. const newChildrenMap = new Map();
  5328. const batches = [];
  5329. const futureNodes = [];
  5330. items.forEach((item, index) => {
  5331. const context = extendScope(Object.create(scope), {
  5332. itemName,
  5333. indexName,
  5334. index,
  5335. item
  5336. });
  5337. const key = getKey ? getKey(context) : index;
  5338. const oldItem = childrenMap.get(key);
  5339. const nodes = [];
  5340. if (mustFilterItem(condition, context)) {
  5341. return;
  5342. }
  5343. const mustMount = !oldItem;
  5344. const componentTemplate = oldItem ? oldItem.template : template.clone();
  5345. const el = componentTemplate.el || root.cloneNode();
  5346. const meta = isTemplateTag && mustMount ? createTemplateMeta(componentTemplate) : componentTemplate.meta;
  5347. if (mustMount) {
  5348. batches.push(() => componentTemplate.mount(el, context, parentScope, meta));
  5349. } else {
  5350. batches.push(() => componentTemplate.update(context, parentScope));
  5351. } // create the collection of nodes to update or to add
  5352. // in case of template tags we need to add all its children nodes
  5353. if (isTemplateTag) {
  5354. nodes.push(...(mustMount ? meta.children : getFragmentChildren(meta)));
  5355. } else {
  5356. nodes.push(el);
  5357. } // delete the old item from the children map
  5358. childrenMap.delete(key);
  5359. futureNodes.push(...nodes); // update the children map
  5360. newChildrenMap.set(key, {
  5361. nodes,
  5362. template: componentTemplate,
  5363. context,
  5364. index
  5365. });
  5366. });
  5367. return {
  5368. newChildrenMap,
  5369. batches,
  5370. futureNodes
  5371. };
  5372. }
  5373. function create$6(node, _ref2) {
  5374. let {
  5375. evaluate,
  5376. condition,
  5377. itemName,
  5378. indexName,
  5379. getKey,
  5380. template
  5381. } = _ref2;
  5382. const placeholder = document.createTextNode('');
  5383. const root = node.cloneNode();
  5384. insertBefore(placeholder, node);
  5385. removeChild(node);
  5386. return Object.assign({}, EachBinding, {
  5387. childrenMap: new Map(),
  5388. node,
  5389. root,
  5390. condition,
  5391. evaluate,
  5392. isTemplateTag: isTemplate(root),
  5393. template: template.createDOM(node),
  5394. getKey,
  5395. indexName,
  5396. itemName,
  5397. placeholder
  5398. });
  5399. }
  5400. /**
  5401. * Binding responsible for the `if` directive
  5402. */
  5403. const IfBinding = {
  5404. // dynamic binding properties
  5405. // node: null,
  5406. // evaluate: null,
  5407. // isTemplateTag: false,
  5408. // placeholder: null,
  5409. // template: null,
  5410. // API methods
  5411. mount(scope, parentScope) {
  5412. return this.update(scope, parentScope);
  5413. },
  5414. update(scope, parentScope) {
  5415. const value = !!this.evaluate(scope);
  5416. const mustMount = !this.value && value;
  5417. const mustUnmount = this.value && !value;
  5418. const mount = () => {
  5419. const pristine = this.node.cloneNode();
  5420. insertBefore(pristine, this.placeholder);
  5421. this.template = this.template.clone();
  5422. this.template.mount(pristine, scope, parentScope);
  5423. };
  5424. switch (true) {
  5425. case mustMount:
  5426. mount();
  5427. break;
  5428. case mustUnmount:
  5429. this.unmount(scope);
  5430. break;
  5431. default:
  5432. if (value) this.template.update(scope, parentScope);
  5433. }
  5434. this.value = value;
  5435. return this;
  5436. },
  5437. unmount(scope, parentScope) {
  5438. this.template.unmount(scope, parentScope, true);
  5439. return this;
  5440. }
  5441. };
  5442. function create$5(node, _ref) {
  5443. let {
  5444. evaluate,
  5445. template
  5446. } = _ref;
  5447. const placeholder = document.createTextNode('');
  5448. insertBefore(placeholder, node);
  5449. removeChild(node);
  5450. return Object.assign({}, IfBinding, {
  5451. node,
  5452. evaluate,
  5453. placeholder,
  5454. template: template.createDOM(node)
  5455. });
  5456. }
  5457. /**
  5458. * Throw an error with a descriptive message
  5459. * @param { string } message - error message
  5460. * @returns { undefined } hoppla.. at this point the program should stop working
  5461. */
  5462. function panic(message) {
  5463. throw new Error(message);
  5464. }
  5465. /**
  5466. * Returns the memoized (cached) function.
  5467. * // borrowed from https://www.30secondsofcode.org/js/s/memoize
  5468. * @param {Function} fn - function to memoize
  5469. * @returns {Function} memoize function
  5470. */
  5471. function memoize(fn) {
  5472. const cache = new Map();
  5473. const cached = val => {
  5474. return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
  5475. };
  5476. cached.cache = cache;
  5477. return cached;
  5478. }
  5479. /**
  5480. * Evaluate a list of attribute expressions
  5481. * @param {Array} attributes - attribute expressions generated by the riot compiler
  5482. * @returns {Object} key value pairs with the result of the computation
  5483. */
  5484. function evaluateAttributeExpressions(attributes) {
  5485. return attributes.reduce((acc, attribute) => {
  5486. const {
  5487. value,
  5488. type
  5489. } = attribute;
  5490. switch (true) {
  5491. // spread attribute
  5492. case !attribute.name && type === ATTRIBUTE:
  5493. return Object.assign({}, acc, value);
  5494. // value attribute
  5495. case type === VALUE:
  5496. acc.value = attribute.value;
  5497. break;
  5498. // normal attributes
  5499. default:
  5500. acc[dashToCamelCase(attribute.name)] = attribute.value;
  5501. }
  5502. return acc;
  5503. }, {});
  5504. }
  5505. const ElementProto = typeof Element === 'undefined' ? {} : Element.prototype;
  5506. const isNativeHtmlProperty = memoize(name => ElementProto.hasOwnProperty(name)); // eslint-disable-line
  5507. /**
  5508. * Add all the attributes provided
  5509. * @param {HTMLElement} node - target node
  5510. * @param {Object} attributes - object containing the attributes names and values
  5511. * @returns {undefined} sorry it's a void function :(
  5512. */
  5513. function setAllAttributes(node, attributes) {
  5514. Object.entries(attributes).forEach(_ref => {
  5515. let [name, value] = _ref;
  5516. return attributeExpression(node, {
  5517. name
  5518. }, value);
  5519. });
  5520. }
  5521. /**
  5522. * Remove all the attributes provided
  5523. * @param {HTMLElement} node - target node
  5524. * @param {Object} newAttributes - object containing all the new attribute names
  5525. * @param {Object} oldAttributes - object containing all the old attribute names
  5526. * @returns {undefined} sorry it's a void function :(
  5527. */
  5528. function removeAllAttributes(node, newAttributes, oldAttributes) {
  5529. const newKeys = newAttributes ? Object.keys(newAttributes) : [];
  5530. Object.keys(oldAttributes).filter(name => !newKeys.includes(name)).forEach(attribute => node.removeAttribute(attribute));
  5531. }
  5532. /**
  5533. * Check whether the attribute value can be rendered
  5534. * @param {*} value - expression value
  5535. * @returns {boolean} true if we can render this attribute value
  5536. */
  5537. function canRenderAttribute(value) {
  5538. return value === true || ['string', 'number'].includes(typeof value);
  5539. }
  5540. /**
  5541. * Check whether the attribute should be removed
  5542. * @param {*} value - expression value
  5543. * @returns {boolean} boolean - true if the attribute can be removed}
  5544. */
  5545. function shouldRemoveAttribute(value) {
  5546. return !value && value !== 0;
  5547. }
  5548. /**
  5549. * This methods handles the DOM attributes updates
  5550. * @param {HTMLElement} node - target node
  5551. * @param {Object} expression - expression object
  5552. * @param {string} expression.name - attribute name
  5553. * @param {*} value - new expression value
  5554. * @param {*} oldValue - the old expression cached value
  5555. * @returns {undefined}
  5556. */
  5557. function attributeExpression(node, _ref2, value, oldValue) {
  5558. let {
  5559. name
  5560. } = _ref2;
  5561. // is it a spread operator? {...attributes}
  5562. if (!name) {
  5563. if (oldValue) {
  5564. // remove all the old attributes
  5565. removeAllAttributes(node, value, oldValue);
  5566. } // is the value still truthy?
  5567. if (value) {
  5568. setAllAttributes(node, value);
  5569. }
  5570. return;
  5571. } // handle boolean attributes
  5572. if (!isNativeHtmlProperty(name) && (isBoolean(value) || isObject(value) || isFunction(value))) {
  5573. node[name] = value;
  5574. }
  5575. if (shouldRemoveAttribute(value)) {
  5576. node.removeAttribute(name);
  5577. } else if (canRenderAttribute(value)) {
  5578. node.setAttribute(name, normalizeValue(name, value));
  5579. }
  5580. }
  5581. /**
  5582. * Get the value as string
  5583. * @param {string} name - attribute name
  5584. * @param {*} value - user input value
  5585. * @returns {string} input value as string
  5586. */
  5587. function normalizeValue(name, value) {
  5588. // be sure that expressions like selected={ true } will be always rendered as selected='selected'
  5589. return value === true ? name : value;
  5590. }
  5591. const RE_EVENTS_PREFIX = /^on/;
  5592. 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
  5593. const EventListener = {
  5594. handleEvent(event) {
  5595. this[event.type](event);
  5596. }
  5597. };
  5598. const ListenersWeakMap = new WeakMap();
  5599. const createListener = node => {
  5600. const listener = Object.create(EventListener);
  5601. ListenersWeakMap.set(node, listener);
  5602. return listener;
  5603. };
  5604. /**
  5605. * Set a new event listener
  5606. * @param {HTMLElement} node - target node
  5607. * @param {Object} expression - expression object
  5608. * @param {string} expression.name - event name
  5609. * @param {*} value - new expression value
  5610. * @returns {value} the callback just received
  5611. */
  5612. function eventExpression(node, _ref, value) {
  5613. let {
  5614. name
  5615. } = _ref;
  5616. const normalizedEventName = name.replace(RE_EVENTS_PREFIX, '');
  5617. const eventListener = ListenersWeakMap.get(node) || createListener(node);
  5618. const [callback, options] = getCallbackAndOptions(value);
  5619. const handler = eventListener[normalizedEventName];
  5620. const mustRemoveEvent = handler && !callback;
  5621. const mustAddEvent = callback && !handler;
  5622. if (mustRemoveEvent) {
  5623. node.removeEventListener(normalizedEventName, eventListener);
  5624. }
  5625. if (mustAddEvent) {
  5626. node.addEventListener(normalizedEventName, eventListener, options);
  5627. }
  5628. eventListener[normalizedEventName] = callback;
  5629. }
  5630. /**
  5631. * Normalize the user value in order to render a empty string in case of falsy values
  5632. * @param {*} value - user input value
  5633. * @returns {string} hopefully a string
  5634. */
  5635. function normalizeStringValue(value) {
  5636. return isNil(value) ? '' : value;
  5637. }
  5638. /**
  5639. * Get the the target text node to update or create one from of a comment node
  5640. * @param {HTMLElement} node - any html element containing childNodes
  5641. * @param {number} childNodeIndex - index of the text node in the childNodes list
  5642. * @returns {Text} the text node to update
  5643. */
  5644. const getTextNode = (node, childNodeIndex) => {
  5645. const target = node.childNodes[childNodeIndex];
  5646. if (target.nodeType === Node.COMMENT_NODE) {
  5647. const textNode = document.createTextNode('');
  5648. node.replaceChild(textNode, target);
  5649. return textNode;
  5650. }
  5651. return target;
  5652. };
  5653. /**
  5654. * This methods handles a simple text expression update
  5655. * @param {HTMLElement} node - target node
  5656. * @param {Object} data - expression object
  5657. * @param {*} value - new expression value
  5658. * @returns {undefined}
  5659. */
  5660. function textExpression(node, data, value) {
  5661. node.data = normalizeStringValue(value);
  5662. }
  5663. /**
  5664. * This methods handles the input fileds value updates
  5665. * @param {HTMLElement} node - target node
  5666. * @param {Object} expression - expression object
  5667. * @param {*} value - new expression value
  5668. * @returns {undefined}
  5669. */
  5670. function valueExpression(node, expression, value) {
  5671. node.value = normalizeStringValue(value);
  5672. }
  5673. var expressions = {
  5674. [ATTRIBUTE]: attributeExpression,
  5675. [EVENT]: eventExpression,
  5676. [TEXT]: textExpression,
  5677. [VALUE]: valueExpression
  5678. };
  5679. const Expression = {
  5680. // Static props
  5681. // node: null,
  5682. // value: null,
  5683. // API methods
  5684. /**
  5685. * Mount the expression evaluating its initial value
  5686. * @param {*} scope - argument passed to the expression to evaluate its current values
  5687. * @returns {Expression} self
  5688. */
  5689. mount(scope) {
  5690. // hopefully a pure function
  5691. this.value = this.evaluate(scope); // IO() DOM updates
  5692. apply(this, this.value);
  5693. return this;
  5694. },
  5695. /**
  5696. * Update the expression if its value changed
  5697. * @param {*} scope - argument passed to the expression to evaluate its current values
  5698. * @returns {Expression} self
  5699. */
  5700. update(scope) {
  5701. // pure function
  5702. const value = this.evaluate(scope);
  5703. if (this.value !== value) {
  5704. // IO() DOM updates
  5705. apply(this, value);
  5706. this.value = value;
  5707. }
  5708. return this;
  5709. },
  5710. /**
  5711. * Expression teardown method
  5712. * @returns {Expression} self
  5713. */
  5714. unmount() {
  5715. // unmount only the event handling expressions
  5716. if (this.type === EVENT) apply(this, null);
  5717. return this;
  5718. }
  5719. };
  5720. /**
  5721. * IO() function to handle the DOM updates
  5722. * @param {Expression} expression - expression object
  5723. * @param {*} value - current expression value
  5724. * @returns {undefined}
  5725. */
  5726. function apply(expression, value) {
  5727. return expressions[expression.type](expression.node, expression, value, expression.value);
  5728. }
  5729. function create$4(node, data) {
  5730. return Object.assign({}, Expression, data, {
  5731. node: data.type === TEXT ? getTextNode(node, data.childNodeIndex) : node
  5732. });
  5733. }
  5734. /**
  5735. * Create a flat object having as keys a list of methods that if dispatched will propagate
  5736. * on the whole collection
  5737. * @param {Array} collection - collection to iterate
  5738. * @param {Array<string>} methods - methods to execute on each item of the collection
  5739. * @param {*} context - context returned by the new methods created
  5740. * @returns {Object} a new object to simplify the the nested methods dispatching
  5741. */
  5742. function flattenCollectionMethods(collection, methods, context) {
  5743. return methods.reduce((acc, method) => {
  5744. return Object.assign({}, acc, {
  5745. [method]: scope => {
  5746. return collection.map(item => item[method](scope)) && context;
  5747. }
  5748. });
  5749. }, {});
  5750. }
  5751. function create$3(node, _ref) {
  5752. let {
  5753. expressions
  5754. } = _ref;
  5755. return Object.assign({}, flattenCollectionMethods(expressions.map(expression => create$4(node, expression)), ['mount', 'update', 'unmount']));
  5756. }
  5757. function extendParentScope(attributes, scope, parentScope) {
  5758. if (!attributes || !attributes.length) return parentScope;
  5759. const expressions = attributes.map(attr => Object.assign({}, attr, {
  5760. value: attr.evaluate(scope)
  5761. }));
  5762. return Object.assign(Object.create(parentScope || null), evaluateAttributeExpressions(expressions));
  5763. } // this function is only meant to fix an edge case
  5764. // https://github.com/riot/riot/issues/2842
  5765. const getRealParent = (scope, parentScope) => scope[PARENT_KEY_SYMBOL] || parentScope;
  5766. const SlotBinding = {
  5767. // dynamic binding properties
  5768. // node: null,
  5769. // name: null,
  5770. attributes: [],
  5771. // template: null,
  5772. getTemplateScope(scope, parentScope) {
  5773. return extendParentScope(this.attributes, scope, parentScope);
  5774. },
  5775. // API methods
  5776. mount(scope, parentScope) {
  5777. const templateData = scope.slots ? scope.slots.find(_ref => {
  5778. let {
  5779. id
  5780. } = _ref;
  5781. return id === this.name;
  5782. }) : false;
  5783. const {
  5784. parentNode
  5785. } = this.node;
  5786. const realParent = getRealParent(scope, parentScope);
  5787. this.template = templateData && create(templateData.html, templateData.bindings).createDOM(parentNode);
  5788. if (this.template) {
  5789. cleanNode(this.node);
  5790. this.template.mount(this.node, this.getTemplateScope(scope, realParent), realParent);
  5791. this.template.children = Array.from(this.node.childNodes);
  5792. }
  5793. moveSlotInnerContent(this.node);
  5794. removeChild(this.node);
  5795. return this;
  5796. },
  5797. update(scope, parentScope) {
  5798. if (this.template) {
  5799. const realParent = getRealParent(scope, parentScope);
  5800. this.template.update(this.getTemplateScope(scope, realParent), realParent);
  5801. }
  5802. return this;
  5803. },
  5804. unmount(scope, parentScope, mustRemoveRoot) {
  5805. if (this.template) {
  5806. this.template.unmount(this.getTemplateScope(scope, parentScope), null, mustRemoveRoot);
  5807. }
  5808. return this;
  5809. }
  5810. };
  5811. /**
  5812. * Move the inner content of the slots outside of them
  5813. * @param {HTMLElement} slot - slot node
  5814. * @returns {undefined} it's a void method ¯\_()_/¯
  5815. */
  5816. function moveSlotInnerContent(slot) {
  5817. const child = slot && slot.firstChild;
  5818. if (!child) return;
  5819. insertBefore(child, slot);
  5820. moveSlotInnerContent(slot);
  5821. }
  5822. /**
  5823. * Create a single slot binding
  5824. * @param {HTMLElement} node - slot node
  5825. * @param {string} name - slot id
  5826. * @param {AttributeExpressionData[]} attributes - slot attributes
  5827. * @returns {Object} Slot binding object
  5828. */
  5829. function createSlot(node, _ref2) {
  5830. let {
  5831. name,
  5832. attributes
  5833. } = _ref2;
  5834. return Object.assign({}, SlotBinding, {
  5835. attributes,
  5836. node,
  5837. name
  5838. });
  5839. }
  5840. /**
  5841. * Create a new tag object if it was registered before, otherwise fallback to the simple
  5842. * template chunk
  5843. * @param {Function} component - component factory function
  5844. * @param {Array<Object>} slots - array containing the slots markup
  5845. * @param {Array} attributes - dynamic attributes that will be received by the tag element
  5846. * @returns {TagImplementation|TemplateChunk} a tag implementation or a template chunk as fallback
  5847. */
  5848. function getTag(component, slots, attributes) {
  5849. if (slots === void 0) {
  5850. slots = [];
  5851. }
  5852. if (attributes === void 0) {
  5853. attributes = [];
  5854. }
  5855. // if this tag was registered before we will return its implementation
  5856. if (component) {
  5857. return component({
  5858. slots,
  5859. attributes
  5860. });
  5861. } // otherwise we return a template chunk
  5862. return create(slotsToMarkup(slots), [...slotBindings(slots), {
  5863. // the attributes should be registered as binding
  5864. // if we fallback to a normal template chunk
  5865. expressions: attributes.map(attr => {
  5866. return Object.assign({
  5867. type: ATTRIBUTE
  5868. }, attr);
  5869. })
  5870. }]);
  5871. }
  5872. /**
  5873. * Merge all the slots bindings into a single array
  5874. * @param {Array<Object>} slots - slots collection
  5875. * @returns {Array<Bindings>} flatten bindings array
  5876. */
  5877. function slotBindings(slots) {
  5878. return slots.reduce((acc, _ref) => {
  5879. let {
  5880. bindings
  5881. } = _ref;
  5882. return acc.concat(bindings);
  5883. }, []);
  5884. }
  5885. /**
  5886. * Merge all the slots together in a single markup string
  5887. * @param {Array<Object>} slots - slots collection
  5888. * @returns {string} markup of all the slots in a single string
  5889. */
  5890. function slotsToMarkup(slots) {
  5891. return slots.reduce((acc, slot) => {
  5892. return acc + slot.html;
  5893. }, '');
  5894. }
  5895. const TagBinding = {
  5896. // dynamic binding properties
  5897. // node: null,
  5898. // evaluate: null,
  5899. // name: null,
  5900. // slots: null,
  5901. // tag: null,
  5902. // attributes: null,
  5903. // getComponent: null,
  5904. mount(scope) {
  5905. return this.update(scope);
  5906. },
  5907. update(scope, parentScope) {
  5908. const name = this.evaluate(scope); // simple update
  5909. if (name && name === this.name) {
  5910. this.tag.update(scope);
  5911. } else {
  5912. // unmount the old tag if it exists
  5913. this.unmount(scope, parentScope, true); // mount the new tag
  5914. this.name = name;
  5915. this.tag = getTag(this.getComponent(name), this.slots, this.attributes);
  5916. this.tag.mount(this.node, scope);
  5917. }
  5918. return this;
  5919. },
  5920. unmount(scope, parentScope, keepRootTag) {
  5921. if (this.tag) {
  5922. // keep the root tag
  5923. this.tag.unmount(keepRootTag);
  5924. }
  5925. return this;
  5926. }
  5927. };
  5928. function create$2(node, _ref2) {
  5929. let {
  5930. evaluate,
  5931. getComponent,
  5932. slots,
  5933. attributes
  5934. } = _ref2;
  5935. return Object.assign({}, TagBinding, {
  5936. node,
  5937. evaluate,
  5938. slots,
  5939. attributes,
  5940. getComponent
  5941. });
  5942. }
  5943. var bindings = {
  5944. [IF]: create$5,
  5945. [SIMPLE]: create$3,
  5946. [EACH]: create$6,
  5947. [TAG]: create$2,
  5948. [SLOT]: createSlot
  5949. };
  5950. /**
  5951. * Text expressions in a template tag will get childNodeIndex value normalized
  5952. * depending on the position of the <template> tag offset
  5953. * @param {Expression[]} expressions - riot expressions array
  5954. * @param {number} textExpressionsOffset - offset of the <template> tag
  5955. * @returns {Expression[]} expressions containing the text expressions normalized
  5956. */
  5957. function fixTextExpressionsOffset(expressions, textExpressionsOffset) {
  5958. return expressions.map(e => e.type === TEXT ? Object.assign({}, e, {
  5959. childNodeIndex: e.childNodeIndex + textExpressionsOffset
  5960. }) : e);
  5961. }
  5962. /**
  5963. * Bind a new expression object to a DOM node
  5964. * @param {HTMLElement} root - DOM node where to bind the expression
  5965. * @param {TagBindingData} binding - binding data
  5966. * @param {number|null} templateTagOffset - if it's defined we need to fix the text expressions childNodeIndex offset
  5967. * @returns {Binding} Binding object
  5968. */
  5969. function create$1(root, binding, templateTagOffset) {
  5970. const {
  5971. selector,
  5972. type,
  5973. redundantAttribute,
  5974. expressions
  5975. } = binding; // find the node to apply the bindings
  5976. const node = selector ? root.querySelector(selector) : root; // remove eventually additional attributes created only to select this node
  5977. if (redundantAttribute) node.removeAttribute(redundantAttribute);
  5978. const bindingExpressions = expressions || []; // init the binding
  5979. return (bindings[type] || bindings[SIMPLE])(node, Object.assign({}, binding, {
  5980. expressions: templateTagOffset && !selector ? fixTextExpressionsOffset(bindingExpressions, templateTagOffset) : bindingExpressions
  5981. }));
  5982. }
  5983. function createHTMLTree(html, root) {
  5984. const template = isTemplate(root) ? root : document.createElement('template');
  5985. template.innerHTML = html;
  5986. return template.content;
  5987. } // for svg nodes we need a bit more work
  5988. function createSVGTree(html, container) {
  5989. // create the SVGNode
  5990. const svgNode = container.ownerDocument.importNode(new window.DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${html}</svg>`, 'application/xml').documentElement, true);
  5991. return svgNode;
  5992. }
  5993. /**
  5994. * Create the DOM that will be injected
  5995. * @param {Object} root - DOM node to find out the context where the fragment will be created
  5996. * @param {string} html - DOM to create as string
  5997. * @returns {HTMLDocumentFragment|HTMLElement} a new html fragment
  5998. */
  5999. function createDOMTree(root, html) {
  6000. if (isSvg(root)) return createSVGTree(html, root);
  6001. return createHTMLTree(html, root);
  6002. }
  6003. /**
  6004. * Inject the DOM tree into a target node
  6005. * @param {HTMLElement} el - target element
  6006. * @param {DocumentFragment|SVGElement} dom - dom tree to inject
  6007. * @returns {undefined}
  6008. */
  6009. function injectDOM(el, dom) {
  6010. switch (true) {
  6011. case isSvg(el):
  6012. moveChildren(dom, el);
  6013. break;
  6014. case isTemplate(el):
  6015. el.parentNode.replaceChild(dom, el);
  6016. break;
  6017. default:
  6018. el.appendChild(dom);
  6019. }
  6020. }
  6021. /**
  6022. * Create the Template DOM skeleton
  6023. * @param {HTMLElement} el - root node where the DOM will be injected
  6024. * @param {string|HTMLElement} html - HTML markup or HTMLElement that will be injected into the root node
  6025. * @returns {?DocumentFragment} fragment that will be injected into the root node
  6026. */
  6027. function createTemplateDOM(el, html) {
  6028. return html && (typeof html === 'string' ? createDOMTree(el, html) : html);
  6029. }
  6030. /**
  6031. * Get the offset of the <template> tag
  6032. * @param {HTMLElement} parentNode - template tag parent node
  6033. * @param {HTMLElement} el - the template tag we want to render
  6034. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  6035. * @returns {number} offset of the <template> tag calculated from its siblings DOM nodes
  6036. */
  6037. function getTemplateTagOffset(parentNode, el, meta) {
  6038. const siblings = Array.from(parentNode.childNodes);
  6039. return Math.max(siblings.indexOf(el), siblings.indexOf(meta.head) + 1, 0);
  6040. }
  6041. /**
  6042. * Template Chunk model
  6043. * @type {Object}
  6044. */
  6045. const TemplateChunk = Object.freeze({
  6046. // Static props
  6047. // bindings: null,
  6048. // bindingsData: null,
  6049. // html: null,
  6050. // isTemplateTag: false,
  6051. // fragment: null,
  6052. // children: null,
  6053. // dom: null,
  6054. // el: null,
  6055. /**
  6056. * Create the template DOM structure that will be cloned on each mount
  6057. * @param {HTMLElement} el - the root node
  6058. * @returns {TemplateChunk} self
  6059. */
  6060. createDOM(el) {
  6061. // make sure that the DOM gets created before cloning the template
  6062. this.dom = this.dom || createTemplateDOM(el, this.html) || document.createDocumentFragment();
  6063. return this;
  6064. },
  6065. // API methods
  6066. /**
  6067. * Attach the template to a DOM node
  6068. * @param {HTMLElement} el - target DOM node
  6069. * @param {*} scope - template data
  6070. * @param {*} parentScope - scope of the parent template tag
  6071. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  6072. * @returns {TemplateChunk} self
  6073. */
  6074. mount(el, scope, parentScope, meta) {
  6075. if (meta === void 0) {
  6076. meta = {};
  6077. }
  6078. if (!el) throw new Error('Please provide DOM node to mount properly your template');
  6079. if (this.el) this.unmount(scope); // <template> tags require a bit more work
  6080. // the template fragment might be already created via meta outside of this call
  6081. const {
  6082. fragment,
  6083. children,
  6084. avoidDOMInjection
  6085. } = meta; // <template> bindings of course can not have a root element
  6086. // so we check the parent node to set the query selector bindings
  6087. const {
  6088. parentNode
  6089. } = children ? children[0] : el;
  6090. const isTemplateTag = isTemplate(el);
  6091. const templateTagOffset = isTemplateTag ? getTemplateTagOffset(parentNode, el, meta) : null; // create the DOM if it wasn't created before
  6092. this.createDOM(el); // create the DOM of this template cloning the original DOM structure stored in this instance
  6093. // notice that if a documentFragment was passed (via meta) we will use it instead
  6094. const cloneNode = fragment || this.dom.cloneNode(true); // store root node
  6095. // notice that for template tags the root note will be the parent tag
  6096. this.el = isTemplateTag ? parentNode : el; // create the children array only for the <template> fragments
  6097. this.children = isTemplateTag ? children || Array.from(cloneNode.childNodes) : null; // inject the DOM into the el only if a fragment is available
  6098. if (!avoidDOMInjection && cloneNode) injectDOM(el, cloneNode); // create the bindings
  6099. this.bindings = this.bindingsData.map(binding => create$1(this.el, binding, templateTagOffset));
  6100. this.bindings.forEach(b => b.mount(scope, parentScope)); // store the template meta properties
  6101. this.meta = meta;
  6102. return this;
  6103. },
  6104. /**
  6105. * Update the template with fresh data
  6106. * @param {*} scope - template data
  6107. * @param {*} parentScope - scope of the parent template tag
  6108. * @returns {TemplateChunk} self
  6109. */
  6110. update(scope, parentScope) {
  6111. this.bindings.forEach(b => b.update(scope, parentScope));
  6112. return this;
  6113. },
  6114. /**
  6115. * Remove the template from the node where it was initially mounted
  6116. * @param {*} scope - template data
  6117. * @param {*} parentScope - scope of the parent template tag
  6118. * @param {boolean|null} mustRemoveRoot - if true remove the root element,
  6119. * if false or undefined clean the root tag content, if null don't touch the DOM
  6120. * @returns {TemplateChunk} self
  6121. */
  6122. unmount(scope, parentScope, mustRemoveRoot) {
  6123. if (mustRemoveRoot === void 0) {
  6124. mustRemoveRoot = false;
  6125. }
  6126. const el = this.el;
  6127. if (!el) {
  6128. return this;
  6129. }
  6130. this.bindings.forEach(b => b.unmount(scope, parentScope, mustRemoveRoot));
  6131. switch (true) {
  6132. // pure components should handle the DOM unmount updates by themselves
  6133. // for mustRemoveRoot === null don't touch the DOM
  6134. case el[IS_PURE_SYMBOL] || mustRemoveRoot === null:
  6135. break;
  6136. // if children are declared, clear them
  6137. // applicable for <template> and <slot/> bindings
  6138. case Array.isArray(this.children):
  6139. clearChildren(this.children);
  6140. break;
  6141. // clean the node children only
  6142. case !mustRemoveRoot:
  6143. cleanNode(el);
  6144. break;
  6145. // remove the root node only if the mustRemoveRoot is truly
  6146. case !!mustRemoveRoot:
  6147. removeChild(el);
  6148. break;
  6149. }
  6150. this.el = null;
  6151. return this;
  6152. },
  6153. /**
  6154. * Clone the template chunk
  6155. * @returns {TemplateChunk} a clone of this object resetting the this.el property
  6156. */
  6157. clone() {
  6158. return Object.assign({}, this, {
  6159. meta: {},
  6160. el: null
  6161. });
  6162. }
  6163. });
  6164. /**
  6165. * Create a template chunk wiring also the bindings
  6166. * @param {string|HTMLElement} html - template string
  6167. * @param {BindingData[]} bindings - bindings collection
  6168. * @returns {TemplateChunk} a new TemplateChunk copy
  6169. */
  6170. function create(html, bindings) {
  6171. if (bindings === void 0) {
  6172. bindings = [];
  6173. }
  6174. return Object.assign({}, TemplateChunk, {
  6175. html,
  6176. bindingsData: bindings
  6177. });
  6178. }
  6179. /**
  6180. * Method used to bind expressions to a DOM node
  6181. * @param {string|HTMLElement} html - your static template html structure
  6182. * @param {Array} bindings - list of the expressions to bind to update the markup
  6183. * @returns {TemplateChunk} a new TemplateChunk object having the `update`,`mount`, `unmount` and `clone` methods
  6184. *
  6185. * @example
  6186. *
  6187. * riotDOMBindings
  6188. * .template(
  6189. * `<div expr0><!----></div><div><p expr1><!----><section expr2></section></p>`,
  6190. * [
  6191. * {
  6192. * selector: '[expr0]',
  6193. * redundantAttribute: 'expr0',
  6194. * expressions: [
  6195. * {
  6196. * type: expressionTypes.TEXT,
  6197. * childNodeIndex: 0,
  6198. * evaluate(scope) {
  6199. * return scope.time;
  6200. * },
  6201. * },
  6202. * ],
  6203. * },
  6204. * {
  6205. * selector: '[expr1]',
  6206. * redundantAttribute: 'expr1',
  6207. * expressions: [
  6208. * {
  6209. * type: expressionTypes.TEXT,
  6210. * childNodeIndex: 0,
  6211. * evaluate(scope) {
  6212. * return scope.name;
  6213. * },
  6214. * },
  6215. * {
  6216. * type: 'attribute',
  6217. * name: 'style',
  6218. * evaluate(scope) {
  6219. * return scope.style;
  6220. * },
  6221. * },
  6222. * ],
  6223. * },
  6224. * {
  6225. * selector: '[expr2]',
  6226. * redundantAttribute: 'expr2',
  6227. * type: bindingTypes.IF,
  6228. * evaluate(scope) {
  6229. * return scope.isVisible;
  6230. * },
  6231. * template: riotDOMBindings.template('hello there'),
  6232. * },
  6233. * ]
  6234. * )
  6235. */
  6236. var DOMBindings = /*#__PURE__*/Object.freeze({
  6237. __proto__: null,
  6238. template: create,
  6239. createBinding: create$1,
  6240. createExpression: create$4,
  6241. bindingTypes: bindingTypes,
  6242. expressionTypes: expressionTypes
  6243. });
  6244. function noop() {
  6245. return this;
  6246. }
  6247. /**
  6248. * Autobind the methods of a source object to itself
  6249. * @param {Object} source - probably a riot tag instance
  6250. * @param {Array<string>} methods - list of the methods to autobind
  6251. * @returns {Object} the original object received
  6252. */
  6253. function autobindMethods(source, methods) {
  6254. methods.forEach(method => {
  6255. source[method] = source[method].bind(source);
  6256. });
  6257. return source;
  6258. }
  6259. /**
  6260. * Call the first argument received only if it's a function otherwise return it as it is
  6261. * @param {*} source - anything
  6262. * @returns {*} anything
  6263. */
  6264. function callOrAssign(source) {
  6265. return isFunction(source) ? source.prototype && source.prototype.constructor ? new source() : source() : source;
  6266. }
  6267. /**
  6268. * Converts any DOM node/s to a loopable array
  6269. * @param { HTMLElement|NodeList } els - single html element or a node list
  6270. * @returns { Array } always a loopable object
  6271. */
  6272. function domToArray(els) {
  6273. // can this object be already looped?
  6274. if (!Array.isArray(els)) {
  6275. // is it a node list?
  6276. 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
  6277. // it will be returned as "array" with one single entry
  6278. return [els];
  6279. } // this object could be looped out of the box
  6280. return els;
  6281. }
  6282. /**
  6283. * Simple helper to find DOM nodes returning them as array like loopable object
  6284. * @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
  6285. * @param { HTMLElement } ctx - context defining where the query will search for the DOM nodes
  6286. * @returns { Array } DOM nodes found as array
  6287. */
  6288. function $(selector, ctx) {
  6289. return domToArray(typeof selector === 'string' ? (ctx || document).querySelectorAll(selector) : selector);
  6290. }
  6291. /**
  6292. * Normalize the return values, in case of a single value we avoid to return an array
  6293. * @param { Array } values - list of values we want to return
  6294. * @returns { Array|string|boolean } either the whole list of values or the single one found
  6295. * @private
  6296. */
  6297. const normalize = values => values.length === 1 ? values[0] : values;
  6298. /**
  6299. * Parse all the nodes received to get/remove/check their attributes
  6300. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  6301. * @param { string|Array } name - name or list of attributes
  6302. * @param { string } method - method that will be used to parse the attributes
  6303. * @returns { Array|string } result of the parsing in a list or a single value
  6304. * @private
  6305. */
  6306. function parseNodes(els, name, method) {
  6307. const names = typeof name === 'string' ? [name] : name;
  6308. return normalize(domToArray(els).map(el => {
  6309. return normalize(names.map(n => el[method](n)));
  6310. }));
  6311. }
  6312. /**
  6313. * Set any attribute on a single or a list of DOM nodes
  6314. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  6315. * @param { string|Object } name - either the name of the attribute to set
  6316. * or a list of properties as object key - value
  6317. * @param { string } value - the new value of the attribute (optional)
  6318. * @returns { HTMLElement|NodeList|Array } the original array of elements passed to this function
  6319. *
  6320. * @example
  6321. *
  6322. * import { set } from 'bianco.attr'
  6323. *
  6324. * const img = document.createElement('img')
  6325. *
  6326. * set(img, 'width', 100)
  6327. *
  6328. * // or also
  6329. * set(img, {
  6330. * width: 300,
  6331. * height: 300
  6332. * })
  6333. *
  6334. */
  6335. function set(els, name, value) {
  6336. const attrs = typeof name === 'object' ? name : {
  6337. [name]: value
  6338. };
  6339. const props = Object.keys(attrs);
  6340. domToArray(els).forEach(el => {
  6341. props.forEach(prop => el.setAttribute(prop, attrs[prop]));
  6342. });
  6343. return els;
  6344. }
  6345. /**
  6346. * Get any attribute from a single or a list of DOM nodes
  6347. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  6348. * @param { string|Array } name - name or list of attributes to get
  6349. * @returns { Array|string } list of the attributes found
  6350. *
  6351. * @example
  6352. *
  6353. * import { get } from 'bianco.attr'
  6354. *
  6355. * const img = document.createElement('img')
  6356. *
  6357. * get(img, 'width') // => '200'
  6358. *
  6359. * // or also
  6360. * get(img, ['width', 'height']) // => ['200', '300']
  6361. *
  6362. * // or also
  6363. * get([img1, img2], ['width', 'height']) // => [['200', '300'], ['500', '200']]
  6364. */
  6365. function get(els, name) {
  6366. return parseNodes(els, name, 'getAttribute');
  6367. }
  6368. const CSS_BY_NAME = new Map();
  6369. const STYLE_NODE_SELECTOR = 'style[riot]'; // memoized curried function
  6370. const getStyleNode = (style => {
  6371. return () => {
  6372. // lazy evaluation:
  6373. // if this function was already called before
  6374. // we return its cached result
  6375. if (style) return style; // create a new style element or use an existing one
  6376. // and cache it internally
  6377. style = $(STYLE_NODE_SELECTOR)[0] || document.createElement('style');
  6378. set(style, 'type', 'text/css');
  6379. /* istanbul ignore next */
  6380. if (!style.parentNode) document.head.appendChild(style);
  6381. return style;
  6382. };
  6383. })();
  6384. /**
  6385. * Object that will be used to inject and manage the css of every tag instance
  6386. */
  6387. var cssManager = {
  6388. CSS_BY_NAME,
  6389. /**
  6390. * Save a tag style to be later injected into DOM
  6391. * @param { string } name - if it's passed we will map the css to a tagname
  6392. * @param { string } css - css string
  6393. * @returns {Object} self
  6394. */
  6395. add(name, css) {
  6396. if (!CSS_BY_NAME.has(name)) {
  6397. CSS_BY_NAME.set(name, css);
  6398. this.inject();
  6399. }
  6400. return this;
  6401. },
  6402. /**
  6403. * Inject all previously saved tag styles into DOM
  6404. * innerHTML seems slow: http://jsperf.com/riot-insert-style
  6405. * @returns {Object} self
  6406. */
  6407. inject() {
  6408. getStyleNode().innerHTML = [...CSS_BY_NAME.values()].join('\n');
  6409. return this;
  6410. },
  6411. /**
  6412. * Remove a tag style from the DOM
  6413. * @param {string} name a registered tagname
  6414. * @returns {Object} self
  6415. */
  6416. remove(name) {
  6417. if (CSS_BY_NAME.has(name)) {
  6418. CSS_BY_NAME.delete(name);
  6419. this.inject();
  6420. }
  6421. return this;
  6422. }
  6423. };
  6424. /**
  6425. * Function to curry any javascript method
  6426. * @param {Function} fn - the target function we want to curry
  6427. * @param {...[args]} acc - initial arguments
  6428. * @returns {Function|*} it will return a function until the target function
  6429. * will receive all of its arguments
  6430. */
  6431. function curry(fn) {
  6432. for (var _len = arguments.length, acc = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  6433. acc[_key - 1] = arguments[_key];
  6434. }
  6435. return function () {
  6436. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6437. args[_key2] = arguments[_key2];
  6438. }
  6439. args = [...acc, ...args];
  6440. return args.length < fn.length ? curry(fn, ...args) : fn(...args);
  6441. };
  6442. }
  6443. /**
  6444. * Get the tag name of any DOM node
  6445. * @param {HTMLElement} element - DOM node we want to inspect
  6446. * @returns {string} name to identify this dom node in riot
  6447. */
  6448. function getName(element) {
  6449. return get(element, IS_DIRECTIVE) || element.tagName.toLowerCase();
  6450. }
  6451. const COMPONENT_CORE_HELPERS = Object.freeze({
  6452. // component helpers
  6453. $(selector) {
  6454. return $(selector, this.root)[0];
  6455. },
  6456. $$(selector) {
  6457. return $(selector, this.root);
  6458. }
  6459. });
  6460. const PURE_COMPONENT_API = Object.freeze({
  6461. [MOUNT_METHOD_KEY]: noop,
  6462. [UPDATE_METHOD_KEY]: noop,
  6463. [UNMOUNT_METHOD_KEY]: noop
  6464. });
  6465. const COMPONENT_LIFECYCLE_METHODS = Object.freeze({
  6466. [SHOULD_UPDATE_KEY]: noop,
  6467. [ON_BEFORE_MOUNT_KEY]: noop,
  6468. [ON_MOUNTED_KEY]: noop,
  6469. [ON_BEFORE_UPDATE_KEY]: noop,
  6470. [ON_UPDATED_KEY]: noop,
  6471. [ON_BEFORE_UNMOUNT_KEY]: noop,
  6472. [ON_UNMOUNTED_KEY]: noop
  6473. });
  6474. const MOCKED_TEMPLATE_INTERFACE = Object.assign({}, PURE_COMPONENT_API, {
  6475. clone: noop,
  6476. createDOM: noop
  6477. });
  6478. /**
  6479. * Performance optimization for the recursive components
  6480. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  6481. * @returns {Object} component like interface
  6482. */
  6483. const memoizedCreateComponent = memoize(createComponent);
  6484. /**
  6485. * Evaluate the component properties either from its real attributes or from its initial user properties
  6486. * @param {HTMLElement} element - component root
  6487. * @param {Object} initialProps - initial props
  6488. * @returns {Object} component props key value pairs
  6489. */
  6490. function evaluateInitialProps(element, initialProps) {
  6491. if (initialProps === void 0) {
  6492. initialProps = {};
  6493. }
  6494. return Object.assign({}, DOMattributesToObject(element), callOrAssign(initialProps));
  6495. }
  6496. /**
  6497. * Bind a DOM node to its component object
  6498. * @param {HTMLElement} node - html node mounted
  6499. * @param {Object} component - Riot.js component object
  6500. * @returns {Object} the component object received as second argument
  6501. */
  6502. const bindDOMNodeToComponentObject = (node, component) => node[DOM_COMPONENT_INSTANCE_PROPERTY$1] = component;
  6503. /**
  6504. * Wrap the Riot.js core API methods using a mapping function
  6505. * @param {Function} mapFunction - lifting function
  6506. * @returns {Object} an object having the { mount, update, unmount } functions
  6507. */
  6508. function createCoreAPIMethods(mapFunction) {
  6509. return [MOUNT_METHOD_KEY, UPDATE_METHOD_KEY, UNMOUNT_METHOD_KEY].reduce((acc, method) => {
  6510. acc[method] = mapFunction(method);
  6511. return acc;
  6512. }, {});
  6513. }
  6514. /**
  6515. * Factory function to create the component templates only once
  6516. * @param {Function} template - component template creation function
  6517. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  6518. * @returns {TemplateChunk} template chunk object
  6519. */
  6520. function componentTemplateFactory(template, componentWrapper) {
  6521. const components = createSubcomponents(componentWrapper.exports ? componentWrapper.exports.components : {});
  6522. return template(create, expressionTypes, bindingTypes, name => {
  6523. // improve support for recursive components
  6524. if (name === componentWrapper.name) return memoizedCreateComponent(componentWrapper); // return the registered components
  6525. return components[name] || COMPONENTS_IMPLEMENTATION_MAP$1.get(name);
  6526. });
  6527. }
  6528. /**
  6529. * Create a pure component
  6530. * @param {Function} pureFactoryFunction - pure component factory function
  6531. * @param {Array} options.slots - component slots
  6532. * @param {Array} options.attributes - component attributes
  6533. * @param {Array} options.template - template factory function
  6534. * @param {Array} options.template - template factory function
  6535. * @param {any} options.props - initial component properties
  6536. * @returns {Object} pure component object
  6537. */
  6538. function createPureComponent(pureFactoryFunction, _ref) {
  6539. let {
  6540. slots,
  6541. attributes,
  6542. props,
  6543. css,
  6544. template
  6545. } = _ref;
  6546. if (template) panic('Pure components can not have html');
  6547. if (css) panic('Pure components do not have css');
  6548. const component = defineDefaults(pureFactoryFunction({
  6549. slots,
  6550. attributes,
  6551. props
  6552. }), PURE_COMPONENT_API);
  6553. return createCoreAPIMethods(method => function () {
  6554. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6555. args[_key] = arguments[_key];
  6556. }
  6557. // intercept the mount calls to bind the DOM node to the pure object created
  6558. // see also https://github.com/riot/riot/issues/2806
  6559. if (method === MOUNT_METHOD_KEY) {
  6560. const [el] = args; // mark this node as pure element
  6561. el[IS_PURE_SYMBOL] = true;
  6562. bindDOMNodeToComponentObject(el, component);
  6563. }
  6564. component[method](...args);
  6565. return component;
  6566. });
  6567. }
  6568. /**
  6569. * Create the component interface needed for the @riotjs/dom-bindings tag bindings
  6570. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  6571. * @param {string} componentWrapper.css - component css
  6572. * @param {Function} componentWrapper.template - function that will return the dom-bindings template function
  6573. * @param {Object} componentWrapper.exports - component interface
  6574. * @param {string} componentWrapper.name - component name
  6575. * @returns {Object} component like interface
  6576. */
  6577. function createComponent(componentWrapper) {
  6578. const {
  6579. css,
  6580. template,
  6581. exports,
  6582. name
  6583. } = componentWrapper;
  6584. const templateFn = template ? componentTemplateFactory(template, componentWrapper) : MOCKED_TEMPLATE_INTERFACE;
  6585. return _ref2 => {
  6586. let {
  6587. slots,
  6588. attributes,
  6589. props
  6590. } = _ref2;
  6591. // pure components rendering will be managed by the end user
  6592. if (exports && exports[IS_PURE_SYMBOL]) return createPureComponent(exports, {
  6593. slots,
  6594. attributes,
  6595. props,
  6596. css,
  6597. template
  6598. });
  6599. const componentAPI = callOrAssign(exports) || {};
  6600. const component = defineComponent({
  6601. css,
  6602. template: templateFn,
  6603. componentAPI,
  6604. name
  6605. })({
  6606. slots,
  6607. attributes,
  6608. props
  6609. }); // notice that for the components create via tag binding
  6610. // we need to invert the mount (state/parentScope) arguments
  6611. // the template bindings will only forward the parentScope updates
  6612. // and never deal with the component state
  6613. return {
  6614. mount(element, parentScope, state) {
  6615. return component.mount(element, state, parentScope);
  6616. },
  6617. update(parentScope, state) {
  6618. return component.update(state, parentScope);
  6619. },
  6620. unmount(preserveRoot) {
  6621. return component.unmount(preserveRoot);
  6622. }
  6623. };
  6624. };
  6625. }
  6626. /**
  6627. * Component definition function
  6628. * @param {Object} implementation - the componen implementation will be generated via compiler
  6629. * @param {Object} component - the component initial properties
  6630. * @returns {Object} a new component implementation object
  6631. */
  6632. function defineComponent(_ref3) {
  6633. let {
  6634. css,
  6635. template,
  6636. componentAPI,
  6637. name
  6638. } = _ref3;
  6639. // add the component css into the DOM
  6640. if (css && name) cssManager.add(name, css);
  6641. return curry(enhanceComponentAPI)(defineProperties( // set the component defaults without overriding the original component API
  6642. defineDefaults(componentAPI, Object.assign({}, COMPONENT_LIFECYCLE_METHODS, {
  6643. [PROPS_KEY]: {},
  6644. [STATE_KEY]: {}
  6645. })), Object.assign({
  6646. // defined during the component creation
  6647. [SLOTS_KEY]: null,
  6648. [ROOT_KEY]: null
  6649. }, COMPONENT_CORE_HELPERS, {
  6650. name,
  6651. css,
  6652. template
  6653. })));
  6654. }
  6655. /**
  6656. * Create the bindings to update the component attributes
  6657. * @param {HTMLElement} node - node where we will bind the expressions
  6658. * @param {Array} attributes - list of attribute bindings
  6659. * @returns {TemplateChunk} - template bindings object
  6660. */
  6661. function createAttributeBindings(node, attributes) {
  6662. if (attributes === void 0) {
  6663. attributes = [];
  6664. }
  6665. const expressions = attributes.map(a => create$4(node, a));
  6666. const binding = {};
  6667. return Object.assign(binding, Object.assign({
  6668. expressions
  6669. }, createCoreAPIMethods(method => scope => {
  6670. expressions.forEach(e => e[method](scope));
  6671. return binding;
  6672. })));
  6673. }
  6674. /**
  6675. * Create the subcomponents that can be included inside a tag in runtime
  6676. * @param {Object} components - components imported in runtime
  6677. * @returns {Object} all the components transformed into Riot.Component factory functions
  6678. */
  6679. function createSubcomponents(components) {
  6680. if (components === void 0) {
  6681. components = {};
  6682. }
  6683. return Object.entries(callOrAssign(components)).reduce((acc, _ref4) => {
  6684. let [key, value] = _ref4;
  6685. acc[camelToDashCase(key)] = createComponent(value);
  6686. return acc;
  6687. }, {});
  6688. }
  6689. /**
  6690. * Run the component instance through all the plugins set by the user
  6691. * @param {Object} component - component instance
  6692. * @returns {Object} the component enhanced by the plugins
  6693. */
  6694. function runPlugins(component) {
  6695. return [...PLUGINS_SET$1].reduce((c, fn) => fn(c) || c, component);
  6696. }
  6697. /**
  6698. * Compute the component current state merging it with its previous state
  6699. * @param {Object} oldState - previous state object
  6700. * @param {Object} newState - new state givent to the `update` call
  6701. * @returns {Object} new object state
  6702. */
  6703. function computeState(oldState, newState) {
  6704. return Object.assign({}, oldState, callOrAssign(newState));
  6705. }
  6706. /**
  6707. * Add eventually the "is" attribute to link this DOM node to its css
  6708. * @param {HTMLElement} element - target root node
  6709. * @param {string} name - name of the component mounted
  6710. * @returns {undefined} it's a void function
  6711. */
  6712. function addCssHook(element, name) {
  6713. if (getName(element) !== name) {
  6714. set(element, IS_DIRECTIVE, name);
  6715. }
  6716. }
  6717. /**
  6718. * Component creation factory function that will enhance the user provided API
  6719. * @param {Object} component - a component implementation previously defined
  6720. * @param {Array} options.slots - component slots generated via riot compiler
  6721. * @param {Array} options.attributes - attribute expressions generated via riot compiler
  6722. * @returns {Riot.Component} a riot component instance
  6723. */
  6724. function enhanceComponentAPI(component, _ref5) {
  6725. let {
  6726. slots,
  6727. attributes,
  6728. props
  6729. } = _ref5;
  6730. return autobindMethods(runPlugins(defineProperties(isObject(component) ? Object.create(component) : component, {
  6731. mount(element, state, parentScope) {
  6732. if (state === void 0) {
  6733. state = {};
  6734. }
  6735. this[PARENT_KEY_SYMBOL] = parentScope;
  6736. this[ATTRIBUTES_KEY_SYMBOL] = createAttributeBindings(element, attributes).mount(parentScope);
  6737. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, evaluateInitialProps(element, props), evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions))));
  6738. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  6739. this[TEMPLATE_KEY_SYMBOL] = this.template.createDOM(element).clone(); // link this object to the DOM node
  6740. bindDOMNodeToComponentObject(element, this); // add eventually the 'is' attribute
  6741. component.name && addCssHook(element, component.name); // define the root element
  6742. defineProperty(this, ROOT_KEY, element); // define the slots array
  6743. defineProperty(this, SLOTS_KEY, slots); // before mount lifecycle event
  6744. this[ON_BEFORE_MOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]); // mount the template
  6745. this[TEMPLATE_KEY_SYMBOL].mount(element, this, parentScope);
  6746. this[ON_MOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6747. return this;
  6748. },
  6749. update(state, parentScope) {
  6750. if (state === void 0) {
  6751. state = {};
  6752. }
  6753. if (parentScope) {
  6754. this[PARENT_KEY_SYMBOL] = parentScope;
  6755. this[ATTRIBUTES_KEY_SYMBOL].update(parentScope);
  6756. }
  6757. const newProps = evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions);
  6758. if (this[SHOULD_UPDATE_KEY](newProps, this[PROPS_KEY]) === false) return;
  6759. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, this[PROPS_KEY], newProps)));
  6760. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  6761. this[ON_BEFORE_UPDATE_KEY](this[PROPS_KEY], this[STATE_KEY]); // avoiding recursive updates
  6762. // see also https://github.com/riot/riot/issues/2895
  6763. if (!this[IS_COMPONENT_UPDATING]) {
  6764. this[IS_COMPONENT_UPDATING] = true;
  6765. this[TEMPLATE_KEY_SYMBOL].update(this, this[PARENT_KEY_SYMBOL]);
  6766. }
  6767. this[ON_UPDATED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6768. this[IS_COMPONENT_UPDATING] = false;
  6769. return this;
  6770. },
  6771. unmount(preserveRoot) {
  6772. this[ON_BEFORE_UNMOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6773. this[ATTRIBUTES_KEY_SYMBOL].unmount(); // if the preserveRoot is null the template html will be left untouched
  6774. // in that case the DOM cleanup will happen differently from a parent node
  6775. this[TEMPLATE_KEY_SYMBOL].unmount(this, this[PARENT_KEY_SYMBOL], preserveRoot === null ? null : !preserveRoot);
  6776. this[ON_UNMOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6777. return this;
  6778. }
  6779. })), Object.keys(component).filter(prop => isFunction(component[prop])));
  6780. }
  6781. /**
  6782. * Component initialization function starting from a DOM node
  6783. * @param {HTMLElement} element - element to upgrade
  6784. * @param {Object} initialProps - initial component properties
  6785. * @param {string} componentName - component id
  6786. * @returns {Object} a new component instance bound to a DOM node
  6787. */
  6788. function mountComponent(element, initialProps, componentName) {
  6789. const name = componentName || getName(element);
  6790. if (!COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component named "${name}" was never registered`);
  6791. const component = COMPONENTS_IMPLEMENTATION_MAP$1.get(name)({
  6792. props: initialProps
  6793. });
  6794. return component.mount(element);
  6795. }
  6796. /**
  6797. * Similar to compose but performs from left-to-right function composition.<br/>
  6798. * {@link https://30secondsofcode.org/function#composeright see also}
  6799. * @param {...[function]} fns) - list of unary function
  6800. * @returns {*} result of the computation
  6801. */
  6802. /**
  6803. * Performs right-to-left function composition.<br/>
  6804. * Use Array.prototype.reduce() to perform right-to-left function composition.<br/>
  6805. * The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
  6806. * {@link https://30secondsofcode.org/function#compose original source code}
  6807. * @param {...[function]} fns) - list of unary function
  6808. * @returns {*} result of the computation
  6809. */
  6810. function compose() {
  6811. for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6812. fns[_key2] = arguments[_key2];
  6813. }
  6814. return fns.reduce((f, g) => function () {
  6815. return f(g(...arguments));
  6816. });
  6817. }
  6818. const {
  6819. DOM_COMPONENT_INSTANCE_PROPERTY,
  6820. COMPONENTS_IMPLEMENTATION_MAP,
  6821. PLUGINS_SET
  6822. } = globals;
  6823. /**
  6824. * Riot public api
  6825. */
  6826. /**
  6827. * Register a custom tag by name
  6828. * @param {string} name - component name
  6829. * @param {Object} implementation - tag implementation
  6830. * @returns {Map} map containing all the components implementations
  6831. */
  6832. function register(name, _ref) {
  6833. let {
  6834. css,
  6835. template,
  6836. exports
  6837. } = _ref;
  6838. if (COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was already registered`);
  6839. COMPONENTS_IMPLEMENTATION_MAP.set(name, createComponent({
  6840. name,
  6841. css,
  6842. template,
  6843. exports
  6844. }));
  6845. return COMPONENTS_IMPLEMENTATION_MAP;
  6846. }
  6847. /**
  6848. * Unregister a riot web component
  6849. * @param {string} name - component name
  6850. * @returns {Map} map containing all the components implementations
  6851. */
  6852. function unregister(name) {
  6853. if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was never registered`);
  6854. COMPONENTS_IMPLEMENTATION_MAP.delete(name);
  6855. cssManager.remove(name);
  6856. return COMPONENTS_IMPLEMENTATION_MAP;
  6857. }
  6858. /**
  6859. * Mounting function that will work only for the components that were globally registered
  6860. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  6861. * @param {Object} initialProps - the initial component properties
  6862. * @param {string} name - optional component name
  6863. * @returns {Array} list of riot components
  6864. */
  6865. function mount(selector, initialProps, name) {
  6866. return $(selector).map(element => mountComponent(element, initialProps, name));
  6867. }
  6868. /**
  6869. * Sweet unmounting helper function for the DOM node mounted manually by the user
  6870. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  6871. * @param {boolean|null} keepRootElement - if true keep the root element
  6872. * @returns {Array} list of nodes unmounted
  6873. */
  6874. function unmount(selector, keepRootElement) {
  6875. return $(selector).map(element => {
  6876. if (element[DOM_COMPONENT_INSTANCE_PROPERTY]) {
  6877. element[DOM_COMPONENT_INSTANCE_PROPERTY].unmount(keepRootElement);
  6878. }
  6879. return element;
  6880. });
  6881. }
  6882. /**
  6883. * Define a riot plugin
  6884. * @param {Function} plugin - function that will receive all the components created
  6885. * @returns {Set} the set containing all the plugins installed
  6886. */
  6887. function install(plugin) {
  6888. if (!isFunction(plugin)) panic('Plugins must be of type function');
  6889. if (PLUGINS_SET.has(plugin)) panic('This plugin was already installed');
  6890. PLUGINS_SET.add(plugin);
  6891. return PLUGINS_SET;
  6892. }
  6893. /**
  6894. * Uninstall a riot plugin
  6895. * @param {Function} plugin - plugin previously installed
  6896. * @returns {Set} the set containing all the plugins installed
  6897. */
  6898. function uninstall(plugin) {
  6899. if (!PLUGINS_SET.has(plugin)) panic('This plugin was never installed');
  6900. PLUGINS_SET.delete(plugin);
  6901. return PLUGINS_SET;
  6902. }
  6903. /**
  6904. * Helper method to create component without relying on the registered ones
  6905. * @param {Object} implementation - component implementation
  6906. * @returns {Function} function that will allow you to mount a riot component on a DOM node
  6907. */
  6908. function component(implementation) {
  6909. return function (el, props, _temp) {
  6910. let {
  6911. slots,
  6912. attributes,
  6913. parentScope
  6914. } = _temp === void 0 ? {} : _temp;
  6915. return compose(c => c.mount(el, parentScope), c => c({
  6916. props,
  6917. slots,
  6918. attributes
  6919. }), createComponent)(implementation);
  6920. };
  6921. }
  6922. /**
  6923. * Lift a riot component Interface into a pure riot object
  6924. * @param {Function} func - RiotPureComponent factory function
  6925. * @returns {Function} the lifted original function received as argument
  6926. */
  6927. function pure(func) {
  6928. if (!isFunction(func)) panic('riot.pure accepts only arguments of type "function"');
  6929. func[IS_PURE_SYMBOL] = true;
  6930. return func;
  6931. }
  6932. /**
  6933. * no-op function needed to add the proper types to your component via typescript
  6934. * @param {Function|Object} component - component default export
  6935. * @returns {Function|Object} returns exactly what it has received
  6936. */
  6937. const withTypes = component => component;
  6938. /** @type {string} current riot version */
  6939. const version = 'v6.0.1'; // expose some internal stuff that might be used from external tools
  6940. const __ = {
  6941. cssManager,
  6942. DOMBindings,
  6943. createComponent,
  6944. defineComponent,
  6945. globals
  6946. };
  6947. /***/ }),
  6948. /***/ "./node_modules/validate.js/validate.js":
  6949. /*!**********************************************!*\
  6950. !*** ./node_modules/validate.js/validate.js ***!
  6951. \**********************************************/
  6952. /***/ (function(module, exports, __webpack_require__) {
  6953. /* module decorator */ module = __webpack_require__.nmd(module);
  6954. /*!
  6955. * validate.js 0.13.1
  6956. *
  6957. * (c) 2013-2019 Nicklas Ansman, 2013 Wrapp
  6958. * Validate.js may be freely distributed under the MIT license.
  6959. * For all details and documentation:
  6960. * http://validatejs.org/
  6961. */
  6962. (function(exports, module, define) {
  6963. "use strict";
  6964. // The main function that calls the validators specified by the constraints.
  6965. // The options are the following:
  6966. // - format (string) - An option that controls how the returned value is formatted
  6967. // * flat - Returns a flat array of just the error messages
  6968. // * grouped - Returns the messages grouped by attribute (default)
  6969. // * detailed - Returns an array of the raw validation data
  6970. // - fullMessages (boolean) - If `true` (default) the attribute name is prepended to the error.
  6971. //
  6972. // Please note that the options are also passed to each validator.
  6973. var validate = function(attributes, constraints, options) {
  6974. options = v.extend({}, v.options, options);
  6975. var results = v.runValidations(attributes, constraints, options)
  6976. , attr
  6977. , validator;
  6978. if (results.some(function(r) { return v.isPromise(r.error); })) {
  6979. throw new Error("Use validate.async if you want support for promises");
  6980. }
  6981. return validate.processValidationResults(results, options);
  6982. };
  6983. var v = validate;
  6984. // Copies over attributes from one or more sources to a single destination.
  6985. // Very much similar to underscore's extend.
  6986. // The first argument is the target object and the remaining arguments will be
  6987. // used as sources.
  6988. v.extend = function(obj) {
  6989. [].slice.call(arguments, 1).forEach(function(source) {
  6990. for (var attr in source) {
  6991. obj[attr] = source[attr];
  6992. }
  6993. });
  6994. return obj;
  6995. };
  6996. v.extend(validate, {
  6997. // This is the version of the library as a semver.
  6998. // The toString function will allow it to be coerced into a string
  6999. version: {
  7000. major: 0,
  7001. minor: 13,
  7002. patch: 1,
  7003. metadata: null,
  7004. toString: function() {
  7005. var version = v.format("%{major}.%{minor}.%{patch}", v.version);
  7006. if (!v.isEmpty(v.version.metadata)) {
  7007. version += "+" + v.version.metadata;
  7008. }
  7009. return version;
  7010. }
  7011. },
  7012. // Below is the dependencies that are used in validate.js
  7013. // The constructor of the Promise implementation.
  7014. // If you are using Q.js, RSVP or any other A+ compatible implementation
  7015. // override this attribute to be the constructor of that promise.
  7016. // Since jQuery promises aren't A+ compatible they won't work.
  7017. Promise: typeof Promise !== "undefined" ? Promise : /* istanbul ignore next */ null,
  7018. EMPTY_STRING_REGEXP: /^\s*$/,
  7019. // Runs the validators specified by the constraints object.
  7020. // Will return an array of the format:
  7021. // [{attribute: "<attribute name>", error: "<validation result>"}, ...]
  7022. runValidations: function(attributes, constraints, options) {
  7023. var results = []
  7024. , attr
  7025. , validatorName
  7026. , value
  7027. , validators
  7028. , validator
  7029. , validatorOptions
  7030. , error;
  7031. if (v.isDomElement(attributes) || v.isJqueryElement(attributes)) {
  7032. attributes = v.collectFormValues(attributes);
  7033. }
  7034. // Loops through each constraints, finds the correct validator and run it.
  7035. for (attr in constraints) {
  7036. value = v.getDeepObjectValue(attributes, attr);
  7037. // This allows the constraints for an attribute to be a function.
  7038. // The function will be called with the value, attribute name, the complete dict of
  7039. // attributes as well as the options and constraints passed in.
  7040. // This is useful when you want to have different
  7041. // validations depending on the attribute value.
  7042. validators = v.result(constraints[attr], value, attributes, attr, options, constraints);
  7043. for (validatorName in validators) {
  7044. validator = v.validators[validatorName];
  7045. if (!validator) {
  7046. error = v.format("Unknown validator %{name}", {name: validatorName});
  7047. throw new Error(error);
  7048. }
  7049. validatorOptions = validators[validatorName];
  7050. // This allows the options to be a function. The function will be
  7051. // called with the value, attribute name, the complete dict of
  7052. // attributes as well as the options and constraints passed in.
  7053. // This is useful when you want to have different
  7054. // validations depending on the attribute value.
  7055. validatorOptions = v.result(validatorOptions, value, attributes, attr, options, constraints);
  7056. if (!validatorOptions) {
  7057. continue;
  7058. }
  7059. results.push({
  7060. attribute: attr,
  7061. value: value,
  7062. validator: validatorName,
  7063. globalOptions: options,
  7064. attributes: attributes,
  7065. options: validatorOptions,
  7066. error: validator.call(validator,
  7067. value,
  7068. validatorOptions,
  7069. attr,
  7070. attributes,
  7071. options)
  7072. });
  7073. }
  7074. }
  7075. return results;
  7076. },
  7077. // Takes the output from runValidations and converts it to the correct
  7078. // output format.
  7079. processValidationResults: function(errors, options) {
  7080. errors = v.pruneEmptyErrors(errors, options);
  7081. errors = v.expandMultipleErrors(errors, options);
  7082. errors = v.convertErrorMessages(errors, options);
  7083. var format = options.format || "grouped";
  7084. if (typeof v.formatters[format] === 'function') {
  7085. errors = v.formatters[format](errors);
  7086. } else {
  7087. throw new Error(v.format("Unknown format %{format}", options));
  7088. }
  7089. return v.isEmpty(errors) ? undefined : errors;
  7090. },
  7091. // Runs the validations with support for promises.
  7092. // This function will return a promise that is settled when all the
  7093. // validation promises have been completed.
  7094. // It can be called even if no validations returned a promise.
  7095. async: function(attributes, constraints, options) {
  7096. options = v.extend({}, v.async.options, options);
  7097. var WrapErrors = options.wrapErrors || function(errors) {
  7098. return errors;
  7099. };
  7100. // Removes unknown attributes
  7101. if (options.cleanAttributes !== false) {
  7102. attributes = v.cleanAttributes(attributes, constraints);
  7103. }
  7104. var results = v.runValidations(attributes, constraints, options);
  7105. return new v.Promise(function(resolve, reject) {
  7106. v.waitForResults(results).then(function() {
  7107. var errors = v.processValidationResults(results, options);
  7108. if (errors) {
  7109. reject(new WrapErrors(errors, options, attributes, constraints));
  7110. } else {
  7111. resolve(attributes);
  7112. }
  7113. }, function(err) {
  7114. reject(err);
  7115. });
  7116. });
  7117. },
  7118. single: function(value, constraints, options) {
  7119. options = v.extend({}, v.single.options, options, {
  7120. format: "flat",
  7121. fullMessages: false
  7122. });
  7123. return v({single: value}, {single: constraints}, options);
  7124. },
  7125. // Returns a promise that is resolved when all promises in the results array
  7126. // are settled. The promise returned from this function is always resolved,
  7127. // never rejected.
  7128. // This function modifies the input argument, it replaces the promises
  7129. // with the value returned from the promise.
  7130. waitForResults: function(results) {
  7131. // Create a sequence of all the results starting with a resolved promise.
  7132. return results.reduce(function(memo, result) {
  7133. // If this result isn't a promise skip it in the sequence.
  7134. if (!v.isPromise(result.error)) {
  7135. return memo;
  7136. }
  7137. return memo.then(function() {
  7138. return result.error.then(function(error) {
  7139. result.error = error || null;
  7140. });
  7141. });
  7142. }, new v.Promise(function(r) { r(); })); // A resolved promise
  7143. },
  7144. // If the given argument is a call: function the and: function return the value
  7145. // otherwise just return the value. Additional arguments will be passed as
  7146. // arguments to the function.
  7147. // Example:
  7148. // ```
  7149. // result('foo') // 'foo'
  7150. // result(Math.max, 1, 2) // 2
  7151. // ```
  7152. result: function(value) {
  7153. var args = [].slice.call(arguments, 1);
  7154. if (typeof value === 'function') {
  7155. value = value.apply(null, args);
  7156. }
  7157. return value;
  7158. },
  7159. // Checks if the value is a number. This function does not consider NaN a
  7160. // number like many other `isNumber` functions do.
  7161. isNumber: function(value) {
  7162. return typeof value === 'number' && !isNaN(value);
  7163. },
  7164. // Returns false if the object is not a function
  7165. isFunction: function(value) {
  7166. return typeof value === 'function';
  7167. },
  7168. // A simple check to verify that the value is an integer. Uses `isNumber`
  7169. // and a simple modulo check.
  7170. isInteger: function(value) {
  7171. return v.isNumber(value) && value % 1 === 0;
  7172. },
  7173. // Checks if the value is a boolean
  7174. isBoolean: function(value) {
  7175. return typeof value === 'boolean';
  7176. },
  7177. // Uses the `Object` function to check if the given argument is an object.
  7178. isObject: function(obj) {
  7179. return obj === Object(obj);
  7180. },
  7181. // Simply checks if the object is an instance of a date
  7182. isDate: function(obj) {
  7183. return obj instanceof Date;
  7184. },
  7185. // Returns false if the object is `null` of `undefined`
  7186. isDefined: function(obj) {
  7187. return obj !== null && obj !== undefined;
  7188. },
  7189. // Checks if the given argument is a promise. Anything with a `then`
  7190. // function is considered a promise.
  7191. isPromise: function(p) {
  7192. return !!p && v.isFunction(p.then);
  7193. },
  7194. isJqueryElement: function(o) {
  7195. return o && v.isString(o.jquery);
  7196. },
  7197. isDomElement: function(o) {
  7198. if (!o) {
  7199. return false;
  7200. }
  7201. if (!o.querySelectorAll || !o.querySelector) {
  7202. return false;
  7203. }
  7204. if (v.isObject(document) && o === document) {
  7205. return true;
  7206. }
  7207. // http://stackoverflow.com/a/384380/699304
  7208. /* istanbul ignore else */
  7209. if (typeof HTMLElement === "object") {
  7210. return o instanceof HTMLElement;
  7211. } else {
  7212. return o &&
  7213. typeof o === "object" &&
  7214. o !== null &&
  7215. o.nodeType === 1 &&
  7216. typeof o.nodeName === "string";
  7217. }
  7218. },
  7219. isEmpty: function(value) {
  7220. var attr;
  7221. // Null and undefined are empty
  7222. if (!v.isDefined(value)) {
  7223. return true;
  7224. }
  7225. // functions are non empty
  7226. if (v.isFunction(value)) {
  7227. return false;
  7228. }
  7229. // Whitespace only strings are empty
  7230. if (v.isString(value)) {
  7231. return v.EMPTY_STRING_REGEXP.test(value);
  7232. }
  7233. // For arrays we use the length property
  7234. if (v.isArray(value)) {
  7235. return value.length === 0;
  7236. }
  7237. // Dates have no attributes but aren't empty
  7238. if (v.isDate(value)) {
  7239. return false;
  7240. }
  7241. // If we find at least one property we consider it non empty
  7242. if (v.isObject(value)) {
  7243. for (attr in value) {
  7244. return false;
  7245. }
  7246. return true;
  7247. }
  7248. return false;
  7249. },
  7250. // Formats the specified strings with the given values like so:
  7251. // ```
  7252. // format("Foo: %{foo}", {foo: "bar"}) // "Foo bar"
  7253. // ```
  7254. // If you want to write %{...} without having it replaced simply
  7255. // prefix it with % like this `Foo: %%{foo}` and it will be returned
  7256. // as `"Foo: %{foo}"`
  7257. format: v.extend(function(str, vals) {
  7258. if (!v.isString(str)) {
  7259. return str;
  7260. }
  7261. return str.replace(v.format.FORMAT_REGEXP, function(m0, m1, m2) {
  7262. if (m1 === '%') {
  7263. return "%{" + m2 + "}";
  7264. } else {
  7265. return String(vals[m2]);
  7266. }
  7267. });
  7268. }, {
  7269. // Finds %{key} style patterns in the given string
  7270. FORMAT_REGEXP: /(%?)%\{([^\}]+)\}/g
  7271. }),
  7272. // "Prettifies" the given string.
  7273. // Prettifying means replacing [.\_-] with spaces as well as splitting
  7274. // camel case words.
  7275. prettify: function(str) {
  7276. if (v.isNumber(str)) {
  7277. // If there are more than 2 decimals round it to two
  7278. if ((str * 100) % 1 === 0) {
  7279. return "" + str;
  7280. } else {
  7281. return parseFloat(Math.round(str * 100) / 100).toFixed(2);
  7282. }
  7283. }
  7284. if (v.isArray(str)) {
  7285. return str.map(function(s) { return v.prettify(s); }).join(", ");
  7286. }
  7287. if (v.isObject(str)) {
  7288. if (!v.isDefined(str.toString)) {
  7289. return JSON.stringify(str);
  7290. }
  7291. return str.toString();
  7292. }
  7293. // Ensure the string is actually a string
  7294. str = "" + str;
  7295. return str
  7296. // Splits keys separated by periods
  7297. .replace(/([^\s])\.([^\s])/g, '$1 $2')
  7298. // Removes backslashes
  7299. .replace(/\\+/g, '')
  7300. // Replaces - and - with space
  7301. .replace(/[_-]/g, ' ')
  7302. // Splits camel cased words
  7303. .replace(/([a-z])([A-Z])/g, function(m0, m1, m2) {
  7304. return "" + m1 + " " + m2.toLowerCase();
  7305. })
  7306. .toLowerCase();
  7307. },
  7308. stringifyValue: function(value, options) {
  7309. var prettify = options && options.prettify || v.prettify;
  7310. return prettify(value);
  7311. },
  7312. isString: function(value) {
  7313. return typeof value === 'string';
  7314. },
  7315. isArray: function(value) {
  7316. return {}.toString.call(value) === '[object Array]';
  7317. },
  7318. // Checks if the object is a hash, which is equivalent to an object that
  7319. // is neither an array nor a function.
  7320. isHash: function(value) {
  7321. return v.isObject(value) && !v.isArray(value) && !v.isFunction(value);
  7322. },
  7323. contains: function(obj, value) {
  7324. if (!v.isDefined(obj)) {
  7325. return false;
  7326. }
  7327. if (v.isArray(obj)) {
  7328. return obj.indexOf(value) !== -1;
  7329. }
  7330. return value in obj;
  7331. },
  7332. unique: function(array) {
  7333. if (!v.isArray(array)) {
  7334. return array;
  7335. }
  7336. return array.filter(function(el, index, array) {
  7337. return array.indexOf(el) == index;
  7338. });
  7339. },
  7340. forEachKeyInKeypath: function(object, keypath, callback) {
  7341. if (!v.isString(keypath)) {
  7342. return undefined;
  7343. }
  7344. var key = ""
  7345. , i
  7346. , escape = false;
  7347. for (i = 0; i < keypath.length; ++i) {
  7348. switch (keypath[i]) {
  7349. case '.':
  7350. if (escape) {
  7351. escape = false;
  7352. key += '.';
  7353. } else {
  7354. object = callback(object, key, false);
  7355. key = "";
  7356. }
  7357. break;
  7358. case '\\':
  7359. if (escape) {
  7360. escape = false;
  7361. key += '\\';
  7362. } else {
  7363. escape = true;
  7364. }
  7365. break;
  7366. default:
  7367. escape = false;
  7368. key += keypath[i];
  7369. break;
  7370. }
  7371. }
  7372. return callback(object, key, true);
  7373. },
  7374. getDeepObjectValue: function(obj, keypath) {
  7375. if (!v.isObject(obj)) {
  7376. return undefined;
  7377. }
  7378. return v.forEachKeyInKeypath(obj, keypath, function(obj, key) {
  7379. if (v.isObject(obj)) {
  7380. return obj[key];
  7381. }
  7382. });
  7383. },
  7384. // This returns an object with all the values of the form.
  7385. // It uses the input name as key and the value as value
  7386. // So for example this:
  7387. // <input type="text" name="email" value="foo@bar.com" />
  7388. // would return:
  7389. // {email: "foo@bar.com"}
  7390. collectFormValues: function(form, options) {
  7391. var values = {}
  7392. , i
  7393. , j
  7394. , input
  7395. , inputs
  7396. , option
  7397. , value;
  7398. if (v.isJqueryElement(form)) {
  7399. form = form[0];
  7400. }
  7401. if (!form) {
  7402. return values;
  7403. }
  7404. options = options || {};
  7405. inputs = form.querySelectorAll("input[name], textarea[name]");
  7406. for (i = 0; i < inputs.length; ++i) {
  7407. input = inputs.item(i);
  7408. if (v.isDefined(input.getAttribute("data-ignored"))) {
  7409. continue;
  7410. }
  7411. var name = input.name.replace(/\./g, "\\\\.");
  7412. value = v.sanitizeFormValue(input.value, options);
  7413. if (input.type === "number") {
  7414. value = value ? +value : null;
  7415. } else if (input.type === "checkbox") {
  7416. if (input.attributes.value) {
  7417. if (!input.checked) {
  7418. value = values[name] || null;
  7419. }
  7420. } else {
  7421. value = input.checked;
  7422. }
  7423. } else if (input.type === "radio") {
  7424. if (!input.checked) {
  7425. value = values[name] || null;
  7426. }
  7427. }
  7428. values[name] = value;
  7429. }
  7430. inputs = form.querySelectorAll("select[name]");
  7431. for (i = 0; i < inputs.length; ++i) {
  7432. input = inputs.item(i);
  7433. if (v.isDefined(input.getAttribute("data-ignored"))) {
  7434. continue;
  7435. }
  7436. if (input.multiple) {
  7437. value = [];
  7438. for (j in input.options) {
  7439. option = input.options[j];
  7440. if (option && option.selected) {
  7441. value.push(v.sanitizeFormValue(option.value, options));
  7442. }
  7443. }
  7444. } else {
  7445. var _val = typeof input.options[input.selectedIndex] !== 'undefined' ? input.options[input.selectedIndex].value : /* istanbul ignore next */ '';
  7446. value = v.sanitizeFormValue(_val, options);
  7447. }
  7448. values[input.name] = value;
  7449. }
  7450. return values;
  7451. },
  7452. sanitizeFormValue: function(value, options) {
  7453. if (options.trim && v.isString(value)) {
  7454. value = value.trim();
  7455. }
  7456. if (options.nullify !== false && value === "") {
  7457. return null;
  7458. }
  7459. return value;
  7460. },
  7461. capitalize: function(str) {
  7462. if (!v.isString(str)) {
  7463. return str;
  7464. }
  7465. return str[0].toUpperCase() + str.slice(1);
  7466. },
  7467. // Remove all errors who's error attribute is empty (null or undefined)
  7468. pruneEmptyErrors: function(errors) {
  7469. return errors.filter(function(error) {
  7470. return !v.isEmpty(error.error);
  7471. });
  7472. },
  7473. // In
  7474. // [{error: ["err1", "err2"], ...}]
  7475. // Out
  7476. // [{error: "err1", ...}, {error: "err2", ...}]
  7477. //
  7478. // All attributes in an error with multiple messages are duplicated
  7479. // when expanding the errors.
  7480. expandMultipleErrors: function(errors) {
  7481. var ret = [];
  7482. errors.forEach(function(error) {
  7483. // Removes errors without a message
  7484. if (v.isArray(error.error)) {
  7485. error.error.forEach(function(msg) {
  7486. ret.push(v.extend({}, error, {error: msg}));
  7487. });
  7488. } else {
  7489. ret.push(error);
  7490. }
  7491. });
  7492. return ret;
  7493. },
  7494. // Converts the error mesages by prepending the attribute name unless the
  7495. // message is prefixed by ^
  7496. convertErrorMessages: function(errors, options) {
  7497. options = options || {};
  7498. var ret = []
  7499. , prettify = options.prettify || v.prettify;
  7500. errors.forEach(function(errorInfo) {
  7501. var error = v.result(errorInfo.error,
  7502. errorInfo.value,
  7503. errorInfo.attribute,
  7504. errorInfo.options,
  7505. errorInfo.attributes,
  7506. errorInfo.globalOptions);
  7507. if (!v.isString(error)) {
  7508. ret.push(errorInfo);
  7509. return;
  7510. }
  7511. if (error[0] === '^') {
  7512. error = error.slice(1);
  7513. } else if (options.fullMessages !== false) {
  7514. error = v.capitalize(prettify(errorInfo.attribute)) + " " + error;
  7515. }
  7516. error = error.replace(/\\\^/g, "^");
  7517. error = v.format(error, {
  7518. value: v.stringifyValue(errorInfo.value, options)
  7519. });
  7520. ret.push(v.extend({}, errorInfo, {error: error}));
  7521. });
  7522. return ret;
  7523. },
  7524. // In:
  7525. // [{attribute: "<attributeName>", ...}]
  7526. // Out:
  7527. // {"<attributeName>": [{attribute: "<attributeName>", ...}]}
  7528. groupErrorsByAttribute: function(errors) {
  7529. var ret = {};
  7530. errors.forEach(function(error) {
  7531. var list = ret[error.attribute];
  7532. if (list) {
  7533. list.push(error);
  7534. } else {
  7535. ret[error.attribute] = [error];
  7536. }
  7537. });
  7538. return ret;
  7539. },
  7540. // In:
  7541. // [{error: "<message 1>", ...}, {error: "<message 2>", ...}]
  7542. // Out:
  7543. // ["<message 1>", "<message 2>"]
  7544. flattenErrorsToArray: function(errors) {
  7545. return errors
  7546. .map(function(error) { return error.error; })
  7547. .filter(function(value, index, self) {
  7548. return self.indexOf(value) === index;
  7549. });
  7550. },
  7551. cleanAttributes: function(attributes, whitelist) {
  7552. function whitelistCreator(obj, key, last) {
  7553. if (v.isObject(obj[key])) {
  7554. return obj[key];
  7555. }
  7556. return (obj[key] = last ? true : {});
  7557. }
  7558. function buildObjectWhitelist(whitelist) {
  7559. var ow = {}
  7560. , lastObject
  7561. , attr;
  7562. for (attr in whitelist) {
  7563. if (!whitelist[attr]) {
  7564. continue;
  7565. }
  7566. v.forEachKeyInKeypath(ow, attr, whitelistCreator);
  7567. }
  7568. return ow;
  7569. }
  7570. function cleanRecursive(attributes, whitelist) {
  7571. if (!v.isObject(attributes)) {
  7572. return attributes;
  7573. }
  7574. var ret = v.extend({}, attributes)
  7575. , w
  7576. , attribute;
  7577. for (attribute in attributes) {
  7578. w = whitelist[attribute];
  7579. if (v.isObject(w)) {
  7580. ret[attribute] = cleanRecursive(ret[attribute], w);
  7581. } else if (!w) {
  7582. delete ret[attribute];
  7583. }
  7584. }
  7585. return ret;
  7586. }
  7587. if (!v.isObject(whitelist) || !v.isObject(attributes)) {
  7588. return {};
  7589. }
  7590. whitelist = buildObjectWhitelist(whitelist);
  7591. return cleanRecursive(attributes, whitelist);
  7592. },
  7593. exposeModule: function(validate, root, exports, module, define) {
  7594. if (exports) {
  7595. if (module && module.exports) {
  7596. exports = module.exports = validate;
  7597. }
  7598. exports.validate = validate;
  7599. } else {
  7600. root.validate = validate;
  7601. if (validate.isFunction(define) && define.amd) {
  7602. define([], function () { return validate; });
  7603. }
  7604. }
  7605. },
  7606. warn: function(msg) {
  7607. if (typeof console !== "undefined" && console.warn) {
  7608. console.warn("[validate.js] " + msg);
  7609. }
  7610. },
  7611. error: function(msg) {
  7612. if (typeof console !== "undefined" && console.error) {
  7613. console.error("[validate.js] " + msg);
  7614. }
  7615. }
  7616. });
  7617. validate.validators = {
  7618. // Presence validates that the value isn't empty
  7619. presence: function(value, options) {
  7620. options = v.extend({}, this.options, options);
  7621. if (options.allowEmpty !== false ? !v.isDefined(value) : v.isEmpty(value)) {
  7622. return options.message || this.message || "can't be blank";
  7623. }
  7624. },
  7625. length: function(value, options, attribute) {
  7626. // Empty values are allowed
  7627. if (!v.isDefined(value)) {
  7628. return;
  7629. }
  7630. options = v.extend({}, this.options, options);
  7631. var is = options.is
  7632. , maximum = options.maximum
  7633. , minimum = options.minimum
  7634. , tokenizer = options.tokenizer || function(val) { return val; }
  7635. , err
  7636. , errors = [];
  7637. value = tokenizer(value);
  7638. var length = value.length;
  7639. if(!v.isNumber(length)) {
  7640. return options.message || this.notValid || "has an incorrect length";
  7641. }
  7642. // Is checks
  7643. if (v.isNumber(is) && length !== is) {
  7644. err = options.wrongLength ||
  7645. this.wrongLength ||
  7646. "is the wrong length (should be %{count} characters)";
  7647. errors.push(v.format(err, {count: is}));
  7648. }
  7649. if (v.isNumber(minimum) && length < minimum) {
  7650. err = options.tooShort ||
  7651. this.tooShort ||
  7652. "is too short (minimum is %{count} characters)";
  7653. errors.push(v.format(err, {count: minimum}));
  7654. }
  7655. if (v.isNumber(maximum) && length > maximum) {
  7656. err = options.tooLong ||
  7657. this.tooLong ||
  7658. "is too long (maximum is %{count} characters)";
  7659. errors.push(v.format(err, {count: maximum}));
  7660. }
  7661. if (errors.length > 0) {
  7662. return options.message || errors;
  7663. }
  7664. },
  7665. numericality: function(value, options, attribute, attributes, globalOptions) {
  7666. // Empty values are fine
  7667. if (!v.isDefined(value)) {
  7668. return;
  7669. }
  7670. options = v.extend({}, this.options, options);
  7671. var errors = []
  7672. , name
  7673. , count
  7674. , checks = {
  7675. greaterThan: function(v, c) { return v > c; },
  7676. greaterThanOrEqualTo: function(v, c) { return v >= c; },
  7677. equalTo: function(v, c) { return v === c; },
  7678. lessThan: function(v, c) { return v < c; },
  7679. lessThanOrEqualTo: function(v, c) { return v <= c; },
  7680. divisibleBy: function(v, c) { return v % c === 0; }
  7681. }
  7682. , prettify = options.prettify ||
  7683. (globalOptions && globalOptions.prettify) ||
  7684. v.prettify;
  7685. // Strict will check that it is a valid looking number
  7686. if (v.isString(value) && options.strict) {
  7687. var pattern = "^-?(0|[1-9]\\d*)";
  7688. if (!options.onlyInteger) {
  7689. pattern += "(\\.\\d+)?";
  7690. }
  7691. pattern += "$";
  7692. if (!(new RegExp(pattern).test(value))) {
  7693. return options.message ||
  7694. options.notValid ||
  7695. this.notValid ||
  7696. this.message ||
  7697. "must be a valid number";
  7698. }
  7699. }
  7700. // Coerce the value to a number unless we're being strict.
  7701. if (options.noStrings !== true && v.isString(value) && !v.isEmpty(value)) {
  7702. value = +value;
  7703. }
  7704. // If it's not a number we shouldn't continue since it will compare it.
  7705. if (!v.isNumber(value)) {
  7706. return options.message ||
  7707. options.notValid ||
  7708. this.notValid ||
  7709. this.message ||
  7710. "is not a number";
  7711. }
  7712. // Same logic as above, sort of. Don't bother with comparisons if this
  7713. // doesn't pass.
  7714. if (options.onlyInteger && !v.isInteger(value)) {
  7715. return options.message ||
  7716. options.notInteger ||
  7717. this.notInteger ||
  7718. this.message ||
  7719. "must be an integer";
  7720. }
  7721. for (name in checks) {
  7722. count = options[name];
  7723. if (v.isNumber(count) && !checks[name](value, count)) {
  7724. // This picks the default message if specified
  7725. // For example the greaterThan check uses the message from
  7726. // this.notGreaterThan so we capitalize the name and prepend "not"
  7727. var key = "not" + v.capitalize(name);
  7728. var msg = options[key] ||
  7729. this[key] ||
  7730. this.message ||
  7731. "must be %{type} %{count}";
  7732. errors.push(v.format(msg, {
  7733. count: count,
  7734. type: prettify(name)
  7735. }));
  7736. }
  7737. }
  7738. if (options.odd && value % 2 !== 1) {
  7739. errors.push(options.notOdd ||
  7740. this.notOdd ||
  7741. this.message ||
  7742. "must be odd");
  7743. }
  7744. if (options.even && value % 2 !== 0) {
  7745. errors.push(options.notEven ||
  7746. this.notEven ||
  7747. this.message ||
  7748. "must be even");
  7749. }
  7750. if (errors.length) {
  7751. return options.message || errors;
  7752. }
  7753. },
  7754. datetime: v.extend(function(value, options) {
  7755. if (!v.isFunction(this.parse) || !v.isFunction(this.format)) {
  7756. throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");
  7757. }
  7758. // Empty values are fine
  7759. if (!v.isDefined(value)) {
  7760. return;
  7761. }
  7762. options = v.extend({}, this.options, options);
  7763. var err
  7764. , errors = []
  7765. , earliest = options.earliest ? this.parse(options.earliest, options) : NaN
  7766. , latest = options.latest ? this.parse(options.latest, options) : NaN;
  7767. value = this.parse(value, options);
  7768. // 86400000 is the number of milliseconds in a day, this is used to remove
  7769. // the time from the date
  7770. if (isNaN(value) || options.dateOnly && value % 86400000 !== 0) {
  7771. err = options.notValid ||
  7772. options.message ||
  7773. this.notValid ||
  7774. "must be a valid date";
  7775. return v.format(err, {value: arguments[0]});
  7776. }
  7777. if (!isNaN(earliest) && value < earliest) {
  7778. err = options.tooEarly ||
  7779. options.message ||
  7780. this.tooEarly ||
  7781. "must be no earlier than %{date}";
  7782. err = v.format(err, {
  7783. value: this.format(value, options),
  7784. date: this.format(earliest, options)
  7785. });
  7786. errors.push(err);
  7787. }
  7788. if (!isNaN(latest) && value > latest) {
  7789. err = options.tooLate ||
  7790. options.message ||
  7791. this.tooLate ||
  7792. "must be no later than %{date}";
  7793. err = v.format(err, {
  7794. date: this.format(latest, options),
  7795. value: this.format(value, options)
  7796. });
  7797. errors.push(err);
  7798. }
  7799. if (errors.length) {
  7800. return v.unique(errors);
  7801. }
  7802. }, {
  7803. parse: null,
  7804. format: null
  7805. }),
  7806. date: function(value, options) {
  7807. options = v.extend({}, options, {dateOnly: true});
  7808. return v.validators.datetime.call(v.validators.datetime, value, options);
  7809. },
  7810. format: function(value, options) {
  7811. if (v.isString(options) || (options instanceof RegExp)) {
  7812. options = {pattern: options};
  7813. }
  7814. options = v.extend({}, this.options, options);
  7815. var message = options.message || this.message || "is invalid"
  7816. , pattern = options.pattern
  7817. , match;
  7818. // Empty values are allowed
  7819. if (!v.isDefined(value)) {
  7820. return;
  7821. }
  7822. if (!v.isString(value)) {
  7823. return message;
  7824. }
  7825. if (v.isString(pattern)) {
  7826. pattern = new RegExp(options.pattern, options.flags);
  7827. }
  7828. match = pattern.exec(value);
  7829. if (!match || match[0].length != value.length) {
  7830. return message;
  7831. }
  7832. },
  7833. inclusion: function(value, options) {
  7834. // Empty values are fine
  7835. if (!v.isDefined(value)) {
  7836. return;
  7837. }
  7838. if (v.isArray(options)) {
  7839. options = {within: options};
  7840. }
  7841. options = v.extend({}, this.options, options);
  7842. if (v.contains(options.within, value)) {
  7843. return;
  7844. }
  7845. var message = options.message ||
  7846. this.message ||
  7847. "^%{value} is not included in the list";
  7848. return v.format(message, {value: value});
  7849. },
  7850. exclusion: function(value, options) {
  7851. // Empty values are fine
  7852. if (!v.isDefined(value)) {
  7853. return;
  7854. }
  7855. if (v.isArray(options)) {
  7856. options = {within: options};
  7857. }
  7858. options = v.extend({}, this.options, options);
  7859. if (!v.contains(options.within, value)) {
  7860. return;
  7861. }
  7862. var message = options.message || this.message || "^%{value} is restricted";
  7863. if (v.isString(options.within[value])) {
  7864. value = options.within[value];
  7865. }
  7866. return v.format(message, {value: value});
  7867. },
  7868. email: v.extend(function(value, options) {
  7869. options = v.extend({}, this.options, options);
  7870. var message = options.message || this.message || "is not a valid email";
  7871. // Empty values are fine
  7872. if (!v.isDefined(value)) {
  7873. return;
  7874. }
  7875. if (!v.isString(value)) {
  7876. return message;
  7877. }
  7878. if (!this.PATTERN.exec(value)) {
  7879. return message;
  7880. }
  7881. }, {
  7882. PATTERN: /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i
  7883. }),
  7884. equality: function(value, options, attribute, attributes, globalOptions) {
  7885. if (!v.isDefined(value)) {
  7886. return;
  7887. }
  7888. if (v.isString(options)) {
  7889. options = {attribute: options};
  7890. }
  7891. options = v.extend({}, this.options, options);
  7892. var message = options.message ||
  7893. this.message ||
  7894. "is not equal to %{attribute}";
  7895. if (v.isEmpty(options.attribute) || !v.isString(options.attribute)) {
  7896. throw new Error("The attribute must be a non empty string");
  7897. }
  7898. var otherValue = v.getDeepObjectValue(attributes, options.attribute)
  7899. , comparator = options.comparator || function(v1, v2) {
  7900. return v1 === v2;
  7901. }
  7902. , prettify = options.prettify ||
  7903. (globalOptions && globalOptions.prettify) ||
  7904. v.prettify;
  7905. if (!comparator(value, otherValue, options, attribute, attributes)) {
  7906. return v.format(message, {attribute: prettify(options.attribute)});
  7907. }
  7908. },
  7909. // A URL validator that is used to validate URLs with the ability to
  7910. // restrict schemes and some domains.
  7911. url: function(value, options) {
  7912. if (!v.isDefined(value)) {
  7913. return;
  7914. }
  7915. options = v.extend({}, this.options, options);
  7916. var message = options.message || this.message || "is not a valid url"
  7917. , schemes = options.schemes || this.schemes || ['http', 'https']
  7918. , allowLocal = options.allowLocal || this.allowLocal || false
  7919. , allowDataUrl = options.allowDataUrl || this.allowDataUrl || false;
  7920. if (!v.isString(value)) {
  7921. return message;
  7922. }
  7923. // https://gist.github.com/dperini/729294
  7924. var regex =
  7925. "^" +
  7926. // protocol identifier
  7927. "(?:(?:" + schemes.join("|") + ")://)" +
  7928. // user:pass authentication
  7929. "(?:\\S+(?::\\S*)?@)?" +
  7930. "(?:";
  7931. var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
  7932. if (allowLocal) {
  7933. tld += "?";
  7934. } else {
  7935. regex +=
  7936. // IP address exclusion
  7937. // private & local networks
  7938. "(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
  7939. "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
  7940. "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})";
  7941. }
  7942. regex +=
  7943. // IP address dotted notation octets
  7944. // excludes loopback network 0.0.0.0
  7945. // excludes reserved space >= 224.0.0.0
  7946. // excludes network & broacast addresses
  7947. // (first & last IP address of each class)
  7948. "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
  7949. "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
  7950. "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
  7951. "|" +
  7952. // host name
  7953. "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" +
  7954. // domain name
  7955. "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
  7956. tld +
  7957. ")" +
  7958. // port number
  7959. "(?::\\d{2,5})?" +
  7960. // resource path
  7961. "(?:[/?#]\\S*)?" +
  7962. "$";
  7963. if (allowDataUrl) {
  7964. // RFC 2397
  7965. var mediaType = "\\w+\\/[-+.\\w]+(?:;[\\w=]+)*";
  7966. var urlchar = "[A-Za-z0-9-_.!~\\*'();\\/?:@&=+$,%]*";
  7967. var dataurl = "data:(?:"+mediaType+")?(?:;base64)?,"+urlchar;
  7968. regex = "(?:"+regex+")|(?:^"+dataurl+"$)";
  7969. }
  7970. var PATTERN = new RegExp(regex, 'i');
  7971. if (!PATTERN.exec(value)) {
  7972. return message;
  7973. }
  7974. },
  7975. type: v.extend(function(value, originalOptions, attribute, attributes, globalOptions) {
  7976. if (v.isString(originalOptions)) {
  7977. originalOptions = {type: originalOptions};
  7978. }
  7979. if (!v.isDefined(value)) {
  7980. return;
  7981. }
  7982. var options = v.extend({}, this.options, originalOptions);
  7983. var type = options.type;
  7984. if (!v.isDefined(type)) {
  7985. throw new Error("No type was specified");
  7986. }
  7987. var check;
  7988. if (v.isFunction(type)) {
  7989. check = type;
  7990. } else {
  7991. check = this.types[type];
  7992. }
  7993. if (!v.isFunction(check)) {
  7994. throw new Error("validate.validators.type.types." + type + " must be a function.");
  7995. }
  7996. if (!check(value, options, attribute, attributes, globalOptions)) {
  7997. var message = originalOptions.message ||
  7998. this.messages[type] ||
  7999. this.message ||
  8000. options.message ||
  8001. (v.isFunction(type) ? "must be of the correct type" : "must be of type %{type}");
  8002. if (v.isFunction(message)) {
  8003. message = message(value, originalOptions, attribute, attributes, globalOptions);
  8004. }
  8005. return v.format(message, {attribute: v.prettify(attribute), type: type});
  8006. }
  8007. }, {
  8008. types: {
  8009. object: function(value) {
  8010. return v.isObject(value) && !v.isArray(value);
  8011. },
  8012. array: v.isArray,
  8013. integer: v.isInteger,
  8014. number: v.isNumber,
  8015. string: v.isString,
  8016. date: v.isDate,
  8017. boolean: v.isBoolean
  8018. },
  8019. messages: {}
  8020. })
  8021. };
  8022. validate.formatters = {
  8023. detailed: function(errors) {return errors;},
  8024. flat: v.flattenErrorsToArray,
  8025. grouped: function(errors) {
  8026. var attr;
  8027. errors = v.groupErrorsByAttribute(errors);
  8028. for (attr in errors) {
  8029. errors[attr] = v.flattenErrorsToArray(errors[attr]);
  8030. }
  8031. return errors;
  8032. },
  8033. constraint: function(errors) {
  8034. var attr;
  8035. errors = v.groupErrorsByAttribute(errors);
  8036. for (attr in errors) {
  8037. errors[attr] = errors[attr].map(function(result) {
  8038. return result.validator;
  8039. }).sort();
  8040. }
  8041. return errors;
  8042. }
  8043. };
  8044. validate.exposeModule(validate, this, exports, module, __webpack_require__.amdD);
  8045. }).call(this,
  8046. true ? /* istanbul ignore next */ exports : 0,
  8047. true ? /* istanbul ignore next */ module : 0,
  8048. __webpack_require__.amdD);
  8049. /***/ })
  8050. /******/ });
  8051. /************************************************************************/
  8052. /******/ // The module cache
  8053. /******/ var __webpack_module_cache__ = {};
  8054. /******/
  8055. /******/ // The require function
  8056. /******/ function __webpack_require__(moduleId) {
  8057. /******/ // Check if module is in cache
  8058. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  8059. /******/ if (cachedModule !== undefined) {
  8060. /******/ return cachedModule.exports;
  8061. /******/ }
  8062. /******/ // Create a new module (and put it into the cache)
  8063. /******/ var module = __webpack_module_cache__[moduleId] = {
  8064. /******/ id: moduleId,
  8065. /******/ loaded: false,
  8066. /******/ exports: {}
  8067. /******/ };
  8068. /******/
  8069. /******/ // Execute the module function
  8070. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  8071. /******/
  8072. /******/ // Flag the module as loaded
  8073. /******/ module.loaded = true;
  8074. /******/
  8075. /******/ // Return the exports of the module
  8076. /******/ return module.exports;
  8077. /******/ }
  8078. /******/
  8079. /************************************************************************/
  8080. /******/ /* webpack/runtime/amd define */
  8081. /******/ (() => {
  8082. /******/ __webpack_require__.amdD = function () {
  8083. /******/ throw new Error('define cannot be used indirect');
  8084. /******/ };
  8085. /******/ })();
  8086. /******/
  8087. /******/ /* webpack/runtime/compat get default export */
  8088. /******/ (() => {
  8089. /******/ // getDefaultExport function for compatibility with non-harmony modules
  8090. /******/ __webpack_require__.n = (module) => {
  8091. /******/ var getter = module && module.__esModule ?
  8092. /******/ () => (module['default']) :
  8093. /******/ () => (module);
  8094. /******/ __webpack_require__.d(getter, { a: getter });
  8095. /******/ return getter;
  8096. /******/ };
  8097. /******/ })();
  8098. /******/
  8099. /******/ /* webpack/runtime/define property getters */
  8100. /******/ (() => {
  8101. /******/ // define getter functions for harmony exports
  8102. /******/ __webpack_require__.d = (exports, definition) => {
  8103. /******/ for(var key in definition) {
  8104. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  8105. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  8106. /******/ }
  8107. /******/ }
  8108. /******/ };
  8109. /******/ })();
  8110. /******/
  8111. /******/ /* webpack/runtime/global */
  8112. /******/ (() => {
  8113. /******/ __webpack_require__.g = (function() {
  8114. /******/ if (typeof globalThis === 'object') return globalThis;
  8115. /******/ try {
  8116. /******/ return this || new Function('return this')();
  8117. /******/ } catch (e) {
  8118. /******/ if (typeof window === 'object') return window;
  8119. /******/ }
  8120. /******/ })();
  8121. /******/ })();
  8122. /******/
  8123. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  8124. /******/ (() => {
  8125. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  8126. /******/ })();
  8127. /******/
  8128. /******/ /* webpack/runtime/make namespace object */
  8129. /******/ (() => {
  8130. /******/ // define __esModule on exports
  8131. /******/ __webpack_require__.r = (exports) => {
  8132. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  8133. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  8134. /******/ }
  8135. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  8136. /******/ };
  8137. /******/ })();
  8138. /******/
  8139. /******/ /* webpack/runtime/node module decorator */
  8140. /******/ (() => {
  8141. /******/ __webpack_require__.nmd = (module) => {
  8142. /******/ module.paths = [];
  8143. /******/ if (!module.children) module.children = [];
  8144. /******/ return module;
  8145. /******/ };
  8146. /******/ })();
  8147. /******/
  8148. /************************************************************************/
  8149. var __webpack_exports__ = {};
  8150. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  8151. (() => {
  8152. "use strict";
  8153. /*!*******************************!*\
  8154. !*** ./resources/js/users.js ***!
  8155. \*******************************/
  8156. __webpack_require__.r(__webpack_exports__);
  8157. /* harmony import */ var riot__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! riot */ "./node_modules/riot/riot.esm.js");
  8158. /* harmony import */ var _components_users_riot__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/users.riot */ "./resources/js/components/users.riot");
  8159. /* harmony import */ var _components_users_form_riot__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/users/form.riot */ "./resources/js/components/users/form.riot");
  8160. /* harmony import */ var _components_sidebar_button_riot__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/sidebar-button.riot */ "./resources/js/components/sidebar-button.riot");
  8161. // register components for buckets
  8162. riot__WEBPACK_IMPORTED_MODULE_3__.register('app-users', _components_users_riot__WEBPACK_IMPORTED_MODULE_0__.default);
  8163. riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-users');
  8164. riot__WEBPACK_IMPORTED_MODULE_3__.register('app-users-form', _components_users_form_riot__WEBPACK_IMPORTED_MODULE_1__.default);
  8165. riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-users-form');
  8166. riot__WEBPACK_IMPORTED_MODULE_3__.register('app-sidebar-button', _components_sidebar_button_riot__WEBPACK_IMPORTED_MODULE_2__.default);
  8167. riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-sidebar-button');
  8168. })();
  8169. /******/ })()
  8170. ;