@mjhls/mjh-framework 1.0.1055 → 1.0.1058

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 (178) hide show
  1. package/README.md +168 -168
  2. package/dist/cjs/AD300x250.js +1 -1
  3. package/dist/cjs/AD300x250x600.js +1 -1
  4. package/dist/cjs/AD728x90.js +1 -1
  5. package/dist/cjs/ADFloatingFooter.js +1 -1
  6. package/dist/cjs/ADGutter.js +1 -1
  7. package/dist/cjs/{ADInfeed-98ee4120.js → ADInfeed-0519664d.js} +1 -1
  8. package/dist/cjs/ADSkyscraper.js +1 -1
  9. package/dist/cjs/ADSponsoredResources.js +1 -1
  10. package/dist/cjs/ADWebcast.js +1 -1
  11. package/dist/cjs/ADWelcome.js +1 -1
  12. package/dist/cjs/{ADlgInfeed-55df7d69.js → ADlgInfeed-e544ac1c.js} +1 -1
  13. package/dist/cjs/AdSlot.js +1 -1
  14. package/dist/cjs/AdSlotsProvider.js +1 -1
  15. package/dist/cjs/AlgoliaSearch.js +23 -27
  16. package/dist/cjs/ArticleCarousel.js +1 -1
  17. package/dist/cjs/ArticleProgramLandingPage.js +3 -4
  18. package/dist/cjs/ArticleSeriesLandingPage.js +3 -3
  19. package/dist/cjs/ArticleSeriesListing.js +1 -1
  20. package/dist/cjs/AuthWrapper.js +294 -1546
  21. package/dist/cjs/CEDeckSupabase.js +2 -2
  22. package/dist/cjs/CMEDeck.js +1 -1
  23. package/dist/cjs/Column3.js +1 -1
  24. package/dist/cjs/ConferenceArticleCard.js +15 -15
  25. package/dist/cjs/ContentCardPaginated.js +3 -3
  26. package/dist/cjs/DeckContent.js +11 -11
  27. package/dist/cjs/DeckQueue.js +2 -2
  28. package/dist/cjs/DeckQueuePaginated.js +2 -2
  29. package/dist/cjs/EventsDeck.js +18 -18
  30. package/dist/cjs/ExternalResources.js +3 -4
  31. package/dist/cjs/Feature.js +1 -1
  32. package/dist/cjs/GridContent.js +4 -4
  33. package/dist/cjs/GridContentPaginated.js +4 -4
  34. package/dist/cjs/GridHero.js +1 -1
  35. package/dist/cjs/HamMagazine.js +11 -11
  36. package/dist/cjs/HealthCareProfessionalModal.js +1 -1
  37. package/dist/cjs/Hero.js +1 -1
  38. package/dist/cjs/HorizontalArticleListing.js +3 -4
  39. package/dist/cjs/{ImageSlider-d65bc9c8.js → ImageSlider-62a43659.js} +123 -106
  40. package/dist/cjs/IssueLanding.js +34 -35
  41. package/dist/cjs/KMTracker.js +15 -15
  42. package/dist/cjs/LeftNav.js +1 -1
  43. package/dist/cjs/MasterDeck.js +11 -11
  44. package/dist/cjs/MasterDeckPaginated.js +11 -11
  45. package/dist/cjs/{MediaSeriesCard-e54b0b0c.js → MediaSeriesCard-3cf661c7.js} +2 -2
  46. package/dist/cjs/MediaSeriesLanding.js +13 -14
  47. package/dist/cjs/MediaSeriesLandingPaginated.js +13 -14
  48. package/dist/cjs/NavMagazine.js +12 -12
  49. package/dist/cjs/NavNative.js +10 -10
  50. package/dist/cjs/OncliveLargeHero.js +1 -1
  51. package/dist/cjs/PartnerDetailListing.js +6 -7
  52. package/dist/cjs/PartnerDetailListingPaginated.js +6 -7
  53. package/dist/cjs/PodcastsLanding.js +6 -7
  54. package/dist/cjs/PubSection.js +4 -4
  55. package/dist/cjs/PublicationLanding.js +26 -26
  56. package/dist/cjs/QueueDeckExpanded.js +4 -4
  57. package/dist/cjs/QueueDeckExpandedPaginated.js +4 -4
  58. package/dist/cjs/RelatedContent.js +28 -28
  59. package/dist/cjs/RelatedTopicsDropdown.js +10 -10
  60. package/dist/cjs/SeriesListingDeck.js +2 -2
  61. package/dist/cjs/{SeriesSlider-086a8319.js → SeriesSlider-edcb8e4b.js} +5 -5
  62. package/dist/cjs/SideFooter.js +2 -2
  63. package/dist/cjs/{SocialSearchComponent-d7e5d3a6.js → SocialSearchComponent-e9ec9c63.js} +1 -1
  64. package/dist/cjs/TaxonomyDescription.js +3 -4
  65. package/dist/cjs/TemplateNormal.js +2 -2
  66. package/dist/cjs/ThumbnailCard.js +1 -1
  67. package/dist/cjs/{Tooltip-02a841b5.js → Tooltip-980a1d1a.js} +140 -348
  68. package/dist/cjs/Ustream.js +1 -1
  69. package/dist/cjs/VideoProgramLandingPage.js +3 -4
  70. package/dist/cjs/VideoSeriesCard.js +1 -1
  71. package/dist/cjs/VideoSeriesLandingPage.js +3 -3
  72. package/dist/cjs/VideoSeriesListing.js +1 -1
  73. package/dist/cjs/View.js +7 -9
  74. package/dist/cjs/YahooHero.js +1 -1
  75. package/dist/cjs/YoutubeGroup.js +5 -5
  76. package/dist/cjs/{entities-df1aed86.js → entities-3f9d0f2f.js} +0 -4
  77. package/dist/cjs/faundadb.js +321 -4
  78. package/dist/cjs/getRelatedArticle.js +211 -6
  79. package/dist/cjs/getSerializers.js +3 -4
  80. package/dist/cjs/{getTargeting-5b954783.js → getTargeting-45ffbee8.js} +9 -9
  81. package/dist/cjs/getTargeting.js +1 -1
  82. package/dist/cjs/{index-9ec837cc.js → index-8041a4eb.js} +10 -0
  83. package/dist/cjs/{index-40a8d091.js → index-c19999b7.js} +605 -19
  84. package/dist/cjs/index.js +10 -18
  85. package/dist/cjs/{main-ae8472f3.js → main-47be4f9f.js} +9 -4
  86. package/dist/esm/AD300x250.js +1 -1
  87. package/dist/esm/AD300x250x600.js +1 -1
  88. package/dist/esm/AD728x90.js +1 -1
  89. package/dist/esm/ADFloatingFooter.js +1 -1
  90. package/dist/esm/ADGutter.js +1 -1
  91. package/dist/esm/{ADInfeed-6d0c0856.js → ADInfeed-c3f5613e.js} +1 -1
  92. package/dist/esm/ADSkyscraper.js +1 -1
  93. package/dist/esm/ADSponsoredResources.js +1 -1
  94. package/dist/esm/ADWebcast.js +1 -1
  95. package/dist/esm/ADWelcome.js +1 -1
  96. package/dist/esm/{ADlgInfeed-93bc2250.js → ADlgInfeed-2b148f3f.js} +1 -1
  97. package/dist/esm/AdSlot.js +1 -1
  98. package/dist/esm/AdSlotsProvider.js +1 -1
  99. package/dist/esm/AlgoliaSearch.js +22 -26
  100. package/dist/esm/ArticleCarousel.js +1 -1
  101. package/dist/esm/ArticleProgramLandingPage.js +3 -4
  102. package/dist/esm/ArticleSeriesLandingPage.js +3 -3
  103. package/dist/esm/ArticleSeriesListing.js +1 -1
  104. package/dist/esm/AuthWrapper.js +288 -1540
  105. package/dist/esm/CEDeckSupabase.js +2 -2
  106. package/dist/esm/CMEDeck.js +1 -1
  107. package/dist/esm/Column3.js +1 -1
  108. package/dist/esm/ConferenceArticleCard.js +15 -15
  109. package/dist/esm/ContentCardPaginated.js +3 -3
  110. package/dist/esm/DeckContent.js +11 -11
  111. package/dist/esm/DeckQueue.js +2 -2
  112. package/dist/esm/DeckQueuePaginated.js +2 -2
  113. package/dist/esm/EventsDeck.js +18 -18
  114. package/dist/esm/ExternalResources.js +3 -4
  115. package/dist/esm/Feature.js +1 -1
  116. package/dist/esm/GridContent.js +4 -4
  117. package/dist/esm/GridContentPaginated.js +4 -4
  118. package/dist/esm/GridHero.js +1 -1
  119. package/dist/esm/HamMagazine.js +11 -11
  120. package/dist/esm/HealthCareProfessionalModal.js +1 -1
  121. package/dist/esm/Hero.js +1 -1
  122. package/dist/esm/HorizontalArticleListing.js +3 -4
  123. package/dist/esm/{ImageSlider-da225417.js → ImageSlider-aea3a615.js} +124 -107
  124. package/dist/esm/IssueLanding.js +34 -35
  125. package/dist/esm/KMTracker.js +15 -15
  126. package/dist/esm/LeftNav.js +1 -1
  127. package/dist/esm/MasterDeck.js +11 -11
  128. package/dist/esm/MasterDeckPaginated.js +11 -11
  129. package/dist/esm/{MediaSeriesCard-3906e9ad.js → MediaSeriesCard-52a2e1ca.js} +2 -2
  130. package/dist/esm/MediaSeriesLanding.js +13 -14
  131. package/dist/esm/MediaSeriesLandingPaginated.js +13 -14
  132. package/dist/esm/NavMagazine.js +12 -12
  133. package/dist/esm/NavNative.js +10 -10
  134. package/dist/esm/OncliveLargeHero.js +1 -1
  135. package/dist/esm/PartnerDetailListing.js +6 -7
  136. package/dist/esm/PartnerDetailListingPaginated.js +6 -7
  137. package/dist/esm/PodcastsLanding.js +6 -7
  138. package/dist/esm/PubSection.js +4 -4
  139. package/dist/esm/PublicationLanding.js +26 -26
  140. package/dist/esm/QueueDeckExpanded.js +4 -4
  141. package/dist/esm/QueueDeckExpandedPaginated.js +4 -4
  142. package/dist/esm/RelatedContent.js +28 -28
  143. package/dist/esm/RelatedTopicsDropdown.js +10 -10
  144. package/dist/esm/SeriesListingDeck.js +2 -2
  145. package/dist/esm/{SeriesSlider-a6b1d617.js → SeriesSlider-2e83e861.js} +5 -5
  146. package/dist/esm/SideFooter.js +2 -2
  147. package/dist/esm/{SocialSearchComponent-6065bff2.js → SocialSearchComponent-020f9e81.js} +1 -1
  148. package/dist/esm/TaxonomyDescription.js +3 -4
  149. package/dist/esm/TemplateNormal.js +2 -2
  150. package/dist/esm/ThumbnailCard.js +1 -1
  151. package/dist/esm/{Tooltip-7a093cd4.js → Tooltip-51957f7c.js} +298 -506
  152. package/dist/esm/Ustream.js +1 -1
  153. package/dist/esm/VideoProgramLandingPage.js +3 -4
  154. package/dist/esm/VideoSeriesCard.js +1 -1
  155. package/dist/esm/VideoSeriesLandingPage.js +3 -3
  156. package/dist/esm/VideoSeriesListing.js +1 -1
  157. package/dist/esm/View.js +7 -9
  158. package/dist/esm/YahooHero.js +1 -1
  159. package/dist/esm/YoutubeGroup.js +5 -5
  160. package/dist/esm/{entities-6d9154b4.js → entities-932b50cf.js} +0 -4
  161. package/dist/esm/faundadb.js +319 -2
  162. package/dist/esm/getRelatedArticle.js +206 -1
  163. package/dist/esm/getSerializers.js +3 -4
  164. package/dist/esm/{getTargeting-5a281334.js → getTargeting-a569a9cc.js} +9 -9
  165. package/dist/esm/getTargeting.js +1 -1
  166. package/dist/esm/{index-718f95b2.js → index-588abaff.js} +595 -9
  167. package/dist/esm/{index-0ce54f8a.js → index-67e1773f.js} +10 -1
  168. package/dist/esm/index.js +10 -17
  169. package/dist/esm/{main-754d4992.js → main-f97773b2.js} +9 -4
  170. package/package.json +116 -116
  171. package/dist/cjs/Auth.js +0 -3682
  172. package/dist/cjs/index-bd6c9f56.js +0 -211
  173. package/dist/cjs/md5-e1ca5797.js +0 -323
  174. package/dist/cjs/util-93a37fd0.js +0 -587
  175. package/dist/esm/Auth.js +0 -3661
  176. package/dist/esm/index-db3bb315.js +0 -207
  177. package/dist/esm/md5-4e42248e.js +0 -321
  178. package/dist/esm/util-8ed16d48.js +0 -585
