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.

10232 lines
295 KiB

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