diff --git a/.gitignore b/.gitignore index 307b99d9..6707ed92 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ apps/extension/.env.development.compass .zed .zed apps/extension/staging-builds +apps/extension/src/components/header/header.tsx \ No newline at end of file diff --git a/apps/demo/tailwind.config.js b/apps/demo/tailwind.config.js index be6d4c2b..64314bda 100644 --- a/apps/demo/tailwind.config.js +++ b/apps/demo/tailwind.config.js @@ -80,7 +80,7 @@ module.exports = { 300: '#FFC770', 500: '#FF9F0A', 600: '#D17F00', - }, + } }, extend: { animation: { diff --git a/apps/extension/e2e-tests/send-tx/sendTxTest.ts b/apps/extension/e2e-tests/send-tx/sendTxTest.ts index bfbb6195..94af2525 100644 --- a/apps/extension/e2e-tests/send-tx/sendTxTest.ts +++ b/apps/extension/e2e-tests/send-tx/sendTxTest.ts @@ -60,7 +60,7 @@ export function sendTxTest() { 'send-recipient-address-error-ele', ) - const expectedSendRecipientAddressErrorEleText = 'IBC transfers not supported on testnet.' + const expectedSendRecipientAddressErrorEleText = 'IBC transfers are not supported on testnet.' expect(sendRecipientAddressErrorEleText).toBe(expectedSendRecipientAddressErrorEleText) }) diff --git a/apps/extension/package.json b/apps/extension/package.json index 841cdf9b..147999bb 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -96,6 +96,7 @@ "react-range": "1.8.14", "react-router": "6.3.0", "react-router-dom": "6.3.0", + "react-window": "1.8.10", "reaviz": "14.9.7", "recoil": "0.7.3", "remark-gfm": "3.0.1", @@ -121,6 +122,7 @@ "@types/react-dom": "18.0.5", "@types/react-lottie": "1.2.6", "@types/react-router-dom": "5.3.2", + "@types/react-window": "1.8.8", "@types/semver": "7.3.10", "@types/dompurify": "3.0.5", "@types/post-message-stream": "3.0.1", @@ -144,7 +146,7 @@ "stream-browserify": "3.0.0", "style-loader": "3.3.1", "svg-url-loader": "7.1.1", - "tailwindcss": "3.2.4", + "tailwindcss": "3.4.4", "ts-jest": "29.0.5", "ts-loader": "9.2.8", "tsconfig-paths-webpack-plugin": "3.5.2", diff --git a/apps/extension/public/base_manifest.json b/apps/extension/public/base_manifest.json index c6af4d0d..0640ee3c 100644 --- a/apps/extension/public/base_manifest.json +++ b/apps/extension/public/base_manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "__NAME__", "description": "__DESCRIPTION__", - "version": "0.12.4", + "version": "0.13.0", "options_page": "index.html", "web_accessible_resources": [ { diff --git a/apps/extension/public/compass/manifest.json b/apps/extension/public/compass/manifest.json index 2e41b5f1..7fa4dbf9 100644 --- a/apps/extension/public/compass/manifest.json +++ b/apps/extension/public/compass/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Compass Wallet for Sei", "description": "A crypto wallet for Sei Blockchain, brought to you by the Leap Wallet team.", - "version": "0.12.4", + "version": "0.13.0", "options_page": "index.html", "web_accessible_resources": [ { diff --git a/apps/extension/public/hcaptcha.js b/apps/extension/public/hcaptcha.js index 22ef77a7..5e352814 100644 --- a/apps/extension/public/hcaptcha.js +++ b/apps/extension/public/hcaptcha.js @@ -28,14 +28,14 @@ var n = Array.prototype.slice.call(t) if (0 === n.length) return e([]) var o = n.length - function s(t, i) { + function r(t, i) { if (i && ('object' == typeof i || 'function' == typeof i)) { - var r = i.then - if ('function' == typeof r) { - return void r.call( + var s = i.then + if ('function' == typeof s) { + return void s.call( i, function (e) { - s(t, e) + r(t, e) }, function (i) { ;(n[t] = { status: 'rejected', reason: i }), 0 == --o && e(n) @@ -45,7 +45,7 @@ } ;(n[t] = { status: 'fulfilled', value: i }), 0 == --o && e(n) } - for (var r = 0; r < n.length; r++) s(r, n[r]) + for (var s = 0; s < n.length; s++) r(s, n[s]) }) } var i = setTimeout, @@ -53,42 +53,42 @@ function o(t) { return Boolean(t && 'undefined' != typeof t.length) } - function s() {} - function r(t) { - if (!(this instanceof r)) throw new TypeError('Promises must be constructed via new') + function r() {} + function s(t) { + if (!(this instanceof s)) throw new TypeError('Promises must be constructed via new') if ('function' != typeof t) throw new TypeError('not a function') ;(this._state = 0), (this._handled = !1), (this._value = undefined), (this._deferreds = []), - d(t, this) + f(t, this) } function a(t, e) { for (; 3 === t._state; ) t = t._value 0 !== t._state ? ((t._handled = !0), - r._immediateFn(function () { + s._immediateFn(function () { var i = 1 === t._state ? e.onFulfilled : e.onRejected if (null !== i) { var n try { n = i(t._value) } catch (o) { - return void c(e.promise, o) + return void l(e.promise, o) } - l(e.promise, n) - } else (1 === t._state ? l : c)(e.promise, t._value) + c(e.promise, n) + } else (1 === t._state ? c : l)(e.promise, t._value) })) : t._deferreds.push(e) } - function l(t, e) { + function c(t, e) { try { if (e === t) throw new TypeError('A promise cannot be resolved with itself.') if (e && ('object' == typeof e || 'function' == typeof e)) { var i = e.then - if (e instanceof r) return (t._state = 3), (t._value = e), void h(t) + if (e instanceof s) return (t._state = 3), (t._value = e), void h(t) if ('function' == typeof i) { - return void d( + return void f( ((n = i), (o = e), function () { @@ -99,19 +99,19 @@ } } ;(t._state = 1), (t._value = e), h(t) - } catch (s) { - c(t, s) + } catch (r) { + l(t, r) } var n, o } - function c(t, e) { + function l(t, e) { ;(t._state = 2), (t._value = e), h(t) } function h(t) { 2 === t._state && 0 === t._deferreds.length && - r._immediateFn(function () { - t._handled || r._unhandledRejectionFn(t._value) + s._immediateFn(function () { + t._handled || s._unhandledRejectionFn(t._value) }) for (var e = 0, i = t._deferreds.length; e < i; e++) a(t, t._deferreds[e]) t._deferreds = null @@ -121,37 +121,37 @@ (this.onRejected = 'function' == typeof e ? e : null), (this.promise = i) } - function d(t, e) { + function f(t, e) { var i = !1 try { t( function (t) { - i || ((i = !0), l(e, t)) + i || ((i = !0), c(e, t)) }, function (t) { - i || ((i = !0), c(e, t)) + i || ((i = !0), l(e, t)) }, ) } catch (n) { if (i) return - ;(i = !0), c(e, n) + ;(i = !0), l(e, n) } } - ;(r.prototype['catch'] = function (t) { + ;(s.prototype['catch'] = function (t) { return this.then(null, t) }), - (r.prototype.then = function (t, e) { - var i = new this.constructor(s) + (s.prototype.then = function (t, e) { + var i = new this.constructor(r) return a(this, new u(t, e, i)), i }), - (r.prototype['finally'] = t), - (r.all = function (t) { - return new r(function (e, i) { + (s.prototype['finally'] = t), + (s.all = function (t) { + return new s(function (e, i) { if (!o(t)) return i(new TypeError('Promise.all accepts an array')) var n = Array.prototype.slice.call(t) if (0 === n.length) return e([]) - var s = n.length - function r(t, o) { + var r = n.length + function s(t, o) { try { if (o && ('object' == typeof o || 'function' == typeof o)) { var a = o.then @@ -159,40 +159,40 @@ return void a.call( o, function (e) { - r(t, e) + s(t, e) }, i, ) } } - ;(n[t] = o), 0 == --s && e(n) - } catch (l) { - i(l) + ;(n[t] = o), 0 == --r && e(n) + } catch (c) { + i(c) } } - for (var a = 0; a < n.length; a++) r(a, n[a]) + for (var a = 0; a < n.length; a++) s(a, n[a]) }) }), - (r.allSettled = e), - (r.resolve = function (t) { - return t && 'object' == typeof t && t.constructor === r + (s.allSettled = e), + (s.resolve = function (t) { + return t && 'object' == typeof t && t.constructor === s ? t - : new r(function (e) { + : new s(function (e) { e(t) }) }), - (r.reject = function (t) { - return new r(function (e, i) { + (s.reject = function (t) { + return new s(function (e, i) { i(t) }) }), - (r.race = function (t) { - return new r(function (e, i) { + (s.race = function (t) { + return new s(function (e, i) { if (!o(t)) return i(new TypeError('Promise.race accepts an array')) - for (var n = 0, s = t.length; n < s; n++) r.resolve(t[n]).then(e, i) + for (var n = 0, r = t.length; n < r; n++) s.resolve(t[n]).then(e, i) }) }), - (r._immediateFn = + (s._immediateFn = ('function' == typeof n && function (t) { n(t) @@ -200,18 +200,18 @@ function (t) { i(t, 0) }), - (r._unhandledRejectionFn = function (t) { + (s._unhandledRejectionFn = function (t) { 'undefined' != typeof console && console && console.warn('Possible Unhandled Promise Rejection:', t) }) - var p = (function () { + var d = (function () { if ('undefined' != typeof self) return self if ('undefined' != typeof window) return window if ('undefined' != typeof global) return global throw new Error('unable to locate global object') })() - function f(t, e, i) { + function p(t, e, i) { return e <= t && t <= i } function m(t) { @@ -219,10 +219,10 @@ if (t === Object(t)) return t throw TypeError('Could not convert argument to dictionary') } - 'function' != typeof p.Promise - ? (p.Promise = r) - : (p.Promise.prototype['finally'] || (p.Promise.prototype['finally'] = t), - p.Promise.allSettled || (p.Promise.allSettled = e)) + 'function' != typeof d.Promise + ? (d.Promise = s) + : (d.Promise.prototype['finally'] || (d.Promise.prototype['finally'] = t), + d.Promise.allSettled || (d.Promise.allSettled = e)) var y = function (t) { return t >= 0 && t <= 127 }, @@ -253,10 +253,10 @@ } function x(t) { return ( - (t = String(t).trim().toLowerCase()), Object.prototype.hasOwnProperty.call(C, t) ? C[t] : null + (t = String(t).trim().toLowerCase()), Object.prototype.hasOwnProperty.call(k, t) ? k[t] : null ) } - var C = {} + var k = {} ;[ { encodings: [{ labels: ['unicode-1-1-utf-8', 'utf-8', 'utf8'], name: 'UTF-8' }], @@ -265,25 +265,25 @@ ].forEach(function (t) { t.encodings.forEach(function (t) { t.labels.forEach(function (e) { - C[e] = t + k[e] = t }) }) }) - var k, + var C, _ = { 'UTF-8': function (t) { - return new H(t) + return new T(t) }, }, E = { 'UTF-8': function (t) { - return new B(t) + return new L(t) }, }, - S = 'utf-8' - function A(t, e) { - if (!(this instanceof A)) throw TypeError("Called as a function. Did you forget 'new'?") - ;(t = t !== undefined ? String(t) : S), + A = 'utf-8' + function S(t, e) { + if (!(this instanceof S)) throw TypeError("Called as a function. Did you forget 'new'?") + ;(t = t !== undefined ? String(t) : A), (e = m(e)), (this._encoding = null), (this._decoder = null), @@ -308,8 +308,8 @@ n ) } - function L(t, e) { - if (!(this instanceof L)) throw TypeError("Called as a function. Did you forget 'new'?") + function B(t, e) { + if (!(this instanceof B)) throw TypeError("Called as a function. Did you forget 'new'?") ;(e = m(e)), (this._encoding = null), (this._encoder = null), @@ -317,7 +317,7 @@ (this._fatal = e.fatal ? 'fatal' : 'replacement') var i = this if (e.NONSTANDARD_allowLegacyEncoding) { - var n = x((t = t !== undefined ? String(t) : S)) + var n = x((t = t !== undefined ? String(t) : A)) if (null === n || 'replacement' === n.name) throw RangeError('Unknown encoding: ' + t) if (!_[n.name]) { throw Error('Encoder not present. Did you forget to include encoding-indexes.js first?') @@ -326,68 +326,68 @@ } else i._encoding = x('utf-8') return Object.defineProperty || (this.encoding = i._encoding.name.toLowerCase()), i } - function B(t) { + function L(t) { var e = t.fatal, i = 0, n = 0, o = 0, - s = 128, - r = 191 + r = 128, + s = 191 this.handler = function (t, a) { if (a === g && 0 !== o) return (o = 0), w(e) if (a === g) return b if (0 === o) { - if (f(a, 0, 127)) return a - if (f(a, 194, 223)) (o = 1), (i = 31 & a) - else if (f(a, 224, 239)) { - 224 === a && (s = 160), 237 === a && (r = 159), (o = 2), (i = 15 & a) + if (p(a, 0, 127)) return a + if (p(a, 194, 223)) (o = 1), (i = 31 & a) + else if (p(a, 224, 239)) { + 224 === a && (r = 160), 237 === a && (s = 159), (o = 2), (i = 15 & a) } else { - if (!f(a, 240, 244)) return w(e) - 240 === a && (s = 144), 244 === a && (r = 143), (o = 3), (i = 7 & a) + if (!p(a, 240, 244)) return w(e) + 240 === a && (r = 144), 244 === a && (s = 143), (o = 3), (i = 7 & a) } return null } - if (!f(a, s, r)) return (i = o = n = 0), (s = 128), (r = 191), t.prepend(a), w(e) - if (((s = 128), (r = 191), (i = (i << 6) | (63 & a)), (n += 1) !== o)) return null - var l = i - return (i = o = n = 0), l + if (!p(a, r, s)) return (i = o = n = 0), (r = 128), (s = 191), t.prepend(a), w(e) + if (((r = 128), (s = 191), (i = (i << 6) | (63 & a)), (n += 1) !== o)) return null + var c = i + return (i = o = n = 0), c } } - function H(t) { + function T(t) { t.fatal this.handler = function (t, e) { if (e === g) return b if (y(e)) return e var i, n - f(e, 128, 2047) + p(e, 128, 2047) ? ((i = 1), (n = 192)) - : f(e, 2048, 65535) + : p(e, 2048, 65535) ? ((i = 2), (n = 224)) - : f(e, 65536, 1114111) && ((i = 3), (n = 240)) + : p(e, 65536, 1114111) && ((i = 3), (n = 240)) for (var o = [(e >> (6 * i)) + n]; i > 0; ) { - var s = e >> (6 * (i - 1)) - o.push(128 | (63 & s)), (i -= 1) + var r = e >> (6 * (i - 1)) + o.push(128 | (63 & r)), (i -= 1) } return o } } Object.defineProperty && - (Object.defineProperty(A.prototype, 'encoding', { + (Object.defineProperty(S.prototype, 'encoding', { get: function () { return this._encoding.name.toLowerCase() }, }), - Object.defineProperty(A.prototype, 'fatal', { + Object.defineProperty(S.prototype, 'fatal', { get: function () { return 'fatal' === this._error_mode }, }), - Object.defineProperty(A.prototype, 'ignoreBOM', { + Object.defineProperty(S.prototype, 'ignoreBOM', { get: function () { return this._ignoreBOM }, })), - (A.prototype.decode = function (t, e) { + (S.prototype.decode = function (t, e) { var i ;(i = 'object' == typeof t && t instanceof ArrayBuffer @@ -400,16 +400,16 @@ ((this._decoder = E[this._encoding.name]({ fatal: 'fatal' === this._error_mode })), (this._BOMseen = !1)), (this._do_not_flush = Boolean(e.stream)) - for (var n, o = new v(i), s = []; ; ) { - var r = o.read() - if (r === g) break - if ((n = this._decoder.handler(o, r)) === b) break - null !== n && (Array.isArray(n) ? s.push.apply(s, n) : s.push(n)) + for (var n, o = new v(i), r = []; ; ) { + var s = o.read() + if (s === g) break + if ((n = this._decoder.handler(o, s)) === b) break + null !== n && (Array.isArray(n) ? r.push.apply(r, n) : r.push(n)) } if (!this._do_not_flush) { do { if ((n = this._decoder.handler(o, o.read())) === b) break - null !== n && (Array.isArray(n) ? s.push.apply(s, n) : s.push(n)) + null !== n && (Array.isArray(n) ? r.push.apply(r, n) : r.push(n)) } while (!o.endOfStream()) this._decoder = null } @@ -434,15 +434,15 @@ return e })(t) ) - }.call(this, s) + }.call(this, r) }), Object.defineProperty && - Object.defineProperty(L.prototype, 'encoding', { + Object.defineProperty(B.prototype, 'encoding', { get: function () { return this._encoding.name.toLowerCase() }, }), - (L.prototype.encode = function (t, e) { + (B.prototype.encode = function (t, e) { ;(t = t === undefined ? '' : String(t)), (e = m(e)), this._do_not_flush || @@ -453,17 +453,17 @@ n = new v( (function (t) { for (var e = String(t), i = e.length, n = 0, o = []; n < i; ) { - var s = e.charCodeAt(n) - if (s < 55296 || s > 57343) o.push(s) - else if (s >= 56320 && s <= 57343) o.push(65533) - else if (s >= 55296 && s <= 56319) { + var r = e.charCodeAt(n) + if (r < 55296 || r > 57343) o.push(r) + else if (r >= 56320 && r <= 57343) o.push(65533) + else if (r >= 55296 && r <= 56319) { if (n === i - 1) o.push(65533) else { - var r = e.charCodeAt(n + 1) - if (r >= 56320 && r <= 57343) { - var a = 1023 & s, - l = 1023 & r - o.push(65536 + (a << 10) + l), (n += 1) + var s = e.charCodeAt(n + 1) + if (s >= 56320 && s <= 57343) { + var a = 1023 & r, + c = 1023 & s + o.push(65536 + (a << 10) + c), (n += 1) } else o.push(65533) } } @@ -476,9 +476,9 @@ ; ) { - var s = n.read() - if (s === g) break - if ((i = this._encoder.handler(n, s)) === b) break + var r = n.read() + if (r === g) break + if ((i = this._encoder.handler(n, r)) === b) break Array.isArray(i) ? o.push.apply(o, i) : o.push(i) } if (!this._do_not_flush) { @@ -489,8 +489,8 @@ } return new Uint8Array(o) }), - window.TextDecoder || (window.TextDecoder = A), - window.TextEncoder || (window.TextEncoder = L), + window.TextDecoder || (window.TextDecoder = S), + window.TextEncoder || (window.TextEncoder = B), (function (t) { if ('function' != typeof Promise) throw 'Promise support required' var e = t.crypto || t.msCrypto @@ -499,50 +499,50 @@ if (i) { var n = t.Crypto || e.constructor || Object, o = t.SubtleCrypto || i.constructor || Object, - s = (t.CryptoKey || t.Key, t.navigator.userAgent.indexOf('Edge/') > -1), - r = !!t.msCrypto && !s, + r = (t.CryptoKey || t.Key, t.navigator.userAgent.indexOf('Edge/') > -1), + s = !!t.msCrypto && !r, a = !e.subtle && !!e.webkitSubtle - if (r || a) { - var l = { KoZIhvcNAQEB: '1.2.840.113549.1.1.1' }, - c = { '1.2.840.113549.1.1.1': 'KoZIhvcNAQEB' } + if (s || a) { + var c = { KoZIhvcNAQEB: '1.2.840.113549.1.1.1' }, + l = { '1.2.840.113549.1.1.1': 'KoZIhvcNAQEB' } if ( (['generateKey', 'importKey', 'unwrapKey'].forEach(function (t) { var n = i[t] - i[t] = function (o, s, l) { - var c, + i[t] = function (o, r, c) { + var l, h, u, - f, + p, w = [].slice.call(arguments) switch (t) { case 'generateKey': - ;(c = m(o)), (h = s), (u = l) + ;(l = m(o)), (h = r), (u = c) break case 'importKey': - ;(c = m(l)), + ;(l = m(c)), (h = w[3]), (u = w[4]), 'jwk' === o && - ((s = g(s)).alg || (s.alg = y(c)), - s.key_ops || - (s.key_ops = - 'oct' !== s.kty ? ('d' in s ? u.filter(E) : u.filter(_)) : u.slice()), - (w[1] = v(s))) + ((r = g(r)).alg || (r.alg = y(l)), + r.key_ops || + (r.key_ops = + 'oct' !== r.kty ? ('d' in r ? u.filter(E) : u.filter(_)) : u.slice()), + (w[1] = v(r))) break case 'unwrapKey': - ;(c = w[4]), (h = w[5]), (u = w[6]), (w[2] = l._key) + ;(l = w[4]), (h = w[5]), (u = w[6]), (w[2] = c._key) } - if ('generateKey' === t && 'HMAC' === c.name && c.hash) { + if ('generateKey' === t && 'HMAC' === l.name && l.hash) { return ( - (c.length = - c.length || + (l.length = + l.length || { 'SHA-1': 512, 'SHA-256': 512, 'SHA-384': 1024, 'SHA-512': 1024 }[ - c.hash.name + l.hash.name ]), i.importKey( 'raw', - e.getRandomValues(new Uint8Array((c.length + 7) >> 3)), - c, + e.getRandomValues(new Uint8Array((l.length + 7) >> 3)), + l, h, u, ) @@ -551,8 +551,8 @@ if ( a && 'generateKey' === t && - 'RSASSA-PKCS1-v1_5' === c.name && - (!c.modulusLength || c.modulusLength >= 2048) + 'RSASSA-PKCS1-v1_5' === l.name && + (!l.modulusLength || l.modulusLength >= 2048) ) { return ( ((o = m(o)).name = 'RSAES-PKCS1-v1_5'), @@ -567,12 +567,12 @@ }) .then(function (t) { return ( - (t[0].alg = t[1].alg = y(c)), + (t[0].alg = t[1].alg = y(l)), (t[0].key_ops = u.filter(_)), (t[1].key_ops = u.filter(E)), Promise.all([ - i.importKey('jwk', t[0], c, !0, t[0].key_ops), - i.importKey('jwk', t[1], c, h, t[1].key_ops), + i.importKey('jwk', t[0], l, !0, t[0].key_ops), + i.importKey('jwk', t[1], l, h, t[1].key_ops), ]) ) }) @@ -582,53 +582,53 @@ ) } if ( - (a || (r && 'SHA-1' === (c.hash || {}).name)) && + (a || (s && 'SHA-1' === (l.hash || {}).name)) && 'importKey' === t && 'jwk' === o && - 'HMAC' === c.name && - 'oct' === s.kty + 'HMAC' === l.name && + 'oct' === r.kty ) { - return i.importKey('raw', p(d(s.k)), l, w[3], w[4]) + return i.importKey('raw', d(f(r.k)), c, w[3], w[4]) } if (a && 'importKey' === t && ('spki' === o || 'pkcs8' === o)) { - return i.importKey('jwk', b(s), l, w[3], w[4]) + return i.importKey('jwk', b(r), c, w[3], w[4]) } - if (r && 'unwrapKey' === t) { - return i.decrypt(w[3], l, s).then(function (t) { + if (s && 'unwrapKey' === t) { + return i.decrypt(w[3], c, r).then(function (t) { return i.importKey(o, t, w[4], w[5], w[6]) }) } try { - f = n.apply(i, w) + p = n.apply(i, w) } catch (x) { return Promise.reject(x) } return ( - r && - (f = new Promise(function (t, e) { - ;(f.onabort = f.onerror = + s && + (p = new Promise(function (t, e) { + ;(p.onabort = p.onerror = function (t) { e(t) }), - (f.oncomplete = function (e) { + (p.oncomplete = function (e) { t(e.target.result) }) })), - (f = f.then(function (t) { + (p = p.then(function (t) { return ( - 'HMAC' === c.name && (c.length || (c.length = 8 * t.algorithm.length)), - 0 == c.name.search('RSA') && - (c.modulusLength || - (c.modulusLength = (t.publicKey || t).algorithm.modulusLength), - c.publicExponent || - (c.publicExponent = (t.publicKey || t).algorithm.publicExponent)), + 'HMAC' === l.name && (l.length || (l.length = 8 * t.algorithm.length)), + 0 == l.name.search('RSA') && + (l.modulusLength || + (l.modulusLength = (t.publicKey || t).algorithm.modulusLength), + l.publicExponent || + (l.publicExponent = (t.publicKey || t).algorithm.publicExponent)), (t = t.publicKey && t.privateKey ? { - publicKey: new k(t.publicKey, c, h, u.filter(_)), - privateKey: new k(t.privateKey, c, h, u.filter(E)), + publicKey: new C(t.publicKey, l, h, u.filter(_)), + privateKey: new C(t.privateKey, l, h, u.filter(E)), } - : new k(t, c, h, u)) + : new C(t, l, h, u)) ) })) ) @@ -636,59 +636,59 @@ }), ['exportKey', 'wrapKey'].forEach(function (t) { var e = i[t] - i[t] = function (n, o, s) { - var l, - c = [].slice.call(arguments) + i[t] = function (n, o, r) { + var c, + l = [].slice.call(arguments) switch (t) { case 'exportKey': - c[1] = o._key + l[1] = o._key break case 'wrapKey': - ;(c[1] = o._key), (c[2] = s._key) + ;(l[1] = o._key), (l[2] = r._key) } if ( - ((a || (r && 'SHA-1' === (o.algorithm.hash || {}).name)) && + ((a || (s && 'SHA-1' === (o.algorithm.hash || {}).name)) && 'exportKey' === t && 'jwk' === n && 'HMAC' === o.algorithm.name && - (c[0] = 'raw'), - !a || 'exportKey' !== t || ('spki' !== n && 'pkcs8' !== n) || (c[0] = 'jwk'), - r && 'wrapKey' === t) + (l[0] = 'raw'), + !a || 'exportKey' !== t || ('spki' !== n && 'pkcs8' !== n) || (l[0] = 'jwk'), + s && 'wrapKey' === t) ) { return i.exportKey(n, o).then(function (t) { return ( - 'jwk' === n && (t = p(unescape(encodeURIComponent(JSON.stringify(g(t)))))), - i.encrypt(c[3], s, t) + 'jwk' === n && (t = d(unescape(encodeURIComponent(JSON.stringify(g(t)))))), + i.encrypt(l[3], r, t) ) }) } try { - l = e.apply(i, c) + c = e.apply(i, l) } catch (h) { return Promise.reject(h) } return ( - r && - (l = new Promise(function (t, e) { - ;(l.onabort = l.onerror = + s && + (c = new Promise(function (t, e) { + ;(c.onabort = c.onerror = function (t) { e(t) }), - (l.oncomplete = function (e) { + (c.oncomplete = function (e) { t(e.target.result) }) })), 'exportKey' === t && 'jwk' === n && - (l = l.then(function (t) { - return (a || (r && 'SHA-1' === (o.algorithm.hash || {}).name)) && + (c = c.then(function (t) { + return (a || (s && 'SHA-1' === (o.algorithm.hash || {}).name)) && 'HMAC' === o.algorithm.name ? { kty: 'oct', alg: y(o.algorithm), key_ops: o.usages.slice(), ext: !0, - k: u(f(t)), + k: u(p(t)), } : ((t = g(t)).alg || (t.alg = y(o.algorithm)), t.key_ops || @@ -703,52 +703,52 @@ !a || 'exportKey' !== t || ('spki' !== n && 'pkcs8' !== n) || - (l = l.then(function (t) { + (c = c.then(function (t) { return (t = w(g(t))) })), - l + c ) } }), ['encrypt', 'decrypt', 'sign', 'verify'].forEach(function (t) { var e = i[t] - i[t] = function (n, o, s, a) { - if (r && (!s.byteLength || (a && !a.byteLength))) { + i[t] = function (n, o, r, a) { + if (s && (!r.byteLength || (a && !a.byteLength))) { throw new Error('Empty input is not allowed') } - var l, - c = [].slice.call(arguments), + var c, + l = [].slice.call(arguments), h = m(n) if ( - (!r || + (!s || ('sign' !== t && 'verify' !== t) || ('RSASSA-PKCS1-v1_5' !== n && 'HMAC' !== n) || - (c[0] = { name: n }), - r && o.algorithm.hash && (c[0].hash = c[0].hash || o.algorithm.hash), - r && 'decrypt' === t && 'AES-GCM' === h.name) + (l[0] = { name: n }), + s && o.algorithm.hash && (l[0].hash = l[0].hash || o.algorithm.hash), + s && 'decrypt' === t && 'AES-GCM' === h.name) ) { var u = n.tagLength >> 3 - ;(c[2] = (s.buffer || s).slice(0, s.byteLength - u)), - (n.tag = (s.buffer || s).slice(s.byteLength - u)) + ;(l[2] = (r.buffer || r).slice(0, r.byteLength - u)), + (n.tag = (r.buffer || r).slice(r.byteLength - u)) } - r && + s && 'AES-GCM' === h.name && - c[0].tagLength === undefined && - (c[0].tagLength = 128), - (c[1] = o._key) + l[0].tagLength === undefined && + (l[0].tagLength = 128), + (l[1] = o._key) try { - l = e.apply(i, c) - } catch (d) { - return Promise.reject(d) + c = e.apply(i, l) + } catch (f) { + return Promise.reject(f) } return ( - r && - (l = new Promise(function (e, i) { - ;(l.onabort = l.onerror = + s && + (c = new Promise(function (e, i) { + ;(c.onabort = c.onerror = function (t) { i(t) }), - (l.oncomplete = function (i) { + (c.oncomplete = function (i) { i = i.target.result if ('encrypt' === t && i instanceof AesGcmEncryptResult) { var n = i.ciphertext, @@ -763,11 +763,11 @@ e(i) }) })), - l + c ) } }), - r) + s) ) { var h = i.digest ;(i.digest = function (t, e) { @@ -799,25 +799,25 @@ }, subtle: { value: i }, })), - (t.CryptoKey = k) + (t.CryptoKey = C) } - a && ((e.subtle = i), (t.Crypto = n), (t.SubtleCrypto = o), (t.CryptoKey = k)) + a && ((e.subtle = i), (t.Crypto = n), (t.SubtleCrypto = o), (t.CryptoKey = C)) } } } function u(t) { return btoa(t).replace(/\=+$/, '').replace(/\+/g, '-').replace(/\//g, '_') } - function d(t) { + function f(t) { return ( (t = (t += '===').slice(0, -t.length % 4)), atob(t.replace(/-/g, '+').replace(/_/g, '/')) ) } - function p(t) { + function d(t) { for (var e = new Uint8Array(t.length), i = 0; i < t.length; i++) e[i] = t.charCodeAt(i) return e } - function f(t) { + function p(t) { return ( t instanceof ArrayBuffer && (t = new Uint8Array(t)), String.fromCharCode.apply(String, t) ) @@ -871,7 +871,7 @@ } function g(t) { ;(t instanceof ArrayBuffer || t instanceof Uint8Array) && - (t = JSON.parse(decodeURIComponent(escape(f(t))))) + (t = JSON.parse(decodeURIComponent(escape(p(t))))) var e = { kty: t.kty, alg: t.alg, ext: t.ext || t.extractable } switch (e.kty) { case 'oct': @@ -889,8 +889,8 @@ function v(t) { var e = g(t) return ( - r && ((e.extractable = e.ext), delete e.ext), - p(unescape(encodeURIComponent(JSON.stringify(e)))).buffer + s && ((e.extractable = e.ext), delete e.ext), + d(unescape(encodeURIComponent(JSON.stringify(e)))).buffer ) } function b(t) { @@ -900,10 +900,10 @@ var n = { ext: !0 } if ('1.2.840.113549.1.1.1' !== e[0][0]) throw new TypeError('Unsupported key type') var o = ['n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'qi'], - s = x(e[1]) - i && s.shift() - for (var r = 0; r < s.length; r++) { - s[r][0] || (s[r] = s[r].subarray(1)), (n[o[r]] = u(f(s[r]))) + r = x(e[1]) + i && r.shift() + for (var s = 0; s < r.length; s++) { + r[s][0] || (r[s] = r[s].subarray(1)), (n[o[s]] = u(p(r[s]))) } return (n.kty = 'RSA'), n } @@ -913,20 +913,20 @@ n = !1 if ('RSA' !== t.kty) throw new TypeError('Unsupported key type') for ( - var o = ['n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'qi'], s = [], r = 0; - r < o.length && o[r] in t; - r++ + var o = ['n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'qi'], r = [], s = 0; + s < o.length && o[s] in t; + s++ ) { - var a = (s[r] = p(d(t[o[r]]))) - 128 & a[0] && ((s[r] = new Uint8Array(a.length + 1)), s[r].set(a, 1)) + var a = (r[s] = d(f(t[o[s]]))) + 128 & a[0] && ((r[s] = new Uint8Array(a.length + 1)), r[s].set(a, 1)) } return ( - s.length > 2 && ((n = !0), s.unshift(new Uint8Array([0]))), + r.length > 2 && ((n = !0), r.unshift(new Uint8Array([0]))), (i[0][0] = '1.2.840.113549.1.1.1'), - (e = s), - i.push(new Uint8Array(C(e)).buffer), + (e = r), + i.push(new Uint8Array(k(e)).buffer), n ? i.unshift(new Uint8Array([0])) : (i[1] = { tag: 3, value: i[1] }), - new Uint8Array(C(i)).buffer + new Uint8Array(k(i)).buffer ) } function x(t, e) { @@ -942,8 +942,8 @@ o = t[e.pos++] if (o >= 128) { if (((o &= 127), e.end - e.pos < o)) throw new RangeError('Malformed DER') - for (var s = 0; o--; ) (s <<= 8), (s |= t[e.pos++]) - o = s + for (var r = 0; o--; ) (r <<= 8), (r |= t[e.pos++]) + o = r } if (e.end - e.pos < o) throw new RangeError('Malformed DER') switch (n) { @@ -960,9 +960,9 @@ i = null break case 6: - var r = btoa(f(t.subarray(e.pos, (e.pos += o)))) - if (!(r in l)) throw new Error('Unsupported OBJECT ID ' + r) - i = l[r] + var s = btoa(p(t.subarray(e.pos, (e.pos += o)))) + if (!(s in c)) throw new Error('Unsupported OBJECT ID ' + s) + i = c[s] break case 48: i = [] @@ -973,31 +973,31 @@ } return i } - function C(t, e) { + function k(t, e) { e || (e = []) var i = 0, n = 0, o = e.length + 2 if ((e.push(0, 0), t instanceof Uint8Array)) { ;(i = 2), (n = t.length) - for (var s = 0; s < n; s++) e.push(t[s]) + for (var r = 0; r < n; r++) e.push(t[r]) } else if (t instanceof ArrayBuffer) { ;(i = 4), (n = t.byteLength), (t = new Uint8Array(t)) - for (s = 0; s < n; s++) e.push(t[s]) + for (r = 0; r < n; r++) e.push(t[r]) } else if (null === t) (i = 5), (n = 0) - else if ('string' == typeof t && t in c) { - var r = p(atob(c[t])) - ;(i = 6), (n = r.length) - for (s = 0; s < n; s++) e.push(r[s]) + else if ('string' == typeof t && t in l) { + var s = d(atob(l[t])) + ;(i = 6), (n = s.length) + for (r = 0; r < n; r++) e.push(s[r]) } else if (t instanceof Array) { - for (s = 0; s < t.length; s++) C(t[s], e) + for (r = 0; r < t.length; r++) k(t[r], e) ;(i = 48), (n = e.length - o) } else { if (!('object' == typeof t && 3 === t.tag && t.value instanceof ArrayBuffer)) { throw new Error('Unsupported DER value ' + t) } ;(i = 3), (n = (t = new Uint8Array(t.value)).byteLength), e.push(0) - for (s = 0; s < n; s++) e.push(t[s]) + for (r = 0; r < n; r++) e.push(t[r]) n++ } if (n >= 128) { @@ -1014,7 +1014,7 @@ } return e.splice(o - 2, 2, i, n), e } - function k(t, e, i, n) { + function C(t, e, i, n) { Object.defineProperties(this, { _key: { value: t }, type: { value: t.type, enumerable: !0 }, @@ -1038,14 +1038,14 @@ } var n = t(this), o = n.length >>> 0, - s = Math.min(0 | i, o) - if (s < 0) s = Math.max(0, o + s) - else if (s >= o) return -1 + r = Math.min(0 | i, o) + if (r < 0) r = Math.max(0, o + r) + else if (r >= o) return -1 if (void 0 === e) { - for (; s !== o; ++s) if (void 0 === n[s] && s in n) return s + for (; r !== o; ++r) if (void 0 === n[r] && r in n) return r } else if (e != e) { - for (; s !== o; ++s) if (n[s] != n[s]) return s - } else for (; s !== o; ++s) if (n[s] === e) return s + for (; r !== o; ++r) if (n[r] != n[r]) return r + } else for (; r !== o; ++r) if (n[r] === e) return r return -1 } })(Object)), @@ -1098,7 +1098,7 @@ }, }) } - } catch (Fs) {} + } catch (Qr) {} Function.prototype.bind || (Function.prototype.bind = function (t) { if ('function' != typeof this) { @@ -1129,22 +1129,22 @@ }), window.console || (window.console = {}) for ( - var T, + var H, M, - V, R, - F = ['error', 'info', 'log', 'show', 'table', 'trace', 'warn'], - P = function (t) {}, - D = F.length; + P, + I = ['error', 'info', 'log', 'show', 'table', 'trace', 'warn'], + V = function (t) {}, + D = I.length; --D > -1; ) { - ;(k = F[D]), window.console[k] || (window.console[k] = P) + ;(C = I[D]), window.console[C] || (window.console[C] = V) } if (window.atob) { try { window.atob(' ') - } catch (Ps) { + } catch (ts) { window.atob = (function (t) { var e = function (e) { return t(String(e).replace(/[\t\n\f\r ]+/g, '')) @@ -1153,7 +1153,7 @@ })(window.atob) } } else { - var I = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', + var F = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', $ = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/ window.atob = function (t) { if (((t = String(t).replace(/[\t\n\f\r ]+/g, '')), !$.test(t))) { @@ -1163,12 +1163,12 @@ } var e, i, n t += '=='.slice(2 - (3 & t.length)) - for (var o = '', s = 0; s < t.length; ) { + for (var o = '', r = 0; r < t.length; ) { ;(e = - (I.indexOf(t.charAt(s++)) << 18) | - (I.indexOf(t.charAt(s++)) << 12) | - ((i = I.indexOf(t.charAt(s++))) << 6) | - (n = I.indexOf(t.charAt(s++)))), + (F.indexOf(t.charAt(r++)) << 18) | + (F.indexOf(t.charAt(r++)) << 12) | + ((i = F.indexOf(t.charAt(r++))) << 6) | + (n = F.indexOf(t.charAt(r++)))), (o += 64 === i ? String.fromCharCode((e >> 16) & 255) @@ -1193,21 +1193,21 @@ console.error( '[hCaptcha] Custom JSON polyfill detected, please remove to ensure hCaptcha works properly', ) - var j = Array.prototype.toJSON, - N = JSON.stringify + var U = Array.prototype.toJSON, + j = JSON.stringify JSON.stringify = function (t) { try { - return delete Array.prototype.toJSON, N(t) + return delete Array.prototype.toJSON, j(t) } finally { - Array.prototype.toJSON = j + Array.prototype.toJSON = U } } } Object.keys || (Object.keys = - ((T = Object.prototype.hasOwnProperty), + ((H = Object.prototype.hasOwnProperty), (M = !Object.prototype.propertyIsEnumerable.call({ toString: null }, 'toString')), - (R = (V = [ + (P = (R = [ 'toString', 'toLocaleString', 'valueOf', @@ -1223,8 +1223,8 @@ var e, i, n = [] - for (e in t) T.call(t, e) && n.push(e) - if (M) for (i = 0; i < R; i++) T.call(t, V[i]) && n.push(V[i]) + for (e in t) H.call(t, e) && n.push(e) + if (M) for (i = 0; i < P; i++) H.call(t, R[i]) && n.push(R[i]) return n })), /*! Raven.js 3.27.2 (6d91db933) | github.com/getsentry/raven-js */ (function (t) { @@ -1242,20 +1242,20 @@ } })(function () { return (function t(e, i, n) { - function o(r, a) { - if (!i[r]) { - if (!e[r]) { - var l = 'function' == typeof require && require - if (!a && l) return l(r, !0) - if (s) return s(r, !0) - var c = new Error("Cannot find module '" + r + "'") - throw ((c.code = 'MODULE_NOT_FOUND'), c) + function o(s, a) { + if (!i[s]) { + if (!e[s]) { + var c = 'function' == typeof require && require + if (!a && c) return c(s, !0) + if (r) return r(s, !0) + var l = new Error("Cannot find module '" + s + "'") + throw ((l.code = 'MODULE_NOT_FOUND'), l) } - var h = (i[r] = { exports: {} }) - e[r][0].call( + var h = (i[s] = { exports: {} }) + e[s][0].call( h.exports, function (t) { - var i = e[r][1][t] + var i = e[s][1][t] return o(i || t) }, h, @@ -1266,9 +1266,9 @@ n, ) } - return i[r].exports + return i[s].exports } - for (var s = 'function' == typeof require && require, r = 0; r < n.length; r++) o(n[r]) + for (var r = 'function' == typeof require && require, s = 0; s < n.length; s++) o(n[s]) return o })( { @@ -1287,22 +1287,22 @@ e.exports = { wrapMethod: function (t, e, i) { var o = t[e], - s = t + r = t if (e in t) { - var r = 'warn' === e ? 'warning' : e + var s = 'warn' === e ? 'warning' : e t[e] = function () { var t = [].slice.call(arguments), a = n.safeJoin(t, ' '), - l = { level: r, logger: 'console', extra: { arguments: t } } + c = { level: s, logger: 'console', extra: { arguments: t } } 'assert' === e ? !1 === t[0] && ((a = 'Assertion failed: ' + (n.safeJoin(t.slice(1), ' ') || 'console.assert')), - (l.extra.arguments = t.slice(1)), - i && i(a, l)) - : i && i(a, l), - o && Function.prototype.apply.call(o, s, t) + (c.extra.arguments = t.slice(1)), + i && i(a, c)) + : i && i(a, c), + o && Function.prototype.apply.call(o, r, t) } } }, @@ -1323,10 +1323,10 @@ } : e } - function s() { + function r() { for (var t in ((this.a = !('object' != typeof JSON || !JSON.stringify)), - (this.b = !g(Z)), - (this.c = !g(U)), + (this.b = !g(z)), + (this.c = !g(Z)), (this.d = null), (this.e = null), (this.f = null), @@ -1335,7 +1335,7 @@ (this.i = null), (this.j = {}), (this.k = { - release: z.SENTRY_RELEASE && z.SENTRY_RELEASE.id, + release: N.SENTRY_RELEASE && N.SENTRY_RELEASE.id, logger: 'javascript', ignoreErrors: [], ignoreUrls: [], @@ -1352,33 +1352,33 @@ sampleRate: 1, sanitizeKeys: [], }), - (this.l = { method: 'POST', referrerPolicy: F() ? 'origin' : '' }), + (this.l = { method: 'POST', referrerPolicy: I() ? 'origin' : '' }), (this.m = 0), (this.n = !1), (this.o = Error.stackTraceLimit), - (this.p = z.console || {}), + (this.p = N.console || {}), (this.q = {}), (this.r = []), (this.s = n()), (this.t = []), (this.u = []), (this.v = null), - (this.w = z.location), + (this.w = N.location), (this.x = this.w && this.w.href), this.y(), this.p)) { this.q[t] = this.p[t] } } - var r = t(6), + var s = t(6), a = t(7), - l = t(8), - c = t(1), + c = t(8), + l = t(1), h = t(5), u = h.isErrorEvent, - d = h.isDOMError, - p = h.isDOMException, - f = h.isError, + f = h.isDOMError, + d = h.isDOMException, + p = h.isError, m = h.isObject, y = h.isPlainObject, g = h.isUndefined, @@ -1386,28 +1386,28 @@ b = h.isString, w = h.isArray, x = h.isEmptyObject, - C = h.each, - k = h.objectMerge, + k = h.each, + C = h.objectMerge, _ = h.truncate, E = h.objectFrozen, - S = h.hasKey, - A = h.joinRegExp, - L = h.urlencode, - B = h.uuid4, - H = h.htmlTreeAsString, + A = h.hasKey, + S = h.joinRegExp, + B = h.urlencode, + L = h.uuid4, + T = h.htmlTreeAsString, O = h.isSameException, - T = h.isSameStacktrace, + H = h.isSameStacktrace, M = h.parseUrl, - V = h.fill, - R = h.supportsFetch, - F = h.supportsReferrerPolicy, - P = h.serializeKeysForMessage, + R = h.fill, + P = h.supportsFetch, + I = h.supportsReferrerPolicy, + V = h.serializeKeysForMessage, D = h.serializeException, - I = h.sanitize, + F = h.sanitize, $ = t(2).wrapMethod, - j = 'source protocol user pass host port path'.split(' '), - N = /^(?:(\w+):)?\/\/(?:(\w+)(:\w+)?@)?([\w\.-]+)(?::(\d+))?(\/.*)/, - z = + U = 'source protocol user pass host port path'.split(' '), + j = /^(?:(\w+):)?\/\/(?:(\w+)(:\w+)?@)?([\w\.-]+)(?::(\d+))?(\/.*)/, + N = 'undefined' != typeof window ? window : void 0 !== i @@ -1415,41 +1415,41 @@ : 'undefined' != typeof self ? self : {}, - Z = z.document, - U = z.navigator - ;(s.prototype = { + z = N.document, + Z = N.navigator + ;(r.prototype = { VERSION: '3.27.2', debug: !1, - TraceKit: r, + TraceKit: s, config: function (t, e) { var i = this if (i.g) return this.z('error', 'Error: Raven has already been configured'), i if (!t) return i var n = i.k e && - C(e, function (t, e) { + k(e, function (t, e) { 'tags' === t || 'extra' === t || 'user' === t ? (i.j[t] = e) : (n[t] = e) }), i.setDSN(t), n.ignoreErrors.push(/^Script error\.?$/), n.ignoreErrors.push(/^Javascript error: Script error\.? on line 0$/), - (n.ignoreErrors = A(n.ignoreErrors)), - (n.ignoreUrls = !!n.ignoreUrls.length && A(n.ignoreUrls)), - (n.whitelistUrls = !!n.whitelistUrls.length && A(n.whitelistUrls)), - (n.includePaths = A(n.includePaths)), + (n.ignoreErrors = S(n.ignoreErrors)), + (n.ignoreUrls = !!n.ignoreUrls.length && S(n.ignoreUrls)), + (n.whitelistUrls = !!n.whitelistUrls.length && S(n.whitelistUrls)), + (n.includePaths = S(n.includePaths)), (n.maxBreadcrumbs = Math.max(0, Math.min(n.maxBreadcrumbs || 100, 100))) var o = { xhr: !0, console: !0, dom: !0, location: !0, sentry: !0 }, - s = n.autoBreadcrumbs - '[object Object]' === {}.toString.call(s) ? (s = k(o, s)) : !1 !== s && (s = o), - (n.autoBreadcrumbs = s) + r = n.autoBreadcrumbs + '[object Object]' === {}.toString.call(r) ? (r = C(o, r)) : !1 !== r && (r = o), + (n.autoBreadcrumbs = r) var a = { tryCatch: !0 }, - l = n.instrument + c = n.instrument return ( - '[object Object]' === {}.toString.call(l) - ? (l = k(a, l)) - : !1 !== l && (l = a), - (n.instrument = l), - (r.collectWindowErrors = !!n.collectWindowErrors), + '[object Object]' === {}.toString.call(c) + ? (c = C(a, c)) + : !1 !== c && (c = a), + (n.instrument = c), + (s.collectWindowErrors = !!n.collectWindowErrors), i ) }, @@ -1458,7 +1458,7 @@ return ( t.isSetup() && !t.n && - (r.report.subscribe(function () { + (s.report.subscribe(function () { t.A.apply(t, arguments) }), t.k.captureUnhandledRejections && t.B(), @@ -1492,10 +1492,10 @@ wrap: function (t, e, i) { function n() { var n = [], - s = arguments.length, - r = !t || (t && !1 !== t.deep) - for (i && v(i) && i.apply(this, arguments); s--; ) { - n[s] = r ? o.wrap(t, arguments[s]) : arguments[s] + r = arguments.length, + s = !t || (t && !1 !== t.deep) + for (i && v(i) && i.apply(this, arguments); r--; ) { + n[r] = s ? o.wrap(t, arguments[r]) : arguments[r] } try { return e.apply(this, n) @@ -1509,15 +1509,15 @@ try { if (e.M) return e if (e.N) return e.N - } catch (s) { + } catch (r) { return e } - for (var r in e) S(e, r) && (n[r] = e[r]) + for (var s in e) A(e, s) && (n[s] = e[s]) return (n.prototype = e.prototype), (e.N = n), (n.M = !0), (n.O = e), n }, uninstall: function () { return ( - r.report.uninstall(), + s.report.uninstall(), this.P(), this.Q(), this.R(), @@ -1536,33 +1536,33 @@ B: function () { return ( (this.T = this.T.bind(this)), - z.addEventListener && z.addEventListener('unhandledrejection', this.T), + N.addEventListener && N.addEventListener('unhandledrejection', this.T), this ) }, P: function () { return ( - z.removeEventListener && z.removeEventListener('unhandledrejection', this.T), + N.removeEventListener && N.removeEventListener('unhandledrejection', this.T), this ) }, captureException: function (t, e) { - if (((e = k({ trimHeadFrames: 0 }, e || {})), u(t) && t.error)) t = t.error + if (((e = C({ trimHeadFrames: 0 }, e || {})), u(t) && t.error)) t = t.error else { - if (d(t) || p(t)) { - var i = t.name || (d(t) ? 'DOMError' : 'DOMException'), + if (f(t) || d(t)) { + var i = t.name || (f(t) ? 'DOMError' : 'DOMException'), n = t.message ? i + ': ' + t.message : i return this.captureMessage( n, - k(e, { stacktrace: !0, trimHeadFrames: e.trimHeadFrames + 1 }), + C(e, { stacktrace: !0, trimHeadFrames: e.trimHeadFrames + 1 }), ) } - if (f(t)); + if (p(t)) t = t else { if (!y(t)) { return this.captureMessage( t, - k(e, { stacktrace: !0, trimHeadFrames: e.trimHeadFrames + 1 }), + C(e, { stacktrace: !0, trimHeadFrames: e.trimHeadFrames + 1 }), ) } ;(e = this.U(e, t)), (t = new Error(e.message)) @@ -1570,18 +1570,18 @@ } this.d = t try { - var o = r.computeStackTrace(t) + var o = s.computeStackTrace(t) this.V(o, e) - } catch (s) { - if (t !== s) throw s + } catch (r) { + if (t !== r) throw r } return this }, U: function (t, e) { var i = Object.keys(e).sort(), - n = k(t, { - message: 'Non-Error exception captured with keys: ' + P(i), - fingerprint: [l(i)], + n = C(t, { + message: 'Non-Error exception captured with keys: ' + V(i), + fingerprint: [c(i)], extra: t.extra || {}, }) return (n.extra.W = D(e)), n @@ -1589,26 +1589,26 @@ captureMessage: function (t, e) { if (!this.k.ignoreErrors.test || !this.k.ignoreErrors.test(t)) { var i, - n = k({ message: (t += '') }, (e = e || {})) + n = C({ message: (t += '') }, (e = e || {})) try { throw new Error(t) } catch (o) { i = o } i.name = null - var s = r.computeStackTrace(i), - a = w(s.stack) && s.stack[1] - a && 'Raven.captureException' === a.func && (a = s.stack[2]) - var l = (a && a.url) || '' + var r = s.computeStackTrace(i), + a = w(r.stack) && r.stack[1] + a && 'Raven.captureException' === a.func && (a = r.stack[2]) + var c = (a && a.url) || '' if ( - (!this.k.ignoreUrls.test || !this.k.ignoreUrls.test(l)) && - (!this.k.whitelistUrls.test || this.k.whitelistUrls.test(l)) + (!this.k.ignoreUrls.test || !this.k.ignoreUrls.test(c)) && + (!this.k.whitelistUrls.test || this.k.whitelistUrls.test(c)) ) { if (this.k.stacktrace || e.stacktrace || '' === n.message) { ;(n.fingerprint = null == n.fingerprint ? t : n.fingerprint), - ((e = k({ trimHeadFrames: 0 }, e)).trimHeadFrames += 1) - var c = this.X(s, e) - n.stacktrace = { frames: c.reverse() } + ((e = C({ trimHeadFrames: 0 }, e)).trimHeadFrames += 1) + var l = this.X(r, e) + n.stacktrace = { frames: l.reverse() } } return ( n.fingerprint && @@ -1620,7 +1620,7 @@ } }, captureBreadcrumb: function (t) { - var e = k({ timestamp: n() / 1e3 }, t) + var e = C({ timestamp: n() / 1e3 }, t) if (v(this.k.breadcrumbCallback)) { var i = this.k.breadcrumbCallback(e) if (m(i) && !x(i)) e = i @@ -1687,20 +1687,20 @@ ) }, afterLoad: function () { - var t = z.RavenConfig + var t = N.RavenConfig t && this.config(t.dsn, t.config).install() }, showReportDialog: function (t) { - if (Z) { + if (z) { if ( - !(t = k( + !(t = C( { eventId: this.lastEventId(), dsn: this.H, user: this.j.user || {} }, t, )).eventId ) { - throw new c('Missing eventId') + throw new l('Missing eventId') } - if (!t.dsn) throw new c('Missing DSN') + if (!t.dsn) throw new l('Missing DSN') var e = encodeURIComponent, i = [] for (var n in t) { @@ -1710,11 +1710,11 @@ o.email && i.push('email=' + e(o.email)) } else i.push(e(n) + '=' + e(t[n])) } - var s = this.J(this.G(t.dsn)), - r = Z.createElement('script') - ;(r.async = !0), - (r.src = s + '/api/embed/error-page/?' + i.join('&')), - (Z.head || Z.body).appendChild(r) + var r = this.J(this.G(t.dsn)), + s = z.createElement('script') + ;(s.async = !0), + (s.src = r + '/api/embed/error-page/?' + i.join('&')), + (z.head || z.body).appendChild(s) } }, L: function () { @@ -1729,16 +1729,16 @@ if (this.b) { for (n in ((e = e || {}), (t = 'raven' + t.substr(0, 1).toUpperCase() + t.substr(1)), - Z.createEvent - ? (i = Z.createEvent('HTMLEvents')).initEvent(t, !0, !0) - : ((i = Z.createEventObject()).eventType = t), + z.createEvent + ? (i = z.createEvent('HTMLEvents')).initEvent(t, !0, !0) + : ((i = z.createEventObject()).eventType = t), e)) { - S(e, n) && (i[n] = e[n]) + A(e, n) && (i[n] = e[n]) } - if (Z.createEvent) Z.dispatchEvent(i) + if (z.createEvent) z.dispatchEvent(i) else { try { - Z.fireEvent('on' + i.eventType.toLowerCase(), i) + z.fireEvent('on' + i.eventType.toLowerCase(), i) } catch (o) {} } } @@ -1750,7 +1750,7 @@ var n e.v = i try { - n = H(i.target) + n = T(i.target) } catch (o) { n = '' } @@ -1769,9 +1769,9 @@ } var n = i && i.tagName if (n && ('INPUT' === n || 'TEXTAREA' === n || i.isContentEditable)) { - var s = t.aa - s || t._('input')(e), - clearTimeout(s), + var r = t.aa + r || t._('input')(e), + clearTimeout(r), (t.aa = setTimeout(function () { t.aa = null }, 1e3)) @@ -1802,12 +1802,12 @@ D: function () { function t(t) { return function (e, n) { - for (var o = new Array(arguments.length), s = 0; s < o.length; ++s) { - o[s] = arguments[s] + for (var o = new Array(arguments.length), r = 0; r < o.length; ++r) { + o[r] = arguments[r] } - var r = o[0] + var s = o[0] return ( - v(r) && + v(s) && (o[0] = i.wrap( { mechanism: { @@ -1815,47 +1815,47 @@ data: { function: t.name || '' }, }, }, - r, + s, )), t.apply ? t.apply(this, o) : t(o[0], o[1]) ) } } function e(t) { - var e = z[t] && z[t].prototype + var e = N[t] && N[t].prototype e && e.hasOwnProperty && e.hasOwnProperty('addEventListener') && - (V( + (R( e, 'addEventListener', function (e) { - return function (n, s, r, a) { + return function (n, r, s, a) { try { - s && - s.handleEvent && - (s.handleEvent = i.wrap( + r && + r.handleEvent && + (r.handleEvent = i.wrap( { mechanism: { type: 'instrument', data: { target: t, function: 'handleEvent', - handler: (s && s.name) || '', + handler: (r && r.name) || '', }, }, }, - s.handleEvent, + r.handleEvent, )) - } catch (l) {} - var c, h, u + } catch (c) {} + var l, h, u return ( o && o.dom && ('EventTarget' === t || 'Node' === t) && ((h = i._('click')), (u = i.ba()), - (c = function (t) { + (l = function (t) { if (t) { var e try { @@ -1876,14 +1876,14 @@ data: { target: t, function: 'addEventListener', - handler: (s && s.name) || '', + handler: (r && r.name) || '', }, }, }, - s, - c, + r, + l, ), - r, + s, a, ) ) @@ -1891,14 +1891,14 @@ }, n, ), - V( + R( e, 'removeEventListener', function (t) { return function (e, i, n, o) { try { i = i && (i.N ? i.N : i) - } catch (s) {} + } catch (r) {} return t.call(this, e, i, n, o) } }, @@ -1908,11 +1908,11 @@ var i = this, n = i.t, o = this.k.autoBreadcrumbs - V(z, 'setTimeout', t, n), - V(z, 'setInterval', t, n), - z.requestAnimationFrame && - V( - z, + R(N, 'setTimeout', t, n), + R(N, 'setInterval', t, n), + N.requestAnimationFrame && + R( + N, 'requestAnimationFrame', function (t) { return function (e) { @@ -1935,7 +1935,7 @@ n, ) for ( - var s = [ + var r = [ 'EventTarget', 'Window', 'Node', @@ -1966,18 +1966,18 @@ 'XMLHttpRequestEventTarget', 'XMLHttpRequestUpload', ], - r = 0; - r < s.length; - r++ + s = 0; + s < r.length; + s++ ) { - e(s[r]) + e(r[s]) } }, E: function () { function t(t, i) { t in i && v(i[t]) && - V(i, t, function (i) { + R(i, t, function (i) { return e.wrap( { mechanism: { @@ -1992,9 +1992,9 @@ var e = this, i = this.k.autoBreadcrumbs, n = e.t - if (i.xhr && 'XMLHttpRequest' in z) { - var o = z.XMLHttpRequest && z.XMLHttpRequest.prototype - V( + if (i.xhr && 'XMLHttpRequest' in N) { + var o = N.XMLHttpRequest && N.XMLHttpRequest.prototype + R( o, 'open', function (t) { @@ -2009,7 +2009,7 @@ }, n, ), - V( + R( o, 'send', function (i) { @@ -2023,15 +2023,15 @@ } } for ( - var o = this, s = ['onload', 'onerror', 'onprogress'], r = 0; - r < s.length; - r++ + var o = this, r = ['onload', 'onerror', 'onprogress'], s = 0; + s < r.length; + s++ ) { - t(s[r], o) + t(r[s], o) } return ( 'onreadystatechange' in o && v(o.onreadystatechange) - ? V(o, 'onreadystatechange', function (t) { + ? R(o, 'onreadystatechange', function (t) { return e.wrap( { mechanism: { @@ -2055,9 +2055,9 @@ ) } i.xhr && - R() && - V( - z, + P() && + R( + N, 'fetch', function (t) { return function () { @@ -2065,20 +2065,20 @@ i[n] = arguments[n] } var o, - s = i[0], - r = 'GET' + r = i[0], + s = 'GET' if ( - ('string' == typeof s - ? (o = s) - : 'Request' in z && s instanceof z.Request - ? ((o = s.url), s.method && (r = s.method)) - : (o = '' + s), + ('string' == typeof r + ? (o = r) + : 'Request' in N && r instanceof N.Request + ? ((o = r.url), r.method && (s = r.method)) + : (o = '' + r), -1 !== o.indexOf(e.h)) ) { return t.apply(this, i) } - i[1] && i[1].method && (r = i[1].method) - var a = { method: r, url: o, status_code: null } + i[1] && i[1].method && (s = i[1].method) + var a = { method: s, url: o, status_code: null } return t .apply(this, i) .then(function (t) { @@ -2105,38 +2105,38 @@ ), i.dom && this.b && - (Z.addEventListener - ? (Z.addEventListener('click', e._('click'), !1), - Z.addEventListener('keypress', e.ba(), !1)) - : Z.attachEvent && - (Z.attachEvent('onclick', e._('click')), - Z.attachEvent('onkeypress', e.ba()))) - var s = z.chrome, - r = - !(s && s.app && s.app.runtime) && - z.history && - z.history.pushState && - z.history.replaceState - if (i.location && r) { - var a = z.onpopstate - z.onpopstate = function () { + (z.addEventListener + ? (z.addEventListener('click', e._('click'), !1), + z.addEventListener('keypress', e.ba(), !1)) + : z.attachEvent && + (z.attachEvent('onclick', e._('click')), + z.attachEvent('onkeypress', e.ba()))) + var r = N.chrome, + s = + !(r && r.app && r.app.runtime) && + N.history && + N.history.pushState && + N.history.replaceState + if (i.location && s) { + var a = N.onpopstate + N.onpopstate = function () { var t = e.w.href if ((e.ca(e.x, t), a)) return a.apply(this, arguments) } - var l = function (t) { + var c = function (t) { return function () { var i = arguments.length > 2 ? arguments[2] : void 0 return i && e.ca(e.x, i + ''), t.apply(this, arguments) } } - V(z.history, 'pushState', l, n), V(z.history, 'replaceState', l, n) + R(N.history, 'pushState', c, n), R(N.history, 'replaceState', c, n) } - if (i.console && 'console' in z && console.log) { - var c = function (t, i) { + if (i.console && 'console' in N && console.log) { + var l = function (t, i) { e.captureBreadcrumb({ message: t, level: i.level, category: 'console' }) } - C(['debug', 'info', 'warn', 'error', 'log'], function (t, e) { - $(console, e, c) + k(['debug', 'info', 'warn', 'error', 'log'], function (t, e) { + $(console, e, l) }) } }, @@ -2153,23 +2153,23 @@ }, F: function () { var t = this - C(this.r, function (e, i) { + k(this.r, function (e, i) { var n = i[0], o = i[1] n.apply(t, [t].concat(o)) }) }, G: function (t) { - var e = N.exec(t), + var e = j.exec(t), i = {}, n = 7 try { - for (; n--; ) i[j[n]] = e[n] || '' + for (; n--; ) i[U[n]] = e[n] || '' } catch (o) { - throw new c('Invalid DSN: ' + t) + throw new l('Invalid DSN: ' + t) } if (i.pass && !this.k.allowSecretKey) { - throw new c( + throw new l( 'Do not specify your secret key in the DSN. See: http://bit.ly/raven-secret-key', ) } @@ -2194,9 +2194,9 @@ if ( t.stack && t.stack.length && - (C(t.stack, function (e, o) { - var s = i.ga(o, t.url) - s && n.push(s) + (k(t.stack, function (e, o) { + var r = i.ga(o, t.url) + r && n.push(r) }), e && e.trimHeadFrames) ) { @@ -2221,35 +2221,35 @@ i ) }, - fa: function (t, e, i, n, o, s) { - var r, + fa: function (t, e, i, n, o, r) { + var s, a = (t ? t + ': ' : '') + (e || '') if ( (!this.k.ignoreErrors.test || (!this.k.ignoreErrors.test(e) && !this.k.ignoreErrors.test(a))) && (o && o.length - ? ((i = o[0].filename || i), o.reverse(), (r = { frames: o })) - : i && (r = { frames: [{ filename: i, lineno: n, in_app: !0 }] }), + ? ((i = o[0].filename || i), o.reverse(), (s = { frames: o })) + : i && (s = { frames: [{ filename: i, lineno: n, in_app: !0 }] }), (!this.k.ignoreUrls.test || !this.k.ignoreUrls.test(i)) && (!this.k.whitelistUrls.test || this.k.whitelistUrls.test(i))) ) { - var l = k( + var c = C( { - exception: { values: [{ type: t, value: e, stacktrace: r }] }, + exception: { values: [{ type: t, value: e, stacktrace: s }] }, transaction: i, }, - s, + r, ), - c = l.exception.values[0] - null == c.type && '' === c.value && (c.value = 'Unrecoverable error caught'), - !l.exception.mechanism && - l.mechanism && - ((l.exception.mechanism = l.mechanism), delete l.mechanism), - (l.exception.mechanism = k( + l = c.exception.values[0] + null == l.type && '' === l.value && (l.value = 'Unrecoverable error caught'), + !c.exception.mechanism && + c.mechanism && + ((c.exception.mechanism = c.mechanism), delete c.mechanism), + (c.exception.mechanism = C( { type: 'generic', handled: !0 }, - l.exception.mechanism || {}, + c.exception.mechanism || {}, )), - this.Y(l) + this.Y(c) } }, ha: function (t) { @@ -2268,14 +2268,14 @@ ) }, ia: function (t) { - for (var e, i, n, o = ['to', 'from', 'url'], s = 0; s < t.values.length; ++s) { - if ((i = t.values[s]).hasOwnProperty('data') && m(i.data) && !E(i.data)) { - n = k({}, i.data) - for (var r = 0; r < o.length; ++r) { - ;(e = o[r]), + for (var e, i, n, o = ['to', 'from', 'url'], r = 0; r < t.values.length; ++r) { + if ((i = t.values[r]).hasOwnProperty('data') && m(i.data) && !E(i.data)) { + n = C({}, i.data) + for (var s = 0; s < o.length; ++s) { + ;(e = o[s]), n.hasOwnProperty(e) && n[e] && (n[e] = _(n[e], this.k.maxUrlLength)) } - t.values[s].data = n + t.values[r].data = n } } }, @@ -2283,11 +2283,11 @@ if (this.c || this.b) { var t = {} return ( - this.c && U.userAgent && (t.headers = { 'User-Agent': U.userAgent }), - z.location && z.location.href && (t.url = z.location.href), + this.c && Z.userAgent && (t.headers = { 'User-Agent': Z.userAgent }), + N.location && N.location.href && (t.url = N.location.href), this.b && - Z.referrer && - (t.headers || (t.headers = {}), (t.headers.Referer = Z.referrer)), + z.referrer && + (t.headers || (t.headers = {}), (t.headers.Referer = z.referrer)), t ) } @@ -2303,7 +2303,7 @@ return ( !(!e || t.message !== e.message || t.transaction !== e.transaction) && (t.stacktrace || e.stacktrace - ? T(t.stacktrace, e.stacktrace) + ? H(t.stacktrace, e.stacktrace) : t.exception || e.exception ? O(t.exception, e.exception) : (!t.fingerprint && !e.fingerprint) || @@ -2317,7 +2317,7 @@ if (400 === e || 401 === e || 429 === e) { var i try { - ;(i = R() + ;(i = P() ? t.headers.get('Retry-After') : t.getResponseHeader('Retry-After')), (i = 1e3 * parseInt(i, 10)) @@ -2333,8 +2333,8 @@ if ( (o && (i.request = o), t.trimHeadFrames && delete t.trimHeadFrames, - ((t = k(i, t)).tags = k(k({}, this.j.tags), t.tags)), - (t.extra = k(k({}, this.j.extra), t.extra)), + ((t = C(i, t)).tags = C(C({}, this.j.tags), t.tags)), + (t.extra = C(C({}, this.j.extra), t.extra)), (t.extra['session:duration'] = n() - this.s), this.u && this.u.length > 0 && @@ -2358,10 +2358,10 @@ } }, pa: function (t) { - return I(t, this.k.sanitizeKeys) + return F(t, this.k.sanitizeKeys) }, ra: function () { - return B() + return L() }, qa: function (t, e) { var i = this, @@ -2379,28 +2379,28 @@ sentry_key: this.h, } this.I && (o.sentry_secret = this.I) - var s = t.exception && t.exception.values[0] + var r = t.exception && t.exception.values[0] this.k.autoBreadcrumbs && this.k.autoBreadcrumbs.sentry && this.captureBreadcrumb({ category: 'sentry', - message: s ? (s.type ? s.type + ': ' : '') + s.value : t.message, + message: r ? (r.type ? r.type + ': ' : '') + r.value : t.message, event_id: t.event_id, level: t.level || 'error', }) - var r = this.K + var s = this.K ;(n.transport || this._makeRequest).call(this, { - url: r, + url: s, auth: o, data: t, options: n, onSuccess: function () { - i.y(), i.$('success', { data: t, src: r }), e && e() + i.y(), i.$('success', { data: t, src: s }), e && e() }, onError: function (n) { i.z('error', 'Raven transport failed to send: ', n), n.request && i.oa(n.request), - i.$('failure', { data: t, src: r }), + i.$('failure', { data: t, src: s }), (n = n || new Error('Raven send failed (no additional details provided)')), e && e(n) @@ -2409,21 +2409,20 @@ } }, _makeRequest: function (t) { - var e = t.url + '?' + L(t.auth), + var e = t.url + '?' + B(t.auth), i = null, n = {} if ( (t.options.headers && (i = this.sa(t.options.headers)), t.options.fetchParameters && (n = this.sa(t.options.fetchParameters)), - R()) + P()) ) { n.body = a(t.data) - var o = k({}, this.l), - s = k(o, n) + var o = C({}, this.l), + r = C(o, n) return ( - i && (s.headers = i), - z - .fetch(e, s) + i && (r.headers = i), + N.fetch(e, r) .then(function (e) { if (e.ok) t.onSuccess && t.onSuccess() else { @@ -2437,33 +2436,33 @@ }) ) } - var r = z.XMLHttpRequest && new z.XMLHttpRequest() - r && - ('withCredentials' in r || 'undefined' != typeof XDomainRequest) && - ('withCredentials' in r - ? (r.onreadystatechange = function () { - if (4 === r.readyState) { - if (200 === r.status) t.onSuccess && t.onSuccess() + var s = N.XMLHttpRequest && new N.XMLHttpRequest() + s && + ('withCredentials' in s || 'undefined' != typeof XDomainRequest) && + ('withCredentials' in s + ? (s.onreadystatechange = function () { + if (4 === s.readyState) { + if (200 === s.status) t.onSuccess && t.onSuccess() else if (t.onError) { - var e = new Error('Sentry error code: ' + r.status) - ;(e.request = r), t.onError(e) + var e = new Error('Sentry error code: ' + s.status) + ;(e.request = s), t.onError(e) } } }) - : ((r = new XDomainRequest()), + : ((s = new XDomainRequest()), (e = e.replace(/^https?:/, '')), - t.onSuccess && (r.onload = t.onSuccess), + t.onSuccess && (s.onload = t.onSuccess), t.onError && - (r.onerror = function () { + (s.onerror = function () { var e = new Error('Sentry error code: XDomainRequest') - ;(e.request = r), t.onError(e) + ;(e.request = s), t.onError(e) })), - r.open('POST', e), + s.open('POST', e), i && - C(i, function (t, e) { - r.setRequestHeader(t, e) + k(i, function (t, e) { + s.setRequestHeader(t, e) }), - r.send(a(t.data))) + s.send(a(t.data))) }, sa: function (t) { var e = {} @@ -2481,12 +2480,12 @@ Function.prototype.apply.call(this.q[t], this.p, [].slice.call(arguments, 1)) }, Z: function (t, e) { - g(e) ? delete this.j[t] : (this.j[t] = k(this.j[t] || {}, e)) + g(e) ? delete this.j[t] : (this.j[t] = C(this.j[t] || {}, e)) }, }), - (s.prototype.setUser = s.prototype.setUserContext), - (s.prototype.setReleaseContext = s.prototype.setRelease), - (e.exports = s) + (r.prototype.setUser = r.prototype.setUserContext), + (r.prototype.setReleaseContext = r.prototype.setRelease), + (e.exports = r) }.call( this, 'undefined' != typeof global @@ -2512,13 +2511,13 @@ : 'undefined' != typeof self ? self : {}, - s = o.Raven, - r = new n() - ;(r.noConflict = function () { - return (o.Raven = s), r + r = o.Raven, + s = new n() + ;(s.noConflict = function () { + return (o.Raven = r), s }), - r.afterLoad(), - (e.exports = r), + s.afterLoad(), + (e.exports = s), (e.exports.Client = n) }.call( this, @@ -2549,19 +2548,19 @@ function o(t) { return '[object DOMError]' === Object.prototype.toString.call(t) } - function s(t) { + function r(t) { return void 0 === t } - function r(t) { + function s(t) { return '[object Object]' === Object.prototype.toString.call(t) } function a(t) { return '[object String]' === Object.prototype.toString.call(t) } - function l(t) { + function c(t) { return '[object Array]' === Object.prototype.toString.call(t) } - function c() { + function l() { if (!('fetch' in x)) return !1 try { return new Headers(), new Request(''), new Response(), !0 @@ -2571,7 +2570,7 @@ } function h(t, e) { var i, n - if (s(t.length)) for (i in t) d(t, i) && e.call(null, i, t[i]) + if (r(t.length)) for (i in t) f(t, i) && e.call(null, i, t[i]) else if ((n = t.length)) for (i = 0; i < n; i++) e.call(null, i, t[i]) } function u(t, e) { @@ -2582,10 +2581,10 @@ ? t : t.substr(0, e) + '…' } - function d(t, e) { + function f(t, e) { return Object.prototype.hasOwnProperty.call(t, e) } - function p(t) { + function d(t) { for (var e, i = [], n = 0, o = t.length; n < o; n++) { a((e = t[n])) ? i.push(e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1')) @@ -2593,26 +2592,26 @@ } return new RegExp(i.join('|'), 'i') } - function f(t) { + function p(t) { var e, i, n, o, - s, - r = [] + r, + s = [] if (!t || !t.tagName) return '' if ( - (r.push(t.tagName.toLowerCase()), - t.id && r.push('#' + t.id), + (s.push(t.tagName.toLowerCase()), + t.id && s.push('#' + t.id), (e = t.className) && a(e)) ) { - for (i = e.split(/\s+/), s = 0; s < i.length; s++) r.push('.' + i[s]) + for (i = e.split(/\s+/), r = 0; r < i.length; r++) s.push('.' + i[r]) } - var l = ['type', 'name', 'title', 'alt'] - for (s = 0; s < l.length; s++) { - ;(n = l[s]), (o = t.getAttribute(n)) && r.push('[' + n + '="' + o + '"]') + var c = ['type', 'name', 'title', 'alt'] + for (r = 0; r < c.length; r++) { + ;(n = c[r]), (o = t.getAttribute(n)) && s.push('[' + n + '="' + o + '"]') } - return r.join('') + return s.join('') } function m(t, e) { return !!(!!t ^ !!e) @@ -2623,14 +2622,14 @@ n = e.frames if (void 0 === i || void 0 === n) return !1 if (i.length !== n.length) return !1 - for (var o, s, r = 0; r < i.length; r++) { + for (var o, r, s = 0; s < i.length; s++) { if ( - ((o = i[r]), - (s = n[r]), - o.filename !== s.filename || - o.lineno !== s.lineno || - o.colno !== s.colno || - o['function'] !== s['function']) + ((o = i[s]), + (r = n[s]), + o.filename !== r.filename || + o.lineno !== r.lineno || + o.colno !== r.colno || + o['function'] !== r['function']) ) { return !1 } @@ -2661,7 +2660,7 @@ function b(t, e) { return 0 === e ? v(t) - : r(t) + : s(t) ? Object.keys(t).reduce(function (i, n) { return (i[n] = b(t[n], e - 1)), i }, {}) @@ -2680,8 +2679,8 @@ : 'undefined' != typeof self ? self : {}, - C = 3, - k = 51200, + k = 3, + C = 51200, _ = 40 e.exports = { isObject: function (t) { @@ -2695,15 +2694,15 @@ isDOMException: function (t) { return '[object DOMException]' === Object.prototype.toString.call(t) }, - isUndefined: s, + isUndefined: r, isFunction: function (t) { return 'function' == typeof t }, - isPlainObject: r, + isPlainObject: s, isString: a, - isArray: l, + isArray: c, isEmptyObject: function (t) { - if (!r(t)) return !1 + if (!s(t)) return !1 for (var e in t) if (t.hasOwnProperty(e)) return !1 return !0 }, @@ -2728,9 +2727,9 @@ return !1 } }, - supportsFetch: c, + supportsFetch: l, supportsReferrerPolicy: function () { - if (!c()) return !1 + if (!l()) return !1 try { return new Request('pickleRick', { referrerPolicy: 'origin' }), !0 } catch (t) { @@ -2759,8 +2758,8 @@ objectFrozen: function (t) { return !!Object.isFrozen && Object.isFrozen(t) }, - hasKey: d, - joinRegExp: p, + hasKey: f, + joinRegExp: d, urlencode: function (t) { var e = [] return ( @@ -2772,7 +2771,7 @@ }, uuid4: function () { var t = x.crypto || x.msCrypto - if (!s(t) && t.getRandomValues) { + if (!r(t) && t.getRandomValues) { var e = new Uint16Array(8) t.getRandomValues(e), (e[3] = (4095 & e[3]) | 16384), @@ -2799,17 +2798,17 @@ }, htmlTreeAsString: function (t) { for ( - var e, i = [], n = 0, o = 0, s = ' > '.length; + var e, i = [], n = 0, o = 0, r = ' > '.length; t && n++ < 5 && - !('html' === (e = f(t)) || (n > 1 && o + i.length * s + e.length >= 80)); + !('html' === (e = p(t)) || (n > 1 && o + i.length * r + e.length >= 80)); ) { i.push(e), (o += e.length), (t = t.parentNode) } return i.reverse().join(' > ') }, - htmlElementAsString: f, + htmlElementAsString: p, isSameException: function (t, e) { return ( !m(t, e) && @@ -2818,7 +2817,7 @@ t.type === e.type && t.value === e.value && !(function (t, e) { - return s(t) && s(e) + return r(t) && r(e) })(t.stacktrace, e.stacktrace) && y(t.stacktrace, e.stacktrace)) ) @@ -2840,7 +2839,7 @@ } }, safeJoin: function (t, e) { - if (!l(t)) return '' + if (!c(t)) return '' for (var i = [], o = 0; o < t.length; o++) { try { i.push(String(t[o])) @@ -2851,8 +2850,8 @@ return i.join(e) }, serializeException: function E(t, e, i) { - if (!r(t)) return t - i = 'number' != typeof (e = 'number' != typeof e ? C : e) ? k : i + if (!s(t)) return t + i = 'number' != typeof (e = 'number' != typeof e ? k : e) ? C : i var n = b(t, e) return g(w(n)) > i ? E(t, e - 1) : n }, @@ -2875,23 +2874,23 @@ return '' }, sanitize: function (t, e) { - if (!l(e) || (l(e) && 0 === e.length)) return t + if (!c(e) || (c(e) && 0 === e.length)) return t var i, - n = p(e), - s = '********' + n = d(e), + r = '********' try { i = JSON.parse(w(t)) } catch (o) { return t } return (function a(t) { - return l(t) + return c(t) ? t.map(function (t) { return a(t) }) - : r(t) + : s(t) ? Object.keys(t).reduce(function (e, i) { - return (e[i] = n.test(i) ? s : a(t[i])), e + return (e[i] = n.test(i) ? r : a(t[i])), e }, {}) : t })(i) @@ -2919,8 +2918,8 @@ : document.location.href } var o = t(5), - s = { collectWindowErrors: !0, debug: !1 }, - r = + r = { collectWindowErrors: !0, debug: !1 }, + s = 'undefined' != typeof window ? window : void 0 !== i @@ -2929,17 +2928,17 @@ ? self : {}, a = [].slice, - l = '?', - c = + c = '?', + l = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/ - ;(s.report = (function () { + ;(r.report = (function () { function t(e, i) { var n = null - if (!i || s.collectWindowErrors) { - for (var o in p) { - if (p.hasOwnProperty(o)) { + if (!i || r.collectWindowErrors) { + for (var o in d) { + if (d.hasOwnProperty(o)) { try { - p[o].apply(null, [e].concat(a.call(arguments, 2))) + d[o].apply(null, [e].concat(a.call(arguments, 2))) } catch (t) { n = t } @@ -2948,26 +2947,26 @@ if (n) throw n } } - function e(e, r, a, h, d) { - var p = o.isErrorEvent(d) ? d.error : d, - f = o.isErrorEvent(e) ? e.message : e - if (y) s.computeStackTrace.augmentStackTraceWithInitialElement(y, r, a, f), i() - else if (p && o.isError(p)) t(s.computeStackTrace(p), !0) + function e(e, s, a, h, f) { + var d = o.isErrorEvent(f) ? f.error : f, + p = o.isErrorEvent(e) ? e.message : e + if (y) r.computeStackTrace.augmentStackTraceWithInitialElement(y, s, a, p), i() + else if (d && o.isError(d)) t(r.computeStackTrace(d), !0) else { var m, - g = { url: r, line: a, column: h }, + g = { url: s, line: a, column: h }, v = void 0 - if ('[object String]' === {}.toString.call(f)) { - ;(m = f.match(c)) && ((v = m[1]), (f = m[2])) + if ('[object String]' === {}.toString.call(p)) { + ;(m = p.match(l)) && ((v = m[1]), (p = m[2])) } - ;(g.func = l), t({ name: v, message: f, url: n(), stack: [g] }, !0) + ;(g.func = c), t({ name: v, message: p, url: n(), stack: [g] }, !0) } return !!u && u.apply(this, arguments) } function i() { var e = y, - i = f - ;(f = null), (y = null), (m = null), t.apply(null, [e, !1].concat(i)) + i = p + ;(p = null), (y = null), (m = null), t.apply(null, [e, !1].concat(i)) } function h(t, e) { var n = a.call(arguments, 1) @@ -2975,11 +2974,11 @@ if (m === t) return i() } - var o = s.computeStackTrace(t) + var o = r.computeStackTrace(t) if ( ((y = o), (m = t), - (f = n), + (p = n), setTimeout( function () { m === t && i() @@ -2992,47 +2991,47 @@ } } var u, - d, - p = [], - f = null, + f, + d = [], + p = null, m = null, y = null return ( (h.subscribe = function (t) { - d || ((u = r.onerror), (r.onerror = e), (d = !0)), p.push(t) + f || ((u = s.onerror), (s.onerror = e), (f = !0)), d.push(t) }), (h.unsubscribe = function (t) { - for (var e = p.length - 1; e >= 0; --e) p[e] === t && p.splice(e, 1) + for (var e = d.length - 1; e >= 0; --e) d[e] === t && d.splice(e, 1) }), (h.uninstall = function () { - d && ((r.onerror = u), (d = !1), (u = void 0)), (p = []) + f && ((s.onerror = u), (f = !1), (u = void 0)), (d = []) }), h ) })()), - (s.computeStackTrace = (function () { + (r.computeStackTrace = (function () { function t(t) { if ('undefined' != typeof t.stack && t.stack) { for ( var e, i, o, - s = - /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack||[a-z]:|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, r = + /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack||[a-z]:|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, + s = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx(?:-web)|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i, a = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i, - c = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i, + l = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i, h = /\((\S*)(?::(\d+))(?::(\d+))\)/, u = t.stack.split('\n'), - d = [], - p = (/^(.*) is undefined$/.exec(t.message), 0), - f = u.length; - p < f; - ++p + f = [], + d = (/^(.*) is undefined$/.exec(t.message), 0), + p = u.length; + d < p; + ++d ) { - if ((i = s.exec(u[p]))) { + if ((i = r.exec(u[d]))) { var m = i[2] && 0 === i[2].indexOf('native') i[2] && 0 === i[2].indexOf('eval') && @@ -3040,37 +3039,37 @@ ((i[2] = e[1]), (i[3] = e[2]), (i[4] = e[3])), (o = { url: m ? null : i[2], - func: i[1] || l, + func: i[1] || c, args: m ? [i[2]] : [], line: i[3] ? +i[3] : null, column: i[4] ? +i[4] : null, }) - } else if ((i = r.exec(u[p]))) { + } else if ((i = s.exec(u[d]))) { o = { url: i[2], - func: i[1] || l, + func: i[1] || c, args: [], line: +i[3], column: i[4] ? +i[4] : null, } } else { - if (!(i = a.exec(u[p]))) continue - i[3] && i[3].indexOf(' > eval') > -1 && (e = c.exec(i[3])) + if (!(i = a.exec(u[d]))) continue + i[3] && i[3].indexOf(' > eval') > -1 && (e = l.exec(i[3])) ? ((i[3] = e[1]), (i[4] = e[2]), (i[5] = null)) - : 0 !== p || + : 0 !== d || i[5] || 'undefined' == typeof t.columnNumber || - (d[0].column = t.columnNumber + 1), + (f[0].column = t.columnNumber + 1), (o = { url: i[3], - func: i[1] || l, + func: i[1] || c, args: i[2] ? i[2].split(',') : [], line: i[4] ? +i[4] : null, column: i[5] ? +i[5] : null, }) } if ( - (!o.func && o.line && (o.func = l), + (!o.func && o.line && (o.func = c), o.url && 'blob:' === o.url.substr(0, 5)) ) { var y = new XMLHttpRequest() @@ -3095,10 +3094,10 @@ } } } - d.push(o) + f.push(o) } - return d.length - ? { name: t.name, message: t.message, url: n(), stack: d } + return f.length + ? { name: t.name, message: t.message, url: n(), stack: f } : null } } @@ -3107,7 +3106,7 @@ if (o.url && o.line) { if ( ((t.incomplete = !1), - o.func || (o.func = l), + o.func || (o.func = c), t.stack.length > 0 && t.stack[0].url === o.url) ) { if (t.stack[0].line === o.line) return !1 @@ -3119,34 +3118,34 @@ } return (t.incomplete = !0), !1 } - function i(t, r) { + function i(t, s) { for ( var a, - c, + l, h = /function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i, u = [], - d = {}, - p = !1, - f = i.caller; - f && !p; - f = f.caller + f = {}, + d = !1, + p = i.caller; + p && !d; + p = p.caller ) { - if (f !== o && f !== s.report) { + if (p !== o && p !== r.report) { if ( - ((c = { url: null, func: l, line: null, column: null }), - f.name - ? (c.func = f.name) - : (a = h.exec(f.toString())) && (c.func = a[1]), - 'undefined' == typeof c.func) + ((l = { url: null, func: c, line: null, column: null }), + p.name + ? (l.func = p.name) + : (a = h.exec(p.toString())) && (l.func = a[1]), + 'undefined' == typeof l.func) ) { try { - c.func = a.input.substring(0, a.input.indexOf('{')) + l.func = a.input.substring(0, a.input.indexOf('{')) } catch (y) {} } - d['' + f] ? (p = !0) : (d['' + f] = !0), u.push(c) + f['' + p] ? (d = !0) : (f['' + p] = !0), u.push(l) } } - r && u.splice(0, r) + s && u.splice(0, s) var m = { name: t.name, message: t.message, url: n(), stack: u } return ( e( @@ -3163,13 +3162,13 @@ o = null == o ? 0 : +o try { if ((a = t(e))) return a - } catch (r) { - if (s.debug) throw r + } catch (s) { + if (r.debug) throw s } try { if ((a = i(e, o + 1))) return a - } catch (r) { - if (s.debug) throw r + } catch (s) { + if (r.debug) throw s } return { name: e.name, message: e.message, url: n() } } @@ -3179,7 +3178,7 @@ o ) })()), - (e.exports = s) + (e.exports = r) }.call( this, 'undefined' != typeof global @@ -3209,24 +3208,24 @@ ? '[Circular ~]' : '[Circular ~.' + o.slice(0, n(i, e)).join('.') + ']' }), - function (s, r) { + function (r, s) { if (i.length > 0) { var a = n(i, this) ~a ? i.splice(a + 1) : i.push(this), - ~a ? o.splice(a, 1 / 0, s) : o.push(s), - ~n(i, r) && (r = e.call(this, s, r)) - } else i.push(r) + ~a ? o.splice(a, 1 / 0, r) : o.push(r), + ~n(i, s) && (s = e.call(this, r, s)) + } else i.push(s) return null == t - ? r instanceof Error + ? s instanceof Error ? (function (t) { var e = { stack: t.stack, message: t.message, name: t.name } for (var i in t) { Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]) } return e - })(r) - : r - : t.call(this, s, r) + })(s) + : s + : t.call(this, r, s) } ) } @@ -3244,133 +3243,133 @@ var i = (65535 & t) + (65535 & e) return (((t >> 16) + (e >> 16) + (i >> 16)) << 16) | (65535 & i) } - function o(t, e, i, o, s, r) { + function o(t, e, i, o, r, s) { return n( (function (t, e) { return (t << e) | (t >>> (32 - e)) - })(n(n(e, t), n(o, r)), s), + })(n(n(e, t), n(o, s)), r), i, ) } - function s(t, e, i, n, s, r, a) { - return o((e & i) | (~e & n), t, e, s, r, a) + function r(t, e, i, n, r, s, a) { + return o((e & i) | (~e & n), t, e, r, s, a) } - function r(t, e, i, n, s, r, a) { - return o((e & n) | (i & ~n), t, e, s, r, a) + function s(t, e, i, n, r, s, a) { + return o((e & n) | (i & ~n), t, e, r, s, a) } - function a(t, e, i, n, s, r, a) { - return o(e ^ i ^ n, t, e, s, r, a) + function a(t, e, i, n, r, s, a) { + return o(e ^ i ^ n, t, e, r, s, a) } - function l(t, e, i, n, s, r, a) { - return o(i ^ (e | ~n), t, e, s, r, a) + function c(t, e, i, n, r, s, a) { + return o(i ^ (e | ~n), t, e, r, s, a) } - function c(t, e) { + function l(t, e) { ;(t[e >> 5] |= 128 << e % 32), (t[14 + (((e + 64) >>> 9) << 4)] = e) var i, o, - c, + l, h, u, - d = 1732584193, - p = -271733879, - f = -1732584194, + f = 1732584193, + d = -271733879, + p = -1732584194, m = 271733878 for (i = 0; i < t.length; i += 16) { - ;(o = d), - (c = p), - (h = f), + ;(o = f), + (l = d), + (h = p), (u = m), - (d = s(d, p, f, m, t[i], 7, -680876936)), - (m = s(m, d, p, f, t[i + 1], 12, -389564586)), - (f = s(f, m, d, p, t[i + 2], 17, 606105819)), - (p = s(p, f, m, d, t[i + 3], 22, -1044525330)), - (d = s(d, p, f, m, t[i + 4], 7, -176418897)), - (m = s(m, d, p, f, t[i + 5], 12, 1200080426)), - (f = s(f, m, d, p, t[i + 6], 17, -1473231341)), - (p = s(p, f, m, d, t[i + 7], 22, -45705983)), - (d = s(d, p, f, m, t[i + 8], 7, 1770035416)), - (m = s(m, d, p, f, t[i + 9], 12, -1958414417)), - (f = s(f, m, d, p, t[i + 10], 17, -42063)), - (p = s(p, f, m, d, t[i + 11], 22, -1990404162)), - (d = s(d, p, f, m, t[i + 12], 7, 1804603682)), - (m = s(m, d, p, f, t[i + 13], 12, -40341101)), - (f = s(f, m, d, p, t[i + 14], 17, -1502002290)), - (d = r( - d, - (p = s(p, f, m, d, t[i + 15], 22, 1236535329)), + (f = r(f, d, p, m, t[i], 7, -680876936)), + (m = r(m, f, d, p, t[i + 1], 12, -389564586)), + (p = r(p, m, f, d, t[i + 2], 17, 606105819)), + (d = r(d, p, m, f, t[i + 3], 22, -1044525330)), + (f = r(f, d, p, m, t[i + 4], 7, -176418897)), + (m = r(m, f, d, p, t[i + 5], 12, 1200080426)), + (p = r(p, m, f, d, t[i + 6], 17, -1473231341)), + (d = r(d, p, m, f, t[i + 7], 22, -45705983)), + (f = r(f, d, p, m, t[i + 8], 7, 1770035416)), + (m = r(m, f, d, p, t[i + 9], 12, -1958414417)), + (p = r(p, m, f, d, t[i + 10], 17, -42063)), + (d = r(d, p, m, f, t[i + 11], 22, -1990404162)), + (f = r(f, d, p, m, t[i + 12], 7, 1804603682)), + (m = r(m, f, d, p, t[i + 13], 12, -40341101)), + (p = r(p, m, f, d, t[i + 14], 17, -1502002290)), + (f = s( f, + (d = r(d, p, m, f, t[i + 15], 22, 1236535329)), + p, m, t[i + 1], 5, -165796510, )), - (m = r(m, d, p, f, t[i + 6], 9, -1069501632)), - (f = r(f, m, d, p, t[i + 11], 14, 643717713)), - (p = r(p, f, m, d, t[i], 20, -373897302)), - (d = r(d, p, f, m, t[i + 5], 5, -701558691)), - (m = r(m, d, p, f, t[i + 10], 9, 38016083)), - (f = r(f, m, d, p, t[i + 15], 14, -660478335)), - (p = r(p, f, m, d, t[i + 4], 20, -405537848)), - (d = r(d, p, f, m, t[i + 9], 5, 568446438)), - (m = r(m, d, p, f, t[i + 14], 9, -1019803690)), - (f = r(f, m, d, p, t[i + 3], 14, -187363961)), - (p = r(p, f, m, d, t[i + 8], 20, 1163531501)), - (d = r(d, p, f, m, t[i + 13], 5, -1444681467)), - (m = r(m, d, p, f, t[i + 2], 9, -51403784)), - (f = r(f, m, d, p, t[i + 7], 14, 1735328473)), - (d = a( - d, - (p = r(p, f, m, d, t[i + 12], 20, -1926607734)), + (m = s(m, f, d, p, t[i + 6], 9, -1069501632)), + (p = s(p, m, f, d, t[i + 11], 14, 643717713)), + (d = s(d, p, m, f, t[i], 20, -373897302)), + (f = s(f, d, p, m, t[i + 5], 5, -701558691)), + (m = s(m, f, d, p, t[i + 10], 9, 38016083)), + (p = s(p, m, f, d, t[i + 15], 14, -660478335)), + (d = s(d, p, m, f, t[i + 4], 20, -405537848)), + (f = s(f, d, p, m, t[i + 9], 5, 568446438)), + (m = s(m, f, d, p, t[i + 14], 9, -1019803690)), + (p = s(p, m, f, d, t[i + 3], 14, -187363961)), + (d = s(d, p, m, f, t[i + 8], 20, 1163531501)), + (f = s(f, d, p, m, t[i + 13], 5, -1444681467)), + (m = s(m, f, d, p, t[i + 2], 9, -51403784)), + (p = s(p, m, f, d, t[i + 7], 14, 1735328473)), + (f = a( f, + (d = s(d, p, m, f, t[i + 12], 20, -1926607734)), + p, m, t[i + 5], 4, -378558, )), - (m = a(m, d, p, f, t[i + 8], 11, -2022574463)), - (f = a(f, m, d, p, t[i + 11], 16, 1839030562)), - (p = a(p, f, m, d, t[i + 14], 23, -35309556)), - (d = a(d, p, f, m, t[i + 1], 4, -1530992060)), - (m = a(m, d, p, f, t[i + 4], 11, 1272893353)), - (f = a(f, m, d, p, t[i + 7], 16, -155497632)), - (p = a(p, f, m, d, t[i + 10], 23, -1094730640)), - (d = a(d, p, f, m, t[i + 13], 4, 681279174)), - (m = a(m, d, p, f, t[i], 11, -358537222)), - (f = a(f, m, d, p, t[i + 3], 16, -722521979)), - (p = a(p, f, m, d, t[i + 6], 23, 76029189)), - (d = a(d, p, f, m, t[i + 9], 4, -640364487)), - (m = a(m, d, p, f, t[i + 12], 11, -421815835)), - (f = a(f, m, d, p, t[i + 15], 16, 530742520)), - (d = l( - d, - (p = a(p, f, m, d, t[i + 2], 23, -995338651)), + (m = a(m, f, d, p, t[i + 8], 11, -2022574463)), + (p = a(p, m, f, d, t[i + 11], 16, 1839030562)), + (d = a(d, p, m, f, t[i + 14], 23, -35309556)), + (f = a(f, d, p, m, t[i + 1], 4, -1530992060)), + (m = a(m, f, d, p, t[i + 4], 11, 1272893353)), + (p = a(p, m, f, d, t[i + 7], 16, -155497632)), + (d = a(d, p, m, f, t[i + 10], 23, -1094730640)), + (f = a(f, d, p, m, t[i + 13], 4, 681279174)), + (m = a(m, f, d, p, t[i], 11, -358537222)), + (p = a(p, m, f, d, t[i + 3], 16, -722521979)), + (d = a(d, p, m, f, t[i + 6], 23, 76029189)), + (f = a(f, d, p, m, t[i + 9], 4, -640364487)), + (m = a(m, f, d, p, t[i + 12], 11, -421815835)), + (p = a(p, m, f, d, t[i + 15], 16, 530742520)), + (f = c( f, + (d = a(d, p, m, f, t[i + 2], 23, -995338651)), + p, m, t[i], 6, -198630844, )), - (m = l(m, d, p, f, t[i + 7], 10, 1126891415)), - (f = l(f, m, d, p, t[i + 14], 15, -1416354905)), - (p = l(p, f, m, d, t[i + 5], 21, -57434055)), - (d = l(d, p, f, m, t[i + 12], 6, 1700485571)), - (m = l(m, d, p, f, t[i + 3], 10, -1894986606)), - (f = l(f, m, d, p, t[i + 10], 15, -1051523)), - (p = l(p, f, m, d, t[i + 1], 21, -2054922799)), - (d = l(d, p, f, m, t[i + 8], 6, 1873313359)), - (m = l(m, d, p, f, t[i + 15], 10, -30611744)), - (f = l(f, m, d, p, t[i + 6], 15, -1560198380)), - (p = l(p, f, m, d, t[i + 13], 21, 1309151649)), - (d = l(d, p, f, m, t[i + 4], 6, -145523070)), - (m = l(m, d, p, f, t[i + 11], 10, -1120210379)), - (f = l(f, m, d, p, t[i + 2], 15, 718787259)), - (p = l(p, f, m, d, t[i + 9], 21, -343485551)), - (d = n(d, o)), - (p = n(p, c)), - (f = n(f, h)), + (m = c(m, f, d, p, t[i + 7], 10, 1126891415)), + (p = c(p, m, f, d, t[i + 14], 15, -1416354905)), + (d = c(d, p, m, f, t[i + 5], 21, -57434055)), + (f = c(f, d, p, m, t[i + 12], 6, 1700485571)), + (m = c(m, f, d, p, t[i + 3], 10, -1894986606)), + (p = c(p, m, f, d, t[i + 10], 15, -1051523)), + (d = c(d, p, m, f, t[i + 1], 21, -2054922799)), + (f = c(f, d, p, m, t[i + 8], 6, 1873313359)), + (m = c(m, f, d, p, t[i + 15], 10, -30611744)), + (p = c(p, m, f, d, t[i + 6], 15, -1560198380)), + (d = c(d, p, m, f, t[i + 13], 21, 1309151649)), + (f = c(f, d, p, m, t[i + 4], 6, -145523070)), + (m = c(m, f, d, p, t[i + 11], 10, -1120210379)), + (p = c(p, m, f, d, t[i + 2], 15, 718787259)), + (d = c(d, p, m, f, t[i + 9], 21, -343485551)), + (f = n(f, o)), + (d = n(d, l)), + (p = n(p, h)), (m = n(m, u)) } - return [d, p, f, m] + return [f, d, p, m] } function h(t) { var e, @@ -3387,7 +3386,7 @@ for (e = 0; e < n; e += 8) i[e >> 5] |= (255 & t.charCodeAt(e / 8)) << e % 32 return i } - function d(t) { + function f(t) { var e, i, n = '0123456789abcdef', @@ -3397,42 +3396,42 @@ } return o } - function p(t) { + function d(t) { return unescape(encodeURIComponent(t)) } - function f(t) { + function p(t) { return (function (t) { - return h(c(u(t), 8 * t.length)) - })(p(t)) + return h(l(u(t), 8 * t.length)) + })(d(t)) } function m(t, e) { return (function (t, e) { var i, n, o = u(t), - s = [], - r = [] + r = [], + s = [] for ( - s[15] = r[15] = void 0, o.length > 16 && (o = c(o, 8 * t.length)), i = 0; + r[15] = s[15] = void 0, o.length > 16 && (o = l(o, 8 * t.length)), i = 0; i < 16; i += 1 ) { - ;(s[i] = 909522486 ^ o[i]), (r[i] = 1549556828 ^ o[i]) + ;(r[i] = 909522486 ^ o[i]), (s[i] = 1549556828 ^ o[i]) } - return (n = c(s.concat(u(e)), 512 + 8 * e.length)), h(c(r.concat(n), 640)) - })(p(t), p(e)) + return (n = l(r.concat(u(e)), 512 + 8 * e.length)), h(l(s.concat(n), 640)) + })(d(t), d(e)) } e.exports = function (t, e, i) { return e ? i ? m(e, t) : (function (t, e) { - return d(m(t, e)) + return f(m(t, e)) })(e, t) : i - ? f(t) + ? p(t) : (function (t) { - return d(f(t)) + return f(p(t)) })(t) } }, @@ -3443,7 +3442,7 @@ [4], )(4) }) - var z = [ + var N = [ { family: 'UC Browser', patterns: ['(UC? ?Browser|UCWEB|U3)[ /]?(\\d+)\\.(\\d+)\\.(\\d+)'] }, { family: 'Opera', @@ -3563,7 +3562,7 @@ ], }, ], - Z = [ + z = [ { family: 'Windows', name_replace: 'Windows Phone', @@ -3695,32 +3694,32 @@ ], }, ], - U = navigator.userAgent, + Z = navigator.userAgent, W = function () { - return U - }, - K = function (t) { - return J(t || U, z) + return Z }, q = function (t) { - return J(t || U, Z) + return G(t || Z, N) + }, + K = function (t) { + return G(t || Z, z) } - function G(t, e) { + function Y(t, e) { try { var i = new RegExp(e).exec(t) return i ? { name: i[1] || 'Other', major: i[2] || '0', minor: i[3] || '0', patch: i[4] || '0' } : null - } catch (Ps) { + } catch (ts) { return null } } - function J(t, e) { - for (var i = null, n = null, o = -1, s = !1; ++o < e.length && !s; ) { + function G(t, e) { + for (var i = null, n = null, o = -1, r = !1; ++o < e.length && !r; ) { i = e[o] - for (var r = -1; ++r < i.patterns.length && !s; ) s = null !== (n = G(t, i.patterns[r])) + for (var s = -1; ++s < i.patterns.length && !r; ) r = null !== (n = Y(t, i.patterns[s])) } - return s + return r ? ((n.family = i.family || i.name_replace || n.name), i.name_replace && (n.name = i.name_replace), i.major_replace && (n.major = i.major_replace), @@ -3729,9 +3728,9 @@ n) : { family: 'Other', name: 'Other', major: '0', minor: '0', patch: '0' } } - function Y() { + function J() { var t = this, - e = K(), + e = q(), i = W() ;(this.agent = i.toLowerCase()), (this.language = window.navigator.userLanguage || window.navigator.language), @@ -3779,21 +3778,24 @@ (this.version = 1 * (e.major + '.' + e.minor) || 0), (this.hasPostMessage = !!window.postMessage) } - ;(Y.prototype.hasEvent = function (t, e) { + ;(J.prototype.hasEvent = function (t, e) { return 'on' + t in (e || document.createElement('div')) }), - (Y.prototype.getScreenDimensions = function () { + (J.prototype.getScreenDimensions = function () { var t = {} for (var e in window.screen) t[e] = window.screen[e] return delete t.orientation, t }), - (Y.prototype.interrogateNavigator = function () { + (J.prototype.getWindowDimensions = function () { + return [this.width(), this.height()] + }), + (J.prototype.interrogateNavigator = function () { var t = {} for (var e in window.navigator) { if ('webkitPersistentStorage' !== e) { try { t[e] = window.navigator[e] - } catch (Fs) {} + } catch (Qr) {} } } if ((delete t.plugins, delete t.mimeTypes, (t.plugins = []), window.navigator.plugins)) { @@ -3803,14 +3805,14 @@ } return t }), - (Y.prototype.supportsPST = function () { + (J.prototype.supportsPST = function () { return document.hasPrivateToken !== undefined }), - (Y.prototype.supportsCanvas = function () { + (J.prototype.supportsCanvas = function () { var t = document.createElement('canvas') return !(!t.getContext || !t.getContext('2d')) }), - (Y.prototype.supportsWebAssembly = function () { + (J.prototype.supportsWebAssembly = function () { try { if ('object' == typeof WebAssembly && 'function' == typeof WebAssembly.instantiate) { var t = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0)) @@ -3818,15 +3820,15 @@ return new WebAssembly.Instance(t) instanceof WebAssembly.Instance } } - } catch (Ps) { + } catch (ts) { return !1 } }) - var X = new Y(), + var X = new J(), Q = new (function () { var t, e, - i = q(), + i = K(), n = W() ;(this.mobile = ((t = !!( @@ -3893,20 +3895,22 @@ }, nt = 'https://hcaptcha.com', ot = 'https://api.hcaptcha.com', - st = 'https://api2.hcaptcha.com', - rt = 'https://cloudflare.hcaptcha.com', - at = [nt, ot, st, rt], + rt = 'https://api2.hcaptcha.com', + st = 'https://cloudflare.hcaptcha.com', + at = { AUTO: 'auto' }, + ct = [nt, ot, rt, st], lt = { __proto__: null, CaptchaEvent: et, CaptchaError: it, ROOT_ENDPOINT: nt, API_ENDPOINT: ot, - API2_ENDPOINT: st, - CF_ENDPOINT: rt, - MAIN_ENDPOINTS: at, + API2_ENDPOINT: rt, + CF_ENDPOINT: st, + EXECUTE_MODE: at, + MAIN_ENDPOINTS: ct, }, - ct = { + ht = { host: null, file: null, sitekey: null, @@ -3918,14 +3922,14 @@ 'ios' !== tt.System.os && 'android' !== tt.System.os, assetDomain: 'https://newassets.hcaptcha.com', - assetUrl: 'https://newassets.hcaptcha.com/captcha/v1/1bcdbdd/static', + assetUrl: 'https://newassets.hcaptcha.com/captcha/v1/a8cd801/static', width: null, height: null, mobile: null, orientation: 'portrait', challenge_type: null, }, - ht = { + ut = { theme: { contrast: { hcolor: '#FFF', hfcolor: '#000' }, light: { hcolor: '#00838F', hfcolor: '#FFF' }, @@ -3943,7 +3947,7 @@ error: '#fc481e', outline: '#262D38', }, - ut = { + ft = { se: null, custom: !1, tplinks: 'on', @@ -3953,6 +3957,7 @@ pstIssuer: 'https://pst-issuer.hcaptcha.com', size: 'normal', theme: 'light', + mode: undefined, assethost: null, imghost: null, recaptchacompat: 'true', @@ -3960,9 +3965,9 @@ confirmNav: !1, }, dt = 'https://30910f52569b4c17b1081ead2dae43b4@sentry.hcaptcha.com/6', - pt = '1bcdbdd', - ft = 'prod' - function mt(t, e) { + pt = 'a8cd801', + mt = 'prod' + function yt(t, e) { ;(t.style.width = '304px'), (t.style.height = '78px'), (t.style.backgroundColor = '#f9e5e5'), @@ -3982,46 +3987,82 @@ "Please upgrade your browser to complete this captcha."), t.appendChild(i) } - var yt = [] function gt(t) { + for (var e = document.getElementsByClassName('h-captcha'), i = [], n = 0; n < e.length; n++) { + i.push(e[n]) + } + var o = [] + if ('off' !== ft.recaptchacompat) { + for (var r = document.getElementsByClassName('g-recaptcha'), s = 0; s < r.length; s++) { + o.push(r[s]) + } + } + for (var a = [].concat(i, o), c = 0; c < a.length; c++) t(a[c]) + } + var vt = 'The captcha failed to load.', + bt = [] + function wt(t) { for ( - var e = [], i = /(https?|wasm):\/\//, n = /^at /, o = /:\d+:\d+/g, s = 0, r = t.length; - s < r; - s++ + var e = [], i = /(https?|wasm):\/\//, n = /^at /, o = /:\d+:\d+/g, r = 0, s = t.length; + r < s; + r++ ) { - var a = t[s] + var a = t[r] if (!i.test(a)) { - var l = a.trim().replace(n, '').replace(o, '') - e.push(l) + var c = a.trim().replace(n, '').replace(o, '') + e.push(c) } } return e.join('\n').trim() } - function vt(t) { + function xt(t) { + if (t && 'string' == typeof t && -1 === bt.indexOf(t) && !(bt.length >= 10)) { + var e = wt(t.trim().split('\n').slice(0, 2)) + bt.push(e) + } + } + function kt(t) { + ;(t && 'object' == typeof t) || (t = { name: 'error', message: '', stack: '' }) var e = { message: t.name + ': ' + t.message } t.stack && (e.stack_trace = { trace: t.stack }), - Ct('report error', 'internal', 'debug', e), - wt(t.message || 'internal error', 'error', ct.file, t) + St('report error', 'internal', 'debug', e), + Et(t.message || 'internal error', 'error', ht.file, t) } - function bt(t) { - if (ut.sentry) { + function Ct(t) { + return function () { + try { + return t.apply(this, arguments) + } catch (Qr) { + throw ( + (kt(Qr), + gt(function (t) { + yt(t, vt) + }), + Qr) + ) + } + } + } + function _t(t) { + if (ft.sentry) { var e = !1 try { e = -1 !== window.location.href.indexOf('chargebee.com') - } catch (Ps) {} + } catch (ts) {} window.Raven && Raven.config(dt, { release: pt, - environment: ft, + environment: mt, autoBreadcrumbs: { xhr: !0, dom: !0, sentry: !0 }, tags: { - 'site-host': ct.host, - 'site-key': ct.sitekey, - 'endpoint-url': ut.endpoint, - 'asset-url': ct.assetUrl, + 'site-host': ht.host, + 'site-key': ht.sitekey, + 'endpoint-url': ft.endpoint, + 'asset-url': ht.assetUrl, }, sampleRate: e ? 1 : 0.01, ignoreErrors: [ + "Cannot set properties of undefined (setting 'data')", 'canvas.contentDocument', "Can't find variable: ZiteReader", 'Cannot redefine property: hcaptcha', @@ -4041,60 +4082,56 @@ 'System-Version': tt.System.version, 'Is-Mobile': tt.System.mobile, }), - Ct(ct.file + '_internal', 'setup', 'info'), + St(ht.file + '_internal', 'setup', 'info'), t && (window.onerror = function (t, e, i, n, o) { - var s = o.name || 'Error', - r = o.stack || '' - !(function (t) { - if (t && 'string' == typeof t && -1 === yt.indexOf(t) && !(yt.length >= 10)) { - var e = gt(t.trim().split('\n').slice(0, 2)) - yt.push(e) - } - })(r), - -1 === r.indexOf('chrome-extension://') && - -1 === r.indexOf('safari-extension://') && - -1 === r.indexOf('moz-extension://') && - -1 === r.indexOf('chrome://internal-') && - -1 === r.indexOf('/hammerhead.js') && - -1 === r.indexOf('eval at buildCode') && - -1 === r.indexOf('u.c.b.r.o.w.s.e.r/ucbrowser_script.js') && - (Ct(t, 'global', 'debug', { name: s, url: e, line: i, column: n, stack: r }), - xt('global', o, { message: t })) + ;(o && 'object' == typeof o) || (o = {}) + var r = o.name || 'Error', + s = o.stack || '' + Ct(xt)(s), + -1 === s.indexOf('chrome-extension://') && + -1 === s.indexOf('safari-extension://') && + -1 === s.indexOf('moz-extension://') && + -1 === s.indexOf('chrome://internal-') && + -1 === s.indexOf('/hammerhead.js') && + -1 === s.indexOf('eval at buildCode') && + -1 === s.indexOf('u.c.b.r.o.w.s.e.r/ucbrowser_script.js') && + (St(t, 'global', 'debug', { name: r, url: e, line: i, column: n, stack: s }), + At('global', o, { message: t })) }) } } - function wt(t, e, i, n) { - if (((e = e || 'error'), ut.sentry)) { + function Et(t, e, i, n) { + if (((e = e || 'error'), ft.sentry)) { var o = 'warn' === e ? 'warning' : e window.Raven && Raven.captureMessage(t, { level: o, logger: i, extra: n }) } } - function xt(t, e, i) { - return ((i = i || {}).error = e), wt(e.message || 'Missing error message', 'error', t, i) + function At(t, e, i) { + return ((i = i || {}).error = e), Et((e && e.message) || 'Missing error message', 'error', t, i) } - function Ct(t, e, i, n) { - ut.sentry && + function St(t, e, i, n) { + ft.sentry && window.Raven && Raven.captureBreadcrumb({ message: t, category: e, level: i, data: n }) } - var kt = { + var Bt = { getCookie: function (t) { var e = document.cookie.replace(/ /g, '').split(';') try { for (var i = '', n = e.length; n-- && !i; ) e[n].indexOf(t) >= 0 && (i = e[n]) return i - } catch (Ps) { + } catch (ts) { return '' } }, hasCookie: function (t) { - return !!kt.getCookie(t) + return !!Bt.getCookie(t) }, supportsAPI: function () { try { return 'hasStorageAccess' in document && 'requestStorageAccess' in document - } catch (Ps) { + } catch (ts) { return !1 } }, @@ -4113,12 +4150,12 @@ requestAccess: function () { try { return document.requestStorageAccess() - } catch (Ps) { + } catch (ts) { return Promise.resolve() } }, }, - _t = { + Lt = { array: function (t) { if (0 === t.length) return t for (var e, i, n = t.length; --n > -1; ) { @@ -4127,7 +4164,7 @@ return t }, } - function Et(t) { + function Tt(t) { ;(this.r = 255), (this.g = 255), (this.b = 255), @@ -4137,20 +4174,20 @@ (this.l = 1), this.parseString(t) } - function St(t, e, i) { + function Ot(t, e, i) { return ( i < 0 && (i += 1), i > 1 && (i -= 1), i < 1 / 6 ? t + 6 * (e - t) * i : i < 0.5 ? e : i < 2 / 3 ? t + (e - t) * (2 / 3 - i) * 6 : t ) } - ;(Et.hasAlpha = function (t) { + ;(Tt.hasAlpha = function (t) { return 'string' == typeof t && (-1 !== t.indexOf('rgba') || (9 === t.length && '#' === t[0])) }), - (Et.prototype.parseString = function (t) { + (Tt.prototype.parseString = function (t) { t && (0 === t.indexOf('#') ? this.fromHex(t) : 0 === t.indexOf('rgb') && this.fromRGBA(t)) }), - (Et.prototype.fromHex = function (t) { + (Tt.prototype.fromHex = function (t) { var e = 1 9 === t.length && (e = parseInt(t.substr(7, 2), 16) / 255) var i = (t = t.substr(1, 6)).replace( @@ -4161,11 +4198,11 @@ ), n = parseInt(i, 16), o = n >> 16, - s = (n >> 8) & 255, - r = 255 & n - this.setRGBA(o, s, r, e) + r = (n >> 8) & 255, + s = 255 & n + this.setRGBA(o, r, s, e) }), - (Et.prototype.fromRGBA = function (t) { + (Tt.prototype.fromRGBA = function (t) { var e = t.indexOf('rgba'), i = t .substr(e) @@ -4175,93 +4212,93 @@ .split(','), n = Math.floor(parseInt(i[0])), o = Math.floor(parseInt(i[1])), - s = Math.floor(parseInt(i[2])), - r = parseFloat(i[3]) - this.setRGBA(n, o, s, r) + r = Math.floor(parseInt(i[2])), + s = parseFloat(i[3]) + this.setRGBA(n, o, r, s) }), - (Et.prototype.setRGB = function (t, e, i) { + (Tt.prototype.setRGB = function (t, e, i) { this.setRGBA(t, e, i, 1) }), - (Et.prototype.setRGBA = function (t, e, i, n) { + (Tt.prototype.setRGBA = function (t, e, i, n) { ;(this.r = t), (this.g = e), (this.b = i), (this.a = isNaN(n) ? this.a : n), this.updateHSL() }), - (Et.prototype.hsl2rgb = function (t, e, i) { + (Tt.prototype.hsl2rgb = function (t, e, i) { if (0 === e) { var n = Math.round(255 * i) return this.setRGB(n, n, n), this } var o = i <= 0.5 ? i * (1 + e) : i + e - i * e, - s = 2 * i - o + r = 2 * i - o return ( - (this.r = Math.round(255 * St(s, o, t + 1 / 3))), - (this.g = Math.round(255 * St(s, o, t))), - (this.b = Math.round(255 * St(s, o, t - 1 / 3))), + (this.r = Math.round(255 * Ot(r, o, t + 1 / 3))), + (this.g = Math.round(255 * Ot(r, o, t))), + (this.b = Math.round(255 * Ot(r, o, t - 1 / 3))), (this.h = t), (this.s = e), (this.l = i), this ) }), - (Et.prototype.updateHSL = function () { + (Tt.prototype.updateHSL = function () { var t, e = this.r / 255, i = this.g / 255, n = this.b / 255, o = Math.max(e, i, n), - s = Math.min(e, i, n), - r = null, - a = (o + s) / 2 - if (o === s) r = t = 0 + r = Math.min(e, i, n), + s = null, + a = (o + r) / 2 + if (o === r) s = t = 0 else { - var l = o - s - switch (((t = a > 0.5 ? l / (2 - o - s) : l / (o + s)), o)) { + var c = o - r + switch (((t = a > 0.5 ? c / (2 - o - r) : c / (o + r)), o)) { case e: - r = (i - n) / l + (i < n ? 6 : 0) + s = (i - n) / c + (i < n ? 6 : 0) break case i: - r = (n - e) / l + 2 + s = (n - e) / c + 2 break case n: - r = (e - i) / l + 4 + s = (e - i) / c + 4 } - r /= 6 + s /= 6 } - return (this.h = r), (this.s = t), (this.l = a), this + return (this.h = s), (this.s = t), (this.l = a), this }), - (Et.prototype.getHex = function () { + (Tt.prototype.getHex = function () { return '#' + ((1 << 24) + (this.r << 16) + (this.g << 8) + this.b).toString(16).slice(1) }), - (Et.prototype.getRGBA = function () { + (Tt.prototype.getRGBA = function () { return 'rgba(' + this.r + ',' + this.g + ',' + this.b + ',' + this.a + ')' }), - (Et.prototype.clone = function () { - var t = new Et() + (Tt.prototype.clone = function () { + var t = new Tt() return t.setRGBA(this.r, this.g, this.b, this.a), t }), - (Et.prototype.mix = function (t, e) { - t instanceof Et || (t = new Et(t)) - var i = new Et(), + (Tt.prototype.mix = function (t, e) { + t instanceof Tt || (t = new Tt(t)) + var i = new Tt(), n = Math.round(this.r + e * (t.r - this.r)), o = Math.round(this.g + e * (t.g - this.g)), - s = Math.round(this.b + e * (t.b - this.b)) - return i.setRGB(n, o, s), i + r = Math.round(this.b + e * (t.b - this.b)) + return i.setRGB(n, o, r), i }), - (Et.prototype.blend = function (t, e) { + (Tt.prototype.blend = function (t, e) { var i - t instanceof Et || (t = new Et(t)) + t instanceof Tt || (t = new Tt(t)) for (var n = [], o = 0; o < e; o++) (i = this.mix.call(this, t, o / e)), n.push(i) return n }), - (Et.prototype.lightness = function (t) { + (Tt.prototype.lightness = function (t) { return t > 1 && (t /= 100), this.hsl2rgb(this.h, this.s, t), this }), - (Et.prototype.saturation = function (t) { + (Tt.prototype.saturation = function (t) { return t > 1 && (t /= 100), this.hsl2rgb(this.h, t, this.l), this }), - (Et.prototype.hue = function (t) { + (Tt.prototype.hue = function (t) { return this.hsl2rgb(t / 360, this.s, this.l), this }) - var At = { + var Ht = { decode: function (t) { try { var e = t.split('.') @@ -4271,7 +4308,7 @@ signature: atob(e[2].replace(/_/g, '/').replace(/-/g, '+')), raw: { header: e[0], payload: e[1], signature: e[2] }, } - } catch (Ps) { + } catch (ts) { throw new Error('Token is invalid.') } }, @@ -4280,7 +4317,7 @@ return !0 }, }, - Lt = { + Mt = { _setup: !1, _af: null, _fps: 60, @@ -4315,111 +4352,111 @@ window[n[o] + 'CancelAnimationFrame'] || window[n[o] + 'CancelRequestAnimationFrame']) } e - ? ((Lt.requestFrame = e.bind(window)), (Lt.cancelFrame = i.bind(window))) - : ((Lt.requestFrame = + ? ((Mt.requestFrame = e.bind(window)), (Mt.cancelFrame = i.bind(window))) + : ((Mt.requestFrame = ((t = Date.now()), function (e) { window.setTimeout(function () { e(Date.now() - t) - }, 1e3 * Lt._singleFrame) + }, 1e3 * Mt._singleFrame) })), - (Lt.cancelFrame = function (t) { + (Mt.cancelFrame = function (t) { return clearTimeout(t), null })), - (Lt._setup = !0), - (Lt._startTime = Lt._lastTime = Date.now()) + (Mt._setup = !0), + (Mt._startTime = Mt._lastTime = Date.now()) }, add: function (t, e) { - Lt._renders.push({ callback: t, paused: !1 == !e || !1 }), !1 == !e && Lt.start() + Mt._renders.push({ callback: t, paused: !1 == !e || !1 }), !1 == !e && Mt.start() }, remove: function (t) { - for (var e = Lt._renders.length; --e > -1; ) { - Lt._renders[e].callback === t && ((Lt._renders[e].paused = !0), Lt._renders.splice(e, 1)) + for (var e = Mt._renders.length; --e > -1; ) { + Mt._renders[e].callback === t && ((Mt._renders[e].paused = !0), Mt._renders.splice(e, 1)) } }, start: function (t) { - if ((!1 === Lt._setup && Lt._init(), t)) { - for (var e = Lt._renders.length; --e > -1; ) { - Lt._renders[e].callback === t && (Lt._renders[e].paused = !1) + if ((!1 === Mt._setup && Mt._init(), t)) { + for (var e = Mt._renders.length; --e > -1; ) { + Mt._renders[e].callback === t && (Mt._renders[e].paused = !1) } } - !0 !== Lt._running && - ((Lt._paused = !1), (Lt._running = !0), (Lt._af = Lt.requestFrame(Lt._update))) + !0 !== Mt._running && + ((Mt._paused = !1), (Mt._running = !0), (Mt._af = Mt.requestFrame(Mt._update))) }, stop: function (t) { if (t) { - for (var e = Lt._renders.length; --e > -1; ) { - Lt._renders[e].callback === t && (Lt._renders[e].paused = !0) + for (var e = Mt._renders.length; --e > -1; ) { + Mt._renders[e].callback === t && (Mt._renders[e].paused = !0) } } else { - !1 !== Lt._running && - ((Lt._af = Lt.cancelFrame(Lt._af)), (Lt._paused = !0), (Lt._running = !1)) + !1 !== Mt._running && + ((Mt._af = Mt.cancelFrame(Mt._af)), (Mt._paused = !0), (Mt._running = !1)) } }, elapsed: function () { - return Date.now() - Lt._startTime + return Date.now() - Mt._startTime }, fps: function (t) { return arguments.length - ? ((Lt._fps = t), - (Lt._singleFrame = 1 / (Lt._fps || 60)), - (Lt._adjustedLag = 2 * Lt._singleFrame), - (Lt._nextTime = Lt.time + Lt._singleFrame), - Lt._fps) - : Lt._fps + ? ((Mt._fps = t), + (Mt._singleFrame = 1 / (Mt._fps || 60)), + (Mt._adjustedLag = 2 * Mt._singleFrame), + (Mt._nextTime = Mt.time + Mt._singleFrame), + Mt._fps) + : Mt._fps }, isRunning: function () { - return Lt._running + return Mt._running }, _update: function () { if ( - !Lt._paused && - ((Lt._elapsed = Date.now() - Lt._lastTime), - (Lt._tick = !1), - Lt._elapsed > Lt._lagThreshold && (Lt._startTime += Lt._elapsed - Lt._adjustedLag), - (Lt._lastTime += Lt._elapsed), - (Lt.time = (Lt._lastTime - Lt._startTime) / 1e3), - (Lt._difference = Lt.time - Lt._nextTime), - Lt._difference > 0 && - (Lt.frame++, - (Lt._nextTime += - Lt._difference + - (Lt._difference >= Lt._singleFrame - ? Lt._singleFrame / 4 - : Lt._singleFrame - Lt._difference)), - (Lt._tick = !0)), - (Lt._af = Lt.requestFrame(Lt._update)), - !0 === Lt._tick && Lt._renders.length > 0) + !Mt._paused && + ((Mt._elapsed = Date.now() - Mt._lastTime), + (Mt._tick = !1), + Mt._elapsed > Mt._lagThreshold && (Mt._startTime += Mt._elapsed - Mt._adjustedLag), + (Mt._lastTime += Mt._elapsed), + (Mt.time = (Mt._lastTime - Mt._startTime) / 1e3), + (Mt._difference = Mt.time - Mt._nextTime), + Mt._difference > 0 && + (Mt.frame++, + (Mt._nextTime += + Mt._difference + + (Mt._difference >= Mt._singleFrame + ? Mt._singleFrame / 4 + : Mt._singleFrame - Mt._difference)), + (Mt._tick = !0)), + (Mt._af = Mt.requestFrame(Mt._update)), + !0 === Mt._tick && Mt._renders.length > 0) ) { - for (var t = Lt._renders.length; --t > -1; ) { - Lt._renders[t] && !1 === Lt._renders[t].paused && Lt._renders[t].callback(Lt.time) + for (var t = Mt._renders.length; --t > -1; ) { + Mt._renders[t] && !1 === Mt._renders[t].paused && Mt._renders[t].callback(Mt.time) } } }, }, - Bt = function (t) { + Rt = function (t) { for ( - var e, i, n, o = {}, s = t ? (t.indexOf('&') >= 0 ? t.split('&') : [t]) : [], r = 0; - r < s.length; - r++ + var e, i, n, o = {}, r = t ? (t.indexOf('&') >= 0 ? t.split('&') : [t]) : [], s = 0; + s < r.length; + s++ ) { - if (s[r].indexOf('=') >= 0) { + if (r[s].indexOf('=') >= 0) { if ( - ((e = s[r].split('=')), + ((e = r[s].split('=')), (i = decodeURIComponent(e[0])), ('false' !== (n = decodeURIComponent(e[1])) && 'true' !== n) || (n = 'true' === n), 'theme' === i || 'themeConfig' === i) ) { try { n = JSON.parse(n) - } catch (Ps) {} + } catch (ts) {} } o[i] = n } } return o }, - Ht = function (t) { + Pt = function (t) { var e = [] for (var i in t) { var n = t[i] @@ -4428,22 +4465,22 @@ } return e.join('&') }, - Ot = { __proto__: null, Decode: Bt, Encode: Ht } - function Tt(t, e, i) { + It = { __proto__: null, Decode: Rt, Encode: Pt } + function Vt(t, e, i) { return Math.min(Math.max(t, e), i) } - function Mt(t, e, i, n, o, s) { - var r = ((t - e) * (o - n)) / (i - e) + n - return !1 === s ? r : Tt(r, Math.min(n, o), Math.max(n, o)) + function Dt(t, e, i, n, o, r) { + var s = ((t - e) * (o - n)) / (i - e) + n + return !1 === r ? s : Vt(s, Math.min(n, o), Math.max(n, o)) } - function Vt(t) { + function Ft(t) { return t * (Math.PI / 180) } - function Rt(t) { + function $t(t) { return (180 * t) / Math.PI } - var Ft = { __proto__: null, clamp: Tt, range: Mt, toRadians: Vt, toDegrees: Rt } - function Pt(t) { + var Ut = { __proto__: null, clamp: Vt, range: Dt, toRadians: Ft, toDegrees: $t } + function jt(t) { var e = [].slice.call(arguments, 1) 'string' == typeof t ? window[t] @@ -4455,42 +4492,46 @@ ? t.apply(null, e) : console.log("[hcaptcha] Invalid callback '" + t + "'.") } - function Dt() { + function Nt() { try { - Pt.apply(null, arguments) - } catch (Fs) { - console.error('[hCaptcha] There was an error in your callback.'), console.error(Fs) + jt.apply(null, arguments) + } catch (Qr) { + console.error('[hCaptcha] There was an error in your callback.'), console.error(Qr) } } - var It = { - UUID: function (t) { - return /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(t) || !1 - }, - UUIDv4: function (t) { - return ( - /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t) || !1 - ) - }, - URL: function (t) { - var e = new RegExp('^(http|https)://'), - i = new RegExp('^((?!(data|javascript):).)*$') - return e.test(t) && i.test(t) - }, - } - function $t(t, e) { + var zt, + Zt = { + UUID: function (t) { + return /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(t) || !1 + }, + UUIDv4: function (t) { + return ( + /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t) || !1 + ) + }, + URL: function (t) { + var e = new RegExp('^(http|https)://'), + i = new RegExp('^((?!(data|javascript):).)*$') + return e.test(t) && i.test(t) && -1 === t.indexOf('#') + }, + IMAGE: function (t) { + return (0 === t.indexOf('https://') || 0 === t.indexOf('/')) && t.endsWith('.png') + }, + } + function Wt(t, e) { var i, n = 'attempts' in (e = e || {}) ? e.attempts : 1, o = e.delay || 0, - s = e.onFail + r = e.onFail return ( - (i = function (e, i, r) { + (i = function (e, i, s) { t().then(e, function (t) { var e = n-- > 0 - if (s) { - var a = s(t, n) + if (r) { + var a = r(t, n) a && ((e = !1 !== a.retry && e), (o = a.delay)) } - e ? setTimeout(r, o || 0) : i(t) + e ? setTimeout(s, o || 0) : i(t) }) }), new Promise(function (t, e) { @@ -4500,7 +4541,7 @@ }) ) } - function jt() { + function qt() { var t = this ;(this._bottom = 0), (this._top = 0), @@ -4522,34 +4563,34 @@ return t._top - t._bottom }) } - var Nt = { - queue: jt, - depth: function Ds(t, e, i) { + var Kt = { + queue: qt, + depth: function es(t, e, i) { if ('object' == typeof t && t[e] && t[e].length > 0) { - for (var n = t[e].length; --n > -1; ) Ds(t[e][n], e, i) + for (var n = t[e].length; --n > -1; ) es(t[e][n], e, i) } t !== undefined && i(t) }, breathe: function (t, e, i) { - var n = new jt(), + var n = new qt(), o = null for (n.add(t), o = n.remove(); o; ) { - for (var s = 0; s < o[e].length; s++) n.add(o[e][s]) + for (var r = 0; r < o[e].length; r++) n.add(o[e][r]) i(o), (o = n.remove()) } }, } - function zt() { + function Yt() { ;(this.children = []), (this._events = []) } - ;(zt.prototype.initComponent = function (t, e) { + ;(Yt.prototype.initComponent = function (t, e) { var i = new t(e) return (i._parent = this), this.children.push(i), i }), - (zt.prototype.destroy = function () { + (Yt.prototype.destroy = function () { var t = this try { - Nt.depth(this, 'children', function (e) { + Kt.depth(this, 'children', function (e) { if (t !== e) { for (var i = t.children.length; --i > -1; ) { t.children[i] === e && t.children.splice(i, 1) @@ -4557,12 +4598,12 @@ } e._destroy && e._destroy(), (e = null) }) - } catch (Ps) { - throw new Error('Trouble destroying nodes: ' + Ps) + } catch (ts) { + throw new Error('Trouble destroying nodes: ' + ts) } return null }), - (zt.prototype._destroy = function () { + (Yt.prototype._destroy = function () { this.onDestroy && this.onDestroy() for (var t = this._events.length || 0; --t > -1; ) this._events.splice(t, 1) ;(this.children = null), @@ -4574,13 +4615,13 @@ (this.off = null), (this.initComponent = null) }), - (zt.prototype.on = function (t, e) { + (Yt.prototype.on = function (t, e) { for (var i = this._events.length, n = !1; --i > -1 && !1 === n; ) { this._events[i].event === t && (n = this._events[i]) } !1 === n && ((n = { event: t, listeners: [] }), this._events.push(n)), n.listeners.push(e) }), - (zt.prototype.off = function (t, e) { + (Yt.prototype.off = function (t, e) { for (var i = this._events.length; --i > -1; ) { if (this._events[i].event === t) { for (var n = this._events[i].listeners.length; --n > -1; ) { @@ -4590,7 +4631,7 @@ } } }), - (zt.prototype.emit = function (t) { + (Yt.prototype.emit = function (t) { for (var e = Array.prototype.slice.call(arguments, 1), i = this._events.length; --i > -1; ) { if (this._events[i].event === t) { for (var n = this._events[i].listeners.length; --n > -1; ) { @@ -4599,7 +4640,7 @@ } } }) - var Zt = { + var Gt = { eventName: function (t) { var e = t return ( @@ -4632,7 +4673,7 @@ ) }, eventCallback: function (t, e, i) { - var n = Zt.actionName(t) + var n = Gt.actionName(t) return function (o) { if ( ((o = o || window.event), @@ -4643,13 +4684,13 @@ 'out' === n || 'click' === n) ) { - var s = Zt.eventCoords(o) - if (!s) return - var r = i.getBoundingClientRect() - ;(o.windowX = s.x), - (o.windowY = s.y), - (o.elementX = o.windowX - (r.x || r.left)), - (o.elementY = o.windowY - (r.y || r.top)) + var r = Gt.eventCoords(o) + if (!r) return + var s = i.getBoundingClientRect() + ;(o.windowX = r.x), + (o.windowY = r.y), + (o.elementX = o.windowX - (s.x || s.left)), + (o.elementY = o.windowY - (s.y || s.top)) } ;(o.keyNum = o.which || o.keyCode || 0), ('enter' === t && 13 !== o.keyNum && 32 !== o.keyNum) || @@ -4670,24 +4711,24 @@ : null }, }, - Ut = ['Webkit', 'Moz', 'ms'], - Wt = document.createElement('div').style, - Kt = {} - function qt(t) { - var e = Kt[t] + Jt = ['Webkit', 'Moz', 'ms'], + Xt = document.createElement('div').style, + Qt = {} + function te(t) { + var e = Qt[t] return ( e || - (t in Wt + (t in Xt ? t - : (Kt[t] = + : (Qt[t] = (function (t) { - for (var e = t[0].toUpperCase() + t.slice(1), i = Ut.length; i--; ) { - if ((t = Ut[i] + e) in Wt) return t + for (var e = t[0].toUpperCase() + t.slice(1), i = Jt.length; i--; ) { + if ((t = Jt[i] + e) in Xt) return t } })(t) || t)) ) } - function Gt(t, e, i) { + function ee(t, e, i) { if ( ((this.dom = null), (this._clss = []), @@ -4700,7 +4741,7 @@ var n = [], o = [] 'string' == typeof t.className && (o = t.className.split(' ')) - for (var s = 0; s < o.length; s++) '' !== o[s] && ' ' !== o[s] && n.push(o[s]) + for (var r = 0; r < o.length; r++) '' !== o[r] && ' ' !== o[r] && n.push(o[r]) this._clss = n } else { ;(i !== undefined && null !== i) || (i = !0), @@ -4714,50 +4755,57 @@ } !0 === i && ((this._frag = document.createDocumentFragment()), this._frag.appendChild(this.dom)) } - ;(Gt.prototype.createElement = function (t, e) { + ;(ee.prototype.cloneNode = function (t) { try { - var i = new Gt(t, e, !1) - return this.appendElement.call(this, i), this._nodes.push(i), i - } catch (Ps) { - return xt('element', Ps), null + return this.dom.cloneNode(t) + } catch (ts) { + return At('element', ts), null } }), - (Gt.prototype.appendElement = function (t) { + (ee.prototype.createElement = function (t, e) { + try { + var i = new ee(t, e, !1) + return this.appendElement.call(this, i), this._nodes.push(i), i + } catch (ts) { + return At('element', ts), null + } + }), + (ee.prototype.appendElement = function (t) { if (t === undefined) { - return vt({ name: 'DomElement Add Child', message: 'Child Element is undefined' }) + return kt({ name: 'DomElement Add Child', message: 'Child Element is undefined' }) } var e e = t._frag !== undefined && null !== t._frag ? t._frag : t.dom !== undefined ? t.dom : t try { - t instanceof Gt && (t._parent = this), this.dom.appendChild(e) - } catch (Ps) { - vt({ name: 'DomElement Add Child', message: 'Failed to append child.' }) + t instanceof ee && (t._parent = this), this.dom.appendChild(e) + } catch (ts) { + kt({ name: 'DomElement Add Child', message: 'Failed to append child.' }) } return this }), - (Gt.prototype.removeElement = function (t) { + (ee.prototype.removeElement = function (t) { try { var e if (t._nodes) for (e = t._nodes.length; e--; ) t.removeElement(t._nodes[e]) for (e = this._nodes.length; --e > -1; ) this._nodes[e] === t && this._nodes.splice(e, 1) - var i = t instanceof Gt ? t.dom : t, + var i = t instanceof ee ? t.dom : t, n = i.parentNode === this.dom ? this.dom : i.parentNode if ((n.removeChild && n.removeChild(i), !n)) { throw new Error('Child component does not have correct setup') } t.__destroy && t.__destroy() - } catch (Ps) { - vt({ name: 'DomElement Remove Child', message: Ps.message || 'Failed to remove child.' }) + } catch (ts) { + kt({ name: 'DomElement Remove Child', message: ts.message || 'Failed to remove child.' }) } }), - (Gt.prototype.addClass = function (t) { + (ee.prototype.addClass = function (t) { return ( !1 === this.hasClass.call(this, t) && (this._clss.push(t), (this.dom.className = this._clss.join(' '))), this ) }), - (Gt.prototype.hasClass = function (t) { + (ee.prototype.hasClass = function (t) { for ( var e = -1 !== this.dom.className.split(' ').indexOf(t), i = this._clss.length; i-- && !e; @@ -4767,15 +4815,15 @@ } return e }), - (Gt.prototype.removeClass = function (t) { + (ee.prototype.removeClass = function (t) { for (var e = this._clss.length; --e > -1; ) this._clss[e] === t && this._clss.splice(e, 1) return (this.dom.className = this._clss.join(' ')), this }), - (Gt.prototype.text = function (t) { + (ee.prototype.text = function (t) { if (this && this.dom) { if (!t) return this.dom.textContent - for (var e, i, n, o, s = /&(.*?);/g, r = /<[a-z][\s\S]*>/i; null !== (e = s.exec(t)); ) { - !1 === r.test(e[0]) + for (var e, i, n, o, r = /&(.*?);/g, s = /<[a-z][\s\S]*>/i; null !== (e = r.exec(t)); ) { + !1 === s.test(e[0]) ? ((n = e[0]), (o = void 0), ((o = document.createElement('div')).innerHTML = n), @@ -4786,8 +4834,8 @@ return (this.dom.textContent = t), this } }), - (Gt.prototype.content = Gt.prototype.text), - (Gt.prototype.css = function (t) { + (ee.prototype.content = ee.prototype.text), + (ee.prototype.css = function (t) { var e, i = 'ie' === tt.Browser.type && 8 === tt.Browser.version, n = 'safari' === tt.Browser.type && 12 === Math.floor(tt.Browser.version) @@ -4801,70 +4849,70 @@ isFinite(e) && parseFloat(e) === e && (e += 'px') - var s = qt(o) + var r = te(o) i && 'opacity' === o ? (this.dom.style.filter = 'alpha(opacity=' + 100 * e + ')') - : i && Et.hasAlpha(e) - ? (this.dom.style[s] = new Et(e).getHex()) - : (this.dom.style[s] = e) - } catch (Fs) {} + : i && Tt.hasAlpha(e) + ? (this.dom.style[r] = new Tt(e).getHex()) + : (this.dom.style[r] = e) + } catch (Qr) {} } return this }), - (Gt.prototype.backgroundImage = function (t, e, i, n) { + (ee.prototype.backgroundImage = function (t, e, i, n) { var o = e !== undefined && i !== undefined, - s = { '-ms-high-contrast-adjust': 'none' } + r = { '-ms-high-contrast-adjust': 'none' } if (('object' == typeof e && (n = e), n === undefined && (n = {}), o)) { - var r = t.width / t.height, + var s = t.width / t.height, a = e, - l = a / r - n.cover && l < i && (a = (l = i) * r), - n.contain && l > i && (a = (l = i) * r), - (s.width = a), - (s.height = l), + c = a / s + n.cover && c < i && (a = (c = i) * s), + n.contain && c > i && (a = (c = i) * s), + (r.width = a), + (r.height = c), n.center && - ((s.marginLeft = -a / 2), - (s.marginTop = -l / 2), - (s.position = 'absolute'), - (s.left = '50%'), - (s.top = '50%')), - (n.left || n.right) && ((s.left = n.left || 0), (s.top = n.top || 0)) + ((r.marginLeft = -a / 2), + (r.marginTop = -c / 2), + (r.position = 'absolute'), + (r.left = '50%'), + (r.top = '50%')), + (n.left || n.right) && ((r.left = n.left || 0), (r.top = n.top || 0)) } 'ie' === tt.Browser.type && 8 === tt.Browser.version - ? (s.filter = + ? (r.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + t.src + "',sizingMethod='scale')") - : ((s.background = 'url(' + t.src + ')'), - (s.backgroundPosition = '50% 50%'), - (s.backgroundRepeat = 'no-repeat'), - (s.backgroundSize = o - ? a + 'px ' + l + 'px' + : ((r.background = 'url(' + t.src + ')'), + (r.backgroundPosition = '50% 50%'), + (r.backgroundRepeat = 'no-repeat'), + (r.backgroundSize = o + ? a + 'px ' + c + 'px' : n.cover ? 'cover' : n.contain ? 'contain' : '100%')), - this.css.call(this, s) + this.css.call(this, r) }), - (Gt.prototype.setAttribute = function (t, e) { + (ee.prototype.setAttribute = function (t, e) { var i if ('object' == typeof t) for (var n in t) (i = t[n]), this.dom.setAttribute(n, i) else this.dom.setAttribute(t, e) }), - (Gt.prototype.removeAttribute = function (t, e) { + (ee.prototype.removeAttribute = function (t, e) { var i if ('object' == typeof t) for (var n in t) (i = t[n]), this.dom.removeAttribute(n, i) else this.dom.removeAttribute(t, e) }), - (Gt.prototype.addEventListener = function (t, e, i) { - var n = { event: Zt.eventName(t), handler: Zt.eventCallback(t, e, this.dom), callback: e } + (ee.prototype.addEventListener = function (t, e, i) { + var n = { event: Gt.eventName(t), handler: Gt.eventCallback(t, e, this.dom), callback: e } this._listeners.push(n), this.dom.addEventListener ? this.dom.addEventListener(n.event, n.handler, i) : this.dom.attachEvent('on' + n.event, n.handler) }), - (Gt.prototype.removeEventListener = function (t, e, i) { + (ee.prototype.removeEventListener = function (t, e, i) { for (var n, o = this._listeners.length; --o > -1; ) { ;(n = this._listeners[o]).event === t && n.callback === e && @@ -4874,16 +4922,16 @@ : this.dom.detachEvent('on' + n.event, n.handler)) } }), - (Gt.prototype.focus = function () { + (ee.prototype.focus = function () { this.dom.focus() }), - (Gt.prototype.blur = function () { + (ee.prototype.blur = function () { this.dom.blur() }), - (Gt.prototype.html = function (t) { + (ee.prototype.html = function (t) { return t && (this.dom.innerHTML = t), this.dom.innerHTML }), - (Gt.prototype.__destroy = function () { + (ee.prototype.__destroy = function () { for (var t, e = this._listeners.length; --e > -1; ) { ;(t = this._listeners[e]), this._listeners.splice(e, 1), @@ -4901,7 +4949,7 @@ null ) }), - (Gt.prototype.isConnected = function () { + (ee.prototype.isConnected = function () { return ( !!this.dom && ('isConnected' in this.dom @@ -4913,7 +4961,7 @@ )) ) }) - var Jt = { + var ie = { self: function (t, e) { var i = {}, n = Array.prototype.slice.call(arguments, 2) @@ -4923,30 +4971,30 @@ ;(t.prototype = Object.create(e.prototype)), (t.prototype.constructor = t) }, } - function Yt(t, e) { - Jt.self(this, Gt, e || 'div', t), (this.children = []), (this._events = []) + function ne(t, e) { + ie.self(this, ee, e || 'div', t), (this.children = []), (this._events = []) } - function Xt(t) { + function oe(t) { if (null === t) return '' var e = [] - return Qt(t, e), e.join('&') + return re(t, e), e.join('&') } - function Qt(t, e) { + function re(t, e) { var i, n if ('object' == typeof t) { - for (n in t) !0 === te((i = t[n])) ? Qt(i, e) : (e[e.length] = ee(n, i)) + for (n in t) !0 === se((i = t[n])) ? re(i, e) : (e[e.length] = ae(n, i)) } else if (!0 === Array.isArray(t)) { - for (var o = 0; o < t.length; o++) !0 === te((i = t[o])) ? Qt(t, e) : (e[e.length] = ee(n, i)) - } else e[e.length] = ee(t) + for (var o = 0; o < t.length; o++) !0 === se((i = t[o])) ? re(t, e) : (e[e.length] = ae(n, i)) + } else e[e.length] = ae(t) } - function te(t) { + function se(t) { return !0 === Array.isArray(t) || 'object' == typeof t } - function ee(t, e) { + function ae(t, e) { return encodeURIComponent(t) + '=' + encodeURIComponent(null === e ? '' : e) } - Jt.proto(Yt, Gt), - (Yt.prototype.initComponent = function (t, e, i) { + ie.proto(ne, ee), + (ne.prototype.initComponent = function (t, e, i) { try { var n = new t(e) return ( @@ -4956,11 +5004,11 @@ (i !== undefined ? i.appendElement && i.appendElement(n) : this.appendElement(n)), n ) - } catch (Ps) { - return xt('component', Ps), null + } catch (ts) { + return At('component', ts), null } }), - (Yt.prototype.removeComponent = function (t) { + (ne.prototype.removeComponent = function (t) { for (var e = this.children.length; --e > -1; ) { if (this.children[e] === t) { this.children.splice(e, 1) @@ -4969,16 +5017,16 @@ } t._destroy && t._destroy(), (t = null) }), - (Yt.prototype.removeAllComponents = function () { + (ne.prototype.removeAllComponents = function () { for (var t = this.children.length; --t > -1; ) { this.children[t]._destroy && this.children[t]._destroy() } this.children = [] }), - (Yt.prototype.destroy = function () { + (ne.prototype.destroy = function () { var t = this try { - Nt.depth(this, 'children', function (e) { + Kt.depth(this, 'children', function (e) { if (t !== e) { for (var i = t.children.length; --i > -1; ) { t.children[i] === e && t.children.splice(i, 1) @@ -4986,12 +5034,12 @@ } e._destroy && e._destroy(), (e = null) }) - } catch (Ps) { - throw new Error('Trouble destroying nodes: ' + Ps) + } catch (ts) { + throw new Error('Trouble destroying nodes: ' + ts) } return null }), - (Yt.prototype._destroy = function () { + (ne.prototype._destroy = function () { try { this.onDestroy && this.onDestroy(), this._parent.removeElement && this._parent.removeElement(this) @@ -5004,17 +5052,17 @@ (this.on = null), (this.off = null), (this.initComponent = null) - } catch (Ps) { - vt({ name: 'DomComponent', message: 'Failed to destroy.' }) + } catch (ts) { + kt({ name: 'DomComponent', message: 'Failed to destroy.' }) } }), - (Yt.prototype.on = function (t, e) { + (ne.prototype.on = function (t, e) { for (var i = this._events.length, n = !1; --i > -1 && !1 === n; ) { this._events[i].event === t && (n = this._events[i]) } !1 === n && ((n = { event: t, listeners: [] }), this._events.push(n)), n.listeners.push(e) }), - (Yt.prototype.off = function (t, e) { + (ne.prototype.off = function (t, e) { for (var i = this._events.length; --i > -1; ) { if (this._events[i].event === t) { for (var n = this._events[i].listeners.length; --n > -1; ) { @@ -5024,7 +5072,7 @@ } } }), - (Yt.prototype.emit = function (t) { + (ne.prototype.emit = function (t) { for ( var e = Array.prototype.slice.call(arguments, 1), i = this._events.length; --i > -1 && this._events; @@ -5037,7 +5085,7 @@ } } }) - var ie = { + var ce = { af: 'Afrikaans', sq: 'Albanian', am: 'Amharic', @@ -5150,7 +5198,7 @@ yo: 'Yoruba', zu: 'Zulu', }, - ne = { + le = { zh: { 'I am human': '我是人' }, ar: { 'I am human': 'أنا الإنسان' }, af: { 'I am human': 'Ek is menslike' }, @@ -5211,30 +5259,30 @@ vi: { 'I am human': 'Tôi là con người' }, zu: { 'I am human': 'Ngingumuntu' }, }, - oe = null, - se = { + he = null, + ue = { translate: function (t, e) { - var i = se.getBestTrans(ne), + var i = ue.getBestTrans(le), n = i && i[t] if (((n = n || t), e)) { - for (var o = Object.keys(e), s = o.length; s--; ) { - n = n.replace(new RegExp('{{' + o[s] + '}}', 'g'), e[o[s]]) + for (var o = Object.keys(e), r = o.length; r--; ) { + n = n.replace(new RegExp('{{' + o[r] + '}}', 'g'), e[o[r]]) } } return n }, getBestTrans: function (t) { - var e = se.getLocale() + var e = ue.getLocale() return e in t ? t[e] - : se.getShortLocale(e) in t - ? t[se.getShortLocale(e)] + : ue.getShortLocale(e) in t + ? t[ue.getShortLocale(e)] : 'en' in t ? t.en : null }, resolveLocale: function (t) { - var e = se.getShortLocale(t) + var e = ue.getShortLocale(t) return ( 'in' === e && (t = 'id'), 'iw' === e && (t = 'he'), @@ -5242,14 +5290,14 @@ 'ji' === e && (t = 'yi'), 'zh-CN' === t && (t = 'zh'), 'jv' === e && (t = 'jw'), - ie[t] ? t : ie[e] ? e : 'en' + ce[t] ? t : ce[e] ? e : 'en' ) }, getLocale: function () { - return se.resolveLocale(oe || window.navigator.userLanguage || window.navigator.language) + return ue.resolveLocale(he || window.navigator.userLanguage || window.navigator.language) }, setLocale: function (t) { - 'zh-Hans' === t ? (t = 'zh-CN') : 'zh-Hant' === t && (t = 'zh-TW'), (oe = t) + 'zh-Hans' === t ? (t = 'zh-CN') : 'zh-Hant' === t && (t = 'zh-TW'), (he = t) }, getShortLocale: function (t) { return t.indexOf('-') >= 0 ? t.substring(0, t.indexOf('-')) : t @@ -5258,37 +5306,37 @@ return 2 === t.length || 3 === t.length }, addTable: function (t, e) { - if ((e || (e = Object.create(null)), ne[t])) { - var i = ne[t] + if ((e || (e = Object.create(null)), le[t])) { + var i = le[t] for (var n in e) i[n] = e[n] - } else ne[t] = e - return ne[t] + } else le[t] = e + return le[t] }, getTable: function (t) { - return ne[t] + return le[t] }, addTables: function (t) { - for (var e in t) se.addTable(e, t[e]) - return ne + for (var e in t) ue.addTable(e, t[e]) + return le }, getTables: function () { - return ne + return le }, }, - re = { + fe = { 400: 'Rate limited or network error. Please retry.', 429: 'Your computer or network has sent too many requests.', 500: 'Cannot contact hCaptcha. Check your connection and try again.', }, - ae = function (t) { + de = function (t) { try { - return se.translate(re[t]) - } catch (Ps) { + return ue.translate(fe[t]) + } catch (ts) { return !1 } }, - le = 'undefined' != typeof XDomainRequest && !('withCredentials' in XMLHttpRequest.prototype) - function ce(t, e, i) { + pe = 'undefined' != typeof XDomainRequest && !('withCredentials' in XMLHttpRequest.prototype) + function me(t, e, i) { i = i || {} var n = { url: e, @@ -5301,16 +5349,16 @@ timeout: i.timeout || null, pst: i.pst || null, } - n.legacy = n.withCredentials && le - var o = 'fetch' in window && n.pst ? ue : he + n.legacy = n.withCredentials && pe + var o = 'fetch' in window && n.pst ? ge : ye return i.retry - ? $t(function () { + ? Wt(function () { return ( i.data && ((n.data = 'function' == typeof i.data ? i.data() : i.data), 'json' === n.dataType && 'object' == typeof n.data ? (n.data = JSON.stringify(n.data)) - : 'query' === n.dataType && (n.data = Xt(n.data))), + : 'query' === n.dataType && (n.data = oe(n.data))), o(n) ) }, i.retry) @@ -5318,76 +5366,115 @@ ((n.data = 'function' == typeof i.data ? i.data() : i.data), 'json' === n.dataType && 'object' == typeof n.data ? (n.data = JSON.stringify(n.data)) - : 'query' === n.dataType && (n.data = Xt(n.data))), + : 'query' === n.dataType && (n.data = oe(n.data))), o(n)) } - function he(t) { + function ye(t) { var e = t.legacy ? new XDomainRequest() : new XMLHttpRequest(), i = 'function' == typeof t.url ? t.url() : t.url return new Promise(function (n, o) { - var s, - r = function (s) { + var r, + s = function (r) { return function () { - var r = e.response || e.responseText, + var s = e.response, a = e.statusText || '', - l = e.status, - c = e.readyState - if (4 === c || t.legacy) { - if ('json' === t.responseType && r) { - try { - r = JSON.parse(r) - } catch (h) {} + c = e.status, + l = e.readyState + if ( + (s || ('' !== e.responseType && 'text' !== e.responseType) || (s = e.responseText), + 4 === l || t.legacy) + ) { + try { + if (s) { + var h = e.contentType + if ( + (e.getResponseHeader && (h = e.getResponseHeader('content-type')), + 'ArrayBuffer' in window && + s instanceof ArrayBuffer && + h && + -1 !== h.toLowerCase().indexOf('application/json') && + (s = new TextDecoder().decode(new Uint8Array(s))), + 'string' == typeof s) + ) { + try { + s = JSON.parse(s) + } catch (u) { + At('http', u, { + url: i, + config: t, + responseType: e.responseType, + contentType: h, + response: s, + }) + } + } + } + } catch (u) { + return ( + At('http', u, { contentType: h }), + void o({ + event: it.NETWORK_ERROR, + endpoint: i, + response: s, + state: l, + status: c, + message: de(c || 400) || a, + }) + ) } - if ('error' === s || (l >= 400 && l <= 511)) { + if ('error' === r || (c >= 400 && c <= 511)) { return void o({ event: it.NETWORK_ERROR, endpoint: i, - response: r, - state: c, - status: l, - message: ae(l || 400) || a, + response: s, + state: l, + status: c, + message: de(c || 400) || a, }) } - n({ state: c, status: l, body: r, message: a }) + n({ state: l, status: c, body: s, message: a }) } } } if ( - ((e.onload = r('complete')), - (e.onerror = e.ontimeout = r('error')), + ((e.onload = s('complete')), + (e.onerror = e.ontimeout = s('error')), e.open(t.method, i), - 'arraybuffer' === t.responseType && (e.responseType = 'arraybuffer'), - t.timeout && (e.timeout = t.timeout), + 'arraybuffer' === t.responseType && + (!t.legacy && 'TextDecoder' in window && 'ArrayBuffer' in window + ? (e.responseType = 'arraybuffer') + : ((t.responseType = 'json'), (t.headers.accept = 'application/json'))), + t.timeout && (e.timeout = 'function' == typeof t.timeout ? t.timeout(i) : t.timeout), !t.legacy) && ((e.withCredentials = t.withCredentials), t.headers) ) { - for (var a in t.headers) (s = t.headers[a]), e.setRequestHeader(a, s) + for (var a in t.headers) (r = t.headers[a]), e.setRequestHeader(a, r) } setTimeout(function () { e.send(t.data) }, 0) }) } - function ue(t) { + function ge(t) { var e, i = 'function' == typeof t.url ? t.url() : t.url, n = new Headers() if (('json' === t.responseType && n.set('content-type', 'application/json'), t.headers)) { for (var o in t.headers) (e = t.headers[o]), n.set(o, e) } - var s = { method: t.method, credentials: 'include', body: t.data, headers: n } + var r = { method: t.method, credentials: 'include', body: t.data, headers: n } if (t.pst) { - var r = {} + var s = {} 'token-request' === t.pst - ? (r = { version: 1, operation: 'token-request' }) + ? (s = { version: 1, operation: 'token-request' }) : 'token-redemption' === t.pst - ? (r = { version: 1, operation: 'token-redemption', refreshPolicy: 'refresh' }) + ? (s = { version: 1, operation: 'token-redemption', refreshPolicy: 'refresh' }) : 'send-redemption-record' === t.pst && - (r = { version: 1, operation: 'send-redemption-record', issuers: [ut.pstIssuer] }), - (s.privateToken = r) + (s = { version: 1, operation: 'send-redemption-record', issuers: [ft.pstIssuer] }), + (r.privateToken = s) } return new Promise(function (e, n) { - fetch(i, s) + fetch(i, r) .then(function (o) { return 200 !== o.status ? n({ @@ -5396,10 +5483,15 @@ response: o, state: 4, status: o.status, - message: ae(o.status || 400), + message: de(o.status || 400), }) - : ('json' === t.responseType ? o.json() : o.text()).then(function (t) { - e({ state: 4, status: o.status, body: t, message: ae(o.status || 400) }) + : ('arraybuffer' === t.responseType + ? o.arrayBuffer() + : 'json' === t.responseType + ? o.json() + : o.text() + ).then(function (t) { + e({ state: 4, status: o.status, body: t, message: de(o.status || 400) }) }) }) ['catch'](function (t) { @@ -5409,48 +5501,31 @@ response: t.error, state: 4, status: 400, - message: ae(400), + message: de(400), }) }) }) } - var de = function (t, e) { + var ve = function (t, e) { if (('object' == typeof t && e === undefined && (t = (e = t).url), null === t)) { throw new Error('Url missing') } - return ce('GET', t, e) + return me('GET', t, e) }, - pe = function (t, e) { + be = function (t, e) { if (('object' == typeof t && e === undefined && (t = (e = t).url), null === t)) { throw new Error('Url missing') } - return ce('POST', t, e) - }, - fe = function (t) { - return t.toLowerCase().match(/\.(?:jpg|gif|png|jpeg|svg)$/g) - ? 'image' - : t.toLowerCase().match(/\.(?:js)$/g) - ? 'script' - : 'file' - }, - me = function (t) { - if (ut.assethost && t.indexOf(ct.assetDomain) >= 0) { - return ut.assethost + t.replace(ct.assetDomain, '') - } - if (ut.imghost && t.indexOf('imgs') >= 0) { - var e = t.indexOf('.ai') >= 0 ? t.indexOf('.ai') + 3 : t.indexOf('.com') + 4 - return ut.imghost + t.substr(e, t.length) - } - return t + return me('POST', t, e) }, - ye = ['svg', 'gif', 'png'] - function ge(t, e) { + we = ['svg', 'gif', 'png'] + function xe(t, e) { e = e || {} var i, n = t if (0 === n.indexOf('data:image')) { - for (var o = !1, s = ye.length, r = -1; r++ < s && !o; ) { - ;(o = n.indexOf(ye[r]) >= 0) && (i = ye[r]) + for (var o = !1, r = we.length, s = -1; s++ < r && !o; ) { + ;(o = n.indexOf(we[s]) >= 0) && (i = we[s]) } } else i = n.substr(n.lastIndexOf('.') + 1, n.length) !!( @@ -5464,7 +5539,16 @@ e.prefix && (n = e.prefix + '/' + n), (this.attribs = { crossOrigin: e.crossOrigin || null }), (this.id = n), - (this.src = me(n)), + (this.src = (function (t) { + if (ft.assethost && 0 === t.indexOf(ht.assetDomain)) { + return ft.assethost + t.replace(ht.assetDomain, '') + } + if (ft.imghost && t.indexOf('imgs') >= 0) { + var e = t.indexOf('.ai') >= 0 ? t.indexOf('.ai') + 3 : t.indexOf('.com') + 4 + return ft.imghost + t.substr(e, t.length) + } + return t + })(n)), (this.ext = i), (this.width = 0), (this.height = 0), @@ -5474,11 +5558,11 @@ (this.element = null), (this.cb = { load: [], error: [] }) } - function ve(t, e, i) { - for (var n = t[e], o = n.length, s = null; --o > -1; ) (s = n[o]), n.splice(o, 1), s(i) + function ke(t, e, i) { + for (var n = t[e], o = n.length, r = null; --o > -1; ) (r = n[o]), n.splice(o, 1), r(i) 'error' === e ? (t.load = []) : (t.error = []) } - function be(t, e) { + function Ce(t, e) { var i = t e || (e = {}), e.prefix && (i = e.prefix + '/' + t), @@ -5489,38 +5573,46 @@ integrity: e.integrity || null, }), (this.id = i), - (this.src = me(i)), + (this.src = (function (t) { + return ft.assethost && 0 === t.indexOf(ht.assetDomain) + ? ft.assethost + t.replace(ht.assetDomain, '') + : t + })(i)), (this.loaded = !1), (this.error = !1), (this.element = null), (this.cb = { load: [], error: [] }) } - function we(t, e, i) { - for (var n = t[e], o = n.length, s = null; --o > -1; ) (s = n[o]), n.splice(o, 1), s(i) + function _e(t, e, i) { + for (var n = t[e], o = n.length, r = null; --o > -1; ) (r = n[o]), n.splice(o, 1), r(i) 'error' === e ? (t.load = []) : (t.error = []) } - function xe(t, e) { + function Ee(t, e) { var i = t e || (e = {}), e.prefix && (i = e.prefix + '/' + t), (this.responseType = e.responseType), (this.id = i), - (this.src = me(i)), + (this.src = (function (t) { + return ft.assethost && 0 === t.indexOf(ht.assetDomain) + ? ft.assethost + t.replace(ht.assetDomain, '') + : t + })(i)), (this.loaded = !1), (this.error = !1), (this.cb = { load: [], error: [] }), (this.data = null) } - function Ce(t, e, i) { - for (var n = t[e], o = n.length, s = null; --o > -1; ) (s = n[o]), n.splice(o, 1), s(i) + function Ae(t, e, i) { + for (var n = t[e], o = n.length, r = null; --o > -1; ) (r = n[o]), n.splice(o, 1), r(i) 'error' === e ? (t.load = []) : (t.error = []) } - ;(ge.prototype.load = function () { + ;(xe.prototype.load = function () { return ('svg' === this.ext ? this._loadSvg() : this._loadImg())['catch'](function (t) { - throw (wt('Asset failed', 'error', 'assets', { error: t }), t) + throw (Et('Asset failed', 'error', 'assets', { error: t }), t) }) }), - (ge.prototype._loadSvg = function () { + (xe.prototype._loadSvg = function () { var t, e = this, i = this.src, @@ -5529,7 +5621,7 @@ var o = i.slice('data:image/svg+xml,'.length) t = Promise.resolve(decodeURIComponent(o)) } else { - t = de(i).then(function (t) { + t = ve(i).then(function (t) { return t.body }) } @@ -5543,16 +5635,16 @@ ['catch'](function (t) { e.error = !0 var i = (t && t.message ? t.message : t || 'Loading Error') + ': ' + n - throw (ve(e.cb, 'error', i), i) + throw (ke(e.cb, 'error', i), i) }) }), - (ge.prototype._loadImg = function () { + (xe.prototype._loadImg = function () { var t = this, e = this.attribs, i = this.src, n = this.id - return new Promise(function (o, s) { - function r() { + return new Promise(function (o, r) { + function s() { t.loaded || (t._imgLoaded(a, a.width, a.height), (a.onload = a.onerror = null), o(t)) } var a = new Image() @@ -5560,192 +5652,179 @@ (a.onerror = function () { ;(t.error = !0), (a.onload = a.onerror = null) var e = 'Loading Error: ' + n - ve(t.cb, 'error', e), s(e) + ke(t.cb, 'error', e), r(e) }), - (a.onload = r), + (a.onload = s), (a.src = i), - a.complete && r() + a.complete && s() }) }), - (ge.prototype._imgLoaded = function (t, e, i) { - ;(this.element = new Gt(t)), + (xe.prototype._imgLoaded = function (t, e, i) { + ;(this.element = new ee(t)), (this.width = e), (this.height = i), (this.aspect = e / i), (this.loaded = !0), - ve(this.cb, 'load', this) + ke(this.cb, 'load', this) }), - (ge.prototype.onload = function (t) { + (xe.prototype.onload = function (t) { this.error || (this.loaded ? t(this) : this.cb.load.push(t)) }), - (ge.prototype.onerror = function (t) { + (xe.prototype.onerror = function (t) { ;(this.loaded && !this.error) || (this.error ? t(this) : this.cb.error.push(t)) }), - (be.prototype.load = function () { + (Ce.prototype.load = function () { var t = this, e = this.attribs, i = this.src, n = this.id - return new Promise(function (o, s) { - var r = document.createElement('script') - ;(t.element = r), - (r.onerror = function () { - ;(t.error = !0), (r.onload = r.onreadystatechange = r.onerror = null) + return new Promise(function (o, r) { + var s = document.createElement('script') + ;(t.element = s), + (s.onerror = function () { + ;(t.error = !0), (s.onload = s.onreadystatechange = s.onerror = null) var e = 'Loading Error: ' + n - we(t.cb, 'error', e), s(e) + _e(t.cb, 'error', e), r(e) }), - (r.onload = r.onreadystatechange = + (s.onload = s.onreadystatechange = function () { this.loaded || - (r.readyState && 'loaded' !== r.readyState && 'complete' !== r.readyState) || + (s.readyState && 'loaded' !== s.readyState && 'complete' !== s.readyState) || ((t.loaded = !0), - (r.onload = r.onreadystatechange = r.onerror = null), - document.body.removeChild(r), - we(t.cb, 'load', t), + (s.onload = s.onreadystatechange = s.onerror = null), + document.body.removeChild(s), + _e(t.cb, 'load', t), o(t)) }), - (r.type = 'text/javascript'), - (r.src = i), - e.crossOrigin && (r.crossorigin = e.crossOrigin), - e.async && (r.async = !0), - e.defer && (r.defer = !0), - e.integrity && (r.integrity = e.integrity), - document.body.appendChild(r), - r.complete && r.onload() + (s.type = 'text/javascript'), + (s.src = i), + e.crossOrigin && (s.crossorigin = e.crossOrigin), + e.async && (s.async = !0), + e.defer && (s.defer = !0), + e.integrity && (s.integrity = e.integrity), + document.body.appendChild(s), + s.complete && s.onload() }) }), - (be.prototype.onload = function (t) { + (Ce.prototype.onload = function (t) { this.error || (this.loaded ? t(this) : this.cb.load.push(t)) }), - (be.prototype.onerror = function (t) { + (Ce.prototype.onerror = function (t) { ;(this.loaded && !this.error) || (this.error ? t(this) : this.cb.error.push(t)) }), - (xe.prototype.load = function () { + (Ee.prototype.load = function () { var t = this, e = this.src, i = this.id return new Promise(function (n, o) { - var s = {} + var r = {} 'arraybuffer' === t.responseType - ? (s.responseType = 'arraybuffer') - : e.indexOf('json') >= 0 && (s.responseType = 'json'), - de(e, s) + ? (r.responseType = 'arraybuffer') + : e.indexOf('json') >= 0 && (r.responseType = 'json'), + ve(e, r) .then(function (e) { - ;(t.loaded = !0), (t.data = e.body), Ce(t.cb, 'load', t), n(t) + ;(t.loaded = !0), (t.data = e.body), Ae(t.cb, 'load', t), n(t) }) ['catch'](function (e) { t.error = !0 var n = (e && e.message ? e.message : 'Loading Error') + ': ' + i - Ce(t.cb, 'error', n), o(n) + Ae(t.cb, 'error', n), o(n) }) }) }), - (xe.prototype.onload = function (t) { + (Ee.prototype.onload = function (t) { this.error || (this.loaded ? t(this) : this.cb.load.push(t)) }), - (xe.prototype.onerror = function (t) { + (Ee.prototype.onerror = function (t) { ;(this.loaded && !this.error) || (this.error ? t(this) : this.cb.error.push(t)) }) - var ke = [], - _e = { - add: function (t, e) { - var i = fe(t) - return _e[i] ? _e[i](t, e) : Promise.resolve(null) - }, - batch: function (t, e) { - for (var i = [], n = -1; ++n < t.length; ) { - var o = t[n] - i.push(_e.add(o, e)) - } - return Promise.all(i)['finally'](function () { - i = [] - }) - }, + var Se = [], + Be = { image: function (t, e) { - var i = new ge(t, e) - return ke.push(i), i.load() + var i = new xe(t, e) + return Se.push(i), i.load() }, script: function (t, e) { - var i = new be(t, e) - return ke.push(i), i.load() + var i = new Ce(t, e) + return Se.push(i), i.load() }, file: function (t, e) { - var i = new xe(t, e) - return ke.push(i), i.load() + var i = new Ee(t, e) + return Se.push(i), i.load() }, retrieve: function (t) { return new Promise(function (e, i) { - for (var n = ke.length, o = !1, s = null; --n > -1 && !o; ) { - o = (s = ke[n]).id === t || -1 !== s.id.indexOf('/' === t[0] ? '' : '/' + t) + for (var n = Se.length, o = !1, r = null; --n > -1 && !o; ) { + o = (r = Se[n]).id === t || -1 !== r.id.indexOf('/' === t[0] ? '' : '/' + t) } if (!o) return e(null) - s.onload(e), s.onerror(i) + r.onload(e), r.onerror(i) }) }, }, - Ee = [], - Se = !1, - Ae = !1 - function Le(t) { + Le = [], + Te = !1, + Oe = !1 + function He(t) { var e = Array.prototype.slice.call(arguments, 1) - !0 !== Ae && + !0 !== Oe && 'interactive' !== document.readyState && 'loaded' !== document.readyState && 'complete' !== document.readyState - ? (Ee.push({ fn: t, args: e }), !1 === Se && Be()) + ? (Le.push({ fn: t, args: e }), !1 === Te && Me()) : setTimeout(function () { t(e) }, 1) } - function Be() { + function Me() { document.addEventListener - ? (document.addEventListener('DOMContentLoaded', Oe), window.addEventListener('load', Oe)) - : (document.attachEvent('onreadystatechange', He), window.attachEvent('onload', Oe)), - (Se = !0) + ? (document.addEventListener('DOMContentLoaded', Pe), window.addEventListener('load', Pe)) + : (document.attachEvent('onreadystatechange', Re), window.attachEvent('onload', Pe)), + (Te = !0) } - function He() { + function Re() { ;('interactive' !== document.readyState && 'loaded' !== document.readyState && 'complete' !== document.readyState) || - Oe() + Pe() } - function Oe() { - if (!1 === Ae) { - for (var t = 0; t < Ee.length; t++) Ee[t].fn.apply(null, Ee[t].args) - Ee = [] + function Pe() { + if (!1 === Oe) { + for (var t = 0; t < Le.length; t++) Le[t].fn.apply(null, Le[t].args) + Le = [] } - ;(Ae = !0), + ;(Oe = !0), document.removeEventListener - ? (document.removeEventListener('DOMContentLoaded', Oe), - window.removeEventListener('load', Oe)) - : (document.detachEvent('onreadystatechange', He), window.detachEvent('onload', Oe)) + ? (document.removeEventListener('DOMContentLoaded', Pe), + window.removeEventListener('load', Pe)) + : (document.detachEvent('onreadystatechange', Re), window.detachEvent('onload', Pe)) } - var Te = new Gt(document), - Me = new Gt(window), - Ve = { + var Ie = new ee(document), + Ve = new ee(window), + De = { __proto__: null, - Loader: _e, - BaseComponent: zt, - DomComponent: Yt, - DomElement: Gt, - Extend: Jt, - Normalize: Zt, + Loader: Be, + BaseComponent: Yt, + DomComponent: ne, + DomElement: ee, + Extend: ie, + Normalize: Gt, Dom: { __proto__: null, - Window: Me, - Document: Te, - Element: Gt, - Ready: Le, + Window: Ve, + Document: Ie, + Element: ee, + Ready: He, Find: function (t) { - for (var e, i, n = null, o = !1, s = t.split(' '), r = 0; r < s.length; r++) { + for (var e, i, n = null, o = !1, r = t.split(' '), s = 0; s < r.length; s++) { if ( - ((e = s[r]).indexOf('#') >= 0 && (n = document.getElementById(e.replace('#', ''))), + ((e = r[s]).indexOf('#') >= 0 && (n = document.getElementById(e.replace('#', ''))), e.indexOf('.') >= 0) ) { if ((null === n && (n = document), o)) { - for (var a = [], l = 0; l < n.length; l++) { - i = n[l].getElementsByClassName(e.replace('.', '')) - for (var c = 0; c < i.length; c++) a.push(i[c]) + for (var a = [], c = 0; c < n.length; c++) { + i = n[c].getElementsByClassName(e.replace('.', '')) + for (var l = 0; l < i.length; l++) a.push(i[l]) } ;(n = a), (a = []) } else (n = n.getElementsByClassName(e.replace('.', ''))), (o = !0) @@ -5760,7 +5839,7 @@ }, }, } - function Re(t, e) { + function Fe(t, e) { ;(this._period = t), (this._interval = e), (this._date = []), @@ -5769,19 +5848,19 @@ (this._meanPeriod = 0), (this._meanCounter = 0) } - ;(Re.prototype.getMeanPeriod = function () { + ;(Fe.prototype.getMeanPeriod = function () { return this._meanPeriod }), - (Re.prototype.getData = function () { + (Fe.prototype.getData = function () { return this._cleanStaleData(), this._data }), - (Re.prototype.getSize = function () { + (Fe.prototype.getSize = function () { return this._cleanStaleData(), this._data.length }), - (Re.prototype.getCapacity = function () { + (Fe.prototype.getCapacity = function () { return 0 === this._period ? this._interval : Math.ceil(this._interval / this._period) }), - (Re.prototype.push = function (t, e) { + (Fe.prototype.push = function (t, e) { this._cleanStaleData() var i = 0 === this._date.length if ( @@ -5795,7 +5874,7 @@ } this._prevTimestamp = t }), - (Re.prototype._cleanStaleData = function () { + (Fe.prototype._cleanStaleData = function () { for (var t = Date.now(), e = this._date.length - 1; e >= 0; e--) { if (t - this._date[e] >= this._interval) { this._date.splice(0, e + 1), this._data.splice(0, e + 1) @@ -5803,12 +5882,13 @@ } } }) - var Fe = { touchstart: 'ts', touchend: 'te', touchmove: 'tm', touchcancel: 'tc' }, - Pe = { mousedown: 'md', mouseup: 'mu', mousemove: 'mm' }, - De = { keydown: 'kd', keyup: 'ku' }, - Ie = { devicemotion: 'dm' }, - $e = function (t, e) { - var i = Pe[t], + var $e = { touchstart: 'ts', touchend: 'te', touchmove: 'tm', touchcancel: 'tc' }, + Ue = { mousedown: 'md', mouseup: 'mu', mousemove: 'mm' }, + je = { pointermove: 'pm' }, + Ne = { keydown: 'kd', keyup: 'ku' }, + ze = { devicemotion: 'dm' }, + Ze = function (t, e) { + var i = Ue[t], n = null return function (t) { ;(n = (function (t) { @@ -5817,8 +5897,25 @@ e(i, n) } }, - je = function (t, e) { - var i = Fe[t], + We = function (t, e) { + var i = je[t], + n = null + return function (t) { + n = (function (t) { + var e = [], + i = [] + t.getCoalescedEvents && (i = t.getCoalescedEvents()) + for (var n = 0; n < i.length; n++) { + var o = i[n] + e.push([o.x, o.y, Date.now()]) + } + return e + })(t) + for (var o = 0; o < n.length; o++) e(i, n[o]) + } + }, + qe = function (t, e) { + var i = $e[t], n = null return function (t) { ;(n = (function (t) { @@ -5832,20 +5929,20 @@ i) ) { for (var o = 0; o < i.length; o++) { - ;(n = Zt.eventCoords(i[o])) && e.push([i[o].identifier, n.x, n.y]) + ;(n = Gt.eventCoords(i[o])) && e.push([i[o].identifier, n.x, n.y]) } e.push(Date.now()) } return e - } catch (Ps) { + } catch (ts) { return e } })(t)), e(i, n) } }, - Ne = function (t, e) { - var i = De[t], + Ke = function (t, e) { + var i = Ne[t], n = null return function (t) { ;(n = (function (t) { @@ -5854,8 +5951,8 @@ e(i, n) } }, - ze = function (t, e) { - var i = Ie[t], + Ye = function (t, e) { + var i = ze[t], n = null, o = [] return function (t) { @@ -5877,17 +5974,17 @@ n = [] if (0 === e.length) (e = i), (n = i) else { - for (var o, s = 0, r = 0; r < 6; r++) { - ;(o = e[r] - i[r]), n.push(i[r]), (s += Math.abs(o)) + for (var o, r = 0, s = 0; s < 6; s++) { + ;(o = e[s] - i[s]), n.push(i[s]), (r += Math.abs(o)) } - if ((n.push(Date.now()), (e = i), s <= 0)) return null + if ((n.push(Date.now()), (e = i), r <= 0)) return null } return { motion: n, prevmotion: e } })(t, o)), null !== n && ((o = n.prevmotion), (n = n.motion), e(i, n)) } } - function Ze() { + function Ge() { ;(this._manifest = {}), (this.state = { timeBuffers: {}, @@ -5898,7 +5995,7 @@ }), (this._recordEvent = this._recordEvent.bind(this)) } - ;(Ze.prototype.record = function (t, e, i, n) { + ;(Ge.prototype.record = function (t, e, i, n) { if ( ((this._manifest.st = Date.now()), (this.state.record.mouse = t === undefined ? this.state.record.mouse : t), @@ -5907,61 +6004,62 @@ (this.state.record.motion = n === undefined ? this.state.record.motion : n), !1 === this.state.initRecord) ) { - var o = new Gt(document.body) + var o = new ee(document.body) this.state.record.mouse && - (o.addEventListener('mousedown', $e('mousedown', this._recordEvent), !0), - o.addEventListener('mousemove', $e('mousemove', this._recordEvent), !0), - o.addEventListener('mouseup', $e('mouseup', this._recordEvent), !0)), + (o.addEventListener('mousedown', Ze('mousedown', this._recordEvent), !0), + o.addEventListener('mousemove', Ze('mousemove', this._recordEvent), !0), + o.addEventListener('mouseup', Ze('mouseup', this._recordEvent), !0), + o.addEventListener('pointermove', We('pointermove', this._recordEvent), !0)), !0 === this.state.record.keys && - (o.addEventListener('keyup', Ne('keyup', this._recordEvent), !0), - o.addEventListener('keydown', Ne('keydown', this._recordEvent), !0)), + (o.addEventListener('keyup', Ke('keyup', this._recordEvent), !0), + o.addEventListener('keydown', Ke('keydown', this._recordEvent), !0)), this.state.record.touch && !0 === tt.Browser.hasEvent('touchstart', document.body) && - (o.addEventListener('touchstart', je('touchstart', this._recordEvent), !0), - o.addEventListener('touchmove', je('touchmove', this._recordEvent), !0), - o.addEventListener('touchend', je('touchend', this._recordEvent), !0)), + (o.addEventListener('touchstart', qe('touchstart', this._recordEvent), !0), + o.addEventListener('touchmove', qe('touchmove', this._recordEvent), !0), + o.addEventListener('touchend', qe('touchend', this._recordEvent), !0)), this.state.record.motion && !0 === tt.Browser.hasEvent('devicemotion', window) && - o.addEventListener('devicemotion', ze('devicemotion', this._recordEvent), !0), + o.addEventListener('devicemotion', Ye('devicemotion', this._recordEvent), !0), (this.state.initRecord = !0) } this.state.recording = !0 }), - (Ze.prototype.stop = function () { + (Ge.prototype.stop = function () { this.state.recording = !1 }), - (Ze.prototype.time = function () { + (Ge.prototype.time = function () { return this.state.loadTime }), - (Ze.prototype.getData = function () { + (Ge.prototype.getData = function () { for (var t in this.state.timeBuffers) { ;(this._manifest[t] = this.state.timeBuffers[t].getData()), (this._manifest[t + '-mp'] = this.state.timeBuffers[t].getMeanPeriod()) } return this._manifest }), - (Ze.prototype.setData = function (t, e) { + (Ge.prototype.setData = function (t, e) { this._manifest[t] = e }), - (Ze.prototype.resetData = function () { + (Ge.prototype.resetData = function () { ;(this._manifest = {}), (this.state.timeBuffers = {}) }), - (Ze.prototype.circBuffPush = function (t, e) { + (Ge.prototype.circBuffPush = function (t, e) { this._recordEvent(t, e) }), - (Ze.prototype._recordEvent = function (t, e) { + (Ge.prototype._recordEvent = function (t, e) { if (!1 !== this.state.recording) { try { var i = e[e.length - 1] - this.state.timeBuffers[t] || (this.state.timeBuffers[t] = new Re(16, 15e3)), + this.state.timeBuffers[t] || (this.state.timeBuffers[t] = new Fe(16, 15e3)), this.state.timeBuffers[t].push(i, e) - } catch (Fs) { - xt('motion', Fs) + } catch (Qr) { + At('motion', Qr) } } }) - var Ue = new Ze() - function We(t) { + var Je = new Ge() + function Xe(t) { ;(t = t || {}), (this.x = t.x || 0), (this.y = t.y || 0), @@ -5975,15 +6073,15 @@ (this.strokeColor = '#fff'), (this.strokeWidth = 1) } - function Ke(t, e, i) { - Jt.self(this, We, t), - (this.handleIn = new We(e)), - (this.handleOut = new We(i)), + function Qe(t, e, i) { + ie.self(this, Xe, t), + (this.handleIn = new Xe(e)), + (this.handleOut = new Xe(i)), (this.prev = null), (this.next = null), (this.index = 0) } - function qe(t) { + function ti(t) { ;(this._closed = !1), (this.stroke = !1), (this.fill = !1), @@ -6003,17 +6101,17 @@ (this.destroy = this.destroy.bind(this)), t && t.length && this.addPoints(t) } - function Ge(t, e) { + function ei(t, e) { if (e.y <= t.y) { - if (e.next.y > t.y && Je(e, e.next, t) > 0) return 1 - } else if (e.next.y <= t.y && Je(e, e.next, t) < 0) return -1 + if (e.next.y > t.y && ii(e, e.next, t) > 0) return 1 + } else if (e.next.y <= t.y && ii(e, e.next, t) < 0) return -1 return 0 } - function Je(t, e, i) { + function ii(t, e, i) { return (e.x - t.x) * (i.y - t.y) - (i.x - t.x) * (e.y - t.y) } - function Ye(t) { - Jt.self(this, qe), + function ni(t) { + ie.self(this, ti), (this.bounding = { left: 0, top: 0, width: 0, height: 0 }), (this.svgData = (function (t) { if ('string' != typeof t) return null @@ -6021,28 +6119,28 @@ i = e.indexOf('d="') + 3, n = e.indexOf('"', i), o = t.slice(i, n), - s = (function (t) { + r = (function (t) { var e = 0, i = 0, n = 0, o = 0, - s = t.match(/]*width=['"]([^'"]+)['"]/), - r = t.match(/]*height=['"]([^'"]+)['"]/) + r = t.match(/]*width=['"]([^'"]+)['"]/), + s = t.match(/]*height=['"]([^'"]+)['"]/) if ( - s && r && - ((n = parseFloat(s[1])), (o = parseFloat(r[1])), !isNaN(n) && !isNaN(o)) + s && + ((n = parseFloat(r[1])), (o = parseFloat(s[1])), !isNaN(n) && !isNaN(o)) ) { return { left: e, top: i, width: n, height: o } } var a = t.match(/]*viewBox=['"]([^'"]+)['"]/) if (a) { - var l = a[1].split(' ') + var c = a[1].split(' ') if ( - ((e = parseFloat(l[0])), - (i = parseFloat(l[1])), - (n = parseFloat(l[2])), - (o = parseFloat(l[3])), + ((e = parseFloat(c[0])), + (i = parseFloat(c[1])), + (n = parseFloat(c[2])), + (o = parseFloat(c[3])), !(isNaN(e) || isNaN(i) || isNaN(n) || isNaN(o))) ) { return { left: e, top: i, width: n, height: o } @@ -6050,57 +6148,57 @@ } return { left: 0, top: 0, width: 0, height: 0 } })(e) - return { pathCommands: Xe(o), viewport: s } + return { pathCommands: oi(o), viewport: r } })(t)), this.svgData && ((this.bounding.width = this.svgData.viewport.width), (this.bounding.height = this.svgData.viewport.height)) } - function Xe(t) { + function oi(t) { for (var e = t.match(/[a-df-zA-DF-Z][^a-df-zA-DF-Z]*/g) || [], i = [], n = 0; n < e.length; ) { for ( var o = e[n], - s = o[0], - r = o + r = o[0], + s = o .slice(1) .trim() .split(/[\s,]+/), a = [], - l = 0; - l < r.length; + c = 0; + c < s.length; ) { - a.push(parseFloat(r[l])), l++ + a.push(parseFloat(s[c])), c++ } - i.push({ type: s, params: a }), n++ + i.push({ type: r, params: a }), n++ } return i } - ;(We.prototype.rotate = function (t, e) { - var i = Vt(e), + ;(Xe.prototype.rotate = function (t, e) { + var i = Ft(e), n = Math.sin(i), o = Math.cos(i), - s = this.x - t.x, - r = this.y - t.y - ;(this.x = s * o - r * n + t.x), (this.y = s * n + r * o + t.y) + r = this.x - t.x, + s = this.y - t.y + ;(this.x = r * o - s * n + t.x), (this.y = r * n + s * o + t.y) }), - (We.prototype.getDistance = function (t) { + (Xe.prototype.getDistance = function (t) { return Math.sqrt(Math.pow(this.x - t.x, 2) + Math.pow(this.y - t.y, 2)) }), - (We.prototype.getAngle = function (t) { + (Xe.prototype.getAngle = function (t) { var e = t.x - this.x, i = t.y - this.y, - n = Rt(Math.atan2(i, e)) + n = $t(Math.atan2(i, e)) return n < 0 && (n += 360), n }), - (We.prototype.hitTest = function (t) { + (Xe.prototype.hitTest = function (t) { return this.radius + this.tolerance >= this.getDistance(t) }), - (We.prototype.restrict = function (t, e, i, n) { + (Xe.prototype.restrict = function (t, e, i, n) { if ('x' !== t && 'y' !== t) throw new Error('Point.restrict requires a value: x or y') return e + this[t] < i ? (e = this[t] - i) : e + this[t] > n && (e = n - this[t]), this[t] + e }), - (We.prototype.draw = function (t) { + (Xe.prototype.draw = function (t) { t.ctx.beginPath(), t.ctx.arc(this.x, this.y, this.radius / t.scale, 0, 2 * Math.PI, !1), this.fill && ((t.ctx.fillStyle = this.fillColor), t.ctx.fill()), @@ -6109,8 +6207,8 @@ (t.ctx.lineWidth = this.strokeWidth / t.scale), t.ctx.stroke()) }), - Jt.proto(Ke, We), - (Ke.prototype.set = function (t, e, i) { + ie.proto(Qe, Xe), + (Qe.prototype.set = function (t, e, i) { ;(this.x = t.x || this.x), (this.y = t.y || this.y), e === undefined @@ -6120,11 +6218,11 @@ ? ((this.handleOut.x = this.x), (this.handleOut.y = this.y)) : ((this.handleOut.x = i.x), (this.handleOut.y = i.y)) }), - (Ke.prototype.clone = function () { + (Qe.prototype.clone = function () { var t = { x: this.x, y: this.y }, e = { x: this.handleIn.x, y: this.handleIn.y }, i = { x: this.handleOut.x, y: this.handleOut.y }, - n = new Ke() + n = new Qe() return ( e.x === i.x && e.y === i.y ? n.set(t) : n.set(t, e, i), (n.index = this.index), @@ -6140,7 +6238,7 @@ n ) }), - (Ke.prototype.move = function (t, e) { + (Qe.prototype.move = function (t, e) { ;(this.x += t), (this.y += e), (this.handleIn.x += t), @@ -6148,15 +6246,15 @@ (this.handleOut.x += t), (this.handleOut.y += e) }), - (Ke.prototype.render = function (t) { + (Qe.prototype.render = function (t) { this.handleIn.x !== this.x && this.handleIn.y !== this.y && this.handleIn.draw(t), this.handleOut.x !== this.x && this.handleOut.y !== this.y && this.handleOut.draw(t), this.draw(t) }), - (qe.prototype.addPoint = function (t) { + (ti.prototype.addPoint = function (t) { var e return ( - t instanceof Ke ? (e = t.clone()) : ((e = new Ke()).set(t), (e.radius = this.pointRadius)), + t instanceof Qe ? (e = t.clone()) : ((e = new Qe()).set(t), (e.radius = this.pointRadius)), (e.index = this.segments.length), null === this._head ? ((this._head = e), (this._tail = e)) @@ -6167,21 +6265,21 @@ e ) }), - (qe.prototype.addPoints = function (t) { + (ti.prototype.addPoints = function (t) { for (var e = 0; e < t.length; e++) this.addPoint(t[e]) t = null }), - (qe.prototype.setPoints = function (t, e) { + (ti.prototype.setPoints = function (t, e) { e === undefined && (e = 0) for (var i = e; i < t.length; i++) { this.segments[i] === undefined ? this.addPoint(t[i]) : this.segments[i].set(t[i]) } ;(t = null), (e = null) }), - (qe.prototype.setPointRadius = function (t) { + (ti.prototype.setPointRadius = function (t) { for (var e = -1; ++e < this.segments.length; ) undefined.radius = t }), - (qe.prototype.removePoint = function (t) { + (ti.prototype.removePoint = function (t) { for (var e = this.segments.length, i = null; --e > -1 && null === i; ) { ;(i = this.segments[e]), t.x === i.x && @@ -6197,51 +6295,51 @@ } return i }), - (qe.prototype.forEachPoint = function (t, e) { + (ti.prototype.forEachPoint = function (t, e) { if (0 !== this.segments.length && this.segments) { for (var i, n = !1, o = this.segments.length; --o > -1 && !n; ) { ;(i = this.segments[e ? this.segments.length - 1 - o : o]), t && (n = t(i)) } } }), - (qe.prototype.close = function (t) { + (ti.prototype.close = function (t) { this._closed = t }), - (qe.prototype.isClosed = function () { + (ti.prototype.isClosed = function () { return this._closed }), - (qe.prototype.start = function () { + (ti.prototype.start = function () { return this._head }), - (qe.prototype.end = function () { + (ti.prototype.end = function () { return this._tail }), - (qe.prototype.rotate = function (t, e) { + (ti.prototype.rotate = function (t, e) { e === undefined && (e = this.getCenter()) for (var i, n = -1; ++n < this.segments.length; ) { ;(i = this.segments[n]).handleIn.rotate(e, t), i.rotate(e, t), i.handleOut.rotate(e, t) } }), - (qe.prototype.move = function (t, e) { + (ti.prototype.move = function (t, e) { for (var i = -1; ++i < this.segments.length; ) this.segments[i].move(t, e) }), - (qe.prototype.getPoint = function (t) { + (ti.prototype.getPoint = function (t) { return this.segments[t] }), - (qe.prototype.getLength = function () { + (ti.prototype.getLength = function () { return this.segments.length }), - (qe.prototype.getCenter = function () { + (ti.prototype.getCenter = function () { var t = this.getBounding() return { x: (t.right - t.left) / 2 + t.left, y: (t.bottom - t.top) / 2 + t.top } }), - (qe.prototype.getDimensions = function () { + (ti.prototype.getDimensions = function () { var t = this.getBounding() return { width: t.right - t.left, height: t.bottom - t.top } }), - (qe.prototype.getBounding = function () { - for (var t, e = null, i = null, n = null, o = null, s = -1; ++s < this.segments.length; ) { - ;(t = this.segments[s]), + (ti.prototype.getBounding = function () { + for (var t, e = null, i = null, n = null, o = null, r = -1; ++r < this.segments.length; ) { + ;(t = this.segments[r]), (null === e || t.x < e) && (e = t.x), (null === i || t.x > i) && (i = t.x), (null === n || t.y < n) && (n = t.y), @@ -6249,7 +6347,7 @@ } return { left: e, top: n, bottom: o, right: i } }), - (qe.prototype.draw = function (t) { + (ti.prototype.draw = function (t) { t.ctx.beginPath() for (var e = -1, i = this.segments.length; ++e < i; ) { var n = this.segments[e], @@ -6292,102 +6390,102 @@ ;(e.fill = !0), e.render(t) }) }), - (qe.prototype.hitTest = function (t, e) { + (ti.prototype.hitTest = function (t, e) { e === undefined && (e = {}) var i, n = !1, o = 0, - s = !1 + r = !1 ;(e.segment = e.segment === undefined || e.segment), (e.path = e.path === undefined || e.path) - for (var r = -1; ++r < this.segments.length; ) { - ;(i = this.segments[r]), - e.path && this._closed && (o += Ge(t, i)), - e.segment && i.hitTest(t) && (s = i) + for (var s = -1; ++s < this.segments.length; ) { + ;(i = this.segments[s]), + e.path && this._closed && (o += ei(t, i)), + e.segment && i.hitTest(t) && (r = i) } return ( - e.path && 0 !== o && !1 === s + e.path && 0 !== o && !1 === r ? (n = { type: 'path', geometry: this }) - : s && (n = { type: 'segment', geometry: s }), + : r && (n = { type: 'segment', geometry: r }), n ) }), - (qe.prototype.destroy = function () { + (ti.prototype.destroy = function () { for (var t = this.segments.length; --t > -1; ) this.segments.splice(t, 1) return (this._head = null), (this._tail = null), (this.segments = []), null }), - Jt.proto(Ye, qe), - (Ye.prototype.size = function (t, e) { + ie.proto(ni, ti), + (ni.prototype.size = function (t, e) { t ? (e || (e = t), (this.bounding.width = t), (this.bounding.height = e)) : ((this.bounding.width = this.svgData.viewport.width), (this.bounding.height = this.svgData.viewport.height)) }), - (Ye.prototype.move = function (t, e) { + (ni.prototype.move = function (t, e) { t && (e || (e = t), (this.bounding.left = t), (this.bounding.top = e)) }), - (Ye.prototype.destroy = function () { + (ni.prototype.destroy = function () { ;(this.bounding = { left: 0, top: 0, width: 0, height: 0 }), (this.svgData = null) }), - (Ye.prototype.getBounding = function () { + (ni.prototype.getBounding = function () { return this.bounding }), - (Ye.prototype.drawSVG = function (t) { - Qe(t, this.svgData, this.bounding) + (ni.prototype.drawSVG = function (t) { + ri(t, this.svgData, this.bounding) }) - var Qe = function (t, e, i) { + var ri = function (t, e, i) { if (t && e && i) { var n = t.ctx, o = 0, - s = 0, - r = e.pathCommands, + r = 0, + s = e.pathCommands, a = e.viewport, - l = i.width / a.width, - c = i.height / a.height, - h = Math.min(l, c) + c = i.width / a.width, + l = i.height / a.height, + h = Math.min(c, l) n.translate(i.left + a.left, i.top + a.top), n.beginPath() - for (var u = 0; u < r.length; ) { - var d = r[u].params - switch (r[u].type) { + for (var u = 0; u < s.length; ) { + var f = s[u].params + switch (s[u].type) { case 'M': - n.moveTo(d[0] * h, d[1] * h), (o = d[0] * h), (s = d[1] * h) + n.moveTo(f[0] * h, f[1] * h), (o = f[0] * h), (r = f[1] * h) break case 'm': - n.moveTo(o + d[0] * h, s + d[1] * h), (o += d[0] * h), (s += d[1] * h) + n.moveTo(o + f[0] * h, r + f[1] * h), (o += f[0] * h), (r += f[1] * h) break case 'L': - n.lineTo(d[0] * h, d[1] * h), (o = d[0] * h), (s = d[1] * h) + n.lineTo(f[0] * h, f[1] * h), (o = f[0] * h), (r = f[1] * h) break case 'l': - n.lineTo(o + d[0] * h, s + d[1] * h), (o += d[0] * h), (s += d[1] * h) + n.lineTo(o + f[0] * h, r + f[1] * h), (o += f[0] * h), (r += f[1] * h) break case 'H': - n.lineTo(d[0] * h, s), (o = d[0] * h) + n.lineTo(f[0] * h, r), (o = f[0] * h) break case 'h': - n.lineTo(o + d[0] * h, s), (o += d[0] * h) + n.lineTo(o + f[0] * h, r), (o += f[0] * h) break case 'V': - n.lineTo(o, d[0] * h), (s = d[0] * h) + n.lineTo(o, f[0] * h), (r = f[0] * h) break case 'v': - n.lineTo(o, s + d[0] * h), (s += d[0] * h) + n.lineTo(o, r + f[0] * h), (r += f[0] * h) break case 'C': - n.bezierCurveTo(d[0] * h, d[1] * h, d[2] * h, d[3] * h, d[4] * h, d[5] * h), - (o = d[4] * h), - (s = d[5] * h) + n.bezierCurveTo(f[0] * h, f[1] * h, f[2] * h, f[3] * h, f[4] * h, f[5] * h), + (o = f[4] * h), + (r = f[5] * h) break case 'c': n.bezierCurveTo( - o + d[0] * h, - s + d[1] * h, - o + d[2] * h, - s + d[3] * h, - o + d[4] * h, - s + d[5] * h, + o + f[0] * h, + r + f[1] * h, + o + f[2] * h, + r + f[3] * h, + o + f[4] * h, + r + f[5] * h, ), - (o += d[4] * h), - (s += d[5] * h) + (o += f[4] * h), + (r += f[5] * h) break case 'Z': case 'z': @@ -6398,8 +6496,8 @@ n.stroke() } } - function ti() { - Jt.self(this, We), + function si() { + ie.self(this, Xe), (this.radius = 0), (this.tolerance = 0), (this.fill = !1), @@ -6409,38 +6507,38 @@ (this.hovered = !1), (this.complete = !1) } - function ei() { - Jt.self(this, Gt, 'canvas') + function ai() { + ie.self(this, ee, 'canvas') var t = this ;(this.element = this.dom), (this.ctx = this.element.getContext('2d')), (this.scale = 1), (this.dpr = window.devicePixelRatio || 1), (this.clearColor = '#fff'), - (this.ctx.roundedRect = function (e, i, n, o, s) { - var r = n > 0 ? s : -s, - a = o > 0 ? s : -s + (this.ctx.roundedRect = function (e, i, n, o, r) { + var s = n > 0 ? r : -r, + a = o > 0 ? r : -r t.ctx.beginPath(), - t.ctx.moveTo(e + r, i), - t.ctx.lineTo(e + n - r, i), + t.ctx.moveTo(e + s, i), + t.ctx.lineTo(e + n - s, i), t.ctx.quadraticCurveTo(e + n, i, e + n, i + a), t.ctx.lineTo(e + n, i + o - a), - t.ctx.quadraticCurveTo(e + n, i + o, e + n - r, i + o), - t.ctx.lineTo(e + r, i + o), + t.ctx.quadraticCurveTo(e + n, i + o, e + n - s, i + o), + t.ctx.lineTo(e + s, i + o), t.ctx.quadraticCurveTo(e, i + o, e, i + o - a), t.ctx.lineTo(e, i + a), - t.ctx.quadraticCurveTo(e, i, e + r, i), + t.ctx.quadraticCurveTo(e, i, e + s, i), t.ctx.closePath() }) } - function ii() { + function ci() { this._events = Object.create(null) } - function ni(t, e, i, n) { + function li(t, e, i, n) { this._events[t] || (this._events[t] = []), this._events[t].unshift({ fn: e, once: n, context: i }) } - function oi(t, e, i) { + function hi(t, e, i) { ;(this.target = t), this.setTargetOrigin(i), (this.id = e), @@ -6450,33 +6548,33 @@ (this.isReady = !0), (this.queue = []) } - Jt.proto(ti, We), - (ti.prototype.draw = function (t) { + ie.proto(si, Xe), + (si.prototype.draw = function (t) { var e = this.radius / t.scale if (this.complete) { t.ctx.save(), t.ctx.beginPath(), t.ctx.arc(this.x, this.y, e + 2, 0, 2 * Math.PI), - (t.ctx.strokeStyle = ht.white), - (t.ctx.fillStyle = ht.white), + (t.ctx.strokeStyle = ut.white), + (t.ctx.fillStyle = ut.white), (t.ctx.lineWidth = 2), t.ctx.stroke(), t.ctx.fill(), t.ctx.beginPath(), t.ctx.arc(this.x, this.y, e + 3, 0, 2 * Math.PI), - (t.ctx.strokeStyle = ht.outline), + (t.ctx.strokeStyle = ut.outline), (t.ctx.lineWidth = 1), t.ctx.stroke(), t.ctx.restore(), this.hovered && (t.ctx.beginPath(), t.ctx.arc(this.x, this.y, e + 9, 0, 2 * Math.PI), - (t.ctx.strokeStyle = ht.white), + (t.ctx.strokeStyle = ut.white), (t.ctx.lineWidth = 2), t.ctx.stroke(), t.ctx.beginPath(), t.ctx.arc(this.x, this.y, e + 10, 0, 2 * Math.PI), - (t.ctx.strokeStyle = ht.outline), + (t.ctx.strokeStyle = ut.outline), (t.ctx.lineWidth = 1), t.ctx.stroke()) } else { @@ -6484,51 +6582,51 @@ n = [2.5, 4] t.ctx.beginPath(), t.ctx.arc(this.x, this.y, 1.5, 0, 2 * Math.PI, !1), - (t.ctx.strokeStyle = ht.white), + (t.ctx.strokeStyle = ut.white), (t.ctx.lineWidth = 0.5), (t.ctx.fillStyle = this.fillColor), t.ctx.fill(), - (t.ctx.strokeStyle = ht.outline), + (t.ctx.strokeStyle = ut.outline), (t.ctx.lineWidth = 0.5), t.ctx.stroke(), t.ctx.beginPath(), t.ctx.arc(this.x, this.y, e + 2, 0, 2 * Math.PI), - (t.ctx.strokeStyle = ht.white), + (t.ctx.strokeStyle = ut.white), (t.ctx.lineWidth = 2), t.ctx.stroke(), t.ctx.beginPath(), t.ctx.arc(this.x, this.y, e + 3, 0, 2 * Math.PI), - (t.ctx.strokeStyle = ht.outline), + (t.ctx.strokeStyle = ut.outline), (t.ctx.lineWidth = 1), t.ctx.stroke(), - (t.ctx.fillStyle = ht.outline), + (t.ctx.fillStyle = ut.outline), t.ctx.roundedRect(this.x - (e + 5), this.y - 2, n[0], n[1], 2), t.ctx.fill(), - (t.ctx.fillStyle = ht.white), + (t.ctx.fillStyle = ut.white), t.ctx.roundedRect(this.x - (e + 5 - 1), this.y - 1, n[0], n[1] / 2, 1), t.ctx.fill(), - (t.ctx.fillStyle = ht.outline), + (t.ctx.fillStyle = ut.outline), t.ctx.roundedRect(this.x + e + i, this.y - 2, n[0], n[1], 2), t.ctx.fill(), - (t.ctx.fillStyle = ht.white), + (t.ctx.fillStyle = ut.white), t.ctx.roundedRect(this.x + e + i - 1, this.y - 1, n[0], n[1] / 2, 1), t.ctx.fill(), - (t.ctx.fillStyle = ht.outline), + (t.ctx.fillStyle = ut.outline), t.ctx.roundedRect(this.x - 2, this.y - e - 5, n[1], n[0], 2), t.ctx.fill(), - (t.ctx.fillStyle = ht.white), + (t.ctx.fillStyle = ut.white), t.ctx.roundedRect(this.x - 1, this.y - e - 5 + 1, n[1] / 2, n[0], 1), t.ctx.fill(), - (t.ctx.fillStyle = ht.outline), + (t.ctx.fillStyle = ut.outline), t.ctx.roundedRect(this.x - 2, this.y + e + i, n[1], n[0], 2), t.ctx.fill(), - (t.ctx.fillStyle = ht.white), + (t.ctx.fillStyle = ut.white), t.ctx.roundedRect(this.x - 1, this.y + e + i - 1, n[1] / 2, n[0], 1), t.ctx.fill() } }), - Jt.proto(ei, Gt), - (ei.prototype.dimensions = function (t, e) { + ie.proto(ai, ee), + (ai.prototype.dimensions = function (t, e) { this.css({ width: t, height: e }), (this.element.width = Math.round(t / this.scale) * this.dpr), (this.element.height = Math.round(e / this.scale) * this.dpr), @@ -6536,35 +6634,35 @@ (this.width = Math.round(t / this.scale)), (this.height = Math.round(e / this.scale)) }), - (ei.prototype.clear = function () { + (ai.prototype.clear = function () { this.ctx && this.ctx.clearRect(0, 0, this.element.width, this.element.height) }), - (ei.prototype.draw = function () { + (ai.prototype.draw = function () { this.ctx && ((this.ctx.fillStyle = this.clearColor), this.ctx.fillRect(0, 0, this.element.width, this.element.height)) }), - (ei.prototype._destroy = function () { + (ai.prototype._destroy = function () { this.__destroy(), (this.element = null), (this.ctx = null), (this.width = null), (this.height = null) }), - (ii.prototype.on = function (t, e, i) { - ni.call(this, t, e, i, !1) + (ci.prototype.on = function (t, e, i) { + li.call(this, t, e, i, !1) }), - (ii.prototype.once = function (t, e, i) { - ni.call(this, t, e, i, !0) + (ci.prototype.once = function (t, e, i) { + li.call(this, t, e, i, !0) }), - (ii.prototype.off = function (t, e) { + (ci.prototype.off = function (t, e) { var i = this._events[t] if (i) { for (var n = i.length; --n > -1; ) i[n].fn === e && i.splice(n, 1) 0 === i.length && delete this._events[t] } }), - (ii.prototype.emit = function (t) { + (ci.prototype.emit = function (t) { var e = this._events[t] if (e) { for (var i, n = Array.prototype.slice.call(arguments, 1), o = e.length; --o > -1; ) { @@ -6573,21 +6671,21 @@ 0 === e.length && delete this._events[t] } }), - (ii.prototype.removeAllListeners = function () { + (ci.prototype.removeAllListeners = function () { this._events = Object.create(null) }), - (oi.prototype._sendMessage = function (t, e) { + (hi.prototype._sendMessage = function (t, e) { var i = t instanceof HTMLIFrameElement try { i ? t.contentWindow.postMessage(JSON.stringify(e), this.targetOrigin) : t.postMessage(JSON.stringify(e), this.targetOrigin) - } catch (Fs) { - xt('messaging', Fs), + } catch (Qr) { + At('messaging', Qr), '*' !== this.targetOrigin && (this.setTargetOrigin('*'), this._sendMessage(t, e)) } }), - (oi.prototype.setReady = function (t) { + (hi.prototype.setReady = function (t) { var e = this ;(e.isReady = t), e.isReady && @@ -6597,16 +6695,16 @@ }), e.clearQueue()) }), - (oi.prototype.clearQueue = function () { + (hi.prototype.clearQueue = function () { this.queue = [] }), - (oi.prototype.setID = function (t) { + (hi.prototype.setID = function (t) { this.id = t }), - (oi.prototype.setTargetOrigin = function (t) { + (hi.prototype.setTargetOrigin = function (t) { this.targetOrigin = '*' }), - (oi.prototype.contact = function (t, e) { + (hi.prototype.contact = function (t, e) { if (!this.id) throw new Error('Chat requires unique id to communicate between windows') var i = this, n = Math.random().toString(36).substr(2), @@ -6615,25 +6713,25 @@ if ('object' != typeof e) throw new Error('Message must be an object.') o.contents = e } - return new Promise(function (e, s) { - i.waiting.push({ label: t, reject: s, resolve: e, lookup: n }), i._addToQueue(i.target, o) + return new Promise(function (e, r) { + i.waiting.push({ label: t, reject: r, resolve: e, lookup: n }), i._addToQueue(i.target, o) }) }), - (oi.prototype.listen = function (t, e) { + (hi.prototype.listen = function (t, e) { if (!this.id) throw new Error('Chat requires unique id to communicate between windows') for (var i = this.messages.length, n = !1; --i > -1 && !1 === n; ) { this.messages[i].label === t && (n = this.messages[i]) } !1 === n && ((n = { label: t, listeners: [] }), this.messages.push(n)), n.listeners.push(e) }), - (oi.prototype.answer = function (t, e) { + (hi.prototype.answer = function (t, e) { if (!this.id) throw new Error('Chat requires unique id to communicate between windows') for (var i = this.incoming.length, n = !1; --i > -1 && !1 === n; ) { this.incoming[i].label === t && (n = this.incoming[i]) } !1 === n && ((n = { label: t, listeners: [] }), this.incoming.push(n)), n.listeners.push(e) }), - (oi.prototype.send = function (t, e) { + (hi.prototype.send = function (t, e) { var i = this if (!i.id) throw new Error('Chat requires unique id to communicate between windows') var n = { source: 'hcaptcha', label: t, id: i.id } @@ -6643,7 +6741,7 @@ } i._addToQueue(i.target, n) }), - (oi.prototype.check = function (t, e) { + (hi.prototype.check = function (t, e) { for ( var i = [].concat.apply([], [this.messages, this.incoming, this.waiting]), n = [], o = -1; ++o < i.length; @@ -6656,45 +6754,45 @@ } return n }), - (oi.prototype.respond = function (t) { + (hi.prototype.respond = function (t) { for ( var e, i, n = -1, o = 0, - s = [].concat.apply([], [this.messages, this.incoming, this.waiting]); - ++n < s.length; + r = [].concat.apply([], [this.messages, this.incoming, this.waiting]); + ++n < r.length; ) { - if (s[n].label === t.label) { - if (t.lookup && s[n].lookup && t.lookup !== s[n].lookup) continue - var r = [] + if (r[n].label === t.label) { + if (t.lookup && r[n].lookup && t.lookup !== r[n].lookup) continue + var s = [] if ( - ((e = s[n]), - t.error && r.push(t.error), - t.contents && r.push(t.contents), + ((e = r[n]), + t.error && s.push(t.error), + t.contents && s.push(t.contents), t.promise && 'create' !== t.promise) ) { - e[t.promise].apply(e[t.promise], r) - for (var a = this.waiting.length, l = !1; --a > -1 && !1 === l; ) { + e[t.promise].apply(e[t.promise], s) + for (var a = this.waiting.length, c = !1; --a > -1 && !1 === c; ) { this.waiting[a].label === e.label && this.waiting[a].lookup === e.lookup && - ((l = !0), this.waiting.splice(a, 1)) + ((c = !0), this.waiting.splice(a, 1)) } continue } for (o = 0; o < e.listeners.length; o++) { if (((i = e.listeners[o]), 'create' === t.promise)) { - var c = this._contactPromise(e.label, t.lookup) - r.push(c) + var l = this._contactPromise(e.label, t.lookup) + s.push(l) } - i.apply(i, r) + i.apply(i, s) } } } - s = null + r = null }), - (oi.prototype.destroy = function () { + (hi.prototype.destroy = function () { return ( this.clearQueue(), (this.messages = null), @@ -6704,28 +6802,28 @@ null ) }), - (oi.prototype._contactPromise = function (t, e) { + (hi.prototype._contactPromise = function (t, e) { var i = this, n = {}, o = new Promise(function (t, e) { ;(n.resolve = t), (n.reject = e) }), - s = { source: 'hcaptcha', label: t, id: i.id, promise: null, lookup: e } + r = { source: 'hcaptcha', label: t, id: i.id, promise: null, lookup: e } return ( o .then(function (t) { - ;(s.promise = 'resolve'), null !== t && (s.contents = t), i._addToQueue(i.target, s) + ;(r.promise = 'resolve'), null !== t && (r.contents = t), i._addToQueue(i.target, r) }) ['catch'](function (t) { - ;(s.promise = 'reject'), null !== t && (s.error = t), i._addToQueue(i.target, s) + ;(r.promise = 'reject'), null !== t && (r.error = t), i._addToQueue(i.target, r) }), n ) }), - (oi.prototype._addToQueue = function (t, e) { + (hi.prototype._addToQueue = function (t, e) { this.isReady ? this._sendMessage(t, e) : this.queue.push([t, e]) }) - var si = { + var ui = { chats: [], messages: [], globalEnabled: !1, @@ -6733,24 +6831,24 @@ return !!window.postMessage }, createChat: function (t, e, i) { - var n = new oi(t, e, i) - return si.chats.push(n), n + var n = new hi(t, e, i) + return ui.chats.push(n), n }, addChat: function (t) { - si.chats.push(t) + ui.chats.push(t) }, removeChat: function (t) { - for (var e = !1, i = si.chats.length; --i > -1 && !1 === e; ) { - t.id === si.chats[i].id && - t.target === si.chats[i].target && - ((e = si.chats[i]), si.chats.splice(i, 1)) + for (var e = !1, i = ui.chats.length; --i > -1 && !1 === e; ) { + t.id === ui.chats[i].id && + t.target === ui.chats[i].target && + ((e = ui.chats[i]), ui.chats.splice(i, 1)) } return e }, handleGlobal: function (t) { - if (si.globalEnabled) { - var e = si.messages - if (e.length >= 10) si.globalEnabled = !1 + if (ui.globalEnabled) { + var e = ui.messages + if (e.length >= 10) ui.globalEnabled = !1 else { var i = e.some(function (e) { return JSON.stringify(e.data) === JSON.stringify(t.data) @@ -6763,29 +6861,29 @@ var e = t.data, i = 'string' == typeof e && e.indexOf('hcaptcha') >= 0 try { - if (!i) return void si.handleGlobal(t) + if (!i) return void ui.handleGlobal(t) e = JSON.parse(e) - for (var n, o = si.chats, s = -1; ++s < o.length; ) { - var r = '*' === (n = o[s]).targetOrigin || t.origin === n.targetOrigin - n.id === e.id && r && n.respond(e) + for (var n, o = ui.chats, r = -1; ++r < o.length; ) { + var s = '*' === (n = o[r]).targetOrigin || t.origin === n.targetOrigin + n.id === e.id && s && n.respond(e) } - } catch (Fs) { - Ct('postMessage handler error', 'postMessage', 'debug', { event: t, error: Fs }) + } catch (Qr) { + St('postMessage handler error', 'postMessage', 'debug', { event: t, error: Qr }) } }, } window.addEventListener - ? window.addEventListener('message', si.handle) - : window.attachEvent('onmessage', si.handle) - var ri = new oi(window.parent) - ri.init = function (t, e) { - ri.setID(t), ri.setTargetOrigin(e), (si.globalEnabled = !0), si.addChat(ri) + ? window.addEventListener('message', ui.handle) + : window.attachEvent('onmessage', ui.handle) + var fi = new hi(window.parent) + fi.init = function (t, e) { + fi.setID(t), fi.setTargetOrigin(e), (ui.globalEnabled = !0), ui.addChat(fi) } - var ai = null - function li(t) { - ai && ut.confirmNav ? ai.display('link', { url: t }) : window.open(t, '_blank') + var di = null + function pi(t) { + di && ft.confirmNav ? di.display('link', { url: t }) : window.open(t, '_blank') } - function ci(t, e) { + function mi(t, e) { for (var i in e) { var n = e[i] switch (typeof n) { @@ -6793,7 +6891,7 @@ t[i] = n break case 'object': - ;(t[i] = t[i] || {}), ci(t[i], n) + ;(t[i] = t[i] || {}), mi(t[i], n) break default: throw new Error( @@ -6802,43 +6900,43 @@ } } } - function hi(t, e) { + function yi(t, e) { try { return t in e } catch (i) { return !1 } } - function ui(t) { + function gi(t) { return !!t && 'object' == typeof t } - function di(t) { - return ui(t) ? pi({}, t) : t + function vi(t) { + return gi(t) ? bi({}, t) : t } - function pi(t, e) { + function bi(t, e) { var i, n = {}, o = Object.keys(t) - for (i = 0; i < o.length; i++) n[o[i]] = di(t[o[i]]) - var s, - r, + for (i = 0; i < o.length; i++) n[o[i]] = vi(t[o[i]]) + var r, + s, a = Object.keys(e) for (i = 0; i < a.length; i++) { - var l = a[i] + var c = a[i] if ( !( - !hi((s = l), (r = t)) || - (Object.hasOwnProperty.call(r, s) && Object.propertyIsEnumerable.call(r, s)) + !yi((r = c), (s = t)) || + (Object.hasOwnProperty.call(s, r) && Object.propertyIsEnumerable.call(s, r)) ) ) { return } - hi(l, t) && ui(t[l]) ? (n[l] = pi(t[l], e[l])) : (n[l] = di(e[l])) + yi(c, t) && gi(t[c]) ? (n[c] = bi(t[c], e[c])) : (n[c] = vi(e[c])) } return n } - var fi = { transparent: 'transparent', white: '#ffffff', black: '#000000' }, - mi = { + var wi = { transparent: 'transparent', white: '#ffffff', black: '#000000' }, + xi = { 100: '#fafafa', 200: '#f5f5f5', 300: '#E0E0E0', @@ -6850,77 +6948,77 @@ 900: '#222222', 1e3: '#14191F', }, - yi = { 300: '#4DE1D2', 500: '#00838F' }, - gi = { 300: '#BF1722', 500: '#BF1722', 700: '#9D1B1B' }, - vi = { __proto__: null, common: fi, grey: mi, teal: yi, red: gi }, - bi = { + ki = { 300: '#4DE1D2', 500: '#00838F' }, + Ci = { 300: '#BF1722', 500: '#BF1722', 700: '#9D1B1B' }, + _i = { __proto__: null, common: wi, grey: xi, teal: ki, red: Ci }, + Ei = { mode: 'light', - grey: mi, - primary: { main: yi[500] }, - secondary: { main: yi[300] }, - warn: { light: gi[300], main: gi[500], dark: gi[700] }, - text: { heading: mi[700], body: mi[700] }, + grey: xi, + primary: { main: ki[500] }, + secondary: { main: ki[300] }, + warn: { light: Ci[300], main: Ci[500], dark: Ci[700] }, + text: { heading: xi[700], body: xi[700] }, }, - wi = { + Ai = { mode: 'dark', - grey: mi, - primary: { main: yi[500] }, - secondary: { main: yi[300] }, - text: { heading: mi[200], body: mi[200] }, + grey: xi, + primary: { main: ki[500] }, + secondary: { main: ki[300] }, + text: { heading: xi[200], body: xi[200] }, } - function xi(t, e) { - return 'dark' === e && t in wi ? wi[t] : bi[t] + function Si(t, e) { + return 'dark' === e && t in Ai ? Ai[t] : Ei[t] } - function Ci() { + function Bi() { ;(this._themes = Object.create(null)), (this._active = 'light'), this.add('light', {}), this.add('dark', { palette: { mode: 'dark' } }) } - ;(Ci.prototype.get = function (t) { + ;(Bi.prototype.get = function (t) { if (!t) return this._themes[this._active] var e = this._themes[t] if (!e) throw new Error('Cannot find theme with name: ' + t) return e }), - (Ci.prototype.use = function (t) { + (Bi.prototype.use = function (t) { this._themes[t] ? (this._active = t) : console.error('Cannot find theme with name: ' + t) }), - (Ci.prototype.active = function () { + (Bi.prototype.active = function () { return this._active }), - (Ci.prototype.add = function (t, e) { + (Bi.prototype.add = function (t, e) { e || (e = {}), (e.palette = (function (t) { t || (t = {}) var e = t.mode || 'light', - i = t.primary || xi('primary', e), - n = t.secondary || xi('secondary', e), - o = t.warn || xi('warn', e), - s = t.grey || xi('grey', e), - r = t.text || xi('text', e) - return pi({ common: fi, mode: e, primary: i, secondary: n, grey: s, warn: o, text: r }, t) + i = t.primary || Si('primary', e), + n = t.secondary || Si('secondary', e), + o = t.warn || Si('warn', e), + r = t.grey || Si('grey', e), + s = t.text || Si('text', e) + return bi({ common: wi, mode: e, primary: i, secondary: n, grey: r, warn: o, text: s }, t) })(e.palette)), (e.component = e.component || Object.create(null)), (this._themes[t] = e) }), - (Ci.prototype.extend = function (t, e) { + (Bi.prototype.extend = function (t, e) { 'string' == typeof e && (e = JSON.parse(e)) var i = JSON.parse(JSON.stringify(this.get(t))) - return ci(i, e), i + return mi(i, e), i }), - (Ci.merge = function (t, e) { - return pi(t, e || {}) + (Bi.merge = function (t, e) { + return bi(t, e || {}) }) - var ki = { __proto__: null, Colors: vi, Theme: Ci }, - _i = new Ci() - function Ei(t) { + var Li = { __proto__: null, Colors: _i, Theme: Bi }, + Ti = new Bi() + function Oi(t) { var e = t.palette, i = t.component - return Ci.merge({ focus: { outline: e.primary.main } }, i.link) + return Bi.merge({ focus: { outline: e.primary.main } }, i.link) } - function Si(t) { - Jt.self(this, Yt, 'link', 'a'), + function Hi(t) { + ie.self(this, ne, 'link', 'a'), (this.config = { url: t.url, text: t.text, @@ -6943,19 +7041,19 @@ this.addEventListener('blur', this.onBlur), this.translate() } - function Ai(t) { - Jt.self(this, Yt, null, 'span'), + function Mi(t) { + ie.self(this, ne, null, 'span'), (this.config = { text: t.text, bold: t.bold }), this.text(this.config.text) } - function Li(t) { - Jt.self(this, Yt, t.selector || null, t.element || 'div'), (this.state = { theme: t.theme }) + function Ri(t) { + ie.self(this, ne, t.selector || null, t.element || 'div'), (this.state = { theme: t.theme }) } - function Bi(t) { + function Pi(t) { if ('string' != typeof t.src && !(t.src instanceof HTMLElement)) { throw new TypeError('Graphic src must be string or HTMLElement. Passed src: ' + t.src) } - Jt.self(this, Yt, t.selector || '.graphic'), + ie.self(this, ne, t.selector || '.graphic'), (this.state = { loaded: !1 }), (this.config = { src: t.src, @@ -6968,26 +7066,26 @@ (this.image = null), (t.autoLoad || t.autoLoad === undefined) && this.load() } - function Hi(t, e) { + function Ii(t, e) { var i = t.nodeName if ('svg' === i || 'g' === i || 'clipPath' === i) { var n = t && (t.children || t.childNodes) if (!n) return - for (var o = 0; o < n.length; o++) Hi(n[o], e) + for (var o = 0; o < n.length; o++) Ii(n[o], e) } else if ( t && t.style && ('path' === i || 'rect' === i || 'circle' === i || 'polygon' === i) ) { - var s = !!t.getAttribute('stroke'), - r = !!t.getAttribute('fill') - s && (t.style.stroke = e), r && (t.style.fill = e), r || s || (t.style.fill = e) + var r = !!t.getAttribute('stroke'), + s = !!t.getAttribute('fill') + r && (t.style.stroke = e), s && (t.style.fill = e), s || r || (t.style.fill = e) } } - function Oi(t) { + function Vi(t) { var e = t.palette, i = t.component - return Ci.merge( + return Bi.merge( { main: { fill: e.common.white, icon: e.grey[700], text: e.text.main }, hover: { fill: e.grey[200], icon: e.primary.main, text: e.text.main }, @@ -6997,8 +7095,8 @@ i.button, ) } - function Ti(t) { - Jt.self(this, Yt, t.selector), + function Di(t) { + ie.self(this, ne, t.selector), (this._theme = t.theme), (this.state = { selectable: !1 !== t.selectable, @@ -7013,7 +7111,7 @@ height: t.height, closedAt: Date.now(), downAt: 0, - style: Oi(this._theme.get()), + style: Vi(this._theme.get()), }), this.addClass('button'), this.setAttribute('tabindex', 0), @@ -7032,13 +7130,13 @@ (this.addEventListener('over', this.onHover), this.addEventListener('out', this.onHover)), this.setCopy() } - _i.add('contrast', { + Ti.add('contrast', { component: { prompt: { main: { fill: '#fff', text: '#000' } }, expandButton: { main: { fill: '#000' } }, }, }), - _i.add('grey-red', { + Ti.add('grey-red', { component: { breadcrumb: { active: { fill: '#FF0000' } }, prompt: { main: { fill: '#6a6a6a' } }, @@ -7048,11 +7146,11 @@ skipButton: { main: { fill: '#6a6a6a' }, hover: { fill: '#6a6a6a' } }, }, }), - Jt.proto(Si, Yt), - (Si.prototype.style = function (t) { + ie.proto(Hi, ne), + (Hi.prototype.style = function (t) { var e = t.fontSize || 12, i = t.color || 'inherit', - n = Ei(this.config.theme.get()) + n = Oi(this.config.theme.get()) this.css({ color: i, fontWeight: 500, @@ -7064,39 +7162,39 @@ lineHeight: e, }) }), - (Si.prototype.translate = function () { - var t = se.translate(this.config.text) + (Hi.prototype.translate = function () { + var t = ue.translate(this.config.text) this.content(t) }), - (Si.prototype.onHover = function (t) { + (Hi.prototype.onHover = function (t) { var e = 'over' === t.action this.css({ textDecoration: e || this.config.underline ? 'underline' : 'none' }) }), - (Si.prototype.onSelect = function (t) { + (Hi.prototype.onSelect = function (t) { this.emit('click', t) }), - (Si.prototype.onFocus = function (t) { - var e = Ei(this.config.theme.get()).focus.outline + (Hi.prototype.onFocus = function (t) { + var e = Oi(this.config.theme.get()).focus.outline this.css({ outline: '2px solid ' + e }) }), - (Si.prototype.onBlur = function (t) { + (Hi.prototype.onBlur = function (t) { this.css({ outline: 'none' }) }), - Jt.proto(Ai, Yt), - (Ai.prototype.style = function (t) { + ie.proto(Mi, ne), + (Mi.prototype.style = function (t) { var e = t.fontSize || 12, i = t.color || '#000' this.css({ color: i, fontWeight: this.config.bold ? 700 : 500, fontSize: e, lineHeight: e }) }), - (Ai.prototype.translate = function () { - var t = se.translate(this.config.text) + (Mi.prototype.translate = function () { + var t = ue.translate(this.config.text) this.text(t) }), - Jt.proto(Li, Yt), - (Li.prototype.style = function (t) { + ie.proto(Ri, ne), + (Ri.prototype.style = function (t) { for (var e = this.children.length; --e > -1; ) this.children[e].style(t) }), - (Li.prototype.parseText = function (t) { + (Ri.prototype.parseText = function (t) { var e, i, n = [ @@ -7111,19 +7209,19 @@ return t.index - e.index })), this.removeAllComponents() - var s = 0 + var r = 0 for (e = 0; e < o.length; e++) { switch ( ((i = o[e]), - this.initComponent(Ai, { text: t.substring(s, i.index) }), - (s = i.index + i[0].length), + this.initComponent(Mi, { text: t.substring(r, i.index) }), + (r = i.index + i[0].length), i.type) ) { case 'BOLD': - this.initComponent(Ai, { text: i[1], bold: !0 }) + this.initComponent(Mi, { text: i[1], bold: !0 }) break case 'LINK': - this.initComponent(Si, { + this.initComponent(Hi, { text: i[1], url: i[2], underline: !0, @@ -7132,25 +7230,24 @@ }) } } - s < t.length && this.initComponent(Ai, { text: t.substring(s) }), + r < t.length && this.initComponent(Mi, { text: t.substring(r) }), this.style({ fontSize: 'inherit', color: 'inherit' }) }), - Jt.proto(Bi, Yt), - (Bi.prototype.load = function () { + ie.proto(Pi, ne), + (Pi.prototype.load = function () { if (this.state.loaded) return Promise.resolve() this.state.loaded = !0 var t = this, e = this.config.src - return _e - .image(e, { fallback: this.config.fallback }) + return Be.image(e, { fallback: this.config.fallback }) .then(function (e) { ;(t.image = e), t.appendElement(e.element), t.size(), t.fill() }) ['catch'](function () { - Ct('graphic failed to load', 'image', 'info', { src: e }) + St('graphic failed to load', 'image', 'info', { src: e }) }) }), - (Bi.prototype.size = function (t, e) { + (Pi.prototype.size = function (t, e) { ;(this.config.width = t || this.config.width), (this.config.height = e || t || this.config.height), this.css({ width: this.config.width, height: this.config.height }), @@ -7161,15 +7258,15 @@ display: 'block', }) }), - (Bi.prototype.fill = function (t) { + (Pi.prototype.fill = function (t) { ;((this.config.fill = t || this.config.fill), this.image && 'svg' === this.image.ext && this.config.fill) && - Hi(this.image.element.dom, this.config.fill) + Ii(this.image.element.dom, this.config.fill) }), - Jt.proto(Ti, Yt), - (Ti.prototype.style = function (t) { + ie.proto(Di, ne), + (Di.prototype.style = function (t) { ;(this.state.mobile = t), - (this.state.style = Oi(this._theme.get())), + (this.state.style = Vi(this._theme.get())), this.css({ width: this.state.width, height: this.state.height, @@ -7183,14 +7280,14 @@ }), this.emit('style') }), - (Ti.prototype.getWidth = function () { + (Di.prototype.getWidth = function () { return this.state.width }), - (Ti.prototype.getHeight = function () { + (Di.prototype.getHeight = function () { return this.state.height }), - (Ti.prototype._updateStyle = function (t) { - this.state.style = Oi(this._theme.get()) + (Di.prototype._updateStyle = function (t) { + this.state.style = Vi(this._theme.get()) var e = t ? 'hover' : 'main' this.css({ backgroundColor: this.state.style[e].fill, @@ -7199,59 +7296,59 @@ }), this.emit('style-update', t) }), - (Ti.prototype.onDown = function () { + (Di.prototype.onDown = function () { this.state.downAt = Date.now() }), - (Ti.prototype.onHover = function (t) { + (Di.prototype.onHover = function (t) { null === this.emit || !0 === this.state.locked || this.state.selected || (this.emit('hover', t), this._updateStyle('over' === t.action)) }), - (Ti.prototype.onSelect = function (t) { + (Di.prototype.onSelect = function (t) { this.emit && !0 !== this.state.locked && (Math.abs(this.state.downAt - this.state.closedAt) < 30 || (this._setState(!!this.state.selectable && !this.state.selected), this.emit('click', { selected: this.state.selected, usingKb: 'enter' === t.action }))) }), - (Ti.prototype.onFocus = function (t) { + (Di.prototype.onFocus = function (t) { var e = this.state.style.focus.outline this.css({ outline: '2px solid ' + e }) }), - (Ti.prototype.onBlur = function (t) { + (Di.prototype.onBlur = function (t) { this.css({ outline: 'none' }) }), - (Ti.prototype.setLock = function (t) { + (Di.prototype.setLock = function (t) { ;(this.state.locked = t), this.css({ cursor: t ? 'default' : 'pointer' }) }), - (Ti.prototype.enable = function (t) { + (Di.prototype.enable = function (t) { ;(this.state.visible = t), this.css({ display: t ? 'inline-block' : 'none' }), this.setLock.call(this, !t) }), - (Ti.prototype.reset = function () { + (Di.prototype.reset = function () { this._setState(!1) }), - (Ti.prototype._setState = function (t) { - ;(this.state.style = Oi(this._theme.get())), + (Di.prototype._setState = function (t) { + ;(this.state.style = Vi(this._theme.get())), (this.state.selected = t), this.css({ backgroundColor: this.state.style.main.fill }), t ? this._updateStyle(!0) : (this.state.closedAt = Date.now()), this.emit('state-changed', t) }), - (Ti.prototype.setLabel = function (t) { + (Di.prototype.setLabel = function (t) { t && (this.state.label = t), - this.state.label && this.setAttribute('aria-label', se.translate(this.state.label)) + this.state.label && this.setAttribute('aria-label', ue.translate(this.state.label)) }), - (Ti.prototype.setTitle = function (t) { + (Di.prototype.setTitle = function (t) { t && (this.state.title = t), - this.state.title && this.setAttribute('title', se.translate(this.state.title)) + this.state.title && this.setAttribute('title', ue.translate(this.state.title)) }), - (Ti.prototype.setCopy = function () { + (Di.prototype.setCopy = function () { this.setLabel(), this.setTitle() }), - (Ti.prototype.controlsMenu = function (t) { + (Di.prototype.controlsMenu = function (t) { this.setAttribute('aria-expanded', !1), this.setAttribute('aria-haspopup', 'menu'), this.setAttribute('aria-controls', t.dom.id), @@ -7262,7 +7359,7 @@ this.setAttribute('aria-expanded', t) }) }), - (Ti.prototype.ownsListBox = function (t) { + (Di.prototype.ownsListBox = function (t) { this.setAttribute('aria-expanded', !1), this.setAttribute('aria-haspopup', 'listbox'), this.setAttribute('aria-owns', t.dom.id), @@ -7272,48 +7369,48 @@ this.setAttribute('aria-expanded', t) }) }), - (Ti.prototype.getValue = function () { + (Di.prototype.getValue = function () { return this.state.value }) - var Mi = 'https://newassets.hcaptcha.com/captcha/v1/1bcdbdd/static/images' - function Vi(t) { + var Fi = 'https://newassets.hcaptcha.com/captcha/v1/a8cd801/static/images' + function $i(t) { ;(t.selector = t.selector || t.name), - Jt.self(this, Ti, t), - (this.$on = this.initComponent(Bi, { + ie.self(this, Di, t), + (this.$on = this.initComponent(Pi, { selector: '.' + t.name + '-on', src: t.src, - fallback: Mi + '/' + t.name + '-on.png', + fallback: Fi + '/' + t.name + '-on.png', autoLoad: !1, })), - (this.$off = this.initComponent(Bi, { + (this.$off = this.initComponent(Pi, { selector: '.' + t.name + '-off', src: t.src, - fallback: Mi + '/' + t.name + '-off.png', + fallback: Fi + '/' + t.name + '-off.png', autoLoad: !1, })), this.on('state-changed', this._onStateChange.bind(this)), this.on('style', this._onStyle.bind(this)), this.on('style-update', this._onStyleUpdate.bind(this)) } - function Ri(t) { - Jt.self(this, Ti, t), + function Ui(t) { + ie.self(this, Di, t), (this.state.text = t.text), (this.$text = this.createElement('.text')), this.on('style', this._onStyle.bind(this)), this.setText() } - function Fi(t) { - Jt.self(this, Ti, t), + function ji(t) { + ie.self(this, Di, t), (this.state.text = t.text), (this.state.type = t.type || 'confirm'), (this.$text = this.createElement('.text')), this.on('style', this._onStyle.bind(this)), this.setText() } - function Pi(t) { + function Ni(t) { var e = t.palette, i = t.component - return Ci.merge( + return Bi.merge( { main: { fill: e.grey[200], border: e.grey[600] }, selected: { check: e.primary.main }, @@ -7322,8 +7419,8 @@ i.radio, ) } - function Di(t) { - Jt.self(this, Yt, 'radio-button'), + function zi(t) { + ie.self(this, ne, 'radio-button'), (this.state = { theme: t.theme, locked: !1, selected: !1, text: t.text, value: t.value }), (this.$wrapper = this.createElement('.wrapper')), (this.$radio = this.$wrapper.createElement('.radio')), @@ -7344,11 +7441,11 @@ this.$radio.addEventListener('focus', this.onFocus), this.$radio.addEventListener('blur', this.onBlur) } - function Ii(t) { + function Zi(t) { var e = t.palette, i = t.component, n = 'light' === e.mode - return Ci.merge( + return Bi.merge( { main: { fill: e.grey[100], border: e.grey[n ? 600 : 200] }, focus: { fill: e.grey[200], outline: e.grey[n ? 800 : 100] }, @@ -7357,8 +7454,8 @@ i.textarea, ) } - function $i(t) { - Jt.self(this, Yt, 'input-textarea') + function Wi(t) { + ie.self(this, ne, 'input-textarea') var e = this ;(this.state = { visible: !1, placeholder: t.placeholder, theme: t.theme }), (this.$textarea = this.createElement('textarea', '.textarea')), @@ -7367,8 +7464,8 @@ e.emit('change', t.target.value) }) } - function ji(t) { - Jt.self(this, Yt, t.selector || 'list-native', 'select') + function qi(t) { + ie.self(this, ne, t.selector || 'list-native', 'select') var e = this ;(this._options = []), (this._selected = null), @@ -7377,11 +7474,11 @@ e.dom.value && e.select(e.dom.value) }) } - Jt.proto(Vi, Ti), - (Vi.prototype.load = function () { + ie.proto($i, Di), + ($i.prototype.load = function () { return Promise.all([this.$on.load(), this.$off.load()]) }), - (Vi.prototype._onStyle = function () { + ($i.prototype._onStyle = function () { var t = this.getWidth(), e = t - 10, i = (t - e) / 2 @@ -7392,23 +7489,23 @@ this.$off.fill(this.state.style.main.icon), this.$off.css({ '-ms-high-contrast-adjust': 'none', position: 'absolute', top: i, left: i }) }), - (Vi.prototype._onStyleUpdate = function (t) { + ($i.prototype._onStyleUpdate = function (t) { 'ie' === tt.Browser.type && 8 === tt.Browser.version ? (this.$on.css({ display: t ? 'block' : 'none' }), this.$off.css({ display: t ? 'none' : 'block' })) : (this.$on.css({ opacity: t ? 1 : 0 }), this.$off.css({ opacity: t ? 0 : 1 })) }), - (Vi.prototype._onStateChange = function (t) { + ($i.prototype._onStateChange = function (t) { 'ie' === tt.Browser.type && 8 === tt.Browser.version ? (this.$on.css({ display: t ? 'block' : 'none' }), this.$off.css({ display: t ? 'none' : 'block' })) : (this.$on.css({ opacity: t ? 1 : 0 }), this.$off.css({ opacity: t ? 0 : 1 })) }), - Jt.proto(Ri, Ti), - (Ri.prototype.setText = function (t) { + ie.proto(Ui, Di), + (Ui.prototype.setText = function (t) { this.$text.text(t || this.state.text || this.state.title) }), - (Ri.prototype._onStyle = function () { + (Ui.prototype._onStyle = function () { this.css({ cursor: 'pointer' }), this.$text.css({ width: '100%', @@ -7420,13 +7517,13 @@ position: 'absolute', }) }), - Jt.proto(Fi, Ti), - (Fi.prototype.setText = function (t) { + ie.proto(ji, Di), + (ji.prototype.setText = function (t) { t && (this.state.text = t), - this.$text.text(se.translate(this.state.text || this.state.title)), + this.$text.text(ue.translate(this.state.text || this.state.title)), this.setCopy() }), - (Fi.prototype._onStyle = function () { + (ji.prototype._onStyle = function () { var t = this._theme.get().palette, e = 'light' === t.mode, i = 'warn' === this.state.type ? t.warn.main : t.primary.main @@ -7448,7 +7545,7 @@ display: 'inline-block', }) }), - (Fi.prototype.lock = function (t) { + (ji.prototype.lock = function (t) { var e = this._theme.get().palette, i = 'warn' === this.state.type ? e.warn.main : e.primary.main, n = 'light' === e.mode @@ -7457,15 +7554,15 @@ this.$text.css({ color: t ? (n ? e.text.body : e.grey[700]) : i }), t ? this.setAttribute('aria-disabled', t) : this.removeAttribute('aria-disabled') }), - Jt.proto(Di, Yt), - (Di.prototype.style = function (t) { - var e = Mt(t, 125, 150, 13, 14), + ie.proto(zi, ne), + (zi.prototype.style = function (t) { + var e = Dt(t, 125, 150, 13, 14), i = 15, n = t - 27, o = this.state.theme, - s = Pi(o.get()), - r = o.get().palette, - a = 'light' === r.mode + r = Ni(o.get()), + s = o.get().palette, + a = 'light' === s.mode this.css({ height: 'auto', marginTop: 5, marginBottom: 5, position: 'relative' }), this.$wrapper.css({ cursor: 'pointer', @@ -7481,7 +7578,7 @@ height: i, borderRadius: 2, overflow: 'hidden', - border: '1px solid ' + s.main.border, + border: '1px solid ' + r.main.border, float: 'left', }), this.$radio.check.css({ @@ -7492,7 +7589,7 @@ width: 11, height: 11, borderRadius: 1, - backgroundColor: s.selected.check, + backgroundColor: r.selected.check, }), this.$radio.bg.css({ position: 'absolute', @@ -7501,7 +7598,7 @@ zIndex: 0, width: i, height: i, - backgroundColor: s.main.fill, + backgroundColor: r.main.fill, }), this.$text.css({ position: 'relative', @@ -7509,48 +7606,48 @@ width: n, fontSize: e, fontWeight: 400, - color: a ? r.text.body : r.grey[700], + color: a ? s.text.body : s.grey[700], float: 'right', marginLeft: 10, marginTop: 1, wordBreak: 'break-word', }) }), - (Di.prototype.toggle = function (t) { + (zi.prototype.toggle = function (t) { this.state.locked || ((this.state.selected = t), this.$radio.check.css({ opacity: t ? 1 : 0 }), this.$radio.setAttribute('aria-pressed', t)) }), - (Di.prototype.lock = function (t) { + (zi.prototype.lock = function (t) { this.state.locked = t }), - (Di.prototype.setCopy = function () { - var t = se.translate(this.state.text) + (zi.prototype.setCopy = function () { + var t = ue.translate(this.state.text) this.$text.text(t) }), - (Di.prototype.onSelect = function (t) { + (zi.prototype.onSelect = function (t) { this.emit('select', this) }), - (Di.prototype.onFocus = function (t) { - var e = Pi(this.state.theme.get()).focus.outline + (zi.prototype.onFocus = function (t) { + var e = Ni(this.state.theme.get()).focus.outline this.$radio.css({ outline: '2px solid ' + e }) }), - (Di.prototype.onBlur = function (t) { + (zi.prototype.onBlur = function (t) { this.$radio.css({ outline: 'none' }) }), - Jt.proto($i, Yt), - ($i.prototype.style = function (t, e) { + ie.proto(Wi, ne), + (Wi.prototype.style = function (t, e) { var i = this.state.theme, - n = Ii(i.get()), + n = Zi(i.get()), o = i.get().palette, - s = 'light' === o.mode + r = 'light' === o.mode this.$textarea.css({ width: t - 30, height: 50, borderRadius: 4, backgroundColor: n.main.fill, - color: s ? o.text.body : o.grey[700], + color: r ? o.text.body : o.grey[700], border: '1px solid ' + n.main.border, fontSize: e ? 12 : 14, lineHeight: e ? 16 : 18, @@ -7565,35 +7662,35 @@ this.css({ height: 50, width: t, position: 'relative' }), this.visible(this.state.visible) }), - ($i.prototype.visible = function (t) { + (Wi.prototype.visible = function (t) { ;(this.state.visible = t), this.css({ display: t ? 'block' : 'none' }) }), - ($i.prototype.disable = function (t) { + (Wi.prototype.disable = function (t) { if (this.state.visible) { - var e = Ii(this.state.theme.get()) + var e = Zi(this.state.theme.get()) ;(this.$textarea.dom.disabled = !t), this.$textarea.css({ backgroundColor: t ? e.main.fill : e.disabled.fill }) } }), - ($i.prototype.getValue = function () { + (Wi.prototype.getValue = function () { return this.$textarea.dom.value }), - ($i.prototype.setValue = function (t) { + (Wi.prototype.setValue = function (t) { this.$textarea.dom.value = t }), - ($i.prototype.setPlaceholder = function () { - this.$textarea.setAttribute('placeholder', se.translate(this.state.placeholder)) + (Wi.prototype.setPlaceholder = function () { + this.$textarea.setAttribute('placeholder', ue.translate(this.state.placeholder)) }), - Jt.proto(ji, Yt), - (ji.prototype.getSelected = function () { + ie.proto(qi, ne), + (qi.prototype.getSelected = function () { return this._selected }), - (ji.prototype.setCopy = function () { + (qi.prototype.setCopy = function () { for (var t = this._options.length; t--; ) { - this._options[t].element.text(se.translate(this._options[t].text)) + this._options[t].element.text(ue.translate(this._options[t].text)) } }), - (ji.prototype.setOptions = function (t) { + (qi.prototype.setOptions = function (t) { for (var e, i = this._options.length; i--; ) this.removeElement(this._options[i].element) for (this._options = t, i = 0; i < t.length; i++) { ;((e = this.createElement('option', t[i].selector || '.option')).dom.value = t[i].value), @@ -7601,7 +7698,7 @@ (this._options[i].element = e) } }), - (ji.prototype.select = function (t) { + (qi.prototype.select = function (t) { for (var e = null, i = this._options.length; i--; ) { t === this._options[i].value && (e = this._options[i]) } @@ -7613,12 +7710,12 @@ this.emit('hide'), this.emit('select', e) }), - (ji.prototype.deselect = function () { + (qi.prototype.deselect = function () { this._selected && this._selected.element.removeAttribute('selected'), (this._selected = null), (this.dom.value = null) }), - (ji.prototype.style = function () { + (qi.prototype.style = function () { this.css({ width: '100%', height: '100%', @@ -7629,15 +7726,15 @@ zIndex: 50, }) }) - var Ni = 37, - zi = 39, - Zi = 38, - Ui = 40, - Wi = ('onwheel' in document || document, document, 'ontouchstart' in document), - Ki = navigator.maxTouchPoints && navigator.maxTouchPoints > 1, - qi = !!window.navigator.msPointerEnabled, - Gi = 'onkeydown' in document - function Ji(t) { + var Ki = 37, + Yi = 39, + Gi = 38, + Ji = 40, + Xi = ('onwheel' in document || document, document, 'ontouchstart' in document), + Qi = navigator.maxTouchPoints && navigator.maxTouchPoints > 1, + tn = !!window.navigator.msPointerEnabled, + en = 'onkeydown' in document + function nn(t) { ;(this.state = { pause: !1, action: null, @@ -7653,7 +7750,7 @@ mouseMult: t.mouseMult || 1, }) var e = t.element || document.body - e instanceof Gt || ((e = new Gt(e)), (this.state.created = !0)), + e instanceof ee || ((e = new ee(e)), (this.state.created = !0)), (this.element = e), (this.msBodyTouch = null), (this.clamp = { enabled: !1, min: { x: 0, y: 0 }, max: { x: 0, y: 0 } }), @@ -7663,21 +7760,21 @@ (this.destroy = this.destroy.bind(this)), this._addListeners() } - function Yi() { - Jt.self(this, Yt, 'scroll-container') + function on() { + ie.self(this, ne, 'scroll-container') } - function Xi(t) { - Jt.self(this, Yt, t.selector || 'list-custom'), + function rn(t) { + ie.self(this, ne, t.selector || 'list-custom'), (this.state = { skipAnimationOnce: !1 }), - (this.scroll = new Ji({ element: this, arrowScrolling: !1, mouseMult: 0.5, keyStep: 46 })), - (this._container = this.initComponent(Yi)), + (this.scroll = new nn({ element: this, arrowScrolling: !1, mouseMult: 0.5, keyStep: 46 })), + (this._container = this.initComponent(on)), (this._handle = this.createElement('div')), this.on('scroll-update', this._onScrollUpdate.bind(this)) } - function Qi(t) { + function sn(t) { var e = t.palette, i = t.component - return Ci.merge( + return Bi.merge( { main: { fill: e.common.transparent, line: e.grey[200], text: e.grey[700] }, hover: { fill: e.grey[200], text: e.grey[900], border: e.primary.main + 'b3' }, @@ -7686,11 +7783,11 @@ i.listItem, ) } - function tn(t) { - Jt.self(this, Yt, t.option.selector || '.option') + function an(t) { + ie.self(this, ne, t.option.selector || '.option') var e = this ;(this.state = { - style: Qi(t.theme.get()), + style: sn(t.theme.get()), selected: !1, usingKb: !1, isLast: !1, @@ -7719,8 +7816,8 @@ this.setAttribute('role', this.state.isMenu ? 'menuitem' : 'option'), this.setCopy() } - function en(t) { - Jt.self(this, Xi, { selector: t.selector || 'list-custom' }), + function cn(t) { + ie.self(this, rn, { selector: t.selector || 'list-custom' }), (this.state = { theme: t.theme, isMenu: t.isMenu, @@ -7741,9 +7838,10 @@ this.setAttribute('role', this.state.isMenu ? 'presentation' : 'listbox'), this.addEventListener('keydown', this.onKeyPress.bind(this)) } - function nn(t) { - Jt.self(this, Yt, (t = t || {}).selector || '.box-container'), + function ln(t) { + ie.self(this, ne, (t = t || {}).selector || '.box-container'), (this._theme = t.theme), + (this._tabbable = 'boolean' != typeof t.tabbable || t.tabbable), (this.boxState = { ariaLabel: t.ariaLabel, visible: !0, @@ -7765,8 +7863,8 @@ this.setAriaLabel(), this.setVisible(!0) } - function on(t) { - Jt.self(this, Yt, t.selector || '.border'), + function hn(t) { + ie.self(this, ne, t.selector || '.border'), (this.state = { visible: t.visible === undefined || t.visible, thickness: t.thickness || 1, @@ -7778,13 +7876,13 @@ (this.$left = this.createElement('div')), (this.$bottom = this.createElement('div')) } - function sn(t) { + function un(t) { var e = t.palette, i = t.component - return Ci.merge({ focus: { outline: e.primary.main } }, i.link) + return Bi.merge({ focus: { outline: e.primary.main } }, i.link) } - function rn(t) { - Jt.self(this, Yt, 'logo', 'a'), + function fn(t) { + ie.self(this, ne, 'logo', 'a'), (this.state = { theme: t.theme, url: t.url || '', @@ -7793,9 +7891,10 @@ }), this.setAttribute('tabindex', 0), this.setAttribute('target', '_blank'), - this.setAttribute('href', this.state.url) + this.setAttribute('href', this.state.url), + this.setAttribute('role', 'button') var e = { selector: '.logo-graphic', src: t.src, fallback: t.fallback, autoLoad: t.autoLoad } - ;(this.graphic = this.initComponent(Bi, e)), + ;(this.graphic = this.initComponent(Pi, e)), this.graphic.css({ cursor: 'pointer', '-ms-high-contrast-adjust': 'none' }), (this.onSelect = this.onSelect.bind(this)), (this.onFocus = this.onFocus.bind(this)), @@ -7805,17 +7904,17 @@ this.addEventListener('focus', this.onFocus), this.addEventListener('blur', this.onBlur) } - function an(t) { + function dn(t) { var e = t.palette, i = t.component - return Ci.merge({ main: { fill: e.primary.main, icon: e.common.white } }, i.badge) + return Bi.merge({ main: { fill: e.primary.main, icon: e.common.white } }, i.badge) } - function ln(t) { + function pn(t) { if ( - (Jt.self(this, Yt, t.selector || '.badge'), + (ie.self(this, ne, t.selector || '.badge'), t || (t = {}), (this._theme = t.theme), - (this._style = an(this._theme.get())), + (this._style = dn(this._theme.get())), (this._timer = null), (this.state = { loaded: !1, visible: !1 }), (this.config = { icon: t.icon, value: t.value, size: t.size || 0 }), @@ -7826,7 +7925,7 @@ 'object' == typeof t.icon && ((i = t.icon.src), (e = t.icon.fallback)), (this.$wrapper = this.createElement('.badge-icon-wrapper')), (this.icon = this.initComponent( - Bi, + Pi, { selector: '.icon', src: i, fallback: e }, this.$wrapper, )) @@ -7834,10 +7933,10 @@ ;(this.$fill = this.createElement('.badge-fill')), (this.$radial = this.createElement('.badge-radial')) } - ;(Ji.prototype.pause = function (t) { + ;(nn.prototype.pause = function (t) { this.state.pause = t }), - (Ji.prototype.update = function (t) { + (nn.prototype.update = function (t) { if (!this.state.pause) { var e = this.state.position, i = this.state.delta, @@ -7845,47 +7944,47 @@ ;(e.x += i.x), (e.y += i.y), this.clamp.enabled - ? ((e.x = Tt(e.x, this.clamp.min.x, this.clamp.max.x)), - (e.y = Tt(e.y, this.clamp.min.y, this.clamp.max.y))) + ? ((e.x = Vt(e.x, this.clamp.min.x, this.clamp.max.x)), + (e.y = Vt(e.y, this.clamp.min.y, this.clamp.max.y))) : console.log(e.y, this.element.dom.scrollHeight), this.element.emit('scroll-update', { x: e.x, y: e.y, delta: i, action: n, original: t }) } }), - (Ji.prototype._addListeners = function () { + (nn.prototype._addListeners = function () { var t = { passive: !1 } ;('ie' !== tt.Browser.type || ('ie' === tt.Browser.type && 8 !== tt.Browser.version)) && (this.element.addEventListener('DOMMouseScroll', this.onWheel), this.element.addEventListener('wheel', this.onWheel, t)), this.element.addEventListener('mousewheel', this.onWheel, t), - Wi && + Xi && (this.element.addEventListener('touchstart', this.onTouch), this.element.addEventListener('touchmove', this.onTouch)), - qi && - Ki && + tn && + Qi && ((this.msBodyTouch = document.body.style.msTouchAction), (document.body.style.msTouchAction = 'none'), this.element.addEventListener('MSPointerDown', this.onTouch, !0), this.element.addEventListener('MSPointerMove', this.onTouch, !0)), - this.config.arrowScrolling && Gi && this.element.addEventListener('keydown', this.onKey) + this.config.arrowScrolling && en && this.element.addEventListener('keydown', this.onKey) }), - (Ji.prototype._removeListeners = function () { + (nn.prototype._removeListeners = function () { var t = { passive: !1 } ;('ie' !== tt.Browser.type || ('ie' === tt.Browser.type && 8 !== tt.Browser.version)) && (this.element.removeEventListener('DOMMouseScroll', this.onWheel), this.element.removeEventListener('wheel', this.onWheel, t)), this.element.removeEventListener('mousewheel', this.onWheel, t), - Wi && + Xi && (this.element.removeEventListener('touchstart', this.onTouch), this.element.removeEventListener('touchmove', this.onTouch)), - qi && - Ki && + tn && + Qi && ((this.msBodyTouch = document.body.style.msTouchAction), (document.body.style.msTouchAction = 'none'), this.element.removeEventListener('MSPointerDown', this.onTouch, !0), this.element.removeEventListener('MSPointerMove', this.onTouch, !0)), - this.config.arrowScrolling && Gi && this.element.removeEventListener('keydown', this.onKey) + this.config.arrowScrolling && en && this.element.removeEventListener('keydown', this.onKey) }), - (Ji.prototype.onWheel = function (t) { + (nn.prototype.onWheel = function (t) { if (!this.state.pause) { ;(t = window.event || t).preventDefault && t.preventDefault() var e = this.state.delta, @@ -7903,7 +8002,7 @@ this.update.call(this, t) } }), - (Ji.prototype.onTouch = function (t) { + (nn.prototype.onTouch = function (t) { if (!this.state.pause) { var e = this.state.position, i = this.state.delta, @@ -7916,21 +8015,21 @@ this.update.call(this, t) } }), - (Ji.prototype.onKey = function (t) { + (nn.prototype.onKey = function (t) { if (!this.state.pause && !t.metaKey) { var e = this.state.delta, i = this.config.keyStep switch (t.keyCode) { - case Ui: + case Ji: t.preventDefault && t.preventDefault(), (e.x = 0), (e.y = -i) break - case Zi: + case Gi: t.preventDefault && t.preventDefault(), (e.x = 0), (e.y = i) break - case Ni: + case Ki: ;(e.x = -i), (e.y = 0) break - case zi: + case Yi: ;(e.x = i), (e.y = 0) break default: @@ -7939,36 +8038,36 @@ ;(this.state.action = 'keypress'), this.update.call(this, t) } }), - (Ji.prototype.clampX = function (t, e, i) { + (nn.prototype.clampX = function (t, e, i) { ;(this.clamp.enabled = t), (this.clamp.min.x = e || 0), (this.clamp.max.x = i || 0) }), - (Ji.prototype.clampY = function (t, e, i) { + (nn.prototype.clampY = function (t, e, i) { ;(this.clamp.enabled = t), (this.clamp.min.y = e || 0), (this.clamp.max.y = i || 0) }), - (Ji.prototype.reset = function () { + (nn.prototype.reset = function () { ;(this.state.position = { x: 0, y: 0 }), (this.state.delta = { x: 0, y: 0 }) }), - (Ji.prototype.setPosX = function (t) { + (nn.prototype.setPosX = function (t) { this.setPos(t, this.state.position.y) }), - (Ji.prototype.setPosY = function (t) { + (nn.prototype.setPosY = function (t) { this.setPos(this.state.position.x, t) }), - (Ji.prototype.moveYBy = function (t) { + (nn.prototype.moveYBy = function (t) { this.setPos(this.state.position.x, this.state.position.y + t) }), - (Ji.prototype.getY = function () { + (nn.prototype.getY = function () { return this.state.position.y }), - (Ji.prototype.setPos = function (t, e) { + (nn.prototype.setPos = function (t, e) { this.clamp.enabled && - ((t = Tt(t, this.clamp.min.x, this.clamp.max.x)), - (e = Tt(e, this.clamp.min.y, this.clamp.max.y))), + ((t = Vt(t, this.clamp.min.x, this.clamp.max.x)), + (e = Vt(e, this.clamp.min.y, this.clamp.max.y))), (this.state.position = { x: t, y: e }), (this.state.delta = { x: 0, y: 0 }), this.element.emit('scroll-update', { x: t, y: e, delta: this.state.delta, action: null }) }), - (Ji.prototype.destroy = function () { + (nn.prototype.destroy = function () { var t = this.state.created this._removeListeners(), (this.state = { @@ -7980,32 +8079,32 @@ }), t && (this.element = this.element.destroy()) }), - Jt.proto(Yi, Yt), - Jt.proto(Xi, Yt), - (Xi.prototype.getContainer = function () { + ie.proto(on, ne), + ie.proto(rn, ne), + (rn.prototype.getContainer = function () { return this._container }), - (Xi.prototype.scrollInView = function (t, e, i) { + (rn.prototype.scrollInView = function (t, e, i) { ;(this.dom.scrollTop = 0), (this.state.skipAnimationOnce = i) var n = -t.offsetTop, o = t.offsetHeight, - s = this.dom.clientHeight, - r = this._container.dom.scrollHeight, + r = this.dom.clientHeight, + s = this._container.dom.scrollHeight, a = this.scroll.getY(), - l = a - s - this._handle.css({ display: r <= s ? 'none' : 'block' }), - this.scroll.clampY(!0, s - r, 0), + c = a - r + this._handle.css({ display: s <= r ? 'none' : 'block' }), + this.scroll.clampY(!0, r - s, 0), e - ? this.scroll.setPosY(n + s / 2 - o / 2) + ? this.scroll.setPosY(n + r / 2 - o / 2) : n > a ? this.scroll.setPosY(n) - : n - o < l && this.scroll.setPosY(n + s - o) + : n - o < c && this.scroll.setPosY(n + r - o) }), - (Xi.prototype._onScrollUpdate = function (t) { + (rn.prototype._onScrollUpdate = function (t) { var e = t.y, i = this._handle.dom.offsetHeight, n = this.dom.clientHeight, - o = (Mt(e, 0, n - this._container.dom.scrollHeight, 0, 1) || 0) * (n - i - 4) + o = (Dt(e, 0, n - this._container.dom.scrollHeight, 0, 1) || 0) * (n - i - 4) 'ie' === tt.Browser.type && 8 === tt.Browser.version ? (this._container.css({ top: e }), this._handle.css({ top: o })) : (this._container.css({ @@ -8018,7 +8117,7 @@ }), (this.state.skipAnimationOnce = !1)) }), - (Xi.prototype.baseStyle = function () { + (rn.prototype.baseStyle = function () { this._container.css({ width: '100%', position: 'absolute', overflowY: 'hidden' }), this._handle.css({ position: 'absolute', @@ -8031,36 +8130,36 @@ backgroundColor: '#6E829E', }) }), - (Xi.prototype.onDestroy = function () { + (rn.prototype.onDestroy = function () { this.scroll.destroy && this.scroll.destroy() }), - Jt.proto(tn, Yt), - (tn.prototype.usingKb = function (t) { + ie.proto(an, ne), + (an.prototype.usingKb = function (t) { this.state.usingKb = t }), - (tn.prototype.select = function () { + (an.prototype.select = function () { ;(this.state.selected = !0), this.setAttribute('aria-selected', this.state.selected), this.updateStyle(this.state.usingKb), this.emit('select', this) }), - (tn.prototype.deselect = function () { + (an.prototype.deselect = function () { ;(this.state.selected = !1), this.dom && (this.setAttribute('aria-selected', this.state.selected), this.updateStyle()) }), - (tn.prototype.focus = function () { + (an.prototype.focus = function () { this.dom && (this.dom.focus(), this.emit('focus')) }), - (tn.prototype.getOptionData = function () { + (an.prototype.getOptionData = function () { return this.state.option }), - (tn.prototype.setCopy = function () { - this._text.text(se.translate(this.state.option.text)) + (an.prototype.setCopy = function () { + this._text.text(ue.translate(this.state.option.text)) }), - (tn.prototype._onHover = function (t) { + (an.prototype._onHover = function (t) { this.emit('hover', t), this.usingKb(!1), this.updateStyle(t) }), - (tn.prototype.updateStyle = function (t) { + (an.prototype.updateStyle = function (t) { if (this.dom) { var e = this.state.theme.get().palette, i = this.state.style @@ -8080,11 +8179,11 @@ }) } }), - (tn.prototype.text = function () { + (an.prototype.text = function () { return this._text.text() }), - (tn.prototype.style = function (t) { - ;(this.state.isLast = t), (this.state.style = Qi(this.state.theme.get())) + (an.prototype.style = function (t) { + ;(this.state.isLast = t), (this.state.style = sn(this.state.theme.get())) this.css({ position: 'relative', cursor: 'pointer', @@ -8105,19 +8204,19 @@ }), this.updateStyle() }), - Jt.proto(en, Xi), - (en.prototype.getSelected = function () { + ie.proto(cn, rn), + (cn.prototype.getSelected = function () { return this.state.selected && this.state.selected.getOptionData() }), - (en.prototype.setCopy = function () { + (cn.prototype.setCopy = function () { for (var t = this._options.length; t--; ) this._options[t].setCopy() }), - (en.prototype.setOptions = function (t) { + (cn.prototype.setOptions = function (t) { for (var e, i = this._options.length; i--; ) { this.getContainer().removeElement(this._options[i]) } for (this._options = [], i = 0; i < t.length; i++) { - e = this.getContainer().initComponent(tn, { + e = this.getContainer().initComponent(an, { theme: this.state.theme, isMenu: this.state.isMenu, size: t.length, @@ -8136,49 +8235,49 @@ var o = -1 === this.state.optionsVisible ? this._options.length : this.state.optionsVisible this.css({ height: o * this.state.optionHeight }) }), - (en.prototype.select = function (t) { + (cn.prototype.select = function (t) { for (var e = null, i = this._options.length; i--; ) { t === this._options[i].getOptionData().value && (e = this._options[i]) } if (!e) throw new Error('Cannot select a missing option value: ' + t) e.select() }), - (en.prototype.deselect = function () { + (cn.prototype.deselect = function () { this.state.selected && this.state.selected.deselect(), (this.state.selected = null) }), - (en.prototype._onOptionSelect = function (t) { + (cn.prototype._onOptionSelect = function (t) { this.hide(), this.state.selected && this.state.selected !== t && this.state.selected.deselect(), (this.state.selected = t), this.emit('select', t.getOptionData()) }), - (en.prototype._onOptionFocus = function (t) { + (cn.prototype._onOptionFocus = function (t) { this.state.focusedId = t var e = this._options[t], i = !this.state.centerOnce && e === this.state.selected i && (this.state.centerOnce = !0), this.scrollInView(e.dom, i, i) }), - (en.prototype._onOptionHover = function () { + (cn.prototype._onOptionHover = function () { for (var t = this._options.length; t--; ) this._options[t].updateStyle(!1) }), - (en.prototype._onOptionBlur = function () { + (cn.prototype._onOptionBlur = function () { var t = this ;(this.state.focusedId = -1), setTimeout(function () { t.dom && -1 === t.state.focusedId && t.hide() }, 0) }), - (en.prototype.isVisible = function () { + (cn.prototype.isVisible = function () { return this.state.visible }), - (en.prototype.hide = function () { + (cn.prototype.hide = function () { this.state.visible && ((this.state.visible = !1), this.setAttribute('aria-expanded', !1), this.css({ display: 'none' }), this.emit('hide')) }), - (en.prototype.open = function () { + (cn.prototype.open = function () { if (!this.state.visible) { ;(this.state.centerOnce = !1), (this.state.visible = !0), @@ -8188,15 +8287,15 @@ t && t.focus(), this.emit('open') } }), - (en.prototype.usingKb = function (t) { + (cn.prototype.usingKb = function (t) { this.state.usingKb = t for (var e = this._options.length; e--; ) this._options[e].usingKb(t) }), - (en.prototype.style = function (t) { + (cn.prototype.style = function (t) { var e = (function (t) { var e = t.palette, i = t.component - return Ci.merge({ main: { fill: e.common.white, border: '#6E829E' } }, i.list) + return Bi.merge({ main: { fill: e.common.white, border: '#6E829E' } }, i.list) })(this.state.theme.get()) this.css({ width: t || 160, @@ -8222,7 +8321,7 @@ } this.baseStyle() }), - (en.prototype.onKeyPress = function (t) { + (cn.prototype.onKeyPress = function (t) { var e = this if (27 === t.keyNum) { return ( @@ -8250,21 +8349,21 @@ n && n.focus() } }), - (en.prototype._findByValue = function (t) { + (cn.prototype._findByValue = function (t) { t = t.toLowerCase() for (var e = null, i = this._options.length; i--; ) { 0 === this._options[i].text().toLowerCase().indexOf(t) && (e = this._options[i]) } return e }), - Jt.proto(nn, Yt), - (nn.prototype.setStyle = function (t) { + ie.proto(ln, ne), + (ln.prototype.setStyle = function (t) { t = t || {} var e = (function (t) { var e = t.palette, i = t.component, n = 'light' === e.mode - return Ci.merge( + return Bi.merge( { main: { fill: e.grey[n ? 100 : 800], border: e.grey[n ? 300 : 200] }, hover: { fill: e.grey[n ? 200 : 900] }, @@ -8287,19 +8386,20 @@ (this.boxState.css.cursor = t.cursor || this.boxState.css.cursor || 'default'), this.css(this.boxState.css) }), - (nn.prototype.setVisible = function (t) { + (ln.prototype.setVisible = function (t) { ;(this.boxState.visible = t), this.setAttribute('aria-hidden', !t), - this.css({ display: t ? 'block' : 'none' }) + this.css({ display: t ? 'block' : 'none' }), + this._tabbable && this.setAttribute('tabindex', t ? '0' : '-1') }), - (nn.prototype.setAriaLabel = function (t) { + (ln.prototype.setAriaLabel = function (t) { t ? this.setAttribute('aria-label', t) : this.boxState.ariaLabel && - this.setAttribute('aria-label', se.translate(this.boxState.ariaLabel)) + this.setAttribute('aria-label', ue.translate(this.boxState.ariaLabel)) }), - Jt.proto(on, Yt), - (on.prototype.style = function (t, e, i) { + ie.proto(hn, ne), + (hn.prototype.style = function (t, e, i) { e || (e = t), i !== undefined && (this.state.thickness = i), this.css({ @@ -8345,28 +8445,28 @@ backgroundColor: this.state.color, }) }), - (on.prototype.setVisibility = function (t) { + (hn.prototype.setVisibility = function (t) { ;(this.state.visible = t), this.css({ opacity: t ? 1 : 0 }) }), - (on.prototype.setColor = function (t) { + (hn.prototype.setColor = function (t) { ;(this.state.color = t), this.$top.css({ backgroundColor: this.state.color }), this.$bottom.css({ backgroundColor: this.state.color }), this.$right.css({ backgroundColor: this.state.color }), this.$left.css({ backgroundColor: this.state.color }) }), - (on.prototype.isVisible = function () { + (hn.prototype.isVisible = function () { return this.state.visible }), - Jt.proto(rn, Yt), - (rn.prototype.setUrl = function (t) { + ie.proto(fn, ne), + (fn.prototype.setUrl = function (t) { this.state.url = t }), - (rn.prototype.getUrl = function () { + (fn.prototype.getUrl = function () { return this.state.url }), - (rn.prototype.size = function (t, e) { - var i = sn(this.state.theme.get()) + (fn.prototype.size = function (t, e) { + var i = un(this.state.theme.get()) t && (this.state.width = t), e ? (this.state.height = e) : t && (this.state.height = t), this.css({ @@ -8377,19 +8477,19 @@ }), this.graphic.size(this.state.width, this.state.height) }), - (rn.prototype.onSelect = function (t) { + (fn.prototype.onSelect = function (t) { t.preventDefault && t.preventDefault(), window.open(this.state.url, '_blank') }), - (rn.prototype.onFocus = function (t) { - var e = sn(this.state.theme.get()).focus.outline + (fn.prototype.onFocus = function (t) { + var e = un(this.state.theme.get()).focus.outline this.css({ outline: '2px solid ' + e }) }), - (rn.prototype.onBlur = function (t) { + (fn.prototype.onBlur = function (t) { this.css({ outline: 'none' }) }), - Jt.proto(ln, Yt), - (ln.prototype.size = function (t, e) { - ;(this.config.size = t || this.config.size), (this._style = an(this._theme.get())) + ie.proto(pn, ne), + (pn.prototype.size = function (t, e) { + ;(this.config.size = t || this.config.size), (this._style = dn(this._theme.get())) var i = e || this._style.main.fill, n = this.state.visible ? 1 : 1.2 if ( @@ -8440,7 +8540,7 @@ this.icon.css({ position: 'absolute', top: 0, left: 0, zIndex: 15 }) } }), - (ln.prototype.display = function (t, e) { + (pn.prototype.display = function (t, e) { this._timer && (this._timer = clearTimeout(this._timer)), this.resetAnimation(), e @@ -8452,7 +8552,7 @@ )) : this.reset(t) }), - (ln.prototype.reset = function (t) { + (pn.prototype.reset = function (t) { ;(this.state.visible = t), this.css({ transition: 'none', opacity: t ? 1 : 0 }), this.icon.css({ @@ -8463,7 +8563,7 @@ this.$radial.css({ opacity: 0, transition: 'none' }), this.$fill.css({ transition: 'none', transform: 'scale(1)' }) }), - (ln.prototype.resetAnimation = function () { + (pn.prototype.resetAnimation = function () { var t = this.state.visible ? 1 : 0.75 this.$fill.css({ transition: 'none', transform: 'scale(' + t + ')' }), this.$radial.css({ opacity: 0.25, transition: 'none', transform: 'scale(1)' }), @@ -8473,7 +8573,7 @@ transition: 'none', }) }), - (ln.prototype.animateIn = function () { + (pn.prototype.animateIn = function () { this.css({ transition: 'all 0.25s cubic-bezier(0.33, 1, 0.68, 1)', opacity: 1 }), this.$fill.css({ transition: 'all 0.25s cubic-bezier(.18,1.78,.66,.84) 0.05s', @@ -8490,7 +8590,7 @@ transition: 'all 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0.05s', }) }), - (ln.prototype.animateOut = function () { + (pn.prototype.animateOut = function () { this.css({ transition: 'opacity 0.2s cubic-bezier(0.25, 1, 0.5, 1) 0.05s', opacity: 0 }), this.$fill.css({ transition: 'transform 0.2s cubic-bezier(0.25, 1, 0.5, 1) 0.05s', @@ -8503,50 +8603,50 @@ transition: 'all 0.2s cubic-bezier(0.25, 1, 0.5, 1)', }) }), - (ln.prototype.fill = function (t) { + (pn.prototype.fill = function (t) { this.$fill.css({ backgroundColor: t, transition: 'none' }), this.$radial.css({ backgroundColor: t, transition: 'none' }) }) - var cn = { + var mn = { __proto__: null, - Graphic: Bi, - ListNative: ji, - ListCustom: en, - Link: Si, - Logo: rn, - Span: Ai, - Markdown: Li, - IconButton: Vi, - TextButton: Ri, - ActionButton: Fi, - RadioButton: Di, - TextArea: $i, - Box: nn, - Border: on, - Badge: ln, - } - function hn() { - Jt.self(this, Vi, { + Graphic: Pi, + ListNative: qi, + ListCustom: cn, + Link: Hi, + Logo: fn, + Span: Mi, + Markdown: Ri, + IconButton: $i, + TextButton: Ui, + ActionButton: ji, + RadioButton: zi, + TextArea: Wi, + Box: ln, + Border: hn, + Badge: pn, + } + function yn() { + ie.self(this, $i, { title: 'Close Modal', name: 'close', src: "data:image/svg+xml,%3csvg width='22' height='22' viewBox='0 0 22 22' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M17.5669 4.17308C17.1764 3.78256 16.5432 3.78256 16.1527 4.17308L11 9.32578L5.84731 4.17309C5.45678 3.78257 4.82362 3.78257 4.43309 4.17309L4.17308 4.43311C3.78256 4.82363 3.78256 5.4568 4.17308 5.84732L9.32577 11L4.17309 16.1527C3.78257 16.5432 3.78257 17.1764 4.17309 17.5669L4.4331 17.8269C4.82363 18.2174 5.45679 18.2174 5.84732 17.8269L11 12.6742L16.1527 17.8269C16.5432 18.2174 17.1764 18.2174 17.5669 17.8269L17.8269 17.5669C18.2174 17.1764 18.2174 16.5432 17.8269 16.1527L12.6742 11L17.8269 5.84731C18.2174 5.45678 18.2174 4.82362 17.8269 4.43309L17.5669 4.17308Z'/%3e%3c/svg%3e", - theme: _i, + theme: Ti, width: 30, height: 30, }) } - function un() { - Jt.self(this, Yt, 'header'), + function gn() { + ie.self(this, ne, 'header'), (this.state = { visible: !0 }), (this.$title = this.createElement('h2', '#modal-title')), (this.$underline = this.createElement('.underline')), this.setAttribute('role', 'heading') } - function dn(t) { + function vn(t) { var e = t.palette, i = t.component, n = 'light' === e.mode - return Ci.merge( + return Bi.merge( { main: { fill: e.common.white, border: e.grey[n ? 300 : 200] }, hover: { fill: e.grey[n ? 200 : 700] }, @@ -8555,23 +8655,23 @@ i.modal, ) } - function pn() { - Jt.self(this, Yt, 'modal') + function bn() { + ie.self(this, ne, 'modal') var t = this ;(this.state = { visible: !1, curr: null, prev: null }), - (this._style = dn(_i.get())), + (this._style = vn(Ti.get())), this.addClass('no-outline'), this.setAttribute('role', 'dialog'), this.setAttribute('aria-modal', !0), this.setAttribute('tabindex', '0'), - (this.header = this.initComponent(un)), + (this.header = this.initComponent(gn)), this.header.on('close', function () { t.emit('close') }), (this.$content = this.createElement('#modal-content')), this.$content.addClass('content'), this.setAttribute('aria-describedby', 'modal-content'), - (this.close = this.initComponent(hn)), + (this.close = this.initComponent(yn)), this.close.on('click', function () { t.emit('close') }), @@ -8591,8 +8691,8 @@ t.css({ border: 'none' }) }) } - function fn(t) { - Jt.self(this, Yt, 'copy', 'p') + function wn(t) { + ie.self(this, ne, 'copy', 'p') var e = this t || (t = {}), (this.state = { @@ -8604,8 +8704,8 @@ replaceText: t.replaceText || null, }), this.state.link && - ((this.link = new Si({ - theme: _i, + ((this.link = new Hi({ + theme: Ti, text: this.state.linkText, url: this.state.linkTo, underline: this.state.linkUnderline, @@ -8615,12 +8715,12 @@ e.emit('click', t) })) } - Jt.proto(hn, Vi), - (hn.size = hn.prototype.size = 30), - Jt.proto(un, Yt), - (un.prototype.style = function (t, e) { + ie.proto(yn, $i), + (yn.size = yn.prototype.size = 30), + ie.proto(gn, ne), + (gn.prototype.style = function (t, e) { var i = e ? 40 : 44, - n = _i.get().palette, + n = Ti.get().palette, o = 'light' === n.mode return ( this.$title.css({ @@ -8632,7 +8732,7 @@ verticalAlign: 'middle', paddingTop: 2, height: i, - width: t - hn.size, + width: t - yn.size, }), this.$underline.css({ backgroundColor: n.primary.main, @@ -8645,23 +8745,23 @@ { height: i, width: t } ) }), - (un.prototype.setCopy = function (t) { - var e = se.translate(t) + (gn.prototype.setCopy = function (t) { + var e = ue.translate(t) this.$title.text(e) }), - (un.prototype.display = function (t) { + (gn.prototype.display = function (t) { ;(this.state.visible = t), this.css({ display: t ? 'table-cell' : 'none' }) }), - (un.prototype.isVisible = function () { + (gn.prototype.isVisible = function () { return this.state.visible }), - Jt.proto(pn, Yt), - (pn.prototype.load = function () { + ie.proto(bn, ne), + (bn.prototype.load = function () { this.close.load() }), - (pn.prototype.style = function (t, e) { + (bn.prototype.style = function (t, e) { var i = t < 300 - ;(this._style = dn(_i.get())), + ;(this._style = vn(Ti.get())), this.css({ width: t, maxHeight: e, @@ -8688,14 +8788,14 @@ this.close.style(), this.close.css({ position: 'absolute', right: 20, top: i ? 5 : 7 }) }), - (pn.prototype.setTitle = function (t) { + (bn.prototype.setTitle = function (t) { t ? (this.header.display(!0), this.header.setCopy(t), this.close.setTitle()) : this.header.display(!1) }), - Jt.proto(fn, Yt), - (fn.prototype.style = function (t, e) { - var i = _i.get().palette, + ie.proto(wn, ne), + (wn.prototype.style = function (t, e) { + var i = Ti.get().palette, n = 'light' === i.mode e || (e = 'center'), this.css({ @@ -8709,8 +8809,8 @@ }), this.state.link && (this.link.style(t), this.link.css({ display: 'inline' })) }), - (fn.prototype.translate = function () { - var t = se.translate(this.state.text) + (wn.prototype.translate = function () { + var t = ue.translate(this.state.text) if (this.state.link) { if ((this.link.translate(), this.state.replaceText)) { var e = t.split('{{' + this.state.replaceText + '}}'), @@ -8725,54 +8825,54 @@ } } else this.content(t) }) - function mn() { - Jt.self(this, Yt, 'instructions') + function xn() { + ie.self(this, ne, 'instructions') var t = this - ;(this.copy = this.initComponent(fn, { + ;(this.copy = this.initComponent(wn, { text: 'hCaptcha is a service that reduces bots and spam by asking simple questions. Please follow the instructions at the top of the screen for each challenge. For more information visit {{site-url}}', link: !0, linkText: 'hcaptcha.com', linkTo: 'https://www.hcaptcha.com/what-is-hcaptcha-about?ref=' + - ct.host + + ht.host + '&utm_campaign=' + - ct.sitekey + + ht.sitekey + '&utm_medium=embed_about', replaceText: 'site-url', })), this.copy.on('click', function (e) { - e.preventDefault(), li(t.copy.state.linkTo) + e.preventDefault(), pi(t.copy.state.linkTo) }) } - function yn() { - Jt.self(this, Yt, 'feedback') + function kn() { + ie.self(this, ne, 'feedback') var t = this - ;(this.info = this.initComponent(Ai, { text: 'Having a problem?' })), - (this.link = this.initComponent(Si, { theme: _i, underline: !0, text: 'Give feedback.' })), + ;(this.info = this.initComponent(Mi, { text: 'Having a problem?' })), + (this.link = this.initComponent(Hi, { theme: Ti, underline: !0, text: 'Give feedback.' })), this.link.on('click', function () { t.emit('click') }) } - function gn() { - Jt.self(this, Yt, 'information') + function Cn() { + ie.self(this, ne, 'information') var t = this - ;(this.instructions = this.initComponent(mn, null, this.$content)), - (this.feedback = this.initComponent(yn, null, this.$content)), + ;(this.instructions = this.initComponent(xn, null, this.$content)), + (this.feedback = this.initComponent(kn, null, this.$content)), this.feedback.on('click', function () { t.emit('change', 'feedback') }) } - function vn() { - Jt.self(this, Yt, 'actions') + function _n() { + ie.self(this, ne, 'actions') var t = this - ;(this.cancel = this.initComponent(Fi, { - theme: _i, + ;(this.cancel = this.initComponent(ji, { + theme: Ti, selector: 'button-cancel', title: 'Cancel', type: 'warn', })), - (this.send = this.initComponent(Fi, { - theme: _i, + (this.send = this.initComponent(ji, { + theme: Ti, selector: 'button-send', title: 'Send', type: 'confirm', @@ -8784,17 +8884,17 @@ t.emit('confirm') }) } - Jt.proto(mn, Yt), - (mn.prototype.style = function (t) { + ie.proto(xn, ne), + (xn.prototype.style = function (t) { this.copy.style(t, 'left') }), - (mn.prototype.setCopy = function () { + (xn.prototype.setCopy = function () { this.copy.translate() }), - Jt.proto(yn, Yt), - (yn.prototype.style = function (t) { - var e = Math.floor(Mt(t, 250, 300, 11, 13)), - i = _i.get().palette, + ie.proto(kn, ne), + (kn.prototype.style = function (t) { + var e = Math.floor(Dt(t, 250, 300, 11, 13)), + i = Ti.get().palette, n = 'light' === i.mode this.css({ textAlign: 'center', @@ -8806,50 +8906,50 @@ }), this.link.css({ fontWeight: 500, marginLeft: 3 }) }), - (yn.prototype.setCopy = function () { - var t = se.translate('Provide feedback regarding the hCaptcha service.') + (kn.prototype.setCopy = function () { + var t = ue.translate('Provide feedback regarding the hCaptcha service.') this.info.translate(), this.link.translate(), this.link.setAttribute('aria-label', t) }), - Jt.proto(gn, Yt), - (gn.prototype.style = function (t, e, i) { - var n = Math.floor(Mt(t, 250, 275, 12, 14)) + ie.proto(Cn, ne), + (Cn.prototype.style = function (t, e, i) { + var n = Math.floor(Dt(t, 250, 275, 12, 14)) this.instructions.style(n), this.instructions.css({ marginBottom: 10 }), this.feedback.style(t) }), - (gn.prototype.setCopy = function () { + (Cn.prototype.setCopy = function () { this.instructions.setCopy(), this.feedback.setCopy() }), - Jt.proto(vn, Yt), - (vn.prototype.style = function (t, e, i) { + ie.proto(_n, ne), + (_n.prototype.style = function (t, e, i) { this.send.style(), this.cancel.style(t, i), this.cancel.css({ position: 'absolute', left: 0 }), this.send.css({ position: 'absolute', right: 0 }) }), - (vn.prototype.setCopy = function () { + (_n.prototype.setCopy = function () { this.cancel.setText(), this.send.setText() }), - (vn.prototype.lockSend = function (t) { + (_n.prototype.lockSend = function (t) { this.send.lock(t), t ? this.send.setLabel('Please select an option to send response.') : this.send.removeAttribute('aria-label') }), - (vn.prototype.visible = function (t) { + (_n.prototype.visible = function (t) { this.cancel.enable(t), this.send.enable(t) }) - function bn() { - Jt.self(this, Yt, 'instructions'), - (this.copy = this.initComponent(fn, { + function En() { + ie.self(this, ne, 'instructions'), + (this.copy = this.initComponent(wn, { text: 'Please select Confirm to follow the link, or Cancel to stay on the current screen.', })) } - function wn(t) { - Jt.self(this, Yt, 'navigation') + function An(t) { + ie.self(this, ne, 'navigation') var e = this - ;(this.confirmation = this.initComponent(bn)), - (this.actions = this.initComponent(vn)), + ;(this.confirmation = this.initComponent(En)), + (this.actions = this.initComponent(_n)), this.actions.on('confirm', function () { window.open(t.url, '_blank'), e.emit('close') }), @@ -8857,8 +8957,8 @@ e.emit('close') }) } - function xn(t) { - Jt.self(this, Yt, 'options'), + function Sn(t) { + ie.self(this, ne, 'options'), (this.state = { visible: !0 }), (this.handeSelect = this.handeSelect.bind(this)), (this.$wrapper = this.createElement('.column-wrapper')), @@ -8868,21 +8968,21 @@ for (var e = null, i = null, n = null, o = 0; o < t.length; o++) { ;(n = t[o]), (i = o >= t.length / 2 ? this.$right : this.$left), - (e = this.initComponent(Di, { theme: _i, text: n.text, value: n.value }, i)).setCopy(), + (e = this.initComponent(zi, { theme: Ti, text: n.text, value: n.value }, i)).setCopy(), e.on('select', this.handeSelect), this.options.push(e) } } - Jt.proto(bn, Yt), - (bn.prototype.style = function (t) { + ie.proto(En, ne), + (En.prototype.style = function (t) { this.copy.style(t, 'left') }), - (bn.prototype.setCopy = function () { + (En.prototype.setCopy = function () { this.copy.translate() }), - Jt.proto(wn, Yt), - (wn.prototype.style = function (t, e, i) { - var n = Math.floor(Mt(t, 250, 275, 12, 14)) + ie.proto(An, ne), + (An.prototype.style = function (t, e, i) { + var n = Math.floor(Dt(t, 250, 275, 12, 14)) this.confirmation.style(n), this.confirmation.css({ marginBottom: 10 }), this.actions.style(t, i), @@ -8893,17 +8993,17 @@ margin: '10px auto 0px', }) }), - (wn.prototype.setCopy = function () { + (An.prototype.setCopy = function () { this.confirmation.setCopy(), this.actions.setCopy() }), - Jt.proto(xn, Yt), - (xn.prototype.style = function (t, e) { + ie.proto(Sn, ne), + (Sn.prototype.style = function (t, e) { var i = Math.floor(t / 2) this.$left.css({ width: '50%', display: 'inline-block' }), this.$right.css({ width: '50%', display: 'inline-block' }) for (var n = 0; n < this.options.length; n++) this.options[n].style(i) }), - (xn.prototype.handeSelect = function (t) { + (Sn.prototype.handeSelect = function (t) { if (this.state.visible) { for (var e = !1, i = 0; i < this.options.length; i++) { ;(e = this.options[i] === t) && e === t.state.selected && (e = !e), @@ -8912,50 +9012,50 @@ this.emit('update', t) } }), - (xn.prototype.visible = function (t) { + (Sn.prototype.visible = function (t) { ;(this.state.visible = t), this.css({ display: t ? 'inline-block' : 'none' }) for (var e = 0; e < this.options.length; e++) this.options[e].lock(!t) }), - (xn.prototype.setCopy = function () { + (Sn.prototype.setCopy = function () { for (var t = 0; t < this.options.length; t++) this.options[t].setCopy() }) - var Cn = 'Please provide details and steps to reproduce.', - kn = [ + var Bn = 'Please provide details and steps to reproduce.', + Ln = [ { text: "Can't Solve", value: 'captcha_solve' }, { text: "Can't Click", value: 'captcha_usability' }, { text: 'Off Screen', value: 'captcha_position' }, { text: 'Other', value: 'other' }, ], - _n = 'Please describe your issue.', - En = [ + Tn = 'Please describe your issue.', + On = [ { text: 'Inappropriate', value: 'inappropriate' }, { text: 'Violent', value: 'violent' }, { text: 'Too Difficult', value: 'difficulty' }, { text: 'Other', value: 'other' }, ], - Sn = 'Please describe your issue.', - An = [ + Hn = 'Please describe your issue.', + Mn = [ { text: 'Inappropriate', value: 'content' }, { text: 'Software Bug', value: 'software' }, { text: 'Too Difficult', value: 'difficulty' }, { text: 'Other', value: 'other' }, ] - function Ln(t) { - Jt.self(this, Yt, 'report') + function Rn(t) { + ie.self(this, ne, 'report') var e = this this.state = { selected: null, taskKey: t.key, type: t.type } var i, n, o, - s = + r = ((i = t.type), - (n = Sn), - (o = An), - 'bug' === i ? ((n = Cn), (o = kn)) : 'image' === i && ((n = _n), (o = En)), + (n = Hn), + (o = Mn), + 'bug' === i ? ((n = Bn), (o = Ln)) : 'image' === i && ((n = Tn), (o = On)), { prompt: n, options: o }) - ;(this.options = this.initComponent(xn, s.options)), - (this.comment = this.initComponent($i, { placeholder: s.prompt, theme: _i })), - (this.actions = this.initComponent(vn)), + ;(this.options = this.initComponent(Sn, r.options)), + (this.comment = this.initComponent(Wi, { placeholder: r.prompt, theme: Ti })), + (this.actions = this.initComponent(_n)), this.actions.lockSend(!0), this.options.on('update', this.storeAnswer.bind(this)), this.actions.on('confirm', this.sendMessage.bind(this)), @@ -8964,44 +9064,44 @@ }), this.setAttribute('role', 'radiogroup') } - function Bn() { - Jt.self(this, Yt, 'thanks-feedback') + function Pn() { + ie.self(this, ne, 'thanks-feedback') var t = this if ( ((this.$copy = this.createElement('.feedback-thanks')), (this.$resolve = this.createElement('.feedback-resolve')), (this.$option = this.createElement('.accessibility-option')), (this.$option.content = this.initComponent( - Ai, - { theme: _i, text: 'Please also try turning off your ad blocker.‍' }, + Mi, + { theme: Ti, text: 'Please also try turning off your ad blocker.‍' }, this.$option, )), (this.$option.link = this.initComponent( - Si, - { theme: _i, text: 'Our accessibility option may help.' }, + Hi, + { theme: Ti, text: 'Our accessibility option may help.' }, this.$option, )), (this.$bug = this.createElement('.feedback-bug')), (this.$bug.content = this.initComponent( - Ai, - { theme: _i, text: 'Reporting a functionality issue?' }, + Mi, + { theme: Ti, text: 'Reporting a functionality issue?' }, this.$bug, )), (this.$bug.link = this.initComponent( - Si, - { theme: _i, text: 'See how to report issues with detailed logs.' }, + Hi, + { theme: Ti, text: 'See how to report issues with detailed logs.' }, this.$bug, )), this.$bug.link.addEventListener('click', function () { - li('https://www.hcaptcha.com/reporting-bugs') + pi('https://www.hcaptcha.com/reporting-bugs') }), this.$option.link.on('click', function () { - li('https://hcaptcha.com/accessibility') + pi('https://hcaptcha.com/accessibility') }), !1 === tt.System.mobile) ) { var e = function (e) { - var i = _i.get().palette, + var i = Ti.get().palette, n = 'light' === i.mode t.$bug.link.css( 'over' === e.action @@ -9011,7 +9111,7 @@ } this.$bug.link.addEventListener('over', e), this.$bug.link.addEventListener('out', e) var i = function (e) { - var i = _i.get().palette, + var i = Ti.get().palette, n = 'light' === i.mode t.$option.link.css( 'over' === e.action @@ -9022,14 +9122,14 @@ this.$option.link.addEventListener('over', i), this.$option.link.addEventListener('out', i) } } - function Hn() { - Jt.self(this, Yt, 'thanks-accessibility') + function In() { + ie.self(this, ne, 'thanks-accessibility') var t = this ;(this.$sorry = this.createElement('.accessibility-text')), (this.$option = this.createElement('.accessibility-option')), (this.$avoid = this.createElement('.accessibility-avoid')) var e = function (t) { - li('https://hcaptcha.com/accessibility') + pi('https://hcaptcha.com/accessibility') } if ( (this.$option.addEventListener('enter', e), @@ -9037,7 +9137,7 @@ !1 === tt.System.mobile) ) { var i = function (e) { - var i = _i.get().palette, + var i = Ti.get().palette, n = 'light' === i.mode t.$option.css( 'over' === e.action @@ -9048,21 +9148,21 @@ this.$option.addEventListener('over', i), this.$option.addEventListener('out', i) } } - function On() { - Jt.self(this, Yt, 'thanks-feedback'), + function Vn() { + ie.self(this, ne, 'thanks-feedback'), (this.$copy = this.createElement('.feedback-thanks')), (this.$resolve = this.createElement('.feedback-resolve')) } - function Tn(t) { - Jt.self(this, Yt, 'thanks'), + function Dn(t) { + ie.self(this, ne, 'thanks'), 'accessibility' === t.response - ? (this.copy = this.initComponent(Hn, null, this.$content)) + ? (this.copy = this.initComponent(In, null, this.$content)) : 'image' === t.response - ? (this.copy = this.initComponent(On, null, this.$content)) - : (this.copy = this.initComponent(Bn, null, this.$content)) + ? (this.copy = this.initComponent(Vn, null, this.$content)) + : (this.copy = this.initComponent(Pn, null, this.$content)) } - Jt.proto(Ln, Yt), - (Ln.prototype.style = function (t, e, i) { + ie.proto(Rn, ne), + (Rn.prototype.style = function (t, e, i) { this.options.style(t, i), this.options.css({ marginBottom: 10 }), this.comment.style(t, i), @@ -9075,7 +9175,7 @@ margin: '10px auto 0px', }) }), - (Ln.prototype.sendMessage = function () { + (Rn.prototype.sendMessage = function () { var t = '', e = this.comment.getValue() this.state.selected && (t = this.state.selected.state.text), @@ -9086,29 +9186,29 @@ this.emit('report', { reason: t, comment: e, key: this.state.taskKey }), this.emit('change', 'thanks', { response: this.state.type }) }), - (Ln.prototype.storeAnswer = function (t) { + (Rn.prototype.storeAnswer = function (t) { var e = t.state.selected, i = 'other' === t.state.value && e this.comment.visible(i), (this.state.selected = e ? t : null), this.actions.lockSend(null === this.selected) }), - (Ln.prototype.setCopy = function (t) { + (Rn.prototype.setCopy = function (t) { this.options.setCopy(), this.comment.setPlaceholder(), this.actions.setCopy() }), - Jt.proto(Bn, Yt), - (Bn.prototype.style = function (t, e) { - var i = Mt(t, 280, 310, 260, 310), - n = Mt(t, 280, 300, 12, 13), + ie.proto(Pn, ne), + (Pn.prototype.style = function (t, e) { + var i = Dt(t, 280, 310, 260, 310), + n = Dt(t, 280, 300, 12, 13), o = n + 4, - s = _i.get().palette, - r = 'light' === s.mode + r = Ti.get().palette, + s = 'light' === r.mode this.css({ fontWeight: 500, textAlign: 'center', fontSize: n + 1, lineHeight: n + 4, - color: r ? s.text.body : s.grey[700], + color: s ? r.text.body : r.grey[700], width: t, }), this.$copy.css({ width: i, margin: '0 auto', fontWeight: 600, marginBottom: 2 }), @@ -9136,39 +9236,39 @@ cursor: 'pointer', }) }), - (Bn.prototype.setCopy = function () { - var t = se.translate('Thank you for your feedback.'), - e = se.translate("We'll resolve your issue as quickly as we can.") + (Pn.prototype.setCopy = function () { + var t = ue.translate('Thank you for your feedback.'), + e = ue.translate("We'll resolve your issue as quickly as we can.") this.$copy.text(t), this.$resolve.text(e), this.$bug.content.translate(), this.$bug.link.translate(), this.$option.content.translate(), this.$option.link.translate() - var i = se.translate('View our accessibility option.'), - n = se.translate("Give a detailed report of a bug you've encountered.") + var i = ue.translate('View our accessibility option.'), + n = ue.translate("Give a detailed report of a bug you've encountered.") this.$option.link.setAttribute('aria-label', i), this.$bug.link.setAttribute('aria-label', n) }), - Jt.proto(Hn, Yt), - (Hn.prototype.style = function (t, e) { - var i = Mt(t, 280, 310, 260, 310), - n = Mt(t, 280, 300, 12, 13), + ie.proto(In, ne), + (In.prototype.style = function (t, e) { + var i = Dt(t, 280, 310, 260, 310), + n = Dt(t, 280, 300, 12, 13), o = n + 4, - s = _i.get().palette, - r = 'light' === s.mode + r = Ti.get().palette, + s = 'light' === r.mode this.css({ fontWeight: 500, fontSize: n + 1, lineHeight: o, textAlign: 'center', - color: r ? s.text.body : s.grey[700], + color: s ? r.text.body : r.grey[700], width: t, }), this.$sorry.css({ fontWeight: 600, width: i, margin: '0 auto', marginBottom: 2 }), this.$option.css({ fontSize: n, lineHeight: o, - color: r ? s.text.body : s.grey[700], + color: s ? r.text.body : r.grey[700], cursor: 'pointer', marginBottom: 10, }), @@ -9180,19 +9280,19 @@ margin: '0 auto', }) }), - (Hn.prototype.setCopy = function () { - var t = se.translate('Sorry to hear that!'), - e = se.translate('Our accessibility option may help.'), - i = se.translate( + (In.prototype.setCopy = function () { + var t = ue.translate('Sorry to hear that!'), + e = ue.translate('Our accessibility option may help.'), + i = ue.translate( 'This lets you avoid future questions by registering and setting a cookie.', ), - n = se.translate('Please also try turning off your ad blocker.‍') + n = ue.translate('Please also try turning off your ad blocker.‍') this.$sorry.text(t + ' '), this.$option.text(e), this.$avoid.text(i + ' ' + n) }), - Jt.proto(On, Yt), - (On.prototype.style = function (t, e) { - var i = Mt(t, 280, 310, 260, 310), - n = Mt(t, 280, 300, 12, 13), + ie.proto(Vn, ne), + (Vn.prototype.style = function (t, e) { + var i = Dt(t, 280, 310, 260, 310), + n = Dt(t, 280, 300, 12, 13), o = n + 4 this.css({ fontWeight: 500, @@ -9211,42 +9311,42 @@ marginBottom: 10, }) }), - (On.prototype.setCopy = function () { + (Vn.prototype.setCopy = function () { var t = { - thanks: se.translate('Thank you for your feedback.'), - resolve: se.translate('We will look into the issue immediately.'), + thanks: ue.translate('Thank you for your feedback.'), + resolve: ue.translate('We will look into the issue immediately.'), } this.$copy.text(t.thanks), this.$resolve.text(t.resolve) }), - Jt.proto(Tn, pn), - (Tn.prototype.style = function (t, e, i) { + ie.proto(Dn, bn), + (Dn.prototype.style = function (t, e, i) { this.copy.style(t, i) }), - (Tn.prototype.setCopy = function () { + (Dn.prototype.setCopy = function () { this.copy.setCopy() }), - (Tn.prototype.setFocus = function () { + (Dn.prototype.setFocus = function () { this.copy.focus() }) - var Mn = 'https://newassets.hcaptcha.com/captcha/v1/1bcdbdd/static/images' - function Vn() { - Jt.self(this, Yt, 'cookie-icon'), - (this.$none = this.initComponent(Bi, { + var Fn = 'https://newassets.hcaptcha.com/captcha/v1/a8cd801/static/images' + function $n() { + ie.self(this, ne, 'cookie-icon'), + (this.$none = this.initComponent(Pi, { selector: '.icon-none', src: "data:image/svg+xml,%3csvg width='155' height='155' viewBox='0 0 155 155' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cmask id='mask0' mask-type='alpha' maskUnits='userSpaceOnUse' x='3' y='4' width='150' height='149'%3e%3cpath d='M153 78C153 119.421 119.421 153 78 153C36.5786 153 3 119.421 3 78C3 42.6044 27.5196 12.9356 60.5 5.0526C66.1145 3.71061 68 4 69.5 5.0526C71.6884 6.5883 62.5 20 69.5 31.5C76.5 43 89.5 39.5 101.5 53C107.488 59.7371 105.376 73.2409 117.5 79C137.5 88.5 151 71 153 78Z' fill='%23555555'/%3e%3c/mask%3e%3cg mask='url(%23mask0)'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M78 153C119.421 153 153 119.421 153 78C153 36.5786 119.421 3 78 3C36.5786 3 3 36.5786 3 78C3 119.421 36.5786 153 78 153ZM57 41.5C57 45.6421 53.6421 49 49.5 49C45.3579 49 42 45.6421 42 41.5C42 37.3579 45.3579 34 49.5 34C53.6421 34 57 37.3579 57 41.5ZM83 74C83 79.5228 78.5228 84 73 84C67.4772 84 63 79.5228 63 74C63 68.4772 67.4772 64 73 64C78.5228 64 83 68.4772 83 74ZM54 117C54 122.523 49.5229 127 44 127C38.4772 127 34 122.523 34 117C34 111.477 38.4772 107 44 107C49.5229 107 54 111.477 54 117ZM119.5 122C123.642 122 127 118.642 127 114.5C127 110.358 123.642 107 119.5 107C115.358 107 112 110.358 112 114.5C112 118.642 115.358 122 119.5 122ZM32 83C34.7614 83 37 80.7614 37 78C37 75.2386 34.7614 73 32 73C29.2386 73 27 75.2386 27 78C27 80.7614 29.2386 83 32 83ZM88 111C88 113.761 85.7614 116 83 116C80.2386 116 78 113.761 78 111C78 108.239 80.2386 106 83 106C85.7614 106 88 108.239 88 111Z' fill='%23555555'/%3e%3c/g%3e%3c/svg%3e", - fallback: Mn + '/cookie-none.png', + fallback: Fn + '/cookie-none.png', width: 18, })), - (this.$blocked = this.initComponent(Bi, { + (this.$blocked = this.initComponent(Pi, { selector: '.icon-blocked', src: "data:image/svg+xml,%3csvg width='155' height='155' viewBox='0 0 155 155' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cmask id='mask0' mask-type='alpha' maskUnits='userSpaceOnUse' x='3' y='4' width='150' height='149'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M78 153C119.421 153 153 119.421 153 78C152.203 75.2117 149.582 76.3107 145.452 78.0421C139.214 80.6575 129.534 84.7159 117.5 79C115.427 78.0152 113.77 76.804 112.418 75.4389L43.3324 144.524C53.7009 149.939 65.4929 153 78 153ZM26.783 132.789L103.528 56.0443C102.962 54.931 102.304 53.9045 101.5 53C95.5 46.25 89.25 43.75 83.625 41.5C78 39.25 73 37.25 69.5 31.5C64.8464 23.8548 67.3474 15.3646 68.904 10.0807C69.6888 7.41648 70.2336 5.56736 69.5 5.05259C68 3.99999 66.1145 3.7106 60.5 5.05259C27.5196 12.9356 3 42.6044 3 78C3 99.6193 12.1474 119.102 26.783 132.789Z' fill='%23EB4040'/%3e%3c/mask%3e%3cg mask='url(%23mask0)'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M78 153C119.421 153 153 119.421 153 78C153 36.5786 119.421 3 78 3C36.5786 3 3 36.5786 3 78C3 119.421 36.5786 153 78 153ZM57 41.5C57 45.6421 53.6421 49 49.5 49C45.3579 49 42 45.6421 42 41.5C42 37.3579 45.3579 34 49.5 34C53.6421 34 57 37.3579 57 41.5ZM83 74C83 79.5228 78.5228 84 73 84C67.4772 84 63 79.5228 63 74C63 68.4772 67.4772 64 73 64C78.5228 64 83 68.4772 83 74ZM54 117C54 122.523 49.5229 127 44 127C38.4772 127 34 122.523 34 117C34 111.477 38.4772 107 44 107C49.5229 107 54 111.477 54 117ZM119.5 122C123.642 122 127 118.642 127 114.5C127 110.358 123.642 107 119.5 107C115.358 107 112 110.358 112 114.5C112 118.642 115.358 122 119.5 122ZM32 83C34.7614 83 37 80.7614 37 78C37 75.2386 34.7614 73 32 73C29.2386 73 27 75.2386 27 78C27 80.7614 29.2386 83 32 83ZM88 111C88 113.761 85.7614 116 83 116C80.2386 116 78 113.761 78 111C78 108.239 80.2386 106 83 106C85.7614 106 88 108.239 88 111Z' fill='%23E25C5C'/%3e%3c/g%3e%3crect x='140.572' y='19' width='13' height='179' transform='rotate(45 140.572 19)' fill='%23555555'/%3e%3c/svg%3e", - fallback: Mn + '/cookie-blocked.png', + fallback: Fn + '/cookie-blocked.png', width: 18, })), - (this.$found = this.initComponent(Bi, { + (this.$found = this.initComponent(Pi, { selector: '.icon-found', src: "data:image/svg+xml,%3csvg width='155' height='155' viewBox='0 0 155 155' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cmask id='mask0' mask-type='alpha' maskUnits='userSpaceOnUse' x='3' y='4' width='150' height='149'%3e%3cpath d='M153 78C153 119.421 119.421 153 78 153C36.5786 153 3 119.421 3 78C3 42.6044 27.5196 12.9356 60.5 5.05259C66.1145 3.7106 68 3.99999 69.5 5.05259C71.6884 6.58829 62.5 20 69.5 31.5C76.5 43 89.5 39.5 101.5 53C107.488 59.737 105.376 73.2409 117.5 79C137.5 88.5 151 71 153 78Z' fill='%23555555'/%3e%3c/mask%3e%3cg mask='url(%23mask0)'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M78 153C119.421 153 153 119.421 153 78C153 36.5786 119.421 3 78 3C36.5786 3 3 36.5786 3 78C3 119.421 36.5786 153 78 153ZM57 41.5C57 45.6421 53.6421 49 49.5 49C45.3579 49 42 45.6421 42 41.5C42 37.3579 45.3579 34 49.5 34C53.6421 34 57 37.3579 57 41.5ZM83 74C83 79.5228 78.5228 84 73 84C67.4772 84 63 79.5228 63 74C63 68.4772 67.4772 64 73 64C78.5228 64 83 68.4772 83 74ZM54 117C54 122.523 49.5229 127 44 127C38.4772 127 34 122.523 34 117C34 111.477 38.4772 107 44 107C49.5229 107 54 111.477 54 117ZM119.5 122C123.642 122 127 118.642 127 114.5C127 110.358 123.642 107 119.5 107C115.358 107 112 110.358 112 114.5C112 118.642 115.358 122 119.5 122ZM32 83C34.7614 83 37 80.7614 37 78C37 75.2386 34.7614 73 32 73C29.2386 73 27 75.2386 27 78C27 80.7614 29.2386 83 32 83ZM88 111C88 113.761 85.7614 116 83 116C80.2386 116 78 113.761 78 111C78 108.239 80.2386 106 83 106C85.7614 106 88 108.239 88 111Z' fill='%2300838f'/%3e%3c/g%3e%3c/svg%3e", - fallback: Mn + '/cookie-found.png', + fallback: Fn + '/cookie-found.png', width: 18, })), 'ie' === tt.Browser.type && 8 === tt.Browser.version @@ -9257,8 +9357,8 @@ this.$blocked.css({ opacity: 0 }), this.$found.css({ opacity: 0 })) } - Jt.proto(Vn, Yt), - (Vn.prototype.style = function () { + ie.proto($n, ne), + ($n.prototype.style = function () { this.css({ width: 18, height: 18, @@ -9269,7 +9369,7 @@ var t = { '-ms-high-contrast-adjust': 'none', position: 'absolute', left: 0, top: 0 } this.$none.css(t), this.$blocked.css(t), this.$found.css(t) }), - (Vn.prototype.display = function (t) { + ($n.prototype.display = function (t) { 'ie' === tt.Browser.type && 8 === tt.Browser.version ? (this.$none.css({ display: 'none' === t ? 'block' : 'none' }), this.$blocked.css({ display: 'blocked' === t ? 'block' : 'none' }), @@ -9278,54 +9378,54 @@ this.$blocked.css({ opacity: 'blocked' === t ? 1 : 0 }), this.$found.css({ opacity: 'found' === t ? 1 : 0 })) }) - var Rn = { + var Un = { noAccess: 'Accessibility cookie is not set. {{retrieve-cookie}}', hasAccess: 'Cookies are disabled or the accessibility cookie is not set. {{enable-cookies}}', }, - Fn = 'Accessibility cookie is set. For help, please email {{support}}', - Pn = 'support@hcaptcha.com' - function Dn() { - Jt.self(this, Yt, 'status') + jn = 'Accessibility cookie is set. For help, please email {{support}}', + Nn = 'support@hcaptcha.com' + function zn() { + ie.self(this, ne, 'status') var t = this ;(this.state = { hasCookie: !1, hasAccess: !1, allowedAccess: !1 }), (this.$header = this.createElement('.header')), (this.$header.copy = this.$header.createElement('.text')), this.$header.setAttribute('aria-hidden', !0), - (this.icon = this.initComponent(Vn, null, this.$header)), - (this.retrieve = this.initComponent(fn, { - text: Rn.noAccess, + (this.icon = this.initComponent($n, null, this.$header)), + (this.retrieve = this.initComponent(wn, { + text: Un.noAccess, link: !0, linkText: 'Retrieve accessibility cookie.', linkUnderline: !0, linkTo: 'https://dashboard.hcaptcha.com/signup?type=accessibility', replaceText: 'retrieve-cookie', })), - (this.disabled = this.initComponent(fn, { - text: Rn.hasAccess, + (this.disabled = this.initComponent(wn, { + text: Un.hasAccess, link: !0, linkText: 'Enable cross-site cookies.', linkUnderline: !0, replaceText: 'enable-cookies', })), - (this.help = this.initComponent(fn, { - text: Fn, + (this.help = this.initComponent(wn, { + text: jn, link: !0, - linkText: Pn, + linkText: Nn, linkUnderline: !0, - linkTo: 'mailto:' + Pn, + linkTo: 'mailto:' + Nn, replaceText: 'support', })), (this.retrieve.dom.id = 'status-retrieve'), (this.disabled.dom.id = 'status-disabled'), (this.help.dom.id = 'status-help'), this.disabled.on('click', function () { - kt.requestAccess().then(function () { + Bt.requestAccess().then(function () { t.setType() }) }) } - Jt.proto(Dn, Yt), - (Dn.prototype.style = function (t) { + ie.proto(zn, ne), + (zn.prototype.style = function (t) { this.css({ fontSize: t, color: '#555555' }), this.$header.css({ fontWeight: 600, marginBottom: 5 }), this.$header.copy.css({ display: 'inline', position: 'relative' }), @@ -9343,20 +9443,20 @@ var n = !this.state.hasCookie && this.state.hasAccess && !this.state.allowedAccess this.disabled.css({ display: n ? 'block' : 'none' }) }), - (Dn.prototype.checkAccess = function () { + (zn.prototype.checkAccess = function () { var t = this - ri.contact('get-ac').then(function (e) { + fi.contact('get-ac').then(function (e) { ;(t.state.hasCookie = !!e), - kt.supportsAPI() + Bt.supportsAPI() ? ((t.state.hasAccess = !0), - kt.hasAccess().then(function (e) { + Bt.hasAccess().then(function (e) { ;(t.state.allowedAccess = e), t.setType() })) : ((t.state.hasAccess = !1), t.setType()) }) }), - (Dn.prototype.setType = function () { - this.$header.copy.text(se.translate('Status:')) + (zn.prototype.setType = function () { + this.$header.copy.text(ue.translate('Status:')) var t = this.state.hasCookie this.help.css({ display: t ? 'block' : 'none' }) var e = @@ -9368,57 +9468,57 @@ var n = this.state.hasCookie ? 'found' : this.state.hasAccess ? 'blocked' : 'none' this.icon.display(n) }), - (Dn.prototype.translate = function () { - this.$header.copy.text(se.translate('Status:')), + (zn.prototype.translate = function () { + this.$header.copy.text(ue.translate('Status:')), this.retrieve.translate(), this.disabled.translate(), this.help.translate() }) - function In() { - Jt.self(this, Yt, 'accessibility') + function Zn() { + ie.self(this, ne, 'accessibility') var t = this - ;(this.copy = this.initComponent(fn, { + ;(this.copy = this.initComponent(wn, { text: 'To bypass our visual challenge, we offer an accessibility cookie.', link: !0, linkText: 'Learn more about hCaptcha Accessibility.', linkUnderline: !0, linkTo: 'https://hcaptcha.com/accessibility?ref=' + - ct.host + + ht.host + '&utm_campaign=' + - ct.sitekey + + ht.sitekey + '&utm_medium=challenge', })), this.copy.on('click', function (e) { - e.preventDefault(), li(t.copy.state.linkTo) + e.preventDefault(), pi(t.copy.state.linkTo) }), - (this.status = this.initComponent(Dn)), + (this.status = this.initComponent(zn)), this.status.checkAccess() } - function $n() { - Jt.self(this, Yt, 'challenge-modal'), + function Wn() { + ie.self(this, ne, 'challenge-modal'), (this.modalContent = null), (this.state = { visible: !1, curr: null, prev: null }), (this.config = { width: 0, height: 0, mobile: !1 }), (this.display = this.display.bind(this)), (this.close = this.close.bind(this)), (this.$container = this.createElement('.container')), - (this.modal = this.initComponent(pn, null, this.$container)), + (this.modal = this.initComponent(bn, null, this.$container)), this.modal.on('close', this.close), (this.$bg = this.createElement('.modal-bg')), this.$bg.addEventListener('click', this.close) var t = 'ie' === tt.Browser.type && 8 === tt.Browser.version this.css({ visibility: 'hidden', display: t ? 'none' : 'table', zIndex: -1 }) } - function jn() { - Jt.self(this, Yt, null, '.challenge-container'), + function qn() { + ie.self(this, ne, null, '.challenge-container'), (this.handleResize = null), (this.handleCheck = null), (this.handleFocus = null), (this.handleSubmit = null) } - function Nn() { - Jt.self(this, Yt, 'display-error'), + function Kn() { + ie.self(this, ne, 'display-error'), (this.visible = !1), this.setAttribute('aria-hidden', !0), this.setAttribute('role', 'alert'), @@ -9427,41 +9527,41 @@ this.setCopy.call(this), this.css({ opacity: 0 }) } - function zn() { - Jt.self(this, Yt, 'Crumb'), (this.$bg = this.createElement('.crumb-bg')) + function Yn() { + ie.self(this, ne, 'Crumb'), (this.$bg = this.createElement('.crumb-bg')) } - function Zn() { - Jt.self(this, Yt, 'challenge-breadcrumbs'), + function Gn() { + ie.self(this, ne, 'challenge-breadcrumbs'), (this.width = 0), (this.size = 0), (this.crumbs = []), (this.$wrapper = this.createElement('.crumbs-wrapper')) } - Jt.proto(In, Yt), - (In.prototype.style = function (t) { - var e = Math.floor(Mt(t, 250, 275, 12, 14)) + ie.proto(Zn, ne), + (Zn.prototype.style = function (t) { + var e = Math.floor(Dt(t, 250, 275, 12, 14)) this.copy.style(e, 'left'), this.copy.css({ position: 'relative', display: 'inline' }), this.status.style(e), this.status.css({ marginTop: 10 }) }), - (In.prototype.setCopy = function () { + (Zn.prototype.setCopy = function () { this.copy.translate(), this.status.translate() }), - Jt.proto($n, Yt), - ($n.prototype.load = function () { + ie.proto(Wn, ne), + (Wn.prototype.load = function () { this.modal.load() }), - ($n.prototype.style = function (t, e, i) { - var n = Mt(t, 300, 450, 290, 375), - o = Mt(e, 275, 300, 260, 275), - s = n - 2 * Mt(t, 300, 450, 20, 25), - r = 'ie' === tt.Browser.type && 8 === tt.Browser.version + (Wn.prototype.style = function (t, e, i) { + var n = Dt(t, 300, 450, 290, 375), + o = Dt(e, 275, 300, 260, 275), + r = n - 2 * Dt(t, 300, 450, 20, 25), + s = 'ie' === tt.Browser.type && 8 === tt.Browser.version this.css({ position: 'absolute', width: '100%', height: '100%', - display: r && !this.state.visible ? 'none' : 'table', + display: s && !this.state.visible ? 'none' : 'table', top: 0, left: 0, }), @@ -9477,17 +9577,17 @@ zindex: 0, cursor: 'pointer', }), - (this.config.width = s), + (this.config.width = r), (this.config.height = o), (this.config.mobile = i), this._styleContent() }), - ($n.prototype._styleContent = function () { + (Wn.prototype._styleContent = function () { this.modal.style(this.config.width, this.config.height), this.modalContent && this.modalContent.style(this.config.width, this.config.height, this.config.mobile) }), - ($n.prototype.close = function () { + (Wn.prototype.close = function () { if (this.state.visible) { ;(this.state.visible = !1), this.modalContent && @@ -9501,7 +9601,7 @@ this.emit('close') } }), - ($n.prototype.display = function (t, e) { + (Wn.prototype.display = function (t, e) { var i = this, n = null e || (e = {}), @@ -9510,21 +9610,21 @@ (this.state.curr = t) var o = null 'info' === t - ? ((n = gn), (o = 'Information')) + ? ((n = Cn), (o = 'Information')) : 'link' === t - ? ((n = wn), (o = 'Confirm Navigation')) + ? ((n = An), (o = 'Confirm Navigation')) : 'feedback' === t - ? ((n = Ln), (o = 'Feedback'), (e.type = 'feedback')) + ? ((n = Rn), (o = 'Feedback'), (e.type = 'feedback')) : 'report_bug' === t - ? ((n = Ln), (o = 'Software Bug'), (e.type = 'bug')) + ? ((n = Rn), (o = 'Software Bug'), (e.type = 'bug')) : 'report_image' === t - ? ((n = Ln), (o = 'Tell Us Why'), (e.type = 'image')) + ? ((n = Rn), (o = 'Tell Us Why'), (e.type = 'image')) : t.indexOf('thanks') >= 0 - ? (n = Tn) - : t.indexOf('accessibility') >= 0 && ((n = In), (o = 'Accessibility')), + ? (n = Dn) + : t.indexOf('accessibility') >= 0 && ((n = Zn), (o = 'Accessibility')), this.state.visible && (this.modal.destroy(), - (this.modal = this.initComponent(pn, null, this.$container)), + (this.modal = this.initComponent(bn, null, this.$container)), this.modal.load(), this.modal.on('close', this.close)), (this.modalContent = this.initComponent(n, e, this.modal.$content)), @@ -9541,14 +9641,14 @@ (this.state.visible = !0), this.emit('open') }), - ($n.prototype.isOpen = function () { + (Wn.prototype.isOpen = function () { return this.state.visible }), - Jt.proto(jn, Yt), - (jn.prototype.style = function (t, e) { + ie.proto(qn, ne), + (qn.prototype.style = function (t, e) { this.css({ width: t, height: e, position: 'relative', zIndex: 0 }) }), - (jn.prototype.mount = function (t) { + (qn.prototype.mount = function (t) { var e = this this.appendElement(t), (this.handleResize = function () { @@ -9558,7 +9658,7 @@ var n = 'skip' i ? (n = t.breadcrumbs && t.served < t.breadcrumbs ? 'next' : 'check') - : 'landscape' === ct.orientation && + : 'landscape' === ht.orientation && t.breadcrumbs && t.served === t.breadcrumbs && (n = 'check'), @@ -9576,7 +9676,7 @@ t.on && t.on('submit', this.handleSubmit), (this.isMounted = !0) }), - (jn.prototype.unmount = function (t) { + (qn.prototype.unmount = function (t) { if (t.destroy) { try { t.off && t.off('display-check', this.handleCheck), @@ -9584,14 +9684,14 @@ t.off && t.off('focus-check', this.handleFocus), t.off && t.off('submit', this.handleSubmit), t.destroy() - } catch (Fs) {} + } catch (Qr) {} } else this.removeElement(t) return (this.isMounted = !1), null }), - Jt.proto(Nn, Yt), - (Nn.prototype.style = function (t) { - var e = _i.get().palette, - i = 'landscape' === ct.orientation && 'image_label_binary' === ct.challenge_type + ie.proto(Kn, ne), + (Kn.prototype.style = function (t) { + var e = Ti.get().palette, + i = 'landscape' === ht.orientation && 'image_label_binary' === ht.challenge_type this.copy.css({ display: 'table-cell', verticalAlign: 'middle' }), this.css({ display: 'table', @@ -9601,103 +9701,103 @@ textAlign: i ? 'left' : 'right', }) }), - (Nn.prototype.display = function (t) { + (Kn.prototype.display = function (t) { this.css({ opacity: t ? 1 : 0 }), (this.visible = t), this.setAttribute('aria-hidden', !t) }), - (Nn.prototype.setCopy = function () { - var t = se.translate('Please try again.') + (Kn.prototype.setCopy = function () { + var t = ue.translate('Please try again.') this.copy.text(t + ' ⚠️') }), - Jt.proto(zn, Yt), - (zn.prototype.style = function (t) { + ie.proto(Yn, ne), + (Yn.prototype.style = function (t) { this.css({ width: t, height: t, overflow: 'hidden', borderRadius: '50%' }), this.$bg.css({ width: t, height: t }) }), - (zn.prototype.active = function (t) { + (Yn.prototype.active = function (t) { var e = (function (t) { var e = t.palette, i = t.component - return Ci.merge( + return Bi.merge( { main: { fill: e.grey[200] }, active: { fill: e.primary.main } }, i.breadcrumb, ) - })(_i.get()) + })(Ti.get()) this.$bg.css({ backgroundColor: t ? e.active.fill : e.main.fill }) }), - (zn.prototype.hide = function () { + (Yn.prototype.hide = function () { this.css({ opacity: 0 }) }), - Jt.proto(Zn, Yt), - (Zn.prototype.createCrumbs = function (t) { + ie.proto(Gn, ne), + (Gn.prototype.createCrumbs = function (t) { this.display = !0 for (var e = null, i = 0; i < t; i++) { - ;(e = this.initComponent(zn, null, this.$wrapper)), this.crumbs.push(e) + ;(e = this.initComponent(Yn, null, this.$wrapper)), this.crumbs.push(e) } }), - (Zn.prototype.removeCrumbs = function () { + (Gn.prototype.removeCrumbs = function () { if (((this.display = !1), 0 !== this.crumbs.length)) { for (var t = -1; ++t < this.crumbs.length; ) this.crumbs[t].destroy() this.crumbs = [] } }), - (Zn.prototype.style = function (t, e) { + (Gn.prototype.style = function (t, e) { for (var i = e ? 6 : 7, n = e ? 4 : 5, o = -1; ++o < this.crumbs.length; ) { this.crumbs[o].style(i), this.crumbs[o].css({ left: o * i + o * n, top: 0, position: 'absolute' }) } this.css({ width: t, height: i }) - var s = this.crumbs.length * i + n * (this.crumbs.length - 1) - this.$wrapper.css({ width: s, height: i, position: 'absolute', left: (t - s) / 2 }), + var r = this.crumbs.length * i + n * (this.crumbs.length - 1) + this.$wrapper.css({ width: r, height: i, position: 'absolute', left: (t - r) / 2 }), (this.size = i), (this.width = t), (this.mobile = e) }), - (Zn.prototype.setIndex = function (t) { + (Gn.prototype.setIndex = function (t) { for (var e = -1; ++e < this.crumbs.length; ) this.crumbs[e].active(t === e) }), - (Zn.prototype.hide = function () { + (Gn.prototype.hide = function () { for (var t = -1; ++t < this.crumbs.length; ) this.crumbs[t].hide() }) - function Un() { - Jt.self(this, Vi, { + function Jn() { + ie.self(this, $i, { selector: '#menu-info', title: 'Get information about hCaptcha and accessibility options.', label: 'Get information about hCaptcha and accessibility options.', name: 'info', src: "data:image/svg+xml,%3csvg width='25' height='25' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='12.5' cy='21.6' r='2' fill='%23787878'/%3e%3ccircle cx='12.5' cy='12.5' r='2' fill='%23787878'/%3e%3ccircle cx='12.5' cy='3.40002' r='2' fill='%23787878'/%3e%3c/svg%3e", - theme: _i, + theme: Ti, width: 35, height: 35, }), (this._ignoreHighlight = !1) } - Jt.proto(Un, Vi), - (Un.prototype.focus = function (t) { + ie.proto(Jn, $i), + (Jn.prototype.focus = function (t) { ;(this._ignoreHighlight = t), this.dom.focus() }), - (Un.prototype.onFocus = function (t) { + (Jn.prototype.onFocus = function (t) { if (this._ignoreHighlight) this._ignoreHighlight = !1 else { var e = this.state.style.focus.outline this.css({ outline: '2px solid ' + e }) } }) - function Wn() { - Jt.self(this, Vi, { + function Xn() { + ie.self(this, $i, { title: 'Refresh Challenge.', label: 'Refresh Challenge.', name: 'refresh', src: "data:image/svg+xml,%3csvg width='25' height='25' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M20.9148 19.6529C20.9994 19.7239 21.0106 19.8501 20.9381 19.9335C19.5234 21.5598 17.6702 22.7467 15.5981 23.3506C13.4619 23.9733 11.1891 23.9485 9.06708 23.2794C6.94502 22.6103 5.06902 21.327 3.67632 19.5917C2.28361 17.8564 1.43675 15.7471 1.24283 13.5306C1.0489 11.314 1.51662 9.08969 2.58684 7.13894C3.65706 5.18818 5.28171 3.5986 7.25535 2.57119C9.22898 1.54378 11.463 1.12469 13.6748 1.36692C15.8203 1.6019 17.8514 2.44889 19.527 3.80487C19.6129 3.87435 19.6238 4.00065 19.5528 4.08527L18.3637 5.50245C18.2927 5.58707 18.1666 5.5979 18.0805 5.5288C16.746 4.45867 15.1329 3.79007 13.4298 3.60355C11.6604 3.40977 9.87319 3.74503 8.29428 4.56696C6.71537 5.38889 5.41565 6.66056 4.55948 8.22116C3.7033 9.78176 3.32913 11.5612 3.48427 13.3345C3.63941 15.1077 4.3169 16.7952 5.43106 18.1834C6.54522 19.5716 8.04602 20.5982 9.74367 21.1335C11.4413 21.6688 13.2596 21.6886 14.9685 21.1905C16.6133 20.7111 18.0858 19.7725 19.2142 18.4869C19.287 18.4039 19.413 18.3927 19.4976 18.4637L20.9148 19.6529Z' fill='%23787878'/%3e%3cpath d='M22.7248 7.93974C22.7557 8.07007 22.6522 8.19336 22.5185 8.18555L14.9712 7.74462C14.807 7.73502 14.7239 7.54239 14.8297 7.4164L20.6321 0.501257C20.7379 0.375269 20.942 0.423631 20.98 0.583657L22.7248 7.93974Z' fill='%23787878'/%3e%3c/svg%3e", - theme: _i, + theme: Ti, width: 35, height: 35, selectable: !1, }) } - function Kn(t) { + function Qn(t) { var e = t.palette, i = t.component - return Ci.merge( + return Bi.merge( { main: { fill: e.primary.main, text: e.common.white, border: e.primary.main }, hover: { fill: e.primary.main, text: e.common.white, border: e.primary.main }, @@ -9706,10 +9806,10 @@ i.verifyButton, ) } - function qn(t) { + function to(t) { var e = t.palette, i = t.component - return Ci.merge( + return Bi.merge( { main: { fill: e.grey[700], text: e.common.white, border: e.grey[700] }, hover: { fill: e.grey[800], text: e.common.white, border: e.grey[800] }, @@ -9718,11 +9818,11 @@ i.skipButton, ) } - function Gn() { - Jt.self(this, Yt, 'button-submit'), + function eo() { + ie.self(this, ne, 'button-submit'), (this.state = { text: 'Check', type: 'check', label: 'Verify Answers', locked: !1 }), - (this._verifyStyle = Kn(_i.get())), - (this._skipStyle = qn(_i.get())), + (this._verifyStyle = Qn(Ti.get())), + (this._skipStyle = to(Ti.get())), (this.copy = this.createElement('.text')), this.addClass('button'), this.setAttribute('tabindex', 0), @@ -9739,44 +9839,44 @@ !1 === tt.System.mobile && (this.addEventListener('over', this.onHover), this.addEventListener('out', this.onHover)) } - function Jn() { - Jt.self(this, Yt, 'interface-challenge') + function io() { + ie.self(this, ne, 'interface-challenge') var t = this ;(this.state = { loaded: !1, action: null, locked: !1, visible: !1, whiteLabel: !1 }), - (this.text = this.initComponent(Nn)), - (this.breadcrumbs = this.initComponent(Zn)), - (this.submit = this.initComponent(Gn)), + (this.text = this.initComponent(Kn)), + (this.breadcrumbs = this.initComponent(Gn)), + (this.submit = this.initComponent(eo)), this.submit.on('click', function () { t.emit('submit') }) } - function Yn(t) { - Jt.self(this, Ri, { selector: 'display-language', theme: _i, width: 26, height: 16 }) + function no(t) { + ie.self(this, Ui, { selector: 'display-language', theme: Ti, width: 26, height: 16 }) var e = this ;(this._theme = t.theme), this.on('style', function () { e.css({ display: 'block' }) }) } - function Xn() { - Jt.self(this, Yt, 'language-selector') + function oo() { + ie.self(this, ne, 'language-selector') var t = this this.state = { locked: !1 } var e = tt.System.mobile - ;(this.list = this.initComponent(e ? ji : en, { - theme: _i, + ;(this.list = this.initComponent(e ? qi : cn, { + theme: Ti, selector: '#language-list', optionsVisible: 5, })), - (this.display = this.initComponent(Yn, { theme: _i })), + (this.display = this.initComponent(no, { theme: Ti })), this.display.ownsListBox(this.list) var i = [] - for (var n in ie) i.push({ value: n, text: ie[n] }) + for (var n in ce) i.push({ value: n, text: ce[n] }) this.list.setOptions(i), this.list.on('select', function (e) { t.display.setLocale(e.value), - e.value !== se.getLocale() && - (se.setLocale(e.value), ri.send('challenge-language', { locale: e.value })) + e.value !== ue.getLocale() && + (ue.setLocale(e.value), fi.send('challenge-language', { locale: e.value })) }), e || this.display.on('click', function (e) { @@ -9788,12 +9888,12 @@ this.style(), this.updateLocale() } - Jt.proto(Wn, Vi), - Jt.proto(Gn, Yt), - (Gn.prototype.style = function (t) { + ie.proto(Xn, $i), + ie.proto(eo, ne), + (eo.prototype.style = function (t) { var e = t ? 30 : 35, i = 'check' === this.state.type || 'next' === this.state.type - ;(this._verifyStyle = Kn(_i.get())), (this._skipStyle = qn(_i.get())) + ;(this._verifyStyle = Qn(Ti.get())), (this._skipStyle = to(Ti.get())) var n = (function (t) { try { var e = t.palette @@ -9802,10 +9902,10 @@ : e.common && e.common.white ? e.common.white : '#FFF' - } catch (Fs) { + } catch (Qr) { return '#FFF' } - })(_i.get()) + })(Ti.get()) this.css({ height: e, cursor: 'pointer', @@ -9830,7 +9930,7 @@ }), (this.height = e) }), - (Gn.prototype.action = function (t) { + (eo.prototype.action = function (t) { var e, i = t.charAt(0).toUpperCase() + t.slice(1), n = @@ -9850,7 +9950,7 @@ this.css({ backgroundColor: n }), this.setLabel.call(this) }), - (Gn.prototype.onHover = function (t) { + (eo.prototype.onHover = function (t) { if (null !== this.emit && !0 !== this.state.locked) { var e = 'over' === t.action, i = @@ -9861,18 +9961,18 @@ this.css({ backgroundColor: i[n].fill }) } }), - (Gn.prototype.onSelect = function (t) { + (eo.prototype.onSelect = function (t) { null !== this.emit && !0 !== this.state.locked && this.emit('click', t) }), - (Gn.prototype.onFocus = function (t) { + (eo.prototype.onFocus = function (t) { var e = 'check' === this.state.type ? '_verifyStyle' : '_skipStyle', i = this[e].focus.border || this[e].focus.outline this.css({ outline: '2px solid ' + i }) }), - (Gn.prototype.onBlur = function (t) { + (eo.prototype.onBlur = function (t) { this.css({ outline: 'none' }) }), - (Gn.prototype.setLock = function (t) { + (eo.prototype.setLock = function (t) { this.state.locked = t var e = 'check' === this.state.type || 'next' === this.state.type @@ -9880,30 +9980,30 @@ : this._skipStyle this.css({ cursor: t ? 'default' : 'pointer', backgroundColor: e.main.fill }) }), - (Gn.prototype.setLabel = function () { - var t = se.translate(this.state.text), - e = se.translate(this.state.label) - se.getLocale().indexOf('en') >= 0 && 'check' === this.state.type && (t = 'Verify'), + (eo.prototype.setLabel = function () { + var t = ue.translate(this.state.text), + e = ue.translate(this.state.label) + ue.getLocale().indexOf('en') >= 0 && 'check' === this.state.type && (t = 'Verify'), this.copy.text(t), this.setAttribute('title', e), this.setAttribute('aria-label', e) }), - (Gn.prototype.getElement = function () { + (eo.prototype.getElement = function () { return (this && this.dom) || null }), - Jt.proto(Jn, Yt), - (Jn.prototype.removeCrumbs = function () { + ie.proto(io, ne), + (io.prototype.removeCrumbs = function () { this.breadcrumbs.removeCrumbs() }), - (Jn.prototype.style = function (t, e, i) { - var n = 'landscape' === ct.orientation && 'image_label_binary' === ct.challenge_type, + (io.prototype.style = function (t, e, i) { + var n = 'landscape' === ht.orientation && 'image_label_binary' === ht.challenge_type, o = n ? e : 16 this.breadcrumbs.display && (this.breadcrumbs.style(t, i), this.breadcrumbs.css({ position: 'absolute', top: (o - this.breadcrumbs.size) / 2 })) - var s = i ? 11 : 12 + var r = i ? 11 : 12 return ( - this.text.style(s), + this.text.style(r), this.text.css({ position: 'absolute', height: o, @@ -9918,38 +10018,38 @@ { width: t, height: e } ) }), - (Jn.prototype.setAction = function (t) { + (io.prototype.setAction = function (t) { ;(this.state.action = t), this.submit.action(t) }), - (Jn.prototype.getAction = function () { + (io.prototype.getAction = function () { return this.state.action }), - (Jn.prototype.displayTryAgain = function (t) { + (io.prototype.displayTryAgain = function (t) { this.text.display(t) }), - (Jn.prototype.setWhiteLabelEnabled = function (t) { + (io.prototype.setWhiteLabelEnabled = function (t) { this.state.whiteLabel = t }), - (Jn.prototype.translate = function () { + (io.prototype.translate = function () { this.text.setCopy(), this.submit.setLabel() }), - (Jn.prototype.setLock = function (t) { + (io.prototype.setLock = function (t) { ;(this.state.locked = t), this.submit.setLock(t) }), - (Jn.prototype.isLocked = function () { + (io.prototype.isLocked = function () { return this.state.locked }), - Jt.proto(Yn, Ri), - (Yn.prototype.setLocale = function (t) { - this.setText(se.getShortLocale(t).toUpperCase()) + ie.proto(no, Ui), + (no.prototype.setLocale = function (t) { + this.setText(ue.getShortLocale(t).toUpperCase()) }), - (Yn.prototype.style = function () { + (no.prototype.style = function () { var t = (function (t) { var e = t.palette, i = t.component - return Ci.merge({ focus: { outline: e.primary.main } }, i.button) + return Bi.merge({ focus: { outline: e.primary.main } }, i.button) })(this._theme.get()), - e = 'landscape' === ct.orientation && 'image_label_binary' === ct.challenge_type, + e = 'landscape' === ht.orientation && 'image_label_binary' === ht.challenge_type, i = e ? 14 : 11, n = e ? 35 : 26, o = e ? 35 : 16 @@ -9968,9 +10068,9 @@ }), this.$text.css({ display: 'table-cell', verticalAlign: 'middle' }) }), - Jt.proto(Xn, Yt), - (Xn.prototype.style = function (t) { - var e = 'landscape' === ct.orientation && 'image_label_binary' === ct.challenge_type + ie.proto(oo, ne), + (oo.prototype.style = function (t) { + var e = 'landscape' === ht.orientation && 'image_label_binary' === ht.challenge_type this.display.style(), this.css({ position: 'relative', @@ -9982,34 +10082,34 @@ this.list.style(), this.list.css({ bottom: e ? -128 : 30, left: e ? 45 : 'auto' }) }), - (Xn.prototype.getDimensions = function () { + (oo.prototype.getDimensions = function () { return { width: this.display.getWidth(), height: this.display.getHeight() } }), - (Xn.prototype.setLabel = function () { + (oo.prototype.setLabel = function () { var t = this.list.getSelected().text, - e = se.translate('Select a language {{language}}', { language: t }) - this.display.setLabel(e), this.display.setTitle(se.translate('Language')) + e = ue.translate('Select a language {{language}}', { language: t }) + this.display.setLabel(e), this.display.setTitle(ue.translate('Language')) }), - (Xn.prototype.updateLocale = function () { - this.list.select(se.getLocale()) + (oo.prototype.updateLocale = function () { + this.list.select(ue.getLocale()) }), - (Xn.prototype.setVisible = function (t) { + (oo.prototype.setVisible = function (t) { this.css({ display: t ? 'block' : 'none ' }) }), - (Xn.prototype.setLock = function (t) { + (oo.prototype.setLock = function (t) { ;(this.state.locked = t), t ? this.list.setAttribute('disabled', t) : this.list.removeAttribute('disabled') }) - function Qn(t) { - Jt.self(this, Yt, 'hcaptcha-logo'), (this.mobile = !1), (this.charity = t) + function ro(t) { + ie.self(this, ne, 'hcaptcha-logo'), (this.mobile = !1), (this.charity = t) var e = this.charity ? "data:image/svg+xml,%3csvg id='logo_charity' role='img' aria-hidden='true' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 500 500'%3e%3crect x='306.25' y='418.75' width='56.25' height='56.25' style='fill:%230074bf%3bopacity:0.5%3bisolation:isolate'/%3e%3crect x='250' y='418.75' width='56.25' height='56.25' style='fill:%230074bf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='193.75' y='418.75' width='56.25' height='56.25' style='fill:%230074bf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='137.5' y='418.75' width='56.25' height='56.25' style='fill:%230074bf%3bopacity:0.5%3bisolation:isolate'/%3e%3crect x='362.5' y='362.5' width='56.25' height='56.25' style='fill:%230082bf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='306.25' y='362.5' width='56.25' height='56.25' style='fill:%230082bf%3bopacity:0.800000011920929%3bisolation:isolate'/%3e%3crect x='250' y='362.5' width='56.25' height='56.25' style='fill:%230082bf'/%3e%3crect x='193.75' y='362.5' width='56.25' height='56.25' style='fill:%230082bf'/%3e%3crect x='137.5' y='362.5' width='56.25' height='56.25' style='fill:%230082bf%3bopacity:0.800000011920929%3bisolation:isolate'/%3e%3crect x='81.25' y='362.5' width='56.25' height='56.25' style='fill:%230082bf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='418.75' y='306.25' width='56.25' height='56.25' style='fill:%23008fbf%3bopacity:0.5%3bisolation:isolate'/%3e%3crect x='362.5' y='306.25' width='56.25' height='56.25' style='fill:%23008fbf%3bopacity:0.800000011920929%3bisolation:isolate'/%3e%3crect x='306.25' y='306.25' width='56.25' height='56.25' style='fill:%23008fbf'/%3e%3crect x='250' y='306.25' width='56.25' height='56.25' style='fill:%23008fbf'/%3e%3crect x='193.75' y='306.25' width='56.25' height='56.25' style='fill:%23008fbf'/%3e%3crect x='137.5' y='306.25' width='56.25' height='56.25' style='fill:%23008fbf'/%3e%3crect x='81.25' y='306.25' width='56.25' height='56.25' style='fill:%23008fbf%3bopacity:0.800000011920929%3bisolation:isolate'/%3e%3crect x='25' y='306.25' width='56.25' height='56.25' style='fill:%23008fbf%3bopacity:0.5%3bisolation:isolate'/%3e%3crect x='418.75' y='250' width='56.25' height='56.25' style='fill:%23009dbf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='362.5' y='250' width='56.25' height='56.25' style='fill:%23009dbf'/%3e%3crect x='306.25' y='250' width='56.25' height='56.25' style='fill:%23009dbf'/%3e%3crect x='250' y='250' width='56.25' height='56.25' style='fill:%23009dbf'/%3e%3crect x='193.75' y='250' width='56.25' height='56.25' style='fill:%23009dbf'/%3e%3crect x='137.5' y='250' width='56.25' height='56.25' style='fill:%23009dbf'/%3e%3crect x='81.25' y='250' width='56.25' height='56.25' style='fill:%23009dbf'/%3e%3crect x='25' y='250' width='56.25' height='56.25' style='fill:%23009dbf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='418.75' y='193.75' width='56.25' height='56.25' style='fill:%2300abbf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='362.5' y='193.75' width='56.25' height='56.25' style='fill:%2300abbf'/%3e%3crect x='306.25' y='193.75' width='56.25' height='56.25' style='fill:%2300abbf'/%3e%3crect x='250' y='193.75' width='56.25' height='56.25' style='fill:%2300abbf'/%3e%3crect x='193.75' y='193.75' width='56.25' height='56.25' style='fill:%2300abbf'/%3e%3crect x='137.5' y='193.75' width='56.25' height='56.25' style='fill:%2300abbf'/%3e%3crect x='81.25' y='193.75' width='56.25' height='56.25' style='fill:%2300abbf'/%3e%3crect x='25' y='193.75' width='56.25' height='56.25' style='fill:%2300abbf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='418.75' y='137.5' width='56.25' height='56.25' style='fill:%2300b9bf%3bopacity:0.5%3bisolation:isolate'/%3e%3crect x='362.5' y='137.5' width='56.25' height='56.25' style='fill:%2300b9bf%3bopacity:0.800000011920929%3bisolation:isolate'/%3e%3crect x='306.25' y='137.5' width='56.25' height='56.25' style='fill:%2300b9bf'/%3e%3crect x='250' y='137.5' width='56.25' height='56.25' style='fill:%2300b9bf'/%3e%3crect x='193.75' y='137.5' width='56.25' height='56.25' style='fill:%2300b9bf'/%3e%3crect x='137.5' y='137.5' width='56.25' height='56.25' style='fill:%2300b9bf'/%3e%3crect x='81.25' y='137.5' width='56.25' height='56.25' style='fill:%2300b9bf%3bopacity:0.800000011920929%3bisolation:isolate'/%3e%3crect x='25' y='137.5' width='56.25' height='56.25' style='fill:%2300b9bf%3bopacity:0.5%3bisolation:isolate'/%3e%3crect x='362.5' y='81.25' width='56.25' height='56.25' style='fill:%2300c6bf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='306.25' y='81.25' width='56.25' height='56.25' style='fill:%2300c6bf%3bopacity:0.800000011920929%3bisolation:isolate'/%3e%3crect x='250' y='81.25' width='56.25' height='56.25' style='fill:%2300c6bf'/%3e%3crect x='193.75' y='81.25' width='56.25' height='56.25' style='fill:%2300c6bf'/%3e%3crect x='137.5' y='81.25' width='56.25' height='56.25' style='fill:%2300c6bf%3bopacity:0.800000011920929%3bisolation:isolate'/%3e%3crect x='81.25' y='81.25' width='56.25' height='56.25' style='fill:%2300c6bf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='306.25' y='25' width='56.25' height='56.25' style='fill:%2300d4bf%3bopacity:0.5%3bisolation:isolate'/%3e%3crect x='250' y='25' width='56.25' height='56.25' style='fill:%2300d4bf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='193.75' y='25' width='56.25' height='56.25' style='fill:%2300d4bf%3bopacity:0.699999988079071%3bisolation:isolate'/%3e%3crect x='137.5' y='25' width='56.25' height='56.25' style='fill:%2300d4bf%3bopacity:0.5%3bisolation:isolate'/%3e%3cpath d='M190.87%2c158.6c36.33%2c0%2c46.52%2c26.05%2c59.6%2c34.41%2c12.11-8.36%2c22.29-34.41%2c59.59-34.41%2c36.34%2c0%2c65.18%2c29.8%2c66%2c67%2c2.78%2c54-90.26%2c135.93-125.63%2c159.19-36.34-23.26-128.42-105.16-126.6-159.19C125.69%2c188.4%2c153.56%2c158.6%2c190.87%2c158.6Z' style='fill:white'/%3e%3c/svg%3e" : "data:image/svg+xml,%3csvg width='32' height='32' viewBox='0 0 32 32' role='img' aria-hidden='true' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath opacity='0.5' d='M24 28H20V32H24V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M20 28H16V32H20V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M16 28H12V32H16V28Z' fill='%230074BF'/%3e%3cpath opacity='0.5' d='M12 28H8V32H12V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M28 24H24V28H28V24Z' fill='%230082BF'/%3e%3cpath opacity='0.8' d='M24 24H20V28H24V24Z' fill='%230082BF'/%3e%3cpath d='M20 24H16V28H20V24Z' fill='%230082BF'/%3e%3cpath d='M16 24H12V28H16V24Z' fill='%230082BF'/%3e%3cpath opacity='0.8' d='M12 24H8V28H12V24Z' fill='%230082BF'/%3e%3cpath opacity='0.7' d='M8 24H4V28H8V24Z' fill='%230082BF'/%3e%3cpath opacity='0.5' d='M32 20H28V24H32V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.8' d='M28 20H24V24H28V20Z' fill='%23008FBF'/%3e%3cpath d='M24 20H20V24H24V20Z' fill='%23008FBF'/%3e%3cpath d='M20 20H16V24H20V20Z' fill='%23008FBF'/%3e%3cpath d='M16 20H12V24H16V20Z' fill='%23008FBF'/%3e%3cpath d='M12 20H8V24H12V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.8' d='M8 20H4V24H8V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.5' d='M4 20H0V24H4V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.7' d='M32 16H28V20H32V16Z' fill='%23009DBF'/%3e%3cpath d='M28 16H24V20H28V16Z' fill='%23009DBF'/%3e%3cpath d='M24 16H20V20H24V16Z' fill='%23009DBF'/%3e%3cpath d='M20 16H16V20H20V16Z' fill='%23009DBF'/%3e%3cpath d='M16 16H12V20H16V16Z' fill='%23009DBF'/%3e%3cpath d='M12 16H8V20H12V16Z' fill='%23009DBF'/%3e%3cpath d='M8 16H4V20H8V16Z' fill='%23009DBF'/%3e%3cpath opacity='0.7' d='M4 16H0V20H4V16Z' fill='%23009DBF'/%3e%3cpath opacity='0.7' d='M32 12H28V16H32V12Z' fill='%2300ABBF'/%3e%3cpath d='M28 12H24V16H28V12Z' fill='%2300ABBF'/%3e%3cpath d='M24 12H20V16H24V12Z' fill='%2300ABBF'/%3e%3cpath d='M20 12H16V16H20V12Z' fill='%2300ABBF'/%3e%3cpath d='M16 12H12V16H16V12Z' fill='%2300ABBF'/%3e%3cpath d='M12 12H8V16H12V12Z' fill='%2300ABBF'/%3e%3cpath d='M8 12H4V16H8V12Z' fill='%2300ABBF'/%3e%3cpath opacity='0.7' d='M4 12H0V16H4V12Z' fill='%2300ABBF'/%3e%3cpath opacity='0.5' d='M32 8H28V12H32V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.8' d='M28 8H24V12H28V8Z' fill='%2300B9BF'/%3e%3cpath d='M24 8H20V12H24V8Z' fill='%2300B9BF'/%3e%3cpath d='M20 8H16V12H20V8Z' fill='%2300B9BF'/%3e%3cpath d='M16 8H12V12H16V8Z' fill='%2300B9BF'/%3e%3cpath d='M12 8H8V12H12V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.8' d='M8 8H4V12H8V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.5' d='M4 8H0V12H4V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.7' d='M28 4H24V8H28V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.8' d='M24 4H20V8H24V4Z' fill='%2300C6BF'/%3e%3cpath d='M20 4H16V8H20V4Z' fill='%2300C6BF'/%3e%3cpath d='M16 4H12V8H16V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.8' d='M12 4H8V8H12V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.7' d='M8 4H4V8H8V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.5' d='M24 0H20V4H24V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.7' d='M20 0H16V4H20V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.7' d='M16 0H12V4H16V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.5' d='M12 0H8V4H12V0Z' fill='%2300D4BF'/%3e%3cpath d='M10.5141 14.9697L11.6379 12.4572C12.0459 11.8129 11.9958 11.0255 11.5449 10.5745C11.4876 10.5173 11.416 10.46 11.3444 10.4171C11.0366 10.2238 10.6572 10.1808 10.3065 10.2954C9.91993 10.4171 9.58349 10.6748 9.36875 11.0184C9.36875 11.0184 7.82972 14.6046 7.26421 16.2153C6.69871 17.8259 6.92062 20.7822 9.12536 22.987C11.4661 25.3277 14.8448 25.8575 17.0066 24.2397C17.0997 24.1967 17.1784 24.1395 17.2572 24.0751L23.9072 18.5202C24.2293 18.2554 24.7089 17.7042 24.2794 17.0743C23.8642 16.4586 23.0697 16.881 22.7404 17.0886L18.9107 19.8731C18.8391 19.9304 18.7318 19.9232 18.6673 19.8517C18.6673 19.8517 18.6673 19.8445 18.6602 19.8445C18.56 19.7228 18.5456 19.4079 18.696 19.2862L24.5657 14.304C25.074 13.8459 25.1456 13.1802 24.7304 12.7292C24.3295 12.2854 23.6924 12.2997 23.1842 12.7578L17.9157 16.881C17.8155 16.9597 17.6652 16.9454 17.5864 16.8452L17.5793 16.838C17.4719 16.7235 17.4361 16.5231 17.5506 16.4014L23.535 10.596C24.0074 10.1522 24.036 9.4149 23.5922 8.94245C23.3775 8.72054 23.084 8.59169 22.7762 8.59169C22.4612 8.59169 22.1606 8.70623 21.9387 8.92813L15.8255 14.6691C15.6823 14.8122 15.396 14.6691 15.3602 14.4973C15.3459 14.4328 15.3674 14.3684 15.4103 14.3255L20.0918 8.99972C20.5571 8.56306 20.5858 7.83292 20.1491 7.36763C19.7124 6.90234 18.9823 6.87371 18.517 7.31036C18.4955 7.32468 18.4812 7.34615 18.4597 7.36763L11.3659 15.2203C11.1082 15.478 10.736 15.4851 10.557 15.342C10.4425 15.2489 10.4282 15.0843 10.5141 14.9697Z' fill='white'/%3e%3c/svg%3e", i = - 'https://newassets.hcaptcha.com/captcha/v1/1bcdbdd/static/images' + + 'https://newassets.hcaptcha.com/captcha/v1/a8cd801/static/images' + (this.charity ? '/icon-charity' : '/icon') + '.png' - this.color = this.initComponent(Bi, { + this.color = this.initComponent(Pi, { selector: '.logo', src: e, width: 32, @@ -10017,26 +10117,26 @@ autoLoad: !1, }) } - function to(t) { - Jt.self(this, Yt, 'hcaptcha-logo'), + function so(t) { + ie.self(this, ne, 'hcaptcha-logo'), t || (t = {}), (this.state = { label: 'hCaptcha' }), (this.mobile = !1), (this.link = 'https://www.hcaptcha.com/what-is-hcaptcha-about?ref=' + - ct.host + + ht.host + '&utm_campaign=' + - ct.sitekey + + ht.sitekey + '&utm_medium=challenge'), - (this.icon = this.initComponent(Qn, !!t.charity)), + (this.icon = this.initComponent(ro, !!t.charity)), (this.onClick = this.onClick.bind(this)), this.addEventListener('click', this.onClick) } - Jt.proto(Qn, Yt), - (Qn.prototype.load = function () { + ie.proto(ro, ne), + (ro.prototype.load = function () { this.color.load() }), - (Qn.prototype.style = function (t) { + (ro.prototype.style = function (t) { this.mobile = t var e = 32 return ( @@ -10053,11 +10153,11 @@ { width: e, height: e } ) }), - Jt.proto(to, Yt), - (to.prototype.load = function () { + ie.proto(so, ne), + (so.prototype.load = function () { this.icon.load() }), - (to.prototype.style = function (t, e) { + (so.prototype.style = function (t, e) { t !== undefined && (this.mobile = t) var i = this.icon.style(this.mobile) this.css({ @@ -10071,14 +10171,14 @@ }), (this.height = i.height) }), - (to.prototype.onClick = function () { - null !== this.fireEvent && li(this.link) + (so.prototype.onClick = function () { + null !== this.fireEvent && pi(this.link) }), - (to.prototype.setLabel = function () { + (so.prototype.setLabel = function () { var t = this.state.label - this.setAttribute('title', t), this.setAttribute('aria-label', t) + this.setAttribute('title', t) }) - var eo = [ + var ao = [ { text: 'Accessibility', value: 'accessibility', selector: '#accessibility', type: 'modal' }, { text: 'Report Image', @@ -10090,30 +10190,30 @@ { text: 'Report Bug', value: 'report_bug', selector: '#report_bug', type: 'modal' }, { text: 'Information', value: 'info', selector: '#info', type: 'modal' }, ] - function io() { - Jt.self(this, en, { isMenu: !0, theme: _i, selector: '#menu', optionsVisible: -1 }), + function co() { + ie.self(this, cn, { isMenu: !0, theme: Ti, selector: '#menu', optionsVisible: -1 }), (this.state.a11yChallenge = !1), (this.options = []), this.on('select', function (t) { t && ('link' === t.type - ? li(t.value) + ? pi(t.value) : 'modal' === t.type ? this.emit('display', t.value) : 'challenge' === t.type && - ('text_challenge' === t.value && ((ct.a11y_tfe = !0), this.emit('refresh')), - 'visual_challenge' === t.value && ((ct.a11y_tfe = !1), this.emit('refresh')))) + ('text_challenge' === t.value && ((ht.a11y_tfe = !0), this.emit('refresh')), + 'visual_challenge' === t.value && ((ht.a11y_tfe = !1), this.emit('refresh')))) }) } - function no() { - Jt.self(this, Yt, 'interface-user') + function lo() { + ie.self(this, ne, 'interface-user') var t = this ;(this.state = { isRq: !1, loaded: !1, locked: !1, visible: !1, whiteLabel: !1 }), - (this.language = this.initComponent(Xn)), - (this.menu = this.initComponent(Un)), - (this.menuList = this.initComponent(io)), - (this.refresh = this.initComponent(Wn)), - (this.logo = this.initComponent(to)), + (this.language = this.initComponent(oo)), + (this.menu = this.initComponent(Jn)), + (this.menuList = this.initComponent(co)), + (this.refresh = this.initComponent(Xn)), + (this.logo = this.initComponent(so)), this.menu.controlsMenu(this.menuList), this.menu.on('click', function (e) { t.menuList.usingKb(e.usingKb), t.menuList.visible(e.selected, t.state.isRq) @@ -10134,20 +10234,20 @@ t.emit('display', e) }) } - Jt.proto(io, en), - (io.prototype.setA11yChallenge = function (t) { + ie.proto(co, cn), + (co.prototype.setA11yChallenge = function (t) { this.state.a11yChallenge = t }), - (io.prototype._setOptions = function (t) { + (co.prototype._setOptions = function (t) { var e - for (this.options = [], e = 0; e < eo.length; e++) { - ;('report_image' === eo[e].value && t) || this.options.push(eo[e]) + for (this.options = [], e = 0; e < ao.length; e++) { + ;('report_image' === ao[e].value && t) || this.options.push(ao[e]) } this.state.a11yChallenge && this.options.splice( 1, 0, - ct.a11y_tfe + ht.a11y_tfe ? { text: 'Visual Challenge', value: 'visual_challenge', @@ -10163,42 +10263,42 @@ ), this.setOptions(this.options) }), - (io.prototype.visible = function (t, e) { + (co.prototype.visible = function (t, e) { t ? (this._setOptions(e), this.deselect(), this.open()) : this.hide() }), - Jt.proto(no, Yt), - (no.prototype.refresh = function () { + ie.proto(lo, ne), + (lo.prototype.refresh = function () { this.refresh.dom.click() }), - (no.prototype.load = function (t) { + (lo.prototype.load = function (t) { ;(this.state.isRq = t), this.state.loaded || (this.menu.load(), this.refresh.load(), this.logo.load()) }), - (no.prototype.setupLogo = function (t, e) { + (lo.prototype.setupLogo = function (t, e) { t && (this.logo.destroy(), - (this.logo = this.initComponent(to, { charity: t })), + (this.logo = this.initComponent(so, { charity: t })), this.logo.load()), (this.logo.link = e || this.logo.link) }), - (no.prototype.style = function (t, e, i) { - var n = 'landscape' === ct.orientation && 'image_label_binary' === ct.challenge_type, + (lo.prototype.style = function (t, e, i) { + var n = 'landscape' === ht.orientation && 'image_label_binary' === ht.challenge_type, o = !this.state.whiteLabel, - s = !this.state.whiteLabel + r = !this.state.whiteLabel if ( (this.language.style(i), this.refresh.style(i), this.menu.style(i, o), this.menuList.style(190), - this.logo.style(t < 400, s), + this.logo.style(t < 400, r), n) ) { - var r = this.language.getDimensions(), - a = (e - (this.refresh.getHeight() + 16 + r.height)) / 2 - this.language.css({ top: a, left: (t - r.width) / 2, position: 'absolute' }), + var s = this.language.getDimensions(), + a = (e - (this.refresh.getHeight() + 16 + s.height)) / 2 + this.language.css({ top: a, left: (t - s.width) / 2, position: 'absolute' }), this.refresh.css({ position: 'absolute', - top: a + 16 + r.height, + top: a + 16 + s.height, bottom: 'auto', left: o ? (t - this.refresh.getWidth()) / 2 : 0, zIndex: 100, @@ -10241,43 +10341,43 @@ } return this.css({ width: t, height: e }), { width: t, height: e } }), - (no.prototype.focus = function (t) { + (lo.prototype.focus = function (t) { 'menu' === t && this.menu.focus() }), - (no.prototype.displayLanguage = function (t) { + (lo.prototype.displayLanguage = function (t) { this.language.setVisible(t) }), - (no.prototype.setWhiteLabel = function (t) { + (lo.prototype.setWhiteLabel = function (t) { this.state.whiteLabel = t }), - (no.prototype.enableRefresh = function (t) { + (lo.prototype.enableRefresh = function (t) { this.refresh.enable(t) }), - (no.prototype.translate = function () { + (lo.prototype.translate = function () { this.language.updateLocale(), this.language.setLabel(), this.menu.setCopy(), this.refresh.setCopy(), this.logo.setLabel() }), - (no.prototype.setLock = function (t) { + (lo.prototype.setLock = function (t) { ;(this.state.locked = t), this.language.setLock(t), this.menu.setLock(t), this.refresh.setLock(t) }), - (no.prototype.isLocked = function () { + (lo.prototype.isLocked = function () { return this.state.locked }) - var oo = null - function so(t, e) { + var ho = null + function uo(t, e) { var i = this e || (e = {}), - (ct.host = e.host ? e.host : ''), - (ct.sitekey = e.sitekey ? e.sitekey : ''), - (ct.charity = !!e.charity), - (ct.orientation = e.orientation) - var n = new ii(), + (ht.host = e.host ? e.host : ''), + (ht.sitekey = e.sitekey ? e.sitekey : ''), + (ht.charity = !!e.charity), + (ht.orientation = e.orientation) + var n = new ci(), o = { visible: !1, create: !1, @@ -10288,94 +10388,94 @@ focus: 'challenge', interaction: 'mouse', } - t instanceof Gt || (t = new Gt(t)) - var s = new Gt('.interface-wrapper'), - r = new jn(), - a = new Jn(), - l = new no(), - c = new $n() + t instanceof ee || (t = new ee(t)) + var r = new ee('.interface-wrapper'), + s = new qn(), + a = new io(), + c = new lo(), + l = new Wn() return ( - t.appendElement(s), - s.appendElement(r), - s.appendElement(l), - s.appendElement(a), - s.appendElement(c), - l.on('display', c.display), + t.appendElement(r), + r.appendElement(s), + r.appendElement(c), + r.appendElement(a), + r.appendElement(l), + c.on('display', l.display), t.setAttribute('aria-hidden', !0), - (ai = c), - c.on('open', function () { + (di = l), + l.on('open', function () { o.preventClose = !0 }), - c.on('close', function () { - o.visible && l.menu.focus(), + l.on('close', function () { + o.visible && c.menu.focus(), i.hideReport(!1), o.preventClose && ((o.preventClose = !1), o.timerExpired && ((o.timerExpired = !1), n.emit('refresh'))) }), - r.on('action-changed', function (t) { + s.on('action-changed', function (t) { a.setAction(t) }), - r.on('submit', function () { + s.on('submit', function () { n.emit('submit') }), - r.on('focus-check', function () { + s.on('focus-check', function () { n.emit('focus-check') }), - r.on('resize', function () { + s.on('resize', function () { n.emit('resize') }), a.on('submit', function () { n.emit('submit') }), - l.on('refresh', function () { + c.on('refresh', function () { n.emit('refresh') }), - l.on('report', function () { + c.on('report', function () { n.emit('report') }), - c.on('report', function (t) { + l.on('report', function (t) { n.emit('report-submission', t) }), - s.addEventListener('keydown', function (t) { + r.addEventListener('keydown', function (t) { o.interaction = 'keyboard' }), - s.addEventListener('click', function (t) { + r.addEventListener('click', function (t) { o.interaction = 'mouse' }), (i.events = n), (i.addTheme = function (t, e) { - _i.add(t, e) + Ti.add(t, e) }), (i.useTheme = function (t) { - _i.use(t) + Ti.use(t) }), (i.size = function (t, e) { return i.style(t, e) }), (i.create = function (t) { - ;(o.create = !0), l.load(!!t.rq), l.displayLanguage(!t.rq), l.enableRefresh(!t.rq) + ;(o.create = !0), c.load(!!t.rq), c.displayLanguage(!t.rq), c.enableRefresh(!t.rq) }), (i.isMounted = function () { - return !!oo + return !!ho }), (i.init = function (t) { var e = t.charity && !0 === t.charity - l.setupLogo(e, t.link), t.a11yChallenge && l.menuList.setA11yChallenge(t.a11yChallenge) + c.setupLogo(e, t.link), t.a11yChallenge && c.menuList.setA11yChallenge(t.a11yChallenge) }), (i.setWhiteLabel = function (t) { - l.setWhiteLabel(t) + c.setWhiteLabel(t) }), (i.setup = function (t, e) { return new Promise(function (i, n) { try { - oo && oo.type !== e.request_type && (r.unmount(oo), (oo = null)), - oo || - ((ct.challenge_type = e.request_type), - (oo = new t({ theme: { name: _i.active(), config: _i.get() } })), - r.mount(oo)), + ho && ho.type !== e.request_type && (s.unmount(ho), (ho = null)), + ho || + ((ht.challenge_type = e.request_type), + (ho = new t({ theme: { name: Ti.active(), config: Ti.get() } })), + s.mount(ho)), a.removeCrumbs(), - oo - .setup(e, ct.orientation) + ho + .setup(e, ht.orientation) .then(i) ['catch'](function (t) { var e = t @@ -10387,16 +10487,16 @@ }), n(e) }), - oo.breadcrumbs && - 'number' == typeof oo.breadcrumbs && - oo.breadcrumbs > 1 && - (a.breadcrumbs.createCrumbs(oo.breadcrumbs), a.breadcrumbs.setIndex(oo.served)) - } catch (Fs) { - r.isMounted || (oo = null), + ho.breadcrumbs && + 'number' == typeof ho.breadcrumbs && + ho.breadcrumbs > 1 && + (a.breadcrumbs.createCrumbs(ho.breadcrumbs), a.breadcrumbs.setIndex(ho.served)) + } catch (Qr) { + s.isMounted || (ho = null), n({ event: it.CHALLENGE_ERROR, message: 'Creating challenge failed.', - reason: Fs.toString(), + reason: Qr.toString(), }) } }) @@ -10405,25 +10505,25 @@ if (!o.create) return Promise.reject(new Error(et.CHALLENGE_ALREADY_CLOSED)) ;(o.visible = !0), t.removeAttribute('aria-hidden'), - Ue.resetData(), - Ue.record(!0, !0, !0, !1), - Ue.setData('dct', Date.now()) + Je.resetData(), + Je.record(!0, !0, !0, !1), + Je.setData('dct', Date.now()) var n = i.setup(e.bundle, e.bundleData), - s = i.style(e.width, e.height).then(function (n) { + r = i.style(e.width, e.height).then(function (n) { o.visible && (a.setLock(!1), - l.setLock(!1), - ri.contact('challenge-ready', n).then(function () { + c.setLock(!1), + fi.contact('challenge-ready', n).then(function () { var n = 'info' === o.focus, - s = e.challengeType.indexOf('text') >= 0, - r = t.hasClass('using-kb') - ct.a11y_tfe || !n || (!r && s) + r = e.challengeType.indexOf('text') >= 0, + s = t.hasClass('using-kb') + ht.a11y_tfe || !n || (!s && r) ? i.focus() - : (l.menu.focus(!r), (o.focus = 'challenge')) + : (c.menu.focus(!s), (o.focus = 'challenge')) })) }) return new Promise(function (t, i) { - s['catch'](i), + r['catch'](i), n.then(t, i), o.timer && clearTimeout(o.timer), (o.timer = setTimeout(function () { @@ -10432,34 +10532,34 @@ }) }), (i.style = function (e, i) { - return oo + return ho ? new Promise(function (n, o) { try { - oo.style(e, i) + ho.style(e, i) .then(function (e) { var i = 10, o = e.mobile ? 60 : 70, h = e.width, u = e.height + i + o - r.style(e.width, e.height, i), - 'landscape' === ct.orientation && 'image_label_binary' === ct.challenge_type + s.style(e.width, e.height, i), + 'landscape' === ht.orientation && 'image_label_binary' === ht.challenge_type ? ((o = 35), (h = e.width + o + i), (u = e.height + o + i), a.style(e.width, o), a.css({ position: 'absolute', right: 0, bottom: 0 }), - l.style(o, u), - l.css({ position: 'absolute', left: 0, bottom: 0 }), - r.css({ position: 'absolute', top: 0, left: o + i })) + c.style(o, u), + c.css({ position: 'absolute', left: 0, bottom: 0 }), + s.css({ position: 'absolute', top: 0, left: o + i })) : (a.style(e.width, o), a.css({ position: 'absolute', left: 0, bottom: 0 }), - l.style(e.width, o), - l.css({ position: 'absolute', left: 0, bottom: 0 }), - r.css({ position: 'relative', marginBottom: i, right: 'auto' })), - s.css({ width: h, height: u, margin: i, position: 'relative' }), + c.style(e.width, o), + c.css({ position: 'absolute', left: 0, bottom: 0 }), + s.css({ position: 'relative', marginBottom: i, right: 'auto' })), + r.css({ width: h, height: u, margin: i, position: 'relative' }), t.css({ width: h + 20, height: u + 20 }), - c.style(h, u, e.mobile), - c.load(), + l.style(h, u, e.mobile), + l.load(), n({ width: h + 20, height: u + 20, mobile: e.mobile }) }) ['catch'](function (t) { @@ -10469,11 +10569,11 @@ reason: t.toString(), }) }) - } catch (Fs) { + } catch (Qr) { o({ event: it.CHALLENGE_ERROR, message: 'Error when calling .style()', - reason: Fs.toString(), + reason: Qr.toString(), }) } }) @@ -10484,7 +10584,7 @@ 'skip' !== a.getAction() ? new Promise(function (t, e) { try { - if ((oo && oo.submit(), i.hasBreadcrumbs())) { + if ((ho && ho.submit(), i.hasBreadcrumbs())) { var n = i.getTotalServed() a.breadcrumbs.setIndex(n) } @@ -10492,8 +10592,8 @@ null !== o._timer && 'check' === a.getAction() && (clearTimeout(o._timer), (o._timer = null)) - } catch (Fs) { - e(Fs) + } catch (Qr) { + e(Qr) } }) : Promise.resolve('challenge-skip') @@ -10506,46 +10606,46 @@ var o if ('fallback' === t.request_type) o = t.key else { - var s = i.hasBreadcrumbs() ? i.getTotalServed() - 1 : 0 - o = t.tasklist[s].task_key + var r = i.hasBreadcrumbs() ? i.getTotalServed() - 1 : 0 + o = t.tasklist[r].task_key } return e(o) } i.report().then(e), a.breadcrumbs && a.breadcrumbs.hide() - } catch (Ps) { - n(Ps) + } catch (ts) { + n(ts) } }) }), (i.hideReport = function () { - oo && oo.report && oo.report(!1) + ho && ho.report && ho.report(!1) }), (i.close = function () { - oo && (oo = r.unmount(oo)), + ho && (ho = s.unmount(ho)), o.timer && clearTimeout(o.timer), (o.timer = null), t.setAttribute('aria-hidden', !0), a.displayTryAgain(!1), a.removeCrumbs(), - c.close(), + l.close(), (o.visible = !1), (o.create = !1) }), (i.translateInterface = function (t) { if (t && t.locale && t.table) { try { - t.table && (se.setLocale(t.locale), se.addTable(t.locale, t.table)), - oo && oo.translate && oo.translate(), + t.table && (ue.setLocale(t.locale), ue.addTable(t.locale, t.table)), + ho && ho.translate && ho.translate(), a.translate(), - l.translate(), - document.documentElement.setAttribute('lang', se.getLocale()) - } catch (Fs) { - xt('translation', Fs) + c.translate(), + document.documentElement.setAttribute('lang', ue.getLocale()) + } catch (Qr) { + At('translation', Qr) } } }), (i.translateBundle = function () { - oo && oo.translate && oo.translate() + ho && ho.translate && ho.translate() }), (i.isVisible = function () { return o.visible @@ -10560,129 +10660,2993 @@ return o.locked }), (i.lockInterface = function (t) { - ;(o.locked = t), a.setLock(t), l.setLock(t) + ;(o.locked = t), a.setLock(t), c.setLock(t) }), (i.hasActiveElement = function () { return ( document.activeElement === a.submit.dom || - document.activeElement === l.refresh.dom || - document.activeElement === l.menu.dom + document.activeElement === c.refresh.dom || + document.activeElement === c.menu.dom ) }), (i.getActiveElement = function () { return document.activeElement === a.submit.dom ? 'submit' - : document.activeElement === l.refresh.dom + : document.activeElement === c.refresh.dom ? 'refresh' - : document.activeElement === l.menu.dom + : document.activeElement === c.menu.dom ? 'menu' : null }), (i.getModal = function () { - return c + return l }), (i.getTotalServed = function () { - return oo.served + return ho.served }), (i.getTotalBreadcrumbs = function () { - return oo ? oo.breadcrumbs : 0 + return ho ? ho.breadcrumbs : 0 }), (i.hasBreadcrumbs = function () { - return !(!oo || !oo.breadcrumbs) + return !(!ho || !ho.breadcrumbs) }), (i.canReport = function () { - return oo.report && 'function' == typeof oo.report + return ho.report && 'function' == typeof ho.report }), (i.report = function () { return new Promise(function (t) { var e = function (i) { - oo.off('report-image', e), t(i) + ho.off('report-image', e), t(i) } - oo.report(!0), oo.on('report-image', e) + ho.report(!0), ho.on('report-image', e) }) }), (i.focus = function (t) { - oo && oo.setFocus && oo.setFocus(t || 0, o.interaction) + ho && ho.setFocus && ho.setFocus(t || 0, o.interaction) }), (i.displayTryAgain = function (t) { a.displayTryAgain(t) }), (i.enableA11yChallenge = function (t) { - l.menuList.setA11yChallenge(t) + c.menuList.setA11yChallenge(t) }), i ) } - var ro = Object.create(null), - ao = null, - lo = null, - co = [], - ho = null, - uo = null - function po(t) { - if (Array.isArray(t) && 0 !== t.length) { - t.forEach(function (t) { - ;-1 === co.indexOf(t) && co.push(t) - }) + !(function (t) { + if ('object' == typeof exports && 'undefined' != typeof module) module.exports = t() + else if ('function' == typeof define && define.amd) define('raven-js', t) + else { + ;('undefined' != typeof window + ? window + : 'undefined' != typeof global + ? global + : 'undefined' != typeof self + ? self + : this + ).msgpack = t() } - } - var fo = function (t) { - if ((Ct('Set spec', 'proof', 'info', t), t)) { - ;(ao = t), (lo = null) - try { - go((lo = At.decode(t.req)))['catch'](function () {}) - } catch (Fs) { - xt('proof', Fs) + })(function () { + return (function t(e, i, n) { + function o(s, a) { + if (!i[s]) { + if (!e[s]) { + var c = 'function' == typeof require && require + if (!a && c) return c(s, !0) + if (r) return r(s, !0) + var l = new Error("Cannot find module '" + s + "'") + throw ((l.code = 'MODULE_NOT_FOUND'), l) + } + var h = (i[s] = { exports: {} }) + e[s][0].call( + h.exports, + function (t) { + var i = e[s][1][t] + return o(i || t) + }, + h, + h.exports, + t, + e, + i, + n, + ) } + return i[s].exports } - }, - mo = function (t) { - t && (ho = t) - }, - yo = function () { - return new Promise(function (t) { - var e = ao, - i = lo - if (e) { - try { - if ( - (Ct('Solve Proof', 'proof', 'info', e), - !( - -1 !== ['hsw', 'hsj', 'hsl'].indexOf(e.type) && - (!('n' in i.payload) || i.payload.n === e.type) - )) - ) { - return ( - wt('Asset script invalid file', 'error', 'proof', { seen: e.type, wanted: i.n }), - void t({ solved: null, spec: e }) - ) - } - Promise.resolve() - .then(function () { - return go(i) - }) - .then(function (t) { + for (var r = 'function' == typeof require && require, s = 0; s < n.length; s++) o(n[s]) + return o + })( + { + 1: [ + function (t, e, i) { + ;(i.encode = t('./encode').encode), + (i.decode = t('./decode').decode), + (i.Encoder = t('./encoder').Encoder), + (i.Decoder = t('./decoder').Decoder), + (i.createCodec = t('./ext').createCodec), + (i.codec = t('./codec').codec) + }, + { + './codec': 10, + './decode': 12, + './decoder': 13, + './encode': 15, + './encoder': 16, + './ext': 20, + }, + ], + 2: [ + function (t, e, i) { + ;(function (t) { + function i(t) { + return t && t.isBuffer && t + } + e.exports = + i(void 0 !== t && t) || + i(this.Buffer) || + i('undefined' != typeof window && window.Buffer) || + this.Buffer + }.call(this, t('buffer').Buffer)) + }, + { buffer: 29 }, + ], + 3: [ + function (t, e, i) { + ;(i.copy = function (t, e, i, n) { + var o + i || (i = 0), n || 0 === n || (n = this.length), e || (e = 0) + var r = n - i + if (t === this && i < e && e < n) for (o = r - 1; o >= 0; o--) t[o + e] = this[o + i] + else for (o = 0; o < r; o++) t[o + e] = this[o + i] + return r + }), + (i.toString = function (t, e, i) { + var n = this, + o = 0 | e + i || (i = n.length) + for (var r = '', s = 0; o < i; ) { + ;(s = n[o++]) < 128 + ? (r += String.fromCharCode(s)) + : (192 == (224 & s) + ? (s = ((31 & s) << 6) | (63 & n[o++])) + : 224 == (240 & s) + ? (s = ((15 & s) << 12) | ((63 & n[o++]) << 6) | (63 & n[o++])) + : 240 == (248 & s) && + (s = + ((7 & s) << 18) | + ((63 & n[o++]) << 12) | + ((63 & n[o++]) << 6) | + (63 & n[o++])), + s >= 65536 + ? ((s -= 65536), + (r += String.fromCharCode(55296 + (s >>> 10), 56320 + (1023 & s)))) + : (r += String.fromCharCode(s))) + } + return r + }), + (i.write = function (t, e) { + for (var i = this, n = e || (e |= 0), o = t.length, r = 0, s = 0; s < o; ) { + ;(r = t.charCodeAt(s++)) < 128 + ? (i[n++] = r) + : r < 2048 + ? ((i[n++] = 192 | (r >>> 6)), (i[n++] = 128 | (63 & r))) + : r < 55296 || r > 57343 + ? ((i[n++] = 224 | (r >>> 12)), + (i[n++] = 128 | ((r >>> 6) & 63)), + (i[n++] = 128 | (63 & r))) + : ((r = 65536 + (((r - 55296) << 10) | (t.charCodeAt(s++) - 56320))), + (i[n++] = 240 | (r >>> 18)), + (i[n++] = 128 | ((r >>> 12) & 63)), + (i[n++] = 128 | ((r >>> 6) & 63)), + (i[n++] = 128 | (63 & r))) + } + return n - e + }) + }, + {}, + ], + 4: [ + function (t, e, i) { + function n(t) { + return new Array(t) + } + var o = t('./bufferish') + ;((i = e.exports = n(0)).alloc = n), + (i.concat = o.concat), + (i.from = function (t) { + if (!o.isBuffer(t) && o.isView(t)) t = o.Uint8Array.from(t) + else if (o.isArrayBuffer(t)) t = new Uint8Array(t) + else { + if ('string' == typeof t) return o.from.call(i, t) + if ('number' == typeof t) { + throw new TypeError('"value" argument must not be a number') + } + } + return Array.prototype.slice.call(t) + }) + }, + { './bufferish': 8 }, + ], + 5: [ + function (t, e, i) { + function n(t) { + return new r(t) + } + var o = t('./bufferish'), + r = o.global + ;((i = e.exports = o.hasBuffer ? n(0) : []).alloc = (o.hasBuffer && r.alloc) || n), + (i.concat = o.concat), + (i.from = function (t) { + if (!o.isBuffer(t) && o.isView(t)) t = o.Uint8Array.from(t) + else if (o.isArrayBuffer(t)) t = new Uint8Array(t) + else { + if ('string' == typeof t) return o.from.call(i, t) + if ('number' == typeof t) { + throw new TypeError('"value" argument must not be a number') + } + } + return r.from && 1 !== r.from.length ? r.from(t) : new r(t) + }) + }, + { './bufferish': 8 }, + ], + 6: [ + function (t, e, i) { + function n(t, e, i, n) { + var a = s.isBuffer(this), + c = s.isBuffer(t) + if (a && c) return this.copy(t, e, i, n) + if (l || a || c || !s.isView(this) || !s.isView(t)) { + return r.copy.call(this, t, e, i, n) + } + var h = i || null != n ? o.call(this, i, n) : this + return t.set(h, e), h.length + } + function o(t, e) { + var i = this.slice || (!l && this.subarray) + if (i) return i.call(this, t, e) + var o = s.alloc.call(this, e - t) + return n.call(this, o, 0, t, e), o + } + var r = t('./buffer-lite') + ;(i.copy = n), + (i.slice = o), + (i.toString = function (t, e, i) { + var n = !c && s.isBuffer(this) ? this.toString : r.toString + return n.apply(this, arguments) + }), + (i.write = (function (t) { + return function () { + var e = this[t] || r[t] + return e.apply(this, arguments) + } + })('write')) + var s = t('./bufferish'), + a = s.global, + c = s.hasBuffer && 'TYPED_ARRAY_SUPPORT' in a, + l = c && !a.TYPED_ARRAY_SUPPORT + }, + { './buffer-lite': 3, './bufferish': 8 }, + ], + 7: [ + function (t, e, i) { + function n(t) { + return new Uint8Array(t) + } + var o = t('./bufferish') + ;((i = e.exports = o.hasArrayBuffer ? n(0) : []).alloc = n), + (i.concat = o.concat), + (i.from = function (t) { + if (o.isView(t)) { + var e = t.byteOffset, + n = t.byteLength + ;(t = t.buffer).byteLength !== n && + (t.slice + ? (t = t.slice(e, e + n)) + : (t = new Uint8Array(t)).byteLength !== n && + (t = Array.prototype.slice.call(t, e, e + n))) + } else { + if ('string' == typeof t) return o.from.call(i, t) + if ('number' == typeof t) { + throw new TypeError('"value" argument must not be a number') + } + } + return new Uint8Array(t) + }) + }, + { './bufferish': 8 }, + ], + 8: [ + function (t, e, i) { + function n(t) { + return r(this).alloc(t) + } + function o(t) { + var e = 3 * t.length, + i = n.call(this, e), + o = g.write.call(i, t) + return e !== o && (i = g.slice.call(i, 0, o)), i + } + function r(t) { + return f(t) ? m : d(t) ? y : u(t) ? p : l ? m : h ? y : p + } + function s() { + return !1 + } + function a(t, e) { + return ( + (t = '[object ' + t + ']'), + function (i) { + return null != i && {}.toString.call(e ? i[e] : i) === t + } + ) + } + var c = (i.global = t('./buffer-global')), + l = (i.hasBuffer = c && !!c.isBuffer), + h = (i.hasArrayBuffer = 'undefined' != typeof ArrayBuffer), + u = (i.isArray = t('isarray')) + i.isArrayBuffer = h + ? function (t) { + return t instanceof ArrayBuffer || v(t) + } + : s + var f = (i.isBuffer = l ? c.isBuffer : s), + d = (i.isView = h ? ArrayBuffer.isView || a('ArrayBuffer', 'buffer') : s) + ;(i.alloc = n), + (i.concat = function (t, e) { + e || + ((e = 0), + Array.prototype.forEach.call(t, function (t) { + e += t.length + })) + var o = (this !== i && this) || t[0], + r = n.call(o, e), + s = 0 + return ( + Array.prototype.forEach.call(t, function (t) { + s += g.copy.call(t, r, s) + }), + r + ) + }), + (i.from = function (t) { + return 'string' == typeof t ? o.call(this, t) : r(this).from(t) + }) + var p = (i.Array = t('./bufferish-array')), + m = (i.Buffer = t('./bufferish-buffer')), + y = (i.Uint8Array = t('./bufferish-uint8array')), + g = (i.prototype = t('./bufferish-proto')), + v = a('ArrayBuffer') + }, + { + './buffer-global': 2, + './bufferish-array': 4, + './bufferish-buffer': 5, + './bufferish-proto': 6, + './bufferish-uint8array': 7, + isarray: 34, + }, + ], + 9: [ + function (t, e, i) { + function n(t) { + return this instanceof n ? ((this.options = t), void this.init()) : new n(t) + } + function o(t, e) { + return t && e + ? function () { + return t.apply(this, arguments), e.apply(this, arguments) + } + : t || e + } + function r(t) { + return new n(t) + } + var s = t('isarray') + ;(i.createCodec = r), + (i.install = function (t) { + for (var e in t) n.prototype[e] = o(n.prototype[e], t[e]) + }), + (i.filter = function (t) { + return s(t) + ? (function (t) { + function e(t, e) { + return e(t) + } + return ( + (t = t.slice()), + function (i) { + return t.reduce(e, i) + } + ) + })(t) + : t + }) + var a = t('./bufferish') + ;(n.prototype.init = function () { + var t = this.options + return t && t.uint8array && (this.bufferish = a.Uint8Array), this + }), + (i.preset = r({ preset: !0 })) + }, + { './bufferish': 8, isarray: 34 }, + ], + 10: [ + function (t, e, i) { + t('./read-core'), t('./write-core'), (i.codec = { preset: t('./codec-base').preset }) + }, + { './codec-base': 9, './read-core': 22, './write-core': 25 }, + ], + 11: [ + function (t, e, i) { + function n(t) { + if (!(this instanceof n)) return new n(t) + if (t && ((this.options = t), t.codec)) { + var e = (this.codec = t.codec) + e.bufferish && (this.bufferish = e.bufferish) + } + } + i.DecodeBuffer = n + var o = t('./read-core').preset + t('./flex-buffer').FlexDecoder.mixin(n.prototype), + (n.prototype.codec = o), + (n.prototype.fetch = function () { + return this.codec.decode(this) + }) + }, + { './flex-buffer': 21, './read-core': 22 }, + ], + 12: [ + function (t, e, i) { + i.decode = function (t, e) { + var i = new n(e) + return i.write(t), i.read() + } + var n = t('./decode-buffer').DecodeBuffer + }, + { './decode-buffer': 11 }, + ], + 13: [ + function (t, e, i) { + function n(t) { + return this instanceof n ? void r.call(this, t) : new n(t) + } + i.Decoder = n + var o = t('event-lite'), + r = t('./decode-buffer').DecodeBuffer + ;(n.prototype = new r()), + o.mixin(n.prototype), + (n.prototype.decode = function (t) { + arguments.length && this.write(t), this.flush() + }), + (n.prototype.push = function (t) { + this.emit('data', t) + }), + (n.prototype.end = function (t) { + this.decode(t), this.emit('end') + }) + }, + { './decode-buffer': 11, 'event-lite': 31 }, + ], + 14: [ + function (t, e, i) { + function n(t) { + if (!(this instanceof n)) return new n(t) + if (t && ((this.options = t), t.codec)) { + var e = (this.codec = t.codec) + e.bufferish && (this.bufferish = e.bufferish) + } + } + i.EncodeBuffer = n + var o = t('./write-core').preset + t('./flex-buffer').FlexEncoder.mixin(n.prototype), + (n.prototype.codec = o), + (n.prototype.write = function (t) { + this.codec.encode(this, t) + }) + }, + { './flex-buffer': 21, './write-core': 25 }, + ], + 15: [ + function (t, e, i) { + i.encode = function (t, e) { + var i = new n(e) + return i.write(t), i.read() + } + var n = t('./encode-buffer').EncodeBuffer + }, + { './encode-buffer': 14 }, + ], + 16: [ + function (t, e, i) { + function n(t) { + return this instanceof n ? void r.call(this, t) : new n(t) + } + i.Encoder = n + var o = t('event-lite'), + r = t('./encode-buffer').EncodeBuffer + ;(n.prototype = new r()), + o.mixin(n.prototype), + (n.prototype.encode = function (t) { + this.write(t), this.emit('data', this.read()) + }), + (n.prototype.end = function (t) { + arguments.length && this.encode(t), this.flush(), this.emit('end') + }) + }, + { './encode-buffer': 14, 'event-lite': 31 }, + ], + 17: [ + function (t, e, i) { + i.ExtBuffer = function o(t, e) { + return this instanceof o + ? ((this.buffer = n.from(t)), void (this.type = e)) + : new o(t, e) + } + var n = t('./bufferish') + }, + { './bufferish': 8 }, + ], + 18: [ + function (t, e, i) { + function n(e) { + return a || (a = t('./encode').encode), a(e) + } + function o(t) { + return t.valueOf() + } + function r(t) { + ;(t = RegExp.prototype.toString.call(t).split('/')).shift() + var e = [t.pop()] + return e.unshift(t.join('/')), e + } + function s(t) { + var e = {} + for (var i in u) e[i] = t[i] + return e + } + i.setExtPackers = function (t) { + t.addExtPacker(14, Error, [s, n]), + t.addExtPacker(1, EvalError, [s, n]), + t.addExtPacker(2, RangeError, [s, n]), + t.addExtPacker(3, ReferenceError, [s, n]), + t.addExtPacker(4, SyntaxError, [s, n]), + t.addExtPacker(5, TypeError, [s, n]), + t.addExtPacker(6, URIError, [s, n]), + t.addExtPacker(10, RegExp, [r, n]), + t.addExtPacker(11, Boolean, [o, n]), + t.addExtPacker(12, String, [o, n]), + t.addExtPacker(13, Date, [Number, n]), + t.addExtPacker(15, Number, [o, n]), + 'undefined' != typeof Uint8Array && + (t.addExtPacker(17, Int8Array, h), + t.addExtPacker(18, Uint8Array, h), + t.addExtPacker(19, Int16Array, h), + t.addExtPacker(20, Uint16Array, h), + t.addExtPacker(21, Int32Array, h), + t.addExtPacker(22, Uint32Array, h), + t.addExtPacker(23, Float32Array, h), + 'undefined' != typeof Float64Array && t.addExtPacker(24, Float64Array, h), + 'undefined' != typeof Uint8ClampedArray && + t.addExtPacker(25, Uint8ClampedArray, h), + t.addExtPacker(26, ArrayBuffer, h), + t.addExtPacker(29, DataView, h)), + c.hasBuffer && t.addExtPacker(27, l, c.from) + } + var a, + c = t('./bufferish'), + l = c.global, + h = c.Uint8Array.from, + u = { name: 1, message: 1, stack: 1, columnNumber: 1, fileName: 1, lineNumber: 1 } + }, + { './bufferish': 8, './encode': 15 }, + ], + 19: [ + function (t, e, i) { + function n(e) { + return c || (c = t('./decode').decode), c(e) + } + function o(t) { + return RegExp.apply(null, t) + } + function r(t) { + return function (e) { + var i = new t() + for (var n in u) i[n] = e[n] + return i + } + } + function s(t) { + return function (e) { + return new t(e) + } + } + function a(t) { + return new Uint8Array(t).buffer + } + i.setExtUnpackers = function (t) { + t.addExtUnpacker(14, [n, r(Error)]), + t.addExtUnpacker(1, [n, r(EvalError)]), + t.addExtUnpacker(2, [n, r(RangeError)]), + t.addExtUnpacker(3, [n, r(ReferenceError)]), + t.addExtUnpacker(4, [n, r(SyntaxError)]), + t.addExtUnpacker(5, [n, r(TypeError)]), + t.addExtUnpacker(6, [n, r(URIError)]), + t.addExtUnpacker(10, [n, o]), + t.addExtUnpacker(11, [n, s(Boolean)]), + t.addExtUnpacker(12, [n, s(String)]), + t.addExtUnpacker(13, [n, s(Date)]), + t.addExtUnpacker(15, [n, s(Number)]), + 'undefined' != typeof Uint8Array && + (t.addExtUnpacker(17, s(Int8Array)), + t.addExtUnpacker(18, s(Uint8Array)), + t.addExtUnpacker(19, [a, s(Int16Array)]), + t.addExtUnpacker(20, [a, s(Uint16Array)]), + t.addExtUnpacker(21, [a, s(Int32Array)]), + t.addExtUnpacker(22, [a, s(Uint32Array)]), + t.addExtUnpacker(23, [a, s(Float32Array)]), + 'undefined' != typeof Float64Array && t.addExtUnpacker(24, [a, s(Float64Array)]), + 'undefined' != typeof Uint8ClampedArray && + t.addExtUnpacker(25, s(Uint8ClampedArray)), + t.addExtUnpacker(26, a), + t.addExtUnpacker(29, [a, s(DataView)])), + l.hasBuffer && t.addExtUnpacker(27, s(h)) + } + var c, + l = t('./bufferish'), + h = l.global, + u = { name: 1, message: 1, stack: 1, columnNumber: 1, fileName: 1, lineNumber: 1 } + }, + { './bufferish': 8, './decode': 12 }, + ], + 20: [ + function (t, e, i) { + t('./read-core'), t('./write-core'), (i.createCodec = t('./codec-base').createCodec) + }, + { './codec-base': 9, './read-core': 22, './write-core': 25 }, + ], + 21: [ + function (t, e, i) { + function n() { + if (!(this instanceof n)) return new n() + } + function o() { + if (!(this instanceof o)) return new o() + } + function r() { + throw new Error('method not implemented: write()') + } + function s() { + throw new Error('method not implemented: fetch()') + } + function a() { + return this.buffers && this.buffers.length + ? (this.flush(), this.pull()) + : this.fetch() + } + function c(t) { + ;(this.buffers || (this.buffers = [])).push(t) + } + function l() { + return (this.buffers || (this.buffers = [])).shift() + } + function h(t) { + return function (e) { + for (var i in t) e[i] = t[i] + return e + } + } + ;(i.FlexDecoder = n), (i.FlexEncoder = o) + var u = t('./bufferish'), + f = 2048, + d = 65536, + p = 'BUFFER_SHORTAGE' + ;(n.mixin = h({ + bufferish: u, + write: function (t) { + var e = this.offset ? u.prototype.slice.call(this.buffer, this.offset) : this.buffer + ;(this.buffer = e ? (t ? this.bufferish.concat([e, t]) : e) : t), (this.offset = 0) + }, + fetch: s, + flush: function () { + for (; this.offset < this.buffer.length; ) { + var t, + e = this.offset + try { + t = this.fetch() + } catch (t) { + if (t && t.message != p) throw t + this.offset = e + break + } + this.push(t) + } + }, + push: c, + pull: l, + read: a, + reserve: function (t) { + var e = this.offset, + i = e + t + if (i > this.buffer.length) throw new Error(p) + return (this.offset = i), e + }, + offset: 0, + })), + n.mixin(n.prototype), + (o.mixin = h({ + bufferish: u, + write: r, + fetch: function () { + var t = this.start + if (t < this.offset) { + var e = (this.start = this.offset) + return u.prototype.slice.call(this.buffer, t, e) + } + }, + flush: function () { + for (; this.start < this.offset; ) { + var t = this.fetch() + t && this.push(t) + } + }, + push: c, + pull: function () { + var t = this.buffers || (this.buffers = []), + e = t.length > 1 ? this.bufferish.concat(t) : t[0] + return (t.length = 0), e + }, + read: a, + reserve: function (t) { + var e = 0 | t + if (this.buffer) { + var i = this.buffer.length, + n = 0 | this.offset, + o = n + e + if (o < i) return (this.offset = o), n + this.flush(), (t = Math.max(t, Math.min(2 * i, this.maxBufferSize))) + } + return ( + (t = Math.max(t, this.minBufferSize)), + (this.buffer = this.bufferish.alloc(t)), + (this.start = 0), + (this.offset = e), + 0 + ) + }, + send: function (t) { + var e = t.length + if (e > this.minBufferSize) this.flush(), this.push(t) + else { + var i = this.reserve(e) + u.prototype.copy.call(t, this.buffer, i) + } + }, + maxBufferSize: d, + minBufferSize: f, + offset: 0, + start: 0, + })), + o.mixin(o.prototype) + }, + { './bufferish': 8 }, + ], + 22: [ + function (t, e, i) { + function n() { + var t = this.options + return ( + (this.decode = (function (t) { + var e = a.getReadToken(t) + return function (t) { + var i = s(t), + n = e[i] + if (!n) throw new Error('Invalid type: ' + (i ? '0x' + i.toString(16) : i)) + return n(t) + } + })(t)), + t && t.preset && r.setExtUnpackers(this), + this + ) + } + var o = t('./ext-buffer').ExtBuffer, + r = t('./ext-unpacker'), + s = t('./read-format').readUint8, + a = t('./read-token'), + c = t('./codec-base') + c.install({ + addExtUnpacker: function (t, e) { + ;(this.extUnpackers || (this.extUnpackers = []))[t] = c.filter(e) + }, + getExtUnpacker: function (t) { + return ( + (this.extUnpackers || (this.extUnpackers = []))[t] || + function (e) { + return new o(e, t) + } + ) + }, + init: n, + }), + (i.preset = n.call(c.preset)) + }, + { + './codec-base': 9, + './ext-buffer': 17, + './ext-unpacker': 19, + './read-format': 23, + './read-token': 24, + }, + ], + 23: [ + function (t, e, i) { + function n(t, e) { + var i, + n = {}, + o = new Array(e), + r = new Array(e), + s = t.codec.decode + for (i = 0; i < e; i++) (o[i] = s(t)), (r[i] = s(t)) + for (i = 0; i < e; i++) n[o[i]] = r[i] + return n + } + function o(t, e) { + var i, + n = new Map(), + o = new Array(e), + r = new Array(e), + s = t.codec.decode + for (i = 0; i < e; i++) (o[i] = s(t)), (r[i] = s(t)) + for (i = 0; i < e; i++) n.set(o[i], r[i]) + return n + } + function r(t, e) { + for (var i = new Array(e), n = t.codec.decode, o = 0; o < e; o++) i[o] = n(t) + return i + } + function s(t, e) { + var i = t.reserve(e), + n = i + e + return B.toString.call(t.buffer, 'utf-8', i, n) + } + function a(t, e) { + var i = t.reserve(e), + n = i + e, + o = B.slice.call(t.buffer, i, n) + return S.from(o) + } + function c(t, e) { + var i = t.reserve(e), + n = i + e, + o = B.slice.call(t.buffer, i, n) + return S.Uint8Array.from(o).buffer + } + function l(t, e) { + var i = t.reserve(e + 1), + n = t.buffer[i++], + o = i + e, + r = t.codec.getExtUnpacker(n) + if (!r) throw new Error('Invalid ext type: ' + (n ? '0x' + n.toString(16) : n)) + return r(B.slice.call(t.buffer, i, o)) + } + function h(t) { + var e = t.reserve(1) + return t.buffer[e] + } + function u(t) { + var e = t.reserve(1), + i = t.buffer[e] + return 128 & i ? i - 256 : i + } + function f(t) { + var e = t.reserve(2), + i = t.buffer + return (i[e++] << 8) | i[e] + } + function d(t) { + var e = t.reserve(2), + i = t.buffer, + n = (i[e++] << 8) | i[e] + return 32768 & n ? n - 65536 : n + } + function p(t) { + var e = t.reserve(4), + i = t.buffer + return 16777216 * i[e++] + (i[e++] << 16) + (i[e++] << 8) + i[e] + } + function m(t) { + var e = t.reserve(4), + i = t.buffer + return (i[e++] << 24) | (i[e++] << 16) | (i[e++] << 8) | i[e] + } + function y(t, e) { + return function (i) { + var n = i.reserve(t) + return e.call(i.buffer, n, T) + } + } + function g(t) { + return new E(this, t).toNumber() + } + function v(t) { + return new A(this, t).toNumber() + } + function b(t) { + return new E(this, t) + } + function w(t) { + return new A(this, t) + } + function x(t) { + return C.read(this, t, !1, 23, 4) + } + function k(t) { + return C.read(this, t, !1, 52, 8) + } + var C = t('ieee754'), + _ = t('int64-buffer'), + E = _.Uint64BE, + A = _.Int64BE + ;(i.getReadFormat = function (t) { + var e = S.hasArrayBuffer && t && t.binarraybuffer, + i = t && t.int64 + return { + map: L && t && t.usemap ? o : n, + array: r, + str: s, + bin: e ? c : a, + ext: l, + uint8: h, + uint16: f, + uint32: p, + uint64: y(8, i ? b : g), + int8: u, + int16: d, + int32: m, + int64: y(8, i ? w : v), + float32: y(4, x), + float64: y(8, k), + } + }), + (i.readUint8 = h) + var S = t('./bufferish'), + B = t('./bufferish-proto'), + L = 'undefined' != typeof Map, + T = !0 + }, + { './bufferish': 8, './bufferish-proto': 6, ieee754: 32, 'int64-buffer': 33 }, + ], + 24: [ + function (t, e, i) { + function n(t) { + var e, + i = new Array(256) + for (e = 0; e <= 127; e++) i[e] = o(e) + for (e = 128; e <= 143; e++) i[e] = s(e - 128, t.map) + for (e = 144; e <= 159; e++) i[e] = s(e - 144, t.array) + for (e = 160; e <= 191; e++) i[e] = s(e - 160, t.str) + for ( + i[192] = o(null), + i[193] = null, + i[194] = o(!1), + i[195] = o(!0), + i[196] = r(t.uint8, t.bin), + i[197] = r(t.uint16, t.bin), + i[198] = r(t.uint32, t.bin), + i[199] = r(t.uint8, t.ext), + i[200] = r(t.uint16, t.ext), + i[201] = r(t.uint32, t.ext), + i[202] = t.float32, + i[203] = t.float64, + i[204] = t.uint8, + i[205] = t.uint16, + i[206] = t.uint32, + i[207] = t.uint64, + i[208] = t.int8, + i[209] = t.int16, + i[210] = t.int32, + i[211] = t.int64, + i[212] = s(1, t.ext), + i[213] = s(2, t.ext), + i[214] = s(4, t.ext), + i[215] = s(8, t.ext), + i[216] = s(16, t.ext), + i[217] = r(t.uint8, t.str), + i[218] = r(t.uint16, t.str), + i[219] = r(t.uint32, t.str), + i[220] = r(t.uint16, t.array), + i[221] = r(t.uint32, t.array), + i[222] = r(t.uint16, t.map), + i[223] = r(t.uint32, t.map), + e = 224; + e <= 255; + e++ + ) { + i[e] = o(e - 256) + } + return i + } + function o(t) { + return function () { + return t + } + } + function r(t, e) { + return function (i) { + var n = t(i) + return e(i, n) + } + } + function s(t, e) { + return function (i) { + return e(i, t) + } + } + var a = t('./read-format') + i.getReadToken = function (t) { + var e = a.getReadFormat(t) + return t && t.useraw + ? (function (t) { + var e, + i = n(t).slice() + for ( + i[217] = i[196], i[218] = i[197], i[219] = i[198], e = 160; + e <= 191; + e++ + ) { + i[e] = s(e - 160, t.bin) + } + return i + })(e) + : n(e) + } + }, + { './read-format': 23 }, + ], + 25: [ + function (t, e, i) { + function n() { + var t = this.options + return ( + (this.encode = (function (t) { + var e = s.getWriteType(t) + return function (t, i) { + var n = e[typeof i] + if (!n) throw new Error('Unsupported type "' + typeof i + '": ' + i) + n(t, i) + } + })(t)), + t && t.preset && r.setExtPackers(this), + this + ) + } + var o = t('./ext-buffer').ExtBuffer, + r = t('./ext-packer'), + s = t('./write-type'), + a = t('./codec-base') + a.install({ + addExtPacker: function (t, e, i) { + function n(e) { + return i && (e = i(e)), new o(e, t) + } + i = a.filter(i) + var r = e.name + r && 'Object' !== r + ? ((this.extPackers || (this.extPackers = {}))[r] = n) + : (this.extEncoderList || (this.extEncoderList = [])).unshift([e, n]) + }, + getExtPacker: function (t) { + var e = this.extPackers || (this.extPackers = {}), + i = t.constructor, + n = i && i.name && e[i.name] + if (n) return n + for ( + var o = this.extEncoderList || (this.extEncoderList = []), r = o.length, s = 0; + s < r; + s++ + ) { + var a = o[s] + if (i === a[0]) return a[1] + } + }, + init: n, + }), + (i.preset = n.call(a.preset)) + }, + { './codec-base': 9, './ext-buffer': 17, './ext-packer': 18, './write-type': 27 }, + ], + 26: [ + function (t, e, i) { + function n() { + var t = y.slice() + return ( + (t[196] = o(196)), + (t[197] = r(197)), + (t[198] = s(198)), + (t[199] = o(199)), + (t[200] = r(200)), + (t[201] = s(201)), + (t[202] = a(202, 4, w.writeFloatBE || h, !0)), + (t[203] = a(203, 8, w.writeDoubleBE || u, !0)), + (t[204] = o(204)), + (t[205] = r(205)), + (t[206] = s(206)), + (t[207] = a(207, 8, c)), + (t[208] = o(208)), + (t[209] = r(209)), + (t[210] = s(210)), + (t[211] = a(211, 8, l)), + (t[217] = o(217)), + (t[218] = r(218)), + (t[219] = s(219)), + (t[220] = r(220)), + (t[221] = s(221)), + (t[222] = r(222)), + (t[223] = s(223)), + t + ) + } + function o(t) { + return function (e, i) { + var n = e.reserve(2), + o = e.buffer + ;(o[n++] = t), (o[n] = i) + } + } + function r(t) { + return function (e, i) { + var n = e.reserve(3), + o = e.buffer + ;(o[n++] = t), (o[n++] = i >>> 8), (o[n] = i) + } + } + function s(t) { + return function (e, i) { + var n = e.reserve(5), + o = e.buffer + ;(o[n++] = t), + (o[n++] = i >>> 24), + (o[n++] = i >>> 16), + (o[n++] = i >>> 8), + (o[n] = i) + } + } + function a(t, e, i, n) { + return function (o, r) { + var s = o.reserve(e + 1) + ;(o.buffer[s++] = t), i.call(o.buffer, r, s, n) + } + } + function c(t, e) { + new p(this, e, t) + } + function l(t, e) { + new m(this, e, t) + } + function h(t, e) { + f.write(this, t, e, !1, 23, 4) + } + function u(t, e) { + f.write(this, t, e, !1, 52, 8) + } + var f = t('ieee754'), + d = t('int64-buffer'), + p = d.Uint64BE, + m = d.Int64BE, + y = t('./write-uint8').uint8, + g = t('./bufferish'), + v = g.global, + b = g.hasBuffer && 'TYPED_ARRAY_SUPPORT' in v && !v.TYPED_ARRAY_SUPPORT, + w = (g.hasBuffer && v.prototype) || {} + i.getWriteToken = function (t) { + return t && t.uint8array + ? (function () { + var t = n() + return (t[202] = a(202, 4, h)), (t[203] = a(203, 8, u)), t + })() + : b || (g.hasBuffer && t && t.safe) + ? (function () { + var t = y.slice() + return ( + (t[196] = a(196, 1, v.prototype.writeUInt8)), + (t[197] = a(197, 2, v.prototype.writeUInt16BE)), + (t[198] = a(198, 4, v.prototype.writeUInt32BE)), + (t[199] = a(199, 1, v.prototype.writeUInt8)), + (t[200] = a(200, 2, v.prototype.writeUInt16BE)), + (t[201] = a(201, 4, v.prototype.writeUInt32BE)), + (t[202] = a(202, 4, v.prototype.writeFloatBE)), + (t[203] = a(203, 8, v.prototype.writeDoubleBE)), + (t[204] = a(204, 1, v.prototype.writeUInt8)), + (t[205] = a(205, 2, v.prototype.writeUInt16BE)), + (t[206] = a(206, 4, v.prototype.writeUInt32BE)), + (t[207] = a(207, 8, c)), + (t[208] = a(208, 1, v.prototype.writeInt8)), + (t[209] = a(209, 2, v.prototype.writeInt16BE)), + (t[210] = a(210, 4, v.prototype.writeInt32BE)), + (t[211] = a(211, 8, l)), + (t[217] = a(217, 1, v.prototype.writeUInt8)), + (t[218] = a(218, 2, v.prototype.writeUInt16BE)), + (t[219] = a(219, 4, v.prototype.writeUInt32BE)), + (t[220] = a(220, 2, v.prototype.writeUInt16BE)), + (t[221] = a(221, 4, v.prototype.writeUInt32BE)), + (t[222] = a(222, 2, v.prototype.writeUInt16BE)), + (t[223] = a(223, 4, v.prototype.writeUInt32BE)), + t + ) + })() + : n() + } + }, + { './bufferish': 8, './write-uint8': 28, ieee754: 32, 'int64-buffer': 33 }, + ], + 27: [ + function (t, e, i) { + var n = t('isarray'), + o = t('int64-buffer'), + r = o.Uint64BE, + s = o.Int64BE, + a = t('./bufferish'), + c = t('./bufferish-proto'), + l = t('./write-token'), + h = t('./write-uint8').uint8, + u = t('./ext-buffer').ExtBuffer, + f = 'undefined' != typeof Uint8Array, + d = 'undefined' != typeof Map, + p = [] + ;(p[1] = 212), + (p[2] = 213), + (p[4] = 214), + (p[8] = 215), + (p[16] = 216), + (i.getWriteType = function (t) { + function e(t, e) { + if (null === e) return i(t, e) + if (b(e)) return w(t, e) + if (n(e)) { + return (function (t, e) { + var i = e.length + y[i < 16 ? 144 + i : i <= 65535 ? 220 : 221](t, i) + for (var n = t.codec.encode, o = 0; o < i; o++) n(t, e[o]) + })(t, e) + } + if (r.isUint64BE(e)) { + return (function (t, e) { + y[207](t, e.toArray()) + })(t, e) + } + if (s.isInt64BE(e)) { + return (function (t, e) { + y[211](t, e.toArray()) + })(t, e) + } + var o = t.codec.getExtPacker(e) + return ( + o && (e = o(e)), + e instanceof u + ? (function (t, e) { + var i = e.buffer, + n = i.length, + o = p[n] || (n < 255 ? 199 : n <= 65535 ? 200 : 201) + y[o](t, n), h[e.type](t), t.send(i) + })(t, e) + : void x(t, e) + ) + } + function i(t, e) { + y[192](t, e) + } + function o(t, e) { + var i = e.length + y[i < 255 ? 196 : i <= 65535 ? 197 : 198](t, i), t.send(e) + } + function m(t, e) { + var i = Object.keys(e), + n = i.length + y[n < 16 ? 128 + n : n <= 65535 ? 222 : 223](t, n) + var o = t.codec.encode + i.forEach(function (i) { + o(t, i), o(t, e[i]) + }) + } + var y = l.getWriteToken(t), + g = t && t.useraw, + v = f && t && t.binarraybuffer, + b = v ? a.isArrayBuffer : a.isBuffer, + w = v + ? function (t, e) { + o(t, new Uint8Array(e)) + } + : o, + x = + d && t && t.usemap + ? function (t, e) { + if (!(e instanceof Map)) return m(t, e) + var i = e.size + y[i < 16 ? 128 + i : i <= 65535 ? 222 : 223](t, i) + var n = t.codec.encode + e.forEach(function (e, i, o) { + n(t, i), n(t, e) + }) + } + : m, + k = { + boolean: function (t, e) { + y[e ? 195 : 194](t, e) + }, + function: i, + number: function (t, e) { + var i = 0 | e + return e !== i + ? void y[203](t, e) + : void y[ + -32 <= i && i <= 127 + ? 255 & i + : 0 <= i + ? i <= 255 + ? 204 + : i <= 65535 + ? 205 + : 206 + : -128 <= i + ? 208 + : -32768 <= i + ? 209 + : 210 + ](t, i) + }, + object: g + ? function (t, i) { + return b(i) + ? (function (t, e) { + var i = e.length + y[i < 32 ? 160 + i : i <= 65535 ? 218 : 219](t, i), t.send(e) + })(t, i) + : void e(t, i) + } + : e, + string: (function (t) { + return function (e, i) { + var n = i.length, + o = 5 + 3 * n + e.offset = e.reserve(o) + var r = e.buffer, + s = t(n), + a = e.offset + s + n = c.write.call(r, i, a) + var l = t(n) + if (s !== l) { + var h = a + l - s, + u = a + n + c.copy.call(r, r, h, a, u) + } + y[1 === l ? 160 + n : l <= 3 ? 215 + l : 219](e, n), (e.offset += n) + } + })( + g + ? function (t) { + return t < 32 ? 1 : t <= 65535 ? 3 : 5 + } + : function (t) { + return t < 32 ? 1 : t <= 255 ? 2 : t <= 65535 ? 3 : 5 + }, + ), + symbol: i, + undefined: i, + } + return k + }) + }, + { + './bufferish': 8, + './bufferish-proto': 6, + './ext-buffer': 17, + './write-token': 26, + './write-uint8': 28, + 'int64-buffer': 33, + isarray: 34, + }, + ], + 28: [ + function (t, e, i) { + function n(t) { + return function (e) { + var i = e.reserve(1) + e.buffer[i] = t + } + } + for (var o = (i.uint8 = new Array(256)), r = 0; r <= 255; r++) o[r] = n(r) + }, + {}, + ], + 29: [ + function (t, e, i) { + ;(function (e) { + function n() { + return r.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823 + } + function o(t, e) { + if (n() < e) throw new RangeError('Invalid typed array length') + return ( + r.TYPED_ARRAY_SUPPORT + ? ((t = new Uint8Array(e)).__proto__ = r.prototype) + : (null === t && (t = new r(e)), (t.length = e)), + t + ) + } + function r(t, e, i) { + if (!(r.TYPED_ARRAY_SUPPORT || this instanceof r)) return new r(t, e, i) + if ('number' == typeof t) { + if ('string' == typeof e) { + throw new Error( + 'If encoding is specified then the first argument must be a string', + ) + } + return c(this, t) + } + return s(this, t, e, i) + } + function s(t, e, i, n) { + if ('number' == typeof e) { + throw new TypeError('"value" argument must not be a number') + } + return 'undefined' != typeof ArrayBuffer && e instanceof ArrayBuffer + ? (function (t, e, i, n) { + if ((e.byteLength, i < 0 || e.byteLength < i)) { + throw new RangeError("'offset' is out of bounds") + } + if (e.byteLength < i + (n || 0)) { + throw new RangeError("'length' is out of bounds") + } + return ( + (e = + void 0 === i && void 0 === n + ? new Uint8Array(e) + : void 0 === n + ? new Uint8Array(e, i) + : new Uint8Array(e, i, n)), + r.TYPED_ARRAY_SUPPORT ? ((t = e).__proto__ = r.prototype) : (t = l(t, e)), + t + ) + })(t, e, i, n) + : 'string' == typeof e + ? (function (t, e, i) { + if ((('string' == typeof i && '' !== i) || (i = 'utf8'), !r.isEncoding(i))) { + throw new TypeError('"encoding" must be a valid string encoding') + } + var n = 0 | u(e, i), + s = (t = o(t, n)).write(e, i) + return s !== n && (t = t.slice(0, s)), t + })(t, e, i) + : (function (t, e) { + if (r.isBuffer(e)) { + var i = 0 | h(e.length) + return 0 === (t = o(t, i)).length || e.copy(t, 0, 0, i), t + } + if (e) { + if ( + ('undefined' != typeof ArrayBuffer && e.buffer instanceof ArrayBuffer) || + 'length' in e + ) { + return 'number' != typeof e.length || + (function (t) { + return t != t + })(e.length) + ? o(t, 0) + : l(t, e) + } + if ('Buffer' === e.type && U(e.data)) return l(t, e.data) + } + throw new TypeError( + 'First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.', + ) + })(t, e) + } + function a(t) { + if ('number' != typeof t) throw new TypeError('"size" argument must be a number') + if (t < 0) throw new RangeError('"size" argument must not be negative') + } + function c(t, e) { + if ((a(e), (t = o(t, e < 0 ? 0 : 0 | h(e))), !r.TYPED_ARRAY_SUPPORT)) { + for (var i = 0; i < e; ++i) t[i] = 0 + } + return t + } + function l(t, e) { + var i = e.length < 0 ? 0 : 0 | h(e.length) + t = o(t, i) + for (var n = 0; n < i; n += 1) t[n] = 255 & e[n] + return t + } + function h(t) { + if (t >= n()) { + throw new RangeError( + 'Attempt to allocate Buffer larger than maximum size: 0x' + + n().toString(16) + + ' bytes', + ) + } + return 0 | t + } + function u(t, e) { + if (r.isBuffer(t)) return t.length + if ( + 'undefined' != typeof ArrayBuffer && + 'function' == typeof ArrayBuffer.isView && + (ArrayBuffer.isView(t) || t instanceof ArrayBuffer) + ) { + return t.byteLength + } + 'string' != typeof t && (t = '' + t) + var i = t.length + if (0 === i) return 0 + for (var n = !1; ; ) { + switch (e) { + case 'ascii': + case 'latin1': + case 'binary': + return i + case 'utf8': + case 'utf-8': + case void 0: + return I(t).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 2 * i + case 'hex': + return i >>> 1 + case 'base64': + return V(t).length + default: + if (n) return I(t).length + ;(e = ('' + e).toLowerCase()), (n = !0) + } + } + } + function f(t, e, i) { + var n = !1 + if (((void 0 === e || e < 0) && (e = 0), e > this.length)) return '' + if (((void 0 === i || i > this.length) && (i = this.length), i <= 0)) return '' + if ((i >>>= 0) <= (e >>>= 0)) return '' + for (t || (t = 'utf8'); ; ) { + switch (t) { + case 'hex': + return A(this, e, i) + case 'utf8': + case 'utf-8': + return C(this, e, i) + case 'ascii': + return _(this, e, i) + case 'latin1': + case 'binary': + return E(this, e, i) + case 'base64': + return k(this, e, i) + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return S(this, e, i) + default: + if (n) throw new TypeError('Unknown encoding: ' + t) + ;(t = (t + '').toLowerCase()), (n = !0) + } + } + } + function d(t, e, i) { + var n = t[e] + ;(t[e] = t[i]), (t[i] = n) + } + function p(t, e, i, n, o) { + if (0 === t.length) return -1 + if ( + ('string' == typeof i + ? ((n = i), (i = 0)) + : i > 2147483647 + ? (i = 2147483647) + : i < -2147483648 && (i = -2147483648), + (i = +i), + isNaN(i) && (i = o ? 0 : t.length - 1), + i < 0 && (i = t.length + i), + i >= t.length) + ) { + if (o) return -1 + i = t.length - 1 + } else if (i < 0) { + if (!o) return -1 + i = 0 + } + if (('string' == typeof e && (e = r.from(e, n)), r.isBuffer(e))) { + return 0 === e.length ? -1 : m(t, e, i, n, o) + } + if ('number' == typeof e) { + return ( + (e &= 255), + r.TYPED_ARRAY_SUPPORT && 'function' == typeof Uint8Array.prototype.indexOf + ? o + ? Uint8Array.prototype.indexOf.call(t, e, i) + : Uint8Array.prototype.lastIndexOf.call(t, e, i) + : m(t, [e], i, n, o) + ) + } + throw new TypeError('val must be string, number or Buffer') + } + function m(t, e, i, n, o) { + function r(t, e) { + return 1 === a ? t[e] : t.readUInt16BE(e * a) + } + var s, + a = 1, + c = t.length, + l = e.length + if ( + void 0 !== n && + ('ucs2' === (n = String(n).toLowerCase()) || + 'ucs-2' === n || + 'utf16le' === n || + 'utf-16le' === n) + ) { + if (t.length < 2 || e.length < 2) return -1 + ;(a = 2), (c /= 2), (l /= 2), (i /= 2) + } + if (o) { + var h = -1 + for (s = i; s < c; s++) { + if (r(t, s) === r(e, -1 === h ? 0 : s - h)) { + if ((-1 === h && (h = s), s - h + 1 === l)) return h * a + } else -1 !== h && (s -= s - h), (h = -1) + } + } else { + for (i + l > c && (i = c - l), s = i; s >= 0; s--) { + for (var u = !0, f = 0; f < l; f++) { + if (r(t, s + f) !== r(e, f)) { + u = !1 + break + } + } + if (u) return s + } + } + return -1 + } + function y(t, e, i, n) { + i = Number(i) || 0 + var o = t.length - i + n ? (n = Number(n)) > o && (n = o) : (n = o) + var r = e.length + if (r % 2 != 0) throw new TypeError('Invalid hex string') + n > r / 2 && (n = r / 2) + for (var s = 0; s < n; ++s) { + var a = parseInt(e.substr(2 * s, 2), 16) + if (isNaN(a)) return s + t[i + s] = a + } + return s + } + function g(t, e, i, n) { + return D(I(e, t.length - i), t, i, n) + } + function v(t, e, i, n) { + return D( + (function (t) { + for (var e = [], i = 0; i < t.length; ++i) e.push(255 & t.charCodeAt(i)) + return e + })(e), + t, + i, + n, + ) + } + function b(t, e, i, n) { + return v(t, e, i, n) + } + function w(t, e, i, n) { + return D(V(e), t, i, n) + } + function x(t, e, i, n) { + return D( + (function (t, e) { + for (var i, n, o, r = [], s = 0; s < t.length && !((e -= 2) < 0); ++s) { + ;(i = t.charCodeAt(s)), (n = i >> 8), (o = i % 256), r.push(o), r.push(n) + } + return r + })(e, t.length - i), + t, + i, + n, + ) + } + function k(t, e, i) { + return 0 === e && i === t.length + ? F.fromByteArray(t) + : F.fromByteArray(t.slice(e, i)) + } + function C(t, e, i) { + i = Math.min(t.length, i) + for (var n = [], o = e; o < i; ) { + var r, + s, + a, + c, + l = t[o], + h = null, + u = l > 239 ? 4 : l > 223 ? 3 : l > 191 ? 2 : 1 + if (o + u <= i) { + switch (u) { + case 1: + l < 128 && (h = l) + break + case 2: + 128 == (192 & (r = t[o + 1])) && + (c = ((31 & l) << 6) | (63 & r)) > 127 && + (h = c) + break + case 3: + ;(r = t[o + 1]), + (s = t[o + 2]), + 128 == (192 & r) && + 128 == (192 & s) && + (c = ((15 & l) << 12) | ((63 & r) << 6) | (63 & s)) > 2047 && + (c < 55296 || c > 57343) && + (h = c) + break + case 4: + ;(r = t[o + 1]), + (s = t[o + 2]), + (a = t[o + 3]), + 128 == (192 & r) && + 128 == (192 & s) && + 128 == (192 & a) && + (c = ((15 & l) << 18) | ((63 & r) << 12) | ((63 & s) << 6) | (63 & a)) > + 65535 && + c < 1114112 && + (h = c) + } + } + null === h + ? ((h = 65533), (u = 1)) + : h > 65535 && + ((h -= 65536), n.push(((h >>> 10) & 1023) | 55296), (h = 56320 | (1023 & h))), + n.push(h), + (o += u) + } + return (function (t) { + var e = t.length + if (e <= j) return String.fromCharCode.apply(String, t) + for (var i = '', n = 0; n < e; ) { + i += String.fromCharCode.apply(String, t.slice(n, (n += j))) + } + return i + })(n) + } + function _(t, e, i) { + var n = '' + i = Math.min(t.length, i) + for (var o = e; o < i; ++o) n += String.fromCharCode(127 & t[o]) + return n + } + function E(t, e, i) { + var n = '' + i = Math.min(t.length, i) + for (var o = e; o < i; ++o) n += String.fromCharCode(t[o]) + return n + } + function A(t, e, i) { + var n = t.length + ;(!e || e < 0) && (e = 0), (!i || i < 0 || i > n) && (i = n) + for (var o = '', r = e; r < i; ++r) o += P(t[r]) + return o + } + function S(t, e, i) { + for (var n = t.slice(e, i), o = '', r = 0; r < n.length; r += 2) { + o += String.fromCharCode(n[r] + 256 * n[r + 1]) + } + return o + } + function B(t, e, i) { + if (t % 1 != 0 || t < 0) throw new RangeError('offset is not uint') + if (t + e > i) throw new RangeError('Trying to access beyond buffer length') + } + function L(t, e, i, n, o, s) { + if (!r.isBuffer(t)) { + throw new TypeError('"buffer" argument must be a Buffer instance') + } + if (e > o || e < s) throw new RangeError('"value" argument is out of bounds') + if (i + n > t.length) throw new RangeError('Index out of range') + } + function T(t, e, i, n) { + e < 0 && (e = 65535 + e + 1) + for (var o = 0, r = Math.min(t.length - i, 2); o < r; ++o) { + t[i + o] = (e & (255 << (8 * (n ? o : 1 - o)))) >>> (8 * (n ? o : 1 - o)) + } + } + function O(t, e, i, n) { + e < 0 && (e = 4294967295 + e + 1) + for (var o = 0, r = Math.min(t.length - i, 4); o < r; ++o) { + t[i + o] = (e >>> (8 * (n ? o : 3 - o))) & 255 + } + } + function H(t, e, i, n, o, r) { + if (i + n > t.length) throw new RangeError('Index out of range') + if (i < 0) throw new RangeError('Index out of range') + } + function M(t, e, i, n, o) { + return o || H(t, 0, i, 4), $.write(t, e, i, n, 23, 4), i + 4 + } + function R(t, e, i, n, o) { + return o || H(t, 0, i, 8), $.write(t, e, i, n, 52, 8), i + 8 + } + function P(t) { + return t < 16 ? '0' + t.toString(16) : t.toString(16) + } + function I(t, e) { + e = e || 1 / 0 + for (var i, n = t.length, o = null, r = [], s = 0; s < n; ++s) { + if ((i = t.charCodeAt(s)) > 55295 && i < 57344) { + if (!o) { + if (i > 56319) { + ;(e -= 3) > -1 && r.push(239, 191, 189) + continue + } + if (s + 1 === n) { + ;(e -= 3) > -1 && r.push(239, 191, 189) + continue + } + o = i + continue + } + if (i < 56320) { + ;(e -= 3) > -1 && r.push(239, 191, 189), (o = i) + continue + } + i = 65536 + (((o - 55296) << 10) | (i - 56320)) + } else o && (e -= 3) > -1 && r.push(239, 191, 189) + if (((o = null), i < 128)) { + if ((e -= 1) < 0) break + r.push(i) + } else if (i < 2048) { + if ((e -= 2) < 0) break + r.push((i >> 6) | 192, (63 & i) | 128) + } else if (i < 65536) { + if ((e -= 3) < 0) break + r.push((i >> 12) | 224, ((i >> 6) & 63) | 128, (63 & i) | 128) + } else { + if (!(i < 1114112)) throw new Error('Invalid code point') + if ((e -= 4) < 0) break + r.push( + (i >> 18) | 240, + ((i >> 12) & 63) | 128, + ((i >> 6) & 63) | 128, + (63 & i) | 128, + ) + } + } + return r + } + function V(t) { + return F.toByteArray( + (function (t) { + if ( + (t = (function (t) { + return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, '') + })(t).replace(N, '')).length < 2 + ) { + return '' + } + for (; t.length % 4 != 0; ) t += '=' + return t + })(t), + ) + } + function D(t, e, i, n) { + for (var o = 0; o < n && !(o + i >= e.length || o >= t.length); ++o) e[o + i] = t[o] + return o + } + var F = t('base64-js'), + $ = t('ieee754'), + U = t('isarray') + ;(i.Buffer = r), + (i.SlowBuffer = function (t) { + return +t != t && (t = 0), r.alloc(+t) + }), + (i.INSPECT_MAX_BYTES = 50), + (r.TYPED_ARRAY_SUPPORT = + void 0 !== e.TYPED_ARRAY_SUPPORT + ? e.TYPED_ARRAY_SUPPORT + : (function () { + try { + var t = new Uint8Array(1) + return ( + (t.__proto__ = { + __proto__: Uint8Array.prototype, + foo: function () { + return 42 + }, + }), + 42 === t.foo() && + 'function' == typeof t.subarray && + 0 === t.subarray(1, 1).byteLength + ) + } catch (t) { + return !1 + } + })()), + (i.kMaxLength = n()), + (r.poolSize = 8192), + (r._augment = function (t) { + return (t.__proto__ = r.prototype), t + }), + (r.from = function (t, e, i) { + return s(null, t, e, i) + }), + r.TYPED_ARRAY_SUPPORT && + ((r.prototype.__proto__ = Uint8Array.prototype), + (r.__proto__ = Uint8Array), + 'undefined' != typeof Symbol && + Symbol.species && + r[Symbol.species] === r && + Object.defineProperty(r, Symbol.species, { value: null, configurable: !0 })), + (r.alloc = function (t, e, i) { + return (function (t, e, i, n) { + return ( + a(e), + e <= 0 + ? o(t, e) + : void 0 !== i + ? 'string' == typeof n + ? o(t, e).fill(i, n) + : o(t, e).fill(i) + : o(t, e) + ) + })(null, t, e, i) + }), + (r.allocUnsafe = function (t) { + return c(null, t) + }), + (r.allocUnsafeSlow = function (t) { + return c(null, t) + }), + (r.isBuffer = function (t) { + return !(null == t || !t._isBuffer) + }), + (r.compare = function (t, e) { + if (!r.isBuffer(t) || !r.isBuffer(e)) { + throw new TypeError('Arguments must be Buffers') + } + if (t === e) return 0 + for (var i = t.length, n = e.length, o = 0, s = Math.min(i, n); o < s; ++o) { + if (t[o] !== e[o]) { + ;(i = t[o]), (n = e[o]) + break + } + } + return i < n ? -1 : n < i ? 1 : 0 + }), + (r.isEncoding = function (t) { + switch (String(t).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return !0 + default: + return !1 + } + }), + (r.concat = function (t, e) { + if (!U(t)) throw new TypeError('"list" argument must be an Array of Buffers') + if (0 === t.length) return r.alloc(0) + var i + if (void 0 === e) for (e = 0, i = 0; i < t.length; ++i) e += t[i].length + var n = r.allocUnsafe(e), + o = 0 + for (i = 0; i < t.length; ++i) { + var s = t[i] + if (!r.isBuffer(s)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + s.copy(n, o), (o += s.length) + } + return n + }), + (r.byteLength = u), + (r.prototype._isBuffer = !0), + (r.prototype.swap16 = function () { + var t = this.length + if (t % 2 != 0) throw new RangeError('Buffer size must be a multiple of 16-bits') + for (var e = 0; e < t; e += 2) d(this, e, e + 1) + return this + }), + (r.prototype.swap32 = function () { + var t = this.length + if (t % 4 != 0) throw new RangeError('Buffer size must be a multiple of 32-bits') + for (var e = 0; e < t; e += 4) d(this, e, e + 3), d(this, e + 1, e + 2) + return this + }), + (r.prototype.swap64 = function () { + var t = this.length + if (t % 8 != 0) throw new RangeError('Buffer size must be a multiple of 64-bits') + for (var e = 0; e < t; e += 8) { + d(this, e, e + 7), + d(this, e + 1, e + 6), + d(this, e + 2, e + 5), + d(this, e + 3, e + 4) + } + return this + }), + (r.prototype.toString = function () { + var t = 0 | this.length + return 0 === t + ? '' + : 0 === arguments.length + ? C(this, 0, t) + : f.apply(this, arguments) + }), + (r.prototype.equals = function (t) { + if (!r.isBuffer(t)) throw new TypeError('Argument must be a Buffer') + return this === t || 0 === r.compare(this, t) + }), + (r.prototype.inspect = function () { + var t = '', + e = i.INSPECT_MAX_BYTES + return ( + this.length > 0 && + ((t = this.toString('hex', 0, e).match(/.{2}/g).join(' ')), + this.length > e && (t += ' ... ')), + '' + ) + }), + (r.prototype.compare = function (t, e, i, n, o) { + if (!r.isBuffer(t)) throw new TypeError('Argument must be a Buffer') + if ( + (void 0 === e && (e = 0), + void 0 === i && (i = t ? t.length : 0), + void 0 === n && (n = 0), + void 0 === o && (o = this.length), + e < 0 || i > t.length || n < 0 || o > this.length) + ) { + throw new RangeError('out of range index') + } + if (n >= o && e >= i) return 0 + if (n >= o) return -1 + if (e >= i) return 1 + if (this === t) return 0 + for ( + var s = (o >>>= 0) - (n >>>= 0), + a = (i >>>= 0) - (e >>>= 0), + c = Math.min(s, a), + l = this.slice(n, o), + h = t.slice(e, i), + u = 0; + u < c; + ++u + ) { + if (l[u] !== h[u]) { + ;(s = l[u]), (a = h[u]) + break + } + } + return s < a ? -1 : a < s ? 1 : 0 + }), + (r.prototype.includes = function (t, e, i) { + return -1 !== this.indexOf(t, e, i) + }), + (r.prototype.indexOf = function (t, e, i) { + return p(this, t, e, i, !0) + }), + (r.prototype.lastIndexOf = function (t, e, i) { + return p(this, t, e, i, !1) + }), + (r.prototype.write = function (t, e, i, n) { + if (void 0 === e) (n = 'utf8'), (i = this.length), (e = 0) + else if (void 0 === i && 'string' == typeof e) (n = e), (i = this.length), (e = 0) + else { + if (!isFinite(e)) { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported', + ) + } + ;(e |= 0), + isFinite(i) + ? ((i |= 0), void 0 === n && (n = 'utf8')) + : ((n = i), (i = void 0)) + } + var o = this.length - e + if ( + ((void 0 === i || i > o) && (i = o), + (t.length > 0 && (i < 0 || e < 0)) || e > this.length) + ) { + throw new RangeError('Attempt to write outside buffer bounds') + } + n || (n = 'utf8') + for (var r = !1; ; ) { + switch (n) { + case 'hex': + return y(this, t, e, i) + case 'utf8': + case 'utf-8': + return g(this, t, e, i) + case 'ascii': + return v(this, t, e, i) + case 'latin1': + case 'binary': + return b(this, t, e, i) + case 'base64': + return w(this, t, e, i) + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return x(this, t, e, i) + default: + if (r) throw new TypeError('Unknown encoding: ' + n) + ;(n = ('' + n).toLowerCase()), (r = !0) + } + } + }), + (r.prototype.toJSON = function () { + return { type: 'Buffer', data: Array.prototype.slice.call(this._arr || this, 0) } + }) + var j = 4096 + ;(r.prototype.slice = function (t, e) { + var i, + n = this.length + if ( + ((t = ~~t) < 0 ? (t += n) < 0 && (t = 0) : t > n && (t = n), + (e = void 0 === e ? n : ~~e) < 0 ? (e += n) < 0 && (e = 0) : e > n && (e = n), + e < t && (e = t), + r.TYPED_ARRAY_SUPPORT) + ) { + ;(i = this.subarray(t, e)).__proto__ = r.prototype + } else { + var o = e - t + i = new r(o, void 0) + for (var s = 0; s < o; ++s) i[s] = this[s + t] + } + return i + }), + (r.prototype.readUIntLE = function (t, e, i) { + ;(t |= 0), (e |= 0), i || B(t, e, this.length) + for (var n = this[t], o = 1, r = 0; ++r < e && (o *= 256); ) n += this[t + r] * o + return n + }), + (r.prototype.readUIntBE = function (t, e, i) { + ;(t |= 0), (e |= 0), i || B(t, e, this.length) + for (var n = this[t + --e], o = 1; e > 0 && (o *= 256); ) n += this[t + --e] * o + return n + }), + (r.prototype.readUInt8 = function (t, e) { + return e || B(t, 1, this.length), this[t] + }), + (r.prototype.readUInt16LE = function (t, e) { + return e || B(t, 2, this.length), this[t] | (this[t + 1] << 8) + }), + (r.prototype.readUInt16BE = function (t, e) { + return e || B(t, 2, this.length), (this[t] << 8) | this[t + 1] + }), + (r.prototype.readUInt32LE = function (t, e) { + return ( + e || B(t, 4, this.length), + (this[t] | (this[t + 1] << 8) | (this[t + 2] << 16)) + 16777216 * this[t + 3] + ) + }), + (r.prototype.readUInt32BE = function (t, e) { + return ( + e || B(t, 4, this.length), + 16777216 * this[t] + ((this[t + 1] << 16) | (this[t + 2] << 8) | this[t + 3]) + ) + }), + (r.prototype.readIntLE = function (t, e, i) { + ;(t |= 0), (e |= 0), i || B(t, e, this.length) + for (var n = this[t], o = 1, r = 0; ++r < e && (o *= 256); ) n += this[t + r] * o + return n >= (o *= 128) && (n -= Math.pow(2, 8 * e)), n + }), + (r.prototype.readIntBE = function (t, e, i) { + ;(t |= 0), (e |= 0), i || B(t, e, this.length) + for (var n = e, o = 1, r = this[t + --n]; n > 0 && (o *= 256); ) { + r += this[t + --n] * o + } + return r >= (o *= 128) && (r -= Math.pow(2, 8 * e)), r + }), + (r.prototype.readInt8 = function (t, e) { + return ( + e || B(t, 1, this.length), 128 & this[t] ? -1 * (255 - this[t] + 1) : this[t] + ) + }), + (r.prototype.readInt16LE = function (t, e) { + e || B(t, 2, this.length) + var i = this[t] | (this[t + 1] << 8) + return 32768 & i ? 4294901760 | i : i + }), + (r.prototype.readInt16BE = function (t, e) { + e || B(t, 2, this.length) + var i = this[t + 1] | (this[t] << 8) + return 32768 & i ? 4294901760 | i : i + }), + (r.prototype.readInt32LE = function (t, e) { + return ( + e || B(t, 4, this.length), + this[t] | (this[t + 1] << 8) | (this[t + 2] << 16) | (this[t + 3] << 24) + ) + }), + (r.prototype.readInt32BE = function (t, e) { + return ( + e || B(t, 4, this.length), + (this[t] << 24) | (this[t + 1] << 16) | (this[t + 2] << 8) | this[t + 3] + ) + }), + (r.prototype.readFloatLE = function (t, e) { + return e || B(t, 4, this.length), $.read(this, t, !0, 23, 4) + }), + (r.prototype.readFloatBE = function (t, e) { + return e || B(t, 4, this.length), $.read(this, t, !1, 23, 4) + }), + (r.prototype.readDoubleLE = function (t, e) { + return e || B(t, 8, this.length), $.read(this, t, !0, 52, 8) + }), + (r.prototype.readDoubleBE = function (t, e) { + return e || B(t, 8, this.length), $.read(this, t, !1, 52, 8) + }), + (r.prototype.writeUIntLE = function (t, e, i, n) { + ;((t = +t), (e |= 0), (i |= 0), n) || L(this, t, e, i, Math.pow(2, 8 * i) - 1, 0) + var o = 1, + r = 0 + for (this[e] = 255 & t; ++r < i && (o *= 256); ) this[e + r] = (t / o) & 255 + return e + i + }), + (r.prototype.writeUIntBE = function (t, e, i, n) { + ;((t = +t), (e |= 0), (i |= 0), n) || L(this, t, e, i, Math.pow(2, 8 * i) - 1, 0) + var o = i - 1, + r = 1 + for (this[e + o] = 255 & t; --o >= 0 && (r *= 256); ) this[e + o] = (t / r) & 255 + return e + i + }), + (r.prototype.writeUInt8 = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 1, 255, 0), + r.TYPED_ARRAY_SUPPORT || (t = Math.floor(t)), + (this[e] = 255 & t), + e + 1 + ) + }), + (r.prototype.writeUInt16LE = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 2, 65535, 0), + r.TYPED_ARRAY_SUPPORT + ? ((this[e] = 255 & t), (this[e + 1] = t >>> 8)) + : T(this, t, e, !0), + e + 2 + ) + }), + (r.prototype.writeUInt16BE = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 2, 65535, 0), + r.TYPED_ARRAY_SUPPORT + ? ((this[e] = t >>> 8), (this[e + 1] = 255 & t)) + : T(this, t, e, !1), + e + 2 + ) + }), + (r.prototype.writeUInt32LE = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 4, 4294967295, 0), + r.TYPED_ARRAY_SUPPORT + ? ((this[e + 3] = t >>> 24), + (this[e + 2] = t >>> 16), + (this[e + 1] = t >>> 8), + (this[e] = 255 & t)) + : O(this, t, e, !0), + e + 4 + ) + }), + (r.prototype.writeUInt32BE = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 4, 4294967295, 0), + r.TYPED_ARRAY_SUPPORT + ? ((this[e] = t >>> 24), + (this[e + 1] = t >>> 16), + (this[e + 2] = t >>> 8), + (this[e + 3] = 255 & t)) + : O(this, t, e, !1), + e + 4 + ) + }), + (r.prototype.writeIntLE = function (t, e, i, n) { + if (((t = +t), (e |= 0), !n)) { + var o = Math.pow(2, 8 * i - 1) + L(this, t, e, i, o - 1, -o) + } + var r = 0, + s = 1, + a = 0 + for (this[e] = 255 & t; ++r < i && (s *= 256); ) { + t < 0 && 0 === a && 0 !== this[e + r - 1] && (a = 1), + (this[e + r] = (((t / s) >> 0) - a) & 255) + } + return e + i + }), + (r.prototype.writeIntBE = function (t, e, i, n) { + if (((t = +t), (e |= 0), !n)) { + var o = Math.pow(2, 8 * i - 1) + L(this, t, e, i, o - 1, -o) + } + var r = i - 1, + s = 1, + a = 0 + for (this[e + r] = 255 & t; --r >= 0 && (s *= 256); ) { + t < 0 && 0 === a && 0 !== this[e + r + 1] && (a = 1), + (this[e + r] = (((t / s) >> 0) - a) & 255) + } + return e + i + }), + (r.prototype.writeInt8 = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 1, 127, -128), + r.TYPED_ARRAY_SUPPORT || (t = Math.floor(t)), + t < 0 && (t = 255 + t + 1), + (this[e] = 255 & t), + e + 1 + ) + }), + (r.prototype.writeInt16LE = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 2, 32767, -32768), + r.TYPED_ARRAY_SUPPORT + ? ((this[e] = 255 & t), (this[e + 1] = t >>> 8)) + : T(this, t, e, !0), + e + 2 + ) + }), + (r.prototype.writeInt16BE = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 2, 32767, -32768), + r.TYPED_ARRAY_SUPPORT + ? ((this[e] = t >>> 8), (this[e + 1] = 255 & t)) + : T(this, t, e, !1), + e + 2 + ) + }), + (r.prototype.writeInt32LE = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 4, 2147483647, -2147483648), + r.TYPED_ARRAY_SUPPORT + ? ((this[e] = 255 & t), + (this[e + 1] = t >>> 8), + (this[e + 2] = t >>> 16), + (this[e + 3] = t >>> 24)) + : O(this, t, e, !0), + e + 4 + ) + }), + (r.prototype.writeInt32BE = function (t, e, i) { + return ( + (t = +t), + (e |= 0), + i || L(this, t, e, 4, 2147483647, -2147483648), + t < 0 && (t = 4294967295 + t + 1), + r.TYPED_ARRAY_SUPPORT + ? ((this[e] = t >>> 24), + (this[e + 1] = t >>> 16), + (this[e + 2] = t >>> 8), + (this[e + 3] = 255 & t)) + : O(this, t, e, !1), + e + 4 + ) + }), + (r.prototype.writeFloatLE = function (t, e, i) { + return M(this, t, e, !0, i) + }), + (r.prototype.writeFloatBE = function (t, e, i) { + return M(this, t, e, !1, i) + }), + (r.prototype.writeDoubleLE = function (t, e, i) { + return R(this, t, e, !0, i) + }), + (r.prototype.writeDoubleBE = function (t, e, i) { + return R(this, t, e, !1, i) + }), + (r.prototype.copy = function (t, e, i, n) { + if ( + (i || (i = 0), + n || 0 === n || (n = this.length), + e >= t.length && (e = t.length), + e || (e = 0), + n > 0 && n < i && (n = i), + n === i) + ) { + return 0 + } + if (0 === t.length || 0 === this.length) return 0 + if (e < 0) throw new RangeError('targetStart out of bounds') + if (i < 0 || i >= this.length) throw new RangeError('sourceStart out of bounds') + if (n < 0) throw new RangeError('sourceEnd out of bounds') + n > this.length && (n = this.length), + t.length - e < n - i && (n = t.length - e + i) + var o, + s = n - i + if (this === t && i < e && e < n) { + for (o = s - 1; o >= 0; --o) t[o + e] = this[o + i] + } else if (s < 1e3 || !r.TYPED_ARRAY_SUPPORT) { + for (o = 0; o < s; ++o) t[o + e] = this[o + i] + } else Uint8Array.prototype.set.call(t, this.subarray(i, i + s), e) + return s + }), + (r.prototype.fill = function (t, e, i, n) { + if ('string' == typeof t) { + if ( + ('string' == typeof e + ? ((n = e), (e = 0), (i = this.length)) + : 'string' == typeof i && ((n = i), (i = this.length)), + 1 === t.length) + ) { + var o = t.charCodeAt(0) + o < 256 && (t = o) + } + if (void 0 !== n && 'string' != typeof n) { + throw new TypeError('encoding must be a string') + } + if ('string' == typeof n && !r.isEncoding(n)) { + throw new TypeError('Unknown encoding: ' + n) + } + } else 'number' == typeof t && (t &= 255) + if (e < 0 || this.length < e || this.length < i) { + throw new RangeError('Out of range index') + } + if (i <= e) return this + var s + if ( + ((e >>>= 0), + (i = void 0 === i ? this.length : i >>> 0), + t || (t = 0), + 'number' == typeof t) + ) { + for (s = e; s < i; ++s) this[s] = t + } else { + var a = r.isBuffer(t) ? t : I(new r(t, n).toString()), + c = a.length + for (s = 0; s < i - e; ++s) this[s + e] = a[s % c] + } + return this + }) + var N = /[^+\/0-9A-Za-z-_]/g + }.call( + this, + 'undefined' != typeof global + ? global + : 'undefined' != typeof self + ? self + : 'undefined' != typeof window + ? window + : {}, + )) + }, + { 'base64-js': 30, ieee754: 32, isarray: 34 }, + ], + 30: [ + function (t, e, i) { + function n(t) { + var e = t.length + if (e % 4 > 0) throw new Error('Invalid string. Length must be a multiple of 4') + return '=' === t[e - 2] ? 2 : '=' === t[e - 1] ? 1 : 0 + } + function o(t) { + return s[(t >> 18) & 63] + s[(t >> 12) & 63] + s[(t >> 6) & 63] + s[63 & t] + } + function r(t, e, i) { + for (var n, r = [], s = e; s < i; s += 3) { + ;(n = (t[s] << 16) + (t[s + 1] << 8) + t[s + 2]), r.push(o(n)) + } + return r.join('') + } + ;(i.byteLength = function (t) { + return (3 * t.length) / 4 - n(t) + }), + (i.toByteArray = function (t) { + var e, + i, + o, + r, + s, + l, + h = t.length + ;(s = n(t)), (l = new c((3 * h) / 4 - s)), (o = s > 0 ? h - 4 : h) + var u = 0 + for (e = 0, i = 0; e < o; e += 4, i += 3) { + ;(r = + (a[t.charCodeAt(e)] << 18) | + (a[t.charCodeAt(e + 1)] << 12) | + (a[t.charCodeAt(e + 2)] << 6) | + a[t.charCodeAt(e + 3)]), + (l[u++] = (r >> 16) & 255), + (l[u++] = (r >> 8) & 255), + (l[u++] = 255 & r) + } + return ( + 2 === s + ? ((r = (a[t.charCodeAt(e)] << 2) | (a[t.charCodeAt(e + 1)] >> 4)), + (l[u++] = 255 & r)) + : 1 === s && + ((r = + (a[t.charCodeAt(e)] << 10) | + (a[t.charCodeAt(e + 1)] << 4) | + (a[t.charCodeAt(e + 2)] >> 2)), + (l[u++] = (r >> 8) & 255), + (l[u++] = 255 & r)), + l + ) + }), + (i.fromByteArray = function (t) { + for ( + var e, i = t.length, n = i % 3, o = '', a = [], c = 16383, l = 0, h = i - n; + l < h; + l += c + ) { + a.push(r(t, l, l + c > h ? h : l + c)) + } + return ( + 1 === n + ? ((e = t[i - 1]), (o += s[e >> 2]), (o += s[(e << 4) & 63]), (o += '==')) + : 2 === n && + ((e = (t[i - 2] << 8) + t[i - 1]), + (o += s[e >> 10]), + (o += s[(e >> 4) & 63]), + (o += s[(e << 2) & 63]), + (o += '=')), + a.push(o), + a.join('') + ) + }) + for ( + var s = [], + a = [], + c = 'undefined' != typeof Uint8Array ? Uint8Array : Array, + l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', + h = 0, + u = l.length; + h < u; + ++h + ) { + ;(s[h] = l[h]), (a[l.charCodeAt(h)] = h) + } + ;(a['-'.charCodeAt(0)] = 62), (a['_'.charCodeAt(0)] = 63) + }, + {}, + ], + 31: [ + function (t, e, i) { + !(function (t) { + function i(t) { + for (var e in s) t[e] = s[e] + return t + } + function n(t, e) { + function i(t) { + return t !== e && t.originalListener !== e + } + var s, + a = this + if (arguments.length) { + if (e) { + if ((s = o(a, t, !0))) { + if (!(s = s.filter(i)).length) return n.call(a, t) + a[r][t] = s + } + } else if ((s = a[r]) && (delete s[t], !Object.keys(s).length)) return n.call(a) + } else delete a[r] + return a + } + function o(t, e, i) { + if (!i || t[r]) { + var n = t[r] || (t[r] = {}) + return n[e] || (n[e] = []) + } + } + void 0 !== e && (e.exports = t) + var r = 'listeners', + s = { + on: function (t, e) { + return o(this, t).push(e), this + }, + once: function (t, e) { + function i() { + n.call(r, t, i), e.apply(this, arguments) + } + var r = this + return (i.originalListener = e), o(r, t).push(i), r + }, + off: n, + emit: function (t, e) { + function i(t) { + t.call(s) + } + function n(t) { + t.call(s, e) + } + function r(t) { + t.apply(s, l) + } + var s = this, + a = o(s, t, !0) + if (!a) return !1 + var c = arguments.length + if (1 === c) a.forEach(i) + else if (2 === c) a.forEach(n) + else { + var l = Array.prototype.slice.call(arguments, 1) + a.forEach(r) + } + return !!a.length + }, + } + i(t.prototype), (t.mixin = i) + })(function n() { + if (!(this instanceof n)) return new n() + }) + }, + {}, + ], + 32: [ + function (t, e, i) { + ;(i.read = function (t, e, i, n, o) { + var r, + s, + a = 8 * o - n - 1, + c = (1 << a) - 1, + l = c >> 1, + h = -7, + u = i ? o - 1 : 0, + f = i ? -1 : 1, + d = t[e + u] + for ( + u += f, r = d & ((1 << -h) - 1), d >>= -h, h += a; + h > 0; + r = 256 * r + t[e + u], u += f, h -= 8 + ); + for ( + s = r & ((1 << -h) - 1), r >>= -h, h += n; + h > 0; + s = 256 * s + t[e + u], u += f, h -= 8 + ); + if (0 === r) r = 1 - l + else { + if (r === c) return s ? NaN : (1 / 0) * (d ? -1 : 1) + ;(s += Math.pow(2, n)), (r -= l) + } + return (d ? -1 : 1) * s * Math.pow(2, r - n) + }), + (i.write = function (t, e, i, n, o, r) { + var s, + a, + c, + l = 8 * r - o - 1, + h = (1 << l) - 1, + u = h >> 1, + f = 23 === o ? Math.pow(2, -24) - Math.pow(2, -77) : 0, + d = n ? 0 : r - 1, + p = n ? 1 : -1, + m = e < 0 || (0 === e && 1 / e < 0) ? 1 : 0 + for ( + e = Math.abs(e), + isNaN(e) || e === 1 / 0 + ? ((a = isNaN(e) ? 1 : 0), (s = h)) + : ((s = Math.floor(Math.log(e) / Math.LN2)), + e * (c = Math.pow(2, -s)) < 1 && (s--, (c *= 2)), + (e += s + u >= 1 ? f / c : f * Math.pow(2, 1 - u)) * c >= 2 && + (s++, (c /= 2)), + s + u >= h + ? ((a = 0), (s = h)) + : s + u >= 1 + ? ((a = (e * c - 1) * Math.pow(2, o)), (s += u)) + : ((a = e * Math.pow(2, u - 1) * Math.pow(2, o)), (s = 0))); + o >= 8; + t[i + d] = 255 & a, d += p, a /= 256, o -= 8 + ); + for (s = (s << o) | a, l += o; l > 0; t[i + d] = 255 & s, d += p, s /= 256, l -= 8); + t[i + d - p] |= 128 * m + }) + }, + {}, + ], + 33: [ + function (t, e, i) { + ;(function (t) { + !(function (e) { + function i(t, i, b) { + function k(t, e, i, n) { + return this instanceof k + ? (function (t, e, i, n, o) { + if ( + (y && + g && + (e instanceof g && (e = new y(e)), n instanceof g && (n = new y(n))), + !(e || i || n || d)) + ) { + return void (t.buffer = c(v, 0)) + } + if (!s(e, i)) { + ;(o = i), (n = e), (i = 0), (e = new (d || Array)(8)) + } + ;(t.buffer = e), + (t.offset = i |= 0), + p !== typeof n && + ('string' == typeof n + ? (function (t, e, i, n) { + var o = 0, + r = i.length, + s = 0, + a = 0 + '-' === i[0] && o++ + for (var c = o; o < r; ) { + var l = parseInt(i[o++], n) + if (!(l >= 0)) break + ;(a = a * n + l), (s = s * n + Math.floor(a / w)), (a %= w) + } + c && ((s = ~s), a ? (a = w - a) : s++), + _(t, e + A, s), + _(t, e + S, a) + })(e, i, n, o || 10) + : s(n, o) + ? a(e, i, n, o) + : 'number' == typeof o + ? (_(e, i + A, n), _(e, i + S, o)) + : n > 0 + ? H(e, i, n) + : n < 0 + ? M(e, i, n) + : a(e, i, v, 0)) + })(this, t, e, i, n) + : new k(t, e, i, n) + } + function C() { + var t = this.buffer, + e = this.offset, + i = E(t, e + A), + n = E(t, e + S) + return b || (i |= 0), i ? i * w + n : n + } + function _(t, e, i) { + ;(t[e + O] = 255 & i), + (i >>= 8), + (t[e + T] = 255 & i), + (i >>= 8), + (t[e + L] = 255 & i), + (i >>= 8), + (t[e + B] = 255 & i) + } + function E(t, e) { + return t[e + B] * x + (t[e + L] << 16) + (t[e + T] << 8) + t[e + O] + } + var A = i ? 0 : 4, + S = i ? 4 : 0, + B = i ? 0 : 3, + L = i ? 1 : 2, + T = i ? 2 : 1, + O = i ? 3 : 0, + H = i ? l : u, + M = i ? h : f, + R = k.prototype, + P = 'is' + t, + I = '_' + P + return ( + (R.buffer = void 0), + (R.offset = 0), + (R[I] = !0), + (R.toNumber = C), + (R.toString = function (t) { + var e = this.buffer, + i = this.offset, + n = E(e, i + A), + o = E(e, i + S), + r = '', + s = !b && 2147483648 & n + for (s && ((n = ~n), (o = w - o)), t = t || 10; ; ) { + var a = (n % t) * w + o + if ( + ((n = Math.floor(n / t)), + (o = Math.floor(a / t)), + (r = (a % t).toString(t) + r), + !n && !o) + ) { + break + } + } + return s && (r = '-' + r), r + }), + (R.toJSON = C), + (R.toArray = n), + m && (R.toBuffer = o), + y && (R.toArrayBuffer = r), + (k[P] = function (t) { + return !(!t || !t[I]) + }), + (e[t] = k), + k + ) + } + function n(t) { + var e = this.buffer, + i = this.offset + return (d = null), !1 !== t && 0 === i && 8 === e.length && b(e) ? e : c(e, i) + } + function o(e) { + var i = this.buffer, + n = this.offset + if (((d = m), !1 !== e && 0 === n && 8 === i.length && t.isBuffer(i))) return i + var o = new m(8) + return a(o, 0, i, n), o + } + function r(t) { + var e = this.buffer, + i = this.offset, + n = e.buffer + if (((d = y), !1 !== t && 0 === i && n instanceof g && 8 === n.byteLength)) { + return n + } + var o = new y(8) + return a(o, 0, e, i), o.buffer + } + function s(t, e) { + var i = t && t.length + return (e |= 0), i && e + 8 <= i && 'string' != typeof t[e] + } + function a(t, e, i, n) { + ;(e |= 0), (n |= 0) + for (var o = 0; o < 8; o++) t[e++] = 255 & i[n++] + } + function c(t, e) { + return Array.prototype.slice.call(t, e, e + 8) + } + function l(t, e, i) { + for (var n = e + 8; n > e; ) (t[--n] = 255 & i), (i /= 256) + } + function h(t, e, i) { + var n = e + 8 + for (i++; n > e; ) (t[--n] = (255 & -i) ^ 255), (i /= 256) + } + function u(t, e, i) { + for (var n = e + 8; e < n; ) (t[e++] = 255 & i), (i /= 256) + } + function f(t, e, i) { + var n = e + 8 + for (i++; e < n; ) (t[e++] = (255 & -i) ^ 255), (i /= 256) + } + var d, + p = 'undefined', + m = p !== typeof t && t, + y = p !== typeof Uint8Array && Uint8Array, + g = p !== typeof ArrayBuffer && ArrayBuffer, + v = [0, 0, 0, 0, 0, 0, 0, 0], + b = + Array.isArray || + function (t) { + return !!t && '[object Array]' == Object.prototype.toString.call(t) + }, + w = 4294967296, + x = 16777216 + i('Uint64BE', !0, !0), + i('Int64BE', !0, !1), + i('Uint64LE', !1, !0), + i('Int64LE', !1, !1) + })('object' == typeof i && 'string' != typeof i.nodeName ? i : this || {}) + }.call(this, t('buffer').Buffer)) + }, + { buffer: 29 }, + ], + 34: [ + function (t, e, i) { + var n = {}.toString + e.exports = + Array.isArray || + function (t) { + return '[object Array]' == n.call(t) + } + }, + {}, + ], + }, + {}, + [1], + )(1) + }) + var fo = Object.create(null), + po = window.msgpack + delete window.msgpack + var mo = null, + yo = null, + go = [], + vo = null, + bo = null + function wo(t) { + if (Array.isArray(t) && 0 !== t.length) { + t.forEach(function (t) { + ;-1 === go.indexOf(t) && go.push(t) + }) + } + } + function xo() { + return ( + !(!mo || !yo) && + -1 !== ['hsw', 'hsj', 'hsl'].indexOf(mo.type) && + (!('n' in yo.payload) || yo.payload.n === mo.type) + ) + } + var ko = function (t) { + if ((St('Set spec', 'proof', 'info', t), t)) { + ;(mo = t), (yo = null) + try { + Bo((yo = Ht.decode(t.req)))['catch'](function () {}) + } catch (Qr) { + At('proof', Qr) + } + } + }, + Co = function (t) { + t && (vo = t) + }, + _o = function () { + return new Promise(function (t) { + var e = mo, + i = yo + if (e) { + try { + if ((St('Solve Proof', 'proof', 'info', e), !xo())) { + return ( + Et('Asset script invalid file', 'error', 'proof', { seen: e.type, wanted: i.n }), + void t({ solved: null, spec: e }) + ) + } + Promise.resolve() + .then(function () { + return Bo(i) + }) + .then(function (t) { if ('function' != typeof t) { return Promise.reject(new Error('Script is not a function')) } var i = { - assethost: ut.assethost, + assethost: ft.assethost, fetchAsset: function (t) { - return _e - .retrieve(t) + return Be.retrieve(t) .then(function (e) { - return e || _e.file(t, { responseType: 'arraybuffer' }) + return e || Be.file(t, { responseType: 'arraybuffer' }) }) .then(function (t) { return t.data }) }, - href: ho, - ardata: uo, + href: vo, + ardata: bo, } return ( - co.length && (i.errors = co), - si.messages.length && (i.messages = si.messages), + go.length && (i.errors = go), + ui.messages.length && (i.messages = ui.messages), t(e.req, i) ) }) @@ -10691,122 +13655,371 @@ }) ['catch'](function (i) { 'string' == typeof i && -1 !== i.indexOf('http') - ? wt('Asset Script Failed', 'error', 'proof', { error: i }) - : xt('proof', i), + ? Et('Asset Script Failed', 'error', 'proof', { error: i }) + : At('proof', i), t({ solved: 'fail', spec: e }) }) - } catch (Fs) { - xt('proof', Fs), t({ solved: null, spec: e }) + } catch (Qr) { + At('proof', Qr), t({ solved: null, spec: e }) } } else t({ solved: null, spec: null }) }) + }, + Eo = function (t) { + return new Promise(function (e) { + if ((St('d0', 'proof', 'info', mo), !xo())) { + return ( + Et('Asset script invalid file', 'error', 'proof', { + seen: !!mo && mo.type, + wanted: !!yo && yo.n, + }), + e(undefined) + ) + } + Bo(yo) + .then(function (e) { + return 'function' != typeof e + ? Promise.reject(new Error('Script is not a function')) + : e(0, t) + }) + .then(function (t) { + e(po.decode(t)) + }) + ['catch'](function (t) { + At('d0', t), e(undefined) + }) + }) + }, + Ao = function (t) { + return new Promise(function (e) { + if ((St('e1', 'proof', 'info', mo), !xo())) { + return ( + Et('Asset script invalid file', 'error', 'proof', { + seen: !!mo && mo.type, + wanted: !!yo && yo.n, + }), + e(undefined) + ) + } + Bo(yo) + .then(function (e) { + return 'function' != typeof e + ? Promise.reject(new Error('Script is not a function')) + : e(1, po.encode(t)) + }) + .then(function (t) { + e(t) + }) + ['catch'](function (t) { + At('e1', t), e(undefined) + }) + }) + }, + So = function (t) { + return po.encode(t) } - function go(t) { - var e = t.payload.l, - i = t.payload.i, + function Bo(t) { + var e = t.payload.l + '/' === e[0] && (e = ht.assetDomain + e) + var i = t.payload.i, n = t.payload.n, - o = ro[n] + o = fo[n] if (o && o.location === e) return o.promise - var s = e + '/' + n + '.js', - r = _e.script(s, { integrity: i }).then(function () { - var t = window[n] - try { - t('IiI=.eyJzIjowLCJmIjowLCJjIjowfQ==.')['catch'](function () {}) - } catch (Ps) {} - return t - }) - return (ro[n] = { location: e, promise: r }), r + var r = Be.script(e + '/' + n + '.js', { integrity: i }).then(function () { + var t = window[n] + try { + t('IiI=.eyJzIjowLCJmIjowLCJjIjowfQ==.')['catch'](function () {}) + } catch (ts) {} + return t + }) + return (fo[n] = { location: e, promise: r }), r } - var vo = null, - bo = null - function wo(t) { - bo && ((bo.e = Date.now() - bo.s), (bo.r = t), (vo = bo)) + var Lo = null, + To = null + function Oo(t) { + To && ((To.e = Date.now() - To.s), (To.r = t), (Lo = To)) } - function xo() { + function Ho() { try { return Object.keys(window).sort().join(',') - } catch (Ps) { + } catch (ts) { return null } } - var Co, - ko, - _o, - Eo, - So, - Ao, - Lo, - Bo = null, - Ho = null, - Oo = null, - To = null, - Mo = {}, - Vo = null, - Ro = null, - Fo = !1, - Po = { + var Mo = 100 + function Ro(t) { + if ('en' === t) return Promise.resolve() + var e = t + '.json' + return new Promise(function (i, n) { + Be.retrieve(e) + .then(function (i) { + return ( + i || + Be.file(e, { + prefix: 'https://newassets.hcaptcha.com/captcha/v1/a8cd801/static/i18n', + }).then(function (e) { + return ue.addTable(t, e.data), e + }) + ) + }) + .then(function (t) { + i(t.data) + }) + ['catch'](function (t) { + n(t) + }) + }) + } + var Po = [ + '10000000-ffff-ffff-ffff-000000000001', + '20000000-ffff-ffff-ffff-000000000002', + '30000000-ffff-ffff-ffff-000000000003', + ], + Io = { + sitekey: function (t) { + return Zt.UUIDv4(t) || '00000000-0000-0000-0000-000000000000' === t || -1 !== Po.indexOf(t) + }, + dummykey: function (t) { + return -1 !== Po.indexOf(t) + }, + logo: function (t) { + if ('string' == typeof t) return Zt.IMAGE(t) + if (t && 'object' == typeof t && !Array.isArray(t)) { + for (var e in t) { + var i = t[e] + if ('string' == typeof i && !Zt.IMAGE(i)) return !1 + } + return !0 + } + return !1 + }, + } + function Vo() { + var t, + e, + i, + n, + o, + r = Io.dummykey(ht.sitekey) + if ('localhost' === ht.host && !r) { + var s = 'Warning: localhost detected. Please use a valid host.' + return console.error(s), Promise.reject(new Error(s)) + } + return ((t = ht.sitekey), + (e = ht.host), + (i = tt.Browser.supportsCanvas() >>> 0), + (n = tt.Browser.supportsWebAssembly() >>> 0), + (o = tt.Browser.supportsPST() >>> 0), + new Promise(function (r, s) { + var a = { v: 'a8cd801', host: e, sitekey: t, sc: i, swa: n, spst: o } + ft.se && (a.se = ft.se) + var c = 0 + be({ + url: function () { + var e = ft.endpoint + return ( + e === ot && + !Do() && + Math.random() < 0.5 && + -1 === t.indexOf('-0000-0000-0000-') && + (e = rt), + c > 0 && (a.r = c), + e + '/checksiteconfig?' + Pt(a) + ) + }, + responseType: 'json', + withCredentials: !0, + timeout: function (t) { + return t && -1 !== t.indexOf(rt) ? 3e3 : 5e3 + }, + headers: { Accept: 'application/json', 'Content-Type': 'text/plain' }, + retry: { + attempts: 4, + delay: Mo, + onFail: function (t, e) { + ;(c += 1), St('challenge', 'api', 'debug', t) + var i = t && 0 === t.status + return e > 1 && !i + ? { retry: !0, delay: Mo } + : 0 === e && -1 !== ct.indexOf(ft.endpoint) + ? ((ft.endpoint = nt), { retry: !0, delay: 0 }) + : ft.endpoint === st || ft.endpoint === nt + ? ((ft.endpoint = ot), { retry: !0, delay: 0 }) + : ft.endpoint === ot + ? Do() + ? { retry: !0, delay: Mo } + : ((ft.endpoint = rt), { retry: !0, delay: 0 }) + : ft.endpoint === rt + ? ((ft.endpoint = ot), { retry: !0, delay: 0 }) + : (Et('api:checksiteconfig failed', 'error', 'challenge', { error: t }), + { retry: t instanceof Error || 400 === t.status, delay: Mo }) + }, + }, + }) + .then(function (t) { + var e = t.body || null + if (e) { + if (!1 === e.success) { + var i = (e['error-codes'] || []).join(', ') + s(new Error(i)) + } else !e.pass && e.error ? s(new Error(e.error)) : r(e) + } else s(new Error('Missing response body.')) + }) + ['catch'](s) + })).then(function (t) { + return ( + St('/checksiteconfig success', 'request', 'info', t), + t.endpoint && -1 !== ct.indexOf(ft.endpoint) + ? ((ft.endpoint = t.endpoint), Vo()) + : (t.endpoint && -1 !== ct.indexOf(ft.endpoint) && (ft.endpoint = t.endpoint), + delete t.endpoint, + t) + ) + }) + } + function Do() { + return -1 !== ['pt-BR', 'es-BR'].indexOf(navigator.language) + } + var Fo, + $o, + Uo, + jo, + No, + zo, + Zo, + Wo = null, + qo = null, + Ko = null, + Yo = null, + Go = {}, + Jo = null, + Xo = !1, + Qo = !1, + tr = !1, + er = null, + ir = !1, + nr = 100, + or = { logAction: function (t) { - Vo = t + Jo = t + }, + setEncryptionSupport: function (t) { + Xo = t }, getTaskData: function (t, e, i, n, o) { t === undefined && (t = {}) - var s = e.proof, - r = { v: '1bcdbdd', sitekey: ct.sitekey, host: ct.host, hl: se.getLocale() } + var r = e.proof, + s = { v: 'a8cd801', sitekey: ht.sitekey, host: ht.host, hl: ue.getLocale() } + o && (s.r = o), + ft.se && (s.se = ft.se), + !0 === ht.a11y_tfe && (s.a11y_tfe = !0), + null !== Jo && ((s.action = Jo), (Jo = null)), + null !== Yo && ((s.extraData = JSON.stringify(Yo)), (Yo = null)), + t && (s.motionData = JSON.stringify(t)), + i && (s.pd = JSON.stringify(i)), + n && (s.pdc = JSON.stringify(n)) + var a = (function () { + if (!performance || !performance.getEntriesByType) return null + var t, + e, + i = {}, + n = performance.getEntriesByType('resource') + for (t = 0; t < n.length; t += 1) { + ;-1 !== (e = n[t]).name.indexOf('checksiteconfig') + ? (i.csc = e.duration) + : -1 !== e.name.indexOf('getcaptcha') && (i.gc = e.duration) + } + return i + })() return ( - o && (r.r = o), - ut.se && (r.se = ut.se), - !0 === ct.a11y_tfe && (r.a11y_tfe = !0), - null !== Vo && ((r.action = Vo), (Vo = null)), - null !== To && ((r.extraData = JSON.stringify(To)), (To = null)), - t && (r.motionData = JSON.stringify(t)), - i && (r.pd = JSON.stringify(i)), - n && (r.pdc = JSON.stringify(n)), - null !== Bo && ((Ho = Bo), (r.old_ekey = Bo)), - null !== Ro && (r.rqdata = Ro), - s && ((r.n = s.solved || null), (r.c = s.spec ? JSON.stringify(s.spec) : null)), - e.authToken && (r.auth_token = e.authToken), - e.hasPst !== undefined && (r.pst = e.hasPst), + a && (s.pem = JSON.stringify(a)), + null !== Wo && ((qo = Wo), (s.old_ekey = Wo)), + null !== er && (s.rqdata = er), + r && ((s.n = r.solved || null), (s.c = r.spec ? JSON.stringify(r.spec) : null)), + e.authToken && (s.auth_token = e.authToken), + e.hasPst !== undefined && (s.pst = e.hasPst), new Promise(function (t, i) { try { - pe({ - url: ut.endpoint + '/getcaptcha/' + r.sitekey, - data: r, - dataType: 'query', - responseType: 'json', - withCredentials: !0, - pst: e.hasPst ? 'send-redemption-record' : null, - headers: { - Accept: 'application/json', - 'Content-type': 'application/x-www-form-urlencoded', - }, + var n = 'arraybuffer', + o = 'query', + r = { + accept: 'application/json, application/octet-stream', + 'content-type': 'application/x-www-form-urlencoded', + } + Qo && ((n = 'json'), (r.accept = 'application/json')) + var a, + c = s + if (('ArrayBuffer' in window || (Xo = !1), Xo)) { + To && ((To.gces = Date.now() - To.s), (To.gcee = null)) + var l = JSON.parse(JSON.stringify(s)) + delete l.c, + (a = Ao(l).then(function (t) { + t + ? (To && (To.gcee = Date.now() - To.s), + (c = So([s.c, t])), + (o = 'arraybuffer'), + (r['content-type'] = 'application/octet-stream')) + : (Xo = !1) + })) + } else a = Promise.resolve() + a.then(function () { + return be({ + url: ft.endpoint + '/getcaptcha/' + s.sitekey, + data: c, + dataType: o, + responseType: n, + withCredentials: !0, + pst: e.hasPst ? 'send-redemption-record' : null, + headers: r, + }) }) + .then(function (t) { + var e = t.body || null + if (!e) throw new Error('Missing response body.') + if ('ArrayBuffer' in window && e instanceof ArrayBuffer) { + return ( + To && ((To.gcds = Date.now() - To.s), (To.gcde = null)), + Eo(new Uint8Array(e)).then(function (t) { + if (!t) throw new Error('error-parse-body') + return To && (To.gcde = Date.now() - To.s), t + }) + ) + } + if ('string' == typeof e) throw new Error('unhandled-getcaptcha-res-type-string') + return e + }) .then(function (e) { - var i = e.body || null - if (!i) throw new Error('Missing response body.') - if (!1 === i.success) { + if (!1 === e.success) { + var i = e['error-codes'] || [] return ( - -1 !== (i['error-codes'] || []).indexOf('invalid-data') && - wt('invalid-data', 'error', 'api', { motionData: r.motionData }), - void t(i) + !1 === tr && + !0 === Qo && + 0 === i.length && + (i.push('expired-session'), (tr = !0)), + -1 !== i.indexOf('invalid-data') && + Et('invalid-data', 'error', 'api', { motionData: s.motionData }), + void t(e) ) } - Po.setData(i), t(i) + or.setData(e), t(e) + }) + ['catch'](function (t) { + ;(Qo = !0), (Xo = !1), i(t) }) - ['catch'](i) - } catch (Ps) { - i(Ps) + } catch (ts) { + i(ts) } }) ) }, loadBundle: function (t) { return new Promise(function (e, i) { - if (Mo[t]) e(Mo[t]) + if (Go[t]) e(Go[t]) else { - var n = Po.createBundleUrl(t) - _e.script(n) + var n = or.createBundleUrl(t) + Be.script(n) .then(function () { - ;(Mo[t] = window[t]), e(Mo[t]) + ;(Go[t] = window[t]), e(Go[t]) }) ['catch'](function (t) { i({ event: it.BUNDLE_ERROR, message: 'Failed to get challenge bundle.', reason: t }) @@ -10816,25 +14029,25 @@ }, createBundleUrl: function (t) { return ( - (ut.assethost || ct.assetDomain) + '/captcha/challenge/' + t + '/1bcdbdd/challenge.js' + (ft.assethost || ht.assetDomain) + '/captcha/challenge/' + t + '/a8cd801/challenge.js' ) }, checkAnswers: function (t, e, i) { var n = { - v: '1bcdbdd', - job_mode: To.request_type, + v: 'a8cd801', + job_mode: Yo.request_type, answers: t, - serverdomain: ct.host, - sitekey: ct.sitekey, + serverdomain: ht.host, + sitekey: ht.sitekey, motionData: JSON.stringify(e), } - ut.se && (n.se = ut.se), i && ((n.n = i.solved), (n.c = JSON.stringify(i.spec))) + ft.se && (n.se = ft.se), i && ((n.n = i.solved), (n.c = JSON.stringify(i.spec))) var o = 0 return new Promise(function (t, e) { try { - pe({ + be({ url: function () { - return ut.endpoint + '/checkcaptcha/' + n.sitekey + '/' + To.key + return ft.endpoint + '/checkcaptcha/' + n.sitekey + '/' + Yo.key }, data: function () { return o > 0 && (n.r = o), n @@ -10845,22 +14058,24 @@ headers: { 'Content-type': 'application/json;charset=UTF-8' }, retry: { attempts: 4, - delay: 100, + delay: nr, onFail: function (t, e) { - ;(o += 1), Ct('checkcaptcha', 'api', 'debug', t) + ;(o += 1), St('checkcaptcha', 'api', 'debug', t) var i = t && 0 === t.status return e > 1 && !i - ? { retry: !0, delay: 100 } - : 0 === e && -1 !== at.indexOf(ut.endpoint) - ? ((ut.endpoint = nt), { retry: !0, delay: 0 }) - : ut.endpoint === rt || ut.endpoint === nt - ? ((ut.endpoint = ot), { retry: !0, delay: 0 }) - : ut.endpoint === ot - ? ((ut.endpoint = st), { retry: !0, delay: 0 }) - : ut.endpoint === st - ? ((ut.endpoint = ot), { retry: !0, delay: 0 }) - : (wt('api:checkcaptcha failed', 'error', 'challenge', { error: t }), - { retry: !0, delay: 100 }) + ? { retry: !0, delay: nr } + : 0 === e && -1 !== ct.indexOf(ft.endpoint) + ? ((ft.endpoint = nt), { retry: !0, delay: 0 }) + : ft.endpoint === st || ft.endpoint === nt + ? ((ft.endpoint = ot), { retry: !0, delay: 0 }) + : ft.endpoint === ot + ? Do() + ? { retry: !0, delay: nr } + : ((ft.endpoint = rt), { retry: !0, delay: 0 }) + : ft.endpoint === rt + ? ((ft.endpoint = ot), { retry: !0, delay: 0 }) + : (Et('api:checkcaptcha failed', 'error', 'challenge', { error: t }), + { retry: !0, delay: nr }) }, }, }) @@ -10870,32 +14085,32 @@ if (!1 === i.success) { var o = i['error-codes'] || [''] ;-1 !== o.indexOf('invalid-data') && - wt('invalid-data', 'error', 'api', { motionData: n.motionData }) - var s = o.join(', ') - throw new Error(s) + Et('invalid-data', 'error', 'api', { motionData: n.motionData }) + var r = o.join(', ') + throw new Error(r) } t(i) }) ['catch'](e) - } catch (Ps) { - e(Ps) + } catch (ts) { + e(ts) } }) }, reportIssue: function (t, e, i) { - var n = { taskdata: To, on_url: ct.url, report_category: t, sid: Oo } + var n = { taskdata: Yo, on_url: ht.url, report_category: t, sid: Ko } if ( (e && (n.user_comments = e), - Ho && (n.last_ekey = Ho), - i && To && 'fallback' !== To.request_type) + qo && (n.last_ekey = qo), + i && Yo && 'fallback' !== Yo.request_type) ) { - for (var o = To.tasklist, s = null, r = -1; ++r < o.length && !s; ) { - o[r].task_key === i && (s = o[r]) + for (var o = Yo.tasklist, r = null, s = -1; ++s < o.length && !r; ) { + o[s].task_key === i && (r = o[s]) } - n.taskdata.tasklist = [s] + n.taskdata.tasklist = [r] } - return pe({ - url: ut.reportapi + '/bug-report', + return be({ + url: ft.reportapi + '/bug-report', data: n, dataType: 'json', responseType: 'json', @@ -10904,32 +14119,32 @@ }) }, getEKey: function () { - return Bo + return Wo }, setData: function (t) { - ;(To = t), (Bo = t.key), (Fo = !!t.rq), Oo || (Oo = Bo) + ;(Yo = t), (Wo = t.key), (ir = !!t.rq), Ko || (Ko = Wo) }, setRqData: function (t) { - Ro = t + er = t }, getRqData: function () { - return Ro + return er }, hasPrivateStateToken: function () { return document.hasPrivateToken ? new Promise(function (t) { document - .hasRedemptionRecord(ut.pstIssuer) + .hasRedemptionRecord(ft.pstIssuer) .then(function (e) { e ? t(!0) : document - .hasPrivateToken(ut.pstIssuer, 'private-state-token') + .hasPrivateToken(ft.pstIssuer, 'private-state-token') .then(function (e) { if (e) { - var i = { v: '1bcdbdd', sitekey: ct.sitekey, host: ct.host } - pe({ - url: ut.pstIssuer + '/pst/redemption', + var i = { v: 'a8cd801', sitekey: ht.sitekey, host: ht.host } + be({ + url: ft.pstIssuer + '/pst/redemption', data: i, dataType: 'json', responseType: 'json', @@ -10944,33 +14159,33 @@ t(!0) }) ['catch'](function (e) { - vt(e), t(undefined) + kt(e), t(undefined) }) } else t(!1) }) ['catch'](function (e) { - vt(e), t(undefined) + kt(e), t(undefined) }) }) ['catch'](function (e) { - vt(e), t(undefined) + kt(e), t(undefined) }) }) : Promise.resolve(undefined) }, isRqChl: function () { - return Fo + return ir }, getData: function () { - return To + return Yo }, authenticate: function (t) { - var e = { v: '1bcdbdd', sitekey: ct.sitekey, host: ct.host } + var e = { v: 'a8cd801', sitekey: ht.sitekey, host: ht.host } return ( - ut.se && (e.se = ut.se), + ft.se && (e.se = ft.se), t && ((e.n = t.solved || null), (e.c = t.spec ? JSON.stringify(t.spec) : null)), - pe({ - url: ut.endpoint + '/authenticate', + be({ + url: ft.endpoint + '/authenticate', data: e, dataType: 'json', responseType: 'json', @@ -10988,198 +14203,87 @@ ) }, }, - Do = - ((Co = []), - (ko = null), - (_o = !1), - (Eo = []), - (So = function (t) { + rr = + ((Fo = []), + ($o = null), + (Uo = !1), + (jo = []), + (No = function (t) { try { - if (Co.length >= 10) return + if (Fo.length >= 10) return var e = t.stack if ('string' != typeof e) return var i = e.trim().split('\n') 'Error' === i[0] && (i = i.slice(1)) - var n = gt((i = i.slice(-2))) - n && -1 === Co.indexOf(n) && Co.push(n) + var n = wt((i = i.slice(-2))) + n && -1 === Fo.indexOf(n) && Fo.push(n) } catch (t) { return } }), - (Ao = function () { - if (_o) { + (zo = function () { + if (Uo) { try { - for (var t = 0; t < Eo.length; t++) Eo[t]() - null !== ko && clearTimeout(ko) + for (var t = 0; t < jo.length; t++) jo[t]() + null !== $o && clearTimeout($o) } catch (e) { - So(e) + No(e) } finally { - ;(Eo = []), (ko = null), (_o = !1) + ;(jo = []), ($o = null), (Uo = !1) } } }), - (Lo = function (t, e) { + (Zo = function (t, e) { var i = Object.getOwnPropertyDescriptor(t, e) if (!i || !1 !== i.writable) { var n = Object.prototype.hasOwnProperty.call(t, e), o = t[e] ;(t[e] = function () { - return _o && (Co.length >= 10 && Ao(), So(new Error())), o.apply(t, arguments) + return Uo && (Fo.length >= 10 && zo(), No(new Error())), o.apply(t, arguments) }), - Eo.push(function () { + jo.push(function () { n ? (t[e] = o) : delete t[e] }) } }), { run: function (t) { - if (!_o) { - ;(_o = !0), + if (!Uo) { + ;(Uo = !0), isFinite(t) && - (ko = setTimeout(function () { - Ao() + ($o = setTimeout(function () { + zo() }, t)) try { - Lo(document, 'getElementsByClassName'), - Lo(document, 'getElementById'), - Lo(document, 'querySelector'), - Lo(document, 'querySelectorAll') + Zo(document, 'getElementsByClassName'), + Zo(document, 'getElementById'), + Zo(document, 'querySelector'), + Zo(document, 'querySelectorAll') } catch (e) { - Ao(), So(e) + zo(), No(e) } } }, collect: function () { - return Co.concat(yt) - }, - }) - function Io(t) { - if ('en' === t) return Promise.resolve() - var e = t + '.json' - return new Promise(function (i, n) { - _e.retrieve(e) - .then(function (i) { - return ( - i || - _e - .file(e, { prefix: 'https://newassets.hcaptcha.com/captcha/v1/1bcdbdd/static/i18n' }) - .then(function (e) { - return se.addTable(t, e.data), e - }) - ) - }) - .then(function (t) { - i(t.data) - }) - ['catch'](function (t) { - n(t) - }) - }) - } - var $o = [ - '10000000-ffff-ffff-ffff-000000000001', - '20000000-ffff-ffff-ffff-000000000002', - '30000000-ffff-ffff-ffff-000000000003', - ], - jo = { - sitekey: function (t) { - return It.UUIDv4(t) || '00000000-0000-0000-0000-000000000000' === t || -1 !== $o.indexOf(t) - }, - dummykey: function (t) { - return -1 !== $o.indexOf(t) - }, - } - function No() { - var t, - e, - i, - n, - o, - s = jo.dummykey(ct.sitekey) - if ('localhost' === ct.host && !s) { - var r = 'Warning: localhost detected. Please use a valid host.' - return console.error(r), Promise.reject(new Error(r)) - } - return ((t = ct.sitekey), - (e = ct.host), - (i = tt.Browser.supportsCanvas() >>> 0), - (n = tt.Browser.supportsWebAssembly() >>> 0), - (o = tt.Browser.supportsPST() >>> 0), - new Promise(function (s, r) { - var a = { v: '1bcdbdd', host: e, sitekey: t, sc: i, swa: n, spst: o } - ut.se && (a.se = ut.se) - var l = 0 - pe({ - url: function () { - var e = ut.endpoint - return ( - e === ot && Math.random() < 0.2 && -1 === t.indexOf('-0000-0000-0000-') && (e = st), - l > 0 && (a.r = l), - e + '/checksiteconfig?' + Ht(a) - ) - }, - responseType: 'json', - withCredentials: !0, - timeout: 5e3, - headers: { Accept: 'application/json', 'Content-Type': 'text/plain' }, - retry: { - attempts: 4, - delay: 100, - onFail: function (t, e) { - ;(l += 1), Ct('challenge', 'api', 'debug', t) - var i = t && 0 === t.status - return e > 1 && !i - ? { retry: !0, delay: 100 } - : 0 === e && -1 !== at.indexOf(ut.endpoint) - ? ((ut.endpoint = nt), { retry: !0, delay: 0 }) - : ut.endpoint === rt || ut.endpoint === nt - ? ((ut.endpoint = ot), { retry: !0, delay: 0 }) - : ut.endpoint === ot - ? ((ut.endpoint = st), { retry: !0, delay: 0 }) - : ut.endpoint === st - ? ((ut.endpoint = ot), { retry: !0, delay: 0 }) - : (wt('api:checksiteconfig failed', 'error', 'challenge', { error: t }), - { retry: t instanceof Error || 400 === t.status, delay: 100 }) - }, + return Fo.concat(bt) }, }) - .then(function (t) { - var e = t.body || null - if (e) { - if (!1 === e.success) { - var i = (e['error-codes'] || []).join(', ') - r(new Error(i)) - } else !e.pass && e.error ? r(new Error(e.error)) : s(e) - } else r(new Error('Missing response body.')) - }) - ['catch'](r) - })).then(function (t) { - return ( - Ct('/checksiteconfig success', 'request', 'info', t), - t.endpoint && -1 !== at.indexOf(ut.endpoint) - ? ((ut.endpoint = t.endpoint), No()) - : (t.endpoint && -1 !== at.indexOf(ut.endpoint) && (ut.endpoint = t.endpoint), - delete t.endpoint, - t) - ) - }) - } - var zo = new Ci() - zo.add('contrast', {}), - zo.add('grey-red', { component: { checkbox: { main: { border: '#6a6a6a' } } } }) - function Zo() { - Jt.self(this, Yt, '#a11y-label'), + var sr = new Bi() + sr.add('contrast', {}), + sr.add('grey-red', { component: { checkbox: { main: { border: '#6a6a6a' } } } }) + function ar() { + ie.self(this, ne, '#a11y-label'), (this.state = { ticked: !1 }), this.setAttribute('aria-hidden', !0), this.css({ display: 'none' }), this.translate() } - function Uo(t) { + function cr(t) { var e = t.get(), i = e.palette, n = e.component, o = 'light' === i.mode - return Ci.merge( + return Bi.merge( { main: { fill: i.grey[100], border: i.grey[o ? 600 : 200] }, focus: { @@ -11191,10 +14295,10 @@ n.input, ) } - function Wo() { - Jt.self(this, Yt, '#checkbox'), + function lr() { + ie.self(this, ne, '#checkbox'), (this.state = { focused: !1, visible: !0, passed: !1 }), - (this._style = Uo(zo)), + (this._style = cr(sr)), this.setAttribute('aria-haspopup', !0), this.setAttribute('aria-checked', !1), this.setAttribute('role', 'checkbox'), @@ -11210,22 +14314,23 @@ this.addEventListener('focus', this.onFocus), this.addEventListener('blur', this.onBlur) } - Jt.proto(Zo, Yt), - (Zo.prototype.setState = function (t) { + ie.proto(ar, ne), + (ar.prototype.setState = function (t) { ;(this.state.ticked = 'passed' === t), this.translate() }), - (Zo.prototype.translate = function () { + (ar.prototype.translate = function () { var t = this.state.ticked - ? 'hCaptcha checkbox. You are verified' - : 'hCaptcha checkbox. Select in order to trigger the challenge, or to bypass it if you have an accessibility cookie.' - this.content(se.translate(t)) + ? "hCaptcha checkbox with text 'I am human' is now checked. You are verified" + : "hCaptcha checkbox with text 'I am human'. Select in order to trigger the challenge, or to bypass it if you have an accessibility cookie." + this.content(ue.translate(t)) }), - Jt.proto(Wo, Yt), - (Wo.prototype.style = function () { - this._style = Uo(zo) + ie.proto(lr, ne), + (lr.prototype.style = function () { + this._style = cr(sr) var t = this.state.visible ? this._style.main.fill : 'transparent', e = this.state.focused ? this._style.focus.border : this._style.main.border, - i = this.state.visible ? e : 'transparent' + i = this.state.visible ? e : 'transparent', + n = this._style.focus.outline this.css({ position: 'absolute', width: 28, @@ -11235,49 +14340,49 @@ borderColor: i, borderRadius: 4, backgroundColor: t, - outlineColor: this._style.focus.outline, + outlineColor: n, top: 0, left: 0, }) }), - (Wo.prototype.onOver = function (t) { + (lr.prototype.onOver = function (t) { this.state.focused || ((this.state.focused = 'focus' === t.action), this.css({ borderColor: this._style.focus.border })) }), - (Wo.prototype.onOut = function (t) { + (lr.prototype.onOut = function (t) { if ('blur' === t.action) this.state.focused = !1 else if (this.state.focused) return this.css({ borderColor: this._style.main.border }) }), - (Wo.prototype.onFocus = function (t) { + (lr.prototype.onFocus = function (t) { var e = this._style.focus.outline this.css({ outline: '2px solid ' + e }) }), - (Wo.prototype.onBlur = function (t) { + (lr.prototype.onBlur = function (t) { this.css({ outline: 'none' }) }), - (Wo.prototype.display = function (t) { + (lr.prototype.display = function (t) { ;(this.state.visible = t), this.setAttribute('tabindex', t ? 0 : -1), this.style() }), - (Wo.prototype.setState = function (t) { + (lr.prototype.setState = function (t) { ;(this.state.passed = 'passed' === t), (this.state.visible = 'loading' !== t && 'passed' !== t), this.setAttribute('tabindex', 'loading' === t || 'solving' === t ? -1 : 0), this.setAttribute('aria-checked', this.state.passed), this.style() }) - function Ko() { - Jt.self(this, Bi, { + function hr() { + ie.self(this, Pi, { selector: '.pulse', src: "data:image/svg+xml,%3c%3fxml version='1.0' encoding='utf-8'%3f%3e%3c!-- Generator: Adobe Illustrator 21.0.2%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 44 44' style='enable-background:new 0 0 44 44%3b' xml:space='preserve'%3e%3cstyle type='text/css'%3e .st0%7bfill:none%3bstroke:%23FF7B00%3bstroke-width:2%3b%7d%3c/style%3e%3cg%3e %3ccircle class='st0' cx='22' cy='22' r='1'%3e %3canimate accumulate='none' additive='replace' attributeName='r' begin='0s' calcMode='spline' dur='1.8s' fill='remove' keySplines='0.165%2c 0.84%2c 0.44%2c 1' keyTimes='0%3b 1' repeatCount='indefinite' restart='always' values='1%3b 20'%3e %3c/animate%3e %3canimate accumulate='none' additive='replace' attributeName='stroke-opacity' begin='0s' calcMode='spline' dur='1.8s' fill='remove' keySplines='0.3%2c 0.61%2c 0.355%2c 1' keyTimes='0%3b 1' repeatCount='indefinite' restart='always' values='1%3b 0'%3e %3c/animate%3e %3c/circle%3e %3ccircle class='st0' cx='22' cy='22' r='1'%3e %3canimate accumulate='none' additive='replace' attributeName='r' begin='-0.9s' calcMode='spline' dur='1.8s' fill='remove' keySplines='0.165%2c 0.84%2c 0.44%2c 1' keyTimes='0%3b 1' repeatCount='indefinite' restart='always' values='1%3b 20'%3e %3c/animate%3e %3canimate accumulate='none' additive='replace' attributeName='stroke-opacity' begin='-0.9s' calcMode='spline' dur='1.8s' fill='remove' keySplines='0.3%2c 0.61%2c 0.355%2c 1' keyTimes='0%3b 1' repeatCount='indefinite' restart='always' values='1%3b 0'%3e %3c/animate%3e %3c/circle%3e%3c/g%3e%3c/svg%3e", width: 30, - fallback: 'https://newassets.hcaptcha.com/captcha/v1/1bcdbdd/static/images/pulse.png', + fallback: 'https://newassets.hcaptcha.com/captcha/v1/a8cd801/static/images/pulse.png', }), (this.state = { visible: !1 }) } - Jt.proto(Ko, Bi), - (Ko.prototype.style = function () { + ie.proto(hr, Pi), + (hr.prototype.style = function () { this.size(), this.css({ display: this.state.visible ? 'block' : 'none', @@ -11286,32 +14391,32 @@ left: 0, }) }), - (Ko.prototype.display = function (t) { + (hr.prototype.display = function (t) { ;(this.state.visible = t), this.style() }) - function qo() { - Jt.self(this, Bi, { + function ur() { + ie.self(this, Pi, { selector: '.check', src: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAC00lEQVR4nO2aTU8TQRyHn39bIdXEm3jwLQhefPkAJorYLYslIF64ohwM8eQH0A/gzYSLIRooxBORKJr4Ultq4smz8YgQb3ow4YAmUHY8IEpgd7vQ3e0smee4+5/uPL+daXdmCwaDwWAwGAwGg8FgMBgM+wBr0u7JFe17QWrTUXcmbqxJuwdhTpDejsHO7Ne5hbJf/b4KYFMeJAuAcKleCPsmgB3ymwiX2m901BZfLHx0a5eKpXcR4ykPgPqdEvnk1Vai7Fgc1JMXkevlm+88p0CiA2hUHhIcQBjykNAAwpKHBAYQpjwkLICw5SFBAUQhDwkJICp5SEAAUcqD5gFELQ8aBxCHPGgaQFzyoGEAccpDwNXgxZmhLCr6sPJTvXk/eRSDYcpDgAAGxgcOZleW31hF+1GUIViTdo9S6qXfna+MlN6HfV3fAApjhdZfrauzInIFkdGoQoh72G/FM4ChmaGW1cPOM+Dav4MRhNBMefAJ4OfK8hjQv+OEyKhV7H0YRgjNmPPb8QxgndQDYMn1pHC30ZHQrDm/Hc8APoy8XVK1dDew6FrQwHTIFe0uRJ43a9hvpW7nc0/6TklmvQq0uxYoNV65VbqDoIJcMFe0uwR5DRxy+bBY5SHgg1B+On9SOZkqqNOuBQFD0E0edvEkuBFCeh7ocC2oE4KO8rCL9wLl4fK3tKOuAguuBT7fCbrKwx7WAvaEfcJJybyCTteCbSNBZ3nY42Ko+2nheKbmVOuFkJuyL+ssDw2sBnNT/cdErVWBMx4ls6D6/B5y4vidr0dDT3PWY+soBzLzwNngrfS485s09HK0crvynbVaDvgSrIVe8hDShsjfkVABznlX6ScPIe4I2dN2W82RisD5nWf1lIeQt8Tsabtt3aEMcuH/UX3lIeQ/SJSGSz9anLQF6vPGEb3lIaJN0cJE4ciaOK9IcV9n+WiJYRPVYDAYDAaDoRH+ALzfixyrasnFAAAAAElFTkSuQmCC', width: 30, }), (this.state = { visible: !1 }) } - function Go() { - Jt.self(this, Yt, '#anchor-wr'), (this.state = { loading: !1, checked: !1 }) + function fr() { + ie.self(this, ne, '#anchor-wr'), (this.state = { loading: !1, checked: !1 }) var t = this.createElement('#anchor-td'), e = t.createElement('#anchor-tc'), i = e.createElement('#anchor-state') - ;(this.a11y = this.initComponent(Zo)), - (this.input = this.initComponent(Wo, null, i)), - (this.loading = this.initComponent(Ko, null, i)), - (this.checked = this.initComponent(qo, null, i)), + ;(this.a11y = this.initComponent(ar)), + (this.input = this.initComponent(lr, null, i)), + (this.loading = this.initComponent(hr, null, i)), + (this.checked = this.initComponent(ur, null, i)), (this.table = t), (this.cell = e), (this.wrapper = i) } - Jt.proto(qo, Bi), - (qo.prototype.style = function () { + ie.proto(ur, Pi), + (ur.prototype.style = function () { this.size(), this.css({ display: this.state.visible ? 'block' : 'none', @@ -11321,11 +14426,11 @@ animation: this.state.visible ? 'pop 0.4s linear' : 'auto', }) }), - (qo.prototype.display = function (t) { + (ur.prototype.display = function (t) { ;(this.state.visible = t), this.style() }), - Jt.proto(Go, Yt), - (Go.prototype.style = function (t) { + ie.proto(fr, ne), + (fr.prototype.style = function (t) { var e = t ? 60 : '100%', i = t ? '0px 12px' : '0px 15px' this.css({ @@ -11341,12 +14446,12 @@ this.loading.style(), this.checked.style() }), - (Go.prototype.describeBy = function (t) { + (fr.prototype.describeBy = function (t) { t && t.dom && t.dom.id ? this.input.setAttribute('aria-describedby', t.dom.id) : this.input.removeAttribute('aria-describedby') }), - (Go.prototype.setState = function (t) { + (fr.prototype.setState = function (t) { var e = 'loading' === t, i = 'passed' === t this.checked.display(i), @@ -11356,10 +14461,10 @@ (this.state.loading = e), (this.state.checked = i) }), - (Go.prototype.focus = function () { + (fr.prototype.focus = function () { this.input.focus() }), - (Go.prototype.getLocation = function () { + (fr.prototype.getLocation = function () { var t = this.input.dom.getBoundingClientRect(), e = t.bottom - t.top, i = t.right - t.left @@ -11374,89 +14479,89 @@ y: t.top + e / 2, } }), - (Go.prototype.translate = function () { + (fr.prototype.translate = function () { this.a11y.translate() }) - function Jo() { - Jt.self(this, Yt, 'label-container'), + function dr() { + ie.self(this, ne, 'label-container'), (this.table = this.createElement('label-td')), (this.cell = this.table.createElement('label-tc')), (this.text = this.cell.createElement('#label')), this.translate() } - Jt.proto(Jo, Yt), - (Jo.prototype.style = function (t) { + ie.proto(dr, ne), + (dr.prototype.style = function (t) { var e = t ? 60 : '100%', i = t ? 100 : 170, - n = zo.get().palette + n = sr.get().palette this.css({ position: 'relative', display: 'inline-block', height: e, width: i }), this.table.css({ position: 'relative', display: 'table', top: 0, height: '100%' }), this.cell.css({ display: 'table-cell', verticalAlign: 'middle' }), this.text.css({ color: n.text.body, fontSize: 14 }) }), - (Jo.prototype.translate = function () { - var t = se.translate('I am human') + (dr.prototype.translate = function () { + var t = ue.translate('I am human') this.text.content(t) }) - var Yo = 'Privacy', - Xo = 'https://hcaptcha.com/privacy', - Qo = 'hCaptcha Privacy Policy', - ts = 'Terms', - es = 'https://hcaptcha.com/terms', - is = 'hCaptcha Terms of Service' - function ns(t) { - Jt.self(this, Yt, 'anchor-links'), + var pr = 'Privacy', + mr = 'https://hcaptcha.com/privacy', + yr = 'hCaptcha Privacy Policy', + gr = 'Terms', + vr = 'https://hcaptcha.com/terms', + br = 'hCaptcha Terms of Service' + function wr(t) { + ie.self(this, ne, 'anchor-links'), (this.state = { theme: t.theme, size: t.size }), - (this.privacy = this.initComponent(Si, { - theme: zo, - text: Yo, + (this.privacy = this.initComponent(Hi, { + theme: sr, + text: pr, url: - (t.privacyUrl || Xo) + + (t.privacyUrl || mr) + '?ref=' + - ct.host + + ht.host + '&utm_campaign=' + - ct.sitekey + + ht.sitekey + '&utm_medium=checkbox', })), - (this.hyphen = this.initComponent(Ai, { text: ' - ' })), - (this.terms = this.initComponent(Si, { - theme: zo, - text: ts, + (this.hyphen = this.initComponent(Mi, { text: ' - ' })), + (this.terms = this.initComponent(Hi, { + theme: sr, + text: gr, url: - (t.termsUrl || es) + + (t.termsUrl || vr) + '?ref=' + - ct.host + + ht.host + '&utm_campaign=' + - ct.sitekey + + ht.sitekey + '&utm_medium=checkbox', })), this.translate() } - Jt.proto(ns, Yt), - (ns.prototype.style = function () { + ie.proto(wr, ne), + (wr.prototype.style = function () { var t = (function (t) { var e = t.palette, i = t.component, n = 'light' === e.mode - return Ci.merge({ main: e.grey[n ? 700 : 200] }, i.link) - })(zo.get()), + return Bi.merge({ main: e.grey[n ? 700 : 200] }, i.link) + })(sr.get()), e = { fontSize: 8, color: t.main } this.privacy.style(e), this.hyphen.style(e), this.terms.style(e) }), - (ns.prototype.translate = function () { + (wr.prototype.translate = function () { this.privacy.translate(), this.terms.translate(), - this.privacy.setAttribute('aria-label', se.translate(Qo)), - this.terms.setAttribute('aria-label', se.translate(is)) + this.privacy.setAttribute('aria-label', ue.translate(yr)), + this.terms.setAttribute('aria-label', ue.translate(br)) }) - var os = 'https://www.hcaptcha.com/what-is-hcaptcha-about', - ss = 'Visit hcaptcha.com to learn more about the service and its accessibility options.' - function rs(t) { - Jt.self(this, Yt, 'anchor-brand'), + var xr = 'https://www.hcaptcha.com/what-is-hcaptcha-about', + kr = 'Visit hcaptcha.com to learn more about the service and its accessibility options.' + function Cr(t) { + ie.self(this, ne, 'anchor-brand'), (this.state = { url: t.logoUrl || - os + '?ref=' + ct.host + '&utm_campaign=' + ct.sitekey + '&utm_medium=checkbox', + xr + '?ref=' + ht.host + '&utm_campaign=' + ht.sitekey + '&utm_medium=checkbox', theme: 'dark' === t.theme ? 'dark' : 'light', display: t.displayLogo, label: 'hCaptcha', @@ -11466,40 +14571,40 @@ ? "data:image/svg+xml,%3csvg width='44' height='46' viewBox='0 0 44 46' role='img' aria-hidden='true' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath opacity='0.5' d='M30 28H26V32H30V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M26 28H22V32H26V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M22 28H18V32H22V28Z' fill='%230074BF'/%3e%3cpath opacity='0.5' d='M18 28H14V32H18V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M34 24H30V28H34V24Z' fill='%230082BF'/%3e%3cpath opacity='0.8' d='M30 24H26V28H30V24Z' fill='%230082BF'/%3e%3cpath d='M26 24H22V28H26V24Z' fill='%230082BF'/%3e%3cpath d='M22 24H18V28H22V24Z' fill='%230082BF'/%3e%3cpath opacity='0.8' d='M18 24H14V28H18V24Z' fill='%230082BF'/%3e%3cpath opacity='0.7' d='M14 24H10V28H14V24Z' fill='%230082BF'/%3e%3cpath opacity='0.5' d='M38 20H34V24H38V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.8' d='M34 20H30V24H34V20Z' fill='%23008FBF'/%3e%3cpath d='M30 20H26V24H30V20Z' fill='%23008FBF'/%3e%3cpath d='M26 20H22V24H26V20Z' fill='%23008FBF'/%3e%3cpath d='M22 20H18V24H22V20Z' fill='%23008FBF'/%3e%3cpath d='M18 20H14V24H18V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.8' d='M14 20H10V24H14V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.5' d='M10 20H6V24H10V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.7' d='M38 16H34V20H38V16Z' fill='%23009DBF'/%3e%3cpath d='M34 16H30V20H34V16Z' fill='%23009DBF'/%3e%3cpath d='M30 16H26V20H30V16Z' fill='%23009DBF'/%3e%3cpath d='M26 16H22V20H26V16Z' fill='%23009DBF'/%3e%3cpath d='M22 16H18V20H22V16Z' fill='%23009DBF'/%3e%3cpath d='M18 16H14V20H18V16Z' fill='%23009DBF'/%3e%3cpath d='M14 16H10V20H14V16Z' fill='%23009DBF'/%3e%3cpath opacity='0.7' d='M10 16H6V20H10V16Z' fill='%23009DBF'/%3e%3cpath opacity='0.7' d='M38 12H34V16H38V12Z' fill='%2300ABBF'/%3e%3cpath d='M34 12H30V16H34V12Z' fill='%2300ABBF'/%3e%3cpath d='M30 12H26V16H30V12Z' fill='%2300ABBF'/%3e%3cpath d='M26 12H22V16H26V12Z' fill='%2300ABBF'/%3e%3cpath d='M22 12H18V16H22V12Z' fill='%2300ABBF'/%3e%3cpath d='M18 12H14V16H18V12Z' fill='%2300ABBF'/%3e%3cpath d='M14 12H10V16H14V12Z' fill='%2300ABBF'/%3e%3cpath opacity='0.7' d='M10 12H6V16H10V12Z' fill='%2300ABBF'/%3e%3cpath opacity='0.5' d='M38 8H34V12H38V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.8' d='M34 8H30V12H34V8Z' fill='%2300B9BF'/%3e%3cpath d='M30 8H26V12H30V8Z' fill='%2300B9BF'/%3e%3cpath d='M26 8H22V12H26V8Z' fill='%2300B9BF'/%3e%3cpath d='M22 8H18V12H22V8Z' fill='%2300B9BF'/%3e%3cpath d='M18 8H14V12H18V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.8' d='M14 8H10V12H14V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.5' d='M10 8H6V12H10V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.7' d='M34 4H30V8H34V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.8' d='M30 4H26V8H30V4Z' fill='%2300C6BF'/%3e%3cpath d='M26 4H22V8H26V4Z' fill='%2300C6BF'/%3e%3cpath d='M22 4H18V8H22V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.8' d='M18 4H14V8H18V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.7' d='M14 4H10V8H14V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.5' d='M30 0H26V4H30V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.7' d='M26 0H22V4H26V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.7' d='M22 0H18V4H22V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.5' d='M18 0H14V4H18V0Z' fill='%2300D4BF'/%3e%3cpath d='M16.5141 14.9697L17.6379 12.4572C18.0459 11.8129 17.9958 11.0255 17.5449 10.5745C17.4876 10.5173 17.416 10.46 17.3444 10.4171C17.0366 10.2238 16.6572 10.1808 16.3065 10.2954C15.9199 10.4171 15.5835 10.6748 15.3687 11.0184C15.3687 11.0184 13.8297 14.6046 13.2642 16.2153C12.6987 17.8259 12.9206 20.7822 15.1254 22.987C17.4661 25.3277 20.8448 25.8575 23.0066 24.2397C23.0997 24.1967 23.1784 24.1395 23.2572 24.0751L29.9072 18.5202C30.2293 18.2554 30.7089 17.7042 30.2794 17.0743C29.8642 16.4586 29.0697 16.881 28.7404 17.0886L24.9107 19.8731C24.8391 19.9304 24.7318 19.9232 24.6673 19.8517C24.6673 19.8517 24.6673 19.8445 24.6602 19.8445C24.56 19.7228 24.5456 19.4079 24.696 19.2862L30.5657 14.304C31.074 13.8459 31.1456 13.1802 30.7304 12.7292C30.3295 12.2854 29.6924 12.2997 29.1842 12.7578L23.9157 16.881C23.8155 16.9597 23.6652 16.9454 23.5864 16.8452L23.5793 16.838C23.4719 16.7235 23.4361 16.5231 23.5506 16.4014L29.535 10.596C30.0074 10.1522 30.036 9.4149 29.5922 8.94245C29.3775 8.72054 29.084 8.59169 28.7762 8.59169C28.4612 8.59169 28.1606 8.70623 27.9387 8.92813L21.8255 14.6691C21.6823 14.8122 21.396 14.6691 21.3602 14.4973C21.3459 14.4328 21.3674 14.3684 21.4103 14.3255L26.0918 8.99972C26.5571 8.56306 26.5858 7.83292 26.1491 7.36763C25.7124 6.90234 24.9823 6.87371 24.517 7.31036C24.4955 7.32468 24.4812 7.34615 24.4597 7.36763L17.3659 15.2203C17.1082 15.478 16.736 15.4851 16.557 15.342C16.4425 15.2489 16.4282 15.0843 16.5141 14.9697Z' fill='white'/%3e%3cpath d='M4.99195 43.6627H3.32946V40.8306C3.32946 40.1764 3.2488 39.6073 2.55423 39.6073C1.85966 39.6073 1.64905 40.2167 1.64905 41.0144V43.6627H0V36.112H1.64905V37.9045C1.64905 38.4512 1.64008 39.0427 1.64008 39.0427C1.89999 38.5632 2.38395 38.1689 3.13677 38.1689C4.61106 38.1689 4.99195 39.1637 4.99195 40.4766V43.6627Z' fill='%23555555'/%3e%3cpath d='M12.081 42.762C11.7181 43.1563 10.9652 43.7882 9.51337 43.7882C7.42069 43.7882 5.77612 42.3228 5.77612 39.8941C5.77612 37.4564 7.43861 36 9.50889 36C10.9742 36 11.7674 36.6453 11.9556 36.8514L11.4402 38.3167C11.3058 38.1285 10.544 37.5281 9.60299 37.5281C8.39757 37.5281 7.4655 38.3795 7.4655 39.8582C7.4655 41.337 8.43342 42.175 9.60299 42.175C10.4902 42.175 11.131 41.803 11.5209 41.3773L12.081 42.762Z' fill='%23555555'/%3e%3cpath d='M17.3016 43.6627H15.7242L15.6928 43.0936C15.4777 43.3221 15.0655 43.7837 14.2365 43.7837C13.3403 43.7837 12.3903 43.2684 12.3903 42.0674C12.3903 40.8665 13.4344 40.4587 14.3709 40.4139L15.6525 40.3601V40.2391C15.6525 39.67 15.2716 39.3743 14.6084 39.3743C13.9586 39.3743 13.3089 39.679 13.049 39.8538L12.6143 38.72C13.049 38.4915 13.8421 38.1733 14.7921 38.1733C15.7421 38.1733 16.2888 38.4019 16.6921 38.7962C17.082 39.1906 17.3016 39.7148 17.3016 40.6245V43.6627ZM15.657 41.2877L14.8414 41.3415C14.3351 41.3639 14.0348 41.5924 14.0348 41.9957C14.0348 42.4125 14.353 42.6634 14.8101 42.6634C15.2537 42.6634 15.5539 42.3587 15.657 42.1705V41.2877Z' fill='%23555555'/%3e%3cpath d='M21.6034 43.7792C20.8506 43.7792 20.3129 43.4835 19.9947 42.9816V45.6389H18.3456V38.2674H19.914L19.9051 38.9575H19.9275C20.2994 38.487 20.8461 38.1689 21.6213 38.1689C23.0867 38.1689 24.0142 39.3832 24.0142 40.9696C24.0142 42.5559 23.0777 43.7792 21.6034 43.7792ZM21.1284 39.549C20.4249 39.549 19.9409 40.1181 19.9409 40.9471C19.9409 41.7762 20.4249 42.3453 21.1284 42.3453C21.8409 42.3453 22.3249 41.7762 22.3249 40.9471C22.3249 40.1181 21.8409 39.549 21.1284 39.549Z' fill='%23555555'/%3e%3cpath d='M27.8321 39.6028H26.7074V41.5386C26.7074 42.0002 26.7701 42.1077 26.8508 42.2063C26.9225 42.296 27.0255 42.3363 27.2406 42.3363C27.4109 42.3318 27.5767 42.3004 27.738 42.2377L27.8187 43.6044C27.4378 43.7165 27.039 43.7747 26.6446 43.7792C26.0576 43.7792 25.6633 43.591 25.4079 43.2773C25.1524 42.9636 25.0449 42.511 25.0449 41.691V39.6028H24.3234V38.2809H25.0449V36.8156H26.7074V38.2809H27.8321V39.6028Z' fill='%23555555'/%3e%3cpath d='M32.7121 43.1339C32.6583 43.1787 32.1251 43.7792 30.7718 43.7792C29.3781 43.7792 28.0876 42.771 28.0876 40.9785C28.0876 39.1726 29.3961 38.1689 30.7897 38.1689C32.0892 38.1689 32.6762 38.738 32.6762 38.738L32.3133 40.0599C31.9458 39.7507 31.4843 39.5804 31.0048 39.5804C30.3013 39.5804 29.7456 40.0957 29.7456 40.9471C29.7456 41.7986 30.252 42.3363 31.0272 42.3363C31.8024 42.3363 32.3178 41.812 32.3178 41.812L32.7121 43.1339Z' fill='%23555555'/%3e%3cpath d='M38.3986 43.6627H36.7361V40.8306C36.7361 40.1764 36.6555 39.6073 35.9609 39.6073C35.2663 39.6073 35.0512 40.2212 35.0512 41.0188V43.6672H33.4067V36.112H35.0557V37.9045C35.0557 38.4512 35.0468 39.0427 35.0468 39.0427C35.3067 38.5632 35.7906 38.1689 36.5435 38.1689C38.0177 38.1689 38.3986 39.1637 38.3986 40.4766V43.6627Z' fill='%23555555'/%3e%3cpath d='M44 43.6627H42.4226L42.3913 43.0936C42.1762 43.3221 41.7639 43.7837 40.9349 43.7837C40.0387 43.7837 39.0887 43.2684 39.0887 42.0674C39.0887 40.8665 40.1328 40.4587 41.0693 40.4139L42.3509 40.3601V40.2391C42.3509 39.67 41.97 39.3743 41.3068 39.3743C40.6571 39.3743 40.0073 39.679 39.7474 39.8538L39.3127 38.7156C39.7474 38.487 40.5406 38.1689 41.4906 38.1689C42.4405 38.1689 42.9872 38.3974 43.3905 38.7917C43.7804 39.1861 44 39.7104 44 40.62V43.6627ZM42.3599 41.2877L41.5443 41.3415C41.038 41.3639 40.7377 41.5924 40.7377 41.9957C40.7377 42.4125 41.0559 42.6634 41.513 42.6634C41.9566 42.6634 42.2568 42.3587 42.3599 42.1705V41.2877V41.2877Z' fill='%23555555'/%3e%3c/svg%3e" : "data:image/svg+xml,%3csvg width='44' height='46' viewBox='0 0 44 46' role='img' aria-hidden='true' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath opacity='0.5' d='M30 28H26V32H30V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M26 28H22V32H26V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M22 28H18V32H22V28Z' fill='%230074BF'/%3e%3cpath opacity='0.5' d='M18 28H14V32H18V28Z' fill='%230074BF'/%3e%3cpath opacity='0.7' d='M34 24H30V28H34V24Z' fill='%230082BF'/%3e%3cpath opacity='0.8' d='M30 24H26V28H30V24Z' fill='%230082BF'/%3e%3cpath d='M26 24H22V28H26V24Z' fill='%230082BF'/%3e%3cpath d='M22 24H18V28H22V24Z' fill='%230082BF'/%3e%3cpath opacity='0.8' d='M18 24H14V28H18V24Z' fill='%230082BF'/%3e%3cpath opacity='0.7' d='M14 24H10V28H14V24Z' fill='%230082BF'/%3e%3cpath opacity='0.5' d='M38 20H34V24H38V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.8' d='M34 20H30V24H34V20Z' fill='%23008FBF'/%3e%3cpath d='M30 20H26V24H30V20Z' fill='%23008FBF'/%3e%3cpath d='M26 20H22V24H26V20Z' fill='%23008FBF'/%3e%3cpath d='M22 20H18V24H22V20Z' fill='%23008FBF'/%3e%3cpath d='M18 20H14V24H18V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.8' d='M14 20H10V24H14V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.5' d='M10 20H6V24H10V20Z' fill='%23008FBF'/%3e%3cpath opacity='0.7' d='M38 16H34V20H38V16Z' fill='%23009DBF'/%3e%3cpath d='M34 16H30V20H34V16Z' fill='%23009DBF'/%3e%3cpath d='M30 16H26V20H30V16Z' fill='%23009DBF'/%3e%3cpath d='M26 16H22V20H26V16Z' fill='%23009DBF'/%3e%3cpath d='M22 16H18V20H22V16Z' fill='%23009DBF'/%3e%3cpath d='M18 16H14V20H18V16Z' fill='%23009DBF'/%3e%3cpath d='M14 16H10V20H14V16Z' fill='%23009DBF'/%3e%3cpath opacity='0.7' d='M10 16H6V20H10V16Z' fill='%23009DBF'/%3e%3cpath opacity='0.7' d='M38 12H34V16H38V12Z' fill='%2300ABBF'/%3e%3cpath d='M34 12H30V16H34V12Z' fill='%2300ABBF'/%3e%3cpath d='M30 12H26V16H30V12Z' fill='%2300ABBF'/%3e%3cpath d='M26 12H22V16H26V12Z' fill='%2300ABBF'/%3e%3cpath d='M22 12H18V16H22V12Z' fill='%2300ABBF'/%3e%3cpath d='M18 12H14V16H18V12Z' fill='%2300ABBF'/%3e%3cpath d='M14 12H10V16H14V12Z' fill='%2300ABBF'/%3e%3cpath opacity='0.7' d='M10 12H6V16H10V12Z' fill='%2300ABBF'/%3e%3cpath opacity='0.5' d='M38 8H34V12H38V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.8' d='M34 8H30V12H34V8Z' fill='%2300B9BF'/%3e%3cpath d='M30 8H26V12H30V8Z' fill='%2300B9BF'/%3e%3cpath d='M26 8H22V12H26V8Z' fill='%2300B9BF'/%3e%3cpath d='M22 8H18V12H22V8Z' fill='%2300B9BF'/%3e%3cpath d='M18 8H14V12H18V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.8' d='M14 8H10V12H14V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.5' d='M10 8H6V12H10V8Z' fill='%2300B9BF'/%3e%3cpath opacity='0.7' d='M34 4H30V8H34V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.8' d='M30 4H26V8H30V4Z' fill='%2300C6BF'/%3e%3cpath d='M26 4H22V8H26V4Z' fill='%2300C6BF'/%3e%3cpath d='M22 4H18V8H22V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.8' d='M18 4H14V8H18V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.7' d='M14 4H10V8H14V4Z' fill='%2300C6BF'/%3e%3cpath opacity='0.5' d='M30 0H26V4H30V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.7' d='M26 0H22V4H26V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.7' d='M22 0H18V4H22V0Z' fill='%2300D4BF'/%3e%3cpath opacity='0.5' d='M18 0H14V4H18V0Z' fill='%2300D4BF'/%3e%3cpath d='M16.5141 14.9697L17.6379 12.4572C18.0459 11.8129 17.9958 11.0255 17.5449 10.5745C17.4876 10.5173 17.416 10.46 17.3444 10.4171C17.0366 10.2238 16.6572 10.1808 16.3065 10.2954C15.9199 10.4171 15.5835 10.6748 15.3687 11.0184C15.3687 11.0184 13.8297 14.6046 13.2642 16.2153C12.6987 17.8259 12.9206 20.7822 15.1254 22.987C17.4661 25.3277 20.8448 25.8575 23.0066 24.2397C23.0997 24.1967 23.1784 24.1395 23.2572 24.0751L29.9072 18.5202C30.2293 18.2554 30.7089 17.7042 30.2794 17.0743C29.8642 16.4586 29.0697 16.881 28.7404 17.0886L24.9107 19.8731C24.8391 19.9304 24.7318 19.9232 24.6673 19.8517C24.6673 19.8517 24.6673 19.8445 24.6602 19.8445C24.56 19.7228 24.5456 19.4079 24.696 19.2862L30.5657 14.304C31.074 13.8459 31.1456 13.1802 30.7304 12.7292C30.3295 12.2854 29.6924 12.2997 29.1842 12.7578L23.9157 16.881C23.8155 16.9597 23.6652 16.9454 23.5864 16.8452L23.5793 16.838C23.4719 16.7235 23.4361 16.5231 23.5506 16.4014L29.535 10.596C30.0074 10.1522 30.036 9.4149 29.5922 8.94245C29.3775 8.72054 29.084 8.59169 28.7762 8.59169C28.4612 8.59169 28.1606 8.70623 27.9387 8.92813L21.8255 14.6691C21.6823 14.8122 21.396 14.6691 21.3602 14.4973C21.3459 14.4328 21.3674 14.3684 21.4103 14.3255L26.0918 8.99972C26.5571 8.56306 26.5858 7.83292 26.1491 7.36763C25.7124 6.90234 24.9823 6.87371 24.517 7.31036C24.4955 7.32468 24.4812 7.34615 24.4597 7.36763L17.3659 15.2203C17.1082 15.478 16.736 15.4851 16.557 15.342C16.4425 15.2489 16.4282 15.0843 16.5141 14.9697Z' fill='white'/%3e%3cpath d='M4.99195 43.6627H3.32946V40.8306C3.32946 40.1764 3.2488 39.6073 2.55423 39.6073C1.85966 39.6073 1.64905 40.2167 1.64905 41.0144V43.6627H0V36.112H1.64905V37.9045C1.64905 38.4512 1.64008 39.0427 1.64008 39.0427C1.89999 38.5632 2.38395 38.1689 3.13677 38.1689C4.61106 38.1689 4.99195 39.1637 4.99195 40.4766V43.6627Z' fill='white'/%3e%3cpath d='M12.081 42.762C11.7181 43.1563 10.9652 43.7882 9.51337 43.7882C7.42069 43.7882 5.77612 42.3228 5.77612 39.8941C5.77612 37.4564 7.43861 36 9.50889 36C10.9742 36 11.7674 36.6453 11.9556 36.8514L11.4402 38.3167C11.3058 38.1285 10.544 37.5281 9.60299 37.5281C8.39757 37.5281 7.4655 38.3795 7.4655 39.8582C7.4655 41.337 8.43342 42.175 9.60299 42.175C10.4902 42.175 11.131 41.803 11.5209 41.3773L12.081 42.762Z' fill='white'/%3e%3cpath d='M17.3016 43.6627H15.7242L15.6928 43.0936C15.4777 43.3221 15.0655 43.7837 14.2365 43.7837C13.3403 43.7837 12.3903 43.2684 12.3903 42.0674C12.3903 40.8665 13.4344 40.4587 14.3709 40.4139L15.6525 40.3601V40.2391C15.6525 39.67 15.2716 39.3743 14.6084 39.3743C13.9586 39.3743 13.3089 39.679 13.049 39.8538L12.6143 38.72C13.049 38.4915 13.8421 38.1733 14.7921 38.1733C15.7421 38.1733 16.2888 38.4019 16.6921 38.7962C17.082 39.1906 17.3016 39.7148 17.3016 40.6245V43.6627ZM15.657 41.2877L14.8414 41.3415C14.3351 41.3639 14.0348 41.5924 14.0348 41.9957C14.0348 42.4125 14.353 42.6634 14.8101 42.6634C15.2537 42.6634 15.5539 42.3587 15.657 42.1705V41.2877Z' fill='white'/%3e%3cpath d='M21.6035 43.7792C20.8506 43.7792 20.3129 43.4835 19.9948 42.9816V45.6389H18.3457V38.2674H19.9141L19.9051 38.9575H19.9275C20.2995 38.487 20.8462 38.1689 21.6214 38.1689C23.0867 38.1689 24.0143 39.3832 24.0143 40.9696C24.0143 42.5559 23.0778 43.7792 21.6035 43.7792ZM21.1285 39.549C20.4249 39.549 19.941 40.1181 19.941 40.9471C19.941 41.7762 20.4249 42.3453 21.1285 42.3453C21.841 42.3453 22.3249 41.7762 22.3249 40.9471C22.3249 40.1181 21.841 39.549 21.1285 39.549Z' fill='white'/%3e%3cpath d='M27.8322 39.6028H26.7074V41.5386C26.7074 42.0002 26.7702 42.1077 26.8508 42.2063C26.9225 42.296 27.0256 42.3363 27.2407 42.3363C27.411 42.3318 27.5768 42.3004 27.7381 42.2377L27.8188 43.6044C27.4379 43.7165 27.039 43.7747 26.6447 43.7792C26.0577 43.7792 25.6633 43.591 25.4079 43.2773C25.1525 42.9636 25.0449 42.511 25.0449 41.691V39.6028H24.3235V38.2809H25.0449V36.8156H26.7074V38.2809H27.8322V39.6028Z' fill='white'/%3e%3cpath d='M32.712 43.1339C32.6583 43.1787 32.125 43.7792 30.7717 43.7792C29.3781 43.7792 28.0875 42.771 28.0875 40.9785C28.0875 39.1726 29.396 38.1689 30.7896 38.1689C32.0892 38.1689 32.6762 38.738 32.6762 38.738L32.3132 40.0599C31.9458 39.7507 31.4842 39.5804 31.0047 39.5804C30.3012 39.5804 29.7455 40.0957 29.7455 40.9471C29.7455 41.7986 30.2519 42.3363 31.0271 42.3363C31.8024 42.3363 32.3177 41.812 32.3177 41.812L32.712 43.1339Z' fill='white'/%3e%3cpath d='M38.3986 43.6627H36.7361V40.8306C36.7361 40.1764 36.6554 39.6073 35.9608 39.6073C35.2663 39.6073 35.0512 40.2212 35.0512 41.0188V43.6672H33.4066V36.112H35.0557V37.9045C35.0557 38.4512 35.0467 39.0427 35.0467 39.0427C35.3066 38.5632 35.7906 38.1689 36.5434 38.1689C38.0177 38.1689 38.3986 39.1637 38.3986 40.4766V43.6627Z' fill='white'/%3e%3cpath d='M44 43.6627H42.4227L42.3913 43.0936C42.1762 43.3221 41.764 43.7837 40.935 43.7837C40.0387 43.7837 39.0887 43.2684 39.0887 42.0674C39.0887 40.8665 40.1328 40.4587 41.0694 40.4139L42.351 40.3601V40.2391C42.351 39.67 41.9701 39.3743 41.3069 39.3743C40.6571 39.3743 40.0074 39.679 39.7475 39.8538L39.3128 38.7156C39.7475 38.487 40.5406 38.1689 41.4906 38.1689C42.4406 38.1689 42.9873 38.3974 43.3906 38.7917C43.7805 39.1861 44 39.7104 44 40.62V43.6627ZM42.3599 41.2877L41.5444 41.3415C41.038 41.3639 40.7378 41.5924 40.7378 41.9957C40.7378 42.4125 41.0559 42.6634 41.513 42.6634C41.9566 42.6634 42.2569 42.3587 42.3599 42.1705V41.2877V41.2877Z' fill='white'/%3e%3c/svg%3e", i = - 'https://newassets.hcaptcha.com/captcha/v1/1bcdbdd/static/images/logo_combination-' + + 'https://newassets.hcaptcha.com/captcha/v1/a8cd801/static/images/logo_combination-' + this.state.theme + '.png' t.logo && ((i = 'png'), (e = 'object' == typeof t.logo ? t.logo[this.state.theme] || t.logo.light : t.logo)) - var n = { theme: zo, url: this.state.url, src: e, fallback: i, autoLoad: this.state.display } - this.logo = this.initComponent(rn, n) + var n = { theme: sr, url: this.state.url, src: e, fallback: i, autoLoad: this.state.display } + this.logo = this.initComponent(fn, n) } - function as(t) { - Jt.self(this, Yt, 'anchor-info'), + function _r(t) { + ie.self(this, ne, 'anchor-info'), (this.state = { size: t.size }), - (this.brand = this.initComponent(rs, t)), - t.linksOff || (this.links = this.initComponent(ns, t)) + (this.brand = this.initComponent(Cr, t)), + t.linksOff || (this.links = this.initComponent(wr, t)) } - function ls() { - Jt.self(this, Yt, '#status'), + function Er() { + ie.self(this, ne, '#status'), (this.state = { visible: !1, copy: '' }), this.translate(), this.setAttribute('aria-hidden', !0), this.setAttribute('aria-live', 'polite') } - function cs() { - Jt.self(this, Yt, '#warning'), + function Ar() { + ie.self(this, ne, '#warning'), (this.state = { visible: !1, copy: '' }), - (this.$copy = this.initComponent(Li, { selector: '.warning-text', theme: zo })), + (this.$copy = this.initComponent(Ri, { selector: '.warning-text', theme: sr })), this.setAttribute('aria-hidden', !0), this.setAttribute('aria-live', 'polite') } - function hs(t) { + function Sr(t) { var e = t.palette, i = t.component, n = 'light' === e.mode - return Ci.merge( + return Bi.merge( { main: { fill: e.grey[n ? 100 : 800], border: e.grey[n ? 300 : 200] }, hover: { fill: e.grey[n ? 200 : 900] }, @@ -11507,8 +14612,8 @@ i.checkbox, ) } - function us(t) { - Jt.self(this, nn, { selector: '#anchor', theme: zo }), + function Br(t) { + ie.self(this, ln, { selector: '#anchor', theme: sr, tabbable: !1 }), (this.state = { selected: !1, warning: !1, @@ -11517,27 +14622,27 @@ defaultVisible: 'invisible' !== t.size, }), (this.config = t), - (this._style = hs(zo.get())), + (this._style = Sr(sr.get())), this.setVisible(this.state.defaultVisible), (this.onClick = this.onClick.bind(this)), (this.onHover = this.onHover.bind(this)), - (this.anchor = this.initComponent(Go)), - (this.label = this.initComponent(Jo)), - (this.info = this.initComponent(as, this.config)), - (this.status = this.initComponent(ls)), - (this.warning = this.initComponent(cs)), + (this.anchor = this.initComponent(fr)), + (this.label = this.initComponent(dr)), + (this.info = this.initComponent(_r, this.config)), + (this.status = this.initComponent(Er)), + (this.warning = this.initComponent(Ar)), this.addEventListener('enter', this.onClick), this.addEventListener('click', this.onClick), this.addEventListener('over', this.onHover), this.addEventListener('out', this.onHover) } - function ds(t, e) { + function Lr(t, e) { var i = this - t instanceof Gt || (t = new Gt(t)), - (ct.host = e.host ? e.host : ''), - (ct.sitekey = e.sitekey ? e.sitekey : '') - var n = new ii(), - o = new us(e) + t instanceof ee || (t = new ee(t)), + (ht.host = e.host ? e.host : ''), + (ht.sitekey = e.sitekey ? e.sitekey : '') + var n = new ci(), + o = new Br(e) return ( o.style(), o.reset(), @@ -11586,42 +14691,42 @@ return o.getLogoUrl() }), (i.theme = function (t, e) { - e ? (zo.add(t, zo.extend(zo.active(), e)), zo.use(t)) : zo.use(t), o.style() + e ? (sr.add(t, sr.extend(sr.active(), e)), sr.use(t)) : sr.use(t), o.style() }), i ) } - function ps(t, e) { + function Tr(t, e) { ;(this.cause = t), (this.message = e) } - function fs(t) { - ps.call(this, it.INVALID_CAPTCHA_ID, 'Invalid hCaptcha id: ' + t) + function Or(t) { + Tr.call(this, it.INVALID_CAPTCHA_ID, 'Invalid hCaptcha id: ' + t) } - function ms() { - ps.call(this, it.MISSING_CAPTCHA, 'No hCaptcha exists.') + function Hr() { + Tr.call(this, it.MISSING_CAPTCHA, 'No hCaptcha exists.') } - function ys() { - ps.call( + function Mr() { + Tr.call( this, it.MISSING_SITEKEY, - 'Missing sitekey - https://hcaptcha.com/docs/configuration#jsapi', + 'Missing sitekey - https://docs.hcaptcha.com/configuration#javascript-api', ) } - Jt.proto(rs, Yt), - (rs.prototype.style = function () { + ie.proto(Cr, ne), + (Cr.prototype.style = function () { if (this.state.display) { this.logo.size(44, 50), this.logo.css({ margin: '0 auto' }) } }), - (rs.prototype.translate = function () { - this.logo.setAttribute('aria-label', se.translate(ss)), + (Cr.prototype.translate = function () { + this.logo.setAttribute('aria-label', ue.translate(kr)), this.setAttribute('title', this.state.label) }), - (rs.prototype.getLogoUrl = function () { + (Cr.prototype.getLogoUrl = function () { return this.state.url }), - Jt.proto(as, Yt), - (as.prototype.style = function () { + ie.proto(_r, ne), + (_r.prototype.style = function () { var t = this.state.size, e = { display: 'inline-block', height: '100%', width: 65 }, i = { margin: '0 auto', top: this.links ? 6 : 10, position: 'relative' }, @@ -11640,15 +14745,24 @@ this.brand.style(), this.brand.css(i) }), - (as.prototype.translate = function () { + (_r.prototype.setVisible = function (t) { + if (this.links) { + var e = '-1' + t && (e = '0'), + this.brand.logo.setAttribute('tabindex', e), + this.links.privacy.setAttribute('tabindex', e), + this.links.terms.setAttribute('tabindex', e) + } + }), + (_r.prototype.translate = function () { this.links && this.links.translate(), this.brand.translate() }), - (as.prototype.getLogoUrl = function () { + (_r.prototype.getLogoUrl = function () { return this.brand.getLogoUrl() }), - Jt.proto(ls, Yt), - (ls.prototype.style = function () { - var t = zo.get().palette + ie.proto(Er, ne), + (Er.prototype.style = function () { + var t = sr.get().palette this.css({ display: this.state.visible ? 'block' : 'none', color: t.warn.main, @@ -11658,7 +14772,7 @@ position: 'absolute', }) }), - (ls.prototype.set = function (t, e) { + (Er.prototype.set = function (t, e) { if (t && t.indexOf('invalid-challenge') >= 0) { var i = t.replace(/-/g, ' ') t = i.charAt(0).toUpperCase() + i.slice(1) + '.' @@ -11670,27 +14784,27 @@ : this.removeAttribute('aria-label'), this.css({ display: this.state.visible ? 'block' : 'none' }) }), - (ls.prototype.reset = function () { + (Er.prototype.reset = function () { ;(this.state.visible = !1), (this.state.copy = ''), this.removeAttribute('aria-label'), this.setAttribute('aria-hidden', !0), this.css({ display: 'none' }) }), - (ls.prototype.translate = function () { + (Er.prototype.translate = function () { if ('' !== this.state.copy) { - var t = se.translate(this.state.copy) + var t = ue.translate(this.state.copy) this.setAttribute('aria-label', t), this.content(t) } }), - (ls.prototype.isVisible = function () { + (Er.prototype.isVisible = function () { return this.state.visible }), - Jt.proto(cs, Yt), - (cs.prototype.style = function (t) { + ie.proto(Ar, ne), + (Ar.prototype.style = function (t) { var e = t ? '95%' : '75%', i = t ? 50 : 5, - n = zo.get().palette + n = sr.get().palette this.css({ display: this.state.visible ? 'block' : 'none', color: n.warn.main, @@ -11701,25 +14815,25 @@ position: 'absolute', }) }), - (cs.prototype.set = function (t) { + (Ar.prototype.set = function (t) { ;(this.state.visible = t && '' !== t), (this.state.copy = t), this.state.visible ? this.translate() : this.removeAttribute('aria-label'), this.css({ display: this.state.visible ? 'block' : 'none' }) }), - (cs.prototype.translate = function () { + (Ar.prototype.translate = function () { if ('' !== this.state.copy) { - var t = se.translate(this.state.copy) + var t = ue.translate(this.state.copy) this.setAttribute('aria-label', t), this.$copy.parseText(t) } }), - (cs.prototype.isVisible = function () { + (Ar.prototype.isVisible = function () { return this.state.visible }), - Jt.proto(us, nn), - (us.prototype.style = function () { + ie.proto(Br, ln), + (Br.prototype.style = function () { var t = 'compact' === this.config.size - ;(this._style = hs(zo.get())), + ;(this._style = Sr(sr.get())), this.info.style(), this.anchor.style(t), this.label.style(t), @@ -11739,139 +14853,142 @@ } this.setStyle(n) }), - (us.prototype.onHover = function (t) { + (Br.prototype.onHover = function (t) { var e = 'over' === t.action ? 'hover' : 'main' this.css({ backgroundColor: this._style[e].fill }) }), - (us.prototype.onClick = function (t) { + (Br.prototype.onClick = function (t) { var e = t.target || t.srcElement, i = 'string' == typeof e.className ? e.className : '', n = i.indexOf('logo') >= 0 || i.indexOf('link') >= 0 if (this.state.selected || t.defaultPrevented || n) return !0 this.emit('select', t) }), - (us.prototype.select = function () { + (Br.prototype.select = function () { ;(this.state.selected = !0), this.setLoading(!0), this.setAttribute('aria-hidden', !0), + this.setAttribute('tabindex', '-1'), this.anchor.setAttribute('aria-checked', 'mixed'), - this.anchor.setAttribute('tabindex', '-1') + this.anchor.setAttribute('tabindex', '-1'), + this.info.setVisible(!1) }), - (us.prototype.reset = function () { + (Br.prototype.reset = function () { ;(this.state.ticked = !1), (this.state.selected = !1), this.setVisible(this.state.defaultVisible), + this.info.setVisible(this.state.defaultVisible), this.anchor.setState(null), this.css({ cursor: 'pointer' }) }), - (us.prototype.setLoading = function (t) { + (Br.prototype.setLoading = function (t) { this.state.loading = t var e = t ? 'loading' : this.state.selected ? 'solving' : null this.anchor.setState(e), this.css({ cursor: 'default' }) }), - (us.prototype.tick = function () { + (Br.prototype.tick = function () { ;(this.state.ticked = !0), this.anchor.setState('passed'), this.css({ cursor: 'default' }) }), - (us.prototype.translate = function () { + (Br.prototype.translate = function () { this.anchor.translate(), this.info.translate(), this.label.translate(), this.status.translate(), this.warning.translate() }), - (us.prototype.getLogoUrl = function () { + (Br.prototype.getLogoUrl = function () { return this.info.getLogoUrl() }), - (ps.prototype = Error.prototype) - var gs = [], - vs = [], - bs = { + (Tr.prototype = Error.prototype) + var Rr = [], + Pr = [], + Ir = { add: function (t) { - gs.push(t) + Rr.push(t) }, remove: function (t) { - for (var e = !1, i = gs.length; --i > -1 && !1 === e; ) { - gs[i].id === t.id && ((e = gs[i]), gs.splice(i, 1)) + for (var e = !1, i = Rr.length; --i > -1 && !1 === e; ) { + Rr[i].id === t.id && ((e = Rr[i]), Rr.splice(i, 1)) } return e }, each: function (t) { - for (var e = -1; ++e < gs.length; ) t(gs[e]) + for (var e = -1; ++e < Rr.length; ) t(Rr[e]) }, isValidId: function (t) { - for (var e = !1, i = -1; ++i < gs.length && !1 === e; ) gs[i].id === t && (e = !0) + for (var e = !1, i = -1; ++i < Rr.length && !1 === e; ) Rr[i].id === t && (e = !0) return e }, getByIndex: function (t) { - for (var e = !1, i = -1; ++i < gs.length && !1 === e; ) i === t && (e = gs[i]) + for (var e = !1, i = -1; ++i < Rr.length && !1 === e; ) i === t && (e = Rr[i]) return e }, getById: function (t) { - for (var e = !1, i = -1; ++i < gs.length && !1 === e; ) gs[i].id === t && (e = gs[i]) + for (var e = !1, i = -1; ++i < Rr.length && !1 === e; ) Rr[i].id === t && (e = Rr[i]) return e }, getCaptchaIdList: function () { var t = [] return ( - bs.each(function (e) { + Ir.each(function (e) { t.push(e.id) }), t ) }, pushSession: function (t, e) { - vs.push([t, e]), vs.length > 10 && vs.splice(0, vs.length - 10) + Pr.push([t, e]), Pr.length > 10 && Pr.splice(0, Pr.length - 10) }, getSession: function () { - return vs + return Pr }, } - function ws(t, e) { + function Vr(t, e) { 'object' != typeof t || e || ((e = t), (t = null)) var i, n, o, - s = !0 === (e = e || {}).async, - r = new Promise(function (t, e) { + r = !0 === (e = e || {}).async, + s = new Promise(function (t, e) { ;(n = t), (o = e) }) - if (((r.resolve = n), (r.reject = o), (i = t ? bs.getById(t) : bs.getByIndex(0)))) { - Ct('Execute called', 'hCaptcha', 'info'), - Ue.setData('exec', !0), - s && i.setPromise(r), + if (((s.resolve = n), (s.reject = o), (i = t ? Ir.getById(t) : Ir.getByIndex(0)))) { + St('Execute called', 'hCaptcha', 'info'), + Je.setData('exec', 'api'), + r && i.setPromise(s), i.onReady(i.initChallenge, e) } else if (t) { - if (!s) throw new fs(t) - r.reject(it.INVALID_CAPTCHA_ID) + if (!r) throw new Or(t) + s.reject(it.INVALID_CAPTCHA_ID) } else { - if (!s) throw new ms() - r.reject(it.MISSING_CAPTCHA) + if (!r) throw new Hr() + s.reject(it.MISSING_CAPTCHA) } - if (s) return r + if (r) return s } - function xs(t) { + function Dr(t) { var e = '', i = null - i = t ? bs.getById(t) : bs.getByIndex(0) + i = t ? Ir.getById(t) : Ir.getByIndex(0) try { - for (var n = bs.getSession(), o = n.length, s = !1; --o > -1 && !s; ) { - ;(s = n[o][1] === i.id) && (e = n[o][0]) + for (var n = Ir.getSession(), o = n.length, r = !1; --o > -1 && !r; ) { + ;(r = n[o][1] === i.id) && (e = n[o][0]) } - } catch (r) { + } catch (s) { e = '' } return e } - function Cs(t) { - var e = t ? bs.getById(t) : bs.getByIndex(0) - if (!e) throw t ? new fs(t) : new ms() - bs.remove(e), e.destroy(), (e = null) + function Fr(t) { + var e = t ? Ir.getById(t) : Ir.getByIndex(0) + if (!e) throw t ? new Or(t) : new Hr() + Ir.remove(e), e.destroy(), (e = null) } - var ks = ['light', 'dark', 'contrast', 'grey-red'], - _s = new Ci() - _s.add('contrast', {}), - _s.add('grey-red', { component: { challenge: { main: { border: '#6a6a6a' } } } }) - function Es(t, e) { + var $r = ['light', 'dark', 'contrast', 'grey-red'], + Ur = new Bi() + Ur.add('contrast', {}), + Ur.add('grey-red', { component: { challenge: { main: { border: '#6a6a6a' } } } }) + function jr(t, e) { var i = this ;(this.id = t), (this.width = null), @@ -11882,36 +14999,34 @@ (this.config = e), (this._visible = !1), (this._selected = !1), - (this.$iframe = new Gt('iframe')), - (this._host = ct.host || window.location.hostname) - var n = ct.assetUrl - ut.assethost && (n = ut.assethost + ct.assetUrl.replace(ct.assetDomain, '')) + (this.$iframe = new ee('iframe')), + (this._host = ht.host || window.location.hostname) + var n = ht.assetUrl + ft.assethost && (n = ft.assethost + ht.assetUrl.replace(ht.assetDomain, '')) var o = n.match(/^.+\:\/\/[^\/]+/), - s = o ? o[0] : null, - r = + r = o ? o[0] : null, + s = n + - '/hcaptcha.html?_v=' + - Math.random().toString(36).substr(2) + - '#frame=challenge&id=' + + '/hcaptcha.html#frame=challenge&id=' + this.id + '&host=' + this._host + - (e ? '&' + Ht(this.config) : ''), + (e ? '&' + Pt(this.config) : ''), a = tt.Browser.supportsPST() this.setupParentContainer(e), - (this.chat = si.createChat(this.$iframe.dom, t, s)), + (this.chat = ui.createChat(this.$iframe.dom, t, r)), this.chat.setReady(!1), (this._timeoutFailedToInitialize = setTimeout(function () { i.$iframe && i.$iframe.isConnected() - ? wt('Failed to initialize. Iframe attached', 'error', 'frame:challenge', { + ? Et('Failed to initialize. Iframe attached', 'error', 'frame:challenge', { contentWindow: !!i.$iframe.dom.contentWindow, - iframeSrc: r, + iframeSrc: s, supportsPST: a, customContainer: i._hasCustomContainer, }) - : wt('Failed to initialize. Iframe detached', 'error', 'frame:challenge') + : Et('Failed to initialize. Iframe detached', 'error', 'frame:challenge') }, 6e4)), - (this.$iframe.dom.src = r), + (this.$iframe.dom.src = s), (this.$iframe.dom.frameBorder = 0), (this.$iframe.dom.scrolling = 'no'), tt.Browser.supportsPST() && @@ -11920,7 +15035,7 @@ this.translate(), this._hasCustomContainer ? (this._hideIframe(), this._parent.appendChild(this.$iframe.dom)) - : ((this.$container = new Gt('div')), + : ((this.$container = new ee('div')), (this.$wrapper = this.$container.createElement('div')), (this.$overlay = this.$container.createElement('div')), (this.$arrow = this.$container.createElement('div')), @@ -11932,7 +15047,7 @@ this.$container.setAttribute('aria-hidden', !0)), this.style() } - ;(Es.prototype.setupParentContainer = function (t) { + ;(jr.prototype.setupParentContainer = function (t) { var e, i = t['challenge-container'] i && (e = 'string' == typeof i ? document.getElementById(i) : i), @@ -11940,7 +15055,7 @@ ? ((this._hasCustomContainer = !0), (this._parent = e)) : ((this._hasCustomContainer = !1), (this._parent = document.body)) }), - (Es.prototype._hideIframe = function () { + (jr.prototype._hideIframe = function () { var t = {} 'ie' !== tt.Browser.type || ('ie' === tt.Browser.type && 8 !== tt.Browser.version) ? ((t.opacity = 0), (t.visibility = 'hidden')) @@ -11948,7 +15063,7 @@ this.$iframe.setAttribute('aria-hidden', !0), this.$iframe.css(t) }), - (Es.prototype._showIframe = function () { + (jr.prototype._showIframe = function () { var t = {} 'ie' !== tt.Browser.type || ('ie' === tt.Browser.type && 8 !== tt.Browser.version) ? ((t.opacity = 1), (t.visibility = 'visible')) @@ -11956,12 +15071,12 @@ this.$iframe.removeAttribute('aria-hidden'), this.$iframe.css(t) }), - (Es.prototype.style = function () { + (jr.prototype.style = function () { var t = (function (t) { var e = t.palette, i = t.component - return Ci.merge({ main: { fill: e.common.white, border: e.grey[400] } }, i.challenge) - })(_s.get()) + return Bi.merge({ main: { fill: e.common.white, border: e.grey[400] } }, i.challenge) + })(Ur.get()) if (this._hasCustomContainer) { this.$iframe.css({ border: 0, position: 'relative', backgroundColor: t.main.fill }) } else { @@ -12019,25 +15134,25 @@ this.$iframe.css({ border: 0, zIndex: 2e9, position: 'relative' }) } }), - (Es.prototype.setup = function (t) { + (jr.prototype.setup = function (t) { return this.chat.send('create-challenge', t) }), - (Es.prototype.sendTranslation = function (t) { - var e = { locale: t, table: se.getTable(t) || {} } + (jr.prototype.sendTranslation = function (t) { + var e = { locale: t, table: ue.getTable(t) || {} } this.chat && this.chat.send('challenge-translate', e), this.translate() }), - (Es.prototype.translate = function () { - this.$iframe.dom.title = se.translate('Main content of the hCaptcha challenge') + (jr.prototype.translate = function () { + this.$iframe.dom.title = ue.translate('Main content of the hCaptcha challenge') }), - (Es.prototype.isVisible = function () { + (jr.prototype.isVisible = function () { return this._visible }), - (Es.prototype.getDimensions = function (t, e) { + (jr.prototype.getDimensions = function (t, e) { return this._visible ? this.chat.contact('resize-challenge', { width: t, height: e }) : Promise.resolve(null) }), - (Es.prototype.show = function () { + (jr.prototype.show = function () { if (!0 !== this._visible) { if (((this._visible = !0), this._hasCustomContainer)) this._showIframe() else { @@ -12050,10 +15165,10 @@ } } }), - (Es.prototype.focus = function () { + (jr.prototype.focus = function () { this.$iframe.dom.focus() }), - (Es.prototype.close = function (t) { + (jr.prototype.close = function (t) { if (!1 !== this._visible) { if (((this._visible = !1), this._hasCustomContainer)) { return this._hideIframe(), void this.chat.send('close-challenge', { event: t }) @@ -12069,7 +15184,7 @@ this.$container.setAttribute('aria-hidden', !0) } }), - (Es.prototype.size = function (t, e, i) { + (jr.prototype.size = function (t, e, i) { ;(this.width = t), (this.height = e), (this.mobile = i), @@ -12078,42 +15193,42 @@ (this.$wrapper.css({ width: t, height: e }), i ? this.$overlay.css({ opacity: 0.5 }) : this.$overlay.css({ opacity: 0.05 })) }), - (Es.prototype.position = function (t) { + (jr.prototype.position = function (t) { if (!this._hasCustomContainer && t) { var e = 10, i = window.document.documentElement, n = tt.Browser.scrollY(), o = tt.Browser.width(), - s = tt.Browser.height(), - r = + r = tt.Browser.height(), + s = this.mobile || 'invisible' === this.config.size || t.offset.left + t.tick.x <= t.tick.width / 2, a = Math.round(t.bounding.top) + n !== t.offset.top, - l = r ? (o - this.width) / 2 : t.bounding.left + t.tick.right + 10 - ;(l + this.width + e > o || l < 0) && ((l = (o - this.width) / 2), (r = !0)) - var c = + c = s ? (o - this.width) / 2 : t.bounding.left + t.tick.right + 10 + ;(c + this.width + e > o || c < 0) && ((c = (o - this.width) / 2), (s = !0)) + var l = (i.scrollHeight < i.clientHeight ? i.clientHeight : i.scrollHeight) - this.height - e, - h = r ? (s - this.height) / 2 + n : t.bounding.top + t.tick.y + n - this.height / 2 + h = s ? (r - this.height) / 2 + n : t.bounding.top + t.tick.y + n - this.height / 2 a && h < n && (h = n + e), - a && h + this.height >= n + s && (h = n + s - (this.height + e)), - (h = Math.max(Math.min(h, c), 10)) + a && h + this.height >= n + r && (h = n + r - (this.height + e)), + (h = Math.max(Math.min(h, l), 10)) var u = t.bounding.top + t.tick.y + n - h - 10, - d = this.height - 10 - 30 - ;(u = Math.max(Math.min(u, d), e)), - this.$container.css({ left: l, top: h }), - this.$arrow.fg.css({ display: r ? 'none' : 'block' }), - this.$arrow.bg.css({ display: r ? 'none' : 'block' }), + f = this.height - 10 - 30 + ;(u = Math.max(Math.min(u, f), e)), + this.$container.css({ left: c, top: h }), + this.$arrow.fg.css({ display: s ? 'none' : 'block' }), + this.$arrow.bg.css({ display: s ? 'none' : 'block' }), this.$arrow.css({ top: u }), (this.top = h), this.$container.dom.getBoundingClientRect() } }), - (Es.prototype.destroy = function () { + (jr.prototype.destroy = function () { this._timeoutFailedToInitialize && (clearTimeout(this._timeoutFailedToInitialize), (this._timeoutFailedToInitialize = null)), this._visible && this.close.call(this), - si.removeChat(this.chat), + ui.removeChat(this.chat), (this.chat = this.chat.destroy()), this._hasCustomContainer ? this._parent.removeChild(this.$iframe.dom) @@ -12121,7 +15236,7 @@ (this.$container = this.$container.__destroy())), (this.$iframe = this.$iframe.__destroy()) }), - (Es.prototype.setReady = function () { + (jr.prototype.setReady = function () { var t this._timeoutFailedToInitialize && (clearTimeout(this._timeoutFailedToInitialize), (this._timeoutFailedToInitialize = null)), @@ -12131,49 +15246,49 @@ ;(t = this.listeners[e]), this.listeners.splice(e, 1), t() } }), - (Es.prototype.onReady = function (t) { + (jr.prototype.onReady = function (t) { var e = Array.prototype.slice.call(arguments, 1), i = function () { t.apply(null, e) } this.ready ? i() : this.listeners.push(i) }), - (Es.prototype.onOverlayClick = function (t) { + (jr.prototype.onOverlayClick = function (t) { this._hasCustomContainer || this.$overlay.addEventListener('click', t) }), - (Es.prototype.setData = function (t) { + (jr.prototype.setData = function (t) { this.chat && this.chat.send('challenge-data', t) }) - function Ss(t, e, i) { + function Nr(t, e, i) { var n = this ;(this.id = e), (this.response = null), (this.location = { tick: null, offset: null, bounding: null }), (this.config = i), (this._ticked = !0), - (this.$container = t instanceof Gt ? t : new Gt(t)), - (this._host = ct.host || window.location.hostname), - (this.$iframe = new Gt('iframe')) - var o = ct.assetUrl - ut.assethost && (o = ut.assethost + ct.assetUrl.replace(ct.assetDomain, '')) - var s = o.match(/^.+\:\/\/[^\/]+/), - r = s ? s[0] : null, + (this.$container = t instanceof ee ? t : new ee(t)), + (this._host = ht.host || window.location.hostname), + (this.$iframe = new ee('iframe')) + var o = ht.assetUrl + ft.assethost && (o = ft.assethost + ht.assetUrl.replace(ht.assetDomain, '')) + var r = o.match(/^.+\:\/\/[^\/]+/), + s = r ? r[0] : null, a = o + '/hcaptcha.html#frame=checkbox&id=' + this.id + '&host=' + this._host + - (i ? '&' + Ht(this.config) : '') - ;(this.chat = si.createChat(this.$iframe.dom, e, r)), + (i ? '&' + Pt(this.config) : '') + ;(this.chat = ui.createChat(this.$iframe.dom, e, s)), this.chat.setReady(!1), (this._timeoutFailedToInitialize = setTimeout(function () { n.$iframe && n.$iframe.isConnected() - ? wt('Failed to initialize. Iframe attached', 'error', 'frame:checkbox', { + ? Et('Failed to initialize. Iframe attached', 'error', 'frame:checkbox', { contentWindow: !!n.$iframe.dom.contentWindow, iframeSrc: a, }) - : wt('Failed to initialize. Iframe detached', 'error', 'frame:checkbox') + : Et('Failed to initialize. Iframe detached', 'error', 'frame:checkbox') }, 6e4)), (this.$iframe.dom.src = a), (this.$iframe.dom.tabIndex = this.config.tabindex || 0), @@ -12189,7 +15304,7 @@ this.$iframe.setAttribute('data-hcaptcha-widget-id', e), this.$iframe.setAttribute('data-hcaptcha-response', ''), this.$container.appendElement(this.$iframe), - 'off' !== ut.recaptchacompat && + 'off' !== ft.recaptchacompat && ((this.$textArea0 = this.$container.createElement( 'textarea', '#g-recaptcha-response-' + e, @@ -12209,19 +15324,19 @@ (this.clearLoading = this.clearLoading.bind(this)), this.style() } - function As(t, e, i) { + function zr(t, e, i) { ;(this.id = e), (this.response = null), (this.location = { tick: null, offset: null, bounding: null }), (this.config = i), - (this.$container = t instanceof Gt ? t : new Gt(t)), - (this.$iframe = new Gt('iframe')), + (this.$container = t instanceof ee ? t : new ee(t)), + (this.$iframe = new ee('iframe')), this.$iframe.setAttribute('aria-hidden', 'true'), this.$iframe.css({ display: 'none' }), this.$iframe.setAttribute('data-hcaptcha-widget-id', e), this.$iframe.setAttribute('data-hcaptcha-response', ''), this.$container.appendElement(this.$iframe), - 'off' !== ut.recaptchacompat && + 'off' !== ft.recaptchacompat && ((this.$textArea0 = this.$container.createElement( 'textarea', '#g-recaptcha-response-' + e, @@ -12232,8 +15347,8 @@ (this.$textArea1.dom.name = 'h-captcha-response'), this.$textArea1.css({ display: 'none' }) } - function Ls(t, e, i) { - if (!i.sitekey) throw new ys() + function Zr(t, e, i) { + if (!i.sitekey) throw new Mr() ;(this.id = e), (this.visible = !1), (this.overflow = { override: !1, cssUsed: !0, value: null, scroll: 0 }), @@ -12247,27 +15362,28 @@ (this._active = !1), (this._listeners = []), (this.config = i), - ks.indexOf(i.theme) >= 0 && _s.use(i.theme), + $r.indexOf(i.theme) >= 0 && Ur.use(i.theme), (this._state = { escaped: !1, passed: !1, expiredChallenge: !1, expiredResponse: !1 }), (this._origData = null), + (this._langSet = !1), (this._promise = null), (this._responseTimer = null), (this.initChallenge = this.initChallenge.bind(this)), (this.closeChallenge = this.closeChallenge.bind(this)), (this.displayChallenge = this.displayChallenge.bind(this)), (this.getGetCaptchaManifest = this.getGetCaptchaManifest.bind(this)), - (this.challenge = new Es(e, i)), + (this.challenge = new jr(e, i)), 'invisible' == this.config.size - ? (Ct('Invisible mode is set', 'hCaptcha', 'info'), (this.checkbox = new As(t, e, i))) - : (this.checkbox = new Ss(t, e, i)) + ? (St('Invisible mode is set', 'hCaptcha', 'info'), (this.checkbox = new zr(t, e, i))) + : (this.checkbox = new Nr(t, e, i)) } - ;(Ss.prototype.setResponse = function (t) { + ;(Nr.prototype.setResponse = function (t) { ;(this.response = t), this.$iframe.dom.setAttribute('data-hcaptcha-response', t), - 'off' !== ut.recaptchacompat && (this.$textArea0.dom.value = t), + 'off' !== ft.recaptchacompat && (this.$textArea0.dom.value = t), (this.$textArea1.dom.value = t) }), - (Ss.prototype.style = function () { + (Nr.prototype.style = function () { var t = this.config.size switch ((this.$iframe.css({ pointerEvents: 'auto' }), t)) { case 'compact': @@ -12280,73 +15396,73 @@ this.$iframe.css({ width: 303, height: 78, overflow: 'hidden' }) } }), - (Ss.prototype.reset = function () { + (Nr.prototype.reset = function () { ;(this._ticked = !1), this.$iframe && this.$iframe.dom.contentWindow && this.chat && this.chat.send('checkbox-reset') }), - (Ss.prototype.clearLoading = function () { + (Nr.prototype.clearLoading = function () { this.chat && this.chat.send('checkbox-clear') }), - (Ss.prototype.sendTranslation = function (t) { - var e = { locale: t, table: se.getTable(t) || {} } + (Nr.prototype.sendTranslation = function (t) { + var e = { locale: t, table: ue.getTable(t) || {} } this.chat && this.chat.send('checkbox-translate', e), this.translate() }), - (Ss.prototype.translate = function () { - this.$iframe.dom.title = se.translate( + (Nr.prototype.translate = function () { + this.$iframe.dom.title = ue.translate( 'Widget containing checkbox for hCaptcha security challenge', ) }), - (Ss.prototype.status = function (t, e) { + (Nr.prototype.status = function (t, e) { this.$iframe && this.$iframe.dom.contentWindow && this.chat && this.chat.send('checkbox-status', { text: t || null, a11yOnly: e || !1 }) }), - (Ss.prototype.tick = function () { + (Nr.prototype.tick = function () { ;(this._ticked = !0), this.chat && this.chat.send('checkbox-tick') }), - (Ss.prototype.getTickLocation = function () { + (Nr.prototype.getTickLocation = function () { return this.chat.contact('checkbox-location') }), - (Ss.prototype.getOffset = function () { + (Nr.prototype.getOffset = function () { var t = this.$iframe.dom t.offsetParent || (t = t.parentElement) for (var e = 0, i = 0; t; ) (e += t.offsetLeft), (i += t.offsetTop), (t = t.offsetParent) return { top: i, left: e } }), - (Ss.prototype.getBounding = function () { + (Nr.prototype.getBounding = function () { return this.$iframe.dom.getBoundingClientRect() }), - (Ss.prototype.destroy = function () { + (Nr.prototype.destroy = function () { this._timeoutFailedToInitialize && (clearTimeout(this._timeoutFailedToInitialize), (this._timeoutFailedToInitialize = null)), this._ticked && this.reset(), - si.removeChat(this.chat), + ui.removeChat(this.chat), (this.chat = this.chat.destroy()), this.$container.removeElement(this.$iframe), this.$container.removeElement(this.$textArea1), - 'off' !== ut.recaptchacompat && + 'off' !== ft.recaptchacompat && (this.$container.removeElement(this.$textArea0), (this.$textArea0 = this.$textArea0.__destroy())), (this.$textArea1 = this.$textArea1.__destroy()), (this.$container = this.$container.__destroy()), (this.$iframe = this.$iframe.__destroy()) }), - (As.prototype.setResponse = function (t) { + (zr.prototype.setResponse = function (t) { ;(this.response = t), this.$iframe.dom.setAttribute('data-hcaptcha-response', t), - 'off' !== ut.recaptchacompat && (this.$textArea0.dom.value = t), + 'off' !== ft.recaptchacompat && (this.$textArea0.dom.value = t), (this.$textArea1.dom.value = t) }), - (As.prototype.reset = function () {}), - (As.prototype.clearLoading = function () {}), - (As.prototype.sendTranslation = function (t) {}), - (As.prototype.status = function (t, e) {}), - (As.prototype.tick = function () {}), - (As.prototype.getTickLocation = function () { + (zr.prototype.reset = function () {}), + (zr.prototype.clearLoading = function () {}), + (zr.prototype.sendTranslation = function (t) {}), + (zr.prototype.status = function (t, e) {}), + (zr.prototype.tick = function () {}), + (zr.prototype.getTickLocation = function () { return Promise.resolve({ left: 0, right: 0, @@ -12358,41 +15474,41 @@ y: 0, }) }), - (As.prototype.getOffset = function () { + (zr.prototype.getOffset = function () { var t = this.$iframe.dom t.offsetParent || (t = t.parentElement) for (var e = 0, i = 0; t; ) (e += t.offsetLeft), (i += t.offsetTop), (t = t.offsetParent) return { top: i, left: e } }), - (As.prototype.getBounding = function () { + (zr.prototype.getBounding = function () { return this.$iframe.dom.getBoundingClientRect() }), - (As.prototype.destroy = function () { + (zr.prototype.destroy = function () { this._ticked && this.reset(), this.$container.removeElement(this.$iframe), this.$container.removeElement(this.$textArea1), - 'off' !== ut.recaptchacompat && + 'off' !== ft.recaptchacompat && (this.$container.removeElement(this.$textArea0), (this.$textArea0 = this.$textArea0.__destroy())), (this.$textArea1 = this.$textArea1.__destroy()), (this.$container = this.$container.__destroy()), (this.$iframe = this.$iframe.__destroy()) }), - (Ls.prototype._resetTimer = function () { + (Zr.prototype._resetTimer = function () { null !== this._responseTimer && (clearTimeout(this._responseTimer), (this._responseTimer = null)) }), - (Ls.prototype.initChallenge = function (t) { - t || (t = {}), Ct('Initiate challenge', 'hCaptcha', 'info'), (this._origData = t) + (Zr.prototype.initChallenge = function (t) { + t || (t = {}), St('Initiate challenge', 'hCaptcha', 'info'), (this._origData = t) var e = this.getGetCaptchaManifest(), i = t.charity || null, n = t.a11yChallenge || !1, o = t.link || null, - s = t.action || '', - r = t.rqdata || null, + r = t.action || '', + s = t.rqdata || null, a = t.errors || [], - l = tt.Browser.width(), - c = tt.Browser.height() + c = tt.Browser.width(), + l = tt.Browser.height() ;(this._active = !0), this._resetTimer(), this._resetState(), @@ -12400,31 +15516,31 @@ this.challenge.setup({ a11yChallenge: n, manifest: e, - width: l, - height: c, + width: c, + height: l, charity: i, link: o, - action: s, - rqdata: r, - wdata: xo(), - errors: a.concat(Do.collect()), + action: r, + rqdata: s, + wdata: Ho(), + errors: a.concat(rr.collect()), }) }), - (Ls.prototype.getGetCaptchaManifest = function () { + (Zr.prototype.getGetCaptchaManifest = function () { var t = (this._origData || {}).manifest || null return ( t || ((t = Object.create(null)).st = Date.now()), (t.v = 1), - (t.topLevel = Ue.getData()), - (t.session = bs.getSession()), - (t.widgetList = bs.getCaptchaIdList()), + (t.topLevel = Je.getData()), + (t.session = Ir.getSession()), + (t.widgetList = Ir.getCaptchaIdList()), (t.widgetId = this.id), (t.href = window.location.href), (t.prev = JSON.parse(JSON.stringify(this._state))), t ) }), - (Ls.prototype.displayChallenge = function (t) { + (Zr.prototype.displayChallenge = function (t) { if (this._active) { var e = this this.visible = !0 @@ -12432,25 +15548,25 @@ n = this.challenge, o = tt.Browser.height() if (!('ie' === tt.Browser.type && 8 === tt.Browser.version)) { - var s = window.getComputedStyle(document.body).getPropertyValue('overflow-y') - ;(this.overflow.override = 'hidden' === s), + var r = window.getComputedStyle(document.body).getPropertyValue('overflow-y') + ;(this.overflow.override = 'hidden' === r), this.overflow.override && ((this.overflow.cssUsed = '' === document.body.style.overflow && '' === document.body.style.overflowY), - this.overflow.cssUsed || (this.overflow.value = '' === s ? 'auto' : s), + this.overflow.cssUsed || (this.overflow.value = '' === r ? 'auto' : r), (this.overflow.scroll = tt.Browser.scrollY()), (document.body.style.overflowY = 'auto')) } - return new Promise(function (s) { + return new Promise(function (r) { i.status(), - i.getTickLocation().then(function (r) { + i.getTickLocation().then(function (s) { if (e._active) { if ( (n.size(t.width, t.height, t.mobile), n.show(), i.clearLoading(), (i.location.bounding = i.getBounding()), - (i.location.tick = r), + (i.location.tick = s), (i.location.offset = i.getOffset()), n.position(i.location), n.focus(), @@ -12460,24 +15576,24 @@ window.document.scrollingElement || document.getElementsByTagName('html')[0] ).scrollTop = Math.abs(n.height - o) + n.top } - s() + r() } }) }).then(function () { - Ct('Challenge is displayed', 'hCaptcha', 'info'), e.onOpen && Dt(e.onOpen) + St('Challenge is displayed', 'hCaptcha', 'info'), e.onOpen && Nt(e.onOpen) }) } }), - (Ls.prototype.resize = function (t, e, i) { + (Zr.prototype.resize = function (t, e, i) { var n = this, o = this.checkbox, - s = this.challenge - s.getDimensions(t, e) + r = this.challenge + r.getDimensions(t, e) .then(function (t) { - t && s.size(t.width, t.height, t.mobile), + t && r.size(t.width, t.height, t.mobile), (o.location.bounding = o.getBounding()), (o.location.offset = o.getOffset()), - (tt.System.mobile && !i) || s.position(o.location) + (tt.System.mobile && !i) || r.position(o.location) }) ['catch'](function (t) { n.closeChallenge.call(n, { @@ -12487,23 +15603,23 @@ }) }) }), - (Ls.prototype.position = function () { + (Zr.prototype.position = function () { var t = this.checkbox, e = this.challenge tt.System.mobile || ((t.location.bounding = t.getBounding()), e.position(t.location)) }), - (Ls.prototype.reset = function () { - Ct('Captcha Reset', 'hCaptcha', 'info') + (Zr.prototype.reset = function () { + St('Captcha Reset', 'hCaptcha', 'info') try { this.checkbox.reset(), this.checkbox.setResponse(''), this._resetTimer(), this._resetState() } catch (t) { - xt('hCaptcha', t) + At('hCaptcha', t) } }), - (Ls.prototype._resetState = function () { + (Zr.prototype._resetState = function () { for (var t in this._state) this._state[t] = !1 }), - (Ls.prototype.closeChallenge = function (t) { + (Zr.prototype.closeChallenge = function (t) { ;(this.visible = !1), (this._active = !1) var e = this, i = this.checkbox, @@ -12519,7 +15635,7 @@ (i.setResponse(o), n.close(t.event), i.$iframe.dom.focus(), - Ct('Challenge has closed', 'hCaptcha', 'info', { + St('Challenge has closed', 'hCaptcha', 'info', { event: t.event, response: t.response, message: t.message, @@ -12529,44 +15645,44 @@ case et.CHALLENGE_ESCAPED: ;(this._state.escaped = !0), i.reset(), - e.onClose && Dt(e.onClose), + e.onClose && Nt(e.onClose), e._promise && e._promise.reject(et.CHALLENGE_CLOSED) break case et.CHALLENGE_EXPIRED: ;(this._state.expiredChallenge = !0), i.reset(), i.status('hCaptcha window closed due to timeout.', !0), - e.onChalExpire && Dt(e.onChalExpire), + e.onChalExpire && Nt(e.onChalExpire), e._promise && e._promise.reject(et.CHALLENGE_EXPIRED) break case it.CHALLENGE_ERROR: case it.BUNDLE_ERROR: case it.NETWORK_ERROR: - var s = t.event + var r = t.event i.reset(), t.event === it.NETWORK_ERROR ? (i.status(t.message), 429 === t.status - ? (s = it.RATE_LIMITED) - : 'invalid-data' === t.message && (s = it.INVALID_DATA)) + ? (r = it.RATE_LIMITED) + : 'invalid-data' === t.message && (r = it.INVALID_DATA)) : t.event === it.BUNDLE_ERROR - ? (s = it.CHALLENGE_ERROR) + ? (r = it.CHALLENGE_ERROR) : t.event === it.CHALLENGE_ERROR && 'Answers are incomplete' === t.message && - (s = it.INCOMPLETE_ANSWER), - wt('Failed to execute', 'error', 'hCaptcha', { - error: s, + (r = it.INCOMPLETE_ANSWER), + Et('Failed to execute', 'error', 'hCaptcha', { + error: r, event: t.event, message: t.message, }), - this.onError && Dt(this.onError, s), - e._promise && e._promise.reject(s) + this.onError && Nt(this.onError, r), + e._promise && e._promise.reject(r) break case et.CHALLENGE_PASSED: ;(this._state.passed = !0), i.tick(), - this.onPass && Dt(this.onPass, o), - e._promise && e._promise.resolve({ response: o, key: xs(this.id) }), + this.onPass && Nt(this.onPass, o), + e._promise && e._promise.resolve({ response: o, key: Dr(this.id) }), 'number' == typeof t.expiration && (e._resetTimer(), (e._responseTimer = setTimeout(function () { @@ -12579,46 +15695,50 @@ 'hCaptcha security token has expired. Please complete the challenge again.', !0, )) - : Cs(e.id)) - } catch (Fs) { - xt('global', Fs) + : Fr(e.id)) + } catch (Qr) { + At('global', Qr) } - e.onExpire && Dt(e.onExpire), + e.onExpire && Nt(e.onExpire), (e._responseTimer = null), (e._state.expiredResponse = !0) }, 1e3 * t.expiration))) } e._promise = null }), - (Ls.prototype.updateTranslation = function (t) { + (Zr.prototype.updateTranslation = function (t) { ;(this.config.hl = t), + (this._langSet = !0), this.checkbox && this.checkbox.sendTranslation(t), this.challenge && this.challenge.sendTranslation(t) }), - (Ls.prototype.isReady = function () { + (Zr.prototype.isLangSet = function () { + return this._langSet + }), + (Zr.prototype.isReady = function () { return this._ready }), - (Ls.prototype.setReady = function (t) { + (Zr.prototype.setReady = function (t) { if (((this._ready = t), this._ready)) { var e - Ct('Instance is ready', 'hCaptcha', 'info') + St('Instance is ready', 'hCaptcha', 'info') for (var i = this._listeners.length; --i > -1; ) { ;(e = this._listeners[i]), this._listeners.splice(i, 1), e() } } }), - (Ls.prototype.setPromise = function (t) { + (Zr.prototype.setPromise = function (t) { this._promise = t }), - (Ls.prototype.onReady = function (t) { + (Zr.prototype.onReady = function (t) { var e = Array.prototype.slice.call(arguments, 1), i = function () { t.apply(null, e) } this._ready ? i() : this._listeners.push(i) }), - (Ls.prototype.destroy = function () { - ;(Ct('Captcha Destroy', 'hCaptcha', 'info'), this._resetTimer(), this.overflow.override) && + (Zr.prototype.destroy = function () { + ;(St('Captcha Destroy', 'hCaptcha', 'info'), this._resetTimer(), this.overflow.override) && (((window.document.scrollingElement || document.getElementsByTagName('html')[0]).scrollTop = this.overflow.scroll), (this.overflow.override = !1), @@ -12629,14 +15749,14 @@ (this.challenge = null), (this.checkbox = null) }), - (Ls.prototype.setSiteConfig = function (t) { + (Zr.prototype.setSiteConfig = function (t) { var e = this if ('ok' in t) { var i = t.ok.features || {} if (this.config.themeConfig && i.custom_theme) { var n = 'custom-' + this.id - _s.add(n, _s.extend(_s.active(), this.config.themeConfig)), - _s.use(n), + Ur.add(n, Ur.extend(Ur.active(), this.config.themeConfig)), + Ur.use(n), this.challenge.style() } } @@ -12653,8 +15773,8 @@ ) }) }) - var Bs = 0, - Hs = [ + var Wr = 0, + qr = [ 'hl', 'custom', 'tplinks', @@ -12665,17 +15785,18 @@ 'challenge-container', 'confirm-nav', 'orientation', + 'mode', ] - function Os(t, e) { + function Kr(t, e) { if (t) { try { t.updateTranslation(e) - } catch (Fs) { - xt('translation', Fs) + } catch (Qr) { + At('translation', Qr) } } } - var Ts = { + var Yr = { render: function (t, e) { if (('string' == typeof t && (t = document.getElementById(t)), t && 1 === t.nodeType)) { if ( @@ -12685,13 +15806,13 @@ return 'string' == typeof e && (e = document.getElementById(e)), !!e && 1 === e.nodeType })(e) ) { - if (!1 !== si.isSupported()) { - for (var i, n, o = t.getElementsByTagName('iframe'), s = -1; ++s < o.length && !i; ) { - ;(n = o[s].getAttribute('data-hcaptcha-widget-id')) && (i = !0) + if (!1 !== ui.isSupported()) { + for (var i, n, o = t.getElementsByTagName('iframe'), r = -1; ++r < o.length && !i; ) { + ;(n = o[r].getAttribute('data-hcaptcha-widget-id')) && (i = !0) } if (i) return console.error('Only one captcha is permitted per parent container.'), n - Ct('Render instance', 'hCaptcha', 'info') - var r = (function (t, e) { + St('Render instance', 'hCaptcha', 'info') + var s = (function (t, e) { for ( var i = [ 'hl', @@ -12712,58 +15833,61 @@ 'challenge-container', 'confirm-nav', 'orientation', + 'mode', ], n = {}, o = 0; o < i.length; o++ ) { - var s = i[o], - r = e && e[s] - r || (r = t.getAttribute('data-' + s)), r && (n[s] = r) + var r = i[o], + s = e && e[r] + s || (s = t.getAttribute('data-' + r)), s && (n[r] = s) } return n })(t, e), - a = Bs++ + Math.random().toString(36).substr(2), - l = Object.create(null) - ;(l.sentry = ut.sentry), - (l.reportapi = ut.reportapi), - (l.recaptchacompat = ut.recaptchacompat), - (l.custom = ut.custom), - null !== ut.language && (l.hl = se.getLocale()), - ut.assethost && (l.assethost = ut.assethost), - ut.imghost && (l.imghost = ut.imghost), - ut.tplinks && (l.tplinks = ut.tplinks), - ut.se && (l.se = ut.se), - 'off' === ut.pat && (l.pat = ut.pat), - (l.pstissuer = ut.pstIssuer), - 'landscape' === ut.orientation && (l.orientation = ut.orientation) - for (var c = 0; c < Hs.length; c++) { - var h = Hs[c] - h in r && (l[h] = r[h]) + a = Wr++ + Math.random().toString(36).substr(2), + c = Object.create(null) + ;(c.sentry = ft.sentry), + (c.reportapi = ft.reportapi), + (c.recaptchacompat = ft.recaptchacompat), + (c.custom = ft.custom), + null !== ft.language && (c.hl = ue.getLocale()), + ft.assethost && (c.assethost = ft.assethost), + ft.imghost && (c.imghost = ft.imghost), + ft.mode && (c.mode = ft.mode), + ft.tplinks && (c.tplinks = ft.tplinks), + ft.se && (c.se = ft.se), + 'off' === ft.pat && (c.pat = ft.pat), + (c.pstissuer = ft.pstIssuer), + 'landscape' === ft.orientation && (c.orientation = ft.orientation) + for (var l = 0; l < qr.length; l++) { + var h = qr[l] + h in s && (c[h] = s[h]) } - var u = ut.endpoint, - d = l.sitekey - '78c843a4-f80d-4a14-b3e5-74b492762487' === d && (u = st), + var u = ft.endpoint, + f = c.sitekey + '78c843a4-f80d-4a14-b3e5-74b492762487' === f && (u = rt), u === ot && + !Do() && Math.random() < 0.005 && - d && - -1 === d.indexOf('-0000-0000-0000-') && - (u = st), - u !== ot && (l.endpoint = u), - (l.theme = ut.theme) - var p = window.location, - f = p.origin || p.protocol + '//' + p.hostname + (p.port ? ':' + p.port : '') - if (('null' !== f && (l.origin = f), r.theme)) { + f && + -1 === f.indexOf('-0000-0000-0000-') && + (u = rt), + u !== ot && (c.endpoint = u), + (c.theme = ft.theme) + var d = window.location, + p = d.origin || d.protocol + '//' + d.hostname + (d.port ? ':' + d.port : '') + if (('null' !== p && (c.origin = p), s.theme)) { try { - var m = r.theme - 'string' == typeof m && (m = JSON.parse(m)), (l.themeConfig = m), (l.custom = !0) - } catch (Ps) { - l.theme = m + var m = s.theme + 'string' == typeof m && (m = JSON.parse(m)), (c.themeConfig = m), (c.custom = !0) + } catch (ts) { + c.theme = m } } if (t instanceof HTMLButtonElement || t instanceof HTMLInputElement) { - var y = new Gt('div', '.h-captcha') + var y = new ee('div', '.h-captcha') y.css({ display: 'none' }) for (var g = null, v = 0; v < t.attributes.length; v++) { ;(g = t.attributes[v]).name.startsWith('data-') && y.setAttribute(g.name, g.value) @@ -12773,63 +15897,112 @@ y.setAttribute('data-hcaptcha-source-id', b), t.parentNode.insertBefore(y.dom, t), (t.onclick = function (t) { - return t.preventDefault(), Ct('User initiated', 'hCaptcha', 'info'), ws(a) + return t.preventDefault(), St('User initiated', 'hCaptcha', 'info'), Vr(a) }), (t = y), - (l.size = 'invisible') + (c.size = 'invisible') } + c.mode === at.AUTO && + 'invisible' === c.size && + (console.warn( + "[hCaptcha] mode='auto' cannot be used in combination with size='invisible'.", + ), + delete c.mode) try { - var w = new Ls(t, a, l) - } catch (Fs) { + var w = new Zr(t, a, c) + } catch (Qr) { var x = 'Your browser plugins or privacy policies are blocking the hCaptcha service. Please disable them for hCaptcha.com' return ( - Fs instanceof ys && + Qr instanceof Mr && ((x = 'hCaptcha has failed to initialize. Please see the developer tools console for more information.'), - console.error(Fs.message)), - mt(t, x), - void xt('api', Fs) + console.error(Qr.message)), + yt(t, x), + void At('api', Qr) ) } + s.callback && (w.onPass = s.callback), + s['expired-callback'] && (w.onExpire = s['expired-callback']), + s['chalexpired-callback'] && (w.onChalExpire = s['chalexpired-callback']), + s['open-callback'] && (w.onOpen = s['open-callback']), + s['close-callback'] && (w.onClose = s['close-callback']), + s['error-callback'] && (w.onError = s['error-callback']) + try { + Je.setData('inv', 'invisible' === c.size), + Je.setData('size', c.size), + Je.setData( + 'theme', + (function (t) { + var e, + i, + n = 'string' == typeof t ? t : JSON.stringify(t), + o = -1 + for ( + zt = + zt || + (function () { + var t, + e, + i, + n = [] + for (e = 0; e < 256; e++) { + for (t = e, i = 0; i < 8; i++) { + t = 1 & t ? 3988292384 ^ (t >>> 1) : t >>> 1 + } + n[e] = t + } + return n + })(), + e = 0, + i = n.length; + e < i; + e += 1 + ) { + o = (o >>> 8) ^ zt[255 & (o ^ n.charCodeAt(e))] + } + return (-1 ^ o) >>> 0 + })(c.themeConfig || c.theme), + ), + Je.setData('pel', (t.outerHTML || '').replace(t.innerHTML, '')) + } catch (k) { + At('api', k) + } return ( - r.callback && (w.onPass = r.callback), - r['expired-callback'] && (w.onExpire = r['expired-callback']), - r['chalexpired-callback'] && (w.onChalExpire = r['chalexpired-callback']), - r['open-callback'] && (w.onOpen = r['open-callback']), - r['close-callback'] && (w.onClose = r['close-callback']), - r['error-callback'] && (w.onError = r['error-callback']), - Ue.setData('inv', 'invisible' === l.size), (function (t, e) { if ('invisible' === e.size) return t.checkbox.chat.listen('checkbox-selected', function (e) { - Ct('User initiated', 'hCaptcha', 'info'), - Ue.setData('exec', !1), - t.onReady(t.initChallenge, e) + St('User initiated', 'hCaptcha', 'info') + var i = 'enter' === e.action ? 'kb' : 'm' + Je.setData('exec', i), t.onReady(t.initChallenge, e) }), t.checkbox.chat.listen('checkbox-loaded', function (i) { - Ct('Loaded', 'frame:checkbox', 'info'), + St('Loaded', 'frame:checkbox', 'info'), (t.checkbox.location.bounding = t.checkbox.getBounding()), (t.checkbox.location.tick = i), (t.checkbox.location.offset = t.checkbox.getOffset()), t.checkbox.sendTranslation(e.hl) - }) - })(w, l), + }), + e.mode === at.AUTO && + t.onReady(function () { + Vr(t.id) + }, e) + })(w, c), (function (t, e) { function i(e, i) { if (e.locale) { - var n = se.resolveLocale(e.locale) - Io(n) + var n = ue.resolveLocale(e.locale) + Ro(n) .then(function () { i - ? Os(t, n) - : (se.setLocale(n), - bs.each(function (t) { - Os(t, n) + ? Kr(t, n) + : (ue.setLocale(n), + Ir.each(function (t) { + Kr(t, n) })) }) ['catch'](function (t) { - xt('api', t, { locale: n }) + At('api', t, { locale: n }) }) } } @@ -12842,7 +16015,7 @@ }) }), t.challenge.chat.listen('challenge-loaded', function () { - Ct('Loaded', 'frame:challenge', 'info'), + St('Loaded', 'frame:challenge', 'info'), t.challenge.setReady(), t.challenge.sendTranslation(e.hl) }), @@ -12855,7 +16028,7 @@ t.resize(e, i) }), t.challenge.chat.listen(et.CHALLENGE_CLOSED, function (e) { - Ue.setData('lpt', Date.now()), t.closeChallenge(e) + Je.setData('lpt', Date.now()), t.closeChallenge(e) }), t.challenge.chat.answer('get-url', function (t) { t.resolve(window.location.href) @@ -12864,10 +16037,10 @@ e.resolve(t.getGetCaptchaManifest()) }), t.challenge.chat.answer('check-api', function (t) { - t.resolve(Ue.getData()) + t.resolve(Je.getData()) }), t.challenge.chat.listen('challenge-key', function (e) { - bs.pushSession(e.key, t.id) + Ir.pushSession(e.key, t.id) }), t.challenge.onOverlayClick(function () { t.closeChallenge({ event: et.CHALLENGE_ESCAPED }) @@ -12875,14 +16048,14 @@ t.challenge.chat.listen('challenge-language', i), i({ locale: e.hl }, !0), t.challenge.chat.answer('get-ac', function (t) { - t.resolve(kt.hasCookie('hc_accessibility')) + t.resolve(Bt.hasCookie('hc_accessibility')) }) - })(w, l), - bs.add(w), + })(w, c), + Ir.add(w), a ) } - mt( + yt( t, "Your browser is missing or has disabled Cross-Window Messaging. Please upgrade your browser or enable it for hCaptcha.com", ) @@ -12896,820 +16069,817 @@ reset: function (t) { var e if (t) { - if (!(e = bs.getById(t))) throw new fs(t) + if (!(e = Ir.getById(t))) throw new Or(t) e.reset() } else { - if (!(e = bs.getByIndex(0))) throw new ms() + if (!(e = Ir.getByIndex(0))) throw new Hr() e.reset() } }, - remove: Cs, - execute: ws, + remove: Fr, + execute: Vr, getResponse: function (t) { var e, i if ( - ((i = t ? bs.getById(t) : bs.getByIndex(0)) && (e = i.checkbox.response || ''), + ((i = t ? Ir.getById(t) : Ir.getByIndex(0)) && (e = i.checkbox.response || ''), void 0 !== e) ) { return e } - throw t ? new fs(t) : new ms() - }, - getRespKey: xs, - close: function (t) { - var e = !1 - if (!(e = t ? bs.getById(t) : bs.getByIndex(0))) throw t ? new fs(t) : new ms() - e.closeChallenge({ event: et.CHALLENGE_ESCAPED }) - }, - setData: function (t, e) { - if (('object' != typeof t || e || ((e = t), (t = null)), !e || 'object' != typeof e)) { - throw Error('[hCaptcha] invalid data supplied') - } - var i = !1 - if (!(i = t ? bs.getById(t) : bs.getByIndex(0))) throw t ? new fs(t) : new ms() - Ct('Set data', 'hCaptcha', 'info') - var n = i.challenge.setData.bind(i.challenge) - i.onReady(n, e) - }, - nodes: bs, - } - function Ms(t) { - ct.file = 'hcaptcha' - var e = document.currentScript, - i = !1, - n = !1, - o = 'on', - s = tt.Browser.width() / tt.Browser.height(), - r = !(!window.hcaptcha || !window.hcaptcha.render) - function a() { - var t = tt.Browser.width(), - e = tt.Browser.height(), - i = tt.System.mobile && s !== t / e - ;(s = t / e), - h(), - Ts.nodes.each(function (n) { - n.visible && n.resize(t, e, i) - }) - } - function l(t) { - c(), - Ts.nodes.each(function (t) { - t.visible && t.position() - }) - } - function c() { - Ue.circBuffPush('xy', [ - tt.Browser.scrollX(), - tt.Browser.scrollY(), - document.documentElement.clientWidth / tt.Browser.width(), - Date.now(), - ]) - } - function h() { - Ue.circBuffPush('wn', [tt.Browser.width(), tt.Browser.height(), tt.System.dpr(), Date.now()]) - } - ;(window.hcaptcha = { - render: Ts.render, - remove: Ts.remove, - execute: Ts.execute, - reset: Ts.reset, - close: Ts.close, - setData: Ts.setData, - getResponse: Ts.getResponse, - getRespKey: Ts.getRespKey, - }), - Do.run(3e3), - Le(function () { - r || - (!(function () { - var s - s = e ? [e] : document.getElementsByTagName('script') - var r = -1, - a = !1, - l = null, - c = null - for (; ++r < s.length && !1 === a; ) { - s[r] && - s[r].src && - ((c = (l = s[r].src.split('?'))[0]), - /\/(hcaptcha|1\/api)\.js$/.test(c) && - ((a = s[r]), - c && - -1 !== c.toLowerCase().indexOf('www.') && - console.warn( - '[hCaptcha] JS API is being loaded from www.hcaptcha.com. Please use https://js.hcaptcha.com/1/api.js', - ))) - } - if (!1 === a) return - ;(t = t || Bt(l[1])), - (i = t.onload || !1), - (n = t.render || !1), - 'off' === t.tplinks && (o = 'off') - ;(ut.tplinks = o), - (ut.language = t.hl || null), - t.endpoint && (ut.endpoint = t.endpoint) - ;(ut.reportapi = t.reportapi || ut.reportapi), - (ut.imghost = t.imghost || null), - (ut.custom = t.custom || ut.custom), - (ut.se = t.se || null), - (ut.pat = t.pat || ut.pat), - (ut.pstIssuer = t.pstissuer || ut.pstIssuer), - (ut.orientation = t.orientation || null), - (ut.assethost = t.assethost || null), - ut.assethost && - !It.URL(ut.assethost) && - ((ut.assethost = null), console.error('Invalid assethost uri.')) - ;(ut.recaptchacompat = t.recaptchacompat || ut.recaptchacompat), - (ct.host = t.host || window.location.hostname), - (ut.sentry = !1 !== t.sentry), - bt(!1), - (ut.language = - ut.language || window.navigator.userLanguage || window.navigator.language), - se.setLocale(ut.language), - 'off' === ut.recaptchacompat ? console.log('recaptchacompat disabled') : '' - // : (window.grecaptcha = window.hcaptcha) - })(), - (function () { - var t = se.getLocale() - if ('en' === t) return - Io(t) - .then(function () { - Ts.nodes.each(function (e) { - if (e) { - try { - e.updateTranslation(t) - } catch (Fs) { - xt('translation', Fs) - } - } - }) - }) - ['catch'](function (e) { - xt('api', e, { locale: t }) - }) - })(), - !1 === n || 'onload' === n - ? (function (t) { - for ( - var e = document.getElementsByClassName('h-captcha'), i = [], n = 0; - n < e.length; - n++ - ) { - i.push(e[n]) - } - var o = [] - if ('off' !== ut.recaptchacompat) { - for ( - var s = document.getElementsByClassName('g-recaptcha'), r = 0; - r < s.length; - r++ - ) { - o.push(s[r]) - } - } - for (var a = [].concat(i, o), l = 0; l < a.length; l++) t(a[l]) - })(Ts.render) - : 'explicit' !== n && - console.log( - "hcaptcha: invalid render parameter '" + n + "', using 'explicit' instead.", - ), - i && - setTimeout(function () { - Dt(i) - }, 1), - (function () { - try { - Ue.record(), - Ue.setData('sc', tt.Browser.getScreenDimensions()), - Ue.setData('nv', tt.Browser.interrogateNavigator()), - Ue.setData('dr', document.referrer), - h(), - c() - } catch (Fs) {} - })(), - Me.addEventListener('resize', a), - Me.addEventListener('scroll', l)) - }) - } - var Vs = window.location.hash.slice(1), - Rs = Bt(Vs).frame - window !== window.top - ? 'challenge' === Rs - ? (function () { - var t, - e = 0, - i = null, - n = null, - o = null, - s = [et.CHALLENGE_ALREADY_CLOSED, et.CHALLENGE_EXPIRED], - r = (function () { - var t = document.currentScript - if (t) return t - for (var e = document.getElementsByTagName('script'), i = e.length; i--; ) { - if (-1 !== (t = e[i]).src.indexOf('hcaptcha.js')) return t - } - })() - if (r) { - var a = r.src.split('#i=')[1] - a && (t = a) && (uo = t) - } - window._sharedLibs = { - packages: { - config: { Options: ut, Color: ht }, - utils: { MathUtil: Ft, Query: Ot, Render: Lt, Color: Et, Shuffle: _t, JWT: At }, - canvas: { - Canvas: ei, - Path: qe, - Segment: Ke, - Point: We, - PathSVG: Ye, - ReticlePoint: ti, - }, - constants: lt, - device: tt, - language: se, - theme: ki, - core: Ve, - ui: cn, - }, - } - var l = window.location.hash.slice(1), - c = Bt(l) - !(function (t) { - ;(ct.host = t.host), - (ct.sitekey = t.sitekey), - (ct.file = 'challenge'), - (ut.sentry = !1 !== t.sentry), - bt(!0), - t.endpoint !== undefined && 'undefined' !== t.endpoint && (ut.endpoint = t.endpoint), - t.reportapi !== undefined && - 'undefined' !== t.reportapi && - (ut.reportapi = t.reportapi), - t.assethost !== undefined && - 'undefined' !== t.assethost && - (It.URL(t.assethost) - ? (ut.assethost = t.assethost) - : console.error('Invalid assethost uri.')), - t.imghost !== undefined && 'undefined' !== t.imghost && (ut.imghost = t.imghost), - t.hl !== undefined && - 'undefined' !== t.hl && - ((ut.language = t.hl), se.setLocale(ut.language)), - t.se !== undefined && 'undefined' !== t.se && (ut.se = t.se), - t.pstissuer !== undefined && - 'undefined' !== t.pstissuer && - (ut.pstIssuer = t.pstissuer), - t.pat !== undefined && 'undefined' !== t.pat && (ut.pat = t.pat), - (ut.theme = t.theme || ut.theme), - t.themeConfig && (ut.themeConfig = t.themeConfig), - t['confirm-nav'] && (ut.confirmNav = !0) - })(c) - var h = setTimeout(function () { - wt('Slow iframe initialization', 'error', 'frame:challenge', { - readyState: document.readyState, - }) - }, 6e4) - function u(t, n) { - mo(t && t.href), - null !== i && (clearTimeout(i), (i = null)), - o.lockInterface(!0), - bo && (bo.p = Date.now() - bo.s), - yo() - .then(function (t) { - return (function (t, e) { - return e || 'on' !== ut.pat || !tt.supportsPAT() - ? Promise.resolve({ proof: t, pass: !1 }) - : Po.authenticate(t) - .then(function (t) { - return ( - fo(t.c), - yo().then(function (e) { - return { proof: e, pass: t.pass, authToken: t.auth_token } - }) - ) - }) - ['catch'](function (t) { - vt(t), Po.logAction(it.AUTHENTICATION_ERROR) - var e = t && t.response, - i = e && e.body - return ( - fo(i.c), - yo().then(function (t) { - return { proof: t, pass: i.pass || !1 } - }) - ) - }) - })(t, n) - }) - .then(function (t) { - return Po.hasPrivateStateToken().then(function (e) { - return (t.hasPst = e), t - }) - }) - .then(function (i) { - return ( - bo && (bo.gcs = Date.now() - bo.s), - Po.getTaskData(t, i, ((n = vo), (vo = null), n), bo, e) - ) - var n + throw t ? new Or(t) : new Hr() + }, + getRespKey: Dr, + close: function (t) { + var e = !1 + if (!(e = t ? Ir.getById(t) : Ir.getByIndex(0))) throw t ? new Or(t) : new Hr() + e.closeChallenge({ event: et.CHALLENGE_ESCAPED }) + }, + setData: function (t, e) { + if (('object' != typeof t || e || ((e = t), (t = null)), !e || 'object' != typeof e)) { + throw Error('[hCaptcha] invalid data supplied') + } + var i = !1 + if (!(i = t ? Ir.getById(t) : Ir.getByIndex(0))) throw t ? new Or(t) : new Hr() + St('Set data', 'hCaptcha', 'info') + var n = i.challenge.setData.bind(i.challenge) + i.onReady(n, e) + }, + nodes: Ir, + } + var Gr = 'hcaptcha-frame-a8cd801' === document.documentElement.getAttribute('data-id'), + Jr = window.location.hash.slice(1), + Xr = Rt(Jr).frame + Gr && 'challenge' === Xr + ? (function () { + var t, + e = undefined, + i = 0, + n = null, + o = null, + r = null, + s = [et.CHALLENGE_ALREADY_CLOSED, et.CHALLENGE_EXPIRED], + a = (function () { + var t = document.currentScript + if (t) return t + for (var e = document.getElementsByTagName('script'), i = e.length; i--; ) { + if (-1 !== (t = e[i]).src.indexOf('hcaptcha.js')) return t + } + })() + if (a) { + var c = a.src.split('#i=')[1] + c && (t = c) && (bo = t) + } + window._sharedLibs = { + packages: { + config: { Options: ft, Color: ut }, + utils: { MathUtil: Ut, Query: It, Render: Mt, Color: Tt, Shuffle: Lt, JWT: Ht }, + canvas: { Canvas: ai, Path: ti, Segment: Qe, Point: Xe, PathSVG: ni, ReticlePoint: si }, + constants: lt, + device: tt, + language: ue, + theme: Li, + core: De, + ui: mn, + }, + } + var l = window.location.hash.slice(1), + h = Rt(l) + !(function (t) { + ;(ht.host = t.host), + (ht.sitekey = t.sitekey), + (ht.file = 'challenge'), + (ft.sentry = !1 !== t.sentry), + _t(!0), + t.endpoint !== undefined && 'undefined' !== t.endpoint && (ft.endpoint = t.endpoint), + t.reportapi !== undefined && + 'undefined' !== t.reportapi && + (ft.reportapi = t.reportapi), + t.assethost !== undefined && + 'undefined' !== t.assethost && + (Zt.URL(t.assethost) + ? (ft.assethost = t.assethost) + : console.error('Invalid assethost uri.')), + t.imghost !== undefined && 'undefined' !== t.imghost && (ft.imghost = t.imghost), + t.hl !== undefined && + 'undefined' !== t.hl && + ((ft.language = t.hl), ue.setLocale(ft.language)), + t.se !== undefined && 'undefined' !== t.se && (ft.se = t.se), + t.pstissuer !== undefined && + 'undefined' !== t.pstissuer && + (ft.pstIssuer = t.pstissuer), + t.pat !== undefined && 'undefined' !== t.pat && (ft.pat = t.pat), + (ft.theme = t.theme || ft.theme), + t.themeConfig && (ft.themeConfig = t.themeConfig), + t['confirm-nav'] && (ft.confirmNav = !0) + })(h) + var u = setTimeout(function () { + Et('Slow iframe initialization', 'error', 'frame:challenge', { + readyState: document.readyState, + }) + }, 6e4) + function f(t, o) { + Co(t && t.href), + null !== n && (clearTimeout(n), (n = null)), + r.lockInterface(!0), + To && (To.p = Date.now() - To.s), + _o() + .then(function (t) { + return (function (t, e) { + return e || 'on' !== ft.pat || !tt.supportsPAT() + ? Promise.resolve({ proof: t, pass: !1 }) + : or + .authenticate(t) + .then(function (t) { + return ( + ko(t.c), + _o().then(function (e) { + return { proof: e, pass: t.pass, authToken: t.auth_token } + }) + ) + }) + ['catch'](function (t) { + kt(t), or.logAction(it.AUTHENTICATION_ERROR) + var e = t && t.response, + i = e && e.body + return ( + ko(i.c), + _o().then(function (t) { + return { proof: t, pass: i.pass || !1 } + }) + ) + }) + })(t, o) + }) + .then(function (t) { + return or.hasPrivateStateToken().then(function (e) { + return (t.hasPst = e), t }) - .then(function (t) { - return ( - bo && (bo.gce = Date.now() - bo.s), - t.pass || !1 === t.success - ? d(t) - : ((e = { c: t.c, rq: t.rq, key: t.key, challengeType: t.request_type }), - e.challengeType - ? (e.key && ri.send('challenge-key', { key: e.key }), - o.create({ rq: e.rq }), - fo(e.c), - (i = e.challengeType), - bo && ((bo.l = Date.now() - bo.s), (bo.t = i)), - Po.loadBundle(e.challengeType) - .then(function (t) { - var i = Po.getData() - return ( - o.lockInterface(!1), - bo && (bo.o = Date.now() - bo.s), - o.show({ - width: ct.browserWidth, - height: ct.browserHeight, - bundle: t, - bundleData: i, - expiration: 1e3 * (i.expiration || 120), - challengeType: e.challengeType, - }) - ) - }) - .then(function (t) { - return new Promise(function (e) { - Promise.all([yo(), ri.contact('check-api')]).then(function (i) { - e({ answers: t, proof: i[0], motionData: i[1] }) - }) + }) + .then(function (e) { + return ( + To && (To.gcs = Date.now() - To.s), + or.getTaskData(t, e, ((n = Lo), (Lo = null), n), To, i) + ) + var n + }) + .then(function (t) { + return ( + To && (To.gce = Date.now() - To.s), + t.pass || !1 === t.success + ? d(t) + : ((e = { c: t.c, rq: t.rq, key: t.key, challengeType: t.request_type }), + e.challengeType + ? (e.key && fi.send('challenge-key', { key: e.key }), + r.create({ rq: e.rq }), + ko(e.c), + (i = e.challengeType), + To && ((To.l = Date.now() - To.s), (To.t = i)), + or + .loadBundle(e.challengeType) + .then(function (t) { + var i = or.getData() + return ( + r.lockInterface(!1), + To && (To.o = Date.now() - To.s), + r.show({ + width: ht.browserWidth, + height: ht.browserHeight, + bundle: t, + bundleData: i, + expiration: 1e3 * (i.expiration || 120), + challengeType: e.challengeType, + }) + ) + }) + .then(function (t) { + return new Promise(function (e) { + Promise.all([_o(), fi.contact('check-api')]).then(function (i) { + e({ answers: t, proof: i[0], motionData: i[1] }) }) }) - .then(function (t) { - Ue.stop() - var e = t.answers, - i = t.proof, - n = Ue.getData() - return ( - (n.topLevel = t.motionData), - (n.v = 1), - bo && (bo.c = Date.now() - bo.s), - Po.checkAnswers(e, n, i) - ) - }) - ['catch'](function (t) { - if (o.isVisible() || (t && -1 === s.indexOf(t.message))) { - throw (o.lockInterface(!0), t) - } - })) - : Promise.resolve({ c: e.c, skip: !0 })).then(d) - ) - var e, i - }) - ['catch'](function (t) { - var i = - t instanceof Error ? { event: it.CHALLENGE_ERROR, message: t.message || '' } : t - Po.logAction(i.event) - var n = 429 === t.status, - o = t.response && t.response['error-codes'], - s = o && -1 !== o.indexOf('invalid-data') - Ct('challenge', 'api', 'debug', t), - n || - s || - (i.event !== it.NETWORK_ERROR && - i.event !== it.CHALLENGE_ERROR && - i.event !== it.BUNDLE_ERROR) || - !(e <= 3) - ? (e > 3 && - 0 !== t.status && - 429 !== t.status && - 403 !== t.status && - 400 !== t.status && - wt('api:getcaptcha failed', 'error', 'challenge', { error: t }), - (e = 0), - s && (i = { event: it.NETWORK_ERROR, message: (o || ['']).join(', ') }), - wo(i.event), - ri.send(et.CHALLENGE_CLOSED, i)) - : (e < 2 || - (e < 3 - ? ut.endpoint === rt || ut.endpoint === nt - ? (ut.endpoint = ot) - : ut.endpoint === ot - ? (ut.endpoint = st) - : ut.endpoint === st && (ut.endpoint = ot) - : -1 !== at.indexOf(ut.endpoint) && (ut.endpoint = nt)), - (e += 1), - p()) - }) - } - function d(t) { - if ((fo(t.c), t.skip)) { - wo(et.CHALLENGE_ESCAPED), - ri.send(et.CHALLENGE_CLOSED, { event: et.CHALLENGE_ESCAPED }) - } else if (t.pass) { - wo(et.CHALLENGE_PASSED), - ri.send(et.CHALLENGE_CLOSED, { - event: et.CHALLENGE_PASSED, - response: t.generated_pass_UUID, - expiration: t.expiration, - }), - t.generated_pass_UUID || wt('no pass id', 'error', 'frame:challenge') - } else if (!1 === t.success) { - var e = t['error-codes'] || [] - if (-1 !== e.indexOf('expired-session') || -1 !== e.indexOf('client-fail')) { - return void p() - } - wo(it.NETWORK_ERROR), - ri.send(et.CHALLENGE_CLOSED, { - event: it.NETWORK_ERROR, - message: (t['error-codes'] || ['']).join(', '), - }) - } else o.displayTryAgain(!0), Po.logAction('challenge-failed'), p() - } - function p() { - if ((bo && (bo = { s: Date.now(), n: bo.n + 1 }), Po.isRqChl() && !ut.a11yChallenge)) { - return ( - o.lockInterface(!0), - void (i = setTimeout(function () { - wo(it.CHALLENGE_ERROR), - ri.send(et.CHALLENGE_CLOSED, { - event: it.CHALLENGE_ERROR, - message: 'Challenge Retry Failed', - }) - }, 2e3)) - ) + }) + .then(function (t) { + Je.stop() + var e = t.answers, + i = t.proof, + n = Je.getData() + return ( + (n.topLevel = t.motionData), + (n.v = 1), + To && (To.c = Date.now() - To.s), + or.checkAnswers(e, n, i) + ) + }) + ['catch'](function (t) { + if (r.isVisible() || (t && -1 === s.indexOf(t.message))) { + throw (r.lockInterface(!0), t) + } + })) + : Promise.resolve({ c: e.c, skip: !0 })).then(d) + ) + var e, i + }) + ['catch'](function (t) { + var n = + t instanceof Error || 'string' == typeof t + ? { + event: it.CHALLENGE_ERROR, + message: ('string' == typeof t ? t : t.message) || '', + } + : t + or.logAction(n.event) + var o = 429 === t.status, + r = t.response && t.response['error-codes'], + s = r && -1 !== r.indexOf('invalid-data') + St('challenge', 'api', 'debug', t), + e || + o || + s || + (n.event !== it.NETWORK_ERROR && + n.event !== it.CHALLENGE_ERROR && + n.event !== it.BUNDLE_ERROR) || + !(i <= 3) + ? (i > 3 && + 0 !== t.status && + 429 !== t.status && + 403 !== t.status && + 400 !== t.status && + Et('api:getcaptcha failed', 'error', 'challenge', { error: t }), + (i = 0), + s && (n = { event: it.NETWORK_ERROR, message: (r || ['']).join(', ') }), + e && + ((n = { event: it.NETWORK_ERROR, message: e }), + console.error('[hCaptcha] ' + e), + (e = undefined)), + Oo(n.event), + fi.send(et.CHALLENGE_CLOSED, n)) + : (i < 2 || + (i < 3 + ? ft.endpoint === st || ft.endpoint === nt + ? (ft.endpoint = ot) + : ft.endpoint === ot + ? Do() || (ft.endpoint = rt) + : ft.endpoint === rt && (ft.endpoint = ot) + : -1 !== ct.indexOf(ft.endpoint) && (ft.endpoint = nt)), + (i += 1), + p()) + }) + } + function d(t) { + if ((ko(t.c), t.skip)) { + Oo(et.CHALLENGE_ESCAPED), fi.send(et.CHALLENGE_CLOSED, { event: et.CHALLENGE_ESCAPED }) + } else if (t.pass) { + Oo(et.CHALLENGE_PASSED), + fi.send(et.CHALLENGE_CLOSED, { + event: et.CHALLENGE_PASSED, + response: t.generated_pass_UUID, + expiration: t.expiration, + }), + t.generated_pass_UUID || Et('no pass id', 'error', 'frame:challenge') + } else if (!1 === t.success) { + var e = t['error-codes'] || [] + if (-1 !== e.indexOf('expired-session') || -1 !== e.indexOf('client-fail')) { + return void p() } - ri.contact('getcaptcha-manifest').then(function (t) { - u(t, !0) - }) - } - function f(t, e) { - ;(ct.browserWidth = t.width), - (ct.browserHeight = t.height), - o.size(t.width, t.height).then(function (t) { - e.resolve(t), Ct('challenge resized', 'challenge', 'info', t) + Oo(it.NETWORK_ERROR), + fi.send(et.CHALLENGE_CLOSED, { + event: it.NETWORK_ERROR, + message: (t['error-codes'] || ['']).join(', '), }) + } else r.displayTryAgain(!0), or.logAction('challenge-failed'), p() + } + function p() { + if ((To && (To = { s: Date.now(), n: To.n + 1 }), or.isRqChl() && !ft.a11yChallenge)) { + return ( + r.lockInterface(!0), + void (n = setTimeout(function () { + Oo(it.CHALLENGE_ERROR), + fi.send(et.CHALLENGE_CLOSED, { + event: it.CHALLENGE_ERROR, + message: 'Challenge Retry Failed', + }) + }, 2e3)) + ) } - function m() { - Ct('challenge refresh', 'challenge', 'info'), Po.logAction('challenge-refresh'), p() - } - function y() { - po(Do.collect()), - o - .submit() - .then(function (t) { - Po.logAction(t), 'challenge-skip' !== t || p() - }) - ['catch'](function (t) { - vt(t), Po.logAction(it.CHALLENGE_ERROR), p() - }) - } - function g() { - var t = Po.getData() - o.displayReport(t) + fi.contact('getcaptcha-manifest').then(function (t) { + f(t, !0) + }) + } + function m(t, e) { + ;(ht.browserWidth = t.width), + (ht.browserHeight = t.height), + r.size(t.width, t.height).then(function (t) { + e.resolve(t), St('challenge resized', 'challenge', 'info', t) + }) + } + function y() { + St('challenge refresh', 'challenge', 'info'), or.logAction('challenge-refresh'), p() + } + function g() { + wo(rr.collect()), + r + .submit() .then(function (t) { - if (t) { - var e = function () { - m(), o.getModal().off('refresh', e) - } - o.getModal().display('report_image', { key: t }), o.getModal().on('refresh', e) - } + or.logAction(t), 'challenge-skip' !== t || p() }) ['catch'](function (t) { - vt(t), m() + kt(t), or.logAction(it.CHALLENGE_ERROR), p() }) - } - window.addEventListener('load', function () { - h && (clearTimeout(h), (h = null)), Ct('iframe:load', 'challenge', 'info') + } + function v() { + var t = or.getData() + r.displayReport(t) + .then(function (t) { + if (t) { + var e = function () { + y(), r.getModal().off('refresh', e) + } + r.getModal().display('report_image', { key: t }), r.getModal().on('refresh', e) + } + }) + ['catch'](function (t) { + kt(t), y() + }) + } + window.addEventListener('load', function () { + u && (clearTimeout(u), (u = null)), St('iframe:load', 'challenge', 'info') + }), + document.addEventListener('DOMContentLoaded', function () { + St('iframe:DOMContentLoaded', 'challenge', 'info') }), - document.addEventListener('DOMContentLoaded', function () { - Ct('iframe:DOMContentLoaded', 'challenge', 'info') - }), - document.addEventListener('readystatechange', function () { - Ct('iframe:readystatechange', 'challenge', 'info', { - readyState: document.readyState, - }) - }), - Do.run(), - (o = new so(document.body, { - host: ct.host, - sitekey: ct.sitekey, - orientation: c.orientation || 'portrait', - })), - ut.themeConfig && o.addTheme('custom', ut.themeConfig), - ri.init(c.id, c.origin), - (n = new Gt(document.body)), - ri.answer('create-challenge', function (t) { - bo = { s: Date.now(), n: 0 } - var e, - i = {} - t && - (Po.setRqData(t.rqdata || Po.getRqData()), - t.wdata && ((e = t.wdata), (window.__wdata = e)), - po(t.errors), - t.width && ((ct.browserWidth = t.width), (ct.browserHeight = t.height)), - t.manifest && (i = t.manifest), - 'enter' === t.action - ? n.addClass('using-kb') - : n.hasClass('using-kb') && n.removeClass('using-kb'), - o.init(t)), - o.setFocus('info'), - u(i, !1) - }), - ri.answer('close-challenge', function (t) { - wo(t.event), - null !== i && (clearTimeout(i), (i = null)), - t && t.event === et.CHALLENGE_ESCAPED && Po.logAction('challenge-abandon-retry'), - Po.setRqData(null), - o.close() - }), - ri.answer('resize-challenge', f), - ri.answer('challenge-translate', function (t) { - o.translateInterface(t), - o.isVisible() && - ('en' !== t.locale - ? (Po.logAction('challenge-language-change'), p()) - : o.translateBundle()) - }), - ri.contact('get-url').then(function (t) { - ct.url = t - }), - ri.answer('challenge-data', function (t) { - t.rqdata && Po.setRqData(t.rqdata) - }), - o.events.on('refresh', m), - o.events.on('submit', y), - o.events.on('report', g), - o.events.on('report-submission', function (t) { - Po.reportIssue(t.reason, t.comment, t.key)['catch'](function (t) {}) - }), - o.events.on('resize', function () { - ri.send('challenge-resize') - }), - o.events.on('focus-check', function () { - n.addClass('using-kb'), o.triggerFocus('submit') - }), - n.addEventListener('down', function (t) { - o.isInterfaceLocked() || o.displayTryAgain(!1) - }), - n.addEventListener('keydown', function (t) { - 27 === t.keyNum && - (o.getModal().isOpen() - ? (o.getModal().close(), o.hideReport()) - : (wo(et.CHALLENGE_ESCAPED), - ri.send(et.CHALLENGE_CLOSED, { event: et.CHALLENGE_ESCAPED }), - o.close())) - }), - n.addEventListener( - 'down', - function () { - 'menu' !== o.getActiveElement() && - n.hasClass('using-kb') && - n.removeClass('using-kb') + document.addEventListener('readystatechange', function () { + St('iframe:readystatechange', 'challenge', 'info', { readyState: document.readyState }) + }), + rr.run(), + (r = new uo(document.body, { + host: ht.host, + sitekey: ht.sitekey, + orientation: h.orientation || 'portrait', + })), + document.addEventListener('securitypolicyviolation', function (t) { + 'img-src' === t.violatedDirective && + (e = 'CSP blocks images (' + t.originalPolicy + ').') + }), + ft.themeConfig && r.addTheme('custom', ft.themeConfig), + fi.init(h.id, h.origin), + (o = new ee(document.body)), + fi.answer('create-challenge', function (t) { + To = { s: Date.now(), n: 0 } + var e, + i = {} + t && + (or.setRqData(t.rqdata || or.getRqData()), + t.wdata && ((e = t.wdata), (window.__wdata = e)), + wo(t.errors), + t.width && ((ht.browserWidth = t.width), (ht.browserHeight = t.height)), + t.manifest && (i = t.manifest), + 'enter' === t.action + ? o.addClass('using-kb') + : o.hasClass('using-kb') && o.removeClass('using-kb'), + r.init(t)), + r.setFocus('info'), + f(i, !1) + }), + fi.answer('close-challenge', function (t) { + Oo(t.event), + null !== n && (clearTimeout(n), (n = null)), + t && t.event === et.CHALLENGE_ESCAPED && or.logAction('challenge-abandon-retry'), + or.setRqData(null), + r.close() + }), + fi.answer('resize-challenge', m), + fi.answer('challenge-translate', function (t) { + r.translateInterface(t), + r.isVisible() && + ('en' !== t.locale + ? (or.logAction('challenge-language-change'), p()) + : r.translateBundle()) + }), + fi.contact('get-url').then(function (t) { + ht.url = t + }), + fi.answer('challenge-data', function (t) { + t.rqdata && or.setRqData(t.rqdata) + }), + r.events.on('refresh', y), + r.events.on('submit', g), + r.events.on('report', v), + r.events.on('report-submission', function (t) { + or.reportIssue(t.reason, t.comment, t.key)['catch'](function (t) {}) + }), + r.events.on('resize', function () { + fi.send('challenge-resize') + }), + r.events.on('focus-check', function () { + o.addClass('using-kb'), r.triggerFocus('submit') + }), + o.addEventListener('down', function (t) { + r.isInterfaceLocked() || r.displayTryAgain(!1) + }), + o.addEventListener('keydown', function (t) { + 27 === t.keyNum && + (r.getModal().isOpen() + ? (r.getModal().close(), r.hideReport()) + : (Oo(et.CHALLENGE_ESCAPED), + fi.send(et.CHALLENGE_CLOSED, { event: et.CHALLENGE_ESCAPED }), + r.close())) + }), + o.addEventListener( + 'down', + function () { + 'menu' !== r.getActiveElement() && o.hasClass('using-kb') && o.removeClass('using-kb') + }, + !0, + ), + o.addEventListener( + 'keydown', + function (t) { + 9 === t.keyNum && + (o.addClass('using-kb'), + t.shiftKey || + ('submit' === r.getActiveElement() && + (r.triggerFocus('challenge', 0), t.preventDefault && t.preventDefault()))) + }, + !0, + ), + o.addEventListener('keydown', function (t) { + if ('submit' === r.getActiveElement()) { + var e = t.keyNum + 37 === e || 38 === e + ? (o.addClass('using-kb'), + r.triggerFocus('challenge', -1), + t.preventDefault && t.preventDefault()) + : (39 !== e && 40 !== e) || + (o.addClass('using-kb'), + r.triggerFocus('challenge', 0), + t.preventDefault && t.preventDefault()) + } + }), + Vo() + .then( + function (t) { + var e = t.features + return ( + 'object' != typeof e && (e = {}), + r.setWhiteLabel(!!t.custom), + ko(t.c), + ft.themeConfig && e.custom_theme ? r.useTheme('custom') : r.useTheme(ft.theme), + e.a11y_challenge && ((ft.a11yChallenge = !0), r.enableA11yChallenge(!0)), + !0 === e.enc_get_req && or.setEncryptionSupport(!0), + { ok: t } + ) }, - !0, - ), - n.addEventListener( - 'keydown', function (t) { - 9 === t.keyNum && - (n.addClass('using-kb'), - t.shiftKey || - ('submit' === o.getActiveElement() && - (o.triggerFocus('challenge', 0), t.preventDefault && t.preventDefault()))) + return { err: t instanceof Error ? { name: t.name, message: t.message } : t } }, - !0, - ), - n.addEventListener('keydown', function (t) { - if ('submit' === o.getActiveElement()) { - var e = t.keyNum - 37 === e || 38 === e - ? (n.addClass('using-kb'), - o.triggerFocus('challenge', -1), - t.preventDefault && t.preventDefault()) - : (39 !== e && 40 !== e) || - (n.addClass('using-kb'), - o.triggerFocus('challenge', 0), - t.preventDefault && t.preventDefault()) - } + ) + .then(function (t) { + fi.send('site-setup', t) }), - No() - .then( - function (t) { - var e = t.features - return ( - 'object' != typeof e && (e = {}), - o.setWhiteLabel(!!t.custom), - fo(t.c), - ut.themeConfig && e.custom_theme ? o.useTheme('custom') : o.useTheme(ut.theme), - e.a11y_challenge && ((ut.a11yChallenge = !0), o.enableA11yChallenge(!0)), - { ok: t } - ) - }, - function (t) { - return { err: t instanceof Error ? { name: t.name, message: t.message } : t } - }, - ) - .then(function (t) { - ri.send('site-setup', t) - }), - ri.send('challenge-loaded') - })() - : 'checkbox' === Rs - ? (function () { - var t = !1, - e = window.location.hash.slice(1), - i = Bt(e), - n = si.createChat(window.parent, i.id, i.origin) - !(function (t) { - ;(ct.id = t.id), - (ct.host = t.host), - (ct.sitekey = t.sitekey), - (ct.file = 'checkbox'), - (ut.sentry = !1 !== t.sentry), - bt(!0), - (ut.size = t.size || ut.compact), - (ut.custom = t.custom || ut.custom), - (ut.se = t.se || null), - t.endpoint !== undefined && 'undefined' !== t.endpoint && (ut.endpoint = t.endpoint), - t.assethost !== undefined && - 'undefined' !== t.assethost && - (It.URL(t.assethost) - ? (ut.assethost = t.assethost) - : console.error('Invalid assethost uri.')), - t.imghost !== undefined && 'undefined' !== t.imghost && (ut.imghost = t.imghost), - t.hl !== undefined && - 'undefined' !== t.hl && - ((ut.language = t.hl), se.setLocale(t.hl)), - t.tplinks !== undefined && 'undefined' !== t.tplinks && (ut.tplinks = t.tplinks), - t.pat !== undefined && 'undefined' !== t.pat && (ut.pat = t.pat), - t.pstissuer !== undefined && - 'undefined' !== t.pstissuer && - (ut.pstIssuer = t.pstissuer), - (ut.theme = t.theme || ut.theme), - (ut.themeConfig = t.themeConfig), - ut.themeConfig && (t.custom = !0) - })(i) - var o = setTimeout(function () { - wt('Slow iframe initialization', 'error', 'frame:checkbox', { - readyState: document.readyState, - }) - }, 6e4) - window.addEventListener('load', function () { - o && (clearTimeout(o), (o = null)), Ct('iframe:load', 'checkbox', 'info') + fi.send('challenge-loaded') + })() + : Gr && 'checkbox' === Xr + ? (function () { + var t = !1, + e = window.location.hash.slice(1), + i = Rt(e), + n = ui.createChat(window.parent, i.id, i.origin) + !(function (t) { + ;(ht.id = t.id), + (ht.host = t.host), + (ht.sitekey = t.sitekey), + (ht.file = 'checkbox'), + (ft.sentry = !1 !== t.sentry), + _t(!0), + (ft.size = t.size || ft.compact), + (ft.custom = t.custom || ft.custom), + (ft.mode = t.mode || ft.mode), + (ft.se = t.se || null), + t.endpoint !== undefined && 'undefined' !== t.endpoint && (ft.endpoint = t.endpoint), + t.assethost !== undefined && + 'undefined' !== t.assethost && + (Zt.URL(t.assethost) + ? (ft.assethost = t.assethost) + : console.error('Invalid assethost uri.')), + t.imghost !== undefined && 'undefined' !== t.imghost && (ft.imghost = t.imghost), + t.hl !== undefined && + 'undefined' !== t.hl && + ((ft.language = t.hl), ue.setLocale(t.hl)), + t.tplinks !== undefined && 'undefined' !== t.tplinks && (ft.tplinks = t.tplinks), + t.pat !== undefined && 'undefined' !== t.pat && (ft.pat = t.pat), + t.pstissuer !== undefined && + 'undefined' !== t.pstissuer && + (ft.pstIssuer = t.pstissuer), + (ft.theme = t.theme || ft.theme), + (ft.themeConfig = t.themeConfig), + ft.themeConfig && (t.custom = !0) + })(i) + var o = setTimeout(function () { + Et('Slow iframe initialization', 'error', 'frame:checkbox', { + readyState: document.readyState, + }) + }, 6e4) + window.addEventListener('load', function () { + o && (clearTimeout(o), (o = null)), St('iframe:load', 'checkbox', 'info') + }), + document.addEventListener('DOMContentLoaded', function () { + St('iframe:DOMContentLoaded', 'checkbox', 'info') }), - document.addEventListener('DOMContentLoaded', function () { - Ct('iframe:DOMContentLoaded', 'checkbox', 'info') - }), - document.addEventListener('readystatechange', function () { - Ct('iframe:readystatechange', 'checkbox', 'info', { readyState: document.readyState }) - }) - var s = jo.sitekey(ct.sitekey), - r = jo.dummykey(ct.sitekey) - Do.run() - var a = null, - l = null, - c = new Promise(function (t) { - l = t - }), - h = null - function u(e, i) { - var n = { - host: ct.host, - sitekey: ct.sitekey, - size: ut.size, - theme: ut.theme, - linksOff: 'off' === ut.tplinks, - displayLogo: 'invisible' !== ut.size, - logo: null, - logoUrl: null, - privacyUrl: null, - termsUrl: null, - }, - o = e && e.custom - if (o) { - ;(n.logo = o.logo), - o.links && - ((n.logoUrl = o.links.logo), - (n.privacyUrl = o.links.privacy), - (n.termsUrl = o.links.terms)) - var a = o.copy - if (a) { - var l = { - checkbox_prompt: 'I am human', - checkbox_a11y: - 'hCaptcha checkbox. Select in order to trigger the challenge, or to bypass it if you have an accessibility cookie.', - } - for (var h in l) { - var u = a[h] - for (var d in u) { - var p = {} - ;(p[l[h]] = u[d]), se.addTable(d, p) - } + document.addEventListener('readystatechange', function () { + St('iframe:readystatechange', 'checkbox', 'info', { readyState: document.readyState }) + }) + var r = Io.sitekey(ht.sitekey), + s = Io.dummykey(ht.sitekey) + rr.run() + var a = null, + c = null, + l = new Promise(function (t) { + c = t + }), + h = null + function u(e, i) { + var n = { + host: ht.host, + sitekey: ht.sitekey, + size: ft.size, + theme: ft.theme, + mode: ft.mode, + linksOff: 'off' === ft.tplinks, + displayLogo: 'invisible' !== ft.size, + logo: null, + logoUrl: null, + privacyUrl: null, + termsUrl: null, + }, + o = e && e.custom + if (o) { + Io.logo(o.logo) && (n.logo = o.logo), + o.links && + ((n.logoUrl = o.links.logo), + (n.privacyUrl = o.links.privacy), + (n.termsUrl = o.links.terms)) + var a = o.copy + if (a) { + var c = { + checkbox_prompt: 'I am human', + checkbox_a11y: + "hCaptcha checkbox with text 'I am human'. Select in order to trigger the challenge, or to bypass it if you have an accessibility cookie.", + } + for (var h in c) { + var u = a[h] + for (var f in u) { + var d = {} + ;(d[c[h]] = u[f]), ue.addTable(f, d) } - c.then(function (t) { - t.translate() - }) } + l.then(function (t) { + t.translate() + }) } - var f = new ds(document.body, n), - m = e && e.features && e.features.custom_theme - return ( - ut.themeConfig && m ? f.theme('custom', ut.themeConfig) : f.theme(ut.theme), - f.setStatus(!1), - s || r - ? r && - f.setWarning( - 'This hCaptcha is for testing only. Please contact the site admin if you see this.', - ) - : f.setWarning( - 'The sitekey for this hCaptcha is incorrect. Please contact the site admin if you see this.', - ), - f.on('select', function (e) { - f.setStatus(!1), - setTimeout(function () { - i.send('checkbox-selected', { - manifest: Ue.getData(), - charity: t, - a11yChallenge: ut.a11yChallenge || !1, - link: f.getLogoUrl(), - action: e, - errors: Do.collect(), - }) - }, 1) - }), - f - ) } - new Promise(function (t) { - h = t + var p = new Lr(document.body, n), + m = e && e.features && e.features.custom_theme + return ( + ft.themeConfig && m ? p.theme('custom', ft.themeConfig) : p.theme(ft.theme), + p.setStatus(!1), + r || s + ? s && + p.setWarning( + 'This hCaptcha is for testing only. Please contact the site admin if you see this.', + ) + : p.setWarning( + 'The sitekey for this hCaptcha is incorrect. Please contact the site admin if you see this.', + ), + p.on('select', function (e) { + p.setStatus(!1), + setTimeout(function () { + i.send('checkbox-selected', { + manifest: Je.getData(), + charity: t, + a11yChallenge: ft.a11yChallenge || !1, + link: p.getLogoUrl(), + action: e, + errors: rr.collect(), + }) + }, 1) + }), + p + ) + } + new Promise(function (t) { + h = t + }) + .then(function (t) { + if ('ok' in t) return t.ok + throw t.err }) - .then(function (t) { - if ('ok' in t) return t.ok - throw t.err + .then( + function (e) { + a || ((a = u(e, n)), c(a)) + var i = e.features || {} + ;(ft.a11yChallenge = i.a11y_challenge || !1), + (t = e.charity || !1), + e.status_message && r && !s && a.setWarning(e.status_message) + }, + function (t) { + a || ((a = u(null, n)), c(a)), t.message && a.setStatus(t.message) + }, + ) + .then(function () { + Je.resetData(), Je.record(!0, !0, !0, !1), n.send('checkbox-loaded', a.getLocation()) + }), + (function (t, e, i) { + i.listen('site-setup', e), + i.listen('checkbox-tick', function () { + t.then(function (t) { + t.tick() + }) + }), + i.listen('checkbox-translate', function (e) { + try { + if (!e || !e.locale || !e.table) return + ue.setLocale(e.locale), + ue.addTable(e.locale, e.table), + t.then(function (t) { + t.translate() + }), + document.documentElement.setAttribute('lang', ue.getLocale()) + } catch (Qr) { + At('translation', Qr) + } + }), + i.listen('checkbox-status', function (e) { + t.then(function (t) { + t.setStatus(e.text, e.a11yOnly) + }) + }), + i.listen('checkbox-reset', function () { + t.then(function (t) { + t.reset(), Je.resetData(), Je.record() + }) + }), + i.listen('checkbox-clear', function () { + t.then(function (t) { + t.setLoading(!1) + }) + }), + i.listen('checkbox-location', function (e) { + t.then(function (t) { + var i = t.getLocation() + e.resolve(i) + }) + }) + })(l, h, n), + n.send('checkbox-ready'), + i.custom || ((a = u(null, n)), c(a)) + })() + : (function (t) { + ht.file = 'hcaptcha' + var e = document.currentScript, + i = !1, + n = !1, + o = 'on', + r = tt.Browser.width() / tt.Browser.height(), + s = !(!window.hcaptcha || !window.hcaptcha.render) + function a() { + var t = tt.Browser.width(), + e = tt.Browser.height(), + i = tt.System.mobile && r !== t / e + ;(r = t / e), + h(), + Yr.nodes.each(function (n) { + n.visible && n.resize(t, e, i) }) - .then( - function (e) { - a || ((a = u(e, n)), l(a)) - var i = e.features || {} - ;(ut.a11yChallenge = i.a11y_challenge || !1), - (t = e.charity || !1), - e.status_message && s && !r && a.setWarning(e.status_message) - }, - function (t) { - a || ((a = u(null, n)), l(a)), t.message && a.setStatus(t.message) - }, + } + function c(t) { + l(), + Yr.nodes.each(function (t) { + t.visible && t.position() + }) + } + function l() { + Je.circBuffPush('xy', [ + tt.Browser.scrollX(), + tt.Browser.scrollY(), + document.documentElement.clientWidth / tt.Browser.width(), + Date.now(), + ]) + } + function h() { + Je.circBuffPush('wn', [ + tt.Browser.width(), + tt.Browser.height(), + tt.System.dpr(), + Date.now(), + ]) + } + ;(window.hcaptcha = { + render: function () { + return ( + s || + console.warn( + '[hCaptcha] should not render before js api is fully loaded. `render=explicit` should be used in combination with `onload`.', + ), + Yr.render.apply(this, arguments) ) - .then(function () { - Ue.resetData(), Ue.record(!0, !0, !0, !1), n.send('checkbox-loaded', a.getLocation()) - }), - (function (t, e, i) { - i.listen('site-setup', e), - i.listen('checkbox-tick', function () { - t.then(function (t) { - t.tick() - }) - }), - i.listen('checkbox-translate', function (e) { - try { - if (!e || !e.locale || !e.table) return - se.setLocale(e.locale), - se.addTable(e.locale, e.table), - t.then(function (t) { - t.translate() - }), - document.documentElement.setAttribute('lang', se.getLocale()) - } catch (Fs) { - xt('translation', Fs) - } - }), - i.listen('checkbox-status', function (e) { - t.then(function (t) { - t.setStatus(e.text, e.a11yOnly) - }) - }), - i.listen('checkbox-reset', function () { - t.then(function (t) { - t.reset(), Ue.resetData(), Ue.record() - }) - }), - i.listen('checkbox-clear', function () { - t.then(function (t) { - t.setLoading(!1) - }) - }), - i.listen('checkbox-location', function (e) { - t.then(function (t) { - var i = t.getLocation() - e.resolve(i) + }, + remove: Yr.remove, + execute: Yr.execute, + reset: Yr.reset, + close: Yr.close, + setData: Yr.setData, + getResponse: Yr.getResponse, + getRespKey: Yr.getRespKey, + }), + rr.run(3e3), + He(function () { + var r + s || + ((function () { + var r + r = e ? [e] : document.getElementsByTagName('script') + for (var s = -1, a = !1, c = null, l = null; ++s < r.length && !1 === a; ) { + r[s] && + r[s].src && + ((l = (c = r[s].src.split('?'))[0]), + /\/(hcaptcha|1\/api)\.js$/.test(l) && + ((a = r[s]), + l && + -1 !== l.toLowerCase().indexOf('www.') && + console.warn( + '[hCaptcha] JS API is being loaded from www.hcaptcha.com. Please use https://js.hcaptcha.com/1/api.js', + ))) + } + !1 !== a && + ((t = t || Rt(c[1])), + (i = t.onload || !1), + (n = t.render || !1), + 'off' === t.tplinks && (o = 'off'), + (ft.tplinks = o), + (ft.language = t.hl || null), + t.endpoint && (ft.endpoint = t.endpoint), + (ft.reportapi = t.reportapi || ft.reportapi), + (ft.imghost = t.imghost || null), + (ft.custom = t.custom || ft.custom), + (ft.se = t.se || null), + (ft.pat = t.pat || ft.pat), + (ft.pstIssuer = t.pstissuer || ft.pstIssuer), + (ft.orientation = t.orientation || null), + (ft.assethost = t.assethost || null), + ft.assethost && + !Zt.URL(ft.assethost) && + ((ft.assethost = null), console.error('Invalid assethost uri.')), + (ft.recaptchacompat = t.recaptchacompat || ft.recaptchacompat), + (ht.host = t.host || window.location.hostname), + (ft.sentry = !1 !== t.sentry), + _t(!1), + (ft.language = + ft.language || window.navigator.userLanguage || window.navigator.language), + ue.setLocale(ft.language), + 'off' === ft.recaptchacompat + ? console.log('recaptchacompat disabled') + : (window.grecaptcha = window.hcaptcha)) + })(), + 'en' !== (r = ue.getLocale()) && + Ro(r) + .then(function () { + Yr.nodes.each(function (t) { + if (t) { + try { + t.isLangSet() || t.updateTranslation(r) + } catch (Qr) { + At('translation', Qr) + } + } + }) }) - }) - })(c, h, n), - n.send('checkbox-ready'), - i.custom || ((a = u(null, n)), l(a)) - })() - : Ms() - : Ms() + ['catch'](function (t) { + At('api', t, { locale: r }) + }), + !1 === n || 'onload' === n + ? gt(Yr.render) + : 'explicit' !== n && + console.log( + "hcaptcha: invalid render parameter '" + n + "', using 'explicit' instead.", + ), + (s = !0), + i && + setTimeout(function () { + Nt(i) + }, 1), + (function () { + try { + Je.record(), + Je.setData('sc', tt.Browser.getScreenDimensions()), + Je.setData('wi', tt.Browser.getWindowDimensions()), + Je.setData('nv', tt.Browser.interrogateNavigator()), + Je.setData('dr', document.referrer), + h(), + l() + } catch (Qr) {} + })(), + Ve.addEventListener('resize', a), + Ve.addEventListener('scroll', c)) + }) + })() })() diff --git a/apps/extension/public/leap-cosmos/favicon.ico b/apps/extension/public/leap-cosmos/favicon.ico index edbe9862..4ae95b99 100644 Binary files a/apps/extension/public/leap-cosmos/favicon.ico and b/apps/extension/public/leap-cosmos/favicon.ico differ diff --git a/apps/extension/public/leap-cosmos/icons/icon-128.png b/apps/extension/public/leap-cosmos/icons/icon-128.png index 7f197875..2ca05b1e 100644 Binary files a/apps/extension/public/leap-cosmos/icons/icon-128.png and b/apps/extension/public/leap-cosmos/icons/icon-128.png differ diff --git a/apps/extension/public/leap-cosmos/icons/icon-16.png b/apps/extension/public/leap-cosmos/icons/icon-16.png index eb4b3b96..5a3e52f6 100644 Binary files a/apps/extension/public/leap-cosmos/icons/icon-16.png and b/apps/extension/public/leap-cosmos/icons/icon-16.png differ diff --git a/apps/extension/public/leap-cosmos/icons/icon-48.png b/apps/extension/public/leap-cosmos/icons/icon-48.png index 913726a7..20a03c4a 100644 Binary files a/apps/extension/public/leap-cosmos/icons/icon-48.png and b/apps/extension/public/leap-cosmos/icons/icon-48.png differ diff --git a/apps/extension/public/leap-cosmos/manifest.json b/apps/extension/public/leap-cosmos/manifest.json index ed981863..e14000ff 100644 --- a/apps/extension/public/leap-cosmos/manifest.json +++ b/apps/extension/public/leap-cosmos/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Leap Cosmos Wallet", "description": "A crypto wallet for Cosmos blockchains.", - "version": "0.12.4", + "version": "0.13.0", "options_page": "index.html", "web_accessible_resources": [ { diff --git a/apps/extension/src/App.tsx b/apps/extension/src/App.tsx index 68e61db7..900ec4c5 100644 --- a/apps/extension/src/App.tsx +++ b/apps/extension/src/App.tsx @@ -1,12 +1,15 @@ import 'react-loading-skeleton/dist/skeleton.css' import { + useBannerConfig, useFeatureFlags, + useFetchAggregatedChainsList, useGetBannerApi, useGetFaucetApi, useGetQuickSearchOptions, useInitBetaEvmNftTokenIds, useInitBetaNFTsCollections, + useInitChainCosmosSDK, useInitChainInfosConfig, useInitCoingeckoPrices, useInitCompassSeiEvmConfig, @@ -16,6 +19,7 @@ import { useInitDisabledCW20Tokens, useInitDisabledNFTsCollections, useInitEnabledCW20Tokens, + useInitEnabledNftsCollections, useInitFeeDenoms, useInitFractionalizedNftContracts, useInitGasAdjustments, @@ -24,10 +28,12 @@ import { useInitInteractedTokens, useInitInvestData, useInitIteratedUriNftContracts, + useInitKadoBuyChains, useInitNftChains, useInitSelectedNetwork, useInitSpamProposals, useInitStakingDenoms, + useInitTxLogCosmosBlockchainMap, useInitTxMetadata, useInitWhitelistedFactoryTokens, useMobileAppBanner, @@ -37,14 +43,18 @@ import { useInitSnipDenoms } from '@leapwallet/cosmos-wallet-hooks/dist/utils/us import { LeapUiTheme } from '@leapwallet/leap-ui' import { AppInitLoader } from 'components/loader/AppInitLoader' import { useNomicBTCDepositConstants } from 'hooks/nomic-btc-deposit' -import { useInitFavouriteNFTs, useInitHiddenNFTs, useInitIsCompassWallet } from 'hooks/settings' +import { + useInitFavouriteNFTs, + useInitHiddenNFTs, + useInitIsCompassWallet, + useInitStarredChains, +} from 'hooks/settings' import { useInitiateCurrencyPreference } from 'hooks/settings/useCurrency' import { useInitHideAssets } from 'hooks/settings/useHideAssets' import { useInitHideSmallBalances } from 'hooks/settings/useHideSmallBalances' import { useInitChainInfos } from 'hooks/useChainInfos' import { useInitNodeUrls } from 'hooks/useInitNodeUrls' -import React from 'react' -import { useState } from 'react' +import React, { useState } from 'react' import { SkeletonTheme } from 'react-loading-skeleton' import Browser from 'webextension-polyfill' @@ -82,6 +92,7 @@ export default function App() { useInitTxMetadata({ appVersion: Browser.runtime.getManifest().version }) useInitFavouriteNFTs() + useInitStarredChains() useInitHiddenNFTs() useInitPrimaryWalletAddress() @@ -107,6 +118,7 @@ export default function App() { useInitDisabledNFTsCollections() useInitBetaNFTsCollections() + useInitEnabledNftsCollections() useInitInvestData() useInitSnipDenoms() useInitIbcTraceStore() @@ -122,9 +134,17 @@ export default function App() { useInitStakingDenoms() useInitChainInfosConfig() + useInitKadoBuyChains() + useInitTxLogCosmosBlockchainMap() + useInitChainCosmosSDK() + + useFetchAggregatedChainsList() useInitBetaEvmNftTokenIds() useInitCompassSeiEvmConfig() + useGetBannerApi() + useBannerConfig() + return ( import('pages/onboarding/import' const OnboardingSuccess = React.lazy(() => import('pages/onboarding/success')) const AddSecretToken = React.lazy(() => import('pages/suggest/SuggestSecret')) const Send = React.lazy(() => import('pages/send-v2')) +const Buy = React.lazy(() => import('pages/buy')) const Sign = React.lazy(() => import('pages/sign/sign-transaction')) const SignSeiEvm = React.lazy(() => import('pages/sign-sei-evm/SignSeiEvmTransaction')) const Stake = React.lazy(() => import('pages/stake')) -const CancelUndelegationPage = React.lazy(() => import('pages/stake/cancelUndelegation')) -const ChooseValidator = React.lazy(() => import('pages/stake/chooseValidator')) -const ValidatorDetails = React.lazy(() => import('pages/stake/validatorDetails')) +const CancelUndelegation = React.lazy(() => import('pages/stake/CancelUndelegation')) +const ChooseValidator = React.lazy(() => import('pages/stake/ChooseValidator')) +const ValidatorDetails = React.lazy(() => import('pages/stake/ValidatorDetails')) const AddChain = React.lazy(() => import('pages/suggestChain/addChain')) const SuggestChain = React.lazy(() => import('pages/suggestChain/suggestChain')) @@ -157,7 +158,7 @@ export default function AppRoutes(): JSX.Element { path='stakeCancelUndelegation' element={ - + } /> @@ -193,6 +194,14 @@ export default function AppRoutes(): JSX.Element { } /> + + + + } + /> + diff --git a/apps/extension/src/atoms/last-accessed-wallet.ts b/apps/extension/src/atoms/last-accessed-wallet.ts new file mode 100644 index 00000000..4083d3d0 --- /dev/null +++ b/apps/extension/src/atoms/last-accessed-wallet.ts @@ -0,0 +1,6 @@ +import { atom } from 'recoil' + +export const lastAccessedWalletState = atom({ + key: 'last-accessed-wallet', + default: undefined, +}) diff --git a/apps/extension/src/components/Header/Header.tsx b/apps/extension/src/components/Header/Header.tsx deleted file mode 100644 index acc79825..00000000 --- a/apps/extension/src/components/Header/Header.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import Text from 'components/text' -import { Images } from 'images' -import React from 'react' -import { isCompassWallet } from 'utils/isCompassWallet' - -type Props = { - heading?: string - subtitle?: string - SubTitleComponent?: React.FC - HeadingComponent?: React.FC - headingSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'jumbo' -} - -export const Header: React.FC = ({ - heading, - subtitle, - SubTitleComponent, - HeadingComponent, -}) => { - return ( -
- - {HeadingComponent ? ( - - ) : ( - - {heading} - - )} - {subtitle && ( - - {subtitle} - - )} - {SubTitleComponent && } -
- ) -} diff --git a/apps/extension/src/components/Header/NewChainSupportTooltip.tsx b/apps/extension/src/components/Header/NewChainSupportTooltip.tsx new file mode 100644 index 00000000..d41cd70d --- /dev/null +++ b/apps/extension/src/components/Header/NewChainSupportTooltip.tsx @@ -0,0 +1,76 @@ +import { useTheme } from '@leapwallet/leap-ui' +import { NewChainTooltipData } from 'hooks/useNewChainTooltip' +import React from 'react' + +type NewChainSupportTooltipProps = { + handleToolTipClose: () => void + handleCTAClick: () => void + toolTipData: NewChainTooltipData +} + +const NewChainSupportTooltip = ({ + toolTipData, + handleCTAClick, + handleToolTipClose, +}: NewChainSupportTooltipProps) => { + const { header, description, imgUrl, ctaText } = toolTipData + + const { theme } = useTheme() + + return ( + <> +
{ + e.stopPropagation() + }} + className='cursor-default z-[2] p-3 rounded-xl absolute bg-white-100 w-[272px] border border-gray-200 dark:border-gray-850 dark:bg-gray-950 top-[56px] right-0 flex flex-col justify-start items-start gap-3' + > +
+ + + + +
+ + {imgUrl && tooltip-img} + +
+
+ {header} +
+
+ {description} +
+
+ +
+ + +
+
+ + ) +} + +export default NewChainSupportTooltip diff --git a/apps/extension/src/components/Header/PageHeader.tsx b/apps/extension/src/components/Header/PageHeader.tsx new file mode 100644 index 00000000..8f7a8b11 --- /dev/null +++ b/apps/extension/src/components/Header/PageHeader.tsx @@ -0,0 +1,85 @@ +import { LineDivider } from '@leapwallet/leap-ui' +import classNames from 'classnames' +import { ActionButton } from 'components/button' +import useNewChainTooltip from 'hooks/useNewChainTooltip' +import { Images } from 'images' +import React from 'react' +import { PageHeaderProps } from 'types/components' + +import NewChainSupportTooltip from './NewChainSupportTooltip' + +const PageHeader = React.memo( + ({ title, action, imgSrc, onImgClick, dontShowFilledArrowIcon = false }: PageHeaderProps) => { + const { showToolTip: _showToolTip, toolTipData, handleToolTipClose } = useNewChainTooltip() + + const showToolTip = _showToolTip && !!toolTipData && !!onImgClick + + return ( + <> + {showToolTip && ( +
+ )} +
+
+
{title}
+
+ + {action ? ( +
+ +
+ ) : null} + + {imgSrc ? ( +
+ {typeof imgSrc === 'string' ? ( + + ) : ( + imgSrc + )} + + {onImgClick !== undefined && !dontShowFilledArrowIcon && ( + + )} + + {showToolTip && ( + { + onImgClick() + handleToolTipClose() + }} + handleToolTipClose={handleToolTipClose} + /> + )} +
+ ) : null} + +
+ +
+
+ + ) + }, +) + +PageHeader.displayName = 'PageHeader' +export { PageHeader } diff --git a/apps/extension/src/components/Header/index.ts b/apps/extension/src/components/Header/index.ts index c73f6da4..f76b3366 100644 --- a/apps/extension/src/components/Header/index.ts +++ b/apps/extension/src/components/Header/index.ts @@ -1 +1,2 @@ -export * from './header' +export * from './Header' +export * from './PageHeader' diff --git a/apps/extension/src/components/Infosheet/index.tsx b/apps/extension/src/components/Infosheet/index.tsx index 7e4bb687..f98fd323 100644 --- a/apps/extension/src/components/Infosheet/index.tsx +++ b/apps/extension/src/components/Infosheet/index.tsx @@ -8,6 +8,7 @@ export default function InfoSheet({ title, isVisible, setVisible, + className, }: { heading: string title: string @@ -15,6 +16,7 @@ export default function InfoSheet({ isVisible: boolean // eslint-disable-next-line no-unused-vars setVisible: (v: boolean) => void + className?: string }) { return ( setVisible(false)} title={title} closeOnBackdropClick={true} + wrapperClassName={className} > {heading} diff --git a/apps/extension/src/components/Receive/index.tsx b/apps/extension/src/components/Receive/index.tsx index 873acb50..742c24f5 100644 --- a/apps/extension/src/components/Receive/index.tsx +++ b/apps/extension/src/components/Receive/index.tsx @@ -1,15 +1,9 @@ import { useActiveChain, useChainInfo } from '@leapwallet/cosmos-wallet-hooks' import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' -import { - Buttons, - HeaderActionType, - OnboardCard, - QrCode, - ThemeName, - useTheme, -} from '@leapwallet/leap-ui' -import BottomSheet from 'components/bottom-sheet/BottomSheet' +import { Buttons, OnboardCard, QrCode, ThemeName, useTheme } from '@leapwallet/leap-ui' +import BottomModal from 'components/bottom-modal' import { ON_RAMP_SUPPORT_CHAINS } from 'config/config' +import { useChainPageInfo } from 'hooks' import { useNomicBTCDepositConstants } from 'hooks/nomic-btc-deposit' import useActiveWallet from 'hooks/settings/useActiveWallet' import { useGetWalletAddresses } from 'hooks/useGetWalletAddresses' @@ -19,7 +13,6 @@ import kadoLightLogo from 'images/logos/Kado-light.svg' import { nBtcSymbol } from 'images/misc' import rightArrow from 'images/misc/right-arrow.svg' import React, { ReactElement } from 'react' -import { Colors } from 'theme/colors' import { UserClipboard } from 'utils/clipboard' import { formatWalletName } from 'utils/formatWalletName' import { isCompassWallet } from 'utils/isCompassWallet' @@ -48,21 +41,24 @@ export type ReceiveTokenProps = { chain?: SupportedChain onCloseHandler?: () => void handleBtcBannerClick?: () => void + tokenBalanceOnChain?: SupportedChain } export default function ReceiveToken({ isVisible, onCloseHandler, handleBtcBannerClick, + tokenBalanceOnChain, }: ReceiveTokenProps): ReactElement { const wallet = useActiveWallet().activeWallet - const activeChainInfo = useChainInfo() - const activeChain = useActiveChain() + const _activeChain = useActiveChain() + const activeChain = tokenBalanceOnChain ?? _activeChain + const { topChainColor } = useChainPageInfo() - const address = wallet?.addresses[activeChainInfo?.key] + const address = wallet?.addresses[activeChain] const { theme } = useTheme() const isDark = theme === ThemeName.DARK - const walletAddress = useGetWalletAddresses() + const walletAddress = useGetWalletAddresses(activeChain) const QrCodeProps = { height: 250, @@ -77,16 +73,15 @@ export default function ReceiveToken({ } return ( - void} - headerTitle={'Your QR code'} - closeOnClickBackDrop={true} - headerActionType={HeaderActionType.CANCEL} + {wallet ? ( -
-
+
+
@@ -94,22 +89,21 @@ export default function ReceiveToken({
{walletAddress.map((address, index) => ( - <> + {index !== 0 &&
} { if (!address) return UserClipboard.copyText(address) }} - key={address} /> - + ))} - {ON_RAMP_SUPPORT_CHAINS.includes(activeChainInfo?.key) && ( + {ON_RAMP_SUPPORT_CHAINS.includes(activeChain) && (
{ @@ -122,9 +116,7 @@ export default function ReceiveToken({ isFilled isRounded size='lg' - title={`Buy ${ - activeChainInfo?.key === 'osmosis' ? 'AxlUSDC' : 'Crypto' - } with Kado Ramp`} + title={`Buy ${activeChain === 'osmosis' ? 'AxlUSDC' : 'Crypto'} with Kado Ramp`} />
)} @@ -134,6 +126,6 @@ export default function ReceiveToken({ ) : ( <> )} - + ) } diff --git a/apps/extension/src/components/Skeletons/GlobalBannersLoading.tsx b/apps/extension/src/components/Skeletons/GlobalBannersLoading.tsx new file mode 100644 index 00000000..b93e3c9b --- /dev/null +++ b/apps/extension/src/components/Skeletons/GlobalBannersLoading.tsx @@ -0,0 +1,34 @@ +import { ThemeName, useTheme } from '@leapwallet/leap-ui' +import React from 'react' +import Skeleton, { SkeletonTheme } from 'react-loading-skeleton' + +export function GlobalBannersLoading() { + const { theme } = useTheme() + const isDark = theme === ThemeName.DARK + const baseColor1 = isDark ? '#393939' : '#D6D6D6' + const highlightColor1 = isDark ? '#2C2C2C' : '#E8E8E8' + + return ( +
+
+
+ + + + +
+ + + +
+
+
+
+ ) +} diff --git a/apps/extension/src/components/Skeletons/TokenListSkeleton.tsx b/apps/extension/src/components/Skeletons/TokenListSkeleton.tsx new file mode 100644 index 00000000..ce32ac0d --- /dev/null +++ b/apps/extension/src/components/Skeletons/TokenListSkeleton.tsx @@ -0,0 +1,26 @@ +import React from 'react' +import Skeleton from 'react-loading-skeleton' + +export function TokenItemSkeleton() { + return ( +
+ +
+ + +
+
+ ) +} + +export default function TokenListSkeleton() { + return ( + <> + + + + + + + ) +} diff --git a/apps/extension/src/components/Skeletons/index.ts b/apps/extension/src/components/Skeletons/index.ts new file mode 100644 index 00000000..6443bc6c --- /dev/null +++ b/apps/extension/src/components/Skeletons/index.ts @@ -0,0 +1 @@ +export * from './GlobalBannersLoading' diff --git a/apps/extension/src/components/WarningCard/index.tsx b/apps/extension/src/components/WarningCard/index.tsx index 572a01a0..22d6a543 100644 --- a/apps/extension/src/components/WarningCard/index.tsx +++ b/apps/extension/src/components/WarningCard/index.tsx @@ -4,7 +4,7 @@ import Text from '../text' export default function WarningCard({ text, subText }: { text: string; subText?: string }) { return ( -
+
info
diff --git a/apps/extension/src/components/action-input-with-preview/index.tsx b/apps/extension/src/components/action-input-with-preview/index.tsx index 733ef4ba..60ab4d01 100644 --- a/apps/extension/src/components/action-input-with-preview/index.tsx +++ b/apps/extension/src/components/action-input-with-preview/index.tsx @@ -73,11 +73,11 @@ export const ActionInputWithPreview = React.forwardRef( transition={{ duration: 0.2, ease: 'linear' }} exit={{ opacity: 0.9 }} className={classNames( - 'border rounded-lg transition bg-gray-50 dark:bg-gray-800 outline-none text-gray-800 caret-gray-800 dark:text-white-100 w-full pl-4 pr-12 py-2', + 'border rounded-xl transition bg-gray-50 dark:bg-gray-900 outline-none text-gray-800 caret-gray-800 dark:text-white-100 w-full pl-4 pr-12 py-2', { 'border-red-300 dark:border-red-300': invalid, 'border-yellow-600 dark:border-yellow-600': warning, - 'border-gray-300 dark:border-gray-800 focus:border-gray-400 dark:focus:border-gray-500': + 'border-[transparent] focus:border-gray-400 dark:focus:border-gray-500': !invalid && !warning, }, )} @@ -133,7 +133,7 @@ export const ActionInputWithPreview = React.forwardRef( > {action - ) : ( + ) : buttonText ? ( - )} + ) : null}
) : null}
diff --git a/apps/extension/src/components/aggregated/AggregatedLoading.tsx b/apps/extension/src/components/aggregated/AggregatedLoading.tsx new file mode 100644 index 00000000..1fce8ff9 --- /dev/null +++ b/apps/extension/src/components/aggregated/AggregatedLoading.tsx @@ -0,0 +1,96 @@ +import { ThemeName, useTheme } from '@leapwallet/leap-ui' +import classNames from 'classnames' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { useActiveChain } from 'hooks/settings/useActiveChain' +import React from 'react' +import Skeleton, { SkeletonTheme } from 'react-loading-skeleton' +import { AggregatedSupportedChain } from 'types/utility' + +type AggregatedLoadingProps = { + className?: string +} + +export function AggregatedLoading({ className }: AggregatedLoadingProps) { + const { theme } = useTheme() + const activeChain = useActiveChain() as AggregatedSupportedChain + + const isDark = theme === ThemeName.DARK + const baseColor1 = isDark ? '#393939' : '#D6D6D6' + const highlightColor1 = isDark ? '#2C2C2C' : '#E8E8E8' + const baseColor2 = isDark ? '#222222' : '#E8E8E8' + const highlightColor2 = isDark ? '#1f1e1e' : '#F4F4F4' + + return ( +
+
+
+ + + + +
+ + + + + {activeChain === AGGREGATED_CHAIN_KEY && ( + + + + )} +
+
+ +
+ + + + + + + +
+
{' '} +
+ ) +} + +export function AggregatedBalanceLoading() { + const { theme } = useTheme() + const isDark = theme === ThemeName.DARK + const baseColor1 = isDark ? '#393939' : '#D6D6D6' + const highlightColor1 = isDark ? '#2C2C2C' : '#E8E8E8' + + return ( +
+ {[0, 1, 2, 3].map((_, index) => ( + + + + ))} +
+ ) +} diff --git a/apps/extension/src/components/aggregated/AggregatedNullComponents.tsx b/apps/extension/src/components/aggregated/AggregatedNullComponents.tsx new file mode 100644 index 00000000..a712a5ad --- /dev/null +++ b/apps/extension/src/components/aggregated/AggregatedNullComponents.tsx @@ -0,0 +1,99 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { + useActiveWallet, + useAggregatedChainsList, + useGetChains, + WALLETTYPE, +} from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { LEDGER_ENABLED_EVM_CHAIN_IDS } from 'config/config' +import { ManageChainSettings, useManageChainData } from 'hooks/settings/useManageChains' +import React, { useMemo } from 'react' +import { isLedgerEnabled } from 'utils/isLedgerEnabled' + +type AggregatedNullComponentsProps = { + setAggregatedStore: any + render: ({ + key, + chain, + setAggregatedStore, + }: { + key: string + chain: SupportedChain + setAggregatedStore: any + }) => JSX.Element +} + +export const AggregatedNullComponents = React.memo(function ({ + setAggregatedStore, + render, +}: AggregatedNullComponentsProps) { + const [managedChains] = useManageChainData() + const chains = useGetChains() + const aggregatedChains = useAggregatedChainsList() + const activeWallet = useActiveWallet() + + const chainsToFetch = useMemo(() => { + return aggregatedChains.reduce((acc: ManageChainSettings[], chain) => { + const chainInfo = chains[chain] + const noAddress = !activeWallet?.addresses[chain] + + // If `connectEVMLedger` check is true, then we will skip the chain + if ( + noAddress && + activeWallet?.walletType === WALLETTYPE.LEDGER && + LEDGER_ENABLED_EVM_CHAIN_IDS.includes(chainInfo?.chainId) + ) { + return acc + } + + // If `ledgerNotSupported` check is true, then we will skip the chain + if ( + noAddress && + activeWallet?.walletType === WALLETTYPE.LEDGER && + !LEDGER_ENABLED_EVM_CHAIN_IDS.includes(chainInfo?.chainId) + ) { + return acc + } + + // If no address, chain is testnet or apiStatus is false, then we will skip the chain + if ( + noAddress || + chainInfo?.chainId === chainInfo?.testnetChainId || + chainInfo?.apiStatus === false + ) { + return acc + } + + // If `disabled` check is true, then we will skip the chain + if ( + activeWallet?.walletType === WALLETTYPE.LEDGER && + !isLedgerEnabled(chain, chainInfo?.bip44?.coinType) + ) { + return acc + } + + // If managed chain is not active, skip fetching the chain + const managedChain = managedChains.find((managedChain) => managedChain.chainName === chain) + if (managedChain && managedChain.active) { + return [...acc, managedChain] + } + + return acc + }, []) + }, [activeWallet?.addresses, activeWallet?.walletType, aggregatedChains, chains, managedChains]) + + return ( + <> + {chainsToFetch.map((chain) => + render({ + key: chain.chainName, + chain: chain.chainName, + setAggregatedStore, + }), + )} + + ) +}) + +AggregatedNullComponents.displayName = 'AggregatedNullComponents' diff --git a/apps/extension/src/components/aggregated/AggregatedSearchComponent.tsx b/apps/extension/src/components/aggregated/AggregatedSearchComponent.tsx new file mode 100644 index 00000000..e00e4c0f --- /dev/null +++ b/apps/extension/src/components/aggregated/AggregatedSearchComponent.tsx @@ -0,0 +1,53 @@ +import classNames from 'classnames' +import { Images } from 'images' +import React, { useEffect, useRef } from 'react' + +type AggregatedSearchComponentsProps = { + handleClose: () => void + value: string + handleChange: (value: string) => void + placeholder?: string + className?: string +} + +export function AggregatedSearchComponent({ + handleClose, + value, + handleChange, + placeholder, + className, +}: AggregatedSearchComponentsProps) { + const inputRef = useRef(null) + + useEffect(() => { + inputRef.current?.focus() + }, []) + + return ( +
+
+ handleChange(event.target.value)} + ref={inputRef} + /> + + +
+ + +
+ ) +} diff --git a/apps/extension/src/components/aggregated/index.ts b/apps/extension/src/components/aggregated/index.ts new file mode 100644 index 00000000..b29b125b --- /dev/null +++ b/apps/extension/src/components/aggregated/index.ts @@ -0,0 +1,3 @@ +export * from './AggregatedLoading' +export * from './AggregatedNullComponents' +export * from './AggregatedSearchComponent' diff --git a/apps/extension/src/components/alert-strip/AlertStrip.tsx b/apps/extension/src/components/alert-strip/AlertStrip.tsx index 7de0e98d..8e5083fa 100644 --- a/apps/extension/src/components/alert-strip/AlertStrip.tsx +++ b/apps/extension/src/components/alert-strip/AlertStrip.tsx @@ -15,59 +15,58 @@ type AlertStripProps = { childComponent?: React.ReactNode } -export default function AlertStrip({ - message, - childComponent, - bgColor, - alwaysShow = false, - onHide, - className, - timeOut = 8000, - textClassName, - onClick, - ...rest -}: AlertStripProps) { - const [show, setShow] = useState(true) - const mountedRef = useRef(true) +const AlertStrip = React.memo( + ({ + message, + bgColor, + alwaysShow = false, + onHide, + className, + timeOut = 8000, + textClassName, + ...rest + }: AlertStripProps) => { + const [show, setShow] = useState(true) + const mountedRef = useRef(true) - const fn = () => { - new Promise((res) => setTimeout(res, timeOut)).then(() => { - if (mountedRef.current) { - setShow(false) - onHide && onHide() + const fn = () => { + new Promise((res) => setTimeout(res, timeOut)).then(() => { + if (mountedRef.current) { + setShow(false) + onHide && onHide() + } + }) + return () => { + mountedRef.current = false } - }) - return () => { - mountedRef.current = false } - } - useEffect(() => { - if (show && !alwaysShow) fn() - return () => { - mountedRef.current = false - } + useEffect(() => { + if (show && !alwaysShow) fn() + return () => { + mountedRef.current = false + } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [show]) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [show]) - return show ? ( -
{ - if (onClick) { - onClick() - } - }} - > - - {childComponent ?? message} - -
- ) : null -} + + {message} + +
+ ) : null + }, +) + +AlertStrip.displayName = 'AlertStrip' + +export { AlertStrip } diff --git a/apps/extension/src/components/alert-strip/SelectedChainAlertStrip.tsx b/apps/extension/src/components/alert-strip/SelectedChainAlertStrip.tsx deleted file mode 100644 index c53f4c56..00000000 --- a/apps/extension/src/components/alert-strip/SelectedChainAlertStrip.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { selectedChainAlertState } from 'atoms/selected-chain-alert' -import { useActiveChain } from 'hooks/settings/useActiveChain' -import { useSelectedNetwork, useSetNetwork } from 'hooks/settings/useNetwork' -import { useChainInfos } from 'hooks/useChainInfos' -import React from 'react' -import { useNavigate } from 'react-router' -import { useRecoilState } from 'recoil' -import { Colors } from 'theme/colors' -import { isCompassWallet } from 'utils/isCompassWallet' - -import AlertStrip from './AlertStrip' - -const SelectedChainAlertStrip = () => { - const [showSelectedChainAlert, setShowSelectedChainAlert] = - useRecoilState(selectedChainAlertState) - - const activeChain = useActiveChain() - const selectedNetwork = useSelectedNetwork() - const adjustedSetCurrentChainName = useSetNetwork() - const navigate = useNavigate() - const chainInfos = useChainInfos() - - const isTestnet = selectedNetwork === 'testnet' - const chain = chainInfos[activeChain] - const isOnTestnetWithNewMainnet = ['pryzmtestnet']?.includes(chain?.key) && isTestnet - - return ( - <> - {isCompassWallet() && isTestnet && activeChain !== 'seiDevnet' && ( - - )} - - {showSelectedChainAlert && !isCompassWallet() && ( - - {chain?.chainName} mainnet is now live. - Switch to mainnet! - - ) : undefined - } - message={`You are on ${chain?.chainName}${ - isTestnet && !chain?.chainName.includes('Testnet') ? ' Testnet' : '' - }`} - className={isOnTestnetWithNewMainnet ? 'cursor-pointer' : ''} - onClick={ - isOnTestnetWithNewMainnet - ? () => { - adjustedSetCurrentChainName('mainnet') - navigate('/', { replace: true }) - } - : undefined - } - bgColor={chain?.theme?.primaryColor} - alwaysShow={isTestnet} - onHide={() => { - setShowSelectedChainAlert(false) - }} - /> - )} - - ) -} - -export default SelectedChainAlertStrip diff --git a/apps/extension/src/components/alert-strip/TestnetAlertStrip.tsx b/apps/extension/src/components/alert-strip/TestnetAlertStrip.tsx new file mode 100644 index 00000000..5f5315ff --- /dev/null +++ b/apps/extension/src/components/alert-strip/TestnetAlertStrip.tsx @@ -0,0 +1,38 @@ +import { useActiveChain, useChainInfo, useSelectedNetwork } from '@leapwallet/cosmos-wallet-hooks' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { useChainPageInfo } from 'hooks' +import React, { useMemo } from 'react' +import { AggregatedSupportedChain } from 'types/utility' + +import { AlertStrip } from './index' + +const TestnetAlertStrip = React.memo(() => { + const activeNetwork = useSelectedNetwork() + const activeChainInfo = useChainInfo() + const activeChain = useActiveChain() as AggregatedSupportedChain + const { topChainColor } = useChainPageInfo() + + const chainName = useMemo(() => { + if (!activeChainInfo) { + return '' + } + + if (activeChainInfo.chainName.includes('Testnet')) { + return activeChainInfo.chainName + } + + return activeChainInfo.chainName + ' Testnet' + }, [activeChainInfo]) + + if (activeNetwork !== 'testnet' || activeChain === AGGREGATED_CHAIN_KEY) { + return null + } + + return ( + + ) +}) + +TestnetAlertStrip.displayName = 'TestnetAlertStrip' + +export { TestnetAlertStrip } diff --git a/apps/extension/src/components/alert-strip/index.ts b/apps/extension/src/components/alert-strip/index.ts new file mode 100644 index 00000000..5c458a0d --- /dev/null +++ b/apps/extension/src/components/alert-strip/index.ts @@ -0,0 +1,2 @@ +export * from './AlertStrip' +export * from './TestnetAlertStrip' diff --git a/apps/extension/src/components/auto-adjust-amount-sheet/index.tsx b/apps/extension/src/components/auto-adjust-amount-sheet/index.tsx index 9debf950..33279d04 100644 --- a/apps/extension/src/components/auto-adjust-amount-sheet/index.tsx +++ b/apps/extension/src/components/auto-adjust-amount-sheet/index.tsx @@ -3,12 +3,11 @@ import { getAutoAdjustAmount, getKeyToUseForDenoms, Token, - useActiveChain, useChainInfo, useDenoms, useShouldShowAutoAdjustSheet, } from '@leapwallet/cosmos-wallet-hooks' -import { fromSmall, NativeDenom, toSmall } from '@leapwallet/cosmos-wallet-sdk' +import { fromSmall, NativeDenom, SupportedChain, toSmall } from '@leapwallet/cosmos-wallet-sdk' import { Buttons, ThemeName, useTheme } from '@leapwallet/leap-ui' import BottomModal from 'components/bottom-modal' import React, { useCallback, useEffect, useMemo } from 'react' @@ -32,8 +31,6 @@ const OptionalAutoAdjustAmountSheet: React.FC< } > = ({ isOpen, tokenAmount, feeAmount, setAmount, nativeDenom, onAdjust, onCancel, onBack }) => { const { theme } = useTheme() - const activeChain = useActiveChain() - const updatedAmount = useMemo(() => { return getAutoAdjustAmount({ tokenAmount, @@ -70,19 +67,29 @@ const OptionalAutoAdjustAmountSheet: React.FC< closeOnBackdropClick={true} onClose={onCancel} onActionButtonClick={onBack} + containerClassName='!max-h-[600px]' + contentClassName='!bg-white-100 dark:!bg-gray-950' + className='p-6' > -
-

- Confirming this transaction may leave you with insufficient {nativeDenom?.coinDenom ?? ''}{' '} - balance for future transaction fees. -

-

- Should we adjust the amount from{' '} - {displayTokenAmount} to{' '} - {displayUpdatedAmount}? -

+

+ Confirming this transaction may leave you with insufficient {nativeDenom?.coinDenom ?? ''}{' '} + balance for future transaction fees. +

+ +
+

Should we auto-adjust the amount?

+ +
+
+ {displayTokenAmount} +
+ +
east
+
{displayUpdatedAmount}
+
-
+ +
- Don't adjust + Cancel + - Auto-adjust + Proceed
@@ -121,14 +129,14 @@ const CompulsoryAutoAdjustAmountSheet: React.FC< onCancel, }) => { const { theme } = useTheme() - const activeChain = useActiveChain() - const updatedAmount = useMemo(() => { return getAutoAdjustAmount({ tokenAmount: tokenBalance, feeAmount, nativeDenom, }) + + // eslint-disable-next-line react-hooks/exhaustive-deps }, [feeAmount, nativeDenom, tokenAmount]) const handleAdjust = useCallback(() => { @@ -158,17 +166,29 @@ const CompulsoryAutoAdjustAmountSheet: React.FC< onClose={onCancel} closeOnBackdropClick={false} title='Adjust for Transaction Fees' - hideActionButton={true} + containerClassName='!bg-white-100 dark:!bg-gray-950 !max-h-[600px]' + contentClassName='!bg-white-100 dark:!bg-gray-950' + className='p-6' > -
-

Insufficient {nativeDenom?.coinDenom ?? ''} balance to pay transaction fees.

-

- Should we adjust the amount from{' '} - {displayTokenAmount} to{' '} - {displayUpdatedAmount}? -

+

+ You seem to have insufficient {nativeDenom?.coinDenom ?? ''} balance to pay transaction + fees. +

+ +
+

Should we auto-adjust the amount?

+ +
+
+ {displayTokenAmount} +
+ +
east
+
{displayUpdatedAmount}
+
-
+ +
- Cancel Transaction + Cancel + - Auto-adjust + Proceed
@@ -205,9 +226,20 @@ export const AutoAdjustAmountSheet: React.FC<{ // eslint-disable-next-line no-unused-vars setShowReviewSheet: (show: boolean) => void closeAdjustmentSheet: () => void -}> = ({ amount, setAmount, selectedToken, fee, setShowReviewSheet, closeAdjustmentSheet }) => { - const chainInfo = useChainInfo() - const shouldShowAutoAdjustSheet = useShouldShowAutoAdjustSheet() + forceChain?: SupportedChain + forceNetwork?: 'mainnet' | 'testnet' +}> = ({ + amount, + setAmount, + selectedToken, + fee, + setShowReviewSheet, + closeAdjustmentSheet, + forceChain, + forceNetwork, +}) => { + const chainInfo = useChainInfo(forceChain) + const shouldShowAutoAdjustSheet = useShouldShowAutoAdjustSheet(forceChain, forceNetwork) const navigate = useNavigate() const denoms = useDenoms() @@ -281,6 +313,7 @@ export const AutoAdjustAmountSheet: React.FC<{ onAdjust={allowReview} onCancel={allowReview} /> + +
{text}
diff --git a/apps/extension/src/components/bottom-modal/index.tsx b/apps/extension/src/components/bottom-modal/index.tsx index 8c336895..1e936c0f 100644 --- a/apps/extension/src/components/bottom-modal/index.tsx +++ b/apps/extension/src/components/bottom-modal/index.tsx @@ -33,13 +33,13 @@ type BottomModalProps = React.PropsWithChildren<{ */ className?: string /* - * custom class names for the container + * custom class names for the main wrapper */ - containerClassName?: string + wrapperClassName?: string /* - * custom class names for the header + * custom class names for the container */ - headerClassName?: string + containerClassName?: string /* * custom class names for the content */ @@ -56,18 +56,10 @@ type BottomModalProps = React.PropsWithChildren<{ * custom action button */ actionButton?: React.ReactNode - /* - * should the secondary action button be shown - */ - showSecondaryActionButton?: boolean /* * custom secondary action button */ secondaryActionButton?: React.ReactNode - /* - * callback when the secondary action button is clicked - */ - onSecondaryActionButtonClick?: () => void }> const BottomModal: React.FC = ({ @@ -81,13 +73,11 @@ const BottomModal: React.FC = ({ disableClose, actionButton, onActionButtonClick, + wrapperClassName, containerClassName, - headerClassName, contentClassName, hideActionButton, - showSecondaryActionButton, secondaryActionButton, - onSecondaryActionButtonClick, }) => { const container = document.getElementById('popup-layout')?.parentNode as HTMLElement @@ -108,46 +98,40 @@ const BottomModal: React.FC = ({ isOpen={isOpen} detent='content-height' onClose={handleCloseAction} - className='w-[400px] h-[600px] mx-auto !absolute' + className={classNames('w-[400px] h-[600px] mx-auto !absolute', wrapperClassName)} > - -
+
+ {secondaryActionButton ? secondaryActionButton : null} + {titleComponent ?? ( +

+ {title} +

+ )} {hideActionButton ? null : actionButton ?? ( -
+
{}
)} - {titleComponent ?? ( -

- {title} -

- )} - {showSecondaryActionButton === true - ? secondaryActionButton ?? ( -
- -
- ) - : null}
-
{children}
+
{children}
void) => ReactElement -} - -export default function BottomSheet({ - isVisible, - onClose, - children, - headerTitle, - headerActionType, - delayDrawTime, - headerRightImg, - onClickHeaderRight, - closeOnClickBackDrop = true, - customHeader, -}: BottomSheetProps) { - if (!isVisible) return null - return ( - - {(toggle) => ( -
- {!customHeader && ( -
- )} - {!!customHeader && customHeader(toggle)} - {children} -
- )} -
- ) -} diff --git a/apps/extension/src/components/button/HeaderActionButton.tsx b/apps/extension/src/components/button/HeaderActionButton.tsx new file mode 100644 index 00000000..bdad192f --- /dev/null +++ b/apps/extension/src/components/button/HeaderActionButton.tsx @@ -0,0 +1,19 @@ +import { Buttons } from '@leapwallet/leap-ui' +import React from 'react' +import { HeaderAction, HeaderActionType } from 'types/components' + +const ActionButton = React.memo(({ type, onClick, className }: HeaderAction) => { + switch (type) { + case HeaderActionType.CANCEL: + return + + case HeaderActionType.BACK: + return + + case HeaderActionType.NAVIGATION: + return + } +}) + +ActionButton.displayName = 'ActionButton' +export { ActionButton } diff --git a/apps/extension/src/components/button/WalletButton.tsx b/apps/extension/src/components/button/WalletButton.tsx new file mode 100644 index 00000000..70b44104 --- /dev/null +++ b/apps/extension/src/components/button/WalletButton.tsx @@ -0,0 +1,101 @@ +import classNames from 'classnames' +import { motion } from 'framer-motion' +import { CopySvg, FilledDownArrowSvg } from 'images/misc' +import React from 'react' + +type WalletButtonProps = { + showWalletAvatar?: boolean + giveCopyOption?: boolean + handleCopyClick?: () => void + walletName: string + showDropdown?: boolean + handleDropdownClick?: () => void + walletAvatar?: string + isAddressCopied?: boolean + isToAddLinkAddressNudgeText?: boolean +} + +const WalletButton = React.memo( + ({ + showWalletAvatar, + giveCopyOption, + handleCopyClick, + walletName, + showDropdown, + handleDropdownClick, + walletAvatar, + isAddressCopied, + isToAddLinkAddressNudgeText, + }: WalletButtonProps) => { + return ( +
+ + + {giveCopyOption ? ( + + ) : null} + + {isAddressCopied && ( + + + check_circle + + Copied! + + )} +
+ ) + }, +) + +WalletButton.displayName = 'WalletButton' +export { WalletButton } diff --git a/apps/extension/src/components/button/index.ts b/apps/extension/src/components/button/index.ts new file mode 100644 index 00000000..15122987 --- /dev/null +++ b/apps/extension/src/components/button/index.ts @@ -0,0 +1,2 @@ +export * from './HeaderActionButton' +export * from './WalletButton' diff --git a/apps/extension/src/components/card/CopyAddressCard.tsx b/apps/extension/src/components/card/CopyAddressCard.tsx new file mode 100644 index 00000000..b947cb9e --- /dev/null +++ b/apps/extension/src/components/card/CopyAddressCard.tsx @@ -0,0 +1,112 @@ +import { sliceAddress, useActiveChain, useGetChains } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import classNames from 'classnames' +import { useDefaultTokenLogo } from 'hooks' +import { CopySvg, OutlinRoundGreenCheckSvg } from 'images/misc' +import React, { ReactNode, useCallback, useMemo, useState } from 'react' +import { UserClipboard } from 'utils/clipboard' +import { imgOnError } from 'utils/imgOnError' + +type CopyAddressCardProps = { + forceChain?: SupportedChain + address: string + showDifferentIconForButton?: boolean + DifferentIconToShow?: ReactNode + differentIconButtonClassName?: string + differentIconButtonOnClick?: () => void + forceName?: string +} + +const CopyAddressCard = React.memo( + ({ + forceChain, + address, + showDifferentIconForButton, + DifferentIconToShow, + differentIconButtonClassName, + differentIconButtonOnClick, + forceName, + }: CopyAddressCardProps) => { + const chains = useGetChains() + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) + + const activeChainInfo = chains[activeChain] + const defaultTokenLogo = useDefaultTokenLogo() + const [isCopied, setIsCopied] = useState(false) + + const name = useMemo(() => { + if (forceName) { + return forceName + } + + let _name = + activeChainInfo.addressPrefix.slice(0, 1).toUpperCase() + + activeChainInfo.addressPrefix.slice(1).toLowerCase() + + if (address.toLowerCase().startsWith('0x')) { + _name = 'EVM' + } + + return _name + ' ' + 'address' + }, [activeChainInfo.addressPrefix, address, forceName]) + + const handleCopyClick = useCallback(() => { + setIsCopied(true) + setTimeout(() => setIsCopied(false), 2000) + + UserClipboard.copyText(address) + }, [address]) + + return ( +
+
+ {activeChainInfo.chainName + +
+

{name}

+

+ {sliceAddress(address, 5)} +

+
+
+ + {showDifferentIconForButton ? ( + + ) : ( + + )} +
+ ) + }, +) + +CopyAddressCard.displayName = 'CopyAddressCard' +export { CopyAddressCard } diff --git a/apps/extension/src/components/card/index.ts b/apps/extension/src/components/card/index.ts new file mode 100644 index 00000000..e9e5af5a --- /dev/null +++ b/apps/extension/src/components/card/index.ts @@ -0,0 +1 @@ +export * from './CopyAddressCard' diff --git a/apps/extension/src/components/coming-soon/ComingSoon.tsx b/apps/extension/src/components/coming-soon/ComingSoon.tsx index 3030cd47..6caa9f27 100644 --- a/apps/extension/src/components/coming-soon/ComingSoon.tsx +++ b/apps/extension/src/components/coming-soon/ComingSoon.tsx @@ -1,12 +1,11 @@ -import { useActiveChain, useGetChains } from '@leapwallet/cosmos-wallet-hooks' import { Header, HeaderActionType } from '@leapwallet/leap-ui' import BottomNav, { BottomNavLabel } from 'components/bottom-nav/BottomNav' import PopupLayout from 'components/layout/popup-layout' -import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' +import { useChainPageInfo } from 'hooks' +import { useDontShowSelectChain } from 'hooks/useDontShowSelectChain' import SelectChain from 'pages/home/SelectChain' import SideNav from 'pages/home/side-nav' import React, { useState } from 'react' -import { Colors } from 'theme/colors' type ComingSoonProps = { title: string @@ -16,13 +15,8 @@ type ComingSoonProps = { export function ComingSoon({ title, bottomNavLabel }: ComingSoonProps) { const [showSideNav, setShowSideNav] = useState(false) const [showChainSelector, setShowChainSelector] = useState(false) - - const activeChain = useActiveChain() - const chains = useGetChains() - const defaultTokenLogo = useDefaultTokenLogo() - - const activeChainInfo = chains[activeChain] - const themeColor = Colors.getChainColor(activeChain, activeChainInfo) + const { headerChainImgSrc } = useChainPageInfo() + const dontShowSelectChain = useDontShowSelectChain() return (
@@ -40,10 +34,9 @@ export function ComingSoon({ title, bottomNavLabel }: ComingSoonProps) { className: 'w-[48px] h-[40px] px-3 bg-[#FFFFFF] dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-full', }} - imgSrc={activeChainInfo.chainSymbolImageUrl ?? defaultTokenLogo} - onImgClick={() => setShowChainSelector(true)} + imgSrc={headerChainImgSrc} + onImgClick={dontShowSelectChain ? undefined : () => setShowChainSelector(true)} title={title} - topColor={themeColor} /> } > diff --git a/apps/extension/src/components/custom-checkbox/CustomCheckbox.tsx b/apps/extension/src/components/custom-checkbox/CustomCheckbox.tsx index 23d3d290..35ff88ef 100644 --- a/apps/extension/src/components/custom-checkbox/CustomCheckbox.tsx +++ b/apps/extension/src/components/custom-checkbox/CustomCheckbox.tsx @@ -17,7 +17,7 @@ export function CustomCheckbox({ checked, onClick }: CustomCheckboxProps) {
) : ( -
+
)}
) diff --git a/apps/extension/src/components/empty-card/index.tsx b/apps/extension/src/components/empty-card/index.tsx index 7680e5fa..d1a9efb9 100644 --- a/apps/extension/src/components/empty-card/index.tsx +++ b/apps/extension/src/components/empty-card/index.tsx @@ -8,26 +8,32 @@ export type EmptyCardProps = { heading?: ReactNode subHeading?: ReactNode classname?: string + imgContainerClassname?: string isRounded?: boolean 'data-testing-id'?: string } export function EmptyCard(props: PropsWithoutRef) { const defaultTokenLogo = useDefaultTokenLogo() - const { src, heading, subHeading, isRounded = true, classname } = props + const { src, heading, subHeading, isRounded = true, classname, imgContainerClassname } = props return ( <>
-
+
{heading && ( diff --git a/apps/extension/src/components/error-boundary-fallback/index.tsx b/apps/extension/src/components/error-boundary-fallback/index.tsx index 023eb44e..b0b6ea08 100644 --- a/apps/extension/src/components/error-boundary-fallback/index.tsx +++ b/apps/extension/src/components/error-boundary-fallback/index.tsx @@ -21,14 +21,7 @@ const ErrorBoundaryFallback = () => { return (
- - } - > + }>
= ({ const [formatCurrency] = useformatCurrency() const [preferredCurrency] = useUserPreferredCurrency() - const { gasLimit, value, feeTokenData, activeChain } = useGasPriceContext() - const chainId = useChainId() + const { gasLimit, value, feeTokenData, activeChain, selectedNetwork } = useGasPriceContext() + const chainId = useChainId(activeChain, selectedNetwork) const chainGasAdjustment = useGasAdjustmentForChain(activeChain) const { data: feeTokenFiatValue } = useQuery( diff --git a/apps/extension/src/components/gas-price-options/fees-settings-sheet.tsx b/apps/extension/src/components/gas-price-options/fees-settings-sheet.tsx index 8fc767fb..481d06a3 100644 --- a/apps/extension/src/components/gas-price-options/fees-settings-sheet.tsx +++ b/apps/extension/src/components/gas-price-options/fees-settings-sheet.tsx @@ -1,8 +1,7 @@ -import { useActiveChain } from '@leapwallet/cosmos-wallet-hooks' import { Buttons } from '@leapwallet/leap-ui' import BottomModal from 'components/bottom-modal' +import { useChainPageInfo } from 'hooks' import React from 'react' -import { Colors } from 'theme/colors' import { isCompassWallet } from 'utils/isCompassWallet' import GasPriceOptions from './index' @@ -18,7 +17,7 @@ export const FeesSettingsSheet: React.FC = ({ showFeesSettingSheet, gasError, }) => { - const activeChain = useActiveChain() + const { topChainColor } = useChainPageInfo() return ( = ({

{gasError}

) : null} 0 +} + // eslint-disable-next-line @typescript-eslint/no-explicit-any export type GasPriceOptionsProps = React.PropsWithChildren & { className?: string @@ -132,11 +141,17 @@ const GasPriceOptions = ({ }: GasPriceOptionsProps) => { const [viewAdditionalOptions, setViewAdditionalOptions] = useState(false) const _activeChain = useActiveChain() - const activeChain = chain ?? _activeChain + const activeChain: SupportedChain = useMemo(() => chain ?? _activeChain, [_activeChain, chain]) const _selectedNetwork = useSelectedNetwork() - const selectedNetwork = network ?? _selectedNetwork + const selectedNetwork: SelectedNetworkType = useMemo( + () => network ?? _selectedNetwork, + [_selectedNetwork, network], + ) + const nonNativeTokenGasLimitMultiplier = useRef(1) + const hasToCalculateDynamicFee = useHasToCalculateDynamicFee(activeChain, selectedNetwork) + const getFeeMarketGasPricesSteps = useGetFeeMarketGasPricesSteps(activeChain, selectedNetwork) useEffect(() => { if (activeChain === 'osmosis') { @@ -149,7 +164,7 @@ const GasPriceOptions = ({ const { chains } = useChainsStore() const chainInfo = chains[activeChain as SupportedChain] const defaultGasEstimates = useDefaultGasEstimates() - const gasAdjustment = useGasAdjustmentForChain() + const gasAdjustment = useGasAdjustmentForChain(activeChain) const baseGasPriceStep = useGasPriceStepForChain(activeChain, selectedNetwork) const { lcdUrl } = useChainApis(activeChain, selectedNetwork) @@ -183,7 +198,7 @@ const GasPriceOptions = ({ gaslimit: fee.gasLimit ?? Long.fromString(fee.gas), feeAmount: fee.amount[0].amount, feeDenom: fee.amount[0].denom, - chain: chain, + chain: activeChain, }, onInvalidFees, ).catch((e) => { @@ -191,7 +206,7 @@ const GasPriceOptions = ({ }) } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [fee, chain]) + }, [fee, activeChain]) useEffect(() => { const fn = async () => { @@ -200,7 +215,7 @@ const GasPriceOptions = ({ if ( activeChain === 'osmosis' && feeTokenData && - ![feeTokenData.ibcDenom, feeTokenData.denom.coinMinimalDenom].includes('uosmo') + ![feeTokenData.ibcDenom, feeTokenData.denom?.coinMinimalDenom].includes('uosmo') ) { const gasPriceStep = await getGasPricesForOsmosisFee( lcdUrl ?? '', @@ -209,12 +224,26 @@ const GasPriceOptions = ({ ) setFeeTokenData(() => ({ ...feeTokenData, gasPriceStep })) } + + if (hasToCalculateDynamicFee && feeTokenData) { + let isIbcDenom = false + if (feeTokenData.ibcDenom?.toLowerCase().startsWith('ibc/')) { + isIbcDenom = true + } + + const gasPriceStep = await getFeeMarketGasPricesSteps( + feeTokenData.denom?.coinMinimalDenom ?? '', + feeTokenData.gasPriceStep, + isIbcDenom, + ) + setFeeTokenData(() => ({ ...feeTokenData, gasPriceStep: gasPriceStep })) + } } fn() // eslint-disable-next-line react-hooks/exhaustive-deps - }, [feeTokensList]) + }, [feeTokensList, hasToCalculateDynamicFee]) const getWallet = Wallet.useGetWallet() const { addressLinkState } = useSeiLinkedAddressState(getWallet) @@ -244,18 +273,8 @@ const GasPriceOptions = ({ } if (token.ibcDenom) { - if (chainInfo?.beta) { - return Object.values(chainInfo.nativeDenoms).find( - (nativeCoinDenom) => nativeCoinDenom.coinMinimalDenom === token.coinMinimalDenom, - ) - } return token.ibcDenom === feeTokenData?.ibcDenom } else { - if (chainInfo?.beta) { - return Object.values(chainInfo.nativeDenoms).find( - (nativeCoinDenom) => nativeCoinDenom.coinMinimalDenom === token.coinMinimalDenom, - ) - } return token.coinMinimalDenom === feeTokenData?.denom.coinMinimalDenom } }) @@ -426,9 +445,11 @@ const GasPriceOptions = ({ (feeToken) => !!allTokens?.find((token) => { if (token.ibcDenom) { - return token.ibcDenom === feeToken?.ibcDenom + return token.ibcDenom === feeToken?.ibcDenom && tokenHasBalance(token) } else { - return token.coinMinimalDenom === feeToken?.denom?.coinMinimalDenom + return ( + token.coinMinimalDenom === feeToken?.denom?.coinMinimalDenom && tokenHasBalance(token) + ) } }), ) @@ -441,6 +462,8 @@ const GasPriceOptions = ({ chainNativeFeeTokenData, setFeeTokenData, onGasPriceOptionChange, + hasToCalculateDynamicFee, + getFeeMarketGasPricesSteps, }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [ @@ -450,13 +473,48 @@ const GasPriceOptions = ({ feeTokensList, isFeeTokensListLoading, userHasSelectedToken, + hasToCalculateDynamicFee, ]) useEffect(() => { - if (isFeeTokensListLoading || !initialFeeDenom || userHasSelectedToken) { + if ( + isFeeTokensListLoading || + !initialFeeDenom || + userHasSelectedToken || + allTokensStatus === 'loading' + ) { return } - const foundFeeTokenData = feeTokensList.find((token) => token.ibcDenom === initialFeeDenom) + let foundFeeTokenData = feeTokensList.find((token) => { + if (token.ibcDenom) { + return token.ibcDenom === initialFeeDenom + } + return token.denom.coinMinimalDenom === initialFeeDenom + }) + if (!notUpdateInitialGasPrice) { + const dAppSuggestedFeeToken = allTokens?.find((token) => { + if (token.ibcDenom) { + return token.ibcDenom === initialFeeDenom + } + return token.coinMinimalDenom === initialFeeDenom + }) + if (!tokenHasBalance(dAppSuggestedFeeToken)) { + foundFeeTokenData = + feeTokensList?.find( + (feeToken) => + !!allTokens?.find((token) => { + if (token.ibcDenom) { + return token.ibcDenom === feeToken?.ibcDenom && tokenHasBalance(token) + } else { + return ( + token.coinMinimalDenom === feeToken?.denom?.coinMinimalDenom && + tokenHasBalance(token) + ) + } + }), + ) ?? foundFeeTokenData + } + } if (foundFeeTokenData) { updateFeeTokenData({ foundFeeTokenData, @@ -467,15 +525,20 @@ const GasPriceOptions = ({ lcdUrl, baseGasPriceStep, notUpdateGasPrice: notUpdateInitialGasPrice, + hasToCalculateDynamicFee, + getFeeMarketGasPricesSteps, }) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [ feeTokensList, initialFeeDenom, + allTokens, + allTokensStatus, isFeeTokensListLoading, userHasSelectedToken, notUpdateInitialGasPrice, + hasToCalculateDynamicFee, ]) if (!feeTokenData) return null @@ -543,9 +606,16 @@ GasPriceOptions.Selector = function Selector({ className?: string preSelected?: boolean }) { - const { value, onChange, gasLimit, feeTokenData, considerGasAdjustment, activeChain } = - useGasPriceContext() - const chainId = useChainId() + const { + value, + onChange, + gasLimit, + feeTokenData, + considerGasAdjustment, + activeChain, + selectedNetwork, + } = useGasPriceContext() + const chainId = useChainId(activeChain, selectedNetwork) const defaultGasEstimates = useDefaultGasEstimates() const [formatCurrency, preferredCurrency] = useFormatCurrency() @@ -666,7 +736,8 @@ GasPriceOptions.Selector = function Selector({ isSelected ? 'dark:brightness-200 brightness-50' : '' } ${formattedAmount.length > 4 ? 'text-[10px]' : 'text-xs'}`} > - {isVerySmallAmount ? '< 0.00001' : formattedAmount} {feeTokenData.denom.coinDenom} + {isVerySmallAmount ? '< 0.00001' : formattedAmount}{' '} + {sliceWord(feeTokenData?.denom?.coinDenom ?? '')} {amountInFiat ? ( @@ -851,22 +922,25 @@ GasPriceOptions.AdditionalSettings = function AdditionalSettings({ const onlySingleFeeToken = feeTokensList?.length === 1 - const handleTokenSelect = async (selectedMinimalDenom: string) => { - let selectedFeeTokenData = feeTokensList.find( - (feeToken) => feeToken.denom.coinMinimalDenom === selectedMinimalDenom, - ) + const handleTokenSelect = async (selectedMinimalDenom: string, selectedIbcDenom?: string) => { + let selectedFeeTokenData = feeTokensList.find((feeToken) => { + if (feeToken.ibcDenom) { + return feeToken.ibcDenom === selectedIbcDenom + } + return feeToken.denom.coinMinimalDenom === selectedMinimalDenom + }) if ( activeChain === 'osmosis' && selectedFeeTokenData && - ![selectedFeeTokenData.ibcDenom, selectedFeeTokenData.denom.coinMinimalDenom].includes( + ![selectedFeeTokenData.ibcDenom, selectedFeeTokenData.denom?.coinMinimalDenom].includes( 'uosmo', ) ) { try { const gasPriceStep = await getGasPricesForOsmosisFee( lcdUrl ?? '', - selectedFeeTokenData?.ibcDenom ?? '', + selectedFeeTokenData.ibcDenom ?? '', baseGasPriceStep, ) @@ -918,7 +992,7 @@ GasPriceOptions.AdditionalSettings = function AdditionalSettings({

@@ -942,10 +1016,10 @@ GasPriceOptions.AdditionalSettings = function AdditionalSettings({ className='text-sm text-gray-700 dark:text-gray-400 font-bold' title={`${new BigNumber(feeTokenAsset?.amount ?? '0').decimalPlaces( feeTokenData.denom.coinDecimals ?? 6, - )} ${feeTokenData.denom.coinDenom}`} + )} ${sliceWord(feeTokenData?.denom?.coinDenom ?? '')}`} > Balance: {formatBigNumber(new BigNumber(feeTokenAsset?.amount ?? '0'))}{' '} - {feeTokenData.denom.coinDenom} + {sliceWord(feeTokenData?.denom?.coinDenom ?? '')}

diff --git a/apps/extension/src/components/gas-price-options/select-token-modal.tsx b/apps/extension/src/components/gas-price-options/select-token-modal.tsx index e4130ff0..333e8d7a 100644 --- a/apps/extension/src/components/gas-price-options/select-token-modal.tsx +++ b/apps/extension/src/components/gas-price-options/select-token-modal.tsx @@ -11,9 +11,9 @@ type SelectTokenSheetProps = { assets: Token[] isOpen: boolean onClose: () => void - selectedToken: Token + selectedToken?: Token // eslint-disable-next-line no-unused-vars - onTokenSelect: (baseDenom: string) => void + onTokenSelect: (baseDenom: string, ibcDenom?: string) => void } export const SelectTokenModal: React.FC = React.memo( @@ -35,7 +35,7 @@ export const SelectTokenModal: React.FC = React.memo( const handleSelectToken = useCallback( (token: Token) => { if (token) { - onTokenSelect(token.coinMinimalDenom) + onTokenSelect(token.coinMinimalDenom, token.ibcDenom) onClose() } }, @@ -58,9 +58,12 @@ export const SelectTokenModal: React.FC = React.memo( const isFirst = index === 0 const isLast = index === choiceOfTokens.length - 1 - const isSelected = selectedToken.ibcDenom - ? selectedToken.ibcDenom === asset.ibcDenom - : selectedToken.coinMinimalDenom === asset.coinMinimalDenom + let isSelected = false + if (selectedToken) { + isSelected = selectedToken?.ibcDenom + ? selectedToken?.ibcDenom === asset.ibcDenom + : selectedToken?.coinMinimalDenom === asset.coinMinimalDenom + } return ( diff --git a/apps/extension/src/components/gas-price-options/utils.ts b/apps/extension/src/components/gas-price-options/utils.ts index d43b4ca0..fd0693a1 100644 --- a/apps/extension/src/components/gas-price-options/utils.ts +++ b/apps/extension/src/components/gas-price-options/utils.ts @@ -19,6 +19,12 @@ type UpdateFeeTokenDataParams = { setFeeTokenData: React.Dispatch> onGasPriceOptionChange: (value: GasPriceOptionValue, feeDenom: FeeTokenData) => void notUpdateGasPrice?: boolean + hasToCalculateDynamicFee: boolean + getFeeMarketGasPricesSteps: ( + feeDenom: string, + forceBaseGasPriceStep?: GasPriceStep, + isIbcDenom?: boolean, + ) => Promise } /** @@ -41,6 +47,8 @@ export async function updateFeeTokenData({ setFeeTokenData, onGasPriceOptionChange, notUpdateGasPrice = false, + hasToCalculateDynamicFee, + getFeeMarketGasPricesSteps, }: UpdateFeeTokenDataParams) { let feeTokenDataToSet = foundFeeTokenData if (foundFeeTokenData) { @@ -67,6 +75,19 @@ export async function updateFeeTokenData({ } captureException(error) } + } else if (hasToCalculateDynamicFee && foundFeeTokenData) { + let isIbcDenom = false + if (foundFeeTokenData.ibcDenom?.toLowerCase().startsWith('ibc/')) { + isIbcDenom = true + } + + const gasPriceStep = await getFeeMarketGasPricesSteps( + foundFeeTokenData.denom?.coinMinimalDenom ?? '', + foundFeeTokenData.gasPriceStep, + isIbcDenom, + ) + + feeTokenDataToSet = { ...foundFeeTokenData, gasPriceStep } } else { feeTokenDataToSet = foundFeeTokenData } diff --git a/apps/extension/src/components/header/NewChainSupportTooltip.tsx b/apps/extension/src/components/header/NewChainSupportTooltip.tsx new file mode 100644 index 00000000..d41cd70d --- /dev/null +++ b/apps/extension/src/components/header/NewChainSupportTooltip.tsx @@ -0,0 +1,76 @@ +import { useTheme } from '@leapwallet/leap-ui' +import { NewChainTooltipData } from 'hooks/useNewChainTooltip' +import React from 'react' + +type NewChainSupportTooltipProps = { + handleToolTipClose: () => void + handleCTAClick: () => void + toolTipData: NewChainTooltipData +} + +const NewChainSupportTooltip = ({ + toolTipData, + handleCTAClick, + handleToolTipClose, +}: NewChainSupportTooltipProps) => { + const { header, description, imgUrl, ctaText } = toolTipData + + const { theme } = useTheme() + + return ( + <> +
{ + e.stopPropagation() + }} + className='cursor-default z-[2] p-3 rounded-xl absolute bg-white-100 w-[272px] border border-gray-200 dark:border-gray-850 dark:bg-gray-950 top-[56px] right-0 flex flex-col justify-start items-start gap-3' + > +
+ + + + +
+ + {imgUrl && tooltip-img} + +
+
+ {header} +
+
+ {description} +
+
+ +
+ + +
+
+ + ) +} + +export default NewChainSupportTooltip diff --git a/apps/extension/src/components/header/PageHeader.tsx b/apps/extension/src/components/header/PageHeader.tsx new file mode 100644 index 00000000..8f7a8b11 --- /dev/null +++ b/apps/extension/src/components/header/PageHeader.tsx @@ -0,0 +1,85 @@ +import { LineDivider } from '@leapwallet/leap-ui' +import classNames from 'classnames' +import { ActionButton } from 'components/button' +import useNewChainTooltip from 'hooks/useNewChainTooltip' +import { Images } from 'images' +import React from 'react' +import { PageHeaderProps } from 'types/components' + +import NewChainSupportTooltip from './NewChainSupportTooltip' + +const PageHeader = React.memo( + ({ title, action, imgSrc, onImgClick, dontShowFilledArrowIcon = false }: PageHeaderProps) => { + const { showToolTip: _showToolTip, toolTipData, handleToolTipClose } = useNewChainTooltip() + + const showToolTip = _showToolTip && !!toolTipData && !!onImgClick + + return ( + <> + {showToolTip && ( +
+ )} +
+
+
{title}
+
+ + {action ? ( +
+ +
+ ) : null} + + {imgSrc ? ( +
+ {typeof imgSrc === 'string' ? ( + + ) : ( + imgSrc + )} + + {onImgClick !== undefined && !dontShowFilledArrowIcon && ( + + )} + + {showToolTip && ( + { + onImgClick() + handleToolTipClose() + }} + handleToolTipClose={handleToolTipClose} + /> + )} +
+ ) : null} + +
+ +
+
+ + ) + }, +) + +PageHeader.displayName = 'PageHeader' +export { PageHeader } diff --git a/apps/extension/src/components/header/index.ts b/apps/extension/src/components/header/index.ts new file mode 100644 index 00000000..f76b3366 --- /dev/null +++ b/apps/extension/src/components/header/index.ts @@ -0,0 +1,2 @@ +export * from './Header' +export * from './PageHeader' diff --git a/apps/extension/src/components/ledger-confirmation/LedgerConfirmationPopup.tsx b/apps/extension/src/components/ledger-confirmation/LedgerConfirmationPopup.tsx index b90d3462..6b93a3ee 100644 --- a/apps/extension/src/components/ledger-confirmation/LedgerConfirmationPopup.tsx +++ b/apps/extension/src/components/ledger-confirmation/LedgerConfirmationPopup.tsx @@ -1,7 +1,6 @@ -import { Header } from '@leapwallet/leap-ui' +import BottomModal from 'components/bottom-modal' import React from 'react' -import BottomSheet from '../bottom-sheet/BottomSheet' import RadarAnimation from '../loader/Radar' import Text from '../text' @@ -16,20 +15,19 @@ export default function LedgerConfirmationPopup({ showLedgerPopup, onCloseLedger } return ( -
} - closeOnClickBackDrop={false} + title={'Confirm on Ledger'} >
-
+
Approve transaction on your hardware wallet
- + ) } diff --git a/apps/extension/src/components/no-stake/NoStake.tsx b/apps/extension/src/components/no-stake/NoStake.tsx index b358a40a..a193a11a 100644 --- a/apps/extension/src/components/no-stake/NoStake.tsx +++ b/apps/extension/src/components/no-stake/NoStake.tsx @@ -1,25 +1,19 @@ -import { useActiveChain, useGetChains } from '@leapwallet/cosmos-wallet-hooks' import { Header, HeaderActionType } from '@leapwallet/leap-ui' import BottomNav, { BottomNavLabel } from 'components/bottom-nav/BottomNav' import PopupLayout from 'components/layout/popup-layout' import Text from 'components/text' -import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' +import { useChainPageInfo } from 'hooks' +import { useDontShowSelectChain } from 'hooks/useDontShowSelectChain' import { Images } from 'images' import SelectChain from 'pages/home/SelectChain' import SideNav from 'pages/home/side-nav' import React, { useState } from 'react' -import { Colors } from 'theme/colors' export function NoStake() { const [showSideNav, setShowSideNav] = useState(false) const [showChainSelector, setShowChainSelector] = useState(false) - - const activeChain = useActiveChain() - const chains = useGetChains() - const defaultTokenLogo = useDefaultTokenLogo() - - const activeChainInfo = chains[activeChain] - const themeColor = Colors.getChainColor(activeChain, activeChainInfo) + const { headerChainImgSrc } = useChainPageInfo() + const dontShowSelectChain = useDontShowSelectChain() return (
@@ -37,10 +31,9 @@ export function NoStake() { className: 'w-[48px] h-[40px] px-3 bg-[#FFFFFF] dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-full', }} - imgSrc={activeChainInfo.chainSymbolImageUrl ?? defaultTokenLogo} - onImgClick={() => setShowChainSelector(true)} + imgSrc={headerChainImgSrc} + onImgClick={dontShowSelectChain ? undefined : () => setShowChainSelector(true)} title={'Staking'} - topColor={themeColor} /> } > diff --git a/apps/extension/src/components/proposal-description/ProposalDescription.tsx b/apps/extension/src/components/proposal-description/ProposalDescription.tsx index 69e5b5cd..49e4e3fc 100644 --- a/apps/extension/src/components/proposal-description/ProposalDescription.tsx +++ b/apps/extension/src/components/proposal-description/ProposalDescription.tsx @@ -11,6 +11,7 @@ type ProposalDescriptionProps = { description: string btnColor: string className?: string + forceChain?: string } export function ProposalDescription({ @@ -18,6 +19,7 @@ export function ProposalDescription({ description, btnColor, className, + forceChain, }: ProposalDescriptionProps) { const [showAll, setShowAll] = useState(false) const [url, setUrl] = useState('') @@ -27,7 +29,8 @@ export function ProposalDescription({ const [showRedirectConfirmation, setShowRedirectConfirmation] = useState(false) const { data: allWhitelistedUrls } = useWhitelistedUrls() - const activeChain = useActiveChain() + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) const whiteListedUrls = useMemo(() => { if (!allWhitelistedUrls) return [] @@ -70,6 +73,7 @@ export function ProposalDescription({ a: ({ ...props }) => { return ( + {/* eslint-disable-next-line react/prop-types */} {props.children} ) diff --git a/apps/extension/src/components/radio-group/index.tsx b/apps/extension/src/components/radio-group/index.tsx index 132910b9..57e76622 100644 --- a/apps/extension/src/components/radio-group/index.tsx +++ b/apps/extension/src/components/radio-group/index.tsx @@ -17,13 +17,6 @@ const RadioGroup: React.FC = ({ className, themeColor, }) => { - const handleOptionChange: React.ChangeEventHandler = useCallback( - (event) => { - onChange(event.target.value) - }, - [onChange], - ) - return (
{options.map((option) => { @@ -40,7 +33,7 @@ const RadioGroup: React.FC = ({ type='radio' value={option.value} checked={isSelected} - onChange={handleOptionChange} + readOnly className='hidden' />
- -
- } > diff --git a/apps/extension/src/components/search-input/SearchInput.tsx b/apps/extension/src/components/search-input/SearchInput.tsx index b4aa2a41..ee53a06d 100644 --- a/apps/extension/src/components/search-input/SearchInput.tsx +++ b/apps/extension/src/components/search-input/SearchInput.tsx @@ -26,14 +26,16 @@ export function SearchInput({ useEffect(() => { if (inputRef.current) { - inputRef.current?.focus() + setTimeout(() => { + inputRef.current?.focus() + }, 100) } }, []) return (
{value.length === 0 ? ( - + ) : ( )} diff --git a/apps/extension/src/components/search-modal/SearchModal.tsx b/apps/extension/src/components/search-modal/SearchModal.tsx index 763a1c7a..5c005634 100644 --- a/apps/extension/src/components/search-modal/SearchModal.tsx +++ b/apps/extension/src/components/search-modal/SearchModal.tsx @@ -9,6 +9,7 @@ import { } from '@leapwallet/cosmos-wallet-hooks' import { WALLETTYPE } from '@leapwallet/leap-keychain' import classNames from 'classnames' +import { AlertStrip } from 'components/alert-strip' import { LoaderAnimation } from 'components/loader/Loader' import { useActiveChain } from 'hooks/settings/useActiveChain' import { Images } from 'images' @@ -23,7 +24,6 @@ import { searchModalEnteredOptionState, searchModalState, } from '../../atoms/search-modal' -import AlertStrip from '../alert-strip/AlertStrip' import { QuickSearchOptions } from './QuickSearchOptions' import { useHardCodedActions } from './useHardCodedActions' @@ -152,7 +152,7 @@ export function SearchModal() { if (!activeWallet) return if ( activeWallet.walletType === WALLETTYPE.LEDGER && - isLedgerEnabled(chain.key, chain.bip44.coinType) + isLedgerEnabled(chain?.key, chain?.bip44?.coinType) ) { break } diff --git a/apps/extension/src/components/search-modal/useHardCodedActions.ts b/apps/extension/src/components/search-modal/useHardCodedActions.ts index 7244d4bb..56ff90a8 100644 --- a/apps/extension/src/components/search-modal/useHardCodedActions.ts +++ b/apps/extension/src/components/search-modal/useHardCodedActions.ts @@ -4,19 +4,18 @@ import { useChainInfo, useFeatureFlags, } from '@leapwallet/cosmos-wallet-hooks' +import { captureException } from '@sentry/react' import { showSideNavFromSearchModalState } from 'atoms/search-modal' +import { ButtonName, ButtonType, EventName, PageName } from 'config/analytics' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' import { useAuth } from 'context/auth-context' +import { useActiveChain } from 'hooks/settings/useActiveChain' import { useHideAssets, useSetHideAssets } from 'hooks/settings/useHideAssets' -import { useGetKadoAssets, useGetKadoChains } from 'hooks/useGetKadoDetails' -import { - BuyUrlFuncParams, - getBuyUrl, - OriginWalletSourceEnum, - ServiceProviderEnum, -} from 'pages/home/utils' +import mixpanel from 'mixpanel-browser' import { useState } from 'react' import { useNavigate } from 'react-router' import { useSetRecoilState } from 'recoil' +import { AggregatedSupportedChain } from 'types/utility' import { UserClipboard } from 'utils/clipboard' import Browser from 'webextension-polyfill' @@ -26,6 +25,7 @@ export function useHardCodedActions() { const { data: featureFlags } = useFeatureFlags() const address = useAddress() + const activeChain = useActiveChain() as AggregatedSupportedChain const activeChainInfo = useChainInfo() const { hideBalances: balancesHidden } = useHideAssets() const setBalancesVisibility = useSetHideAssets() @@ -34,27 +34,8 @@ export function useHardCodedActions() { const [alertMessage, setAlertMessage] = useState('') const setShowSideNav = useSetRecoilState(showSideNavFromSearchModalState) - const walletAddress = useAddress() - const activeWalletCosmosAddress = useAddress('cosmos') - const { data: kadoSupportedChainId = [] } = useGetKadoChains() - const { data: kadoSupportedAssets = [] } = useGetKadoAssets() - const isKadoSupported = - kadoSupportedChainId.includes(activeChainInfo?.chainId) && - kadoSupportedAssets.includes(activeChainInfo?.denom) - - const handleBuyClick = (type: 'leap' | 'compass') => { - const buyUrlArgs: BuyUrlFuncParams = { - serviceProvider: ServiceProviderEnum.KADO, - originWalletSource: - type === 'leap' ? OriginWalletSourceEnum.LEAP : OriginWalletSourceEnum.COMPASS, - walletAddress: isKadoSupported ? walletAddress : activeWalletCosmosAddress, - providerApiKey: process.env.KADO_API_KEY as string, - activeChain: isKadoSupported ? activeChainInfo.chainName.toUpperCase() : 'COSMOS HUB', - denom: isKadoSupported ? activeChainInfo.denom : 'ATOM', - } - - const buyUrl = getBuyUrl(buyUrlArgs) - window.open(buyUrl, '_blank') + const handleBuyClick = () => { + navigate(`/buy?pageSource=${PageName.Home}`) } function handleSwapClick(_redirectUrl?: string, navigateUrl?: string) { @@ -85,6 +66,29 @@ export function useHardCodedActions() { } } + function handleBridgeClick() { + const baseUrl = 'https://swapfast.app/bridge' + let redirectURL = `${baseUrl}?destinationChainId=${activeChainInfo?.chainId}` + + if (activeChainInfo?.key === 'mainCoreum') { + redirectURL = 'https://sologenic.org/coreum-bridge' + } else if (activeChain === AGGREGATED_CHAIN_KEY) { + redirectURL = baseUrl + } + window.open(redirectURL, '_blank') + + try { + mixpanel.track(EventName.ButtonClick, { + buttonType: ButtonType.HOME, + buttonName: ButtonName.BRIDGE, + redirectURL: redirectURL, + time: Date.now() / 1000, + }) + } catch (e) { + captureException(e) + } + } + function onSendClick(_redirectUrl?: string) { if (featureFlags?.ibc?.extension === 'redirect') { const redirectUrl = @@ -140,5 +144,6 @@ export function useHardCodedActions() { handleNftsClick, handleVoteClick, onSendClick, + handleBridgeClick, } } diff --git a/apps/extension/src/components/select-wallet-sheet/index.tsx b/apps/extension/src/components/select-wallet-sheet/index.tsx index 8cf55774..7ab2ff1d 100644 --- a/apps/extension/src/components/select-wallet-sheet/index.tsx +++ b/apps/extension/src/components/select-wallet-sheet/index.tsx @@ -116,9 +116,10 @@ export default function SelectWalletSheet({
{ + const walletIds = currentWalletInfo?.wallets.map((wallet) => wallet.id) await addToConnections( currentWalletInfo?.chainIds as [string], - currentWalletInfo?.wallets as Key[], + walletIds ?? [], currentWalletInfo?.origin as string, ) setActiveWallet(wallet) diff --git a/apps/extension/src/components/token-card/TokenCard.tsx b/apps/extension/src/components/token-card/TokenCard.tsx index 7a46ab2e..eb781ed3 100644 --- a/apps/extension/src/components/token-card/TokenCard.tsx +++ b/apps/extension/src/components/token-card/TokenCard.tsx @@ -3,16 +3,21 @@ import { formatTokenAmount, IbcChainInfo, sliceWord, + useActiveChain, + useGetChains, useUserPreferredCurrency, } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { GenericCard } from '@leapwallet/leap-ui' import BigNumber from 'bignumber.js' import Badge from 'components/badge/Badge' import IBCTokenBadge from 'components/badge/IbcTokenBadge' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' import { useFormatCurrency } from 'hooks/settings/useCurrency' import { useHideAssets } from 'hooks/settings/useHideAssets' import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' -import React from 'react' +import React, { useMemo } from 'react' +import { AggregatedSupportedChain } from 'types/utility' import { imgOnError } from 'utils/imgOnError' type TokenCardProps = { @@ -32,6 +37,7 @@ type TokenCardProps = { readonly hasToShowEvmTag?: boolean readonly isEvm?: boolean readonly hideAmount?: boolean + readonly tokenBalanceOnChain?: SupportedChain } export function TokenCard({ @@ -51,7 +57,10 @@ export function TokenCard({ hasToShowEvmTag, isEvm, hideAmount = false, + tokenBalanceOnChain, }: TokenCardProps) { + const activeChain = useActiveChain() as AggregatedSupportedChain + const chains = useGetChains() const [formatCurrency] = useFormatCurrency() const { formatHideBalance } = useHideAssets() @@ -59,27 +68,47 @@ export function TokenCard({ const [preferredCurrency] = useUserPreferredCurrency() const formattedFiatValue = usdValue ? formatCurrency(new BigNumber(usdValue)) : '-' + const ibcInfo = useMemo(() => { + if (!ibcChainInfo) return '' + + return `${ibcChainInfo.pretty_name} / ${sliceWord(ibcChainInfo?.channelId ?? '', 7, 5)}` + }, [ibcChainInfo]) + + const Title = useMemo(() => { + let _Title = ( +

+ {sliceWord(title, 7, 4)} +

+ ) + + if (activeChain === AGGREGATED_CHAIN_KEY && ibcChainInfo) { + _Title = ( +
+ {title} + {activeChain === AGGREGATED_CHAIN_KEY && ibcChainInfo ? ( + + ) : null} +
+ ) + } + + return _Title + }, [title, activeChain, ibcChainInfo, ibcInfo]) + return ( - {sliceWord(title, 7, 4)} - - } + title={Title} subtitle={
- {ibcChainInfo && !hasToShowIbcTag ? ( - - ) : null} - - {ibcChainInfo && hasToShowIbcTag ? : null} - {isEvm && hasToShowEvmTag ? : null} + {activeChain === AGGREGATED_CHAIN_KEY && tokenBalanceOnChain ? ( +

{chains[tokenBalanceOnChain]?.chainName ?? 'Unknown Chain'}

+ ) : ( + <> + {ibcChainInfo && !hasToShowIbcTag ? : null} + {ibcChainInfo && hasToShowIbcTag ? : null} + {isEvm && hasToShowEvmTag ? : null} + + )}
} title2={ diff --git a/apps/extension/src/config/analytics.ts b/apps/extension/src/config/analytics.ts index abece5f9..e1c88d00 100644 --- a/apps/extension/src/config/analytics.ts +++ b/apps/extension/src/config/analytics.ts @@ -13,6 +13,8 @@ export enum EventName { OnboardingCompleted = 'Onboarding Completed', OnboardingClicked = 'Onboarding CTA Clicked', SwapTransactionStatus = 'Transaction Status', + ChainFavorited = 'Chain Favorited', + ChainUnfavorited = 'Chain Unfavorited', } export enum ButtonType { @@ -57,4 +59,7 @@ export enum PageName { NFT = 'NFT Collections', SyncWithMobileApp = 'Sync with Mobile App', Airdrops = 'Airdrops', + Buy = 'Buy', + OnRampQuotePreview = 'On-ramp quote preview', + AssetDetails = 'Asset Details', } diff --git a/apps/extension/src/config/config.ts b/apps/extension/src/config/config.ts index d3e70bc9..6fbfc2a2 100644 --- a/apps/extension/src/config/config.ts +++ b/apps/extension/src/config/config.ts @@ -6,18 +6,6 @@ export const DEFAULT_GAS_TRANSFER = 80000 export const DEFAULT_GAS_STAKE = 150000 export const DEFAULT_SWAP_FEE = 0.004 export const ON_RAMP_SUPPORT_CHAINS = ['osmosis', 'juno', 'kujira'] -export const KADO_BUY_SUPPORT_CHAINS: SupportedChain[] = [ - 'cosmos', - 'juno', - 'osmosis', - 'secret', - 'injective', - 'stargaze', - 'comdex', - 'terra', - 'migaloo', - 'agoric', -] export const LEDGER_NAME_EDITED_SUFFIX = '%LEDGER_NAME_EDITED%' export const LEDGER_NAME_EDITED_SUFFIX_REGEX = new RegExp(LEDGER_NAME_EDITED_SUFFIX) @@ -35,6 +23,7 @@ export const LEDGER_ENABLED_EVM_CHAINS = [ ChainInfos.injective.key, ChainInfos.evmos.key, ChainInfos.dymension.key, + ChainInfos.humans.key, 'Nim' as SupportedChain, ] @@ -45,6 +34,7 @@ export const LEDGER_ENABLED_EVM_CHAIN_IDS = [ ChainInfos.injective.testnetChainId, ChainInfos.evmos.testnetChainId, ChainInfos.dymension.testnetChainId, + ChainInfos.humans.chainId, 'nim_1122-1', ] diff --git a/apps/extension/src/config/constants.ts b/apps/extension/src/config/constants.ts index 7f06ca7b..c2cebb39 100644 --- a/apps/extension/src/config/constants.ts +++ b/apps/extension/src/config/constants.ts @@ -32,5 +32,8 @@ export const ETHERMINT_CHAINS = [ ] export const FIXED_FEE_CHAINS = ['mayachain', 'thorchain'] +export const SHOW_ETH_ADDRESS_CHAINS = ['dymension', 'seiDevnet', 'seiTestnet2', 'humans'] -export const SHOW_ETH_ADDRESS_CHAINS = ['dymension', 'seiDevnet', 'seiTestnet2'] +export const AGGREGATED_CHAIN_KEY = 'aggregated' +export const SEI_EVM_LEDGER_ERROR_MESSAGE = + 'Transactions for EVM addresses are not supported on Ledger yet' diff --git a/apps/extension/src/config/storage-keys.ts b/apps/extension/src/config/storage-keys.ts index ef024f68..892e3041 100644 --- a/apps/extension/src/config/storage-keys.ts +++ b/apps/extension/src/config/storage-keys.ts @@ -28,8 +28,13 @@ export const DISABLE_BANNER_ADS = 'disabled-banner-ads' export const CUSTOM_ENDPOINTS = 'custom-endpoints' export const V80_KEYSTORE_MIGRATION_COMPLETE = 'v80-keystore-migration-complete' export const V118_KEYSTORE_MIGRATION_COMPLETE = 'v118-keystore-migration-complete' +export const V125_BETA_NFT_COLLECTIONS_MIGRATION_COMPLETE = + 'v125-beta-nft-collections-migration-complete' export const PENDING_SWAP_TXS = 'pending-swap-txs' export const CURRENT_SWAP_TXS = 'current-swap-txs' export const NETWORK_MAP = 'networkMap' +export const STARRED_CHAINS = 'starred-chains' +export const NEW_CHAIN_TOOLTIP_STORAGE_KEY = 'leap-new-chain-tooltip-user-preference' export const SHOW_LINK_ADDRESS_NUDGE = 'show-link-address-nudge' +export const ACTIVE_WALLET_ID = 'active-wallet-id' diff --git a/apps/extension/src/context/auth-context.tsx b/apps/extension/src/context/auth-context.tsx index fcbf439a..a2f5bffe 100644 --- a/apps/extension/src/context/auth-context.tsx +++ b/apps/extension/src/context/auth-context.tsx @@ -1,6 +1,12 @@ /* eslint-disable no-unused-vars */ -import { useChainInfo } from '@leapwallet/cosmos-wallet-hooks' -import { ChainInfos } from '@leapwallet/cosmos-wallet-sdk' +import { + BETA_NFTS_COLLECTIONS, + ENABLED_NFTS_COLLECTIONS, + StoredBetaNftCollection, + useActiveChain, + useGetChains, +} from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { ENCRYPTED_ACTIVE_WALLET } from '@leapwallet/leap-keychain' import { KeyChain } from '@leapwallet/leap-keychain' import * as Sentry from '@sentry/react' @@ -14,6 +20,7 @@ import { KEYSTORE, V80_KEYSTORE_MIGRATION_COMPLETE, V118_KEYSTORE_MIGRATION_COMPLETE, + V125_BETA_NFT_COLLECTIONS_MIGRATION_COMPLETE, } from 'config/storage-keys' import { migrateEncryptedKeyStore, migrateKeyStore } from 'extension-scripts/migrations/v80' import { migratePicassoAddress } from 'extension-scripts/migrations/v118-migrate-picasso-address' @@ -25,6 +32,7 @@ import { useRef } from 'react' import KeyboardEventHandler from 'react-keyboard-event-handler' import { Navigate, useLocation } from 'react-router-dom' import { useRecoilState, useSetRecoilState } from 'recoil' +import { AggregatedSupportedChain } from 'types/utility' import { hasMnemonicWallet } from 'utils/hasMnemonicWallet' import { isCompassWallet } from 'utils/isCompassWallet' import browser, { extension } from 'webextension-polyfill' @@ -54,6 +62,7 @@ export function AuthProvider({ children }: { children: ReactNode }): ReactElemen const [noAccount, setNoAccount] = useState(false) const setPassword = useSetPassword() const testPassword = SeedPhrase.useTestPassword() + const chains = useGetChains() useEffect(() => { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -95,6 +104,7 @@ export function AuthProvider({ children }: { children: ReactNode }): ReactElemen KEYSTORE, V80_KEYSTORE_MIGRATION_COMPLETE, V118_KEYSTORE_MIGRATION_COMPLETE, + V125_BETA_NFT_COLLECTIONS_MIGRATION_COMPLETE, ENCRYPTED_KEY_STORE, ENCRYPTED_ACTIVE_WALLET, ]) @@ -129,17 +139,74 @@ export function AuthProvider({ children }: { children: ReactNode }): ReactElemen }) } } + + if (!storage[V125_BETA_NFT_COLLECTIONS_MIGRATION_COMPLETE]) { + const storedBetaNftCollections = await browser.storage.local.get([ + BETA_NFTS_COLLECTIONS, + ]) + + if (storedBetaNftCollections[BETA_NFTS_COLLECTIONS]) { + const betaNftCollections = JSON.parse( + storedBetaNftCollections[BETA_NFTS_COLLECTIONS] ?? '{}', + ) + const formattedBetaNftCollections: { + [chain: string]: { [network: string]: StoredBetaNftCollection[] } + } = {} + + for (const chain in betaNftCollections) { + const _chain = chain as SupportedChain + const isTestnetOnly = chains?.[_chain]?.chainId === chains?.[_chain]?.testnetChainId + + if (chains?.[_chain] && isTestnetOnly) { + formattedBetaNftCollections[chain] = { + testnet: betaNftCollections[chain].map((collection: string) => { + return { address: collection, name: '', image: '' } + }), + } + } else { + const evenHasTestnet = chains?.[_chain]?.testnetChainId + + if (evenHasTestnet) { + formattedBetaNftCollections[chain] = { + testnet: betaNftCollections[chain].map((collection: string) => { + return { address: collection, name: '', image: '' } + }), + } + } + + formattedBetaNftCollections[chain] = { + ...(formattedBetaNftCollections[chain] ?? {}), + mainnet: betaNftCollections[chain].map((collection: string) => { + return { address: collection, name: '', image: '' } + }), + } + } + } + + await browser.storage.local.set({ + [BETA_NFTS_COLLECTIONS]: JSON.stringify(formattedBetaNftCollections), + [ENABLED_NFTS_COLLECTIONS]: JSON.stringify(betaNftCollections), + [V125_BETA_NFT_COLLECTIONS_MIGRATION_COMPLETE]: true, + }) + } else { + await browser.storage.local.set({ + [V125_BETA_NFT_COLLECTIONS_MIGRATION_COMPLETE]: true, + }) + } + } + setLocked(false) setNoAccount(false) setLoading(false) setPassword(password) callback && callback() } catch (e) { + setLoading(false) throw new Error('Password authentication failed') } } }, - [setPassword, testPassword], + [setPassword, testPassword, chains], ) const signout = useCallback( @@ -166,7 +233,11 @@ export function AuthProvider({ children }: { children: ReactNode }): ReactElemen if (sender.id !== browser.runtime.id) return if (message.type === 'authentication') { if (message.data.status === 'success') { - signin(message.data.password) + try { + await signin(message.data.password) + } catch (_) { + setLoading(false) + } } else { setLoading(() => false) } @@ -231,7 +302,7 @@ export function RequireAuth({ ) const setSearchModalEnteredOption = useSetRecoilState(searchModalEnteredOptionState) const [showSideNav, setShowSideNav] = useRecoilState(showSideNavFromSearchModalState) - const chain = useChainInfo() + const activeChain = useActiveChain() as AggregatedSupportedChain if (auth?.locked) { return @@ -240,7 +311,9 @@ export function RequireAuth({ const views = extension.getViews({ type: 'popup' }) const Children = - QUICK_SEARCH_DISABLED_PAGES.includes(location.pathname) || isCompassWallet() ? ( + QUICK_SEARCH_DISABLED_PAGES.includes(location.pathname) || + isCompassWallet() || + activeChain === 'aggregated' ? ( children ) : ( <> diff --git a/apps/extension/src/extension-scripts/background.ts b/apps/extension/src/extension-scripts/background.ts index 23e8f085..5c3a88a8 100644 --- a/apps/extension/src/extension-scripts/background.ts +++ b/apps/extension/src/extension-scripts/background.ts @@ -11,39 +11,35 @@ import './fetch-preserver' import { SUPPORTED_METHODS } from '@leapwallet/cosmos-wallet-provider/dist/provider/messaging/requester' import { ChainInfo, - ChainInfos, encodedUtf8HexToText, formatEtherValue, getRestUrl, getSeiEvmAddressToShow, parseStandardTokenTransactionData, fetchERC20Balances, - SupportedChain, SeiEvmTx, } from '@leapwallet/cosmos-wallet-sdk' -import { decrypt, initCrypto, initStorage, WALLETTYPE } from '@leapwallet/leap-keychain' +import { decrypt, initCrypto, initStorage } from '@leapwallet/leap-keychain' import { ACTIVE_CHAIN, ACTIVE_WALLET, AUTO_LOCK_TIME, BETA_CHAINS, BG_RESPONSE, - CONNECTIONS, ENCRYPTED_ACTIVE_WALLET, KEYSTORE, REDIRECT_REQUEST, SELECTED_NETWORK, V118_KEYSTORE_MIGRATION_COMPLETE, + V125_BETA_NFT_COLLECTIONS_MIGRATION_COMPLETE, V80_KEYSTORE_MIGRATION_COMPLETE, VIEWING_KEYS, } from 'config/storage-keys' import PortStream from 'extension-port-stream' -import { toUint8Array } from 'utils/uint8Utils' import browser, { Storage } from 'webextension-polyfill' import customIcon from '../images/logos/generic-light.svg' -import { Bech32Address } from '../utils/bech32' import { getStorageAdapter } from '../utils/storageAdapter' import { NEW_CHAIN_REQUEST, SUGGEST_TOKEN } from './../config/storage-keys' @@ -62,10 +58,7 @@ import { LineType, } from '@leapwallet/cosmos-wallet-provider/dist/provider/types' import { EncryptionUtilsImpl } from '@leapwallet/cosmos-wallet-sdk/dist/browser/secret/encryptionutil' -import { LEDGER_ENABLED_EVM_CHAIN_IDS } from 'config/config' import { MessageTypes } from 'config/message-types' -import { getUpdatedKeyStore } from 'hooks/wallet/getUpdatedKeyStore' -import { formatWalletName } from 'utils/formatWalletName' import { handleSendTx } from './handle-sendtx' import { storageMigrationV10 } from './migrations/v10' import { storageMigrationV19 } from './migrations/v19' @@ -77,11 +70,10 @@ import { PasswordManager } from './password-manager' import { initiatePendingSwapTxTracking, listenPendingSwapTx } from './pending-swap-tx' import { + awaitApproveChainResponse, awaitSigningResponse, awaitUIResponse, - checkChainConnections, checkConnection, - decodeChainIdToChain, disconnect, getSeed, getSupportedChains, @@ -93,6 +85,7 @@ import { validateNewChainInfo, } from './utils' import { addTxToPendingTxList } from 'utils/pendingSwapsTxsStore' +import { handleGetKey } from './request-handlers/getKey.handler' global.window = self @@ -107,7 +100,7 @@ type Data = EthereumRequestMessage & { const windowIdForPayloadId: { [x: number | string]: { type: string; payloadId: number } } = {} -let enableAccessRequests: Record = {} +const enableAccessRequests: Map = new Map() const passwordManager = PasswordManager.create() initiatePendingSwapTxTracking() @@ -120,7 +113,7 @@ const connectRemote = (remotePort: any) => { const portStream = new PortStream(remotePort) - const sendResponse = (name: any, payload: any, id: number) => { + const sendResponse = (name: string, payload: any, id: number) => { portStream.write({ name, payload, id }) } @@ -131,7 +124,7 @@ const connectRemote = (remotePort: any) => { case 'chain-enabled': if (message.payload?.ecosystem === LINE_TYPE.ETHEREUM) { const store = await browser.storage.local.get([ACTIVE_WALLET, ACTIVE_CHAIN]) - const activeChain = store[ACTIVE_CHAIN] + const activeChain = store[ACTIVE_CHAIN] ?? 'seiTestnet2' const seiEvmAddress = getSeiEvmAddressToShow(store[ACTIVE_WALLET].pubKeys?.[activeChain]) if (seiEvmAddress.startsWith('0x')) { @@ -167,11 +160,11 @@ const connectRemote = (remotePort: any) => { ) } } else { - sendResponse( - `on${SUPPORTED_METHODS.ENABLE_ACCESS}`, - { success: 'Chain enabled' }, - message.payload.payloadId, - ) + // sendResponse( + // `on${SUPPORTED_METHODS.ENABLE_ACCESS}`, + // { success: 'Chain enabled' }, + // message.payload.payloadId, + // ) } break @@ -184,11 +177,11 @@ const connectRemote = (remotePort: any) => { message.payload.payloadId, ) } else { - sendResponse( - `on${SUPPORTED_METHODS.ENABLE_ACCESS}`, - { error: 'Request rejected' }, - message.payload.payloadId, - ) + // sendResponse( + // `on${SUPPORTED_METHODS.ENABLE_ACCESS}`, + // { error: 'Request rejected' }, + // message.payload.payloadId, + // ) } break @@ -196,9 +189,9 @@ const connectRemote = (remotePort: any) => { case 'pending-swaps': await addTxToPendingTxList(message.payload, message.override) break - case 'popup-closed': - enableAccessRequests = {} - break + // case 'popup-closed': + // enableAccessRequests.clear() + // break } }) @@ -274,8 +267,8 @@ const connectRemote = (remotePort: any) => { }, }) .then(() => - openPopup('suggestChain').then(async (windowId) => { - popupWindowId = windowId ?? 0 + openPopup('suggestChain').then(async (window) => { + popupWindowId = window?.id ?? 0 windowIdForPayloadId[popupWindowId] = { type: type.toUpperCase(), payloadId: payload.id, @@ -340,173 +333,54 @@ const connectRemote = (remotePort: any) => { queryString += `&chainIds=${chainId}` }) - const store = await browser.storage.local.get([ACTIVE_WALLET]) + const password = passwordManager.getPassword() - if (!store[ACTIVE_WALLET]) { - try { - await openPopup('login', '?close-on-login=true') - await awaitUIResponse('user-logged-in') - } catch { - sendResponse(`on${type.toUpperCase()}`, { error: 'User rejected request' }, payload.id) - break - } - } - - checkConnection(chainIds, msg) - .then(async ({ validChainIds, isNewChainPresent }) => { - if (validChainIds.length > 0) { - if (isNewChainPresent) { - await browser.storage.local.set({ - [REDIRECT_REQUEST]: { type: type, msg: { ...msg, validChainIds } }, - }) - - delete enableAccessRequests[queryString] - enableAccessRequests[queryString] = popupWindowId - await openPopup('approveConnection') - requestEnableAccess({ origin: msg.origin, validChainIds, payloadId: payload.id }) - windowIdForPayloadId[popupWindowId] = { - type: type.toUpperCase(), - payloadId: payload.id, - } - - try { - const response = await awaitEnableChainResponse() - // hasUnApprovedTx = false - sendResponse(`on${type.toUpperCase()}`, response, payload.id) - delete enableAccessRequests[queryString] - } catch (error: any) { - sendResponse(`on${type.toUpperCase()}`, { error: error.error }, payload.id) - delete enableAccessRequests[queryString] - } - } else { - sendResponse(`on${type.toUpperCase()}`, { success: 'Chain enabled' }, payload.id) - // hasUnApprovedTx = false - // sendResponse() + try { + const { validChainIds, isNewChainPresent } = await checkConnection(chainIds, msg) + if (validChainIds.length > 0) { + if (isNewChainPresent || !password) { + await browser.storage.local.set({ + [REDIRECT_REQUEST]: { type: type, msg: { ...msg, validChainIds } }, + }) + enableAccessRequests.delete(queryString) + enableAccessRequests.set(queryString, popupWindowId) + await openPopup('approveConnection', '?unlock-to-approve') + requestEnableAccess({ origin: msg.origin, validChainIds, payloadId: payload.id }) + windowIdForPayloadId[popupWindowId] = { + type: type.toUpperCase(), + payloadId: payload.id, + } + try { + const response: any = await awaitApproveChainResponse(payload.id) + sendResponse(`on${type.toUpperCase()}`, response, response.payloadId) + enableAccessRequests.delete(queryString) + } catch (error: any) { + sendResponse(`on${type.toUpperCase()}`, { error: error.error }, payload.id) + enableAccessRequests.delete(queryString) } } else { - sendResponse(`on${type.toUpperCase()}`, { error: 'Invalid chain id' }, payload.id) - delete enableAccessRequests[queryString] + sendResponse(`on${type.toUpperCase()}`, { success: 'Chain enabled' }, payload.id) + enableAccessRequests.delete(queryString) } - }) - .catch(() => { - sendResponse(`on${type.toUpperCase()}`, { error: `Invalid chain id` }, payload.id) - delete enableAccessRequests[queryString] - }) + } else { + sendResponse(`on${type.toUpperCase()}`, { error: 'Invalid chain id' }, payload.id) + enableAccessRequests.delete(queryString) + } + } catch (e: any) { + sendResponse(`on${type.toUpperCase()}`, { error: `Invalid chain id` }, payload.id) + enableAccessRequests.delete(queryString) + } break } case SUPPORTED_METHODS.GET_KEYS: case SUPPORTED_METHODS.GET_KEY: { - const msg = payload - const chainIds = msg.chainIds ?? Array.isArray(msg.chainId) ? msg.chainId : [msg.chainId] - const eventName = `on${type.toUpperCase()}` - - let queryString = `?origin=${msg?.origin}` - chainIds?.forEach((chainId: string) => { - queryString += `&chainIds=${chainId}` + await handleGetKey({ + message: { type, payload }, + passwordManager, + sendResponse, }) - - await browser.storage.local.get([ACTIVE_WALLET]) - const password = passwordManager.getPassword() - if (!password) { - try { - await openPopup('login', '?close-on-login=true') - await awaitUIResponse('user-logged-in') - } catch { - sendResponse(eventName, { error: 'Invalid chain id' }, payload.id) - break - } - } - - const store = await browser.storage.local.get([CONNECTIONS, ACTIVE_WALLET]) - const activeWallet = store[ACTIVE_WALLET] - const connections = store[CONNECTIONS] - - const { validChainIds, isNewChainPresent } = await checkChainConnections( - chainIds, - connections, - msg, - activeWallet, - ) - - if (validChainIds.length === 0) { - sendResponse(eventName, { error: 'Invalid chain id' }, payload.id) - return - } - const isEvmChainId = validChainIds.some((chainId) => - LEDGER_ENABLED_EVM_CHAIN_IDS.includes(chainId), - ) - - if (activeWallet.walletType === WALLETTYPE.LEDGER && isEvmChainId) { - const chainIdToChain = await decodeChainIdToChain() - const requestedChainKeys = validChainIds - .map((chainId) => chainIdToChain[chainId]) - .filter((chainKey) => !!activeWallet.addresses[chainKey]) - - if (requestedChainKeys.length === 0) { - sendResponse( - eventName, - { error: `No public key for ${validChainIds.join(',')}` }, - payload.id, - ) - return - } - } - - if (isNewChainPresent) { - await openPopup('approveConnection') - windowIdForPayloadId[popupWindowId] = { - type: type.toUpperCase(), - payloadId: payload.id, - } - requestEnableAccess({ - origin: msg.origin, - validChainIds, - payloadId: payload.id, - }) - - try { - const response = await awaitEnableChainResponse() - if (response) { - if (type === 'get-key') { - getKey(validChainIds[0]).then((key) => { - sendResponse(eventName, { key }, payload.id) - }) - } else { - getKeys(validChainIds).then((keys) => { - sendResponse(eventName, { keys }, payload.id) - }) - } - delete enableAccessRequests[queryString] - } - } catch (e) { - sendResponse(eventName, { error: 'Request rejected' }, payload.id) - delete enableAccessRequests[queryString] - } - } else { - if (type === 'get-key') { - getKey(validChainIds[0]) - .then((key) => { - sendResponse(eventName, { key }, payload.id) - delete enableAccessRequests[queryString] - }) - .catch(() => { - sendResponse(eventName, { error: 'Invalid chain Id' }, payload.id) - delete enableAccessRequests[queryString] - }) - } else { - getKeys(validChainIds) - .then((keys) => { - sendResponse(eventName, { keys }, payload.id) - delete enableAccessRequests[queryString] - }) - .catch(() => { - sendResponse(eventName, { error: 'Invalid chain Id' }, payload.id) - delete enableAccessRequests[queryString] - }) - } - } } break @@ -629,16 +503,8 @@ const connectRemote = (remotePort: any) => { return sendResponse(`on${type.toUpperCase()}`, '', payload.id) } - const checkSuggestTokenChainConnections = ( - eventName: string, - store: Record, - ) => { - return checkChainConnections( - [payload.chainId], - store[CONNECTIONS], - payload, - store[ACTIVE_WALLET], - ).then(({ validChainIds }) => { + const checkSuggestTokenChainConnections = (eventName: string) => { + return checkConnection([payload.chainId], payload).then(({ validChainIds }) => { if (validChainIds.length === 0) { return sendResponse(eventName, { error: 'Invalid chain id' }, payload.id) } @@ -650,8 +516,8 @@ const connectRemote = (remotePort: any) => { }, }) .then(async () => - openPopup('add-secret-token').then((windowId) => { - popupWindowId = windowId ?? 0 + openPopup('add-secret-token').then((window) => { + popupWindowId = window?.id ?? 0 windowIdForPayloadId[popupWindowId] = { type: eventName, payloadId: payload.id, @@ -677,21 +543,18 @@ const connectRemote = (remotePort: any) => { await browser.storage.local.set({ [SUGGEST_TOKEN]: { ...payload, address }, }) - return browser.storage.local.get([CONNECTIONS, ACTIVE_WALLET]).then((store) => { - const eventName = `on${type.toUpperCase()}` - checkSuggestTokenChainConnections(eventName, store) - }) - }) - } else { - browser.storage.local.get([CONNECTIONS, ACTIVE_WALLET]).then(async (store) => { + const eventName = `on${type.toUpperCase()}` - const address = await getWalletAddress(payload.chainId) + checkSuggestTokenChainConnections(eventName) + }) - await browser.storage.local.set({ - [SUGGEST_TOKEN]: { ...payload, address, type }, - }) - checkSuggestTokenChainConnections(eventName, store) + const eventName = `on${type.toUpperCase()}` + const address = await getWalletAddress(payload.chainId) + + await browser.storage.local.set({ + [SUGGEST_TOKEN]: { ...payload, address, type }, }) + checkSuggestTokenChainConnections(eventName) } break @@ -769,7 +632,6 @@ const connectRemote = (remotePort: any) => { const { COMPASS_EVM_CHAIN_IDS, - ARCTIC_COSMOS_CHAIN_ID, ATLANTIC_COSMOS_CHAIN_ID, PACIFIC_COSMOS_CHAIN_ID, ATLANTIC_ETH_CHAIN_ID, @@ -846,6 +708,46 @@ const connectRemote = (remotePort: any) => { break } + case ETHEREUM_METHOD_TYPE.ETH__GET_BLOCK_BY_NUMBER: { + try { + const rpcUrl = (await getSeiEvmInfo({ + activeChain, + activeNetwork, + infoType: SeiEvmInfoEnum.EVM_RPC_URL, + })) as string + + const result = await SeiEvmTx.GetBlockByNumber(payload.params, rpcUrl) + sendResponse(sendResponseName, { success: result }, payloadId) + } catch (error) { + sendResponse( + sendResponseName, + { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, (error as Error).message) }, + payloadId, + ) + } + break + } + + case ETHEREUM_METHOD_TYPE.ETH__GET_BALANCE: { + try { + const rpcUrl = (await getSeiEvmInfo({ + activeChain, + activeNetwork, + infoType: SeiEvmInfoEnum.EVM_RPC_URL, + })) as string + + const result = await SeiEvmTx.EthGetBalance(payload.params, rpcUrl) + sendResponse(sendResponseName, { success: result }, payloadId) + } catch (error) { + sendResponse( + sendResponseName, + { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, (error as Error).message) }, + payloadId, + ) + } + break + } + case ETHEREUM_METHOD_TYPE.ETH__GET_TRANSACTION_RECEIPT: case ETHEREUM_METHOD_TYPE.ETH__GET_TRANSACTION_BY_HASH: { const transactionHash = payload.params[0] @@ -1157,12 +1059,15 @@ const connectRemote = (remotePort: any) => { const to = payload.params[0].to // @ts-ignore const data = payload.params[0].data + // @ts-ignore + const gas = payload.params[0].gas signTxnData = { params: payload.params, value: value ? formatEtherValue(value) : '0', to, data, + gas, details: { Value: value ? `${formatEtherValue(value)} SEI` : '0', 'Contract Interaction': to, @@ -1170,16 +1075,16 @@ const connectRemote = (remotePort: any) => { }, } } else { + const value = parsedData.value.toString() + // @ts-ignore + const to = payload.params[0].to + // @ts-ignore + const data = payload.params[0].data + // @ts-ignore + const gas = payload.params[0].gas + switch (parsedData.name) { case 'approve': { - const value = parsedData.value.toString() - // @ts-ignore - const to = payload.params[0].to - // @ts-ignore - const data = payload.params[0].data - // @ts-ignore - const gas = payload.params[0].gas - signTxnData = { value, to, @@ -1197,6 +1102,39 @@ const connectRemote = (remotePort: any) => { break } + + case 'safeTransferFrom': { + signTxnData = { + value, + to, + data, + gas, + details: { + To: parsedData.args[1], + Data: { + Function: 'Safe Transfer From', + HEX: data, + }, + }, + } + + break + } + + default: { + signTxnData = { + value, + to, + data, + gas, + details: { + Data: { + Function: parsedData.name, + HEX: data, + }, + }, + } + } } } @@ -1235,22 +1173,13 @@ const connectRemote = (remotePort: any) => { } const msg = payload - const chainIds: string[] = [ - ARCTIC_COSMOS_CHAIN_ID, - ATLANTIC_COSMOS_CHAIN_ID, - PACIFIC_COSMOS_CHAIN_ID, - ] + const chainIds: string[] = [ATLANTIC_COSMOS_CHAIN_ID, PACIFIC_COSMOS_CHAIN_ID] let queryString = `?origin=${msg?.origin}` chainIds?.forEach((chainId: string) => { queryString += `&chainIds=${chainId}` }) - if (method === ETHEREUM_METHOD_TYPE.ETH__ACCOUNTS && !enableAccessRequests[queryString]) { - sendResponse(sendResponseName, { success: [] }, payloadId) - break - } - const seiEvmAddress = await getWalletAddress(payloadId) if (seiEvmAddress === 'error') { break @@ -1279,33 +1208,22 @@ const connectRemote = (remotePort: any) => { : [seiEvmAddress] if (isNewChainPresent) { - await browser.storage.local.set({ - [REDIRECT_REQUEST]: { type: method, msg: { ...msg, validChainIds } }, - }) - - const shouldOpenPopup = - Object.keys(enableAccessRequests).length === 0 || - !Object.keys(enableAccessRequests).some((key) => key.includes(msg.origin)) - - if (shouldOpenPopup) { - delete enableAccessRequests[queryString] - enableAccessRequests[queryString] = popupWindowId - await openPopup('approveConnection') - - requestEnableAccess({ - origin: msg.origin, - validChainIds, - payloadId: payloadId as unknown as string, - ecosystem: LINE_TYPE.ETHEREUM, - ethMethod: method, + if (method === ETHEREUM_METHOD_TYPE.ETH__ACCOUNTS) { + sendResponse(sendResponseName, { success: [] }, payloadId) + } else { + await browser.storage.local.set({ + [REDIRECT_REQUEST]: { type: method, msg: { ...msg, validChainIds } }, }) - windowIdForPayloadId[popupWindowId] = { - type: method.toUpperCase(), - payloadId: payloadId, - } - } else { - if (!enableAccessRequests[queryString]) { + const shouldOpenPopup = + Object.keys(enableAccessRequests).length === 0 || + !Object.keys(enableAccessRequests).some((key) => key.includes(msg.origin)) + + if (shouldOpenPopup) { + enableAccessRequests.delete(queryString) + enableAccessRequests.set(queryString, popupWindowId) + await openPopup('approveConnection') + requestEnableAccess({ origin: msg.origin, validChainIds, @@ -1314,31 +1232,44 @@ const connectRemote = (remotePort: any) => { ethMethod: method, }) - enableAccessRequests[queryString] = popupWindowId + windowIdForPayloadId[popupWindowId] = { + type: method.toUpperCase(), + payloadId: payloadId, + } + } else { + if (!enableAccessRequests.has(queryString)) { + requestEnableAccess({ + origin: msg.origin, + validChainIds, + payloadId: payloadId as unknown as string, + ecosystem: LINE_TYPE.ETHEREUM, + ethMethod: method, + }) + enableAccessRequests.set(queryString, popupWindowId) + } } - } - try { - await awaitEnableChainResponse() + try { + await awaitEnableChainResponse() - if (seiEvmAddress.startsWith('0x')) { - sendResponse(sendResponseName, { success: successResponse }, payloadId) - } else { + if (seiEvmAddress.startsWith('0x')) { + sendResponse(sendResponseName, { success: successResponse }, payloadId) + } else { + sendResponse( + sendResponseName, + { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, seiEvmAddress) }, + payloadId, + ) + } + enableAccessRequests.delete(queryString) + } catch (error: any) { sendResponse( sendResponseName, - { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, seiEvmAddress) }, + { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, error.error) }, payloadId, ) + enableAccessRequests.delete(queryString) } - - delete enableAccessRequests[queryString] - } catch (error: any) { - sendResponse( - sendResponseName, - { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, error.error) }, - payloadId, - ) - delete enableAccessRequests[queryString] } } else { if (seiEvmAddress.startsWith('0x')) { @@ -1349,9 +1280,8 @@ const connectRemote = (remotePort: any) => { { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, seiEvmAddress) }, payloadId, ) - - delete enableAccessRequests[queryString] } + enableAccessRequests.delete(queryString) } } else { sendResponse( @@ -1359,8 +1289,7 @@ const connectRemote = (remotePort: any) => { { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, 'Invalid chain id') }, payloadId, ) - - delete enableAccessRequests[queryString] + enableAccessRequests.delete(queryString) } }) .catch(() => { @@ -1369,8 +1298,7 @@ const connectRemote = (remotePort: any) => { { error: getEvmError(ETHEREUM_RPC_ERROR.INTERNAL, 'Invalid chain id') }, payloadId, ) - - delete enableAccessRequests[queryString] + enableAccessRequests.delete(queryString) }) break @@ -1492,63 +1420,6 @@ const connectRemote = (remotePort: any) => { browser.runtime.onConnect.addListener(connectRemote) -async function getKey(_chain: string) { - let { 'active-wallet': activeWallet } = await browser.storage.local.get([ACTIVE_WALLET]) - const _chainIdToChain = await decodeChainIdToChain() - let chain = _chainIdToChain[_chain] - - chain = chain === 'cosmoshub' ? 'cosmos' : chain - const password = passwordManager.getPassword() - if (!activeWallet.addresses[chain] && !ChainInfos[chain as SupportedChain].enabled) { - throw new Error('Invalid chain id') - } - - if (!activeWallet.addresses[chain] && ChainInfos[chain as SupportedChain].enabled && password) { - if ( - activeWallet.walletType === WALLETTYPE.LEDGER && - ChainInfos[chain as SupportedChain].bip44.coinType === '60' - ) { - throw new Error('Ledger wallet is not supported for this chain') - } - const updatedKeyStore = await getUpdatedKeyStore( - ChainInfos, - password, - chain as SupportedChain, - activeWallet, - 'UPDATE', - ) - activeWallet = updatedKeyStore - } - - return { - address: Bech32Address.fromBech32(activeWallet.addresses[chain] ?? '').address, - algo: 'secp256k1', - bech32Address: activeWallet.addresses[chain], - isNanoLedger: activeWallet.walletType === 3, - name: formatWalletName(activeWallet.name), - pubKey: toUint8Array(activeWallet.pubKeys?.[chain] ?? ''), - } -} - -async function getKeys(chainIds: string[]) { - const { 'active-wallet': activeWallet } = await browser.storage.local.get([ACTIVE_WALLET]) - const _chainIdToChain = await decodeChainIdToChain() - const chains = chainIds.map((chainId) => _chainIdToChain[chainId]) - const keys = Object.keys(activeWallet.addresses) - .filter((chain: string) => chains.indexOf(chain) > -1) - .map((chain) => { - return { - address: Bech32Address.fromBech32(activeWallet.addresses[chain] ?? '').address, - algo: 'secp256k1', - bech32Address: activeWallet.addresses[chain], - isNanoLedger: activeWallet.walletType === 3, - name: formatWalletName(activeWallet.name.replace), - pubKey: toUint8Array(activeWallet.pubKeys?.[chain] ?? ''), - } - }) - return keys -} - browser.runtime.onInstalled.addListener((details) => { browser.storage.local .get([ @@ -1571,6 +1442,7 @@ browser.runtime.onInstalled.addListener((details) => { await browser.storage.local.set({ [V80_KEYSTORE_MIGRATION_COMPLETE]: true, [V118_KEYSTORE_MIGRATION_COMPLETE]: true, + [V125_BETA_NFT_COLLECTIONS_MIGRATION_COMPLETE]: true, }) } else if (details.reason === 'update' && (activeWallet || encryptedActiveWallet)) { //previous version as int (e.g. v 0.1.9 will return 19) @@ -1711,6 +1583,7 @@ function formatNewChainInfo(chainInfo: any) { addressPrefix: addressPrefix, gasPriceStep: gasPriceStep, ibcChannelIds: {}, + feeCurrencies: chainInfo.feeCurrencies, nativeDenoms: { [rest.coinMinimalDenom]: rest, }, diff --git a/apps/extension/src/extension-scripts/request-handlers/getKey.handler.ts b/apps/extension/src/extension-scripts/request-handlers/getKey.handler.ts new file mode 100644 index 00000000..065e164d --- /dev/null +++ b/apps/extension/src/extension-scripts/request-handlers/getKey.handler.ts @@ -0,0 +1,168 @@ +import { WALLETTYPE } from '@leapwallet/cosmos-wallet-hooks' +import { ChainInfos, SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import browser from 'webextension-polyfill' + +import { LEDGER_ENABLED_EVM_CHAIN_IDS } from '../../config/config' +import { ACTIVE_WALLET, CONNECTIONS } from '../../config/storage-keys' +import { getUpdatedKeyStore } from '../../hooks/wallet/getUpdatedKeyStore' +import { Bech32Address } from '../../utils/bech32' +import { formatWalletName } from '../../utils/formatWalletName' +import { toUint8Array } from '../../utils/uint8Utils' +import { PasswordManager } from '../password-manager' +import { checkConnection, decodeChainIdToChain } from '../utils' +import { awaitApproveChainResponse, openPopup, requestEnableAccess } from '../utils' + +type GetKeyRequest = { + message: { + payload: any + type: string + } + passwordManager: PasswordManager + sendResponse: (eventName: string, payload: any, payloadId: number) => void +} + +async function getKey(_chain: string, passwordManager: PasswordManager) { + let { 'active-wallet': activeWallet } = await browser.storage.local.get([ACTIVE_WALLET]) + const _chainIdToChain = await decodeChainIdToChain() + let chain = _chainIdToChain[_chain] + + chain = chain === 'cosmoshub' ? 'cosmos' : chain + const password = passwordManager.getPassword() + if (!activeWallet.addresses[chain] && !ChainInfos[chain as SupportedChain].enabled) { + throw new Error('Invalid chain id') + } + + if (!activeWallet.addresses[chain] && ChainInfos[chain as SupportedChain].enabled && password) { + if ( + activeWallet.walletType === WALLETTYPE.LEDGER && + ChainInfos[chain as SupportedChain].bip44.coinType === '60' + ) { + throw new Error('Ledger wallet is not supported for this chain') + } + const updatedKeyStore = await getUpdatedKeyStore( + ChainInfos, + password, + chain as SupportedChain, + activeWallet, + 'UPDATE', + ) + activeWallet = updatedKeyStore + } + + return { + address: Bech32Address.fromBech32(activeWallet.addresses[chain] ?? '').address, + algo: 'secp256k1', + bech32Address: activeWallet.addresses[chain], + isNanoLedger: activeWallet.walletType === 3, + name: formatWalletName(activeWallet.name), + pubKey: toUint8Array(activeWallet.pubKeys?.[chain] ?? ''), + } +} + +async function getKeys(chainIds: string[]) { + const { 'active-wallet': activeWallet } = await browser.storage.local.get([ACTIVE_WALLET]) + const _chainIdToChain = await decodeChainIdToChain() + const chains = chainIds.map((chainId) => _chainIdToChain[chainId]) + const keys = Object.keys(activeWallet.addresses) + .filter((chain: string) => chains.indexOf(chain) > -1) + .map((chain) => { + return { + address: Bech32Address.fromBech32(activeWallet.addresses[chain] ?? '').address, + algo: 'secp256k1', + bech32Address: activeWallet.addresses[chain], + isNanoLedger: activeWallet.walletType === 3, + name: formatWalletName(activeWallet.name.replace), + pubKey: toUint8Array(activeWallet.pubKeys?.[chain] ?? ''), + } + }) + return keys +} + +const requests = new Map() + +export async function handleGetKey({ message, passwordManager, sendResponse }: GetKeyRequest) { + requests.set(message.payload.id, false) + const { payload, type } = message + const msg = payload + const chainIds = msg.chainIds ?? Array.isArray(msg.chainId) ? msg.chainId : [msg.chainId] + const eventName = `on${type.toUpperCase()}` + + let queryString = `?origin=${msg?.origin}` + chainIds?.forEach((chainId: string) => { + queryString += `&chainIds=${chainId}` + }) + + try { + const store = await browser.storage.local.get([CONNECTIONS, ACTIVE_WALLET]) + const activeWallet = store[ACTIVE_WALLET] + const { validChainIds, isNewChainPresent } = await checkConnection(chainIds, msg) + + const password = passwordManager.getPassword() + + if (validChainIds.length === 0) { + sendResponse(eventName, { error: 'Invalid chain id' }, payload.id) + return + } + const isEvmChainId = validChainIds.some((chainId) => + LEDGER_ENABLED_EVM_CHAIN_IDS.includes(chainId), + ) + + if (activeWallet && activeWallet.walletType === WALLETTYPE.LEDGER && isEvmChainId) { + const chainIdToChain = await decodeChainIdToChain() + const requestedChainKeys = validChainIds + .map((chainId) => [chainId, chainIdToChain[chainId]]) + .filter(([_, chainKey]) => !!activeWallet.addresses[chainKey]) + + if (requestedChainKeys.length === 0) { + requestedChainKeys.forEach(([requestedChainId]) => { + sendResponse(eventName, { error: `No public key for ${requestedChainId}` }, payload.id) + }) + return + } + } + + if (isNewChainPresent || !password) { + await openPopup('approveConnection', '?unlock-to-approve') + requestEnableAccess({ + origin: msg.origin, + validChainIds, + payloadId: payload.id, + }) + + try { + const response: any = await awaitApproveChainResponse(payload.id) + if (response) { + if (type === 'get-key') { + const key = await getKey(validChainIds[0], passwordManager) + sendResponse(eventName, { key }, response.payloadId) + } else { + const keys = await getKeys(validChainIds) + sendResponse(eventName, { keys }, response.payloadId) + } + } + } catch (e) { + sendResponse(eventName, { error: 'Request rejected' }, payload.id) + } + } else { + if (type === 'get-key') { + getKey(validChainIds[0], passwordManager) + .then((key) => { + sendResponse(eventName, { key }, payload.id) + }) + .catch(() => { + sendResponse(eventName, { error: 'Invalid chain Id' }, payload.id) + }) + } else { + getKeys(validChainIds) + .then((keys) => { + sendResponse(eventName, { keys }, payload.id) + }) + .catch(() => { + sendResponse(eventName, { error: 'Invalid chain Id' }, payload.id) + }) + } + } + } catch (e) { + sendResponse(eventName, { error: 'Unable to get key' }, payload.id) + } +} diff --git a/apps/extension/src/extension-scripts/utils.ts b/apps/extension/src/extension-scripts/utils.ts index 2acc7adb..095b1940 100644 --- a/apps/extension/src/extension-scripts/utils.ts +++ b/apps/extension/src/extension-scripts/utils.ts @@ -1,13 +1,12 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/ban-ts-comment */ -import { Key } from '@leapwallet/cosmos-wallet-hooks' import { getChains } from '@leapwallet/cosmos-wallet-hooks' import { LineType } from '@leapwallet/cosmos-wallet-provider/dist/provider/types' import { chainIdToChain, ChainInfo, SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { KeyChain } from '@leapwallet/leap-keychain' import { initStorage } from '@leapwallet/leap-keychain' import { MessageTypes } from 'config/message-types' -import { BETA_CHAINS } from 'config/storage-keys' +import { ACTIVE_WALLET_ID, BETA_CHAINS } from 'config/storage-keys' import CryptoJs from 'crypto-js' import { addToConnections } from 'pages/ApproveConnection/utils' import { getStorageAdapter } from 'utils/storageAdapter' @@ -71,14 +70,14 @@ export async function checkChainConnections( connections: any, // eslint-disable-next-line @typescript-eslint/no-explicit-any msg: any, - activeWallet: Key, + activeWalletId: string, ) { const isLeapBoardOrigin = 'https://cosmos.leapwallet.io' === msg.origin - let isNewChainPresent = !activeWallet + let isNewChainPresent = !activeWalletId - if (activeWallet) { + if (activeWalletId) { chainIds.forEach((chainId: string) => { - const sites: [string] = connections?.[activeWallet.id]?.[chainId] || [] + const sites: [string] = connections?.[activeWalletId]?.[chainId] || [] if (!sites.includes(msg?.origin)) { isNewChainPresent = true @@ -91,7 +90,7 @@ export async function checkChainConnections( if (validChainIds.length && isLeapBoardOrigin) { isNewChainPresent = false - await addToConnections(chainIds, [activeWallet], msg.origin) + await addToConnections(chainIds, [activeWalletId], msg.origin) } return { @@ -110,10 +109,15 @@ const getActiveWallet = async () => { return activeWallet } +const getActiveWalletId = async () => { + const store = await browser.storage.local.get([ACTIVE_WALLET_ID]) + return store[ACTIVE_WALLET_ID] +} + // eslint-disable-next-line @typescript-eslint/no-explicit-any export async function checkConnection(chainIds: string[], msg: any) { - const [activeWallet, connections] = await Promise.all([getActiveWallet(), getConnections()]) - return await checkChainConnections(chainIds, connections, msg, activeWallet) + const [activeWalletId, connections] = await Promise.all([getActiveWalletId(), getConnections()]) + return await checkChainConnections(chainIds, connections, msg, activeWalletId) } const popupIds: Record = {} const pendingPromises: Record> = {} @@ -186,14 +190,16 @@ export async function openPopup(page: Page, queryString?: string) { } else { throw new Error('No tabs') } - } catch { + } catch (e: any) { try { - const promise = browser.windows.create(popup) - pendingPromises[url] = promise - - const window = await promise - if (window.id) { - popupIds[url] = window.id + if (e.message.includes(`No tab with id`)) { + const promise = browser.windows.create(popup) + pendingPromises[url] = promise + + const window = await promise + if (window.id) { + popupIds[url] = window.id + } } } finally { delete pendingPromises[url] @@ -202,13 +208,12 @@ export async function openPopup(page: Page, queryString?: string) { } else { try { const promise = browser.windows.create(popup) - pendingPromises[url] = promise const window = await promise if (window.id) { popupIds[url] = window.id } - return window.id + return window } finally { delete pendingPromises[url] } @@ -365,6 +370,36 @@ export async function awaitUIResponse(messageType: string) { }) } +export async function awaitApproveChainResponse(payloadId: string) { + return new Promise((resolve, reject) => { + const listener = async ( + message: { type: string; payload: any; status: string }, + sender: any, + ) => { + if (sender.id !== browser.runtime.id) reject('Invalid sender') + if (message.type === 'chain-enabled' && message.payload.payloadId === payloadId) { + resolve({ status: 'success', payloadId: message.payload.payloadId }) + //browser.runtime.onMessage.removeListener(listener) + } else if ( + message.type === 'chain-approval-rejected' && + message.payload.payloadId === payloadId + ) { + reject({ status: 'rejected', payloadId: message.payload.payloadId }) + browser.runtime.onMessage.removeListener(listener) + } else if (message.type === 'popup-closed') { + resolve('popup-closed') + browser.runtime.onMessage.removeListener(listener) + } else if (message.type === 'user-logged-in' && message.status !== 'success') { + reject('failed') + browser.runtime.onMessage.removeListener(listener) + } + // if (ApprovalMessageTypes.includes(message.type)) { + // browser.runtime.onMessage.removeListener(listener) + // } + } + browser.runtime.onMessage.addListener(listener) + }) +} export function requestSignTransaction(payload: any) { const listener = (message: any, sender: any) => { if (sender.id !== browser.runtime.id) throw new Error('Invalid Sender') diff --git a/apps/extension/src/hooks/activity/useActivityImage.ts b/apps/extension/src/hooks/activity/useActivityImage.ts index a5daabee..3ef5e831 100644 --- a/apps/extension/src/hooks/activity/useActivityImage.ts +++ b/apps/extension/src/hooks/activity/useActivityImage.ts @@ -1,7 +1,6 @@ -import { ActivityType, useActiveChain } from '@leapwallet/cosmos-wallet-hooks' +import { ActivityType, useActiveChain, useGetChains } from '@leapwallet/cosmos-wallet-hooks' import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { ThemeName, useTheme } from '@leapwallet/leap-ui' -import { useChainInfos } from 'hooks/useChainInfos' import { useMemo } from 'react' import { Images } from '../../images' @@ -15,31 +14,32 @@ export const getSwapImage = (activeChain: SupportedChain): string => { } } -export function useActivityImage(txType: ActivityType) { - const chainInfos = useChainInfos() +export function useActivityImage(txType: ActivityType, forceChain?: SupportedChain) { + const chains = useGetChains() const theme = useTheme().theme - const activeChain = useActiveChain() + const _activeChain = useActiveChain() + const activeChain = forceChain || _activeChain const genericAssetIcon = theme === ThemeName.DARK ? Images.Logos.GenericDark : Images.Logos.GenericLight return useMemo(() => { const content: Record = { - send: chainInfos[activeChain].chainSymbolImageUrl as string, - receive: chainInfos[activeChain].chainSymbolImageUrl as string, + send: chains[activeChain]?.chainSymbolImageUrl ?? genericAssetIcon, + receive: chains[activeChain]?.chainSymbolImageUrl ?? genericAssetIcon, vote: Images.Activity.Voting, fallback: genericAssetIcon, delegate: genericAssetIcon, undelegate: genericAssetIcon, 'ibc/transfer': genericAssetIcon, pending: genericAssetIcon, - secretTokenTransfer: chainInfos[activeChain].chainSymbolImageUrl as string, + secretTokenTransfer: chains[activeChain]?.chainSymbolImageUrl ?? genericAssetIcon, swap: getSwapImage(activeChain), - 'liquidity/add': Images.Logos.ChainLogos[activeChain] as string, - 'liquidity/remove': Images.Logos.ChainLogos[activeChain] as string, - grant: Images.Logos.ChainLogos[activeChain] as string, - revoke: Images.Logos.ChainLogos[activeChain] as string, + 'liquidity/add': Images.Logos.ChainLogos[activeChain] ?? genericAssetIcon, + 'liquidity/remove': Images.Logos.ChainLogos[activeChain] ?? genericAssetIcon, + grant: Images.Logos.ChainLogos[activeChain] ?? genericAssetIcon, + revoke: Images.Logos.ChainLogos[activeChain] ?? genericAssetIcon, cw20TokenTransfer: genericAssetIcon, } return content[txType] - }, [activeChain, chainInfos, genericAssetIcon, txType]) + }, [activeChain, chains, genericAssetIcon, txType]) } diff --git a/apps/extension/src/hooks/analytics/usePageView.ts b/apps/extension/src/hooks/analytics/usePageView.ts index eb250b85..28e285d4 100644 --- a/apps/extension/src/hooks/analytics/usePageView.ts +++ b/apps/extension/src/hooks/analytics/usePageView.ts @@ -1,8 +1,11 @@ import { useChainInfo } from '@leapwallet/cosmos-wallet-hooks' import { ChainInfo } from '@leapwallet/cosmos-wallet-sdk' import { EventName, PageName } from 'config/analytics' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { useActiveChain } from 'hooks/settings/useActiveChain' import mixpanel from 'mixpanel-browser' import { useEffect } from 'react' +import { AggregatedSupportedChain } from 'types/utility' import { isCompassWallet } from 'utils/isCompassWallet' /** @@ -11,6 +14,10 @@ import { isCompassWallet } from 'utils/isCompassWallet' // eslint-disable-next-line @typescript-eslint/no-explicit-any export const usePageView = (pageName: PageName, enable = true, additionalProperties?: any) => { const chain = useChainInfo() as ChainInfo | undefined + const activeChain = useActiveChain() as AggregatedSupportedChain + const isAggregatedView = activeChain === AGGREGATED_CHAIN_KEY + const chainId = isAggregatedView ? 'all' : chain?.chainId ?? '' + const chainName = isAggregatedView ? 'All Chains' : chain?.chainName ?? '' useEffect(() => { if (!enable || (isCompassWallet() && pageName !== PageName.Home)) return @@ -21,8 +28,8 @@ export const usePageView = (pageName: PageName, enable = true, additionalPropert EventName.PageView, { pageName, - chainId: chain?.chainId ?? '', - chainName: chain?.chainName ?? '', + chainId, + chainName, time: Date.now() / 1000, ...(additionalProperties ?? {}), }, diff --git a/apps/extension/src/hooks/index.ts b/apps/extension/src/hooks/index.ts new file mode 100644 index 00000000..1bb761c0 --- /dev/null +++ b/apps/extension/src/hooks/index.ts @@ -0,0 +1,2 @@ +export * from './useWalletInfo' +export * from './utility' diff --git a/apps/extension/src/hooks/kado/useGetSupportedAssets.ts b/apps/extension/src/hooks/kado/useGetSupportedAssets.ts new file mode 100644 index 00000000..e4b13c39 --- /dev/null +++ b/apps/extension/src/hooks/kado/useGetSupportedAssets.ts @@ -0,0 +1,70 @@ +import { useDenoms, useTokenPriorityKado } from '@leapwallet/cosmos-wallet-hooks' +import { useQuery } from '@tanstack/react-query' +import { useChainInfos } from 'hooks/useChainInfos' +import { useKadoAssets } from 'hooks/useGetKadoDetails' +import { isCompassWallet } from 'utils/isCompassWallet' + +export type AssetProps = { + id?: string + symbol: string + chainName: string + chainId?: string + assetImg?: string + chainSymbolImageUrl?: string + priority?: number + origin: string +} + +export function useGetSupportedAssets() { + const chainInfos = useChainInfos() + const denoms = useDenoms() + const { data: kadoAssets = [], isLoading: isAssetsLoading } = useKadoAssets() + const { data: tokenPriority = {}, isLoading: isPriorityListLoading } = useTokenPriorityKado() + + function filterData() { + const denomsArray = Object.values(denoms) + const chainsArray = Object.values(chainInfos) + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const filteredAssets = kadoAssets.reduce((acc: AssetProps[], asset: any) => { + const chain = chainsArray.find((chain) => { + if (isCompassWallet() && chain.key === 'cosmos') { + return false + } + + return chain.chainId === asset.officialChainId + }) + + const denomData = denomsArray.find( + (denom) => denom.coinDenom.toLowerCase() === asset.symbol.toLowerCase(), + ) + if (chain) { + acc.push({ + id: asset._id, + symbol: asset.symbol, + chainName: chain.chainName, + chainId: chain.chainId, + assetImg: denomData?.icon, + chainSymbolImageUrl: chain.chainSymbolImageUrl, + priority: tokenPriority[chain.key]?.[asset.symbol], + origin: asset.origin, + }) + } + return acc + }, []) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + filteredAssets.sort((assetA: any, assetB: any) => { + const priorityA = assetA.priority ?? Infinity + const priorityB = assetB.priority ?? Infinity + if (priorityA !== priorityB) { + return priorityA - priorityB + } + return assetA.symbol.localeCompare(assetB.symbol) + }) + return filteredAssets + } + + return useQuery(['filtered-kado-assets'], filterData, { + enabled: chainInfos && denoms && !isAssetsLoading && !isPriorityListLoading, + }) +} diff --git a/apps/extension/src/hooks/nomic-btc-deposit/useGetBTCDepositInfo.ts b/apps/extension/src/hooks/nomic-btc-deposit/useGetBTCDepositInfo.ts index 671b2568..e34b5651 100644 --- a/apps/extension/src/hooks/nomic-btc-deposit/useGetBTCDepositInfo.ts +++ b/apps/extension/src/hooks/nomic-btc-deposit/useGetBTCDepositInfo.ts @@ -40,18 +40,24 @@ export const getNomicBTCDepositConstants = ( export function useNomicBTCDepositConstants() { const storage = useGetStorageLayer() const chain = ChainInfos.nomic.chainRegistryPath + const activeChain = useActiveChain() as SupportedChain & 'aggregated' return useQuery( ['query-nomic-btc-deposit-constants', chain], async () => { - const res = await fetch(`https://assets.leapwallet.io/ibc-support-db/chains/${chain}.json`) - const ibcChains = await res.json() + if (activeChain !== 'aggregated') { + const res = await fetch(`https://assets.leapwallet.io/ibc-support-db/chains/${chain}.json`) + const ibcChains = await res.json() - const constants: NomicBTCDepositConstants = await getNomicBTCDepositConstants(storage) - return { ...constants, ibcChains } + const constants: NomicBTCDepositConstants = await getNomicBTCDepositConstants(storage) + return { ...constants, ibcChains } + } + + return {} as NomicBTCDepositConstants }, { retry: 2, + enabled: activeChain !== 'aggregated', }, ) } diff --git a/apps/extension/src/hooks/secret/useCreateViewingKey.ts b/apps/extension/src/hooks/secret/useCreateViewingKey.ts index 3974bc53..be85ff62 100644 --- a/apps/extension/src/hooks/secret/useCreateViewingKey.ts +++ b/apps/extension/src/hooks/secret/useCreateViewingKey.ts @@ -73,6 +73,7 @@ export function useCreateViewingKey() { }, feeDenomination: 'uscrt', feeQuantity: _txStatus.tx?.auth_info?.fee?.amount?.[0]?.amount ?? '0.01', + chainId, }) viewingKey = _key diff --git a/apps/extension/src/hooks/settings/index.ts b/apps/extension/src/hooks/settings/index.ts index 6fb73fa6..0a17b9fa 100644 --- a/apps/extension/src/hooks/settings/index.ts +++ b/apps/extension/src/hooks/settings/index.ts @@ -4,3 +4,4 @@ export { useFillBetaERC20Tokens } from './useFillBetaERC20Tokens' export { useFillBetaNativeTokens } from './useFillBetaNativeTokens' export * from './useHiddenNFTs' export { useInitIsCompassWallet } from './useInitIsCompassWallet' +export * from './useStarredChains' diff --git a/apps/extension/src/hooks/settings/useActiveChain.ts b/apps/extension/src/hooks/settings/useActiveChain.ts index 93e503f1..3f7e46e9 100644 --- a/apps/extension/src/hooks/settings/useActiveChain.ts +++ b/apps/extension/src/hooks/settings/useActiveChain.ts @@ -4,6 +4,7 @@ import { SeiEvmInfoEnum, SelectedNetworkType, useActiveChain as useActiveChainWalletHooks, + useFeatureFlags, useGetChains, usePendingTxState, useSetActiveChain as useSetActiveChainWalletHooks, @@ -11,16 +12,18 @@ import { } from '@leapwallet/cosmos-wallet-hooks' import { ChainInfo, SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { useQueryClient } from '@tanstack/react-query' +import { selectedChainAlertState } from 'atoms/selected-chain-alert' import { COMPASS_CHAINS } from 'config/config' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' import { ACTIVE_CHAIN, KEYSTORE } from 'config/storage-keys' import { useSetNetwork } from 'hooks/settings/useNetwork' import { useChainInfos } from 'hooks/useChainInfos' import { useEffect } from 'react' import { useSetRecoilState } from 'recoil' +import { AggregatedSupportedChain } from 'types/utility' import { sendMessageToTab } from 'utils' import browser from 'webextension-polyfill' -import { selectedChainAlertState } from '../../atoms/selected-chain-alert' import { isCompassWallet } from '../../utils/isCompassWallet' import useActiveWallet, { useUpdateKeyStore } from './useActiveWallet' @@ -41,66 +44,74 @@ export function useSetActiveChain() { const queryClient = useQueryClient() - return async (chain: SupportedChain, chainInfo?: ChainInfo) => { + return async (chain: AggregatedSupportedChain, chainInfo?: ChainInfo) => { const storage = await browser.storage.local.get(['networkMap', KEYSTORE]) - const keystore = storage[KEYSTORE] - if (keystore) { - const shouldUpdateKeystore = Object.keys(keystore).some((key) => { - const wallet = keystore[key] - return wallet && (!wallet.addresses[chain] || !wallet.pubKeys?.[chain]) - }) - if (activeWallet && shouldUpdateKeystore) { - const updatedKeystore = await updateKeyStore(activeWallet, chain) - await setActiveWallet(updatedKeystore[activeWallet.id] as Key) + if (chain !== AGGREGATED_CHAIN_KEY) { + const keystore = storage[KEYSTORE] + if (keystore) { + const shouldUpdateKeystore = Object.keys(keystore).some((key) => { + const wallet = keystore[key] + return wallet && (!wallet.addresses[chain] || !wallet.pubKeys?.[chain]) + }) + if (activeWallet && shouldUpdateKeystore) { + const updatedKeystore = await updateKeyStore(activeWallet, chain) + await setActiveWallet(updatedKeystore[activeWallet.id] as Key) + } } } await queryClient.cancelQueries() - setActiveChain(chain) + setActiveChain(chain as SupportedChain) setSelectedChainAlert(true) browser.storage.local.set({ [ACTIVE_CHAIN]: chain }) setPendingTx(null) - const networkMap = JSON.parse(storage.networkMap ?? '{}') - const _chainInfo = chainInfos[chain] || chainInfo - let _network: SelectedNetworkType = 'mainnet' - - if (chain === 'seiDevnet') { - setSelectedNetwork('mainnet') - setNetwork('mainnet') - } else { - if (networkMap[chain]) { - let network = networkMap[chain] - let hasChainOnlyTestnet = false - - if (_chainInfo && !_chainInfo?.beta && _chainInfo?.chainId === _chainInfo?.testnetChainId) { - hasChainOnlyTestnet = true - } + if (chain !== AGGREGATED_CHAIN_KEY) { + const networkMap = JSON.parse(storage.networkMap ?? '{}') + const _chainInfo = chainInfos[chain] || chainInfo + let _network: SelectedNetworkType = 'mainnet' - if (hasChainOnlyTestnet && network !== 'testnet') { - network = 'testnet' + if (chain === 'seiDevnet') { + setSelectedNetwork('mainnet') + setNetwork('mainnet') + } else { + if (networkMap[chain]) { + let network = networkMap[chain] + let hasChainOnlyTestnet = false + + if ( + _chainInfo && + !_chainInfo?.beta && + _chainInfo?.chainId === _chainInfo?.testnetChainId + ) { + hasChainOnlyTestnet = true + } + + if (hasChainOnlyTestnet && network !== 'testnet') { + network = 'testnet' + _network = 'testnet' + } + + setNetwork(network) + setSelectedNetwork(network) + } else if (_chainInfo && _chainInfo?.apis?.rpc) { + setNetwork('mainnet') + setSelectedNetwork('mainnet') + } else if (_chainInfo && _chainInfo?.apis?.rpcTest) { + setNetwork('testnet') + setSelectedNetwork('testnet') _network = 'testnet' } - - setNetwork(network) - setSelectedNetwork(network) - } else if (_chainInfo && _chainInfo?.apis?.rpc) { - setNetwork('mainnet') - setSelectedNetwork('mainnet') - } else if (_chainInfo && _chainInfo?.apis?.rpcTest) { - setNetwork('testnet') - setSelectedNetwork('testnet') - _network = 'testnet' } - } - if (isCompassWallet()) { - const chainId = await getSeiEvmInfo({ - activeChain: chain as 'seiDevnet' | 'seiTestnet2', - activeNetwork: _network, - infoType: SeiEvmInfoEnum.EVM_CHAIN_ID, - }) - await sendMessageToTab({ event: 'chainChanged', data: chainId }) + if (isCompassWallet()) { + const chainId = await getSeiEvmInfo({ + activeChain: chain as 'seiDevnet' | 'seiTestnet2', + activeNetwork: _network, + infoType: SeiEvmInfoEnum.EVM_CHAIN_ID, + }) + await sendMessageToTab({ event: 'chainChanged', data: chainId }) + } } } } @@ -109,13 +120,26 @@ export function useInitActiveChain() { const chainInfos = useChainInfos() const chains = useGetChains() const setActiveChain = useSetActiveChainWalletHooks() + const { data: featureFlags } = useFeatureFlags() useEffect(() => { browser.storage.local.get(ACTIVE_CHAIN).then((storage) => { let activeChain: SupportedChain = storage[ACTIVE_CHAIN] - const defaultActiveChain = isCompassWallet() - ? chainInfos.seiTestnet2.key - : chainInfos.cosmos.key + const leapFallbackChain = + featureFlags?.give_all_chains_option_in_wallet?.extension === 'active' + ? (AGGREGATED_CHAIN_KEY as SupportedChain) + : chainInfos.cosmos.key + + const defaultActiveChain = isCompassWallet() ? chainInfos.seiTestnet2.key : leapFallbackChain + + if ( + (activeChain as AggregatedSupportedChain) === AGGREGATED_CHAIN_KEY && + featureFlags?.give_all_chains_option_in_wallet?.extension === 'active' && + !isCompassWallet() + ) { + setActiveChain(activeChain) + return + } if (!activeChain || chains[activeChain] === undefined) { activeChain = defaultActiveChain @@ -129,5 +153,5 @@ export function useInitActiveChain() { }) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [chainInfos, chains]) + }, [chainInfos, chains, featureFlags]) } diff --git a/apps/extension/src/hooks/settings/useActiveWallet.ts b/apps/extension/src/hooks/settings/useActiveWallet.ts index dc5d8d34..108f7b9b 100644 --- a/apps/extension/src/hooks/settings/useActiveWallet.ts +++ b/apps/extension/src/hooks/settings/useActiveWallet.ts @@ -11,6 +11,7 @@ import browser from 'webextension-polyfill' import { ACTIVE_CHAIN, ACTIVE_WALLET, + ACTIVE_WALLET_ID, KEYSTORE, MANAGE_CHAIN_SETTINGS, } from '../../config/storage-keys' @@ -80,10 +81,16 @@ export function useInitActiveWallet() { const { setActiveWallet } = useActiveWalletStore() const password = usePassword() useEffect(() => { - browser.storage.local.get([ACTIVE_WALLET, MANAGE_CHAIN_SETTINGS]).then((storage) => { - setActiveWallet(storage[ACTIVE_WALLET]) - }) - + browser.storage.local + .get([ACTIVE_WALLET, MANAGE_CHAIN_SETTINGS, ACTIVE_WALLET_ID]) + .then((storage) => { + const activeWallet = storage[ACTIVE_WALLET] + const activeWalletId = storage[ACTIVE_WALLET_ID] + setActiveWallet(activeWallet) + if (!activeWalletId && activeWallet) { + browser.storage.local.set({ [ACTIVE_WALLET_ID]: storage[ACTIVE_WALLET].id }) + } + }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [password]) } @@ -104,7 +111,7 @@ export default function useActiveWallet() { } await sendMessageToTab({ event: 'leap_keystorechange' }) - await browser.storage.local.set({ [ACTIVE_WALLET]: wallet }) + await browser.storage.local.set({ [ACTIVE_WALLET]: wallet, [ACTIVE_WALLET_ID]: wallet.id }) try { setState(wallet) } catch (e) { diff --git a/apps/extension/src/hooks/settings/useCurrency.ts b/apps/extension/src/hooks/settings/useCurrency.ts index 94c10c8c..4bcc90dc 100644 --- a/apps/extension/src/hooks/settings/useCurrency.ts +++ b/apps/extension/src/hooks/settings/useCurrency.ts @@ -118,7 +118,7 @@ export const useFormatCurrency = () => { // * @param currencyValue - the currency value to be formatted const currencyFormatter = useCallback( - (currencyValue: BigNumber) => { + (currencyValue: BigNumber, returnNumber: boolean = false) => { const formatCurrency = (amount: BigNumber) => { return new Intl.NumberFormat(currencyDetail[preferredCurrency].locale, { style: 'currency', @@ -127,9 +127,12 @@ export const useFormatCurrency = () => { notation: 'compact', }).format(amount.toNumber()) } - if (isNaN(currencyValue.toNumber()) || currencyValue.toNumber() === 0) { + if (isNaN(currencyValue.toNumber())) { return '-' } + if (currencyValue.toNumber() === 0) { + return returnNumber ? formatCurrency(new BigNumber(0.0)) : '-' + } if (currencyValue.toNumber() < 0.01 && currencyValue.toNumber() !== 0) { return `<${formatCurrency(new BigNumber(0.01))}` } else { diff --git a/apps/extension/src/hooks/settings/useFillBetaCW20Tokens.ts b/apps/extension/src/hooks/settings/useFillBetaCW20Tokens.ts index 866b7a65..db071325 100644 --- a/apps/extension/src/hooks/settings/useFillBetaCW20Tokens.ts +++ b/apps/extension/src/hooks/settings/useFillBetaCW20Tokens.ts @@ -4,25 +4,31 @@ import { useBetaCW20TokensStore, } from '@leapwallet/cosmos-wallet-hooks' import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' -import { useEffect } from 'react' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { useEffect, useMemo } from 'react' +import { AggregatedSupportedChain } from 'types/utility' import { fillBetaValuesFromStorage } from './fillBetaValuesFromStorage' export function useFillBetaCW20Tokens(forceChain?: SupportedChain) { const _activeChain = useActiveChain() - const activeChain = forceChain || _activeChain + const activeChain = useMemo( + () => (forceChain || _activeChain) as AggregatedSupportedChain, + [forceChain, _activeChain], + ) + const { setBetaCW20Tokens } = useBetaCW20TokensStore() - useEffect( - () => + useEffect(() => { + if (activeChain && activeChain !== AGGREGATED_CHAIN_KEY) { fillBetaValuesFromStorage( activeChain, BETA_CW20_TOKENS, (value) => setBetaCW20Tokens(value, activeChain), {}, - ), + ) + } // eslint-disable-next-line react-hooks/exhaustive-deps - [activeChain], - ) + }, [activeChain]) } diff --git a/apps/extension/src/hooks/settings/useFillBetaERC20Tokens.ts b/apps/extension/src/hooks/settings/useFillBetaERC20Tokens.ts index 7df4ef4e..f3ea36e0 100644 --- a/apps/extension/src/hooks/settings/useFillBetaERC20Tokens.ts +++ b/apps/extension/src/hooks/settings/useFillBetaERC20Tokens.ts @@ -4,23 +4,32 @@ import { useBetaERC20TokensStore, } from '@leapwallet/cosmos-wallet-hooks' import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' -import { useEffect } from 'react' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { useEffect, useMemo } from 'react' +import { AggregatedSupportedChain } from 'types/utility' import { fillBetaValuesFromStorage } from './fillBetaValuesFromStorage' export function useFillBetaERC20Tokens(forceChain?: SupportedChain) { const _activeChain = useActiveChain() - const activeChain = forceChain || _activeChain + const activeChain = useMemo( + () => (forceChain || _activeChain) as AggregatedSupportedChain, + [forceChain, _activeChain], + ) + const { setBetaERC20Tokens } = useBetaERC20TokensStore() useEffect( - () => - fillBetaValuesFromStorage( - activeChain, - BETA_ERC20_TOKENS, - (value) => setBetaERC20Tokens(value, activeChain), - {}, - ), + () => { + if (activeChain && activeChain !== AGGREGATED_CHAIN_KEY) { + fillBetaValuesFromStorage( + activeChain, + BETA_ERC20_TOKENS, + (value) => setBetaERC20Tokens(value, activeChain), + {}, + ) + } + }, // eslint-disable-next-line react-hooks/exhaustive-deps [activeChain], diff --git a/apps/extension/src/hooks/settings/useFillBetaNativeTokens.ts b/apps/extension/src/hooks/settings/useFillBetaNativeTokens.ts index 74b57498..db3c69f9 100644 --- a/apps/extension/src/hooks/settings/useFillBetaNativeTokens.ts +++ b/apps/extension/src/hooks/settings/useFillBetaNativeTokens.ts @@ -3,22 +3,33 @@ import { useActiveChain, useBetaNativeTokensStore, } from '@leapwallet/cosmos-wallet-hooks' -import { useEffect } from 'react' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { useEffect, useMemo } from 'react' +import { AggregatedSupportedChain } from 'types/utility' import { fillBetaValuesFromStorage } from './fillBetaValuesFromStorage' -export function useFillBetaNativeTokens() { - const activeChain = useActiveChain() +export function useFillBetaNativeTokens(forceChain?: SupportedChain) { + const _activeChain = useActiveChain() + const activeChain = useMemo( + () => (forceChain || _activeChain) as AggregatedSupportedChain, + [forceChain, _activeChain], + ) + const { setBetaNativeTokens } = useBetaNativeTokensStore() useEffect( - () => - fillBetaValuesFromStorage( - activeChain, - BETA_NATIVE_TOKENS, - (value) => setBetaNativeTokens(value), - {}, - ), + () => { + if (activeChain && activeChain !== AGGREGATED_CHAIN_KEY) { + fillBetaValuesFromStorage( + activeChain, + BETA_NATIVE_TOKENS, + (value) => setBetaNativeTokens(value), + {}, + ) + } + }, // eslint-disable-next-line react-hooks/exhaustive-deps [activeChain], diff --git a/apps/extension/src/hooks/settings/useNetwork.ts b/apps/extension/src/hooks/settings/useNetwork.ts index 1dedfb8c..9de001e2 100644 --- a/apps/extension/src/hooks/settings/useNetwork.ts +++ b/apps/extension/src/hooks/settings/useNetwork.ts @@ -4,10 +4,8 @@ import { } from '@leapwallet/cosmos-wallet-hooks' import { SELECTED_NETWORK } from 'config/storage-keys' import { useEffect } from 'react' -import { useSetRecoilState } from 'recoil' import browser from 'webextension-polyfill' -import { selectedChainAlertState } from '../../atoms/selected-chain-alert' import { isCompassWallet } from '../../utils/isCompassWallet' export type SelectedNetwork = 'mainnet' | 'testnet' @@ -18,10 +16,8 @@ export function useSelectedNetwork() { export function useSetNetwork() { const setSelectedNetwork = useSetSelectedNetwork() - const setShowChainAlert = useSetRecoilState(selectedChainAlertState) return (chain: SelectedNetwork) => { - setShowChainAlert(true) setSelectedNetwork(chain) browser.storage.local.set({ [SELECTED_NETWORK]: chain }) } diff --git a/apps/extension/src/hooks/settings/useStarredChains.ts b/apps/extension/src/hooks/settings/useStarredChains.ts new file mode 100644 index 00000000..2b8d9670 --- /dev/null +++ b/apps/extension/src/hooks/settings/useStarredChains.ts @@ -0,0 +1,52 @@ +import { STARRED_CHAINS } from 'config/storage-keys' +import { useEffect } from 'react' +import { atom, useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil' +import Browser from 'webextension-polyfill' + +const starredChainsStorage = atom({ + key: STARRED_CHAINS, + default: [], +}) + +export function useInitStarredChains() { + const setStarredChains = useSetRecoilState(starredChainsStorage) + + useEffect(() => { + Browser.storage.local.get([STARRED_CHAINS]).then((storage) => { + if (storage[STARRED_CHAINS]) { + const starredChains = JSON.parse(storage[STARRED_CHAINS]) + setStarredChains(starredChains ?? []) + } else { + setStarredChains([]) + } + }) + }, [setStarredChains]) +} + +export function useStarredChains(): string[] { + return useRecoilValue(starredChainsStorage) as string[] +} + +export function useModifyStarredChains() { + const [starredChains, setStarredChains] = useRecoilState(starredChainsStorage) + + const addStarredChain = async (chain: string) => { + const _starredChains = [...(starredChains as string[]), chain] + setStarredChains(_starredChains) + + await Browser.storage.local.set({ + [STARRED_CHAINS]: JSON.stringify(_starredChains), + }) + } + + const removeStarredChain = async (chain: string) => { + const _starredChains = starredChains?.filter((f) => f !== chain) + setStarredChains(_starredChains) + + await Browser.storage.local.set({ + [STARRED_CHAINS]: JSON.stringify(_starredChains), + }) + } + + return { starredChains, addStarredChain, removeStarredChain } +} diff --git a/apps/extension/src/hooks/useAirdropsData.ts b/apps/extension/src/hooks/useAirdropsData.ts index 3367bf6e..171123fc 100644 --- a/apps/extension/src/hooks/useAirdropsData.ts +++ b/apps/extension/src/hooks/useAirdropsData.ts @@ -13,8 +13,8 @@ export const useAirdropsData = () => { const fetchAirdropsData = useCallback(async () => { const allWallets = await KeyChain.getAllWallets() const addresses = Object.values( - Object.values(allWallets).filter((wallet: Key) => wallet.id === activeWallet?.id)?.[0] - ?.addresses, + Object.values(allWallets ?? {}).filter((wallet: Key) => wallet.id === activeWallet?.id)?.[0] + ?.addresses ?? {}, ) const uniqueAddresses = [...new Set(addresses)] fetchAirdropsEligibilityData(uniqueAddresses) diff --git a/apps/extension/src/hooks/useChainInfos.ts b/apps/extension/src/hooks/useChainInfos.ts index fd09f08a..2d78cd6c 100644 --- a/apps/extension/src/hooks/useChainInfos.ts +++ b/apps/extension/src/hooks/useChainInfos.ts @@ -1,7 +1,5 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/ban-ts-comment */ import { useChainsStore, useCustomChains } from '@leapwallet/cosmos-wallet-hooks' -import { ChainInfos } from '@leapwallet/cosmos-wallet-sdk' +import { ChainInfo, ChainInfos } from '@leapwallet/cosmos-wallet-sdk' import { chainInfosState } from 'atoms/chains' import { BETA_CHAINS, CUSTOM_ENDPOINTS } from 'config/storage-keys' import { useEffect } from 'react' @@ -17,15 +15,16 @@ export function useInitChainInfos() { useEffect(() => { function getBetaChains(updateStore?: boolean) { browser.storage.local.get([BETA_CHAINS, CUSTOM_ENDPOINTS]).then(async (resp) => { - const _allChains: any = JSON.parse(resp[BETA_CHAINS] ?? '{}') + const _allChains: Record = {} + const _betaChains = JSON.parse(resp[BETA_CHAINS] ?? '{}') + + // Update previously added custom chains with the latest chain info for (let i = 0; i < customChains?.length; i++) { - if ( - !isCompassWallet() && - !!resp[BETA_CHAINS] && - Object.keys(JSON.parse(resp[BETA_CHAINS])).includes(customChains[i].chainName) - ) { - const existingChain = JSON.parse(resp[BETA_CHAINS])[customChains[i]?.chainName] - _allChains[customChains[i]?.chainName] = { + const existingChain = + _betaChains[customChains[i].key] || _betaChains[customChains[i].chainName] + + if (!isCompassWallet() && !!resp[BETA_CHAINS] && existingChain) { + _allChains[customChains[i].key] = { ...customChains[i], chainId: existingChain.chainId, bip44: existingChain.bip44, @@ -33,26 +32,28 @@ export function useInitChainInfos() { chainRegistryPath: existingChain.chainRegistryPath, testnetChainRegistryPath: existingChain.testnetChainRegistryPath, } + + delete _betaChains[customChains[i].key] + delete _betaChains[customChains[i].chainName] } } - const betaChains = isCompassWallet() - ? {} - : Object.keys(_allChains).length > 0 - ? _allChains - : JSON.parse(resp[BETA_CHAINS] ?? '{}') + let betaChains = + Object.keys(_allChains).length > 0 ? { ..._allChains, ..._betaChains } : _betaChains + betaChains = isCompassWallet() ? {} : betaChains if (!isCompassWallet()) { - for (const chainName in betaChains) { + // Delete beta chains that are already in the native chain list + for (const chainKey in betaChains) { if ( Object.values(ChainInfos).some( (chainInfo) => [chainInfo.chainId, chainInfo.testnetChainId].includes( - betaChains[chainName].chainId, + betaChains[chainKey].chainId, ) && chainInfo.enabled, ) ) { - delete betaChains[chainName] + delete betaChains[chainKey] } } @@ -63,7 +64,7 @@ export function useInitChainInfos() { const enabledChains = Object.entries(ChainInfos).reduce( (chainInfos, [chainKey, chainData]) => { - //cosmoshub is kept here for backwards compatibility + // Cosmoshub is kept here for backwards compatibility if ( isCompassWallet() && !['arctic-1', 'pacific-1', 'cosmoshub-4'].includes(chainData.chainId) @@ -85,7 +86,7 @@ export function useInitChainInfos() { allChains[a].chainName.toLowerCase().localeCompare(allChains[b].chainName.toLowerCase()), ) - const _chains: Record = {} + const _chains: Record = {} sortedChains.map((key) => { _chains[key] = allChains[key] }) @@ -130,6 +131,7 @@ export function useInitChainInfos() { } getBetaChains(true) + // eslint-disable-next-line @typescript-eslint/no-explicit-any const addChainEventListener = (storage: Record) => { if (storage && (storage[BETA_CHAINS] || storage[CUSTOM_ENDPOINTS])) { getBetaChains(false) diff --git a/apps/extension/src/hooks/useContacts.ts b/apps/extension/src/hooks/useContacts.ts index 25a1841e..0c79f034 100644 --- a/apps/extension/src/hooks/useContacts.ts +++ b/apps/extension/src/hooks/useContacts.ts @@ -25,6 +25,7 @@ export const useContacts = () => { acc[key] = contact return acc }, {}) + setContacts(contactsToShow) setLoading(false) } @@ -47,11 +48,13 @@ export const useContactsSearch = (searchQuery?: string): AddressBook.SavedAddres if (loading) { return [] } + const contactsList = Object.values(contacts) const cleanSearchQuery = searchQuery?.trim().toLowerCase() ?? '' if (cleanSearchQuery.length === 0) { return contactsList } + return new Fuse(contactsList, { threshold: 0.3, keys: ['name', 'address', 'ethAddress'], diff --git a/apps/extension/src/hooks/useDontShowSelectChain.ts b/apps/extension/src/hooks/useDontShowSelectChain.ts new file mode 100644 index 00000000..e4e97acd --- /dev/null +++ b/apps/extension/src/hooks/useDontShowSelectChain.ts @@ -0,0 +1,15 @@ +import { useManageChainData } from 'hooks/settings/useManageChains' +import { useMemo } from 'react' +import { isCompassWallet } from 'utils/isCompassWallet' + +export function useDontShowSelectChain() { + const [chains] = useManageChainData() + + const chainsInSelectChain = useMemo(() => { + return chains.filter((chain) => { + return !(isCompassWallet() && chain.chainName === 'cosmos') + }) + }, [chains]) + + return isCompassWallet() && chainsInSelectChain.length === 1 +} diff --git a/apps/extension/src/hooks/useGetKadoDetails.tsx b/apps/extension/src/hooks/useGetKadoDetails.tsx index 3017f8cd..d8e54fb9 100644 --- a/apps/extension/src/hooks/useGetKadoDetails.tsx +++ b/apps/extension/src/hooks/useGetKadoDetails.tsx @@ -1,9 +1,26 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { useQuery } from '@tanstack/react-query' import axios from 'axios' +import { convertObjInQueryParams } from 'pages/home/utils' +import { getCountryLogo } from 'utils/getCountryLogo' const BASE_API = 'https://api.kado.money' +type RequestQuoteArgs = { + transactionType: 'buy' | 'sell' + fiatMethod: 'card' | 'ach' | 'credit_card' + partner: string + amount: number + currency: string + asset: string + blockchain: string +} + +type ConversionRateArgs = { + from: string + to: string +} + export function useGetKadoChains() { return useQuery( ['kado-chains'], @@ -31,3 +48,60 @@ export function useGetKadoAssets() { }, ) } + +export function useKadoAssets() { + return useQuery( + ['kado-asset-list'], + async () => { + const res = await axios.get(`${BASE_API}/v1/ramp/blockchains`) + const supportedChains = res?.data?.data?.blockchains + const supportedAssets = supportedChains.reduce((res: any, chain: any) => { + const assets = [...res] + chain.associatedAssets.forEach((asset: any) => { + assets.push({ + ...asset, + origin: chain.origin, + }) + }) + return assets + }, []) + return supportedAssets + }, + { + staleTime: 1 * 60 * 1000, + cacheTime: 5 * 60 * 1000, + }, + ) +} + +export function useGetKadoCurrencies() { + return useQuery( + ['kado-currency-list'], + async () => { + const res = await axios.get(`${BASE_API}/v1/ramp/currencies`) + const kadoCurrencies = res?.data?.data?.currencyData + const kadoCurrenciesWithLogo = kadoCurrencies.map((currency: any) => ({ + ...currency, + logo: getCountryLogo(currency.code), + })) + return kadoCurrenciesWithLogo + }, + { + staleTime: 1 * 60 * 1000, + cacheTime: 5 * 60 * 1000, + }, + ) +} + +export async function getQuoteKado(args: RequestQuoteArgs) { + const queryParams = convertObjInQueryParams(args) + const result = await axios.get(`${BASE_API}/v2/ramp/quote?${queryParams}`, { + timeout: 10000, + }) + return result?.data +} + +export async function getConversionRateKado({ from, to }: ConversionRateArgs) { + const result = await axios.get(`${BASE_API}/v1/ramp/currencyconvert?from=${from}&to=${to}`) + return result?.data?.data?.conversion +} diff --git a/apps/extension/src/hooks/useGetWalletAddresses.ts b/apps/extension/src/hooks/useGetWalletAddresses.ts index c7e0791d..d94715f2 100644 --- a/apps/extension/src/hooks/useGetWalletAddresses.ts +++ b/apps/extension/src/hooks/useGetWalletAddresses.ts @@ -1,4 +1,4 @@ -import { useActiveChain, useAddress, WALLETTYPE } from '@leapwallet/cosmos-wallet-hooks' +import { useActiveChain, useAddress } from '@leapwallet/cosmos-wallet-hooks' import { getEthereumAddress, getSeiEvmAddressToShow, @@ -19,7 +19,7 @@ export function useGetWalletAddresses(forceChain?: SupportedChain) { return useMemo(() => { if ( activeWallet && - activeWallet?.walletType !== WALLETTYPE.LEDGER && + activeWallet?.addresses?.[activeChain] && SHOW_ETH_ADDRESS_CHAINS.includes(activeChain) ) { if (!isCompassWallet() && activeChain !== 'seiTestnet2') { diff --git a/apps/extension/src/hooks/useNewChainTooltip.ts b/apps/extension/src/hooks/useNewChainTooltip.ts new file mode 100644 index 00000000..474e8655 --- /dev/null +++ b/apps/extension/src/hooks/useNewChainTooltip.ts @@ -0,0 +1,110 @@ +import { + cachedRemoteDataWithLastModified, + useGetStorageLayer, +} from '@leapwallet/cosmos-wallet-hooks' +import { useQuery } from '@tanstack/react-query' +import { NEW_CHAIN_TOOLTIP_STORAGE_KEY } from 'config/storage-keys' +import { useCallback, useEffect, useState } from 'react' +import { isCompassWallet } from 'utils/isCompassWallet' +import browser from 'webextension-polyfill' + +export type NewChainTooltipData = { + header: string + description: string + imgUrl?: string + ctaText: string +} + +export default function useNewChainTooltip() { + const storage = useGetStorageLayer() + const [showToolTip, setShowToolTip] = useState(false) + const [userPreference, setUserPreference] = useState() + const [userPreferenceLoading, setUserPreferenceLoading] = useState(true) + const [toolTipData, setToolTipData] = useState() + + const version = browser.runtime.getManifest().version + + const { data } = useQuery( + ['leap-new-chains-tooltip', storage], + async () => { + const data = await cachedRemoteDataWithLastModified({ + remoteUrl: 'https://assets.leapwallet.io/cosmos-registry/v1/nudges/new-chain-tooltip.json', + storageKey: 'leap-new-chains-tooltip', + storage, + }) + + return data as { + featureFlags: { + 'compass-extension'?: boolean + 'leap-extension'?: boolean + } + } & { [version: string]: NewChainTooltipData } + }, + { + staleTime: 5 * 60 * 1000, + cacheTime: 10 * 60 * 1000, + }, + ) + + useEffect(() => { + async function loadUserPreferences() { + try { + setUserPreferenceLoading(true) + const _userPreferenceJson = await storage.get(NEW_CHAIN_TOOLTIP_STORAGE_KEY) + const _userPreference = JSON.parse(_userPreferenceJson) + setUserPreference(_userPreference) + setUserPreferenceLoading(false) + } catch (_) { + setUserPreferenceLoading(false) + // + } + } + loadUserPreferences() + }, [storage]) + + useEffect(() => { + let isFeatureEnabled = false + if (isCompassWallet()) { + isFeatureEnabled = data?.['featureFlags']?.['compass-extension'] ?? false + } else { + isFeatureEnabled = data?.['featureFlags']?.['leap-extension'] ?? false + } + + if ( + !isFeatureEnabled || + userPreferenceLoading || + userPreference?.[version] === false || + !data?.[version] + ) { + setShowToolTip(false) + return + } + + if (!data?.[version]) { + setShowToolTip(false) + return + } + + setShowToolTip(true) + setToolTipData(data?.[version]) + }, [data, userPreference, userPreferenceLoading, version]) + + const handleToolTipClose = useCallback(() => { + setShowToolTip(false) + async function updateUserPreference() { + try { + const _userPreferenceJson = await storage.get(NEW_CHAIN_TOOLTIP_STORAGE_KEY) + const _userPreference = JSON.parse(_userPreferenceJson) + storage.set( + NEW_CHAIN_TOOLTIP_STORAGE_KEY, + JSON.stringify({ ..._userPreference, [version]: false }), + ) + } catch (_) { + // + } + } + updateUserPreference() + }, [setShowToolTip, version, storage]) + + return { showToolTip, toolTipData, handleToolTipClose } +} diff --git a/apps/extension/src/hooks/useWalletClient.ts b/apps/extension/src/hooks/useWalletClient.ts index 441553b0..3ed7f7c5 100644 --- a/apps/extension/src/hooks/useWalletClient.ts +++ b/apps/extension/src/hooks/useWalletClient.ts @@ -9,12 +9,13 @@ import useActiveWallet from 'hooks/settings/useActiveWallet' import { Wallet } from 'hooks/wallet/useWallet' import { useCallback, useMemo } from 'react' -export const useWalletClient = () => { +export const useWalletClient = (forceChain?: SupportedChain) => { const { activeWallet } = useActiveWallet() const getWallet = Wallet.useGetWallet() - const activeChain = useActiveChain() const { chains } = useChainsStore() + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) const isLedgerTypeWallet = activeWallet?.walletType === WALLETTYPE.LEDGER const signDirect: SignDirectMethod = useCallback( diff --git a/apps/extension/src/hooks/useWalletInfo.ts b/apps/extension/src/hooks/useWalletInfo.ts new file mode 100644 index 00000000..b58265b2 --- /dev/null +++ b/apps/extension/src/hooks/useWalletInfo.ts @@ -0,0 +1,36 @@ +import { useActiveWallet, WALLETTYPE } from '@leapwallet/cosmos-wallet-hooks' +import { LEDGER_NAME_EDITED_SUFFIX_REGEX } from 'config/config' +import { walletLabels } from 'config/constants' +import { Images } from 'images' +import { useMemo } from 'react' +import { formatWalletName } from 'utils/formatWalletName' +import { isCompassWallet } from 'utils/isCompassWallet' + +export function useWalletInfo() { + const activeWallet = useActiveWallet() + + const walletAvatar = useMemo(() => { + if (activeWallet?.avatar) { + return activeWallet.avatar + } + + if (isCompassWallet()) { + return Images.Logos.CompassCircle + } + + return Images.Logos.LeapLogo28 + }, [activeWallet?.avatar]) + + const walletName = useMemo(() => { + if ( + activeWallet?.walletType === WALLETTYPE.LEDGER && + !LEDGER_NAME_EDITED_SUFFIX_REGEX.test(activeWallet?.name) + ) { + return `${walletLabels[activeWallet?.walletType]} Wallet ${activeWallet?.addressIndex + 1}` + } + + return formatWalletName(activeWallet?.name ?? '') + }, [activeWallet?.addressIndex, activeWallet?.name, activeWallet?.walletType]) + + return { walletAvatar, walletName, activeWallet } +} diff --git a/apps/extension/src/hooks/utility/index.ts b/apps/extension/src/hooks/utility/index.ts new file mode 100644 index 00000000..4be3e9a5 --- /dev/null +++ b/apps/extension/src/hooks/utility/index.ts @@ -0,0 +1,2 @@ +export * from './useChainPageInfo' +export * from './useDefaultTokenLogo' diff --git a/apps/extension/src/hooks/utility/useChainPageInfo.tsx b/apps/extension/src/hooks/utility/useChainPageInfo.tsx new file mode 100644 index 00000000..e432a675 --- /dev/null +++ b/apps/extension/src/hooks/utility/useChainPageInfo.tsx @@ -0,0 +1,53 @@ +import { useActiveChain, useGetChains } from '@leapwallet/cosmos-wallet-hooks' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { Images } from 'images' +import { useMemo } from 'react' +import { Colors } from 'theme/colors' +import { AggregatedSupportedChain } from 'types/utility' +import { isCompassWallet } from 'utils/isCompassWallet' + +import { useDefaultTokenLogo } from './index' + +export function useChainPageInfo() { + const chains = useGetChains() + const activeChain = useActiveChain() as AggregatedSupportedChain + const defaultTokenLogo = useDefaultTokenLogo() + + const headerChainImgSrc = useMemo(() => { + if (activeChain === AGGREGATED_CHAIN_KEY) { + return Images.Misc.AggregatedViewSvg + } + + return chains[activeChain]?.chainSymbolImageUrl ?? defaultTokenLogo + }, [activeChain, chains, defaultTokenLogo]) + + const gradientChainColor = useMemo(() => { + if (activeChain === AGGREGATED_CHAIN_KEY) { + return Colors.aggregateGradient + } + + if (isCompassWallet()) { + return Colors.compassGradient + } + + return chains[activeChain]?.theme?.gradient + }, [activeChain, chains]) + + const topChainColor = useMemo(() => { + if (activeChain === AGGREGATED_CHAIN_KEY) { + return Colors.aggregatePrimary + } + + if (isCompassWallet()) { + return Colors.compassPrimary + } + + return Colors.getChainColor(activeChain, chains[activeChain]) + }, [activeChain, chains]) + + return { + headerChainImgSrc, + gradientChainColor, + topChainColor, + } +} diff --git a/apps/extension/src/hooks/utility/useThemeColor.tsx b/apps/extension/src/hooks/utility/useThemeColor.tsx index 0a27f495..0f94bba0 100644 --- a/apps/extension/src/hooks/utility/useThemeColor.tsx +++ b/apps/extension/src/hooks/utility/useThemeColor.tsx @@ -1,13 +1,12 @@ -import { useActiveChain } from 'hooks/settings/useActiveChain' -import { useChainInfos } from 'hooks/useChainInfos' +import { useActiveChain, useChainInfo } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { useMemo } from 'react' import { Colors } from 'theme/colors' -export const useThemeColor = () => { - const chainInfos = useChainInfos() - const activeChain = useActiveChain() - - const chainInfo = useMemo(() => chainInfos[activeChain], [activeChain, chainInfos]) +export const useThemeColor = (forceChain?: SupportedChain) => { + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [forceChain, _activeChain]) + const chainInfo = useChainInfo(activeChain) return Colors.getChainColor(activeChain, chainInfo) } diff --git a/apps/extension/src/hooks/wallet/useWallet.ts b/apps/extension/src/hooks/wallet/useWallet.ts index a15bf66f..28e7d609 100644 --- a/apps/extension/src/hooks/wallet/useWallet.ts +++ b/apps/extension/src/hooks/wallet/useWallet.ts @@ -1,5 +1,11 @@ import { AccountData, DirectSecp256k1HdWallet, OfflineSigner } from '@cosmjs/proto-signing' -import { Key, useChainsStore, WALLETTYPE } from '@leapwallet/cosmos-wallet-hooks' +import { + FEATURE_FLAG_STORAGE_KEY, + Key, + useChainsStore, + useFeatureFlags, + WALLETTYPE, +} from '@leapwallet/cosmos-wallet-hooks' import { ChainInfos, generateWalletFromMnemonic, @@ -11,7 +17,7 @@ import { import getHDPath from '@leapwallet/cosmos-wallet-sdk/dist/browser/utils/get-hdpath' import { KeyChain } from '@leapwallet/leap-keychain' import { encrypt } from '@leapwallet/leap-keychain' -import { LEDGER_DISABLED_COINTYPES } from 'config/config' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' import { ACTIVE_CHAIN, ACTIVE_WALLET, @@ -44,15 +50,21 @@ export namespace Wallet { export type Keystore = Record export async function storeWallets(newWallets: Record): Promise { - const data = await browser.storage.local.get([KEYSTORE]) + const data = await browser.storage.local.get([KEYSTORE, FEATURE_FLAG_STORAGE_KEY]) const keystore: Keystore[] = data[KEYSTORE] ?? {} const newKeystore = { ...keystore, ...newWallets } const newWalletEntries = Object.keys(newWallets) const lastEntry = newWalletEntries[0] + const featureFlags = JSON.parse(data[FEATURE_FLAG_STORAGE_KEY] ?? '{}') + const leapFallbackChain = + featureFlags?.give_all_chains_option_in_wallet?.extension === 'active' + ? AGGREGATED_CHAIN_KEY + : ChainInfos.cosmos.key + return await browser.storage.local.set({ [KEYSTORE]: newKeystore, [ACTIVE_WALLET]: newWallets[lastEntry], - [ACTIVE_CHAIN]: isCompassWallet() ? ChainInfos.seiTestnet2.key : ChainInfos.cosmos.key, + [ACTIVE_CHAIN]: isCompassWallet() ? ChainInfos.seiTestnet2.key : leapFallbackChain, }) } @@ -80,8 +92,14 @@ export namespace Wallet { export function useRemoveWallet() { const { activeWallet, setActiveWallet } = useActiveWallet() const auth = useAuth() + const { data: featureFlags } = useFeatureFlags() const removeAll = async (signout = true) => { + const leapFallbackChain = + featureFlags?.give_all_chains_option_in_wallet?.extension === 'active' + ? AGGREGATED_CHAIN_KEY + : ChainInfos.cosmos.key + await browser.storage.local.set({ [KEYSTORE]: null, [ACTIVE_WALLET]: null, @@ -89,7 +107,7 @@ export namespace Wallet { [ENCRYPTED_ACTIVE_WALLET]: null, [CONNECTIONS]: null, [BETA_CHAINS]: null, - [ACTIVE_CHAIN]: isCompassWallet() ? ChainInfos.seiTestnet2.key : ChainInfos.cosmos.key, + [ACTIVE_CHAIN]: isCompassWallet() ? ChainInfos.seiTestnet2.key : leapFallbackChain, [NETWORK_MAP]: null, [SELECTED_NETWORK]: 'mainnet', }) @@ -445,7 +463,7 @@ export namespace Wallet { password: password as string, pubKeys, }) - setActiveWallet(wallets[0]) + setActiveWallet(Object.values(wallets)[0]) return wallets }, @@ -455,9 +473,10 @@ export namespace Wallet { ) } - export function useGetWallet() { + export function useGetWallet(forceChain?: SupportedChain) { const chainInfos = useChainInfos() - const activeChain = useActiveChain() + const _activeChain = useActiveChain() + const activeChain = forceChain || _activeChain const { activeWallet } = useActiveWallet() const password = usePassword() return useCallback( @@ -469,9 +488,9 @@ export namespace Wallet { const prefix = chainInfos[_chain].addressPrefix if ( activeWallet?.walletType === WALLETTYPE.LEDGER && - isLedgerEnabled(_chain, chainInfos[_chain].bip44.coinType) + isLedgerEnabled(_chain, chainInfos[_chain]?.bip44?.coinType) ) { - if (chainInfos[_chain].bip44.coinType === '60') { + if (chainInfos[_chain]?.bip44?.coinType === '60') { const hdPaths = [`m/44'/60'/0'/0/${activeWallet.addressIndex}`] const ledgerTransport = await getLedgerTransport() return new LeapLedgerSignerEth(ledgerTransport, { hdPaths, prefix }) @@ -489,7 +508,7 @@ export namespace Wallet { const walletId = activeWallet?.id const signer = await KeyChain.getSigner(walletId as string, password as string, { addressPrefix: chainInfos[_chain].addressPrefix, - coinType: chainInfos[_chain].bip44.coinType, + coinType: chainInfos[_chain]?.bip44?.coinType, ethWallet, pubKeyBech32Address: ethWallet, }) diff --git a/apps/extension/src/images/activity/error.svg b/apps/extension/src/images/activity/error.svg index f1e4a534..a1c00c02 100644 --- a/apps/extension/src/images/activity/error.svg +++ b/apps/extension/src/images/activity/error.svg @@ -1,4 +1,5 @@ - - - - + + + + + \ No newline at end of file diff --git a/apps/extension/src/images/activity/send-details.svg b/apps/extension/src/images/activity/send-details.svg index c10f266d..1c56af70 100644 --- a/apps/extension/src/images/activity/send-details.svg +++ b/apps/extension/src/images/activity/send-details.svg @@ -1,4 +1,4 @@ - - - - + + + + \ No newline at end of file diff --git a/apps/extension/src/images/countries/ARS.png b/apps/extension/src/images/countries/ARS.png new file mode 100644 index 00000000..fde1c83e Binary files /dev/null and b/apps/extension/src/images/countries/ARS.png differ diff --git a/apps/extension/src/images/countries/AUD.png b/apps/extension/src/images/countries/AUD.png new file mode 100644 index 00000000..4890feff Binary files /dev/null and b/apps/extension/src/images/countries/AUD.png differ diff --git a/apps/extension/src/images/countries/BRL.png b/apps/extension/src/images/countries/BRL.png new file mode 100644 index 00000000..3c799314 Binary files /dev/null and b/apps/extension/src/images/countries/BRL.png differ diff --git a/apps/extension/src/images/countries/CAD.png b/apps/extension/src/images/countries/CAD.png new file mode 100644 index 00000000..d4492dd0 Binary files /dev/null and b/apps/extension/src/images/countries/CAD.png differ diff --git a/apps/extension/src/images/countries/CHF.png b/apps/extension/src/images/countries/CHF.png new file mode 100644 index 00000000..1c4ac7c5 Binary files /dev/null and b/apps/extension/src/images/countries/CHF.png differ diff --git a/apps/extension/src/images/countries/CLP.png b/apps/extension/src/images/countries/CLP.png new file mode 100644 index 00000000..6bc9dc59 Binary files /dev/null and b/apps/extension/src/images/countries/CLP.png differ diff --git a/apps/extension/src/images/countries/COP.png b/apps/extension/src/images/countries/COP.png new file mode 100644 index 00000000..84aebb94 Binary files /dev/null and b/apps/extension/src/images/countries/COP.png differ diff --git a/apps/extension/src/images/countries/CRC.png b/apps/extension/src/images/countries/CRC.png new file mode 100644 index 00000000..c3eb7263 Binary files /dev/null and b/apps/extension/src/images/countries/CRC.png differ diff --git a/apps/extension/src/images/countries/DKK.png b/apps/extension/src/images/countries/DKK.png new file mode 100644 index 00000000..c16e84a1 Binary files /dev/null and b/apps/extension/src/images/countries/DKK.png differ diff --git a/apps/extension/src/images/countries/EUR.png b/apps/extension/src/images/countries/EUR.png new file mode 100644 index 00000000..27656076 Binary files /dev/null and b/apps/extension/src/images/countries/EUR.png differ diff --git a/apps/extension/src/images/countries/GBP.png b/apps/extension/src/images/countries/GBP.png new file mode 100644 index 00000000..f2dc8d32 Binary files /dev/null and b/apps/extension/src/images/countries/GBP.png differ diff --git a/apps/extension/src/images/countries/INR.png b/apps/extension/src/images/countries/INR.png new file mode 100644 index 00000000..06113dcc Binary files /dev/null and b/apps/extension/src/images/countries/INR.png differ diff --git a/apps/extension/src/images/countries/JPY.png b/apps/extension/src/images/countries/JPY.png new file mode 100644 index 00000000..5f8b7403 Binary files /dev/null and b/apps/extension/src/images/countries/JPY.png differ diff --git a/apps/extension/src/images/countries/KRW.png b/apps/extension/src/images/countries/KRW.png new file mode 100644 index 00000000..2c0bd072 Binary files /dev/null and b/apps/extension/src/images/countries/KRW.png differ diff --git a/apps/extension/src/images/countries/MXN.png b/apps/extension/src/images/countries/MXN.png new file mode 100644 index 00000000..a08d4d3e Binary files /dev/null and b/apps/extension/src/images/countries/MXN.png differ diff --git a/apps/extension/src/images/countries/NOK.png b/apps/extension/src/images/countries/NOK.png new file mode 100644 index 00000000..ee1ca9ab Binary files /dev/null and b/apps/extension/src/images/countries/NOK.png differ diff --git a/apps/extension/src/images/countries/NZD.png b/apps/extension/src/images/countries/NZD.png new file mode 100644 index 00000000..aedc9da2 Binary files /dev/null and b/apps/extension/src/images/countries/NZD.png differ diff --git a/apps/extension/src/images/countries/PEN.png b/apps/extension/src/images/countries/PEN.png new file mode 100644 index 00000000..a865fd69 Binary files /dev/null and b/apps/extension/src/images/countries/PEN.png differ diff --git a/apps/extension/src/images/countries/PHP.png b/apps/extension/src/images/countries/PHP.png new file mode 100644 index 00000000..edd354e8 Binary files /dev/null and b/apps/extension/src/images/countries/PHP.png differ diff --git a/apps/extension/src/images/countries/PLN.png b/apps/extension/src/images/countries/PLN.png new file mode 100644 index 00000000..d77af5b7 Binary files /dev/null and b/apps/extension/src/images/countries/PLN.png differ diff --git a/apps/extension/src/images/countries/SEK.png b/apps/extension/src/images/countries/SEK.png new file mode 100644 index 00000000..35e0d892 Binary files /dev/null and b/apps/extension/src/images/countries/SEK.png differ diff --git a/apps/extension/src/images/countries/SGD.png b/apps/extension/src/images/countries/SGD.png new file mode 100644 index 00000000..36d103c9 Binary files /dev/null and b/apps/extension/src/images/countries/SGD.png differ diff --git a/apps/extension/src/images/countries/TRY.png b/apps/extension/src/images/countries/TRY.png new file mode 100644 index 00000000..8878668e Binary files /dev/null and b/apps/extension/src/images/countries/TRY.png differ diff --git a/apps/extension/src/images/countries/TWD.png b/apps/extension/src/images/countries/TWD.png new file mode 100644 index 00000000..92e69b06 Binary files /dev/null and b/apps/extension/src/images/countries/TWD.png differ diff --git a/apps/extension/src/images/countries/USD.png b/apps/extension/src/images/countries/USD.png new file mode 100644 index 00000000..8dbbe348 Binary files /dev/null and b/apps/extension/src/images/countries/USD.png differ diff --git a/apps/extension/src/images/countries/UYU.png b/apps/extension/src/images/countries/UYU.png new file mode 100644 index 00000000..244c36b3 Binary files /dev/null and b/apps/extension/src/images/countries/UYU.png differ diff --git a/apps/extension/src/images/countries/VND.png b/apps/extension/src/images/countries/VND.png new file mode 100644 index 00000000..c4d104ab Binary files /dev/null and b/apps/extension/src/images/countries/VND.png differ diff --git a/apps/extension/src/images/countries/index.ts b/apps/extension/src/images/countries/index.ts new file mode 100644 index 00000000..651ee8a6 --- /dev/null +++ b/apps/extension/src/images/countries/index.ts @@ -0,0 +1,57 @@ +import ARS from './ARS.png' +import AUD from './AUD.png' +import BRL from './BRL.png' +import CAD from './CAD.png' +import CHF from './CHF.png' +import CLP from './CLP.png' +import COP from './COP.png' +import CRC from './CRC.png' +import DKK from './DKK.png' +import EUR from './EUR.png' +import GBP from './GBP.png' +import INR from './INR.png' +import JPY from './JPY.png' +import KRW from './KRW.png' +import MXN from './MXN.png' +import NOK from './NOK.png' +import NZD from './NZD.png' +import PEN from './PEN.png' +import PHP from './PHP.png' +import PLN from './PLN.png' +import SEK from './SEK.png' +import SGD from './SGD.png' +import TRY from './TRY.png' +import TWD from './TWD.png' +import USD from './USD.png' +import UYU from './UYU.png' +import VND from './VND.png' + +export { + ARS, + AUD, + BRL, + CAD, + CHF, + CLP, + COP, + CRC, + DKK, + EUR, + GBP, + INR, + JPY, + KRW, + MXN, + NOK, + NZD, + PEN, + PHP, + PLN, + SEK, + SGD, + TRY, + TWD, + USD, + UYU, + VND, +} diff --git a/apps/extension/src/images/index.ts b/apps/extension/src/images/index.ts index c9a820c2..b3443f49 100644 --- a/apps/extension/src/images/index.ts +++ b/apps/extension/src/images/index.ts @@ -1,6 +1,7 @@ import * as activity from './activity' import * as airdrop from './airdrop' import * as banners from './banners' +import * as countries from './countries' import * as gov from './gov' import * as loaders from './loaders' import * as logos from './logos' @@ -13,6 +14,7 @@ import * as swap from './swap' export namespace Images { export const Activity = activity export const Airdrop = airdrop + export const Countries = countries export const Misc = misc export const Nav = nav export const Loaders = loaders diff --git a/apps/extension/src/images/logos/index.ts b/apps/extension/src/images/logos/index.ts index e2bb944b..194b676d 100644 --- a/apps/extension/src/images/logos/index.ts +++ b/apps/extension/src/images/logos/index.ts @@ -111,6 +111,7 @@ const ChainLogos: Record = { odin: ChainInfos.odin.chainSymbolImageUrl, saga: ChainInfos.saga.chainSymbolImageUrl, initia: ChainInfos.initia.chainSymbolImageUrl, + humans: ChainInfos.humans.chainSymbolImageUrl, } export const getChainImage = (name: string) => { diff --git a/apps/extension/src/images/misc/FilledDownArrowSvg.tsx b/apps/extension/src/images/misc/FilledDownArrowSvg.tsx new file mode 100644 index 00000000..4c1fac11 --- /dev/null +++ b/apps/extension/src/images/misc/FilledDownArrowSvg.tsx @@ -0,0 +1,17 @@ +import React from 'react' + +const FilledDownArrowSvg = React.memo((props: React.SVGProps) => ( + + + +)) + +FilledDownArrowSvg.displayName = 'DownArrowSvg' +export { FilledDownArrowSvg } diff --git a/apps/extension/src/images/misc/OutlineRoundGreenCheckSvg.tsx b/apps/extension/src/images/misc/OutlineRoundGreenCheckSvg.tsx new file mode 100644 index 00000000..a40d50da --- /dev/null +++ b/apps/extension/src/images/misc/OutlineRoundGreenCheckSvg.tsx @@ -0,0 +1,40 @@ +import React from 'react' + +const OutlinRoundGreenCheckSvg = React.memo((props: React.SVGProps) => ( + + + + + + + + + + + + + + + +)) + +OutlinRoundGreenCheckSvg.displayName = 'DownArrowSvg' +export { OutlinRoundGreenCheckSvg } diff --git a/apps/extension/src/images/misc/RightArrowSvg.tsx b/apps/extension/src/images/misc/RightArrowSvg.tsx new file mode 100644 index 00000000..0801d0de --- /dev/null +++ b/apps/extension/src/images/misc/RightArrowSvg.tsx @@ -0,0 +1,17 @@ +import React from 'react' + +const RightArrowSvg = React.memo((props: React.SVGProps) => ( + + + +)) + +RightArrowSvg.displayName = 'DownArrowSvg' +export { RightArrowSvg } diff --git a/apps/extension/src/images/misc/aggregated-view.svg b/apps/extension/src/images/misc/aggregated-view.svg new file mode 100644 index 00000000..688c4484 --- /dev/null +++ b/apps/extension/src/images/misc/aggregated-view.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/extension/src/images/misc/down-gray-200-arrow.svg b/apps/extension/src/images/misc/down-gray-200-arrow.svg new file mode 100644 index 00000000..3a5ba3cf --- /dev/null +++ b/apps/extension/src/images/misc/down-gray-200-arrow.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/extension/src/images/misc/gear-white.svg b/apps/extension/src/images/misc/gear-white.svg new file mode 100644 index 00000000..7b17dc2b --- /dev/null +++ b/apps/extension/src/images/misc/gear-white.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/extension/src/images/misc/ibc-protocal.tsx b/apps/extension/src/images/misc/ibc-protocal.tsx new file mode 100644 index 00000000..bd9b1fde --- /dev/null +++ b/apps/extension/src/images/misc/ibc-protocal.tsx @@ -0,0 +1,14 @@ +import * as React from 'react' + +const IBCProtocol = ({ color }: { color: string }) => ( + + + +) + +export default IBCProtocol diff --git a/apps/extension/src/images/misc/ibc-protocol.svg b/apps/extension/src/images/misc/ibc-protocol.svg deleted file mode 100644 index cbf0385b..00000000 --- a/apps/extension/src/images/misc/ibc-protocol.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/apps/extension/src/images/misc/index.ts b/apps/extension/src/images/misc/index.ts index 7c76a6ef..3cdf452c 100644 --- a/apps/extension/src/images/misc/index.ts +++ b/apps/extension/src/images/misc/index.ts @@ -4,6 +4,7 @@ import { isCompassWallet } from 'utils/isCompassWallet' import Add from './add.svg' import AddCircle from './add-circle.svg' import AddContact from './add-contact.svg' +import AggregatedViewSvg from './aggregated-view.svg' import ArrowBack from './arrow-back.svg' import ArrowDown from './arrow-down.svg' import Blockchain from './blockchain.svg' @@ -43,6 +44,7 @@ import Delete from './delete.svg' import DeleteRed from './delete-red.svg' import DeleteTokenSheetBin from './delete-token-sheet-bin.svg' import DownArrow from './down-arrow.svg' +import DownGray200Arrow from './down-gray-200-arrow.svg' import dropUpDarkModeIcon from './drop-up-dark-mode.svg' import dropUpLightModeIcon from './drop-up-light-mode.svg' import EditItems from './edit-items.svg' @@ -55,11 +57,13 @@ import FilledFavStar from './filled-fav-star.svg' import FilledKey from './filled-key.svg' import FilledPen from './filled-pen.svg' import FilledRoundedSquareCheckMark from './filled-rounded-square-check-mark.svg' +import { FilledDownArrowSvg } from './FilledDownArrowSvg' import FlashOn from './flash-on.svg' import FrogHappy from './frog-happy.svg' import FrogPanic from './frog-panic.svg' import FrogSad from './frog-sad.svg' import Gear from './gear.svg' +import GearWhiteIcon from './gear-white.svg' import Globe from './globe.svg' import GreenTick from './green-tick.svg' import GreyCross from './grey-cross.svg' @@ -70,7 +74,7 @@ import HelpIcon from './help.svg' import HelpOutline from './help-outline.svg' import HideNft from './hide-nft.svg' import IBC from './ibc.svg' -import IbcProtocol from './ibc-protocol.svg' +import IbcProtocol from './ibc-protocal' import IbcUnion from './ibc-union.svg' import IconRight from './icon-right-gray-400.svg' import Info from './info.svg' @@ -101,6 +105,7 @@ import NotAllowed from './not-allowed.svg' import OnboardingFrog from './onboarding-frog.svg' import OpenLink from './open-link.svg' import OutlinedFavStar from './outlined-fav-start.svg' +import { OutlinRoundGreenCheckSvg } from './OutlineRoundGreenCheckSvg' import Pin from './pin.svg' import PinToExtension from './pin-to-extension.svg' import PkWallet from './pk-wallet.svg' @@ -109,9 +114,10 @@ import RadioButtonUnchecked from './radio-button-unchecked.svg' import RemoveCircle from './remove-circle.svg' import RightArrow from './right-arrow.svg' import RightArrowCollapsed from './right-arrow-collapsed.svg' +import { RightArrowSvg } from './RightArrowSvg' import Search from './search.svg' -import SearchIcon from './search-gray-400-icon.svg' import SearchModalGlass from './search-modal-glass.svg' +import SearchWhiteIcon from './search-white-icon.svg' import Sell from './sell.svg' import Settings from './settings.svg' import SideNavIcon from './side-nav-icon.svg' @@ -121,7 +127,9 @@ import SwapVert from './swap-vert.svg' import TextSnippet from './text-snippet.svg' import Tick from './tick.svg' import Timer from './timer.svg' +import TuneIcon from './tune.svg' import UnhideNft from './unhide-nft.svg' +import UpArrow from './up-arrow.svg' import Validator from './validator.svg' import VerifiedWithBgStar from './verified.png' import Verified from './verified.svg' @@ -138,6 +146,7 @@ import Wallet5 from './wallet-5.svg' import WalletIconGreen from './wallet-green.svg' import WalletIcon2 from './wallet-icon.svg' import WalletIcon from './wallet-sample.svg' +import WalletIconTeal from './wallet-teal.svg' import WalletIconWhite from './wallet-white.svg' import Warning from './warning.svg' @@ -173,6 +182,7 @@ export { Add, AddCircle, AddContact, + AggregatedViewSvg, ArrowBack, ArrowDown, Blockchain, @@ -209,6 +219,7 @@ export { DeleteRed, DeleteTokenSheetBin, DownArrow, + DownGray200Arrow, dropUpDarkModeIcon, dropUpLightModeIcon, EditItems, @@ -216,6 +227,7 @@ export { ExpandContent, Explore, FilledArrowDown, + FilledDownArrowSvg, FilledExclamationMark, FilledFavStar, FilledKey, @@ -226,6 +238,7 @@ export { FrogPanic, FrogSad, Gear, + GearWhiteIcon, Globe, GreenTick, GreyCross, @@ -267,6 +280,7 @@ export { OnboardingFrog, OpenLink, OutlinedFavStar, + OutlinRoundGreenCheckSvg, Pin, PinToExtension, PkWallet, @@ -275,9 +289,10 @@ export { RemoveCircle, RightArrow, RightArrowCollapsed, + RightArrowSvg, Search, - SearchIcon, SearchModalGlass, + SearchWhiteIcon, Sell, Settings, SideNavIcon, @@ -287,7 +302,9 @@ export { TextSnippet, Tick, Timer, + TuneIcon, UnhideNft, + UpArrow, Validator, Verified, VerifiedWithBgStar, @@ -298,6 +315,7 @@ export { WalletIcon, WalletIcon2, WalletIconGreen, + WalletIconTeal, WalletIconWhite, Warning, } diff --git a/apps/extension/src/images/misc/search-gray-400-icon.svg b/apps/extension/src/images/misc/search-white-icon.svg similarity index 96% rename from apps/extension/src/images/misc/search-gray-400-icon.svg rename to apps/extension/src/images/misc/search-white-icon.svg index 3aaaabbe..165e5c38 100644 --- a/apps/extension/src/images/misc/search-gray-400-icon.svg +++ b/apps/extension/src/images/misc/search-white-icon.svg @@ -1,3 +1,3 @@ - + diff --git a/apps/extension/src/images/misc/tune.svg b/apps/extension/src/images/misc/tune.svg new file mode 100644 index 00000000..10da7bc3 --- /dev/null +++ b/apps/extension/src/images/misc/tune.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/extension/src/images/misc/up-arrow.svg b/apps/extension/src/images/misc/up-arrow.svg new file mode 100644 index 00000000..f70b6d29 --- /dev/null +++ b/apps/extension/src/images/misc/up-arrow.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/extension/src/images/misc/verified-dark.png b/apps/extension/src/images/misc/verified-dark.png index b5b6a812..ee8c7cff 100644 Binary files a/apps/extension/src/images/misc/verified-dark.png and b/apps/extension/src/images/misc/verified-dark.png differ diff --git a/apps/extension/src/images/misc/wallet-teal.svg b/apps/extension/src/images/misc/wallet-teal.svg new file mode 100644 index 00000000..a893d978 --- /dev/null +++ b/apps/extension/src/images/misc/wallet-teal.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/extension/src/pages/ApproveConnection/ApproveConnection.tsx b/apps/extension/src/pages/ApproveConnection/ApproveConnection.tsx index 8f162767..17358ec9 100644 --- a/apps/extension/src/pages/ApproveConnection/ApproveConnection.tsx +++ b/apps/extension/src/pages/ApproveConnection/ApproveConnection.tsx @@ -1,19 +1,22 @@ -import { Key } from '@leapwallet/cosmos-wallet-hooks' +import { Key, sliceAddress, useActiveWallet, useChainsStore } from '@leapwallet/cosmos-wallet-hooks' import { LineType } from '@leapwallet/cosmos-wallet-provider/dist/provider/types' import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { Buttons } from '@leapwallet/leap-ui' +import classNames from 'classnames' +import { Divider } from 'components/dapp' +import { Header } from 'components/header' import Loader from 'components/loader/Loader' -import { SelectWallets } from 'components/SelectWallets' import Text from 'components/text' import { ACTIVE_WALLET, BG_RESPONSE, CONNECTIONS } from 'config/storage-keys' import { checkChainConnections, decodeChainIdToChain } from 'extension-scripts/utils' +import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' import { useWindowSize } from 'hooks/utility/useWindowSize' import { Images } from 'images' -import React, { useCallback, useEffect, useState } from 'react' +import React, { useCallback, useEffect, useMemo, useState } from 'react' import { Colors } from 'theme/colors' +import { isCompassWallet } from 'utils/isCompassWallet' import browser from 'webextension-polyfill' -import { Header } from '../../components/header' import { addToConnections } from './utils' type WebsiteProps = { @@ -59,7 +62,7 @@ function closeWindow() { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -async function sendMessage(message: { type: string; payload: any }) { +async function sendMessage(message: { type: string; payload: any; status: 'success' | 'failed' }) { try { await browser.runtime.sendMessage(message) } catch (e) { @@ -72,24 +75,49 @@ const ApproveConnection = () => { const { width } = useWindowSize() - const [requestedChains, setRequestedChains] = useState([]) + const [requestedChains, setRequestedChains] = useState< + Array<{ chain: SupportedChain; payloadId: string }> + >([]) + + const [readMoreEnabled, setReadMoreEnabled] = useState(false) const [showApprovalUi, setShowApprovalUi] = useState(false) // eslint-disable-next-line @typescript-eslint/no-explicit-any const [approvalRequests, setApprovalRequests] = useState>([]) + const activeWallet = useActiveWallet() + const { chains } = useChainsStore() + const defaultTokenLogo = useDefaultTokenLogo() + + const displayedRequestedChains = useMemo(() => { + if (isCompassWallet()) { + return [{ chain: 'seiTestnet2' as SupportedChain, payloadId: '123' }] + } else { + const uniqueChainRequests = requestedChains.reduce( + (acc: Array<{ chain: SupportedChain; payloadId: string }>, element) => { + const existingRequest = acc.find((request) => request.chain === element.chain) + if (!existingRequest) { + acc.push(element) + return acc + } + return acc + }, + [], + ) + return uniqueChainRequests + } + }, [requestedChains]) const handleCancel = useCallback(async () => { - for (const currentApprovalRequest of approvalRequests) { - if (!currentApprovalRequest) { - closeWindow() - return - } + if (!approvalRequests[0]) { + closeWindow() + return + } + for (const currentApprovalRequest of approvalRequests) { const chainsIds = currentApprovalRequest?.validChainIds ?? [ currentApprovalRequest?.[0]?.chainId, ] - - browser.runtime.sendMessage({ + await sendMessage({ type: 'chain-approval-rejected', payload: { origin, @@ -97,13 +125,19 @@ const ApproveConnection = () => { payloadId: currentApprovalRequest.payloadId, ecosystem: currentApprovalRequest.ecosystem, }, + status: 'failed', }) } - window.removeEventListener('beforeunload', handleCancel) closeWindow() }, [approvalRequests]) + useEffect(() => { + if (activeWallet) { + setSelectedWallets([activeWallet]) + } + }, [activeWallet]) + useEffect(() => { window.addEventListener('beforeunload', handleCancel) browser.storage.local.remove(BG_RESPONSE) @@ -138,14 +172,17 @@ const ApproveConnection = () => { chainIds, connections, { origin: message.payload.origin }, - storedActiveWallet, + storedActiveWallet.id, ) if (isNewChainPresent) { setApprovalRequests((prev) => [...prev, message.payload]) const _chainIdToChain = await decodeChainIdToChain() const chain = _chainIdToChain[chainIds[0]] - setRequestedChains((prev) => [...prev, chain as unknown as SupportedChain]) + setRequestedChains((prev) => [ + ...prev, + { chain: chain as unknown as SupportedChain, payloadId: message.payload.payloadId }, + ]) setShowApprovalUi(true) } else { await browser.runtime.sendMessage({ @@ -157,8 +194,9 @@ const ApproveConnection = () => { ecosystem: message.payload.ecosystem, ethMethod: message.payload.ethMethod, }, + status: 'success', }) - // closeWindow() + closeWindow() } } } @@ -172,29 +210,28 @@ const ApproveConnection = () => { }, []) const handleApproveConnection = async () => { - const currentApprovalRequest = approvalRequests?.[0] - const chainsIds: string[] | undefined = currentApprovalRequest - ? currentApprovalRequest?.validChainIds ?? [currentApprovalRequest[0]?.chainId] - : undefined - if (!chainsIds) return + for await (const currentApprovalRequest of approvalRequests) { + const chainsIds: string[] | undefined = currentApprovalRequest + ? currentApprovalRequest?.validChainIds ?? [currentApprovalRequest[0]?.chainId] + : undefined + if (!chainsIds) return + const selectedWalletIds = selectedWallets.map((wallet) => wallet.id) - await addToConnections(chainsIds, selectedWallets, currentApprovalRequest.origin) - await sendMessage({ - type: 'chain-enabled', - payload: { - origin, - chainsIds, - payloadId: currentApprovalRequest.payloadId, - ecosystem: currentApprovalRequest.ecosystem, - ethMethod: currentApprovalRequest.ethMethod, - }, - }) - setApprovalRequests((prev) => prev.slice(1)) - setRequestedChains((prev) => prev.slice(1)) - if (approvalRequests.length === 1) { - window.removeEventListener('beforeunload', handleCancel) - closeWindow() + await addToConnections(chainsIds, selectedWalletIds, currentApprovalRequest.origin) + await sendMessage({ + type: 'chain-enabled', + payload: { + origin, + chainsIds, + payloadId: currentApprovalRequest.payloadId, + ecosystem: currentApprovalRequest.ecosystem, + ethMethod: currentApprovalRequest.ethMethod, + }, + status: 'success', + }) } + window.removeEventListener('beforeunload', handleCancel) + closeWindow() } const isFullScreen = width && width > 800 @@ -210,51 +247,118 @@ const ApproveConnection = () => { } return ( -
-
+
+
( )} SubTitleComponent={() => } /> - -
1, + 'h-[100px]': displayedRequestedChains.length <= 1, + })} > - - This app will be able to - - - - View your wallet balance and activity - - - - Request approval for transactions. - +
setReadMoreEnabled(false)} + > + + {`Connecting ${activeWallet?.name}`} + {displayedRequestedChains?.length > 1 && readMoreEnabled ? ( + + keyboard_arrow_up + + ) : null} +
+
1, + 'h-[16px] mb-4': requestedChains.length <= 1, + })} + > + {displayedRequestedChains.map((requestedChain, index: number) => { + const isLast = index === displayedRequestedChains.length - 1 + return ( + +
1, + })} + style={{ + display: index <= 2 || readMoreEnabled ? 'flex' : 'none', + }} + > + + + {chains[requestedChain.chain].chainName} + + + {sliceAddress(selectedWallets?.[0]?.addresses[requestedChain.chain])} + +
+
+ {!isLast ? Divider : null} +
+
+ ) + })} +
+ {!readMoreEnabled && displayedRequestedChains.length > 3 ? ( + + ) : null} +
-
+ {!readMoreEnabled ? ( +
+ + This app will be able to + + + + View your wallet balance and activity + + + + Request approval for transactions. + - - This app won't be able to - - - - Move funds without your permission - -
+
+ + + This app won't be able to + + + + Move funds without your permission + +
+ ) : null}
{ +export const addToConnections = async (chainIds: string[], walletIds: string[], origin: string) => { let { connections = {} } = await browser.storage.local.get(CONNECTIONS) if (connections === null) { connections = {} } chainIds.forEach((chainId: string) => { - wallets.forEach((wallet: Key) => { - const sites: [string] = connections?.[wallet.id]?.[chainId] || [] + walletIds.forEach((walletId: string) => { + const sites: [string] = connections?.[walletId]?.[chainId] || [] if (!sites.includes(origin)) { sites.push(origin) } - connections[wallet.id] = { - ...connections?.[wallet.id], + connections[walletId] = { + ...connections?.[walletId], [chainId]: [...sites], } }) diff --git a/apps/extension/src/pages/activity/Activity.tsx b/apps/extension/src/pages/activity/Activity.tsx index 6db0d16b..e6e29591 100644 --- a/apps/extension/src/pages/activity/Activity.tsx +++ b/apps/extension/src/pages/activity/Activity.tsx @@ -1,20 +1,30 @@ -import { useIsFeatureExistForChain } from '@leapwallet/cosmos-wallet-hooks' +import { useActiveChain, useIsFeatureExistForChain } from '@leapwallet/cosmos-wallet-hooks' import { BottomNavLabel } from 'components/bottom-nav/BottomNav' import { ComingSoon } from 'components/coming-soon' +import { PageName } from 'config/analytics' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { usePageView } from 'hooks/analytics/usePageView' import React from 'react' +import { AggregatedSupportedChain } from 'types/utility' -import { ActivityLandingPage } from './ActivityLandingPage' +import { AggregatedActivity, ChainActivity } from './components' export default function Activity() { + usePageView(PageName.Activity) + const activeChain = useActiveChain() as AggregatedSupportedChain const isActivityComingSoon = useIsFeatureExistForChain({ checkForExistenceType: 'comingSoon', feature: 'activity', platform: 'Extension', }) + if (activeChain === AGGREGATED_CHAIN_KEY) { + return + } + if (isActivityComingSoon) { return } - return + return } diff --git a/apps/extension/src/pages/activity/ActivityLandingPage.tsx b/apps/extension/src/pages/activity/ActivityLandingPage.tsx deleted file mode 100644 index 283dc357..00000000 --- a/apps/extension/src/pages/activity/ActivityLandingPage.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import { ActivityCardContent, useActivity } from '@leapwallet/cosmos-wallet-hooks' -import { Header, HeaderActionType } from '@leapwallet/leap-ui' -import type { ParsedTransaction } from '@leapwallet/parser-parfait' -import { QueryStatus } from '@tanstack/react-query' -import SelectedChainAlertStrip from 'components/alert-strip/SelectedChainAlertStrip' -import BottomNav, { BottomNavLabel } from 'components/bottom-nav/BottomNav' -import PopupLayout from 'components/layout/popup-layout' -import { PageName } from 'config/analytics' -import { usePageView } from 'hooks/analytics/usePageView' -import { usePerformanceMonitor } from 'hooks/perf-monitoring/usePerformanceMonitor' -import { useActiveChain } from 'hooks/settings/useActiveChain' -import { useChainInfos } from 'hooks/useChainInfos' -import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' -import { useThemeColor } from 'hooks/utility/useThemeColor' -import SelectChain from 'pages/home/SelectChain' -import SideNav from 'pages/home/side-nav' -import React, { useMemo, useState } from 'react' - -import { ActivityList } from './ActivityList' -import TxDetails from './TxDetails' - -export type SelectedTx = { - parsedTx: ParsedTransaction - content: ActivityCardContent -} - -export function ActivityLandingPage() { - usePageView(PageName.Activity) - - const chainInfos = useChainInfos() - const [showSideNav, setShowSideNav] = useState(false) - const [showChainSelector, setShowChainSelector] = useState(false) - const [selectedTx, setSelectedTx] = useState(null) - - const defaultTokenLogo = useDefaultTokenLogo() - const activeChain = useActiveChain() - const { txResponse } = useActivity() - const themeColor = useThemeColor() - - const queryStatus = useMemo(() => { - let status = txResponse.loading ? 'loading' : 'success' - status = txResponse.error ? 'error' : status - - return status - }, [txResponse.error, txResponse.loading]) - - usePerformanceMonitor({ - page: 'activity', - queryStatus: queryStatus as QueryStatus, - op: 'activityPageLoad', - description: 'loading state on activity page', - }) - - return ( -
- {selectedTx ? ( - setSelectedTx(null)} - /> - ) : ( - <> - setShowChainSelector(true)} - title={'Activity'} - topColor={themeColor} - /> - } - > - setShowSideNav(!showSideNav)} /> - - - -
- -
-
- setShowChainSelector(false)} /> - - - )} -
- ) -} diff --git a/apps/extension/src/pages/activity/ActivityList.tsx b/apps/extension/src/pages/activity/ActivityList.tsx deleted file mode 100644 index b7e7b4b3..00000000 --- a/apps/extension/src/pages/activity/ActivityList.tsx +++ /dev/null @@ -1,170 +0,0 @@ -import { - ActivityCardContent, - TxResponse, - useActiveChain, - useGetExplorerAccountUrl, -} from '@leapwallet/cosmos-wallet-hooks' -import { CardDivider } from '@leapwallet/leap-ui' -import type { ParsedTransaction } from '@leapwallet/parser-parfait' -import { EmptyCard } from 'components/empty-card' -import { SearchInput } from 'components/search-input' -import dayjs from 'dayjs' -import { Images } from 'images' -import React, { useMemo, useState } from 'react' -import { Colors } from 'theme/colors' -import { sliceSearchWord } from 'utils/strings' - -import TokenCardSkeleton from '../../components/Skeletons/TokenCardSkeleton' -import { ActivityCard } from './ActivityCard' -import { SelectedTx } from './ActivityLandingPage' - -export type ActivityListProps = { - txResponse: TxResponse - setSelectedTx: React.Dispatch> -} - -export function ActivityList({ txResponse, setSelectedTx }: ActivityListProps) { - const activeChain = useActiveChain() - - const { activity } = txResponse - const [assetFilter, setAssetFilter] = useState('') - const { explorerAccountUrl } = useGetExplorerAccountUrl({}) - - const handleFilterChange = (event: React.FormEvent) => { - setAssetFilter(event.currentTarget.value.toLowerCase()) - } - - const sections = useMemo(() => { - const txsByDate = activity - ?.filter((tx) => { - return tx.content.title1.toLowerCase().includes(assetFilter) - }) - .reduce( - ( - acc: Record, - tx, - ) => { - if (!tx.parsedTx) return acc - - const date = dayjs(tx.parsedTx.timestamp).format('MMMM DD') - if (acc[date]) { - acc[date].push(tx) - } else { - acc = { ...acc, [date]: [tx] } - } - return acc - }, - {}, - ) - return Object.entries(txsByDate ?? {}).map((entry) => ({ title: entry[0], data: entry[1] })) - }, [activity, assetFilter]) - - if (activity?.length === 0 && !txResponse.loading) { - return ( -
- - - {explorerAccountUrl ? ( - - Check on Explorer - - ) : null} -
- ) - } - - if (txResponse.error) { - return ( -
- - - {explorerAccountUrl ? ( - - Check on Explorer - - ) : null} -
- ) - } - - return ( -
- setAssetFilter('')} - inputDisabled={txResponse.loading} - /> - -
- {txResponse.loading && ( -
- - -
- )} - - {!txResponse.loading && sections.length === 0 && ( - - )} - - {!txResponse.loading && - sections.map(({ data, title }, index) => { - return ( -
-
- {title} -
-
- {data.map((tx, index) => ( - - {index !== 0 && } - setSelectedTx(tx)} - isSuccessful={tx.parsedTx.code === 0} - /> - - ))} -
-
- ) - })} - - {!txResponse.loading && explorerAccountUrl ? ( - - Check more on Explorer - - ) : null} -
-
- ) -} diff --git a/apps/extension/src/pages/activity/PendingTx.tsx b/apps/extension/src/pages/activity/PendingTx.tsx index 8d3cffc6..1edbc5a0 100644 --- a/apps/extension/src/pages/activity/PendingTx.tsx +++ b/apps/extension/src/pages/activity/PendingTx.tsx @@ -8,23 +8,25 @@ import { MobileAppBanner, sliceAddress, useActiveChain, + useAddress, + useChainId, useGetExplorerTxnUrl, useInvalidateActivity, useInvalidateDelegations, useInvalidateTokenBalances, useMobileAppBanner, usePendingTxState, + useSelectedNetwork, } from '@leapwallet/cosmos-wallet-hooks' -import { Buttons, GenericCard, Header } from '@leapwallet/leap-ui' +import { Buttons, Header, ThemeName, useTheme } from '@leapwallet/leap-ui' import BigNumber from 'bignumber.js' import classnames from 'classnames' -import { InfoCard } from 'components/info-card' import PopupLayout from 'components/layout/popup-layout' import { LoaderAnimation } from 'components/loader/Loader' import { useHideAssets } from 'hooks/settings/useHideAssets' import { Images } from 'images' import { Cross } from 'images/misc' -import React, { useEffect, useRef, useState } from 'react' +import React, { useEffect, useMemo, useRef, useState } from 'react' import { useNavigate } from 'react-router' import { TxResponse } from 'secretjs' import { Colors } from 'theme/colors' @@ -33,6 +35,18 @@ import { isCompassWallet } from 'utils/isCompassWallet' const PENDING_TX_MOBILE_QR_CODE_BANNER = 'pending-tx-mobile-qr-code-banner' +const txStatusStyles = { + loading: { + title: 'In Progress...', + }, + success: { + title: 'Complete', + }, + failed: { + title: 'Failed', + }, +} + function MobileQrCode({ setShowMobileQrCode, data, @@ -56,25 +70,52 @@ function MobileQrCode({ } export default function PendingTx() { - const activeChain = useActiveChain() const navigate = useNavigate() const [txHash, setTxHash] = useState('') const [showMobileQrCode, setShowMobileQrCode] = useState( sessionStorage.getItem(PENDING_TX_MOBILE_QR_CODE_BANNER) ? false : true, ) - + const { theme } = useTheme() const copyTxHashRef = useRef(null) const { pendingTx, setPendingTx } = usePendingTxState() const txPostToDB = LeapWalletApi.useOperateCosmosTx() + const invalidateBalances = useInvalidateTokenBalances() const invalidateDelegations = useInvalidateDelegations() const invalidateActivity = useInvalidateActivity() + const { + txType, + title1, + subtitle1, + sentTokenInfo, + sentAmount, + receivedAmount, + sentUsdValue, + receivedTokenInfo, + txStatus, + txHash: _txHash, + sourceChain, + sourceNetwork, + } = pendingTx ?? {} + + const _activeChain = useActiveChain() + const activeChain = useMemo(() => sourceChain || _activeChain, [_activeChain, sourceChain]) + + const _selectedNetwork = useSelectedNetwork() + const selectedNetwork = useMemo( + () => sourceNetwork || _selectedNetwork, + [_selectedNetwork, sourceNetwork], + ) + + const activeChainId = useChainId(activeChain, selectedNetwork) + const address = useAddress(activeChain) + useEffect(() => { const invalidateQueries = () => { invalidateBalances(activeChain) invalidateDelegations() - invalidateActivity() + invalidateActivity(activeChain) } if (pendingTx && pendingTx.promise) { @@ -111,6 +152,10 @@ export default function PendingTx() { feeQuantity, feeDenomination: 'uscrt', amount: pendingTx.txnLogAmount, + forceChain: activeChain, + forceNetwork: selectedNetwork, + forceWalletAddress: address, + chainId: activeChainId, }) } @@ -129,40 +174,25 @@ export default function PendingTx() { feeQuantity: pendingTx.feeQuantity, feeDenomination: pendingTx.feeDenomination, amount: pendingTx.txnLogAmount, + forceChain: activeChain, + forceNetwork: selectedNetwork, + forceWalletAddress: address, + chainId: activeChainId, }) } - setTimeout(() => { - invalidateQueries() - }, 2000) + invalidateQueries() }) .catch(() => { if (pendingTx.txType === 'cw20TokenTransfer') { setPendingTx({ ...pendingTx, txStatus: 'failed' }) } - setTimeout(() => { - invalidateQueries() - }, 2000) + invalidateQueries() }) } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [txPostToDB]) - - const { - txType, - title1, - subtitle1, - sentTokenInfo, - sentAmount, - receivedAmount, - sentUsdValue, - receivedTokenInfo, - txStatus, - txHash: _txHash, - isEvmTx, - } = pendingTx ?? {} + }, [activeChain, address, selectedNetwork, activeChainId]) useEffect(() => { if (_txHash) setTxHash(_txHash) @@ -183,53 +213,54 @@ export default function PendingTx() { const balanceIncreased = txType === 'undelegate' || txType === 'receive' || txType === 'liquidity/remove' - const { explorerTxnUrl: txnUrl } = useGetExplorerTxnUrl({ forceTxHash: txHash }) - const txStatusStyles = { - loading: { - topColor: '#696969', - title: 'Processing...', - }, - success: { - topColor: '#29A874', - title: 'Success', - }, - failed: { - topColor: '#D10014', - title: 'Failed', - }, - } + const { explorerTxnUrl: txnUrl } = useGetExplorerTxnUrl({ + forceTxHash: txHash, + forceChain: activeChain, + }) - const handleCloseClick = () => { - navigate('/home') - } + const isSendTxn = txType + ? ['ibc/transfer', 'send', 'secretTokenTransfer', 'cw20TokenTransfer'].includes(txType) + : false return ( -
-
-
-
- {txStatus === 'loading' && } - {txStatus === 'success' && ( - - )} - {txStatus === 'failed' && } +
+
+
+ {txStatus === 'loading' && ( + + )} + {txStatus === 'success' && ( + + )} + {txStatus === 'failed' && } -
- {title1} +
+ {title1} +
+ {isSendTxn ? ( +
+ {txStatus === 'success' + ? 'sent successfully to' + : txStatus === 'failed' + ? 'failed sending to' + : 'sending to'} +
+ ) : null} + {isSendTxn ? ( +
+
+ account_circle +
+ {subtitle1}
-
+ ) : ( +
{subtitle1}
+ )} + {!isSendTxn ? (
{txType === 'swap' ? ( <> @@ -267,67 +298,94 @@ export default function PendingTx() { )}
-
+ ) : null} +
- {txHash && ( -
- } - subtitle={sliceAddress(txHash)} + {txHash && ( +
{ + copyTxHashRef.current?.click() + UserClipboard.copyText(txHash) + setIsCopiedClick(true) + setTimeout(() => setIsCopiedClick(false), 2000) + }} + > +
+
+ Transaction ID +
+
+ {sliceAddress(txHash)} +
+
+ + + + {!isCopiedClick && ( + { copyTxHashRef.current?.click() UserClipboard.copyText(txHash) setIsCopiedClick(true) setTimeout(() => setIsCopiedClick(false), 2000) }} - size='md' - icon={ - <> - - - {txnUrl && !isCopiedClick ? ( - { - event.stopPropagation() - window.open(txnUrl, '_blank') - }} - > - open_in_new - - ) : null} - - } - /> -
- )} - - {!isCompassWallet() && - showMobileQrCode && - status === 'success' && - data && - data.visible ? ( - - ) : null} - - {isCompassWallet() && - title1?.toLowerCase().includes('sent nft') && - isEvmTx && - txStatus === 'success' ? ( - - ) : null} + > + content_copy + + )} - - Done + {txnUrl && !isCopiedClick ? ( + { + event.stopPropagation() + window.open(txnUrl, '_blank') + }} + > + open_in_new + + ) : null} +
+ )} + + {!isCompassWallet() && showMobileQrCode && status === 'success' && data && data.visible ? ( + + ) : null} + +
+ navigate('/home')} + > +

Home

+ {isSendTxn && !title1?.toLowerCase()?.includes('nft') ? ( + + navigate( + `/send?assetCoinDenom=${ + sentTokenInfo?.ibcDenom || sentTokenInfo?.coinMinimalDenom + }`, + { replace: true }, + ) + } + disabled={txStatus !== 'success'} + > + Send Again + + ) : null}
diff --git a/apps/extension/src/pages/activity/ActivityCard.tsx b/apps/extension/src/pages/activity/components/ActivityCard.tsx similarity index 84% rename from apps/extension/src/pages/activity/ActivityCard.tsx rename to apps/extension/src/pages/activity/components/ActivityCard.tsx index c25dfc0c..faf8fd38 100644 --- a/apps/extension/src/pages/activity/ActivityCard.tsx +++ b/apps/extension/src/pages/activity/components/ActivityCard.tsx @@ -1,12 +1,13 @@ import { ActivityCardContent } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { default as classNames } from 'classnames' +import { useActivityImage } from 'hooks/activity/useActivityImage' import { useHideAssets } from 'hooks/settings/useHideAssets' import { Images } from 'images' import React from 'react' +import { formatTokenAmount } from 'utils/strings' -import { useActivityImage } from '../../hooks/activity/useActivityImage' -import { formatTokenAmount } from '../../utils/strings' -import { ActivityIcon } from './ActivityIcon' +import { ActivityIcon } from './index' export type ActivityCardProps = { content: ActivityCardContent @@ -14,6 +15,9 @@ export type ActivityCardProps = { onClick?: () => void isSuccessful: boolean containerClassNames?: string + forceChain?: SupportedChain + titleClassName?: string + imgSize?: 'sm' | 'md' | 'lg' } export function ActivityCard({ @@ -22,6 +26,9 @@ export function ActivityCard({ showLoader, isSuccessful, containerClassNames, + forceChain, + titleClassName, + imgSize, }: ActivityCardProps) { const { txType, @@ -36,7 +43,7 @@ export function ActivityCard({ receivedTokenInfo, } = content - const defaultImg = useActivityImage(txType) + const defaultImg = useActivityImage(txType, forceChain) const img = customImage || defaultImg const { formatHideBalance } = useHideAssets() @@ -68,9 +75,15 @@ export function ActivityCard({ secondaryImg={secondaryImg} type={txType} isSuccessful={isSuccessful} + size={imgSize} />
-
+
{title1}
{subtitle1}
@@ -112,7 +125,8 @@ export function ActivityCard({ )}
- + + {onClick ? : null}
) diff --git a/apps/extension/src/pages/activity/ActivityIcon.tsx b/apps/extension/src/pages/activity/components/ActivityIcon.tsx similarity index 84% rename from apps/extension/src/pages/activity/ActivityIcon.tsx rename to apps/extension/src/pages/activity/components/ActivityIcon.tsx index 1a8063f4..036802a3 100644 --- a/apps/extension/src/pages/activity/ActivityIcon.tsx +++ b/apps/extension/src/pages/activity/components/ActivityIcon.tsx @@ -1,9 +1,9 @@ import { ActivityType } from '@leapwallet/cosmos-wallet-hooks' -import classnames from 'classnames' +import classNames from 'classnames' import { Images } from 'images' import React from 'react' -import { LoaderAnimation } from '../../components/loader/Loader' +import { LoaderAnimation } from '../../../components/loader/Loader' export type ActivityIconProps = { img?: string @@ -11,7 +11,7 @@ export type ActivityIconProps = { type: ActivityType showLoader?: boolean voteOption?: string - size?: 'md' | 'lg' + size?: 'sm' | 'md' | 'lg' isSuccessful: boolean } @@ -70,38 +70,45 @@ export function ActivityIcon({ const icon = getActivityActionTypeIcon(type, voteOption) return (
+ {secondaryImg && ( )} + {showLoader && (
)} + {!secondaryImg && !showLoader && ( )}
diff --git a/apps/extension/src/pages/activity/components/AggregatedActivity.tsx b/apps/extension/src/pages/activity/components/AggregatedActivity.tsx new file mode 100644 index 00000000..4567ee57 --- /dev/null +++ b/apps/extension/src/pages/activity/components/AggregatedActivity.tsx @@ -0,0 +1,39 @@ +import { useAggregatedActivity, useGetChains } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import React, { useMemo, useState } from 'react' + +import { AggregatedActivityNullComponents, GeneralActivity } from './index' + +const AggregatedActivity = React.memo(() => { + const { perChainActivity } = useAggregatedActivity() + const chains = useGetChains() + const [selectedChain, setSelectedChain] = useState(chains.cosmos.key) + + const { txResponse } = useMemo( + () => perChainActivity?.[selectedChain] ?? {}, + [perChainActivity, selectedChain], + ) + + const filteredChains = useMemo(() => { + return ((Object.keys(perChainActivity ?? {}) ?? []) as SupportedChain[]).map( + (chainKey) => chains[chainKey].chainRegistryPath, + ) + }, [chains, perChainActivity]) + + return ( + <> + + + + + ) +}) + +AggregatedActivity.displayName = 'AggregatedActivity' +export { AggregatedActivity } diff --git a/apps/extension/src/pages/activity/components/AggregatedActivityNullComponents.tsx b/apps/extension/src/pages/activity/components/AggregatedActivityNullComponents.tsx new file mode 100644 index 00000000..ad86aef6 --- /dev/null +++ b/apps/extension/src/pages/activity/components/AggregatedActivityNullComponents.tsx @@ -0,0 +1,38 @@ +import { + AggregatedActivity, + useAggregatedActivityStore, + useFillAggregatedActivity, +} from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { AggregatedNullComponents } from 'components/aggregated' +import React from 'react' + +type FetchChainActivityProps = { + chain: SupportedChain + setAggregatedActivity: (aggregatedActivity: AggregatedActivity) => void +} + +const FetchChainActivity = React.memo(function ({ + chain, + setAggregatedActivity, +}: FetchChainActivityProps) { + useFillAggregatedActivity(chain, setAggregatedActivity) + return <> +}) + +FetchChainActivity.displayName = 'FetchChainActivity' + +export const AggregatedActivityNullComponents = React.memo(function () { + const { setAggregatedActivity } = useAggregatedActivityStore() + + return ( + ( + + )} + /> + ) +}) + +AggregatedActivityNullComponents.displayName = 'AggregatedActivityNullComponents' diff --git a/apps/extension/src/pages/activity/components/ChainActivity.tsx b/apps/extension/src/pages/activity/components/ChainActivity.tsx new file mode 100644 index 00000000..b3db5eca --- /dev/null +++ b/apps/extension/src/pages/activity/components/ChainActivity.tsx @@ -0,0 +1,35 @@ +import { ActivityCardContent, useActivity } from '@leapwallet/cosmos-wallet-hooks' +import type { ParsedTransaction } from '@leapwallet/parser-parfait' +import { QueryStatus } from '@tanstack/react-query' +import { usePerformanceMonitor } from 'hooks/perf-monitoring/usePerformanceMonitor' +import React, { useMemo } from 'react' + +import { GeneralActivity } from './index' + +export type SelectedTx = { + parsedTx: ParsedTransaction + content: ActivityCardContent +} + +const ChainActivity = React.memo(() => { + const { txResponse } = useActivity() + + const queryStatus = useMemo(() => { + let status = txResponse.loading ? 'loading' : 'success' + status = txResponse.error ? 'error' : status + + return status + }, [txResponse.error, txResponse.loading]) + + usePerformanceMonitor({ + page: 'activity', + queryStatus: queryStatus as QueryStatus, + op: 'activityPageLoad', + description: 'loading state on activity page', + }) + + return +}) + +ChainActivity.displayName = 'ChainActivity' +export { ChainActivity } diff --git a/apps/extension/src/pages/activity/components/ErrorActivityView.tsx b/apps/extension/src/pages/activity/components/ErrorActivityView.tsx new file mode 100644 index 00000000..940afe85 --- /dev/null +++ b/apps/extension/src/pages/activity/components/ErrorActivityView.tsx @@ -0,0 +1,33 @@ +import { useGetChains } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { EmptyCard } from 'components/empty-card' +import { Images } from 'images' +import React from 'react' +import { Colors } from 'theme/colors' + +type ErrorActivityViewProps = { + accountExplorerLink: string + chain: SupportedChain +} + +export function ErrorActivityView({ accountExplorerLink, chain }: ErrorActivityViewProps) { + const chains = useGetChains() + + return ( +
+ + + {accountExplorerLink ? ( + + Check on Explorer + + ) : null} +
+ ) +} diff --git a/apps/extension/src/pages/activity/components/GeneralActivity.tsx b/apps/extension/src/pages/activity/components/GeneralActivity.tsx new file mode 100644 index 00000000..3e558c3c --- /dev/null +++ b/apps/extension/src/pages/activity/components/GeneralActivity.tsx @@ -0,0 +1,273 @@ +import { + removeTrailingSlash, + TxResponse, + useActiveChain, + useAddress, + useGetChains, + useSelectedNetwork, +} from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { AggregatedLoading } from 'components/aggregated' +import BottomNav, { BottomNavLabel } from 'components/bottom-nav/BottomNav' +import { PageHeader } from 'components/header' +import PopupLayout from 'components/layout/popup-layout' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { useChainPageInfo } from 'hooks' +import { SelectedNetwork } from 'hooks/settings/useNetwork' +import { Images } from 'images' +import SelectChain from 'pages/home/SelectChain' +import SideNav from 'pages/home/side-nav' +import React, { useCallback, useMemo, useState } from 'react' +import { Colors } from 'theme/colors' +import { HeaderActionType } from 'types/components' +import { AggregatedSupportedChain } from 'types/utility' + +import { reduceActivityInSections } from '../utils' +import { SelectedTx } from './ChainActivity' +import { + ActivityCard, + AggregatedActivityNullComponents, + ErrorActivityView, + NoActivityView, + SelectAggregatedActivityChain, + TxDetails, +} from './index' + +type GeneralActivityProps = { + txResponse: TxResponse + filteredChains?: string[] + forceChain?: SupportedChain + forceNetwork?: SelectedNetwork + setSelectedChain?: React.Dispatch> +} + +const GeneralActivity = React.memo( + ({ + txResponse, + filteredChains, + forceChain, + forceNetwork, + setSelectedChain, + }: GeneralActivityProps) => { + /** + * Custom hooks + */ + const chains = useGetChains() + const activeChain = useActiveChain() as AggregatedSupportedChain + const [showActivityChainSelector, setShowActivityChainSelector] = useState(false) + const _activeNetwork = useSelectedNetwork() + const { headerChainImgSrc } = useChainPageInfo() + + const selectedChain = useMemo(() => { + if (activeChain !== AGGREGATED_CHAIN_KEY) { + return activeChain + } + + return forceChain ?? chains.cosmos.key + }, [activeChain, forceChain, chains.cosmos.key]) + const address = useAddress(selectedChain) + + /** + * Local states + */ + const [showSideNav, setShowSideNav] = useState(false) + const [showChainSelector, setShowChainSelector] = useState(false) + const [selectedTx, setSelectedTx] = useState(null) + + /** + * Memoized values + */ + const { activity } = useMemo(() => txResponse ?? {}, [txResponse]) + const activeNetwork = useMemo( + () => forceNetwork || _activeNetwork, + [_activeNetwork, forceNetwork], + ) + + const accountExplorerLink = useMemo(() => { + if (chains[selectedChain]?.txExplorer?.[activeNetwork]?.accountUrl) { + return `${removeTrailingSlash( + chains[selectedChain]?.txExplorer?.[activeNetwork]?.accountUrl ?? '', + )}/${address}` + } + + return '' + }, [activeNetwork, address, chains, selectedChain]) + + const sections = useMemo(() => { + const txsByDate = activity?.reduce(reduceActivityInSections, {}) + return Object.entries(txsByDate ?? {}).map((entry) => ({ title: entry[0], data: entry[1] })) + }, [activity]) + + const ShowView = useMemo(() => { + if (activity?.length === 0 && !txResponse?.loading) { + return ( +
+ +
+ ) + } + + if (txResponse?.error) { + return ( +
+ +
+ ) + } + + return ( + <> + {txResponse?.loading ? ( +
+ + +
+ ) : null} + + {!txResponse?.loading && + sections && + sections.map(({ data, title }, index) => { + return ( +
+
+ {title} +
+ +
+ {data.map((tx) => ( + + setSelectedTx(tx)} + /> + + ))} +
+
+ ) + })} + + {!txResponse?.loading && accountExplorerLink ? ( + + Check more on Explorer + + ) : null} + + ) + }, [ + accountExplorerLink, + activity?.length, + chains, + sections, + selectedChain, + txResponse?.error, + txResponse?.loading, + ]) + + /** + * Memoized functions + */ + + const onChainSelect = useCallback( + (chainName: SupportedChain) => { + setSelectedChain && setSelectedChain(chainName) + setShowActivityChainSelector(false) + }, + [setSelectedChain], + ) + + const handleOpenSelectChainSheet = useCallback(() => setShowChainSelector(true), []) + const handleOpenSideNavSheet = useCallback(() => setShowSideNav(true), []) + + /** + * Render + */ + + return ( +
+ + + {selectedTx ? ( + setSelectedTx(null)} + forceChain={selectedChain} + /> + ) : ( + <> + setShowSideNav(!showSideNav)} /> + + } + > +
+

+
+ Activity + + {chains[selectedChain]?.chainName ?? 'Unknown Chain'} + +
+ + {filteredChains?.length ? ( + + ) : null} +

+ + {ShowView} +
+
+ + {filteredChains?.length ? ( + setShowActivityChainSelector(false)} + onChainSelect={onChainSelect} + chainsToShow={filteredChains} + selectedChain={selectedChain} + /> + ) : null} + setShowChainSelector(false)} + /> + + + )} +
+ ) + }, +) + +GeneralActivity.displayName = 'GeneralActivity' +export { GeneralActivity } diff --git a/apps/extension/src/pages/activity/components/NoActivityView.tsx b/apps/extension/src/pages/activity/components/NoActivityView.tsx new file mode 100644 index 00000000..13618683 --- /dev/null +++ b/apps/extension/src/pages/activity/components/NoActivityView.tsx @@ -0,0 +1,37 @@ +import { useGetChains } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { EmptyCard } from 'components/empty-card' +import { Images } from 'images' +import React from 'react' +import { Colors } from 'theme/colors' + +type NoActivityViewProps = { + accountExplorerLink?: string + chain: SupportedChain +} + +export function NoActivityView({ accountExplorerLink, chain }: NoActivityViewProps) { + const chains = useGetChains() + + return ( +
+ + + {accountExplorerLink ? ( + + Check on Explorer + + ) : null} +
+ ) +} diff --git a/apps/extension/src/pages/activity/components/SelectAggregatedActivityChain.tsx b/apps/extension/src/pages/activity/components/SelectAggregatedActivityChain.tsx new file mode 100644 index 00000000..9c6031ad --- /dev/null +++ b/apps/extension/src/pages/activity/components/SelectAggregatedActivityChain.tsx @@ -0,0 +1,35 @@ +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import BottomModal from 'components/bottom-modal' +import { ListChains } from 'pages/home/SelectChain' +import React from 'react' + +type SelectAggregatedActivityChainProps = { + isVisible: boolean + onClose: () => void + chainsToShow: string[] + selectedChain: SupportedChain + onChainSelect: (chainName: SupportedChain) => void +} + +export function SelectAggregatedActivityChain({ + isVisible, + onClose, + chainsToShow, + selectedChain, + onChainSelect, +}: SelectAggregatedActivityChainProps) { + return ( + + + + ) +} diff --git a/apps/extension/src/pages/activity/TxDetails.tsx b/apps/extension/src/pages/activity/components/TxDetails.tsx similarity index 89% rename from apps/extension/src/pages/activity/TxDetails.tsx rename to apps/extension/src/pages/activity/components/TxDetails.tsx index 37d7dfe9..49e41089 100644 --- a/apps/extension/src/pages/activity/TxDetails.tsx +++ b/apps/extension/src/pages/activity/components/TxDetails.tsx @@ -1,28 +1,34 @@ -import { ActivityCardContent, useGetExplorerTxnUrl } from '@leapwallet/cosmos-wallet-hooks' +import { + ActivityCardContent, + useAddress, + useGetExplorerTxnUrl, +} from '@leapwallet/cosmos-wallet-hooks' import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' -import { Avatar, Buttons, Card, GenericCard, Header, HeaderActionType } from '@leapwallet/leap-ui' +import { Avatar, Buttons, Card, GenericCard } from '@leapwallet/leap-ui' import { parfait, ParsedMessageType, type ParsedTransaction } from '@leapwallet/parser-parfait' +import { PageHeader } from 'components/header' import PopupLayout from 'components/layout/popup-layout' import dayjs from 'dayjs' +import { getSwapImage, useActivityImage } from 'hooks/activity/useActivityImage' import { useActiveChain } from 'hooks/settings/useActiveChain' import { useSelectedNetwork } from 'hooks/settings/useNetwork' import { useChainInfos } from 'hooks/useChainInfos' -import { useAddress } from 'hooks/wallet/useAddress' import { Images } from 'images' -import React, { useEffect, useRef, useState } from 'react' +import React, { useEffect, useMemo, useRef, useState } from 'react' +import { Colors } from 'theme/colors' +import { HeaderActionType } from 'types/components' import { AddressBook } from 'utils/addressbook' import { UserClipboard } from 'utils/clipboard' import { isCompassWallet } from 'utils/isCompassWallet' import { formatTokenAmount, sliceAddress } from 'utils/strings' -import { getSwapImage, useActivityImage } from '../../hooks/activity/useActivityImage' -import { Colors } from '../../theme/colors' import { ActivityIcon } from './ActivityIcon' export type TxDetailsProps = { parsedTx: ParsedTransaction content: ActivityCardContent onBack: () => void + forceChain?: SupportedChain } export type ToExplorer = { @@ -67,13 +73,14 @@ const getActivityIconAndTitle = ( const emptyContact = { name: '', emoji: 0 } -function TxDetails({ parsedTx, content, onBack }: TxDetailsProps) { +export function TxDetails({ parsedTx, content, onBack, forceChain }: TxDetailsProps) { const chainInfos = useChainInfos() - const activeChain = useActiveChain() const selectedNetwork = useSelectedNetwork() const copyAddressRef = useRef(null) const copyTxHashRef = useRef(null) + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [forceChain, _activeChain]) const [contact, setContact] = useState<{ name: string; emoji: number }>(emptyContact) const { @@ -87,15 +94,15 @@ function TxDetails({ parsedTx, content, onBack }: TxDetailsProps) { img: customImage, } = content - const txnMessage = parsedTx.messages[0] - + const address = useAddress(activeChain) const defaultImg = useActivityImage(txType) + const txnMessage = parsedTx.messages[0] const img = customImage || defaultImg - const iconAndTitle = getActivityIconAndTitle(activeChain) const { icon, title } = iconAndTitle[txType] ?? iconAndTitle.fallback const date = dayjs(parsedTx.timestamp).format('D MMMM YYYY h:mm A') + const sentAmountInfo = sentAmount && sentTokenInfo?.coinDenom ? formatTokenAmount(sentAmount, sentTokenInfo.coinDenom) @@ -105,8 +112,6 @@ function TxDetails({ parsedTx, content, onBack }: TxDetailsProps) { ? formatTokenAmount(receivedAmount, receivedTokenInfo.coinDenom) : undefined - const address = useAddress() - useEffect(() => { if (txnMessage.__type === ParsedMessageType.BankSend) { const isReceive = address === txnMessage.toAddress @@ -133,18 +138,16 @@ function TxDetails({ parsedTx, content, onBack }: TxDetailsProps) { return ( -
+
-
+
{content.txType === 'vote' || content.txType === 'swap' ? ( {content.txType === 'vote' ? content.title1 : isTxSuccessful ? title : 'Fail'}
+ {content.txType === 'vote' && (
{content.subtitle1}
)} + {content.txType === 'swap' ? (

{content.title1}

@@ -203,9 +208,11 @@ function TxDetails({ parsedTx, content, onBack }: TxDetailsProps) { )}
)} + {/** Date */}
{date}
+ {/** Send, Receive and IBC */} {isSimpleTokenTransfer && (
@@ -224,8 +231,10 @@ function TxDetails({ parsedTx, content, onBack }: TxDetailsProps) { copyIcon={Images.Activity.Copy} ref={copyAddressRef} color={isCompassWallet() ? Colors.compassPrimary : Colors.green600} + className='dark:!bg-gray-950' /> } + className='dark:!bg-gray-950' /> ) : content.txType === 'receive' ? ( } + className='dark:!bg-gray-950' /> ) : ( content.txType === 'ibc/transfer' && @@ -271,8 +282,10 @@ function TxDetails({ parsedTx, content, onBack }: TxDetailsProps) { copyIcon={Images.Activity.Copy} ref={copyAddressRef} color={isCompassWallet() ? Colors.compassPrimary : Colors.green600} + className='dark:!bg-gray-950' /> } + className='dark:!bg-gray-950' /> ) })() @@ -295,18 +308,23 @@ function TxDetails({ parsedTx, content, onBack }: TxDetailsProps) { copyIcon={Images.Activity.Copy} ref={copyTxHashRef} color={isCompassWallet() ? Colors.compassPrimary : Colors.green600} + className='dark:!bg-gray-950' /> } + className='dark:!bg-gray-950' /> + {content.feeAmount && ( )}
+ {txnUrl && ( ) } - -export default TxDetails diff --git a/apps/extension/src/pages/activity/components/index.ts b/apps/extension/src/pages/activity/components/index.ts new file mode 100644 index 00000000..74e3d3cd --- /dev/null +++ b/apps/extension/src/pages/activity/components/index.ts @@ -0,0 +1,10 @@ +export * from './ActivityCard' +export * from './ActivityIcon' +export * from './AggregatedActivity' +export * from './AggregatedActivityNullComponents' +export * from './ChainActivity' +export * from './ErrorActivityView' +export * from './GeneralActivity' +export * from './NoActivityView' +export * from './SelectAggregatedActivityChain' +export * from './TxDetails' diff --git a/apps/extension/src/pages/activity/utils/index.ts b/apps/extension/src/pages/activity/utils/index.ts new file mode 100644 index 00000000..ff6d1a6c --- /dev/null +++ b/apps/extension/src/pages/activity/utils/index.ts @@ -0,0 +1 @@ +export * from './reduceActivityInSections' diff --git a/apps/extension/src/pages/activity/utils/reduceActivityInSections.ts b/apps/extension/src/pages/activity/utils/reduceActivityInSections.ts new file mode 100644 index 00000000..279160be --- /dev/null +++ b/apps/extension/src/pages/activity/utils/reduceActivityInSections.ts @@ -0,0 +1,19 @@ +import { Activity, ActivityCardContent } from '@leapwallet/cosmos-wallet-hooks' +import { ParsedTransaction } from '@leapwallet/parser-parfait' +import dayjs from 'dayjs' + +export function reduceActivityInSections( + acc: Record, + tx: Activity, +) { + if (!tx.parsedTx) return acc + + const date = dayjs(tx.parsedTx.timestamp).format('MMMM DD') + if (acc[date]) { + acc[date].push(tx) + } else { + acc = { ...acc, [date]: [tx] } + } + + return acc +} diff --git a/apps/extension/src/pages/add-token/AddToken.tsx b/apps/extension/src/pages/add-token/AddToken.tsx index d03b4336..b3c4d9bf 100644 --- a/apps/extension/src/pages/add-token/AddToken.tsx +++ b/apps/extension/src/pages/add-token/AddToken.tsx @@ -202,7 +202,9 @@ function AddTokenForm() { if (value) { if (name === 'coinMinimalDenom') { const _value = value.trim().toLowerCase() - if (Object.keys(combinedDenoms).includes(_value)) { + const combinedDenomsKey = Object.keys(combinedDenoms).map((key) => key.toLowerCase()) + + if (combinedDenomsKey.includes(_value)) { error = 'Token with same minimal denom already exists' } else if (!isSeiEvmChain && (_value.startsWith('erc20/') || isEthAddress(_value))) { error = "We don't support adding erc20 token yet." @@ -387,7 +389,6 @@ function AddTokenForm() { } export default function AddToken() { - const activeChain = useActiveChain() const navigate = useNavigate() return ( @@ -402,7 +403,6 @@ export default function AddToken() { }, type: HeaderActionType.BACK, }} - topColor={Colors.getChainColor(activeChain)} /> } > diff --git a/apps/extension/src/pages/airdrops/AirdropsDetails.tsx b/apps/extension/src/pages/airdrops/AirdropsDetails.tsx index d84134a2..40885c9f 100644 --- a/apps/extension/src/pages/airdrops/AirdropsDetails.tsx +++ b/apps/extension/src/pages/airdrops/AirdropsDetails.tsx @@ -1,20 +1,15 @@ -import { - AirdropEligibilityInfo, - useAirdropsEligibilityData, - useGetChains, -} from '@leapwallet/cosmos-wallet-hooks' +import { AirdropEligibilityInfo, useAirdropsEligibilityData } from '@leapwallet/cosmos-wallet-hooks' +import { PageHeader } from 'components/header' import PopupLayout from 'components/layout/popup-layout' import { PageName } from 'config/analytics' import { motion } from 'framer-motion' import { usePageView } from 'hooks/analytics/usePageView' -import { useActiveChain } from 'hooks/settings/useActiveChain' -import React, { useEffect, useState } from 'react' +import React, { useCallback, useEffect, useState } from 'react' import { useLocation, useNavigate } from 'react-router' -import { Colors } from 'theme/colors' +import { HeaderActionType } from 'types/components' import { trim } from 'utils/strings' import { AboutAirdropsSheet } from './components/about-airdrops-sheet' -import AirdropHeader, { HeaderActionType } from './components/AirdropHeader' import ClaimButton from './components/ClaimButton' import ClaimPeriod from './components/ClaimPeriod' import EligibleWallets from './components/EligibleWallets' @@ -22,10 +17,6 @@ import FailedAirdropsDetails from './components/FailedAirdropsDetails' import ImageWithDetails from './components/ImageWithDetails' export default function AirdropsDetails() { - const chains = useGetChains() - const activeChain = useActiveChain() - const activeChainInfo = chains[activeChain] - const themeColor = Colors.getChainColor(activeChain, activeChainInfo) const navigate = useNavigate() const airdropId = new URLSearchParams(useLocation().search).get('airdropId') const airdropsEligibilityData = useAirdropsEligibilityData() || {} @@ -54,18 +45,28 @@ export default function AirdropsDetails() { // eslint-disable-next-line react-hooks/exhaustive-deps }, []) + const handleShowAboutAirdropsSheet = useCallback(() => setshowAboutAirdrops(true), []) + return ( + info_outline +
+ } + onImgClick={handleShowAboutAirdropsSheet} action={{ onClick: () => navigate(-1), type: HeaderActionType.BACK, }} - onImgClick={() => setshowAboutAirdrops(true)} - title={trim(selectedAirdrop?.name, 18)} - topColor={themeColor} + dontShowFilledArrowIcon={true} /> } > diff --git a/apps/extension/src/pages/airdrops/components/AirdropHeader.tsx b/apps/extension/src/pages/airdrops/components/AirdropHeader.tsx deleted file mode 100644 index 104862ec..00000000 --- a/apps/extension/src/pages/airdrops/components/AirdropHeader.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { Buttons, LineDivider } from '@leapwallet/leap-ui' -import classNames from 'classnames' -import React, { ReactElement, ReactNode } from 'react' - -export enum HeaderActionType { - /** @see {@link Buttons.Back} */ - BACK = 'back', - /** @see {@link Buttons.Cancel} */ - CANCEL = 'cancel', - NAVIGATION = 'nav', -} - -export type HeaderAction = { - readonly type: HeaderActionType - readonly onClick: () => void - readonly 'data-testing-id'?: string - readonly className?: string -} - -type ActionButtonProps = HeaderAction - -function ActionButton({ type, onClick, ...rest }: ActionButtonProps): ReactElement { - let button: ReactElement | undefined - switch (type) { - case HeaderActionType.CANCEL: - button = - break - case HeaderActionType.BACK: - button = - break - case HeaderActionType.NAVIGATION: - button = - } - return button -} - -export type HeaderProps = { - readonly title: ReactNode - /** If `undefined`, no action button will display to the left of the {@link title}. */ - readonly action?: HeaderAction - readonly onImgClick?: () => void - readonly size?: 'sm' | 'normal' - /** color should be a hex value , ex : "#754F9C" */ - readonly topColor?: string - readonly 'data-testing-id'?: string -} - -export default function AirdropHeader(props: HeaderProps) { - const { title, action, size = 'normal', topColor, onImgClick } = props - - return ( -
-
-
{title}
-
-
- {action !== undefined && } -
-
-
- info_outline -
-
-
- -
-
-
- ) -} diff --git a/apps/extension/src/pages/airdrops/index.tsx b/apps/extension/src/pages/airdrops/index.tsx index a07a9104..ca68512a 100644 --- a/apps/extension/src/pages/airdrops/index.tsx +++ b/apps/extension/src/pages/airdrops/index.tsx @@ -1,45 +1,45 @@ -import { useGetChains } from '@leapwallet/cosmos-wallet-hooks' import BottomNav, { BottomNavLabel } from 'components/bottom-nav/BottomNav' +import { PageHeader } from 'components/header' import PopupLayout from 'components/layout/popup-layout' import { PageName } from 'config/analytics' import { motion } from 'framer-motion' import { usePageView } from 'hooks/analytics/usePageView' -import { useActiveChain } from 'hooks/settings/useActiveChain' import SideNav from 'pages/home/side-nav' -import React, { useState } from 'react' -import { Colors } from 'theme/colors' +import React, { useCallback, useState } from 'react' +import { HeaderActionType } from 'types/components' import AirdropsHome from './AirdropsHome' import { AboutAirdropsSheet } from './components/about-airdrops-sheet' -import AirdropHeader, { HeaderActionType } from './components/AirdropHeader' export default function Airdrops() { usePageView(PageName.Airdrops) - - const chains = useGetChains() - const activeChain = useActiveChain() - const activeChainInfo = chains[activeChain] - const themeColor = Colors.getChainColor(activeChain, activeChainInfo) - const [showSideNav, setShowSideNav] = useState(false) const [showAboutAirdrops, setshowAboutAirdrops] = useState(false) + const handleShowAboutAirdropsSheet = useCallback(() => setshowAboutAirdrops(true), []) + const handleOpenSideNavSheet = useCallback(() => setShowSideNav(true), []) + return ( + info_outline +
+ } + onImgClick={handleShowAboutAirdropsSheet} action={{ - onClick: function noRefCheck() { - setShowSideNav(true) - }, + onClick: handleOpenSideNavSheet, type: HeaderActionType.NAVIGATION, - className: - 'w-[48px] h-[40px] px-3 bg-[#FFFFFF] dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-full', + className: 'w-[48px] h-[40px] px-3 bg-[#FFFFFF] dark:bg-gray-950 rounded-full', }} - onImgClick={() => setshowAboutAirdrops(true)} - title={'Airdrops'} - topColor={themeColor} + dontShowFilledArrowIcon={true} /> } > diff --git a/apps/extension/src/pages/asset-details/components/chart-details/index.tsx b/apps/extension/src/pages/asset-details/components/chart-details/index.tsx index f967b0f2..3ec68a3a 100644 --- a/apps/extension/src/pages/asset-details/components/chart-details/index.tsx +++ b/apps/extension/src/pages/asset-details/components/chart-details/index.tsx @@ -10,7 +10,7 @@ import { useformatCurrency, useUserPreferredCurrency, } from '@leapwallet/cosmos-wallet-hooks' -import { SupportedChain, SupportedDenoms } from '@leapwallet/cosmos-wallet-sdk' +import { chainIdToChain, SupportedChain, SupportedDenoms } from '@leapwallet/cosmos-wallet-sdk' import { useSkipAssets } from '@leapwallet/elements-hooks' import { CardDivider, Header, HeaderActionType } from '@leapwallet/leap-ui' import { useQuery as useReactQuery } from '@tanstack/react-query' @@ -22,15 +22,18 @@ import ReadMoreText from 'components/read-more-text' import ReceiveToken from 'components/Receive' import { useHardCodedActions } from 'components/search-modal' import Text from 'components/text' -import { KADO_BUY_SUPPORT_CHAINS } from 'config/config' +import { PageName } from 'config/analytics' import { differenceInDays } from 'date-fns' +import { useChainPageInfo } from 'hooks' import useGetTopCGTokens from 'hooks/explore/useGetTopCGTokens' import { useActiveChain } from 'hooks/settings/useActiveChain' import { useChainInfos } from 'hooks/useChainInfos' +import { useDontShowSelectChain } from 'hooks/useDontShowSelectChain' +import { useKadoAssets } from 'hooks/useGetKadoDetails' import useQuery from 'hooks/useQuery' import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' import SelectChain from 'pages/home/SelectChain' -import React, { useMemo, useState } from 'react' +import React, { useEffect, useMemo, useState } from 'react' import Skeleton from 'react-loading-skeleton' import { useLocation, useNavigate } from 'react-router' import { Colors } from 'theme/colors' @@ -94,14 +97,21 @@ function TokenCTAs({ function TokensDetails() { const assetType = undefined const chainInfos = useChainInfos() - const activeChain = useActiveChain() + const _activeChain = useActiveChain() const assetsId = useQuery().get('assetName') ?? undefined const tokenChain = useQuery().get('tokenChain') ?? undefined - + const { data: kadoSupportedAssets = [] } = useKadoAssets() + const [isBuySupported, setIsBuySupported] = useState(false) const navigate = useNavigate() const { data: cgTokens = [] } = useGetTopCGTokens() const { data: featureFlags } = useFeatureFlags() + const state = useLocation().state + const portfolio: Token = state as Token + const activeChain = useMemo(() => { + return portfolio?.tokenBalanceOnChain ?? _activeChain + }, [_activeChain, portfolio?.tokenBalanceOnChain]) + const { headerChainImgSrc } = useChainPageInfo() const { data: skipAssets } = useSkipAssets((chainInfos?.[activeChain]?.chainId ?? '') as string, { includeCW20Assets: true, includeNoMetadataAssets: false, @@ -113,9 +123,6 @@ function TokensDetails() { } }, [assetType, assetsId, cgTokens]) - const state = useLocation().state - const portfolio: Token = state as Token - const skipSupportsToken = useMemo(() => { return ( skipAssets && @@ -132,7 +139,6 @@ function TokensDetails() { const [showReceiveSheet, setShowReceiveSheet] = useState(false) const [formatCurrency] = useformatCurrency() - const defaultTokenLogo = useDefaultTokenLogo() const { handleSwapClick } = useHardCodedActions() const { @@ -223,17 +229,28 @@ function TokensDetails() { } const portfolioPercentChange = portfolio?.percentChange ?? priceChange - const { chartData, minMax } = chartsData ?? { chartData: undefined, minMax: undefined } - const totalHoldingsInUsd = portfolio?.usdValue - const filteredChartDays = ChartDays - const displayChain = chainInfos[tokenChain as SupportedChain]?.chainName ?? tokenChain + const dontShowSelectChain = useDontShowSelectChain() const defaultIconLogo = useDefaultTokenLogo() + useEffect(() => { + if (kadoSupportedAssets.length > 0 && portfolio) { + const supportedAsset = kadoSupportedAssets.find( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (item: any) => + item.symbol === portfolio.symbol && + chainIdToChain[item.officialChainId] === portfolio.chain, + ) + if (supportedAsset) { + setIsBuySupported(true) + } + } + }, [portfolio, kadoSupportedAssets]) + return (
setShowChainSelector(true)} + imgSrc={headerChainImgSrc} + onImgClick={dontShowSelectChain ? undefined : () => setShowChainSelector(true)} title={Asset details} - topColor={Colors.getChainColor(activeChain)} /> } headerZIndex={showReceiveSheet ? 0 : 3} @@ -415,9 +431,9 @@ function TokensDetails() { { - window.open(`https://cosmos.leapwallet.io/transact/buy`, '_blank') + navigate(`/buy?pageSource=${PageName.AssetDetails}`, { state: portfolio }) }} - isBuyDisabled={!KADO_BUY_SUPPORT_CHAINS.includes(activeChain)} + isBuyDisabled={!isBuySupported} onSendClick={() => { navigate('/send', { state }) }} @@ -466,6 +482,7 @@ function TokensDetails() { { setShowReceiveSheet(false) }} diff --git a/apps/extension/src/pages/asset-details/index.tsx b/apps/extension/src/pages/asset-details/index.tsx index d21430a8..dd376ed9 100644 --- a/apps/extension/src/pages/asset-details/index.tsx +++ b/apps/extension/src/pages/asset-details/index.tsx @@ -113,7 +113,6 @@ export default function AssetDetails() { imgSrc={activeChainInfo.chainSymbolImageUrl ?? defaultTokenLogo} onImgClick={() => setShowChainSelector(true)} title={Asset details} - topColor={Colors.getChainColor(activeChain)} /> } headerZIndex={3} diff --git a/apps/extension/src/pages/auth/login.tsx b/apps/extension/src/pages/auth/login.tsx index 74fc96b0..9beebe62 100644 --- a/apps/extension/src/pages/auth/login.tsx +++ b/apps/extension/src/pages/auth/login.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/ban-ts-comment */ import { ENCRYPTED_ACTIVE_WALLET } from '@leapwallet/leap-keychain' import { Buttons, Input, ThemeName, useTheme } from '@leapwallet/leap-ui' import classNames from 'classnames' @@ -28,9 +29,11 @@ function LoginView(props: { onClick1: () => void loading: boolean unlockLoader: boolean + fullHeight?: boolean }) { const theme = useTheme() const isDark = theme.theme === ThemeName.DARK + if (props.loading) { return ( @@ -42,7 +45,7 @@ function LoginView(props: { } return ( - +
{ const handleCancel = async () => { const searchParams = new URLSearchParams(location.search) - if (searchParams.has('close-on-login')) { + //@ts-ignore + if ( + searchParams.has('close-on-login') || + //@ts-ignore + location.state?.from.search.includes('unlock-to-approve') + ) { browser.runtime.sendMessage({ type: 'user-logged-in', payload: { status: 'failed' } }) } else { await browser.storage.local.set({ [BG_RESPONSE]: { error: 'Request rejected' } }) @@ -274,6 +282,7 @@ export default function Login() { loading={(auth as AuthContextType).loading} onSubmit={handleSubmit} errorHighlighted={isError} + fullHeight={true} onChange={(event) => { setError(false) setPasswordInput(event.target.value) diff --git a/apps/extension/src/pages/buy/components/AssetCard.tsx b/apps/extension/src/pages/buy/components/AssetCard.tsx new file mode 100644 index 00000000..d9b87ac7 --- /dev/null +++ b/apps/extension/src/pages/buy/components/AssetCard.tsx @@ -0,0 +1,56 @@ +import { sliceWord } from '@leapwallet/cosmos-wallet-hooks' +import { GenericCard, ThemeName, useTheme } from '@leapwallet/leap-ui' +import { ImgNotAvailableDark, ImgNotAvailableLight } from 'images/logos' +import React from 'react' + +export type AssetCardProps = { + id?: string + symbol: string + chainName: string + assetImg?: string + chainSymbolImageUrl?: string + onClick: () => void +} + +export default function AssetCard({ + symbol, + chainName, + assetImg, + onClick, + chainSymbolImageUrl, +}: AssetCardProps) { + const { theme } = useTheme() + return ( + +

+ {sliceWord(symbol)} +

+
+ } + subtitle={chainName} + img={ +
+ + +
+ } + isRounded={true} + className={'my-2'} + onClick={onClick} + size={'md'} + /> + ) +} diff --git a/apps/extension/src/pages/buy/components/CurrencyCard.tsx b/apps/extension/src/pages/buy/components/CurrencyCard.tsx new file mode 100644 index 00000000..75947380 --- /dev/null +++ b/apps/extension/src/pages/buy/components/CurrencyCard.tsx @@ -0,0 +1,35 @@ +import { sliceWord } from '@leapwallet/cosmos-wallet-hooks' +import { GenericCard } from '@leapwallet/leap-ui' +import React from 'react' + +export type CurrencyCardProps = { + code: string + name: string + logo: string + onClick: () => void +} + +export default function CurrencyCard({ code, name, logo, onClick }: CurrencyCardProps) { + return ( + +

+ {sliceWord(code)} +

+
+ } + subtitle={name} + img={ + + } + isRounded={true} + className={'my-2'} + onClick={onClick} + size={'md'} + /> + ) +} diff --git a/apps/extension/src/pages/buy/components/SelectAssetSheet.tsx b/apps/extension/src/pages/buy/components/SelectAssetSheet.tsx new file mode 100644 index 00000000..a938617d --- /dev/null +++ b/apps/extension/src/pages/buy/components/SelectAssetSheet.tsx @@ -0,0 +1,78 @@ +import BottomModal from 'components/bottom-modal' +import { EmptyCard } from 'components/empty-card' +import { SearchInput } from 'components/search-input' +import TokenListSkeleton from 'components/Skeletons/TokenListSkeleton' +import { AssetProps, useGetSupportedAssets } from 'hooks/kado/useGetSupportedAssets' +import { Images } from 'images' +import React, { useMemo, useState } from 'react' + +import AssetCard from './AssetCard' + +type SelectAssetSheetProps = { + isVisible: boolean + onClose: () => void + onAssetSelect: (asset: AssetProps) => void +} + +export default function SelectAssetSheet({ + isVisible, + onClose, + onAssetSelect, +}: SelectAssetSheetProps) { + const [searchTerm, setSearchTerm] = useState('') + const { isLoading, data: supportedAssets = [] } = useGetSupportedAssets() + + const assetList = useMemo( + () => + supportedAssets.filter( + (asset: AssetProps) => + asset.symbol.toLowerCase().includes(searchTerm) || + asset.chainName.toLowerCase().includes(searchTerm), + ), + [supportedAssets, searchTerm], + ) + + return ( + +
+ setSearchTerm(e.target.value)} + data-testing-id='buy-asset-input-search' + placeholder='Search token' + onClear={() => setSearchTerm('')} + /> +
+ {isLoading && } + {!isLoading && ( +
+ {assetList?.length === 0 && ( + + )} + {assetList.length !== 0 && + assetList.map((asset) => ( + onAssetSelect(asset)} + /> + ))} +
+ )} +
+ ) +} diff --git a/apps/extension/src/pages/buy/components/SelectButton.tsx b/apps/extension/src/pages/buy/components/SelectButton.tsx new file mode 100644 index 00000000..de6c853a --- /dev/null +++ b/apps/extension/src/pages/buy/components/SelectButton.tsx @@ -0,0 +1,56 @@ +import { sliceWord } from '@leapwallet/cosmos-wallet-hooks' +import { ThemeName, useTheme } from '@leapwallet/leap-ui' +import { Images } from 'images' +import { GenericLight, ImgNotAvailableDark, ImgNotAvailableLight } from 'images/logos' +import React from 'react' +import { imgOnError } from 'utils/imgOnError' + +type SelectButtonProps = { + title: string + subtitle?: string + chainImg?: string + logo?: string + onClick: () => void +} + +export function SelectCurrencyButton({ onClick, logo, title }: SelectButtonProps) { + return ( + + ) +} + +export function SelectAssetButton({ onClick, logo, title, subtitle, chainImg }: SelectButtonProps) { + const { theme } = useTheme() + return ( + + ) +} diff --git a/apps/extension/src/pages/buy/components/SelectCurrencySheet.tsx b/apps/extension/src/pages/buy/components/SelectCurrencySheet.tsx new file mode 100644 index 00000000..2f119d37 --- /dev/null +++ b/apps/extension/src/pages/buy/components/SelectCurrencySheet.tsx @@ -0,0 +1,82 @@ +import BottomModal from 'components/bottom-modal' +import { EmptyCard } from 'components/empty-card' +import { SearchInput } from 'components/search-input' +import TokenListSkeleton from 'components/Skeletons/TokenListSkeleton' +import { useGetKadoCurrencies } from 'hooks/useGetKadoDetails' +import { Images } from 'images' +import React, { useMemo, useState } from 'react' + +import CurrencyCard from './CurrencyCard' + +type SelectCurrencySheetProps = { + isVisible: boolean + onClose: () => void + onCurrencySelect: (code: string) => void +} + +type CurrencyProps = { + code: string + name: string + logo: string +} + +export default function SelectCurrencySheet({ + isVisible, + onClose, + onCurrencySelect, +}: SelectCurrencySheetProps) { + const [searchedCurrency, setSearchedCurrency] = useState('') + const { isLoading, data: supportedCurrencies = [] } = useGetKadoCurrencies() + const currencyList = useMemo( + () => + supportedCurrencies.filter( + (currency: CurrencyProps) => + currency.code.toLowerCase().includes(searchedCurrency) || + currency.name.toLowerCase().includes(searchedCurrency), + ), + [supportedCurrencies, searchedCurrency], + ) + + return ( + +
+ setSearchedCurrency(e.target.value)} + data-testing-id='currency-input-search' + placeholder='Search currency' + onClear={() => setSearchedCurrency('')} + /> +
+ {isLoading && } + {!isLoading && ( +
+ {currencyList?.length === 0 && ( + + )} + {currencyList.length !== 0 && + currencyList.map((currency) => ( + onCurrencySelect(currency.code)} + /> + ))} +
+ )} +
+ ) +} diff --git a/apps/extension/src/pages/buy/index.tsx b/apps/extension/src/pages/buy/index.tsx new file mode 100644 index 00000000..5487986f --- /dev/null +++ b/apps/extension/src/pages/buy/index.tsx @@ -0,0 +1,379 @@ +import { formatTokenAmount, useDebounce } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { Buttons, Header, HeaderActionType, ThemeName, useTheme } from '@leapwallet/leap-ui' +import { captureException } from '@sentry/react' +import BigNumber from 'bignumber.js' +import PopupLayout from 'components/layout/popup-layout' +import Text from 'components/text' +import { EventName, PageName } from 'config/analytics' +import { motion } from 'framer-motion' +import { usePageView } from 'hooks/analytics/usePageView' +import { AssetProps } from 'hooks/kado/useGetSupportedAssets' +import { useChainInfos } from 'hooks/useChainInfos' +import { getConversionRateKado, getQuoteKado } from 'hooks/useGetKadoDetails' +import useQuery from 'hooks/useQuery' +import { useThemeColor } from 'hooks/utility/useThemeColor' +import { useAddress } from 'hooks/wallet/useAddress' +import kadoDarkLogo from 'images/logos/Kado-dark.svg' +import kadoLightLogo from 'images/logos/Kado-light.svg' +import { isString } from 'markdown-it/lib/common/utils' +import mixpanel from 'mixpanel-browser' +import { convertObjInQueryParams } from 'pages/home/utils' +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import Skeleton from 'react-loading-skeleton' +import { useLocation, useNavigate } from 'react-router' +import { getCountryLogo } from 'utils/getCountryLogo' +import { removeLeadingZeroes } from 'utils/strings' + +import SelectAssetSheet from './components/SelectAssetSheet' +import { SelectAssetButton, SelectCurrencyButton } from './components/SelectButton' +import SelectCurrencySheet from './components/SelectCurrencySheet' + +export enum ServiceProviderEnum { + KADO = 'kado', +} + +export enum ServiceProviderBaseUrlEnum { + KADO = 'https://app.kado.money', +} + +const Buy = () => { + const pageViewSource = useQuery().get('pageSource') ?? undefined + const pageViewAdditionalProperties = useMemo( + () => ({ + pageViewSource, + }), + [pageViewSource], + ) + usePageView(PageName.OnRampQuotePreview, true, pageViewAdditionalProperties) + const themeColor = useThemeColor() + const { theme } = useTheme() + + const navigate = useNavigate() + const location = useLocation() + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const asset: any = location.state + + const [showSelectCurrencySheet, setShowSelectCurrencySheet] = useState(false) + const [showSelectTokenSheet, setShowSelectTokenSheet] = useState(false) + + const [selectedCurrency, setSelectedCurrency] = useState('USD') + const [selectedAsset, setSelectedAsset] = useState(undefined) + const selectedAddress = useAddress() + + const [payFiatAmount, setPayFiatAmount] = useState('0') + const debouncedPayAmount = useDebounce(payFiatAmount, 500) + const [fiatAmountInUsd, setFiatAmountInUsd] = useState('0') + const [getAssetAmount, setGetAssetAmount] = useState('0') + const [loadingQuote, setLoadingQuote] = useState(false) + const [error, setError] = useState(null) + const inputAmountRef = useRef(null) + const chains = useChainInfos() + + useEffect(() => { + async function getQuote() { + try { + setLoadingQuote(true) + const quote = await getQuoteKado({ + transactionType: 'buy', + fiatMethod: 'credit_card', + partner: 'fortress', + amount: new BigNumber(debouncedPayAmount).toNumber(), + currency: selectedCurrency, + asset: selectedAsset?.symbol ?? 'ATOM', + blockchain: selectedAsset?.origin.toLowerCase() ?? 'cosmos hub', + }) + if (quote.success) { + setGetAssetAmount(quote?.data?.quote?.receiveUnitCountAfterFees?.amount ?? '0') + } else { + setGetAssetAmount('0') + } + } catch (error) { + captureException(error) + } finally { + setLoadingQuote(false) + } + } + if (debouncedPayAmount && new BigNumber(debouncedPayAmount).isGreaterThan('0')) { + getQuote() + } else { + setGetAssetAmount('0') + } + }, [debouncedPayAmount, selectedAsset, selectedCurrency]) + + useEffect(() => { + if (inputAmountRef.current) { + ;(inputAmountRef.current as HTMLElement)?.focus() + } + }, []) + + useEffect(() => { + if (pageViewSource === PageName.AssetDetails) { + const chain = chains[asset.chain as SupportedChain] + setSelectedAsset({ + symbol: asset.symbol, + chainName: chain.chainName, + chainId: chain.chainId, + chainSymbolImageUrl: chain.chainSymbolImageUrl, + assetImg: asset.img, + origin: chain.chainName, + }) + } else { + setShowSelectTokenSheet(true) + } + }, [asset, chains, pageViewSource]) + + useEffect(() => { + async function currencyToUsd(amount: string, currency: string) { + if (currency !== 'USD') { + const conversionRateToUsd = await getConversionRateKado({ + from: currency, + to: 'USD', + }) + const usdAmount = new BigNumber(amount).multipliedBy(conversionRateToUsd) + setFiatAmountInUsd(usdAmount.toString()) + } else { + setFiatAmountInUsd(amount) + } + } + currencyToUsd(debouncedPayAmount, selectedCurrency) + }, [debouncedPayAmount, selectedCurrency]) + + useEffect(() => { + async function setLimitError() { + setError(null) + if (parseFloat(fiatAmountInUsd) > 0) { + const conversionRate = await getConversionRateKado({ + from: 'USD', + to: selectedCurrency, + }) + if (parseFloat(fiatAmountInUsd) < 10) { + setError( + `Amount should be at least ${(10 * conversionRate).toFixed(2)} ${selectedCurrency}`, + ) + } else if (parseFloat(fiatAmountInUsd) > 10000) { + setError( + `Amount exceeds your daily limit of ${(10000 * conversionRate).toFixed( + 2, + )} ${selectedCurrency}`, + ) + } + } + } + setLimitError() + }, [fiatAmountInUsd, selectedCurrency]) + + const trackCTAEvent = useCallback((amount: string, asset: AssetProps, currency: string) => { + mixpanel.track(EventName.ButtonClick, { + buttonType: 'onramp', + buttonName: 'Redirection', + provider: ServiceProviderEnum.KADO, + buyToken: asset?.symbol, + buyTokenNetwork: asset?.origin, + chainName: asset?.chainName, + chainId: asset?.chainId, + fiatCurrency: currency, + fiatAmount: new BigNumber(amount).toNumber(), + }) + }, []) + + const handleBuyClick = useCallback(() => { + const params = { + apiKey: process.env.KADO_API_KEY, + onPayAmount: payFiatAmount, + onPayCurrency: selectedCurrency, + onRevCurrency: selectedAsset?.symbol, + onToAddress: selectedAddress, + network: selectedAsset?.origin, + product: 'BUY', + productList: 'BUY', + mode: 'minimal', + theme: 'dark', + } + + const queryParams = convertObjInQueryParams(params) + const url = `${ServiceProviderBaseUrlEnum.KADO}?${queryParams}` + window.open(url, '_blank') + if (selectedAsset) { + trackCTAEvent(fiatAmountInUsd, selectedAsset, selectedCurrency) + } + }, [ + fiatAmountInUsd, + payFiatAmount, + selectedAddress, + selectedAsset, + selectedCurrency, + trackCTAEvent, + ]) + + return ( +
+ + navigate(-1), + type: HeaderActionType.BACK, + }} + imgSrc={undefined} + title='Buy' + topColor={themeColor} + /> + } + > +
+
+
+ +
+ + You Pay + +
+ +
+ { + setError(null) + const val = e.target.value + const amount = removeLeadingZeroes(val) + if (parseFloat(amount) < 0) { + setError('Please enter a valid positive number.') + } else { + setPayFiatAmount(amount) + } + }} + type='number' + placeholder={'Amount'} + ref={inputAmountRef} + /> + setShowSelectCurrencySheet(true)} + logo={getCountryLogo(selectedCurrency)} + title={selectedCurrency} + /> +
+ {error && ( + + {error} + + )} +
+ + +
+ + You Get + +
+ + {selectedAsset && ( +
+ {!loadingQuote && ( + + {parseFloat(getAssetAmount) * 10000 > 0 + ? formatTokenAmount(getAssetAmount, undefined, 4) + : getAssetAmount} + + )} + {loadingQuote && ( +
+ +
+ )} + setShowSelectTokenSheet(true)} + logo={selectedAsset.assetImg} + chainImg={selectedAsset.chainSymbolImageUrl} + title={selectedAsset.symbol} + subtitle={selectedAsset.chainName} + /> +
+ )} +
+
+
+ +
+
+ + Powered by Kado + + +
+
+ + You'll be redirected to Kado's website for this transaction + +
+
+ +
+ Buy + open_in_new +
+
+
+
+
+
+ + setShowSelectCurrencySheet(false)} + onCurrencySelect={(currency) => { + setSelectedCurrency(currency) + setShowSelectCurrencySheet(false) + if (inputAmountRef.current) { + ;(inputAmountRef.current as HTMLElement).focus() + } + }} + /> + + { + if (!selectedAsset) { + navigate(-1) + } else { + setShowSelectTokenSheet(false) + } + }} + onAssetSelect={(asset) => { + setSelectedAsset(asset) + setShowSelectTokenSheet(false) + if (inputAmountRef.current) { + ;(inputAmountRef.current as HTMLElement).focus() + } + }} + /> +
+
+ ) +} + +export default Buy diff --git a/apps/extension/src/pages/earn/index.tsx b/apps/extension/src/pages/earn/index.tsx index 448e2200..455bf9bd 100644 --- a/apps/extension/src/pages/earn/index.tsx +++ b/apps/extension/src/pages/earn/index.tsx @@ -1,19 +1,16 @@ import { Header, HeaderActionType } from '@leapwallet/leap-ui' -import SelectedChainAlertStrip from 'components/alert-strip/SelectedChainAlertStrip' +import { TestnetAlertStrip } from 'components/alert-strip' import BottomNav, { BottomNavLabel } from 'components/bottom-nav/BottomNav' import { EmptyCard } from 'components/empty-card' import PopupLayout from 'components/layout/popup-layout' import { PageName } from 'config/analytics' +import { useChainPageInfo } from 'hooks' import { usePageView } from 'hooks/analytics/usePageView' -import { useActiveChain } from 'hooks/settings/useActiveChain' import useActiveWallet from 'hooks/settings/useActiveWallet' -import { useChainInfos } from 'hooks/useChainInfos' -import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' import { LeapCosmos } from 'images/logos' import SelectChain from 'pages/home/SelectChain' import SideNav from 'pages/home/side-nav' import React, { useState } from 'react' -import { Colors } from 'theme/colors' import { DisplaySettingsModal } from './display-settings-modal' import InvestViewContainer from './invest-view' @@ -25,18 +22,13 @@ export default function EarnPage() { const [showSideNav, setShowSideNav] = useState(false) const [showChainSelector, setShowChainSelector] = useState(false) const [showDisplaySettings, setShowDisplaySettings] = useState(false) - const defaultTokenLogo = useDefaultTokenLogo() + const { activeWallet } = useActiveWallet() + const { headerChainImgSrc } = useChainPageInfo() const [displaySettings, setDisplaySettings] = useState({ sortBy: 'tvl', }) - const { activeWallet } = useActiveWallet() - const activeChain = useActiveChain() - const chainInfos = useChainInfos() - const activeChainInfo = chainInfos[activeChain] - const themeColor = Colors.getChainColor(activeChain, activeChainInfo) - if (!activeWallet) { return (
@@ -65,14 +57,13 @@ export default function EarnPage() { className: 'w-[48px] h-[40px] px-3 bg-[#FFFFFF] dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-full', }} - imgSrc={activeChainInfo.chainSymbolImageUrl ?? defaultTokenLogo} + imgSrc={headerChainImgSrc} onImgClick={() => setShowChainSelector(true)} title='Earn' - topColor={themeColor} /> } > - +
diff --git a/apps/extension/src/pages/governance/ProposalDetails.tsx b/apps/extension/src/pages/governance/ProposalDetails.tsx deleted file mode 100644 index b92dbb0a..00000000 --- a/apps/extension/src/pages/governance/ProposalDetails.tsx +++ /dev/null @@ -1,666 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable react/no-children-prop */ -import { - useChainApis, - useChainInfo, - useChainsStore, - useGetExplorerAccountUrl, - useGetProposal, - useStaking, -} from '@leapwallet/cosmos-wallet-hooks' -import { axiosWrapper, ChainInfo, CoinType, SupportedChain } from '@leapwallet/cosmos-wallet-sdk' -import { Buttons, CardDivider, Header, HeaderActionType, LineDivider } from '@leapwallet/leap-ui' -import { captureException } from '@sentry/react' -import { useQuery } from '@tanstack/react-query' -import axios from 'axios' -import classNames from 'classnames' -import BottomSheet from 'components/bottom-sheet/BottomSheet' -import PopupLayout from 'components/layout/popup-layout' -import { ProposalDescription } from 'components/proposal-description' -import Text from 'components/text' -import dayjs from 'dayjs' -import { useActiveChain } from 'hooks/settings/useActiveChain' -import useHorizontalScroll from 'hooks/useHorizontalScroll' -import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' -import { useAddress } from 'hooks/wallet/useAddress' -import React, { Fragment, useEffect, useMemo, useState } from 'react' -import Skeleton from 'react-loading-skeleton' -import { PieChart } from 'react-minimal-pie-chart' -import { Colors } from 'theme/colors' -import { voteRatio } from 'utils/gov/voteRatio' -import { imgOnError } from 'utils/imgOnError' - -import { CastVote } from './CastVote' -import RequireMinStaking from './RequireMinStaking' -import Status, { ProposalStatus } from './Status' - -export type ProposalDetailsProps = { - selectedProp: string | undefined - onBack: () => void - proposalList: any[] - shouldUseFallback: boolean -} - -export function convertTime(seconds: number) { - let sec: number | string = seconds - let hours: number | string = Math.floor(sec / 3600) - hours >= 1 ? (sec = sec - hours * 3600) : (hours = '00') - let min: number | string = Math.floor(sec / 60) - min >= 1 ? (sec = sec - min * 60) : (min = '00') - sec < 1 ? (sec = '00') : void 0 - - min.toString().length == 1 ? (min = '0' + min) : void 0 - sec.toString().length == 1 ? (sec = '0' + sec) : void 0 - - return hours + ':' + min + ':' + sec -} - -type IShowVotes = { - dataMock: { - title: string - value: number - color: string - percent: string - }[] - chain: ChainInfo -} - -const chainDecimals: Record = { - '60': 18, - '118': 6, - '529': 6, - '750': 6, - '394': 8, - '234': 6, - '564': 6, - '852': 6, - '639': 6, - '459': 6, - '330': 6, - '990': 6, - '931': 6, - '4444': 6, - '505': 9, - '494': 6, -} - -export const ShowVotes = ({ dataMock, chain }: IShowVotes) => { - const { scrollRef, props } = useHorizontalScroll() - const decimals = - Object.values(chain.nativeDenoms)?.[0]?.coinDecimals ?? - (chainDecimals as any)[chain.bip44.coinType] - - return ( -
-
- {dataMock.map((item) => { - const isLoading = item.title === 'loading' - return ( -
- {isLoading ? ( - - ) : ( - <> -
-
-

{`${item.title} - ${item.percent}`}

-
- - {`${new Intl.NumberFormat('en-US').format( - +Number(item.value / Math.pow(10, decimals)).toFixed(2), - )} ${chain.denom}`} - - - )} -
- ) - })} -
-
- ) -} - -function VoteDetails({ - currVote, - proposal, - isLoading, - activeChain, - hasMinStaked, - onVote, -}: { - proposal: any - currVote: string - isLoading: boolean - activeChain: SupportedChain - onVote: () => void - hasMinStaked: boolean -}) { - const [timeLeft, setTimeLeft] = useState() - - useEffect(() => { - const getTime = () => { - const now = dayjs() - const end = dayjs( - proposal.status === ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD - ? proposal.deposit_end_time - : proposal.voting_end_time, - ) - const duration = end.diff(now, 'seconds') - setTimeLeft(convertTime(duration)) - } - - const i = setInterval(getTime, 1000) - return () => clearInterval(i) - - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [proposal, convertTime]) - - switch (proposal.status) { - case ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD: - return ( - <> -
-
-
- Voting Starts -
-
- {dayjs(proposal.voting_start_time).format('MMM DD, YYYY')} -
-
- -
-
- Voting Ends -
-
- {dayjs(proposal.voting_end_time).format('MMM DD, YYYY')} -
-
-
- {timeLeft && `Ending in ${timeLeft}`} -
-
- - {isLoading ? ( -
- -
- - -
-
- ) : null} - - {currVote && currVote !== 'NO_VOTE' && ( -
-
- thumb_up -
-
-
Vote submitted
-
Voted {currVote}
-
-
- )} - - onVote()} - disabled={!hasMinStaked} - > -
- how_to_vote - Vote -
-
- - ) - - case ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD: - return ( - <> -
-
-
- Deposit Period Ends -
-
- {dayjs(proposal.deposit_end_time).format('MMM DD, YYYY')} -
-
- {timeLeft && ( -
- {timeLeft && `Ending in ${timeLeft}`} -
- )} -
- - ) - - case ProposalStatus.PROPOSAL_STATUS_PASSED: - case ProposalStatus.PROPOSAL_STATUS_FAILED: - case ProposalStatus.PROPOSAL_STATUS_REJECTED: - return ( - <> -
-
-
- Results -
-
-
- -
- {voteRatio(proposal.tally || proposal.final_tally_result).map((values) => ( -
-
- {values.label} -
-
- - {values.percentage.toFixed(2)} - -
-
-
- ))} -
-
- - ) - } - - return <> -} - -type ITally = { - label: string - value: number -} - -export const Turnout = ({ tallying }: { tallying: ITally[] }) => { - const [detail, showDetail] = useState('') - return ( - <> -
- {tallying.map((tally, index) => ( - -
-
-

{tally.label}

- -
- - {tally.value ? ( -

- {`${Number(tally.value).toFixed(2)}%`} -

- ) : ( - - )} -
- - {index === 0 && } -
- ))} -
- - showDetail('')} - headerTitle={detail} - headerActionType={HeaderActionType.CANCEL} - closeOnClickBackDrop - > - - {detail === 'Turnout' - ? 'Defined as the percentage of voting power already casted on a proposal as a percentage of total staked tokens.' - : 'Defined as the minimum percentage of voting power that needs to be cast on a proposal for the result to be valid.'} - - - - ) -} - -export const getPercentage = (a: number, b: number) => { - if (b === 0) return '0%' - return `${Number((a / b) * 100).toFixed(2)}%` -} - -const activeProposalStatusTypes = [ - ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD, - ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD, -] - -function ProposalDetails({ - selectedProp, - onBack, - proposalList, - shouldUseFallback, -}: ProposalDetailsProps) { - const { chains } = useChainsStore() - const activeChain = useActiveChain() - const address = useAddress() - const activeChainInfo = useChainInfo() - - const chain = chains[activeChain] - const { lcdUrl } = useChainApis() - const { getExplorerAccountUrl } = useGetExplorerAccountUrl({}) - const [showCastVoteSheet, setShowCastVoteSheet] = useState(false) - - const { totalDelegation } = useStaking() - - const hasMinAmountStaked = useMemo(() => { - if (activeChain === 'cosmos') { - return totalDelegation?.gte(1) - } - - return true - }, [activeChain, totalDelegation]) - - const proposal = useMemo( - () => proposalList.find((prop) => prop.proposal_id === selectedProp), - [proposalList, selectedProp], - ) - - const defaultTokenLogo = useDefaultTokenLogo() - - const { - data: currVote, - refetch, - isLoading, - } = useQuery( - ['currVote', activeChain, address, selectedProp], - async (): Promise => { - if (activeChain) { - try { - const { data } = await axios.post( - `${process.env.LEAP_WALLET_BACKEND_API_URL}/gov/vote/${activeChainInfo.chainId}/${selectedProp}`, - { userAddress: address }, - ) - return data - } catch (error: any) { - try { - const data = await axiosWrapper( - { - baseURL: lcdUrl ?? '', - method: 'get', - url: `/cosmos/gov/v1beta1/proposals/${selectedProp}/votes/${address}`, - }, - 1, - 'proposals-votes', - ) - - const voteOption = data.data.vote.options[0].option - return voteOption.replace('VOTE_OPTION_', '') - } catch (error: any) { - if (error.response.data.code === 3 || error.response.data.error?.code === -32700) { - return 'NO_VOTE' - } else { - captureException(error) - throw new Error(error) - } - } - } - } - }, - { - retry: (failureCount) => { - return failureCount !== 2 - }, - enabled: proposal.status === ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD, - }, - ) - - // eslint-disable-next-line prefer-const - let { data: _proposalVotes, status } = useGetProposal(proposal.proposal_id, shouldUseFallback) - status = shouldUseFallback ? status : 'success' - const { yes, no, abstain, no_with_veto } = (proposal.tally || - _proposalVotes || - proposal.final_tally_result) as any - const totalVotes = [yes, no, abstain, no_with_veto].reduce((sum, val) => sum + Number(val), 0) - - const dataMock = useMemo(() => { - return !totalVotes - ? [{ title: 'loading', value: 1, color: '#ccc', percent: '0%' }] - : [ - { - title: 'YES', - value: +yes, - color: '#29A874', - percent: getPercentage(+yes, totalVotes), - }, - { - title: 'NO', - value: +no, - color: '#FF707E', - percent: getPercentage(+no, totalVotes), - }, - { - title: 'No with Veto', - value: +no_with_veto, - color: '#8583EC', - percent: getPercentage(+no_with_veto, totalVotes), - }, - { - title: 'Abstain', - value: +abstain, - color: '#D1A700', - percent: getPercentage(+abstain, totalVotes), - }, - ] - }, [abstain, no, no_with_veto, totalVotes, yes]) - - const tallying = useMemo(() => { - return [ - { - label: 'Turnout', - value: !shouldUseFallback - ? proposal.turnout - : (totalVotes / (_proposalVotes as any)?.bonded_tokens) * 100, - }, - { - label: 'Quorum', - value: !shouldUseFallback ? proposal.quorum : (_proposalVotes as any)?.quorum * 100, - }, - ] - }, [_proposalVotes, proposal.quorum, proposal.turnout, shouldUseFallback, totalVotes]) - - const proposer = useMemo(() => { - if (!shouldUseFallback) { - return proposal?.proposer?.address - ? { - address: proposal?.proposer?.address, - url: proposal?.proposer?.url ?? `${getExplorerAccountUrl(proposal?.proposer?.address)}`, - } - : undefined - } - return _proposalVotes?.proposer?.depositor - ? { - address: _proposalVotes?.proposer?.depositor as string, - url: _proposalVotes?.proposerTxUrl as string | undefined, - } - : undefined - }, [ - _proposalVotes?.proposer?.depositor, - _proposalVotes?.proposerTxUrl, - getExplorerAccountUrl, - proposal?.proposer?.address, - proposal?.proposer?.url, - shouldUseFallback, - ]) - - return ( -
- -
-
-
- #{proposal.proposal_id} ·{' '} - -
-
- {proposal?.title ?? proposal?.content?.title} -
- - {proposal.status === ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD && - !hasMinAmountStaked && } - - setShowCastVoteSheet(true)} - currVote={currVote ?? ''} - isLoading={isLoading} - hasMinStaked={hasMinAmountStaked} - /> - -
- -
- - {proposal.status !== ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD && totalVotes ? ( - <> -
-
- {status !== 'success' ? ( - - ) : ( - - )} -

- Current Status -

-
-
- - - - ) : null} - - {activeProposalStatusTypes.includes(proposal.status) && proposer?.address && ( -
-
-
- 👤 - chain logo -
- -
- - Proposer - - {proposer ? ( - - {`${proposer.address.slice(0, 5)}...${proposer.address.slice(-6)}`} - - ) : ( - - )} -
-
- - {proposer?.url && ( - - )} -
- )} - -
- -
- - {(proposal?.description || proposal?.content?.description) && ( - - )} -
- - - -
- ) -} - -export default ProposalDetails diff --git a/apps/extension/src/pages/governance/ProposalList.tsx b/apps/extension/src/pages/governance/ProposalList.tsx index ff0b0a66..ae44804f 100644 --- a/apps/extension/src/pages/governance/ProposalList.tsx +++ b/apps/extension/src/pages/governance/ProposalList.tsx @@ -1,25 +1,23 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Proposal, useStaking } from '@leapwallet/cosmos-wallet-hooks' import { CardDivider, Header, HeaderActionType } from '@leapwallet/leap-ui' -import SelectedChainAlertStrip from 'components/alert-strip/SelectedChainAlertStrip' +import { TestnetAlertStrip } from 'components/alert-strip' import BottomModal from 'components/bottom-modal' import { EmptyCard } from 'components/empty-card' import PopupLayout from 'components/layout/popup-layout' import { LoaderAnimation } from 'components/loader/Loader' import { SearchInput } from 'components/search-input' +import { useChainPageInfo } from 'hooks' import { useActiveChain } from 'hooks/settings/useActiveChain' import { useChainInfos } from 'hooks/useChainInfos' -import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' import { Images } from 'images' import SelectChain from 'pages/home/SelectChain' import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react' import { useNavigate } from 'react-router-dom' -import { Colors } from 'theme/colors' import { sliceSearchWord } from 'utils/strings' import GovCardSkeleton from '../../components/Skeletons/GovCardSkeleton' -import RequireMinStaking from './RequireMinStaking' -import Status, { ProposalStatus } from './Status' +import { ProposalStatus, ProposalStatusEnum, RequireMinStaking } from './components' export type ProposalListProps = { // eslint-disable-next-line no-unused-vars @@ -32,9 +30,9 @@ export type ProposalListProps = { const filters = [ { key: 'all', label: 'All Proposals' }, - { key: ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD, label: 'Voting in Progress' }, - { key: ProposalStatus.PROPOSAL_STATUS_PASSED, label: 'Passed' }, - { key: ProposalStatus.PROPOSAL_STATUS_REJECTED, label: 'Rejected' }, + { key: ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD, label: 'Voting in Progress' }, + { key: ProposalStatusEnum.PROPOSAL_STATUS_PASSED, label: 'Passed' }, + { key: ProposalStatusEnum.PROPOSAL_STATUS_REJECTED, label: 'Rejected' }, ] function ProposalList({ @@ -50,7 +48,6 @@ function ProposalList({ } const navigate = useNavigate() - const defaultTokenLogo = useDefaultTokenLogo() const [showFilter, setShowFilter] = useState(false) const [filter, setFilter] = useState('all') const [showChainSelector, setShowChainSelector] = useState(false) @@ -123,7 +120,7 @@ function ProposalList({ }, [fetchMore, filteredProposalList.length, proposalListStatus]) const activeChainInfo = chainInfos[activeChain] - const themeColor = Colors.getChainColor(activeChain, activeChainInfo) + const { headerChainImgSrc } = useChainPageInfo() return (
@@ -134,22 +131,21 @@ function ProposalList({ onClick: () => navigate(-1), type: HeaderActionType.BACK, }} - imgSrc={activeChainInfo.chainSymbolImageUrl ?? defaultTokenLogo} + imgSrc={headerChainImgSrc} onImgClick={() => setShowChainSelector(true)} title={'Governance'} - topColor={themeColor} /> } > <> - +
Proposals
- List of proposals in {activeChainInfo.chainName} + List of proposals in {activeChainInfo?.chainName ?? ''}
{!hasMinAmountStaked && } @@ -202,7 +198,7 @@ function ProposalList({
#{prop.proposal_id} ·{' '} - +
diff --git a/apps/extension/src/pages/governance/Proposals.tsx b/apps/extension/src/pages/governance/Proposals.tsx index a27b795c..7d84b59f 100644 --- a/apps/extension/src/pages/governance/Proposals.tsx +++ b/apps/extension/src/pages/governance/Proposals.tsx @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { useActiveChain, - useGetChains, useGetNtrnProposals, useGovProposals, useIsFeatureExistForChain, @@ -10,18 +9,17 @@ import { QueryStatus } from '@tanstack/react-query' import { BottomNavLabel } from 'components/bottom-nav/BottomNav' import { ComingSoon } from 'components/coming-soon' import { PageName } from 'config/analytics' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' import { usePageView } from 'hooks/analytics/usePageView' import { usePerformanceMonitor } from 'hooks/perf-monitoring/usePerformanceMonitor' import React, { useMemo, useState } from 'react' +import { AggregatedSupportedChain } from 'types/utility' +import { AggregatedGovernance, ProposalDetails, ProposalStatusEnum } from './components' import { NtrnProposalDetails, NtrnProposalList, NtrnProposalStatus } from './neutron' -import ProposalDetails from './ProposalDetails' import ProposalList from './ProposalList' -import { ProposalStatus } from './Status' function GeneralProposals() { - usePageView(PageName.Governance) - const [selectedProposal, setSelectedProposal] = useState() const { data: proposalsList, status, fetchMore, shouldUseFallback } = useGovProposals() @@ -63,20 +61,20 @@ function NeutronProposals() { const formatProposalStatus = (proposal: any): any => { let status = proposal?.status switch (proposal?.status) { - case ProposalStatus.PROPOSAL_STATUS_EXECUTED: { + case ProposalStatusEnum.PROPOSAL_STATUS_EXECUTED: { status = NtrnProposalStatus.EXECUTED break } - case ProposalStatus.PROPOSAL_STATUS_REJECTED: { + case ProposalStatusEnum.PROPOSAL_STATUS_REJECTED: { status = NtrnProposalStatus.REJECTED break } - case ProposalStatus.PROPOSAL_STATUS_PASSED: { + case ProposalStatusEnum.PROPOSAL_STATUS_PASSED: { status = NtrnProposalStatus.PASSED break } - case ProposalStatus.PROPOSAL_STATUS_IN_PROGRESS: - case ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD: { + case ProposalStatusEnum.PROPOSAL_STATUS_IN_PROGRESS: + case ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD: { status = NtrnProposalStatus.OPEN break } @@ -112,13 +110,18 @@ function NeutronProposals() { } function Proposals() { - const activeChain = useActiveChain() + usePageView(PageName.Governance) + const activeChain = useActiveChain() as AggregatedSupportedChain const isGovernanceComingSoon = useIsFeatureExistForChain({ checkForExistenceType: 'comingSoon', feature: 'governance', platform: 'Extension', }) + if (activeChain === AGGREGATED_CHAIN_KEY) { + return + } + if (isGovernanceComingSoon) { return } diff --git a/apps/extension/src/pages/governance/components/AggregatedGovernance.tsx b/apps/extension/src/pages/governance/components/AggregatedGovernance.tsx new file mode 100644 index 00000000..c2505158 --- /dev/null +++ b/apps/extension/src/pages/governance/components/AggregatedGovernance.tsx @@ -0,0 +1,164 @@ +import { + sliceSearchWord, + useAggregatedGovernance, + useGetChains, +} from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { Header, HeaderActionType } from '@leapwallet/leap-ui' +import classNames from 'classnames' +import { AggregatedSearchComponent } from 'components/aggregated' +import { EmptyCard } from 'components/empty-card' +import PopupLayout from 'components/layout/popup-layout' +import { Images } from 'images' +import SelectChain from 'pages/home/SelectChain' +import React, { useCallback, useMemo, useState } from 'react' +import { useNavigate } from 'react-router' +import { VariableSizeList } from 'react-window' + +import { filterSearchedProposal, sortProposal } from '../utils' +import GenericProposalDetails from './GenericProposalDetails' +import { AggregatedGovernanceNullComponents, ProposalCard } from './index' + +const NETWORK = 'mainnet' + +export function AggregatedGovernance() { + const navigate = useNavigate() + const [showChainSelector, setShowChainSelector] = useState(false) + const { votingProposals, nonVotingProposals, perChainShouldUseFallback } = + useAggregatedGovernance() + + const chains = useGetChains() + const [showSearchInput, setShowSearchInput] = useState(false) + const [searchedText, setSearchedText] = useState('') + const [selectedProposalId, setSelectedProposalId] = useState() + const [shouldUseFallback, setShouldUseFallback] = useState(false) + const [selectedProposalChain, setSelectedProposalChain] = useState() + + const allProposals = useMemo(() => { + const formattedVotingProposals = votingProposals + .filter((proposal) => filterSearchedProposal(proposal, searchedText, chains)) + .sort((itemA, itemB) => sortProposal(itemA, itemB, chains)) + + const formattedNonVotingProposals = nonVotingProposals + .filter((proposal) => filterSearchedProposal(proposal, searchedText, chains)) + .sort((itemA, itemB) => sortProposal(itemA, itemB, chains)) + + return [...formattedVotingProposals, ...formattedNonVotingProposals] + }, [votingProposals, nonVotingProposals, searchedText, chains]) + + const handleProposalCardClick = useCallback( + (proposalId: string, chain: SupportedChain) => { + setSelectedProposalId(proposalId) + setShouldUseFallback(perChainShouldUseFallback[chain]) + setSelectedProposalChain(chain) + }, + [perChainShouldUseFallback], + ) + + const handleProposalDetailsBack = useCallback(() => { + setSelectedProposalId(undefined) + setSelectedProposalChain(undefined) + setShouldUseFallback(false) + }, []) + + return ( +
+ + + {selectedProposalId && selectedProposalChain ? ( + + ) : ( + <> + navigate(-1), + type: HeaderActionType.BACK, + }} + imgSrc={Images.Misc.AggregatedViewSvg} + onImgClick={() => setShowChainSelector(true)} + title='Governance' + /> + } + > +
+ {showSearchInput ? ( + { + setShowSearchInput(false) + setSearchedText('') + }} + handleChange={(value) => setSearchedText(value)} + value={searchedText} + placeholder='Search proposal' + /> + ) : ( +

+ Governance + + +

+ )} + +
+ {allProposals.length > 0 ? ( + 124} + > + {({ index, style }) => ( +
+ + handleProposalCardClick( + allProposals[index].proposal_id, + (allProposals[index]?.chain || 'cosmos') as SupportedChain, + ) + } + /> +
+ )} +
+ ) : ( + <> + {searchedText.trim().length > 0 ? ( + + ) : null} + + )} +
+
+
+ + setShowChainSelector(false)} /> + + )} +
+ ) +} diff --git a/apps/extension/src/pages/governance/components/AggregatedGovernanceNullComponents.tsx b/apps/extension/src/pages/governance/components/AggregatedGovernanceNullComponents.tsx new file mode 100644 index 00000000..bdaad5dc --- /dev/null +++ b/apps/extension/src/pages/governance/components/AggregatedGovernanceNullComponents.tsx @@ -0,0 +1,42 @@ +import { + AggregatedGovernance, + useAggregatedGovernanceStore, + useFillAggregatedGovernance, +} from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { AggregatedNullComponents } from 'components/aggregated' +import React from 'react' + +type FetchChainGovernanceProps = { + chain: SupportedChain + setAggregatedGovernance: (aggregatedGovernance: AggregatedGovernance) => void +} + +const FetchChainGovernance = React.memo(function ({ + chain, + setAggregatedGovernance, +}: FetchChainGovernanceProps) { + useFillAggregatedGovernance(chain, setAggregatedGovernance) + return <> +}) + +FetchChainGovernance.displayName = 'FetchChainGovernance' + +export const AggregatedGovernanceNullComponents = React.memo(function () { + const { setAggregatedGovernance } = useAggregatedGovernanceStore() + + return ( + ( + + )} + /> + ) +}) + +AggregatedGovernanceNullComponents.displayName = 'AggregatedGovernanceNullComponents' diff --git a/apps/extension/src/pages/governance/CastVote.tsx b/apps/extension/src/pages/governance/components/CastVote.tsx similarity index 74% rename from apps/extension/src/pages/governance/CastVote.tsx rename to apps/extension/src/pages/governance/components/CastVote.tsx index 012bbdf5..72691b3a 100644 --- a/apps/extension/src/pages/governance/CastVote.tsx +++ b/apps/extension/src/pages/governance/components/CastVote.tsx @@ -4,12 +4,15 @@ import { GasOptions, getOsmosisGasPriceSteps, useChainApis, + useChainCosmosSDK, useDefaultGasEstimates, useGasAdjustmentForChain, useGasPriceSteps, - useGetChains, + useGetFeeMarketGasPricesSteps, useGov, + useHasToCalculateDynamicFee, useNativeFeeDenom, + useSelectedNetwork, useSimulateVote, VoteOptions, } from '@leapwallet/cosmos-wallet-hooks' @@ -19,6 +22,7 @@ import { GasPrice, getSimulationFee, NativeDenom, + SupportedChain, } from '@leapwallet/cosmos-wallet-sdk' import { captureException } from '@sentry/react' import classNames from 'classnames' @@ -31,8 +35,7 @@ import { Wallet } from 'hooks/wallet/useWallet' import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useTxCallBack } from 'utils/txCallback' -import CastVoteSheet from './CastVoteSheet' -import ReviewVoteCast from './ReviewVoteCast' +import { CastVoteSheet, ReviewVoteCast } from './index' const useGetWallet = Wallet.useGetWallet @@ -43,32 +46,47 @@ export type CastVoteProps = { refetchVote: () => Promise showCastVoteSheet: boolean setShowCastVoteSheet: React.Dispatch> + forceChain?: SupportedChain + forceNetwork?: 'mainnet' | 'testnet' } -export const CastVote: React.FC = ({ +export function CastVote({ className, proposalId, refetchVote, showCastVoteSheet, setShowCastVoteSheet, -}) => { - const activeChain = useActiveChain() - const defaultGasPrice = useDefaultGasPrice() - const chains = useGetChains() - const activeChainInfo = chains[activeChain] + forceChain, + forceNetwork, +}: CastVoteProps) { + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) + const _selectedNetwork = useSelectedNetwork() + const selectedNetwork = useMemo( + () => forceNetwork || _selectedNetwork, + [_selectedNetwork, forceNetwork], + ) + + const defaultGasPrice = useDefaultGasPrice({ + activeChain, + selectedNetwork, + }) const getWallet = useGetWallet() const txCallback = useTxCallBack() const defaultGasEstimates = useDefaultGasEstimates() + const activeChainCosmosSDK = useChainCosmosSDK(activeChain) const { loading, vote, error, memo, setMemo, feeText, showLedgerPopup, clearError, ledgerError } = useGov({ proposalId, + forceChain: activeChain, + forceNetwork: selectedNetwork, }) - const { lcdUrl } = useChainApis() + const { lcdUrl } = useChainApis(activeChain, selectedNetwork) const allChainsGasPriceSteps = useGasPriceSteps() - const nativeFeeDenom = useNativeFeeDenom() - const gasAdjustment = useGasAdjustmentForChain() + const nativeFeeDenom = useNativeFeeDenom(activeChain, selectedNetwork) + const gasAdjustment = useGasAdjustmentForChain(activeChain) const [showFeesSettingSheet, setShowFeesSettingSheet] = useState(false) const [gasError, setGasError] = useState(null) @@ -83,17 +101,31 @@ export const CastVote: React.FC = ({ option: GasOptions.LOW, gasPrice: defaultGasPrice.gasPrice, }) - const simulateVote = useSimulateVote() + const simulateVote = useSimulateVote(activeChain, selectedNetwork) + const hasToCalculateDynamicFee = useHasToCalculateDynamicFee(activeChain, selectedNetwork) + const getFeeMarketGasPricesSteps = useGetFeeMarketGasPricesSteps(activeChain, selectedNetwork) const firstTime = useRef(true) useEffect(() => { ;(async function () { + let low: number, medium: number, high: number + let updateGasPriceSteps = false + if (feeDenom.coinMinimalDenom === 'uosmo' && activeChain === 'osmosis') { - const { low, medium, high } = await getOsmosisGasPriceSteps( + ;({ low, medium, high } = await getOsmosisGasPriceSteps( lcdUrl ?? '', allChainsGasPriceSteps, - ) + )) + updateGasPriceSteps = true + } else if ( + hasToCalculateDynamicFee && + feeDenom.coinMinimalDenom === nativeFeeDenom?.coinMinimalDenom + ) { + ;({ low, medium, high } = await getFeeMarketGasPricesSteps(feeDenom.coinMinimalDenom)) + updateGasPriceSteps = true + } + if (updateGasPriceSteps) { switch (gasPriceOption.option) { case GasOptions.LOW: { setGasPriceOption((prev) => ({ @@ -123,7 +155,13 @@ export const CastVote: React.FC = ({ })() // eslint-disable-next-line react-hooks/exhaustive-deps - }, [activeChain, gasLimit, feeDenom.coinMinimalDenom, gasPriceOption.option]) + }, [ + activeChain, + gasLimit, + feeDenom.coinMinimalDenom, + gasPriceOption.option, + nativeFeeDenom?.coinMinimalDenom, + ]) const customFee = useMemo(() => { const gasEstimate = Math.ceil(Number(gasLimit) * gasAdjustment) @@ -141,7 +179,7 @@ export const CastVote: React.FC = ({ const submitVote = useCallback( async (option: VoteOptions) => { try { - const wallet = await getWallet() + const wallet = await getWallet(activeChain) const result = await vote({ wallet, callback: txCallback, @@ -152,13 +190,14 @@ export const CastVote: React.FC = ({ }, isSimulation: false, }) + return !!result } catch (e) { captureException(e) return false } }, - [customFee, feeDenom, getWallet, txCallback, vote], + [activeChain, customFee, feeDenom, getWallet, txCallback, vote], ) const handleCloseReviewVoteCastSheet = useCallback(() => { @@ -186,15 +225,13 @@ export const CastVote: React.FC = ({ const _estimate = result.gasUsed.toString() setRecommendedGasLimit( String( - Number(_estimate) * - (activeChainInfo.cosmosSDK === CosmosSDK.Version_Point_47 ? 1.5 : 1), + Number(_estimate) * (activeChainCosmosSDK === CosmosSDK.Version_Point_47 ? 1.5 : 1), ), ) if (firstTime.current) { setGasLimit( String( - Number(_estimate) * - (activeChainInfo.cosmosSDK === CosmosSDK.Version_Point_47 ? 1.5 : 1), + Number(_estimate) * (activeChainCosmosSDK === CosmosSDK.Version_Point_47 ? 1.5 : 1), ), ) firstTime.current = false @@ -210,14 +247,16 @@ export const CastVote: React.FC = ({ } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [activeChainInfo.cosmosSDK, proposalId, simulateVote]) + }, [activeChainCosmosSDK, proposalId, simulateVote]) useEffect(() => { setGasPriceOption({ option: GasOptions.LOW, gasPrice: defaultGasPrice.gasPrice, }) - }, [defaultGasPrice]) + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [defaultGasPrice.gasPrice.amount.toString(), defaultGasPrice.gasPrice.denom]) return (
@@ -229,6 +268,8 @@ export const CastVote: React.FC = ({ onGasPriceOptionChange={handleGasPriceOptionChange} error={gasError} setError={setGasError} + chain={activeChain} + network={selectedNetwork} > = ({ setRecommendedGasLimit={setRecommendedGasLimit} proposalId={proposalId} setGasLimit={setGasLimit} + forceChain={activeChain} + forceNetwork={selectedNetwork} /> @@ -269,6 +312,7 @@ export const CastVote: React.FC = ({ onCloseHandler={handleCloseReviewVoteCastSheet} showLedgerPopup={showLedgerPopup} gasOption={gasPriceOption.option} + forceChain={activeChain} />
diff --git a/apps/extension/src/pages/governance/CastVoteSheet.tsx b/apps/extension/src/pages/governance/components/CastVoteSheet.tsx similarity index 81% rename from apps/extension/src/pages/governance/CastVoteSheet.tsx rename to apps/extension/src/pages/governance/components/CastVoteSheet.tsx index 3272f2c9..5dd40ace 100644 --- a/apps/extension/src/pages/governance/CastVoteSheet.tsx +++ b/apps/extension/src/pages/governance/components/CastVoteSheet.tsx @@ -1,12 +1,21 @@ /* eslint-disable no-unused-vars */ -import { useActiveChain, useSimulateVote } from '@leapwallet/cosmos-wallet-hooks' -import { GasPrice, getSimulationFee, NativeDenom } from '@leapwallet/cosmos-wallet-sdk' +import { + useActiveChain, + useSelectedNetwork, + useSimulateVote, +} from '@leapwallet/cosmos-wallet-hooks' +import { + GasPrice, + getSimulationFee, + NativeDenom, + SupportedChain, +} from '@leapwallet/cosmos-wallet-sdk' import { Buttons } from '@leapwallet/leap-ui' import { captureException } from '@sentry/react' import classNames from 'classnames' import { DisplayFee } from 'components/gas-price-options/display-fee' import { LoaderAnimation } from 'components/loader/Loader' -import React, { useEffect, useRef, useState } from 'react' +import React, { useEffect, useMemo, useRef, useState } from 'react' import { Colors } from 'theme/colors' export enum VoteOptions { @@ -48,21 +57,31 @@ export type CastVoteSheetProps = { setRecommendedGasLimit: React.Dispatch> proposalId: string setGasLimit: React.Dispatch> + forceChain?: SupportedChain + forceNetwork?: 'mainnet' | 'testnet' } -function CastVoteSheet({ +export function CastVoteSheet({ onSubmitVote, setShowFeesSettingSheet, setRecommendedGasLimit, proposalId, setGasLimit, feeDenom, + forceChain, + forceNetwork, }: CastVoteSheetProps): React.ReactElement { - const [selectedOption, setSelectedOption] = useState(undefined) - const activeChain = useActiveChain() - const simulateVote = useSimulateVote() + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) + const _selectedNetwork = useSelectedNetwork() + const selectedNetwork = useMemo( + () => forceNetwork || _selectedNetwork, + [_selectedNetwork, forceNetwork], + ) + const simulateVote = useSimulateVote(activeChain, selectedNetwork) const firstTime = useRef(true) const [simulating, setSimulating] = useState(true) + const [selectedOption, setSelectedOption] = useState(undefined) useEffect(() => { let cancelled = false @@ -79,6 +98,7 @@ function CastVoteSheet({ if (result !== null && !cancelled) { const _estimate = result.gasUsed.toString() setRecommendedGasLimit(_estimate) + if (firstTime.current) { setGasLimit(_estimate) firstTime.current = false @@ -92,13 +112,12 @@ function CastVoteSheet({ } simulate().catch(captureException) - return () => { cancelled = true } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [proposalId, simulateVote]) + }, [feeDenom.coinMinimalDenom, proposalId, simulateVote]) return ( <> @@ -141,5 +160,3 @@ function CastVoteSheet({ ) } - -export default CastVoteSheet diff --git a/apps/extension/src/pages/governance/components/GenericProposalDetails.tsx b/apps/extension/src/pages/governance/components/GenericProposalDetails.tsx new file mode 100644 index 00000000..442e996a --- /dev/null +++ b/apps/extension/src/pages/governance/components/GenericProposalDetails.tsx @@ -0,0 +1,46 @@ +import { Proposal, ProposalApi } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import React from 'react' + +import { NtrnProposalDetails } from '../neutron' +import { ProposalDetails } from './index' + +export default function GenericProposalDetails({ + selectedProposalChain, + selectedProposalId, + handleProposalDetailsBack, + allProposals, + shouldUseFallback, + forceNetwork, +}: { + selectedProposalChain: SupportedChain + selectedProposalId: string + handleProposalDetailsBack: () => void + allProposals: (Proposal | ProposalApi)[] + shouldUseFallback: boolean + forceNetwork: 'mainnet' | 'testnet' +}) { + if (selectedProposalChain === 'neutron') { + return ( + + ) + } + + return ( + + ) +} diff --git a/apps/extension/src/pages/governance/components/ProposalCard.tsx b/apps/extension/src/pages/governance/components/ProposalCard.tsx new file mode 100644 index 00000000..e6783c8f --- /dev/null +++ b/apps/extension/src/pages/governance/components/ProposalCard.tsx @@ -0,0 +1,36 @@ +import { Proposal, ProposalApi, useChainInfo } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import React from 'react' + +import { ProposalStatus, ProposalStatusEnum } from './ProposalStatus' + +type ProposalCardProps = { + proposal: Proposal | ProposalApi + style?: React.CSSProperties + handleClick: () => void +} + +export function ProposalCard({ proposal, style, handleClick }: ProposalCardProps) { + const chainInfo = useChainInfo((proposal.chain ?? 'cosmos') as SupportedChain) + + return ( +
+

+ {chainInfo?.chainName ?? 'Unknown Chain'} +

+

+ {(proposal as ProposalApi)?.title ?? (proposal as Proposal)?.content?.title} +

+

+ #{proposal.proposal_id} · +

+
+ ) +} diff --git a/apps/extension/src/pages/governance/components/ProposalDetails.tsx b/apps/extension/src/pages/governance/components/ProposalDetails.tsx new file mode 100644 index 00000000..d7637aca --- /dev/null +++ b/apps/extension/src/pages/governance/components/ProposalDetails.tsx @@ -0,0 +1,348 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { + useActiveChain, + useAddress, + useChainApis, + useChainInfo, + useFetchStakeDelegations, + useGetProposal, + useSelectedNetwork, + useStakeDelegations, +} from '@leapwallet/cosmos-wallet-hooks' +import { axiosWrapper, SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { Header, HeaderActionType, LineDivider } from '@leapwallet/leap-ui' +import { captureException } from '@sentry/react' +import { useQuery } from '@tanstack/react-query' +import axios from 'axios' +import PopupLayout from 'components/layout/popup-layout' +import { ProposalDescription } from 'components/proposal-description' +import Text from 'components/text' +import { useChainPageInfo } from 'hooks' +import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' +import React, { useMemo, useState } from 'react' +import Skeleton from 'react-loading-skeleton' +import { PieChart } from 'react-minimal-pie-chart' +import { imgOnError } from 'utils/imgOnError' + +import { getPercentage } from '../utils' +import { CastVote, RequireMinStaking, ShowVotes, Turnout, VoteDetails } from './index' +import { ProposalStatus, ProposalStatusEnum } from './ProposalStatus' + +export type ProposalDetailsProps = { + selectedProp: string | undefined + onBack: () => void + proposalList: any[] + shouldUseFallback: boolean + forceChain?: SupportedChain + forceNetwork?: 'mainnet' | 'testnet' +} + +const activeProposalStatusTypes = [ + ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD, + ProposalStatusEnum.PROPOSAL_STATUS_DEPOSIT_PERIOD, +] + +export function ProposalDetails({ + selectedProp, + onBack, + proposalList, + shouldUseFallback, + forceChain, + forceNetwork, +}: ProposalDetailsProps) { + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) + const _selectedNetwork = useSelectedNetwork() + const selectedNetwork = useMemo( + () => forceNetwork || _selectedNetwork, + [_selectedNetwork, forceNetwork], + ) + + const address = useAddress(activeChain) + const activeChainInfo = useChainInfo(activeChain) + const { lcdUrl, txUrl } = useChainApis(activeChain, selectedNetwork) + const [showCastVoteSheet, setShowCastVoteSheet] = useState(false) + const defaultTokenLogo = useDefaultTokenLogo() + + useFetchStakeDelegations(activeChain, selectedNetwork) + const { delegationInfo } = useStakeDelegations() + const hasMinAmountStaked = useMemo(() => { + if (activeChain === 'cosmos') { + return delegationInfo?.totalDelegation?.gte(1) + } + + return true + }, [activeChain, delegationInfo?.totalDelegation]) + + const { topChainColor } = useChainPageInfo() + const proposal = useMemo( + () => proposalList.find((prop) => prop.proposal_id === selectedProp), + [proposalList, selectedProp], + ) + + const { + data: currVote, + refetch, + isLoading, + } = useQuery( + ['currVote', activeChain, address, selectedProp], + async (): Promise => { + if (activeChain) { + try { + const { data } = await axios.post( + `${process.env.LEAP_WALLET_BACKEND_API_URL}/gov/vote/${activeChainInfo.chainId}/${selectedProp}`, + { userAddress: address }, + ) + return data + } catch (error: any) { + try { + const data = await axiosWrapper( + { + baseURL: lcdUrl ?? '', + method: 'get', + url: `/cosmos/gov/v1beta1/proposals/${selectedProp}/votes/${address}`, + }, + 1, + 'proposals-votes', + ) + + const voteOption = data.data.vote.options[0].option + return voteOption.replace('VOTE_OPTION_', '') + } catch (error: any) { + if (error.response.data.code === 3 || error.response.data.error?.code === -32700) { + return 'NO_VOTE' + } else { + captureException(error) + throw new Error(error) + } + } + } + } + }, + { + retry: (failureCount) => { + return failureCount !== 2 + }, + enabled: proposal.status === ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD, + }, + ) + + // eslint-disable-next-line prefer-const + let { data: _proposalVotes, status } = useGetProposal( + proposal.proposal_id, + shouldUseFallback, + activeChain, + selectedNetwork, + ) + + status = shouldUseFallback ? status : 'success' + const { yes, no, abstain, no_with_veto } = (proposal.tally || + _proposalVotes || + proposal.final_tally_result) as any + const totalVotes = [yes, no, abstain, no_with_veto].reduce((sum, val) => sum + Number(val), 0) + + const dataMock = useMemo(() => { + return !totalVotes + ? [{ title: 'loading', value: 1, color: '#ccc', percent: '0%' }] + : [ + { + title: 'YES', + value: +yes, + color: '#29A874', + percent: getPercentage(+yes, totalVotes), + }, + { + title: 'NO', + value: +no, + color: '#FF707E', + percent: getPercentage(+no, totalVotes), + }, + { + title: 'No with Veto', + value: +no_with_veto, + color: '#8583EC', + percent: getPercentage(+no_with_veto, totalVotes), + }, + { + title: 'Abstain', + value: +abstain, + color: '#D1A700', + percent: getPercentage(+abstain, totalVotes), + }, + ] + }, [abstain, no, no_with_veto, totalVotes, yes]) + + const tallying = useMemo(() => { + return [ + { + label: 'Turnout', + value: !shouldUseFallback + ? proposal.turnout + : (totalVotes / (_proposalVotes as any)?.bonded_tokens) * 100, + }, + { + label: 'Quorum', + value: !shouldUseFallback ? proposal.quorum : (_proposalVotes as any)?.quorum * 100, + }, + ] + }, [_proposalVotes, proposal.quorum, proposal.turnout, shouldUseFallback, totalVotes]) + + const proposer = useMemo(() => { + if (!shouldUseFallback) { + return proposal?.proposer?.address + ? { + address: proposal?.proposer?.address, + url: + proposal?.proposer?.url ?? + `${txUrl?.replace('txs', 'account')}/${proposal?.proposer?.address}`, + } + : undefined + } + return _proposalVotes?.proposer?.depositor + ? { + address: _proposalVotes?.proposer?.depositor as string, + url: _proposalVotes?.proposerTxUrl as string | undefined, + } + : undefined + }, [ + _proposalVotes?.proposer?.depositor, + _proposalVotes?.proposerTxUrl, + proposal?.proposer?.address, + proposal?.proposer?.url, + shouldUseFallback, + txUrl, + ]) + + return ( +
+ +
+
+
+ #{proposal.proposal_id} ·{' '} + +
+
+ {proposal?.title ?? proposal?.content?.title} +
+ + {proposal.status === ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD && + !hasMinAmountStaked && ( + + )} + + setShowCastVoteSheet(true)} + currVote={currVote ?? ''} + isLoading={isLoading} + hasMinStaked={hasMinAmountStaked} + /> + +
+ +
+ + {proposal.status !== ProposalStatusEnum.PROPOSAL_STATUS_DEPOSIT_PERIOD && totalVotes && ( + <> +
+
+ {status !== 'success' ? ( + + ) : ( + + )} + +

+ Current Status +

+
+
+ + + + + )} + + {activeProposalStatusTypes.includes(proposal.status) && proposer?.address && ( +
+
+
+ 👤 + chain logo +
+ +
+ + Proposer + + {proposer ? ( + + {`${proposer.address.slice(0, 5)}...${proposer.address.slice(-6)}`} + + ) : ( + + )} +
+
+ + {proposer?.url && ( + + )} +
+ )} + +
+ +
+ + {(proposal?.description || proposal?.content?.description) && ( + + )} +
+ + + +
+ ) +} diff --git a/apps/extension/src/pages/governance/Status.tsx b/apps/extension/src/pages/governance/components/ProposalStatus.tsx similarity index 72% rename from apps/extension/src/pages/governance/Status.tsx rename to apps/extension/src/pages/governance/components/ProposalStatus.tsx index e4a8915c..d4670af7 100644 --- a/apps/extension/src/pages/governance/Status.tsx +++ b/apps/extension/src/pages/governance/components/ProposalStatus.tsx @@ -1,7 +1,7 @@ /* eslint-disable no-unused-vars */ import React from 'react' -export enum ProposalStatus { +export enum ProposalStatusEnum { PROPOSAL_STATUS_IN_PROGRESS = 'PROPOSAL_STATUS_IN_PROGRESS', PROPOSAL_STATUS_DEPOSIT_PERIOD = 'PROPOSAL_STATUS_DEPOSIT_PERIOD', PROPOSAL_STATUS_VOTING_PERIOD = 'PROPOSAL_STATUS_VOTING_PERIOD', @@ -13,30 +13,28 @@ export enum ProposalStatus { } export type ProposalStatusProps = { - status: ProposalStatus + status: ProposalStatusEnum } -function Status({ status }: ProposalStatusProps): JSX.Element { +export function ProposalStatus({ status }: ProposalStatusProps): JSX.Element { switch (status) { - case ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD: + case ProposalStatusEnum.PROPOSAL_STATUS_DEPOSIT_PERIOD: return ( Deposit Period ) - case ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD: + case ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD: return ( Voting Period ) - case ProposalStatus.PROPOSAL_STATUS_PASSED: + case ProposalStatusEnum.PROPOSAL_STATUS_PASSED: return Passed - case ProposalStatus.PROPOSAL_STATUS_FAILED: + case ProposalStatusEnum.PROPOSAL_STATUS_FAILED: return Failed - case ProposalStatus.PROPOSAL_STATUS_REJECTED: + case ProposalStatusEnum.PROPOSAL_STATUS_REJECTED: return Rejected - case ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED: + case ProposalStatusEnum.PROPOSAL_STATUS_UNSPECIFIED: return Unspecified default: return Unspecified } } - -export default Status diff --git a/apps/extension/src/pages/governance/RequireMinStaking.tsx b/apps/extension/src/pages/governance/components/RequireMinStaking.tsx similarity index 72% rename from apps/extension/src/pages/governance/RequireMinStaking.tsx rename to apps/extension/src/pages/governance/components/RequireMinStaking.tsx index 49eba706..6d117d71 100644 --- a/apps/extension/src/pages/governance/RequireMinStaking.tsx +++ b/apps/extension/src/pages/governance/components/RequireMinStaking.tsx @@ -1,10 +1,16 @@ import { useActiveStakingDenom, useChainInfo } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import React, { useCallback } from 'react' import { useNavigate } from 'react-router' -const RequireMinStaking = () => { - const chainInfo = useChainInfo() - const [activeStakingDenom] = useActiveStakingDenom() +type RequireMinStakingProps = { + forceChain?: SupportedChain + forceNetwork?: 'mainnet' | 'testnet' +} + +export function RequireMinStaking({ forceChain, forceNetwork }: RequireMinStakingProps) { + const chainInfo = useChainInfo(forceChain) + const [activeStakingDenom] = useActiveStakingDenom(forceChain, forceNetwork) const navigate = useNavigate() const handleButtonClick = useCallback(() => { @@ -27,5 +33,3 @@ const RequireMinStaking = () => {
) } - -export default RequireMinStaking diff --git a/apps/extension/src/pages/governance/ReviewVoteCast.tsx b/apps/extension/src/pages/governance/components/ReviewVoteCast.tsx similarity index 89% rename from apps/extension/src/pages/governance/ReviewVoteCast.tsx rename to apps/extension/src/pages/governance/components/ReviewVoteCast.tsx index dae66d49..10bea959 100644 --- a/apps/extension/src/pages/governance/ReviewVoteCast.tsx +++ b/apps/extension/src/pages/governance/components/ReviewVoteCast.tsx @@ -4,6 +4,7 @@ import { useActiveChain, VoteOptions, } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { Buttons, Memo } from '@leapwallet/leap-ui' import classNames from 'classnames' import BottomModal from 'components/bottom-modal' @@ -11,11 +12,10 @@ import { ErrorCard } from 'components/ErrorCard' import LedgerConfirmationPopup from 'components/ledger-confirmation/LedgerConfirmationPopup' import { LoaderAnimation } from 'components/loader/Loader' import Text from 'components/text' -import React from 'react' +import { useCaptureTxError } from 'hooks/utility/useCaptureTxError' +import React, { useMemo } from 'react' import { Colors } from 'theme/colors' -import { useCaptureTxError } from '../../hooks/utility/useCaptureTxError' - export type ReviewVoteCastProps = { isOpen: boolean onCloseHandler: () => void @@ -33,9 +33,10 @@ export type ReviewVoteCastProps = { showLedgerPopup?: boolean ledgerError?: string gasOption: GasOptions + forceChain?: SupportedChain } -function ReviewVoteCast({ +export function ReviewVoteCast({ isOpen, onCloseHandler, onSubmitVote, @@ -50,11 +51,12 @@ function ReviewVoteCast({ showLedgerPopup, ledgerError, gasOption, + forceChain, }: ReviewVoteCastProps): React.ReactElement { - const activeChain = useActiveChain() + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) useCaptureTxError(error) - if (showLedgerPopup) { return } @@ -116,5 +118,3 @@ function ReviewVoteCast({ ) } - -export default ReviewVoteCast diff --git a/apps/extension/src/pages/governance/components/ShowVotes.tsx b/apps/extension/src/pages/governance/components/ShowVotes.tsx new file mode 100644 index 00000000..e5783971 --- /dev/null +++ b/apps/extension/src/pages/governance/components/ShowVotes.tsx @@ -0,0 +1,71 @@ +import { ChainInfo } from '@leapwallet/cosmos-wallet-sdk' +import Text from 'components/text' +import useHorizontalScroll from 'hooks/useHorizontalScroll' +import React from 'react' +import Skeleton from 'react-loading-skeleton' + +import { chainDecimals } from '../utils' + +type IShowVotes = { + dataMock: { + title: string + value: number + color: string + percent: string + }[] + chain: ChainInfo +} + +export function ShowVotes({ dataMock, chain }: IShowVotes) { + const { scrollRef, props } = useHorizontalScroll() + const decimals = + Object.values(chain.nativeDenoms)?.[0]?.coinDecimals ?? + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (chainDecimals as any)[chain?.bip44?.coinType] + + return ( +
+
+ {dataMock.map((item) => { + const isLoading = item.title === 'loading' + + return ( +
+ {isLoading ? ( + + ) : ( + <> +
+
+

{`${item.title} - ${item.percent}`}

+
+ + {`${new Intl.NumberFormat('en-US').format( + +Number(item.value / Math.pow(10, decimals)).toFixed(2), + )} ${chain.denom}`} + + + )} +
+ ) + })} +
+
+ ) +} diff --git a/apps/extension/src/pages/governance/components/Turnout.tsx b/apps/extension/src/pages/governance/components/Turnout.tsx new file mode 100644 index 00000000..79dbf3c0 --- /dev/null +++ b/apps/extension/src/pages/governance/components/Turnout.tsx @@ -0,0 +1,61 @@ +import { CardDivider } from '@leapwallet/leap-ui' +import BottomModal from 'components/bottom-modal' +import Text from 'components/text' +import React, { Fragment, useState } from 'react' +import Skeleton from 'react-loading-skeleton' + +type ITally = { + label: string + value: number +} + +export function Turnout({ tallying }: { tallying: ITally[] }) { + const [detail, showDetail] = useState('') + + return ( + <> +
+ {tallying.map((tally, index) => ( + +
+
+

{tally.label}

+ +
+ + {tally.value ? ( +

+ {`${Number(tally.value).toFixed(2)}%`} +

+ ) : ( + + )} +
+ + {index === 0 && } +
+ ))} +
+ + showDetail('')} + title={detail} + closeOnBackdropClick={true} + > + + {detail === 'Turnout' + ? 'Defined as the percentage of voting power already casted on a proposal as a percentage of total staked tokens.' + : 'Defined as the minimum percentage of voting power that needs to be cast on a proposal for the result to be valid.'} + + + + ) +} diff --git a/apps/extension/src/pages/governance/components/VoteDetails.tsx b/apps/extension/src/pages/governance/components/VoteDetails.tsx new file mode 100644 index 00000000..91d0268e --- /dev/null +++ b/apps/extension/src/pages/governance/components/VoteDetails.tsx @@ -0,0 +1,198 @@ +import { Proposal, ProposalApi } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { Buttons, CardDivider } from '@leapwallet/leap-ui' +import classNames from 'classnames' +import dayjs from 'dayjs' +import React, { useEffect, useState } from 'react' +import Skeleton from 'react-loading-skeleton' +import { Colors } from 'theme/colors' + +import { convertTime, voteRatio } from '../utils' +import { ProposalStatusEnum } from './ProposalStatus' + +type VoteDetailsProps = { + proposal: Proposal | ProposalApi + currVote: string + isLoading: boolean + activeChain: SupportedChain + onVote: () => void + hasMinStaked: boolean +} + +export function VoteDetails({ + currVote, + proposal, + isLoading, + activeChain, + hasMinStaked, + onVote, +}: VoteDetailsProps) { + const [timeLeft, setTimeLeft] = useState() + + useEffect(() => { + const getTime = () => { + const now = dayjs() + const end = dayjs( + proposal.status === ProposalStatusEnum.PROPOSAL_STATUS_DEPOSIT_PERIOD + ? proposal.deposit_end_time + : proposal.voting_end_time, + ) + const duration = end.diff(now, 'seconds') + setTimeLeft(convertTime(duration)) + } + + const i = setInterval(getTime, 1000) + return () => clearInterval(i) + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [proposal, convertTime]) + + switch (proposal.status) { + case ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD: + return ( + <> +
+
+
+ Voting Starts +
+ +
+ {dayjs(proposal.voting_start_time).format('MMM DD, YYYY')} +
+
+ + + +
+
+ Voting Ends +
+ +
+ {dayjs(proposal.voting_end_time).format('MMM DD, YYYY')} +
+
+ +
+ {timeLeft && `Ending in ${timeLeft}`} +
+
+ + {isLoading ? ( +
+ + +
+ + +
+
+ ) : null} + + {currVote && currVote !== 'NO_VOTE' && ( +
+
+ thumb_up +
+ +
+
Vote submitted
+
Voted {currVote}
+
+
+ )} + + onVote()} + disabled={!hasMinStaked} + > +
+ how_to_vote + Vote +
+
+ + ) + + case ProposalStatusEnum.PROPOSAL_STATUS_DEPOSIT_PERIOD: + return ( + <> +
+
+
+ Deposit Period Ends +
+
+ {dayjs(proposal.deposit_end_time).format('MMM DD, YYYY')} +
+
+ {timeLeft && ( +
+ {timeLeft && `Ending in ${timeLeft}`} +
+ )} +
+ + ) + + case ProposalStatusEnum.PROPOSAL_STATUS_PASSED: + case ProposalStatusEnum.PROPOSAL_STATUS_FAILED: + case ProposalStatusEnum.PROPOSAL_STATUS_REJECTED: + return ( + <> +
+
+
+ Results +
+
+
+ +
+ {voteRatio( + (proposal as unknown as ProposalApi).tally || proposal.final_tally_result, + ).map((values) => ( +
+
+ {values.label} +
+
+ + {values.percentage.toFixed(2)} + +
+
+
+ ))} +
+
+ + ) + } + + return <> +} diff --git a/apps/extension/src/pages/governance/components/index.ts b/apps/extension/src/pages/governance/components/index.ts new file mode 100644 index 00000000..8c9d88e2 --- /dev/null +++ b/apps/extension/src/pages/governance/components/index.ts @@ -0,0 +1,12 @@ +export * from './AggregatedGovernance' +export * from './AggregatedGovernanceNullComponents' +export * from './CastVote' +export * from './CastVoteSheet' +export * from './ProposalCard' +export * from './ProposalDetails' +export * from './ProposalStatus' +export * from './RequireMinStaking' +export * from './ReviewVoteCast' +export * from './ShowVotes' +export * from './Turnout' +export * from './VoteDetails' diff --git a/apps/extension/src/pages/governance/neutron/NtrnCastVote.tsx b/apps/extension/src/pages/governance/neutron/NtrnCastVote.tsx index 1c9f6d97..8a35c36e 100644 --- a/apps/extension/src/pages/governance/neutron/NtrnCastVote.tsx +++ b/apps/extension/src/pages/governance/neutron/NtrnCastVote.tsx @@ -5,6 +5,7 @@ import { useActiveChain, useNtrnGov, } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { Buttons } from '@leapwallet/leap-ui' import classNames from 'classnames' import BottomModal from 'components/bottom-modal' @@ -15,13 +16,13 @@ import { FeesSettingsSheet } from 'components/gas-price-options/fees-settings-sh import { LoaderAnimation } from 'components/loader/Loader' import { useCaptureTxError } from 'hooks/utility/useCaptureTxError' import { Wallet } from 'hooks/wallet/useWallet' -import React, { useCallback, useEffect, useState } from 'react' +import React, { useCallback, useEffect, useMemo, useState } from 'react' import { Colors } from 'theme/colors' import { useTxCallBack } from 'utils/txCallback' -import { CastVoteProps } from '../CastVote' -import { VoteOptions } from '../CastVoteSheet' +import { CastVoteProps } from '../components' import { NtrnReviewVoteCast } from './index' +import { VoteOptions } from './utils' const useGetWallet = Wallet.useGetWallet @@ -52,6 +53,7 @@ type CastVoteSheetProps = { onCloseHandler: () => void showFeesSettingSheet: boolean gasError: string + forceChain?: SupportedChain simulateNtrnVote: ( wallet: OfflineSigner, proposalId: number, @@ -67,11 +69,14 @@ function CastVoteSheet({ onSubmitVote, showFeesSettingSheet, gasError, + forceChain, simulateNtrnVote, }: CastVoteSheetProps) { const [selectedOption, setSelectedOption] = useState(undefined) - const activeChain = useActiveChain() - const getWallet = useGetWallet() + + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) + const getWallet = useGetWallet(forceChain) const [simulateError, setSimulateError] = useState('') const [isSimulating, setIsSimulating] = useState(false) @@ -145,9 +150,14 @@ export function NtrnCastVote({ showCastVoteSheet, setShowCastVoteSheet, className, + forceChain, + forceNetwork, }: CastVoteProps) { - const getWallet = useGetWallet() - const defaultGasPrice = useDefaultGasPrice() + const getWallet = useGetWallet(forceChain) + const defaultGasPrice = useDefaultGasPrice({ + activeChain: forceChain, + selectedNetwork: forceNetwork, + }) const txCallback = useTxCallBack() const { @@ -166,7 +176,7 @@ export function NtrnCastVote({ isVoting, handleVote, simulateNtrnVote, - } = useNtrnGov() + } = useNtrnGov(forceChain, forceNetwork) const [selectedVoteOption, setSelectedVoteOption] = useState(undefined) const [showFeesSettingSheet, setShowFeesSettingSheet] = useState(false) @@ -232,6 +242,8 @@ export function NtrnCastVote({ onGasPriceOptionChange={handleGasPriceOptionChange} error={gasError} setError={setGasError} + chain={forceChain} + network={forceNetwork} >
diff --git a/apps/extension/src/pages/governance/neutron/NtrnProposalDetails.tsx b/apps/extension/src/pages/governance/neutron/NtrnProposalDetails.tsx index 7783ac82..1a7b305e 100644 --- a/apps/extension/src/pages/governance/neutron/NtrnProposalDetails.tsx +++ b/apps/extension/src/pages/governance/neutron/NtrnProposalDetails.tsx @@ -1,5 +1,10 @@ -import { useActiveChain, useChainApis, useChainsStore } from '@leapwallet/cosmos-wallet-hooks' -import { getNeutronProposalVote } from '@leapwallet/cosmos-wallet-sdk' +import { + useActiveChain, + useAddress, + useChainApis, + useChainsStore, +} from '@leapwallet/cosmos-wallet-hooks' +import { getNeutronProposalVote, SupportedChain } from '@leapwallet/cosmos-wallet-sdk' import { Buttons, Header, HeaderActionType, LineDivider } from '@leapwallet/leap-ui' import { useQuery } from '@tanstack/react-query' import axios from 'axios' @@ -8,34 +13,29 @@ import PopupLayout from 'components/layout/popup-layout' import { ProposalDescription } from 'components/proposal-description' import Text from 'components/text' import dayjs from 'dayjs' +import { useSelectedNetwork } from 'hooks/settings/useNetwork' import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' -import { useAddress } from 'hooks/wallet/useAddress' import React, { useEffect, useMemo, useState } from 'react' import Skeleton from 'react-loading-skeleton' import { PieChart } from 'react-minimal-pie-chart' import { Colors } from 'theme/colors' -import { voteRatio } from 'utils/gov/voteRatio' import { imgOnError } from 'utils/imgOnError' -import { VoteOptions } from '../CastVoteSheet' -import { - convertTime, - getPercentage, - ProposalDetailsProps, - ShowVotes, - Turnout, -} from '../ProposalDetails' +import { ProposalDetailsProps, ProposalStatusEnum, ShowVotes, Turnout } from '../components' +import { convertTime, getPercentage, voteRatio } from '../utils' import { NtrnCastVote, NtrnStatus } from './index' import { NtrnProposalStatus } from './NtrnStatus' import { getDescription, getEndTime, + getId, getProposer, getQuorum, getStatus, getTitle, getTurnout, getVotes, + VoteOptions, } from './utils' type VoteDetailsProps = { @@ -45,6 +45,7 @@ type VoteDetailsProps = { currVote: string isLoading: boolean shouldUseFallback: boolean + forceChain?: SupportedChain } function VoteDetails({ @@ -53,9 +54,11 @@ function VoteDetails({ currVote, isLoading, shouldUseFallback, + forceChain, }: VoteDetailsProps) { const [timeLeft, setTimeLeft] = useState() - const activeChain = useActiveChain() + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) useEffect(() => { const getTime = () => { @@ -71,6 +74,8 @@ function VoteDetails({ switch (getStatus(proposal, shouldUseFallback)) { case NtrnProposalStatus.OPEN: + case ProposalStatusEnum.PROPOSAL_STATUS_IN_PROGRESS: + case ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD: return ( <>
@@ -132,6 +137,10 @@ function VoteDetails({ case NtrnProposalStatus.EXECUTED: case NtrnProposalStatus.PASSED: case NtrnProposalStatus.REJECTED: + case ProposalStatusEnum.PROPOSAL_STATUS_PASSED: + case ProposalStatusEnum.PROPOSAL_STATUS_EXECUTED: + case ProposalStatusEnum.PROPOSAL_STATUS_FAILED: + case ProposalStatusEnum.PROPOSAL_STATUS_REJECTED: return (
@@ -185,13 +194,21 @@ export function NtrnProposalDetails({ onBack, proposalList, shouldUseFallback, + forceChain, + forceNetwork, }: ProposalDetailsProps) { const { chains } = useChainsStore() - const activeChain = useActiveChain() - const chain = chains[activeChain] - const address = useAddress() + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) + const _selectedNetwork = useSelectedNetwork() + const selectedNetwork = useMemo( + () => forceNetwork || _selectedNetwork, + [_selectedNetwork, forceNetwork], + ) - const { rpcUrl, txUrl } = useChainApis() + const address = useAddress(activeChain) + const chain = chains[activeChain] + const { rpcUrl, txUrl } = useChainApis(activeChain, selectedNetwork) const defaultTokenLogo = useDefaultTokenLogo() const [showCastVoteSheet, setShowCastVoteSheet] = useState(false) @@ -205,6 +222,14 @@ export function NtrnProposalDetails({ const { abstain, yes, no } = shouldUseFallback ? proposal.proposal.votes : proposal.tally const totalVotes = [yes, no, abstain].reduce((sum, val) => sum + Number(val), 0) + const isProposalInVotingPeriod = useMemo(() => { + return [ + NtrnProposalStatus.OPEN, + ProposalStatusEnum.PROPOSAL_STATUS_IN_PROGRESS, + ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD, + ].includes(getStatus(proposal, shouldUseFallback)) + }, [proposal, shouldUseFallback]) + const dataMock = useMemo(() => { return !totalVotes ? [{ title: 'loading', value: 1, color: '#ccc', percent: '0%' }] @@ -262,7 +287,7 @@ export function NtrnProposalDetails({ }, { retry: (failureCount) => failureCount <= 2, - enabled: getStatus(proposal, shouldUseFallback) === NtrnProposalStatus.OPEN && !!rpcUrl, + enabled: isProposalInVotingPeriod && !!rpcUrl, }, ) @@ -278,7 +303,8 @@ export function NtrnProposalDetails({ />
- #{proposal.id} · + #{getId(proposal, shouldUseFallback)} ·{' '} +
{getTitle(proposal, shouldUseFallback)} @@ -290,6 +316,7 @@ export function NtrnProposalDetails({ currVote={currVote?.vote} isLoading={isLoading} shouldUseFallback={shouldUseFallback} + forceChain={forceChain} />
@@ -312,7 +339,7 @@ export function NtrnProposalDetails({ )} - {getStatus(proposal, shouldUseFallback) === NtrnProposalStatus.OPEN && ( + {isProposalInVotingPeriod && (
)}
diff --git a/apps/extension/src/pages/governance/neutron/NtrnProposalList.tsx b/apps/extension/src/pages/governance/neutron/NtrnProposalList.tsx index d3f7647d..a905a702 100644 --- a/apps/extension/src/pages/governance/neutron/NtrnProposalList.tsx +++ b/apps/extension/src/pages/governance/neutron/NtrnProposalList.tsx @@ -1,6 +1,6 @@ import { useActiveChain } from '@leapwallet/cosmos-wallet-hooks' import { CardDivider, Header, HeaderActionType } from '@leapwallet/leap-ui' -import SelectedChainAlertStrip from 'components/alert-strip/SelectedChainAlertStrip' +import { TestnetAlertStrip } from 'components/alert-strip' import BottomModal from 'components/bottom-modal' import { EmptyCard } from 'components/empty-card' import PopupLayout from 'components/layout/popup-layout' @@ -12,7 +12,6 @@ import { Images } from 'images' import SelectChain from 'pages/home/SelectChain' import React, { Fragment, useMemo, useState } from 'react' import { useNavigate } from 'react-router-dom' -import { Colors } from 'theme/colors' import { sliceSearchWord } from 'utils/strings' import { ProposalListProps } from '../ProposalList' @@ -45,7 +44,6 @@ export function NtrnProposalList({ const loading = proposalListStatus === 'loading' const activeChainInfo = chainInfos[activeChain] - const themeColor = Colors.getChainColor(activeChain, activeChainInfo) const filteredProposalList = useMemo(() => { return _proposalList?.reduce((acc, curr) => { @@ -89,11 +87,10 @@ export function NtrnProposalList({ imgSrc={activeChainInfo.chainSymbolImageUrl ?? defaultTokenLogo} onImgClick={() => setShowChainSelector(true)} title='Governance' - topColor={themeColor} /> } > - +
Proposals
diff --git a/apps/extension/src/pages/governance/neutron/NtrnReviewVoteCast.tsx b/apps/extension/src/pages/governance/neutron/NtrnReviewVoteCast.tsx index 8e553d54..85288fc6 100644 --- a/apps/extension/src/pages/governance/neutron/NtrnReviewVoteCast.tsx +++ b/apps/extension/src/pages/governance/neutron/NtrnReviewVoteCast.tsx @@ -5,10 +5,10 @@ import { ErrorCard } from 'components/ErrorCard' import { DisplayFee } from 'components/gas-price-options/display-fee' import { LoaderAnimation } from 'components/loader/Loader' import { useCaptureTxError } from 'hooks/utility/useCaptureTxError' -import React from 'react' +import React, { useMemo } from 'react' import { Colors } from 'theme/colors' -import { ReviewVoteCastProps } from '../ReviewVoteCast' +import { ReviewVoteCastProps } from '../components/ReviewVoteCast' export function NtrnReviewVoteCast({ isOpen, @@ -21,8 +21,10 @@ export function NtrnReviewVoteCast({ setMemo, proposalId, gasOption, + forceChain, }: Omit) { - const activeChain = useActiveChain() + const _activeChain = useActiveChain() + const activeChain = useMemo(() => forceChain || _activeChain, [_activeChain, forceChain]) useCaptureTxError(error) return ( diff --git a/apps/extension/src/pages/governance/neutron/NtrnStatus.tsx b/apps/extension/src/pages/governance/neutron/NtrnStatus.tsx index 49322d9b..d12f219e 100644 --- a/apps/extension/src/pages/governance/neutron/NtrnStatus.tsx +++ b/apps/extension/src/pages/governance/neutron/NtrnStatus.tsx @@ -1,6 +1,8 @@ /* eslint-disable no-unused-vars */ import React from 'react' +import { ProposalStatusEnum } from '../components' + export enum NtrnProposalStatus { OPEN = 'open', EXECUTED = 'executed', @@ -9,18 +11,24 @@ export enum NtrnProposalStatus { } type NtrnStatusProps = { - status: NtrnProposalStatus + status: NtrnProposalStatus | ProposalStatusEnum } export function NtrnStatus({ status }: NtrnStatusProps) { switch (status) { case NtrnProposalStatus.OPEN: + case ProposalStatusEnum.PROPOSAL_STATUS_IN_PROGRESS: + case ProposalStatusEnum.PROPOSAL_STATUS_VOTING_PERIOD: return ( In Progress ) case NtrnProposalStatus.PASSED: case NtrnProposalStatus.EXECUTED: + case ProposalStatusEnum.PROPOSAL_STATUS_PASSED: + case ProposalStatusEnum.PROPOSAL_STATUS_EXECUTED: return Executed + case ProposalStatusEnum.PROPOSAL_STATUS_FAILED: + case ProposalStatusEnum.PROPOSAL_STATUS_REJECTED: case NtrnProposalStatus.REJECTED: return Rejected default: diff --git a/apps/extension/src/pages/governance/neutron/utils.ts b/apps/extension/src/pages/governance/neutron/utils.ts index 060fd8a8..87ea0e0a 100644 --- a/apps/extension/src/pages/governance/neutron/utils.ts +++ b/apps/extension/src/pages/governance/neutron/utils.ts @@ -1,4 +1,12 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ + +export enum VoteOptions { + YES = 'Yes', + NO = 'No', + NO_WITH_VETO = 'No with Veto', + ABSTAIN = 'Abstain', +} + export const getTitle = (proposal: any, shouldPreferFallback: boolean) => { if (shouldPreferFallback === true) { return proposal?.proposal?.title diff --git a/apps/extension/src/pages/governance/utils/constants.ts b/apps/extension/src/pages/governance/utils/constants.ts new file mode 100644 index 00000000..304e53e2 --- /dev/null +++ b/apps/extension/src/pages/governance/utils/constants.ts @@ -0,0 +1,20 @@ +import { CoinType } from '@leapwallet/cosmos-wallet-sdk' + +export const chainDecimals: Record = { + '60': 18, + '118': 6, + '529': 6, + '750': 6, + '394': 8, + '234': 6, + '564': 6, + '852': 6, + '639': 6, + '459': 6, + '330': 6, + '990': 6, + '931': 6, + '4444': 6, + '505': 9, + '494': 6, +} diff --git a/apps/extension/src/pages/governance/utils/convertTime.ts b/apps/extension/src/pages/governance/utils/convertTime.ts new file mode 100644 index 00000000..47f4e069 --- /dev/null +++ b/apps/extension/src/pages/governance/utils/convertTime.ts @@ -0,0 +1,13 @@ +export function convertTime(seconds: number) { + let sec: number | string = seconds + let hours: number | string = Math.floor(sec / 3600) + hours >= 1 ? (sec = sec - hours * 3600) : (hours = '00') + let min: number | string = Math.floor(sec / 60) + min >= 1 ? (sec = sec - min * 60) : (min = '00') + sec < 1 ? (sec = '00') : void 0 + + min.toString().length == 1 ? (min = '0' + min) : void 0 + sec.toString().length == 1 ? (sec = '0' + sec) : void 0 + + return hours + ':' + min + ':' + sec +} diff --git a/apps/extension/src/pages/governance/utils/filterSearchedProposal.ts b/apps/extension/src/pages/governance/utils/filterSearchedProposal.ts new file mode 100644 index 00000000..88c020e4 --- /dev/null +++ b/apps/extension/src/pages/governance/utils/filterSearchedProposal.ts @@ -0,0 +1,34 @@ +import { Proposal, ProposalApi } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' + +export function filterSearchedProposal( + proposal: Proposal | ProposalApi, + searchedText: string, + chains: Record, +) { + if (!searchedText) { + return true + } + + const formattedSearchedText = searchedText.trim().toLowerCase() + const chainName = proposal.chain ? chains[proposal.chain as SupportedChain].chainName : '' + if (chainName.toLowerCase().includes(formattedSearchedText)) { + return true + } + + const proposalTitle = + (proposal as ProposalApi)?.title ?? (proposal as Proposal)?.content?.title ?? '' + if (proposalTitle.toLowerCase().includes(formattedSearchedText)) { + return true + } + + if (proposal.proposal_id.toString().includes(formattedSearchedText)) { + return true + } + + if (proposal.status.toLowerCase().includes(formattedSearchedText)) { + return true + } + + return false +} diff --git a/apps/extension/src/pages/governance/utils/getPercentage.ts b/apps/extension/src/pages/governance/utils/getPercentage.ts new file mode 100644 index 00000000..18bc1169 --- /dev/null +++ b/apps/extension/src/pages/governance/utils/getPercentage.ts @@ -0,0 +1,4 @@ +export function getPercentage(a: number, b: number) { + if (b === 0) return '0%' + return `${Number((a / b) * 100).toFixed(2)}%` +} diff --git a/apps/extension/src/pages/governance/utils/index.ts b/apps/extension/src/pages/governance/utils/index.ts new file mode 100644 index 00000000..65ab5943 --- /dev/null +++ b/apps/extension/src/pages/governance/utils/index.ts @@ -0,0 +1,6 @@ +export * from './constants' +export * from './convertTime' +export * from './filterSearchedProposal' +export * from './getPercentage' +export * from './sortProposal' +export * from './voteRatio' diff --git a/apps/extension/src/pages/governance/utils/sortProposal.ts b/apps/extension/src/pages/governance/utils/sortProposal.ts new file mode 100644 index 00000000..cc4dd64b --- /dev/null +++ b/apps/extension/src/pages/governance/utils/sortProposal.ts @@ -0,0 +1,18 @@ +import { Proposal, ProposalApi } from '@leapwallet/cosmos-wallet-hooks' +import { SupportedChain } from '@leapwallet/cosmos-wallet-sdk' + +type GovProposal = Proposal | ProposalApi + +export function sortProposal( + itemA: GovProposal, + itemB: GovProposal, + chains: Record, +) { + const chainA = (itemA.chain ?? 'cosmos') as SupportedChain + const chainB = (itemB.chain ?? 'cosmos') as SupportedChain + + const chainNameA = chains[chainA].chainName + const chainNameB = chains[chainB].chainName + + return chainNameA.localeCompare(chainNameB) +} diff --git a/apps/extension/src/utils/gov/voteRatio.ts b/apps/extension/src/pages/governance/utils/voteRatio.ts similarity index 97% rename from apps/extension/src/utils/gov/voteRatio.ts rename to apps/extension/src/pages/governance/utils/voteRatio.ts index 35929ffa..adfbaa0e 100644 --- a/apps/extension/src/utils/gov/voteRatio.ts +++ b/apps/extension/src/pages/governance/utils/voteRatio.ts @@ -1,10 +1,10 @@ -import { VoteOptions } from 'pages/governance/CastVoteSheet' +import { VoteOptions } from '../components/CastVoteSheet' type TallyResult = { yes: string abstain: string no: string - no_with_veto: string + no_with_veto?: string } type VoteSectionValues = { diff --git a/apps/extension/src/pages/home/AddFromChainStore.tsx b/apps/extension/src/pages/home/AddFromChainStore.tsx index 5988f73e..e41090ac 100644 --- a/apps/extension/src/pages/home/AddFromChainStore.tsx +++ b/apps/extension/src/pages/home/AddFromChainStore.tsx @@ -1,5 +1,5 @@ import { Key as WalletKey, useChainsStore } from '@leapwallet/cosmos-wallet-hooks' -import { sleep, SupportedChain } from '@leapwallet/cosmos-wallet-sdk' +import { ChainInfo, sleep } from '@leapwallet/cosmos-wallet-sdk' import { Buttons, GenericCard } from '@leapwallet/leap-ui' import { captureException } from '@sentry/react' import { chainInfosState } from 'atoms/chains' @@ -27,8 +27,7 @@ import browser from 'webextension-polyfill' type AddFromChainStoreProps = { readonly isVisible: boolean readonly onClose: VoidFunction - // eslint-disable-next-line @typescript-eslint/no-explicit-any - newAddChain: any + newAddChain: ChainInfo } export default function AddFromChainStore({ @@ -54,8 +53,7 @@ export default function AddFromChainStore({ onClose() } - const chainName = newAddChain?.chainName - + const newChainKey = newAddChain?.key ?? newAddChain?.chainName const onAddChain = async () => { if (!isCompassWallet()) { try { @@ -63,7 +61,7 @@ export default function AddFromChainStore({ buttonType: ButtonType.CHAIN_MANAGEMENT, buttonName: ButtonName.ADD_CHAIN_FROM_STORE, redirectURL: '/home', - addedChainName: chainName, + addedChainName: newAddChain?.chainName, time: Date.now() / 1000, }) } catch (e) { @@ -72,27 +70,27 @@ export default function AddFromChainStore({ } setIsLoading(true) - setChainInfos({ ...chainInfos, [chainName]: newAddChain }) - setChains({ ...chainInfos, [chainName]: newAddChain }) + setChainInfos({ ...chainInfos, [newChainKey]: newAddChain }) + setChains({ ...chainInfos, [newChainKey]: newAddChain }) await sleep(500) browser.storage.local.get([BETA_CHAINS]).then(async (resp) => { try { const updatedKeystore = await updateKeyStore( activeWallet as WalletKey, - chainName as unknown as SupportedChain, + newChainKey, 'UPDATE', newAddChain, ) let betaChains = resp?.[BETA_CHAINS] betaChains = typeof betaChains === 'string' ? JSON.parse(betaChains) : {} - betaChains[chainName] = newAddChain + betaChains[newChainKey] = newAddChain await browser.storage.local.set({ [BETA_CHAINS]: JSON.stringify(betaChains) }) if (activeWallet) { await setActiveWallet(updatedKeystore[activeWallet.id] as WalletKey) } - await setActiveChain(chainName as unknown as SupportedChain, newAddChain) + await setActiveChain(newChainKey, newAddChain) navigate('/') } catch (error) { setErrors((s) => ({ ...s, submit: 'Unable to add chain' })) @@ -108,6 +106,12 @@ export default function AddFromChainStore({ onClose={onClose} closeOnBackdropClick={true} title='Add From Chain Store' + hideActionButton + secondaryActionButton={ +
+ +
+ } >
@@ -141,7 +145,7 @@ export default function AddFromChainStore({ <> {Divider} Coin Type - {newAddChain?.bip44.coinType ?? ''} + {newAddChain?.bip44?.coinType ?? ''} {Divider} Address Prefix {newAddChain?.addressPrefix ?? ''} diff --git a/apps/extension/src/pages/home/AssetCard.tsx b/apps/extension/src/pages/home/AssetCard.tsx deleted file mode 100644 index 1b12970c..00000000 --- a/apps/extension/src/pages/home/AssetCard.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { isTerraClassic, Token } from '@leapwallet/cosmos-wallet-hooks' -import { CardDivider } from '@leapwallet/leap-ui' -import { TokenCard } from 'components/token-card/TokenCard' -import React from 'react' -import { useNavigate } from 'react-router' - -type AssetCardProps = { isLast: boolean; asset: Token } - -const AssetCard: React.FC = ({ isLast, asset }) => { - const { symbol, amount, usdValue, img, ibcChainInfo, coinMinimalDenom, name, chain, isEvm } = - asset - const navigate = useNavigate() - let tokenChain = chain?.replace('cosmoshub', 'cosmos') - - if (isTerraClassic(ibcChainInfo?.pretty_name ?? '') && coinMinimalDenom === 'uluna') { - tokenChain = 'terra-classic' - } - - const handleCardClick = () => { - if (!tokenChain) return - - navigate( - `/assetDetails?assetName=${ - coinMinimalDenom.length > 0 ? coinMinimalDenom : symbol - }&tokenChain=${tokenChain}`, - { state: asset }, - ) - } - - return ( - - - {!isLast && } - - ) -} - -export default AssetCard diff --git a/apps/extension/src/pages/home/CreateNewWallet.tsx b/apps/extension/src/pages/home/CreateNewWallet.tsx index 94ac1a74..6c56a47c 100644 --- a/apps/extension/src/pages/home/CreateNewWallet.tsx +++ b/apps/extension/src/pages/home/CreateNewWallet.tsx @@ -1,5 +1,5 @@ -import { Buttons, HeaderActionType } from '@leapwallet/leap-ui' -import BottomSheet from 'components/bottom-sheet/BottomSheet' +import { Buttons } from '@leapwallet/leap-ui' +import BottomModal from 'components/bottom-modal' import React, { useCallback, useState } from 'react' import { Wallet } from '../../hooks/wallet/useWallet' @@ -49,14 +49,13 @@ export function NewWalletForm({ isVisible, onClose }: NewWalletFormProps) { } return ( - handleClose(false)} - headerTitle={'Create new wallet'} - headerActionType={HeaderActionType.CANCEL} - closeOnClickBackDrop={true} + title={'Create new wallet'} + closeOnBackdropClick={true} > -
+
- + ) } diff --git a/apps/extension/src/pages/home/EditWallet.tsx b/apps/extension/src/pages/home/EditWallet.tsx index 93aca3fc..6e7f3f01 100644 --- a/apps/extension/src/pages/home/EditWallet.tsx +++ b/apps/extension/src/pages/home/EditWallet.tsx @@ -1,19 +1,22 @@ import { Key, WALLETTYPE } from '@leapwallet/cosmos-wallet-hooks' import { KeyChain } from '@leapwallet/leap-keychain' -import { Buttons, Header, HeaderActionType, Input, ThemeName, useTheme } from '@leapwallet/leap-ui' +import { Buttons, Input, ThemeName, useTheme } from '@leapwallet/leap-ui' import classNames from 'classnames' +import BottomModal from 'components/bottom-modal' import { ErrorCard } from 'components/ErrorCard' import IconButton from 'components/icon-button' import { LEDGER_NAME_EDITED_SUFFIX, LEDGER_NAME_EDITED_SUFFIX_REGEX } from 'config/config' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' +import { useChainPageInfo } from 'hooks' import { useActiveChain } from 'hooks/settings/useActiveChain' import useActiveWallet from 'hooks/settings/useActiveWallet' import { Images } from 'images' import React, { ChangeEventHandler, useEffect, useState } from 'react' import { Colors } from 'theme/colors' +import { AggregatedSupportedChain } from 'types/utility' import { UserClipboard } from 'utils/clipboard' import { sliceAddress } from 'utils/strings' -import BottomSheet from '../../components/bottom-sheet/BottomSheet' import { RemoveWallet } from './RemoveWallet' type EditWalletFormProps = { @@ -28,7 +31,7 @@ export function EditWalletForm({ isVisible, wallet, onClose }: EditWalletFormPro const [error, setError] = useState('') const [isShowRemoveWallet, setShowRemoveWallet] = useState(false) const { activeWallet, setActiveWallet } = useActiveWallet() - const activeChain = useActiveChain() + const activeChain = useActiveChain() as AggregatedSupportedChain const [colorIndex, setColorIndex] = useState(wallet?.colorIndex ?? 0) const isDark = useTheme().theme === ThemeName.DARK @@ -38,6 +41,7 @@ export function EditWalletForm({ isVisible, wallet, onClose }: EditWalletFormPro setColorIndex(wallet?.colorIndex ?? 0) }, [wallet, isVisible]) + const { topChainColor } = useChainPageInfo() const handleInputChange: ChangeEventHandler = (e) => { setError('') if (e.target.value.length < 25) setName(e.target.value) @@ -70,34 +74,24 @@ export function EditWalletForm({ isVisible, wallet, onClose }: EditWalletFormPro return ( <> - onClose(false)} - headerTitle={'Edit wallet'} - headerActionType={HeaderActionType.CANCEL} - closeOnClickBackDrop={true} - customHeader={(toggle) => ( -
-
+ { + setShowRemoveWallet(true) }} + image={{ src: Images.Misc.DeleteRed, alt: ' ' }} + data-testing-id='btn-remove-wallet-bin' /> -
- { - setShowRemoveWallet(true) - }} - image={{ src: Images.Misc.DeleteRed, alt: ' ' }} - data-testing-id='btn-remove-wallet-bin' - /> -
- )} + } > -
+
- {activeChain && wallet && ( + {activeChain && activeChain !== AGGREGATED_CHAIN_KEY && wallet && ( )} + {wallet ? (
{`${name.length}/24`}
) : null} +
{Colors.walletColors.map((color, index) => { return ( @@ -164,18 +160,16 @@ export function EditWalletForm({ isVisible, wallet, onClose }: EditWalletFormPro })}
+ {!!error && }
- + Save changes
-
+ + { - if (type === 'swap' || type === 'bridge') { - return `https://swapfast.app/?destinationChainId=${chain?.chainId}` - } - return `https://cosmos.leapwallet.io/transact/${type}?destinationChainId=${chain?.chainId}` - } - - const [showCopyAddress, setShowCopyAddress] = useState(false) - - const trackCTAEvent = (buttonName: string, redirectURL?: string) => { - if (!isCompassWallet()) { - try { - mixpanel.track(EventName.ButtonClick, { - buttonType: ButtonType.ADD_FUNDS, - buttonName, - redirectURL, - time: Date.now() / 1000, - chainId: chain.chainId, - chainName: chain.chainName, - }) - } catch (e) { - captureException(e) - } - } - } - - useEffect(() => { - if (showCopyAddress) { - setTimeout(() => { - setShowCopyAddress(false) - }, 2000) - } - }, [showCopyAddress]) - - const bannerData = [ - { - icon: 'copy', - title: 'Receive Assets', - content: 'Copy address and transfer funds to this wallet ', - textColor: '#8583EC', - onClick: () => { - if (!activeWallet) return - if ( - activeWallet.walletType === WALLETTYPE.LEDGER && - isLedgerEnabled(chain.key, chain.bip44.coinType) - ) { - return - } - UserClipboard.copyText(address) - setShowCopyAddress(true) - trackCTAEvent(ButtonName.RECEIVE_ASSETS) - }, - }, - { - icon: Images.Misc.IbcProtocol, - type: 'image', - title: 'IBC Swaps', - content: 'Swap or transfer from other Cosmos chains', - textColor: '#C984EB', - onClick: () => { - handleSwapClick(transactUrl('swap')) - trackCTAEvent(ButtonName.IBC_SWAP, transactUrl('swap')) - }, - }, - { - icon: 'route', - title: 'Bridge', - content: 'Bridge or swap from EVM chains', - textColor: '#E18881', - onClick: () => { - window.open(transactUrl('bridge'), '_blank') - trackCTAEvent(ButtonName.BRIDGE, transactUrl('bridge')) - }, - }, - { - icon: Images.Misc.Add, - type: 'image', - title: 'Fiat On-Ramp', - content: 'Buy assets using any currency', - textColor: '#FFC770', - onClick: () => { - window.open(transactUrl('buy'), '_blank') - trackCTAEvent(ButtonName.BUY, transactUrl('buy')) - }, - }, - ] - - return ( -
- - Deposit {chain?.denom} into this wallet - -
- {bannerData.map((d, index) => ( -
- {d?.type === 'image' ? ( - - ) : ( -
- {d.icon} -
- )} -
- {d.title} - - {d.content} - -
- {showCopyAddress && d.title === 'Receive Assets' && ( -
-
- check_circle -
- - Copied Address - -
- )} -
- ))} -
-
- ) -} diff --git a/apps/extension/src/pages/home/GlobalBannersAD.tsx b/apps/extension/src/pages/home/GlobalBannersAD.tsx deleted file mode 100644 index 22eb78a6..00000000 --- a/apps/extension/src/pages/home/GlobalBannersAD.tsx +++ /dev/null @@ -1,493 +0,0 @@ -import { - BannerAD, - NumiaTrackAction, - postNumiaEvent, - useActiveWallet, - useAddress, - useBannerConfig, - useChainInfo, - useGetBannerData, - useGetNumiaBanner, -} from '@leapwallet/cosmos-wallet-hooks' -import { ChainInfo } from '@leapwallet/cosmos-wallet-sdk' -import { captureException } from '@sentry/react' -import classNames from 'classnames' -import Text from 'components/text' -import { EventName } from 'config/analytics' -import { DISABLE_BANNER_ADS } from 'config/storage-keys' -import mixpanel from 'mixpanel-browser' -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' -import { useNavigate } from 'react-router-dom' -import { isCompassWallet } from 'utils/isCompassWallet' -import Browser from 'webextension-polyfill' - -// session storage key for storing the numia banner impression info -const NUMIA_IMPRESSION_INFO = 'numia-impression-info' -// session storage key for storing the mixpanel banner views info -const MIXPANEL_BANNER_VIEWS_INFO = 'mixpanel-banner-views-info' -// seconds -const DEFAULT_AUTO_SCROLL_DURATION = 30 -// pixels -const AUTO_SWITCH_LEFT = 352 - -type BannerADData = BannerAD & { - logo?: string -} - -function getMixpanelBannerId(bannerId: string, campaignId?: number) { - return bannerId.includes('numia') ? `numia-campaign-${campaignId}` : bannerId -} - -function getMixpanelPositionId(bannerId: string, banner?: BannerAD) { - return bannerId.includes('numia') ? banner?.attributes?.position_id : banner?.position_id -} - -function BannerAdCard({ - bannerData, - chain, - index, - onClick, - onClose, - handleBtcBannerClick, -}: { - bannerData: BannerADData - chain: ChainInfo - index: number - // eslint-disable-next-line no-unused-vars - onClick: (bannerId: string, index: number) => void - // eslint-disable-next-line no-unused-vars - onClose: (bannerId: string, index: number) => void - handleBtcBannerClick: () => void -}) { - const navigate = useNavigate() - - const handleClick = useCallback(() => { - if (bannerData.id.trim().toLowerCase().includes('nbtc-banner')) { - handleBtcBannerClick() - } else if (bannerData.banner_type === 'redirect-interanlly') { - navigate(bannerData.redirect_url) - } else { - if (bannerData?.redirect_url && bannerData?.redirect_url !== '#') { - window.open(bannerData.redirect_url) - } - } - - onClick(bannerData.id, index) - - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [bannerData, index, onClick]) - - return ( -
- - - -
- ) -} - -export default function GlobalBannersAD({ - handleBtcBannerClick, -}: { - handleBtcBannerClick: () => void -}) { - const chain = useChainInfo() - const [disabledBannerAds, setDisableBannerAds] = useState([]) - const scrollableContainerRef = useRef(null) - const [timeCounter, setTimeCounter] = useState(0) - const [autoSwitchBanner, setAutoSwitchBanner] = useState(true) - const timerCountRef = useRef(0) - const walletAddress = useAddress() - const activeWallet = useActiveWallet() - const osmoWalletAddress = activeWallet?.addresses.osmosis - const cosmosWalletAddress = activeWallet?.addresses.cosmos - - const { data: bannerConfig } = useBannerConfig() - - const { data: numiaBanners, status: numiaStatus } = useGetNumiaBanner( - osmoWalletAddress ?? '', - bannerConfig?.extension['position-ids'] ?? [], - ) - const leapBanners = useGetBannerData(chain?.chainId) - - // this is in seconds - const autoScrollDuration = useMemo(() => { - return bannerConfig?.extension?.['auto-scroll-duration'] ?? DEFAULT_AUTO_SCROLL_DURATION - }, [bannerConfig]) - - const bannerAds = useMemo(() => { - if (numiaStatus !== 'loading') { - return [...(numiaBanners ?? []), ...(leapBanners ?? [])] - } - - return [] - }, [leapBanners, numiaBanners, numiaStatus]) - - const displayADs = useMemo(() => { - return bannerAds?.filter((ad) => { - const date = new Date() - const startDate = new Date(ad.start_date) - const endDate = new Date(ad.end_date) - const isCorrectTime = date >= startDate && date <= endDate - return !disabledBannerAds?.includes(ad.id) && isCorrectTime - }) - }, [bannerAds, disabledBannerAds]) - - const { activeBannerId, activeBannerData, activeBannerIndex } = useMemo(() => { - const activeBannerIndex = timeCounter % displayADs.length - const activeBannerData: BannerAD | undefined = displayADs?.[activeBannerIndex] - const activeBannerId: string | undefined = activeBannerData?.id - - return { - activeBannerId, - activeBannerData, - activeBannerIndex, - } - }, [displayADs, timeCounter]) - - useEffect(() => { - if (!activeBannerId || isNaN(activeBannerIndex)) return - - if (activeBannerData.id !== activeBannerId) return - - const storedMixpanelBannerViewsInfo = sessionStorage.getItem(MIXPANEL_BANNER_VIEWS_INFO) - const mixpanelBannerViewsInfo = JSON.parse(storedMixpanelBannerViewsInfo ?? '{}') - - if (!mixpanelBannerViewsInfo[walletAddress]?.includes(activeBannerId)) { - try { - if (!isCompassWallet()) { - mixpanel.track(EventName.BannerView, { - bannerId: getMixpanelBannerId(activeBannerId, activeBannerData.attributes?.campaign_id), - bannerIndex: activeBannerIndex, - chainId: chain.chainId, - chainName: chain.chainName, - positionId: getMixpanelPositionId(activeBannerId, activeBannerData), - time: Date.now() / 1000, - }) - } - - sessionStorage.setItem( - MIXPANEL_BANNER_VIEWS_INFO, - JSON.stringify({ - ...mixpanelBannerViewsInfo, - [walletAddress]: [...(mixpanelBannerViewsInfo[walletAddress] ?? []), activeBannerId], - }), - ) - } catch (e) { - captureException(e) - } - } - - if (activeBannerId.includes('numia')) { - const storedNumiaImpressionInfo = sessionStorage.getItem(NUMIA_IMPRESSION_INFO) - const numiaImpressionInfo = JSON.parse(storedNumiaImpressionInfo ?? '{}') - - if (!numiaImpressionInfo[walletAddress]?.includes(activeBannerId)) { - sessionStorage.setItem( - NUMIA_IMPRESSION_INFO, - JSON.stringify({ - ...numiaImpressionInfo, - [walletAddress]: [...(numiaImpressionInfo[walletAddress] ?? []), activeBannerId], - }), - ) - - try { - if (activeBannerData && activeBannerData.attributes && osmoWalletAddress) { - // call only for a new wallet address in a session - ;(async function () { - await postNumiaEvent( - osmoWalletAddress, - NumiaTrackAction.VIEWED, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - activeBannerData.attributes!, - ) - })() - } - } catch (_) { - // - } - } - } - }, [ - walletAddress, - activeBannerId, - activeBannerData, - activeBannerIndex, - chain.chainId, - chain.chainName, - cosmosWalletAddress, - osmoWalletAddress, - ]) - - const handleContainerScroll = useCallback( - (newIndex?: number) => { - // new index will be from 0 - displayADs.length - if (newIndex !== undefined) { - timerCountRef.current = Math.floor(timerCountRef.current / displayADs.length) + newIndex - } else { - timerCountRef.current += 1 - } - - scrollableContainerRef.current?.scrollTo({ - top: 0, - left: AUTO_SWITCH_LEFT * (timerCountRef.current % displayADs.length), - behavior: 'smooth', - }) - - setTimeCounter(timerCountRef.current) - }, - [displayADs.length], - ) - - useEffect(() => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let intervalId: any - if (scrollableContainerRef.current && displayADs.length > 1 && autoSwitchBanner) { - intervalId = setInterval(handleContainerScroll, autoScrollDuration * 1000) - } - - return () => clearInterval(intervalId) - }, [displayADs.length, handleContainerScroll, autoSwitchBanner, autoScrollDuration]) - - useEffect(() => { - // stop auto-switching when the banner is not visible to the user - if (!scrollableContainerRef.current) { - return - } - - const intersectionCallback = (entries: IntersectionObserverEntry[]) => { - const isIntersecting = entries[0].isIntersecting - // isIntersecting - meaning the banner is visible to the user (in the popup-layout area) - setAutoSwitchBanner(isIntersecting) - } - - const observer = new IntersectionObserver(intersectionCallback, { - root: document.querySelector('#popup-layout'), - rootMargin: '0px', - threshold: 1.0, - }) - - observer.observe(scrollableContainerRef.current) - - return () => { - observer.disconnect() - } - }, []) - - useEffect(() => { - // stop auto-switching when the user is not on the tab, or has minimised the window or using another app - - const handleVisibilityChanges = () => { - if (document.visibilityState === 'visible') { - setAutoSwitchBanner(true) - } else { - setAutoSwitchBanner(false) - } - } - - document.addEventListener('visibilitychange', handleVisibilityChanges) - - return () => { - document.removeEventListener('visibilitychange', handleVisibilityChanges) - } - }, []) - - const handleBannerClose = useCallback( - async (bannerId: string, bannerIndex: number) => { - const newDisabledBannerAds = [...disabledBannerAds, bannerId] - const storedDisabledBannerAds = await Browser.storage.local.get([DISABLE_BANNER_ADS]) - let parsedDisabledAds = {} - - try { - parsedDisabledAds = JSON.parse(storedDisabledBannerAds[DISABLE_BANNER_ADS] ?? '{}') - } catch (_) { - // - } - - await Browser.storage.local.set({ - [DISABLE_BANNER_ADS]: JSON.stringify({ - ...parsedDisabledAds, - [cosmosWalletAddress ?? '']: newDisabledBannerAds, - }), - }) - - if (!isCompassWallet()) { - try { - const banner = bannerAds.find((_banner) => _banner.id === bannerId) - - mixpanel.track(EventName.BannerClose, { - bannerId: getMixpanelBannerId(bannerId, banner?.attributes?.campaign_id), - bannerIndex, - chainId: chain.chainId, - chainName: chain.chainName, - positionId: getMixpanelPositionId(bannerId, banner), - time: Date.now() / 1000, - }) - } catch (_) { - // - } - - setDisableBannerAds(newDisabledBannerAds) - } - }, - [disabledBannerAds, bannerAds, cosmosWalletAddress, chain.chainId, chain.chainName], - ) - - const handleBannerClick = useCallback( - (bannerId: string, bannerIndex: number) => { - const banner = bannerAds.find((_banner) => _banner.id === bannerId) - - if (bannerId.includes('numia')) { - try { - if (banner && osmoWalletAddress) { - ;(async function () { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await postNumiaEvent(osmoWalletAddress, NumiaTrackAction.CLICKED, banner.attributes!) - })() - } - } catch (_) { - // - } - } - - if (!isCompassWallet()) { - try { - mixpanel.track(EventName.BannerClick, { - bannerId: getMixpanelBannerId(bannerId, banner?.attributes?.campaign_id), - bannerIndex, - chainId: chain.chainId, - chainName: chain.chainName, - positionId: getMixpanelPositionId(bannerId, banner), - time: Date.now() / 1000, - }) - } catch (e) { - captureException(e) - } - } - }, - [bannerAds, chain.chainId, chain.chainName, osmoWalletAddress], - ) - - const handleScroll: React.UIEventHandler = useCallback( - (e) => { - // if event is user generated, then update the active banner index - // for this we check the isTrusted property of the event - if (e.isTrusted && !autoSwitchBanner) { - const scrollLeft = e.currentTarget.scrollLeft - const bannerIndex = Math.floor(scrollLeft / AUTO_SWITCH_LEFT) - timerCountRef.current = bannerIndex - setTimeCounter(bannerIndex) - } - }, - [autoSwitchBanner], - ) - - const handleMouseEnter = useCallback(() => { - setAutoSwitchBanner(false) - }, []) - - const handleMouseLeave = useCallback(() => { - setAutoSwitchBanner(true) - }, []) - - useEffect(() => { - const fn = async () => { - const disabledBannerAds = await Browser.storage.local.get([DISABLE_BANNER_ADS]) - const parsedDisabledAds = JSON.parse(disabledBannerAds[DISABLE_BANNER_ADS] ?? '{}') - - setDisableBannerAds(parsedDisabledAds[cosmosWalletAddress ?? ''] ?? []) - } - - // eslint-disable-next-line no-console - fn().catch(console.error) - }, [cosmosWalletAddress]) - - if (!bannerAds || bannerAds.length === 0 || displayADs.length === 0) return null - - return ( -
-
- {displayADs.map((bannerData, index) => { - return ( - - ) - })} -
- - {displayADs.length > 1 ? ( -
- {displayADs.map((ad, i) => { - const isActive = activeBannerId === ad.id - - return ( - handleContainerScroll(i)} - /> - ) - })} -
- ) : null} -
- ) -} diff --git a/apps/extension/src/pages/home/Home.tsx b/apps/extension/src/pages/home/Home.tsx index f72298b7..aa335761 100644 --- a/apps/extension/src/pages/home/Home.tsx +++ b/apps/extension/src/pages/home/Home.tsx @@ -1,763 +1,19 @@ -import { - useGetAsteroidTokens, - useGetSeiEvmBalance, - useGetTokenBalances, - useIsSeiEvmChain, - useSeiLinkedAddressState, - useSnipGetSnip20TokenBalances, - WALLETTYPE, -} from '@leapwallet/cosmos-wallet-hooks' -import { ChainInfo } from '@leapwallet/cosmos-wallet-sdk' -import { Buttons, CardDivider, GenericCard, Header, HeaderActionType } from '@leapwallet/leap-ui' -import { QueryStatus } from '@tanstack/react-query' -import classNames from 'classnames' -import AlertStrip from 'components/alert-strip/AlertStrip' -import SelectedChainAlertStrip from 'components/alert-strip/SelectedChainAlertStrip' -import BottomNav, { BottomNavLabel } from 'components/bottom-nav/BottomNav' -import { EmptyCard } from 'components/empty-card' -import { EthCopyWalletAddress } from 'components/eth-copy-wallet-address' -import PopupLayout from 'components/layout/popup-layout' -import ReceiveToken from 'components/Receive' -import TokenCardSkeleton from 'components/Skeletons/TokenCardSkeleton' -import Text from 'components/text' -import WarningCard from 'components/WarningCard' +import { useActiveChain } from '@leapwallet/cosmos-wallet-hooks' import { PageName } from 'config/analytics' -import { LEDGER_ENABLED_EVM_CHAIN_IDS, LEDGER_NAME_EDITED_SUFFIX_REGEX } from 'config/config' -import { walletLabels } from 'config/constants' -import { SHOW_LINK_ADDRESS_NUDGE } from 'config/storage-keys' +import { AGGREGATED_CHAIN_KEY } from 'config/constants' import { usePageView } from 'hooks/analytics/usePageView' -import { usePerformanceMonitor } from 'hooks/perf-monitoring/usePerformanceMonitor' -import { useActiveChain } from 'hooks/settings/useActiveChain' -import useActiveWallet from 'hooks/settings/useActiveWallet' -import { useFormatCurrency } from 'hooks/settings/useCurrency' -import { useHideAssets, useSetHideAssets } from 'hooks/settings/useHideAssets' -import { useHideSmallBalances } from 'hooks/settings/useHideSmallBalances' -import { useSelectedNetwork } from 'hooks/settings/useNetwork' -import { useChainInfos } from 'hooks/useChainInfos' -import { useGetWalletAddresses } from 'hooks/useGetWalletAddresses' -import useQuery from 'hooks/useQuery' -import { useDefaultTokenLogo } from 'hooks/utility/useDefaultTokenLogo' -import { useAddress } from 'hooks/wallet/useAddress' -import { Wallet } from 'hooks/wallet/useWallet' -import { Images } from 'images' -import { ActivitySwapTxPage } from 'pages/activity/ActivitySwapTxPage' -import qs from 'qs' -import React, { useCallback, useEffect, useMemo, useState } from 'react' -import Skeleton from 'react-loading-skeleton' -import { useNavigate } from 'react-router' -import { useSetRecoilState } from 'recoil' -import { Colors } from 'theme/colors' -import { UserClipboard } from 'utils/clipboard' -import { formatWalletName } from 'utils/formatWalletName' -import { isCompassWallet } from 'utils/isCompassWallet' -import { isLedgerEnabled } from 'utils/isLedgerEnabled' -import { sliceAddress, trim } from 'utils/strings' -import Browser from 'webextension-polyfill' +import React from 'react' +import { AggregatedSupportedChain } from 'types/utility' -import { searchModalState } from '../../atoms/search-modal' -import AssetCard from './AssetCard' -import { CopyAddressSheet, HomeButtons, LinkAddressesSheet, WalletNotConnected } from './components' -import { BitcoinDeposit, DepositBTCBanner } from './DepositBTCBanner' -import FundBanners from './FundBanners' -import GlobalBannersAD from './GlobalBannersAD' -import PendingSwapsAlertStrip from './PendingSwapsAlertStrip' -import PendingSwapsSheet from './PendingSwapsSheet' -import RequestFaucet from './RequestFaucet' -import SelectChain from './SelectChain' -import SelectWallet from './SelectWallet' -import SideNav from './side-nav' - -type InitialFaucetResp = { - msg: string - status: 'success' | 'fail' | null -} - -const initialFaucetResp: InitialFaucetResp = { - msg: '', - status: null, -} - -interface ChainInfoProp extends ChainInfo { - apiStatus?: boolean -} +import { AggregatedHome, ChainHome } from './components' export default function Home() { usePageView(PageName.Home) + const activeChain = useActiveChain() as AggregatedSupportedChain - const chainInfos = useChainInfos() - const txDeclined = useQuery().get('txDeclined') ?? undefined - const walletAvatarChanged = useQuery().get('walletAvatarChanged') ?? undefined - const [showWalletAvatarMsg, setShowWalletAvatarMsg] = useState(!!walletAvatarChanged) - const [showQuickOptionDiv, setShowQuickOptionDiv] = useState( - localStorage.getItem('showQuickOptionDiv') ? false : true, - ) - - const navigate = useNavigate() - - const defaultTokenLogo = useDefaultTokenLogo() - const [showChainSelector, setShowChainSelector] = useState(false) - const [showSelectWallet, setShowSelectWallet] = useState(false) - const [showSideNav, setShowSideNav] = useState(false) - const [showReceiveSheet, setShowReceiveSheet] = useState(false) - - const [showFaucetResp, setShowFaucetResp] = useState(initialFaucetResp) - const [showErrorMessage, setShowErrorMessage] = useState(!!txDeclined) - const [scrtTokenContractAddress, setScrtTokenContractAddress] = useState('') - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const [showSwapTxPageFor, setShowSwapTxPageFor] = useState() - const [showPendingSwapsSheet, setShowPendingSwapsSheet] = useState(false) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const [pendingSwapTxs, setPendingSwapTxs] = useState([]) - - const selectedNetwork = useSelectedNetwork() - const { - snip20Tokens, - snip20TokensStatus, - enabled: snip20Enabled, - } = useSnipGetSnip20TokenBalances() - - const address = useAddress() - const [formatCurrency] = useFormatCurrency() - const isSeiEvmChain = useIsSeiEvmChain() - - const [areSmallBalancesHidden] = useHideSmallBalances() - const { hideBalances: balancesHidden, formatHideBalance } = useHideAssets() - const setBalancesVisibility = useSetHideAssets() - - const setShowSearchModal = useSetRecoilState(searchModalState) - const [showBitcoinDepositSheet, setShowBitcoinDepositSheet] = useState(false) - - const { - isWalletHasFunds, - allAssets: _allAssets, - totalCurrencyInPreferredFiatValue: _allAssetsCurrencyInFiat, - s3IbcTokensStatus, - nonS3IbcTokensStatus, - nativeTokensStatus, - cw20TokensStatus, - erc20TokensStatus, - refetchBalances, - } = useGetTokenBalances() - - // refetch balances - useEffect(() => { - refetchBalances() - }, []) - - const getWallet = Wallet.useGetWallet() - const { addressLinkState } = useSeiLinkedAddressState(getWallet) - const { data: seiEvmBalance, status: seiEvmStatus } = useGetSeiEvmBalance() - const { status: asteroidsTokensStatus, data: asteroidTokenBalance } = useGetAsteroidTokens() - - const allAssets = useMemo(() => { - let allAssets = [..._allAssets, ...(asteroidTokenBalance?.asteroidTokens ?? [])] - - if (!['done', 'unknown'].includes(addressLinkState)) { - const firstElement = allAssets?.[0] - - if (firstElement) { - allAssets = [ - firstElement, - ...(seiEvmBalance?.seiEvmBalance ?? []), - ...(allAssets ?? []).slice(1), - ] - } else { - allAssets = [...(seiEvmBalance?.seiEvmBalance ?? []), ...(allAssets ?? []).slice(1)] - } - } - - return allAssets - }, [ - _allAssets, - addressLinkState, - asteroidTokenBalance?.asteroidTokens, - seiEvmBalance?.seiEvmBalance, - ]) - - const totalCurrencyInPreferredFiatValue = useMemo(() => { - let totalCurrencyInPreferredFiatValue = _allAssetsCurrencyInFiat.plus( - asteroidTokenBalance?.currencyInFiatValue ?? 0, - ) - - if (!['done', 'unknown'].includes(addressLinkState)) { - totalCurrencyInPreferredFiatValue = totalCurrencyInPreferredFiatValue.plus( - seiEvmBalance?.currencyInFiatValue ?? 0, - ) - } - - return totalCurrencyInPreferredFiatValue - }, [ - _allAssetsCurrencyInFiat, - addressLinkState, - asteroidTokenBalance?.currencyInFiatValue, - seiEvmBalance?.currencyInFiatValue, - ]) - - const activeChain = useActiveChain() - const [showCopyAddressSheet, setShowCopyAddressSheet] = useState(false) - const [isThisALinkEvmAddressNudge, setIsThisALinkEvmAddressNudge] = useState(false) - const { activeWallet } = useActiveWallet() - - const chain: ChainInfoProp = chainInfos[activeChain] - const walletAddresses = useGetWalletAddresses() - - const walletAvatar = useMemo(() => { - if (activeWallet?.avatar) { - return activeWallet.avatar - } - - if (isCompassWallet()) { - return Images.Logos.CompassCircle - } - - return Images.Logos.LeapLogo28 - }, [activeWallet?.avatar]) - - const queryStatus = useMemo(() => { - let status = - erc20TokensStatus !== 'success' && - cw20TokensStatus !== 'success' && - s3IbcTokensStatus !== 'success' && - nonS3IbcTokensStatus !== 'success' && - nativeTokensStatus !== 'success' && - asteroidsTokensStatus !== 'success' && - seiEvmStatus !== 'success' - ? 'loading' - : '' - - status = - erc20TokensStatus === 'success' && - cw20TokensStatus == 'success' && - s3IbcTokensStatus === 'success' && - nonS3IbcTokensStatus === 'success' && - nativeTokensStatus === 'success' && - asteroidsTokensStatus === 'success' && - seiEvmStatus === 'success' - ? 'success' - : status - - status = - erc20TokensStatus === 'error' && - cw20TokensStatus === 'error' && - s3IbcTokensStatus === 'error' && - nonS3IbcTokensStatus === 'error' && - nativeTokensStatus === 'error' && - asteroidsTokensStatus === 'error' && - seiEvmStatus === 'error' - ? 'error' - : status - - return status - }, [ - asteroidsTokensStatus, - cw20TokensStatus, - erc20TokensStatus, - nativeTokensStatus, - nonS3IbcTokensStatus, - s3IbcTokensStatus, - seiEvmStatus, - ]) - - const handleCopyAddressSheetClose = useCallback( - (refetch?: boolean) => { - setShowCopyAddressSheet(false) - setIsThisALinkEvmAddressNudge(false) - localStorage.setItem(SHOW_LINK_ADDRESS_NUDGE, 'false') - - if (refetch) { - refetchBalances() - } - }, - [refetchBalances], - ) - - useEffect(() => { - if ( - isSeiEvmChain && - !['done', 'unknown', 'loading'].includes(addressLinkState) && - seiEvmStatus === 'success' && - localStorage.getItem(SHOW_LINK_ADDRESS_NUDGE) !== 'false' - ) { - setIsThisALinkEvmAddressNudge(true) - } else { - setIsThisALinkEvmAddressNudge(false) - } - }, [addressLinkState, isSeiEvmChain, seiEvmStatus]) - - usePerformanceMonitor({ - page: 'home', - queryStatus: queryStatus as QueryStatus, - op: 'homePageLoad', - description: 'loading state on home page', - }) - - const [assets, smallBalanceAssets] = useMemo(() => { - let assetsToShow = allAssets - - if (allAssets && snip20Tokens) { - assetsToShow = assetsToShow.concat( - snip20Tokens.filter((token) => { - return !token.invalidKey - }), - ) - } - - if (areSmallBalancesHidden) { - return [ - assetsToShow.filter((asset) => Number(asset.usdValue) >= 0.1), - assetsToShow.filter((asset) => Number(asset.usdValue) < 0.1), - ] - } - - return [assetsToShow, []] - }, [allAssets, snip20Tokens, areSmallBalancesHidden]) - - const invalidKeyTokens = useMemo(() => { - if (snip20Tokens) { - return snip20Tokens.filter((token) => token.invalidKey === true) - } - return [] - }, [snip20Tokens]) - - if (!activeWallet) { - return ( -
- -
- -
-
-
- ) + if (activeChain === AGGREGATED_CHAIN_KEY) { + return } - const loading = - erc20TokensStatus !== 'success' && - cw20TokensStatus !== 'success' && - s3IbcTokensStatus !== 'success' && - nonS3IbcTokensStatus !== 'success' && - nativeTokensStatus !== 'success' && - asteroidsTokensStatus !== 'success' && - seiEvmStatus !== 'success' - - const disabled = - activeWallet.walletType === WALLETTYPE.LEDGER && - !isLedgerEnabled(activeChain, chain?.bip44.coinType) - - const walletName = - activeWallet.walletType === WALLETTYPE.LEDGER && - !LEDGER_NAME_EDITED_SUFFIX_REGEX.test(activeWallet.name) - ? `${walletLabels[activeWallet.walletType]} Wallet ${activeWallet.addressIndex + 1}` - : formatWalletName(activeWallet.name) - - const atLeastOneTokenIsLoading = - erc20TokensStatus === 'loading' || - nativeTokensStatus === 'loading' || - cw20TokensStatus === 'loading' || - s3IbcTokensStatus === 'loading' || - nonS3IbcTokensStatus === 'loading' || - asteroidsTokensStatus === 'loading' || - seiEvmStatus === 'loading' - - const activeChainInfo = chainInfos[activeChain] - - if (!activeChainInfo) { - return null - } - - const handleQuickSearchIconClick = () => { - setShowSearchModal(true) - } - - const noAddress = !activeWallet.addresses[activeChain] - const apiUnavailable = atLeastOneTokenIsLoading && chain?.apiStatus === false - const showDisabledCard = noAddress || apiUnavailable - const connectEVMLedger = - noAddress && - LEDGER_ENABLED_EVM_CHAIN_IDS.includes(chain.chainId) && - activeWallet.walletType === WALLETTYPE.LEDGER - const ledgerNoSupported = - noAddress && - !LEDGER_ENABLED_EVM_CHAIN_IDS.includes(chain.chainId) && - activeWallet.walletType === WALLETTYPE.LEDGER - let disabledCardMessage = '' - if (connectEVMLedger) { - disabledCardMessage = `Please import your ${chain.chainName} wallet by connecting EVM Ledger app.` - } else if (ledgerNoSupported) { - disabledCardMessage = `Ledger support coming soon for ${chain.chainName}` - } else if (apiUnavailable) { - disabledCardMessage = `The ${chain.chainName} network is currently experiencing issues. Please try again later.` - } - - return ( -
- setShowSideNav(!showSideNav)} /> - setShowSideNav(true), - type: HeaderActionType.NAVIGATION, - 'data-testing-id': 'home-sidenav-hamburger-btn', - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - className: - 'w-[48px] h-[40px] px-3 bg-[#FFFFFF] dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-full', - }} - imgSrc={activeChainInfo.chainSymbolImageUrl ?? defaultTokenLogo} - onImgClick={() => setShowChainSelector(true)} - title={ - - ) : undefined - } - onClick={function noRefCheck() { - setShowSelectWallet(true) - }} - title={trim(walletName, 10)} - data-testing-id='home-create-wallet-btn' - /> - } - topColor={Colors.getChainColor(activeChain, activeChainInfo)} - data-testing-id='home-switch-chain-btn' - /> - } - > - -
- {!showErrorMessage && } - - {showErrorMessage && ( - setShowErrorMessage(false)} - /> - )} - - {showFaucetResp.msg && ( - setShowFaucetResp(initialFaucetResp)} - className='absolute bottom-[80px] rounded-xl w-80 h-auto p-2' - timeOut={6000} - /> - )} - - {showWalletAvatarMsg && ( - setShowWalletAvatarMsg(false)} - className='absolute top-[80px] rounded-2xl w-80 h-auto p-2' - timeOut={1000} - /> - )} - -
-
- Your portfolio -
-
- {!loading ? ( - formatHideBalance(formatCurrency(totalCurrencyInPreferredFiatValue)) - ) : ( - - )} -
- {disabled ? ( -
- error{' '} - Ledger not supported for {chain?.chainName} -
- ) : !walletAddresses?.[0]?.length ? ( -
- - EVM wallets not connected - - -
- window.open(Browser.runtime.getURL('index.html#/onboardEvmLedger')) - } - > - - Connect EVM wallet - -
-
- ) : ( -
- sliceAddress(address))} - color={isCompassWallet() ? Colors.compassPrimary : Colors.green600} - onCopy={() => UserClipboard.copyText(walletAddresses[0])} - data-testing-id='home-copy-address-btn' - onTextClick={ - walletAddresses.length > 1 ? () => setShowCopyAddressSheet(true) : undefined - } - /> - - {isCompassWallet() ? ( - - ) : ( - - )} -
- )} - - {!isCompassWallet() ? ( - setShowBitcoinDepositSheet(true)} /> - ) : null} - setShowReceiveSheet(true)} /> -
- - {showQuickOptionDiv && !isCompassWallet() ? ( -
-

- Press {navigator.userAgent.toLowerCase().includes('windows') ? 'ctrl' : 'cmd'} + k - for quick actions ✨ -

- -
- ) : null} - - {(isCompassWallet() ? true : selectedNetwork !== 'testnet') && - isWalletHasFunds && - !atLeastOneTokenIsLoading && ( - setShowBitcoinDepositSheet(true)} /> - )} - - {selectedNetwork === 'testnet' && ( - { - setShowFaucetResp(data) - }} - /> - )} - - {showDisabledCard ? ( - - ) : !isCompassWallet() && !isWalletHasFunds && !atLeastOneTokenIsLoading ? ( - - ) : ( -
- {!atLeastOneTokenIsLoading && ( - - Available Tokens {(assets?.length ?? 0) > 0 ? `(${assets.length})` : ''} - - )} - - {!atLeastOneTokenIsLoading && assets.length === 0 ? ( - - You don't have any tokens yet. - - ) : null} - - {assets?.map((asset, index, array) => ( - - ))} - - {!atLeastOneTokenIsLoading && - areSmallBalancesHidden && - smallBalanceAssets?.length !== 0 ? ( -

- Tokens with small balances hidden (<$0.1). Customize settings{' '} - - . -

- ) : null} - - {invalidKeyTokens?.map((token) => { - return ( - - - setScrtTokenContractAddress(token.coinMinimalDenom)} - title={token.symbol} - img={} - subtitle2={error} - /> -
- - Wrong Key or Key not set - -
-
- ) - })} - - {nativeTokensStatus !== 'success' ? : null} - {s3IbcTokensStatus !== 'success' ? : null} - {nonS3IbcTokensStatus !== 'success' ? : null} - - {cw20TokensStatus !== 'success' ? : null} - {erc20TokensStatus !== 'success' ? : null} - {asteroidsTokensStatus !== 'success' ? : null} - {seiEvmStatus !== 'success' ? : null} - {activeChain === 'secret' && snip20TokensStatus !== 'success' && snip20Enabled ? ( - - ) : null} - - {!atLeastOneTokenIsLoading && cw20TokensStatus === 'success' && ( -
{ - if (activeChain === 'secret' && selectedNetwork === 'mainnet') { - navigate('/snip20-manage-tokens?contractAddress=' + scrtTokenContractAddress) - } else { - navigate('/manage-tokens') - } - }} - > - - Manage Tokens - -
- )} -
- )} -
-
- - setShowChainSelector(false)} /> - setShowSelectWallet(false)} - title='Wallets' - /> - - {showSwapTxPageFor ? ( - { - setShowSwapTxPageFor(undefined) - let queryStr = '' - if (sourceChainId || sourceToken || destinationChainId || destinationToken) { - queryStr = `?${qs.stringify({ - sourceChainId, - sourceToken, - destinationChainId, - destinationToken, - pageSource: 'swapAgain', - })}` - } - navigate(`/swap${queryStr}`) - }} - {...showSwapTxPageFor} - /> - ) : null} - - { - setShowReceiveSheet(false) - }} - handleBtcBannerClick={() => setShowBitcoinDepositSheet(true)} - /> - { - setShowBitcoinDepositSheet(false) - }} - /> - - {!['done', 'unknown'].includes(addressLinkState) ? ( - - ) : ( - - )} - - - { - setShowPendingSwapsSheet(false) - }} - /> - {!connectEVMLedger ? ( - - ) : null} -
- ) + return } diff --git a/apps/extension/src/pages/home/ImportPrivateKey.tsx b/apps/extension/src/pages/home/ImportPrivateKey.tsx index d3d4a90d..6273d9ec 100644 --- a/apps/extension/src/pages/home/ImportPrivateKey.tsx +++ b/apps/extension/src/pages/home/ImportPrivateKey.tsx @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { Buttons, HeaderActionType, TextArea } from '@leapwallet/leap-ui' +import { Buttons, TextArea } from '@leapwallet/leap-ui' import classNames from 'classnames' +import BottomModal from 'components/bottom-modal' import { LoaderAnimation } from 'components/loader/Loader' import Text from 'components/text' import { usePassword } from 'hooks/settings/usePassword' @@ -8,7 +9,6 @@ import { Images } from 'images' import React, { useState } from 'react' import { Colors } from 'theme/colors' -import BottomSheet from '../../components/bottom-sheet/BottomSheet' import { Wallet } from '../../hooks/wallet/useWallet' import useImportWallet = Wallet.useImportWallet import { useActiveChain, useIsSeiEvmChain } from '@leapwallet/cosmos-wallet-hooks' @@ -63,29 +63,29 @@ export function ImportPrivateKey({ isVisible, onClose }: ImportPrivateKeyProps) } return ( - { onClose(false) setError('') }} - headerTitle='Import Wallet' - headerActionType={HeaderActionType.CANCEL} - closeOnClickBackDrop={true} + title={'Import Wallet'} + closeOnBackdropClick={true} > <> {isSeiEvmChain ? ( ) : null} -
+
- Enter the private key below. This will import an existing wallet. + Use private key to import your MetaMask wallet to generate the same EVM address as on + MetaMask.