package/dist/esm/Auth.js DELETED
@@ -1,3661 +0,0 @@
1
- import { _ as _asyncToGenerator, r as regenerator } from './asyncToGenerator-64822ccc.js';
2
- import { _ as _JSON$stringify } from './stringify-2b084bee.js';
3
- import { _ as _slicedToArray, a as _getIterator } from './slicedToArray-6ebcbfea.js';
4
- import React__default, { useEffect, useState } from 'react';
5
- import Router from 'next/router';
6
- import { _ as _extends } from './extends-1559c147.js';
7
- import { Form, Col, Button, Spinner } from 'react-bootstrap';
8
- import useSWR from 'swr';
9
- import { s as serialize_1, p as parse_1 } from './index-db3bb315.js';
10
- import Local from 'passport-local';
11
- import mysql from 'mysql';
12
- import { u as util } from './util-8ed16d48.js';
13
- import { c as createCommonjsModule } from './_commonjsHelpers-0c4b6f40.js';
14
- import { m as md5 } from './md5-4e42248e.js';
15
- import './core.get-iterator-method-ea258bb1.js';
16
- import './web.dom.iterable-ab4dea5c.js';
17
- import './_library-528f1934.js';
18
- import './_set-species-2cd9340f.js';
19
- import './_iter-detect-98db3b07.js';
20
-
21
- var returnFormField = function returnFormField(_ref) {
22
- var name = _ref.name,
23
- label = _ref.label,
24
- type = _ref.type,
25
- _ref$required = _ref.required,
26
- required = _ref$required === undefined ? false : _ref$required,
27
- _ref$readonly = _ref.readonly,
28
- readonly = _ref$readonly === undefined ? false : _ref$readonly,
29
- _ref$options = _ref.options,
30
- options = _ref$options === undefined ? null : _ref$options,
31
- _ref$groupType = _ref.groupType,
32
- groupType = _ref$groupType === undefined ? '' : _ref$groupType,
33
- _ref$errors = _ref.errors,
34
- errors = _ref$errors === undefined ? {} : _ref$errors,
35
- _ref$handleChanged = _ref.handleChanged,
36
- handleChanged = _ref$handleChanged === undefined ? null : _ref$handleChanged,
37
- _ref$default_value = _ref.default_value,
38
- default_value = _ref$default_value === undefined ? null : _ref$default_value;
39
-
40
- var opts = [];
41
- if (groupType) {
42
- opts['as'] = groupType;
43
- if (groupType === Col) {
44
- opts['xs'] = 12;
45
- opts['md'] = 6;
46
- }
47
- }
48
-
49
- if (handleChanged) {
50
- opts['onChange'] = handleChanged;
51
- }
52
-
53
- if (readonly) {
54
- opts['readOnly'] = readonly;
55
- }
56
-
57
- if (type == 'text' || type == 'email' || type == 'password' || type == 'number') {
58
- return React__default.createElement(
59
- Form.Group,
60
- _extends({}, opts, { controlId: name }),
61
- React__default.createElement(
62
- Form.Label,
63
- { kye: name + '_label' },
64
- label,
65
- required && React__default.createElement(
66
- 'span',
67
- { style: { color: 'red' } },
68
- '*'
69
- )
70
- ),
71
- React__default.createElement(Form.Control, { key: name + '_' + type, type: type, readOnly: readonly, name: name, placeholder: '', defaultValue: default_value, required: required }),
72
- React__default.createElement(
73
- Form.Control.Feedback,
74
- { key: name + '_feedback', type: 'invalid' },
75
- errors[name]
76
- )
77
- );
78
- }
79
- if (type == 'select') {
80
- return React__default.createElement(
81
- Form.Group,
82
- _extends({}, opts, { key: name, controlId: name }),
83
- React__default.createElement(
84
- Form.Label,
85
- { key: name + '_' + label },
86
- label,
87
- required && React__default.createElement(
88
- 'span',
89
- { key: name + '_required_span', style: { color: 'red' } },
90
- '*'
91
- )
92
- ),
93
- React__default.createElement(
94
- Form.Control,
95
- { key: name + '_select', as: 'select', name: name, required: required, defaultValue: default_value },
96
- React__default.createElement('option', { value: '', key: name + '_options_empty' }),
97
- options.map(function (option, index) {
98
- var value = option.value ? option.value : option;
99
- var label = option.label ? option.label : option;
100
- var key = name + '_options_' + index;
101
- return React__default.createElement(
102
- 'option',
103
- { key: key, value: value },
104
- label
105
- );
106
- })
107
- )
108
- );
109
- }
110
-
111
- if (type == 'radio' || type == 'checkbox') {
112
- return React__default.createElement(
113
- Form.Group,
114
- opts,
115
- React__default.createElement(
116
- Form.Label,
117
- null,
118
- label,
119
- required && React__default.createElement(
120
- 'span',
121
- { style: { color: 'red' } },
122
- '*'
123
- )
124
- ),
125
- options.map(function (option, index) {
126
- return React__default.createElement(
127
- Form.Check,
128
- { type: type, key: index, required: required },
129
- React__default.createElement(Form.Check.Input, { type: type, key: type + '_' + index + '_input', defaultChecked: default_value ? default_value === option.value : false, name: name, id: name + '_' + index, value: option.value, required: required }),
130
- React__default.createElement(Form.Check.Label, { style: { cursor: 'pointer' }, 'for': name + '_' + index, key: type + '_' + index + '_label', dangerouslySetInnerHTML: { __html: option.label } })
131
- );
132
- })
133
- );
134
- }
135
- };
136
-
137
- var _this$4 = undefined;
138
-
139
- var dataHandler = function () {
140
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(api_url, body) {
141
- var res, result;
142
- return regenerator.wrap(function _callee$(_context) {
143
- while (1) {
144
- switch (_context.prev = _context.next) {
145
- case 0:
146
- _context.prev = 0;
147
- _context.next = 3;
148
- return fetch(api_url, {
149
- method: 'POST',
150
- headers: { 'Content-Type': 'application/json' },
151
- body: _JSON$stringify(body)
152
- });
153
-
154
- case 3:
155
- res = _context.sent;
156
-
157
- if (!(res.status === 200)) {
158
- _context.next = 13;
159
- break;
160
- }
161
-
162
- _context.next = 7;
163
- return res.json();
164
-
165
- case 7:
166
- result = _context.sent;
167
-
168
- if (!result.error) {
169
- _context.next = 10;
170
- break;
171
- }
172
-
173
- throw new Error(result.error);
174
-
175
- case 10:
176
- return _context.abrupt('return', result.data);
177
-
178
- case 13:
179
- _context.t0 = Error;
180
- _context.next = 16;
181
- return res.text();
182
-
183
- case 16:
184
- _context.t1 = _context.sent;
185
- throw new _context.t0(_context.t1);
186
-
187
- case 18:
188
- _context.next = 24;
189
- break;
190
-
191
- case 20:
192
- _context.prev = 20;
193
- _context.t2 = _context['catch'](0);
194
-
195
- console.error('data handler failed : ' + api_url, _context.t2);
196
- return _context.abrupt('return', null);
197
-
198
- case 24:
199
- case 'end':
200
- return _context.stop();
201
- }
202
- }
203
- }, _callee, _this$4, [[0, 20]]);
204
- }));
205
-
206
- return function dataHandler(_x, _x2) {
207
- return _ref.apply(this, arguments);
208
- };
209
- }();
210
-
211
- function useUser() {
212
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
213
- redirectTo = _ref.redirectTo,
214
- redirectIfFound = _ref.redirectIfFound;
215
-
216
- var _useSWR = useSWR('/api/auth/user', dataHandler),
217
- data = _useSWR.data,
218
- error = _useSWR.error;
219
-
220
- var user = data;
221
- var finished = Boolean(data);
222
- var hasUser = Boolean(user);
223
-
224
- useEffect(function () {
225
- if (!redirectTo || !finished) return;
226
- if (
227
- // If redirectTo is set, redirect if the user was not found.
228
- redirectTo && !redirectIfFound && !hasUser ||
229
- // If redirectIfFound is also set, redirect if the user was found
230
- redirectIfFound && hasUser) {
231
- Router.push(redirectTo);
232
- }
233
- }, [redirectTo, redirectIfFound, finished, hasUser]);
234
-
235
- return error ? null : user;
236
- }
237
-
238
- var hooks = /*#__PURE__*/Object.freeze({
239
- __proto__: null,
240
- useUser: useUser
241
- });
242
-
243
- var LoginForm = function LoginForm(props) {
244
- var handleSubmit = function () {
245
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
246
- var body, res;
247
- return regenerator.wrap(function _callee$(_context) {
248
- while (1) {
249
- switch (_context.prev = _context.next) {
250
- case 0:
251
- event.preventDefault();
252
-
253
- if (errorMsg) setErrorMsg('');
254
- setLoading(true);
255
-
256
- body = {
257
- email: e.currentTarget.email.value,
258
- password: e.currentTarget.password.value
259
- };
260
- _context.prev = 4;
261
- _context.next = 7;
262
- return fetch('/api/auth/login', {
263
- method: 'POST',
264
- headers: { 'Content-Type': 'application/json' },
265
- body: _JSON$stringify(body)
266
- });
267
-
268
- case 7:
269
- res = _context.sent;
270
-
271
- setLoading(false);
272
-
273
- if (!(res.status === 200)) {
274
- _context.next = 13;
275
- break;
276
- }
277
-
278
- // here, Router.push() does not carry new cookie value.
279
- // so need hard redirect
280
- window.location.href = callbackUrl;
281
- _context.next = 18;
282
- break;
283
-
284
- case 13:
285
- _context.t0 = Error;
286
- _context.next = 16;
287
- return res.text();
288
-
289
- case 16:
290
- _context.t1 = _context.sent;
291
- throw new _context.t0(_context.t1);
292
-
293
- case 18:
294
- _context.next = 23;
295
- break;
296
-
297
- case 20:
298
- _context.prev = 20;
299
- _context.t2 = _context['catch'](4);
300
-
301
- setErrorMsg(_context.t2.message);
302
-
303
- case 23:
304
- case 'end':
305
- return _context.stop();
306
- }
307
- }
308
- }, _callee, this, [[4, 20]]);
309
- }));
310
-
311
- return function handleSubmit(_x) {
312
- return _ref.apply(this, arguments);
313
- };
314
- }();
315
-
316
- var _props$callbackUrl = props.callbackUrl,
317
- callbackUrl = _props$callbackUrl === undefined ? '/' : _props$callbackUrl;
318
-
319
-
320
- useEffect(function () {
321
- if (props.user) {
322
- window.location.href = '/auth/profile';
323
- }
324
- }, []);
325
- useUser('/auth/profile', true);
326
-
327
- var _useState = useState(''),
328
- _useState2 = _slicedToArray(_useState, 2),
329
- errorMsg = _useState2[0],
330
- setErrorMsg = _useState2[1];
331
-
332
- var _useState3 = useState(false),
333
- _useState4 = _slicedToArray(_useState3, 2),
334
- loading = _useState4[0],
335
- setLoading = _useState4[1];
336
-
337
- return React__default.createElement(
338
- Form,
339
- { className: 'login', onSubmit: handleSubmit },
340
- React__default.createElement(
341
- 'h1',
342
- null,
343
- 'Login'
344
- ),
345
- React__default.createElement('hr', null),
346
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true }),
347
- returnFormField({ name: 'password', label: 'Password', type: 'password', required: true }),
348
- React__default.createElement('hr', null),
349
- React__default.createElement(
350
- Form.Row,
351
- null,
352
- React__default.createElement(
353
- Form.Group,
354
- { as: Col },
355
- React__default.createElement(
356
- 'a',
357
- { href: '/auth/signup' },
358
- 'I don\'t have an account'
359
- )
360
- ),
361
- React__default.createElement(
362
- Form.Group,
363
- { as: Col, className: 'text-right' },
364
- !loading && React__default.createElement(
365
- Button,
366
- { type: 'submit' },
367
- 'Login'
368
- ),
369
- loading && React__default.createElement(
370
- Button,
371
- { variant: 'primary', disabled: true },
372
- React__default.createElement(Spinner, { as: 'span', animation: 'border', role: 'status', 'aria-hidden': 'true', size: 'sm' }),
373
- React__default.createElement(
374
- 'span',
375
- { className: 'sr-only' },
376
- 'Loading...'
377
- )
378
- )
379
- )
380
- ),
381
- errorMsg && React__default.createElement(
382
- 'p',
383
- { className: 'error' },
384
- errorMsg
385
- ),
386
- React__default.createElement(
387
- 'style',
388
- { jsx: 'true'.toString() },
389
- '\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 '
390
- )
391
- );
392
- };
393
-
394
- // get country & state options
395
- var countries = ["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"];
396
-
397
- 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'];
398
-
399
- var _this$3 = undefined;
400
-
401
- var SignupForm$1 = function SignupForm(props) {
402
- var handleSubmit = function () {
403
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
404
- var formData, body, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, res;
405
-
406
- return regenerator.wrap(function _callee3$(_context3) {
407
- while (1) {
408
- switch (_context3.prev = _context3.next) {
409
- case 0:
410
- event.preventDefault();
411
- setLoading(true);
412
- if (errorMsg) setErrorMsg('');
413
-
414
- formData = new FormData(e.currentTarget);
415
- body = {};
416
- _iteratorNormalCompletion = true;
417
- _didIteratorError = false;
418
- _iteratorError = undefined;
419
- _context3.prev = 8;
420
-
421
- for (_iterator = _getIterator(formData.keys()); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
422
- key = _step.value;
423
-
424
- body[key] = formData.get(key);
425
- }
426
-
427
- _context3.next = 16;
428
- break;
429
-
430
- case 12:
431
- _context3.prev = 12;
432
- _context3.t0 = _context3['catch'](8);
433
- _didIteratorError = true;
434
- _iteratorError = _context3.t0;
435
-
436
- case 16:
437
- _context3.prev = 16;
438
- _context3.prev = 17;
439
-
440
- if (!_iteratorNormalCompletion && _iterator.return) {
441
- _iterator.return();
442
- }
443
-
444
- case 19:
445
- _context3.prev = 19;
446
-
447
- if (!_didIteratorError) {
448
- _context3.next = 22;
449
- break;
450
- }
451
-
452
- throw _iteratorError;
453
-
454
- case 22:
455
- return _context3.finish(19);
456
-
457
- case 23:
458
- return _context3.finish(16);
459
-
460
- case 24:
461
- _context3.prev = 24;
462
- _context3.next = 27;
463
- return fetch('/api/auth/signup', {
464
- method: 'POST',
465
- headers: { 'Content-Type': 'application/json' },
466
- body: _JSON$stringify(body)
467
- });
468
-
469
- case 27:
470
- res = _context3.sent;
471
-
472
- setLoading(false);
473
-
474
- if (!(res.status === 200)) {
475
- _context3.next = 33;
476
- break;
477
- }
478
-
479
- window.location.href = '/';
480
- _context3.next = 38;
481
- break;
482
-
483
- case 33:
484
- _context3.t1 = Error;
485
- _context3.next = 36;
486
- return res.text();
487
-
488
- case 36:
489
- _context3.t2 = _context3.sent;
490
- throw new _context3.t1(_context3.t2);
491
-
492
- case 38:
493
- _context3.next = 43;
494
- break;
495
-
496
- case 40:
497
- _context3.prev = 40;
498
- _context3.t3 = _context3['catch'](24);
499
-
500
- setErrorMsg(_context3.t3.message);
501
-
502
- case 43:
503
- case 'end':
504
- return _context3.stop();
505
- }
506
- }
507
- }, _callee3, this, [[8, 12, 16, 24], [17,, 19, 23], [24, 40]]);
508
- }));
509
-
510
- return function handleSubmit(_x2) {
511
- return _ref3.apply(this, arguments);
512
- };
513
- }();
514
-
515
- var _useState = useState(''),
516
- _useState2 = _slicedToArray(_useState, 2),
517
- errorMsg = _useState2[0],
518
- setErrorMsg = _useState2[1];
519
-
520
- var _useState3 = useState(false),
521
- _useState4 = _slicedToArray(_useState3, 2),
522
- countryUS = _useState4[0],
523
- setCountryUS = _useState4[1];
524
-
525
- var _useState5 = useState([]),
526
- _useState6 = _slicedToArray(_useState5, 2),
527
- healthcareOccupation = _useState6[0],
528
- setHealthcareOccupation = _useState6[1];
529
-
530
- var _useState7 = useState([]),
531
- _useState8 = _slicedToArray(_useState7, 2),
532
- nonHealthcareOccupation = _useState8[0],
533
- setNonHealthcareOccupation = _useState8[1];
534
-
535
- var loadInitData = function () {
536
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
537
- var healthcare_occupation, non_healthcare_occupation;
538
- return regenerator.wrap(function _callee$(_context) {
539
- while (1) {
540
- switch (_context.prev = _context.next) {
541
- case 0:
542
- _context.next = 2;
543
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Healthcare' });
544
-
545
- case 2:
546
- healthcare_occupation = _context.sent;
547
- _context.next = 5;
548
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Non-Healthcare' });
549
-
550
- case 5:
551
- non_healthcare_occupation = _context.sent;
552
-
553
-
554
- setHealthcareOccupation(healthcare_occupation);
555
- setNonHealthcareOccupation(non_healthcare_occupation);
556
-
557
- case 8:
558
- case 'end':
559
- return _context.stop();
560
- }
561
- }
562
- }, _callee, _this$3);
563
- }));
564
-
565
- return function loadInitData() {
566
- return _ref.apply(this, arguments);
567
- };
568
- }();
569
-
570
- useEffect(function () {
571
- if (props.user) {
572
- window.location.href = '/auth/profile';
573
- } else {
574
- loadInitData();
575
- }
576
- }, []);
577
-
578
- // make it to change layout based on radio buton
579
- var handleCountryChanged = function handleCountryChanged(e) {
580
- if (e.target.value === 'United States') {
581
- setCountryUS(true);
582
- } else {
583
- setCountryUS(false);
584
- }
585
- };
586
-
587
- var _useState9 = useState(true),
588
- _useState10 = _slicedToArray(_useState9, 2),
589
- healcareProfessional = _useState10[0],
590
- setHealthcareProfessional = _useState10[1];
591
-
592
- var handleHealthcareProfessionalChanged = function handleHealthcareProfessionalChanged(e) {
593
-
594
- if (e.target.value === 'Y') {
595
- setHealthcareProfessional(true);
596
- } else {
597
- setHealthcareProfessional(false);
598
- }
599
- document.getElementById('occupation').value = '';
600
- setOccupationFields(null);
601
- };
602
-
603
- var _useState11 = useState(null),
604
- _useState12 = _slicedToArray(_useState11, 2),
605
- occupationFields = _useState12[0],
606
- setOccupationFields = _useState12[1];
607
-
608
- var handleOccupationChanged = function () {
609
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
610
- var occupation, fields;
611
- return regenerator.wrap(function _callee2$(_context2) {
612
- while (1) {
613
- switch (_context2.prev = _context2.next) {
614
- case 0:
615
- occupation = e.target.value;
616
- _context2.next = 3;
617
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: occupation });
618
-
619
- case 3:
620
- fields = _context2.sent;
621
-
622
- setOccupationFields(fields);
623
-
624
- case 5:
625
- case 'end':
626
- return _context2.stop();
627
- }
628
- }
629
- }, _callee2, _this$3);
630
- }));
631
-
632
- return function handleOccupationChanged(_x) {
633
- return _ref2.apply(this, arguments);
634
- };
635
- }();
636
-
637
- var _useState13 = useState(false),
638
- _useState14 = _slicedToArray(_useState13, 2),
639
- loading = _useState14[0],
640
- setLoading = _useState14[1];
641
-
642
- return React__default.createElement(
643
- Form,
644
- { className: 'login', id: 'signupForm', onSubmit: handleSubmit },
645
- React__default.createElement(
646
- 'h1',
647
- null,
648
- 'Sign Up'
649
- ),
650
- React__default.createElement('hr', null),
651
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true }),
652
- React__default.createElement(
653
- Form.Row,
654
- null,
655
- returnFormField({ name: 'password', label: 'Password', type: 'password', groupType: Col, required: true }),
656
- returnFormField({ name: 'rpassword', label: 'Retype Password', type: 'password', groupType: Col, required: true })
657
- ),
658
- React__default.createElement(
659
- Form.Row,
660
- null,
661
- returnFormField({ name: 'first_name', label: 'First Name', type: 'text', groupType: Col, required: true }),
662
- returnFormField({ name: 'last_name', label: 'Last Name', type: 'text', groupType: Col, required: true })
663
- ),
664
- React__default.createElement(
665
- Form.Row,
666
- null,
667
- returnFormField({
668
- name: 'country',
669
- label: 'Country',
670
- type: 'select',
671
- required: true,
672
- groupType: Col,
673
- options: countries,
674
- handleChanged: handleCountryChanged
675
- }),
676
- countryUS && returnFormField({ name: 'state', label: 'State', type: 'select', required: true, groupType: Col, options: states })
677
- ),
678
- React__default.createElement(
679
- Form.Row,
680
- null,
681
- countryUS && returnFormField({ name: 'zip', label: 'Working Zip Code', type: 'text', required: true, groupType: Col }),
682
- countryUS && returnFormField({ name: 'phone', label: 'Phone', type: 'text', required: true, groupType: Col })
683
- ),
684
- returnFormField({
685
- name: 'healthcare_professional',
686
- label: 'Are You a Health Care Professional?',
687
- type: 'radio',
688
- required: true,
689
- options: [{ value: 'Y', label: 'Yes', checked: true }, { value: 'N', label: 'No', checked: false }],
690
- handleChanged: handleHealthcareProfessionalChanged,
691
- default_value: 'Y'
692
- }),
693
- healcareProfessional && returnFormField({
694
- name: 'occupation',
695
- label: 'Occupation',
696
- type: 'select',
697
- required: true,
698
- options: healthcareOccupation,
699
- handleChanged: handleOccupationChanged
700
- }),
701
- !healcareProfessional && returnFormField({
702
- name: 'occupation',
703
- label: 'Non Provider Role',
704
- type: 'select',
705
- required: true,
706
- options: nonHealthcareOccupation,
707
- handleChanged: handleOccupationChanged
708
- }),
709
- occupationFields && occupationFields.map(function (field) {
710
- return returnFormField({
711
- name: field.name,
712
- label: field.label,
713
- type: field.type,
714
- required: field.required === 1,
715
- options: field.options
716
- });
717
- }),
718
- returnFormField({
719
- name: 'agree',
720
- label: 'Terms & Conditions | Privacy Policy',
721
- type: 'checkbox',
722
- required: true,
723
- options: [{ label: 'By registering you agree to our <a href="/terms" style="color:blue">Terms and Conditions</a> and <a href="/privacy" style="color:blue">Privacy Policy</a> and understand that you will be receiving email communications', value: 'Y' }]
724
- }),
725
- React__default.createElement('hr', null),
726
- React__default.createElement(
727
- Form.Row,
728
- null,
729
- React__default.createElement(
730
- Form.Group,
731
- { as: Col },
732
- React__default.createElement(
733
- 'a',
734
- { href: '/auth/login' },
735
- 'I already have an account'
736
- )
737
- ),
738
- React__default.createElement(
739
- Form.Group,
740
- { as: Col, className: 'text-right' },
741
- !loading && React__default.createElement(
742
- Button,
743
- { type: 'submit' },
744
- 'Sign Up'
745
- ),
746
- loading && React__default.createElement(
747
- Button,
748
- { variant: 'primary', disabled: true },
749
- React__default.createElement(Spinner, {
750
- as: 'span',
751
- animation: 'border',
752
- role: 'status',
753
- 'aria-hidden': 'true',
754
- size: 'sm'
755
- }),
756
- React__default.createElement(
757
- 'span',
758
- { className: 'sr-only' },
759
- 'Loading...'
760
- )
761
- )
762
- )
763
- ),
764
- errorMsg && React__default.createElement(
765
- 'p',
766
- { className: 'error' },
767
- errorMsg
768
- ),
769
- React__default.createElement(
770
- 'style',
771
- { jsx: 'true'.toString() },
772
- ' \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 '
773
- )
774
- );
775
- };
776
-
777
- var _this$2 = undefined;
778
-
779
- var SignupForm = function SignupForm(props) {
780
- var handleSubmit = function () {
781
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
782
- var formData, body, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, res;
783
-
784
- return regenerator.wrap(function _callee3$(_context3) {
785
- while (1) {
786
- switch (_context3.prev = _context3.next) {
787
- case 0:
788
- event.preventDefault();
789
-
790
- setErrorMsg('');
791
- setSuccessMsg('');
792
- setLoading(true);
793
-
794
- formData = new FormData(e.currentTarget);
795
- body = {};
796
- _iteratorNormalCompletion = true;
797
- _didIteratorError = false;
798
- _iteratorError = undefined;
799
- _context3.prev = 9;
800
-
801
- for (_iterator = _getIterator(formData.keys()); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
802
- key = _step.value;
803
-
804
- body[key] = formData.get(key);
805
- }
806
-
807
- _context3.next = 17;
808
- break;
809
-
810
- case 13:
811
- _context3.prev = 13;
812
- _context3.t0 = _context3['catch'](9);
813
- _didIteratorError = true;
814
- _iteratorError = _context3.t0;
815
-
816
- case 17:
817
- _context3.prev = 17;
818
- _context3.prev = 18;
819
-
820
- if (!_iteratorNormalCompletion && _iterator.return) {
821
- _iterator.return();
822
- }
823
-
824
- case 20:
825
- _context3.prev = 20;
826
-
827
- if (!_didIteratorError) {
828
- _context3.next = 23;
829
- break;
830
- }
831
-
832
- throw _iteratorError;
833
-
834
- case 23:
835
- return _context3.finish(20);
836
-
837
- case 24:
838
- return _context3.finish(17);
839
-
840
- case 25:
841
- body['user_id'] = userData.id;
842
-
843
- _context3.prev = 26;
844
- _context3.next = 29;
845
- return fetch('/api/auth/profile', {
846
- method: 'POST',
847
- headers: { 'Content-Type': 'application/json' },
848
- body: _JSON$stringify(body)
849
- });
850
-
851
- case 29:
852
- res = _context3.sent;
853
-
854
- setLoading(false);
855
-
856
- if (!(res.status === 200)) {
857
- _context3.next = 35;
858
- break;
859
- }
860
-
861
- setSuccessMsg('Your request has been processed successfully!');
862
- _context3.next = 40;
863
- break;
864
-
865
- case 35:
866
- _context3.t1 = Error;
867
- _context3.next = 38;
868
- return res.text();
869
-
870
- case 38:
871
- _context3.t2 = _context3.sent;
872
- throw new _context3.t1(_context3.t2);
873
-
874
- case 40:
875
- _context3.next = 45;
876
- break;
877
-
878
- case 42:
879
- _context3.prev = 42;
880
- _context3.t3 = _context3['catch'](26);
881
-
882
- setErrorMsg(_context3.t3.message);
883
-
884
- case 45:
885
- case 'end':
886
- return _context3.stop();
887
- }
888
- }
889
- }, _callee3, this, [[9, 13, 17, 25], [18,, 20, 24], [26, 42]]);
890
- }));
891
-
892
- return function handleSubmit(_x2) {
893
- return _ref3.apply(this, arguments);
894
- };
895
- }();
896
-
897
- var _useState = useState(''),
898
- _useState2 = _slicedToArray(_useState, 2),
899
- errorMsg = _useState2[0],
900
- setErrorMsg = _useState2[1];
901
-
902
- var _useState3 = useState(false),
903
- _useState4 = _slicedToArray(_useState3, 2),
904
- countryUS = _useState4[0],
905
- setCountryUS = _useState4[1];
906
-
907
- var _useState5 = useState([]),
908
- _useState6 = _slicedToArray(_useState5, 2),
909
- healthcareOccupation = _useState6[0],
910
- setHealthcareOccupation = _useState6[1];
911
-
912
- var _useState7 = useState([]),
913
- _useState8 = _slicedToArray(_useState7, 2),
914
- nonHealthcareOccupation = _useState8[0],
915
- setNonHealthcareOccupation = _useState8[1];
916
-
917
- var _useState9 = useState(null),
918
- _useState10 = _slicedToArray(_useState9, 2),
919
- userData = _useState10[0],
920
- setUserData = _useState10[1];
921
-
922
- var user = props.user;
923
-
924
- var loadInitData = function () {
925
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
926
- var healthcare_occupation, non_healthcare_occupation, foundOccupation, fields;
927
- return regenerator.wrap(function _callee$(_context) {
928
- while (1) {
929
- switch (_context.prev = _context.next) {
930
- case 0:
931
- _context.next = 2;
932
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Healthcare' });
933
-
934
- case 2:
935
- healthcare_occupation = _context.sent;
936
- _context.next = 5;
937
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Non-Healthcare' });
938
-
939
- case 5:
940
- non_healthcare_occupation = _context.sent;
941
- foundOccupation = healthcare_occupation.find(function (item) {
942
- return item.value === user.shared.occupation_id;
943
- });
944
-
945
- if (foundOccupation) {
946
- user.shared.healthcare_professional = 'Y';
947
- } else {
948
- user.shared.healthcare_professional = 'N';
949
- }
950
-
951
- setHealthcareOccupation(healthcare_occupation);
952
- setNonHealthcareOccupation(non_healthcare_occupation);
953
- setUserData(user);
954
-
955
- if (user.shared.country === 'United States') {
956
- setCountryUS(true);
957
- } else {
958
- setCountryUS(false);
959
- }
960
-
961
- _context.next = 14;
962
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: user.shared.occupation_id });
963
-
964
- case 14:
965
- fields = _context.sent;
966
-
967
- setOccupationFields(fields);
968
-
969
- case 16:
970
- case 'end':
971
- return _context.stop();
972
- }
973
- }
974
- }, _callee, _this$2);
975
- }));
976
-
977
- return function loadInitData() {
978
- return _ref.apply(this, arguments);
979
- };
980
- }();
981
-
982
- useEffect(function () {
983
- if (!user) {
984
- window.location.href = '/auth/login';
985
- } else {
986
- loadInitData();
987
- }
988
- }, []);
989
-
990
- // make it to change layout based on radio buton
991
- var handleCountryChanged = function handleCountryChanged(e) {
992
- if (e.target.value === 'United States') {
993
- setCountryUS(true);
994
- } else {
995
- setCountryUS(false);
996
- }
997
- };
998
-
999
- var _useState11 = useState(true),
1000
- _useState12 = _slicedToArray(_useState11, 2),
1001
- healcareProfessional = _useState12[0],
1002
- setHealthcareProfessional = _useState12[1];
1003
-
1004
- var handleHealthcareProfessionalChanged = function handleHealthcareProfessionalChanged(e) {
1005
-
1006
- if (e.target.value === 'Y') {
1007
- setHealthcareProfessional(true);
1008
- } else {
1009
- setHealthcareProfessional(false);
1010
- }
1011
- document.getElementById('occupation').value = '';
1012
- setOccupationFields(null);
1013
- };
1014
-
1015
- var _useState13 = useState(null),
1016
- _useState14 = _slicedToArray(_useState13, 2),
1017
- occupationFields = _useState14[0],
1018
- setOccupationFields = _useState14[1];
1019
-
1020
- var handleOccupationChanged = function () {
1021
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
1022
- var occupation, fields;
1023
- return regenerator.wrap(function _callee2$(_context2) {
1024
- while (1) {
1025
- switch (_context2.prev = _context2.next) {
1026
- case 0:
1027
- occupation = e.target.value;
1028
- _context2.next = 3;
1029
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: occupation });
1030
-
1031
- case 3:
1032
- fields = _context2.sent;
1033
-
1034
- setOccupationFields(fields);
1035
-
1036
- case 5:
1037
- case 'end':
1038
- return _context2.stop();
1039
- }
1040
- }
1041
- }, _callee2, _this$2);
1042
- }));
1043
-
1044
- return function handleOccupationChanged(_x) {
1045
- return _ref2.apply(this, arguments);
1046
- };
1047
- }();
1048
-
1049
- var _useState15 = useState(''),
1050
- _useState16 = _slicedToArray(_useState15, 2),
1051
- successMsg = _useState16[0],
1052
- setSuccessMsg = _useState16[1];
1053
-
1054
- var _useState17 = useState(false),
1055
- _useState18 = _slicedToArray(_useState17, 2),
1056
- loading = _useState18[0],
1057
- setLoading = _useState18[1];
1058
-
1059
- return React__default.createElement(
1060
- Form,
1061
- { className: 'login', id: 'signupForm', onSubmit: handleSubmit },
1062
- React__default.createElement(
1063
- 'h1',
1064
- null,
1065
- 'Profile'
1066
- ),
1067
- React__default.createElement('hr', null),
1068
- userData ? React__default.createElement(
1069
- React__default.Fragment,
1070
- null,
1071
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true, readonly: true, default_value: userData.email }),
1072
- React__default.createElement(
1073
- Form.Row,
1074
- null,
1075
- returnFormField({ name: 'password', label: 'Password', type: 'password', groupType: Col, required: false }),
1076
- returnFormField({ name: 'rpassword', label: 'Retype Password', type: 'password', groupType: Col, required: false })
1077
- ),
1078
- React__default.createElement(
1079
- Form.Row,
1080
- null,
1081
- returnFormField({ name: 'first_name', label: 'First Name', type: 'text', groupType: Col, required: true, default_value: userData.shared.first_name }),
1082
- returnFormField({ name: 'last_name', label: 'Last Name', type: 'text', groupType: Col, required: true, default_value: userData.shared.last_name })
1083
- ),
1084
- React__default.createElement(
1085
- Form.Row,
1086
- null,
1087
- returnFormField({
1088
- name: 'country',
1089
- label: 'Country',
1090
- type: 'select',
1091
- required: true,
1092
- groupType: Col,
1093
- options: countries,
1094
- handleChanged: handleCountryChanged,
1095
- default_value: userData.shared.country
1096
- }),
1097
- countryUS && returnFormField({ name: 'state', label: 'State', type: 'select', required: true, groupType: Col, options: states, default_value: userData.shared.state })
1098
- ),
1099
- React__default.createElement(
1100
- Form.Row,
1101
- null,
1102
- countryUS && returnFormField({ name: 'zip', label: 'Working Zip Code', type: 'text', required: true, groupType: Col, default_value: userData.shared.zip }),
1103
- countryUS && returnFormField({ name: 'phone', label: 'Phone', type: 'text', required: true, groupType: Col, default_value: userData.shared.phone })
1104
- ),
1105
- returnFormField({
1106
- name: 'healthcare_professional',
1107
- label: 'Are You a Health Care Professional?',
1108
- type: 'radio',
1109
- required: true,
1110
- options: [{ value: 'Y', label: 'Yes', checked: true }, { value: 'N', label: 'No', checked: false }],
1111
- default_value: userData.shared.healthcare_professional,
1112
- handleChanged: handleHealthcareProfessionalChanged
1113
- }),
1114
- healcareProfessional && returnFormField({
1115
- name: 'occupation',
1116
- label: 'Occupation',
1117
- type: 'select',
1118
- required: true,
1119
- options: healthcareOccupation,
1120
- handleChanged: handleOccupationChanged,
1121
- default_value: userData.shared.occupation_id
1122
- }),
1123
- !healcareProfessional && returnFormField({
1124
- name: 'occupation',
1125
- label: 'Non Provider Role',
1126
- type: 'select',
1127
- required: true,
1128
- options: nonHealthcareOccupation,
1129
- handleChanged: handleOccupationChanged,
1130
- default_value: userData.shared.occupation_id
1131
- }),
1132
- occupationFields && occupationFields.map(function (field) {
1133
- return returnFormField({
1134
- name: field.name,
1135
- label: field.label,
1136
- type: field.type,
1137
- required: field.required === 1,
1138
- options: field.options,
1139
- default_value: userData.shared[field.name]
1140
- });
1141
- }),
1142
- returnFormField({
1143
- name: 'agree',
1144
- label: 'Terms & Conditions | Privacy Policy',
1145
- type: 'checkbox',
1146
- required: true,
1147
- options: [{ label: 'By registering you agree to our <a href="/terms">Terms and Conditions</a> and <a href="/privacy">Privacy Policy</a> and understand that you will be receiving email communications', value: 'Y' }]
1148
- }),
1149
- React__default.createElement('hr', null),
1150
- React__default.createElement(
1151
- Form.Row,
1152
- null,
1153
- React__default.createElement(
1154
- Form.Group,
1155
- { as: Col },
1156
- !loading && React__default.createElement(
1157
- Button,
1158
- { type: 'submit' },
1159
- 'Update'
1160
- ),
1161
- loading && React__default.createElement(
1162
- Button,
1163
- { variant: 'primary', disabled: true },
1164
- React__default.createElement(Spinner, {
1165
- as: 'span',
1166
- animation: 'border',
1167
- role: 'status',
1168
- 'aria-hidden': 'true',
1169
- size: 'sm'
1170
- }),
1171
- React__default.createElement(
1172
- 'span',
1173
- { className: 'sr-only' },
1174
- 'Loading...'
1175
- )
1176
- )
1177
- )
1178
- )
1179
- ) : React__default.createElement(Spinner, {
1180
- as: 'span',
1181
- animation: 'border',
1182
- role: 'status',
1183
- 'aria-hidden': 'true',
1184
- size: 'sm'
1185
- }),
1186
- errorMsg && React__default.createElement(
1187
- 'p',
1188
- { className: 'error' },
1189
- errorMsg
1190
- ),
1191
- successMsg && React__default.createElement(
1192
- 'p',
1193
- { className: 'success' },
1194
- successMsg
1195
- ),
1196
- React__default.createElement(
1197
- 'style',
1198
- { jsx: 'true'.toString() },
1199
- ' \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 '
1200
- )
1201
- );
1202
- };
1203
-
1204
- var TOKEN_NAME = 'token';
1205
- var MAX_AGE = 60 * 60 * 8; // 8 hours
1206
-
1207
- function setTokenCookie(res, token, eKey) {
1208
- var cookies_serailized = [];
1209
- cookies_serailized.push(serialize_1(TOKEN_NAME, token, {
1210
- //maxAge: MAX_AGE, // we want login cookie to expire when browser
1211
- //expires: new Date(Date.now() + MAX_AGE * 1000),
1212
- //httpOnly: true,
1213
- //secure: process.env.NODE_ENV === 'production',
1214
- path: '/'
1215
- //sameSite: 'lax',
1216
- }));
1217
-
1218
- cookies_serailized.push(serialize_1('eKey', eKey, {
1219
- //maxAge: MAX_AGE, // we want login cookie to expire when browser
1220
- //expires: new Date(Date.now() + MAX_AGE * 1000),
1221
- //httpOnly: true,
1222
- //secure: process.env.NODE_ENV === 'production',
1223
- path: '/'
1224
- //sameSite: 'lax',
1225
- }));
1226
-
1227
- res.setHeader('Set-Cookie', cookies_serailized);
1228
- }
1229
-
1230
- function removeTokenCookie(res) {
1231
- var cookies_serailized = [];
1232
- cookies_serailized.push(serialize_1(TOKEN_NAME, '', {
1233
- maxAge: -1,
1234
- expires: new Date(Date.now() - MAX_AGE * 1000),
1235
- path: '/'
1236
- }));
1237
- cookies_serailized.push(serialize_1('eKey', '', {
1238
- maxAge: -1,
1239
- expires: new Date(Date.now() - MAX_AGE * 1000),
1240
- path: '/'
1241
- }));
1242
-
1243
- res.setHeader('Set-Cookie', cookies_serailized);
1244
- }
1245
-
1246
- function parseCookies(req) {
1247
- // For API Routes we don't need to parse the cookies.
1248
- if (req.cookies) return req.cookies;
1249
-
1250
- // For pages we do need to parse the cookies.
1251
- var cookie = req.headers ? req.headers.cookie : null;
1252
- return parse_1(cookie || '');
1253
- }
1254
-
1255
- function getTokenCookie(req) {
1256
- var cookies = parseCookies(req);
1257
- return cookies[TOKEN_NAME];
1258
- }
1259
-
1260
- var authCookies = /*#__PURE__*/Object.freeze({
1261
- __proto__: null,
1262
- setTokenCookie: setTokenCookie,
1263
- removeTokenCookie: removeTokenCookie,
1264
- parseCookies: parseCookies,
1265
- getTokenCookie: getTokenCookie
1266
- });
1267
-
1268
- function encryptSession(session) {
1269
- var buffer = new Buffer(_JSON$stringify(session));
1270
- return buffer.toString('base64');
1271
- //return jwt.sign(session, TOKEN_SECRET)
1272
- //return Iron.seal(session, TOKEN_SECRET, Iron.defaults)
1273
- }
1274
-
1275
- var getSession = function () {
1276
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(req) {
1277
- var token, buff;
1278
- return regenerator.wrap(function _callee$(_context) {
1279
- while (1) {
1280
- switch (_context.prev = _context.next) {
1281
- case 0:
1282
- token = getTokenCookie(req);
1283
-
1284
- if (!token) {
1285
- _context.next = 4;
1286
- break;
1287
- }
1288
-
1289
- buff = new Buffer(token, 'base64');
1290
- return _context.abrupt('return', JSON.parse(buff.toString('utf8')));
1291
-
1292
- case 4:
1293
- return _context.abrupt('return', null);
1294
-
1295
- case 5:
1296
- case 'end':
1297
- return _context.stop();
1298
- }
1299
- }
1300
- }, _callee, this);
1301
- }));
1302
-
1303
- return function getSession(_x) {
1304
- return _ref.apply(this, arguments);
1305
- };
1306
- }();
1307
-
1308
- var iron = /*#__PURE__*/Object.freeze({
1309
- __proto__: null,
1310
- encryptSession: encryptSession,
1311
- getSession: getSession
1312
- });
1313
-
1314
- var toStr$6 = Object.prototype.toString;
1315
-
1316
- var isArguments = function isArguments(value) {
1317
- var str = toStr$6.call(value);
1318
- var isArgs = str === '[object Arguments]';
1319
- if (!isArgs) {
1320
- isArgs = str !== '[object Array]' &&
1321
- value !== null &&
1322
- typeof value === 'object' &&
1323
- typeof value.length === 'number' &&
1324
- value.length >= 0 &&
1325
- toStr$6.call(value.callee) === '[object Function]';
1326
- }
1327
- return isArgs;
1328
- };
1329
-
1330
- var keysShim$1;
1331
- if (!Object.keys) {
1332
- // modified from https://github.com/es-shims/es5-shim
1333
- var has$1 = Object.prototype.hasOwnProperty;
1334
- var toStr$5 = Object.prototype.toString;
1335
- var isArgs = isArguments; // eslint-disable-line global-require
1336
- var isEnumerable = Object.prototype.propertyIsEnumerable;
1337
- var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
1338
- var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
1339
- var dontEnums = [
1340
- 'toString',
1341
- 'toLocaleString',
1342
- 'valueOf',
1343
- 'hasOwnProperty',
1344
- 'isPrototypeOf',
1345
- 'propertyIsEnumerable',
1346
- 'constructor'
1347
- ];
1348
- var equalsConstructorPrototype = function (o) {
1349
- var ctor = o.constructor;
1350
- return ctor && ctor.prototype === o;
1351
- };
1352
- var excludedKeys = {
1353
- $applicationCache: true,
1354
- $console: true,
1355
- $external: true,
1356
- $frame: true,
1357
- $frameElement: true,
1358
- $frames: true,
1359
- $innerHeight: true,
1360
- $innerWidth: true,
1361
- $onmozfullscreenchange: true,
1362
- $onmozfullscreenerror: true,
1363
- $outerHeight: true,
1364
- $outerWidth: true,
1365
- $pageXOffset: true,
1366
- $pageYOffset: true,
1367
- $parent: true,
1368
- $scrollLeft: true,
1369
- $scrollTop: true,
1370
- $scrollX: true,
1371
- $scrollY: true,
1372
- $self: true,
1373
- $webkitIndexedDB: true,
1374
- $webkitStorageInfo: true,
1375
- $window: true
1376
- };
1377
- var hasAutomationEqualityBug = (function () {
1378
- /* global window */
1379
- if (typeof window === 'undefined') { return false; }
1380
- for (var k in window) {
1381
- try {
1382
- if (!excludedKeys['$' + k] && has$1.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
1383
- try {
1384
- equalsConstructorPrototype(window[k]);
1385
- } catch (e) {
1386
- return true;
1387
- }
1388
- }
1389
- } catch (e) {
1390
- return true;
1391
- }
1392
- }
1393
- return false;
1394
- }());
1395
- var equalsConstructorPrototypeIfNotBuggy = function (o) {
1396
- /* global window */
1397
- if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
1398
- return equalsConstructorPrototype(o);
1399
- }
1400
- try {
1401
- return equalsConstructorPrototype(o);
1402
- } catch (e) {
1403
- return false;
1404
- }
1405
- };
1406
-
1407
- keysShim$1 = function keys(object) {
1408
- var isObject = object !== null && typeof object === 'object';
1409
- var isFunction = toStr$5.call(object) === '[object Function]';
1410
- var isArguments = isArgs(object);
1411
- var isString = isObject && toStr$5.call(object) === '[object String]';
1412
- var theKeys = [];
1413
-
1414
- if (!isObject && !isFunction && !isArguments) {
1415
- throw new TypeError('Object.keys called on a non-object');
1416
- }
1417
-
1418
- var skipProto = hasProtoEnumBug && isFunction;
1419
- if (isString && object.length > 0 && !has$1.call(object, 0)) {
1420
- for (var i = 0; i < object.length; ++i) {
1421
- theKeys.push(String(i));
1422
- }
1423
- }
1424
-
1425
- if (isArguments && object.length > 0) {
1426
- for (var j = 0; j < object.length; ++j) {
1427
- theKeys.push(String(j));
1428
- }
1429
- } else {
1430
- for (var name in object) {
1431
- if (!(skipProto && name === 'prototype') && has$1.call(object, name)) {
1432
- theKeys.push(String(name));
1433
- }
1434
- }
1435
- }
1436
-
1437
- if (hasDontEnumBug) {
1438
- var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
1439
-
1440
- for (var k = 0; k < dontEnums.length; ++k) {
1441
- if (!(skipConstructor && dontEnums[k] === 'constructor') && has$1.call(object, dontEnums[k])) {
1442
- theKeys.push(dontEnums[k]);
1443
- }
1444
- }
1445
- }
1446
- return theKeys;
1447
- };
1448
- }
1449
- var implementation$3 = keysShim$1;
1450
-
1451
- var slice$1 = Array.prototype.slice;
1452
-
1453
-
1454
- var origKeys = Object.keys;
1455
- var keysShim = origKeys ? function keys(o) { return origKeys(o); } : implementation$3;
1456
-
1457
- var originalKeys = Object.keys;
1458
-
1459
- keysShim.shim = function shimObjectKeys() {
1460
- if (Object.keys) {
1461
- var keysWorksWithArguments = (function () {
1462
- // Safari 5.0 bug
1463
- var args = Object.keys(arguments);
1464
- return args && args.length === arguments.length;
1465
- }(1, 2));
1466
- if (!keysWorksWithArguments) {
1467
- Object.keys = function keys(object) { // eslint-disable-line func-name-matching
1468
- if (isArguments(object)) {
1469
- return originalKeys(slice$1.call(object));
1470
- }
1471
- return originalKeys(object);
1472
- };
1473
- }
1474
- } else {
1475
- Object.keys = keysShim;
1476
- }
1477
- return Object.keys || keysShim;
1478
- };
1479
-
1480
- var objectKeys = keysShim;
1481
-
1482
- var hasSymbols$3 = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
1483
-
1484
- var toStr$4 = Object.prototype.toString;
1485
- var concat = Array.prototype.concat;
1486
- var origDefineProperty = Object.defineProperty;
1487
-
1488
- var isFunction = function (fn) {
1489
- return typeof fn === 'function' && toStr$4.call(fn) === '[object Function]';
1490
- };
1491
-
1492
- var arePropertyDescriptorsSupported = function () {
1493
- var obj = {};
1494
- try {
1495
- origDefineProperty(obj, 'x', { enumerable: false, value: obj });
1496
- // eslint-disable-next-line no-unused-vars, no-restricted-syntax
1497
- for (var _ in obj) { // jscs:ignore disallowUnusedVariables
1498
- return false;
1499
- }
1500
- return obj.x === obj;
1501
- } catch (e) { /* this is IE 8. */
1502
- return false;
1503
- }
1504
- };
1505
- var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
1506
-
1507
- var defineProperty = function (object, name, value, predicate) {
1508
- if (name in object && (!isFunction(predicate) || !predicate())) {
1509
- return;
1510
- }
1511
- if (supportsDescriptors) {
1512
- origDefineProperty(object, name, {
1513
- configurable: true,
1514
- enumerable: false,
1515
- value: value,
1516
- writable: true
1517
- });
1518
- } else {
1519
- object[name] = value;
1520
- }
1521
- };
1522
-
1523
- var defineProperties = function (object, map) {
1524
- var predicates = arguments.length > 2 ? arguments[2] : {};
1525
- var props = objectKeys(map);
1526
- if (hasSymbols$3) {
1527
- props = concat.call(props, Object.getOwnPropertySymbols(map));
1528
- }
1529
- for (var i = 0; i < props.length; i += 1) {
1530
- defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
1531
- }
1532
- };
1533
-
1534
- defineProperties.supportsDescriptors = !!supportsDescriptors;
1535
-
1536
- var defineProperties_1 = defineProperties;
1537
-
1538
- /* eslint no-invalid-this: 1 */
1539
-
1540
- var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
1541
- var slice = Array.prototype.slice;
1542
- var toStr$3 = Object.prototype.toString;
1543
- var funcType = '[object Function]';
1544
-
1545
- var implementation$2 = function bind(that) {
1546
- var target = this;
1547
- if (typeof target !== 'function' || toStr$3.call(target) !== funcType) {
1548
- throw new TypeError(ERROR_MESSAGE + target);
1549
- }
1550
- var args = slice.call(arguments, 1);
1551
-
1552
- var bound;
1553
- var binder = function () {
1554
- if (this instanceof bound) {
1555
- var result = target.apply(
1556
- this,
1557
- args.concat(slice.call(arguments))
1558
- );
1559
- if (Object(result) === result) {
1560
- return result;
1561
- }
1562
- return this;
1563
- } else {
1564
- return target.apply(
1565
- that,
1566
- args.concat(slice.call(arguments))
1567
- );
1568
- }
1569
- };
1570
-
1571
- var boundLength = Math.max(0, target.length - args.length);
1572
- var boundArgs = [];
1573
- for (var i = 0; i < boundLength; i++) {
1574
- boundArgs.push('$' + i);
1575
- }
1576
-
1577
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
1578
-
1579
- if (target.prototype) {
1580
- var Empty = function Empty() {};
1581
- Empty.prototype = target.prototype;
1582
- bound.prototype = new Empty();
1583
- Empty.prototype = null;
1584
- }
1585
-
1586
- return bound;
1587
- };
1588
-
1589
- var functionBind = Function.prototype.bind || implementation$2;
1590
-
1591
- /* eslint complexity: [2, 18], max-statements: [2, 33] */
1592
- var shams$1 = function hasSymbols() {
1593
- if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
1594
- if (typeof Symbol.iterator === 'symbol') { return true; }
1595
-
1596
- var obj = {};
1597
- var sym = Symbol('test');
1598
- var symObj = Object(sym);
1599
- if (typeof sym === 'string') { return false; }
1600
-
1601
- if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
1602
- if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
1603
-
1604
- // temp disabled per https://github.com/ljharb/object.assign/issues/17
1605
- // if (sym instanceof Symbol) { return false; }
1606
- // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
1607
- // if (!(symObj instanceof Symbol)) { return false; }
1608
-
1609
- // if (typeof Symbol.prototype.toString !== 'function') { return false; }
1610
- // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
1611
-
1612
- var symVal = 42;
1613
- obj[sym] = symVal;
1614
- for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
1615
- if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
1616
-
1617
- if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
1618
-
1619
- var syms = Object.getOwnPropertySymbols(obj);
1620
- if (syms.length !== 1 || syms[0] !== sym) { return false; }
1621
-
1622
- if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
1623
-
1624
- if (typeof Object.getOwnPropertyDescriptor === 'function') {
1625
- var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
1626
- if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
1627
- }
1628
-
1629
- return true;
1630
- };
1631
-
1632
- var origSymbol = typeof Symbol !== 'undefined' && Symbol;
1633
-
1634
-
1635
- var hasSymbols$2 = function hasNativeSymbols() {
1636
- if (typeof origSymbol !== 'function') { return false; }
1637
- if (typeof Symbol !== 'function') { return false; }
1638
- if (typeof origSymbol('foo') !== 'symbol') { return false; }
1639
- if (typeof Symbol('bar') !== 'symbol') { return false; }
1640
-
1641
- return shams$1();
1642
- };
1643
-
1644
- var src = functionBind.call(Function.call, Object.prototype.hasOwnProperty);
1645
-
1646
- var undefined$1;
1647
-
1648
- var $SyntaxError$1 = SyntaxError;
1649
- var $Function = Function;
1650
- var $TypeError$5 = TypeError;
1651
-
1652
- // eslint-disable-next-line consistent-return
1653
- var getEvalledConstructor = function (expressionSyntax) {
1654
- try {
1655
- return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
1656
- } catch (e) {}
1657
- };
1658
-
1659
- var $gOPD$2 = Object.getOwnPropertyDescriptor;
1660
- if ($gOPD$2) {
1661
- try {
1662
- $gOPD$2({}, '');
1663
- } catch (e) {
1664
- $gOPD$2 = null; // this is IE 8, which has a broken gOPD
1665
- }
1666
- }
1667
-
1668
- var throwTypeError = function () {
1669
- throw new $TypeError$5();
1670
- };
1671
- var ThrowTypeError = $gOPD$2
1672
- ? (function () {
1673
- try {
1674
- // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
1675
- arguments.callee; // IE 8 does not throw here
1676
- return throwTypeError;
1677
- } catch (calleeThrows) {
1678
- try {
1679
- // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
1680
- return $gOPD$2(arguments, 'callee').get;
1681
- } catch (gOPDthrows) {
1682
- return throwTypeError;
1683
- }
1684
- }
1685
- }())
1686
- : throwTypeError;
1687
-
1688
- var hasSymbols$1 = hasSymbols$2();
1689
-
1690
- var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
1691
-
1692
- var needsEval = {};
1693
-
1694
- var TypedArray = typeof Uint8Array === 'undefined' ? undefined$1 : getProto(Uint8Array);
1695
-
1696
- var INTRINSICS = {
1697
- '%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
1698
- '%Array%': Array,
1699
- '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
1700
- '%ArrayIteratorPrototype%': hasSymbols$1 ? getProto([][Symbol.iterator]()) : undefined$1,
1701
- '%AsyncFromSyncIteratorPrototype%': undefined$1,
1702
- '%AsyncFunction%': needsEval,
1703
- '%AsyncGenerator%': needsEval,
1704
- '%AsyncGeneratorFunction%': needsEval,
1705
- '%AsyncIteratorPrototype%': needsEval,
1706
- '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
1707
- '%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
1708
- '%Boolean%': Boolean,
1709
- '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
1710
- '%Date%': Date,
1711
- '%decodeURI%': decodeURI,
1712
- '%decodeURIComponent%': decodeURIComponent,
1713
- '%encodeURI%': encodeURI,
1714
- '%encodeURIComponent%': encodeURIComponent,
1715
- '%Error%': Error,
1716
- '%eval%': eval, // eslint-disable-line no-eval
1717
- '%EvalError%': EvalError,
1718
- '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
1719
- '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
1720
- '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
1721
- '%Function%': $Function,
1722
- '%GeneratorFunction%': needsEval,
1723
- '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
1724
- '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
1725
- '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
1726
- '%isFinite%': isFinite,
1727
- '%isNaN%': isNaN,
1728
- '%IteratorPrototype%': hasSymbols$1 ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
1729
- '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
1730
- '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
1731
- '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$1 ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
1732
- '%Math%': Math,
1733
- '%Number%': Number,
1734
- '%Object%': Object,
1735
- '%parseFloat%': parseFloat,
1736
- '%parseInt%': parseInt,
1737
- '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
1738
- '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
1739
- '%RangeError%': RangeError,
1740
- '%ReferenceError%': ReferenceError,
1741
- '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
1742
- '%RegExp%': RegExp,
1743
- '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
1744
- '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$1 ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
1745
- '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
1746
- '%String%': String,
1747
- '%StringIteratorPrototype%': hasSymbols$1 ? getProto(''[Symbol.iterator]()) : undefined$1,
1748
- '%Symbol%': hasSymbols$1 ? Symbol : undefined$1,
1749
- '%SyntaxError%': $SyntaxError$1,
1750
- '%ThrowTypeError%': ThrowTypeError,
1751
- '%TypedArray%': TypedArray,
1752
- '%TypeError%': $TypeError$5,
1753
- '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
1754
- '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
1755
- '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
1756
- '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
1757
- '%URIError%': URIError,
1758
- '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
1759
- '%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
1760
- '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
1761
- };
1762
-
1763
- var doEval = function doEval(name) {
1764
- var value;
1765
- if (name === '%AsyncFunction%') {
1766
- value = getEvalledConstructor('async function () {}');
1767
- } else if (name === '%GeneratorFunction%') {
1768
- value = getEvalledConstructor('function* () {}');
1769
- } else if (name === '%AsyncGeneratorFunction%') {
1770
- value = getEvalledConstructor('async function* () {}');
1771
- } else if (name === '%AsyncGenerator%') {
1772
- var fn = doEval('%AsyncGeneratorFunction%');
1773
- if (fn) {
1774
- value = fn.prototype;
1775
- }
1776
- } else if (name === '%AsyncIteratorPrototype%') {
1777
- var gen = doEval('%AsyncGenerator%');
1778
- if (gen) {
1779
- value = getProto(gen.prototype);
1780
- }
1781
- }
1782
-
1783
- INTRINSICS[name] = value;
1784
-
1785
- return value;
1786
- };
1787
-
1788
- var LEGACY_ALIASES = {
1789
- '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
1790
- '%ArrayPrototype%': ['Array', 'prototype'],
1791
- '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
1792
- '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
1793
- '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
1794
- '%ArrayProto_values%': ['Array', 'prototype', 'values'],
1795
- '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
1796
- '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
1797
- '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
1798
- '%BooleanPrototype%': ['Boolean', 'prototype'],
1799
- '%DataViewPrototype%': ['DataView', 'prototype'],
1800
- '%DatePrototype%': ['Date', 'prototype'],
1801
- '%ErrorPrototype%': ['Error', 'prototype'],
1802
- '%EvalErrorPrototype%': ['EvalError', 'prototype'],
1803
- '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
1804
- '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
1805
- '%FunctionPrototype%': ['Function', 'prototype'],
1806
- '%Generator%': ['GeneratorFunction', 'prototype'],
1807
- '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
1808
- '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
1809
- '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
1810
- '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
1811
- '%JSONParse%': ['JSON', 'parse'],
1812
- '%JSONStringify%': ['JSON', 'stringify'],
1813
- '%MapPrototype%': ['Map', 'prototype'],
1814
- '%NumberPrototype%': ['Number', 'prototype'],
1815
- '%ObjectPrototype%': ['Object', 'prototype'],
1816
- '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
1817
- '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
1818
- '%PromisePrototype%': ['Promise', 'prototype'],
1819
- '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
1820
- '%Promise_all%': ['Promise', 'all'],
1821
- '%Promise_reject%': ['Promise', 'reject'],
1822
- '%Promise_resolve%': ['Promise', 'resolve'],
1823
- '%RangeErrorPrototype%': ['RangeError', 'prototype'],
1824
- '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
1825
- '%RegExpPrototype%': ['RegExp', 'prototype'],
1826
- '%SetPrototype%': ['Set', 'prototype'],
1827
- '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
1828
- '%StringPrototype%': ['String', 'prototype'],
1829
- '%SymbolPrototype%': ['Symbol', 'prototype'],
1830
- '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
1831
- '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
1832
- '%TypeErrorPrototype%': ['TypeError', 'prototype'],
1833
- '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
1834
- '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
1835
- '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
1836
- '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
1837
- '%URIErrorPrototype%': ['URIError', 'prototype'],
1838
- '%WeakMapPrototype%': ['WeakMap', 'prototype'],
1839
- '%WeakSetPrototype%': ['WeakSet', 'prototype']
1840
- };
1841
-
1842
-
1843
-
1844
- var $concat$2 = functionBind.call(Function.call, Array.prototype.concat);
1845
- var $spliceApply = functionBind.call(Function.apply, Array.prototype.splice);
1846
- var $replace = functionBind.call(Function.call, String.prototype.replace);
1847
- var $strSlice = functionBind.call(Function.call, String.prototype.slice);
1848
-
1849
- /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
1850
- var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
1851
- var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
1852
- var stringToPath = function stringToPath(string) {
1853
- var first = $strSlice(string, 0, 1);
1854
- var last = $strSlice(string, -1);
1855
- if (first === '%' && last !== '%') {
1856
- throw new $SyntaxError$1('invalid intrinsic syntax, expected closing `%`');
1857
- } else if (last === '%' && first !== '%') {
1858
- throw new $SyntaxError$1('invalid intrinsic syntax, expected opening `%`');
1859
- }
1860
- var result = [];
1861
- $replace(string, rePropName, function (match, number, quote, subString) {
1862
- result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
1863
- });
1864
- return result;
1865
- };
1866
- /* end adaptation */
1867
-
1868
- var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
1869
- var intrinsicName = name;
1870
- var alias;
1871
- if (src(LEGACY_ALIASES, intrinsicName)) {
1872
- alias = LEGACY_ALIASES[intrinsicName];
1873
- intrinsicName = '%' + alias[0] + '%';
1874
- }
1875
-
1876
- if (src(INTRINSICS, intrinsicName)) {
1877
- var value = INTRINSICS[intrinsicName];
1878
- if (value === needsEval) {
1879
- value = doEval(intrinsicName);
1880
- }
1881
- if (typeof value === 'undefined' && !allowMissing) {
1882
- throw new $TypeError$5('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
1883
- }
1884
-
1885
- return {
1886
- alias: alias,
1887
- name: intrinsicName,
1888
- value: value
1889
- };
1890
- }
1891
-
1892
- throw new $SyntaxError$1('intrinsic ' + name + ' does not exist!');
1893
- };
1894
-
1895
- var getIntrinsic = function GetIntrinsic(name, allowMissing) {
1896
- if (typeof name !== 'string' || name.length === 0) {
1897
- throw new $TypeError$5('intrinsic name must be a non-empty string');
1898
- }
1899
- if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
1900
- throw new $TypeError$5('"allowMissing" argument must be a boolean');
1901
- }
1902
-
1903
- var parts = stringToPath(name);
1904
- var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
1905
-
1906
- var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
1907
- var intrinsicRealName = intrinsic.name;
1908
- var value = intrinsic.value;
1909
- var skipFurtherCaching = false;
1910
-
1911
- var alias = intrinsic.alias;
1912
- if (alias) {
1913
- intrinsicBaseName = alias[0];
1914
- $spliceApply(parts, $concat$2([0, 1], alias));
1915
- }
1916
-
1917
- for (var i = 1, isOwn = true; i < parts.length; i += 1) {
1918
- var part = parts[i];
1919
- var first = $strSlice(part, 0, 1);
1920
- var last = $strSlice(part, -1);
1921
- if (
1922
- (
1923
- (first === '"' || first === "'" || first === '`')
1924
- || (last === '"' || last === "'" || last === '`')
1925
- )
1926
- && first !== last
1927
- ) {
1928
- throw new $SyntaxError$1('property names with quotes must have matching quotes');
1929
- }
1930
- if (part === 'constructor' || !isOwn) {
1931
- skipFurtherCaching = true;
1932
- }
1933
-
1934
- intrinsicBaseName += '.' + part;
1935
- intrinsicRealName = '%' + intrinsicBaseName + '%';
1936
-
1937
- if (src(INTRINSICS, intrinsicRealName)) {
1938
- value = INTRINSICS[intrinsicRealName];
1939
- } else if (value != null) {
1940
- if (!(part in value)) {
1941
- if (!allowMissing) {
1942
- throw new $TypeError$5('base intrinsic for ' + name + ' exists, but the property is not available.');
1943
- }
1944
- return void undefined$1;
1945
- }
1946
- if ($gOPD$2 && (i + 1) >= parts.length) {
1947
- var desc = $gOPD$2(value, part);
1948
- isOwn = !!desc;
1949
-
1950
- // By convention, when a data property is converted to an accessor
1951
- // property to emulate a data property that does not suffer from
1952
- // the override mistake, that accessor's getter is marked with
1953
- // an `originalValue` property. Here, when we detect this, we
1954
- // uphold the illusion by pretending to see that original data
1955
- // property, i.e., returning the value rather than the getter
1956
- // itself.
1957
- if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
1958
- value = desc.get;
1959
- } else {
1960
- value = value[part];
1961
- }
1962
- } else {
1963
- isOwn = src(value, part);
1964
- value = value[part];
1965
- }
1966
-
1967
- if (isOwn && !skipFurtherCaching) {
1968
- INTRINSICS[intrinsicRealName] = value;
1969
- }
1970
- }
1971
- }
1972
- return value;
1973
- };
1974
-
1975
- var callBind = createCommonjsModule(function (module) {
1976
-
1977
-
1978
-
1979
-
1980
- var $apply = getIntrinsic('%Function.prototype.apply%');
1981
- var $call = getIntrinsic('%Function.prototype.call%');
1982
- var $reflectApply = getIntrinsic('%Reflect.apply%', true) || functionBind.call($call, $apply);
1983
-
1984
- var $gOPD = getIntrinsic('%Object.getOwnPropertyDescriptor%', true);
1985
- var $defineProperty = getIntrinsic('%Object.defineProperty%', true);
1986
- var $max = getIntrinsic('%Math.max%');
1987
-
1988
- if ($defineProperty) {
1989
- try {
1990
- $defineProperty({}, 'a', { value: 1 });
1991
- } catch (e) {
1992
- // IE 8 has a broken defineProperty
1993
- $defineProperty = null;
1994
- }
1995
- }
1996
-
1997
- module.exports = function callBind(originalFunction) {
1998
- var func = $reflectApply(functionBind, $call, arguments);
1999
- if ($gOPD && $defineProperty) {
2000
- var desc = $gOPD(func, 'length');
2001
- if (desc.configurable) {
2002
- // original length, plus the receiver, minus any additional arguments (after the receiver)
2003
- $defineProperty(
2004
- func,
2005
- 'length',
2006
- { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
2007
- );
2008
- }
2009
- }
2010
- return func;
2011
- };
2012
-
2013
- var applyBind = function applyBind() {
2014
- return $reflectApply(functionBind, $apply, arguments);
2015
- };
2016
-
2017
- if ($defineProperty) {
2018
- $defineProperty(module.exports, 'apply', { value: applyBind });
2019
- } else {
2020
- module.exports.apply = applyBind;
2021
- }
2022
- });
2023
- callBind.apply;
2024
-
2025
- var $indexOf = callBind(getIntrinsic('String.prototype.indexOf'));
2026
-
2027
- var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
2028
- var intrinsic = getIntrinsic(name, !!allowMissing);
2029
- if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
2030
- return callBind(intrinsic);
2031
- }
2032
- return intrinsic;
2033
- };
2034
-
2035
- var $Array$1 = getIntrinsic('%Array%');
2036
-
2037
- // eslint-disable-next-line global-require
2038
- var toStr$2 = !$Array$1.isArray && callBound$1('Object.prototype.toString');
2039
-
2040
- // https://ecma-international.org/ecma-262/6.0/#sec-isarray
2041
-
2042
- var IsArray$1 = $Array$1.isArray || function IsArray(argument) {
2043
- return toStr$2(argument) === '[object Array]';
2044
- };
2045
-
2046
- var $defineProperty = getIntrinsic('%Object.defineProperty%', true);
2047
-
2048
- if ($defineProperty) {
2049
- try {
2050
- $defineProperty({}, 'a', { value: 1 });
2051
- } catch (e) {
2052
- // IE 8 has a broken defineProperty
2053
- $defineProperty = null;
2054
- }
2055
- }
2056
-
2057
- // node v0.6 has a bug where array lengths can be Set but not Defined
2058
- var hasArrayLengthDefineBug = Object.defineProperty && Object.defineProperty([], 'length', { value: 1 }).length === 0;
2059
-
2060
- // eslint-disable-next-line global-require
2061
- var isArray = hasArrayLengthDefineBug && IsArray$1; // this does not depend on any other AOs.
2062
-
2063
-
2064
-
2065
- var $isEnumerable$1 = callBound$1('Object.prototype.propertyIsEnumerable');
2066
-
2067
- // eslint-disable-next-line max-params
2068
- var DefineOwnProperty = function DefineOwnProperty(IsDataDescriptor, SameValue, FromPropertyDescriptor, O, P, desc) {
2069
- if (!$defineProperty) {
2070
- if (!IsDataDescriptor(desc)) {
2071
- // ES3 does not support getters/setters
2072
- return false;
2073
- }
2074
- if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) {
2075
- return false;
2076
- }
2077
-
2078
- // fallback for ES3
2079
- if (P in O && $isEnumerable$1(O, P) !== !!desc['[[Enumerable]]']) {
2080
- // a non-enumerable existing property
2081
- return false;
2082
- }
2083
-
2084
- // property does not exist at all, or exists but is enumerable
2085
- var V = desc['[[Value]]'];
2086
- // eslint-disable-next-line no-param-reassign
2087
- O[P] = V; // will use [[Define]]
2088
- return SameValue(O[P], V);
2089
- }
2090
- if (
2091
- hasArrayLengthDefineBug
2092
- && P === 'length'
2093
- && '[[Value]]' in desc
2094
- && isArray(O)
2095
- && O.length !== desc['[[Value]]']
2096
- ) {
2097
- // eslint-disable-next-line no-param-reassign
2098
- O.length = desc['[[Value]]'];
2099
- return O.length === desc['[[Value]]'];
2100
- }
2101
-
2102
- $defineProperty(O, P, FromPropertyDescriptor(desc));
2103
- return true;
2104
- };
2105
-
2106
- var $TypeError$4 = getIntrinsic('%TypeError%');
2107
- var $SyntaxError = getIntrinsic('%SyntaxError%');
2108
-
2109
-
2110
-
2111
- var predicates = {
2112
- // https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type
2113
- 'Property Descriptor': function isPropertyDescriptor(Type, Desc) {
2114
- if (Type(Desc) !== 'Object') {
2115
- return false;
2116
- }
2117
- var allowed = {
2118
- '[[Configurable]]': true,
2119
- '[[Enumerable]]': true,
2120
- '[[Get]]': true,
2121
- '[[Set]]': true,
2122
- '[[Value]]': true,
2123
- '[[Writable]]': true
2124
- };
2125
-
2126
- for (var key in Desc) { // eslint-disable-line
2127
- if (src(Desc, key) && !allowed[key]) {
2128
- return false;
2129
- }
2130
- }
2131
-
2132
- var isData = src(Desc, '[[Value]]');
2133
- var IsAccessor = src(Desc, '[[Get]]') || src(Desc, '[[Set]]');
2134
- if (isData && IsAccessor) {
2135
- throw new $TypeError$4('Property Descriptors may not be both accessor and data descriptors');
2136
- }
2137
- return true;
2138
- }
2139
- };
2140
-
2141
- var assertRecord = function assertRecord(Type, recordType, argumentName, value) {
2142
- var predicate = predicates[recordType];
2143
- if (typeof predicate !== 'function') {
2144
- throw new $SyntaxError('unknown record type: ' + recordType);
2145
- }
2146
- if (!predicate(Type, value)) {
2147
- throw new $TypeError$4(argumentName + ' must be a ' + recordType);
2148
- }
2149
- };
2150
-
2151
- // https://262.ecma-international.org/5.1/#sec-8
2152
-
2153
- var Type$1 = function Type(x) {
2154
- if (x === null) {
2155
- return 'Null';
2156
- }
2157
- if (typeof x === 'undefined') {
2158
- return 'Undefined';
2159
- }
2160
- if (typeof x === 'function' || typeof x === 'object') {
2161
- return 'Object';
2162
- }
2163
- if (typeof x === 'number') {
2164
- return 'Number';
2165
- }
2166
- if (typeof x === 'boolean') {
2167
- return 'Boolean';
2168
- }
2169
- if (typeof x === 'string') {
2170
- return 'String';
2171
- }
2172
- };
2173
-
2174
- // https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values
2175
-
2176
- var Type = function Type(x) {
2177
- if (typeof x === 'symbol') {
2178
- return 'Symbol';
2179
- }
2180
- if (typeof x === 'bigint') {
2181
- return 'BigInt';
2182
- }
2183
- return Type$1(x);
2184
- };
2185
-
2186
- // https://ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
2187
-
2188
- var FromPropertyDescriptor = function FromPropertyDescriptor(Desc) {
2189
- if (typeof Desc === 'undefined') {
2190
- return Desc;
2191
- }
2192
-
2193
- assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
2194
-
2195
- var obj = {};
2196
- if ('[[Value]]' in Desc) {
2197
- obj.value = Desc['[[Value]]'];
2198
- }
2199
- if ('[[Writable]]' in Desc) {
2200
- obj.writable = Desc['[[Writable]]'];
2201
- }
2202
- if ('[[Get]]' in Desc) {
2203
- obj.get = Desc['[[Get]]'];
2204
- }
2205
- if ('[[Set]]' in Desc) {
2206
- obj.set = Desc['[[Set]]'];
2207
- }
2208
- if ('[[Enumerable]]' in Desc) {
2209
- obj.enumerable = Desc['[[Enumerable]]'];
2210
- }
2211
- if ('[[Configurable]]' in Desc) {
2212
- obj.configurable = Desc['[[Configurable]]'];
2213
- }
2214
- return obj;
2215
- };
2216
-
2217
- var $gOPD$1 = getIntrinsic('%Object.getOwnPropertyDescriptor%', true);
2218
- if ($gOPD$1) {
2219
- try {
2220
- $gOPD$1([], 'length');
2221
- } catch (e) {
2222
- // IE 8 has a broken gOPD
2223
- $gOPD$1 = null;
2224
- }
2225
- }
2226
-
2227
- var getOwnPropertyDescriptor = $gOPD$1;
2228
-
2229
- var $Array = getIntrinsic('%Array%');
2230
-
2231
- // eslint-disable-next-line global-require
2232
- var toStr$1 = !$Array.isArray && callBound$1('Object.prototype.toString');
2233
-
2234
- // https://ecma-international.org/ecma-262/6.0/#sec-isarray
2235
-
2236
- var IsArray = $Array.isArray || function IsArray(argument) {
2237
- return toStr$1(argument) === '[object Array]';
2238
- };
2239
-
2240
- // https://ecma-international.org/ecma-262/6.0/#sec-ispropertykey
2241
-
2242
- var IsPropertyKey = function IsPropertyKey(argument) {
2243
- return typeof argument === 'string' || typeof argument === 'symbol';
2244
- };
2245
-
2246
- var shams = function hasToStringTagShams() {
2247
- return shams$1() && !!Symbol.toStringTag;
2248
- };
2249
-
2250
- var hasToStringTag$1 = shams();
2251
- var has;
2252
- var $exec;
2253
- var isRegexMarker;
2254
- var badStringifier;
2255
-
2256
- if (hasToStringTag$1) {
2257
- has = callBound$1('Object.prototype.hasOwnProperty');
2258
- $exec = callBound$1('RegExp.prototype.exec');
2259
- isRegexMarker = {};
2260
-
2261
- var throwRegexMarker = function () {
2262
- throw isRegexMarker;
2263
- };
2264
- badStringifier = {
2265
- toString: throwRegexMarker,
2266
- valueOf: throwRegexMarker
2267
- };
2268
-
2269
- if (typeof Symbol.toPrimitive === 'symbol') {
2270
- badStringifier[Symbol.toPrimitive] = throwRegexMarker;
2271
- }
2272
- }
2273
-
2274
- var $toString = callBound$1('Object.prototype.toString');
2275
- var gOPD = Object.getOwnPropertyDescriptor;
2276
- var regexClass = '[object RegExp]';
2277
-
2278
- var isRegex = hasToStringTag$1
2279
- // eslint-disable-next-line consistent-return
2280
- ? function isRegex(value) {
2281
- if (!value || typeof value !== 'object') {
2282
- return false;
2283
- }
2284
-
2285
- var descriptor = gOPD(value, 'lastIndex');
2286
- var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
2287
- if (!hasLastIndexDataProperty) {
2288
- return false;
2289
- }
2290
-
2291
- try {
2292
- $exec(value, badStringifier);
2293
- } catch (e) {
2294
- return e === isRegexMarker;
2295
- }
2296
- }
2297
- : function isRegex(value) {
2298
- // In older browsers, typeof regex incorrectly returns 'function'
2299
- if (!value || (typeof value !== 'object' && typeof value !== 'function')) {
2300
- return false;
2301
- }
2302
-
2303
- return $toString(value) === regexClass;
2304
- };
2305
-
2306
- // http://262.ecma-international.org/5.1/#sec-9.2
2307
-
2308
- var ToBoolean = function ToBoolean(value) { return !!value; };
2309
-
2310
- var $match = getIntrinsic('%Symbol.match%', true);
2311
-
2312
-
2313
-
2314
-
2315
-
2316
- // https://ecma-international.org/ecma-262/6.0/#sec-isregexp
2317
-
2318
- var IsRegExp = function IsRegExp(argument) {
2319
- if (!argument || typeof argument !== 'object') {
2320
- return false;
2321
- }
2322
- if ($match) {
2323
- var isRegExp = argument[$match];
2324
- if (typeof isRegExp !== 'undefined') {
2325
- return ToBoolean(isRegExp);
2326
- }
2327
- }
2328
- return isRegex(argument);
2329
- };
2330
-
2331
- var fnToStr = Function.prototype.toString;
2332
- var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply;
2333
- var badArrayLike;
2334
- var isCallableMarker;
2335
- if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') {
2336
- try {
2337
- badArrayLike = Object.defineProperty({}, 'length', {
2338
- get: function () {
2339
- throw isCallableMarker;
2340
- }
2341
- });
2342
- isCallableMarker = {};
2343
- // eslint-disable-next-line no-throw-literal
2344
- reflectApply(function () { throw 42; }, null, badArrayLike);
2345
- } catch (_) {
2346
- if (_ !== isCallableMarker) {
2347
- reflectApply = null;
2348
- }
2349
- }
2350
- } else {
2351
- reflectApply = null;
2352
- }
2353
-
2354
- var constructorRegex = /^\s*class\b/;
2355
- var isES6ClassFn = function isES6ClassFunction(value) {
2356
- try {
2357
- var fnStr = fnToStr.call(value);
2358
- return constructorRegex.test(fnStr);
2359
- } catch (e) {
2360
- return false; // not a function
2361
- }
2362
- };
2363
-
2364
- var tryFunctionObject = function tryFunctionToStr(value) {
2365
- try {
2366
- if (isES6ClassFn(value)) { return false; }
2367
- fnToStr.call(value);
2368
- return true;
2369
- } catch (e) {
2370
- return false;
2371
- }
2372
- };
2373
- var toStr = Object.prototype.toString;
2374
- var fnClass = '[object Function]';
2375
- var genClass = '[object GeneratorFunction]';
2376
- var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag`
2377
- /* globals document: false */
2378
- var documentDotAll = typeof document === 'object' && typeof document.all === 'undefined' && document.all !== undefined ? document.all : {};
2379
-
2380
- var isCallable = reflectApply
2381
- ? function isCallable(value) {
2382
- if (value === documentDotAll) { return true; }
2383
- if (!value) { return false; }
2384
- if (typeof value !== 'function' && typeof value !== 'object') { return false; }
2385
- if (typeof value === 'function' && !value.prototype) { return true; }
2386
- try {
2387
- reflectApply(value, null, badArrayLike);
2388
- } catch (e) {
2389
- if (e !== isCallableMarker) { return false; }
2390
- }
2391
- return !isES6ClassFn(value);
2392
- }
2393
- : function isCallable(value) {
2394
- if (value === documentDotAll) { return true; }
2395
- if (!value) { return false; }
2396
- if (typeof value !== 'function' && typeof value !== 'object') { return false; }
2397
- if (typeof value === 'function' && !value.prototype) { return true; }
2398
- if (hasToStringTag) { return tryFunctionObject(value); }
2399
- if (isES6ClassFn(value)) { return false; }
2400
- var strClass = toStr.call(value);
2401
- return strClass === fnClass || strClass === genClass;
2402
- };
2403
-
2404
- // http://262.ecma-international.org/5.1/#sec-9.11
2405
-
2406
- var IsCallable = isCallable;
2407
-
2408
- var $TypeError$3 = getIntrinsic('%TypeError%');
2409
-
2410
-
2411
-
2412
-
2413
-
2414
- // https://262.ecma-international.org/5.1/#sec-8.10.5
2415
-
2416
- var ToPropertyDescriptor = function ToPropertyDescriptor(Obj) {
2417
- if (Type(Obj) !== 'Object') {
2418
- throw new $TypeError$3('ToPropertyDescriptor requires an object');
2419
- }
2420
-
2421
- var desc = {};
2422
- if (src(Obj, 'enumerable')) {
2423
- desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable);
2424
- }
2425
- if (src(Obj, 'configurable')) {
2426
- desc['[[Configurable]]'] = ToBoolean(Obj.configurable);
2427
- }
2428
- if (src(Obj, 'value')) {
2429
- desc['[[Value]]'] = Obj.value;
2430
- }
2431
- if (src(Obj, 'writable')) {
2432
- desc['[[Writable]]'] = ToBoolean(Obj.writable);
2433
- }
2434
- if (src(Obj, 'get')) {
2435
- var getter = Obj.get;
2436
- if (typeof getter !== 'undefined' && !IsCallable(getter)) {
2437
- throw new $TypeError$3('getter must be a function');
2438
- }
2439
- desc['[[Get]]'] = getter;
2440
- }
2441
- if (src(Obj, 'set')) {
2442
- var setter = Obj.set;
2443
- if (typeof setter !== 'undefined' && !IsCallable(setter)) {
2444
- throw new $TypeError$3('setter must be a function');
2445
- }
2446
- desc['[[Set]]'] = setter;
2447
- }
2448
-
2449
- if ((src(desc, '[[Get]]') || src(desc, '[[Set]]')) && (src(desc, '[[Value]]') || src(desc, '[[Writable]]'))) {
2450
- throw new $TypeError$3('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute');
2451
- }
2452
- return desc;
2453
- };
2454
-
2455
- var $TypeError$2 = getIntrinsic('%TypeError%');
2456
-
2457
-
2458
-
2459
- var $isEnumerable = callBound$1('Object.prototype.propertyIsEnumerable');
2460
-
2461
-
2462
-
2463
-
2464
-
2465
-
2466
-
2467
-
2468
-
2469
- // https://ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
2470
-
2471
- var OrdinaryGetOwnProperty = function OrdinaryGetOwnProperty(O, P) {
2472
- if (Type(O) !== 'Object') {
2473
- throw new $TypeError$2('Assertion failed: O must be an Object');
2474
- }
2475
- if (!IsPropertyKey(P)) {
2476
- throw new $TypeError$2('Assertion failed: P must be a Property Key');
2477
- }
2478
- if (!src(O, P)) {
2479
- return void 0;
2480
- }
2481
- if (!getOwnPropertyDescriptor) {
2482
- // ES3 / IE 8 fallback
2483
- var arrayLength = IsArray(O) && P === 'length';
2484
- var regexLastIndex = IsRegExp(O) && P === 'lastIndex';
2485
- return {
2486
- '[[Configurable]]': !(arrayLength || regexLastIndex),
2487
- '[[Enumerable]]': $isEnumerable(O, P),
2488
- '[[Value]]': O[P],
2489
- '[[Writable]]': true
2490
- };
2491
- }
2492
- return ToPropertyDescriptor(getOwnPropertyDescriptor(O, P));
2493
- };
2494
-
2495
- // https://ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor
2496
-
2497
- var IsDataDescriptor = function IsDataDescriptor(Desc) {
2498
- if (typeof Desc === 'undefined') {
2499
- return false;
2500
- }
2501
-
2502
- assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
2503
-
2504
- if (!src(Desc, '[[Value]]') && !src(Desc, '[[Writable]]')) {
2505
- return false;
2506
- }
2507
-
2508
- return true;
2509
- };
2510
-
2511
- var isPrimitive = function isPrimitive(value) {
2512
- return value === null || (typeof value !== 'function' && typeof value !== 'object');
2513
- };
2514
-
2515
- var $Object$1 = getIntrinsic('%Object%');
2516
-
2517
-
2518
-
2519
- var $preventExtensions = $Object$1.preventExtensions;
2520
- var $isExtensible = $Object$1.isExtensible;
2521
-
2522
- // https://ecma-international.org/ecma-262/6.0/#sec-isextensible-o
2523
-
2524
- var IsExtensible = $preventExtensions
2525
- ? function IsExtensible(obj) {
2526
- return !isPrimitive(obj) && $isExtensible(obj);
2527
- }
2528
- : function IsExtensible(obj) {
2529
- return !isPrimitive(obj);
2530
- };
2531
-
2532
- var _isNaN = Number.isNaN || function isNaN(a) {
2533
- return a !== a;
2534
- };
2535
-
2536
- // http://262.ecma-international.org/5.1/#sec-9.12
2537
-
2538
- var SameValue = function SameValue(x, y) {
2539
- if (x === y) { // 0 === -0, but they are not identical.
2540
- if (x === 0) { return 1 / x === 1 / y; }
2541
- return true;
2542
- }
2543
- return _isNaN(x) && _isNaN(y);
2544
- };
2545
-
2546
- var $TypeError$1 = getIntrinsic('%TypeError%');
2547
-
2548
-
2549
-
2550
-
2551
-
2552
-
2553
-
2554
-
2555
-
2556
-
2557
-
2558
- // https://ecma-international.org/ecma-262/6.0/#sec-createdataproperty
2559
-
2560
- var CreateDataProperty = function CreateDataProperty(O, P, V) {
2561
- if (Type(O) !== 'Object') {
2562
- throw new $TypeError$1('Assertion failed: Type(O) is not Object');
2563
- }
2564
- if (!IsPropertyKey(P)) {
2565
- throw new $TypeError$1('Assertion failed: IsPropertyKey(P) is not true');
2566
- }
2567
- var oldDesc = OrdinaryGetOwnProperty(O, P);
2568
- var extensible = !oldDesc || IsExtensible(O);
2569
- var immutable = oldDesc && (!oldDesc['[[Writable]]'] || !oldDesc['[[Configurable]]']);
2570
- if (immutable || !extensible) {
2571
- return false;
2572
- }
2573
- return DefineOwnProperty(
2574
- IsDataDescriptor,
2575
- SameValue,
2576
- FromPropertyDescriptor,
2577
- O,
2578
- P,
2579
- {
2580
- '[[Configurable]]': true,
2581
- '[[Enumerable]]': true,
2582
- '[[Value]]': V,
2583
- '[[Writable]]': true
2584
- }
2585
- );
2586
- };
2587
-
2588
- var $TypeError = getIntrinsic('%TypeError%');
2589
-
2590
- // http://262.ecma-international.org/5.1/#sec-9.10
2591
-
2592
- var CheckObjectCoercible = function CheckObjectCoercible(value, optMessage) {
2593
- if (value == null) {
2594
- throw new $TypeError(optMessage || ('Cannot call method on ' + value));
2595
- }
2596
- return value;
2597
- };
2598
-
2599
- var RequireObjectCoercible = CheckObjectCoercible;
2600
-
2601
- var $Object = getIntrinsic('%Object%');
2602
-
2603
-
2604
-
2605
- // https://ecma-international.org/ecma-262/6.0/#sec-toobject
2606
-
2607
- var ToObject = function ToObject(value) {
2608
- RequireObjectCoercible(value);
2609
- return $Object(value);
2610
- };
2611
-
2612
- var $gOPD = Object.getOwnPropertyDescriptor;
2613
- var $getOwnNames = Object.getOwnPropertyNames;
2614
- var $getSymbols = Object.getOwnPropertySymbols;
2615
- var $concat$1 = callBound$1('Array.prototype.concat');
2616
- var $reduce = callBound$1('Array.prototype.reduce');
2617
- var getAll = $getSymbols ? function (obj) {
2618
- return $concat$1($getOwnNames(obj), $getSymbols(obj));
2619
- } : $getOwnNames;
2620
-
2621
- var isES5$1 = IsCallable($gOPD) && IsCallable($getOwnNames);
2622
-
2623
- var implementation$1 = function getOwnPropertyDescriptors(value) {
2624
- RequireObjectCoercible(value);
2625
- if (!isES5$1) {
2626
- throw new TypeError('getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor');
2627
- }
2628
-
2629
- var O = ToObject(value);
2630
- return $reduce(
2631
- getAll(O),
2632
- function (acc, key) {
2633
- var descriptor = $gOPD(O, key);
2634
- if (typeof descriptor !== 'undefined') {
2635
- CreateDataProperty(acc, key, descriptor);
2636
- }
2637
- return acc;
2638
- },
2639
- {}
2640
- );
2641
- };
2642
-
2643
- var polyfill$2 = function getPolyfill() {
2644
- return typeof Object.getOwnPropertyDescriptors === 'function' ? Object.getOwnPropertyDescriptors : implementation$1;
2645
- };
2646
-
2647
- var shim$1 = function shimGetOwnPropertyDescriptors() {
2648
- var polyfill = polyfill$2();
2649
- defineProperties_1(
2650
- Object,
2651
- { getOwnPropertyDescriptors: polyfill },
2652
- { getOwnPropertyDescriptors: function () { return Object.getOwnPropertyDescriptors !== polyfill; } }
2653
- );
2654
- return polyfill;
2655
- };
2656
-
2657
- var bound = callBind(polyfill$2(), Object);
2658
-
2659
- defineProperties_1(bound, {
2660
- getPolyfill: polyfill$2,
2661
- implementation: implementation$1,
2662
- shim: shim$1
2663
- });
2664
-
2665
- var object_getownpropertydescriptors = bound;
2666
-
2667
- // TODO; semver-major: remove
2668
-
2669
- var callBound = callBound$1;
2670
-
2671
- var isES5 = typeof Object.defineProperty === 'function'
2672
- && typeof Object.defineProperties === 'function';
2673
-
2674
- var hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
2675
-
2676
- if (!isES5 || !hasProto) {
2677
- throw new TypeError('util.promisify requires a true ES5 environment, that also supports `__proto__`');
2678
- }
2679
-
2680
-
2681
-
2682
- if (typeof Promise !== 'function') {
2683
- throw new TypeError('`Promise` must be globally available for util.promisify to work.');
2684
- }
2685
-
2686
-
2687
-
2688
- var $slice = callBound('Array.prototype.slice');
2689
- var $concat = callBound('Array.prototype.concat');
2690
- var $forEach = callBound('Array.prototype.forEach');
2691
-
2692
- var hasSymbols = hasSymbols$2();
2693
-
2694
- var kCustomPromisifiedSymbol = hasSymbols ? Symbol('util.promisify.custom') : null;
2695
- var kCustomPromisifyArgsSymbol = hasSymbols ? Symbol('customPromisifyArgs') : null;
2696
-
2697
- var implementation = function promisify(orig) {
2698
- if (typeof orig !== 'function') {
2699
- var error = new TypeError('The "original" argument must be of type function');
2700
- error.name = 'TypeError [ERR_INVALID_ARG_TYPE]';
2701
- error.code = 'ERR_INVALID_ARG_TYPE';
2702
- throw error;
2703
- }
2704
-
2705
- if (hasSymbols && orig[kCustomPromisifiedSymbol]) {
2706
- var customFunction = orig[kCustomPromisifiedSymbol];
2707
- if (typeof customFunction !== 'function') {
2708
- throw new TypeError('The [util.promisify.custom] property must be a function');
2709
- }
2710
- Object.defineProperty(customFunction, kCustomPromisifiedSymbol, {
2711
- configurable: true,
2712
- enumerable: false,
2713
- value: customFunction,
2714
- writable: false
2715
- });
2716
- return customFunction;
2717
- }
2718
-
2719
- // Names to create an object from in case the callback receives multiple
2720
- // arguments, e.g. ['stdout', 'stderr'] for child_process.exec.
2721
- var argumentNames = orig[kCustomPromisifyArgsSymbol];
2722
-
2723
- var promisified = function fn() {
2724
- var args = $slice(arguments);
2725
- var self = this; // eslint-disable-line no-invalid-this
2726
- return new Promise(function (resolve, reject) {
2727
- orig.apply(self, $concat(args, function (err) {
2728
- var values = arguments.length > 1 ? $slice(arguments, 1) : [];
2729
- if (err) {
2730
- reject(err);
2731
- } else if (typeof argumentNames !== 'undefined' && values.length > 1) {
2732
- var obj = {};
2733
- $forEach(argumentNames, function (name, index) {
2734
- obj[name] = values[index];
2735
- });
2736
- resolve(obj);
2737
- } else {
2738
- resolve(values[0]);
2739
- }
2740
- }));
2741
- });
2742
- };
2743
-
2744
- promisified.__proto__ = orig.__proto__; // eslint-disable-line no-proto
2745
-
2746
- Object.defineProperty(promisified, kCustomPromisifiedSymbol, {
2747
- configurable: true,
2748
- enumerable: false,
2749
- value: promisified,
2750
- writable: false
2751
- });
2752
- return Object.defineProperties(promisified, object_getownpropertydescriptors(orig));
2753
- };
2754
-
2755
- var custom = kCustomPromisifiedSymbol;
2756
- var customPromisifyArgs = kCustomPromisifyArgsSymbol;
2757
- implementation.custom = custom;
2758
- implementation.customPromisifyArgs = customPromisifyArgs;
2759
-
2760
- var polyfill$1 = function getPolyfill() {
2761
- if (typeof util.promisify === 'function') {
2762
- return util.promisify;
2763
- }
2764
- return implementation;
2765
- };
2766
-
2767
- var shim = function shimUtilPromisify() {
2768
- var polyfill = polyfill$1();
2769
- if (polyfill !== util.promisify) {
2770
- Object.defineProperty(util, 'promisify', {
2771
- configurable: true,
2772
- enumerable: true,
2773
- value: polyfill,
2774
- writable: true
2775
- });
2776
- }
2777
- return polyfill;
2778
- };
2779
-
2780
- var polyfill = polyfill$1();
2781
-
2782
-
2783
- /* eslint-disable no-unused-vars */
2784
- var boundPromisify = function promisify(orig) {
2785
- /* eslint-enable no-unused-vars */
2786
- return polyfill.apply(util, arguments);
2787
- };
2788
- defineProperties_1(boundPromisify, {
2789
- custom: polyfill.custom,
2790
- customPromisifyArgs: polyfill.customPromisifyArgs,
2791
- getPolyfill: polyfill$1,
2792
- implementation: implementation,
2793
- shim: shim
2794
- });
2795
-
2796
- var util_promisify = boundPromisify;
2797
-
2798
- util_promisify.shim();
2799
-
2800
- function connect() {
2801
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2802
-
2803
- if (!config) {
2804
- config = {
2805
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
2806
- user: 'nasp',
2807
- password: 'uRNkF9SkfXQs6AKK',
2808
- database: 'user'
2809
- };
2810
- }
2811
-
2812
- var connection = mysql.createConnection(config);
2813
- return {
2814
- query: function query(sql, args) {
2815
- return util.promisify(connection.query).call(connection, sql, args);
2816
- },
2817
- beginTransaction: function beginTransaction() {
2818
- return util.promisify(connection.beginTransaction).call(connection);
2819
- },
2820
- commit: function commit() {
2821
- return util.promisify(connection.commit).call(connection);
2822
- },
2823
- rollback: function rollback() {
2824
- return util.promisify(connection.rollback).call(connection);
2825
- },
2826
- close: function close() {
2827
- return util.promisify(connection.end).call(connection);
2828
- }
2829
- };
2830
- }
2831
-
2832
- var db = connect;
2833
-
2834
- var _this$1 = undefined;
2835
-
2836
- var config$1 = {
2837
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
2838
- user: 'nasp',
2839
- password: 'uRNkF9SkfXQs6AKK',
2840
- database: 'user'
2841
- };
2842
-
2843
- var findUser$1 = function () {
2844
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(email) {
2845
- var password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2846
- var db$1, query, res, user, hash, passwordsMatch, user_shared, occupation_id;
2847
- return regenerator.wrap(function _callee$(_context) {
2848
- while (1) {
2849
- switch (_context.prev = _context.next) {
2850
- case 0:
2851
- db$1 = null;
2852
- _context.prev = 1;
2853
-
2854
-
2855
- db$1 = db(config$1);
2856
-
2857
- query = '\n select * \n from user \n where trim(lower(email)) = ?\n ';
2858
- _context.next = 6;
2859
- return db$1.query(query, [email.toLowerCase().trim()]);
2860
-
2861
- case 6:
2862
- res = _context.sent;
2863
- user = res.length > 0 ? res[0] : null;
2864
-
2865
- if (user) {
2866
- _context.next = 10;
2867
- break;
2868
- }
2869
-
2870
- throw new Error('Invalid credential provided');
2871
-
2872
- case 10:
2873
- if (!password) {
2874
- _context.next = 15;
2875
- break;
2876
- }
2877
-
2878
- hash = md5(password);
2879
- passwordsMatch = hash === user.password;
2880
-
2881
- if (passwordsMatch) {
2882
- _context.next = 15;
2883
- break;
2884
- }
2885
-
2886
- throw new Error('Password doesn\'t match');
2887
-
2888
- case 15:
2889
-
2890
- query = '\n select * \n from user_shared \n where user_id = ?\n ';
2891
- _context.next = 18;
2892
- return db$1.query(query, [user.id]);
2893
-
2894
- case 18:
2895
- res = _context.sent;
2896
- user_shared = res.length > 0 ? res[0] : null;
2897
-
2898
- user.shared = user_shared;
2899
-
2900
- // occupation
2901
- query = '\n select id \n from occupation \n where name = ?\n ';
2902
- _context.next = 24;
2903
- return db$1.query(query, [user_shared.occupation]);
2904
-
2905
- case 24:
2906
- res = _context.sent;
2907
- occupation_id = res.length > 0 ? res[0].id : '';
2908
-
2909
- user.shared.occupation_id = occupation_id;
2910
-
2911
- _context.next = 29;
2912
- return db$1.close();
2913
-
2914
- case 29:
2915
- return _context.abrupt('return', {
2916
- error: '',
2917
- user: user
2918
- });
2919
-
2920
- case 32:
2921
- _context.prev = 32;
2922
- _context.t0 = _context['catch'](1);
2923
-
2924
- if (!db$1) {
2925
- _context.next = 37;
2926
- break;
2927
- }
2928
-
2929
- _context.next = 37;
2930
- return db$1.close();
2931
-
2932
- case 37:
2933
- return _context.abrupt('return', {
2934
- error: _context.t0.message,
2935
- user: null
2936
- });
2937
-
2938
- case 38:
2939
- case 'end':
2940
- return _context.stop();
2941
- }
2942
- }
2943
- }, _callee, this, [[1, 32]]);
2944
- }));
2945
-
2946
- return function findUser(_x) {
2947
- return _ref.apply(this, arguments);
2948
- };
2949
- }();
2950
-
2951
- var updateUser$1 = function () {
2952
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(data) {
2953
- var db$1, query, res, hash, columns, i, column, occupation_name;
2954
- return regenerator.wrap(function _callee2$(_context2) {
2955
- while (1) {
2956
- switch (_context2.prev = _context2.next) {
2957
- case 0:
2958
- db$1 = null;
2959
- _context2.prev = 1;
2960
-
2961
-
2962
- validateUserData(data);
2963
-
2964
- db$1 = db(config$1);
2965
-
2966
- _context2.next = 6;
2967
- return db$1.beginTransaction();
2968
-
2969
- case 6:
2970
- if (data.user_id) {
2971
- _context2.next = 8;
2972
- break;
2973
- }
2974
-
2975
- throw new Error('Please provide user ID');
2976
-
2977
- case 8:
2978
-
2979
- data.email = data.email.toLowerCase().trim();
2980
-
2981
- // check if new email is taken
2982
- query = '\n select * \n from user \n where lower(trim(email)) = ?\n and id != ?\n ';
2983
- _context2.next = 12;
2984
- return db$1.query(query, [data.email, data.user_id]);
2985
-
2986
- case 12:
2987
- res = _context2.sent;
2988
-
2989
- if (!(res && res.length > 0)) {
2990
- _context2.next = 15;
2991
- break;
2992
- }
2993
-
2994
- throw new Error('Email already taken');
2995
-
2996
- case 15:
2997
- if (!data.password) {
2998
- _context2.next = 23;
2999
- break;
3000
- }
3001
-
3002
- hash = md5(data.password);
3003
-
3004
- query = '\n update user \n set password = ?\n where user_id = ?\n ';
3005
- _context2.next = 20;
3006
- return db$1.query(query, [hash, data.user_id]);
3007
-
3008
- case 20:
3009
- res = _context2.sent;
3010
-
3011
- if (!(!res || res.affectedRows < 1)) {
3012
- _context2.next = 23;
3013
- break;
3014
- }
3015
-
3016
- throw new Error('Failed to update password');
3017
-
3018
- case 23:
3019
-
3020
- query = 'show columns from user_shared';
3021
- _context2.next = 26;
3022
- return db$1.query(query);
3023
-
3024
- case 26:
3025
- columns = _context2.sent;
3026
-
3027
-
3028
- for (i = 0; i < columns.length; i++) {
3029
- column = columns[i].Field;
3030
-
3031
- if (typeof data[column] === 'undefined') {
3032
- data[column] = '';
3033
- }
3034
- }
3035
-
3036
- // user_shared
3037
- 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 ';
3038
-
3039
- _context2.next = 31;
3040
- return getOccupationNameById(db$1, data.occupation);
3041
-
3042
- case 31:
3043
- occupation_name = _context2.sent;
3044
- _context2.next = 34;
3045
- 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]);
3046
-
3047
- case 34:
3048
- res = _context2.sent;
3049
-
3050
- if (!(!res || res.affectedRows < 1)) {
3051
- _context2.next = 37;
3052
- break;
3053
- }
3054
-
3055
- throw new Error('Failed to update user shared information record');
3056
-
3057
- case 37:
3058
- _context2.next = 39;
3059
- return db$1.commit();
3060
-
3061
- case 39:
3062
- _context2.next = 41;
3063
- return db$1.close();
3064
-
3065
- case 41:
3066
-
3067
- db$1 = null;
3068
-
3069
- return _context2.abrupt('return', {
3070
- error: '',
3071
- user: findUser$1(data.email)
3072
- });
3073
-
3074
- case 45:
3075
- _context2.prev = 45;
3076
- _context2.t0 = _context2['catch'](1);
3077
-
3078
-
3079
- console.log('error:', _context2.t0);
3080
-
3081
- if (!db$1) {
3082
- _context2.next = 53;
3083
- break;
3084
- }
3085
-
3086
- _context2.next = 51;
3087
- return db$1.rollback();
3088
-
3089
- case 51:
3090
- _context2.next = 53;
3091
- return db$1.close();
3092
-
3093
- case 53:
3094
- return _context2.abrupt('return', {
3095
- error: _context2.t0.message,
3096
- user: null
3097
- });
3098
-
3099
- case 54:
3100
- case 'end':
3101
- return _context2.stop();
3102
- }
3103
- }
3104
- }, _callee2, this, [[1, 45]]);
3105
- }));
3106
-
3107
- return function updateUser(_x3) {
3108
- return _ref2.apply(this, arguments);
3109
- };
3110
- }();
3111
-
3112
- var validateUserData = function validateUserData(data) {
3113
- var requirePassword = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3114
-
3115
- if (!data.email) {
3116
- throw new Error('Email is required');
3117
- }
3118
-
3119
- if (requirePassword && !data.password) {
3120
- throw new Error('Password is required');
3121
- }
3122
-
3123
- if (data.password && data.password !== data.rpassword) {
3124
- throw new Error('Password does not match');
3125
- }
3126
-
3127
- if (!data.first_name) {
3128
- throw new Error('First name is required');
3129
- }
3130
-
3131
- if (!data.last_name) {
3132
- throw new Error('Last name is required');
3133
- }
3134
-
3135
- if (!data.country) {
3136
- throw new Error('Country is required');
3137
- }
3138
-
3139
- if (data.country === 'United States') {
3140
- if (!data.state) {
3141
- throw new Error('State is required');
3142
- }
3143
-
3144
- if (!data.zip) {
3145
- throw new Error('Zip code is required');
3146
- }
3147
-
3148
- if (!data.phone) {
3149
- throw new Error('Phone is required');
3150
- }
3151
- }
3152
- };
3153
-
3154
- var getOccupationNameById = function () {
3155
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(db, occupation_id) {
3156
- var query, res;
3157
- return regenerator.wrap(function _callee3$(_context3) {
3158
- while (1) {
3159
- switch (_context3.prev = _context3.next) {
3160
- case 0:
3161
- query = '\n select name\n from occupation \n where id = ?\n ';
3162
- _context3.next = 3;
3163
- return db.query(query, [occupation_id]);
3164
-
3165
- case 3:
3166
- res = _context3.sent;
3167
-
3168
- if (!(res && res.length > 0)) {
3169
- _context3.next = 6;
3170
- break;
3171
- }
3172
-
3173
- return _context3.abrupt('return', res[0].name);
3174
-
3175
- case 6:
3176
- throw new Error('Failed to get occupation name by ID: ' + occupation_id);
3177
-
3178
- case 7:
3179
- case 'end':
3180
- return _context3.stop();
3181
- }
3182
- }
3183
- }, _callee3, _this$1);
3184
- }));
3185
-
3186
- return function getOccupationNameById(_x5, _x6) {
3187
- return _ref3.apply(this, arguments);
3188
- };
3189
- }();
3190
-
3191
- var createUser$1 = function () {
3192
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(data) {
3193
- var db$1, query, res, hash, columns, i, column, user_id, occupation_name;
3194
- return regenerator.wrap(function _callee4$(_context4) {
3195
- while (1) {
3196
- switch (_context4.prev = _context4.next) {
3197
- case 0:
3198
- db$1 = null;
3199
- _context4.prev = 1;
3200
-
3201
-
3202
- validateUserData(data, true);
3203
-
3204
- db$1 = db(config$1);
3205
-
3206
- _context4.next = 6;
3207
- return db$1.beginTransaction();
3208
-
3209
- case 6:
3210
-
3211
- data.email = data.email.toLowerCase().trim();
3212
-
3213
- // check if user exists
3214
- query = '\n select * \n from user \n where lower(trim(email)) = ?\n ';
3215
- _context4.next = 10;
3216
- return db$1.query(query, [data.email]);
3217
-
3218
- case 10:
3219
- res = _context4.sent;
3220
-
3221
- if (!(res && res.length > 0)) {
3222
- _context4.next = 13;
3223
- break;
3224
- }
3225
-
3226
- throw new Error('User already exists');
3227
-
3228
- case 13:
3229
- hash = md5(data.password);
3230
-
3231
- // basic user info
3232
-
3233
- query = '\n insert into user ( \n email, password, created\n ) values (\n ?, ?, current_timestamp\n )\n ';
3234
- _context4.next = 17;
3235
- return db$1.query(query, [data.email, hash]);
3236
-
3237
- case 17:
3238
- res = _context4.sent;
3239
-
3240
- if (!(!res || res.insertId < 1)) {
3241
- _context4.next = 20;
3242
- break;
3243
- }
3244
-
3245
- throw new Error('Failed to create user');
3246
-
3247
- case 20:
3248
-
3249
- query = 'show columns from user_shared';
3250
- _context4.next = 23;
3251
- return db$1.query(query);
3252
-
3253
- case 23:
3254
- columns = _context4.sent;
3255
-
3256
-
3257
- for (i = 0; i < columns.length; i++) {
3258
- column = columns[i].Field;
3259
-
3260
- if (typeof data[column] === 'undefined') {
3261
- data[column] = '';
3262
- }
3263
- }
3264
-
3265
- user_id = res.insertId;
3266
-
3267
- // user_shared
3268
-
3269
- 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 ';
3270
-
3271
- _context4.next = 29;
3272
- return getOccupationNameById(db$1, data.occupation);
3273
-
3274
- case 29:
3275
- occupation_name = _context4.sent;
3276
- _context4.next = 32;
3277
- 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]);
3278
-
3279
- case 32:
3280
- res = _context4.sent;
3281
-
3282
- if (!(!res || res.affectedRows < 1)) {
3283
- _context4.next = 35;
3284
- break;
3285
- }
3286
-
3287
- throw new Error('Failed to create user shared information record');
3288
-
3289
- case 35:
3290
- _context4.next = 37;
3291
- return db$1.commit();
3292
-
3293
- case 37:
3294
- _context4.next = 39;
3295
- return db$1.close();
3296
-
3297
- case 39:
3298
- return _context4.abrupt('return', {
3299
- error: '',
3300
- user: findUser$1(data.email)
3301
- });
3302
-
3303
- case 42:
3304
- _context4.prev = 42;
3305
- _context4.t0 = _context4['catch'](1);
3306
-
3307
- if (!db$1) {
3308
- _context4.next = 49;
3309
- break;
3310
- }
3311
-
3312
- _context4.next = 47;
3313
- return db$1.rollback();
3314
-
3315
- case 47:
3316
- _context4.next = 49;
3317
- return db$1.close();
3318
-
3319
- case 49:
3320
- return _context4.abrupt('return', {
3321
- error: _context4.t0.message,
3322
- user: null
3323
- });
3324
-
3325
- case 50:
3326
- case 'end':
3327
- return _context4.stop();
3328
- }
3329
- }
3330
- }, _callee4, this, [[1, 42]]);
3331
- }));
3332
-
3333
- return function createUser(_x7) {
3334
- return _ref4.apply(this, arguments);
3335
- };
3336
- }();
3337
-
3338
- var createUser = function () {
3339
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(data) {
3340
- var res;
3341
- return regenerator.wrap(function _callee$(_context) {
3342
- while (1) {
3343
- switch (_context.prev = _context.next) {
3344
- case 0:
3345
- _context.next = 2;
3346
- return createUser$1(data);
3347
-
3348
- case 2:
3349
- res = _context.sent;
3350
-
3351
- if (!res.error) {
3352
- _context.next = 5;
3353
- break;
3354
- }
3355
-
3356
- throw new Error(res.error);
3357
-
3358
- case 5:
3359
- return _context.abrupt('return', res.user);
3360
-
3361
- case 6:
3362
- case 'end':
3363
- return _context.stop();
3364
- }
3365
- }
3366
- }, _callee, this);
3367
- }));
3368
-
3369
- return function createUser(_x) {
3370
- return _ref.apply(this, arguments);
3371
- };
3372
- }();
3373
-
3374
- var updateUser = function () {
3375
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(data) {
3376
- var res;
3377
- return regenerator.wrap(function _callee2$(_context2) {
3378
- while (1) {
3379
- switch (_context2.prev = _context2.next) {
3380
- case 0:
3381
- _context2.next = 2;
3382
- return updateUser$1(data);
3383
-
3384
- case 2:
3385
- res = _context2.sent;
3386
-
3387
- if (!res.error) {
3388
- _context2.next = 5;
3389
- break;
3390
- }
3391
-
3392
- throw new Error(res.error);
3393
-
3394
- case 5:
3395
- return _context2.abrupt('return', res.user);
3396
-
3397
- case 6:
3398
- case 'end':
3399
- return _context2.stop();
3400
- }
3401
- }
3402
- }, _callee2, this);
3403
- }));
3404
-
3405
- return function updateUser(_x2) {
3406
- return _ref2.apply(this, arguments);
3407
- };
3408
- }();
3409
-
3410
- var findUser = function () {
3411
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(_ref4) {
3412
- var email = _ref4.email,
3413
- password = _ref4.password;
3414
- var res;
3415
- return regenerator.wrap(function _callee3$(_context3) {
3416
- while (1) {
3417
- switch (_context3.prev = _context3.next) {
3418
- case 0:
3419
- _context3.next = 2;
3420
- return findUser$1(email, password);
3421
-
3422
- case 2:
3423
- res = _context3.sent;
3424
-
3425
- if (!res.error) {
3426
- _context3.next = 5;
3427
- break;
3428
- }
3429
-
3430
- throw new Error(res.error);
3431
-
3432
- case 5:
3433
- return _context3.abrupt('return', res.user);
3434
-
3435
- case 6:
3436
- case 'end':
3437
- return _context3.stop();
3438
- }
3439
- }
3440
- }, _callee3, this);
3441
- }));
3442
-
3443
- return function findUser(_x3) {
3444
- return _ref3.apply(this, arguments);
3445
- };
3446
- }();
3447
-
3448
- var user = /*#__PURE__*/Object.freeze({
3449
- __proto__: null,
3450
- createUser: createUser,
3451
- updateUser: updateUser,
3452
- findUser: findUser
3453
- });
3454
-
3455
- var localStrategy = new Local.Strategy({
3456
- usernameField: 'email',
3457
- passwordField: 'password'
3458
- }, function (email, password, done) {
3459
-
3460
- findUser({ email: email, password: password }).then(function (user) {
3461
- done(null, user);
3462
- }).catch(function (error) {
3463
- done(error);
3464
- });
3465
- });
3466
-
3467
- var passportLocal = /*#__PURE__*/Object.freeze({
3468
- __proto__: null,
3469
- localStrategy: localStrategy
3470
- });
3471
-
3472
- var _this = undefined;
3473
-
3474
- var config = {
3475
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
3476
- user: 'nasp',
3477
- password: 'uRNkF9SkfXQs6AKK',
3478
- database: 'user'
3479
- };
3480
-
3481
- var getOccupation = function () {
3482
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(type) {
3483
- var db$1, query, result;
3484
- return regenerator.wrap(function _callee$(_context) {
3485
- while (1) {
3486
- switch (_context.prev = _context.next) {
3487
- case 0:
3488
- db$1 = db(config);
3489
- query = '\n select name as label, id as value\n from occupation\n where type = ?\n ';
3490
- _context.next = 4;
3491
- return db$1.query(query, [type]);
3492
-
3493
- case 4:
3494
- result = _context.sent;
3495
- _context.next = 7;
3496
- return db$1.close();
3497
-
3498
- case 7:
3499
- return _context.abrupt('return', result);
3500
-
3501
- case 8:
3502
- case 'end':
3503
- return _context.stop();
3504
- }
3505
- }
3506
- }, _callee, _this);
3507
- }));
3508
-
3509
- return function getOccupation(_x) {
3510
- return _ref.apply(this, arguments);
3511
- };
3512
- }();
3513
-
3514
- var getFieldsAndOptions = function () {
3515
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(occupation) {
3516
- var db$1, query, result, i, field, optionQuery, options;
3517
- return regenerator.wrap(function _callee2$(_context2) {
3518
- while (1) {
3519
- switch (_context2.prev = _context2.next) {
3520
- case 0:
3521
- db$1 = db(config);
3522
- query = '\n select * \n from field\n where occupation_id = ?\n order by sorting\n ';
3523
- _context2.next = 4;
3524
- return db$1.query(query, [occupation]);
3525
-
3526
- case 4:
3527
- result = _context2.sent;
3528
- i = 0;
3529
-
3530
- case 6:
3531
- if (!(i < result.length)) {
3532
- _context2.next = 17;
3533
- break;
3534
- }
3535
-
3536
- field = result[i];
3537
-
3538
- if (!(field.type === 'select')) {
3539
- _context2.next = 14;
3540
- break;
3541
- }
3542
-
3543
- optionQuery = '\n select * \n from options\n where list_id = ?\n order by sorting\n ';
3544
- _context2.next = 12;
3545
- return db$1.query(optionQuery, [field.list_id]);
3546
-
3547
- case 12:
3548
- options = _context2.sent;
3549
-
3550
- field.options = options ? options : [];
3551
-
3552
- case 14:
3553
- i++;
3554
- _context2.next = 6;
3555
- break;
3556
-
3557
- case 17:
3558
- _context2.next = 19;
3559
- return db$1.close();
3560
-
3561
- case 19:
3562
- return _context2.abrupt('return', result);
3563
-
3564
- case 20:
3565
- case 'end':
3566
- return _context2.stop();
3567
- }
3568
- }
3569
- }, _callee2, _this);
3570
- }));
3571
-
3572
- return function getFieldsAndOptions(_x2) {
3573
- return _ref2.apply(this, arguments);
3574
- };
3575
- }();
3576
-
3577
- var ProcessData = (function () {
3578
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(req, res) {
3579
- var action, data, type, occupation;
3580
- return regenerator.wrap(function _callee3$(_context3) {
3581
- while (1) {
3582
- switch (_context3.prev = _context3.next) {
3583
- case 0:
3584
- _context3.prev = 0;
3585
- action = req.body.action;
3586
- data = null;
3587
- _context3.t0 = action;
3588
- _context3.next = _context3.t0 === 'get-occupation' ? 6 : _context3.t0 === 'get-fields' ? 11 : 16;
3589
- break;
3590
-
3591
- case 6:
3592
- type = req.body.type;
3593
- _context3.next = 9;
3594
- return getOccupation(type);
3595
-
3596
- case 9:
3597
- data = _context3.sent;
3598
- return _context3.abrupt('break', 17);
3599
-
3600
- case 11:
3601
- occupation = req.body.occupation;
3602
- _context3.next = 14;
3603
- return getFieldsAndOptions(occupation);
3604
-
3605
- case 14:
3606
- data = _context3.sent;
3607
- return _context3.abrupt('break', 17);
3608
-
3609
- case 16:
3610
- throw new Error('Invalid action: ' + action);
3611
-
3612
- case 17:
3613
- return _context3.abrupt('return', res.json({
3614
- error: '',
3615
- data: data
3616
- }));
3617
-
3618
- case 20:
3619
- _context3.prev = 20;
3620
- _context3.t1 = _context3['catch'](0);
3621
- return _context3.abrupt('return', res.json({
3622
- error: _context3.t1.message,
3623
- data: null
3624
- }));
3625
-
3626
- case 23:
3627
- case 'end':
3628
- return _context3.stop();
3629
- }
3630
- }
3631
- }, _callee3, this, [[0, 20]]);
3632
- }));
3633
-
3634
- return function (_x3, _x4) {
3635
- return _ref3.apply(this, arguments);
3636
- };
3637
- })();
3638
-
3639
- var LoginForm_1 = LoginForm;
3640
- var SignupForm_1 = SignupForm$1;
3641
- var ProfileForm_1 = SignupForm;
3642
- var AuthCookies_1 = authCookies;
3643
- var AuthHooks_1 = hooks;
3644
- var Iron_1 = iron;
3645
- var PassportLocal_1 = passportLocal;
3646
- var User_1 = user;
3647
- var ProcessData_1 = ProcessData;
3648
-
3649
- var auth = {
3650
- LoginForm: LoginForm_1,
3651
- SignupForm: SignupForm_1,
3652
- ProfileForm: ProfileForm_1,
3653
- AuthCookies: AuthCookies_1,
3654
- AuthHooks: AuthHooks_1,
3655
- Iron: Iron_1,
3656
- PassportLocal: PassportLocal_1,
3657
- User: User_1,
3658
- ProcessData: ProcessData_1
3659
- };
3660
-
3661
- export { AuthCookies_1 as AuthCookies, AuthHooks_1 as AuthHooks, Iron_1 as Iron, LoginForm_1 as LoginForm, PassportLocal_1 as PassportLocal, ProcessData_1 as ProcessData, ProfileForm_1 as ProfileForm, SignupForm_1 as SignupForm, User_1 as User, auth as default };