@bigbinary/neeto-commons-frontend 1.0.9

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.
@@ -0,0 +1,822 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+ var ramda = require('ramda');
5
+ var i18next = require('i18next');
6
+ var dayjs = require('dayjs');
7
+ var relativeTime = require('dayjs/plugin/relativeTime');
8
+ var updateLocale = require('dayjs/plugin/updateLocale');
9
+ var mixpanel = require('mixpanel-browser');
10
+ var reactI18next = require('react-i18next');
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
15
+ var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
16
+ var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
17
+ var relativeTime__default = /*#__PURE__*/_interopDefaultLegacy(relativeTime);
18
+ var updateLocale__default = /*#__PURE__*/_interopDefaultLegacy(updateLocale);
19
+ var mixpanel__default = /*#__PURE__*/_interopDefaultLegacy(mixpanel);
20
+
21
+ var HEADERS_KEYS = {
22
+ xAuthEmail: "X-Auth-Email",
23
+ xAuthToken: "X-Auth-Token",
24
+ xCsrfToken: "X-CSRF-TOKEN"
25
+ };
26
+
27
+ var resetAuthTokens = function resetAuthTokens() {
28
+ ramda.values(HEADERS_KEYS).forEach(function (header) {
29
+ delete axios__default["default"].defaults.headers[header];
30
+ });
31
+ };
32
+
33
+ function _arrayWithHoles(arr) {
34
+ if (Array.isArray(arr)) return arr;
35
+ }
36
+
37
+ function _iterableToArrayLimit(arr, i) {
38
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
39
+
40
+ if (_i == null) return;
41
+ var _arr = [];
42
+ var _n = true;
43
+ var _d = false;
44
+
45
+ var _s, _e;
46
+
47
+ try {
48
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
49
+ _arr.push(_s.value);
50
+
51
+ if (i && _arr.length === i) break;
52
+ }
53
+ } catch (err) {
54
+ _d = true;
55
+ _e = err;
56
+ } finally {
57
+ try {
58
+ if (!_n && _i["return"] != null) _i["return"]();
59
+ } finally {
60
+ if (_d) throw _e;
61
+ }
62
+ }
63
+
64
+ return _arr;
65
+ }
66
+
67
+ function _arrayLikeToArray(arr, len) {
68
+ if (len == null || len > arr.length) len = arr.length;
69
+
70
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
71
+ arr2[i] = arr[i];
72
+ }
73
+
74
+ return arr2;
75
+ }
76
+
77
+ function _unsupportedIterableToArray(o, minLen) {
78
+ if (!o) return;
79
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
80
+ var n = Object.prototype.toString.call(o).slice(8, -1);
81
+ if (n === "Object" && o.constructor) n = o.constructor.name;
82
+ if (n === "Map" || n === "Set") return Array.from(o);
83
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
84
+ }
85
+
86
+ function _nonIterableRest() {
87
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
88
+ }
89
+
90
+ function _slicedToArray(arr, i) {
91
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
92
+ }
93
+
94
+ function _typeof$1(obj) {
95
+ "@babel/helpers - typeof";
96
+
97
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
98
+ return typeof obj;
99
+ } : function (obj) {
100
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
101
+ }, _typeof$1(obj);
102
+ }
103
+
104
+ var snakeToCamelCase = function snakeToCamelCase(string) {
105
+ return string.replace(/(_\w)/g, function (letter) {
106
+ return letter[1].toUpperCase();
107
+ });
108
+ };
109
+ var camelToSnakeCase = function camelToSnakeCase(string) {
110
+ return string.replace(/[A-Z]/g, function (letter) {
111
+ return "_".concat(letter.toLowerCase());
112
+ });
113
+ };
114
+
115
+ var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
116
+ if (Array.isArray(object)) {
117
+ return object.map(function (obj) {
118
+ return transformObjectDeep(obj, keyValueTransformer);
119
+ });
120
+ } else if (object === null || _typeof$1(object) !== "object") {
121
+ return object;
122
+ }
123
+
124
+ return Object.fromEntries(Object.entries(object).map(function (_ref) {
125
+ var _ref2 = _slicedToArray(_ref, 2),
126
+ key = _ref2[0],
127
+ value = _ref2[1];
128
+
129
+ return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
130
+ }));
131
+ };
132
+ var keysToCamelCase = function keysToCamelCase(object) {
133
+ return transformObjectDeep(object, function (key, value) {
134
+ return [snakeToCamelCase(key), value];
135
+ });
136
+ };
137
+ var keysToSnakeCase = function keysToSnakeCase(object) {
138
+ return transformObjectDeep(object, function (key, value) {
139
+ return [camelToSnakeCase(key), value];
140
+ });
141
+ };
142
+ var deepFreezeObject = function deepFreezeObject(object) {
143
+ if (object && _typeof$1(object) === "object" && !Object.isFrozen(object)) {
144
+ Object.keys(object).forEach(function (property) {
145
+ return deepFreezeObject(object[property]);
146
+ });
147
+ Object.freeze(object);
148
+ }
149
+
150
+ return object;
151
+ };
152
+ var matches = ramda.curry(function (pattern, object) {
153
+ if (object === pattern) return true;
154
+ if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
155
+ if (_typeof$1(pattern) !== "object") return false;
156
+ return Object.entries(pattern).every(function (_ref3) {
157
+ var _ref4 = _slicedToArray(_ref3, 2),
158
+ key = _ref4[0],
159
+ value = _ref4[1];
160
+
161
+ return matches(value, object[key]);
162
+ });
163
+ });
164
+
165
+ function _defineProperty(obj, key, value) {
166
+ if (key in obj) {
167
+ Object.defineProperty(obj, key, {
168
+ value: value,
169
+ enumerable: true,
170
+ configurable: true,
171
+ writable: true
172
+ });
173
+ } else {
174
+ obj[key] = value;
175
+ }
176
+
177
+ return obj;
178
+ }
179
+
180
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
181
+
182
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
183
+ ramda.curry(function (id, array) {
184
+ return array.filter(function (item) {
185
+ return item.id !== id;
186
+ });
187
+ });
188
+ ramda.curry(function (id, array) {
189
+ return array.find(function (item) {
190
+ return item.id === id;
191
+ });
192
+ });
193
+ ramda.curry(function (id, newItem, array) {
194
+ return array.map(function (item) {
195
+ return item.id === id ? newItem : item;
196
+ });
197
+ });
198
+ ramda.curry(function (id, modifier, array) {
199
+ return array.map(function (item) {
200
+ return item.id === id ? modifier(item) : item;
201
+ });
202
+ });
203
+ ramda.curry(function (pattern, array) {
204
+ return array.find(matches(pattern));
205
+ });
206
+ ramda.curry(function (pattern, array) {
207
+ return array.filter(ramda.complement(matches(pattern)));
208
+ });
209
+ ramda.curry(function (pattern, newItem, array) {
210
+ return array.map(function (item) {
211
+ return matches(pattern, item) ? newItem : item;
212
+ });
213
+ });
214
+ ramda.curry(function (pattern, modifier, array) {
215
+ return array.map(function (item) {
216
+ return matches(pattern, item) ? modifier(item) : item;
217
+ });
218
+ });
219
+ ramda.curry(function (id, array) {
220
+ return array.some(function (item) {
221
+ return item.id === id;
222
+ });
223
+ });
224
+ ramda.curry(function (pattern, array) {
225
+ return array.some(matches(pattern));
226
+ });
227
+ ramda.curry(function (keyMap, objectArray) {
228
+ return objectArray.map(function (object) {
229
+ return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref) {
230
+ var _ref2 = _slicedToArray(_ref, 2),
231
+ key = _ref2[0],
232
+ value = _ref2[1];
233
+
234
+ return [value, object[key]];
235
+ })));
236
+ });
237
+ });
238
+ ramda.curry(function (keyMap, objectArray) {
239
+ return objectArray.map(function (object) {
240
+ return _objectSpread(_objectSpread({}, ramda.omit(ramda.keys(keyMap), object)), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref3) {
241
+ var _ref4 = _slicedToArray(_ref3, 2),
242
+ source = _ref4[0],
243
+ destination = _ref4[1];
244
+
245
+ return [destination, object[source]];
246
+ })));
247
+ });
248
+ });
249
+ ramda.curry(function (keyMap, objectArray) {
250
+ var copyKeysSingleObject = function copyKeysSingleObject(object, keyMap) {
251
+ var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
252
+ return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref5) {
253
+ var _ref6 = _slicedToArray(_ref5, 2),
254
+ destination = _ref6[0],
255
+ source = _ref6[1];
256
+
257
+ if (typeof source === "function") {
258
+ return [destination, source(object[destination], root)];
259
+ } else if (Array.isArray(source)) {
260
+ return [destination, ramda.path(source, root)];
261
+ } else if (_typeof$1(source) === "object") {
262
+ return [destination, copyKeysSingleObject(object[destination], source, root)];
263
+ }
264
+
265
+ return [destination, object[source]];
266
+ })));
267
+ };
268
+
269
+ return objectArray.map(function (object) {
270
+ return copyKeysSingleObject(object, keyMap);
271
+ });
272
+ });
273
+
274
+ var regeneratorRuntime$1 = {exports: {}};
275
+
276
+ var _typeof = {exports: {}};
277
+
278
+ (function (module) {
279
+ function _typeof(obj) {
280
+ "@babel/helpers - typeof";
281
+
282
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
283
+ return typeof obj;
284
+ } : function (obj) {
285
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
286
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
287
+ }
288
+
289
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
290
+ } (_typeof));
291
+
292
+ (function (module) {
293
+ var _typeof$1 = _typeof.exports["default"];
294
+
295
+ function _regeneratorRuntime() {
296
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
297
+
298
+ module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
299
+ return exports;
300
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
301
+ var exports = {},
302
+ Op = Object.prototype,
303
+ hasOwn = Op.hasOwnProperty,
304
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
305
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
306
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
307
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
308
+
309
+ function define(obj, key, value) {
310
+ return Object.defineProperty(obj, key, {
311
+ value: value,
312
+ enumerable: !0,
313
+ configurable: !0,
314
+ writable: !0
315
+ }), obj[key];
316
+ }
317
+
318
+ try {
319
+ define({}, "");
320
+ } catch (err) {
321
+ define = function define(obj, key, value) {
322
+ return obj[key] = value;
323
+ };
324
+ }
325
+
326
+ function wrap(innerFn, outerFn, self, tryLocsList) {
327
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
328
+ generator = Object.create(protoGenerator.prototype),
329
+ context = new Context(tryLocsList || []);
330
+ return generator._invoke = function (innerFn, self, context) {
331
+ var state = "suspendedStart";
332
+ return function (method, arg) {
333
+ if ("executing" === state) throw new Error("Generator is already running");
334
+
335
+ if ("completed" === state) {
336
+ if ("throw" === method) throw arg;
337
+ return doneResult();
338
+ }
339
+
340
+ for (context.method = method, context.arg = arg;;) {
341
+ var delegate = context.delegate;
342
+
343
+ if (delegate) {
344
+ var delegateResult = maybeInvokeDelegate(delegate, context);
345
+
346
+ if (delegateResult) {
347
+ if (delegateResult === ContinueSentinel) continue;
348
+ return delegateResult;
349
+ }
350
+ }
351
+
352
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
353
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
354
+ context.dispatchException(context.arg);
355
+ } else "return" === context.method && context.abrupt("return", context.arg);
356
+ state = "executing";
357
+ var record = tryCatch(innerFn, self, context);
358
+
359
+ if ("normal" === record.type) {
360
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
361
+ return {
362
+ value: record.arg,
363
+ done: context.done
364
+ };
365
+ }
366
+
367
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
368
+ }
369
+ };
370
+ }(innerFn, self, context), generator;
371
+ }
372
+
373
+ function tryCatch(fn, obj, arg) {
374
+ try {
375
+ return {
376
+ type: "normal",
377
+ arg: fn.call(obj, arg)
378
+ };
379
+ } catch (err) {
380
+ return {
381
+ type: "throw",
382
+ arg: err
383
+ };
384
+ }
385
+ }
386
+
387
+ exports.wrap = wrap;
388
+ var ContinueSentinel = {};
389
+
390
+ function Generator() {}
391
+
392
+ function GeneratorFunction() {}
393
+
394
+ function GeneratorFunctionPrototype() {}
395
+
396
+ var IteratorPrototype = {};
397
+ define(IteratorPrototype, iteratorSymbol, function () {
398
+ return this;
399
+ });
400
+ var getProto = Object.getPrototypeOf,
401
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
402
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
403
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
404
+
405
+ function defineIteratorMethods(prototype) {
406
+ ["next", "throw", "return"].forEach(function (method) {
407
+ define(prototype, method, function (arg) {
408
+ return this._invoke(method, arg);
409
+ });
410
+ });
411
+ }
412
+
413
+ function AsyncIterator(generator, PromiseImpl) {
414
+ function invoke(method, arg, resolve, reject) {
415
+ var record = tryCatch(generator[method], generator, arg);
416
+
417
+ if ("throw" !== record.type) {
418
+ var result = record.arg,
419
+ value = result.value;
420
+ return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
421
+ invoke("next", value, resolve, reject);
422
+ }, function (err) {
423
+ invoke("throw", err, resolve, reject);
424
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
425
+ result.value = unwrapped, resolve(result);
426
+ }, function (error) {
427
+ return invoke("throw", error, resolve, reject);
428
+ });
429
+ }
430
+
431
+ reject(record.arg);
432
+ }
433
+
434
+ var previousPromise;
435
+
436
+ this._invoke = function (method, arg) {
437
+ function callInvokeWithMethodAndArg() {
438
+ return new PromiseImpl(function (resolve, reject) {
439
+ invoke(method, arg, resolve, reject);
440
+ });
441
+ }
442
+
443
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
444
+ };
445
+ }
446
+
447
+ function maybeInvokeDelegate(delegate, context) {
448
+ var method = delegate.iterator[context.method];
449
+
450
+ if (undefined === method) {
451
+ if (context.delegate = null, "throw" === context.method) {
452
+ if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
453
+ context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
454
+ }
455
+
456
+ return ContinueSentinel;
457
+ }
458
+
459
+ var record = tryCatch(method, delegate.iterator, context.arg);
460
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
461
+ var info = record.arg;
462
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
463
+ }
464
+
465
+ function pushTryEntry(locs) {
466
+ var entry = {
467
+ tryLoc: locs[0]
468
+ };
469
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
470
+ }
471
+
472
+ function resetTryEntry(entry) {
473
+ var record = entry.completion || {};
474
+ record.type = "normal", delete record.arg, entry.completion = record;
475
+ }
476
+
477
+ function Context(tryLocsList) {
478
+ this.tryEntries = [{
479
+ tryLoc: "root"
480
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
481
+ }
482
+
483
+ function values(iterable) {
484
+ if (iterable) {
485
+ var iteratorMethod = iterable[iteratorSymbol];
486
+ if (iteratorMethod) return iteratorMethod.call(iterable);
487
+ if ("function" == typeof iterable.next) return iterable;
488
+
489
+ if (!isNaN(iterable.length)) {
490
+ var i = -1,
491
+ next = function next() {
492
+ for (; ++i < iterable.length;) {
493
+ if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
494
+ }
495
+
496
+ return next.value = undefined, next.done = !0, next;
497
+ };
498
+
499
+ return next.next = next;
500
+ }
501
+ }
502
+
503
+ return {
504
+ next: doneResult
505
+ };
506
+ }
507
+
508
+ function doneResult() {
509
+ return {
510
+ value: undefined,
511
+ done: !0
512
+ };
513
+ }
514
+
515
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
516
+ var ctor = "function" == typeof genFun && genFun.constructor;
517
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
518
+ }, exports.mark = function (genFun) {
519
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
520
+ }, exports.awrap = function (arg) {
521
+ return {
522
+ __await: arg
523
+ };
524
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
525
+ return this;
526
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
527
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
528
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
529
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
530
+ return result.done ? result.value : iter.next();
531
+ });
532
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
533
+ return this;
534
+ }), define(Gp, "toString", function () {
535
+ return "[object Generator]";
536
+ }), exports.keys = function (object) {
537
+ var keys = [];
538
+
539
+ for (var key in object) {
540
+ keys.push(key);
541
+ }
542
+
543
+ return keys.reverse(), function next() {
544
+ for (; keys.length;) {
545
+ var key = keys.pop();
546
+ if (key in object) return next.value = key, next.done = !1, next;
547
+ }
548
+
549
+ return next.done = !0, next;
550
+ };
551
+ }, exports.values = values, Context.prototype = {
552
+ constructor: Context,
553
+ reset: function reset(skipTempReset) {
554
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
555
+ "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
556
+ }
557
+ },
558
+ stop: function stop() {
559
+ this.done = !0;
560
+ var rootRecord = this.tryEntries[0].completion;
561
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
562
+ return this.rval;
563
+ },
564
+ dispatchException: function dispatchException(exception) {
565
+ if (this.done) throw exception;
566
+ var context = this;
567
+
568
+ function handle(loc, caught) {
569
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
570
+ }
571
+
572
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
573
+ var entry = this.tryEntries[i],
574
+ record = entry.completion;
575
+ if ("root" === entry.tryLoc) return handle("end");
576
+
577
+ if (entry.tryLoc <= this.prev) {
578
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
579
+ hasFinally = hasOwn.call(entry, "finallyLoc");
580
+
581
+ if (hasCatch && hasFinally) {
582
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
583
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
584
+ } else if (hasCatch) {
585
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
586
+ } else {
587
+ if (!hasFinally) throw new Error("try statement without catch or finally");
588
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
589
+ }
590
+ }
591
+ }
592
+ },
593
+ abrupt: function abrupt(type, arg) {
594
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
595
+ var entry = this.tryEntries[i];
596
+
597
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
598
+ var finallyEntry = entry;
599
+ break;
600
+ }
601
+ }
602
+
603
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
604
+ var record = finallyEntry ? finallyEntry.completion : {};
605
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
606
+ },
607
+ complete: function complete(record, afterLoc) {
608
+ if ("throw" === record.type) throw record.arg;
609
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
610
+ },
611
+ finish: function finish(finallyLoc) {
612
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
613
+ var entry = this.tryEntries[i];
614
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
615
+ }
616
+ },
617
+ "catch": function _catch(tryLoc) {
618
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
619
+ var entry = this.tryEntries[i];
620
+
621
+ if (entry.tryLoc === tryLoc) {
622
+ var record = entry.completion;
623
+
624
+ if ("throw" === record.type) {
625
+ var thrown = record.arg;
626
+ resetTryEntry(entry);
627
+ }
628
+
629
+ return thrown;
630
+ }
631
+ }
632
+
633
+ throw new Error("illegal catch attempt");
634
+ },
635
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
636
+ return this.delegate = {
637
+ iterator: values(iterable),
638
+ resultName: resultName,
639
+ nextLoc: nextLoc
640
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
641
+ }
642
+ }, exports;
643
+ }
644
+
645
+ module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
646
+ } (regeneratorRuntime$1));
647
+
648
+ // TODO(Babel 8): Remove this file.
649
+
650
+ var runtime = regeneratorRuntime$1.exports();
651
+
652
+ // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
653
+ try {
654
+ regeneratorRuntime = runtime;
655
+ } catch (accidentalStrictMode) {
656
+ if (typeof globalThis === "object") {
657
+ globalThis.regeneratorRuntime = runtime;
658
+ } else {
659
+ Function("r", "regeneratorRuntime = r")(runtime);
660
+ }
661
+ }
662
+
663
+ ramda.curry(function (func, event) {
664
+ return func(event.target.value);
665
+ });
666
+
667
+ dayjs__default["default"].extend(relativeTime__default["default"]);
668
+ dayjs__default["default"].extend(updateLocale__default["default"]);
669
+
670
+ var _document$getElements, _document$getElements2;
671
+ window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
672
+ deepFreezeObject(window.globalProps);
673
+
674
+ var setAxiosDefaults = function setAxiosDefaults() {
675
+ axios__default["default"].defaults.baseURL = "/";
676
+ setAuthHeaders();
677
+ registerIntercepts();
678
+ };
679
+
680
+ var setAuthHeaders = function setAuthHeaders() {
681
+ var _globalProps$user, _globalProps$user2;
682
+
683
+ axios__default["default"].defaults.headers = _defineProperty({
684
+ Accept: "application/json",
685
+ "Content-Type": "application/json"
686
+ }, HEADERS_KEYS.xCsrfToken, document.querySelector('[name="csrf-token"]').getAttribute("content"));
687
+ var token = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.authenticationToken;
688
+ var email = (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email;
689
+
690
+ if (token && email) {
691
+ axios__default["default"].defaults.headers[HEADERS_KEYS.xAuthEmail] = email;
692
+ axios__default["default"].defaults.headers[HEADERS_KEYS.xAuthToken] = token;
693
+ }
694
+ };
695
+
696
+ var handleSuccessResponse = function handleSuccessResponse(response) {
697
+ var _response$config = response.config,
698
+ _response$config$tran = _response$config.transformResponseCase,
699
+ transformResponseCase = _response$config$tran === void 0 ? true : _response$config$tran,
700
+ _response$config$incl = _response$config.includeMetadataInResponse,
701
+ includeMetadataInResponse = _response$config$incl === void 0 ? false : _response$config$incl;
702
+
703
+ if (transformResponseCase && response.data) {
704
+ response.data = keysToCamelCase(response.data);
705
+ }
706
+
707
+ return includeMetadataInResponse ? response : response.data;
708
+ };
709
+
710
+ var handleErrorResponse = function handleErrorResponse(error) {
711
+ var _error$response, _error$response2;
712
+
713
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 404) {
714
+ window.location.href = "/page-not-found";
715
+ } else if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 401) {
716
+ resetAuthTokens();
717
+ setTimeout(function () {
718
+ var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
719
+ window.location.href = redirectTo;
720
+ }, 300);
721
+ }
722
+
723
+ return Promise.reject(error);
724
+ };
725
+
726
+ var cleanupCredentialsForCrossOrigin = function cleanupCredentialsForCrossOrigin(request) {
727
+ if (!request.url.includes("://")) return request;
728
+ if (request.url.includes(window.location.hostname)) return request;
729
+ return ramda.evolve({
730
+ headers: ramda.omit(ramda.values(HEADERS_KEYS))
731
+ })(request);
732
+ };
733
+
734
+ var transformDataToSnakeCase = function transformDataToSnakeCase(request) {
735
+ var _request$transformReq = request.transformRequestCase,
736
+ transformRequestCase = _request$transformReq === void 0 ? true : _request$transformReq;
737
+ if (!transformRequestCase || !request.data) return request;
738
+ return ramda.evolve({
739
+ data: keysToSnakeCase
740
+ })(request);
741
+ };
742
+
743
+ var registerIntercepts = function registerIntercepts() {
744
+ axios__default["default"].interceptors.request.use(ramda.pipe(cleanupCredentialsForCrossOrigin, transformDataToSnakeCase));
745
+ axios__default["default"].interceptors.response.use(handleSuccessResponse, handleErrorResponse);
746
+ };
747
+
748
+ setAxiosDefaults();
749
+
750
+ var isProduction = process.env.NODE_ENV === "production";
751
+ var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
752
+ var isUserLoggedIn = !ramda.either(ramda.isEmpty, ramda.isNil)(globalProps.user);
753
+
754
+ if (isProduction && isTokenPresent && isUserLoggedIn) {
755
+ mixpanel__default["default"].init(process.env.MIXPANEL_TOKEN);
756
+ mixpanel__default["default"].people.set({
757
+ $email: globalProps.user.email,
758
+ $fist_name: globalProps.user.firstName,
759
+ $last_name: globalProps.user.lastName
760
+ });
761
+ mixpanel__default["default"].identify(globalProps.user.email);
762
+ } else {
763
+ /*
764
+ We need to initialize mixpanel with a bogus token in development and test environment to
765
+ prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
766
+ */
767
+ mixpanel__default["default"].init("TEST_TOKEN");
768
+ }
769
+
770
+ var neetoCommons = {
771
+ errorPage: {
772
+ pageDoesNotExist: "Page does not exist.",
773
+ goToHome: "Go home"
774
+ },
775
+ sidebar: {
776
+ profile: "Profile",
777
+ orgSettings: "Organization Settings",
778
+ logout: "Logout",
779
+ help: "Help"
780
+ },
781
+ common: {
782
+ actions: {
783
+ cancel: "Cancel",
784
+ save: "Save"
785
+ }
786
+ },
787
+ toastr: {
788
+ success: {
789
+ copiedToClipboard: "Copied to clipboard!"
790
+ }
791
+ },
792
+ notice: {
793
+ errorOccurred: "Some error occurred."
794
+ }
795
+ };
796
+ var en = {
797
+ neetoCommons: neetoCommons
798
+ };
799
+
800
+ var initializeI18n = function initializeI18n(resources) {
801
+ i18next__default["default"].use(reactI18next.initReactI18next).init({
802
+ resources: ramda.mergeDeepLeft({
803
+ en: {
804
+ translation: en
805
+ }
806
+ }, resources),
807
+ lng: "en",
808
+ fallbackLng: "en",
809
+ interpolation: {
810
+ escapeValue: false,
811
+ skipOnVariables: false
812
+ }
813
+ });
814
+ };
815
+
816
+ /* eslint-disable import/order */
817
+ function initializeApplication(_ref) {
818
+ var translationResources = _ref.translationResources;
819
+ initializeI18n(translationResources);
820
+ }
821
+
822
+ module.exports = initializeApplication;