@bigbinary/neeto-commons-frontend 2.0.87 → 2.0.89

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.
package/react-utils.js CHANGED
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { useEffect, useState, useDebugValue, useRef, useMemo } from 'react';
3
3
  import { Honeybadger, HoneybadgerErrorBoundary as HoneybadgerErrorBoundary$1 } from '@honeybadger-io/react';
4
4
  import { Typography, Button } from '@bigbinary/neetoui';
5
- import { isNil, includes, __, prop, toPairs, mergeLeft, isEmpty, omit, curry, keys } from 'ramda';
5
+ import { isNil, includes, __, prop, toPairs, mergeLeft, curry, keys, isEmpty, mergeDeepLeft, path, omit } from 'ramda';
6
6
  import { useTranslation, Trans } from 'react-i18next';
7
7
  import ErrorPage from '@bigbinary/neeto-molecules/ErrorPage';
8
8
  import { Route, Redirect } from 'react-router-dom';
@@ -3454,18 +3454,6 @@ var usePrevious = function usePrevious(value) {
3454
3454
  return ref.current;
3455
3455
  };
3456
3456
 
3457
- var useStateWithDependency = function useStateWithDependency(defaultValue) {
3458
- var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [defaultValue];
3459
- var _useState = useState(defaultValue),
3460
- _useState2 = _slicedToArray(_useState, 2),
3461
- value = _useState2[0],
3462
- setValue = _useState2[1];
3463
- useEffect(function () {
3464
- setValue(defaultValue);
3465
- }, dependencies);
3466
- return [value, setValue];
3467
- };
3468
-
3469
3457
  function _typeof$1(obj) {
3470
3458
  "@babel/helpers - typeof";
3471
3459
 
@@ -3507,582 +3495,53 @@ function _defineProperty(obj, key, value) {
3507
3495
  return obj;
3508
3496
  }
3509
3497
 
3510
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
3511
- // require the crypto API and do not support built-in fallback to lower quality random number
3512
- // generators (like Math.random()).
3513
- let getRandomValues;
3514
- const rnds8 = new Uint8Array(16);
3515
- function rng() {
3516
- // lazy load so that environments that need to polyfill have a chance to do so
3517
- if (!getRandomValues) {
3518
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
3519
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
3520
-
3521
- if (!getRandomValues) {
3522
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
3523
- }
3524
- }
3525
-
3526
- return getRandomValues(rnds8);
3527
- }
3528
-
3529
- var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
3530
-
3531
- function validate(uuid) {
3532
- return typeof uuid === 'string' && REGEX.test(uuid);
3533
- }
3534
-
3535
- /**
3536
- * Convert array of 16 byte values to UUID string format of the form:
3537
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
3538
- */
3539
-
3540
- const byteToHex = [];
3541
-
3542
- for (let i = 0; i < 256; ++i) {
3543
- byteToHex.push((i + 0x100).toString(16).slice(1));
3544
- }
3545
-
3546
- function unsafeStringify(arr, offset = 0) {
3547
- // Note: Be careful editing this code! It's been tuned for performance
3548
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
3549
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
3550
- }
3551
-
3552
- function parse(uuid) {
3553
- if (!validate(uuid)) {
3554
- throw TypeError('Invalid UUID');
3498
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
3499
+ try {
3500
+ var info = gen[key](arg);
3501
+ var value = info.value;
3502
+ } catch (error) {
3503
+ reject(error);
3504
+ return;
3555
3505
  }
3556
-
3557
- let v;
3558
- const arr = new Uint8Array(16); // Parse ########-....-....-....-............
3559
-
3560
- arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
3561
- arr[1] = v >>> 16 & 0xff;
3562
- arr[2] = v >>> 8 & 0xff;
3563
- arr[3] = v & 0xff; // Parse ........-####-....-....-............
3564
-
3565
- arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
3566
- arr[5] = v & 0xff; // Parse ........-....-####-....-............
3567
-
3568
- arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
3569
- arr[7] = v & 0xff; // Parse ........-....-....-####-............
3570
-
3571
- arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
3572
- arr[9] = v & 0xff; // Parse ........-....-....-....-############
3573
- // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
3574
-
3575
- arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
3576
- arr[11] = v / 0x100000000 & 0xff;
3577
- arr[12] = v >>> 24 & 0xff;
3578
- arr[13] = v >>> 16 & 0xff;
3579
- arr[14] = v >>> 8 & 0xff;
3580
- arr[15] = v & 0xff;
3581
- return arr;
3582
- }
3583
-
3584
- function stringToBytes(str) {
3585
- str = unescape(encodeURIComponent(str)); // UTF8 escape
3586
-
3587
- const bytes = [];
3588
-
3589
- for (let i = 0; i < str.length; ++i) {
3590
- bytes.push(str.charCodeAt(i));
3506
+ if (info.done) {
3507
+ resolve(value);
3508
+ } else {
3509
+ Promise.resolve(value).then(_next, _throw);
3591
3510
  }
3592
-
3593
- return bytes;
3594
3511
  }
3595
-
3596
- const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
3597
- const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
3598
- function v35(name, version, hashfunc) {
3599
- function generateUUID(value, namespace, buf, offset) {
3600
- var _namespace;
3601
-
3602
- if (typeof value === 'string') {
3603
- value = stringToBytes(value);
3604
- }
3605
-
3606
- if (typeof namespace === 'string') {
3607
- namespace = parse(namespace);
3608
- }
3609
-
3610
- if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
3611
- throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
3612
- } // Compute hash of namespace and value, Per 4.3
3613
- // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
3614
- // hashfunc([...namespace, ... value])`
3615
-
3616
-
3617
- let bytes = new Uint8Array(16 + value.length);
3618
- bytes.set(namespace);
3619
- bytes.set(value, namespace.length);
3620
- bytes = hashfunc(bytes);
3621
- bytes[6] = bytes[6] & 0x0f | version;
3622
- bytes[8] = bytes[8] & 0x3f | 0x80;
3623
-
3624
- if (buf) {
3625
- offset = offset || 0;
3626
-
3627
- for (let i = 0; i < 16; ++i) {
3628
- buf[offset + i] = bytes[i];
3512
+ function _asyncToGenerator(fn) {
3513
+ return function () {
3514
+ var self = this,
3515
+ args = arguments;
3516
+ return new Promise(function (resolve, reject) {
3517
+ var gen = fn.apply(self, args);
3518
+ function _next(value) {
3519
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
3629
3520
  }
3630
-
3631
- return buf;
3632
- }
3633
-
3634
- return unsafeStringify(bytes);
3635
- } // Function#name is not settable on some platforms (#270)
3636
-
3637
-
3638
- try {
3639
- generateUUID.name = name; // eslint-disable-next-line no-empty
3640
- } catch (err) {} // For CommonJS default export support
3641
-
3642
-
3643
- generateUUID.DNS = DNS;
3644
- generateUUID.URL = URL;
3645
- return generateUUID;
3646
- }
3647
-
3648
- /*
3649
- * Browser-compatible JavaScript MD5
3650
- *
3651
- * Modification of JavaScript MD5
3652
- * https://github.com/blueimp/JavaScript-MD5
3653
- *
3654
- * Copyright 2011, Sebastian Tschan
3655
- * https://blueimp.net
3656
- *
3657
- * Licensed under the MIT license:
3658
- * https://opensource.org/licenses/MIT
3659
- *
3660
- * Based on
3661
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
3662
- * Digest Algorithm, as defined in RFC 1321.
3663
- * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
3664
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
3665
- * Distributed under the BSD License
3666
- * See http://pajhome.org.uk/crypt/md5 for more info.
3667
- */
3668
- function md5(bytes) {
3669
- if (typeof bytes === 'string') {
3670
- const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
3671
-
3672
- bytes = new Uint8Array(msg.length);
3673
-
3674
- for (let i = 0; i < msg.length; ++i) {
3675
- bytes[i] = msg.charCodeAt(i);
3676
- }
3677
- }
3678
-
3679
- return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
3680
- }
3681
- /*
3682
- * Convert an array of little-endian words to an array of bytes
3683
- */
3684
-
3685
-
3686
- function md5ToHexEncodedArray(input) {
3687
- const output = [];
3688
- const length32 = input.length * 32;
3689
- const hexTab = '0123456789abcdef';
3690
-
3691
- for (let i = 0; i < length32; i += 8) {
3692
- const x = input[i >> 5] >>> i % 32 & 0xff;
3693
- const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
3694
- output.push(hex);
3695
- }
3696
-
3697
- return output;
3521
+ function _throw(err) {
3522
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
3523
+ }
3524
+ _next(undefined);
3525
+ });
3526
+ };
3698
3527
  }
3699
- /**
3700
- * Calculate output length with padding and bit length
3701
- */
3702
3528
 
3529
+ var regeneratorRuntime$1 = {exports: {}};
3703
3530
 
3704
- function getOutputLength(inputLength8) {
3705
- return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
3706
- }
3707
- /*
3708
- * Calculate the MD5 of an array of little-endian words, and a bit length.
3709
- */
3531
+ var _typeof = {exports: {}};
3710
3532
 
3533
+ (function (module) {
3534
+ function _typeof(obj) {
3535
+ "@babel/helpers - typeof";
3711
3536
 
3712
- function wordsToMd5(x, len) {
3713
- /* append padding */
3714
- x[len >> 5] |= 0x80 << len % 32;
3715
- x[getOutputLength(len) - 1] = len;
3716
- let a = 1732584193;
3717
- let b = -271733879;
3718
- let c = -1732584194;
3719
- let d = 271733878;
3720
-
3721
- for (let i = 0; i < x.length; i += 16) {
3722
- const olda = a;
3723
- const oldb = b;
3724
- const oldc = c;
3725
- const oldd = d;
3726
- a = md5ff(a, b, c, d, x[i], 7, -680876936);
3727
- d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
3728
- c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
3729
- b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
3730
- a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
3731
- d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
3732
- c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
3733
- b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
3734
- a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
3735
- d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
3736
- c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
3737
- b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
3738
- a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
3739
- d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
3740
- c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
3741
- b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
3742
- a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
3743
- d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
3744
- c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
3745
- b = md5gg(b, c, d, a, x[i], 20, -373897302);
3746
- a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
3747
- d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
3748
- c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
3749
- b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
3750
- a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
3751
- d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
3752
- c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
3753
- b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
3754
- a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
3755
- d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
3756
- c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
3757
- b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
3758
- a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
3759
- d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
3760
- c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
3761
- b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
3762
- a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
3763
- d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
3764
- c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
3765
- b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
3766
- a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
3767
- d = md5hh(d, a, b, c, x[i], 11, -358537222);
3768
- c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
3769
- b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
3770
- a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
3771
- d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
3772
- c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
3773
- b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
3774
- a = md5ii(a, b, c, d, x[i], 6, -198630844);
3775
- d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
3776
- c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
3777
- b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
3778
- a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
3779
- d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
3780
- c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
3781
- b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
3782
- a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
3783
- d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
3784
- c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
3785
- b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
3786
- a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
3787
- d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
3788
- c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
3789
- b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
3790
- a = safeAdd(a, olda);
3791
- b = safeAdd(b, oldb);
3792
- c = safeAdd(c, oldc);
3793
- d = safeAdd(d, oldd);
3794
- }
3795
-
3796
- return [a, b, c, d];
3797
- }
3798
- /*
3799
- * Convert an array bytes to an array of little-endian words
3800
- * Characters >255 have their high-byte silently ignored.
3801
- */
3802
-
3803
-
3804
- function bytesToWords(input) {
3805
- if (input.length === 0) {
3806
- return [];
3807
- }
3808
-
3809
- const length8 = input.length * 8;
3810
- const output = new Uint32Array(getOutputLength(length8));
3811
-
3812
- for (let i = 0; i < length8; i += 8) {
3813
- output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
3814
- }
3815
-
3816
- return output;
3817
- }
3818
- /*
3819
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
3820
- * to work around bugs in some JS interpreters.
3821
- */
3822
-
3823
-
3824
- function safeAdd(x, y) {
3825
- const lsw = (x & 0xffff) + (y & 0xffff);
3826
- const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
3827
- return msw << 16 | lsw & 0xffff;
3828
- }
3829
- /*
3830
- * Bitwise rotate a 32-bit number to the left.
3831
- */
3832
-
3833
-
3834
- function bitRotateLeft(num, cnt) {
3835
- return num << cnt | num >>> 32 - cnt;
3836
- }
3837
- /*
3838
- * These functions implement the four basic operations the algorithm uses.
3839
- */
3840
-
3841
-
3842
- function md5cmn(q, a, b, x, s, t) {
3843
- return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
3844
- }
3845
-
3846
- function md5ff(a, b, c, d, x, s, t) {
3847
- return md5cmn(b & c | ~b & d, a, b, x, s, t);
3848
- }
3849
-
3850
- function md5gg(a, b, c, d, x, s, t) {
3851
- return md5cmn(b & d | c & ~d, a, b, x, s, t);
3852
- }
3853
-
3854
- function md5hh(a, b, c, d, x, s, t) {
3855
- return md5cmn(b ^ c ^ d, a, b, x, s, t);
3856
- }
3857
-
3858
- function md5ii(a, b, c, d, x, s, t) {
3859
- return md5cmn(c ^ (b | ~d), a, b, x, s, t);
3860
- }
3861
-
3862
- v35('v3', 0x30, md5);
3863
-
3864
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
3865
- var native = {
3866
- randomUUID
3867
- };
3868
-
3869
- function v4(options, buf, offset) {
3870
- if (native.randomUUID && !buf && !options) {
3871
- return native.randomUUID();
3872
- }
3873
-
3874
- options = options || {};
3875
- const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
3876
-
3877
- rnds[6] = rnds[6] & 0x0f | 0x40;
3878
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
3879
-
3880
- if (buf) {
3881
- offset = offset || 0;
3882
-
3883
- for (let i = 0; i < 16; ++i) {
3884
- buf[offset + i] = rnds[i];
3885
- }
3886
-
3887
- return buf;
3888
- }
3889
-
3890
- return unsafeStringify(rnds);
3891
- }
3892
-
3893
- // Adapted from Chris Veness' SHA1 code at
3894
- // http://www.movable-type.co.uk/scripts/sha1.html
3895
- function f(s, x, y, z) {
3896
- switch (s) {
3897
- case 0:
3898
- return x & y ^ ~x & z;
3899
-
3900
- case 1:
3901
- return x ^ y ^ z;
3902
-
3903
- case 2:
3904
- return x & y ^ x & z ^ y & z;
3905
-
3906
- case 3:
3907
- return x ^ y ^ z;
3908
- }
3909
- }
3910
-
3911
- function ROTL(x, n) {
3912
- return x << n | x >>> 32 - n;
3913
- }
3914
-
3915
- function sha1(bytes) {
3916
- const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
3917
- const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
3918
-
3919
- if (typeof bytes === 'string') {
3920
- const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
3921
-
3922
- bytes = [];
3923
-
3924
- for (let i = 0; i < msg.length; ++i) {
3925
- bytes.push(msg.charCodeAt(i));
3926
- }
3927
- } else if (!Array.isArray(bytes)) {
3928
- // Convert Array-like to Array
3929
- bytes = Array.prototype.slice.call(bytes);
3930
- }
3931
-
3932
- bytes.push(0x80);
3933
- const l = bytes.length / 4 + 2;
3934
- const N = Math.ceil(l / 16);
3935
- const M = new Array(N);
3936
-
3937
- for (let i = 0; i < N; ++i) {
3938
- const arr = new Uint32Array(16);
3939
-
3940
- for (let j = 0; j < 16; ++j) {
3941
- arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
3942
- }
3943
-
3944
- M[i] = arr;
3945
- }
3946
-
3947
- M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
3948
- M[N - 1][14] = Math.floor(M[N - 1][14]);
3949
- M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
3950
-
3951
- for (let i = 0; i < N; ++i) {
3952
- const W = new Uint32Array(80);
3953
-
3954
- for (let t = 0; t < 16; ++t) {
3955
- W[t] = M[i][t];
3956
- }
3957
-
3958
- for (let t = 16; t < 80; ++t) {
3959
- W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
3960
- }
3961
-
3962
- let a = H[0];
3963
- let b = H[1];
3964
- let c = H[2];
3965
- let d = H[3];
3966
- let e = H[4];
3967
-
3968
- for (let t = 0; t < 80; ++t) {
3969
- const s = Math.floor(t / 20);
3970
- const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
3971
- e = d;
3972
- d = c;
3973
- c = ROTL(b, 30) >>> 0;
3974
- b = a;
3975
- a = T;
3976
- }
3977
-
3978
- H[0] = H[0] + a >>> 0;
3979
- H[1] = H[1] + b >>> 0;
3980
- H[2] = H[2] + c >>> 0;
3981
- H[3] = H[3] + d >>> 0;
3982
- H[4] = H[4] + e >>> 0;
3983
- }
3984
-
3985
- return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
3986
- }
3987
-
3988
- v35('v5', 0x50, sha1);
3989
-
3990
- var useTimerStore = create$1(function () {
3991
- return {};
3992
- });
3993
- setInterval(function () {
3994
- var currentState = useTimerStore.getState();
3995
- var nextState = {};
3996
- var now = Date.now();
3997
- for (var key in currentState) {
3998
- var _currentState$key = currentState[key],
3999
- lastUpdated = _currentState$key.lastUpdated,
4000
- interval = _currentState$key.interval;
4001
- var shouldUpdate = now - lastUpdated >= interval;
4002
- if (shouldUpdate) nextState[key] = {
4003
- lastUpdated: now,
4004
- interval: interval
4005
- };
4006
- }
4007
- if (!isEmpty(nextState)) useTimerStore.setState(nextState);
4008
- }, 1000);
4009
- var useTimer = function useTimer() {
4010
- var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 60;
4011
- var key = useMemo(function () {
4012
- return v4();
4013
- }, []);
4014
- useEffect(function () {
4015
- useTimerStore.setState(_defineProperty({}, key, {
4016
- lastUpdated: Date.now(),
4017
- interval: 1000 * interval // convert seconds to ms
4018
- }));
4019
-
4020
- return function () {
4021
- return useTimerStore.setState(omit([key], useTimerStore.getState()), true);
4022
- };
4023
- }, [interval, key]);
4024
- return useTimerStore(prop(key));
4025
- };
4026
-
4027
- var useUpdateEffect = function useUpdateEffect(callback) {
4028
- var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
4029
- var isInitialMount = useRef(true);
4030
- useEffect(function () {
4031
- if (isInitialMount.current) {
4032
- isInitialMount.current = false;
4033
- return;
4034
- }
4035
- callback();
4036
- }, dependencies);
4037
- };
4038
-
4039
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4040
- try {
4041
- var info = gen[key](arg);
4042
- var value = info.value;
4043
- } catch (error) {
4044
- reject(error);
4045
- return;
4046
- }
4047
- if (info.done) {
4048
- resolve(value);
4049
- } else {
4050
- Promise.resolve(value).then(_next, _throw);
4051
- }
4052
- }
4053
- function _asyncToGenerator(fn) {
4054
- return function () {
4055
- var self = this,
4056
- args = arguments;
4057
- return new Promise(function (resolve, reject) {
4058
- var gen = fn.apply(self, args);
4059
- function _next(value) {
4060
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
4061
- }
4062
- function _throw(err) {
4063
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
4064
- }
4065
- _next(undefined);
4066
- });
4067
- };
4068
- }
4069
-
4070
- var regeneratorRuntime$1 = {exports: {}};
4071
-
4072
- var _typeof = {exports: {}};
4073
-
4074
- (function (module) {
4075
- function _typeof(obj) {
4076
- "@babel/helpers - typeof";
4077
-
4078
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
4079
- return typeof obj;
4080
- } : function (obj) {
4081
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
4082
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
4083
- }
4084
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
4085
- } (_typeof));
3537
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
3538
+ return typeof obj;
3539
+ } : function (obj) {
3540
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
3541
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
3542
+ }
3543
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
3544
+ } (_typeof));
4086
3545
 
4087
3546
  (function (module) {
4088
3547
  var _typeof$1 = _typeof.exports["default"];
@@ -4390,304 +3849,863 @@ var _typeof = {exports: {}};
4390
3849
  module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
4391
3850
  } (regeneratorRuntime$1));
4392
3851
 
4393
- // TODO(Babel 8): Remove this file.
3852
+ // TODO(Babel 8): Remove this file.
3853
+
3854
+ var runtime = regeneratorRuntime$1.exports();
3855
+ var regenerator = runtime;
3856
+
3857
+ // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
3858
+ try {
3859
+ regeneratorRuntime = runtime;
3860
+ } catch (accidentalStrictMode) {
3861
+ if (typeof globalThis === "object") {
3862
+ globalThis.regeneratorRuntime = runtime;
3863
+ } else {
3864
+ Function("r", "regeneratorRuntime = r")(runtime);
3865
+ }
3866
+ }
3867
+
3868
+ // THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
3869
+ var devicesBaseUrl = "/neeto_notifications/api/v1/devices";
3870
+ var create = function create(payload) {
3871
+ return axios.post(devicesBaseUrl, payload);
3872
+ };
3873
+ var destroy = function destroy(deviceId) {
3874
+ return axios["delete"]("".concat(devicesBaseUrl, "/").concat(deviceId));
3875
+ };
3876
+ var devicesApi = {
3877
+ create: create,
3878
+ destroy: destroy
3879
+ };
3880
+
3881
+ // THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
3882
+ // AND IS USED FOR BROWSER NOTIFICATIONS
3883
+ // CONTACT NEETO NOTIFICATIONS TEAM BEFORE MODIFYING THIS FILE
3884
+
3885
+ function urlB64ToUint8Array(base64String) {
3886
+ var padding = "=".repeat((4 - base64String.length % 4) % 4);
3887
+ var base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
3888
+ var rawData = window.atob(base64);
3889
+ var outputArray = new Uint8Array(rawData.length);
3890
+ for (var i = 0; i < rawData.length; ++i) {
3891
+ outputArray[i] = rawData.charCodeAt(i);
3892
+ }
3893
+ return outputArray;
3894
+ }
3895
+ var subscribeBrowserNotifications = /*#__PURE__*/function () {
3896
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(vapidPublicKey) {
3897
+ var subscription, permission, sw;
3898
+ return regenerator.wrap(function _callee$(_context) {
3899
+ while (1) switch (_context.prev = _context.next) {
3900
+ case 0:
3901
+ subscription = {};
3902
+ _context.prev = 1;
3903
+ _context.next = 4;
3904
+ return Notification.requestPermission();
3905
+ case 4:
3906
+ permission = _context.sent;
3907
+ if (!(permission !== "denied")) {
3908
+ _context.next = 15;
3909
+ break;
3910
+ }
3911
+ _context.next = 8;
3912
+ return navigator.serviceWorker.register("/serviceworker.js");
3913
+ case 8:
3914
+ _context.next = 10;
3915
+ return navigator.serviceWorker.ready;
3916
+ case 10:
3917
+ sw = _context.sent;
3918
+ _context.next = 13;
3919
+ return sw.pushManager.subscribe({
3920
+ userVisibleOnly: true,
3921
+ applicationServerKey: urlB64ToUint8Array(vapidPublicKey)
3922
+ });
3923
+ case 13:
3924
+ subscription = _context.sent;
3925
+ return _context.abrupt("return", subscription);
3926
+ case 15:
3927
+ logger.error("Notification Permission Denied");
3928
+ _context.next = 21;
3929
+ break;
3930
+ case 18:
3931
+ _context.prev = 18;
3932
+ _context.t0 = _context["catch"](1);
3933
+ logger.error(_context.t0);
3934
+ case 21:
3935
+ return _context.abrupt("return", null);
3936
+ case 22:
3937
+ case "end":
3938
+ return _context.stop();
3939
+ }
3940
+ }, _callee, null, [[1, 18]]);
3941
+ }));
3942
+ return function subscribeBrowserNotifications(_x) {
3943
+ return _ref.apply(this, arguments);
3944
+ };
3945
+ }();
3946
+ var unsubscribeBrowserNotifications = /*#__PURE__*/function () {
3947
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
3948
+ var sw, subscription, res;
3949
+ return regenerator.wrap(function _callee2$(_context2) {
3950
+ while (1) switch (_context2.prev = _context2.next) {
3951
+ case 0:
3952
+ _context2.prev = 0;
3953
+ _context2.next = 3;
3954
+ return navigator.serviceWorker.ready;
3955
+ case 3:
3956
+ sw = _context2.sent;
3957
+ _context2.next = 6;
3958
+ return sw.pushManager.getSubscription();
3959
+ case 6:
3960
+ subscription = _context2.sent;
3961
+ if (!subscription) {
3962
+ _context2.next = 12;
3963
+ break;
3964
+ }
3965
+ _context2.next = 10;
3966
+ return subscription.unsubscribe();
3967
+ case 10:
3968
+ res = _context2.sent;
3969
+ logger.error(res);
3970
+ case 12:
3971
+ _context2.next = 17;
3972
+ break;
3973
+ case 14:
3974
+ _context2.prev = 14;
3975
+ _context2.t0 = _context2["catch"](0);
3976
+ logger.error(_context2.t0);
3977
+ case 17:
3978
+ case "end":
3979
+ return _context2.stop();
3980
+ }
3981
+ }, _callee2, null, [[0, 14]]);
3982
+ }));
3983
+ return function unsubscribeBrowserNotifications() {
3984
+ return _ref2.apply(this, arguments);
3985
+ };
3986
+ }();
3987
+ var registerServiceWorker = /*#__PURE__*/function () {
3988
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(vapidPublicKey) {
3989
+ var res;
3990
+ return regenerator.wrap(function _callee3$(_context3) {
3991
+ while (1) switch (_context3.prev = _context3.next) {
3992
+ case 0:
3993
+ if (!(navigator.serviceWorker && vapidPublicKey)) {
3994
+ _context3.next = 5;
3995
+ break;
3996
+ }
3997
+ _context3.next = 3;
3998
+ return subscribeBrowserNotifications(vapidPublicKey);
3999
+ case 3:
4000
+ res = _context3.sent;
4001
+ return _context3.abrupt("return", res);
4002
+ case 5:
4003
+ logger.error("Service worker is not supported in this Browser");
4004
+ return _context3.abrupt("return", null);
4005
+ case 7:
4006
+ case "end":
4007
+ return _context3.stop();
4008
+ }
4009
+ }, _callee3);
4010
+ }));
4011
+ return function registerServiceWorker(_x2) {
4012
+ return _ref3.apply(this, arguments);
4013
+ };
4014
+ }();
4015
+
4016
+ var createBrowserSubscription = /*#__PURE__*/function () {
4017
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(subscription) {
4018
+ var payload;
4019
+ return regenerator.wrap(function _callee$(_context) {
4020
+ while (1) switch (_context.prev = _context.next) {
4021
+ case 0:
4022
+ if (!subscription) {
4023
+ _context.next = 13;
4024
+ break;
4025
+ }
4026
+ payload = {
4027
+ device: {
4028
+ subscription: subscription,
4029
+ platform: "browser"
4030
+ }
4031
+ };
4032
+ _context.prev = 2;
4033
+ _context.next = 5;
4034
+ return devicesApi.create(payload);
4035
+ case 5:
4036
+ localStorage.setItem("deviceId", JSON.stringify(subscription.toJSON().keys.auth));
4037
+ _context.next = 11;
4038
+ break;
4039
+ case 8:
4040
+ _context.prev = 8;
4041
+ _context.t0 = _context["catch"](2);
4042
+ logger.error("Device registration Failed: ", _context.t0);
4043
+ case 11:
4044
+ _context.next = 14;
4045
+ break;
4046
+ case 13:
4047
+ logger.error("Something went wrong while registering device for browser subscription");
4048
+ case 14:
4049
+ case "end":
4050
+ return _context.stop();
4051
+ }
4052
+ }, _callee, null, [[2, 8]]);
4053
+ }));
4054
+ return function createBrowserSubscription(_x) {
4055
+ return _ref.apply(this, arguments);
4056
+ };
4057
+ }();
4058
+ var destroyBrowserSubscription = /*#__PURE__*/function () {
4059
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
4060
+ var deviceId;
4061
+ return regenerator.wrap(function _callee2$(_context2) {
4062
+ while (1) switch (_context2.prev = _context2.next) {
4063
+ case 0:
4064
+ _context2.prev = 0;
4065
+ _context2.next = 3;
4066
+ return unsubscribeBrowserNotifications();
4067
+ case 3:
4068
+ deviceId = JSON.parse(localStorage.getItem("deviceId"));
4069
+ _context2.next = 6;
4070
+ return devicesApi.destroy(deviceId);
4071
+ case 6:
4072
+ localStorage.removeItem("deviceId");
4073
+ _context2.next = 12;
4074
+ break;
4075
+ case 9:
4076
+ _context2.prev = 9;
4077
+ _context2.t0 = _context2["catch"](0);
4078
+ logger.error("Something went wrong while unsubscribing browser notification:", _context2.t0);
4079
+ case 12:
4080
+ case "end":
4081
+ return _context2.stop();
4082
+ }
4083
+ }, _callee2, null, [[0, 9]]);
4084
+ }));
4085
+ return function destroyBrowserSubscription() {
4086
+ return _ref2.apply(this, arguments);
4087
+ };
4088
+ }();
4089
+ var registerBrowserNotifications = /*#__PURE__*/function () {
4090
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
4091
+ var vapidPublicKey,
4092
+ response,
4093
+ _args3 = arguments;
4094
+ return regenerator.wrap(function _callee3$(_context3) {
4095
+ while (1) switch (_context3.prev = _context3.next) {
4096
+ case 0:
4097
+ vapidPublicKey = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.env.VAPID_PUBLIC_KEY;
4098
+ _context3.next = 3;
4099
+ return registerServiceWorker(vapidPublicKey);
4100
+ case 3:
4101
+ response = _context3.sent;
4102
+ _context3.next = 6;
4103
+ return createBrowserSubscription(response);
4104
+ case 6:
4105
+ case "end":
4106
+ return _context3.stop();
4107
+ }
4108
+ }, _callee3);
4109
+ }));
4110
+ return function registerBrowserNotifications() {
4111
+ return _ref3.apply(this, arguments);
4112
+ };
4113
+ }();
4114
+
4115
+ var handleMetaClick = curry(function (history, params, event) {
4116
+ return isMetaKeyPressed(event) ? window.open(params.pathname || params, "_blank") : history.push(params);
4117
+ });
4118
+ var isMetaKeyPressed = function isMetaKeyPressed(event) {
4119
+ return !!(event !== null && event !== void 0 && event.ctrlKey || event !== null && event !== void 0 && event.metaKey);
4120
+ };
4121
+
4122
+ var withTitle = function withTitle(Component) {
4123
+ var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
4124
+ var PageTitle = function PageTitle(props) {
4125
+ var pageTitle = title ? "".concat(title, " | ").concat(globalProps.appName) : globalProps.appName;
4126
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Helmet, null, /*#__PURE__*/React__default.createElement("title", null, pageTitle)), /*#__PURE__*/React__default.createElement(Component, props));
4127
+ };
4128
+ return PageTitle;
4129
+ };
4130
+
4131
+ var setWithoutModifyingActions = function setWithoutModifyingActions(set) {
4132
+ return function (partial) {
4133
+ return set(function (previous) {
4134
+ if (typeof partial === "function") partial = partial(previous);
4135
+ var overwrittenActions = keys(partial).filter(function (key) {
4136
+ return typeof (previous === null || previous === void 0 ? void 0 : previous[key]) === "function" && partial[key] !== previous[key];
4137
+ });
4138
+ if (!isEmpty(overwrittenActions)) {
4139
+ throw new Error("Actions should not be modified. Touched action(s): ".concat(overwrittenActions.join(", ")));
4140
+ }
4141
+ return partial;
4142
+ }, false);
4143
+ };
4144
+ };
4145
+ var withImmutableActions = function withImmutableActions(config) {
4146
+ return function (set, get, api) {
4147
+ return config(setWithoutModifyingActions(set), get, api);
4148
+ };
4149
+ };
4150
+
4151
+ /** @type {import("neetocommons/react-utils").ZustandStoreHook} */
4152
+ var useCheckpointStore = create$1(withImmutableActions(function (set) {
4153
+ return {
4154
+ checkpoints: {},
4155
+ setCheckpoint: function setCheckpoint(key, path) {
4156
+ return set(mergeDeepLeft({
4157
+ checkpoints: _defineProperty({}, key, path)
4158
+ }));
4159
+ }
4160
+ };
4161
+ }));
4162
+ var useRegisterNavigationCheckpoint = function useRegisterNavigationCheckpoint() {
4163
+ return useCheckpointStore(prop("setCheckpoint"));
4164
+ };
4165
+ var useNavigationCheckpoint = function useNavigationCheckpoint(key) {
4166
+ return useCheckpointStore(path(["checkpoints", key]));
4167
+ };
4168
+
4169
+ var useStateWithDependency = function useStateWithDependency(defaultValue) {
4170
+ var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [defaultValue];
4171
+ var _useState = useState(defaultValue),
4172
+ _useState2 = _slicedToArray(_useState, 2),
4173
+ value = _useState2[0],
4174
+ setValue = _useState2[1];
4175
+ useEffect(function () {
4176
+ setValue(defaultValue);
4177
+ }, dependencies);
4178
+ return [value, setValue];
4179
+ };
4180
+
4181
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
4182
+ // require the crypto API and do not support built-in fallback to lower quality random number
4183
+ // generators (like Math.random()).
4184
+ let getRandomValues;
4185
+ const rnds8 = new Uint8Array(16);
4186
+ function rng() {
4187
+ // lazy load so that environments that need to polyfill have a chance to do so
4188
+ if (!getRandomValues) {
4189
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
4190
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
4191
+
4192
+ if (!getRandomValues) {
4193
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
4194
+ }
4195
+ }
4196
+
4197
+ return getRandomValues(rnds8);
4198
+ }
4199
+
4200
+ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
4201
+
4202
+ function validate(uuid) {
4203
+ return typeof uuid === 'string' && REGEX.test(uuid);
4204
+ }
4205
+
4206
+ /**
4207
+ * Convert array of 16 byte values to UUID string format of the form:
4208
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
4209
+ */
4210
+
4211
+ const byteToHex = [];
4212
+
4213
+ for (let i = 0; i < 256; ++i) {
4214
+ byteToHex.push((i + 0x100).toString(16).slice(1));
4215
+ }
4216
+
4217
+ function unsafeStringify(arr, offset = 0) {
4218
+ // Note: Be careful editing this code! It's been tuned for performance
4219
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
4220
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
4221
+ }
4222
+
4223
+ function parse(uuid) {
4224
+ if (!validate(uuid)) {
4225
+ throw TypeError('Invalid UUID');
4226
+ }
4227
+
4228
+ let v;
4229
+ const arr = new Uint8Array(16); // Parse ########-....-....-....-............
4230
+
4231
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
4232
+ arr[1] = v >>> 16 & 0xff;
4233
+ arr[2] = v >>> 8 & 0xff;
4234
+ arr[3] = v & 0xff; // Parse ........-####-....-....-............
4235
+
4236
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
4237
+ arr[5] = v & 0xff; // Parse ........-....-####-....-............
4238
+
4239
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
4240
+ arr[7] = v & 0xff; // Parse ........-....-....-####-............
4241
+
4242
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
4243
+ arr[9] = v & 0xff; // Parse ........-....-....-....-############
4244
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
4245
+
4246
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
4247
+ arr[11] = v / 0x100000000 & 0xff;
4248
+ arr[12] = v >>> 24 & 0xff;
4249
+ arr[13] = v >>> 16 & 0xff;
4250
+ arr[14] = v >>> 8 & 0xff;
4251
+ arr[15] = v & 0xff;
4252
+ return arr;
4253
+ }
4254
+
4255
+ function stringToBytes(str) {
4256
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
4257
+
4258
+ const bytes = [];
4259
+
4260
+ for (let i = 0; i < str.length; ++i) {
4261
+ bytes.push(str.charCodeAt(i));
4262
+ }
4263
+
4264
+ return bytes;
4265
+ }
4266
+
4267
+ const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
4268
+ const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
4269
+ function v35(name, version, hashfunc) {
4270
+ function generateUUID(value, namespace, buf, offset) {
4271
+ var _namespace;
4272
+
4273
+ if (typeof value === 'string') {
4274
+ value = stringToBytes(value);
4275
+ }
4276
+
4277
+ if (typeof namespace === 'string') {
4278
+ namespace = parse(namespace);
4279
+ }
4280
+
4281
+ if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
4282
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
4283
+ } // Compute hash of namespace and value, Per 4.3
4284
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
4285
+ // hashfunc([...namespace, ... value])`
4286
+
4287
+
4288
+ let bytes = new Uint8Array(16 + value.length);
4289
+ bytes.set(namespace);
4290
+ bytes.set(value, namespace.length);
4291
+ bytes = hashfunc(bytes);
4292
+ bytes[6] = bytes[6] & 0x0f | version;
4293
+ bytes[8] = bytes[8] & 0x3f | 0x80;
4294
+
4295
+ if (buf) {
4296
+ offset = offset || 0;
4297
+
4298
+ for (let i = 0; i < 16; ++i) {
4299
+ buf[offset + i] = bytes[i];
4300
+ }
4301
+
4302
+ return buf;
4303
+ }
4304
+
4305
+ return unsafeStringify(bytes);
4306
+ } // Function#name is not settable on some platforms (#270)
4307
+
4308
+
4309
+ try {
4310
+ generateUUID.name = name; // eslint-disable-next-line no-empty
4311
+ } catch (err) {} // For CommonJS default export support
4312
+
4313
+
4314
+ generateUUID.DNS = DNS;
4315
+ generateUUID.URL = URL;
4316
+ return generateUUID;
4317
+ }
4318
+
4319
+ /*
4320
+ * Browser-compatible JavaScript MD5
4321
+ *
4322
+ * Modification of JavaScript MD5
4323
+ * https://github.com/blueimp/JavaScript-MD5
4324
+ *
4325
+ * Copyright 2011, Sebastian Tschan
4326
+ * https://blueimp.net
4327
+ *
4328
+ * Licensed under the MIT license:
4329
+ * https://opensource.org/licenses/MIT
4330
+ *
4331
+ * Based on
4332
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
4333
+ * Digest Algorithm, as defined in RFC 1321.
4334
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
4335
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
4336
+ * Distributed under the BSD License
4337
+ * See http://pajhome.org.uk/crypt/md5 for more info.
4338
+ */
4339
+ function md5(bytes) {
4340
+ if (typeof bytes === 'string') {
4341
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
4342
+
4343
+ bytes = new Uint8Array(msg.length);
4344
+
4345
+ for (let i = 0; i < msg.length; ++i) {
4346
+ bytes[i] = msg.charCodeAt(i);
4347
+ }
4348
+ }
4349
+
4350
+ return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
4351
+ }
4352
+ /*
4353
+ * Convert an array of little-endian words to an array of bytes
4354
+ */
4355
+
4356
+
4357
+ function md5ToHexEncodedArray(input) {
4358
+ const output = [];
4359
+ const length32 = input.length * 32;
4360
+ const hexTab = '0123456789abcdef';
4361
+
4362
+ for (let i = 0; i < length32; i += 8) {
4363
+ const x = input[i >> 5] >>> i % 32 & 0xff;
4364
+ const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
4365
+ output.push(hex);
4366
+ }
4367
+
4368
+ return output;
4369
+ }
4370
+ /**
4371
+ * Calculate output length with padding and bit length
4372
+ */
4373
+
4374
+
4375
+ function getOutputLength(inputLength8) {
4376
+ return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
4377
+ }
4378
+ /*
4379
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
4380
+ */
4381
+
4382
+
4383
+ function wordsToMd5(x, len) {
4384
+ /* append padding */
4385
+ x[len >> 5] |= 0x80 << len % 32;
4386
+ x[getOutputLength(len) - 1] = len;
4387
+ let a = 1732584193;
4388
+ let b = -271733879;
4389
+ let c = -1732584194;
4390
+ let d = 271733878;
4391
+
4392
+ for (let i = 0; i < x.length; i += 16) {
4393
+ const olda = a;
4394
+ const oldb = b;
4395
+ const oldc = c;
4396
+ const oldd = d;
4397
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
4398
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
4399
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
4400
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
4401
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
4402
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
4403
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
4404
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
4405
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
4406
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
4407
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
4408
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
4409
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
4410
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
4411
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
4412
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
4413
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
4414
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
4415
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
4416
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
4417
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
4418
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
4419
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
4420
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
4421
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
4422
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
4423
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
4424
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
4425
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
4426
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
4427
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
4428
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
4429
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
4430
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
4431
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
4432
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
4433
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
4434
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
4435
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
4436
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
4437
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
4438
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
4439
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
4440
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
4441
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
4442
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
4443
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
4444
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
4445
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
4446
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
4447
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
4448
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
4449
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
4450
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
4451
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
4452
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
4453
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
4454
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
4455
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
4456
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
4457
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
4458
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
4459
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
4460
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
4461
+ a = safeAdd(a, olda);
4462
+ b = safeAdd(b, oldb);
4463
+ c = safeAdd(c, oldc);
4464
+ d = safeAdd(d, oldd);
4465
+ }
4466
+
4467
+ return [a, b, c, d];
4468
+ }
4469
+ /*
4470
+ * Convert an array bytes to an array of little-endian words
4471
+ * Characters >255 have their high-byte silently ignored.
4472
+ */
4394
4473
 
