@mjhls/mjh-framework 1.0.296 → 1.0.297

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/{ADInfeed-824fcfb6.js → ADInfeed-6b94763a.js} +1 -1
  3. package/dist/cjs/{AdSlot-405b39eb.js → AdSlot-29aee917.js} +124 -62
  4. package/dist/cjs/DeckContent.js +4 -4
  5. package/dist/cjs/DeckQueue.js +1 -1
  6. package/dist/cjs/{Dfp-f75c65fd.js → Dfp-f871551d.js} +1 -1
  7. package/dist/cjs/{Figure-0681dd7d.js → Figure-434da9bb.js} +1 -1
  8. package/dist/cjs/{GridContent-929798bf.js → GridContent-888d2bfa.js} +3 -3
  9. package/dist/cjs/GridContent.js +5 -5
  10. package/dist/cjs/MasterDeck.js +1 -1
  11. package/dist/cjs/{Normal-d3a56ac1.js → Normal-c3f4eec3.js} +114 -76
  12. package/dist/cjs/QueueDeckExpanded.js +3 -3
  13. package/dist/cjs/TemplateNormal.js +3 -3
  14. package/dist/cjs/{Ustream-85b14a8d.js → Ustream-3a3c56b8.js} +1 -1
  15. package/dist/cjs/Ustream.js +2 -2
  16. package/dist/cjs/VideoSeriesListing.js +1 -1
  17. package/dist/cjs/index.js +3990 -11
  18. package/dist/cjs/{inherits-dd435947.js → inherits-663e8f74.js} +1 -0
  19. package/dist/cjs/{slicedToArray-e38fb29d.js → slicedToArray-bed4d943.js} +2 -1
  20. package/dist/esm/{ADInfeed-a1d8cb44.js → ADInfeed-94f767ec.js} +1 -1
  21. package/dist/esm/{AdSlot-b4f04c96.js → AdSlot-3d2ecc87.js} +125 -63
  22. package/dist/esm/DeckContent.js +4 -4
  23. package/dist/esm/DeckQueue.js +1 -1
  24. package/dist/esm/{Dfp-ea8d4531.js → Dfp-d2d43384.js} +1 -1
  25. package/dist/esm/{Figure-cff72982.js → Figure-d0f95cc0.js} +1 -1
  26. package/dist/esm/{GridContent-862176ac.js → GridContent-ce2f615a.js} +3 -3
  27. package/dist/esm/GridContent.js +5 -5
  28. package/dist/esm/MasterDeck.js +1 -1
  29. package/dist/esm/{Normal-4180d06d.js → Normal-0bf73d75.js} +114 -76
  30. package/dist/esm/QueueDeckExpanded.js +3 -3
  31. package/dist/esm/TemplateNormal.js +3 -3
  32. package/dist/esm/{Ustream-d51b9b11.js → Ustream-c153a835.js} +1 -1
  33. package/dist/esm/Ustream.js +2 -2
  34. package/dist/esm/VideoSeriesListing.js +1 -1
  35. package/dist/esm/index.js +3994 -16
  36. package/dist/esm/{inherits-2a854891.js → inherits-4cae443b.js} +1 -1
  37. package/dist/esm/{slicedToArray-d0a9593a.js → slicedToArray-d1db3163.js} +2 -2
  38. package/package.json +2 -1
package/dist/esm/index.js CHANGED
@@ -6,7 +6,7 @@ import { m as main_36, a as main_16, b as main_35 } from './main-155ec04f.js';
6
6
  import { _ as _toConsumableArray, a as _Array$from } from './toConsumableArray-eb308ede.js';
7
7
  import './core.get-iterator-method-31c1fb1a.js';
8
8
  import { _ as _extends$2 } from './extends-dbbe308d.js';
9
- import { _ as _objectSap, a as _inherits$1, b as _classCallCheck$1, c as _possibleConstructorReturn$1, d as _Object$getPrototypeOf, e as _createClass$1 } from './inherits-2a854891.js';
9
+ import { _ as _objectSap, a as _inherits$1, b as _classCallCheck$1, c as _possibleConstructorReturn$1, d as _Object$getPrototypeOf, e as _createClass$1, f as defineProperty$2 } from './inherits-4cae443b.js';
10
10
  import React__default, { useState, useRef, useEffect } from 'react';
11
11
  import PropTypes from 'prop-types';
12
12
  import Container from 'react-bootstrap/Container';
@@ -20,14 +20,14 @@ import 'react-dom';
20
20
  import { i as imageUrlBuilder } from './index-3849e3fe.js';
21
21
  import './index-5f9f807a.js';
22
22
  import { h as html_decode_1, c as clean_html_1 } from './entities-7cc3bf45.js';
23
- import { _ as _slicedToArray } from './slicedToArray-d0a9593a.js';
24
- import { _ as _JSON$stringify, a as _asyncToGenerator, r as regenerator, D as DFPAdSlot, B as Beam } from './AdSlot-b4f04c96.js';
25
- export { D as AdSlot, B as Beam } from './AdSlot-b4f04c96.js';
23
+ import { _ as _slicedToArray, a as _getIterator } from './slicedToArray-d1db3163.js';
24
+ import { _ as _JSON$stringify, a as _asyncToGenerator, r as regenerator, D as DFPAdSlot, B as Beam } from './AdSlot-3d2ecc87.js';
25
+ export { D as AdSlot, B as Beam } from './AdSlot-3d2ecc87.js';
26
26
  import './promise-e3480f1c.js';
27
- import './ADInfeed-a1d8cb44.js';
27
+ import './ADInfeed-94f767ec.js';
28
28
  export { default as DeckContent } from './DeckContent.js';
29
29
  import { i as isFunction_1, a as isArray_1, _ as _arrayMap } from './get-9c285a85.js';
30
- export { A as AD, G as GridContent } from './GridContent-862176ac.js';
30
+ export { A as AD, G as GridContent } from './GridContent-ce2f615a.js';
31
31
  export { default as DeckQueue } from './DeckQueue.js';
32
32
  import 'react-bootstrap/Media';
33
33
  export { default as ThumbnailCard } from './ThumbnailCard.js';
@@ -38,7 +38,7 @@ import GroupDeck from './GroupDeck.js';
38
38
  export { default as GroupDeck } from './GroupDeck.js';
39
39
  import { g as getYoutubeId } from './YoutubeGroup-562ed456.js';
40
40
  export { Y as YoutubeGroup } from './YoutubeGroup-562ed456.js';
41
- import { Spinner as Spinner$1, Container as Container$1, Row as Row$1, Col as Col$1, Carousel, Table, Figure as Figure$1, Button as Button$1, ProgressBar, Card } from 'react-bootstrap';
41
+ import { Spinner as Spinner$1, Container as Container$1, Row as Row$1, Col as Col$1, Carousel, Table, Figure as Figure$1, Button as Button$1, ProgressBar, Card, Form } from 'react-bootstrap';
42
42
  export { default as QueueDeckExpanded } from './QueueDeckExpanded.js';
43
43
  import { I as IoMdArrowDropdown } from './index.esm-536609db.js';
44
44
  export { default as VideoSeriesListing } from './VideoSeriesListing.js';
@@ -49,8 +49,8 @@ export { default as IssueDeck } from './IssueDeck.js';
49
49
  import 'react-bootstrap/Badge';
50
50
  export { default as IssueContentDeck } from './IssueContentDeck.js';
51
51
  import Spinner from 'react-bootstrap/Spinner';
52
- import { M as MdPictureAsPdf } from './Normal-4180d06d.js';
53
- export { A as AD728x90, C as Column1, a as Column2, b as Column3, f as HamMagazine, H as Header, L as LeftNav, e as NavDvm, c as NavMagazine, N as NavNative, d as NavNormal, P as PageFilter, S as Search, g as SideFooter, T as TemplateNormal } from './Normal-4180d06d.js';
52
+ import { M as MdPictureAsPdf } from './Normal-0bf73d75.js';
53
+ export { A as AD728x90, C as Column1, a as Column2, b as Column3, f as HamMagazine, H as Header, L as LeftNav, e as NavDvm, c as NavMagazine, N as NavNative, d as NavNormal, P as PageFilter, S as Search, g as SideFooter, T as TemplateNormal } from './Normal-0bf73d75.js';
54
54
  import 'react-bootstrap/ListGroup';
55
55
  import Head from 'next/head';
56
56
  import Accordion from 'react-bootstrap/Accordion';
@@ -67,8 +67,12 @@ import Carousel$1 from 'react-bootstrap/Carousel';
67
67
  import Breadcrumb from 'react-bootstrap/Breadcrumb';
68
68
  import DropdownButton from 'react-bootstrap/DropdownButton';
69
69
  import Dropdown from 'react-bootstrap/Dropdown';
70
- import { F as FaLongArrowAltRight } from './Ustream-d51b9b11.js';
71
- export { U as Ustream } from './Ustream-d51b9b11.js';
70
+ import { F as FaLongArrowAltRight } from './Ustream-c153a835.js';
71
+ export { U as Ustream } from './Ustream-c153a835.js';
72
+ import useSWR from 'swr';
73
+ import Iron from '@hapi/iron';
74
+ import Local from 'passport-local';
75
+ import mysql from 'mysql';
72
76
 
73
77
  var momentTimezone = createCommonjsModule(function (module) {
74
78
  //! moment-timezone.js
@@ -6486,7 +6490,7 @@ DocumentFragment.prototype.toString =
6486
6490
  }).join("")
6487
6491
  };
6488
6492
 
6489
- var event = Event$1;
6493
+ var event$1 = Event$1;
6490
6494
 
6491
6495
  function Event$1(family) {}
6492
6496
 
@@ -6535,7 +6539,7 @@ proto.createDocumentFragment = function createDocumentFragment() {
6535
6539
  };
6536
6540
 
6537
6541
  proto.createEvent = function createEvent(family) {
6538
- return new event(family)
6542
+ return new event$1(family)
6539
6543
  };
6540
6544
 
6541
6545
  proto.createComment = function createComment(data) {
@@ -13551,7 +13555,7 @@ var NativeAd = function NativeAd(props) {
13551
13555
  };
13552
13556
 
13553
13557
  var Figure = dynamic(function () {
13554
- return import('./Figure-cff72982.js');
13558
+ return import('./Figure-d0f95cc0.js');
13555
13559
  }, { ssr: false });
13556
13560
 
13557
13561
  var checkUrlIsExternal = function checkUrlIsExternal(url) {
@@ -14938,7 +14942,7 @@ var YahooHero = function YahooHero(props) {
14938
14942
  React__default.createElement(
14939
14943
  'style',
14940
14944
  { jsx: 'true' },
14941
- '\n .yh-top-article {\n display: flex;\n flex-direction: row;\n position: relative;\n font-family: \'Roboto\', sans-serif;\n margin-bottom: 1rem;\n border-radius: 15px;\n overflow: hidden;\n min-height: 315px;\n }\n .yh-top-article--img {\n width: 100%;\n min-height: 240px;\n overflow: hidden;\n }\n .yh-top-article--img img {\n width: 100%;\n height: auto;\n min-height: 100%;\n max-height: 315px;\n object-fit: cover;\n }\n .yh-top-article--body {\n height: 100%;\n width: 40%;\n min-width: 320px;\n right: 0;\n position: absolute;\n color: white;\n padding: 1.75rem;\n height: 315px;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n flex-direction: column;\n }\n .yh-top-article--body h1 {\n color: white!important;\n font-size: 1.4rem;\n font-weight: 500;\n margin-bottom: 0.5rem;\n }\n .yh-top-article--body p {\n font-size: 0.9rem;\n margin-bottom: 0.5rem;\n }\n .yh-top-article--blur {\n height: 100%;\n width: 40%;\n right: 0;\n position: absolute;\n filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));\n background: rgba(0,0,0,.65);\n min-width: 320px;\n }\n .yh-sub-article-container {\n display: flex;\n justify-content: space-between;\n }\n .yh-sub-article {\n width: 23.25%;\n }\n .yh-sub-article p.yh-sub-article--title {\n font-weight: bold;\n }\n .yh-sub-article img {\n width: 100%;\n height: 150px;\n object-fit: cover;\n border-radius: 15px;\n }\n .yh-sub-article img[src=\'' + props.thumbnail + '\']{\n object-fit: contain;\n }\n .yh-sub-article--title {\n font-weight: bold;\n margin-top: .25rem;\n font-size: 1rem;\n margin-bottom: .25rem;\n }\n .yh-sub-article--info {\n font-size: .8rem;\n margin-bottom: 0;\n\n }\n @media screen and (max-width: 968px) {\n .yh-sub-article-container {\n flex-wrap: wrap;\n }\n .yh-sub-article {\n width: 48%;\n margin-bottom: 1rem;\n }\n }\n '
14945
+ '\n .yh-top-article {\n display: flex;\n flex-direction: row;\n position: relative;\n font-family: Roboto, sans-serif;\n margin-bottom: 1rem;\n border-radius: 15px;\n overflow: hidden;\n min-height: 315px;\n }\n .yh-top-article--img {\n width: 100%;\n min-height: 240px;\n overflow: hidden;\n }\n .yh-top-article--img img {\n width: 100%;\n height: auto;\n min-height: 100%;\n max-height: 315px;\n object-fit: cover;\n }\n .yh-top-article--body {\n height: 100%;\n width: 40%;\n min-width: 320px;\n right: 0;\n position: absolute;\n color: white;\n padding: 1.75rem;\n height: 315px;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n flex-direction: column;\n }\n .yh-top-article--body h1 {\n color: white!important;\n font-size: 1.4rem;\n font-weight: 500;\n margin-bottom: 0.5rem;\n }\n .yh-top-article--body p {\n font-size: 0.9rem;\n margin-bottom: 0.5rem;\n }\n .yh-top-article--blur {\n height: 100%;\n width: 40%;\n right: 0;\n position: absolute;\n filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));\n background: rgba(0,0,0,.65);\n min-width: 320px;\n }\n .yh-sub-article-container {\n display: flex;\n justify-content: space-between;\n }\n .yh-sub-article {\n width: 23.25%;\n }\n .yh-sub-article p.yh-sub-article--title {\n font-weight: bold;\n }\n .yh-sub-article img {\n width: 100%;\n height: 150px;\n object-fit: cover;\n border-radius: 15px;\n }\n .yh-sub-article img[src=\'' + props.thumbnail + '\']{\n object-fit: contain;\n }\n .yh-sub-article--title {\n font-weight: bold;\n margin-top: .25rem;\n font-size: 1rem;\n margin-bottom: .25rem;\n }\n .yh-sub-article--info {\n font-size: .8rem;\n margin-bottom: 0;\n\n }\n @media screen and (max-width: 968px) {\n .yh-sub-article-container {\n flex-wrap: wrap;\n }\n .yh-sub-article {\n width: 48%;\n margin-bottom: 1rem;\n }\n }\n '
14942
14946
  )
14943
14947
  );
14944
14948
  };
@@ -16653,4 +16657,3978 @@ var KMTracker = function KMTracker(props) {
16653
16657
  }
16654
16658
  };
16655
16659
 
