aidbox-react 1.5.0 → 1.7.0

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 (76) hide show
  1. package/dist/cjs/components/RenderRemoteData/index.d.ts +15 -0
  2. package/dist/cjs/hooks/bus.d.ts +17 -0
  3. package/dist/cjs/hooks/crud.d.ts +7 -0
  4. package/dist/cjs/hooks/pager.d.ts +13 -0
  5. package/dist/cjs/hooks/service.d.ts +8 -0
  6. package/dist/cjs/hooks/shared-state.d.ts +9 -0
  7. package/dist/cjs/index.d.ts +16 -0
  8. package/dist/cjs/index.js +3317 -0
  9. package/dist/cjs/libs/remoteData.d.ts +35 -0
  10. package/dist/cjs/services/fhir.d.ts +44 -0
  11. package/dist/cjs/services/instance.d.ts +6 -0
  12. package/dist/cjs/services/search.d.ts +4 -0
  13. package/dist/cjs/services/service.d.ts +33 -0
  14. package/dist/cjs/services/token.d.ts +4 -0
  15. package/dist/cjs/utils/date.d.ts +14 -0
  16. package/dist/cjs/utils/error.d.ts +30 -0
  17. package/dist/cjs/utils/tests.d.ts +10 -0
  18. package/dist/cjs/utils/uuid.d.ts +1 -0
  19. package/dist/esm/components/RenderRemoteData/index.d.ts +15 -0
  20. package/dist/esm/hooks/bus.d.ts +17 -0
  21. package/dist/esm/hooks/crud.d.ts +7 -0
  22. package/dist/esm/hooks/pager.d.ts +13 -0
  23. package/dist/esm/hooks/service.d.ts +8 -0
  24. package/dist/esm/hooks/shared-state.d.ts +9 -0
  25. package/dist/esm/index.d.ts +16 -0
  26. package/dist/esm/index.js +3226 -0
  27. package/dist/esm/libs/remoteData.d.ts +35 -0
  28. package/dist/esm/services/fhir.d.ts +44 -0
  29. package/dist/esm/services/instance.d.ts +6 -0
  30. package/dist/esm/services/search.d.ts +4 -0
  31. package/dist/esm/services/service.d.ts +33 -0
  32. package/dist/esm/services/token.d.ts +4 -0
  33. package/dist/esm/utils/date.d.ts +14 -0
  34. package/dist/esm/utils/error.d.ts +30 -0
  35. package/dist/esm/utils/tests.d.ts +10 -0
  36. package/dist/esm/utils/uuid.d.ts +1 -0
  37. package/dist/index.d.ts +248 -0
  38. package/lib/components/RenderRemoteData/index.d.ts +1 -1
  39. package/lib/components/RenderRemoteData/index.js +5 -5
  40. package/lib/components/RenderRemoteData/index.js.map +1 -1
  41. package/lib/hooks/bus.d.ts +5 -5
  42. package/lib/hooks/bus.js +1 -1
  43. package/lib/hooks/bus.js.map +1 -1
  44. package/lib/hooks/crud.js +14 -14
  45. package/lib/hooks/crud.js.map +1 -1
  46. package/lib/hooks/pager.d.ts +4 -0
  47. package/lib/hooks/pager.js +21 -12
  48. package/lib/hooks/pager.js.map +1 -1
  49. package/lib/hooks/service.js +15 -15
  50. package/lib/hooks/service.js.map +1 -1
  51. package/lib/hooks/shared-state.js +3 -3
  52. package/lib/hooks/shared-state.js.map +1 -1
  53. package/lib/index.d.ts +16 -0
  54. package/lib/index.js +20 -0
  55. package/lib/index.js.map +1 -0
  56. package/lib/libs/remoteData.d.ts +2 -2
  57. package/lib/services/fhir.d.ts +3 -3
  58. package/lib/services/fhir.js +38 -38
  59. package/lib/services/fhir.js.map +1 -1
  60. package/lib/services/instance.js +1 -1
  61. package/lib/services/instance.js.map +1 -1
  62. package/lib/services/search.d.ts +1 -1
  63. package/lib/services/service.d.ts +4 -4
  64. package/lib/services/service.js +13 -13
  65. package/lib/services/service.js.map +1 -1
  66. package/lib/utils/date.js +9 -9
  67. package/lib/utils/date.js.map +1 -1
  68. package/lib/utils/error.js +1 -1
  69. package/lib/utils/error.js.map +1 -1
  70. package/lib/utils/tests.d.ts +1 -1
  71. package/lib/utils/tests.js +7 -7
  72. package/lib/utils/tests.js.map +1 -1
  73. package/package.json +18 -7
  74. package/src/hooks/pager.ts +37 -12
  75. package/src/index.ts +20 -0
  76. package/CHANGELOG.md +0 -28