4395
- var runtime = regeneratorRuntime$1.exports();
4396
- var regenerator = runtime;
4397
4474
 
4398
- // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
4399
- try {
4400
- regeneratorRuntime = runtime;
4401
- } catch (accidentalStrictMode) {
4402
- if (typeof globalThis === "object") {
4403
- globalThis.regeneratorRuntime = runtime;
4404
- } else {
4405
- Function("r", "regeneratorRuntime = r")(runtime);
4475
+ function bytesToWords(input) {
4476
+ if (input.length === 0) {
4477
+ return [];
4478
+ }
4479
+
4480
+ const length8 = input.length * 8;
4481
+ const output = new Uint32Array(getOutputLength(length8));
4482
+
4483
+ for (let i = 0; i < length8; i += 8) {
4484
+ output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
4406
4485
  }
4486
+
4487
+ return output;
4407
4488
  }
4489
+ /*
4490
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
4491
+ * to work around bugs in some JS interpreters.
4492
+ */
4408
4493
 
4409
- // THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
4410
- var devicesBaseUrl = "/neeto_notifications/api/v1/devices";
4411
- var create = function create(payload) {
4412
- return axios.post(devicesBaseUrl, payload);
4413
- };
4414
- var destroy = function destroy(deviceId) {
4415
- return axios["delete"]("".concat(devicesBaseUrl, "/").concat(deviceId));
4416
- };
4417
- var devicesApi = {
4418
- create: create,
4419
- destroy: destroy
4494
+
4495
+ function safeAdd(x, y) {
4496
+ const lsw = (x & 0xffff) + (y & 0xffff);
4497
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
4498
+ return msw << 16 | lsw & 0xffff;
4499
+ }
4500
+ /*
4501
+ * Bitwise rotate a 32-bit number to the left.
4502
+ */
4503
+
4504
+
4505
+ function bitRotateLeft(num, cnt) {
4506
+ return num << cnt | num >>> 32 - cnt;
4507
+ }
4508
+ /*
4509
+ * These functions implement the four basic operations the algorithm uses.
4510
+ */
4511
+
4512
+
4513
+ function md5cmn(q, a, b, x, s, t) {
4514
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
4515
+ }
4516
+
4517
+ function md5ff(a, b, c, d, x, s, t) {
4518
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
4519
+ }
4520
+
4521
+ function md5gg(a, b, c, d, x, s, t) {
4522
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
4523
+ }
4524
+
4525
+ function md5hh(a, b, c, d, x, s, t) {
4526
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
4527
+ }
4528
+
4529
+ function md5ii(a, b, c, d, x, s, t) {
4530
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
4531
+ }
4532
+
4533
+ v35('v3', 0x30, md5);
4534
+
4535
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
4536
+ var native = {
4537
+ randomUUID
4420
4538
  };
4421
4539
 
4422
- // THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
4423
- // AND IS USED FOR BROWSER NOTIFICATIONS
4424
- // CONTACT NEETO NOTIFICATIONS TEAM BEFORE MODIFYING THIS FILE
4540
+ function v4(options, buf, offset) {
4541
+ if (native.randomUUID && !buf && !options) {
4542
+ return native.randomUUID();
4543
+ }
4425
4544
 
4426
- function urlB64ToUint8Array(base64String) {
4427
- var padding = "=".repeat((4 - base64String.length % 4) % 4);
4428
- var base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
4429
- var rawData = window.atob(base64);
4430
- var outputArray = new Uint8Array(rawData.length);
4431
- for (var i = 0; i < rawData.length; ++i) {
4432
- outputArray[i] = rawData.charCodeAt(i);
4545
+ options = options || {};
4546
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
4547
+
4548
+ rnds[6] = rnds[6] & 0x0f | 0x40;
4549
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
4550
+
4551
+ if (buf) {
4552
+ offset = offset || 0;
4553
+
4554
+ for (let i = 0; i < 16; ++i) {
4555
+ buf[offset + i] = rnds[i];
4556
+ }
4557
+
4558
+ return buf;
4433
4559
  }
4434
- return outputArray;
4560
+
4561
+ return unsafeStringify(rnds);
4435
4562
  }
4436
- var subscribeBrowserNotifications = /*#__PURE__*/function () {
4437
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(vapidPublicKey) {
4438
- var subscription, permission, sw;
4439
- return regenerator.wrap(function _callee$(_context) {
4440
- while (1) switch (_context.prev = _context.next) {
4441
- case 0:
4442
- subscription = {};
4443
- _context.prev = 1;
4444
- _context.next = 4;
4445
- return Notification.requestPermission();
4446
- case 4:
4447
- permission = _context.sent;
4448
- if (!(permission !== "denied")) {
4449
- _context.next = 15;
4450
- break;
4451
- }
4452
- _context.next = 8;
4453
- return navigator.serviceWorker.register("/serviceworker.js");
4454
- case 8:
4455
- _context.next = 10;
4456
- return navigator.serviceWorker.ready;
4457
- case 10:
4458
- sw = _context.sent;
4459
- _context.next = 13;
4460
- return sw.pushManager.subscribe({
4461
- userVisibleOnly: true,
4462
- applicationServerKey: urlB64ToUint8Array(vapidPublicKey)
4463
- });
4464
- case 13:
4465
- subscription = _context.sent;
4466
- return _context.abrupt("return", subscription);
4467
- case 15:
4468
- logger.error("Notification Permission Denied");
4469
- _context.next = 21;
4470
- break;
4471
- case 18:
4472
- _context.prev = 18;
4473
- _context.t0 = _context["catch"](1);
4474
- logger.error(_context.t0);
4475
- case 21:
4476
- return _context.abrupt("return", null);
4477
- case 22:
4478
- case "end":
4479
- return _context.stop();
4480
- }
4481
- }, _callee, null, [[1, 18]]);
4482
- }));
4483
- return function subscribeBrowserNotifications(_x) {
4484
- return _ref.apply(this, arguments);
4485
- };
4486
- }();
4487
- var unsubscribeBrowserNotifications = /*#__PURE__*/function () {
4488
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
4489
- var sw, subscription, res;
4490
- return regenerator.wrap(function _callee2$(_context2) {
4491
- while (1) switch (_context2.prev = _context2.next) {
4492
- case 0:
4493
- _context2.prev = 0;
4494
- _context2.next = 3;
4495
- return navigator.serviceWorker.ready;
4496
- case 3:
4497
- sw = _context2.sent;
4498
- _context2.next = 6;
4499
- return sw.pushManager.getSubscription();
4500
- case 6:
4501
- subscription = _context2.sent;
4502
- if (!subscription) {
4503
- _context2.next = 12;
4504
- break;
4505
- }
4506
- _context2.next = 10;
4507
- return subscription.unsubscribe();
4508
- case 10:
4509
- res = _context2.sent;
4510
- logger.error(res);
4511
- case 12:
4512
- _context2.next = 17;
4513
- break;
4514
- case 14:
4515
- _context2.prev = 14;
4516
- _context2.t0 = _context2["catch"](0);
4517
- logger.error(_context2.t0);
4518
- case 17:
4519
- case "end":
4520
- return _context2.stop();
4521
- }
4522
- }, _callee2, null, [[0, 14]]);
4523
- }));
4524
- return function unsubscribeBrowserNotifications() {
4525
- return _ref2.apply(this, arguments);
4526
- };
4527
- }();
4528
- var registerServiceWorker = /*#__PURE__*/function () {
4529
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(vapidPublicKey) {
4530
- var res;
4531
- return regenerator.wrap(function _callee3$(_context3) {
4532
- while (1) switch (_context3.prev = _context3.next) {
4533
- case 0:
4534
- if (!(navigator.serviceWorker && vapidPublicKey)) {
4535
- _context3.next = 5;
4536
- break;
4537
- }
4538
- _context3.next = 3;
4539
- return subscribeBrowserNotifications(vapidPublicKey);
4540
- case 3:
4541
- res = _context3.sent;
4542
- return _context3.abrupt("return", res);
4543
- case 5:
4544
- logger.error("Service worker is not supported in this Browser");
4545
- return _context3.abrupt("return", null);
4546
- case 7:
4547
- case "end":
4548
- return _context3.stop();
4549
- }
4550
- }, _callee3);
4551
- }));
4552
- return function registerServiceWorker(_x2) {
4553
- return _ref3.apply(this, arguments);
4554
- };
4555
- }();
4556
4563
 