16656
- export { AD300x250, AD300x250x600, ADFloatingFooter, ADFooter, ADGutter, ADWelcome, AccordionPanel, AdSlotsProvider, AlphabeticList, ArticleDetailDropdown, ArticleQueue, Breadcrumbs$1 as Breadcrumbs, CMEDeck, ConferenceArticleCard, EventsDeck, Feature, fbsHero as ForbesHero, GridHero, Hero, HighlightenVideo, HorizontalHero, KMTracker, OncliveHero, OncliveLargeHero, PdfDownload, RelatedContent, RelatedTopicsDropdown, SetCookie, SocialShare$1 as SocialShare, VerticalHero, YahooHero, getSerializers };
16660
+ var defineProperty = createCommonjsModule(function (module, exports) {
16661
+
16662
+ exports.__esModule = true;
16663
+
16664
+
16665
+
16666
+ var _defineProperty2 = _interopRequireDefault(defineProperty$2);
16667
+
16668
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16669
+
16670
+ exports.default = function (obj, key, value) {
16671
+ if (key in obj) {
16672
+ (0, _defineProperty2.default)(obj, key, {
16673
+ value: value,
16674
+ enumerable: true,
16675
+ configurable: true,
16676
+ writable: true
16677
+ });
16678
+ } else {
16679
+ obj[key] = value;
16680
+ }
16681
+
16682
+ return obj;
16683
+ };
16684
+ });
16685
+
16686
+ var _defineProperty$1 = unwrapExports(defineProperty);
16687
+
16688
+ var returnFormField = function returnFormField(_ref) {
16689
+ var name = _ref.name,
16690
+ label = _ref.label,
16691
+ type = _ref.type,
16692
+ _ref$required = _ref.required,
16693
+ required = _ref$required === undefined ? false : _ref$required,
16694
+ _ref$readonly = _ref.readonly,
16695
+ readonly = _ref$readonly === undefined ? false : _ref$readonly,
16696
+ _ref$options = _ref.options,
16697
+ options = _ref$options === undefined ? null : _ref$options,
16698
+ _ref$groupType = _ref.groupType,
16699
+ groupType = _ref$groupType === undefined ? '' : _ref$groupType,
16700
+ _ref$errors = _ref.errors,
16701
+ errors = _ref$errors === undefined ? {} : _ref$errors,
16702
+ _ref$handleChanged = _ref.handleChanged,
16703
+ handleChanged = _ref$handleChanged === undefined ? null : _ref$handleChanged,
16704
+ _ref$default_value = _ref.default_value,
16705
+ default_value = _ref$default_value === undefined ? null : _ref$default_value;
16706
+
16707
+ var opts = [];
16708
+ if (groupType) {
16709
+ opts['as'] = groupType;
16710
+ if (groupType === Col$1) {
16711
+ opts['xs'] = 12;
16712
+ opts['md'] = 6;
16713
+ }
16714
+ }
16715
+
16716
+ if (handleChanged) {
16717
+ opts['onChange'] = handleChanged;
16718
+ }
16719
+
16720
+ if (readonly) {
16721
+ opts['readOnly'] = readonly;
16722
+ }
16723
+
16724
+ if (type == 'text' || type == 'email' || type == 'password' || type == 'number') {
16725
+ return React__default.createElement(
16726
+ Form.Group,
16727
+ _extends$2({}, opts, { controlId: name }),
16728
+ React__default.createElement(
16729
+ Form.Label,
16730
+ { kye: name + '_label' },
16731
+ label,
16732
+ required && React__default.createElement(
16733
+ 'span',
16734
+ { style: { color: 'red' } },
16735
+ '*'
16736
+ )
16737
+ ),
16738
+ React__default.createElement(Form.Control, { key: name + '_' + type, type: type, readOnly: readonly, name: name, placeholder: '', defaultValue: default_value, required: required }),
16739
+ React__default.createElement(
16740
+ Form.Control.Feedback,
16741
+ { key: name + '_feedback', type: 'invalid' },
16742
+ errors[name]
16743
+ )
16744
+ );
16745
+ }
16746
+ if (type == 'select') {
16747
+ return React__default.createElement(
16748
+ Form.Group,
16749
+ _extends$2({}, opts, { key: name, controlId: name }),
16750
+ React__default.createElement(
16751
+ Form.Label,
16752
+ { key: name + '_' + label },
16753
+ label,
16754
+ required && React__default.createElement(
16755
+ 'span',
16756
+ { key: name + '_required_span', style: { color: 'red' } },
16757
+ '*'
16758
+ )
16759
+ ),
16760
+ React__default.createElement(
16761
+ Form.Control,
16762
+ { key: name + '_select', as: 'select', name: name, required: required, defaultValue: default_value },
16763
+ React__default.createElement('option', { value: '', key: name + '_options_empty' }),
16764
+ options.map(function (option, index) {
16765
+ var value = option.value ? option.value : option;
16766
+ var label = option.label ? option.label : option;
16767
+ var key = name + '_options_' + index;
16768
+ return React__default.createElement(
16769
+ 'option',
16770
+ { key: key, value: value },
16771
+ label
16772
+ );
16773
+ })
16774
+ )
16775
+ );
16776
+ }
16777
+
16778
+ if (type == 'radio' || type == 'checkbox') {
16779
+ return React__default.createElement(
16780
+ Form.Group,
16781
+ _extends$2({}, opts, { controlId: name }),
16782
+ React__default.createElement(
16783
+ Form.Label,
16784
+ null,
16785
+ label,
16786
+ required && React__default.createElement(
16787
+ 'span',
16788
+ { style: { color: 'red' } },
16789
+ '*'
16790
+ )
16791
+ ),
16792
+ options.map(function (option, index) {
16793
+ var _React$createElement;
16794
+
16795
+ return React__default.createElement(Form.Check, (_React$createElement = { type: type, key: index, defaultChecked: default_value ? default_value === option.value : false, name: name, id: name + '_' + index }, _defineProperty$1(_React$createElement, 'key', index), _defineProperty$1(_React$createElement, 'value', option.value), _defineProperty$1(_React$createElement, 'label', option.label), _defineProperty$1(_React$createElement, 'required', required), _React$createElement));
16796
+ })
16797
+ );
16798
+ }
16799
+ };
16800
+
16801
+ var _this = undefined;
16802
+
16803
+ var dataHandler = function () {
16804
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(api_url, body) {
16805
+ var res, result;
16806
+ return regenerator.wrap(function _callee$(_context) {
16807
+ while (1) {
16808
+ switch (_context.prev = _context.next) {
16809
+ case 0:
16810
+ _context.prev = 0;
16811
+ _context.next = 3;
16812
+ return fetch(api_url, {
16813
+ method: 'POST',
16814
+ headers: { 'Content-Type': 'application/json' },
16815
+ body: _JSON$stringify(body)
16816
+ });
16817
+
16818
+ case 3:
16819
+ res = _context.sent;
16820
+
16821
+ if (!(res.status === 200)) {
16822
+ _context.next = 13;
16823
+ break;
16824
+ }
16825
+
16826
+ _context.next = 7;
16827
+ return res.json();
16828
+
16829
+ case 7:
16830
+ result = _context.sent;
16831
+
16832
+ if (!result.error) {
16833
+ _context.next = 10;
16834
+ break;
16835
+ }
16836
+
16837
+ throw new Error(result.error);
16838
+
16839
+ case 10:
16840
+ return _context.abrupt('return', result.data);
16841
+
16842
+ case 13:
16843
+ _context.t0 = Error;
16844
+ _context.next = 16;
16845
+ return res.text();
16846
+
16847
+ case 16:
16848
+ _context.t1 = _context.sent;
16849
+ throw new _context.t0(_context.t1);
16850
+
16851
+ case 18:
16852
+ _context.next = 24;
16853
+ break;
16854
+
16855
+ case 20:
16856
+ _context.prev = 20;
16857
+ _context.t2 = _context['catch'](0);
16858
+
16859
+ console.error('data handler failed : ' + api_url, _context.t2);
16860
+ return _context.abrupt('return', null);
16861
+
16862
+ case 24:
16863
+ case 'end':
16864
+ return _context.stop();
16865
+ }
16866
+ }
16867
+ }, _callee, _this, [[0, 20]]);
16868
+ }));
16869
+
16870
+ return function dataHandler(_x, _x2) {
16871
+ return _ref.apply(this, arguments);
16872
+ };
16873
+ }();
16874
+
16875
+ function useUser() {
16876
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
16877
+ redirectTo = _ref.redirectTo,
16878
+ redirectIfFound = _ref.redirectIfFound;
16879
+
16880
+ var _useSWR = useSWR('/api/auth/user', dataHandler),
16881
+ data = _useSWR.data,
16882
+ error = _useSWR.error;
16883
+
16884
+ var user = data;
16885
+ var finished = Boolean(data);
16886
+ var hasUser = Boolean(user);
16887
+
16888
+ useEffect(function () {
16889
+ if (!redirectTo || !finished) return;
16890
+ if (
16891
+ // If redirectTo is set, redirect if the user was not found.
16892
+ redirectTo && !redirectIfFound && !hasUser ||
16893
+ // If redirectIfFound is also set, redirect if the user was found
16894
+ redirectIfFound && hasUser) {
16895
+ Router.push(redirectTo);
16896
+ }
16897
+ }, [redirectTo, redirectIfFound, finished, hasUser]);
16898
+
16899
+ return error ? null : user;
16900
+ }
16901
+
16902
+ var hooks = /*#__PURE__*/Object.freeze({
16903
+ __proto__: null,
16904
+ useUser: useUser
16905
+ });
16906
+
16907
+ var LoginForm = function LoginForm(props) {
16908
+ var handleSubmit = function () {
16909
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
16910
+ var body, res;
16911
+ return regenerator.wrap(function _callee$(_context) {
16912
+ while (1) {
16913
+ switch (_context.prev = _context.next) {
16914
+ case 0:
16915
+ event.preventDefault();
16916
+
16917
+ if (errorMsg) setErrorMsg('');
16918
+ setLoading(true);
16919
+
16920
+ body = {
16921
+ email: e.currentTarget.email.value,
16922
+ password: e.currentTarget.password.value
16923
+ };
16924
+ _context.prev = 4;
16925
+ _context.next = 7;
16926
+ return fetch('/api/auth/login', {
16927
+ method: 'POST',
16928
+ headers: { 'Content-Type': 'application/json' },
16929
+ body: _JSON$stringify(body)
16930
+ });
16931
+
16932
+ case 7:
16933
+ res = _context.sent;
16934
+
16935
+ setLoading(false);
16936
+
16937
+ if (!(res.status === 200)) {
16938
+ _context.next = 13;
16939
+ break;
16940
+ }
16941
+
16942
+ // here, Router.push() does not carry new cookie value.
16943
+ // so need hard redirect
16944
+ window.location.href = '/';
16945
+ _context.next = 18;
16946
+ break;
16947
+
16948
+ case 13:
16949
+ _context.t0 = Error;
16950
+ _context.next = 16;
16951
+ return res.text();
16952
+
16953
+ case 16:
16954
+ _context.t1 = _context.sent;
16955
+ throw new _context.t0(_context.t1);
16956
+
16957
+ case 18:
16958
+ _context.next = 23;
16959
+ break;
16960
+
16961
+ case 20:
16962
+ _context.prev = 20;
16963
+ _context.t2 = _context['catch'](4);
16964
+
16965
+ setErrorMsg(_context.t2.message);
16966
+
16967
+ case 23:
16968
+ case 'end':
16969
+ return _context.stop();
16970
+ }
16971
+ }
16972
+ }, _callee, this, [[4, 20]]);
16973
+ }));
16974
+
16975
+ return function handleSubmit(_x) {
16976
+ return _ref.apply(this, arguments);
16977
+ };
16978
+ }();
16979
+
16980
+ useEffect(function () {
16981
+ if (props.user) {
16982
+ window.location.href = '/auth/profile';
16983
+ }
16984
+ }, []);
16985
+ useUser('/auth/profile', true);
16986
+
16987
+ var _useState = useState(''),
16988
+ _useState2 = _slicedToArray(_useState, 2),
16989
+ errorMsg = _useState2[0],
16990
+ setErrorMsg = _useState2[1];
16991
+
16992
+ var _useState3 = useState(false),
16993
+ _useState4 = _slicedToArray(_useState3, 2),
16994
+ loading = _useState4[0],
16995
+ setLoading = _useState4[1];
16996
+
16997
+ return React__default.createElement(
16998
+ Form,
16999
+ { className: 'login', onSubmit: handleSubmit },
17000
+ React__default.createElement(
17001
+ 'h1',
17002
+ null,
17003
+ 'Login'
17004
+ ),
17005
+ React__default.createElement('hr', null),
17006
+ returnFormField({ name: 'email', label: 'Email', type: 'email', required: true }),
17007
+ returnFormField({ name: 'password', label: 'Password', type: 'password', required: true }),
17008
+ React__default.createElement('hr', null),
17009
+ React__default.createElement(
17010
+ Form.Row,
17011
+ null,
17012
+ React__default.createElement(
17013
+ Form.Group,
17014
+ { as: Col$1 },
17015
+ React__default.createElement(
17016
+ 'a',
17017
+ { href: '/auth/signup' },
17018
+ 'I don\'t have an account'
17019
+ )
17020
+ ),
17021
+ React__default.createElement(
17022
+ Form.Group,
17023
+ { as: Col$1, className: 'text-right' },
17024
+ !loading && React__default.createElement(
17025
+ Button$1,
17026
+ { type: 'submit' },
17027
+ 'Login'
17028
+ ),
17029
+ loading && React__default.createElement(
17030
+ Button$1,
17031
+ { variant: 'primary', disabled: true },
17032
+ React__default.createElement(Spinner$1, {
17033
+ as: 'span',
17034
+ animation: 'border',
17035
+ role: 'status',
17036
+ 'aria-hidden': 'true',
17037
+ size: 'sm'
17038
+ }),
17039
+ React__default.createElement(
17040
+ 'span',
17041
+ { className: 'sr-only' },
17042
+ 'Loading...'
17043
+ )
17044
+ )
17045
+ )
17046
+ ),
17047
+ errorMsg && React__default.createElement(
17048
+ 'p',
17049
+ { className: 'error' },
17050
+ errorMsg
17051
+ ),
17052
+ React__default.createElement(
17053
+ 'style',
17054
+ { jsx: 'true'.toString() },
17055
+ ' \n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n '
17056
+ )
17057
+ );
17058
+ };
17059
+
17060
+ // get country & state options
17061
+ var countries$1 = ["United States", "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas (the)", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia (Plurinational State of)", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory (the)", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands (the)", "Central African Republic (the)", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands (the)", "Colombia", "Comoros (the)", "Congo (the Democratic Republic of the)", "Congo (the)", "Cook Islands (the)", "Costa Rica", "Croatia", "Cuba", "Curaçao", "Cyprus", "Czechia", "Côte d'Ivoire", "Denmark", "Djibouti", "Dominica", "Dominican Republic (the)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Eswatini", "Ethiopia", "Falkland Islands (the) [Malvinas]", "Faroe Islands (the)", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories (the)", "Gabon", "Gambia (the)", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (the)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea (the Democratic People's Republic of)", "Korea (the Republic of)", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic (the)", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands (the)", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia (Federated States of)", "Moldova (the Republic of)", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands (the)", "New Caledonia", "New Zealand", "Nicaragua", "Niger (the)", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands (the)", "Norway", "Oman", "Pakistan", "Palau", "Palestine, State of", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines (the)", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Republic of North Macedonia", "Romania", "Russian Federation (the)", "Rwanda", "Réunion", "Saint Barthélemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka", "Sudan (the)", "Suriname", "Svalbard and Jan Mayen", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan (Province of China)", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands (the)", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates (the)", "United Kingdom of Great Britain and Northern Ireland (the)", "United States Minor Outlying Islands (the)", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela (Bolivarian Republic of)", "Viet Nam", "Virgin Islands (British)", "Virgin Islands (U.S.)", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe", "Åland Islands"];
17062
+
17063
+ var states = ['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA', 'WA', 'WV', 'WI', 'WY'];
17064
+
17065
+ var _this$1 = undefined;
17066
+
17067
+ var SignupForm = function SignupForm(props) {
17068
+ var handleSubmit = function () {
17069
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
17070
+ var formData, body, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, res;
17071
+
17072
+ return regenerator.wrap(function _callee3$(_context3) {
17073
+ while (1) {
17074
+ switch (_context3.prev = _context3.next) {
17075
+ case 0:
17076
+ event.preventDefault();
17077
+ setLoading(true);
17078
+ if (errorMsg) setErrorMsg('');
17079
+
17080
+ formData = new FormData(e.currentTarget);
17081
+ body = {};
17082
+ _iteratorNormalCompletion = true;
17083
+ _didIteratorError = false;
17084
+ _iteratorError = undefined;
17085
+ _context3.prev = 8;
17086
+
17087
+ for (_iterator = _getIterator(formData.keys()); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
17088
+ key = _step.value;
17089
+
17090
+ body[key] = formData.get(key);
17091
+ }
17092
+
17093
+ _context3.next = 16;
17094
+ break;
17095
+
17096
+ case 12:
17097
+ _context3.prev = 12;
17098
+ _context3.t0 = _context3['catch'](8);
17099
+ _didIteratorError = true;
17100
+ _iteratorError = _context3.t0;
17101
+
17102
+ case 16:
17103
+ _context3.prev = 16;
17104
+ _context3.prev = 17;
17105
+
17106
+ if (!_iteratorNormalCompletion && _iterator.return) {
17107
+ _iterator.return();
17108
+ }
17109
+
17110
+ case 19:
17111
+ _context3.prev = 19;
17112
+
17113
+ if (!_didIteratorError) {
17114
+ _context3.next = 22;
17115
+ break;
17116
+ }
17117
+
17118
+ throw _iteratorError;
17119
+
17120
+ case 22:
17121
+ return _context3.finish(19);
17122
+
17123
+ case 23:
17124
+ return _context3.finish(16);
17125
+
17126
+ case 24:
17127
+ _context3.prev = 24;
17128
+ _context3.next = 27;
17129
+ return fetch('/api/auth/signup', {
17130
+ method: 'POST',
17131
+ headers: { 'Content-Type': 'application/json' },
17132
+ body: _JSON$stringify(body)
17133
+ });
17134
+
17135
+ case 27:
17136
+ res = _context3.sent;
17137
+
17138
+ setLoading(false);
17139
+
17140
+ if (!(res.status === 200)) {
17141
+ _context3.next = 33;
17142
+ break;
17143
+ }
17144
+
17145
+ window.location.href = '/auth/login';
17146
+ _context3.next = 38;
17147
+ break;
17148
+
17149
+ case 33:
17150
+ _context3.t1 = Error;
17151
+ _context3.next = 36;
17152
+ return res.text();
17153
+
17154
+ case 36:
17155
+ _context3.t2 = _context3.sent;
17156
+ throw new _context3.t1(_context3.t2);
17157
+
17158
+ case 38:
17159
+ _context3.next = 43;
17160
+ break;
17161
+
17162
+ case 40:
17163
+ _context3.prev = 40;
17164
+ _context3.t3 = _context3['catch'](24);
17165
+
17166
+ setErrorMsg(_context3.t3.message);
17167
+
17168
+ case 43:
17169
+ case 'end':
17170
+ return _context3.stop();
17171
+ }
17172
+ }
17173
+ }, _callee3, this, [[8, 12, 16, 24], [17,, 19, 23], [24, 40]]);
17174
+ }));
17175
+
17176
+ return function handleSubmit(_x2) {
17177
+ return _ref3.apply(this, arguments);
17178
+ };
17179
+ }();
17180
+
17181
+ var _useState = useState(''),
17182
+ _useState2 = _slicedToArray(_useState, 2),
17183
+ errorMsg = _useState2[0],
17184
+ setErrorMsg = _useState2[1];
17185
+
17186
+ var _useState3 = useState(false),
17187
+ _useState4 = _slicedToArray(_useState3, 2),
17188
+ countryUS = _useState4[0],
17189
+ setCountryUS = _useState4[1];
17190
+
17191
+ var _useState5 = useState([]),
17192
+ _useState6 = _slicedToArray(_useState5, 2),
17193
+ healthcareOccupation = _useState6[0],
17194
+ setHealthcareOccupation = _useState6[1];
17195
+
17196
+ var _useState7 = useState([]),
17197
+ _useState8 = _slicedToArray(_useState7, 2),
17198
+ nonHealthcareOccupation = _useState8[0],
17199
+ setNonHealthcareOccupation = _useState8[1];
17200
+
17201
+ var loadInitData = function () {
17202
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
17203
+ var healthcare_occupation, non_healthcare_occupation;
17204
+ return regenerator.wrap(function _callee$(_context) {
17205
+ while (1) {
17206
+ switch (_context.prev = _context.next) {
17207
+ case 0:
17208
+ _context.next = 2;
17209
+ return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Healthcare' });
17210
+
17211
+ case 2:
17212
+ healthcare_occupation = _context.sent;
17213
+ _context.next = 5;
17214
+ return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Non-Healthcare' });
17215
+
17216
+ case 5:
17217
+ non_healthcare_occupation = _context.sent;
17218
+
17219
+
17220
+ setHealthcareOccupation(healthcare_occupation);
17221
+ setNonHealthcareOccupation(non_healthcare_occupation);
17222
+
17223
+ case 8:
17224
+ case 'end':
17225
+ return _context.stop();
17226
+ }
17227
+ }
17228
+ }, _callee, _this$1);
17229
+ }));
17230
+
17231
+ return function loadInitData() {
17232
+ return _ref.apply(this, arguments);
17233
+ };
17234
+ }();
17235
+
17236
+ useEffect(function () {
17237
+ if (props.user) {
17238
+ window.location.href = '/auth/profile';
17239
+ } else {
17240
+ loadInitData();
17241
+ }
17242
+ }, []);
17243
+
17244
+ // make it to change layout based on radio buton
17245
+ var handleCountryChanged = function handleCountryChanged(e) {
17246
+ if (e.target.value === 'United States') {
17247
+ setCountryUS(true);
17248
+ } else {
17249
+ setCountryUS(false);
17250
+ }
17251
+ };
17252
+
17253
+ var _useState9 = useState(true),
17254
+ _useState10 = _slicedToArray(_useState9, 2),
17255
+ healcareProfessional = _useState10[0],
17256
+ setHealthcareProfessional = _useState10[1];
17257
+
17258
+ var handleHealthcareProfessionalChanged = function handleHealthcareProfessionalChanged(e) {
17259
+
17260
+ if (e.target.value === 'Y') {
17261
+ setHealthcareProfessional(true);
17262
+ } else {
17263
+ setHealthcareProfessional(false);
17264
+ }
17265
+ document.getElementById('occupation').value = '';
17266
+ setOccupationFields(null);
17267
+ };
17268
+
17269
+ var _useState11 = useState(null),
17270
+ _useState12 = _slicedToArray(_useState11, 2),
17271
+ occupationFields = _useState12[0],
17272
+ setOccupationFields = _useState12[1];
17273
+
17274
+ var handleOccupationChanged = function () {
17275
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
17276
+ var occupation, fields;
17277
+ return regenerator.wrap(function _callee2$(_context2) {
17278
+ while (1) {
17279
+ switch (_context2.prev = _context2.next) {
17280
+ case 0:
17281
+ occupation = e.target.value;
17282
+ _context2.next = 3;
17283
+ return dataHandler('/api/auth/data', { action: 'get-fields', occupation: occupation });
17284
+
17285
+ case 3:
17286
+ fields = _context2.sent;
17287
+
17288
+ setOccupationFields(fields);
17289
+
17290
+ case 5:
17291
+ case 'end':
17292
+ return _context2.stop();
17293
+ }
17294
+ }
17295
+ }, _callee2, _this$1);
17296
+ }));
17297
+
17298
+ return function handleOccupationChanged(_x) {
17299
+ return _ref2.apply(this, arguments);
17300
+ };
17301
+ }();
17302
+
17303
+ var _useState13 = useState(false),
17304
+ _useState14 = _slicedToArray(_useState13, 2),
17305
+ loading = _useState14[0],
17306
+ setLoading = _useState14[1];
17307
+
17308
+ return React__default.createElement(
17309
+ Form,
17310
+ { className: 'login', id: 'signupForm', onSubmit: handleSubmit },
17311
+ React__default.createElement(
17312
+ 'h1',
17313
+ null,
17314
+ 'Sign Up'
17315
+ ),
17316
+ React__default.createElement('hr', null),
17317
+ returnFormField({ name: 'email', label: 'Email', type: 'email', required: true }),
17318
+ React__default.createElement(
17319
+ Form.Row,
17320
+ null,
17321
+ returnFormField({ name: 'password', label: 'Password', type: 'password', groupType: Col$1, required: true }),
17322
+ returnFormField({ name: 'rpassword', label: 'Retype Password', type: 'password', groupType: Col$1, required: true })
17323
+ ),
17324
+ React__default.createElement(
17325
+ Form.Row,
17326
+ null,
17327
+ returnFormField({ name: 'first_name', label: 'First Name', type: 'text', groupType: Col$1, required: true }),
17328
+ returnFormField({ name: 'last_name', label: 'Last Name', type: 'text', groupType: Col$1, required: true })
17329
+ ),
17330
+ React__default.createElement(
17331
+ Form.Row,
17332
+ null,
17333
+ returnFormField({
17334
+ name: 'country',
17335
+ label: 'Country',
17336
+ type: 'select',
17337
+ required: true,
17338
+ groupType: Col$1,
17339
+ options: countries$1,
17340
+ handleChanged: handleCountryChanged
17341
+ }),
17342
+ countryUS && returnFormField({ name: 'state', label: 'State', type: 'select', required: true, groupType: Col$1, options: states })
17343
+ ),
17344
+ React__default.createElement(
17345
+ Form.Row,
17346
+ null,
17347
+ countryUS && returnFormField({ name: 'zip', label: 'Working Zip Code', type: 'text', required: true, groupType: Col$1 }),
17348
+ countryUS && returnFormField({ name: 'phone', label: 'Phone', type: 'text', required: true, groupType: Col$1 })
17349
+ ),
17350
+ returnFormField({
17351
+ name: 'healthcare_professional',
17352
+ label: 'Are You a Health Care Professional?',
17353
+ type: 'radio',
17354
+ required: true,
17355
+ options: [{ value: 'Y', label: 'Yes', checked: true }, { value: 'N', label: 'No', checked: false }],
17356
+ handleChanged: handleHealthcareProfessionalChanged,
17357
+ default_value: 'Y'
17358
+ }),
17359
+ healcareProfessional && returnFormField({
17360
+ name: 'occupation',
17361
+ label: 'Occupation',
17362
+ type: 'select',
17363
+ required: true,
17364
+ options: healthcareOccupation,
17365
+ handleChanged: handleOccupationChanged
17366
+ }),
17367
+ !healcareProfessional && returnFormField({
17368
+ name: 'occupation',
17369
+ label: 'Non Provider Role',
17370
+ type: 'select',
17371
+ required: true,
17372
+ options: nonHealthcareOccupation,
17373
+ handleChanged: handleOccupationChanged
17374
+ }),
17375
+ occupationFields && occupationFields.map(function (field) {
17376
+ return returnFormField({
17377
+ name: field.name,
17378
+ label: field.label,
17379
+ type: field.type,
17380
+ required: field.required === 1,
17381
+ options: field.options
17382
+ });
17383
+ }),
17384
+ returnFormField({
17385
+ name: 'agree',
17386
+ label: 'Terms & Conditions | Privacy Policy',
17387
+ type: 'checkbox',
17388
+ required: true,
17389
+ options: [{ label: 'By registering you agree to our Terms and Conditions and Privacy Policy and understand that you will be receiving email communications', value: 'Y' }]
17390
+ }),
17391
+ React__default.createElement('hr', null),
17392
+ React__default.createElement(
17393
+ Form.Row,
17394
+ null,
17395
+ React__default.createElement(
17396
+ Form.Group,
17397
+ { as: Col$1 },
17398
+ React__default.createElement(
17399
+ 'a',
17400
+ { href: '/auth/login' },
17401
+ 'I already have an account'
17402
+ )
17403
+ ),
17404
+ React__default.createElement(
17405
+ Form.Group,
17406
+ { as: Col$1, className: 'text-right' },
17407
+ !loading && React__default.createElement(
17408
+ Button$1,
17409
+ { type: 'submit' },
17410
+ 'Sign Up'
17411
+ ),
17412
+ loading && React__default.createElement(
17413
+ Button$1,
17414
+ { variant: 'primary', disabled: true },
17415
+ React__default.createElement(Spinner$1, {
17416
+ as: 'span',
17417
+ animation: 'border',
17418
+ role: 'status',
17419
+ 'aria-hidden': 'true',
17420
+ size: 'sm'
17421
+ }),
17422
+ React__default.createElement(
17423
+ 'span',
17424
+ { className: 'sr-only' },
17425
+ 'Loading...'
17426
+ )
17427
+ )
17428
+ )
17429
+ ),
17430
+ errorMsg && React__default.createElement(
17431
+ 'p',
17432
+ { className: 'error' },
17433
+ errorMsg
17434
+ ),
17435
+ React__default.createElement(
17436
+ 'style',
17437
+ { jsx: 'true'.toString() },
17438
+ ' \n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n '
17439
+ )
17440
+ );
17441
+ };
17442
+
17443
+ var _this$2 = undefined;
17444
+
17445
+ var SignupForm$1 = function SignupForm(props) {
17446
+ var handleSubmit = function () {
17447
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
17448
+ var formData, body, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, res;
17449
+
17450
+ return regenerator.wrap(function _callee3$(_context3) {
17451
+ while (1) {
17452
+ switch (_context3.prev = _context3.next) {
17453
+ case 0:
17454
+ event.preventDefault();
17455
+
17456
+ setErrorMsg('');
17457
+ setSuccessMsg('');
17458
+ setLoading(true);
17459
+
17460
+ formData = new FormData(e.currentTarget);
17461
+ body = {};
17462
+ _iteratorNormalCompletion = true;
17463
+ _didIteratorError = false;
17464
+ _iteratorError = undefined;
17465
+ _context3.prev = 9;
17466
+
17467
+ for (_iterator = _getIterator(formData.keys()); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
17468
+ key = _step.value;
17469
+
17470
+ body[key] = formData.get(key);
17471
+ }
17472
+
17473
+ _context3.next = 17;
17474
+ break;
17475
+
17476
+ case 13:
17477
+ _context3.prev = 13;
17478
+ _context3.t0 = _context3['catch'](9);
17479
+ _didIteratorError = true;
17480
+ _iteratorError = _context3.t0;
17481
+
17482
+ case 17:
17483
+ _context3.prev = 17;
17484
+ _context3.prev = 18;
17485
+
17486
+ if (!_iteratorNormalCompletion && _iterator.return) {
17487
+ _iterator.return();
17488
+ }
17489
+
17490
+ case 20:
17491
+ _context3.prev = 20;
17492
+
17493
+ if (!_didIteratorError) {
17494
+ _context3.next = 23;
17495
+ break;
17496
+ }
17497
+
17498
+ throw _iteratorError;
17499
+
17500
+ case 23:
17501
+ return _context3.finish(20);
17502
+
17503
+ case 24:
17504
+ return _context3.finish(17);
17505
+
17506
+ case 25:
17507
+ body['user_id'] = userData.id;
17508
+
17509
+ _context3.prev = 26;
17510
+ _context3.next = 29;
17511
+ return fetch('/api/auth/profile', {
17512
+ method: 'POST',
17513
+ headers: { 'Content-Type': 'application/json' },
17514
+ body: _JSON$stringify(body)
17515
+ });
17516
+
17517
+ case 29:
17518
+ res = _context3.sent;
17519
+
17520
+ setLoading(false);
17521
+
17522
+ if (!(res.status === 200)) {
17523
+ _context3.next = 35;
17524
+ break;
17525
+ }
17526
+
17527
+ setSuccessMsg('Your request has been processed successfully!');
17528
+ _context3.next = 40;
17529
+ break;
17530
+
17531
+ case 35:
17532
+ _context3.t1 = Error;
17533
+ _context3.next = 38;
17534
+ return res.text();
17535
+
17536
+ case 38:
17537
+ _context3.t2 = _context3.sent;
17538
+ throw new _context3.t1(_context3.t2);
17539
+
17540
+ case 40:
17541
+ _context3.next = 45;
17542
+ break;
17543
+
17544
+ case 42:
17545
+ _context3.prev = 42;
17546
+ _context3.t3 = _context3['catch'](26);
17547
+
17548
+ setErrorMsg(_context3.t3.message);
17549
+
17550
+ case 45:
17551
+ case 'end':
17552
+ return _context3.stop();
17553
+ }
17554
+ }
17555
+ }, _callee3, this, [[9, 13, 17, 25], [18,, 20, 24], [26, 42]]);
17556
+ }));
17557
+
17558
+ return function handleSubmit(_x2) {
17559
+ return _ref3.apply(this, arguments);
17560
+ };
17561
+ }();
17562
+
17563
+ var _useState = useState(''),
17564
+ _useState2 = _slicedToArray(_useState, 2),
17565
+ errorMsg = _useState2[0],
17566
+ setErrorMsg = _useState2[1];
17567
+
17568
+ var _useState3 = useState(false),
17569
+ _useState4 = _slicedToArray(_useState3, 2),
17570
+ countryUS = _useState4[0],
17571
+ setCountryUS = _useState4[1];
17572
+
17573
+ var _useState5 = useState([]),
17574
+ _useState6 = _slicedToArray(_useState5, 2),
17575
+ healthcareOccupation = _useState6[0],
17576
+ setHealthcareOccupation = _useState6[1];
17577
+
17578
+ var _useState7 = useState([]),
17579
+ _useState8 = _slicedToArray(_useState7, 2),
17580
+ nonHealthcareOccupation = _useState8[0],
17581
+ setNonHealthcareOccupation = _useState8[1];
17582
+
17583
+ var _useState9 = useState(null),
17584
+ _useState10 = _slicedToArray(_useState9, 2),
17585
+ userData = _useState10[0],
17586
+ setUserData = _useState10[1];
17587
+
17588
+ var user = props.user;
17589
+
17590
+ var loadInitData = function () {
17591
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
17592
+ var healthcare_occupation, non_healthcare_occupation, foundOccupation, fields;
17593
+ return regenerator.wrap(function _callee$(_context) {
17594
+ while (1) {
17595
+ switch (_context.prev = _context.next) {
17596
+ case 0:
17597
+ _context.next = 2;
17598
+ return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Healthcare' });
17599
+
17600
+ case 2:
17601
+ healthcare_occupation = _context.sent;
17602
+ _context.next = 5;
17603
+ return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Non-Healthcare' });
17604
+
17605
+ case 5:
17606
+ non_healthcare_occupation = _context.sent;
17607
+ foundOccupation = healthcare_occupation.find(function (item) {
17608
+ return item.value === user.shared.occupation_id;
17609
+ });
17610
+
17611
+ if (foundOccupation) {
17612
+ user.shared.healthcare_professional = 'Y';
17613
+ } else {
17614
+ user.shared.healthcare_professional = 'N';
17615
+ }
17616
+
17617
+ setHealthcareOccupation(healthcare_occupation);
17618
+ setNonHealthcareOccupation(non_healthcare_occupation);
17619
+ setUserData(user);
17620
+
17621
+ if (user.shared.country === 'United States') {
17622
+ setCountryUS(true);
17623
+ } else {
17624
+ setCountryUS(false);
17625
+ }
17626
+
17627
+ _context.next = 14;
17628
+ return dataHandler('/api/auth/data', { action: 'get-fields', occupation: user.shared.occupation_id });
17629
+
17630
+ case 14:
17631
+ fields = _context.sent;
17632
+
17633
+ setOccupationFields(fields);
17634
+
17635
+ case 16:
17636
+ case 'end':
17637
+ return _context.stop();
17638
+ }
17639
+ }
17640
+ }, _callee, _this$2);
17641
+ }));
17642
+
17643
+ return function loadInitData() {
17644
+ return _ref.apply(this, arguments);
17645
+ };
17646
+ }();
17647
+
17648
+ useEffect(function () {
17649
+ if (!user) {
17650
+ window.location.href = '/auth/login';
17651
+ } else {
17652
+ loadInitData();
17653
+ }
17654
+ }, []);
17655
+
17656
+ // make it to change layout based on radio buton
17657
+ var handleCountryChanged = function handleCountryChanged(e) {
17658
+ if (e.target.value === 'United States') {
17659
+ setCountryUS(true);
17660
+ } else {
17661
+ setCountryUS(false);
17662
+ }
17663
+ };
17664
+
17665
+ var _useState11 = useState(true),
17666
+ _useState12 = _slicedToArray(_useState11, 2),
17667
+ healcareProfessional = _useState12[0],
17668
+ setHealthcareProfessional = _useState12[1];
17669
+
17670
+ var handleHealthcareProfessionalChanged = function handleHealthcareProfessionalChanged(e) {
17671
+
17672
+ if (e.target.value === 'Y') {
17673
+ setHealthcareProfessional(true);
17674
+ } else {
17675
+ setHealthcareProfessional(false);
17676
+ }
17677
+ document.getElementById('occupation').value = '';
17678
+ setOccupationFields(null);
17679
+ };
17680
+
17681
+ var _useState13 = useState(null),
17682
+ _useState14 = _slicedToArray(_useState13, 2),
17683
+ occupationFields = _useState14[0],
17684
+ setOccupationFields = _useState14[1];
17685
+
17686
+ var handleOccupationChanged = function () {
17687
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
17688
+ var occupation, fields;
17689
+ return regenerator.wrap(function _callee2$(_context2) {
17690
+ while (1) {
17691
+ switch (_context2.prev = _context2.next) {
17692
+ case 0:
17693
+ occupation = e.target.value;
17694
+ _context2.next = 3;
17695
+ return dataHandler('/api/auth/data', { action: 'get-fields', occupation: occupation });
17696
+
17697
+ case 3:
17698
+ fields = _context2.sent;
17699
+
17700
+ setOccupationFields(fields);
17701
+
17702
+ case 5:
17703
+ case 'end':
17704
+ return _context2.stop();
17705
+ }
17706
+ }
17707
+ }, _callee2, _this$2);
17708
+ }));
17709
+
17710
+ return function handleOccupationChanged(_x) {
17711
+ return _ref2.apply(this, arguments);
17712
+ };
17713
+ }();
17714
+
17715
+ var _useState15 = useState(''),
17716
+ _useState16 = _slicedToArray(_useState15, 2),
17717
+ successMsg = _useState16[0],
17718
+ setSuccessMsg = _useState16[1];
17719
+
17720
+ var _useState17 = useState(false),
17721
+ _useState18 = _slicedToArray(_useState17, 2),
17722
+ loading = _useState18[0],
17723
+ setLoading = _useState18[1];
17724
+
17725
+ return React__default.createElement(
17726
+ Form,
17727
+ { className: 'login', id: 'signupForm', onSubmit: handleSubmit },
17728
+ React__default.createElement(
17729
+ 'h1',
17730
+ null,
17731
+ 'Profile'
17732
+ ),
17733
+ React__default.createElement('hr', null),
17734
+ userData ? React__default.createElement(
17735
+ React__default.Fragment,
17736
+ null,
17737
+ returnFormField({ name: 'email', label: 'Email', type: 'email', required: true, readonly: true, default_value: userData.email }),
17738
+ React__default.createElement(
17739
+ Form.Row,
17740
+ null,
17741
+ returnFormField({ name: 'password', label: 'Password', type: 'password', groupType: Col$1, required: false }),
17742
+ returnFormField({ name: 'rpassword', label: 'Retype Password', type: 'password', groupType: Col$1, required: false })
17743
+ ),
17744
+ React__default.createElement(
17745
+ Form.Row,
17746
+ null,
17747
+ returnFormField({ name: 'first_name', label: 'First Name', type: 'text', groupType: Col$1, required: true, default_value: userData.shared.first_name }),
17748
+ returnFormField({ name: 'last_name', label: 'Last Name', type: 'text', groupType: Col$1, required: true, default_value: userData.shared.last_name })
17749
+ ),
17750
+ React__default.createElement(
17751
+ Form.Row,
17752
+ null,
17753
+ returnFormField({
17754
+ name: 'country',
17755
+ label: 'Country',
17756
+ type: 'select',
17757
+ required: true,
17758
+ groupType: Col$1,
17759
+ options: countries$1,
17760
+ handleChanged: handleCountryChanged,
17761
+ default_value: userData.shared.country
17762
+ }),
17763
+ countryUS && returnFormField({ name: 'state', label: 'State', type: 'select', required: true, groupType: Col$1, options: states, default_value: userData.shared.state })
17764
+ ),
17765
+ React__default.createElement(
17766
+ Form.Row,
17767
+ null,
17768
+ countryUS && returnFormField({ name: 'zip', label: 'Working Zip Code', type: 'text', required: true, groupType: Col$1, default_value: userData.shared.zip }),
17769
+ countryUS && returnFormField({ name: 'phone', label: 'Phone', type: 'text', required: true, groupType: Col$1, default_value: userData.shared.phone })
17770
+ ),
17771
+ returnFormField({
17772
+ name: 'healthcare_professional',
17773
+ label: 'Are You a Health Care Professional?',
17774
+ type: 'radio',
17775
+ required: true,
17776
+ options: [{ value: 'Y', label: 'Yes', checked: true }, { value: 'N', label: 'No', checked: false }],
17777
+ default_value: userData.shared.healthcare_professional,
17778
+ handleChanged: handleHealthcareProfessionalChanged
17779
+ }),
17780
+ healcareProfessional && returnFormField({
17781
+ name: 'occupation',
17782
+ label: 'Occupation',
17783
+ type: 'select',
17784
+ required: true,
17785
+ options: healthcareOccupation,
17786
+ handleChanged: handleOccupationChanged,
17787
+ default_value: userData.shared.occupation_id
17788
+ }),
17789
+ !healcareProfessional && returnFormField({
17790
+ name: 'occupation',
17791
+ label: 'Non Provider Role',
17792
+ type: 'select',
17793
+ required: true,
17794
+ options: nonHealthcareOccupation,
17795
+ handleChanged: handleOccupationChanged,
17796
+ default_value: userData.shared.occupation_id
17797
+ }),
17798
+ occupationFields && occupationFields.map(function (field) {
17799
+ return returnFormField({
17800
+ name: field.name,
17801
+ label: field.label,
17802
+ type: field.type,
17803
+ required: field.required === 1,
17804
+ options: field.options,
17805
+ default_value: userData.shared[field.name]
17806
+ });
17807
+ }),
17808
+ returnFormField({
17809
+ name: 'agree',
17810
+ label: 'Terms & Conditions | Privacy Policy',
17811
+ type: 'checkbox',
17812
+ required: true,
17813
+ options: [{ label: 'By registering you agree to our Terms and Conditions and Privacy Policy and understand that you will be receiving email communications', value: 'Y' }]
17814
+ }),
17815
+ React__default.createElement('hr', null),
17816
+ React__default.createElement(
17817
+ Form.Row,
17818
+ null,
17819
+ React__default.createElement(
17820
+ Form.Group,
17821
+ { as: Col$1 },
17822
+ !loading && React__default.createElement(
17823
+ Button$1,
17824
+ { type: 'submit' },
17825
+ 'Update'
17826
+ ),
17827
+ loading && React__default.createElement(
17828
+ Button$1,
17829
+ { variant: 'primary', disabled: true },
17830
+ React__default.createElement(Spinner$1, {
17831
+ as: 'span',
17832
+ animation: 'border',
17833
+ role: 'status',
17834
+ 'aria-hidden': 'true',
17835
+ size: 'sm'
17836
+ }),
17837
+ React__default.createElement(
17838
+ 'span',
17839
+ { className: 'sr-only' },
17840
+ 'Loading...'
17841
+ )
17842
+ )
17843
+ )
17844
+ )
17845
+ ) : React__default.createElement(Spinner$1, {
17846
+ as: 'span',
17847
+ animation: 'border',
17848
+ role: 'status',
17849
+ 'aria-hidden': 'true',
17850
+ size: 'sm'
17851
+ }),
17852
+ errorMsg && React__default.createElement(
17853
+ 'p',
17854
+ { className: 'error' },
17855
+ errorMsg
17856
+ ),
17857
+ successMsg && React__default.createElement(
17858
+ 'p',
17859
+ { className: 'success' },
17860
+ successMsg
17861
+ ),
17862
+ React__default.createElement(
17863
+ 'style',
17864
+ { jsx: 'true'.toString() },
17865
+ ' \n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n .success {\n color: green;\n margin: 1rem 0 0;\n }\n '
17866
+ )
17867
+ );
17868
+ };
17869
+
17870
+ /*!
17871
+ * cookie
17872
+ * Copyright(c) 2012-2014 Roman Shtylman
17873
+ * Copyright(c) 2015 Douglas Christopher Wilson
17874
+ * MIT Licensed
17875
+ */
17876
+
17877
+ /**
17878
+ * Module exports.
17879
+ * @public
17880
+ */
17881
+
17882
+ var parse_1 = parse$1;
17883
+ var serialize_1 = serialize$1;
17884
+
17885
+ /**
17886
+ * Module variables.
17887
+ * @private
17888
+ */
17889
+
17890
+ var decode = decodeURIComponent;
17891
+ var encode = encodeURIComponent;
17892
+ var pairSplitRegExp = /; */;
17893
+
17894
+ /**
17895
+ * RegExp to match field-content in RFC 7230 sec 3.2
17896
+ *
17897
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
17898
+ * field-vchar = VCHAR / obs-text
17899
+ * obs-text = %x80-FF
17900
+ */
17901
+
17902
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
17903
+
17904
+ /**
17905
+ * Parse a cookie header.
17906
+ *
17907
+ * Parse the given cookie header string into an object
17908
+ * The object has the various cookies as keys(names) => values
17909
+ *
17910
+ * @param {string} str
17911
+ * @param {object} [options]
17912
+ * @return {object}
17913
+ * @public
17914
+ */
17915
+
17916
+ function parse$1(str, options) {
17917
+ if (typeof str !== 'string') {
17918
+ throw new TypeError('argument str must be a string');
17919
+ }
17920
+
17921
+ var obj = {};
17922
+ var opt = options || {};
17923
+ var pairs = str.split(pairSplitRegExp);
17924
+ var dec = opt.decode || decode;
17925
+
17926
+ for (var i = 0; i < pairs.length; i++) {
17927
+ var pair = pairs[i];
17928
+ var eq_idx = pair.indexOf('=');
17929
+
17930
+ // skip things that don't look like key=value
17931
+ if (eq_idx < 0) {
17932
+ continue;
17933
+ }
17934
+
17935
+ var key = pair.substr(0, eq_idx).trim();
17936
+ var val = pair.substr(++eq_idx, pair.length).trim();
17937
+
17938
+ // quoted values
17939
+ if ('"' == val[0]) {
17940
+ val = val.slice(1, -1);
17941
+ }
17942
+
17943
+ // only assign once
17944
+ if (undefined == obj[key]) {
17945
+ obj[key] = tryDecode(val, dec);
17946
+ }
17947
+ }
17948
+
17949
+ return obj;
17950
+ }
17951
+
17952
+ /**
17953
+ * Serialize data into a cookie header.
17954
+ *
17955
+ * Serialize the a name value pair into a cookie string suitable for
17956
+ * http headers. An optional options object specified cookie parameters.
17957
+ *
17958
+ * serialize('foo', 'bar', { httpOnly: true })
17959
+ * => "foo=bar; httpOnly"
17960
+ *
17961
+ * @param {string} name
17962
+ * @param {string} val
17963
+ * @param {object} [options]
17964
+ * @return {string}
17965
+ * @public
17966
+ */
17967
+
17968
+ function serialize$1(name, val, options) {
17969
+ var opt = options || {};
17970
+ var enc = opt.encode || encode;
17971
+
17972
+ if (typeof enc !== 'function') {
17973
+ throw new TypeError('option encode is invalid');
17974
+ }
17975
+
17976
+ if (!fieldContentRegExp.test(name)) {
17977
+ throw new TypeError('argument name is invalid');
17978
+ }
17979
+
17980
+ var value = enc(val);
17981
+
17982
+ if (value && !fieldContentRegExp.test(value)) {
17983
+ throw new TypeError('argument val is invalid');
17984
+ }
17985
+
17986
+ var str = name + '=' + value;
17987
+
17988
+ if (null != opt.maxAge) {
17989
+ var maxAge = opt.maxAge - 0;
17990
+
17991
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
17992
+ throw new TypeError('option maxAge is invalid')
17993
+ }
17994
+
17995
+ str += '; Max-Age=' + Math.floor(maxAge);
17996
+ }
17997
+
17998
+ if (opt.domain) {
17999
+ if (!fieldContentRegExp.test(opt.domain)) {
18000
+ throw new TypeError('option domain is invalid');
18001
+ }
18002
+
18003
+ str += '; Domain=' + opt.domain;
18004
+ }
18005
+
18006
+ if (opt.path) {
18007
+ if (!fieldContentRegExp.test(opt.path)) {
18008
+ throw new TypeError('option path is invalid');
18009
+ }
18010
+
18011
+ str += '; Path=' + opt.path;
18012
+ }
18013
+
18014
+ if (opt.expires) {
18015
+ if (typeof opt.expires.toUTCString !== 'function') {
18016
+ throw new TypeError('option expires is invalid');
18017
+ }
18018
+
18019
+ str += '; Expires=' + opt.expires.toUTCString();
18020
+ }
18021
+
18022
+ if (opt.httpOnly) {
18023
+ str += '; HttpOnly';
18024
+ }
18025
+
18026
+ if (opt.secure) {
18027
+ str += '; Secure';
18028
+ }
18029
+
18030
+ if (opt.sameSite) {
18031
+ var sameSite = typeof opt.sameSite === 'string'
18032
+ ? opt.sameSite.toLowerCase() : opt.sameSite;
18033
+
18034
+ switch (sameSite) {
18035
+ case true:
18036
+ str += '; SameSite=Strict';
18037
+ break;
18038
+ case 'lax':
18039
+ str += '; SameSite=Lax';
18040
+ break;
18041
+ case 'strict':
18042
+ str += '; SameSite=Strict';
18043
+ break;
18044
+ case 'none':
18045
+ str += '; SameSite=None';
18046
+ break;
18047
+ default:
18048
+ throw new TypeError('option sameSite is invalid');
18049
+ }
18050
+ }
18051
+
18052
+ return str;
18053
+ }
18054
+
18055
+ /**
18056
+ * Try decoding a string using a decoding function.
18057
+ *
18058
+ * @param {string} str
18059
+ * @param {function} decode
18060
+ * @private
18061
+ */
18062
+
18063
+ function tryDecode(str, decode) {
18064
+ try {
18065
+ return decode(str);
18066
+ } catch (e) {
18067
+ return str;
18068
+ }
18069
+ }
18070
+
18071
+ var TOKEN_NAME = 'token';
18072
+ var MAX_AGE = 60 * 60 * 8; // 8 hours
18073
+
18074
+ function setTokenCookie(res, token, eKey) {
18075
+ var cookies_serailized = [];
18076
+ cookies_serailized.push(serialize_1(TOKEN_NAME, token, {
18077
+ //maxAge: MAX_AGE, // we want login cookie to expire when browser
18078
+ //expires: new Date(Date.now() + MAX_AGE * 1000),
18079
+ //httpOnly: true,
18080
+ //secure: process.env.NODE_ENV === 'production',
18081
+ path: '/'
18082
+ //sameSite: 'lax',
18083
+ }));
18084
+
18085
+ cookies_serailized.push(serialize_1('eKey', eKey, {
18086
+ //maxAge: MAX_AGE, // we want login cookie to expire when browser
18087
+ //expires: new Date(Date.now() + MAX_AGE * 1000),
18088
+ //httpOnly: true,
18089
+ //secure: process.env.NODE_ENV === 'production',
18090
+ path: '/'
18091
+ //sameSite: 'lax',
18092
+ }));
18093
+
18094
+ res.setHeader('Set-Cookie', cookies_serailized);
18095
+ }
18096
+
18097
+ function removeTokenCookie(res) {
18098
+ var cookies_serailized = [];
18099
+ cookies_serailized.push(serialize_1(TOKEN_NAME, '', {
18100
+ maxAge: -1,
18101
+ expires: new Date(Date.now() - MAX_AGE * 1000),
18102
+ path: '/'
18103
+ }));
18104
+ cookies_serailized.push(serialize_1('eKey', '', {
18105
+ maxAge: -1,
18106
+ expires: new Date(Date.now() - MAX_AGE * 1000),
18107
+ path: '/'
18108
+ }));
18109
+
18110
+ res.setHeader('Set-Cookie', cookies_serailized);
18111
+ }
18112
+
18113
+ function parseCookies(req) {
18114
+ // For API Routes we don't need to parse the cookies.
18115
+ if (req.cookies) return req.cookies;
18116
+
18117
+ // For pages we do need to parse the cookies.
18118
+ var cookie = req.headers ? req.headers.cookie : null;
18119
+ return parse_1(cookie || '');
18120
+ }
18121
+
18122
+ function getTokenCookie(req) {
18123
+ var cookies = parseCookies(req);
18124
+ return cookies[TOKEN_NAME];
18125
+ }
18126
+
18127
+ var authCookies = /*#__PURE__*/Object.freeze({
18128
+ __proto__: null,
18129
+ setTokenCookie: setTokenCookie,
18130
+ removeTokenCookie: removeTokenCookie,
18131
+ parseCookies: parseCookies,
18132
+ getTokenCookie: getTokenCookie
18133
+ });
18134
+
18135
+ var TOKEN_SECRET = ',Qjn4rG\'Is=&wx,EXd<AYW|<{THTrspDkKJV5J{@@=?zDh,OX6Ky=0&T"L419;)';
18136
+
18137
+ function encryptSession(session) {
18138
+ return Iron.seal(session, TOKEN_SECRET, Iron.defaults);
18139
+ }
18140
+
18141
+ var getSession = function () {
18142
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(req) {
18143
+ var token;
18144
+ return regenerator.wrap(function _callee$(_context) {
18145
+ while (1) {
18146
+ switch (_context.prev = _context.next) {
18147
+ case 0:
18148
+ token = getTokenCookie(req);
18149
+ return _context.abrupt('return', token ? Iron.unseal(token, TOKEN_SECRET, Iron.defaults) : null);
18150
+
18151
+ case 2:
18152
+ case 'end':
18153
+ return _context.stop();
18154
+ }
18155
+ }
18156
+ }, _callee, this);
18157
+ }));
18158
+
18159
+ return function getSession(_x) {
18160
+ return _ref.apply(this, arguments);
18161
+ };
18162
+ }();
18163
+
18164
+ var iron = /*#__PURE__*/Object.freeze({
18165
+ __proto__: null,
18166
+ encryptSession: encryptSession,
18167
+ getSession: getSession
18168
+ });
18169
+
18170
+ var toStr = Object.prototype.toString;
18171
+
18172
+ var isArguments$1 = function isArguments(value) {
18173
+ var str = toStr.call(value);
18174
+ var isArgs = str === '[object Arguments]';
18175
+ if (!isArgs) {
18176
+ isArgs = str !== '[object Array]' &&
18177
+ value !== null &&
18178
+ typeof value === 'object' &&
18179
+ typeof value.length === 'number' &&
18180
+ value.length >= 0 &&
18181
+ toStr.call(value.callee) === '[object Function]';
18182
+ }
18183
+ return isArgs;
18184
+ };
18185
+
18186
+ var keysShim;
18187
+ if (!Object.keys) {
18188
+ // modified from https://github.com/es-shims/es5-shim
18189
+ var has$1 = Object.prototype.hasOwnProperty;
18190
+ var toStr$1 = Object.prototype.toString;
18191
+ var isArgs = isArguments$1; // eslint-disable-line global-require
18192
+ var isEnumerable = Object.prototype.propertyIsEnumerable;
18193
+ var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
18194
+ var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
18195
+ var dontEnums = [
18196
+ 'toString',
18197
+ 'toLocaleString',
18198
+ 'valueOf',
18199
+ 'hasOwnProperty',
18200
+ 'isPrototypeOf',
18201
+ 'propertyIsEnumerable',
18202
+ 'constructor'
18203
+ ];
18204
+ var equalsConstructorPrototype = function (o) {
18205
+ var ctor = o.constructor;
18206
+ return ctor && ctor.prototype === o;
18207
+ };
18208
+ var excludedKeys = {
18209
+ $applicationCache: true,
18210
+ $console: true,
18211
+ $external: true,
18212
+ $frame: true,
18213
+ $frameElement: true,
18214
+ $frames: true,
18215
+ $innerHeight: true,
18216
+ $innerWidth: true,
18217
+ $onmozfullscreenchange: true,
18218
+ $onmozfullscreenerror: true,
18219
+ $outerHeight: true,
18220
+ $outerWidth: true,
18221
+ $pageXOffset: true,
18222
+ $pageYOffset: true,
18223
+ $parent: true,
18224
+ $scrollLeft: true,
18225
+ $scrollTop: true,
18226
+ $scrollX: true,
18227
+ $scrollY: true,
18228
+ $self: true,
18229
+ $webkitIndexedDB: true,
18230
+ $webkitStorageInfo: true,
18231
+ $window: true
18232
+ };
18233
+ var hasAutomationEqualityBug = (function () {
18234
+ /* global window */
18235
+ if (typeof window === 'undefined') { return false; }
18236
+ for (var k in window) {
18237
+ try {
18238
+ if (!excludedKeys['$' + k] && has$1.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
18239
+ try {
18240
+ equalsConstructorPrototype(window[k]);
18241
+ } catch (e) {
18242
+ return true;
18243
+ }
18244
+ }
18245
+ } catch (e) {
18246
+ return true;
18247
+ }
18248
+ }
18249
+ return false;
18250
+ }());
18251
+ var equalsConstructorPrototypeIfNotBuggy = function (o) {
18252
+ /* global window */
18253
+ if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
18254
+ return equalsConstructorPrototype(o);
18255
+ }
18256
+ try {
18257
+ return equalsConstructorPrototype(o);
18258
+ } catch (e) {
18259
+ return false;
18260
+ }
18261
+ };
18262
+
18263
+ keysShim = function keys(object) {
18264
+ var isObject = object !== null && typeof object === 'object';
18265
+ var isFunction = toStr$1.call(object) === '[object Function]';
18266
+ var isArguments = isArgs(object);
18267
+ var isString = isObject && toStr$1.call(object) === '[object String]';
18268
+ var theKeys = [];
18269
+
18270
+ if (!isObject && !isFunction && !isArguments) {
18271
+ throw new TypeError('Object.keys called on a non-object');
18272
+ }
18273
+
18274
+ var skipProto = hasProtoEnumBug && isFunction;
18275
+ if (isString && object.length > 0 && !has$1.call(object, 0)) {
18276
+ for (var i = 0; i < object.length; ++i) {
18277
+ theKeys.push(String(i));
18278
+ }
18279
+ }
18280
+
18281
+ if (isArguments && object.length > 0) {
18282
+ for (var j = 0; j < object.length; ++j) {
18283
+ theKeys.push(String(j));
18284
+ }
18285
+ } else {
18286
+ for (var name in object) {
18287
+ if (!(skipProto && name === 'prototype') && has$1.call(object, name)) {
18288
+ theKeys.push(String(name));
18289
+ }
18290
+ }
18291
+ }
18292
+
18293
+ if (hasDontEnumBug) {
18294
+ var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
18295
+
18296
+ for (var k = 0; k < dontEnums.length; ++k) {
18297
+ if (!(skipConstructor && dontEnums[k] === 'constructor') && has$1.call(object, dontEnums[k])) {
18298
+ theKeys.push(dontEnums[k]);
18299
+ }
18300
+ }
18301
+ }
18302
+ return theKeys;
18303
+ };
18304
+ }
18305
+ var implementation = keysShim;
18306
+
18307
+ var slice$1 = Array.prototype.slice;
18308
+
18309
+
18310
+ var origKeys = Object.keys;
18311
+ var keysShim$1 = origKeys ? function keys(o) { return origKeys(o); } : implementation;
18312
+
18313
+ var originalKeys = Object.keys;
18314
+
18315
+ keysShim$1.shim = function shimObjectKeys() {
18316
+ if (Object.keys) {
18317
+ var keysWorksWithArguments = (function () {
18318
+ // Safari 5.0 bug
18319
+ var args = Object.keys(arguments);
18320
+ return args && args.length === arguments.length;
18321
+ }(1, 2));
18322
+ if (!keysWorksWithArguments) {
18323
+ Object.keys = function keys(object) { // eslint-disable-line func-name-matching
18324
+ if (isArguments$1(object)) {
18325
+ return originalKeys(slice$1.call(object));
18326
+ }
18327
+ return originalKeys(object);
18328
+ };
18329
+ }
18330
+ } else {
18331
+ Object.keys = keysShim$1;
18332
+ }
18333
+ return Object.keys || keysShim$1;
18334
+ };
18335
+
18336
+ var objectKeys = keysShim$1;
18337
+
18338
+ var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
18339
+
18340
+ var toStr$2 = Object.prototype.toString;
18341
+ var concat = Array.prototype.concat;
18342
+ var origDefineProperty = Object.defineProperty;
18343
+
18344
+ var isFunction$1 = function (fn) {
18345
+ return typeof fn === 'function' && toStr$2.call(fn) === '[object Function]';
18346
+ };
18347
+
18348
+ var arePropertyDescriptorsSupported = function () {
18349
+ var obj = {};
18350
+ try {
18351
+ origDefineProperty(obj, 'x', { enumerable: false, value: obj });
18352
+ // eslint-disable-next-line no-unused-vars, no-restricted-syntax
18353
+ for (var _ in obj) { // jscs:ignore disallowUnusedVariables
18354
+ return false;
18355
+ }
18356
+ return obj.x === obj;
18357
+ } catch (e) { /* this is IE 8. */
18358
+ return false;
18359
+ }
18360
+ };
18361
+ var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
18362
+
18363
+ var defineProperty$1 = function (object, name, value, predicate) {
18364
+ if (name in object && (!isFunction$1(predicate) || !predicate())) {
18365
+ return;
18366
+ }
18367
+ if (supportsDescriptors) {
18368
+ origDefineProperty(object, name, {
18369
+ configurable: true,
18370
+ enumerable: false,
18371
+ value: value,
18372
+ writable: true
18373
+ });
18374
+ } else {
18375
+ object[name] = value;
18376
+ }
18377
+ };
18378
+
18379
+ var defineProperties = function (object, map) {
18380
+ var predicates = arguments.length > 2 ? arguments[2] : {};
18381
+ var props = objectKeys(map);
18382
+ if (hasSymbols) {
18383
+ props = concat.call(props, Object.getOwnPropertySymbols(map));
18384
+ }
18385
+ for (var i = 0; i < props.length; i += 1) {
18386
+ defineProperty$1(object, props[i], map[props[i]], predicates[props[i]]);
18387
+ }
18388
+ };
18389
+
18390
+ defineProperties.supportsDescriptors = !!supportsDescriptors;
18391
+
18392
+ var defineProperties_1 = defineProperties;
18393
+
18394
+ /* eslint complexity: [2, 18], max-statements: [2, 33] */
18395
+ var shams = function hasSymbols() {
18396
+ if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
18397
+ if (typeof Symbol.iterator === 'symbol') { return true; }
18398
+
18399
+ var obj = {};
18400
+ var sym = Symbol('test');
18401
+ var symObj = Object(sym);
18402
+ if (typeof sym === 'string') { return false; }
18403
+
18404
+ if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
18405
+ if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
18406
+
18407
+ // temp disabled per https://github.com/ljharb/object.assign/issues/17
18408
+ // if (sym instanceof Symbol) { return false; }
18409
+ // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
18410
+ // if (!(symObj instanceof Symbol)) { return false; }
18411
+
18412
+ // if (typeof Symbol.prototype.toString !== 'function') { return false; }
18413
+ // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
18414
+
18415
+ var symVal = 42;
18416
+ obj[sym] = symVal;
18417
+ for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
18418
+ if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
18419
+
18420
+ if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
18421
+
18422
+ var syms = Object.getOwnPropertySymbols(obj);
18423
+ if (syms.length !== 1 || syms[0] !== sym) { return false; }
18424
+
18425
+ if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
18426
+
18427
+ if (typeof Object.getOwnPropertyDescriptor === 'function') {
18428
+ var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
18429
+ if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
18430
+ }
18431
+
18432
+ return true;
18433
+ };
18434
+
18435
+ var origSymbol = commonjsGlobal.Symbol;
18436
+
18437
+
18438
+ var hasSymbols$1 = function hasNativeSymbols() {
18439
+ if (typeof origSymbol !== 'function') { return false; }
18440
+ if (typeof Symbol !== 'function') { return false; }
18441
+ if (typeof origSymbol('foo') !== 'symbol') { return false; }
18442
+ if (typeof Symbol('bar') !== 'symbol') { return false; }
18443
+
18444
+ return shams();
18445
+ };
18446
+
18447
+ /* eslint no-invalid-this: 1 */
18448
+
18449
+ var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
18450
+ var slice$2 = Array.prototype.slice;
18451
+ var toStr$3 = Object.prototype.toString;
18452
+ var funcType = '[object Function]';
18453
+
18454
+ var implementation$1 = function bind(that) {
18455
+ var target = this;
18456
+ if (typeof target !== 'function' || toStr$3.call(target) !== funcType) {
18457
+ throw new TypeError(ERROR_MESSAGE + target);
18458
+ }
18459
+ var args = slice$2.call(arguments, 1);
18460
+
18461
+ var bound;
18462
+ var binder = function () {
18463
+ if (this instanceof bound) {
18464
+ var result = target.apply(
18465
+ this,
18466
+ args.concat(slice$2.call(arguments))
18467
+ );
18468
+ if (Object(result) === result) {
18469
+ return result;
18470
+ }
18471
+ return this;
18472
+ } else {
18473
+ return target.apply(
18474
+ that,
18475
+ args.concat(slice$2.call(arguments))
18476
+ );
18477
+ }
18478
+ };
18479
+
18480
+ var boundLength = Math.max(0, target.length - args.length);
18481
+ var boundArgs = [];
18482
+ for (var i = 0; i < boundLength; i++) {
18483
+ boundArgs.push('$' + i);
18484
+ }
18485
+
18486
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
18487
+
18488
+ if (target.prototype) {
18489
+ var Empty = function Empty() {};
18490
+ Empty.prototype = target.prototype;
18491
+ bound.prototype = new Empty();
18492
+ Empty.prototype = null;
18493
+ }
18494
+
18495
+ return bound;
18496
+ };
18497
+
18498
+ var functionBind = Function.prototype.bind || implementation$1;
18499
+
18500
+ /* globals
18501
+ Atomics,
18502
+ SharedArrayBuffer,
18503
+ */
18504
+
18505
+ var undefined$1;
18506
+
18507
+ var $TypeError = TypeError;
18508
+
18509
+ var $gOPD = Object.getOwnPropertyDescriptor;
18510
+ if ($gOPD) {
18511
+ try {
18512
+ $gOPD({}, '');
18513
+ } catch (e) {
18514
+ $gOPD = null; // this is IE 8, which has a broken gOPD
18515
+ }
18516
+ }
18517
+
18518
+ var throwTypeError = function () { throw new $TypeError(); };
18519
+ var ThrowTypeError = $gOPD
18520
+ ? (function () {
18521
+ try {
18522
+ // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
18523
+ arguments.callee; // IE 8 does not throw here
18524
+ return throwTypeError;
18525
+ } catch (calleeThrows) {
18526
+ try {
18527
+ // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
18528
+ return $gOPD(arguments, 'callee').get;
18529
+ } catch (gOPDthrows) {
18530
+ return throwTypeError;
18531
+ }
18532
+ }
18533
+ }())
18534
+ : throwTypeError;
18535
+
18536
+ var hasSymbols$2 = hasSymbols$1();
18537
+
18538
+ var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
18539
+ var generatorFunction = undefined$1;
18540
+ var asyncFunction = undefined$1;
18541
+ var asyncGenFunction = undefined$1;
18542
+
18543
+ var TypedArray = typeof Uint8Array === 'undefined' ? undefined$1 : getProto(Uint8Array);
18544
+
18545
+ var INTRINSICS = {
18546
+ '%Array%': Array,
18547
+ '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
18548
+ '%ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer.prototype,
18549
+ '%ArrayIteratorPrototype%': hasSymbols$2 ? getProto([][Symbol.iterator]()) : undefined$1,
18550
+ '%ArrayPrototype%': Array.prototype,
18551
+ '%ArrayProto_entries%': Array.prototype.entries,
18552
+ '%ArrayProto_forEach%': Array.prototype.forEach,
18553
+ '%ArrayProto_keys%': Array.prototype.keys,
18554
+ '%ArrayProto_values%': Array.prototype.values,
18555
+ '%AsyncFromSyncIteratorPrototype%': undefined$1,
18556
+ '%AsyncFunction%': asyncFunction,
18557
+ '%AsyncFunctionPrototype%': undefined$1,
18558
+ '%AsyncGenerator%': undefined$1,
18559
+ '%AsyncGeneratorFunction%': asyncGenFunction,
18560
+ '%AsyncGeneratorPrototype%': undefined$1,
18561
+ '%AsyncIteratorPrototype%': undefined$1,
18562
+ '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
18563
+ '%Boolean%': Boolean,
18564
+ '%BooleanPrototype%': Boolean.prototype,
18565
+ '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
18566
+ '%DataViewPrototype%': typeof DataView === 'undefined' ? undefined$1 : DataView.prototype,
18567
+ '%Date%': Date,
18568
+ '%DatePrototype%': Date.prototype,
18569
+ '%decodeURI%': decodeURI,
18570
+ '%decodeURIComponent%': decodeURIComponent,
18571
+ '%encodeURI%': encodeURI,
18572
+ '%encodeURIComponent%': encodeURIComponent,
18573
+ '%Error%': Error,
18574
+ '%ErrorPrototype%': Error.prototype,
18575
+ '%eval%': eval, // eslint-disable-line no-eval
18576
+ '%EvalError%': EvalError,
18577
+ '%EvalErrorPrototype%': EvalError.prototype,
18578
+ '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
18579
+ '%Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array.prototype,
18580
+ '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
18581
+ '%Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array.prototype,
18582
+ '%Function%': Function,
18583
+ '%FunctionPrototype%': Function.prototype,
18584
+ '%Generator%': undefined$1,
18585
+ '%GeneratorFunction%': generatorFunction,
18586
+ '%GeneratorPrototype%': undefined$1,
18587
+ '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
18588
+ '%Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array.prototype,
18589
+ '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
18590
+ '%Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined$1 : Int8Array.prototype,
18591
+ '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
18592
+ '%Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array.prototype,
18593
+ '%isFinite%': isFinite,
18594
+ '%isNaN%': isNaN,
18595
+ '%IteratorPrototype%': hasSymbols$2 ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
18596
+ '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
18597
+ '%JSONParse%': typeof JSON === 'object' ? JSON.parse : undefined$1,
18598
+ '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
18599
+ '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
18600
+ '%MapPrototype%': typeof Map === 'undefined' ? undefined$1 : Map.prototype,
18601
+ '%Math%': Math,
18602
+ '%Number%': Number,
18603
+ '%NumberPrototype%': Number.prototype,
18604
+ '%Object%': Object,
18605
+ '%ObjectPrototype%': Object.prototype,
18606
+ '%ObjProto_toString%': Object.prototype.toString,
18607
+ '%ObjProto_valueOf%': Object.prototype.valueOf,
18608
+ '%parseFloat%': parseFloat,
18609
+ '%parseInt%': parseInt,
18610
+ '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
18611
+ '%PromisePrototype%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype,
18612
+ '%PromiseProto_then%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype.then,
18613
+ '%Promise_all%': typeof Promise === 'undefined' ? undefined$1 : Promise.all,
18614
+ '%Promise_reject%': typeof Promise === 'undefined' ? undefined$1 : Promise.reject,
18615
+ '%Promise_resolve%': typeof Promise === 'undefined' ? undefined$1 : Promise.resolve,
18616
+ '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
18617
+ '%RangeError%': RangeError,
18618
+ '%RangeErrorPrototype%': RangeError.prototype,
18619
+ '%ReferenceError%': ReferenceError,
18620
+ '%ReferenceErrorPrototype%': ReferenceError.prototype,
18621
+ '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
18622
+ '%RegExp%': RegExp,
18623
+ '%RegExpPrototype%': RegExp.prototype,
18624
+ '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
18625
+ '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
18626
+ '%SetPrototype%': typeof Set === 'undefined' ? undefined$1 : Set.prototype,
18627
+ '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
18628
+ '%SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer.prototype,
18629
+ '%String%': String,
18630
+ '%StringIteratorPrototype%': hasSymbols$2 ? getProto(''[Symbol.iterator]()) : undefined$1,
18631
+ '%StringPrototype%': String.prototype,
18632
+ '%Symbol%': hasSymbols$2 ? Symbol : undefined$1,
18633
+ '%SymbolPrototype%': hasSymbols$2 ? Symbol.prototype : undefined$1,
18634
+ '%SyntaxError%': SyntaxError,
18635
+ '%SyntaxErrorPrototype%': SyntaxError.prototype,
18636
+ '%ThrowTypeError%': ThrowTypeError,
18637
+ '%TypedArray%': TypedArray,
18638
+ '%TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined$1,
18639
+ '%TypeError%': $TypeError,
18640
+ '%TypeErrorPrototype%': $TypeError.prototype,
18641
+ '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
18642
+ '%Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array.prototype,
18643
+ '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
18644
+ '%Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray.prototype,
18645
+ '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
18646
+ '%Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array.prototype,
18647
+ '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
18648
+ '%Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array.prototype,
18649
+ '%URIError%': URIError,
18650
+ '%URIErrorPrototype%': URIError.prototype,
18651
+ '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
18652
+ '%WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap.prototype,
18653
+ '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet,
18654
+ '%WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet.prototype
18655
+ };
18656
+
18657
+
18658
+ var $replace = functionBind.call(Function.call, String.prototype.replace);
18659
+
18660
+ /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
18661
+ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
18662
+ var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
18663
+ var stringToPath = function stringToPath(string) {
18664
+ var result = [];
18665
+ $replace(string, rePropName, function (match, number, quote, subString) {
18666
+ result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : (number || match);
18667
+ });
18668
+ return result;
18669
+ };
18670
+ /* end adaptation */
18671
+
18672
+ var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
18673
+ if (!(name in INTRINSICS)) {
18674
+ throw new SyntaxError('intrinsic ' + name + ' does not exist!');
18675
+ }
18676
+
18677
+ // istanbul ignore if // hopefully this is impossible to test :-)
18678
+ if (typeof INTRINSICS[name] === 'undefined' && !allowMissing) {
18679
+ throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
18680
+ }
18681
+
18682
+ return INTRINSICS[name];
18683
+ };
18684
+
18685
+ var GetIntrinsic = function GetIntrinsic(name, allowMissing) {
18686
+ if (typeof name !== 'string' || name.length === 0) {
18687
+ throw new TypeError('intrinsic name must be a non-empty string');
18688
+ }
18689
+ if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
18690
+ throw new TypeError('"allowMissing" argument must be a boolean');
18691
+ }
18692
+
18693
+ var parts = stringToPath(name);
18694
+
18695
+ var value = getBaseIntrinsic('%' + (parts.length > 0 ? parts[0] : '') + '%', allowMissing);
18696
+ for (var i = 1; i < parts.length; i += 1) {
18697
+ if (value != null) {
18698
+ if ($gOPD && (i + 1) >= parts.length) {
18699
+ var desc = $gOPD(value, parts[i]);
18700
+ value = desc ? (desc.get || desc.value) : value[parts[i]];
18701
+ } else {
18702
+ value = value[parts[i]];
18703
+ }
18704
+ }
18705
+ }
18706
+ return value;
18707
+ };
18708
+
18709
+ var $Function = GetIntrinsic('%Function%');
18710
+ var $apply = $Function.apply;
18711
+ var $call = $Function.call;
18712
+
18713
+ var callBind = function callBind() {
18714
+ return functionBind.apply($call, arguments);
18715
+ };
18716
+
18717
+ var apply = function applyBind() {
18718
+ return functionBind.apply($apply, arguments);
18719
+ };
18720
+ callBind.apply = apply;
18721
+
18722
+ var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
18723
+
18724
+ var callBound = function callBoundIntrinsic(name, allowMissing) {
18725
+ var intrinsic = GetIntrinsic(name, !!allowMissing);
18726
+ if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.')) {
18727
+ return callBind(intrinsic);
18728
+ }
18729
+ return intrinsic;
18730
+ };
18731
+
18732
+ var $defineProperty = GetIntrinsic('%Object.defineProperty%');
18733
+
18734
+
18735
+
18736
+ var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
18737
+
18738
+ // eslint-disable-next-line max-params
18739
+ var DefineOwnProperty = function DefineOwnProperty(IsDataDescriptor, SameValue, FromPropertyDescriptor, O, P, desc) {
18740
+ if (!$defineProperty) {
18741
+ if (!IsDataDescriptor(desc)) {
18742
+ // ES3 does not support getters/setters
18743
+ return false;
18744
+ }
18745
+ if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) {
18746
+ return false;
18747
+ }
18748
+
18749
+ // fallback for ES3
18750
+ if (P in O && $isEnumerable(O, P) !== !!desc['[[Enumerable]]']) {
18751
+ // a non-enumerable existing property
18752
+ return false;
18753
+ }
18754
+
18755
+ // property does not exist at all, or exists but is enumerable
18756
+ var V = desc['[[Value]]'];
18757
+ // eslint-disable-next-line no-param-reassign
18758
+ O[P] = V; // will use [[Define]]
18759
+ return SameValue(O[P], V);
18760
+ }
18761
+ $defineProperty(O, P, FromPropertyDescriptor(desc));
18762
+ return true;
18763
+ };
18764
+
18765
+ var src$1 = functionBind.call(Function.call, Object.prototype.hasOwnProperty);
18766
+
18767
+ var $TypeError$1 = GetIntrinsic('%TypeError%');
18768
+ var $SyntaxError = GetIntrinsic('%SyntaxError%');
18769
+
18770
+
18771
+
18772
+ var predicates = {
18773
+ // https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
18774
+ 'Property Descriptor': function isPropertyDescriptor(Type, Desc) {
18775
+ if (Type(Desc) !== 'Object') {
18776
+ return false;
18777
+ }
18778
+ var allowed = {
18779
+ '[[Configurable]]': true,
18780
+ '[[Enumerable]]': true,
18781
+ '[[Get]]': true,
18782
+ '[[Set]]': true,
18783
+ '[[Value]]': true,
18784
+ '[[Writable]]': true
18785
+ };
18786
+
18787
+ for (var key in Desc) { // eslint-disable-line
18788
+ if (src$1(Desc, key) && !allowed[key]) {
18789
+ return false;
18790
+ }
18791
+ }
18792
+
18793
+ var isData = src$1(Desc, '[[Value]]');
18794
+ var IsAccessor = src$1(Desc, '[[Get]]') || src$1(Desc, '[[Set]]');
18795
+ if (isData && IsAccessor) {
18796
+ throw new $TypeError$1('Property Descriptors may not be both accessor and data descriptors');
18797
+ }
18798
+ return true;
18799
+ }
18800
+ };
18801
+
18802
+ var assertRecord = function assertRecord(Type, recordType, argumentName, value) {
18803
+ var predicate = predicates[recordType];
18804
+ if (typeof predicate !== 'function') {
18805
+ throw new $SyntaxError('unknown record type: ' + recordType);
18806
+ }
18807
+ if (!predicate(Type, value)) {
18808
+ throw new $TypeError$1(argumentName + ' must be a ' + recordType);
18809
+ }
18810
+ };
18811
+
18812
+ // https://www.ecma-international.org/ecma-262/5.1/#sec-8
18813
+
18814
+ var Type = function Type(x) {
18815
+ if (x === null) {
18816
+ return 'Null';
18817
+ }
18818
+ if (typeof x === 'undefined') {
18819
+ return 'Undefined';
18820
+ }
18821
+ if (typeof x === 'function' || typeof x === 'object') {
18822
+ return 'Object';
18823
+ }
18824
+ if (typeof x === 'number') {
18825
+ return 'Number';
18826
+ }
18827
+ if (typeof x === 'boolean') {
18828
+ return 'Boolean';
18829
+ }
18830
+ if (typeof x === 'string') {
18831
+ return 'String';
18832
+ }
18833
+ };
18834
+
18835
+ // https://www.ecma-international.org/ecma-262/6.0/#sec-tostring
18836
+
18837
+ var Type$1 = function Type$1(x) {
18838
+ if (typeof x === 'symbol') {
18839
+ return 'Symbol';
18840
+ }
18841
+ return Type(x);
18842
+ };
18843
+
18844
+ // https://www.ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
18845
+
18846
+ var FromPropertyDescriptor = function FromPropertyDescriptor(Desc) {
18847
+ if (typeof Desc === 'undefined') {
18848
+ return Desc;
18849
+ }
18850
+
18851
+ assertRecord(Type$1, 'Property Descriptor', 'Desc', Desc);
18852
+
18853
+ var obj = {};
18854
+ if ('[[Value]]' in Desc) {
18855
+ obj.value = Desc['[[Value]]'];
18856
+ }
18857
+ if ('[[Writable]]' in Desc) {
18858
+ obj.writable = Desc['[[Writable]]'];
18859
+ }
18860
+ if ('[[Get]]' in Desc) {
18861
+ obj.get = Desc['[[Get]]'];
18862
+ }
18863
+ if ('[[Set]]' in Desc) {
18864
+ obj.set = Desc['[[Set]]'];
18865
+ }
18866
+ if ('[[Enumerable]]' in Desc) {
18867
+ obj.enumerable = Desc['[[Enumerable]]'];
18868
+ }
18869
+ if ('[[Configurable]]' in Desc) {
18870
+ obj.configurable = Desc['[[Configurable]]'];
18871
+ }
18872
+ return obj;
18873
+ };
18874
+
18875
+ // https://www.ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor
18876
+
18877
+ var IsDataDescriptor = function IsDataDescriptor(Desc) {
18878
+ if (typeof Desc === 'undefined') {
18879
+ return false;
18880
+ }
18881
+
18882
+ assertRecord(Type$1, 'Property Descriptor', 'Desc', Desc);
18883
+
18884
+ if (!src$1(Desc, '[[Value]]') && !src$1(Desc, '[[Writable]]')) {
18885
+ return false;
18886
+ }
18887
+
18888
+ return true;
18889
+ };
18890
+
18891
+ var isPrimitive$1 = function isPrimitive(value) {
18892
+ return value === null || (typeof value !== 'function' && typeof value !== 'object');
18893
+ };
18894
+
18895
+ var $Object = GetIntrinsic('%Object%');
18896
+
18897
+
18898
+
18899
+ var $preventExtensions = $Object.preventExtensions;
18900
+ var $isExtensible = $Object.isExtensible;
18901
+
18902
+ // https://www.ecma-international.org/ecma-262/6.0/#sec-isextensible-o
18903
+
18904
+ var IsExtensible = $preventExtensions
18905
+ ? function IsExtensible(obj) {
18906
+ return !isPrimitive$1(obj) && $isExtensible(obj);
18907
+ }
18908
+ : function IsExtensible(obj) { // eslint-disable-line no-unused-vars
18909
+ return true;
18910
+ };
18911
+
18912
+ // https://www.ecma-international.org/ecma-262/6.0/#sec-ispropertykey
18913
+
18914
+ var IsPropertyKey = function IsPropertyKey(argument) {
18915
+ return typeof argument === 'string' || typeof argument === 'symbol';
18916
+ };
18917
+
18918
+ var _isNaN = Number.isNaN || function isNaN(a) {
18919
+ return a !== a;
18920
+ };
18921
+
18922
+ // http://www.ecma-international.org/ecma-262/5.1/#sec-9.12
18923
+
18924
+ var SameValue = function SameValue(x, y) {
18925
+ if (x === y) { // 0 === -0, but they are not identical.
18926
+ if (x === 0) { return 1 / x === 1 / y; }
18927
+ return true;
18928
+ }
18929
+ return _isNaN(x) && _isNaN(y);
18930
+ };
18931
+
18932
+ var $gOPD$1 = GetIntrinsic('%Object.getOwnPropertyDescriptor%');
18933
+ var $TypeError$2 = GetIntrinsic('%TypeError%');
18934
+
18935
+
18936
+
18937
+
18938
+
18939
+
18940
+
18941
+
18942
+
18943
+
18944
+ // https://www.ecma-international.org/ecma-262/6.0/#sec-createdataproperty
18945
+
18946
+ var CreateDataProperty = function CreateDataProperty(O, P, V) {
18947
+ if (Type$1(O) !== 'Object') {
18948
+ throw new $TypeError$2('Assertion failed: Type(O) is not Object');
18949
+ }
18950
+ if (!IsPropertyKey(P)) {
18951
+ throw new $TypeError$2('Assertion failed: IsPropertyKey(P) is not true');
18952
+ }
18953
+ var oldDesc = $gOPD$1(O, P);
18954
+ var extensible = oldDesc || IsExtensible(O);
18955
+ var immutable = oldDesc && (!oldDesc.writable || !oldDesc.configurable);
18956
+ if (immutable || !extensible) {
18957
+ return false;
18958
+ }
18959
+ return DefineOwnProperty(
18960
+ IsDataDescriptor,
18961
+ SameValue,
18962
+ FromPropertyDescriptor,
18963
+ O,
18964
+ P,
18965
+ {
18966
+ '[[Configurable]]': true,
18967
+ '[[Enumerable]]': true,
18968
+ '[[Value]]': V,
18969
+ '[[Writable]]': true
18970
+ }
18971
+ );
18972
+ };
18973
+
18974
+ var fnToStr = Function.prototype.toString;
18975
+
18976
+ var constructorRegex = /^\s*class\b/;
18977
+ var isES6ClassFn = function isES6ClassFunction(value) {
18978
+ try {
18979
+ var fnStr = fnToStr.call(value);
18980
+ return constructorRegex.test(fnStr);
18981
+ } catch (e) {
18982
+ return false; // not a function
18983
+ }
18984
+ };
18985
+
18986
+ var tryFunctionObject = function tryFunctionToStr(value) {
18987
+ try {
18988
+ if (isES6ClassFn(value)) { return false; }
18989
+ fnToStr.call(value);
18990
+ return true;
18991
+ } catch (e) {
18992
+ return false;
18993
+ }
18994
+ };
18995
+ var toStr$4 = Object.prototype.toString;
18996
+ var fnClass = '[object Function]';
18997
+ var genClass = '[object GeneratorFunction]';
18998
+ var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
18999
+
19000
+ var isCallable = function isCallable(value) {
19001
+ if (!value) { return false; }
19002
+ if (typeof value !== 'function' && typeof value !== 'object') { return false; }
19003
+ if (typeof value === 'function' && !value.prototype) { return true; }
19004
+ if (hasToStringTag) { return tryFunctionObject(value); }
19005
+ if (isES6ClassFn(value)) { return false; }
19006
+ var strClass = toStr$4.call(value);
19007
+ return strClass === fnClass || strClass === genClass;
19008
+ };
19009
+
19010
+ // http://www.ecma-international.org/ecma-262/5.1/#sec-9.11
19011
+
19012
+ var IsCallable = isCallable;
19013
+
19014
+ var $TypeError$3 = GetIntrinsic('%TypeError%');
19015
+
19016
+ // http://www.ecma-international.org/ecma-262/5.1/#sec-9.10
19017
+
19018
+ var CheckObjectCoercible = function CheckObjectCoercible(value, optMessage) {
19019
+ if (value == null) {
19020
+ throw new $TypeError$3(optMessage || ('Cannot call method on ' + value));
19021
+ }
19022
+ return value;
19023
+ };
19024
+
19025
+ var RequireObjectCoercible = CheckObjectCoercible;
19026
+
19027
+ var $Object$1 = GetIntrinsic('%Object%');
19028
+
19029
+
19030
+
19031
+ // https://www.ecma-international.org/ecma-262/6.0/#sec-toobject
19032
+
19033
+ var ToObject = function ToObject(value) {
19034
+ RequireObjectCoercible(value);
19035
+ return $Object$1(value);
19036
+ };
19037
+
19038
+ var $gOPD$2 = Object.getOwnPropertyDescriptor;
19039
+ var $getOwnNames = Object.getOwnPropertyNames;
19040
+ var $getSymbols = Object.getOwnPropertySymbols;
19041
+ var $concat = callBound('Array.prototype.concat');
19042
+ var $reduce = callBound('Array.prototype.reduce');
19043
+ var getAll = $getSymbols ? function (obj) {
19044
+ return $concat($getOwnNames(obj), $getSymbols(obj));
19045
+ } : $getOwnNames;
19046
+
19047
+ var isES5 = IsCallable($gOPD$2) && IsCallable($getOwnNames);
19048
+
19049
+ var implementation$2 = function getOwnPropertyDescriptors(value) {
19050
+ RequireObjectCoercible(value);
19051
+ if (!isES5) {
19052
+ throw new TypeError('getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor');
19053
+ }
19054
+
19055
+ var O = ToObject(value);
19056
+ return $reduce(
19057
+ getAll(O),
19058
+ function (acc, key) {
19059
+ var descriptor = $gOPD$2(O, key);
19060
+ if (typeof descriptor !== 'undefined') {
19061
+ CreateDataProperty(acc, key, descriptor);
19062
+ }
19063
+ return acc;
19064
+ },
19065
+ {}
19066
+ );
19067
+ };
19068
+
19069
+ var polyfill = function getPolyfill() {
19070
+ return typeof Object.getOwnPropertyDescriptors === 'function' ? Object.getOwnPropertyDescriptors : implementation$2;
19071
+ };
19072
+
19073
+ var shim = function shimGetOwnPropertyDescriptors() {
19074
+ var polyfill$1 = polyfill();
19075
+ defineProperties_1(
19076
+ Object,
19077
+ { getOwnPropertyDescriptors: polyfill$1 },
19078
+ { getOwnPropertyDescriptors: function () { return Object.getOwnPropertyDescriptors !== polyfill$1; } }
19079
+ );
19080
+ return polyfill$1;
19081
+ };
19082
+
19083
+ defineProperties_1(implementation$2, {
19084
+ getPolyfill: polyfill,
19085
+ implementation: implementation$2,
19086
+ shim: shim
19087
+ });
19088
+
19089
+ var object_getownpropertydescriptors = implementation$2;
19090
+
19091
+ /* globals
19092
+ Atomics,
19093
+ SharedArrayBuffer,
19094
+ */
19095
+
19096
+ var undefined$2;
19097
+
19098
+ var $TypeError$4 = TypeError;
19099
+
19100
+ var $gOPD$3 = Object.getOwnPropertyDescriptor;
19101
+ if ($gOPD$3) {
19102
+ try {
19103
+ $gOPD$3({}, '');
19104
+ } catch (e) {
19105
+ $gOPD$3 = null; // this is IE 8, which has a broken gOPD
19106
+ }
19107
+ }
19108
+
19109
+ var throwTypeError$1 = function () { throw new $TypeError$4(); };
19110
+ var ThrowTypeError$1 = $gOPD$3
19111
+ ? (function () {
19112
+ try {
19113
+ // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
19114
+ arguments.callee; // IE 8 does not throw here
19115
+ return throwTypeError$1;
19116
+ } catch (calleeThrows) {
19117
+ try {
19118
+ // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
19119
+ return $gOPD$3(arguments, 'callee').get;
19120
+ } catch (gOPDthrows) {
19121
+ return throwTypeError$1;
19122
+ }
19123
+ }
19124
+ }())
19125
+ : throwTypeError$1;
19126
+
19127
+ var hasSymbols$3 = hasSymbols$1();
19128
+
19129
+ var getProto$1 = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
19130
+ var generatorFunction$1 = undefined$2;
19131
+ var asyncFunction$1 = undefined$2;
19132
+ var asyncGenFunction$1 = undefined$2;
19133
+
19134
+ var TypedArray$1 = typeof Uint8Array === 'undefined' ? undefined$2 : getProto$1(Uint8Array);
19135
+
19136
+ var INTRINSICS$1 = {
19137
+ '%Array%': Array,
19138
+ '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$2 : ArrayBuffer,
19139
+ '%ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined$2 : ArrayBuffer.prototype,
19140
+ '%ArrayIteratorPrototype%': hasSymbols$3 ? getProto$1([][Symbol.iterator]()) : undefined$2,
19141
+ '%ArrayPrototype%': Array.prototype,
19142
+ '%ArrayProto_entries%': Array.prototype.entries,
19143
+ '%ArrayProto_forEach%': Array.prototype.forEach,
19144
+ '%ArrayProto_keys%': Array.prototype.keys,
19145
+ '%ArrayProto_values%': Array.prototype.values,
19146
+ '%AsyncFromSyncIteratorPrototype%': undefined$2,
19147
+ '%AsyncFunction%': asyncFunction$1,
19148
+ '%AsyncFunctionPrototype%': undefined$2,
19149
+ '%AsyncGenerator%': undefined$2,
19150
+ '%AsyncGeneratorFunction%': asyncGenFunction$1,
19151
+ '%AsyncGeneratorPrototype%': undefined$2,
19152
+ '%AsyncIteratorPrototype%': undefined$2,
19153
+ '%Atomics%': typeof Atomics === 'undefined' ? undefined$2 : Atomics,
19154
+ '%Boolean%': Boolean,
19155
+ '%BooleanPrototype%': Boolean.prototype,
19156
+ '%DataView%': typeof DataView === 'undefined' ? undefined$2 : DataView,
19157
+ '%DataViewPrototype%': typeof DataView === 'undefined' ? undefined$2 : DataView.prototype,
19158
+ '%Date%': Date,
19159
+ '%DatePrototype%': Date.prototype,
19160
+ '%decodeURI%': decodeURI,
19161
+ '%decodeURIComponent%': decodeURIComponent,
19162
+ '%encodeURI%': encodeURI,
19163
+ '%encodeURIComponent%': encodeURIComponent,
19164
+ '%Error%': Error,
19165
+ '%ErrorPrototype%': Error.prototype,
19166
+ '%eval%': eval, // eslint-disable-line no-eval
19167
+ '%EvalError%': EvalError,
19168
+ '%EvalErrorPrototype%': EvalError.prototype,
19169
+ '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$2 : Float32Array,
19170
+ '%Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined$2 : Float32Array.prototype,
19171
+ '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$2 : Float64Array,
19172
+ '%Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined$2 : Float64Array.prototype,
19173
+ '%Function%': Function,
19174
+ '%FunctionPrototype%': Function.prototype,
19175
+ '%Generator%': undefined$2,
19176
+ '%GeneratorFunction%': generatorFunction$1,
19177
+ '%GeneratorPrototype%': undefined$2,
19178
+ '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$2 : Int8Array,
19179
+ '%Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined$2 : Int8Array.prototype,
19180
+ '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$2 : Int16Array,
19181
+ '%Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined$2 : Int8Array.prototype,
19182
+ '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$2 : Int32Array,
19183
+ '%Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined$2 : Int32Array.prototype,
19184
+ '%isFinite%': isFinite,
19185
+ '%isNaN%': isNaN,
19186
+ '%IteratorPrototype%': hasSymbols$3 ? getProto$1(getProto$1([][Symbol.iterator]())) : undefined$2,
19187
+ '%JSON%': typeof JSON === 'object' ? JSON : undefined$2,
19188
+ '%JSONParse%': typeof JSON === 'object' ? JSON.parse : undefined$2,
19189
+ '%Map%': typeof Map === 'undefined' ? undefined$2 : Map,
19190
+ '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$3 ? undefined$2 : getProto$1(new Map()[Symbol.iterator]()),
19191
+ '%MapPrototype%': typeof Map === 'undefined' ? undefined$2 : Map.prototype,
19192
+ '%Math%': Math,
19193
+ '%Number%': Number,
19194
+ '%NumberPrototype%': Number.prototype,
19195
+ '%Object%': Object,
19196
+ '%ObjectPrototype%': Object.prototype,
19197
+ '%ObjProto_toString%': Object.prototype.toString,
19198
+ '%ObjProto_valueOf%': Object.prototype.valueOf,
19199
+ '%parseFloat%': parseFloat,
19200
+ '%parseInt%': parseInt,
19201
+ '%Promise%': typeof Promise === 'undefined' ? undefined$2 : Promise,
19202
+ '%PromisePrototype%': typeof Promise === 'undefined' ? undefined$2 : Promise.prototype,
19203
+ '%PromiseProto_then%': typeof Promise === 'undefined' ? undefined$2 : Promise.prototype.then,
19204
+ '%Promise_all%': typeof Promise === 'undefined' ? undefined$2 : Promise.all,
19205
+ '%Promise_reject%': typeof Promise === 'undefined' ? undefined$2 : Promise.reject,
19206
+ '%Promise_resolve%': typeof Promise === 'undefined' ? undefined$2 : Promise.resolve,
19207
+ '%Proxy%': typeof Proxy === 'undefined' ? undefined$2 : Proxy,
19208
+ '%RangeError%': RangeError,
19209
+ '%RangeErrorPrototype%': RangeError.prototype,
19210
+ '%ReferenceError%': ReferenceError,
19211
+ '%ReferenceErrorPrototype%': ReferenceError.prototype,
19212
+ '%Reflect%': typeof Reflect === 'undefined' ? undefined$2 : Reflect,
19213
+ '%RegExp%': RegExp,
19214
+ '%RegExpPrototype%': RegExp.prototype,
19215
+ '%Set%': typeof Set === 'undefined' ? undefined$2 : Set,
19216
+ '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$3 ? undefined$2 : getProto$1(new Set()[Symbol.iterator]()),
19217
+ '%SetPrototype%': typeof Set === 'undefined' ? undefined$2 : Set.prototype,
19218
+ '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$2 : SharedArrayBuffer,
19219
+ '%SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined$2 : SharedArrayBuffer.prototype,
19220
+ '%String%': String,
19221
+ '%StringIteratorPrototype%': hasSymbols$3 ? getProto$1(''[Symbol.iterator]()) : undefined$2,
19222
+ '%StringPrototype%': String.prototype,
19223
+ '%Symbol%': hasSymbols$3 ? Symbol : undefined$2,
19224
+ '%SymbolPrototype%': hasSymbols$3 ? Symbol.prototype : undefined$2,
19225
+ '%SyntaxError%': SyntaxError,
19226
+ '%SyntaxErrorPrototype%': SyntaxError.prototype,
19227
+ '%ThrowTypeError%': ThrowTypeError$1,
19228
+ '%TypedArray%': TypedArray$1,
19229
+ '%TypedArrayPrototype%': TypedArray$1 ? TypedArray$1.prototype : undefined$2,
19230
+ '%TypeError%': $TypeError$4,
19231
+ '%TypeErrorPrototype%': $TypeError$4.prototype,
19232
+ '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$2 : Uint8Array,
19233
+ '%Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined$2 : Uint8Array.prototype,
19234
+ '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$2 : Uint8ClampedArray,
19235
+ '%Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined$2 : Uint8ClampedArray.prototype,
19236
+ '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$2 : Uint16Array,
19237
+ '%Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined$2 : Uint16Array.prototype,
19238
+ '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$2 : Uint32Array,
19239
+ '%Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined$2 : Uint32Array.prototype,
19240
+ '%URIError%': URIError,
19241
+ '%URIErrorPrototype%': URIError.prototype,
19242
+ '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$2 : WeakMap,
19243
+ '%WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined$2 : WeakMap.prototype,
19244
+ '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$2 : WeakSet,
19245
+ '%WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined$2 : WeakSet.prototype
19246
+ };
19247
+
19248
+
19249
+ var $replace$1 = functionBind.call(Function.call, String.prototype.replace);
19250
+
19251
+ /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
19252
+ var rePropName$1 = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
19253
+ var reEscapeChar$1 = /\\(\\)?/g; /** Used to match backslashes in property paths. */
19254
+ var stringToPath$1 = function stringToPath(string) {
19255
+ var result = [];
19256
+ $replace$1(string, rePropName$1, function (match, number, quote, subString) {
19257
+ result[result.length] = quote ? $replace$1(subString, reEscapeChar$1, '$1') : (number || match);
19258
+ });
19259
+ return result;
19260
+ };
19261
+ /* end adaptation */
19262
+
19263
+ var getBaseIntrinsic$1 = function getBaseIntrinsic(name, allowMissing) {
19264
+ if (!(name in INTRINSICS$1)) {
19265
+ throw new SyntaxError('intrinsic ' + name + ' does not exist!');
19266
+ }
19267
+
19268
+ // istanbul ignore if // hopefully this is impossible to test :-)
19269
+ if (typeof INTRINSICS$1[name] === 'undefined' && !allowMissing) {
19270
+ throw new $TypeError$4('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
19271
+ }
19272
+
19273
+ return INTRINSICS$1[name];
19274
+ };
19275
+
19276
+ var GetIntrinsic$1 = function GetIntrinsic(name, allowMissing) {
19277
+ if (typeof name !== 'string' || name.length === 0) {
19278
+ throw new TypeError('intrinsic name must be a non-empty string');
19279
+ }
19280
+ if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
19281
+ throw new TypeError('"allowMissing" argument must be a boolean');
19282
+ }
19283
+
19284
+ var parts = stringToPath$1(name);
19285
+
19286
+ var value = getBaseIntrinsic$1('%' + (parts.length > 0 ? parts[0] : '') + '%', allowMissing);
19287
+ for (var i = 1; i < parts.length; i += 1) {
19288
+ if (value != null) {
19289
+ if ($gOPD$3 && (i + 1) >= parts.length) {
19290
+ var desc = $gOPD$3(value, parts[i]);
19291
+ if (!allowMissing && !(parts[i] in value)) {
19292
+ throw new $TypeError$4('base intrinsic for ' + name + ' exists, but the property is not available.');
19293
+ }
19294
+ value = desc ? (desc.get || desc.value) : value[parts[i]];
19295
+ } else {
19296
+ value = value[parts[i]];
19297
+ }
19298
+ }
19299
+ }
19300
+ return value;
19301
+ };
19302
+
19303
+ var $apply$1 = GetIntrinsic$1('%Function.prototype.apply%');
19304
+ var $call$1 = GetIntrinsic$1('%Function.prototype.call%');
19305
+ var $reflectApply = GetIntrinsic$1('%Reflect.apply%', true) || functionBind.call($call$1, $apply$1);
19306
+
19307
+ var callBind$1 = function callBind() {
19308
+ return $reflectApply(functionBind, $call$1, arguments);
19309
+ };
19310
+
19311
+ var apply$1 = function applyBind() {
19312
+ return $reflectApply(functionBind, $apply$1, arguments);
19313
+ };
19314
+ callBind$1.apply = apply$1;
19315
+
19316
+ var $indexOf$1 = callBind$1(GetIntrinsic$1('String.prototype.indexOf'));
19317
+
19318
+ var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
19319
+ var intrinsic = GetIntrinsic$1(name, !!allowMissing);
19320
+ if (typeof intrinsic === 'function' && $indexOf$1(name, '.prototype.')) {
19321
+ return callBind$1(intrinsic);
19322
+ }
19323
+ return intrinsic;
19324
+ };
19325
+
19326
+ var isES5$1 = typeof Object.defineProperty === 'function'
19327
+ && typeof Object.defineProperties === 'function';
19328
+
19329
+ var hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
19330
+
19331
+ if (!isES5$1 || !hasProto) {
19332
+ throw new TypeError('util.promisify requires a true ES5 environment, that also supports `__proto__`');
19333
+ }
19334
+
19335
+
19336
+
19337
+ if (typeof Promise !== 'function') {
19338
+ throw new TypeError('`Promise` must be globally available for util.promisify to work.');
19339
+ }
19340
+
19341
+
19342
+
19343
+ var $slice = callBound$1('Array.prototype.slice');
19344
+ var $concat$1 = callBound$1('Array.prototype.concat');
19345
+ var $forEach = callBound$1('Array.prototype.forEach');
19346
+
19347
+ var hasSymbols$4 = hasSymbols$1();
19348
+
19349
+ var kCustomPromisifiedSymbol = hasSymbols$4 ? Symbol('util.promisify.custom') : null;
19350
+ var kCustomPromisifyArgsSymbol = hasSymbols$4 ? Symbol('customPromisifyArgs') : null;
19351
+
19352
+ var implementation$3 = function promisify(orig) {
19353
+ if (typeof orig !== 'function') {
19354
+ var error = new TypeError('The "original" argument must be of type function');
19355
+ error.name = 'TypeError [ERR_INVALID_ARG_TYPE]';
19356
+ error.code = 'ERR_INVALID_ARG_TYPE';
19357
+ throw error;
19358
+ }
19359
+
19360
+ if (hasSymbols$4 && orig[kCustomPromisifiedSymbol]) {
19361
+ var customFunction = orig[kCustomPromisifiedSymbol];
19362
+ if (typeof customFunction !== 'function') {
19363
+ throw new TypeError('The [util.promisify.custom] property must be a function');
19364
+ }
19365
+ Object.defineProperty(customFunction, kCustomPromisifiedSymbol, {
19366
+ configurable: true,
19367
+ enumerable: false,
19368
+ value: customFunction,
19369
+ writable: false
19370
+ });
19371
+ return customFunction;
19372
+ }
19373
+
19374
+ // Names to create an object from in case the callback receives multiple
19375
+ // arguments, e.g. ['stdout', 'stderr'] for child_process.exec.
19376
+ var argumentNames = orig[kCustomPromisifyArgsSymbol];
19377
+
19378
+ var promisified = function fn() {
19379
+ var args = $slice(arguments);
19380
+ var self = this; // eslint-disable-line no-invalid-this
19381
+ return new Promise(function (resolve, reject) {
19382
+ orig.apply(self, $concat$1(args, function (err) {
19383
+ var values = arguments.length > 1 ? $slice(arguments, 1) : [];
19384
+ if (err) {
19385
+ reject(err);
19386
+ } else if (typeof argumentNames !== 'undefined' && values.length > 1) {
19387
+ var obj = {};
19388
+ $forEach(argumentNames, function (name, index) {
19389
+ obj[name] = values[index];
19390
+ });
19391
+ resolve(obj);
19392
+ } else {
19393
+ resolve(values[0]);
19394
+ }
19395
+ }));
19396
+ });
19397
+ };
19398
+
19399
+ promisified.__proto__ = orig.__proto__; // eslint-disable-line no-proto
19400
+
19401
+ Object.defineProperty(promisified, kCustomPromisifiedSymbol, {
19402
+ configurable: true,
19403
+ enumerable: false,
19404
+ value: promisified,
19405
+ writable: false
19406
+ });
19407
+ return Object.defineProperties(promisified, object_getownpropertydescriptors(orig));
19408
+ };
19409
+
19410
+ var custom = kCustomPromisifiedSymbol;
19411
+ var customPromisifyArgs = kCustomPromisifyArgsSymbol;
19412
+ implementation$3.custom = custom;
19413
+ implementation$3.customPromisifyArgs = customPromisifyArgs;
19414
+
19415
+ var polyfill$1 = function getPolyfill() {
19416
+ if (typeof util.promisify === 'function') {
19417
+ return util.promisify;
19418
+ }
19419
+ return implementation$3;
19420
+ };
19421
+
19422
+ var shim$1 = function shimUtilPromisify() {
19423
+ var polyfill = polyfill$1();
19424
+ if (polyfill !== util.promisify) {
19425
+ Object.defineProperty(util, 'promisify', {
19426
+ configurable: true,
19427
+ enumerable: true,
19428
+ value: polyfill,
19429
+ writable: true
19430
+ });
19431
+ }
19432
+ return polyfill;
19433
+ };
19434
+
19435
+ var polyfill$2 = polyfill$1();
19436
+
19437
+
19438
+ /* eslint-disable no-unused-vars */
19439
+ var boundPromisify = function promisify(orig) {
19440
+ /* eslint-enable no-unused-vars */
19441
+ return polyfill$2.apply(util, arguments);
19442
+ };
19443
+ defineProperties_1(boundPromisify, {
19444
+ custom: polyfill$2.custom,
19445
+ customPromisifyArgs: polyfill$2.customPromisifyArgs,
19446
+ getPolyfill: polyfill$1,
19447
+ implementation: implementation$3,
19448
+ shim: shim$1
19449
+ });
19450
+
19451
+ var util_promisify = boundPromisify;
19452
+
19453
+ util_promisify.shim();
19454
+
19455
+ function connect() {
19456
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
19457
+
19458
+ if (!config) {
19459
+ config = {
19460
+ host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
19461
+ user: 'nasp',
19462
+ password: 'uRNkF9SkfXQs6AKK',
19463
+ database: 'user'
19464
+ };
19465
+ }
19466
+
19467
+ var connection = mysql.createConnection(config);
19468
+ return {
19469
+ query: function query(sql, args) {
19470
+ return util.promisify(connection.query).call(connection, sql, args);
19471
+ },
19472
+ beginTransaction: function beginTransaction() {
19473
+ return util.promisify(connection.beginTransaction).call(connection);
19474
+ },
19475
+ commit: function commit() {
19476
+ return util.promisify(connection.commit).call(connection);
19477
+ },
19478
+ rollback: function rollback() {
19479
+ return util.promisify(connection.rollback).call(connection);
19480
+ },
19481
+ close: function close() {
19482
+ return util.promisify(connection.end).call(connection);
19483
+ }
19484
+ };
19485
+ }
19486
+
19487
+ var db = connect;
19488
+
19489
+ var crypt = createCommonjsModule(function (module) {
19490
+ (function() {
19491
+ var base64map
19492
+ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
19493
+
19494
+ crypt = {
19495
+ // Bit-wise rotation left
19496
+ rotl: function(n, b) {
19497
+ return (n << b) | (n >>> (32 - b));
19498
+ },
19499
+
19500
+ // Bit-wise rotation right
19501
+ rotr: function(n, b) {
19502
+ return (n << (32 - b)) | (n >>> b);
19503
+ },
19504
+
19505
+ // Swap big-endian to little-endian and vice versa
19506
+ endian: function(n) {
19507
+ // If number given, swap endian
19508
+ if (n.constructor == Number) {
19509
+ return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
19510
+ }
19511
+
19512
+ // Else, assume array and swap all items
19513
+ for (var i = 0; i < n.length; i++)
19514
+ n[i] = crypt.endian(n[i]);
19515
+ return n;
19516
+ },
19517
+
19518
+ // Generate an array of any length of random bytes
19519
+ randomBytes: function(n) {
19520
+ for (var bytes = []; n > 0; n--)
19521
+ bytes.push(Math.floor(Math.random() * 256));
19522
+ return bytes;
19523
+ },
19524
+
19525
+ // Convert a byte array to big-endian 32-bit words
19526
+ bytesToWords: function(bytes) {
19527
+ for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
19528
+ words[b >>> 5] |= bytes[i] << (24 - b % 32);
19529
+ return words;
19530
+ },
19531
+
19532
+ // Convert big-endian 32-bit words to a byte array
19533
+ wordsToBytes: function(words) {
19534
+ for (var bytes = [], b = 0; b < words.length * 32; b += 8)
19535
+ bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
19536
+ return bytes;
19537
+ },
19538
+
19539
+ // Convert a byte array to a hex string
19540
+ bytesToHex: function(bytes) {
19541
+ for (var hex = [], i = 0; i < bytes.length; i++) {
19542
+ hex.push((bytes[i] >>> 4).toString(16));
19543
+ hex.push((bytes[i] & 0xF).toString(16));
19544
+ }
19545
+ return hex.join('');
19546
+ },
19547
+
19548
+ // Convert a hex string to a byte array
19549
+ hexToBytes: function(hex) {
19550
+ for (var bytes = [], c = 0; c < hex.length; c += 2)
19551
+ bytes.push(parseInt(hex.substr(c, 2), 16));
19552
+ return bytes;
19553
+ },
19554
+
19555
+ // Convert a byte array to a base-64 string
19556
+ bytesToBase64: function(bytes) {
19557
+ for (var base64 = [], i = 0; i < bytes.length; i += 3) {
19558
+ var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
19559
+ for (var j = 0; j < 4; j++)
19560
+ if (i * 8 + j * 6 <= bytes.length * 8)
19561
+ base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
19562
+ else
19563
+ base64.push('=');
19564
+ }
19565
+ return base64.join('');
19566
+ },
19567
+
19568
+ // Convert a base-64 string to a byte array
19569
+ base64ToBytes: function(base64) {
19570
+ // Remove non-base-64 characters
19571
+ base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
19572
+
19573
+ for (var bytes = [], i = 0, imod4 = 0; i < base64.length;
19574
+ imod4 = ++i % 4) {
19575
+ if (imod4 == 0) continue;
19576
+ bytes.push(((base64map.indexOf(base64.charAt(i - 1))
19577
+ & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))
19578
+ | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
19579
+ }
19580
+ return bytes;
19581
+ }
19582
+ };
19583
+
19584
+ module.exports = crypt;
19585
+ })();
19586
+ });
19587
+
19588
+ var charenc = {
19589
+ // UTF-8 encoding
19590
+ utf8: {
19591
+ // Convert a string to a byte array
19592
+ stringToBytes: function(str) {
19593
+ return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
19594
+ },
19595
+
19596
+ // Convert a byte array to a string
19597
+ bytesToString: function(bytes) {
19598
+ return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
19599
+ }
19600
+ },
19601
+
19602
+ // Binary encoding
19603
+ bin: {
19604
+ // Convert a string to a byte array
19605
+ stringToBytes: function(str) {
19606
+ for (var bytes = [], i = 0; i < str.length; i++)
19607
+ bytes.push(str.charCodeAt(i) & 0xFF);
19608
+ return bytes;
19609
+ },
19610
+
19611
+ // Convert a byte array to a string
19612
+ bytesToString: function(bytes) {
19613
+ for (var str = [], i = 0; i < bytes.length; i++)
19614
+ str.push(String.fromCharCode(bytes[i]));
19615
+ return str.join('');
19616
+ }
19617
+ }
19618
+ };
19619
+
19620
+ var charenc_1 = charenc;
19621
+
19622
+ /*!
19623
+ * Determine if an object is a Buffer
19624
+ *
19625
+ * @author Feross Aboukhadijeh <https://feross.org>
19626
+ * @license MIT
19627
+ */
19628
+
19629
+ // The _isBuffer check is for Safari 5-7 support, because it's missing
19630
+ // Object.prototype.constructor. Remove this eventually
19631
+ var isBuffer_1$1 = function (obj) {
19632
+ return obj != null && (isBuffer$1(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
19633
+ };
19634
+
19635
+ function isBuffer$1 (obj) {
19636
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
19637
+ }
19638
+
19639
+ // For Node v0.10 support. Remove this eventually.
19640
+ function isSlowBuffer (obj) {
19641
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer$1(obj.slice(0, 0))
19642
+ }
19643
+
19644
+ var md5 = createCommonjsModule(function (module) {
19645
+ (function(){
19646
+ var crypt$1 = crypt,
19647
+ utf8 = charenc_1.utf8,
19648
+ isBuffer = isBuffer_1$1,
19649
+ bin = charenc_1.bin,
19650
+
19651
+ // The core
19652
+ md5 = function (message, options) {
19653
+ // Convert to byte array
19654
+ if (message.constructor == String)
19655
+ if (options && options.encoding === 'binary')
19656
+ message = bin.stringToBytes(message);
19657
+ else
19658
+ message = utf8.stringToBytes(message);
19659
+ else if (isBuffer(message))
19660
+ message = Array.prototype.slice.call(message, 0);
19661
+ else if (!Array.isArray(message))
19662
+ message = message.toString();
19663
+ // else, assume byte array already
19664
+
19665
+ var m = crypt$1.bytesToWords(message),
19666
+ l = message.length * 8,
19667
+ a = 1732584193,
19668
+ b = -271733879,
19669
+ c = -1732584194,
19670
+ d = 271733878;
19671
+
19672
+ // Swap endian
19673
+ for (var i = 0; i < m.length; i++) {
19674
+ m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
19675
+ ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
19676
+ }
19677
+
19678
+ // Padding
19679
+ m[l >>> 5] |= 0x80 << (l % 32);
19680
+ m[(((l + 64) >>> 9) << 4) + 14] = l;
19681
+
19682
+ // Method shortcuts
19683
+ var FF = md5._ff,
19684
+ GG = md5._gg,
19685
+ HH = md5._hh,
19686
+ II = md5._ii;
19687
+
19688
+ for (var i = 0; i < m.length; i += 16) {
19689
+
19690
+ var aa = a,
19691
+ bb = b,
19692
+ cc = c,
19693
+ dd = d;
19694
+
19695
+ a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
19696
+ d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
19697
+ c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
19698
+ b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
19699
+ a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
19700
+ d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
19701
+ c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
19702
+ b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
19703
+ a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
19704
+ d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
19705
+ c = FF(c, d, a, b, m[i+10], 17, -42063);
19706
+ b = FF(b, c, d, a, m[i+11], 22, -1990404162);
19707
+ a = FF(a, b, c, d, m[i+12], 7, 1804603682);
19708
+ d = FF(d, a, b, c, m[i+13], 12, -40341101);
19709
+ c = FF(c, d, a, b, m[i+14], 17, -1502002290);
19710
+ b = FF(b, c, d, a, m[i+15], 22, 1236535329);
19711
+
19712
+ a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
19713
+ d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
19714
+ c = GG(c, d, a, b, m[i+11], 14, 643717713);
19715
+ b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
19716
+ a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
19717
+ d = GG(d, a, b, c, m[i+10], 9, 38016083);
19718
+ c = GG(c, d, a, b, m[i+15], 14, -660478335);
19719
+ b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
19720
+ a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
19721
+ d = GG(d, a, b, c, m[i+14], 9, -1019803690);
19722
+ c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
19723
+ b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
19724
+ a = GG(a, b, c, d, m[i+13], 5, -1444681467);
19725
+ d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
19726
+ c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
19727
+ b = GG(b, c, d, a, m[i+12], 20, -1926607734);
19728
+
19729
+ a = HH(a, b, c, d, m[i+ 5], 4, -378558);
19730
+ d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
19731
+ c = HH(c, d, a, b, m[i+11], 16, 1839030562);
19732
+ b = HH(b, c, d, a, m[i+14], 23, -35309556);
19733
+ a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
19734
+ d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
19735
+ c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
19736
+ b = HH(b, c, d, a, m[i+10], 23, -1094730640);
19737
+ a = HH(a, b, c, d, m[i+13], 4, 681279174);
19738
+ d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
19739
+ c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
19740
+ b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
19741
+ a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
19742
+ d = HH(d, a, b, c, m[i+12], 11, -421815835);
19743
+ c = HH(c, d, a, b, m[i+15], 16, 530742520);
19744
+ b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
19745
+
19746
+ a = II(a, b, c, d, m[i+ 0], 6, -198630844);
19747
+ d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
19748
+ c = II(c, d, a, b, m[i+14], 15, -1416354905);
19749
+ b = II(b, c, d, a, m[i+ 5], 21, -57434055);
19750
+ a = II(a, b, c, d, m[i+12], 6, 1700485571);
19751
+ d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
19752
+ c = II(c, d, a, b, m[i+10], 15, -1051523);
19753
+ b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
19754
+ a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
19755
+ d = II(d, a, b, c, m[i+15], 10, -30611744);
19756
+ c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
19757
+ b = II(b, c, d, a, m[i+13], 21, 1309151649);
19758
+ a = II(a, b, c, d, m[i+ 4], 6, -145523070);
19759
+ d = II(d, a, b, c, m[i+11], 10, -1120210379);
19760
+ c = II(c, d, a, b, m[i+ 2], 15, 718787259);
19761
+ b = II(b, c, d, a, m[i+ 9], 21, -343485551);
19762
+
19763
+ a = (a + aa) >>> 0;
19764
+ b = (b + bb) >>> 0;
19765
+ c = (c + cc) >>> 0;
19766
+ d = (d + dd) >>> 0;
19767
+ }
19768
+
19769
+ return crypt$1.endian([a, b, c, d]);
19770
+ };
19771
+
19772
+ // Auxiliary functions
19773
+ md5._ff = function (a, b, c, d, x, s, t) {
19774
+ var n = a + (b & c | ~b & d) + (x >>> 0) + t;
19775
+ return ((n << s) | (n >>> (32 - s))) + b;
19776
+ };
19777
+ md5._gg = function (a, b, c, d, x, s, t) {
19778
+ var n = a + (b & d | c & ~d) + (x >>> 0) + t;
19779
+ return ((n << s) | (n >>> (32 - s))) + b;
19780
+ };
19781
+ md5._hh = function (a, b, c, d, x, s, t) {
19782
+ var n = a + (b ^ c ^ d) + (x >>> 0) + t;
19783
+ return ((n << s) | (n >>> (32 - s))) + b;
19784
+ };
19785
+ md5._ii = function (a, b, c, d, x, s, t) {
19786
+ var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
19787
+ return ((n << s) | (n >>> (32 - s))) + b;
19788
+ };
19789
+
19790
+ // Package private blocksize
19791
+ md5._blocksize = 16;
19792
+ md5._digestsize = 16;
19793
+
19794
+ module.exports = function (message, options) {
19795
+ if (message === undefined || message === null)
19796
+ throw new Error('Illegal argument ' + message);
19797
+
19798
+ var digestbytes = crypt$1.wordsToBytes(md5(message, options));
19799
+ return options && options.asBytes ? digestbytes :
19800
+ options && options.asString ? bin.bytesToString(digestbytes) :
19801
+ crypt$1.bytesToHex(digestbytes);
19802
+ };
19803
+
19804
+ })();
19805
+ });
19806
+
19807
+ var _this$3 = undefined;
19808
+
19809
+ var config = {
19810
+ host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
19811
+ user: 'nasp',
19812
+ password: 'uRNkF9SkfXQs6AKK',
19813
+ database: 'user'
19814
+ };
19815
+
19816
+ var findUser = function () {
19817
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(email) {
19818
+ var password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
19819
+ var db$1, query, res, user, hash, passwordsMatch, user_shared, occupation_id;
19820
+ return regenerator.wrap(function _callee$(_context) {
19821
+ while (1) {
19822
+ switch (_context.prev = _context.next) {
19823
+ case 0:
19824
+ db$1 = null;
19825
+ _context.prev = 1;
19826
+
19827
+
19828
+ db$1 = db(config);
19829
+
19830
+ query = '\n select * \n from user \n where trim(lower(email)) = ?\n ';
19831
+ _context.next = 6;
19832
+ return db$1.query(query, [email.toLowerCase().trim()]);
19833
+
19834
+ case 6:
19835
+ res = _context.sent;
19836
+ user = res.length > 0 ? res[0] : null;
19837
+
19838
+ if (user) {
19839
+ _context.next = 10;
19840
+ break;
19841
+ }
19842
+
19843
+ throw new Error('Invalid credential provided');
19844
+
19845
+ case 10:
19846
+ if (!password) {
19847
+ _context.next = 15;
19848
+ break;
19849
+ }
19850
+
19851
+ hash = md5(password);
19852
+ passwordsMatch = hash === user.password;
19853
+
19854
+ if (passwordsMatch) {
19855
+ _context.next = 15;
19856
+ break;
19857
+ }
19858
+
19859
+ throw new Error('Password doesn\'t match');
19860
+
19861
+ case 15:
19862
+
19863
+ query = '\n select * \n from user_shared \n where user_id = ?\n ';
19864
+ _context.next = 18;
19865
+ return db$1.query(query, [user.id]);
19866
+
19867
+ case 18:
19868
+ res = _context.sent;
19869
+ user_shared = res.length > 0 ? res[0] : null;
19870
+
19871
+ user.shared = user_shared;
19872
+
19873
+ // occupation
19874
+ query = '\n select id \n from occupation \n where name = ?\n ';
19875
+ _context.next = 24;
19876
+ return db$1.query(query, [user_shared.occupation]);
19877
+
19878
+ case 24:
19879
+ res = _context.sent;
19880
+ occupation_id = res.length > 0 ? res[0].id : '';
19881
+
19882
+ user.shared.occupation_id = occupation_id;
19883
+
19884
+ _context.next = 29;
19885
+ return db$1.close();
19886
+
19887
+ case 29:
19888
+ return _context.abrupt('return', {
19889
+ error: '',
19890
+ user: user
19891
+ });
19892
+
19893
+ case 32:
19894
+ _context.prev = 32;
19895
+ _context.t0 = _context['catch'](1);
19896
+
19897
+ if (!db$1) {
19898
+ _context.next = 37;
19899
+ break;
19900
+ }
19901
+
19902
+ _context.next = 37;
19903
+ return db$1.close();
19904
+
19905
+ case 37:
19906
+ return _context.abrupt('return', {
19907
+ error: _context.t0.message,
19908
+ user: null
19909
+ });
19910
+
19911
+ case 38:
19912
+ case 'end':
19913
+ return _context.stop();
19914
+ }
19915
+ }
19916
+ }, _callee, this, [[1, 32]]);
19917
+ }));
19918
+
19919
+ return function findUser(_x) {
19920
+ return _ref.apply(this, arguments);
19921
+ };
19922
+ }();
19923
+
19924
+ var updateUser = function () {
19925
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(data) {
19926
+ var db$1, query, res, hash, columns, i, column, occupation_name;
19927
+ return regenerator.wrap(function _callee2$(_context2) {
19928
+ while (1) {
19929
+ switch (_context2.prev = _context2.next) {
19930
+ case 0:
19931
+ db$1 = null;
19932
+ _context2.prev = 1;
19933
+
19934
+
19935
+ validateUserData(data);
19936
+
19937
+ db$1 = db(config);
19938
+
19939
+ _context2.next = 6;
19940
+ return db$1.beginTransaction();
19941
+
19942
+ case 6:
19943
+ if (data.user_id) {
19944
+ _context2.next = 8;
19945
+ break;
19946
+ }
19947
+
19948
+ throw new Error('Please provide user ID');
19949
+
19950
+ case 8:
19951
+
19952
+ data.email = data.email.toLowerCase().trim();
19953
+
19954
+ // check if new email is taken
19955
+ query = '\n select * \n from user \n where lower(trim(email)) = ?\n and id != ?\n ';
19956
+ _context2.next = 12;
19957
+ return db$1.query(query, [data.email, data.user_id]);
19958
+
19959
+ case 12:
19960
+ res = _context2.sent;
19961
+
19962
+ if (!(res && res.length > 0)) {
19963
+ _context2.next = 15;
19964
+ break;
19965
+ }
19966
+
19967
+ throw new Error('Email already taken');
19968
+
19969
+ case 15:
19970
+ if (!data.password) {
19971
+ _context2.next = 23;
19972
+ break;
19973
+ }
19974
+
19975
+ hash = md5(data.password);
19976
+
19977
+ query = '\n update user \n set password = ?\n where user_id = ?\n ';
19978
+ _context2.next = 20;
19979
+ return db$1.query(query, [hash, data.user_id]);
19980
+
19981
+ case 20:
19982
+ res = _context2.sent;
19983
+
19984
+ if (!(!res || res.affectedRows < 1)) {
19985
+ _context2.next = 23;
19986
+ break;
19987
+ }
19988
+
19989
+ throw new Error('Failed to update password');
19990
+
19991
+ case 23:
19992
+
19993
+ query = 'show columns from user_shared';
19994
+ _context2.next = 26;
19995
+ return db$1.query(query);
19996
+
19997
+ case 26:
19998
+ columns = _context2.sent;
19999
+
20000
+
20001
+ for (i = 0; i < columns.length; i++) {
20002
+ column = columns[i].Field;
20003
+
20004
+ if (typeof data[column] === 'undefined') {
20005
+ data[column] = '';
20006
+ }
20007
+ }
20008
+
20009
+ // user_shared
20010
+ query = '\n update user_shared\n set \n first_name = ?,\n last_name = ?,\n country = ?,\n city = ?,\n state = ?,\n zip = ?,\n phone = ?,\n occupation = ?,\n primary_specialty = ?,\n area_of_practice = ?,\n work_place = ?,\n graduation_year = ?,\n medical_school = ?,\n npi = ?,\n role = ?,\n updated = current_timestamp\n where user_id = ?\n ';
20011
+
20012
+ _context2.next = 31;
20013
+ return getOccupationNameById(db$1, data.occupation);
20014
+
20015
+ case 31:
20016
+ occupation_name = _context2.sent;
20017
+ _context2.next = 34;
20018
+ return db$1.query(query, [data.first_name, data.last_name, data.country, data.city, data.state, data.zip, data.phone, occupation_name, data.primary_specialty, data.area_of_practice, data.work_place, data.graduation_year, data.medical_school, data.npi, data.role, data.user_id]);
20019
+
20020
+ case 34:
20021
+ res = _context2.sent;
20022
+
20023
+ if (!(!res || res.affectedRows < 1)) {
20024
+ _context2.next = 37;
20025
+ break;
20026
+ }
20027
+
20028
+ throw new Error('Failed to update user shared information record');
20029
+
20030
+ case 37:
20031
+ _context2.next = 39;
20032
+ return db$1.commit();
20033
+
20034
+ case 39:
20035
+ _context2.next = 41;
20036
+ return db$1.close();
20037
+
20038
+ case 41:
20039
+
20040
+ db$1 = null;
20041
+
20042
+ return _context2.abrupt('return', {
20043
+ error: '',
20044
+ user: findUser(data.email)
20045
+ });
20046
+
20047
+ case 45:
20048
+ _context2.prev = 45;
20049
+ _context2.t0 = _context2['catch'](1);
20050
+
20051
+
20052
+ console.log('error:', _context2.t0);
20053
+
20054
+ if (!db$1) {
20055
+ _context2.next = 53;
20056
+ break;
20057
+ }
20058
+
20059
+ _context2.next = 51;
20060
+ return db$1.rollback();
20061
+
20062
+ case 51:
20063
+ _context2.next = 53;
20064
+ return db$1.close();
20065
+
20066
+ case 53:
20067
+ return _context2.abrupt('return', {
20068
+ error: _context2.t0.message,
20069
+ user: null
20070
+ });
20071
+
20072
+ case 54:
20073
+ case 'end':
20074
+ return _context2.stop();
20075
+ }
20076
+ }
20077
+ }, _callee2, this, [[1, 45]]);
20078
+ }));
20079
+
20080
+ return function updateUser(_x3) {
20081
+ return _ref2.apply(this, arguments);
20082
+ };
20083
+ }();
20084
+
20085
+ var validateUserData = function validateUserData(data) {
20086
+ var requirePassword = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
20087
+
20088
+ if (!data.email) {
20089
+ throw new Error('Email is required');
20090
+ }
20091
+
20092
+ if (requirePassword && !data.password) {
20093
+ throw new Error('Password is required');
20094
+ }
20095
+
20096
+ if (data.password && data.password !== data.rpassword) {
20097
+ throw new Error('Password does not match');
20098
+ }
20099
+
20100
+ if (!data.first_name) {
20101
+ throw new Error('First name is required');
20102
+ }
20103
+
20104
+ if (!data.last_name) {
20105
+ throw new Error('Last name is required');
20106
+ }
20107
+
20108
+ if (!data.country) {
20109
+ throw new Error('Country is required');
20110
+ }
20111
+
20112
+ if (data.country === 'United States') {
20113
+ if (!data.state) {
20114
+ throw new Error('State is required');
20115
+ }
20116
+
20117
+ if (!data.zip) {
20118
+ throw new Error('Zip code is required');
20119
+ }
20120
+
20121
+ if (!data.phone) {
20122
+ throw new Error('Phone is required');
20123
+ }
20124
+ }
20125
+ };
20126
+
20127
+ var getOccupationNameById = function () {
20128
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(db, occupation_id) {
20129
+ var query, res;
20130
+ return regenerator.wrap(function _callee3$(_context3) {
20131
+ while (1) {
20132
+ switch (_context3.prev = _context3.next) {
20133
+ case 0:
20134
+ query = '\n select name\n from occupation \n where id = ?\n ';
20135
+ _context3.next = 3;
20136
+ return db.query(query, [occupation_id]);
20137
+
20138
+ case 3:
20139
+ res = _context3.sent;
20140
+
20141
+ if (!(res && res.length > 0)) {
20142
+ _context3.next = 6;
20143
+ break;
20144
+ }
20145
+
20146
+ return _context3.abrupt('return', res[0].name);
20147
+
20148
+ case 6:
20149
+ throw new Error('Failed to get occupation name by ID: ' + occupation_id);
20150
+
20151
+ case 7:
20152
+ case 'end':
20153
+ return _context3.stop();
20154
+ }
20155
+ }
20156
+ }, _callee3, _this$3);
20157
+ }));
20158
+
20159
+ return function getOccupationNameById(_x5, _x6) {
20160
+ return _ref3.apply(this, arguments);
20161
+ };
20162
+ }();
20163
+
20164
+ var createUser = function () {
20165
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(data) {
20166
+ var db$1, query, res, hash, columns, i, column, user_id, occupation_name;
20167
+ return regenerator.wrap(function _callee4$(_context4) {
20168
+ while (1) {
20169
+ switch (_context4.prev = _context4.next) {
20170
+ case 0:
20171
+ db$1 = null;
20172
+ _context4.prev = 1;
20173
+
20174
+
20175
+ validateUserData(data, true);
20176
+
20177
+ db$1 = db(config);
20178
+
20179
+ _context4.next = 6;
20180
+ return db$1.beginTransaction();
20181
+
20182
+ case 6:
20183
+
20184
+ data.email = data.email.toLowerCase().trim();
20185
+
20186
+ // check if user exists
20187
+ query = '\n select * \n from user \n where lower(trim(email)) = ?\n ';
20188
+ _context4.next = 10;
20189
+ return db$1.query(query, [data.email]);
20190
+
20191
+ case 10:
20192
+ res = _context4.sent;
20193
+
20194
+ if (!(res && res.length > 0)) {
20195
+ _context4.next = 13;
20196
+ break;
20197
+ }
20198
+
20199
+ throw new Error('User already exists');
20200
+
20201
+ case 13:
20202
+ hash = md5(data.password);
20203
+
20204
+ // basic user info
20205
+
20206
+ query = '\n insert into user ( \n email, password, created\n ) values (\n ?, ?, current_timestamp\n )\n ';
20207
+ _context4.next = 17;
20208
+ return db$1.query(query, [data.email, hash]);
20209
+
20210
+ case 17:
20211
+ res = _context4.sent;
20212
+
20213
+ if (!(!res || res.insertId < 1)) {
20214
+ _context4.next = 20;
20215
+ break;
20216
+ }
20217
+
20218
+ throw new Error('Failed to create user');
20219
+
20220
+ case 20:
20221
+
20222
+ query = 'show columns from user_shared';
20223
+ _context4.next = 23;
20224
+ return db$1.query(query);
20225
+
20226
+ case 23:
20227
+ columns = _context4.sent;
20228
+
20229
+
20230
+ for (i = 0; i < columns.length; i++) {
20231
+ column = columns[i].Field;
20232
+
20233
+ if (typeof data[column] === 'undefined') {
20234
+ data[column] = '';
20235
+ }
20236
+ }
20237
+
20238
+ user_id = res.insertId;
20239
+
20240
+ // user_shared
20241
+
20242
+ query = '\n insert into user_shared (\n user_id, first_name, last_name, country, city, state, zip, phone, \n occupation, primary_specialty, area_of_practice, work_place, graduation_year, medical_school, \n npi, role, updated \n ) values (\n ?, ?, ?, ?, ?, ?, ?, ?,\n ?, ?, ?, ?, ?, ?,\n ?, ?, current_timestamp\n )\n ';
20243
+
20244
+ _context4.next = 29;
20245
+ return getOccupationNameById(db$1, data.occupation);
20246
+
20247
+ case 29:
20248
+ occupation_name = _context4.sent;
20249
+ _context4.next = 32;
20250
+ return db$1.query(query, [user_id, data.first_name, data.last_name, data.country, data.city, data.state, data.zip, data.phone, occupation_name, data.primary_specialty, data.area_of_practice, data.work_place, data.graduation_year, data.medical_school, data.npi, data.role]);
20251
+
20252
+ case 32:
20253
+ res = _context4.sent;
20254
+
20255
+ if (!(!res || res.affectedRows < 1)) {
20256
+ _context4.next = 35;
20257
+ break;
20258
+ }
20259
+
20260
+ throw new Error('Failed to create user shared information record');
20261
+
20262
+ case 35:
20263
+ _context4.next = 37;
20264
+ return db$1.commit();
20265
+
20266
+ case 37:
20267
+ _context4.next = 39;
20268
+ return db$1.close();
20269
+
20270
+ case 39:
20271
+ return _context4.abrupt('return', {
20272
+ error: '',
20273
+ user: findUser(data.email)
20274
+ });
20275
+
20276
+ case 42:
20277
+ _context4.prev = 42;
20278
+ _context4.t0 = _context4['catch'](1);
20279
+
20280
+ if (!db$1) {
20281
+ _context4.next = 49;
20282
+ break;
20283
+ }
20284
+
20285
+ _context4.next = 47;
20286
+ return db$1.rollback();
20287
+
20288
+ case 47:
20289
+ _context4.next = 49;
20290
+ return db$1.close();
20291
+
20292
+ case 49:
20293
+ return _context4.abrupt('return', {
20294
+ error: _context4.t0.message,
20295
+ user: null
20296
+ });
20297
+
20298
+ case 50:
20299
+ case 'end':
20300
+ return _context4.stop();
20301
+ }
20302
+ }
20303
+ }, _callee4, this, [[1, 42]]);
20304
+ }));
20305
+
20306
+ return function createUser(_x7) {
20307
+ return _ref4.apply(this, arguments);
20308
+ };
20309
+ }();
20310
+
20311
+ var createUser$1 = function () {
20312
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(data) {
20313
+ var res;
20314
+ return regenerator.wrap(function _callee$(_context) {
20315
+ while (1) {
20316
+ switch (_context.prev = _context.next) {
20317
+ case 0:
20318
+ _context.next = 2;
20319
+ return createUser(data);
20320
+
20321
+ case 2:
20322
+ res = _context.sent;
20323
+
20324
+ if (!res.error) {
20325
+ _context.next = 5;
20326
+ break;
20327
+ }
20328
+
20329
+ throw new Error(res.error);
20330
+
20331
+ case 5:
20332
+ return _context.abrupt('return', res.user);
20333
+
20334
+ case 6:
20335
+ case 'end':
20336
+ return _context.stop();
20337
+ }
20338
+ }
20339
+ }, _callee, this);
20340
+ }));
20341
+
20342
+ return function createUser(_x) {
20343
+ return _ref.apply(this, arguments);
20344
+ };
20345
+ }();
20346
+
20347
+ var updateUser$1 = function () {
20348
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(data) {
20349
+ var res;
20350
+ return regenerator.wrap(function _callee2$(_context2) {
20351
+ while (1) {
20352
+ switch (_context2.prev = _context2.next) {
20353
+ case 0:
20354
+ _context2.next = 2;
20355
+ return updateUser(data);
20356
+
20357
+ case 2:
20358
+ res = _context2.sent;
20359
+
20360
+ if (!res.error) {
20361
+ _context2.next = 5;
20362
+ break;
20363
+ }
20364
+
20365
+ throw new Error(res.error);
20366
+
20367
+ case 5:
20368
+ return _context2.abrupt('return', res.user);
20369
+
20370
+ case 6:
20371
+ case 'end':
20372
+ return _context2.stop();
20373
+ }
20374
+ }
20375
+ }, _callee2, this);
20376
+ }));
20377
+
20378
+ return function updateUser(_x2) {
20379
+ return _ref2.apply(this, arguments);
20380
+ };
20381
+ }();
20382
+
20383
+ var findUser$1 = function () {
20384
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(_ref4) {
20385
+ var email = _ref4.email,
20386
+ password = _ref4.password;
20387
+ var res;
20388
+ return regenerator.wrap(function _callee3$(_context3) {
20389
+ while (1) {
20390
+ switch (_context3.prev = _context3.next) {
20391
+ case 0:
20392
+ _context3.next = 2;
20393
+ return findUser(email, password);
20394
+
20395
+ case 2:
20396
+ res = _context3.sent;
20397
+
20398
+ if (!res.error) {
20399
+ _context3.next = 5;
20400
+ break;
20401
+ }
20402
+
20403
+ throw new Error(res.error);
20404
+
20405
+ case 5:
20406
+ return _context3.abrupt('return', res.user);
20407
+
20408
+ case 6:
20409
+ case 'end':
20410
+ return _context3.stop();
20411
+ }
20412
+ }
20413
+ }, _callee3, this);
20414
+ }));
20415
+
20416
+ return function findUser(_x3) {
20417
+ return _ref3.apply(this, arguments);
20418
+ };
20419
+ }();
20420
+
20421
+ var user = /*#__PURE__*/Object.freeze({
20422
+ __proto__: null,
20423
+ createUser: createUser$1,
20424
+ updateUser: updateUser$1,
20425
+ findUser: findUser$1
20426
+ });
20427
+
20428
+ var localStrategy = new Local.Strategy({
20429
+ usernameField: 'email',
20430
+ passwordField: 'password'
20431
+ }, function (email, password, done) {
20432
+
20433
+ findUser$1({ email: email, password: password }).then(function (user) {
20434
+ done(null, user);
20435
+ }).catch(function (error) {
20436
+ done(error);
20437
+ });
20438
+ });
20439
+
20440
+ var passportLocal = /*#__PURE__*/Object.freeze({
20441
+ __proto__: null,
20442
+ localStrategy: localStrategy
20443
+ });
20444
+
20445
+ var _this$4 = undefined;
20446
+
20447
+ var config$1 = {
20448
+ host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
20449
+ user: 'nasp',
20450
+ password: 'uRNkF9SkfXQs6AKK',
20451
+ database: 'user'
20452
+ };
20453
+
20454
+ var getOccupation = function () {
20455
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(type) {
20456
+ var db$1, query, result;
20457
+ return regenerator.wrap(function _callee$(_context) {
20458
+ while (1) {
20459
+ switch (_context.prev = _context.next) {
20460
+ case 0:
20461
+ db$1 = db(config$1);
20462
+ query = '\n select name as label, id as value\n from occupation\n where type = ?\n ';
20463
+ _context.next = 4;
20464
+ return db$1.query(query, [type]);
20465
+
20466
+ case 4:
20467
+ result = _context.sent;
20468
+ _context.next = 7;
20469
+ return db$1.close();
20470
+
20471
+ case 7:
20472
+ return _context.abrupt('return', result);
20473
+
20474
+ case 8:
20475
+ case 'end':
20476
+ return _context.stop();
20477
+ }
20478
+ }
20479
+ }, _callee, _this$4);
20480
+ }));
20481
+
20482
+ return function getOccupation(_x) {
20483
+ return _ref.apply(this, arguments);
20484
+ };
20485
+ }();
20486
+
20487
+ var getFieldsAndOptions = function () {
20488
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(occupation) {
20489
+ var db$1, query, result, i, field, optionQuery, options;
20490
+ return regenerator.wrap(function _callee2$(_context2) {
20491
+ while (1) {
20492
+ switch (_context2.prev = _context2.next) {
20493
+ case 0:
20494
+ db$1 = db(config$1);
20495
+ query = '\n select * \n from field\n where occupation_id = ?\n order by sorting\n ';
20496
+ _context2.next = 4;
20497
+ return db$1.query(query, [occupation]);
20498
+
20499
+ case 4:
20500
+ result = _context2.sent;
20501
+ i = 0;
20502
+
20503
+ case 6:
20504
+ if (!(i < result.length)) {
20505
+ _context2.next = 17;
20506
+ break;
20507
+ }
20508
+
20509
+ field = result[i];
20510
+
20511
+ if (!(field.type === 'select')) {
20512
+ _context2.next = 14;
20513
+ break;
20514
+ }
20515
+
20516
+ optionQuery = '\n select * \n from options\n where list_id = ?\n order by sorting\n ';
20517
+ _context2.next = 12;
20518
+ return db$1.query(optionQuery, [field.list_id]);
20519
+
20520
+ case 12:
20521
+ options = _context2.sent;
20522
+
20523
+ field.options = options ? options : [];
20524
+
20525
+ case 14:
20526
+ i++;
20527
+ _context2.next = 6;
20528
+ break;
20529
+
20530
+ case 17:
20531
+ _context2.next = 19;
20532
+ return db$1.close();
20533
+
20534
+ case 19:
20535
+ return _context2.abrupt('return', result);
20536
+
20537
+ case 20:
20538
+ case 'end':
20539
+ return _context2.stop();
20540
+ }
20541
+ }
20542
+ }, _callee2, _this$4);
20543
+ }));
20544
+
20545
+ return function getFieldsAndOptions(_x2) {
20546
+ return _ref2.apply(this, arguments);
20547
+ };
20548
+ }();
20549
+
20550
+ var ProcessData = (function () {
20551
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(req, res) {
20552
+ var action, data, type, occupation;
20553
+ return regenerator.wrap(function _callee3$(_context3) {
20554
+ while (1) {
20555
+ switch (_context3.prev = _context3.next) {
20556
+ case 0:
20557
+ _context3.prev = 0;
20558
+ action = req.body.action;
20559
+ data = null;
20560
+ _context3.t0 = action;
20561
+ _context3.next = _context3.t0 === 'get-occupation' ? 6 : _context3.t0 === 'get-fields' ? 11 : 16;
20562
+ break;
20563
+
20564
+ case 6:
20565
+ type = req.body.type;
20566
+ _context3.next = 9;
20567
+ return getOccupation(type);
20568
+
20569
+ case 9:
20570
+ data = _context3.sent;
20571
+ return _context3.abrupt('break', 17);
20572
+
20573
+ case 11:
20574
+ occupation = req.body.occupation;
20575
+ _context3.next = 14;
20576
+ return getFieldsAndOptions(occupation);
20577
+
20578
+ case 14:
20579
+ data = _context3.sent;
20580
+ return _context3.abrupt('break', 17);
20581
+
20582
+ case 16:
20583
+ throw new Error('Invalid action: ' + action);
20584
+
20585
+ case 17:
20586
+ return _context3.abrupt('return', res.json({
20587
+ error: '',
20588
+ data: data
20589
+ }));
20590
+
20591
+ case 20:
20592
+ _context3.prev = 20;
20593
+ _context3.t1 = _context3['catch'](0);
20594
+ return _context3.abrupt('return', res.json({
20595
+ error: _context3.t1.message,
20596
+ data: null
20597
+ }));
20598
+
20599
+ case 23:
20600
+ case 'end':
20601
+ return _context3.stop();
20602
+ }
20603
+ }
20604
+ }, _callee3, this, [[0, 20]]);
20605
+ }));
20606
+
20607
+ return function (_x3, _x4) {
20608
+ return _ref3.apply(this, arguments);
20609
+ };
20610
+ })();
20611
+
20612
+ var LoginForm_1 = LoginForm;
20613
+ var SignupForm_1 = SignupForm;
20614
+ var ProfileForm_1 = SignupForm$1;
20615
+ var AuthCookies_1 = authCookies;
20616
+ var AuthHooks_1 = hooks;
20617
+ var Iron_1 = iron;
20618
+ var PassportLocal_1 = passportLocal;
20619
+ var User_1 = user;
20620
+ var ProcessData_1 = ProcessData;
20621
+
20622
+ var auth = {
20623
+ LoginForm: LoginForm_1,
20624
+ SignupForm: SignupForm_1,
20625
+ ProfileForm: ProfileForm_1,
20626
+ AuthCookies: AuthCookies_1,
20627
+ AuthHooks: AuthHooks_1,
20628
+ Iron: Iron_1,
20629
+ PassportLocal: PassportLocal_1,
20630
+ User: User_1,
20631
+ ProcessData: ProcessData_1
20632
+ };
20633
+
20634
+ export { AD300x250, AD300x250x600, ADFloatingFooter, ADFooter, ADGutter, ADWelcome, AccordionPanel, AdSlotsProvider, AlphabeticList, ArticleDetailDropdown, ArticleQueue, auth as Auth, Breadcrumbs$1 as Breadcrumbs, CMEDeck, ConferenceArticleCard, EventsDeck, Feature, fbsHero as ForbesHero, GridHero, Hero, HighlightenVideo, HorizontalHero, KMTracker, OncliveHero, OncliveLargeHero, PdfDownload, RelatedContent, RelatedTopicsDropdown, SetCookie, SocialShare$1 as SocialShare, VerticalHero, YahooHero, getSerializers };