@@ -0,0 +1,3317 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+ var moment = require('moment');
5
+
6
+ var Status;
7
+ (function (Status) {
8
+ Status["Success"] = "Success";
9
+ Status["Failure"] = "Failure";
10
+ Status["Loading"] = "Loading";
11
+ Status["NotAsked"] = "NotAsked";
12
+ })(Status || (Status = {}));
13
+ const notAsked = {
14
+ status: Status.NotAsked,
15
+ };
16
+ const loading = {
17
+ status: Status.Loading,
18
+ };
19
+ function success(data) {
20
+ return {
21
+ status: Status.Success,
22
+ data,
23
+ };
24
+ }
25
+ function failure(error) {
26
+ return {
27
+ status: Status.Failure,
28
+ error,
29
+ };
30
+ }
31
+ function isNotAsked(remoteData) {
32
+ return remoteData.status === Status.NotAsked;
33
+ }
34
+ function isLoading(remoteData) {
35
+ return remoteData.status === Status.Loading;
36
+ }
37
+ function isSuccess(remoteData) {
38
+ return remoteData.status === Status.Success;
39
+ }
40
+ function isSuccessAll(responses) {
41
+ return responses.every(isSuccess);
42
+ }
43
+ function isFailure(remoteData) {
44
+ return remoteData.status === Status.Failure;
45
+ }
46
+ function isFailureAny(responses) {
47
+ return responses.some(isFailure);
48
+ }
49
+ function isLoadingAny(responses) {
50
+ return responses.some(isLoading);
51
+ }
52
+ function isNotAskedAny(responses) {
53
+ return responses.some(isNotAsked);
54
+ }
55
+
56
+ const flatten = (list) => list.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
57
+ const encodeEntry = (key, value) => encodeURIComponent(key) + '=' + encodeURIComponent(value);
58
+ const packEntry = (accumulator, [key, value]) => {
59
+ if (typeof value === 'undefined') {
60
+ return accumulator;
61
+ }
62
+ if (Array.isArray(value)) {
63
+ value.forEach((value) => {
64
+ accumulator.push(encodeEntry(key, Array.isArray(value) ? flatten(value) : value));
65
+ });
66
+ }
67
+ else {
68
+ accumulator.push(encodeEntry(key, value));
69
+ }
70
+ return accumulator;
71
+ };
72
+ function buildQueryParams(params) {
73
+ return Object.entries(params)
74
+ .reduce(packEntry, [])
75
+ .join('&');
76
+ }
77
+ const axiosInstance = axios.create({
78
+ paramsSerializer: buildQueryParams,
79
+ headers: {
80
+ 'Content-Type': 'application/json',
81
+ 'Cache-Control': 'no-cache',
82
+ },
83
+ });
84
+ function setInstanceBaseURL(baseURL) {
85
+ axiosInstance.defaults.baseURL = baseURL;
86
+ }
87
+ function setInstanceToken(token) {
88
+ axiosInstance.defaults.headers.Authorization = `Bearer ${token.access_token}`;
89
+ }
90
+ function resetInstanceToken() {
91
+ delete axiosInstance.defaults.headers.Authorization;
92
+ }
93
+
94
+ /******************************************************************************
95
+ Copyright (c) Microsoft Corporation.
96
+
97
+ Permission to use, copy, modify, and/or distribute this software for any
98
+ purpose with or without fee is hereby granted.
99
+
100
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
101
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
102
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
103
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
104
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
105
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
106
+ PERFORMANCE OF THIS SOFTWARE.
107
+ ***************************************************************************** */
108
+
109
+ function __awaiter(thisArg, _arguments, P, generator) {
110
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
111
+ return new (P || (P = Promise))(function (resolve, reject) {
112
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
113
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
114
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
115
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
116
+ });
117
+ }
118
+
119
+ function service(config) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ try {
122
+ const response = yield axiosInstance(config);
123
+ return success(response.data);
124
+ }
125
+ catch (err) {
126
+ return failure(err.response ? err.response.data : err.message);
127
+ }
128
+ });
129
+ }
130
+ function applyDataTransformer(servicePromise, transformer) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ const response = yield servicePromise;
133
+ return mapSuccess(response, transformer);
134
+ });
135
+ }
136
+ function applyErrorTransformer(servicePromise, transformer) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ const response = yield servicePromise;
139
+ return mapFailure(response, transformer);
140
+ });
141
+ }
142
+ function mapSuccess(remoteData, transformer) {
143
+ if (isSuccess(remoteData)) {
144
+ return success(transformer(remoteData.data));
145
+ }
146
+ return remoteData;
147
+ }
148
+ function mapFailure(remoteData, transformer) {
149
+ if (isFailure(remoteData)) {
150
+ return failure(transformer(remoteData.error));
151
+ }
152
+ return remoteData;
153
+ }
154
+ function createKeysMapTransformer(keys) {
155
+ return (data) => keys.reduce((transformed, key, index) => {
156
+ transformed[key] = data[index];
157
+ return transformed;
158
+ }, {});
159
+ }
160
+ function sequenceArray(remoteDataArray) {
161
+ if (isSuccessAll(remoteDataArray)) {
162
+ return success(remoteDataArray.map((remoteDataResult) => remoteDataResult.data));
163
+ }
164
+ if (isFailureAny(remoteDataArray)) {
165
+ return failure(remoteDataArray.reduce((accumulator, remoteDataResult) => {
166
+ if (isFailure(remoteDataResult)) {
167
+ accumulator.push(remoteDataResult.error);
168
+ }
169
+ return accumulator;
170
+ }, []));
171
+ }
172
+ if (isLoadingAny(remoteDataArray)) {
173
+ return loading;
174
+ }
175
+ return notAsked;
176
+ }
177
+ function sequenceMap(remoteDataMap) {
178
+ const keys = Object.keys(remoteDataMap);
179
+ const remoteDataArray = Object.values(remoteDataMap);
180
+ return mapSuccess(sequenceArray(remoteDataArray), createKeysMapTransformer(keys));
181
+ }
182
+ function resolveArray(promiseArray) {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ const remoteDataResults = (yield Promise.all(promiseArray));
185
+ return sequenceArray(remoteDataResults);
186
+ });
187
+ }
188
+ function resolveMap(promiseMap) {
189
+ return __awaiter(this, void 0, void 0, function* () {
190
+ const keys = Object.keys(promiseMap);
191
+ const remoteDataResults = (yield Promise.all(Object.values(promiseMap)));
192
+ const result = mapSuccess(sequenceArray(remoteDataResults), createKeysMapTransformer(keys));
193
+ return Promise.resolve(result);
194
+ });
195
+ }
196
+ function resolveServiceMap(promiseMap) {
197
+ return __awaiter(this, void 0, void 0, function* () {
198
+ return resolveMap(promiseMap);
199
+ });
200
+ }
201
+
202
+ const inactiveMapping = {
203
+ DocumentReference: {
204
+ searchField: 'status',
205
+ statusField: 'status',
206
+ value: 'entered-in-error',
207
+ },
208
+ Observation: {
209
+ searchField: 'status',
210
+ statusField: 'status',
211
+ value: 'entered-in-error',
212
+ },
213
+ Location: {
214
+ searchField: 'status',
215
+ statusField: 'status',
216
+ value: 'inactive',
217
+ },
218
+ Schedule: {
219
+ searchField: 'active',
220
+ statusField: 'active',
221
+ value: false,
222
+ },
223
+ Slot: {
224
+ searchField: 'status',
225
+ statusField: 'status',
226
+ value: 'entered-in-error',
227
+ },
228
+ Practitioner: {
229
+ searchField: 'active',
230
+ statusField: 'active',
231
+ value: false,
232
+ },
233
+ Patient: {
234
+ searchField: 'active',
235
+ statusField: 'active',
236
+ value: false,
237
+ },
238
+ User: {
239
+ searchField: 'active',
240
+ statusField: 'active',
241
+ value: false,
242
+ },
243
+ Note: {
244
+ searchField: 'status',
245
+ statusField: 'status',
246
+ value: 'entered-in-error',
247
+ },
248
+ EpisodeOfCare: {
249
+ searchField: 'status',
250
+ statusField: 'status',
251
+ value: 'entered-in-error',
252
+ },
253
+ };
254
+ function isObject$1(value) {
255
+ return typeof value === 'object' && value !== null;
256
+ }
257
+ function getInactiveSearchParam(resourceType) {
258
+ const item = inactiveMapping[resourceType];
259
+ if (item) {
260
+ return {
261
+ [`${item.searchField}:not`]: [item.value],
262
+ };
263
+ }
264
+ return {};
265
+ }
266
+ function createFHIRResource(resource, searchParams) {
267
+ return __awaiter(this, void 0, void 0, function* () {
268
+ return service(create(resource, searchParams));
269
+ });
270
+ }
271
+ function create(resource, searchParams) {
272
+ return {
273
+ method: 'POST',
274
+ url: `/${resource.resourceType}`,
275
+ params: searchParams,
276
+ data: resource,
277
+ };
278
+ }
279
+ function updateFHIRResource(resource, searchParams) {
280
+ return __awaiter(this, void 0, void 0, function* () {
281
+ return service(update(resource, searchParams));
282
+ });
283
+ }
284
+ function update(resource, searchParams) {
285
+ if (searchParams) {
286
+ return {
287
+ method: 'PUT',
288
+ url: `/${resource.resourceType}`,
289
+ data: resource,
290
+ params: searchParams,
291
+ };
292
+ }
293
+ if (resource.id) {
294
+ const versionId = resource.meta && resource.meta.versionId;
295
+ return Object.assign({ method: 'PUT', url: `/${resource.resourceType}/${resource.id}`, data: resource }, (versionId ? { headers: { 'If-Match': versionId } } : {}));
296
+ }
297
+ throw new Error('Resourse id and search parameters are not specified');
298
+ }
299
+ function getFHIRResource(reference) {
300
+ return __awaiter(this, void 0, void 0, function* () {
301
+ return service(get(reference));
302
+ });
303
+ }
304
+ function get(reference) {
305
+ return {
306
+ method: 'GET',
307
+ url: `/${reference.resourceType}/${reference.id}`,
308
+ };
309
+ }
310
+ function getFHIRResources(resourceType, searchParams, extraPath) {
311
+ return __awaiter(this, void 0, void 0, function* () {
312
+ return service(list(resourceType, searchParams, extraPath));
313
+ });
314
+ }
315
+ function getAllFHIRResources(resourceType, params, extraPath) {
316
+ var _a;
317
+ return __awaiter(this, void 0, void 0, function* () {
318
+ const resultBundleResponse = yield getFHIRResources(resourceType, params, extraPath);
319
+ if (isFailure(resultBundleResponse)) {
320
+ return resultBundleResponse;
321
+ }
322
+ let resultBundle = resultBundleResponse.data;
323
+ while (true) {
324
+ let nextLink = (_a = resultBundle.link) === null || _a === void 0 ? void 0 : _a.find((link) => {
325
+ return link.relation === 'next';
326
+ });
327
+ if (!nextLink) {
328
+ break;
329
+ }
330
+ const response = yield service({
331
+ method: 'GET',
332
+ url: nextLink.url,
333
+ });
334
+ if (isFailure(response)) {
335
+ return response;
336
+ }
337
+ resultBundle = Object.assign(Object.assign({}, response.data), { entry: [...resultBundle.entry, ...response.data.entry] });
338
+ }
339
+ return success(resultBundle);
340
+ });
341
+ }
342
+ function list(resourceType, searchParams, extraPath) {
343
+ return {
344
+ method: 'GET',
345
+ url: extraPath ? `/${resourceType}/${extraPath}` : `/${resourceType}`,
346
+ params: Object.assign(Object.assign({}, searchParams), getInactiveSearchParam(resourceType)),
347
+ };
348
+ }
349
+ function findFHIRResource(resourceType, params, extraPath) {
350
+ return __awaiter(this, void 0, void 0, function* () {
351
+ const response = yield getFHIRResources(resourceType, params, extraPath);
352
+ if (isFailure(response)) {
353
+ return response;
354
+ }
355
+ const resources = extractBundleResources(response.data)[resourceType];
356
+ if (resources.length === 1) {
357
+ return success(resources[0]);
358
+ }
359
+ else if (resources.length === 0) {
360
+ return failure({ error_description: 'No resources found', error: 'no_resources_found' });
361
+ }
362
+ else {
363
+ return failure({
364
+ error_description: 'Too many resources found',
365
+ error: 'too_many_resources_found',
366
+ });
367
+ }
368
+ });
369
+ }
370
+ function saveFHIRResource(resource) {
371
+ return __awaiter(this, void 0, void 0, function* () {
372
+ return service(save(resource));
373
+ });
374
+ }
375
+ function save(resource) {
376
+ const versionId = resource.meta && resource.meta.versionId;
377
+ return Object.assign({ method: resource.id ? 'PUT' : 'POST', data: resource, url: `/${resource.resourceType}${resource.id ? '/' + resource.id : ''}` }, (resource.id && versionId ? { headers: { 'If-Match': versionId } } : {}));
378
+ }
379
+ function saveFHIRResources(resources, bundleType) {
380
+ return __awaiter(this, void 0, void 0, function* () {
381
+ return service({
382
+ method: 'POST',
383
+ url: '/',
384
+ data: {
385
+ type: bundleType,
386
+ entry: resources.map((resource) => {
387
+ const versionId = resource.meta && resource.meta.versionId;
388
+ return {
389
+ resource,
390
+ request: Object.assign({ method: resource.id ? 'PUT' : 'POST', url: `/${resource.resourceType}${resource.id ? '/' + resource.id : ''}` }, (resource.id && versionId ? { ifMatch: versionId } : {})),
391
+ };
392
+ }),
393
+ },
394
+ });
395
+ });
396
+ }
397
+ function patchFHIRResource(resource, searchParams) {
398
+ return __awaiter(this, void 0, void 0, function* () {
399
+ return service(patch(resource, searchParams));
400
+ });
401
+ }
402
+ function patch(resource, searchParams) {
403
+ if (searchParams) {
404
+ return {
405
+ method: 'PATCH',
406
+ url: `/${resource.resourceType}`,
407
+ data: resource,
408
+ params: searchParams,
409
+ };
410
+ }
411
+ if (resource.id) {
412
+ return {
413
+ method: 'PATCH',
414
+ url: `/${resource.resourceType}/${resource.id}`,
415
+ data: resource,
416
+ };
417
+ }
418
+ throw new Error('Resourse id and search parameters are not specified');
419
+ }
420
+ function deleteFHIRResource(resource) {
421
+ return __awaiter(this, void 0, void 0, function* () {
422
+ return service(markAsDeleted(resource));
423
+ });
424
+ }
425
+ function markAsDeleted(resource) {
426
+ const inactiveMappingItem = inactiveMapping[resource.resourceType];
427
+ if (!inactiveMappingItem) {
428
+ throw new Error(`Specify inactiveMapping for ${resource.resourceType} to mark item deleted`);
429
+ }
430
+ return {
431
+ method: 'PATCH',
432
+ url: `/${resource.resourceType}/${resource.id}`,
433
+ data: {
434
+ [inactiveMappingItem.statusField]: inactiveMappingItem.value,
435
+ },
436
+ };
437
+ }
438
+ function forceDeleteFHIRResource(resource) {
439
+ return __awaiter(this, void 0, void 0, function* () {
440
+ return service(forceDelete(resource.resourceType, resource.id));
441
+ });
442
+ }
443
+ function forceDelete(resourceType, idOrSearchParams) {
444
+ if (isObject$1(idOrSearchParams)) {
445
+ return {
446
+ method: 'DELETE',
447
+ url: `/${resourceType}`,
448
+ params: idOrSearchParams,
449
+ };
450
+ }
451
+ return {
452
+ method: 'DELETE',
453
+ url: `/${resourceType}/${idOrSearchParams}`,
454
+ };
455
+ }
456
+ function getReference(resource, display) {
457
+ return Object.assign({ resourceType: resource.resourceType, id: resource.id }, (display ? { display } : {}));
458
+ }
459
+ function makeReference(resourceType, id, display) {
460
+ return {
461
+ resourceType,
462
+ id,
463
+ display,
464
+ };
465
+ }
466
+ function isReference(resource) {
467
+ return !Object.keys(resource).filter((attribute) => ['id', 'resourceType', '_id', 'resource', 'display', 'identifier', 'uri', 'localRef', 'extension'].indexOf(attribute) === -1).length;
468
+ }
469
+ function extractBundleResources(bundle) {
470
+ const entriesByResourceType = {};
471
+ const entries = bundle.entry || [];
472
+ entries.forEach(function (entry) {
473
+ const type = entry.resource.resourceType;
474
+ if (!entriesByResourceType[type]) {
475
+ entriesByResourceType[type] = [];
476
+ }
477
+ entriesByResourceType[type].push(entry.resource);
478
+ });
479
+ return new Proxy(entriesByResourceType, {
480
+ get: (obj, prop) => (obj.hasOwnProperty(prop) ? obj[prop] : []),
481
+ });
482
+ }
483
+ function getIncludedResource(
484
+ // TODO: improve type for includedResources: must contain T
485
+ resources, reference) {
486
+ const typeResources = resources[reference.resourceType];
487
+ if (!typeResources) {
488
+ return undefined;
489
+ }
490
+ const index = typeResources.findIndex((resource) => resource.id === reference.id);
491
+ return typeResources[index];
492
+ }
493
+ function getIncludedResources(
494
+ // TODO: improve type for includedResources: must contain T
495
+ resources, resourceType) {
496
+ return (resources[resourceType] || []);
497
+ }
498
+ function getMainResources(bundle, resourceType) {
499
+ if (!bundle.entry) {
500
+ return [];
501
+ }
502
+ return bundle.entry
503
+ .filter((entry) => { var _a; return ((_a = entry.resource) === null || _a === void 0 ? void 0 : _a.resourceType) === resourceType; })
504
+ .map((entry) => entry.resource);
505
+ }
506
+ function getConcepts(valueSetId, params) {
507
+ return service({
508
+ method: 'GET',
509
+ url: `/ValueSet/${valueSetId}/$expand`,
510
+ params: Object.assign({}, params),
511
+ });
512
+ }
513
+ function applyFHIRService(request) {
514
+ return __awaiter(this, void 0, void 0, function* () {
515
+ return service(request);
516
+ });
517
+ }
518
+ const toCamelCase = (str) => {
519
+ const withFirstLowerLetter = str.charAt(0).toLowerCase() + str.slice(1);
520
+ return withFirstLowerLetter.replace(/-/gi, '');
521
+ };
522
+ function transformToBundleEntry(config) {
523
+ const { method, url, data, params, headers = [] } = config;
524
+ if (!method || !url) {
525
+ return null;
526
+ }
527
+ const request = {
528
+ method,
529
+ url: isObject$1(params) ? url + '?' + buildQueryParams(params) : url,
530
+ };
531
+ ['If-Modified-Since', 'If-Match', 'If-None-Match', 'If-None-Exist'].forEach((header) => {
532
+ if (headers[header]) {
533
+ request[toCamelCase(header)] = isObject$1(headers[header])
534
+ ? buildQueryParams(headers[header])
535
+ : headers[header];
536
+ }
537
+ });
538
+ return Object.assign(Object.assign({}, (data ? { resource: data } : {})), { request });
539
+ }
540
+ function applyFHIRServices(requests, type = 'transaction') {
541
+ return __awaiter(this, void 0, void 0, function* () {
542
+ return service({
543
+ method: 'POST',
544
+ url: '/',
545
+ data: {
546
+ type,
547
+ entry: requests.map(transformToBundleEntry).filter((entry) => entry !== null),
548
+ },
549
+ });
550
+ });
551
+ }
552
+
553
+ const FHIRDateFormat = 'YYYY-MM-DD';
554
+ const FHIRTimeFormat = 'HH:mm:ss';
555
+ const FHIRDateTimeFormat = 'YYYY-MM-DDTHH:mm:ss[Z]';
556
+ const formatFHIRTime = (date) => moment(date).format(FHIRTimeFormat);
557
+ const formatFHIRDate = (date) => moment(date).format(FHIRDateFormat);
558
+ const formatFHIRDateTime = (date) => moment(date)
559
+ .utc()
560
+ .format(FHIRDateTimeFormat);
561
+ const parseFHIRTime = (date) => moment(date, FHIRTimeFormat);
562
+ const parseFHIRDate = (date) => moment(date, FHIRDateFormat);
563
+ const parseFHIRDateTime = (date) => moment.utc(date, FHIRDateTimeFormat).local();
564
+ const makeFHIRDateTime = (date, time = '00:00:00') => formatFHIRDateTime(moment(`${date}T${time}`, `${FHIRDateFormat}T${FHIRTimeFormat}`));
565
+ const extractFHIRDate = (date) => {
566
+ if (date.length === FHIRDateFormat.length) {
567
+ return date;
568
+ }
569
+ return formatFHIRDate(parseFHIRDateTime(date));
570
+ };
571
+ const extractFHIRTime = (date) => {
572
+ if (date.length === FHIRTimeFormat.length) {
573
+ return date;
574
+ }
575
+ return formatFHIRTime(parseFHIRDateTime(date));
576
+ };
577
+ const isFHIRDateEqual = (date1, date2) => extractFHIRDate(date1) === extractFHIRDate(date2);
578
+
579
+ // Mapping that describes default error codes such as network_error and unknown.
580
+ // These are both two edge cases: network error - when request has fallen due to problems with
581
+ // network (no internet connection, server is down) and unknown when
582
+ // response has no defined error code
583
+ const baseErrorMapping = {
584
+ network_error: 'Network error',
585
+ unknown: 'Unknown error',
586
+ };
587
+ // Network error constant that axios returns in case if request failed
588
+ const axiosNetworkError = 'Network Error';
589
+ /**
590
+ * Returns formatted error (when you need to display human-friendly error message)
591
+ *
592
+ * formatError(
593
+ * error,
594
+ * {
595
+ * mapping: {'conflict': 'Please reload page'},
596
+ * format: (errorCode, errorDescription) =>
597
+ * `An error occurred: ${errorDescription} (${errorCode}). Please reach tech support`
598
+ * }
599
+ * )
600
+ */
601
+ function formatError(error, config = {}) {
602
+ const { mapping, format } = config;
603
+ const extendedMapping = Object.assign(Object.assign({}, baseErrorMapping), mapping);
604
+ const errorCode = extractErrorCode(error);
605
+ if (errorCode in extendedMapping) {
606
+ return extendedMapping[errorCode];
607
+ }
608
+ const errorDescription = extractErrorDescription(error);
609
+ if (format) {
610
+ return format(errorCode, errorDescription);
611
+ }
612
+ return `${errorDescription} (${errorCode})`;
613
+ }
614
+ function extractErrorDescription(error) {
615
+ var _a, _b, _c, _d, _e;
616
+ if (error === axiosNetworkError) {
617
+ return baseErrorMapping.network_error;
618
+ }
619
+ if (isOperationOutcome(error)) {
620
+ if ((_c = (_b = (_a = error.issue) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.details) === null || _c === void 0 ? void 0 : _c.text) {
621
+ return error.issue[0].details.text;
622
+ }
623
+ if ((_e = (_d = error.issue) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.diagnostics) {
624
+ return error.issue[0].diagnostics;
625
+ }
626
+ }
627
+ if (isBackendError(error) && error.error_description) {
628
+ return error.error_description;
629
+ }
630
+ return baseErrorMapping.unknown;
631
+ }
632
+ function extractErrorCode(error) {
633
+ if (error === axiosNetworkError) {
634
+ return 'network_error';
635
+ }
636
+ if (isOperationOutcome(error)) {
637
+ return error.issue[0].code;
638
+ }
639
+ if (isBackendError(error)) {
640
+ return error.error;
641
+ }
642
+ return 'unknown';
643
+ }
644
+ function isObject(value) {
645
+ return value && typeof value === 'object' && !(value instanceof Array);
646
+ }
647
+ function isOperationOutcome(error) {
648
+ return isObject(error) && error.resourceType === 'OperationOutcome';
649
+ }
650
+ function isBackendError(error) {
651
+ return isObject(error) && error.error;
652
+ }
653
+
654
+ function withRootAccess(fn) {
655
+ return __awaiter(this, void 0, void 0, function* () {
656
+ axiosInstance.defaults.auth = {
657
+ username: 'root',
658
+ password: 'secret',
659
+ };
660
+ try {
661
+ return yield fn();
662
+ }
663
+ finally {
664
+ delete axiosInstance.defaults.auth;
665
+ }
666
+ });
667
+ }
668
+ function ensure(result) {
669
+ if (isSuccess(result)) {
670
+ return result.data;
671
+ }
672
+ throw new Error(`Network error ${JSON.stringify(result)}`);
673
+ }
674
+ function investigate(result) {
675
+ if (isFailure(result)) {
676
+ return result.error;
677
+ }
678
+ throw new Error(`Nothing to investigate for ${JSON.stringify(result)}`);
679
+ }
680
+ function getToken(user, loginService) {
681
+ return __awaiter(this, void 0, void 0, function* () {
682
+ if (!user.email) {
683
+ throw new Error('Can not login for user without an email');
684
+ }
685
+ const result = yield loginService(user);
686
+ return ensure(result);
687
+ });
688
+ }
689
+ function login(user, loginService) {
690
+ return __awaiter(this, void 0, void 0, function* () {
691
+ resetInstanceToken();
692
+ const token = yield getToken(user, loginService);
693
+ setInstanceToken(token);
694
+ return token;
695
+ });
696
+ }
697
+ function getUserInfo() {
698
+ return __awaiter(this, void 0, void 0, function* () {
699
+ const result = yield service({
700
+ method: 'GET',
701
+ url: '/auth/userinfo',
702
+ headers: {
703
+ Accept: 'application/json',
704
+ 'Content-Type': 'application/json',
705
+ },
706
+ });
707
+ return ensure(result);
708
+ });
709
+ }
710
+
711
+ function uuid4() {
712
+ //// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
713
+ let uuid = '';
714
+ for (let ii = 0; ii < 32; ii += 1) {
715
+ switch (ii) {
716
+ case 8:
717
+ case 20:
718
+ uuid += '-';
719
+ uuid += ((Math.random() * 16) | 0).toString(16);
720
+ break;
721
+ case 12:
722
+ uuid += '-';
723
+ uuid += '4';
724
+ break;
725
+ case 16:
726
+ uuid += '-';
727
+ uuid += ((Math.random() * 4) | 8).toString(16);
728
+ break;
729
+ default:
730
+ uuid += ((Math.random() * 16) | 0).toString(16);
731
+ }
732
+ }
733
+ return uuid;
734
+ }
735
+
736
+ function getDefaultExportFromCjs (x) {
737
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
738
+ }
739
+
740
+ var react = {exports: {}};
741
+
742
+ var react_production_min = {};
743
+
744
+ /*
745
+ object-assign
746
+ (c) Sindre Sorhus
747
+ @license MIT
748
+ */
749
+
750
+ var objectAssign;
751
+ var hasRequiredObjectAssign;
752
+
753
+ function requireObjectAssign () {
754
+ if (hasRequiredObjectAssign) return objectAssign;
755
+ hasRequiredObjectAssign = 1;
756
+ /* eslint-disable no-unused-vars */
757
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
758
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
759
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
760
+
761
+ function toObject(val) {
762
+ if (val === null || val === undefined) {
763
+ throw new TypeError('Object.assign cannot be called with null or undefined');
764
+ }
765
+
766
+ return Object(val);
767
+ }
768
+
769
+ function shouldUseNative() {
770
+ try {
771
+ if (!Object.assign) {
772
+ return false;
773
+ }
774
+
775
+ // Detect buggy property enumeration order in older V8 versions.
776
+
777
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
778
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
779
+ test1[5] = 'de';
780
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
781
+ return false;
782
+ }
783
+
784
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
785
+ var test2 = {};
786
+ for (var i = 0; i < 10; i++) {
787
+ test2['_' + String.fromCharCode(i)] = i;
788
+ }
789
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
790
+ return test2[n];
791
+ });
792
+ if (order2.join('') !== '0123456789') {
793
+ return false;
794
+ }
795
+
796
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
797
+ var test3 = {};
798
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
799
+ test3[letter] = letter;
800
+ });
801
+ if (Object.keys(Object.assign({}, test3)).join('') !==
802
+ 'abcdefghijklmnopqrst') {
803
+ return false;
804
+ }
805
+
806
+ return true;
807
+ } catch (err) {
808
+ // We don't expect any of the above to throw, but better to be safe.
809
+ return false;
810
+ }
811
+ }
812
+
813
+ objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
814
+ var from;
815
+ var to = toObject(target);
816
+ var symbols;
817
+
818
+ for (var s = 1; s < arguments.length; s++) {
819
+ from = Object(arguments[s]);
820
+
821
+ for (var key in from) {
822
+ if (hasOwnProperty.call(from, key)) {
823
+ to[key] = from[key];
824
+ }
825
+ }
826
+
827
+ if (getOwnPropertySymbols) {
828
+ symbols = getOwnPropertySymbols(from);
829
+ for (var i = 0; i < symbols.length; i++) {
830
+ if (propIsEnumerable.call(from, symbols[i])) {
831
+ to[symbols[i]] = from[symbols[i]];
832
+ }
833
+ }
834
+ }
835
+ }
836
+
837
+ return to;
838
+ };
839
+ return objectAssign;
840
+ }
841
+
842
+ /** @license React v16.14.0
843
+ * react.production.min.js
844
+ *
845
+ * Copyright (c) Facebook, Inc. and its affiliates.
846
+ *
847
+ * This source code is licensed under the MIT license found in the
848
+ * LICENSE file in the root directory of this source tree.
849
+ */
850
+
851
+ var hasRequiredReact_production_min;
852
+
853
+ function requireReact_production_min () {
854
+ if (hasRequiredReact_production_min) return react_production_min;
855
+ hasRequiredReact_production_min = 1;
856
+ var l=requireObjectAssign(),n="function"===typeof Symbol&&Symbol.for,p=n?Symbol.for("react.element"):60103,q=n?Symbol.for("react.portal"):60106,r=n?Symbol.for("react.fragment"):60107,t=n?Symbol.for("react.strict_mode"):60108,u=n?Symbol.for("react.profiler"):60114,v=n?Symbol.for("react.provider"):60109,w=n?Symbol.for("react.context"):60110,x=n?Symbol.for("react.forward_ref"):60112,y=n?Symbol.for("react.suspense"):60113,z=n?Symbol.for("react.memo"):60115,A=n?Symbol.for("react.lazy"):
857
+ 60116,B="function"===typeof Symbol&&Symbol.iterator;function C(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)b+="&args[]="+encodeURIComponent(arguments[c]);return "Minified React error #"+a+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}
858
+ var D={isMounted:function(){return !1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E={};function F(a,b,c){this.props=a;this.context=b;this.refs=E;this.updater=c||D;}F.prototype.isReactComponent={};F.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error(C(85));this.updater.enqueueSetState(this,a,b,"setState");};F.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate");};
859
+ function G(){}G.prototype=F.prototype;function H(a,b,c){this.props=a;this.context=b;this.refs=E;this.updater=c||D;}var I=H.prototype=new G;I.constructor=H;l(I,F.prototype);I.isPureReactComponent=!0;var J={current:null},K=Object.prototype.hasOwnProperty,L={key:!0,ref:!0,__self:!0,__source:!0};
860
+ function M(a,b,c){var e,d={},g=null,k=null;if(null!=b)for(e in void 0!==b.ref&&(k=b.ref),void 0!==b.key&&(g=""+b.key),b)K.call(b,e)&&!L.hasOwnProperty(e)&&(d[e]=b[e]);var f=arguments.length-2;if(1===f)d.children=c;else if(1<f){for(var h=Array(f),m=0;m<f;m++)h[m]=arguments[m+2];d.children=h;}if(a&&a.defaultProps)for(e in f=a.defaultProps,f)void 0===d[e]&&(d[e]=f[e]);return {$$typeof:p,type:a,key:g,ref:k,props:d,_owner:J.current}}
861
+ function N(a,b){return {$$typeof:p,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function O(a){return "object"===typeof a&&null!==a&&a.$$typeof===p}function escape(a){var b={"=":"=0",":":"=2"};return "$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}var P=/\/+/g,Q=[];function R(a,b,c,e){if(Q.length){var d=Q.pop();d.result=a;d.keyPrefix=b;d.func=c;d.context=e;d.count=0;return d}return {result:a,keyPrefix:b,func:c,context:e,count:0}}
862
+ function S(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>Q.length&&Q.push(a);}
863
+ function T(a,b,c,e){var d=typeof a;if("undefined"===d||"boolean"===d)a=null;var g=!1;if(null===a)g=!0;else switch(d){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case p:case q:g=!0;}}if(g)return c(e,a,""===b?"."+U(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var k=0;k<a.length;k++){d=a[k];var f=b+U(d,k);g+=T(d,f,c,e);}else if(null===a||"object"!==typeof a?f=null:(f=B&&a[B]||a["@@iterator"],f="function"===typeof f?f:null),"function"===typeof f)for(a=f.call(a),k=
864
+ 0;!(d=a.next()).done;)d=d.value,f=b+U(d,k++),g+=T(d,f,c,e);else if("object"===d)throw c=""+a,Error(C(31,"[object Object]"===c?"object with keys {"+Object.keys(a).join(", ")+"}":c,""));return g}function V(a,b,c){return null==a?0:T(a,"",b,c)}function U(a,b){return "object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function W(a,b){a.func.call(a.context,b,a.count++);}
865
+ function aa(a,b,c){var e=a.result,d=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?X(a,e,c,function(a){return a}):null!=a&&(O(a)&&(a=N(a,d+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(P,"$&/")+"/")+c)),e.push(a));}function X(a,b,c,e,d){var g="";null!=c&&(g=(""+c).replace(P,"$&/")+"/");b=R(b,g,e,d);V(a,aa,b);S(b);}var Y={current:null};function Z(){var a=Y.current;if(null===a)throw Error(C(321));return a}
866
+ var ba={ReactCurrentDispatcher:Y,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:J,IsSomeRendererActing:{current:!1},assign:l};react_production_min.Children={map:function(a,b,c){if(null==a)return a;var e=[];X(a,e,null,b,c);return e},forEach:function(a,b,c){if(null==a)return a;b=R(null,null,b,c);V(a,W,b);S(b);},count:function(a){return V(a,function(){return null},null)},toArray:function(a){var b=[];X(a,b,null,function(a){return a});return b},only:function(a){if(!O(a))throw Error(C(143));return a}};
867
+ react_production_min.Component=F;react_production_min.Fragment=r;react_production_min.Profiler=u;react_production_min.PureComponent=H;react_production_min.StrictMode=t;react_production_min.Suspense=y;react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ba;
868
+ react_production_min.cloneElement=function(a,b,c){if(null===a||void 0===a)throw Error(C(267,a));var e=l({},a.props),d=a.key,g=a.ref,k=a._owner;if(null!=b){void 0!==b.ref&&(g=b.ref,k=J.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var f=a.type.defaultProps;for(h in b)K.call(b,h)&&!L.hasOwnProperty(h)&&(e[h]=void 0===b[h]&&void 0!==f?f[h]:b[h]);}var h=arguments.length-2;if(1===h)e.children=c;else if(1<h){f=Array(h);for(var m=0;m<h;m++)f[m]=arguments[m+2];e.children=f;}return {$$typeof:p,type:a.type,
869
+ key:d,ref:g,props:e,_owner:k}};react_production_min.createContext=function(a,b){void 0===b&&(b=null);a={$$typeof:w,_calculateChangedBits:b,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:v,_context:a};return a.Consumer=a};react_production_min.createElement=M;react_production_min.createFactory=function(a){var b=M.bind(null,a);b.type=a;return b};react_production_min.createRef=function(){return {current:null}};react_production_min.forwardRef=function(a){return {$$typeof:x,render:a}};react_production_min.isValidElement=O;
870
+ react_production_min.lazy=function(a){return {$$typeof:A,_ctor:a,_status:-1,_result:null}};react_production_min.memo=function(a,b){return {$$typeof:z,type:a,compare:void 0===b?null:b}};react_production_min.useCallback=function(a,b){return Z().useCallback(a,b)};react_production_min.useContext=function(a,b){return Z().useContext(a,b)};react_production_min.useDebugValue=function(){};react_production_min.useEffect=function(a,b){return Z().useEffect(a,b)};react_production_min.useImperativeHandle=function(a,b,c){return Z().useImperativeHandle(a,b,c)};
871
+ react_production_min.useLayoutEffect=function(a,b){return Z().useLayoutEffect(a,b)};react_production_min.useMemo=function(a,b){return Z().useMemo(a,b)};react_production_min.useReducer=function(a,b,c){return Z().useReducer(a,b,c)};react_production_min.useRef=function(a){return Z().useRef(a)};react_production_min.useState=function(a){return Z().useState(a)};react_production_min.version="16.14.0";
872
+ return react_production_min;
873
+ }
874
+
875
+ var react_development = {};
876
+
877
+ /**
878
+ * Copyright (c) 2013-present, Facebook, Inc.
879
+ *
880
+ * This source code is licensed under the MIT license found in the
881
+ * LICENSE file in the root directory of this source tree.
882
+ */
883
+
884
+ var ReactPropTypesSecret_1;
885
+ var hasRequiredReactPropTypesSecret;
886
+
887
+ function requireReactPropTypesSecret () {
888
+ if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
889
+ hasRequiredReactPropTypesSecret = 1;
890
+
891
+ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
892
+
893
+ ReactPropTypesSecret_1 = ReactPropTypesSecret;
894
+ return ReactPropTypesSecret_1;
895
+ }
896
+
897
+ var has;
898
+ var hasRequiredHas;
899
+
900
+ function requireHas () {
901
+ if (hasRequiredHas) return has;
902
+ hasRequiredHas = 1;
903
+ has = Function.call.bind(Object.prototype.hasOwnProperty);
904
+ return has;
905
+ }
906
+
907
+ /**
908
+ * Copyright (c) 2013-present, Facebook, Inc.
909
+ *
910
+ * This source code is licensed under the MIT license found in the
911
+ * LICENSE file in the root directory of this source tree.
912
+ */
913
+
914
+ var checkPropTypes_1;
915
+ var hasRequiredCheckPropTypes;
916
+
917
+ function requireCheckPropTypes () {
918
+ if (hasRequiredCheckPropTypes) return checkPropTypes_1;
919
+ hasRequiredCheckPropTypes = 1;
920
+
921
+ var printWarning = function() {};
922
+
923
+ if (process.env.NODE_ENV !== 'production') {
924
+ var ReactPropTypesSecret = requireReactPropTypesSecret();
925
+ var loggedTypeFailures = {};
926
+ var has = requireHas();
927
+
928
+ printWarning = function(text) {
929
+ var message = 'Warning: ' + text;
930
+ if (typeof console !== 'undefined') {
931
+ console.error(message);
932
+ }
933
+ try {
934
+ // --- Welcome to debugging React ---
935
+ // This error was thrown as a convenience so that you can use this stack
936
+ // to find the callsite that caused this warning to fire.
937
+ throw new Error(message);
938
+ } catch (x) { /**/ }
939
+ };
940
+ }
941
+
942
+ /**
943
+ * Assert that the values match with the type specs.
944
+ * Error messages are memorized and will only be shown once.
945
+ *
946
+ * @param {object} typeSpecs Map of name to a ReactPropType
947
+ * @param {object} values Runtime values that need to be type-checked
948
+ * @param {string} location e.g. "prop", "context", "child context"
949
+ * @param {string} componentName Name of the component for error messages.
950
+ * @param {?Function} getStack Returns the component stack.
951
+ * @private
952
+ */
953
+ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
954
+ if (process.env.NODE_ENV !== 'production') {
955
+ for (var typeSpecName in typeSpecs) {
956
+ if (has(typeSpecs, typeSpecName)) {
957
+ var error;
958
+ // Prop type validation may throw. In case they do, we don't want to
959
+ // fail the render phase where it didn't fail before. So we log it.
960
+ // After these have been cleaned up, we'll let them throw.
961
+ try {
962
+ // This is intentionally an invariant that gets caught. It's the same
963
+ // behavior as without this statement except with a better message.
964
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
965
+ var err = Error(
966
+ (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
967
+ 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
968
+ 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
969
+ );
970
+ err.name = 'Invariant Violation';
971
+ throw err;
972
+ }
973
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
974
+ } catch (ex) {
975
+ error = ex;
976
+ }
977
+ if (error && !(error instanceof Error)) {
978
+ printWarning(
979
+ (componentName || 'React class') + ': type specification of ' +
980
+ location + ' `' + typeSpecName + '` is invalid; the type checker ' +
981
+ 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
982
+ 'You may have forgotten to pass an argument to the type checker ' +
983
+ 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
984
+ 'shape all require an argument).'
985
+ );
986
+ }
987
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
988
+ // Only monitor this failure once because there tends to be a lot of the
989
+ // same error.
990
+ loggedTypeFailures[error.message] = true;
991
+
992
+ var stack = getStack ? getStack() : '';
993
+
994
+ printWarning(
995
+ 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
996
+ );
997
+ }
998
+ }
999
+ }
1000
+ }
1001
+ }
1002
+
1003
+ /**
1004
+ * Resets warning cache when testing.
1005
+ *
1006
+ * @private
1007
+ */
1008
+ checkPropTypes.resetWarningCache = function() {
1009
+ if (process.env.NODE_ENV !== 'production') {
1010
+ loggedTypeFailures = {};
1011
+ }
1012
+ };
1013
+
1014
+ checkPropTypes_1 = checkPropTypes;
1015
+ return checkPropTypes_1;
1016
+ }
1017
+
1018
+ /** @license React v16.14.0
1019
+ * react.development.js
1020
+ *
1021
+ * Copyright (c) Facebook, Inc. and its affiliates.
1022
+ *
1023
+ * This source code is licensed under the MIT license found in the
1024
+ * LICENSE file in the root directory of this source tree.
1025
+ */
1026
+
1027
+ var hasRequiredReact_development;
1028
+
1029
+ function requireReact_development () {
1030
+ if (hasRequiredReact_development) return react_development;
1031
+ hasRequiredReact_development = 1;
1032
+
1033
+
1034
+
1035
+ if (process.env.NODE_ENV !== "production") {
1036
+ (function() {
1037
+
1038
+ var _assign = requireObjectAssign();
1039
+ var checkPropTypes = requireCheckPropTypes();
1040
+
1041
+ var ReactVersion = '16.14.0';
1042
+
1043
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
1044
+ // nor polyfill, then a plain number is used for performance.
1045
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
1046
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
1047
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
1048
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
1049
+ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
1050
+ var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
1051
+ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
1052
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
1053
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
1054
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
1055
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
1056
+ var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
1057
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
1058
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
1059
+ var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
1060
+ var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
1061
+ var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
1062
+ var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
1063
+ var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
1064
+ var FAUX_ITERATOR_SYMBOL = '@@iterator';
1065
+ function getIteratorFn(maybeIterable) {
1066
+ if (maybeIterable === null || typeof maybeIterable !== 'object') {
1067
+ return null;
1068
+ }
1069
+
1070
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
1071
+
1072
+ if (typeof maybeIterator === 'function') {
1073
+ return maybeIterator;
1074
+ }
1075
+
1076
+ return null;
1077
+ }
1078
+
1079
+ /**
1080
+ * Keeps track of the current dispatcher.
1081
+ */
1082
+ var ReactCurrentDispatcher = {
1083
+ /**
1084
+ * @internal
1085
+ * @type {ReactComponent}
1086
+ */
1087
+ current: null
1088
+ };
1089
+
1090
+ /**
1091
+ * Keeps track of the current batch's configuration such as how long an update
1092
+ * should suspend for if it needs to.
1093
+ */
1094
+ var ReactCurrentBatchConfig = {
1095
+ suspense: null
1096
+ };
1097
+
1098
+ /**
1099
+ * Keeps track of the current owner.
1100
+ *
1101
+ * The current owner is the component who should own any components that are
1102
+ * currently being constructed.
1103
+ */
1104
+ var ReactCurrentOwner = {
1105
+ /**
1106
+ * @internal
1107
+ * @type {ReactComponent}
1108
+ */
1109
+ current: null
1110
+ };
1111
+
1112
+ var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
1113
+ function describeComponentFrame (name, source, ownerName) {
1114
+ var sourceInfo = '';
1115
+
1116
+ if (source) {
1117
+ var path = source.fileName;
1118
+ var fileName = path.replace(BEFORE_SLASH_RE, '');
1119
+
1120
+ {
1121
+ // In DEV, include code for a common special case:
1122
+ // prefer "folder/index.js" instead of just "index.js".
1123
+ if (/^index\./.test(fileName)) {
1124
+ var match = path.match(BEFORE_SLASH_RE);
1125
+
1126
+ if (match) {
1127
+ var pathBeforeSlash = match[1];
1128
+
1129
+ if (pathBeforeSlash) {
1130
+ var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
1131
+ fileName = folderName + '/' + fileName;
1132
+ }
1133
+ }
1134
+ }
1135
+ }
1136
+
1137
+ sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
1138
+ } else if (ownerName) {
1139
+ sourceInfo = ' (created by ' + ownerName + ')';
1140
+ }
1141
+
1142
+ return '\n in ' + (name || 'Unknown') + sourceInfo;
1143
+ }
1144
+
1145
+ var Resolved = 1;
1146
+ function refineResolvedLazyComponent(lazyComponent) {
1147
+ return lazyComponent._status === Resolved ? lazyComponent._result : null;
1148
+ }
1149
+
1150
+ function getWrappedName(outerType, innerType, wrapperName) {
1151
+ var functionName = innerType.displayName || innerType.name || '';
1152
+ return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
1153
+ }
1154
+
1155
+ function getComponentName(type) {
1156
+ if (type == null) {
1157
+ // Host root, text node or just invalid type.
1158
+ return null;
1159
+ }
1160
+
1161
+ {
1162
+ if (typeof type.tag === 'number') {
1163
+ error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
1164
+ }
1165
+ }
1166
+
1167
+ if (typeof type === 'function') {
1168
+ return type.displayName || type.name || null;
1169
+ }
1170
+
1171
+ if (typeof type === 'string') {
1172
+ return type;
1173
+ }
1174
+
1175
+ switch (type) {
1176
+ case REACT_FRAGMENT_TYPE:
1177
+ return 'Fragment';
1178
+
1179
+ case REACT_PORTAL_TYPE:
1180
+ return 'Portal';
1181
+
1182
+ case REACT_PROFILER_TYPE:
1183
+ return "Profiler";
1184
+
1185
+ case REACT_STRICT_MODE_TYPE:
1186
+ return 'StrictMode';
1187
+
1188
+ case REACT_SUSPENSE_TYPE:
1189
+ return 'Suspense';
1190
+
1191
+ case REACT_SUSPENSE_LIST_TYPE:
1192
+ return 'SuspenseList';
1193
+ }
1194
+
1195
+ if (typeof type === 'object') {
1196
+ switch (type.$$typeof) {
1197
+ case REACT_CONTEXT_TYPE:
1198
+ return 'Context.Consumer';
1199
+
1200
+ case REACT_PROVIDER_TYPE:
1201
+ return 'Context.Provider';
1202
+
1203
+ case REACT_FORWARD_REF_TYPE:
1204
+ return getWrappedName(type, type.render, 'ForwardRef');
1205
+
1206
+ case REACT_MEMO_TYPE:
1207
+ return getComponentName(type.type);
1208
+
1209
+ case REACT_BLOCK_TYPE:
1210
+ return getComponentName(type.render);
1211
+
1212
+ case REACT_LAZY_TYPE:
1213
+ {
1214
+ var thenable = type;
1215
+ var resolvedThenable = refineResolvedLazyComponent(thenable);
1216
+
1217
+ if (resolvedThenable) {
1218
+ return getComponentName(resolvedThenable);
1219
+ }
1220
+
1221
+ break;
1222
+ }
1223
+ }
1224
+ }
1225
+
1226
+ return null;
1227
+ }
1228
+
1229
+ var ReactDebugCurrentFrame = {};
1230
+ var currentlyValidatingElement = null;
1231
+ function setCurrentlyValidatingElement(element) {
1232
+ {
1233
+ currentlyValidatingElement = element;
1234
+ }
1235
+ }
1236
+
1237
+ {
1238
+ // Stack implementation injected by the current renderer.
1239
+ ReactDebugCurrentFrame.getCurrentStack = null;
1240
+
1241
+ ReactDebugCurrentFrame.getStackAddendum = function () {
1242
+ var stack = ''; // Add an extra top frame while an element is being validated
1243
+
1244
+ if (currentlyValidatingElement) {
1245
+ var name = getComponentName(currentlyValidatingElement.type);
1246
+ var owner = currentlyValidatingElement._owner;
1247
+ stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
1248
+ } // Delegate to the injected renderer-specific implementation
1249
+
1250
+
1251
+ var impl = ReactDebugCurrentFrame.getCurrentStack;
1252
+
1253
+ if (impl) {
1254
+ stack += impl() || '';
1255
+ }
1256
+
1257
+ return stack;
1258
+ };
1259
+ }
1260
+
1261
+ /**
1262
+ * Used by act() to track whether you're inside an act() scope.
1263
+ */
1264
+ var IsSomeRendererActing = {
1265
+ current: false
1266
+ };
1267
+
1268
+ var ReactSharedInternals = {
1269
+ ReactCurrentDispatcher: ReactCurrentDispatcher,
1270
+ ReactCurrentBatchConfig: ReactCurrentBatchConfig,
1271
+ ReactCurrentOwner: ReactCurrentOwner,
1272
+ IsSomeRendererActing: IsSomeRendererActing,
1273
+ // Used by renderers to avoid bundling object-assign twice in UMD bundles:
1274
+ assign: _assign
1275
+ };
1276
+
1277
+ {
1278
+ _assign(ReactSharedInternals, {
1279
+ // These should not be included in production.
1280
+ ReactDebugCurrentFrame: ReactDebugCurrentFrame,
1281
+ // Shim for React DOM 16.0.0 which still destructured (but not used) this.
1282
+ // TODO: remove in React 17.0.
1283
+ ReactComponentTreeHook: {}
1284
+ });
1285
+ }
1286
+
1287
+ // by calls to these methods by a Babel plugin.
1288
+ //
1289
+ // In PROD (or in packages without access to React internals),
1290
+ // they are left as they are instead.
1291
+
1292
+ function warn(format) {
1293
+ {
1294
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1295
+ args[_key - 1] = arguments[_key];
1296
+ }
1297
+
1298
+ printWarning('warn', format, args);
1299
+ }
1300
+ }
1301
+ function error(format) {
1302
+ {
1303
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1304
+ args[_key2 - 1] = arguments[_key2];
1305
+ }
1306
+
1307
+ printWarning('error', format, args);
1308
+ }
1309
+ }
1310
+
1311
+ function printWarning(level, format, args) {
1312
+ // When changing this logic, you might want to also
1313
+ // update consoleWithStackDev.www.js as well.
1314
+ {
1315
+ var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
1316
+
1317
+ if (!hasExistingStack) {
1318
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1319
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
1320
+
1321
+ if (stack !== '') {
1322
+ format += '%s';
1323
+ args = args.concat([stack]);
1324
+ }
1325
+ }
1326
+
1327
+ var argsWithFormat = args.map(function (item) {
1328
+ return '' + item;
1329
+ }); // Careful: RN currently depends on this prefix
1330
+
1331
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
1332
+ // breaks IE9: https://github.com/facebook/react/issues/13610
1333
+ // eslint-disable-next-line react-internal/no-production-logging
1334
+
1335
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
1336
+
1337
+ try {
1338
+ // --- Welcome to debugging React ---
1339
+ // This error was thrown as a convenience so that you can use this stack
1340
+ // to find the callsite that caused this warning to fire.
1341
+ var argIndex = 0;
1342
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
1343
+ return args[argIndex++];
1344
+ });
1345
+ throw new Error(message);
1346
+ } catch (x) {}
1347
+ }
1348
+ }
1349
+
1350
+ var didWarnStateUpdateForUnmountedComponent = {};
1351
+
1352
+ function warnNoop(publicInstance, callerName) {
1353
+ {
1354
+ var _constructor = publicInstance.constructor;
1355
+ var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
1356
+ var warningKey = componentName + "." + callerName;
1357
+
1358
+ if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
1359
+ return;
1360
+ }
1361
+
1362
+ error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
1363
+
1364
+ didWarnStateUpdateForUnmountedComponent[warningKey] = true;
1365
+ }
1366
+ }
1367
+ /**
1368
+ * This is the abstract API for an update queue.
1369
+ */
1370
+
1371
+
1372
+ var ReactNoopUpdateQueue = {
1373
+ /**
1374
+ * Checks whether or not this composite component is mounted.
1375
+ * @param {ReactClass} publicInstance The instance we want to test.
1376
+ * @return {boolean} True if mounted, false otherwise.
1377
+ * @protected
1378
+ * @final
1379
+ */
1380
+ isMounted: function (publicInstance) {
1381
+ return false;
1382
+ },
1383
+
1384
+ /**
1385
+ * Forces an update. This should only be invoked when it is known with
1386
+ * certainty that we are **not** in a DOM transaction.
1387
+ *
1388
+ * You may want to call this when you know that some deeper aspect of the
1389
+ * component's state has changed but `setState` was not called.
1390
+ *
1391
+ * This will not invoke `shouldComponentUpdate`, but it will invoke
1392
+ * `componentWillUpdate` and `componentDidUpdate`.
1393
+ *
1394
+ * @param {ReactClass} publicInstance The instance that should rerender.
1395
+ * @param {?function} callback Called after component is updated.
1396
+ * @param {?string} callerName name of the calling function in the public API.
1397
+ * @internal
1398
+ */
1399
+ enqueueForceUpdate: function (publicInstance, callback, callerName) {
1400
+ warnNoop(publicInstance, 'forceUpdate');
1401
+ },
1402
+
1403
+ /**
1404
+ * Replaces all of the state. Always use this or `setState` to mutate state.
1405
+ * You should treat `this.state` as immutable.
1406
+ *
1407
+ * There is no guarantee that `this.state` will be immediately updated, so
1408
+ * accessing `this.state` after calling this method may return the old value.
1409
+ *
1410
+ * @param {ReactClass} publicInstance The instance that should rerender.
1411
+ * @param {object} completeState Next state.
1412
+ * @param {?function} callback Called after component is updated.
1413
+ * @param {?string} callerName name of the calling function in the public API.
1414
+ * @internal
1415
+ */
1416
+ enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
1417
+ warnNoop(publicInstance, 'replaceState');
1418
+ },
1419
+
1420
+ /**
1421
+ * Sets a subset of the state. This only exists because _pendingState is
1422
+ * internal. This provides a merging strategy that is not available to deep
1423
+ * properties which is confusing. TODO: Expose pendingState or don't use it
1424
+ * during the merge.
1425
+ *
1426
+ * @param {ReactClass} publicInstance The instance that should rerender.
1427
+ * @param {object} partialState Next partial state to be merged with state.
1428
+ * @param {?function} callback Called after component is updated.
1429
+ * @param {?string} Name of the calling function in the public API.
1430
+ * @internal
1431
+ */
1432
+ enqueueSetState: function (publicInstance, partialState, callback, callerName) {
1433
+ warnNoop(publicInstance, 'setState');
1434
+ }
1435
+ };
1436
+
1437
+ var emptyObject = {};
1438
+
1439
+ {
1440
+ Object.freeze(emptyObject);
1441
+ }
1442
+ /**
1443
+ * Base class helpers for the updating state of a component.
1444
+ */
1445
+
1446
+
1447
+ function Component(props, context, updater) {
1448
+ this.props = props;
1449
+ this.context = context; // If a component has string refs, we will assign a different object later.
1450
+
1451
+ this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
1452
+ // renderer.
1453
+
1454
+ this.updater = updater || ReactNoopUpdateQueue;
1455
+ }
1456
+
1457
+ Component.prototype.isReactComponent = {};
1458
+ /**
1459
+ * Sets a subset of the state. Always use this to mutate
1460
+ * state. You should treat `this.state` as immutable.
1461
+ *
1462
+ * There is no guarantee that `this.state` will be immediately updated, so
1463
+ * accessing `this.state` after calling this method may return the old value.
1464
+ *
1465
+ * There is no guarantee that calls to `setState` will run synchronously,
1466
+ * as they may eventually be batched together. You can provide an optional
1467
+ * callback that will be executed when the call to setState is actually
1468
+ * completed.
1469
+ *
1470
+ * When a function is provided to setState, it will be called at some point in
1471
+ * the future (not synchronously). It will be called with the up to date
1472
+ * component arguments (state, props, context). These values can be different
1473
+ * from this.* because your function may be called after receiveProps but before
1474
+ * shouldComponentUpdate, and this new state, props, and context will not yet be
1475
+ * assigned to this.
1476
+ *
1477
+ * @param {object|function} partialState Next partial state or function to
1478
+ * produce next partial state to be merged with current state.
1479
+ * @param {?function} callback Called after state is updated.
1480
+ * @final
1481
+ * @protected
1482
+ */
1483
+
1484
+ Component.prototype.setState = function (partialState, callback) {
1485
+ if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
1486
+ {
1487
+ throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." );
1488
+ }
1489
+ }
1490
+
1491
+ this.updater.enqueueSetState(this, partialState, callback, 'setState');
1492
+ };
1493
+ /**
1494
+ * Forces an update. This should only be invoked when it is known with
1495
+ * certainty that we are **not** in a DOM transaction.
1496
+ *
1497
+ * You may want to call this when you know that some deeper aspect of the
1498
+ * component's state has changed but `setState` was not called.
1499
+ *
1500
+ * This will not invoke `shouldComponentUpdate`, but it will invoke
1501
+ * `componentWillUpdate` and `componentDidUpdate`.
1502
+ *
1503
+ * @param {?function} callback Called after update is complete.
1504
+ * @final
1505
+ * @protected
1506
+ */
1507
+
1508
+
1509
+ Component.prototype.forceUpdate = function (callback) {
1510
+ this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
1511
+ };
1512
+ /**
1513
+ * Deprecated APIs. These APIs used to exist on classic React classes but since
1514
+ * we would like to deprecate them, we're not going to move them over to this
1515
+ * modern base class. Instead, we define a getter that warns if it's accessed.
1516
+ */
1517
+
1518
+
1519
+ {
1520
+ var deprecatedAPIs = {
1521
+ isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
1522
+ replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
1523
+ };
1524
+
1525
+ var defineDeprecationWarning = function (methodName, info) {
1526
+ Object.defineProperty(Component.prototype, methodName, {
1527
+ get: function () {
1528
+ warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
1529
+
1530
+ return undefined;
1531
+ }
1532
+ });
1533
+ };
1534
+
1535
+ for (var fnName in deprecatedAPIs) {
1536
+ if (deprecatedAPIs.hasOwnProperty(fnName)) {
1537
+ defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
1538
+ }
1539
+ }
1540
+ }
1541
+
1542
+ function ComponentDummy() {}
1543
+
1544
+ ComponentDummy.prototype = Component.prototype;
1545
+ /**
1546
+ * Convenience component with default shallow equality check for sCU.
1547
+ */
1548
+
1549
+ function PureComponent(props, context, updater) {
1550
+ this.props = props;
1551
+ this.context = context; // If a component has string refs, we will assign a different object later.
1552
+
1553
+ this.refs = emptyObject;
1554
+ this.updater = updater || ReactNoopUpdateQueue;
1555
+ }
1556
+
1557
+ var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
1558
+ pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
1559
+
1560
+ _assign(pureComponentPrototype, Component.prototype);
1561
+
1562
+ pureComponentPrototype.isPureReactComponent = true;
1563
+
1564
+ // an immutable object with a single mutable value
1565
+ function createRef() {
1566
+ var refObject = {
1567
+ current: null
1568
+ };
1569
+
1570
+ {
1571
+ Object.seal(refObject);
1572
+ }
1573
+
1574
+ return refObject;
1575
+ }
1576
+
1577
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
1578
+ var RESERVED_PROPS = {
1579
+ key: true,
1580
+ ref: true,
1581
+ __self: true,
1582
+ __source: true
1583
+ };
1584
+ var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
1585
+
1586
+ {
1587
+ didWarnAboutStringRefs = {};
1588
+ }
1589
+
1590
+ function hasValidRef(config) {
1591
+ {
1592
+ if (hasOwnProperty.call(config, 'ref')) {
1593
+ var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
1594
+
1595
+ if (getter && getter.isReactWarning) {
1596
+ return false;
1597
+ }
1598
+ }
1599
+ }
1600
+
1601
+ return config.ref !== undefined;
1602
+ }
1603
+
1604
+ function hasValidKey(config) {
1605
+ {
1606
+ if (hasOwnProperty.call(config, 'key')) {
1607
+ var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
1608
+
1609
+ if (getter && getter.isReactWarning) {
1610
+ return false;
1611
+ }
1612
+ }
1613
+ }
1614
+
1615
+ return config.key !== undefined;
1616
+ }
1617
+
1618
+ function defineKeyPropWarningGetter(props, displayName) {
1619
+ var warnAboutAccessingKey = function () {
1620
+ {
1621
+ if (!specialPropKeyWarningShown) {
1622
+ specialPropKeyWarningShown = true;
1623
+
1624
+ error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
1625
+ }
1626
+ }
1627
+ };
1628
+
1629
+ warnAboutAccessingKey.isReactWarning = true;
1630
+ Object.defineProperty(props, 'key', {
1631
+ get: warnAboutAccessingKey,
1632
+ configurable: true
1633
+ });
1634
+ }
1635
+
1636
+ function defineRefPropWarningGetter(props, displayName) {
1637
+ var warnAboutAccessingRef = function () {
1638
+ {
1639
+ if (!specialPropRefWarningShown) {
1640
+ specialPropRefWarningShown = true;
1641
+
1642
+ error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
1643
+ }
1644
+ }
1645
+ };
1646
+
1647
+ warnAboutAccessingRef.isReactWarning = true;
1648
+ Object.defineProperty(props, 'ref', {
1649
+ get: warnAboutAccessingRef,
1650
+ configurable: true
1651
+ });
1652
+ }
1653
+
1654
+ function warnIfStringRefCannotBeAutoConverted(config) {
1655
+ {
1656
+ if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
1657
+ var componentName = getComponentName(ReactCurrentOwner.current.type);
1658
+
1659
+ if (!didWarnAboutStringRefs[componentName]) {
1660
+ error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
1661
+
1662
+ didWarnAboutStringRefs[componentName] = true;
1663
+ }
1664
+ }
1665
+ }
1666
+ }
1667
+ /**
1668
+ * Factory method to create a new React element. This no longer adheres to
1669
+ * the class pattern, so do not use new to call it. Also, instanceof check
1670
+ * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1671
+ * if something is a React Element.
1672
+ *
1673
+ * @param {*} type
1674
+ * @param {*} props
1675
+ * @param {*} key
1676
+ * @param {string|object} ref
1677
+ * @param {*} owner
1678
+ * @param {*} self A *temporary* helper to detect places where `this` is
1679
+ * different from the `owner` when React.createElement is called, so that we
1680
+ * can warn. We want to get rid of owner and replace string `ref`s with arrow
1681
+ * functions, and as long as `this` and owner are the same, there will be no
1682
+ * change in behavior.
1683
+ * @param {*} source An annotation object (added by a transpiler or otherwise)
1684
+ * indicating filename, line number, and/or other information.
1685
+ * @internal
1686
+ */
1687
+
1688
+
1689
+ var ReactElement = function (type, key, ref, self, source, owner, props) {
1690
+ var element = {
1691
+ // This tag allows us to uniquely identify this as a React Element
1692
+ $$typeof: REACT_ELEMENT_TYPE,
1693
+ // Built-in properties that belong on the element
1694
+ type: type,
1695
+ key: key,
1696
+ ref: ref,
1697
+ props: props,
1698
+ // Record the component responsible for creating this element.
1699
+ _owner: owner
1700
+ };
1701
+
1702
+ {
1703
+ // The validation flag is currently mutative. We put it on
1704
+ // an external backing store so that we can freeze the whole object.
1705
+ // This can be replaced with a WeakMap once they are implemented in
1706
+ // commonly used development environments.
1707
+ element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
1708
+ // the validation flag non-enumerable (where possible, which should
1709
+ // include every environment we run tests in), so the test framework
1710
+ // ignores it.
1711
+
1712
+ Object.defineProperty(element._store, 'validated', {
1713
+ configurable: false,
1714
+ enumerable: false,
1715
+ writable: true,
1716
+ value: false
1717
+ }); // self and source are DEV only properties.
1718
+
1719
+ Object.defineProperty(element, '_self', {
1720
+ configurable: false,
1721
+ enumerable: false,
1722
+ writable: false,
1723
+ value: self
1724
+ }); // Two elements created in two different places should be considered
1725
+ // equal for testing purposes and therefore we hide it from enumeration.
1726
+
1727
+ Object.defineProperty(element, '_source', {
1728
+ configurable: false,
1729
+ enumerable: false,
1730
+ writable: false,
1731
+ value: source
1732
+ });
1733
+
1734
+ if (Object.freeze) {
1735
+ Object.freeze(element.props);
1736
+ Object.freeze(element);
1737
+ }
1738
+ }
1739
+
1740
+ return element;
1741
+ };
1742
+ /**
1743
+ * Create and return a new ReactElement of the given type.
1744
+ * See https://reactjs.org/docs/react-api.html#createelement
1745
+ */
1746
+
1747
+ function createElement(type, config, children) {
1748
+ var propName; // Reserved names are extracted
1749
+
1750
+ var props = {};
1751
+ var key = null;
1752
+ var ref = null;
1753
+ var self = null;
1754
+ var source = null;
1755
+
1756
+ if (config != null) {
1757
+ if (hasValidRef(config)) {
1758
+ ref = config.ref;
1759
+
1760
+ {
1761
+ warnIfStringRefCannotBeAutoConverted(config);
1762
+ }
1763
+ }
1764
+
1765
+ if (hasValidKey(config)) {
1766
+ key = '' + config.key;
1767
+ }
1768
+
1769
+ self = config.__self === undefined ? null : config.__self;
1770
+ source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
1771
+
1772
+ for (propName in config) {
1773
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1774
+ props[propName] = config[propName];
1775
+ }
1776
+ }
1777
+ } // Children can be more than one argument, and those are transferred onto
1778
+ // the newly allocated props object.
1779
+
1780
+
1781
+ var childrenLength = arguments.length - 2;
1782
+
1783
+ if (childrenLength === 1) {
1784
+ props.children = children;
1785
+ } else if (childrenLength > 1) {
1786
+ var childArray = Array(childrenLength);
1787
+
1788
+ for (var i = 0; i < childrenLength; i++) {
1789
+ childArray[i] = arguments[i + 2];
1790
+ }
1791
+
1792
+ {
1793
+ if (Object.freeze) {
1794
+ Object.freeze(childArray);
1795
+ }
1796
+ }
1797
+
1798
+ props.children = childArray;
1799
+ } // Resolve default props
1800
+
1801
+
1802
+ if (type && type.defaultProps) {
1803
+ var defaultProps = type.defaultProps;
1804
+
1805
+ for (propName in defaultProps) {
1806
+ if (props[propName] === undefined) {
1807
+ props[propName] = defaultProps[propName];
1808
+ }
1809
+ }
1810
+ }
1811
+
1812
+ {
1813
+ if (key || ref) {
1814
+ var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
1815
+
1816
+ if (key) {
1817
+ defineKeyPropWarningGetter(props, displayName);
1818
+ }
1819
+
1820
+ if (ref) {
1821
+ defineRefPropWarningGetter(props, displayName);
1822
+ }
1823
+ }
1824
+ }
1825
+
1826
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1827
+ }
1828
+ function cloneAndReplaceKey(oldElement, newKey) {
1829
+ var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
1830
+ return newElement;
1831
+ }
1832
+ /**
1833
+ * Clone and return a new ReactElement using element as the starting point.
1834
+ * See https://reactjs.org/docs/react-api.html#cloneelement
1835
+ */
1836
+
1837
+ function cloneElement(element, config, children) {
1838
+ if (!!(element === null || element === undefined)) {
1839
+ {
1840
+ throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." );
1841
+ }
1842
+ }
1843
+
1844
+ var propName; // Original props are copied
1845
+
1846
+ var props = _assign({}, element.props); // Reserved names are extracted
1847
+
1848
+
1849
+ var key = element.key;
1850
+ var ref = element.ref; // Self is preserved since the owner is preserved.
1851
+
1852
+ var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
1853
+ // transpiler, and the original source is probably a better indicator of the
1854
+ // true owner.
1855
+
1856
+ var source = element._source; // Owner will be preserved, unless ref is overridden
1857
+
1858
+ var owner = element._owner;
1859
+
1860
+ if (config != null) {
1861
+ if (hasValidRef(config)) {
1862
+ // Silently steal the ref from the parent.
1863
+ ref = config.ref;
1864
+ owner = ReactCurrentOwner.current;
1865
+ }
1866
+
1867
+ if (hasValidKey(config)) {
1868
+ key = '' + config.key;
1869
+ } // Remaining properties override existing props
1870
+
1871
+
1872
+ var defaultProps;
1873
+
1874
+ if (element.type && element.type.defaultProps) {
1875
+ defaultProps = element.type.defaultProps;
1876
+ }
1877
+
1878
+ for (propName in config) {
1879
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1880
+ if (config[propName] === undefined && defaultProps !== undefined) {
1881
+ // Resolve default props
1882
+ props[propName] = defaultProps[propName];
1883
+ } else {
1884
+ props[propName] = config[propName];
1885
+ }
1886
+ }
1887
+ }
1888
+ } // Children can be more than one argument, and those are transferred onto
1889
+ // the newly allocated props object.
1890
+
1891
+
1892
+ var childrenLength = arguments.length - 2;
1893
+
1894
+ if (childrenLength === 1) {
1895
+ props.children = children;
1896
+ } else if (childrenLength > 1) {
1897
+ var childArray = Array(childrenLength);
1898
+
1899
+ for (var i = 0; i < childrenLength; i++) {
1900
+ childArray[i] = arguments[i + 2];
1901
+ }
1902
+
1903
+ props.children = childArray;
1904
+ }
1905
+
1906
+ return ReactElement(element.type, key, ref, self, source, owner, props);
1907
+ }
1908
+ /**
1909
+ * Verifies the object is a ReactElement.
1910
+ * See https://reactjs.org/docs/react-api.html#isvalidelement
1911
+ * @param {?object} object
1912
+ * @return {boolean} True if `object` is a ReactElement.
1913
+ * @final
1914
+ */
1915
+
1916
+ function isValidElement(object) {
1917
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1918
+ }
1919
+
1920
+ var SEPARATOR = '.';
1921
+ var SUBSEPARATOR = ':';
1922
+ /**
1923
+ * Escape and wrap key so it is safe to use as a reactid
1924
+ *
1925
+ * @param {string} key to be escaped.
1926
+ * @return {string} the escaped key.
1927
+ */
1928
+
1929
+ function escape(key) {
1930
+ var escapeRegex = /[=:]/g;
1931
+ var escaperLookup = {
1932
+ '=': '=0',
1933
+ ':': '=2'
1934
+ };
1935
+ var escapedString = ('' + key).replace(escapeRegex, function (match) {
1936
+ return escaperLookup[match];
1937
+ });
1938
+ return '$' + escapedString;
1939
+ }
1940
+ /**
1941
+ * TODO: Test that a single child and an array with one item have the same key
1942
+ * pattern.
1943
+ */
1944
+
1945
+
1946
+ var didWarnAboutMaps = false;
1947
+ var userProvidedKeyEscapeRegex = /\/+/g;
1948
+
1949
+ function escapeUserProvidedKey(text) {
1950
+ return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
1951
+ }
1952
+
1953
+ var POOL_SIZE = 10;
1954
+ var traverseContextPool = [];
1955
+
1956
+ function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
1957
+ if (traverseContextPool.length) {
1958
+ var traverseContext = traverseContextPool.pop();
1959
+ traverseContext.result = mapResult;
1960
+ traverseContext.keyPrefix = keyPrefix;
1961
+ traverseContext.func = mapFunction;
1962
+ traverseContext.context = mapContext;
1963
+ traverseContext.count = 0;
1964
+ return traverseContext;
1965
+ } else {
1966
+ return {
1967
+ result: mapResult,
1968
+ keyPrefix: keyPrefix,
1969
+ func: mapFunction,
1970
+ context: mapContext,
1971
+ count: 0
1972
+ };
1973
+ }
1974
+ }
1975
+
1976
+ function releaseTraverseContext(traverseContext) {
1977
+ traverseContext.result = null;
1978
+ traverseContext.keyPrefix = null;
1979
+ traverseContext.func = null;
1980
+ traverseContext.context = null;
1981
+ traverseContext.count = 0;
1982
+
1983
+ if (traverseContextPool.length < POOL_SIZE) {
1984
+ traverseContextPool.push(traverseContext);
1985
+ }
1986
+ }
1987
+ /**
1988
+ * @param {?*} children Children tree container.
1989
+ * @param {!string} nameSoFar Name of the key path so far.
1990
+ * @param {!function} callback Callback to invoke with each child found.
1991
+ * @param {?*} traverseContext Used to pass information throughout the traversal
1992
+ * process.
1993
+ * @return {!number} The number of children in this subtree.
1994
+ */
1995
+
1996
+
1997
+ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
1998
+ var type = typeof children;
1999
+
2000
+ if (type === 'undefined' || type === 'boolean') {
2001
+ // All of the above are perceived as null.
2002
+ children = null;
2003
+ }
2004
+
2005
+ var invokeCallback = false;
2006
+
2007
+ if (children === null) {
2008
+ invokeCallback = true;
2009
+ } else {
2010
+ switch (type) {
2011
+ case 'string':
2012
+ case 'number':
2013
+ invokeCallback = true;
2014
+ break;
2015
+
2016
+ case 'object':
2017
+ switch (children.$$typeof) {
2018
+ case REACT_ELEMENT_TYPE:
2019
+ case REACT_PORTAL_TYPE:
2020
+ invokeCallback = true;
2021
+ }
2022
+
2023
+ }
2024
+ }
2025
+
2026
+ if (invokeCallback) {
2027
+ callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array
2028
+ // so that it's consistent if the number of children grows.
2029
+ nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
2030
+ return 1;
2031
+ }
2032
+
2033
+ var child;
2034
+ var nextName;
2035
+ var subtreeCount = 0; // Count of children found in the current subtree.
2036
+
2037
+ var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
2038
+
2039
+ if (Array.isArray(children)) {
2040
+ for (var i = 0; i < children.length; i++) {
2041
+ child = children[i];
2042
+ nextName = nextNamePrefix + getComponentKey(child, i);
2043
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2044
+ }
2045
+ } else {
2046
+ var iteratorFn = getIteratorFn(children);
2047
+
2048
+ if (typeof iteratorFn === 'function') {
2049
+
2050
+ {
2051
+ // Warn about using Maps as children
2052
+ if (iteratorFn === children.entries) {
2053
+ if (!didWarnAboutMaps) {
2054
+ warn('Using Maps as children is deprecated and will be removed in ' + 'a future major release. Consider converting children to ' + 'an array of keyed ReactElements instead.');
2055
+ }
2056
+
2057
+ didWarnAboutMaps = true;
2058
+ }
2059
+ }
2060
+
2061
+ var iterator = iteratorFn.call(children);
2062
+ var step;
2063
+ var ii = 0;
2064
+
2065
+ while (!(step = iterator.next()).done) {
2066
+ child = step.value;
2067
+ nextName = nextNamePrefix + getComponentKey(child, ii++);
2068
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2069
+ }
2070
+ } else if (type === 'object') {
2071
+ var addendum = '';
2072
+
2073
+ {
2074
+ addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
2075
+ }
2076
+
2077
+ var childrenString = '' + children;
2078
+
2079
+ {
2080
+ {
2081
+ throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum );
2082
+ }
2083
+ }
2084
+ }
2085
+ }
2086
+
2087
+ return subtreeCount;
2088
+ }
2089
+ /**
2090
+ * Traverses children that are typically specified as `props.children`, but
2091
+ * might also be specified through attributes:
2092
+ *
2093
+ * - `traverseAllChildren(this.props.children, ...)`
2094
+ * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
2095
+ *
2096
+ * The `traverseContext` is an optional argument that is passed through the
2097
+ * entire traversal. It can be used to store accumulations or anything else that
2098
+ * the callback might find relevant.
2099
+ *
2100
+ * @param {?*} children Children tree object.
2101
+ * @param {!function} callback To invoke upon traversing each child.
2102
+ * @param {?*} traverseContext Context for traversal.
2103
+ * @return {!number} The number of children in this subtree.
2104
+ */
2105
+
2106
+
2107
+ function traverseAllChildren(children, callback, traverseContext) {
2108
+ if (children == null) {
2109
+ return 0;
2110
+ }
2111
+
2112
+ return traverseAllChildrenImpl(children, '', callback, traverseContext);
2113
+ }
2114
+ /**
2115
+ * Generate a key string that identifies a component within a set.
2116
+ *
2117
+ * @param {*} component A component that could contain a manual key.
2118
+ * @param {number} index Index that is used if a manual key is not provided.
2119
+ * @return {string}
2120
+ */
2121
+
2122
+
2123
+ function getComponentKey(component, index) {
2124
+ // Do some typechecking here since we call this blindly. We want to ensure
2125
+ // that we don't block potential future ES APIs.
2126
+ if (typeof component === 'object' && component !== null && component.key != null) {
2127
+ // Explicit key
2128
+ return escape(component.key);
2129
+ } // Implicit key determined by the index in the set
2130
+
2131
+
2132
+ return index.toString(36);
2133
+ }
2134
+
2135
+ function forEachSingleChild(bookKeeping, child, name) {
2136
+ var func = bookKeeping.func,
2137
+ context = bookKeeping.context;
2138
+ func.call(context, child, bookKeeping.count++);
2139
+ }
2140
+ /**
2141
+ * Iterates through children that are typically specified as `props.children`.
2142
+ *
2143
+ * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
2144
+ *
2145
+ * The provided forEachFunc(child, index) will be called for each
2146
+ * leaf child.
2147
+ *
2148
+ * @param {?*} children Children tree container.
2149
+ * @param {function(*, int)} forEachFunc
2150
+ * @param {*} forEachContext Context for forEachContext.
2151
+ */
2152
+
2153
+
2154
+ function forEachChildren(children, forEachFunc, forEachContext) {
2155
+ if (children == null) {
2156
+ return children;
2157
+ }
2158
+
2159
+ var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
2160
+ traverseAllChildren(children, forEachSingleChild, traverseContext);
2161
+ releaseTraverseContext(traverseContext);
2162
+ }
2163
+
2164
+ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
2165
+ var result = bookKeeping.result,
2166
+ keyPrefix = bookKeeping.keyPrefix,
2167
+ func = bookKeeping.func,
2168
+ context = bookKeeping.context;
2169
+ var mappedChild = func.call(context, child, bookKeeping.count++);
2170
+
2171
+ if (Array.isArray(mappedChild)) {
2172
+ mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
2173
+ return c;
2174
+ });
2175
+ } else if (mappedChild != null) {
2176
+ if (isValidElement(mappedChild)) {
2177
+ mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
2178
+ // traverseAllChildren used to do for objects as children
2179
+ keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
2180
+ }
2181
+
2182
+ result.push(mappedChild);
2183
+ }
2184
+ }
2185
+
2186
+ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
2187
+ var escapedPrefix = '';
2188
+
2189
+ if (prefix != null) {
2190
+ escapedPrefix = escapeUserProvidedKey(prefix) + '/';
2191
+ }
2192
+
2193
+ var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
2194
+ traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
2195
+ releaseTraverseContext(traverseContext);
2196
+ }
2197
+ /**
2198
+ * Maps children that are typically specified as `props.children`.
2199
+ *
2200
+ * See https://reactjs.org/docs/react-api.html#reactchildrenmap
2201
+ *
2202
+ * The provided mapFunction(child, key, index) will be called for each
2203
+ * leaf child.
2204
+ *
2205
+ * @param {?*} children Children tree container.
2206
+ * @param {function(*, int)} func The map function.
2207
+ * @param {*} context Context for mapFunction.
2208
+ * @return {object} Object containing the ordered map of results.
2209
+ */
2210
+
2211
+
2212
+ function mapChildren(children, func, context) {
2213
+ if (children == null) {
2214
+ return children;
2215
+ }
2216
+
2217
+ var result = [];
2218
+ mapIntoWithKeyPrefixInternal(children, result, null, func, context);
2219
+ return result;
2220
+ }
2221
+ /**
2222
+ * Count the number of children that are typically specified as
2223
+ * `props.children`.
2224
+ *
2225
+ * See https://reactjs.org/docs/react-api.html#reactchildrencount
2226
+ *
2227
+ * @param {?*} children Children tree container.
2228
+ * @return {number} The number of children.
2229
+ */
2230
+
2231
+
2232
+ function countChildren(children) {
2233
+ return traverseAllChildren(children, function () {
2234
+ return null;
2235
+ }, null);
2236
+ }
2237
+ /**
2238
+ * Flatten a children object (typically specified as `props.children`) and
2239
+ * return an array with appropriately re-keyed children.
2240
+ *
2241
+ * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
2242
+ */
2243
+
2244
+
2245
+ function toArray(children) {
2246
+ var result = [];
2247
+ mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
2248
+ return child;
2249
+ });
2250
+ return result;
2251
+ }
2252
+ /**
2253
+ * Returns the first child in a collection of children and verifies that there
2254
+ * is only one child in the collection.
2255
+ *
2256
+ * See https://reactjs.org/docs/react-api.html#reactchildrenonly
2257
+ *
2258
+ * The current implementation of this function assumes that a single child gets
2259
+ * passed without a wrapper, but the purpose of this helper function is to
2260
+ * abstract away the particular structure of children.
2261
+ *
2262
+ * @param {?object} children Child collection structure.
2263
+ * @return {ReactElement} The first and only `ReactElement` contained in the
2264
+ * structure.
2265
+ */
2266
+
2267
+
2268
+ function onlyChild(children) {
2269
+ if (!isValidElement(children)) {
2270
+ {
2271
+ throw Error( "React.Children.only expected to receive a single React element child." );
2272
+ }
2273
+ }
2274
+
2275
+ return children;
2276
+ }
2277
+
2278
+ function createContext(defaultValue, calculateChangedBits) {
2279
+ if (calculateChangedBits === undefined) {
2280
+ calculateChangedBits = null;
2281
+ } else {
2282
+ {
2283
+ if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') {
2284
+ error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
2285
+ }
2286
+ }
2287
+ }
2288
+
2289
+ var context = {
2290
+ $$typeof: REACT_CONTEXT_TYPE,
2291
+ _calculateChangedBits: calculateChangedBits,
2292
+ // As a workaround to support multiple concurrent renderers, we categorize
2293
+ // some renderers as primary and others as secondary. We only expect
2294
+ // there to be two concurrent renderers at most: React Native (primary) and
2295
+ // Fabric (secondary); React DOM (primary) and React ART (secondary).
2296
+ // Secondary renderers store their context values on separate fields.
2297
+ _currentValue: defaultValue,
2298
+ _currentValue2: defaultValue,
2299
+ // Used to track how many concurrent renderers this context currently
2300
+ // supports within in a single renderer. Such as parallel server rendering.
2301
+ _threadCount: 0,
2302
+ // These are circular
2303
+ Provider: null,
2304
+ Consumer: null
2305
+ };
2306
+ context.Provider = {
2307
+ $$typeof: REACT_PROVIDER_TYPE,
2308
+ _context: context
2309
+ };
2310
+ var hasWarnedAboutUsingNestedContextConsumers = false;
2311
+ var hasWarnedAboutUsingConsumerProvider = false;
2312
+
2313
+ {
2314
+ // A separate object, but proxies back to the original context object for
2315
+ // backwards compatibility. It has a different $$typeof, so we can properly
2316
+ // warn for the incorrect usage of Context as a Consumer.
2317
+ var Consumer = {
2318
+ $$typeof: REACT_CONTEXT_TYPE,
2319
+ _context: context,
2320
+ _calculateChangedBits: context._calculateChangedBits
2321
+ }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
2322
+
2323
+ Object.defineProperties(Consumer, {
2324
+ Provider: {
2325
+ get: function () {
2326
+ if (!hasWarnedAboutUsingConsumerProvider) {
2327
+ hasWarnedAboutUsingConsumerProvider = true;
2328
+
2329
+ error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
2330
+ }
2331
+
2332
+ return context.Provider;
2333
+ },
2334
+ set: function (_Provider) {
2335
+ context.Provider = _Provider;
2336
+ }
2337
+ },
2338
+ _currentValue: {
2339
+ get: function () {
2340
+ return context._currentValue;
2341
+ },
2342
+ set: function (_currentValue) {
2343
+ context._currentValue = _currentValue;
2344
+ }
2345
+ },
2346
+ _currentValue2: {
2347
+ get: function () {
2348
+ return context._currentValue2;
2349
+ },
2350
+ set: function (_currentValue2) {
2351
+ context._currentValue2 = _currentValue2;
2352
+ }
2353
+ },
2354
+ _threadCount: {
2355
+ get: function () {
2356
+ return context._threadCount;
2357
+ },
2358
+ set: function (_threadCount) {
2359
+ context._threadCount = _threadCount;
2360
+ }
2361
+ },
2362
+ Consumer: {
2363
+ get: function () {
2364
+ if (!hasWarnedAboutUsingNestedContextConsumers) {
2365
+ hasWarnedAboutUsingNestedContextConsumers = true;
2366
+
2367
+ error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
2368
+ }
2369
+
2370
+ return context.Consumer;
2371
+ }
2372
+ }
2373
+ }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
2374
+
2375
+ context.Consumer = Consumer;
2376
+ }
2377
+
2378
+ {
2379
+ context._currentRenderer = null;
2380
+ context._currentRenderer2 = null;
2381
+ }
2382
+
2383
+ return context;
2384
+ }
2385
+
2386
+ function lazy(ctor) {
2387
+ var lazyType = {
2388
+ $$typeof: REACT_LAZY_TYPE,
2389
+ _ctor: ctor,
2390
+ // React uses these fields to store the result.
2391
+ _status: -1,
2392
+ _result: null
2393
+ };
2394
+
2395
+ {
2396
+ // In production, this would just set it on the object.
2397
+ var defaultProps;
2398
+ var propTypes;
2399
+ Object.defineProperties(lazyType, {
2400
+ defaultProps: {
2401
+ configurable: true,
2402
+ get: function () {
2403
+ return defaultProps;
2404
+ },
2405
+ set: function (newDefaultProps) {
2406
+ error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
2407
+
2408
+ defaultProps = newDefaultProps; // Match production behavior more closely:
2409
+
2410
+ Object.defineProperty(lazyType, 'defaultProps', {
2411
+ enumerable: true
2412
+ });
2413
+ }
2414
+ },
2415
+ propTypes: {
2416
+ configurable: true,
2417
+ get: function () {
2418
+ return propTypes;
2419
+ },
2420
+ set: function (newPropTypes) {
2421
+ error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
2422
+
2423
+ propTypes = newPropTypes; // Match production behavior more closely:
2424
+
2425
+ Object.defineProperty(lazyType, 'propTypes', {
2426
+ enumerable: true
2427
+ });
2428
+ }
2429
+ }
2430
+ });
2431
+ }
2432
+
2433
+ return lazyType;
2434
+ }
2435
+
2436
+ function forwardRef(render) {
2437
+ {
2438
+ if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
2439
+ error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
2440
+ } else if (typeof render !== 'function') {
2441
+ error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
2442
+ } else {
2443
+ if (render.length !== 0 && render.length !== 2) {
2444
+ error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.');
2445
+ }
2446
+ }
2447
+
2448
+ if (render != null) {
2449
+ if (render.defaultProps != null || render.propTypes != null) {
2450
+ error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');
2451
+ }
2452
+ }
2453
+ }
2454
+
2455
+ return {
2456
+ $$typeof: REACT_FORWARD_REF_TYPE,
2457
+ render: render
2458
+ };
2459
+ }
2460
+
2461
+ function isValidElementType(type) {
2462
+ return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2463
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
2464
+ }
2465
+
2466
+ function memo(type, compare) {
2467
+ {
2468
+ if (!isValidElementType(type)) {
2469
+ error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
2470
+ }
2471
+ }
2472
+
2473
+ return {
2474
+ $$typeof: REACT_MEMO_TYPE,
2475
+ type: type,
2476
+ compare: compare === undefined ? null : compare
2477
+ };
2478
+ }
2479
+
2480
+ function resolveDispatcher() {
2481
+ var dispatcher = ReactCurrentDispatcher.current;
2482
+
2483
+ if (!(dispatcher !== null)) {
2484
+ {
2485
+ throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." );
2486
+ }
2487
+ }
2488
+
2489
+ return dispatcher;
2490
+ }
2491
+
2492
+ function useContext(Context, unstable_observedBits) {
2493
+ var dispatcher = resolveDispatcher();
2494
+
2495
+ {
2496
+ if (unstable_observedBits !== undefined) {
2497
+ error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '');
2498
+ } // TODO: add a more generic warning for invalid values.
2499
+
2500
+
2501
+ if (Context._context !== undefined) {
2502
+ var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
2503
+ // and nobody should be using this in existing code.
2504
+
2505
+ if (realContext.Consumer === Context) {
2506
+ error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
2507
+ } else if (realContext.Provider === Context) {
2508
+ error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
2509
+ }
2510
+ }
2511
+ }
2512
+
2513
+ return dispatcher.useContext(Context, unstable_observedBits);
2514
+ }
2515
+ function useState(initialState) {
2516
+ var dispatcher = resolveDispatcher();
2517
+ return dispatcher.useState(initialState);
2518
+ }
2519
+ function useReducer(reducer, initialArg, init) {
2520
+ var dispatcher = resolveDispatcher();
2521
+ return dispatcher.useReducer(reducer, initialArg, init);
2522
+ }
2523
+ function useRef(initialValue) {
2524
+ var dispatcher = resolveDispatcher();
2525
+ return dispatcher.useRef(initialValue);
2526
+ }
2527
+ function useEffect(create, deps) {
2528
+ var dispatcher = resolveDispatcher();
2529
+ return dispatcher.useEffect(create, deps);
2530
+ }
2531
+ function useLayoutEffect(create, deps) {
2532
+ var dispatcher = resolveDispatcher();
2533
+ return dispatcher.useLayoutEffect(create, deps);
2534
+ }
2535
+ function useCallback(callback, deps) {
2536
+ var dispatcher = resolveDispatcher();
2537
+ return dispatcher.useCallback(callback, deps);
2538
+ }
2539
+ function useMemo(create, deps) {
2540
+ var dispatcher = resolveDispatcher();
2541
+ return dispatcher.useMemo(create, deps);
2542
+ }
2543
+ function useImperativeHandle(ref, create, deps) {
2544
+ var dispatcher = resolveDispatcher();
2545
+ return dispatcher.useImperativeHandle(ref, create, deps);
2546
+ }
2547
+ function useDebugValue(value, formatterFn) {
2548
+ {
2549
+ var dispatcher = resolveDispatcher();
2550
+ return dispatcher.useDebugValue(value, formatterFn);
2551
+ }
2552
+ }
2553
+
2554
+ var propTypesMisspellWarningShown;
2555
+
2556
+ {
2557
+ propTypesMisspellWarningShown = false;
2558
+ }
2559
+
2560
+ function getDeclarationErrorAddendum() {
2561
+ if (ReactCurrentOwner.current) {
2562
+ var name = getComponentName(ReactCurrentOwner.current.type);
2563
+
2564
+ if (name) {
2565
+ return '\n\nCheck the render method of `' + name + '`.';
2566
+ }
2567
+ }
2568
+
2569
+ return '';
2570
+ }
2571
+
2572
+ function getSourceInfoErrorAddendum(source) {
2573
+ if (source !== undefined) {
2574
+ var fileName = source.fileName.replace(/^.*[\\\/]/, '');
2575
+ var lineNumber = source.lineNumber;
2576
+ return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
2577
+ }
2578
+
2579
+ return '';
2580
+ }
2581
+
2582
+ function getSourceInfoErrorAddendumForProps(elementProps) {
2583
+ if (elementProps !== null && elementProps !== undefined) {
2584
+ return getSourceInfoErrorAddendum(elementProps.__source);
2585
+ }
2586
+
2587
+ return '';
2588
+ }
2589
+ /**
2590
+ * Warn if there's no key explicitly set on dynamic arrays of children or
2591
+ * object keys are not valid. This allows us to keep track of children between
2592
+ * updates.
2593
+ */
2594
+
2595
+
2596
+ var ownerHasKeyUseWarning = {};
2597
+
2598
+ function getCurrentComponentErrorInfo(parentType) {
2599
+ var info = getDeclarationErrorAddendum();
2600
+
2601
+ if (!info) {
2602
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
2603
+
2604
+ if (parentName) {
2605
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
2606
+ }
2607
+ }
2608
+
2609
+ return info;
2610
+ }
2611
+ /**
2612
+ * Warn if the element doesn't have an explicit key assigned to it.
2613
+ * This element is in an array. The array could grow and shrink or be
2614
+ * reordered. All children that haven't already been validated are required to
2615
+ * have a "key" property assigned to it. Error statuses are cached so a warning
2616
+ * will only be shown once.
2617
+ *
2618
+ * @internal
2619
+ * @param {ReactElement} element Element that requires a key.
2620
+ * @param {*} parentType element's parent's type.
2621
+ */
2622
+
2623
+
2624
+ function validateExplicitKey(element, parentType) {
2625
+ if (!element._store || element._store.validated || element.key != null) {
2626
+ return;
2627
+ }
2628
+
2629
+ element._store.validated = true;
2630
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
2631
+
2632
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
2633
+ return;
2634
+ }
2635
+
2636
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
2637
+ // property, it may be the creator of the child that's responsible for
2638
+ // assigning it a key.
2639
+
2640
+ var childOwner = '';
2641
+
2642
+ if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2643
+ // Give the component that originally created this child.
2644
+ childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
2645
+ }
2646
+
2647
+ setCurrentlyValidatingElement(element);
2648
+
2649
+ {
2650
+ error('Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
2651
+ }
2652
+
2653
+ setCurrentlyValidatingElement(null);
2654
+ }
2655
+ /**
2656
+ * Ensure that every element either is passed in a static location, in an
2657
+ * array with an explicit keys property defined, or in an object literal
2658
+ * with valid key property.
2659
+ *
2660
+ * @internal
2661
+ * @param {ReactNode} node Statically passed child of any type.
2662
+ * @param {*} parentType node's parent's type.
2663
+ */
2664
+
2665
+
2666
+ function validateChildKeys(node, parentType) {
2667
+ if (typeof node !== 'object') {
2668
+ return;
2669
+ }
2670
+
2671
+ if (Array.isArray(node)) {
2672
+ for (var i = 0; i < node.length; i++) {
2673
+ var child = node[i];
2674
+
2675
+ if (isValidElement(child)) {
2676
+ validateExplicitKey(child, parentType);
2677
+ }
2678
+ }
2679
+ } else if (isValidElement(node)) {
2680
+ // This element was passed in a valid location.
2681
+ if (node._store) {
2682
+ node._store.validated = true;
2683
+ }
2684
+ } else if (node) {
2685
+ var iteratorFn = getIteratorFn(node);
2686
+
2687
+ if (typeof iteratorFn === 'function') {
2688
+ // Entry iterators used to provide implicit keys,
2689
+ // but now we print a separate warning for them later.
2690
+ if (iteratorFn !== node.entries) {
2691
+ var iterator = iteratorFn.call(node);
2692
+ var step;
2693
+
2694
+ while (!(step = iterator.next()).done) {
2695
+ if (isValidElement(step.value)) {
2696
+ validateExplicitKey(step.value, parentType);
2697
+ }
2698
+ }
2699
+ }
2700
+ }
2701
+ }
2702
+ }
2703
+ /**
2704
+ * Given an element, validate that its props follow the propTypes definition,
2705
+ * provided by the type.
2706
+ *
2707
+ * @param {ReactElement} element
2708
+ */
2709
+
2710
+
2711
+ function validatePropTypes(element) {
2712
+ {
2713
+ var type = element.type;
2714
+
2715
+ if (type === null || type === undefined || typeof type === 'string') {
2716
+ return;
2717
+ }
2718
+
2719
+ var name = getComponentName(type);
2720
+ var propTypes;
2721
+
2722
+ if (typeof type === 'function') {
2723
+ propTypes = type.propTypes;
2724
+ } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
2725
+ // Inner props are checked in the reconciler.
2726
+ type.$$typeof === REACT_MEMO_TYPE)) {
2727
+ propTypes = type.propTypes;
2728
+ } else {
2729
+ return;
2730
+ }
2731
+
2732
+ if (propTypes) {
2733
+ setCurrentlyValidatingElement(element);
2734
+ checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
2735
+ setCurrentlyValidatingElement(null);
2736
+ } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2737
+ propTypesMisspellWarningShown = true;
2738
+
2739
+ error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
2740
+ }
2741
+
2742
+ if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
2743
+ error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
2744
+ }
2745
+ }
2746
+ }
2747
+ /**
2748
+ * Given a fragment, validate that it can only be provided with fragment props
2749
+ * @param {ReactElement} fragment
2750
+ */
2751
+
2752
+
2753
+ function validateFragmentProps(fragment) {
2754
+ {
2755
+ setCurrentlyValidatingElement(fragment);
2756
+ var keys = Object.keys(fragment.props);
2757
+
2758
+ for (var i = 0; i < keys.length; i++) {
2759
+ var key = keys[i];
2760
+
2761
+ if (key !== 'children' && key !== 'key') {
2762
+ error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
2763
+
2764
+ break;
2765
+ }
2766
+ }
2767
+
2768
+ if (fragment.ref !== null) {
2769
+ error('Invalid attribute `ref` supplied to `React.Fragment`.');
2770
+ }
2771
+
2772
+ setCurrentlyValidatingElement(null);
2773
+ }
2774
+ }
2775
+ function createElementWithValidation(type, props, children) {
2776
+ var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
2777
+ // succeed and there will likely be errors in render.
2778
+
2779
+ if (!validType) {
2780
+ var info = '';
2781
+
2782
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
2783
+ info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
2784
+ }
2785
+
2786
+ var sourceInfo = getSourceInfoErrorAddendumForProps(props);
2787
+
2788
+ if (sourceInfo) {
2789
+ info += sourceInfo;
2790
+ } else {
2791
+ info += getDeclarationErrorAddendum();
2792
+ }
2793
+
2794
+ var typeString;
2795
+
2796
+ if (type === null) {
2797
+ typeString = 'null';
2798
+ } else if (Array.isArray(type)) {
2799
+ typeString = 'array';
2800
+ } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
2801
+ typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
2802
+ info = ' Did you accidentally export a JSX literal instead of a component?';
2803
+ } else {
2804
+ typeString = typeof type;
2805
+ }
2806
+
2807
+ {
2808
+ error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
2809
+ }
2810
+ }
2811
+
2812
+ var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
2813
+ // TODO: Drop this when these are no longer allowed as the type argument.
2814
+
2815
+ if (element == null) {
2816
+ return element;
2817
+ } // Skip key warning if the type isn't valid since our key validation logic
2818
+ // doesn't expect a non-string/function type and can throw confusing errors.
2819
+ // We don't want exception behavior to differ between dev and prod.
2820
+ // (Rendering will throw with a helpful message and as soon as the type is
2821
+ // fixed, the key warnings will appear.)
2822
+
2823
+
2824
+ if (validType) {
2825
+ for (var i = 2; i < arguments.length; i++) {
2826
+ validateChildKeys(arguments[i], type);
2827
+ }
2828
+ }
2829
+
2830
+ if (type === REACT_FRAGMENT_TYPE) {
2831
+ validateFragmentProps(element);
2832
+ } else {
2833
+ validatePropTypes(element);
2834
+ }
2835
+
2836
+ return element;
2837
+ }
2838
+ var didWarnAboutDeprecatedCreateFactory = false;
2839
+ function createFactoryWithValidation(type) {
2840
+ var validatedFactory = createElementWithValidation.bind(null, type);
2841
+ validatedFactory.type = type;
2842
+
2843
+ {
2844
+ if (!didWarnAboutDeprecatedCreateFactory) {
2845
+ didWarnAboutDeprecatedCreateFactory = true;
2846
+
2847
+ warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');
2848
+ } // Legacy hook: remove it
2849
+
2850
+
2851
+ Object.defineProperty(validatedFactory, 'type', {
2852
+ enumerable: false,
2853
+ get: function () {
2854
+ warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
2855
+
2856
+ Object.defineProperty(this, 'type', {
2857
+ value: type
2858
+ });
2859
+ return type;
2860
+ }
2861
+ });
2862
+ }
2863
+
2864
+ return validatedFactory;
2865
+ }
2866
+ function cloneElementWithValidation(element, props, children) {
2867
+ var newElement = cloneElement.apply(this, arguments);
2868
+
2869
+ for (var i = 2; i < arguments.length; i++) {
2870
+ validateChildKeys(arguments[i], newElement.type);
2871
+ }
2872
+
2873
+ validatePropTypes(newElement);
2874
+ return newElement;
2875
+ }
2876
+
2877
+ {
2878
+
2879
+ try {
2880
+ var frozenObject = Object.freeze({});
2881
+ var testMap = new Map([[frozenObject, null]]);
2882
+ var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused.
2883
+ // https://github.com/rollup/rollup/issues/1771
2884
+ // TODO: we can remove these if Rollup fixes the bug.
2885
+
2886
+ testMap.set(0, 0);
2887
+ testSet.add(0);
2888
+ } catch (e) {
2889
+ }
2890
+ }
2891
+
2892
+ var createElement$1 = createElementWithValidation ;
2893
+ var cloneElement$1 = cloneElementWithValidation ;
2894
+ var createFactory = createFactoryWithValidation ;
2895
+ var Children = {
2896
+ map: mapChildren,
2897
+ forEach: forEachChildren,
2898
+ count: countChildren,
2899
+ toArray: toArray,
2900
+ only: onlyChild
2901
+ };
2902
+
2903
+ react_development.Children = Children;
2904
+ react_development.Component = Component;
2905
+ react_development.Fragment = REACT_FRAGMENT_TYPE;
2906
+ react_development.Profiler = REACT_PROFILER_TYPE;
2907
+ react_development.PureComponent = PureComponent;
2908
+ react_development.StrictMode = REACT_STRICT_MODE_TYPE;
2909
+ react_development.Suspense = REACT_SUSPENSE_TYPE;
2910
+ react_development.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
2911
+ react_development.cloneElement = cloneElement$1;
2912
+ react_development.createContext = createContext;
2913
+ react_development.createElement = createElement$1;
2914
+ react_development.createFactory = createFactory;
2915
+ react_development.createRef = createRef;
2916
+ react_development.forwardRef = forwardRef;
2917
+ react_development.isValidElement = isValidElement;
2918
+ react_development.lazy = lazy;
2919
+ react_development.memo = memo;
2920
+ react_development.useCallback = useCallback;
2921
+ react_development.useContext = useContext;
2922
+ react_development.useDebugValue = useDebugValue;
2923
+ react_development.useEffect = useEffect;
2924
+ react_development.useImperativeHandle = useImperativeHandle;
2925
+ react_development.useLayoutEffect = useLayoutEffect;
2926
+ react_development.useMemo = useMemo;
2927
+ react_development.useReducer = useReducer;
2928
+ react_development.useRef = useRef;
2929
+ react_development.useState = useState;
2930
+ react_development.version = ReactVersion;
2931
+ })();
2932
+ }
2933
+ return react_development;
2934
+ }
2935
+
2936
+ (function (module) {
2937
+
2938
+ if (process.env.NODE_ENV === 'production') {
2939
+ module.exports = requireReact_production_min();
2940
+ } else {
2941
+ module.exports = requireReact_development();
2942
+ }
2943
+ } (react));
2944
+
2945
+ var React = /*@__PURE__*/getDefaultExportFromCjs(react.exports);
2946
+
2947
+ const subscribers = new Map();
2948
+ function subscribe(type, callback) {
2949
+ if (type === undefined || type === null)
2950
+ return;
2951
+ if (callback === undefined || callback === null)
2952
+ return;
2953
+ if (!subscribers.has(type))
2954
+ subscribers.set(type, new Set());
2955
+ subscribers.get(type).add(callback);
2956
+ }
2957
+ function unsubscribe(type, callback) {
2958
+ if (!subscribers.has(type))
2959
+ return;
2960
+ if (callback === undefined || callback === null)
2961
+ return;
2962
+ subscribers.get(type).delete(callback);
2963
+ if (subscribers.get(type).size === 0)
2964
+ subscribers.delete(type);
2965
+ }
2966
+ function isAction(actionOrType) {
2967
+ return typeof actionOrType !== 'string';
2968
+ }
2969
+ function dispatch(actionOrType) {
2970
+ const action = isAction(actionOrType) ? actionOrType : { type: actionOrType };
2971
+ if (!subscribers.has(action.type))
2972
+ return;
2973
+ // if we use set without conversion to array
2974
+ // subscribers.get(type).forEach
2975
+ // it stucks if it has two same functions
2976
+ // tested on notification counter at home screen
2977
+ // It is not clear why it happens,
2978
+ // conversion to array did a trick
2979
+ // however it may only hide a real problem.
2980
+ const data = Array.from(subscribers.get(action.type));
2981
+ data.forEach((callback) => {
2982
+ callback(action);
2983
+ });
2984
+ }
2985
+ function useBus(type, callback, deps) {
2986
+ // eslint-disable-next-line react-hooks/rules-of-hooks
2987
+ react.exports.useEffect(() => {
2988
+ subscribe(type, callback);
2989
+ return () => {
2990
+ unsubscribe(type, callback);
2991
+ };
2992
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2993
+ }, deps);
2994
+ return dispatch;
2995
+ }
2996
+ function createBus() {
2997
+ const useBusTyped = useBus;
2998
+ const dispatchTyped = dispatch;
2999
+ return {
3000
+ useBus: useBusTyped,
3001
+ dispatch: dispatchTyped,
3002
+ };
3003
+ }
3004
+ // Example of usage
3005
+ // interface Inc {
3006
+ // type: 'inc';
3007
+ // }
3008
+ // interface Dec {
3009
+ // type: 'dec';
3010
+ // value: number;
3011
+ // }
3012
+ // type Event = Inc | Dec;
3013
+ // const b = createBus<Event>();
3014
+ // // ok
3015
+ // b.dispatch({ type: 'inc' });
3016
+ // b.dispatch('inc');
3017
+ // b.dispatch({ type: 'dec', value: 1 });
3018
+ // b.useBus('inc', () => {}, []);
3019
+ // b.useBus('dec', () => {}, []);
3020
+ // // error
3021
+ // b.dispatch({ type: 'dec' });
3022
+ // b.dispatch('dec');
3023
+ // b.dispatch({ type: 'foo' });
3024
+ // b.useBus('__super_error__', () => {}, []);
3025
+
3026
+ function useService(asyncFunction, deps = []) {
3027
+ const [remoteData, setRemoteData] = react.exports.useState(notAsked);
3028
+ const [reloadsCount, setReloadsCount] = react.exports.useState(0);
3029
+ const reload = react.exports.useCallback(() => setReloadsCount((x) => x + 1), []);
3030
+ const load = react.exports.useCallback(() => __awaiter(this, void 0, void 0, function* () {
3031
+ try {
3032
+ return yield asyncFunction();
3033
+ }
3034
+ catch (err) {
3035
+ return failure(err.response ? err.response.data : err.message);
3036
+ }
3037
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3038
+ }), deps);
3039
+ const softReloadAsync = react.exports.useCallback(() => __awaiter(this, void 0, void 0, function* () {
3040
+ const response = yield load();
3041
+ setRemoteData(response);
3042
+ return response;
3043
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3044
+ }), [...deps, load]);
3045
+ const reloadAsync = react.exports.useCallback(() => __awaiter(this, void 0, void 0, function* () {
3046
+ setRemoteData(loading);
3047
+ const response = yield load();
3048
+ setRemoteData(response);
3049
+ return response;
3050
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3051
+ }), [...deps, load]);
3052
+ react.exports.useEffect(() => {
3053
+ (() => __awaiter(this, void 0, void 0, function* () {
3054
+ setRemoteData(loading);
3055
+ setRemoteData(yield load());
3056
+ }))();
3057
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3058
+ }, [...deps, reloadsCount, load]);
3059
+ const set = react.exports.useCallback((dataOrFn) => {
3060
+ if (typeof dataOrFn === 'function') {
3061
+ setRemoteData((rd) => (isSuccess(rd) ? success(dataOrFn(rd.data)) : rd));
3062
+ }
3063
+ else {
3064
+ setRemoteData(success(dataOrFn));
3065
+ }
3066
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3067
+ }, deps);
3068
+ const manager = react.exports.useMemo(() => ({
3069
+ reload,
3070
+ reloadAsync,
3071
+ softReloadAsync,
3072
+ set,
3073
+ }), [reload, reloadAsync, softReloadAsync, set]);
3074
+ return [remoteData, manager];
3075
+ }
3076
+
3077
+ function useCRUD(resourceType, id, getOrCreate, defaultResource) {
3078
+ const [remoteData, setRemoteData] = react.exports.useState(notAsked);
3079
+ const makeDefaultResource = react.exports.useCallback(() => (Object.assign(Object.assign({ resourceType }, (id && getOrCreate ? { id } : {})), defaultResource)), [resourceType, defaultResource, id, getOrCreate]);
3080
+ react.exports.useEffect(() => {
3081
+ (() => __awaiter(this, void 0, void 0, function* () {
3082
+ if (id) {
3083
+ setRemoteData(loading);
3084
+ const response = yield getFHIRResource(makeReference(resourceType, id));
3085
+ if (isFailure(response) && getOrCreate) {
3086
+ setRemoteData(success(makeDefaultResource()));
3087
+ }
3088
+ else {
3089
+ setRemoteData(response);
3090
+ }
3091
+ }
3092
+ else {
3093
+ setRemoteData(success(makeDefaultResource()));
3094
+ }
3095
+ }))();
3096
+ }, [getOrCreate, id, makeDefaultResource, resourceType]);
3097
+ return [
3098
+ remoteData,
3099
+ {
3100
+ handleSave: (updatedResource, relatedResources) => __awaiter(this, void 0, void 0, function* () {
3101
+ // Why do we need relatedResource here?
3102
+ // TODO refactor
3103
+ setRemoteData(loading);
3104
+ if (relatedResources && relatedResources.length) {
3105
+ const bundleResponse = yield saveFHIRResources([updatedResource, ...relatedResources], 'transaction');
3106
+ if (isSuccess(bundleResponse)) {
3107
+ const extracted = extractBundleResources(bundleResponse.data);
3108
+ if (extracted) {
3109
+ const resource = success(extracted[resourceType][0]);
3110
+ setRemoteData(resource);
3111
+ return resource;
3112
+ }
3113
+ else {
3114
+ return failure({ message: 'empty response from server' });
3115
+ }
3116
+ }
3117
+ else {
3118
+ setRemoteData(bundleResponse);
3119
+ return bundleResponse;
3120
+ }
3121
+ }
3122
+ else {
3123
+ const response = yield saveFHIRResource(updatedResource);
3124
+ setRemoteData(response);
3125
+ return response;
3126
+ }
3127
+ }),
3128
+ handleDelete: (resourceToDelete) => __awaiter(this, void 0, void 0, function* () {
3129
+ setRemoteData(loading);
3130
+ setRemoteData(yield deleteFHIRResource(getReference(resourceToDelete)));
3131
+ }),
3132
+ },
3133
+ ];
3134
+ }
3135
+
3136
+ class SharedStateInitializationError extends Error {
3137
+ constructor(message) {
3138
+ super(message);
3139
+ }
3140
+ }
3141
+ function createSharedState(initial) {
3142
+ const uniqBus = uuid4();
3143
+ const { useBus, dispatch } = createBus();
3144
+ let mutableState = initial;
3145
+ const setter = (s) => {
3146
+ mutableState = s;
3147
+ dispatch({ type: uniqBus, s });
3148
+ };
3149
+ return {
3150
+ setSharedState: setter,
3151
+ getSharedState: () => {
3152
+ if (typeof mutableState === 'undefined') {
3153
+ throw new SharedStateInitializationError();
3154
+ }
3155
+ return mutableState;
3156
+ },
3157
+ useSharedState: () => {
3158
+ const [state, setState] = react.exports.useState(mutableState);
3159
+ if (typeof state === 'undefined') {
3160
+ throw new SharedStateInitializationError();
3161
+ }
3162
+ useBus(uniqBus, ({ s }) => {
3163
+ setState(s);
3164
+ }, [setState]);
3165
+ return [state, setter];
3166
+ },
3167
+ };
3168
+ }
3169
+
3170
+ function usePager(resourceType, resourcesOnPage = 15, searchParams = {}) {
3171
+ var _a;
3172
+ const [pageToLoad, setPageToLoad] = react.exports.useState((_a = searchParams._page) !== null && _a !== void 0 ? _a : 1);
3173
+ const [reloadsCount, setReloadsCount] = react.exports.useState(0);
3174
+ const [resources] = useService(() => getFHIRResources(resourceType, Object.assign(Object.assign({}, searchParams), { _count: resourcesOnPage, _page: pageToLoad })), [pageToLoad, reloadsCount, resourcesOnPage]);
3175
+ const hasNext = react.exports.useMemo(() => { var _a; return (isSuccess(resources) ? Boolean((_a = resources.data.link) === null || _a === void 0 ? void 0 : _a.some((link) => link.relation === 'next')) : false); }, [resources]);
3176
+ const hasPrevious = react.exports.useMemo(() => { var _a; return isSuccess(resources) ? Boolean((_a = resources.data.link) === null || _a === void 0 ? void 0 : _a.some((link) => link.relation === 'previous')) : false; }, [resources]);
3177
+ const loadNext = react.exports.useCallback(() => setPageToLoad((currentPage) => currentPage + 1), []);
3178
+ const loadPrevious = react.exports.useCallback(() => setPageToLoad((currentPage) => (hasPrevious ? currentPage - 1 : currentPage)), [hasPrevious]);
3179
+ const reload = react.exports.useCallback(() => {
3180
+ setPageToLoad(1);
3181
+ setReloadsCount((c) => c + 1);
3182
+ }, []);
3183
+ return [
3184
+ resources,
3185
+ {
3186
+ loadNext,
3187
+ loadPrevious,
3188
+ loadPage: setPageToLoad,
3189
+ reload,
3190
+ hasNext,
3191
+ hasPrevious,
3192
+ currentPage: pageToLoad,
3193
+ },
3194
+ ];
3195
+ }
3196
+
3197
+ function renderFailureDefault(error) {
3198
+ return React.createElement(React.Fragment, null, formatError(error));
3199
+ }
3200
+ function renderLoadingDefault() {
3201
+ return React.createElement(React.Fragment, null, "Loading...");
3202
+ }
3203
+ function RenderRemoteData(props) {
3204
+ const { remoteData, children, renderFailure, renderLoading, renderNotAsked } = props;
3205
+ if (isNotAsked(remoteData)) {
3206
+ return renderNotAsked ? renderNotAsked() : null;
3207
+ }
3208
+ else if (isLoading(remoteData)) {
3209
+ return (renderLoading !== null && renderLoading !== void 0 ? renderLoading : renderLoadingDefault)();
3210
+ }
3211
+ else if (isFailure(remoteData)) {
3212
+ return (renderFailure !== null && renderFailure !== void 0 ? renderFailure : renderFailureDefault)(remoteData.error);
3213
+ }
3214
+ else if (isSuccess(remoteData)) {
3215
+ return children(remoteData.data);
3216
+ }
3217
+ else {
3218
+ const n = remoteData;
3219
+ throw new Error(n);
3220
+ }
3221
+ }
3222
+ function withRender(config) {
3223
+ return function (props) {
3224
+ return React.createElement(RenderRemoteData, Object.assign({}, config, props));
3225
+ };
3226
+ }
3227
+
3228
+ exports.FHIRDateFormat = FHIRDateFormat;
3229
+ exports.FHIRDateTimeFormat = FHIRDateTimeFormat;
3230
+ exports.FHIRTimeFormat = FHIRTimeFormat;
3231
+ exports.RenderRemoteData = RenderRemoteData;
3232
+ exports.SharedStateInitializationError = SharedStateInitializationError;
3233
+ exports.applyDataTransformer = applyDataTransformer;
3234
+ exports.applyErrorTransformer = applyErrorTransformer;
3235
+ exports.applyFHIRService = applyFHIRService;
3236
+ exports.applyFHIRServices = applyFHIRServices;
3237
+ exports.axiosInstance = axiosInstance;
3238
+ exports.buildQueryParams = buildQueryParams;
3239
+ exports.create = create;
3240
+ exports.createBus = createBus;
3241
+ exports.createFHIRResource = createFHIRResource;
3242
+ exports.createSharedState = createSharedState;
3243
+ exports.deleteFHIRResource = deleteFHIRResource;
3244
+ exports.ensure = ensure;
3245
+ exports.extractBundleResources = extractBundleResources;
3246
+ exports.extractErrorCode = extractErrorCode;
3247
+ exports.extractErrorDescription = extractErrorDescription;
3248
+ exports.extractFHIRDate = extractFHIRDate;
3249
+ exports.extractFHIRTime = extractFHIRTime;
3250
+ exports.failure = failure;
3251
+ exports.findFHIRResource = findFHIRResource;
3252
+ exports.forceDelete = forceDelete;
3253
+ exports.forceDeleteFHIRResource = forceDeleteFHIRResource;
3254
+ exports.formatError = formatError;
3255
+ exports.formatFHIRDate = formatFHIRDate;
3256
+ exports.formatFHIRDateTime = formatFHIRDateTime;
3257
+ exports.formatFHIRTime = formatFHIRTime;
3258
+ exports.get = get;
3259
+ exports.getAllFHIRResources = getAllFHIRResources;
3260
+ exports.getConcepts = getConcepts;
3261
+ exports.getFHIRResource = getFHIRResource;
3262
+ exports.getFHIRResources = getFHIRResources;
3263
+ exports.getIncludedResource = getIncludedResource;
3264
+ exports.getIncludedResources = getIncludedResources;
3265
+ exports.getMainResources = getMainResources;
3266
+ exports.getReference = getReference;
3267
+ exports.getToken = getToken;
3268
+ exports.getUserInfo = getUserInfo;
3269
+ exports.investigate = investigate;
3270
+ exports.isBackendError = isBackendError;
3271
+ exports.isFHIRDateEqual = isFHIRDateEqual;
3272
+ exports.isFailure = isFailure;
3273
+ exports.isFailureAny = isFailureAny;
3274
+ exports.isLoading = isLoading;
3275
+ exports.isLoadingAny = isLoadingAny;
3276
+ exports.isNotAsked = isNotAsked;
3277
+ exports.isNotAskedAny = isNotAskedAny;
3278
+ exports.isOperationOutcome = isOperationOutcome;
3279
+ exports.isReference = isReference;
3280
+ exports.isSuccess = isSuccess;
3281
+ exports.isSuccessAll = isSuccessAll;
3282
+ exports.list = list;
3283
+ exports.loading = loading;
3284
+ exports.login = login;
3285
+ exports.makeFHIRDateTime = makeFHIRDateTime;
3286
+ exports.makeReference = makeReference;
3287
+ exports.mapFailure = mapFailure;
3288
+ exports.mapSuccess = mapSuccess;
3289
+ exports.markAsDeleted = markAsDeleted;
3290
+ exports.notAsked = notAsked;
3291
+ exports.parseFHIRDate = parseFHIRDate;
3292
+ exports.parseFHIRDateTime = parseFHIRDateTime;
3293
+ exports.parseFHIRTime = parseFHIRTime;
3294
+ exports.patch = patch;
3295
+ exports.patchFHIRResource = patchFHIRResource;
3296
+ exports.resetInstanceToken = resetInstanceToken;
3297
+ exports.resolveArray = resolveArray;
3298
+ exports.resolveMap = resolveMap;
3299
+ exports.resolveServiceMap = resolveServiceMap;
3300
+ exports.save = save;
3301
+ exports.saveFHIRResource = saveFHIRResource;
3302
+ exports.saveFHIRResources = saveFHIRResources;
3303
+ exports.sequenceArray = sequenceArray;
3304
+ exports.sequenceMap = sequenceMap;
3305
+ exports.service = service;
3306
+ exports.setInstanceBaseURL = setInstanceBaseURL;
3307
+ exports.setInstanceToken = setInstanceToken;
3308
+ exports.success = success;
3309
+ exports.transformToBundleEntry = transformToBundleEntry;
3310
+ exports.update = update;
3311
+ exports.updateFHIRResource = updateFHIRResource;
3312
+ exports.useCRUD = useCRUD;
3313
+ exports.usePager = usePager;
3314
+ exports.useService = useService;
3315
+ exports.uuid4 = uuid4;
3316
+ exports.withRender = withRender;
3317
+ exports.withRootAccess = withRootAccess;