4557
- var createBrowserSubscription = /*#__PURE__*/function () {
4558
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(subscription) {
4559
- var payload;
4560
- return regenerator.wrap(function _callee$(_context) {
4561
- while (1) switch (_context.prev = _context.next) {
4562
- case 0:
4563
- if (!subscription) {
4564
- _context.next = 13;
4565
- break;
4566
- }
4567
- payload = {
4568
- device: {
4569
- subscription: subscription,
4570
- platform: "browser"
4571
- }
4572
- };
4573
- _context.prev = 2;
4574
- _context.next = 5;
4575
- return devicesApi.create(payload);
4576
- case 5:
4577
- localStorage.setItem("deviceId", JSON.stringify(subscription.toJSON().keys.auth));
4578
- _context.next = 11;
4579
- break;
4580
- case 8:
4581
- _context.prev = 8;
4582
- _context.t0 = _context["catch"](2);
4583
- logger.error("Device registration Failed: ", _context.t0);
4584
- case 11:
4585
- _context.next = 14;
4586
- break;
4587
- case 13:
4588
- logger.error("Something went wrong while registering device for browser subscription");
4589
- case 14:
4590
- case "end":
4591
- return _context.stop();
4592
- }
4593
- }, _callee, null, [[2, 8]]);
4594
- }));
4595
- return function createBrowserSubscription(_x) {
4596
- return _ref.apply(this, arguments);
4597
- };
4598
- }();
4599
- var destroyBrowserSubscription = /*#__PURE__*/function () {
4600
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
4601
- var deviceId;
4602
- return regenerator.wrap(function _callee2$(_context2) {
4603
- while (1) switch (_context2.prev = _context2.next) {
4604
- case 0:
4605
- _context2.prev = 0;
4606
- _context2.next = 3;
4607
- return unsubscribeBrowserNotifications();
4608
- case 3:
4609
- deviceId = JSON.parse(localStorage.getItem("deviceId"));
4610
- _context2.next = 6;
4611
- return devicesApi.destroy(deviceId);
4612
- case 6:
4613
- localStorage.removeItem("deviceId");
4614
- _context2.next = 12;
4615
- break;
4616
- case 9:
4617
- _context2.prev = 9;
4618
- _context2.t0 = _context2["catch"](0);
4619
- logger.error("Something went wrong while unsubscribing browser notification:", _context2.t0);
4620
- case 12:
4621
- case "end":
4622
- return _context2.stop();
4623
- }
4624
- }, _callee2, null, [[0, 9]]);
4625
- }));
4626
- return function destroyBrowserSubscription() {
4627
- return _ref2.apply(this, arguments);
4628
- };
4629
- }();
4630
- var registerBrowserNotifications = /*#__PURE__*/function () {
4631
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
4632
- var vapidPublicKey,
4633
- response,
4634
- _args3 = arguments;
4635
- return regenerator.wrap(function _callee3$(_context3) {
4636
- while (1) switch (_context3.prev = _context3.next) {
4637
- case 0:
4638
- vapidPublicKey = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.env.VAPID_PUBLIC_KEY;
4639
- _context3.next = 3;
4640
- return registerServiceWorker(vapidPublicKey);
4641
- case 3:
4642
- response = _context3.sent;
4643
- _context3.next = 6;
4644
- return createBrowserSubscription(response);
4645
- case 6:
4646
- case "end":
4647
- return _context3.stop();
4648
- }
4649
- }, _callee3);
4650
- }));
4651
- return function registerBrowserNotifications() {
4652
- return _ref3.apply(this, arguments);
4653
- };
4654
- }();
4564
+ // Adapted from Chris Veness' SHA1 code at
4565
+ // http://www.movable-type.co.uk/scripts/sha1.html
4566
+ function f(s, x, y, z) {
4567
+ switch (s) {
4568
+ case 0:
4569
+ return x & y ^ ~x & z;
4570
+
4571
+ case 1:
4572
+ return x ^ y ^ z;
4573
+
4574
+ case 2:
4575
+ return x & y ^ x & z ^ y & z;
4576
+
4577
+ case 3:
4578
+ return x ^ y ^ z;
4579
+ }
4580
+ }
4655
4581
 
4656
- var handleMetaClick = curry(function (history, params, event) {
4657
- return isMetaKeyPressed(event) ? window.open(params.pathname || params, "_blank") : history.push(params);
4582
+ function ROTL(x, n) {
4583
+ return x << n | x >>> 32 - n;
4584
+ }
4585
+
4586
+ function sha1(bytes) {
4587
+ const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
4588
+ const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
4589
+
4590
+ if (typeof bytes === 'string') {
4591
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
4592
+
4593
+ bytes = [];
4594
+
4595
+ for (let i = 0; i < msg.length; ++i) {
4596
+ bytes.push(msg.charCodeAt(i));
4597
+ }
4598
+ } else if (!Array.isArray(bytes)) {
4599
+ // Convert Array-like to Array
4600
+ bytes = Array.prototype.slice.call(bytes);
4601
+ }
4602
+
4603
+ bytes.push(0x80);
4604
+ const l = bytes.length / 4 + 2;
4605
+ const N = Math.ceil(l / 16);
4606
+ const M = new Array(N);
4607
+
4608
+ for (let i = 0; i < N; ++i) {
4609
+ const arr = new Uint32Array(16);
4610
+
4611
+ for (let j = 0; j < 16; ++j) {
4612
+ arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
4613
+ }
4614
+
4615
+ M[i] = arr;
4616
+ }
4617
+
4618
+ M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
4619
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
4620
+ M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
4621
+
4622
+ for (let i = 0; i < N; ++i) {
4623
+ const W = new Uint32Array(80);
4624
+
4625
+ for (let t = 0; t < 16; ++t) {
4626
+ W[t] = M[i][t];
4627
+ }
4628
+
4629
+ for (let t = 16; t < 80; ++t) {
4630
+ W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
4631
+ }
4632
+
4633
+ let a = H[0];
4634
+ let b = H[1];
4635
+ let c = H[2];
4636
+ let d = H[3];
4637
+ let e = H[4];
4638
+
4639
+ for (let t = 0; t < 80; ++t) {
4640
+ const s = Math.floor(t / 20);
4641
+ const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
4642
+ e = d;
4643
+ d = c;
4644
+ c = ROTL(b, 30) >>> 0;
4645
+ b = a;
4646
+ a = T;
4647
+ }
4648
+
4649
+ H[0] = H[0] + a >>> 0;
4650
+ H[1] = H[1] + b >>> 0;
4651
+ H[2] = H[2] + c >>> 0;
4652
+ H[3] = H[3] + d >>> 0;
4653
+ H[4] = H[4] + e >>> 0;
4654
+ }
4655
+
4656
+ return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
4657
+ }
4658
+
4659
+ v35('v5', 0x50, sha1);
4660
+
4661
+ var useTimerStore = create$1(function () {
4662
+ return {};
4658
4663
  });
4659
- var isMetaKeyPressed = function isMetaKeyPressed(event) {
4660
- return !!(event !== null && event !== void 0 && event.ctrlKey || event !== null && event !== void 0 && event.metaKey);
4661
- };
4664
+ setInterval(function () {
4665
+ var currentState = useTimerStore.getState();
4666
+ var nextState = {};
4667
+ var now = Date.now();
4668
+ for (var key in currentState) {
4669
+ var _currentState$key = currentState[key],
4670
+ lastUpdated = _currentState$key.lastUpdated,
4671
+ interval = _currentState$key.interval;
4672
+ var shouldUpdate = now - lastUpdated >= interval;
4673
+ if (shouldUpdate) nextState[key] = {
4674
+ lastUpdated: now,
4675
+ interval: interval
4676
+ };
4677
+ }
4678
+ if (!isEmpty(nextState)) useTimerStore.setState(nextState);
4679
+ }, 1000);
4680
+ var useTimer = function useTimer() {
4681
+ var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 60;
4682
+ var key = useMemo(function () {
4683
+ return v4();
4684
+ }, []);
4685
+ useEffect(function () {
4686
+ useTimerStore.setState(_defineProperty({}, key, {
4687
+ lastUpdated: Date.now(),
4688
+ interval: 1000 * interval // convert seconds to ms
4689
+ }));
4662
4690
 
4663
- var withTitle = function withTitle(Component) {
4664
- var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
4665
- var PageTitle = function PageTitle(props) {
4666
- var pageTitle = title ? "".concat(title, " | ").concat(globalProps.appName) : globalProps.appName;
4667
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Helmet, null, /*#__PURE__*/React__default.createElement("title", null, pageTitle)), /*#__PURE__*/React__default.createElement(Component, props));
4668
- };
4669
- return PageTitle;
4691
+ return function () {
4692
+ return useTimerStore.setState(omit([key], useTimerStore.getState()), true);
4693
+ };
4694
+ }, [interval, key]);
4695
+ return useTimerStore(prop(key));
4670
4696
  };
4671
4697
 
4672
- var setWithoutModifyingActions = function setWithoutModifyingActions(set) {
4673
- return function (partial) {
4674
- return set(function (previous) {
4675
- if (typeof partial === "function") partial = partial(previous);
4676
- var overwrittenActions = keys(partial).filter(function (key) {
4677
- return typeof (previous === null || previous === void 0 ? void 0 : previous[key]) === "function" && partial[key] !== previous[key];
4678
- });
4679
- if (!isEmpty(overwrittenActions)) {
4680
- throw new Error("Actions should not be modified. Touched action(s): ".concat(overwrittenActions.join(", ")));
4681
- }
4682
- return partial;
4683
- }, false);
4684
- };
4685
- };
4686
- var withImmutableActions = function withImmutableActions(config) {
4687
- return function (set, get, api) {
4688
- return config(setWithoutModifyingActions(set), get, api);
4689
- };
4698
+ var useUpdateEffect = function useUpdateEffect(callback) {
4699
+ var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
4700
+ var isInitialMount = useRef(true);
4701
+ useEffect(function () {
4702
+ if (isInitialMount.current) {
4703
+ isInitialMount.current = false;
4704
+ return;
4705
+ }
4706
+ callback();
4707
+ }, dependencies);
4690
4708
  };
4691
4709
 
4692
- export { HoneybadgerErrorBoundary, PrivateRoute, destroyBrowserSubscription, handleMetaClick, isMetaKeyPressed, registerBrowserNotifications, useDebounce, useDisplayErrorPage, useErrorDisplayStore, useFuncDebounce, useHotKeys, useIsElementVisibleInDom, useKeyboardShortcutsPaneState, useLocalStorage, useOnClickOutside, usePrevious, useStateWithDependency, useTimer, useUpdateEffect, withImmutableActions, withTitle };
4710
+ export { HoneybadgerErrorBoundary, PrivateRoute, destroyBrowserSubscription, handleMetaClick, isMetaKeyPressed, registerBrowserNotifications, useDebounce, useDisplayErrorPage, useErrorDisplayStore, useFuncDebounce, useHotKeys, useIsElementVisibleInDom, useKeyboardShortcutsPaneState, useLocalStorage, useNavigationCheckpoint, useOnClickOutside, usePrevious, useRegisterNavigationCheckpoint, useStateWithDependency, useTimer, useUpdateEffect, withImmutableActions, withTitle };
4693
4711
  //# sourceMappingURL=react-utils.js.map