@lydianpay/sdk-web 1.1.7 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3579 @@
1
+ import { g as Qt, i as Fe, I as ft, h as pt, b as jn, s as Bn } from "./index-CPaNT4Oo.js";
2
+ var Oe = { exports: {} }, gt;
3
+ function Wn() {
4
+ return gt || (gt = 1, (function(t) {
5
+ var e = Object.prototype.hasOwnProperty, n = "~";
6
+ function s() {
7
+ }
8
+ Object.create && (s.prototype = /* @__PURE__ */ Object.create(null), new s().__proto__ || (n = !1));
9
+ function r(u, d, p) {
10
+ this.fn = u, this.context = d, this.once = p || !1;
11
+ }
12
+ function i(u, d, p, g, o) {
13
+ if (typeof p != "function")
14
+ throw new TypeError("The listener must be a function");
15
+ var c = new r(p, g || u, o), h = n ? n + d : d;
16
+ return u._events[h] ? u._events[h].fn ? u._events[h] = [u._events[h], c] : u._events[h].push(c) : (u._events[h] = c, u._eventsCount++), u;
17
+ }
18
+ function a(u, d) {
19
+ --u._eventsCount === 0 ? u._events = new s() : delete u._events[d];
20
+ }
21
+ function l() {
22
+ this._events = new s(), this._eventsCount = 0;
23
+ }
24
+ l.prototype.eventNames = function() {
25
+ var d = [], p, g;
26
+ if (this._eventsCount === 0) return d;
27
+ for (g in p = this._events)
28
+ e.call(p, g) && d.push(n ? g.slice(1) : g);
29
+ return Object.getOwnPropertySymbols ? d.concat(Object.getOwnPropertySymbols(p)) : d;
30
+ }, l.prototype.listeners = function(d) {
31
+ var p = n ? n + d : d, g = this._events[p];
32
+ if (!g) return [];
33
+ if (g.fn) return [g.fn];
34
+ for (var o = 0, c = g.length, h = new Array(c); o < c; o++)
35
+ h[o] = g[o].fn;
36
+ return h;
37
+ }, l.prototype.listenerCount = function(d) {
38
+ var p = n ? n + d : d, g = this._events[p];
39
+ return g ? g.fn ? 1 : g.length : 0;
40
+ }, l.prototype.emit = function(d, p, g, o, c, h) {
41
+ var E = n ? n + d : d;
42
+ if (!this._events[E]) return !1;
43
+ var _ = this._events[E], I = arguments.length, v, k;
44
+ if (_.fn) {
45
+ switch (_.once && this.removeListener(d, _.fn, void 0, !0), I) {
46
+ case 1:
47
+ return _.fn.call(_.context), !0;
48
+ case 2:
49
+ return _.fn.call(_.context, p), !0;
50
+ case 3:
51
+ return _.fn.call(_.context, p, g), !0;
52
+ case 4:
53
+ return _.fn.call(_.context, p, g, o), !0;
54
+ case 5:
55
+ return _.fn.call(_.context, p, g, o, c), !0;
56
+ case 6:
57
+ return _.fn.call(_.context, p, g, o, c, h), !0;
58
+ }
59
+ for (k = 1, v = new Array(I - 1); k < I; k++)
60
+ v[k - 1] = arguments[k];
61
+ _.fn.apply(_.context, v);
62
+ } else {
63
+ var C = _.length, y;
64
+ for (k = 0; k < C; k++)
65
+ switch (_[k].once && this.removeListener(d, _[k].fn, void 0, !0), I) {
66
+ case 1:
67
+ _[k].fn.call(_[k].context);
68
+ break;
69
+ case 2:
70
+ _[k].fn.call(_[k].context, p);
71
+ break;
72
+ case 3:
73
+ _[k].fn.call(_[k].context, p, g);
74
+ break;
75
+ case 4:
76
+ _[k].fn.call(_[k].context, p, g, o);
77
+ break;
78
+ default:
79
+ if (!v) for (y = 1, v = new Array(I - 1); y < I; y++)
80
+ v[y - 1] = arguments[y];
81
+ _[k].fn.apply(_[k].context, v);
82
+ }
83
+ }
84
+ return !0;
85
+ }, l.prototype.on = function(d, p, g) {
86
+ return i(this, d, p, g, !1);
87
+ }, l.prototype.once = function(d, p, g) {
88
+ return i(this, d, p, g, !0);
89
+ }, l.prototype.removeListener = function(d, p, g, o) {
90
+ var c = n ? n + d : d;
91
+ if (!this._events[c]) return this;
92
+ if (!p)
93
+ return a(this, c), this;
94
+ var h = this._events[c];
95
+ if (h.fn)
96
+ h.fn === p && (!o || h.once) && (!g || h.context === g) && a(this, c);
97
+ else {
98
+ for (var E = 0, _ = [], I = h.length; E < I; E++)
99
+ (h[E].fn !== p || o && !h[E].once || g && h[E].context !== g) && _.push(h[E]);
100
+ _.length ? this._events[c] = _.length === 1 ? _[0] : _ : a(this, c);
101
+ }
102
+ return this;
103
+ }, l.prototype.removeAllListeners = function(d) {
104
+ var p;
105
+ return d ? (p = n ? n + d : d, this._events[p] && a(this, p)) : (this._events = new s(), this._eventsCount = 0), this;
106
+ }, l.prototype.off = l.prototype.removeListener, l.prototype.addListener = l.prototype.on, l.prefixed = n, l.EventEmitter = l, t.exports = l;
107
+ })(Oe)), Oe.exports;
108
+ }
109
+ var qn = Wn();
110
+ const Vn = /* @__PURE__ */ Qt(qn);
111
+ function Kn(t, e) {
112
+ if (!Fe(t, { strict: !1 }))
113
+ throw new ft({ address: t });
114
+ if (!Fe(e, { strict: !1 }))
115
+ throw new ft({ address: e });
116
+ return t.toLowerCase() === e.toLowerCase();
117
+ }
118
+ const Fn = (t, e) => {
119
+ let n;
120
+ switch (t) {
121
+ case "standard":
122
+ return n = e, `data:image/svg+xml,%3Csvg width='${e}' height='${n}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
123
+ case "circle":
124
+ return n = e, `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${n}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;
125
+ case "text":
126
+ return n = (0.1 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
127
+ case "textWithLogo":
128
+ return n = (0.25 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
129
+ case "textLight":
130
+ return n = (0.1 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
131
+ case "textWithLogoLight":
132
+ return n = (0.25 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
133
+ default:
134
+ return n = e, `data:image/svg+xml,%3Csvg width='${e}' height='${n}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
135
+ }
136
+ };
137
+ class Y {
138
+ constructor(e, n) {
139
+ this.scope = e, this.module = n;
140
+ }
141
+ storeObject(e, n) {
142
+ this.setItem(e, JSON.stringify(n));
143
+ }
144
+ loadObject(e) {
145
+ const n = this.getItem(e);
146
+ return n ? JSON.parse(n) : void 0;
147
+ }
148
+ setItem(e, n) {
149
+ localStorage.setItem(this.scopedKey(e), n);
150
+ }
151
+ getItem(e) {
152
+ return localStorage.getItem(this.scopedKey(e));
153
+ }
154
+ removeItem(e) {
155
+ localStorage.removeItem(this.scopedKey(e));
156
+ }
157
+ clear() {
158
+ const e = this.scopedKey(""), n = [];
159
+ for (let s = 0; s < localStorage.length; s++) {
160
+ const r = localStorage.key(s);
161
+ typeof r == "string" && r.startsWith(e) && n.push(r);
162
+ }
163
+ n.forEach((s) => localStorage.removeItem(s));
164
+ }
165
+ scopedKey(e) {
166
+ return `-${this.scope}${this.module ? `:${this.module}` : ""}:${e}`;
167
+ }
168
+ static clearAll() {
169
+ new Y("CBWSDK").clear(), new Y("walletlink").clear();
170
+ }
171
+ }
172
+ const U = {
173
+ rpc: {
174
+ invalidInput: -32e3,
175
+ resourceNotFound: -32001,
176
+ resourceUnavailable: -32002,
177
+ transactionRejected: -32003,
178
+ methodNotSupported: -32004,
179
+ limitExceeded: -32005,
180
+ parse: -32700,
181
+ invalidRequest: -32600,
182
+ methodNotFound: -32601,
183
+ invalidParams: -32602,
184
+ internal: -32603
185
+ },
186
+ provider: {
187
+ userRejectedRequest: 4001,
188
+ unauthorized: 4100,
189
+ unsupportedMethod: 4200,
190
+ disconnected: 4900,
191
+ chainDisconnected: 4901,
192
+ unsupportedChain: 4902
193
+ }
194
+ }, ze = {
195
+ "-32700": {
196
+ standard: "JSON RPC 2.0",
197
+ message: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
198
+ },
199
+ "-32600": {
200
+ standard: "JSON RPC 2.0",
201
+ message: "The JSON sent is not a valid Request object."
202
+ },
203
+ "-32601": {
204
+ standard: "JSON RPC 2.0",
205
+ message: "The method does not exist / is not available."
206
+ },
207
+ "-32602": {
208
+ standard: "JSON RPC 2.0",
209
+ message: "Invalid method parameter(s)."
210
+ },
211
+ "-32603": {
212
+ standard: "JSON RPC 2.0",
213
+ message: "Internal JSON-RPC error."
214
+ },
215
+ "-32000": {
216
+ standard: "EIP-1474",
217
+ message: "Invalid input."
218
+ },
219
+ "-32001": {
220
+ standard: "EIP-1474",
221
+ message: "Resource not found."
222
+ },
223
+ "-32002": {
224
+ standard: "EIP-1474",
225
+ message: "Resource unavailable."
226
+ },
227
+ "-32003": {
228
+ standard: "EIP-1474",
229
+ message: "Transaction rejected."
230
+ },
231
+ "-32004": {
232
+ standard: "EIP-1474",
233
+ message: "Method not supported."
234
+ },
235
+ "-32005": {
236
+ standard: "EIP-1474",
237
+ message: "Request limit exceeded."
238
+ },
239
+ 4001: {
240
+ standard: "EIP-1193",
241
+ message: "User rejected the request."
242
+ },
243
+ 4100: {
244
+ standard: "EIP-1193",
245
+ message: "The requested account and/or method has not been authorized by the user."
246
+ },
247
+ 4200: {
248
+ standard: "EIP-1193",
249
+ message: "The requested method is not supported by this Ethereum provider."
250
+ },
251
+ 4900: {
252
+ standard: "EIP-1193",
253
+ message: "The provider is disconnected from all chains."
254
+ },
255
+ 4901: {
256
+ standard: "EIP-1193",
257
+ message: "The provider is disconnected from the specified chain."
258
+ },
259
+ 4902: {
260
+ standard: "EIP-3085",
261
+ message: "Unrecognized chain ID."
262
+ }
263
+ }, Xt = "Unspecified error message.", zn = "Unspecified server error.";
264
+ function tt(t, e = Xt) {
265
+ if (t && Number.isInteger(t)) {
266
+ const n = t.toString();
267
+ if ($e(ze, n))
268
+ return ze[n].message;
269
+ if (en(t))
270
+ return zn;
271
+ }
272
+ return e;
273
+ }
274
+ function $n(t) {
275
+ if (!Number.isInteger(t))
276
+ return !1;
277
+ const e = t.toString();
278
+ return !!(ze[e] || en(t));
279
+ }
280
+ function Zn(t, { shouldIncludeStack: e = !1 } = {}) {
281
+ const n = {};
282
+ if (t && typeof t == "object" && !Array.isArray(t) && $e(t, "code") && $n(t.code)) {
283
+ const s = t;
284
+ n.code = s.code, s.message && typeof s.message == "string" ? (n.message = s.message, $e(s, "data") && (n.data = s.data)) : (n.message = tt(n.code), n.data = { originalError: _t(t) });
285
+ } else
286
+ n.code = U.rpc.internal, n.message = mt(t, "message") ? t.message : Xt, n.data = { originalError: _t(t) };
287
+ return e && (n.stack = mt(t, "stack") ? t.stack : void 0), n;
288
+ }
289
+ function en(t) {
290
+ return t >= -32099 && t <= -32e3;
291
+ }
292
+ function _t(t) {
293
+ return t && typeof t == "object" && !Array.isArray(t) ? Object.assign({}, t) : t;
294
+ }
295
+ function $e(t, e) {
296
+ return Object.prototype.hasOwnProperty.call(t, e);
297
+ }
298
+ function mt(t, e) {
299
+ return typeof t == "object" && t !== null && e in t && typeof t[e] == "string";
300
+ }
301
+ const L = {
302
+ rpc: {
303
+ parse: (t) => $(U.rpc.parse, t),
304
+ invalidRequest: (t) => $(U.rpc.invalidRequest, t),
305
+ invalidParams: (t) => $(U.rpc.invalidParams, t),
306
+ methodNotFound: (t) => $(U.rpc.methodNotFound, t),
307
+ internal: (t) => $(U.rpc.internal, t),
308
+ server: (t) => {
309
+ if (!t || typeof t != "object" || Array.isArray(t))
310
+ throw new Error("Ethereum RPC Server errors must provide single object argument.");
311
+ const { code: e } = t;
312
+ if (!Number.isInteger(e) || e > -32005 || e < -32099)
313
+ throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');
314
+ return $(e, t);
315
+ },
316
+ invalidInput: (t) => $(U.rpc.invalidInput, t),
317
+ resourceNotFound: (t) => $(U.rpc.resourceNotFound, t),
318
+ resourceUnavailable: (t) => $(U.rpc.resourceUnavailable, t),
319
+ transactionRejected: (t) => $(U.rpc.transactionRejected, t),
320
+ methodNotSupported: (t) => $(U.rpc.methodNotSupported, t),
321
+ limitExceeded: (t) => $(U.rpc.limitExceeded, t)
322
+ },
323
+ provider: {
324
+ userRejectedRequest: (t) => oe(U.provider.userRejectedRequest, t),
325
+ unauthorized: (t) => oe(U.provider.unauthorized, t),
326
+ unsupportedMethod: (t) => oe(U.provider.unsupportedMethod, t),
327
+ disconnected: (t) => oe(U.provider.disconnected, t),
328
+ chainDisconnected: (t) => oe(U.provider.chainDisconnected, t),
329
+ unsupportedChain: (t) => oe(U.provider.unsupportedChain, t),
330
+ custom: (t) => {
331
+ if (!t || typeof t != "object" || Array.isArray(t))
332
+ throw new Error("Ethereum Provider custom errors must provide single object argument.");
333
+ const { code: e, message: n, data: s } = t;
334
+ if (!n || typeof n != "string")
335
+ throw new Error('"message" must be a nonempty string');
336
+ return new sn(e, n, s);
337
+ }
338
+ }
339
+ };
340
+ function $(t, e) {
341
+ const [n, s] = tn(e);
342
+ return new nn(t, n || tt(t), s);
343
+ }
344
+ function oe(t, e) {
345
+ const [n, s] = tn(e);
346
+ return new sn(t, n || tt(t), s);
347
+ }
348
+ function tn(t) {
349
+ if (t) {
350
+ if (typeof t == "string")
351
+ return [t];
352
+ if (typeof t == "object" && !Array.isArray(t)) {
353
+ const { message: e, data: n } = t;
354
+ if (e && typeof e != "string")
355
+ throw new Error("Must specify string message.");
356
+ return [e || void 0, n];
357
+ }
358
+ }
359
+ return [];
360
+ }
361
+ class nn extends Error {
362
+ constructor(e, n, s) {
363
+ if (!Number.isInteger(e))
364
+ throw new Error('"code" must be an integer.');
365
+ if (!n || typeof n != "string")
366
+ throw new Error('"message" must be a nonempty string.');
367
+ super(n), this.code = e, s !== void 0 && (this.data = s);
368
+ }
369
+ }
370
+ class sn extends nn {
371
+ /**
372
+ * Create an Ethereum Provider JSON-RPC error.
373
+ * `code` must be an integer in the 1000 <= 4999 range.
374
+ */
375
+ constructor(e, n, s) {
376
+ if (!Gn(e))
377
+ throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
378
+ super(e, n, s);
379
+ }
380
+ }
381
+ function Gn(t) {
382
+ return Number.isInteger(t) && t >= 1e3 && t <= 4999;
383
+ }
384
+ function nt() {
385
+ return (t) => t;
386
+ }
387
+ const _e = nt(), Yn = nt(), Jn = nt();
388
+ function J(t) {
389
+ return Math.floor(t);
390
+ }
391
+ const rn = /^[0-9]*$/, an = /^[a-f0-9]*$/;
392
+ function ie(t) {
393
+ return st(crypto.getRandomValues(new Uint8Array(t)));
394
+ }
395
+ function st(t) {
396
+ return [...t].map((e) => e.toString(16).padStart(2, "0")).join("");
397
+ }
398
+ function ve(t) {
399
+ return new Uint8Array(t.match(/.{1,2}/g).map((e) => Number.parseInt(e, 16)));
400
+ }
401
+ function he(t, e = !1) {
402
+ const n = t.toString("hex");
403
+ return _e(e ? `0x${n}` : n);
404
+ }
405
+ function Ne(t) {
406
+ return he(Ze(t), !0);
407
+ }
408
+ function Z(t) {
409
+ return Jn(t.toString(10));
410
+ }
411
+ function ne(t) {
412
+ return _e(`0x${BigInt(t).toString(16)}`);
413
+ }
414
+ function on(t) {
415
+ return t.startsWith("0x") || t.startsWith("0X");
416
+ }
417
+ function it(t) {
418
+ return on(t) ? t.slice(2) : t;
419
+ }
420
+ function cn(t) {
421
+ return on(t) ? `0x${t.slice(2)}` : `0x${t}`;
422
+ }
423
+ function Me(t) {
424
+ if (typeof t != "string")
425
+ return !1;
426
+ const e = it(t).toLowerCase();
427
+ return an.test(e);
428
+ }
429
+ function Qn(t, e = !1) {
430
+ if (typeof t == "string") {
431
+ const n = it(t).toLowerCase();
432
+ if (an.test(n))
433
+ return _e(e ? `0x${n}` : n);
434
+ }
435
+ throw L.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`);
436
+ }
437
+ function rt(t, e = !1) {
438
+ let n = Qn(t, !1);
439
+ return n.length % 2 === 1 && (n = _e(`0${n}`)), e ? _e(`0x${n}`) : n;
440
+ }
441
+ function ee(t) {
442
+ if (typeof t == "string") {
443
+ const e = it(t).toLowerCase();
444
+ if (Me(e) && e.length === 40)
445
+ return Yn(cn(e));
446
+ }
447
+ throw L.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`);
448
+ }
449
+ function Ze(t) {
450
+ if (Buffer.isBuffer(t))
451
+ return t;
452
+ if (typeof t == "string") {
453
+ if (Me(t)) {
454
+ const e = rt(t, !1);
455
+ return Buffer.from(e, "hex");
456
+ }
457
+ return Buffer.from(t, "utf8");
458
+ }
459
+ throw L.rpc.invalidParams(`Not binary data: ${String(t)}`);
460
+ }
461
+ function fe(t) {
462
+ if (typeof t == "number" && Number.isInteger(t))
463
+ return J(t);
464
+ if (typeof t == "string") {
465
+ if (rn.test(t))
466
+ return J(Number(t));
467
+ if (Me(t))
468
+ return J(Number(BigInt(rt(t, !0))));
469
+ }
470
+ throw L.rpc.invalidParams(`Not an integer: ${String(t)}`);
471
+ }
472
+ function de(t) {
473
+ if (t !== null && (typeof t == "bigint" || es(t)))
474
+ return BigInt(t.toString(10));
475
+ if (typeof t == "number")
476
+ return BigInt(fe(t));
477
+ if (typeof t == "string") {
478
+ if (rn.test(t))
479
+ return BigInt(t);
480
+ if (Me(t))
481
+ return BigInt(rt(t, !0));
482
+ }
483
+ throw L.rpc.invalidParams(`Not an integer: ${String(t)}`);
484
+ }
485
+ function Xn(t) {
486
+ if (typeof t == "string")
487
+ return JSON.parse(t);
488
+ if (typeof t == "object")
489
+ return t;
490
+ throw L.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`);
491
+ }
492
+ function es(t) {
493
+ if (t == null || typeof t.constructor != "function")
494
+ return !1;
495
+ const { constructor: e } = t;
496
+ return typeof e.config == "function" && typeof e.EUCLID == "number";
497
+ }
498
+ function ts() {
499
+ const t = document.querySelector('link[sizes="192x192"]') || document.querySelector('link[sizes="180x180"]') || document.querySelector('link[rel="icon"]') || document.querySelector('link[rel="shortcut icon"]'), { protocol: e, host: n } = document.location, s = t ? t.getAttribute("href") : null;
500
+ return !s || s.startsWith("javascript:") || s.startsWith("vbscript:") ? `${e}//${n}/favicon.ico` : s.startsWith("http://") || s.startsWith("https://") || s.startsWith("data:") ? s : s.startsWith("//") ? e + s : `${e}//${n}${s}`;
501
+ }
502
+ async function ns() {
503
+ return crypto.subtle.generateKey({
504
+ name: "ECDH",
505
+ namedCurve: "P-256"
506
+ }, !0, ["deriveKey"]);
507
+ }
508
+ async function ss(t, e) {
509
+ return crypto.subtle.deriveKey({
510
+ name: "ECDH",
511
+ public: e
512
+ }, t, {
513
+ name: "AES-GCM",
514
+ length: 256
515
+ }, !1, ["encrypt", "decrypt"]);
516
+ }
517
+ async function is(t, e) {
518
+ const n = crypto.getRandomValues(new Uint8Array(12)), s = await crypto.subtle.encrypt({
519
+ name: "AES-GCM",
520
+ iv: n
521
+ }, t, new TextEncoder().encode(e));
522
+ return { iv: n, cipherText: s };
523
+ }
524
+ async function rs(t, { iv: e, cipherText: n }) {
525
+ const s = await crypto.subtle.decrypt({
526
+ name: "AES-GCM",
527
+ iv: e
528
+ }, t, n);
529
+ return new TextDecoder().decode(s);
530
+ }
531
+ function ln(t) {
532
+ switch (t) {
533
+ case "public":
534
+ return "spki";
535
+ case "private":
536
+ return "pkcs8";
537
+ }
538
+ }
539
+ async function dn(t, e) {
540
+ const n = ln(t), s = await crypto.subtle.exportKey(n, e);
541
+ return st(new Uint8Array(s));
542
+ }
543
+ async function un(t, e) {
544
+ const n = ln(t), s = ve(e).buffer;
545
+ return await crypto.subtle.importKey(n, new Uint8Array(s), {
546
+ name: "ECDH",
547
+ namedCurve: "P-256"
548
+ }, !0, t === "private" ? ["deriveKey"] : []);
549
+ }
550
+ async function as(t, e) {
551
+ const n = JSON.stringify(t, (s, r) => {
552
+ if (!(r instanceof Error))
553
+ return r;
554
+ const i = r;
555
+ return Object.assign(Object.assign({}, i.code ? { code: i.code } : {}), { message: i.message });
556
+ });
557
+ return is(e, n);
558
+ }
559
+ async function os(t, e) {
560
+ return JSON.parse(await rs(e, t));
561
+ }
562
+ const De = {
563
+ storageKey: "ownPrivateKey",
564
+ keyType: "private"
565
+ }, He = {
566
+ storageKey: "ownPublicKey",
567
+ keyType: "public"
568
+ }, Ue = {
569
+ storageKey: "peerPublicKey",
570
+ keyType: "public"
571
+ };
572
+ class cs {
573
+ constructor() {
574
+ this.storage = new Y("CBWSDK", "SCWKeyManager"), this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null;
575
+ }
576
+ async getOwnPublicKey() {
577
+ return await this.loadKeysIfNeeded(), this.ownPublicKey;
578
+ }
579
+ // returns null if the shared secret is not yet derived
580
+ async getSharedSecret() {
581
+ return await this.loadKeysIfNeeded(), this.sharedSecret;
582
+ }
583
+ async setPeerPublicKey(e) {
584
+ this.sharedSecret = null, this.peerPublicKey = e, await this.storeKey(Ue, e), await this.loadKeysIfNeeded();
585
+ }
586
+ async clear() {
587
+ this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null, this.storage.removeItem(He.storageKey), this.storage.removeItem(De.storageKey), this.storage.removeItem(Ue.storageKey);
588
+ }
589
+ async generateKeyPair() {
590
+ const e = await ns();
591
+ this.ownPrivateKey = e.privateKey, this.ownPublicKey = e.publicKey, await this.storeKey(De, e.privateKey), await this.storeKey(He, e.publicKey);
592
+ }
593
+ async loadKeysIfNeeded() {
594
+ if (this.ownPrivateKey === null && (this.ownPrivateKey = await this.loadKey(De)), this.ownPublicKey === null && (this.ownPublicKey = await this.loadKey(He)), (this.ownPrivateKey === null || this.ownPublicKey === null) && await this.generateKeyPair(), this.peerPublicKey === null && (this.peerPublicKey = await this.loadKey(Ue)), this.sharedSecret === null) {
595
+ if (this.ownPrivateKey === null || this.peerPublicKey === null)
596
+ return;
597
+ this.sharedSecret = await ss(this.ownPrivateKey, this.peerPublicKey);
598
+ }
599
+ }
600
+ // storage methods
601
+ async loadKey(e) {
602
+ const n = this.storage.getItem(e.storageKey);
603
+ return n ? un(e.keyType, n) : null;
604
+ }
605
+ async storeKey(e, n) {
606
+ const s = await dn(e.keyType, n);
607
+ this.storage.setItem(e.storageKey, s);
608
+ }
609
+ }
610
+ function ls(t) {
611
+ if (!t || !Array.isArray(t) || t.length !== 1 && t.length !== 2 || typeof t[0] != "string" || !Fe(t[0]))
612
+ throw L.rpc.invalidParams();
613
+ if (t.length === 2) {
614
+ if (!Array.isArray(t[1]))
615
+ throw L.rpc.invalidParams();
616
+ for (const e of t[1])
617
+ if (typeof e != "string" || !e.startsWith("0x"))
618
+ throw L.rpc.invalidParams();
619
+ }
620
+ }
621
+ const me = "4.3.7", hn = "@coinbase/wallet-sdk";
622
+ async function at(t, e) {
623
+ const n = Object.assign(Object.assign({}, t), { jsonrpc: "2.0", id: crypto.randomUUID() }), s = await window.fetch(e, {
624
+ method: "POST",
625
+ body: JSON.stringify(n),
626
+ mode: "cors",
627
+ headers: {
628
+ "Content-Type": "application/json",
629
+ "X-Cbw-Sdk-Version": me,
630
+ "X-Cbw-Sdk-Platform": hn
631
+ }
632
+ }), { result: r, error: i } = await s.json();
633
+ if (i)
634
+ throw i;
635
+ return r;
636
+ }
637
+ function ds() {
638
+ return globalThis.coinbaseWalletExtension;
639
+ }
640
+ function us() {
641
+ var t, e;
642
+ try {
643
+ const n = globalThis;
644
+ return (e = (t = n.top) === null || t === void 0 ? void 0 : t.ethereum) !== null && e !== void 0 ? e : n.ethereum;
645
+ } catch {
646
+ return;
647
+ }
648
+ }
649
+ function hs({ metadata: t, preference: e }) {
650
+ var n, s;
651
+ const { appName: r, appLogoUrl: i, appChainIds: a } = t;
652
+ if (e.options !== "smartWalletOnly") {
653
+ const u = ds();
654
+ if (u)
655
+ return (n = u.setAppInfo) === null || n === void 0 || n.call(u, r, i, a, e), u;
656
+ }
657
+ const l = us();
658
+ if (l != null && l.isCoinbaseBrowser)
659
+ return (s = l.setAppInfo) === null || s === void 0 || s.call(l, r, i, a, e), l;
660
+ }
661
+ function fs(t) {
662
+ if (!t || typeof t != "object" || Array.isArray(t))
663
+ throw L.rpc.invalidParams({
664
+ message: "Expected a single, non-array, object argument.",
665
+ data: t
666
+ });
667
+ const { method: e, params: n } = t;
668
+ if (typeof e != "string" || e.length === 0)
669
+ throw L.rpc.invalidParams({
670
+ message: "'args.method' must be a non-empty string.",
671
+ data: t
672
+ });
673
+ if (n !== void 0 && !Array.isArray(n) && (typeof n != "object" || n === null))
674
+ throw L.rpc.invalidParams({
675
+ message: "'args.params' must be an object or array if provided.",
676
+ data: t
677
+ });
678
+ switch (e) {
679
+ case "eth_sign":
680
+ case "eth_signTypedData_v2":
681
+ case "eth_subscribe":
682
+ case "eth_unsubscribe":
683
+ throw L.provider.unsupportedMethod();
684
+ }
685
+ }
686
+ const yt = "accounts", wt = "activeChain", bt = "availableChains", vt = "walletCapabilities";
687
+ class ps {
688
+ constructor(e) {
689
+ var n, s, r;
690
+ this.metadata = e.metadata, this.communicator = e.communicator, this.callback = e.callback, this.keyManager = new cs(), this.storage = new Y("CBWSDK", "SCWStateManager"), this.accounts = (n = this.storage.loadObject(yt)) !== null && n !== void 0 ? n : [], this.chain = this.storage.loadObject(wt) || {
691
+ id: (r = (s = e.metadata.appChainIds) === null || s === void 0 ? void 0 : s[0]) !== null && r !== void 0 ? r : 1
692
+ }, this.handshake = this.handshake.bind(this), this.request = this.request.bind(this), this.createRequestMessage = this.createRequestMessage.bind(this), this.decryptResponseMessage = this.decryptResponseMessage.bind(this);
693
+ }
694
+ async handshake(e) {
695
+ var n, s, r, i;
696
+ await ((s = (n = this.communicator).waitForPopupLoaded) === null || s === void 0 ? void 0 : s.call(n));
697
+ const a = await this.createRequestMessage({
698
+ handshake: {
699
+ method: e.method,
700
+ params: Object.assign({}, this.metadata, (r = e.params) !== null && r !== void 0 ? r : {})
701
+ }
702
+ }), l = await this.communicator.postRequestAndWaitForResponse(a);
703
+ if ("failure" in l.content)
704
+ throw l.content.failure;
705
+ const u = await un("public", l.sender);
706
+ await this.keyManager.setPeerPublicKey(u);
707
+ const p = (await this.decryptResponseMessage(l)).result;
708
+ if ("error" in p)
709
+ throw p.error;
710
+ switch (e.method) {
711
+ case "eth_requestAccounts": {
712
+ const g = p.value;
713
+ this.accounts = g, this.storage.storeObject(yt, g), (i = this.callback) === null || i === void 0 || i.call(this, "accountsChanged", g);
714
+ break;
715
+ }
716
+ }
717
+ }
718
+ async request(e) {
719
+ var n;
720
+ if (this.accounts.length === 0)
721
+ switch (e.method) {
722
+ case "wallet_sendCalls":
723
+ return this.sendRequestToPopup(e);
724
+ default:
725
+ throw L.provider.unauthorized();
726
+ }
727
+ switch (e.method) {
728
+ case "eth_requestAccounts":
729
+ return (n = this.callback) === null || n === void 0 || n.call(this, "connect", { chainId: ne(this.chain.id) }), this.accounts;
730
+ case "eth_accounts":
731
+ return this.accounts;
732
+ case "eth_coinbase":
733
+ return this.accounts[0];
734
+ case "net_version":
735
+ return this.chain.id;
736
+ case "eth_chainId":
737
+ return ne(this.chain.id);
738
+ case "wallet_getCapabilities":
739
+ return this.handleGetCapabilitiesRequest(e);
740
+ case "wallet_switchEthereumChain":
741
+ return this.handleSwitchChainRequest(e);
742
+ case "eth_ecRecover":
743
+ case "personal_sign":
744
+ case "wallet_sign":
745
+ case "personal_ecRecover":
746
+ case "eth_signTransaction":
747
+ case "eth_sendTransaction":
748
+ case "eth_signTypedData_v1":
749
+ case "eth_signTypedData_v3":
750
+ case "eth_signTypedData_v4":
751
+ case "eth_signTypedData":
752
+ case "wallet_addEthereumChain":
753
+ case "wallet_watchAsset":
754
+ case "wallet_sendCalls":
755
+ case "wallet_showCallsStatus":
756
+ case "wallet_grantPermissions":
757
+ return this.sendRequestToPopup(e);
758
+ default:
759
+ if (!this.chain.rpcUrl)
760
+ throw L.rpc.internal("No RPC URL set for chain");
761
+ return at(e, this.chain.rpcUrl);
762
+ }
763
+ }
764
+ async sendRequestToPopup(e) {
765
+ var n, s;
766
+ await ((s = (n = this.communicator).waitForPopupLoaded) === null || s === void 0 ? void 0 : s.call(n));
767
+ const r = await this.sendEncryptedRequest(e), a = (await this.decryptResponseMessage(r)).result;
768
+ if ("error" in a)
769
+ throw a.error;
770
+ return a.value;
771
+ }
772
+ async cleanup() {
773
+ var e, n;
774
+ this.storage.clear(), await this.keyManager.clear(), this.accounts = [], this.chain = {
775
+ id: (n = (e = this.metadata.appChainIds) === null || e === void 0 ? void 0 : e[0]) !== null && n !== void 0 ? n : 1
776
+ };
777
+ }
778
+ /**
779
+ * @returns `null` if the request was successful.
780
+ * https://eips.ethereum.org/EIPS/eip-3326#wallet_switchethereumchain
781
+ */
782
+ async handleSwitchChainRequest(e) {
783
+ var n;
784
+ const s = e.params;
785
+ if (!s || !(!((n = s[0]) === null || n === void 0) && n.chainId))
786
+ throw L.rpc.invalidParams();
787
+ const r = fe(s[0].chainId);
788
+ if (this.updateChain(r))
789
+ return null;
790
+ const a = await this.sendRequestToPopup(e);
791
+ return a === null && this.updateChain(r), a;
792
+ }
793
+ async handleGetCapabilitiesRequest(e) {
794
+ ls(e.params);
795
+ const n = e.params[0], s = e.params[1];
796
+ if (!this.accounts.some((l) => Kn(l, n)))
797
+ throw L.provider.unauthorized("no active account found");
798
+ const r = this.storage.loadObject(vt);
799
+ if (!r)
800
+ return {};
801
+ if (!s || s.length === 0)
802
+ return r;
803
+ const i = new Set(s.map((l) => pt(l)));
804
+ return Object.fromEntries(Object.entries(r).filter(([l]) => {
805
+ try {
806
+ const u = pt(l);
807
+ return i.has(u);
808
+ } catch {
809
+ return !1;
810
+ }
811
+ }));
812
+ }
813
+ async sendEncryptedRequest(e) {
814
+ const n = await this.keyManager.getSharedSecret();
815
+ if (!n)
816
+ throw L.provider.unauthorized("No valid session found, try requestAccounts before other methods");
817
+ const s = await as({
818
+ action: e,
819
+ chainId: this.chain.id
820
+ }, n), r = await this.createRequestMessage({ encrypted: s });
821
+ return this.communicator.postRequestAndWaitForResponse(r);
822
+ }
823
+ async createRequestMessage(e) {
824
+ const n = await dn("public", await this.keyManager.getOwnPublicKey());
825
+ return {
826
+ id: crypto.randomUUID(),
827
+ sender: n,
828
+ content: e,
829
+ timestamp: /* @__PURE__ */ new Date()
830
+ };
831
+ }
832
+ async decryptResponseMessage(e) {
833
+ var n, s;
834
+ const r = e.content;
835
+ if ("failure" in r)
836
+ throw r.failure;
837
+ const i = await this.keyManager.getSharedSecret();
838
+ if (!i)
839
+ throw L.provider.unauthorized("Invalid session");
840
+ const a = await os(r.encrypted, i), l = (n = a.data) === null || n === void 0 ? void 0 : n.chains;
841
+ if (l) {
842
+ const d = Object.entries(l).map(([p, g]) => ({
843
+ id: Number(p),
844
+ rpcUrl: g
845
+ }));
846
+ this.storage.storeObject(bt, d), this.updateChain(this.chain.id, d);
847
+ }
848
+ const u = (s = a.data) === null || s === void 0 ? void 0 : s.capabilities;
849
+ return u && this.storage.storeObject(vt, u), a;
850
+ }
851
+ updateChain(e, n) {
852
+ var s;
853
+ const r = n ?? this.storage.loadObject(bt), i = r == null ? void 0 : r.find((a) => a.id === e);
854
+ return i ? (i !== this.chain && (this.chain = i, this.storage.storeObject(wt, i), (s = this.callback) === null || s === void 0 || s.call(this, "chainChanged", ne(i.id))), !0) : !1;
855
+ }
856
+ }
857
+ var T = {}, x = {}, kt;
858
+ function gs() {
859
+ if (kt) return x;
860
+ kt = 1, Object.defineProperty(x, "__esModule", { value: !0 }), x.toBig = x.shrSL = x.shrSH = x.rotrSL = x.rotrSH = x.rotrBL = x.rotrBH = x.rotr32L = x.rotr32H = x.rotlSL = x.rotlSH = x.rotlBL = x.rotlBH = x.add5L = x.add5H = x.add4L = x.add4H = x.add3L = x.add3H = void 0, x.add = I, x.fromBig = n, x.split = s;
861
+ const t = /* @__PURE__ */ BigInt(2 ** 32 - 1), e = /* @__PURE__ */ BigInt(32);
862
+ function n(b, m = !1) {
863
+ return m ? { h: Number(b & t), l: Number(b >> e & t) } : { h: Number(b >> e & t) | 0, l: Number(b & t) | 0 };
864
+ }
865
+ function s(b, m = !1) {
866
+ const w = b.length;
867
+ let H = new Uint32Array(w), W = new Uint32Array(w);
868
+ for (let q = 0; q < w; q++) {
869
+ const { h: re, l: ae } = n(b[q], m);
870
+ [H[q], W[q]] = [re, ae];
871
+ }
872
+ return [H, W];
873
+ }
874
+ const r = (b, m) => BigInt(b >>> 0) << e | BigInt(m >>> 0);
875
+ x.toBig = r;
876
+ const i = (b, m, w) => b >>> w;
877
+ x.shrSH = i;
878
+ const a = (b, m, w) => b << 32 - w | m >>> w;
879
+ x.shrSL = a;
880
+ const l = (b, m, w) => b >>> w | m << 32 - w;
881
+ x.rotrSH = l;
882
+ const u = (b, m, w) => b << 32 - w | m >>> w;
883
+ x.rotrSL = u;
884
+ const d = (b, m, w) => b << 64 - w | m >>> w - 32;
885
+ x.rotrBH = d;
886
+ const p = (b, m, w) => b >>> w - 32 | m << 64 - w;
887
+ x.rotrBL = p;
888
+ const g = (b, m) => m;
889
+ x.rotr32H = g;
890
+ const o = (b, m) => b;
891
+ x.rotr32L = o;
892
+ const c = (b, m, w) => b << w | m >>> 32 - w;
893
+ x.rotlSH = c;
894
+ const h = (b, m, w) => m << w | b >>> 32 - w;
895
+ x.rotlSL = h;
896
+ const E = (b, m, w) => m << w - 32 | b >>> 64 - w;
897
+ x.rotlBH = E;
898
+ const _ = (b, m, w) => b << w - 32 | m >>> 64 - w;
899
+ x.rotlBL = _;
900
+ function I(b, m, w, H) {
901
+ const W = (m >>> 0) + (H >>> 0);
902
+ return { h: b + w + (W / 2 ** 32 | 0) | 0, l: W | 0 };
903
+ }
904
+ const v = (b, m, w) => (b >>> 0) + (m >>> 0) + (w >>> 0);
905
+ x.add3L = v;
906
+ const k = (b, m, w, H) => m + w + H + (b / 2 ** 32 | 0) | 0;
907
+ x.add3H = k;
908
+ const C = (b, m, w, H) => (b >>> 0) + (m >>> 0) + (w >>> 0) + (H >>> 0);
909
+ x.add4L = C;
910
+ const y = (b, m, w, H, W) => m + w + H + W + (b / 2 ** 32 | 0) | 0;
911
+ x.add4H = y;
912
+ const A = (b, m, w, H, W) => (b >>> 0) + (m >>> 0) + (w >>> 0) + (H >>> 0) + (W >>> 0);
913
+ x.add5L = A;
914
+ const M = (b, m, w, H, W, q) => m + w + H + W + q + (b / 2 ** 32 | 0) | 0;
915
+ x.add5H = M;
916
+ const P = {
917
+ fromBig: n,
918
+ split: s,
919
+ toBig: r,
920
+ shrSH: i,
921
+ shrSL: a,
922
+ rotrSH: l,
923
+ rotrSL: u,
924
+ rotrBH: d,
925
+ rotrBL: p,
926
+ rotr32H: g,
927
+ rotr32L: o,
928
+ rotlSH: c,
929
+ rotlSL: h,
930
+ rotlBH: E,
931
+ rotlBL: _,
932
+ add: I,
933
+ add3L: v,
934
+ add3H: k,
935
+ add4L: C,
936
+ add4H: y,
937
+ add5H: M,
938
+ add5L: A
939
+ };
940
+ return x.default = P, x;
941
+ }
942
+ var je = {}, ue = {}, Et;
943
+ function _s() {
944
+ return Et || (Et = 1, Object.defineProperty(ue, "__esModule", { value: !0 }), ue.crypto = void 0, ue.crypto = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0), ue;
945
+ }
946
+ var It;
947
+ function ms() {
948
+ return It || (It = 1, (function(t) {
949
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
950
+ Object.defineProperty(t, "__esModule", { value: !0 }), t.wrapXOFConstructorWithOpts = t.wrapConstructorWithOpts = t.wrapConstructor = t.Hash = t.nextTick = t.swap32IfBE = t.byteSwapIfBE = t.swap8IfBE = t.isLE = void 0, t.isBytes = n, t.anumber = s, t.abytes = r, t.ahash = i, t.aexists = a, t.aoutput = l, t.u8 = u, t.u32 = d, t.clean = p, t.createView = g, t.rotr = o, t.rotl = c, t.byteSwap = h, t.byteSwap32 = E, t.bytesToHex = v, t.hexToBytes = y, t.asyncLoop = M, t.utf8ToBytes = P, t.bytesToUtf8 = b, t.toBytes = m, t.kdfInputToBytes = w, t.concatBytes = H, t.checkOpts = W, t.createHasher = re, t.createOptHasher = ae, t.createXOFer = se, t.randomBytes = Hn;
951
+ const e = /* @__PURE__ */ _s();
952
+ function n(f) {
953
+ return f instanceof Uint8Array || ArrayBuffer.isView(f) && f.constructor.name === "Uint8Array";
954
+ }
955
+ function s(f) {
956
+ if (!Number.isSafeInteger(f) || f < 0)
957
+ throw new Error("positive integer expected, got " + f);
958
+ }
959
+ function r(f, ...S) {
960
+ if (!n(f))
961
+ throw new Error("Uint8Array expected");
962
+ if (S.length > 0 && !S.includes(f.length))
963
+ throw new Error("Uint8Array expected of length " + S + ", got length=" + f.length);
964
+ }
965
+ function i(f) {
966
+ if (typeof f != "function" || typeof f.create != "function")
967
+ throw new Error("Hash should be wrapped by utils.createHasher");
968
+ s(f.outputLen), s(f.blockLen);
969
+ }
970
+ function a(f, S = !0) {
971
+ if (f.destroyed)
972
+ throw new Error("Hash instance has been destroyed");
973
+ if (S && f.finished)
974
+ throw new Error("Hash#digest() has already been called");
975
+ }
976
+ function l(f, S) {
977
+ r(f);
978
+ const N = S.outputLen;
979
+ if (f.length < N)
980
+ throw new Error("digestInto() expects output buffer of length at least " + N);
981
+ }
982
+ function u(f) {
983
+ return new Uint8Array(f.buffer, f.byteOffset, f.byteLength);
984
+ }
985
+ function d(f) {
986
+ return new Uint32Array(f.buffer, f.byteOffset, Math.floor(f.byteLength / 4));
987
+ }
988
+ function p(...f) {
989
+ for (let S = 0; S < f.length; S++)
990
+ f[S].fill(0);
991
+ }
992
+ function g(f) {
993
+ return new DataView(f.buffer, f.byteOffset, f.byteLength);
994
+ }
995
+ function o(f, S) {
996
+ return f << 32 - S | f >>> S;
997
+ }
998
+ function c(f, S) {
999
+ return f << S | f >>> 32 - S >>> 0;
1000
+ }
1001
+ t.isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1002
+ function h(f) {
1003
+ return f << 24 & 4278190080 | f << 8 & 16711680 | f >>> 8 & 65280 | f >>> 24 & 255;
1004
+ }
1005
+ t.swap8IfBE = t.isLE ? (f) => f : (f) => h(f), t.byteSwapIfBE = t.swap8IfBE;
1006
+ function E(f) {
1007
+ for (let S = 0; S < f.length; S++)
1008
+ f[S] = h(f[S]);
1009
+ return f;
1010
+ }
1011
+ t.swap32IfBE = t.isLE ? (f) => f : E;
1012
+ const _ = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", I = /* @__PURE__ */ Array.from({ length: 256 }, (f, S) => S.toString(16).padStart(2, "0"));
1013
+ function v(f) {
1014
+ if (r(f), _)
1015
+ return f.toHex();
1016
+ let S = "";
1017
+ for (let N = 0; N < f.length; N++)
1018
+ S += I[f[N]];
1019
+ return S;
1020
+ }
1021
+ const k = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
1022
+ function C(f) {
1023
+ if (f >= k._0 && f <= k._9)
1024
+ return f - k._0;
1025
+ if (f >= k.A && f <= k.F)
1026
+ return f - (k.A - 10);
1027
+ if (f >= k.a && f <= k.f)
1028
+ return f - (k.a - 10);
1029
+ }
1030
+ function y(f) {
1031
+ if (typeof f != "string")
1032
+ throw new Error("hex string expected, got " + typeof f);
1033
+ if (_)
1034
+ return Uint8Array.fromHex(f);
1035
+ const S = f.length, N = S / 2;
1036
+ if (S % 2)
1037
+ throw new Error("hex string expected, got unpadded hex of length " + S);
1038
+ const D = new Uint8Array(N);
1039
+ for (let V = 0, F = 0; V < N; V++, F += 2) {
1040
+ const ut = C(f.charCodeAt(F)), ht = C(f.charCodeAt(F + 1));
1041
+ if (ut === void 0 || ht === void 0) {
1042
+ const Un = f[F] + f[F + 1];
1043
+ throw new Error('hex string expected, got non-hex character "' + Un + '" at index ' + F);
1044
+ }
1045
+ D[V] = ut * 16 + ht;
1046
+ }
1047
+ return D;
1048
+ }
1049
+ const A = async () => {
1050
+ };
1051
+ t.nextTick = A;
1052
+ async function M(f, S, N) {
1053
+ let D = Date.now();
1054
+ for (let V = 0; V < f; V++) {
1055
+ N(V);
1056
+ const F = Date.now() - D;
1057
+ F >= 0 && F < S || (await (0, t.nextTick)(), D += F);
1058
+ }
1059
+ }
1060
+ function P(f) {
1061
+ if (typeof f != "string")
1062
+ throw new Error("string expected");
1063
+ return new Uint8Array(new TextEncoder().encode(f));
1064
+ }
1065
+ function b(f) {
1066
+ return new TextDecoder().decode(f);
1067
+ }
1068
+ function m(f) {
1069
+ return typeof f == "string" && (f = P(f)), r(f), f;
1070
+ }
1071
+ function w(f) {
1072
+ return typeof f == "string" && (f = P(f)), r(f), f;
1073
+ }
1074
+ function H(...f) {
1075
+ let S = 0;
1076
+ for (let D = 0; D < f.length; D++) {
1077
+ const V = f[D];
1078
+ r(V), S += V.length;
1079
+ }
1080
+ const N = new Uint8Array(S);
1081
+ for (let D = 0, V = 0; D < f.length; D++) {
1082
+ const F = f[D];
1083
+ N.set(F, V), V += F.length;
1084
+ }
1085
+ return N;
1086
+ }
1087
+ function W(f, S) {
1088
+ if (S !== void 0 && {}.toString.call(S) !== "[object Object]")
1089
+ throw new Error("options should be object or undefined");
1090
+ return Object.assign(f, S);
1091
+ }
1092
+ class q {
1093
+ }
1094
+ t.Hash = q;
1095
+ function re(f) {
1096
+ const S = (D) => f().update(m(D)).digest(), N = f();
1097
+ return S.outputLen = N.outputLen, S.blockLen = N.blockLen, S.create = () => f(), S;
1098
+ }
1099
+ function ae(f) {
1100
+ const S = (D, V) => f(V).update(m(D)).digest(), N = f({});
1101
+ return S.outputLen = N.outputLen, S.blockLen = N.blockLen, S.create = (D) => f(D), S;
1102
+ }
1103
+ function se(f) {
1104
+ const S = (D, V) => f(V).update(m(D)).digest(), N = f({});
1105
+ return S.outputLen = N.outputLen, S.blockLen = N.blockLen, S.create = (D) => f(D), S;
1106
+ }
1107
+ t.wrapConstructor = re, t.wrapConstructorWithOpts = ae, t.wrapXOFConstructorWithOpts = se;
1108
+ function Hn(f = 32) {
1109
+ if (e.crypto && typeof e.crypto.getRandomValues == "function")
1110
+ return e.crypto.getRandomValues(new Uint8Array(f));
1111
+ if (e.crypto && typeof e.crypto.randomBytes == "function")
1112
+ return Uint8Array.from(e.crypto.randomBytes(f));
1113
+ throw new Error("crypto.getRandomValues must be defined");
1114
+ }
1115
+ })(je)), je;
1116
+ }
1117
+ var Ct;
1118
+ function ys() {
1119
+ if (Ct) return T;
1120
+ Ct = 1, Object.defineProperty(T, "__esModule", { value: !0 }), T.shake256 = T.shake128 = T.keccak_512 = T.keccak_384 = T.keccak_256 = T.keccak_224 = T.sha3_512 = T.sha3_384 = T.sha3_256 = T.sha3_224 = T.Keccak = void 0, T.keccakP = _;
1121
+ const t = /* @__PURE__ */ gs(), e = /* @__PURE__ */ ms(), n = BigInt(0), s = BigInt(1), r = BigInt(2), i = BigInt(7), a = BigInt(256), l = BigInt(113), u = [], d = [], p = [];
1122
+ for (let C = 0, y = s, A = 1, M = 0; C < 24; C++) {
1123
+ [A, M] = [M, (2 * A + 3 * M) % 5], u.push(2 * (5 * M + A)), d.push((C + 1) * (C + 2) / 2 % 64);
1124
+ let P = n;
1125
+ for (let b = 0; b < 7; b++)
1126
+ y = (y << s ^ (y >> i) * l) % a, y & r && (P ^= s << (s << /* @__PURE__ */ BigInt(b)) - s);
1127
+ p.push(P);
1128
+ }
1129
+ const g = (0, t.split)(p, !0), o = g[0], c = g[1], h = (C, y, A) => A > 32 ? (0, t.rotlBH)(C, y, A) : (0, t.rotlSH)(C, y, A), E = (C, y, A) => A > 32 ? (0, t.rotlBL)(C, y, A) : (0, t.rotlSL)(C, y, A);
1130
+ function _(C, y = 24) {
1131
+ const A = new Uint32Array(10);
1132
+ for (let M = 24 - y; M < 24; M++) {
1133
+ for (let m = 0; m < 10; m++)
1134
+ A[m] = C[m] ^ C[m + 10] ^ C[m + 20] ^ C[m + 30] ^ C[m + 40];
1135
+ for (let m = 0; m < 10; m += 2) {
1136
+ const w = (m + 8) % 10, H = (m + 2) % 10, W = A[H], q = A[H + 1], re = h(W, q, 1) ^ A[w], ae = E(W, q, 1) ^ A[w + 1];
1137
+ for (let se = 0; se < 50; se += 10)
1138
+ C[m + se] ^= re, C[m + se + 1] ^= ae;
1139
+ }
1140
+ let P = C[2], b = C[3];
1141
+ for (let m = 0; m < 24; m++) {
1142
+ const w = d[m], H = h(P, b, w), W = E(P, b, w), q = u[m];
1143
+ P = C[q], b = C[q + 1], C[q] = H, C[q + 1] = W;
1144
+ }
1145
+ for (let m = 0; m < 50; m += 10) {
1146
+ for (let w = 0; w < 10; w++)
1147
+ A[w] = C[m + w];
1148
+ for (let w = 0; w < 10; w++)
1149
+ C[m + w] ^= ~A[(w + 2) % 10] & A[(w + 4) % 10];
1150
+ }
1151
+ C[0] ^= o[M], C[1] ^= c[M];
1152
+ }
1153
+ (0, e.clean)(A);
1154
+ }
1155
+ class I extends e.Hash {
1156
+ // NOTE: we accept arguments in bytes instead of bits here.
1157
+ constructor(y, A, M, P = !1, b = 24) {
1158
+ if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = y, this.suffix = A, this.outputLen = M, this.enableXOF = P, this.rounds = b, (0, e.anumber)(M), !(0 < y && y < 200))
1159
+ throw new Error("only keccak-f1600 function is supported");
1160
+ this.state = new Uint8Array(200), this.state32 = (0, e.u32)(this.state);
1161
+ }
1162
+ clone() {
1163
+ return this._cloneInto();
1164
+ }
1165
+ keccak() {
1166
+ (0, e.swap32IfBE)(this.state32), _(this.state32, this.rounds), (0, e.swap32IfBE)(this.state32), this.posOut = 0, this.pos = 0;
1167
+ }
1168
+ update(y) {
1169
+ (0, e.aexists)(this), y = (0, e.toBytes)(y), (0, e.abytes)(y);
1170
+ const { blockLen: A, state: M } = this, P = y.length;
1171
+ for (let b = 0; b < P; ) {
1172
+ const m = Math.min(A - this.pos, P - b);
1173
+ for (let w = 0; w < m; w++)
1174
+ M[this.pos++] ^= y[b++];
1175
+ this.pos === A && this.keccak();
1176
+ }
1177
+ return this;
1178
+ }
1179
+ finish() {
1180
+ if (this.finished)
1181
+ return;
1182
+ this.finished = !0;
1183
+ const { state: y, suffix: A, pos: M, blockLen: P } = this;
1184
+ y[M] ^= A, (A & 128) !== 0 && M === P - 1 && this.keccak(), y[P - 1] ^= 128, this.keccak();
1185
+ }
1186
+ writeInto(y) {
1187
+ (0, e.aexists)(this, !1), (0, e.abytes)(y), this.finish();
1188
+ const A = this.state, { blockLen: M } = this;
1189
+ for (let P = 0, b = y.length; P < b; ) {
1190
+ this.posOut >= M && this.keccak();
1191
+ const m = Math.min(M - this.posOut, b - P);
1192
+ y.set(A.subarray(this.posOut, this.posOut + m), P), this.posOut += m, P += m;
1193
+ }
1194
+ return y;
1195
+ }
1196
+ xofInto(y) {
1197
+ if (!this.enableXOF)
1198
+ throw new Error("XOF is not possible for this instance");
1199
+ return this.writeInto(y);
1200
+ }
1201
+ xof(y) {
1202
+ return (0, e.anumber)(y), this.xofInto(new Uint8Array(y));
1203
+ }
1204
+ digestInto(y) {
1205
+ if ((0, e.aoutput)(y, this), this.finished)
1206
+ throw new Error("digest() was already called");
1207
+ return this.writeInto(y), this.destroy(), y;
1208
+ }
1209
+ digest() {
1210
+ return this.digestInto(new Uint8Array(this.outputLen));
1211
+ }
1212
+ destroy() {
1213
+ this.destroyed = !0, (0, e.clean)(this.state);
1214
+ }
1215
+ _cloneInto(y) {
1216
+ const { blockLen: A, suffix: M, outputLen: P, rounds: b, enableXOF: m } = this;
1217
+ return y || (y = new I(A, M, P, m, b)), y.state32.set(this.state32), y.pos = this.pos, y.posOut = this.posOut, y.finished = this.finished, y.rounds = b, y.suffix = M, y.outputLen = P, y.enableXOF = m, y.destroyed = this.destroyed, y;
1218
+ }
1219
+ }
1220
+ T.Keccak = I;
1221
+ const v = (C, y, A) => (0, e.createHasher)(() => new I(y, C, A));
1222
+ T.sha3_224 = v(6, 144, 224 / 8), T.sha3_256 = v(6, 136, 256 / 8), T.sha3_384 = v(6, 104, 384 / 8), T.sha3_512 = v(6, 72, 512 / 8), T.keccak_224 = v(1, 144, 224 / 8), T.keccak_256 = v(1, 136, 256 / 8), T.keccak_384 = v(1, 104, 384 / 8), T.keccak_512 = v(1, 72, 512 / 8);
1223
+ const k = (C, y, A) => (0, e.createXOFer)((M = {}) => new I(y, C, M.dkLen === void 0 ? A : M.dkLen, !0));
1224
+ return T.shake128 = k(31, 168, 128 / 8), T.shake256 = k(31, 136, 256 / 8), T;
1225
+ }
1226
+ var Be, St;
1227
+ function fn() {
1228
+ if (St) return Be;
1229
+ St = 1;
1230
+ const { keccak_256: t } = /* @__PURE__ */ ys();
1231
+ function e(c) {
1232
+ return Buffer.allocUnsafe(c).fill(0);
1233
+ }
1234
+ function n(c) {
1235
+ return c.toString(2).length;
1236
+ }
1237
+ function s(c, h) {
1238
+ let E = c.toString(16);
1239
+ E.length % 2 !== 0 && (E = "0" + E);
1240
+ const _ = E.match(/.{1,2}/g).map((I) => parseInt(I, 16));
1241
+ for (; _.length < h; )
1242
+ _.unshift(0);
1243
+ return Buffer.from(_);
1244
+ }
1245
+ function r(c, h) {
1246
+ const E = c < 0n;
1247
+ let _;
1248
+ if (E) {
1249
+ const I = (1n << BigInt(h)) - 1n;
1250
+ _ = (~c & I) + 1n;
1251
+ } else
1252
+ _ = c;
1253
+ return _ &= (1n << BigInt(h)) - 1n, _;
1254
+ }
1255
+ function i(c, h, E) {
1256
+ const _ = e(h);
1257
+ return c = l(c), E ? c.length < h ? (c.copy(_), _) : c.slice(0, h) : c.length < h ? (c.copy(_, h - c.length), _) : c.slice(-h);
1258
+ }
1259
+ function a(c, h) {
1260
+ return i(c, h, !0);
1261
+ }
1262
+ function l(c) {
1263
+ if (!Buffer.isBuffer(c))
1264
+ if (Array.isArray(c))
1265
+ c = Buffer.from(c);
1266
+ else if (typeof c == "string")
1267
+ g(c) ? c = Buffer.from(p(o(c)), "hex") : c = Buffer.from(c);
1268
+ else if (typeof c == "number")
1269
+ c = intToBuffer(c);
1270
+ else if (c == null)
1271
+ c = Buffer.allocUnsafe(0);
1272
+ else if (typeof c == "bigint")
1273
+ c = s(c);
1274
+ else if (c.toArray)
1275
+ c = Buffer.from(c.toArray());
1276
+ else
1277
+ throw new Error("invalid type");
1278
+ return c;
1279
+ }
1280
+ function u(c) {
1281
+ return c = l(c), "0x" + c.toString("hex");
1282
+ }
1283
+ function d(c, h) {
1284
+ if (c = l(c), h || (h = 256), h !== 256)
1285
+ throw new Error("unsupported");
1286
+ return Buffer.from(t(new Uint8Array(c)));
1287
+ }
1288
+ function p(c) {
1289
+ return c.length % 2 ? "0" + c : c;
1290
+ }
1291
+ function g(c) {
1292
+ return typeof c == "string" && c.match(/^0x[0-9A-Fa-f]*$/);
1293
+ }
1294
+ function o(c) {
1295
+ return typeof c == "string" && c.startsWith("0x") ? c.slice(2) : c;
1296
+ }
1297
+ return Be = {
1298
+ zeros: e,
1299
+ setLength: i,
1300
+ setLengthRight: a,
1301
+ isHexString: g,
1302
+ stripHexPrefix: o,
1303
+ toBuffer: l,
1304
+ bufferToHex: u,
1305
+ keccak: d,
1306
+ bitLengthFromBigInt: n,
1307
+ bufferBEFromBigInt: s,
1308
+ twosFromBigInt: r
1309
+ }, Be;
1310
+ }
1311
+ var We, At;
1312
+ function ws() {
1313
+ if (At) return We;
1314
+ At = 1;
1315
+ const t = /* @__PURE__ */ fn();
1316
+ function e(o) {
1317
+ return o.startsWith("int[") ? "int256" + o.slice(3) : o === "int" ? "int256" : o.startsWith("uint[") ? "uint256" + o.slice(4) : o === "uint" ? "uint256" : o.startsWith("fixed[") ? "fixed128x128" + o.slice(5) : o === "fixed" ? "fixed128x128" : o.startsWith("ufixed[") ? "ufixed128x128" + o.slice(6) : o === "ufixed" ? "ufixed128x128" : o;
1318
+ }
1319
+ function n(o) {
1320
+ return Number.parseInt(/^\D+(\d+)$/.exec(o)[1], 10);
1321
+ }
1322
+ function s(o) {
1323
+ var c = /^\D+(\d+)x(\d+)$/.exec(o);
1324
+ return [Number.parseInt(c[1], 10), Number.parseInt(c[2], 10)];
1325
+ }
1326
+ function r(o) {
1327
+ var c = o.match(/(.*)\[(.*?)\]$/);
1328
+ return c ? c[2] === "" ? "dynamic" : Number.parseInt(c[2], 10) : null;
1329
+ }
1330
+ function i(o) {
1331
+ var c = typeof o;
1332
+ if (c === "string" || c === "number")
1333
+ return BigInt(o);
1334
+ if (c === "bigint")
1335
+ return o;
1336
+ throw new Error("Argument is not a number");
1337
+ }
1338
+ function a(o, c) {
1339
+ var h, E, _, I;
1340
+ if (o === "address")
1341
+ return a("uint160", i(c));
1342
+ if (o === "bool")
1343
+ return a("uint8", c ? 1 : 0);
1344
+ if (o === "string")
1345
+ return a("bytes", new Buffer(c, "utf8"));
1346
+ if (u(o)) {
1347
+ if (typeof c.length > "u")
1348
+ throw new Error("Not an array?");
1349
+ if (h = r(o), h !== "dynamic" && h !== 0 && c.length > h)
1350
+ throw new Error("Elements exceed array size: " + h);
1351
+ _ = [], o = o.slice(0, o.lastIndexOf("[")), typeof c == "string" && (c = JSON.parse(c));
1352
+ for (I in c)
1353
+ _.push(a(o, c[I]));
1354
+ if (h === "dynamic") {
1355
+ var v = a("uint256", c.length);
1356
+ _.unshift(v);
1357
+ }
1358
+ return Buffer.concat(_);
1359
+ } else {
1360
+ if (o === "bytes")
1361
+ return c = new Buffer(c), _ = Buffer.concat([a("uint256", c.length), c]), c.length % 32 !== 0 && (_ = Buffer.concat([_, t.zeros(32 - c.length % 32)])), _;
1362
+ if (o.startsWith("bytes")) {
1363
+ if (h = n(o), h < 1 || h > 32)
1364
+ throw new Error("Invalid bytes<N> width: " + h);
1365
+ return t.setLengthRight(c, 32);
1366
+ } else if (o.startsWith("uint")) {
1367
+ if (h = n(o), h % 8 || h < 8 || h > 256)
1368
+ throw new Error("Invalid uint<N> width: " + h);
1369
+ E = i(c);
1370
+ const k = t.bitLengthFromBigInt(E);
1371
+ if (k > h)
1372
+ throw new Error("Supplied uint exceeds width: " + h + " vs " + k);
1373
+ if (E < 0)
1374
+ throw new Error("Supplied uint is negative");
1375
+ return t.bufferBEFromBigInt(E, 32);
1376
+ } else if (o.startsWith("int")) {
1377
+ if (h = n(o), h % 8 || h < 8 || h > 256)
1378
+ throw new Error("Invalid int<N> width: " + h);
1379
+ E = i(c);
1380
+ const k = t.bitLengthFromBigInt(E);
1381
+ if (k > h)
1382
+ throw new Error("Supplied int exceeds width: " + h + " vs " + k);
1383
+ const C = t.twosFromBigInt(E, 256);
1384
+ return t.bufferBEFromBigInt(C, 32);
1385
+ } else if (o.startsWith("ufixed")) {
1386
+ if (h = s(o), E = i(c), E < 0)
1387
+ throw new Error("Supplied ufixed is negative");
1388
+ return a("uint256", E * BigInt(2) ** BigInt(h[1]));
1389
+ } else if (o.startsWith("fixed"))
1390
+ return h = s(o), a("int256", i(c) * BigInt(2) ** BigInt(h[1]));
1391
+ }
1392
+ throw new Error("Unsupported or invalid type: " + o);
1393
+ }
1394
+ function l(o) {
1395
+ return o === "string" || o === "bytes" || r(o) === "dynamic";
1396
+ }
1397
+ function u(o) {
1398
+ return o.lastIndexOf("]") === o.length - 1;
1399
+ }
1400
+ function d(o, c) {
1401
+ var h = [], E = [], _ = 32 * o.length;
1402
+ for (var I in o) {
1403
+ var v = e(o[I]), k = c[I], C = a(v, k);
1404
+ l(v) ? (h.push(a("uint256", _)), E.push(C), _ += C.length) : h.push(C);
1405
+ }
1406
+ return Buffer.concat(h.concat(E));
1407
+ }
1408
+ function p(o, c) {
1409
+ if (o.length !== c.length)
1410
+ throw new Error("Number of types are not matching the values");
1411
+ for (var h, E, _ = [], I = 0; I < o.length; I++) {
1412
+ var v = e(o[I]), k = c[I];
1413
+ if (v === "bytes")
1414
+ _.push(k);
1415
+ else if (v === "string")
1416
+ _.push(new Buffer(k, "utf8"));
1417
+ else if (v === "bool")
1418
+ _.push(new Buffer(k ? "01" : "00", "hex"));
1419
+ else if (v === "address")
1420
+ _.push(t.setLength(k, 20));
1421
+ else if (v.startsWith("bytes")) {
1422
+ if (h = n(v), h < 1 || h > 32)
1423
+ throw new Error("Invalid bytes<N> width: " + h);
1424
+ _.push(t.setLengthRight(k, h));
1425
+ } else if (v.startsWith("uint")) {
1426
+ if (h = n(v), h % 8 || h < 8 || h > 256)
1427
+ throw new Error("Invalid uint<N> width: " + h);
1428
+ E = i(k);
1429
+ const C = t.bitLengthFromBigInt(E);
1430
+ if (C > h)
1431
+ throw new Error("Supplied uint exceeds width: " + h + " vs " + C);
1432
+ _.push(t.bufferBEFromBigInt(E, h / 8));
1433
+ } else if (v.startsWith("int")) {
1434
+ if (h = n(v), h % 8 || h < 8 || h > 256)
1435
+ throw new Error("Invalid int<N> width: " + h);
1436
+ E = i(k);
1437
+ const C = t.bitLengthFromBigInt(E);
1438
+ if (C > h)
1439
+ throw new Error("Supplied int exceeds width: " + h + " vs " + C);
1440
+ const y = t.twosFromBigInt(E, h);
1441
+ _.push(t.bufferBEFromBigInt(y, h / 8));
1442
+ } else
1443
+ throw new Error("Unsupported or invalid type: " + v);
1444
+ }
1445
+ return Buffer.concat(_);
1446
+ }
1447
+ function g(o, c) {
1448
+ return t.keccak(p(o, c));
1449
+ }
1450
+ return We = {
1451
+ rawEncode: d,
1452
+ solidityPack: p,
1453
+ soliditySHA3: g
1454
+ }, We;
1455
+ }
1456
+ var qe, xt;
1457
+ function bs() {
1458
+ if (xt) return qe;
1459
+ xt = 1;
1460
+ const t = /* @__PURE__ */ fn(), e = /* @__PURE__ */ ws(), n = {
1461
+ type: "object",
1462
+ properties: {
1463
+ types: {
1464
+ type: "object",
1465
+ additionalProperties: {
1466
+ type: "array",
1467
+ items: {
1468
+ type: "object",
1469
+ properties: {
1470
+ name: { type: "string" },
1471
+ type: { type: "string" }
1472
+ },
1473
+ required: ["name", "type"]
1474
+ }
1475
+ }
1476
+ },
1477
+ primaryType: { type: "string" },
1478
+ domain: { type: "object" },
1479
+ message: { type: "object" }
1480
+ },
1481
+ required: ["types", "primaryType", "domain", "message"]
1482
+ }, s = {
1483
+ /**
1484
+ * Encodes an object by encoding and concatenating each of its members
1485
+ *
1486
+ * @param {string} primaryType - Root type
1487
+ * @param {Object} data - Object to encode
1488
+ * @param {Object} types - Type definitions
1489
+ * @returns {string} - Encoded representation of an object
1490
+ */
1491
+ encodeData(i, a, l, u = !0) {
1492
+ const d = ["bytes32"], p = [this.hashType(i, l)];
1493
+ if (u) {
1494
+ const g = (o, c, h) => {
1495
+ if (l[c] !== void 0)
1496
+ return ["bytes32", h == null ? "0x0000000000000000000000000000000000000000000000000000000000000000" : t.keccak(this.encodeData(c, h, l, u))];
1497
+ if (h === void 0)
1498
+ throw new Error(`missing value for field ${o} of type ${c}`);
1499
+ if (c === "bytes")
1500
+ return ["bytes32", t.keccak(h)];
1501
+ if (c === "string")
1502
+ return typeof h == "string" && (h = Buffer.from(h, "utf8")), ["bytes32", t.keccak(h)];
1503
+ if (c.lastIndexOf("]") === c.length - 1) {
1504
+ const E = c.slice(0, c.lastIndexOf("[")), _ = h.map((I) => g(o, E, I));
1505
+ return ["bytes32", t.keccak(e.rawEncode(
1506
+ _.map(([I]) => I),
1507
+ _.map(([, I]) => I)
1508
+ ))];
1509
+ }
1510
+ return [c, h];
1511
+ };
1512
+ for (const o of l[i]) {
1513
+ const [c, h] = g(o.name, o.type, a[o.name]);
1514
+ d.push(c), p.push(h);
1515
+ }
1516
+ } else
1517
+ for (const g of l[i]) {
1518
+ let o = a[g.name];
1519
+ if (o !== void 0)
1520
+ if (g.type === "bytes")
1521
+ d.push("bytes32"), o = t.keccak(o), p.push(o);
1522
+ else if (g.type === "string")
1523
+ d.push("bytes32"), typeof o == "string" && (o = Buffer.from(o, "utf8")), o = t.keccak(o), p.push(o);
1524
+ else if (l[g.type] !== void 0)
1525
+ d.push("bytes32"), o = t.keccak(this.encodeData(g.type, o, l, u)), p.push(o);
1526
+ else {
1527
+ if (g.type.lastIndexOf("]") === g.type.length - 1)
1528
+ throw new Error("Arrays currently unimplemented in encodeData");
1529
+ d.push(g.type), p.push(o);
1530
+ }
1531
+ }
1532
+ return e.rawEncode(d, p);
1533
+ },
1534
+ /**
1535
+ * Encodes the type of an object by encoding a comma delimited list of its members
1536
+ *
1537
+ * @param {string} primaryType - Root type to encode
1538
+ * @param {Object} types - Type definitions
1539
+ * @returns {string} - Encoded representation of the type of an object
1540
+ */
1541
+ encodeType(i, a) {
1542
+ let l = "", u = this.findTypeDependencies(i, a).filter((d) => d !== i);
1543
+ u = [i].concat(u.sort());
1544
+ for (const d of u) {
1545
+ if (!a[d])
1546
+ throw new Error("No type definition specified: " + d);
1547
+ l += d + "(" + a[d].map(({ name: g, type: o }) => o + " " + g).join(",") + ")";
1548
+ }
1549
+ return l;
1550
+ },
1551
+ /**
1552
+ * Finds all types within a type definition object
1553
+ *
1554
+ * @param {string} primaryType - Root type
1555
+ * @param {Object} types - Type definitions
1556
+ * @param {Array} results - current set of accumulated types
1557
+ * @returns {Array} - Set of all types found in the type definition
1558
+ */
1559
+ findTypeDependencies(i, a, l = []) {
1560
+ if (i = i.match(/^\w*/)[0], l.includes(i) || a[i] === void 0)
1561
+ return l;
1562
+ l.push(i);
1563
+ for (const u of a[i])
1564
+ for (const d of this.findTypeDependencies(u.type, a, l))
1565
+ !l.includes(d) && l.push(d);
1566
+ return l;
1567
+ },
1568
+ /**
1569
+ * Hashes an object
1570
+ *
1571
+ * @param {string} primaryType - Root type
1572
+ * @param {Object} data - Object to hash
1573
+ * @param {Object} types - Type definitions
1574
+ * @returns {Buffer} - Hash of an object
1575
+ */
1576
+ hashStruct(i, a, l, u = !0) {
1577
+ return t.keccak(this.encodeData(i, a, l, u));
1578
+ },
1579
+ /**
1580
+ * Hashes the type of an object
1581
+ *
1582
+ * @param {string} primaryType - Root type to hash
1583
+ * @param {Object} types - Type definitions
1584
+ * @returns {string} - Hash of an object
1585
+ */
1586
+ hashType(i, a) {
1587
+ return t.keccak(this.encodeType(i, a));
1588
+ },
1589
+ /**
1590
+ * Removes properties from a message object that are not defined per EIP-712
1591
+ *
1592
+ * @param {Object} data - typed message object
1593
+ * @returns {Object} - typed message object with only allowed fields
1594
+ */
1595
+ sanitizeData(i) {
1596
+ const a = {};
1597
+ for (const l in n.properties)
1598
+ i[l] && (a[l] = i[l]);
1599
+ return a.types && (a.types = Object.assign({ EIP712Domain: [] }, a.types)), a;
1600
+ },
1601
+ /**
1602
+ * Returns the hash of a typed message as per EIP-712 for signing
1603
+ *
1604
+ * @param {Object} typedData - Types message data to sign
1605
+ * @returns {string} - sha3 hash for signing
1606
+ */
1607
+ hash(i, a = !0) {
1608
+ const l = this.sanitizeData(i), u = [Buffer.from("1901", "hex")];
1609
+ return u.push(this.hashStruct("EIP712Domain", l.domain, l.types, a)), l.primaryType !== "EIP712Domain" && u.push(this.hashStruct(l.primaryType, l.message, l.types, a)), t.keccak(Buffer.concat(u));
1610
+ }
1611
+ };
1612
+ qe = {
1613
+ TYPED_MESSAGE_SCHEMA: n,
1614
+ TypedDataUtils: s,
1615
+ hashForSignTypedDataLegacy: function(i) {
1616
+ return r(i.data);
1617
+ },
1618
+ hashForSignTypedData_v3: function(i) {
1619
+ return s.hash(i.data, !1);
1620
+ },
1621
+ hashForSignTypedData_v4: function(i) {
1622
+ return s.hash(i.data);
1623
+ }
1624
+ };
1625
+ function r(i) {
1626
+ const a = new Error("Expect argument to be non-empty array");
1627
+ if (typeof i != "object" || !i.length) throw a;
1628
+ const l = i.map(function(p) {
1629
+ return p.type === "bytes" ? t.toBuffer(p.value) : p.value;
1630
+ }), u = i.map(function(p) {
1631
+ return p.type;
1632
+ }), d = i.map(function(p) {
1633
+ if (!p.name) throw a;
1634
+ return p.type + " " + p.name;
1635
+ });
1636
+ return e.soliditySHA3(
1637
+ ["bytes32", "bytes32"],
1638
+ [
1639
+ e.soliditySHA3(new Array(i.length).fill("string"), d),
1640
+ e.soliditySHA3(u, l)
1641
+ ]
1642
+ );
1643
+ }
1644
+ return qe;
1645
+ }
1646
+ var vs = /* @__PURE__ */ bs();
1647
+ const ye = /* @__PURE__ */ Qt(vs), ks = "walletUsername", Ge = "Addresses", Es = "AppVersion";
1648
+ function K(t) {
1649
+ return t.errorMessage !== void 0;
1650
+ }
1651
+ class Is {
1652
+ // @param secret hex representation of 32-byte secret
1653
+ constructor(e) {
1654
+ this.secret = e;
1655
+ }
1656
+ /**
1657
+ *
1658
+ * @param plainText string to be encrypted
1659
+ * returns hex string representation of bytes in the order: initialization vector (iv),
1660
+ * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes. Remaining bytes are the
1661
+ * encrypted plainText.
1662
+ */
1663
+ async encrypt(e) {
1664
+ const n = this.secret;
1665
+ if (n.length !== 64)
1666
+ throw Error("secret must be 256 bits");
1667
+ const s = crypto.getRandomValues(new Uint8Array(12)), r = await crypto.subtle.importKey("raw", ve(n), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), i = new TextEncoder(), a = await window.crypto.subtle.encrypt({
1668
+ name: "AES-GCM",
1669
+ iv: s
1670
+ }, r, i.encode(e)), l = 16, u = a.slice(a.byteLength - l), d = a.slice(0, a.byteLength - l), p = new Uint8Array(u), g = new Uint8Array(d), o = new Uint8Array([...s, ...p, ...g]);
1671
+ return st(o);
1672
+ }
1673
+ /**
1674
+ *
1675
+ * @param cipherText hex string representation of bytes in the order: initialization vector (iv),
1676
+ * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes.
1677
+ */
1678
+ async decrypt(e) {
1679
+ const n = this.secret;
1680
+ if (n.length !== 64)
1681
+ throw Error("secret must be 256 bits");
1682
+ return new Promise((s, r) => {
1683
+ (async function() {
1684
+ const i = await crypto.subtle.importKey("raw", ve(n), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), a = ve(e), l = a.slice(0, 12), u = a.slice(12, 28), d = a.slice(28), p = new Uint8Array([...d, ...u]), g = {
1685
+ name: "AES-GCM",
1686
+ iv: new Uint8Array(l)
1687
+ };
1688
+ try {
1689
+ const o = await window.crypto.subtle.decrypt(g, i, p), c = new TextDecoder();
1690
+ s(c.decode(o));
1691
+ } catch (o) {
1692
+ r(o);
1693
+ }
1694
+ })();
1695
+ });
1696
+ }
1697
+ }
1698
+ class Cs {
1699
+ constructor(e, n, s) {
1700
+ this.linkAPIUrl = e, this.sessionId = n;
1701
+ const r = `${n}:${s}`;
1702
+ this.auth = `Basic ${btoa(r)}`;
1703
+ }
1704
+ // mark unseen events as seen
1705
+ async markUnseenEventsAsSeen(e) {
1706
+ return Promise.all(e.map((n) => fetch(`${this.linkAPIUrl}/events/${n.eventId}/seen`, {
1707
+ method: "POST",
1708
+ headers: {
1709
+ Authorization: this.auth
1710
+ }
1711
+ }))).catch((n) => console.error("Unabled to mark event as failed:", n));
1712
+ }
1713
+ async fetchUnseenEvents() {
1714
+ var e;
1715
+ const n = await fetch(`${this.linkAPIUrl}/events?unseen=true`, {
1716
+ headers: {
1717
+ Authorization: this.auth
1718
+ }
1719
+ });
1720
+ if (n.ok) {
1721
+ const { events: s, error: r } = await n.json();
1722
+ if (r)
1723
+ throw new Error(`Check unseen events failed: ${r}`);
1724
+ const i = (e = s == null ? void 0 : s.filter((a) => a.event === "Web3Response").map((a) => ({
1725
+ type: "Event",
1726
+ sessionId: this.sessionId,
1727
+ eventId: a.id,
1728
+ event: a.event,
1729
+ data: a.data
1730
+ }))) !== null && e !== void 0 ? e : [];
1731
+ return this.markUnseenEventsAsSeen(i), i;
1732
+ }
1733
+ throw new Error(`Check unseen events failed: ${n.status}`);
1734
+ }
1735
+ }
1736
+ var G;
1737
+ (function(t) {
1738
+ t[t.DISCONNECTED = 0] = "DISCONNECTED", t[t.CONNECTING = 1] = "CONNECTING", t[t.CONNECTED = 2] = "CONNECTED";
1739
+ })(G || (G = {}));
1740
+ class z {
1741
+ setConnectionStateListener(e) {
1742
+ this.connectionStateListener = e;
1743
+ }
1744
+ setIncomingDataListener(e) {
1745
+ this.incomingDataListener = e;
1746
+ }
1747
+ /**
1748
+ * Constructor
1749
+ * @param url WebSocket server URL
1750
+ * @param [WebSocketClass] Custom WebSocket implementation
1751
+ */
1752
+ constructor(e, n = WebSocket) {
1753
+ this.WebSocketClass = n, this.webSocket = null, this.isDisconnecting = !1, this.url = e.replace(/^http/, "ws"), this.instanceId = z.instanceCounter++, z.activeInstances.add(this.instanceId);
1754
+ }
1755
+ /**
1756
+ * Make a websocket connection
1757
+ * @returns a Promise that resolves when connected
1758
+ */
1759
+ async connect() {
1760
+ if (this.webSocket)
1761
+ throw new Error("webSocket object is not null");
1762
+ if (this.isDisconnecting)
1763
+ throw new Error("WebSocket is disconnecting, cannot reconnect on same instance");
1764
+ return new Promise((e, n) => {
1765
+ var s;
1766
+ let r;
1767
+ try {
1768
+ this.webSocket = r = new this.WebSocketClass(this.url);
1769
+ } catch (i) {
1770
+ n(i);
1771
+ return;
1772
+ }
1773
+ (s = this.connectionStateListener) === null || s === void 0 || s.call(this, G.CONNECTING), r.onclose = (i) => {
1774
+ var a;
1775
+ this.clearWebSocket(), r.readyState !== WebSocket.OPEN && n(new Error(`websocket error ${i.code}: ${i.reason}`)), (a = this.connectionStateListener) === null || a === void 0 || a.call(this, G.DISCONNECTED);
1776
+ }, r.onopen = (i) => {
1777
+ var a;
1778
+ e(), (a = this.connectionStateListener) === null || a === void 0 || a.call(this, G.CONNECTED), z.pendingData.length > 0 && ([...z.pendingData].forEach((u) => this.sendData(u)), z.pendingData = []);
1779
+ }, r.onmessage = (i) => {
1780
+ var a, l;
1781
+ if (i.data === "h")
1782
+ (a = this.incomingDataListener) === null || a === void 0 || a.call(this, {
1783
+ type: "Heartbeat"
1784
+ });
1785
+ else
1786
+ try {
1787
+ const u = JSON.parse(i.data);
1788
+ (l = this.incomingDataListener) === null || l === void 0 || l.call(this, u);
1789
+ } catch {
1790
+ }
1791
+ };
1792
+ });
1793
+ }
1794
+ /**
1795
+ * Disconnect from server
1796
+ */
1797
+ disconnect() {
1798
+ var e;
1799
+ const { webSocket: n } = this;
1800
+ if (n) {
1801
+ this.isDisconnecting = !0, this.clearWebSocket(), (e = this.connectionStateListener) === null || e === void 0 || e.call(this, G.DISCONNECTED), this.connectionStateListener = void 0, this.incomingDataListener = void 0;
1802
+ try {
1803
+ n.close();
1804
+ } catch {
1805
+ }
1806
+ }
1807
+ }
1808
+ /**
1809
+ * Send data to server
1810
+ * @param data text to send
1811
+ */
1812
+ sendData(e) {
1813
+ const { webSocket: n } = this;
1814
+ if (!n) {
1815
+ z.pendingData.push(e), this.isDisconnecting || this.connect();
1816
+ return;
1817
+ }
1818
+ if (n.readyState !== WebSocket.OPEN) {
1819
+ z.pendingData.push(e);
1820
+ return;
1821
+ }
1822
+ n.send(e);
1823
+ }
1824
+ clearWebSocket() {
1825
+ const { webSocket: e } = this;
1826
+ e && (this.webSocket = null, e.onclose = null, e.onerror = null, e.onmessage = null, e.onopen = null);
1827
+ }
1828
+ /**
1829
+ * remove ws from active instances
1830
+ */
1831
+ cleanup() {
1832
+ z.activeInstances.delete(this.instanceId);
1833
+ }
1834
+ }
1835
+ z.instanceCounter = 0;
1836
+ z.activeInstances = /* @__PURE__ */ new Set();
1837
+ z.pendingData = [];
1838
+ const Lt = 1e4, Ss = 6e4;
1839
+ class As {
1840
+ /**
1841
+ * Constructor
1842
+ * @param session Session
1843
+ * @param linkAPIUrl Coinbase Wallet link server URL
1844
+ * @param listener WalletLinkConnectionUpdateListener
1845
+ * @param [WebSocketClass] Custom WebSocket implementation
1846
+ */
1847
+ constructor({ session: e, linkAPIUrl: n, listener: s }) {
1848
+ this.destroyed = !1, this.lastHeartbeatResponse = 0, this.nextReqId = J(1), this.reconnectAttempts = 0, this.isReconnecting = !1, this._connected = !1, this._linked = !1, this.requestResolutions = /* @__PURE__ */ new Map(), this.handleSessionMetadataUpdated = (i) => {
1849
+ if (!i)
1850
+ return;
1851
+ (/* @__PURE__ */ new Map([
1852
+ ["__destroyed", this.handleDestroyed],
1853
+ ["EthereumAddress", this.handleAccountUpdated],
1854
+ ["WalletUsername", this.handleWalletUsernameUpdated],
1855
+ ["AppVersion", this.handleAppVersionUpdated],
1856
+ [
1857
+ "ChainId",
1858
+ // ChainId and JsonRpcUrl are always updated together
1859
+ (l) => i.JsonRpcUrl && this.handleChainUpdated(l, i.JsonRpcUrl)
1860
+ ]
1861
+ ])).forEach((l, u) => {
1862
+ const d = i[u];
1863
+ d !== void 0 && l(d);
1864
+ });
1865
+ }, this.handleDestroyed = (i) => {
1866
+ var a;
1867
+ i === "1" && ((a = this.listener) === null || a === void 0 || a.resetAndReload());
1868
+ }, this.handleAccountUpdated = async (i) => {
1869
+ var a;
1870
+ try {
1871
+ const l = await this.cipher.decrypt(i);
1872
+ (a = this.listener) === null || a === void 0 || a.accountUpdated(l);
1873
+ } catch {
1874
+ }
1875
+ }, this.handleMetadataUpdated = async (i, a) => {
1876
+ var l;
1877
+ try {
1878
+ const u = await this.cipher.decrypt(a);
1879
+ (l = this.listener) === null || l === void 0 || l.metadataUpdated(i, u);
1880
+ } catch {
1881
+ }
1882
+ }, this.handleWalletUsernameUpdated = async (i) => {
1883
+ this.handleMetadataUpdated(ks, i);
1884
+ }, this.handleAppVersionUpdated = async (i) => {
1885
+ this.handleMetadataUpdated(Es, i);
1886
+ }, this.handleChainUpdated = async (i, a) => {
1887
+ var l;
1888
+ try {
1889
+ const u = await this.cipher.decrypt(i), d = await this.cipher.decrypt(a);
1890
+ (l = this.listener) === null || l === void 0 || l.chainUpdated(u, d);
1891
+ } catch {
1892
+ }
1893
+ }, this.session = e, this.cipher = new Is(e.secret), this.listener = s, this.linkAPIUrl = n, this.WebSocketClass = WebSocket;
1894
+ const r = this.createWebSocket();
1895
+ this.ws = r, this.http = new Cs(n, e.id, e.key), this.setupVisibilityChangeHandler();
1896
+ }
1897
+ createWebSocket() {
1898
+ const e = new z(`${this.linkAPIUrl}/rpc`, this.WebSocketClass);
1899
+ return this.activeWsInstance = e, e.setConnectionStateListener(async (n) => {
1900
+ if (e !== this.activeWsInstance)
1901
+ return;
1902
+ let s = !1;
1903
+ switch (n) {
1904
+ case G.DISCONNECTED:
1905
+ this.heartbeatIntervalId && (clearInterval(this.heartbeatIntervalId), this.heartbeatIntervalId = void 0), this.lastHeartbeatResponse = 0, s = !1, this.destroyed || (async () => {
1906
+ if (this.isReconnecting)
1907
+ return;
1908
+ this.isReconnecting = !0;
1909
+ const i = this.reconnectAttempts === 0 ? 0 : 3e3;
1910
+ await new Promise((a) => setTimeout(a, i)), !this.destroyed && e === this.activeWsInstance ? (this.reconnectAttempts++, "cleanup" in this.ws && typeof this.ws.cleanup == "function" && this.ws.cleanup(), this.ws = this.createWebSocket(), this.ws.connect().catch(() => {
1911
+ }).finally(() => {
1912
+ this.isReconnecting = !1;
1913
+ })) : this.isReconnecting = !1;
1914
+ })();
1915
+ break;
1916
+ case G.CONNECTED:
1917
+ this.reconnectAttempts = 0;
1918
+ try {
1919
+ s = await this.handleConnected(), this.fetchUnseenEventsAPI().catch(() => {
1920
+ });
1921
+ } catch {
1922
+ break;
1923
+ }
1924
+ this.connected = s, this.updateLastHeartbeat(), this.heartbeatIntervalId && clearInterval(this.heartbeatIntervalId), this.heartbeatIntervalId = window.setInterval(() => {
1925
+ this.heartbeat();
1926
+ }, Lt), setTimeout(() => {
1927
+ this.heartbeat();
1928
+ }, 100);
1929
+ break;
1930
+ case G.CONNECTING:
1931
+ break;
1932
+ }
1933
+ n !== G.CONNECTED && (this.connected = s);
1934
+ }), e.setIncomingDataListener((n) => {
1935
+ var s;
1936
+ switch (n.type) {
1937
+ // handle server's heartbeat responses
1938
+ case "Heartbeat":
1939
+ this.updateLastHeartbeat();
1940
+ return;
1941
+ // handle link status updates
1942
+ case "IsLinkedOK":
1943
+ case "Linked": {
1944
+ const r = n.type === "IsLinkedOK" ? n.linked : void 0;
1945
+ this.linked = r || n.onlineGuests > 0;
1946
+ break;
1947
+ }
1948
+ // handle session config updates
1949
+ case "GetSessionConfigOK":
1950
+ case "SessionConfigUpdated": {
1951
+ this.handleSessionMetadataUpdated(n.metadata);
1952
+ break;
1953
+ }
1954
+ case "Event": {
1955
+ this.handleIncomingEvent(n);
1956
+ break;
1957
+ }
1958
+ }
1959
+ n.id !== void 0 && ((s = this.requestResolutions.get(n.id)) === null || s === void 0 || s(n));
1960
+ }), e;
1961
+ }
1962
+ setupVisibilityChangeHandler() {
1963
+ this.visibilityChangeHandler = () => {
1964
+ !document.hidden && !this.destroyed && (this.connected ? this.heartbeat() : this.reconnectWithFreshWebSocket());
1965
+ }, this.focusHandler = () => {
1966
+ !this.destroyed && !this.connected && this.reconnectWithFreshWebSocket();
1967
+ }, document.addEventListener("visibilitychange", this.visibilityChangeHandler), window.addEventListener("focus", this.focusHandler), window.addEventListener("pageshow", (e) => {
1968
+ e.persisted && this.focusHandler && this.focusHandler();
1969
+ });
1970
+ }
1971
+ reconnectWithFreshWebSocket() {
1972
+ if (this.destroyed)
1973
+ return;
1974
+ const e = this.ws;
1975
+ this.activeWsInstance = void 0, e.disconnect(), "cleanup" in e && typeof e.cleanup == "function" && e.cleanup(), this.ws = this.createWebSocket(), this.ws.connect().catch(() => {
1976
+ });
1977
+ }
1978
+ /**
1979
+ * Make a connection to the server
1980
+ */
1981
+ connect() {
1982
+ if (this.destroyed)
1983
+ throw new Error("instance is destroyed");
1984
+ this.ws.connect();
1985
+ }
1986
+ /**
1987
+ * Terminate connection, and mark as destroyed. To reconnect, create a new
1988
+ * instance of WalletSDKConnection
1989
+ */
1990
+ async destroy() {
1991
+ this.destroyed || (await this.makeRequest({
1992
+ type: "SetSessionConfig",
1993
+ id: J(this.nextReqId++),
1994
+ sessionId: this.session.id,
1995
+ metadata: { __destroyed: "1" }
1996
+ }, { timeout: 1e3 }), this.destroyed = !0, this.activeWsInstance = void 0, this.heartbeatIntervalId && (clearInterval(this.heartbeatIntervalId), this.heartbeatIntervalId = void 0), this.visibilityChangeHandler && document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.focusHandler && window.removeEventListener("focus", this.focusHandler), this.ws.disconnect(), "cleanup" in this.ws && typeof this.ws.cleanup == "function" && this.ws.cleanup(), this.listener = void 0);
1997
+ }
1998
+ get connected() {
1999
+ return this._connected;
2000
+ }
2001
+ set connected(e) {
2002
+ this._connected = e;
2003
+ }
2004
+ get linked() {
2005
+ return this._linked;
2006
+ }
2007
+ set linked(e) {
2008
+ var n, s;
2009
+ this._linked = e, e && ((n = this.onceLinked) === null || n === void 0 || n.call(this)), (s = this.listener) === null || s === void 0 || s.linkedUpdated(e);
2010
+ }
2011
+ setOnceLinked(e) {
2012
+ return new Promise((n) => {
2013
+ this.linked ? e().then(n) : this.onceLinked = () => {
2014
+ e().then(n), this.onceLinked = void 0;
2015
+ };
2016
+ });
2017
+ }
2018
+ async handleIncomingEvent(e) {
2019
+ var n;
2020
+ if (!(e.type !== "Event" || e.event !== "Web3Response"))
2021
+ try {
2022
+ const s = await this.cipher.decrypt(e.data), r = JSON.parse(s);
2023
+ if (r.type !== "WEB3_RESPONSE")
2024
+ return;
2025
+ (n = this.listener) === null || n === void 0 || n.handleWeb3ResponseMessage(r.id, r.response);
2026
+ } catch {
2027
+ }
2028
+ }
2029
+ async checkUnseenEvents() {
2030
+ await new Promise((e) => setTimeout(e, 250));
2031
+ try {
2032
+ await this.fetchUnseenEventsAPI();
2033
+ } catch (e) {
2034
+ console.error("Unable to check for unseen events", e);
2035
+ }
2036
+ }
2037
+ async fetchUnseenEventsAPI() {
2038
+ try {
2039
+ (await this.http.fetchUnseenEvents()).forEach((n) => {
2040
+ this.handleIncomingEvent(n);
2041
+ });
2042
+ } catch {
2043
+ }
2044
+ }
2045
+ /**
2046
+ * Publish an event and emit event ID when successful
2047
+ * @param event event name
2048
+ * @param unencryptedData unencrypted event data
2049
+ * @param callWebhook whether the webhook should be invoked
2050
+ * @returns a Promise that emits event ID when successful
2051
+ */
2052
+ async publishEvent(e, n, s = !1) {
2053
+ const r = await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({}, n), { origin: location.origin, location: location.href, relaySource: "coinbaseWalletExtension" in window && window.coinbaseWalletExtension ? "injected_sdk" : "sdk" }))), i = {
2054
+ type: "PublishEvent",
2055
+ id: J(this.nextReqId++),
2056
+ sessionId: this.session.id,
2057
+ event: e,
2058
+ data: r,
2059
+ callWebhook: s
2060
+ };
2061
+ return this.setOnceLinked(async () => {
2062
+ const a = await this.makeRequest(i);
2063
+ if (a.type === "Fail")
2064
+ throw new Error(a.error || "failed to publish event");
2065
+ return a.eventId;
2066
+ });
2067
+ }
2068
+ sendData(e) {
2069
+ this.ws.sendData(JSON.stringify(e));
2070
+ }
2071
+ updateLastHeartbeat() {
2072
+ this.lastHeartbeatResponse = Date.now();
2073
+ }
2074
+ heartbeat() {
2075
+ if (Date.now() - this.lastHeartbeatResponse > Lt * 2) {
2076
+ this.ws.disconnect();
2077
+ return;
2078
+ }
2079
+ if (this.connected)
2080
+ try {
2081
+ this.ws.sendData("h");
2082
+ } catch {
2083
+ }
2084
+ }
2085
+ async makeRequest(e, n = { timeout: Ss }) {
2086
+ const s = e.id;
2087
+ this.sendData(e);
2088
+ let r;
2089
+ return Promise.race([
2090
+ new Promise((i, a) => {
2091
+ r = window.setTimeout(() => {
2092
+ a(new Error(`request ${s} timed out`));
2093
+ }, n.timeout);
2094
+ }),
2095
+ new Promise((i) => {
2096
+ this.requestResolutions.set(s, (a) => {
2097
+ clearTimeout(r), i(a), this.requestResolutions.delete(s);
2098
+ });
2099
+ })
2100
+ ]);
2101
+ }
2102
+ async handleConnected() {
2103
+ return (await this.makeRequest({
2104
+ type: "HostSession",
2105
+ id: J(this.nextReqId++),
2106
+ sessionId: this.session.id,
2107
+ sessionKey: this.session.key
2108
+ })).type === "Fail" ? !1 : (this.sendData({
2109
+ type: "IsLinked",
2110
+ id: J(this.nextReqId++),
2111
+ sessionId: this.session.id
2112
+ }), this.sendData({
2113
+ type: "GetSessionConfig",
2114
+ id: J(this.nextReqId++),
2115
+ sessionId: this.session.id
2116
+ }), !0);
2117
+ }
2118
+ }
2119
+ class xs {
2120
+ constructor() {
2121
+ this._nextRequestId = 0, this.callbacks = /* @__PURE__ */ new Map();
2122
+ }
2123
+ makeRequestId() {
2124
+ this._nextRequestId = (this._nextRequestId + 1) % 2147483647;
2125
+ const e = this._nextRequestId, n = cn(e.toString(16));
2126
+ return this.callbacks.get(n) && this.callbacks.delete(n), e;
2127
+ }
2128
+ }
2129
+ const Mt = "session:id", Pt = "session:secret", Rt = "session:linked";
2130
+ class ce {
2131
+ constructor(e, n, s, r = !1) {
2132
+ this.storage = e, this.id = n, this.secret = s, this.key = jn(Bn(`${n}, ${s} WalletLink`)), this._linked = !!r;
2133
+ }
2134
+ static create(e) {
2135
+ const n = ie(16), s = ie(32);
2136
+ return new ce(e, n, s).save();
2137
+ }
2138
+ static load(e) {
2139
+ const n = e.getItem(Mt), s = e.getItem(Rt), r = e.getItem(Pt);
2140
+ return n && r ? new ce(e, n, r, s === "1") : null;
2141
+ }
2142
+ get linked() {
2143
+ return this._linked;
2144
+ }
2145
+ set linked(e) {
2146
+ this._linked = e, this.persistLinked();
2147
+ }
2148
+ save() {
2149
+ return this.storage.setItem(Mt, this.id), this.storage.setItem(Pt, this.secret), this.persistLinked(), this;
2150
+ }
2151
+ persistLinked() {
2152
+ this.storage.setItem(Rt, this._linked ? "1" : "0");
2153
+ }
2154
+ }
2155
+ function Ls() {
2156
+ try {
2157
+ return window.frameElement !== null;
2158
+ } catch {
2159
+ return !1;
2160
+ }
2161
+ }
2162
+ function Ms() {
2163
+ try {
2164
+ return Ls() && window.top ? window.top.location : window.location;
2165
+ } catch {
2166
+ return window.location;
2167
+ }
2168
+ }
2169
+ function Ps() {
2170
+ var t;
2171
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t = window == null ? void 0 : window.navigator) === null || t === void 0 ? void 0 : t.userAgent);
2172
+ }
2173
+ function pn() {
2174
+ var t, e;
2175
+ return (e = (t = window == null ? void 0 : window.matchMedia) === null || t === void 0 ? void 0 : t.call(window, "(prefers-color-scheme: dark)").matches) !== null && e !== void 0 ? e : !1;
2176
+ }
2177
+ const Rs = '@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';
2178
+ function gn() {
2179
+ const t = document.createElement("style");
2180
+ t.type = "text/css", t.appendChild(document.createTextNode(Rs)), document.documentElement.appendChild(t);
2181
+ }
2182
+ function _n(t) {
2183
+ var e, n, s = "";
2184
+ if (typeof t == "string" || typeof t == "number") s += t;
2185
+ else if (typeof t == "object") if (Array.isArray(t)) for (e = 0; e < t.length; e++) t[e] && (n = _n(t[e])) && (s && (s += " "), s += n);
2186
+ else for (e in t) t[e] && (s && (s += " "), s += e);
2187
+ return s;
2188
+ }
2189
+ function pe() {
2190
+ for (var t, e, n = 0, s = ""; n < arguments.length; ) (t = arguments[n++]) && (e = _n(t)) && (s && (s += " "), s += e);
2191
+ return s;
2192
+ }
2193
+ var Pe, O, mn, te, Tt, yn, wn, Ve, ke, ge, bn, ot, Ye, Je, Se = {}, Ae = [], Ts = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, Re = Array.isArray;
2194
+ function X(t, e) {
2195
+ for (var n in e) t[n] = e[n];
2196
+ return t;
2197
+ }
2198
+ function ct(t) {
2199
+ t && t.parentNode && t.parentNode.removeChild(t);
2200
+ }
2201
+ function R(t, e, n) {
2202
+ var s, r, i, a = {};
2203
+ for (i in e) i == "key" ? s = e[i] : i == "ref" ? r = e[i] : a[i] = e[i];
2204
+ if (arguments.length > 2 && (a.children = arguments.length > 3 ? Pe.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (i in t.defaultProps) a[i] === void 0 && (a[i] = t.defaultProps[i]);
2205
+ return Ee(t, a, s, r, null);
2206
+ }
2207
+ function Ee(t, e, n, s, r) {
2208
+ var i = { type: t, props: e, key: n, ref: s, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: r ?? ++mn, __i: -1, __u: 0 };
2209
+ return r == null && O.vnode != null && O.vnode(i), i;
2210
+ }
2211
+ function Te(t) {
2212
+ return t.children;
2213
+ }
2214
+ function Ie(t, e) {
2215
+ this.props = t, this.context = e;
2216
+ }
2217
+ function le(t, e) {
2218
+ if (e == null) return t.__ ? le(t.__, t.__i + 1) : null;
2219
+ for (var n; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) return n.__e;
2220
+ return typeof t.type == "function" ? le(t) : null;
2221
+ }
2222
+ function Os(t) {
2223
+ if (t.__P && t.__d) {
2224
+ var e = t.__v, n = e.__e, s = [], r = [], i = X({}, e);
2225
+ i.__v = e.__v + 1, O.vnode && O.vnode(i), lt(t.__P, i, e, t.__n, t.__P.namespaceURI, 32 & e.__u ? [n] : null, s, n ?? le(e), !!(32 & e.__u), r), i.__v = e.__v, i.__.__k[i.__i] = i, Cn(s, i, r), e.__e = e.__ = null, i.__e != n && vn(i);
2226
+ }
2227
+ }
2228
+ function vn(t) {
2229
+ if ((t = t.__) != null && t.__c != null) return t.__e = t.__c.base = null, t.__k.some(function(e) {
2230
+ if (e != null && e.__e != null) return t.__e = t.__c.base = e.__e;
2231
+ }), vn(t);
2232
+ }
2233
+ function Ot(t) {
2234
+ (!t.__d && (t.__d = !0) && te.push(t) && !xe.__r++ || Tt != O.debounceRendering) && ((Tt = O.debounceRendering) || yn)(xe);
2235
+ }
2236
+ function xe() {
2237
+ try {
2238
+ for (var t, e = 1; te.length; ) te.length > e && te.sort(wn), t = te.shift(), e = te.length, Os(t);
2239
+ } finally {
2240
+ te.length = xe.__r = 0;
2241
+ }
2242
+ }
2243
+ function kn(t, e, n, s, r, i, a, l, u, d, p) {
2244
+ var g, o, c, h, E, _, I, v = s && s.__k || Ae, k = e.length;
2245
+ for (u = Ns(n, e, v, u, k), g = 0; g < k; g++) (c = n.__k[g]) != null && (o = c.__i != -1 && v[c.__i] || Se, c.__i = g, _ = lt(t, c, o, r, i, a, l, u, d, p), h = c.__e, c.ref && o.ref != c.ref && (o.ref && dt(o.ref, null, c), p.push(c.ref, c.__c || h, c)), E == null && h != null && (E = h), (I = !!(4 & c.__u)) || o.__k === c.__k ? (u = En(c, u, t, I), I && o.__e && (o.__e = null)) : typeof c.type == "function" && _ !== void 0 ? u = _ : h && (u = h.nextSibling), c.__u &= -7);
2246
+ return n.__e = E, u;
2247
+ }
2248
+ function Ns(t, e, n, s, r) {
2249
+ var i, a, l, u, d, p = n.length, g = p, o = 0;
2250
+ for (t.__k = new Array(r), i = 0; i < r; i++) (a = e[i]) != null && typeof a != "boolean" && typeof a != "function" ? (typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? a = t.__k[i] = Ee(null, a, null, null, null) : Re(a) ? a = t.__k[i] = Ee(Te, { children: a }, null, null, null) : a.constructor === void 0 && a.__b > 0 ? a = t.__k[i] = Ee(a.type, a.props, a.key, a.ref ? a.ref : null, a.__v) : t.__k[i] = a, u = i + o, a.__ = t, a.__b = t.__b + 1, l = null, (d = a.__i = Ds(a, n, u, g)) != -1 && (g--, (l = n[d]) && (l.__u |= 2)), l == null || l.__v == null ? (d == -1 && (r > p ? o-- : r < p && o++), typeof a.type != "function" && (a.__u |= 4)) : d != u && (d == u - 1 ? o-- : d == u + 1 ? o++ : (d > u ? o-- : o++, a.__u |= 4))) : t.__k[i] = null;
2251
+ if (g) for (i = 0; i < p; i++) (l = n[i]) != null && (2 & l.__u) == 0 && (l.__e == s && (s = le(l)), An(l, l));
2252
+ return s;
2253
+ }
2254
+ function En(t, e, n, s) {
2255
+ var r, i;
2256
+ if (typeof t.type == "function") {
2257
+ for (r = t.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = t, e = En(r[i], e, n, s));
2258
+ return e;
2259
+ }
2260
+ t.__e != e && (s && (e && t.type && !e.parentNode && (e = le(t)), n.insertBefore(t.__e, e || null)), e = t.__e);
2261
+ do
2262
+ e = e && e.nextSibling;
2263
+ while (e != null && e.nodeType == 8);
2264
+ return e;
2265
+ }
2266
+ function Ds(t, e, n, s) {
2267
+ var r, i, a, l = t.key, u = t.type, d = e[n], p = d != null && (2 & d.__u) == 0;
2268
+ if (d === null && l == null || p && l == d.key && u == d.type) return n;
2269
+ if (s > (p ? 1 : 0)) {
2270
+ for (r = n - 1, i = n + 1; r >= 0 || i < e.length; ) if ((d = e[a = r >= 0 ? r-- : i++]) != null && (2 & d.__u) == 0 && l == d.key && u == d.type) return a;
2271
+ }
2272
+ return -1;
2273
+ }
2274
+ function Nt(t, e, n) {
2275
+ e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || Ts.test(e) ? n : n + "px";
2276
+ }
2277
+ function we(t, e, n, s, r) {
2278
+ var i, a;
2279
+ e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
2280
+ else {
2281
+ if (typeof s == "string" && (t.style.cssText = s = ""), s) for (e in s) n && e in n || Nt(t.style, e, "");
2282
+ if (n) for (e in n) s && n[e] == s[e] || Nt(t.style, e, n[e]);
2283
+ }
2284
+ else if (e[0] == "o" && e[1] == "n") i = e != (e = e.replace(bn, "$1")), a = e.toLowerCase(), e = a in t || e == "onFocusOut" || e == "onFocusIn" ? a.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + i] = n, n ? s ? n[ge] = s[ge] : (n[ge] = ot, t.addEventListener(e, i ? Je : Ye, i)) : t.removeEventListener(e, i ? Je : Ye, i);
2285
+ else {
2286
+ if (r == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
2287
+ else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
2288
+ t[e] = n ?? "";
2289
+ break e;
2290
+ } catch {
2291
+ }
2292
+ typeof n == "function" || (n == null || n === !1 && e[4] != "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && n == 1 ? "" : n));
2293
+ }
2294
+ }
2295
+ function Dt(t) {
2296
+ return function(e) {
2297
+ if (this.l) {
2298
+ var n = this.l[e.type + t];
2299
+ if (e[ke] == null) e[ke] = ot++;
2300
+ else if (e[ke] < n[ge]) return;
2301
+ return n(O.event ? O.event(e) : e);
2302
+ }
2303
+ };
2304
+ }
2305
+ function lt(t, e, n, s, r, i, a, l, u, d) {
2306
+ var p, g, o, c, h, E, _, I, v, k, C, y, A, M, P, b, m = e.type;
2307
+ if (e.constructor !== void 0) return null;
2308
+ 128 & n.__u && (u = !!(32 & n.__u), i = [l = e.__e = n.__e]), (p = O.__b) && p(e);
2309
+ e: if (typeof m == "function") {
2310
+ g = a.length;
2311
+ try {
2312
+ if (v = e.props, k = m.prototype && m.prototype.render, C = (p = m.contextType) && s[p.__c], y = p ? C ? C.props.value : p.__ : s, n.__c ? I = (o = e.__c = n.__c).__ = o.__E : (k ? e.__c = o = new m(v, y) : (e.__c = o = new Ie(v, y), o.constructor = m, o.render = Us), C && C.sub(o), o.state || (o.state = {}), o.__n = s, c = o.__d = !0, o.__h = [], o._sb = []), k && o.__s == null && (o.__s = o.state), k && m.getDerivedStateFromProps != null && (o.__s == o.state && (o.__s = X({}, o.__s)), X(o.__s, m.getDerivedStateFromProps(v, o.__s))), h = o.props, E = o.state, o.__v = e, c) k && m.getDerivedStateFromProps == null && o.componentWillMount != null && o.componentWillMount(), k && o.componentDidMount != null && o.__h.push(o.componentDidMount);
2313
+ else {
2314
+ if (k && m.getDerivedStateFromProps == null && v !== h && o.componentWillReceiveProps != null && o.componentWillReceiveProps(v, y), e.__v == n.__v || !o.__e && o.shouldComponentUpdate != null && o.shouldComponentUpdate(v, o.__s, y) === !1) {
2315
+ e.__v != n.__v && (o.props = v, o.state = o.__s, o.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(w) {
2316
+ w && (w.__ = e);
2317
+ }), Ae.push.apply(o.__h, o._sb), o._sb = [], o.__h.length && a.push(o);
2318
+ break e;
2319
+ }
2320
+ o.componentWillUpdate != null && o.componentWillUpdate(v, o.__s, y), k && o.componentDidUpdate != null && o.__h.push(function() {
2321
+ o.componentDidUpdate(h, E, _);
2322
+ });
2323
+ }
2324
+ if (o.context = y, o.props = v, o.__P = t, o.__e = !1, A = O.__r, M = 0, k) o.state = o.__s, o.__d = !1, A && A(e), p = o.render(o.props, o.state, o.context), Ae.push.apply(o.__h, o._sb), o._sb = [];
2325
+ else do
2326
+ o.__d = !1, A && A(e), p = o.render(o.props, o.state, o.context), o.state = o.__s;
2327
+ while (o.__d && ++M < 25);
2328
+ o.state = o.__s, o.getChildContext != null && (s = X(X({}, s), o.getChildContext())), k && !c && o.getSnapshotBeforeUpdate != null && (_ = o.getSnapshotBeforeUpdate(h, E)), P = p != null && p.type === Te && p.key == null ? Sn(p.props.children) : p, l = kn(t, Re(P) ? P : [P], e, n, s, r, i, a, l, u, d), o.base = e.__e, e.__u &= -161, o.__h.length && a.push(o), I && (o.__E = o.__ = null);
2329
+ } catch (w) {
2330
+ if (a.length = g, e.__v = null, u || i != null) {
2331
+ if (w.then) {
2332
+ for (e.__u |= u ? 160 : 128; l && l.nodeType == 8 && l.nextSibling; ) l = l.nextSibling;
2333
+ i != null && (i[i.indexOf(l)] = null), e.__e = l;
2334
+ } else if (i != null) for (b = i.length; b--; ) ct(i[b]);
2335
+ } else e.__e = n.__e;
2336
+ e.__k == null && (e.__k = n.__k || []), w.then || In(e), O.__e(w, e, n);
2337
+ }
2338
+ } else i == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : l = e.__e = Hs(n.__e, e, n, s, r, i, a, u, d);
2339
+ return (p = O.diffed) && p(e), 128 & e.__u ? void 0 : l;
2340
+ }
2341
+ function In(t) {
2342
+ t && (t.__c && (t.__c.__e = !0), t.__k && t.__k.some(In));
2343
+ }
2344
+ function Cn(t, e, n) {
2345
+ for (var s = 0; s < n.length; s++) dt(n[s], n[++s], n[++s]);
2346
+ O.__c && O.__c(e, t), t.some(function(r) {
2347
+ try {
2348
+ t = r.__h, r.__h = [], t.some(function(i) {
2349
+ i.call(r);
2350
+ });
2351
+ } catch (i) {
2352
+ O.__e(i, r.__v);
2353
+ }
2354
+ });
2355
+ }
2356
+ function Sn(t) {
2357
+ return typeof t != "object" || t == null || t.__b > 0 ? t : Re(t) ? t.map(Sn) : t.constructor !== void 0 ? null : X({}, t);
2358
+ }
2359
+ function Hs(t, e, n, s, r, i, a, l, u) {
2360
+ var d, p, g, o, c, h, E, _ = n.props || Se, I = e.props, v = e.type;
2361
+ if (v == "svg" ? r = "http://www.w3.org/2000/svg" : v == "math" ? r = "http://www.w3.org/1998/Math/MathML" : r || (r = "http://www.w3.org/1999/xhtml"), i != null) {
2362
+ for (d = 0; d < i.length; d++) if ((c = i[d]) && "setAttribute" in c == !!v && (v ? c.localName == v : c.nodeType == 3)) {
2363
+ t = c, i[d] = null;
2364
+ break;
2365
+ }
2366
+ }
2367
+ if (t == null) {
2368
+ if (v == null) return document.createTextNode(I);
2369
+ t = document.createElementNS(r, v, I.is && I), l && (O.__m && O.__m(e, i), l = !1), i = null;
2370
+ }
2371
+ if (v == null) _ === I || l && t.data == I || (t.data = I);
2372
+ else {
2373
+ if (i = v == "textarea" && I.defaultValue != null ? null : i && Pe.call(t.childNodes), !l && i != null) for (_ = {}, d = 0; d < t.attributes.length; d++) _[(c = t.attributes[d]).name] = c.value;
2374
+ for (d in _) c = _[d], d == "dangerouslySetInnerHTML" ? g = c : d == "children" || d in I || d == "value" && "defaultValue" in I || d == "checked" && "defaultChecked" in I || we(t, d, null, c, r);
2375
+ for (d in I) c = I[d], d == "children" ? o = c : d == "dangerouslySetInnerHTML" ? p = c : d == "value" ? h = c : d == "checked" ? E = c : l && typeof c != "function" || _[d] === c || we(t, d, c, _[d], r);
2376
+ if (p) l || g && (p.__html == g.__html || p.__html == t.innerHTML) || (t.innerHTML = p.__html), e.__k = [];
2377
+ else if (g && (t.innerHTML = ""), kn(e.type == "template" ? t.content : t, Re(o) ? o : [o], e, n, s, v == "foreignObject" ? "http://www.w3.org/1999/xhtml" : r, i, a, i ? i[0] : n.__k && le(n, 0), l, u), i != null) for (d = i.length; d--; ) ct(i[d]);
2378
+ l && v != "textarea" || (d = "value", v == "progress" && h == null ? t.removeAttribute("value") : h != null && (h !== t[d] || v == "progress" && !h || v == "option" && h != _[d]) && we(t, d, h, _[d], r), d = "checked", E != null && E != t[d] && we(t, d, E, _[d], r));
2379
+ }
2380
+ return t;
2381
+ }
2382
+ function dt(t, e, n) {
2383
+ try {
2384
+ if (typeof t == "function") {
2385
+ var s = typeof t.__u == "function";
2386
+ s && t.__u(), s && e == null || (t.__u = t(e));
2387
+ } else t.current = e;
2388
+ } catch (r) {
2389
+ O.__e(r, n);
2390
+ }
2391
+ }
2392
+ function An(t, e, n) {
2393
+ var s, r;
2394
+ if (O.unmount && O.unmount(t), (s = t.ref) && (s.current && s.current != t.__e || dt(s, null, e)), (s = t.__c) != null) {
2395
+ if (s.componentWillUnmount) try {
2396
+ s.componentWillUnmount();
2397
+ } catch (i) {
2398
+ O.__e(i, e);
2399
+ }
2400
+ s.base = s.__P = s.__n = null;
2401
+ }
2402
+ if (s = t.__k) for (r = 0; r < s.length; r++) s[r] && An(s[r], e, n || typeof t.type != "function");
2403
+ n || ct(t.__e), t.__c = t.__ = t.__e = void 0;
2404
+ }
2405
+ function Us(t, e, n) {
2406
+ return this.constructor(t, n);
2407
+ }
2408
+ function Qe(t, e, n) {
2409
+ var s, r, i, a;
2410
+ e == document && (e = document.documentElement), O.__ && O.__(t, e), r = (s = !1) ? null : e.__k, i = [], a = [], lt(e, t = e.__k = R(Te, null, [t]), r || Se, Se, e.namespaceURI, r ? null : e.firstChild ? Pe.call(e.childNodes) : null, i, r ? r.__e : e.firstChild, s, a), Cn(i, t, a), t.props.children = null;
2411
+ }
2412
+ Pe = Ae.slice, O = { __e: function(t, e, n, s) {
2413
+ for (var r, i, a; e = e.__; ) if ((r = e.__c) && !r.__) try {
2414
+ if ((i = r.constructor) && i.getDerivedStateFromError != null && (r.setState(i.getDerivedStateFromError(t)), a = r.__d), r.componentDidCatch != null && (r.componentDidCatch(t, s || {}), a = r.__d), a) return r.__E = r;
2415
+ } catch (l) {
2416
+ t = l;
2417
+ }
2418
+ throw t;
2419
+ } }, mn = 0, Ie.prototype.setState = function(t, e) {
2420
+ var n;
2421
+ n = this.__s != null && this.__s != this.state ? this.__s : this.__s = X({}, this.state), typeof t == "function" && (t = t(X({}, n), this.props)), t && X(n, t), t != null && this.__v && (e && this._sb.push(e), Ot(this));
2422
+ }, Ie.prototype.forceUpdate = function(t) {
2423
+ this.__v && (this.__e = !0, t && this.__h.push(t), Ot(this));
2424
+ }, Ie.prototype.render = Te, te = [], yn = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, wn = function(t, e) {
2425
+ return t.__v.__b - e.__v.__b;
2426
+ }, xe.__r = 0, Ve = Math.random().toString(8), ke = "__d" + Ve, ge = "__a" + Ve, bn = /(PointerCapture)$|Capture$/i, ot = 0, Ye = Dt(!1), Je = Dt(!0);
2427
+ var Le, j, Ke, Ht, Xe = 0, xn = [], B = O, Ut = B.__b, jt = B.__r, Bt = B.diffed, Wt = B.__c, qt = B.unmount, Vt = B.__;
2428
+ function Ln(t, e) {
2429
+ B.__h && B.__h(j, t, Xe || e), Xe = 0;
2430
+ var n = j.__H || (j.__H = { __: [], __h: [] });
2431
+ return t >= n.__.length && n.__.push({}), n.__[t];
2432
+ }
2433
+ function Kt(t) {
2434
+ return Xe = 1, js(Mn, t);
2435
+ }
2436
+ function js(t, e, n) {
2437
+ var s = Ln(Le++, 2);
2438
+ if (s.t = t, !s.__c && (s.__ = [Mn(void 0, e), function(l) {
2439
+ var u = s.__N ? s.__N[0] : s.__[0], d = s.t(u, l);
2440
+ u !== d && (s.__N = [d, s.__[1]], s.__c.setState({}));
2441
+ }], s.__c = j, !j.__f)) {
2442
+ var r = function(l, u, d) {
2443
+ if (!s.__c.__H) return !0;
2444
+ var p = !1, g = s.__c.props !== l;
2445
+ if (s.__c.__H.__.some(function(c) {
2446
+ if (c.__N) {
2447
+ p = !0;
2448
+ var h = c.__[0];
2449
+ c.__ = c.__N, c.__N = void 0, h !== c.__[0] && (g = !0);
2450
+ }
2451
+ }), i) {
2452
+ var o = i.call(this, l, u, d);
2453
+ return p ? o || g : o;
2454
+ }
2455
+ return !p || g;
2456
+ };
2457
+ j.__f = !0;
2458
+ var i = j.shouldComponentUpdate, a = j.componentWillUpdate;
2459
+ j.componentWillUpdate = function(l, u, d) {
2460
+ if (this.__e) {
2461
+ var p = i;
2462
+ i = void 0, r(l, u, d), i = p;
2463
+ }
2464
+ a && a.call(this, l, u, d);
2465
+ }, j.shouldComponentUpdate = r;
2466
+ }
2467
+ return s.__N || s.__;
2468
+ }
2469
+ function Bs(t, e) {
2470
+ var n = Ln(Le++, 3);
2471
+ !B.__s && Vs(n.__H, e) && (n.__ = t, n.u = e, j.__H.__h.push(n));
2472
+ }
2473
+ function Ws() {
2474
+ for (var t; t = xn.shift(); ) {
2475
+ var e = t.__H;
2476
+ if (t.__P && e) try {
2477
+ e.__h.some(Ce), e.__h.some(et), e.__h = [];
2478
+ } catch (n) {
2479
+ e.__h = [], B.__e(n, t.__v);
2480
+ }
2481
+ }
2482
+ }
2483
+ B.__b = function(t) {
2484
+ j = null, Ut && Ut(t);
2485
+ }, B.__ = function(t, e) {
2486
+ t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Vt && Vt(t, e);
2487
+ }, B.__r = function(t) {
2488
+ jt && jt(t), Le = 0;
2489
+ var e = (j = t.__c).__H;
2490
+ e && (Ke === j ? (e.__h = [], j.__h = [], e.__.some(function(n) {
2491
+ n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
2492
+ })) : (e.__h.some(Ce), e.__h.some(et), e.__h = [], Le = 0)), Ke = j;
2493
+ }, B.diffed = function(t) {
2494
+ Bt && Bt(t);
2495
+ var e = t.__c;
2496
+ e && e.__H && (e.__H.__h.length && (xn.push(e) !== 1 && Ht === B.requestAnimationFrame || ((Ht = B.requestAnimationFrame) || qs)(Ws)), e.__H.__.some(function(n) {
2497
+ n.u && (n.__H = n.u, n.u = void 0);
2498
+ })), Ke = j = null;
2499
+ }, B.__c = function(t, e) {
2500
+ e.some(function(n) {
2501
+ try {
2502
+ n.__h.some(Ce), n.__h = n.__h.filter(function(s) {
2503
+ return !s.__ || et(s);
2504
+ });
2505
+ } catch (s) {
2506
+ e.some(function(r) {
2507
+ r.__h && (r.__h = []);
2508
+ }), e = [], B.__e(s, n.__v);
2509
+ }
2510
+ }), Wt && Wt(t, e);
2511
+ }, B.unmount = function(t) {
2512
+ qt && qt(t);
2513
+ var e, n = t.__c;
2514
+ n && n.__H && (n.__H.__.some(function(s) {
2515
+ try {
2516
+ Ce(s);
2517
+ } catch (r) {
2518
+ e = r;
2519
+ }
2520
+ }), n.__H = void 0, e && B.__e(e, n.__v));
2521
+ };
2522
+ var Ft = typeof requestAnimationFrame == "function";
2523
+ function qs(t) {
2524
+ var e, n = function() {
2525
+ clearTimeout(s), Ft && cancelAnimationFrame(e), setTimeout(t);
2526
+ }, s = setTimeout(n, 35);
2527
+ Ft && (e = requestAnimationFrame(n));
2528
+ }
2529
+ function Ce(t) {
2530
+ var e = j, n = t.__c;
2531
+ typeof n == "function" && (t.__c = void 0, n()), j = e;
2532
+ }
2533
+ function et(t) {
2534
+ var e = j;
2535
+ t.__c = t.__(), j = e;
2536
+ }
2537
+ function Vs(t, e) {
2538
+ return !t || t.length !== e.length || e.some(function(n, s) {
2539
+ return n !== t[s];
2540
+ });
2541
+ }
2542
+ function Mn(t, e) {
2543
+ return typeof e == "function" ? e(t) : e;
2544
+ }
2545
+ const Ks = ".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}", Fs = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+", zs = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";
2546
+ class Pn {
2547
+ constructor() {
2548
+ this.items = /* @__PURE__ */ new Map(), this.nextItemKey = 0, this.root = null, this.darkMode = pn();
2549
+ }
2550
+ attach(e) {
2551
+ this.root = document.createElement("div"), this.root.className = "-cbwsdk-snackbar-root", e.appendChild(this.root), this.render();
2552
+ }
2553
+ presentItem(e) {
2554
+ const n = this.nextItemKey++;
2555
+ return this.items.set(n, e), this.render(), () => {
2556
+ this.items.delete(n), this.render();
2557
+ };
2558
+ }
2559
+ clear() {
2560
+ this.items.clear(), this.render();
2561
+ }
2562
+ render() {
2563
+ this.root && Qe(R(
2564
+ "div",
2565
+ null,
2566
+ R(Rn, { darkMode: this.darkMode }, Array.from(this.items.entries()).map(([e, n]) => R($s, Object.assign({}, n, { key: e }))))
2567
+ ), this.root);
2568
+ }
2569
+ }
2570
+ const Rn = (t) => R(
2571
+ "div",
2572
+ { class: pe("-cbwsdk-snackbar-container") },
2573
+ R("style", null, Ks),
2574
+ R("div", { class: "-cbwsdk-snackbar" }, t.children)
2575
+ ), $s = ({ autoExpand: t, message: e, menuItems: n }) => {
2576
+ const [s, r] = Kt(!0), [i, a] = Kt(t ?? !1);
2577
+ Bs(() => {
2578
+ const u = [
2579
+ window.setTimeout(() => {
2580
+ r(!1);
2581
+ }, 1),
2582
+ window.setTimeout(() => {
2583
+ a(!0);
2584
+ }, 1e4)
2585
+ ];
2586
+ return () => {
2587
+ u.forEach(window.clearTimeout);
2588
+ };
2589
+ });
2590
+ const l = () => {
2591
+ a(!i);
2592
+ };
2593
+ return R(
2594
+ "div",
2595
+ { class: pe("-cbwsdk-snackbar-instance", s && "-cbwsdk-snackbar-instance-hidden", i && "-cbwsdk-snackbar-instance-expanded") },
2596
+ R(
2597
+ "div",
2598
+ { class: "-cbwsdk-snackbar-instance-header", onClick: l },
2599
+ R("img", { src: Fs, class: "-cbwsdk-snackbar-instance-header-cblogo" }),
2600
+ " ",
2601
+ R("div", { class: "-cbwsdk-snackbar-instance-header-message" }, e),
2602
+ R(
2603
+ "div",
2604
+ { class: "-gear-container" },
2605
+ !i && R(
2606
+ "svg",
2607
+ { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
2608
+ R("circle", { cx: "12", cy: "12", r: "12", fill: "#F5F7F8" })
2609
+ ),
2610
+ R("img", { src: zs, class: "-gear-icon", title: "Expand" })
2611
+ )
2612
+ ),
2613
+ n && n.length > 0 && R("div", { class: "-cbwsdk-snackbar-instance-menu" }, n.map((u, d) => R(
2614
+ "div",
2615
+ { class: pe("-cbwsdk-snackbar-instance-menu-item", u.isRed && "-cbwsdk-snackbar-instance-menu-item-is-red"), onClick: u.onClick, key: d },
2616
+ R(
2617
+ "svg",
2618
+ { width: u.svgWidth, height: u.svgHeight, viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
2619
+ R("path", { "fill-rule": u.defaultFillRule, "clip-rule": u.defaultClipRule, d: u.path, fill: "#AAAAAA" })
2620
+ ),
2621
+ R("span", { class: pe("-cbwsdk-snackbar-instance-menu-item-info", u.isRed && "-cbwsdk-snackbar-instance-menu-item-info-is-red") }, u.info)
2622
+ )))
2623
+ );
2624
+ }, Tn = "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z";
2625
+ class Zs {
2626
+ constructor() {
2627
+ this.attached = !1, this.snackbar = new Pn();
2628
+ }
2629
+ attach() {
2630
+ if (this.attached)
2631
+ throw new Error("Coinbase Wallet SDK UI is already attached");
2632
+ const e = document.documentElement, n = document.createElement("div");
2633
+ n.className = "-cbwsdk-css-reset", e.appendChild(n), this.snackbar.attach(n), this.attached = !0, gn();
2634
+ }
2635
+ showConnecting(e) {
2636
+ let n;
2637
+ return e.isUnlinkedErrorState ? n = {
2638
+ autoExpand: !0,
2639
+ message: "Connection lost",
2640
+ menuItems: [
2641
+ {
2642
+ isRed: !1,
2643
+ info: "Reset connection",
2644
+ svgWidth: "10",
2645
+ svgHeight: "11",
2646
+ path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",
2647
+ defaultFillRule: "evenodd",
2648
+ defaultClipRule: "evenodd",
2649
+ onClick: e.onResetConnection
2650
+ }
2651
+ ]
2652
+ } : n = {
2653
+ message: "Confirm on phone",
2654
+ menuItems: [
2655
+ {
2656
+ isRed: !0,
2657
+ info: "Cancel transaction",
2658
+ svgWidth: "11",
2659
+ svgHeight: "11",
2660
+ path: "M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",
2661
+ defaultFillRule: "inherit",
2662
+ defaultClipRule: "inherit",
2663
+ onClick: e.onCancel
2664
+ },
2665
+ {
2666
+ isRed: !1,
2667
+ info: "Reset connection",
2668
+ svgWidth: "10",
2669
+ svgHeight: "11",
2670
+ path: Tn,
2671
+ defaultFillRule: "evenodd",
2672
+ defaultClipRule: "evenodd",
2673
+ onClick: e.onResetConnection
2674
+ }
2675
+ ]
2676
+ }, this.snackbar.presentItem(n);
2677
+ }
2678
+ }
2679
+ const Gs = ".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";
2680
+ class Ys {
2681
+ constructor() {
2682
+ this.root = null, this.darkMode = pn();
2683
+ }
2684
+ attach() {
2685
+ const e = document.documentElement;
2686
+ this.root = document.createElement("div"), this.root.className = "-cbwsdk-css-reset", e.appendChild(this.root), gn();
2687
+ }
2688
+ present(e) {
2689
+ this.render(e);
2690
+ }
2691
+ clear() {
2692
+ this.render(null);
2693
+ }
2694
+ render(e) {
2695
+ this.root && (Qe(null, this.root), e && Qe(R(Js, Object.assign({}, e, { onDismiss: () => {
2696
+ this.clear();
2697
+ }, darkMode: this.darkMode })), this.root));
2698
+ }
2699
+ }
2700
+ const Js = ({ title: t, buttonText: e, darkMode: n, onButtonClick: s, onDismiss: r }) => {
2701
+ const i = n ? "dark" : "light";
2702
+ return R(
2703
+ Rn,
2704
+ { darkMode: n },
2705
+ R(
2706
+ "div",
2707
+ { class: "-cbwsdk-redirect-dialog" },
2708
+ R("style", null, Gs),
2709
+ R("div", { class: "-cbwsdk-redirect-dialog-backdrop", onClick: r }),
2710
+ R(
2711
+ "div",
2712
+ { class: pe("-cbwsdk-redirect-dialog-box", i) },
2713
+ R("p", null, t),
2714
+ R("button", { onClick: s }, e)
2715
+ )
2716
+ )
2717
+ );
2718
+ }, Qs = "https://keys.coinbase.com/connect", Xs = "https://rpc.wallet.coinbase.com", zt = "https://www.walletlink.org", ei = "https://go.cb-w.com/walletlink";
2719
+ class $t {
2720
+ constructor() {
2721
+ this.attached = !1, this.redirectDialog = new Ys();
2722
+ }
2723
+ attach() {
2724
+ if (this.attached)
2725
+ throw new Error("Coinbase Wallet SDK UI is already attached");
2726
+ this.redirectDialog.attach(), this.attached = !0;
2727
+ }
2728
+ redirectToCoinbaseWallet(e) {
2729
+ const n = new URL(ei);
2730
+ n.searchParams.append("redirect_url", Ms().href), e && n.searchParams.append("wl_url", e);
2731
+ const s = document.createElement("a");
2732
+ s.target = "cbw-opener", s.href = n.href, s.rel = "noreferrer noopener", s.click();
2733
+ }
2734
+ openCoinbaseWalletDeeplink(e) {
2735
+ this.redirectToCoinbaseWallet(e), setTimeout(() => {
2736
+ this.redirectDialog.present({
2737
+ title: "Redirecting to Coinbase Wallet...",
2738
+ buttonText: "Open",
2739
+ onButtonClick: () => {
2740
+ this.redirectToCoinbaseWallet(e);
2741
+ }
2742
+ });
2743
+ }, 99);
2744
+ }
2745
+ showConnecting(e) {
2746
+ return () => {
2747
+ this.redirectDialog.clear();
2748
+ };
2749
+ }
2750
+ }
2751
+ class Q {
2752
+ constructor(e) {
2753
+ this.chainCallbackParams = { chainId: "", jsonRpcUrl: "" }, this.isMobileWeb = Ps(), this.linkedUpdated = (i) => {
2754
+ this.isLinked = i;
2755
+ const a = this.storage.getItem(Ge);
2756
+ if (i && (this._session.linked = i), this.isUnlinkedErrorState = !1, a) {
2757
+ const l = a.split(" "), u = this.storage.getItem("IsStandaloneSigning") === "true";
2758
+ l[0] !== "" && !i && this._session.linked && !u && (this.isUnlinkedErrorState = !0);
2759
+ }
2760
+ }, this.metadataUpdated = (i, a) => {
2761
+ this.storage.setItem(i, a);
2762
+ }, this.chainUpdated = (i, a) => {
2763
+ this.chainCallbackParams.chainId === i && this.chainCallbackParams.jsonRpcUrl === a || (this.chainCallbackParams = {
2764
+ chainId: i,
2765
+ jsonRpcUrl: a
2766
+ }, this.chainCallback && this.chainCallback(a, Number.parseInt(i, 10)));
2767
+ }, this.accountUpdated = (i) => {
2768
+ this.accountsCallback && this.accountsCallback([i]), Q.accountRequestCallbackIds.size > 0 && (Array.from(Q.accountRequestCallbackIds.values()).forEach((a) => {
2769
+ this.invokeCallback(a, {
2770
+ method: "requestEthereumAccounts",
2771
+ result: [i]
2772
+ });
2773
+ }), Q.accountRequestCallbackIds.clear());
2774
+ }, this.resetAndReload = this.resetAndReload.bind(this), this.linkAPIUrl = e.linkAPIUrl, this.storage = e.storage, this.metadata = e.metadata, this.accountsCallback = e.accountsCallback, this.chainCallback = e.chainCallback;
2775
+ const { session: n, ui: s, connection: r } = this.subscribe();
2776
+ this._session = n, this.connection = r, this.relayEventManager = new xs(), this.ui = s, this.ui.attach();
2777
+ }
2778
+ subscribe() {
2779
+ const e = ce.load(this.storage) || ce.create(this.storage), { linkAPIUrl: n } = this, s = new As({
2780
+ session: e,
2781
+ linkAPIUrl: n,
2782
+ listener: this
2783
+ }), r = this.isMobileWeb ? new $t() : new Zs();
2784
+ return s.connect(), { session: e, ui: r, connection: s };
2785
+ }
2786
+ resetAndReload() {
2787
+ this.connection.destroy().then(() => {
2788
+ const e = ce.load(this.storage);
2789
+ (e == null ? void 0 : e.id) === this._session.id && Y.clearAll(), document.location.reload();
2790
+ }).catch((e) => {
2791
+ });
2792
+ }
2793
+ signEthereumTransaction(e) {
2794
+ return this.sendRequest({
2795
+ method: "signEthereumTransaction",
2796
+ params: {
2797
+ fromAddress: e.fromAddress,
2798
+ toAddress: e.toAddress,
2799
+ weiValue: Z(e.weiValue),
2800
+ data: he(e.data, !0),
2801
+ nonce: e.nonce,
2802
+ gasPriceInWei: e.gasPriceInWei ? Z(e.gasPriceInWei) : null,
2803
+ maxFeePerGas: e.gasPriceInWei ? Z(e.gasPriceInWei) : null,
2804
+ maxPriorityFeePerGas: e.gasPriceInWei ? Z(e.gasPriceInWei) : null,
2805
+ gasLimit: e.gasLimit ? Z(e.gasLimit) : null,
2806
+ chainId: e.chainId,
2807
+ shouldSubmit: !1
2808
+ }
2809
+ });
2810
+ }
2811
+ signAndSubmitEthereumTransaction(e) {
2812
+ return this.sendRequest({
2813
+ method: "signEthereumTransaction",
2814
+ params: {
2815
+ fromAddress: e.fromAddress,
2816
+ toAddress: e.toAddress,
2817
+ weiValue: Z(e.weiValue),
2818
+ data: he(e.data, !0),
2819
+ nonce: e.nonce,
2820
+ gasPriceInWei: e.gasPriceInWei ? Z(e.gasPriceInWei) : null,
2821
+ maxFeePerGas: e.maxFeePerGas ? Z(e.maxFeePerGas) : null,
2822
+ maxPriorityFeePerGas: e.maxPriorityFeePerGas ? Z(e.maxPriorityFeePerGas) : null,
2823
+ gasLimit: e.gasLimit ? Z(e.gasLimit) : null,
2824
+ chainId: e.chainId,
2825
+ shouldSubmit: !0
2826
+ }
2827
+ });
2828
+ }
2829
+ submitEthereumTransaction(e, n) {
2830
+ return this.sendRequest({
2831
+ method: "submitEthereumTransaction",
2832
+ params: {
2833
+ signedTransaction: he(e, !0),
2834
+ chainId: n
2835
+ }
2836
+ });
2837
+ }
2838
+ getWalletLinkSession() {
2839
+ return this._session;
2840
+ }
2841
+ sendRequest(e) {
2842
+ let n = null;
2843
+ const s = ie(8), r = (i) => {
2844
+ this.publishWeb3RequestCanceledEvent(s), this.handleErrorResponse(s, e.method, i), n == null || n();
2845
+ };
2846
+ return new Promise((i, a) => {
2847
+ n = this.ui.showConnecting({
2848
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
2849
+ onCancel: r,
2850
+ onResetConnection: this.resetAndReload
2851
+ // eslint-disable-line @typescript-eslint/unbound-method
2852
+ }), this.relayEventManager.callbacks.set(s, (l) => {
2853
+ if (n == null || n(), K(l))
2854
+ return a(new Error(l.errorMessage));
2855
+ i(l);
2856
+ }), this.publishWeb3RequestEvent(s, e);
2857
+ });
2858
+ }
2859
+ publishWeb3RequestEvent(e, n) {
2860
+ const s = { type: "WEB3_REQUEST", id: e, request: n };
2861
+ this.publishEvent("Web3Request", s, !0).then((r) => {
2862
+ }).catch((r) => {
2863
+ this.handleWeb3ResponseMessage(s.id, {
2864
+ method: n.method,
2865
+ errorMessage: r.message
2866
+ });
2867
+ }), this.isMobileWeb && this.openCoinbaseWalletDeeplink(n.method);
2868
+ }
2869
+ // copied from MobileRelay
2870
+ openCoinbaseWalletDeeplink(e) {
2871
+ if (this.ui instanceof $t)
2872
+ switch (e) {
2873
+ case "requestEthereumAccounts":
2874
+ // requestEthereumAccounts is handled via popup
2875
+ case "switchEthereumChain":
2876
+ return;
2877
+ default:
2878
+ window.addEventListener("blur", () => {
2879
+ window.addEventListener("focus", () => {
2880
+ this.connection.checkUnseenEvents();
2881
+ }, { once: !0 });
2882
+ }, { once: !0 }), this.ui.openCoinbaseWalletDeeplink();
2883
+ break;
2884
+ }
2885
+ }
2886
+ publishWeb3RequestCanceledEvent(e) {
2887
+ const n = {
2888
+ type: "WEB3_REQUEST_CANCELED",
2889
+ id: e
2890
+ };
2891
+ this.publishEvent("Web3RequestCanceled", n, !1).then();
2892
+ }
2893
+ publishEvent(e, n, s) {
2894
+ return this.connection.publishEvent(e, n, s);
2895
+ }
2896
+ handleWeb3ResponseMessage(e, n) {
2897
+ if (n.method === "requestEthereumAccounts") {
2898
+ Q.accountRequestCallbackIds.forEach((s) => this.invokeCallback(s, n)), Q.accountRequestCallbackIds.clear();
2899
+ return;
2900
+ }
2901
+ this.invokeCallback(e, n);
2902
+ }
2903
+ handleErrorResponse(e, n, s) {
2904
+ var r;
2905
+ const i = (r = s == null ? void 0 : s.message) !== null && r !== void 0 ? r : "Unspecified error message.";
2906
+ this.handleWeb3ResponseMessage(e, {
2907
+ method: n,
2908
+ errorMessage: i
2909
+ });
2910
+ }
2911
+ invokeCallback(e, n) {
2912
+ const s = this.relayEventManager.callbacks.get(e);
2913
+ s && (s(n), this.relayEventManager.callbacks.delete(e));
2914
+ }
2915
+ requestEthereumAccounts() {
2916
+ const { appName: e, appLogoUrl: n } = this.metadata, s = {
2917
+ method: "requestEthereumAccounts",
2918
+ params: {
2919
+ appName: e,
2920
+ appLogoUrl: n
2921
+ }
2922
+ }, r = ie(8);
2923
+ return new Promise((i, a) => {
2924
+ this.relayEventManager.callbacks.set(r, (l) => {
2925
+ if (K(l))
2926
+ return a(new Error(l.errorMessage));
2927
+ i(l);
2928
+ }), Q.accountRequestCallbackIds.add(r), this.publishWeb3RequestEvent(r, s);
2929
+ });
2930
+ }
2931
+ watchAsset(e, n, s, r, i, a) {
2932
+ const l = {
2933
+ method: "watchAsset",
2934
+ params: {
2935
+ type: e,
2936
+ options: {
2937
+ address: n,
2938
+ symbol: s,
2939
+ decimals: r,
2940
+ image: i
2941
+ },
2942
+ chainId: a
2943
+ }
2944
+ };
2945
+ let u = null;
2946
+ const d = ie(8), p = (g) => {
2947
+ this.publishWeb3RequestCanceledEvent(d), this.handleErrorResponse(d, l.method, g), u == null || u();
2948
+ };
2949
+ return u = this.ui.showConnecting({
2950
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
2951
+ onCancel: p,
2952
+ onResetConnection: this.resetAndReload
2953
+ // eslint-disable-line @typescript-eslint/unbound-method
2954
+ }), new Promise((g, o) => {
2955
+ this.relayEventManager.callbacks.set(d, (c) => {
2956
+ if (u == null || u(), K(c))
2957
+ return o(new Error(c.errorMessage));
2958
+ g(c);
2959
+ }), this.publishWeb3RequestEvent(d, l);
2960
+ });
2961
+ }
2962
+ addEthereumChain(e, n, s, r, i, a) {
2963
+ const l = {
2964
+ method: "addEthereumChain",
2965
+ params: {
2966
+ chainId: e,
2967
+ rpcUrls: n,
2968
+ blockExplorerUrls: r,
2969
+ chainName: i,
2970
+ iconUrls: s,
2971
+ nativeCurrency: a
2972
+ }
2973
+ };
2974
+ let u = null;
2975
+ const d = ie(8), p = (g) => {
2976
+ this.publishWeb3RequestCanceledEvent(d), this.handleErrorResponse(d, l.method, g), u == null || u();
2977
+ };
2978
+ return u = this.ui.showConnecting({
2979
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
2980
+ onCancel: p,
2981
+ onResetConnection: this.resetAndReload
2982
+ // eslint-disable-line @typescript-eslint/unbound-method
2983
+ }), new Promise((g, o) => {
2984
+ this.relayEventManager.callbacks.set(d, (c) => {
2985
+ if (u == null || u(), K(c))
2986
+ return o(new Error(c.errorMessage));
2987
+ g(c);
2988
+ }), this.publishWeb3RequestEvent(d, l);
2989
+ });
2990
+ }
2991
+ switchEthereumChain(e, n) {
2992
+ const s = {
2993
+ method: "switchEthereumChain",
2994
+ params: Object.assign({ chainId: e }, { address: n })
2995
+ };
2996
+ let r = null;
2997
+ const i = ie(8), a = (l) => {
2998
+ this.publishWeb3RequestCanceledEvent(i), this.handleErrorResponse(i, s.method, l), r == null || r();
2999
+ };
3000
+ return r = this.ui.showConnecting({
3001
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
3002
+ onCancel: a,
3003
+ onResetConnection: this.resetAndReload
3004
+ // eslint-disable-line @typescript-eslint/unbound-method
3005
+ }), new Promise((l, u) => {
3006
+ this.relayEventManager.callbacks.set(i, (d) => {
3007
+ if (r == null || r(), K(d) && d.errorCode)
3008
+ return u(L.provider.custom({
3009
+ code: d.errorCode,
3010
+ message: "Unrecognized chain ID. Try adding the chain using addEthereumChain first."
3011
+ }));
3012
+ if (K(d))
3013
+ return u(new Error(d.errorMessage));
3014
+ l(d);
3015
+ }), this.publishWeb3RequestEvent(i, s);
3016
+ });
3017
+ }
3018
+ }
3019
+ Q.accountRequestCallbackIds = /* @__PURE__ */ new Set();
3020
+ const Zt = "DefaultChainId", Gt = "DefaultJsonRpcUrl";
3021
+ class On {
3022
+ constructor(e) {
3023
+ this._relay = null, this._addresses = [], this.metadata = e.metadata, this._storage = new Y("walletlink", zt), this.callback = e.callback || null;
3024
+ const n = this._storage.getItem(Ge);
3025
+ if (n) {
3026
+ const s = n.split(" ");
3027
+ s[0] !== "" && (this._addresses = s.map((r) => ee(r)));
3028
+ }
3029
+ this.initializeRelay();
3030
+ }
3031
+ getSession() {
3032
+ const e = this.initializeRelay(), { id: n, secret: s } = e.getWalletLinkSession();
3033
+ return { id: n, secret: s };
3034
+ }
3035
+ async handshake() {
3036
+ await this._eth_requestAccounts();
3037
+ }
3038
+ get selectedAddress() {
3039
+ return this._addresses[0] || void 0;
3040
+ }
3041
+ get jsonRpcUrl() {
3042
+ var e;
3043
+ return (e = this._storage.getItem(Gt)) !== null && e !== void 0 ? e : void 0;
3044
+ }
3045
+ set jsonRpcUrl(e) {
3046
+ this._storage.setItem(Gt, e);
3047
+ }
3048
+ updateProviderInfo(e, n) {
3049
+ var s;
3050
+ this.jsonRpcUrl = e;
3051
+ const r = this.getChainId();
3052
+ this._storage.setItem(Zt, n.toString(10)), fe(n) !== r && ((s = this.callback) === null || s === void 0 || s.call(this, "chainChanged", ne(n)));
3053
+ }
3054
+ async watchAsset(e) {
3055
+ const n = Array.isArray(e) ? e[0] : e;
3056
+ if (!n.type)
3057
+ throw L.rpc.invalidParams("Type is required");
3058
+ if ((n == null ? void 0 : n.type) !== "ERC20")
3059
+ throw L.rpc.invalidParams(`Asset of type '${n.type}' is not supported`);
3060
+ if (!(n != null && n.options))
3061
+ throw L.rpc.invalidParams("Options are required");
3062
+ if (!(n != null && n.options.address))
3063
+ throw L.rpc.invalidParams("Address is required");
3064
+ const s = this.getChainId(), { address: r, symbol: i, image: a, decimals: l } = n.options, d = await this.initializeRelay().watchAsset(n.type, r, i, l, a, s == null ? void 0 : s.toString());
3065
+ return K(d) ? !1 : !!d.result;
3066
+ }
3067
+ async addEthereumChain(e) {
3068
+ var n, s;
3069
+ const r = e[0];
3070
+ if (((n = r.rpcUrls) === null || n === void 0 ? void 0 : n.length) === 0)
3071
+ throw L.rpc.invalidParams("please pass in at least 1 rpcUrl");
3072
+ if (!r.chainName || r.chainName.trim() === "")
3073
+ throw L.rpc.invalidParams("chainName is a required field");
3074
+ if (!r.nativeCurrency)
3075
+ throw L.rpc.invalidParams("nativeCurrency is a required field");
3076
+ const i = Number.parseInt(r.chainId, 16);
3077
+ if (i === this.getChainId())
3078
+ return !1;
3079
+ const a = this.initializeRelay(), { rpcUrls: l = [], blockExplorerUrls: u = [], chainName: d, iconUrls: p = [], nativeCurrency: g } = r, o = await a.addEthereumChain(i.toString(), l, p, u, d, g);
3080
+ if (K(o))
3081
+ return !1;
3082
+ if (((s = o.result) === null || s === void 0 ? void 0 : s.isApproved) === !0)
3083
+ return this.updateProviderInfo(l[0], i), null;
3084
+ throw L.rpc.internal("unable to add ethereum chain");
3085
+ }
3086
+ async switchEthereumChain(e) {
3087
+ const n = e[0], s = Number.parseInt(n.chainId, 16), i = await this.initializeRelay().switchEthereumChain(s.toString(10), this.selectedAddress || void 0);
3088
+ if (K(i))
3089
+ throw i;
3090
+ const a = i.result;
3091
+ return a.isApproved && a.rpcUrl.length > 0 && this.updateProviderInfo(a.rpcUrl, s), null;
3092
+ }
3093
+ async cleanup() {
3094
+ this.callback = null, this._relay && this._relay.resetAndReload(), this._storage.clear();
3095
+ }
3096
+ _setAddresses(e, n) {
3097
+ var s;
3098
+ if (!Array.isArray(e))
3099
+ throw new Error("addresses is not an array");
3100
+ const r = e.map((i) => ee(i));
3101
+ JSON.stringify(r) !== JSON.stringify(this._addresses) && (this._addresses = r, (s = this.callback) === null || s === void 0 || s.call(this, "accountsChanged", r), this._storage.setItem(Ge, r.join(" ")));
3102
+ }
3103
+ async request(e) {
3104
+ const n = e.params || [];
3105
+ switch (e.method) {
3106
+ case "eth_accounts":
3107
+ return [...this._addresses];
3108
+ case "eth_coinbase":
3109
+ return this.selectedAddress || null;
3110
+ case "net_version":
3111
+ return this.getChainId().toString(10);
3112
+ case "eth_chainId":
3113
+ return ne(this.getChainId());
3114
+ case "eth_requestAccounts":
3115
+ return this._eth_requestAccounts();
3116
+ case "eth_ecRecover":
3117
+ case "personal_ecRecover":
3118
+ return this.ecRecover(e);
3119
+ case "personal_sign":
3120
+ return this.personalSign(e);
3121
+ case "eth_signTransaction":
3122
+ return this._eth_signTransaction(n);
3123
+ case "eth_sendRawTransaction":
3124
+ return this._eth_sendRawTransaction(n);
3125
+ case "eth_sendTransaction":
3126
+ return this._eth_sendTransaction(n);
3127
+ case "eth_signTypedData_v1":
3128
+ case "eth_signTypedData_v3":
3129
+ case "eth_signTypedData_v4":
3130
+ case "eth_signTypedData":
3131
+ return this.signTypedData(e);
3132
+ case "wallet_addEthereumChain":
3133
+ return this.addEthereumChain(n);
3134
+ case "wallet_switchEthereumChain":
3135
+ return this.switchEthereumChain(n);
3136
+ case "wallet_watchAsset":
3137
+ return this.watchAsset(n);
3138
+ default:
3139
+ if (!this.jsonRpcUrl)
3140
+ throw L.rpc.internal("No RPC URL set for chain");
3141
+ return at(e, this.jsonRpcUrl);
3142
+ }
3143
+ }
3144
+ _ensureKnownAddress(e) {
3145
+ const n = ee(e);
3146
+ if (!this._addresses.map((r) => ee(r)).includes(n))
3147
+ throw new Error("Unknown Ethereum address");
3148
+ }
3149
+ _prepareTransactionParams(e) {
3150
+ const n = e.from ? ee(e.from) : this.selectedAddress;
3151
+ if (!n)
3152
+ throw new Error("Ethereum address is unavailable");
3153
+ this._ensureKnownAddress(n);
3154
+ const s = e.to ? ee(e.to) : null, r = e.value != null ? de(e.value) : BigInt(0), i = e.data ? Ze(e.data) : Buffer.alloc(0), a = e.nonce != null ? fe(e.nonce) : null, l = e.gasPrice != null ? de(e.gasPrice) : null, u = e.maxFeePerGas != null ? de(e.maxFeePerGas) : null, d = e.maxPriorityFeePerGas != null ? de(e.maxPriorityFeePerGas) : null, p = e.gas != null ? de(e.gas) : null, g = e.chainId ? fe(e.chainId) : this.getChainId();
3155
+ return {
3156
+ fromAddress: n,
3157
+ toAddress: s,
3158
+ weiValue: r,
3159
+ data: i,
3160
+ nonce: a,
3161
+ gasPriceInWei: l,
3162
+ maxFeePerGas: u,
3163
+ maxPriorityFeePerGas: d,
3164
+ gasLimit: p,
3165
+ chainId: g
3166
+ };
3167
+ }
3168
+ async ecRecover(e) {
3169
+ const { method: n, params: s } = e;
3170
+ if (!Array.isArray(s))
3171
+ throw L.rpc.invalidParams();
3172
+ const i = await this.initializeRelay().sendRequest({
3173
+ method: "ethereumAddressFromSignedMessage",
3174
+ params: {
3175
+ message: Ne(s[0]),
3176
+ signature: Ne(s[1]),
3177
+ addPrefix: n === "personal_ecRecover"
3178
+ }
3179
+ });
3180
+ if (K(i))
3181
+ throw i;
3182
+ return i.result;
3183
+ }
3184
+ getChainId() {
3185
+ var e;
3186
+ return Number.parseInt((e = this._storage.getItem(Zt)) !== null && e !== void 0 ? e : "1", 10);
3187
+ }
3188
+ async _eth_requestAccounts() {
3189
+ var e, n;
3190
+ if (this._addresses.length > 0)
3191
+ return (e = this.callback) === null || e === void 0 || e.call(this, "connect", { chainId: ne(this.getChainId()) }), this._addresses;
3192
+ const r = await this.initializeRelay().requestEthereumAccounts();
3193
+ if (K(r))
3194
+ throw r;
3195
+ if (!r.result)
3196
+ throw new Error("accounts received is empty");
3197
+ return this._setAddresses(r.result), (n = this.callback) === null || n === void 0 || n.call(this, "connect", { chainId: ne(this.getChainId()) }), this._addresses;
3198
+ }
3199
+ async personalSign({ params: e }) {
3200
+ if (!Array.isArray(e))
3201
+ throw L.rpc.invalidParams();
3202
+ const n = e[1], s = e[0];
3203
+ this._ensureKnownAddress(n);
3204
+ const i = await this.initializeRelay().sendRequest({
3205
+ method: "signEthereumMessage",
3206
+ params: {
3207
+ address: ee(n),
3208
+ message: Ne(s),
3209
+ addPrefix: !0,
3210
+ typedDataJson: null
3211
+ }
3212
+ });
3213
+ if (K(i))
3214
+ throw i;
3215
+ return i.result;
3216
+ }
3217
+ async _eth_signTransaction(e) {
3218
+ const n = this._prepareTransactionParams(e[0] || {}), r = await this.initializeRelay().signEthereumTransaction(n);
3219
+ if (K(r))
3220
+ throw r;
3221
+ return r.result;
3222
+ }
3223
+ async _eth_sendRawTransaction(e) {
3224
+ const n = Ze(e[0]), r = await this.initializeRelay().submitEthereumTransaction(n, this.getChainId());
3225
+ if (K(r))
3226
+ throw r;
3227
+ return r.result;
3228
+ }
3229
+ async _eth_sendTransaction(e) {
3230
+ const n = this._prepareTransactionParams(e[0] || {}), r = await this.initializeRelay().signAndSubmitEthereumTransaction(n);
3231
+ if (K(r))
3232
+ throw r;
3233
+ return r.result;
3234
+ }
3235
+ async signTypedData(e) {
3236
+ const { method: n, params: s } = e;
3237
+ if (!Array.isArray(s))
3238
+ throw L.rpc.invalidParams();
3239
+ const r = (d) => {
3240
+ const p = {
3241
+ eth_signTypedData_v1: ye.hashForSignTypedDataLegacy,
3242
+ eth_signTypedData_v3: ye.hashForSignTypedData_v3,
3243
+ eth_signTypedData_v4: ye.hashForSignTypedData_v4,
3244
+ eth_signTypedData: ye.hashForSignTypedData_v4
3245
+ };
3246
+ return he(p[n]({
3247
+ data: Xn(d)
3248
+ }), !0);
3249
+ }, i = s[n === "eth_signTypedData_v1" ? 1 : 0], a = s[n === "eth_signTypedData_v1" ? 0 : 1];
3250
+ this._ensureKnownAddress(i);
3251
+ const u = await this.initializeRelay().sendRequest({
3252
+ method: "signEthereumMessage",
3253
+ params: {
3254
+ address: ee(i),
3255
+ message: r(a),
3256
+ typedDataJson: JSON.stringify(a, null, 2),
3257
+ addPrefix: !1
3258
+ }
3259
+ });
3260
+ if (K(u))
3261
+ throw u;
3262
+ return u.result;
3263
+ }
3264
+ initializeRelay() {
3265
+ return this._relay || (this._relay = new Q({
3266
+ linkAPIUrl: zt,
3267
+ storage: this._storage,
3268
+ metadata: this.metadata,
3269
+ accountsCallback: this._setAddresses.bind(this),
3270
+ chainCallback: this.updateProviderInfo.bind(this)
3271
+ })), this._relay;
3272
+ }
3273
+ }
3274
+ const Nn = "SignerType", Dn = new Y("CBWSDK", "SignerConfigurator");
3275
+ function ti() {
3276
+ return Dn.getItem(Nn);
3277
+ }
3278
+ function ni(t) {
3279
+ Dn.setItem(Nn, t);
3280
+ }
3281
+ async function si(t) {
3282
+ const { communicator: e, metadata: n, handshakeRequest: s, callback: r } = t;
3283
+ ri(e, n, r).catch(() => {
3284
+ });
3285
+ const i = {
3286
+ id: crypto.randomUUID(),
3287
+ event: "selectSignerType",
3288
+ data: Object.assign(Object.assign({}, t.preference), { handshakeRequest: s })
3289
+ }, { data: a } = await e.postRequestAndWaitForResponse(i);
3290
+ return a;
3291
+ }
3292
+ function ii(t) {
3293
+ const { signerType: e, metadata: n, communicator: s, callback: r } = t;
3294
+ switch (e) {
3295
+ case "scw":
3296
+ return new ps({
3297
+ metadata: n,
3298
+ callback: r,
3299
+ communicator: s
3300
+ });
3301
+ case "walletlink":
3302
+ return new On({
3303
+ metadata: n,
3304
+ callback: r
3305
+ });
3306
+ }
3307
+ }
3308
+ async function ri(t, e, n) {
3309
+ await t.onMessage(({ event: r }) => r === "WalletLinkSessionRequest");
3310
+ const s = new On({
3311
+ metadata: e,
3312
+ callback: n
3313
+ });
3314
+ t.postMessage({
3315
+ event: "WalletLinkUpdate",
3316
+ data: { session: s.getSession() }
3317
+ }), await s.handshake(), t.postMessage({
3318
+ event: "WalletLinkUpdate",
3319
+ data: { connected: !0 }
3320
+ });
3321
+ }
3322
+ const ai = `Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.
3323
+
3324
+ Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`, oi = () => {
3325
+ let t;
3326
+ return {
3327
+ getCrossOriginOpenerPolicy: () => t === void 0 ? "undefined" : t,
3328
+ checkCrossOriginOpenerPolicy: async () => {
3329
+ if (typeof window > "u") {
3330
+ t = "non-browser-env";
3331
+ return;
3332
+ }
3333
+ try {
3334
+ const e = `${window.location.origin}${window.location.pathname}`, n = await fetch(e, {
3335
+ method: "HEAD"
3336
+ });
3337
+ if (!n.ok)
3338
+ throw new Error(`HTTP error! status: ${n.status}`);
3339
+ const s = n.headers.get("Cross-Origin-Opener-Policy");
3340
+ t = s ?? "null", t === "same-origin" && console.error(ai);
3341
+ } catch (e) {
3342
+ console.error("Error checking Cross-Origin-Opener-Policy:", e.message), t = "error";
3343
+ }
3344
+ }
3345
+ };
3346
+ }, { checkCrossOriginOpenerPolicy: ci, getCrossOriginOpenerPolicy: li } = oi(), Yt = 420, Jt = 540, di = {
3347
+ isRed: !1,
3348
+ info: "Retry",
3349
+ svgWidth: "10",
3350
+ svgHeight: "11",
3351
+ path: Tn,
3352
+ defaultFillRule: "evenodd",
3353
+ defaultClipRule: "evenodd"
3354
+ }, ui = "Popup was blocked. Try again.";
3355
+ let be = null;
3356
+ function hi(t) {
3357
+ const e = (window.innerWidth - Yt) / 2 + window.screenX, n = (window.innerHeight - Jt) / 2 + window.screenY;
3358
+ pi(t);
3359
+ function s() {
3360
+ const i = `wallet_${crypto.randomUUID()}`, a = window.open(t, i, `width=${Yt}, height=${Jt}, left=${e}, top=${n}`);
3361
+ return a == null || a.focus(), a || null;
3362
+ }
3363
+ let r = s();
3364
+ if (!r) {
3365
+ const i = gi();
3366
+ return new Promise((a, l) => {
3367
+ i.presentItem({
3368
+ autoExpand: !0,
3369
+ message: ui,
3370
+ menuItems: [
3371
+ Object.assign(Object.assign({}, di), { onClick: () => {
3372
+ r = s(), r ? a(r) : l(L.rpc.internal("Popup window was blocked")), i.clear();
3373
+ } })
3374
+ ]
3375
+ });
3376
+ });
3377
+ }
3378
+ return Promise.resolve(r);
3379
+ }
3380
+ function fi(t) {
3381
+ t && !t.closed && t.close();
3382
+ }
3383
+ function pi(t) {
3384
+ const e = {
3385
+ sdkName: hn,
3386
+ sdkVersion: me,
3387
+ origin: window.location.origin,
3388
+ coop: li()
3389
+ };
3390
+ for (const [n, s] of Object.entries(e))
3391
+ t.searchParams.append(n, s.toString());
3392
+ }
3393
+ function gi() {
3394
+ if (!be) {
3395
+ const t = document.createElement("div");
3396
+ t.className = "-cbwsdk-css-reset", document.body.appendChild(t), be = new Pn(), be.attach(t);
3397
+ }
3398
+ return be;
3399
+ }
3400
+ class _i {
3401
+ constructor({ url: e = Qs, metadata: n, preference: s }) {
3402
+ this.popup = null, this.listeners = /* @__PURE__ */ new Map(), this.postMessage = async (r) => {
3403
+ (await this.waitForPopupLoaded()).postMessage(r, this.url.origin);
3404
+ }, this.postRequestAndWaitForResponse = async (r) => {
3405
+ const i = this.onMessage(({ requestId: a }) => a === r.id);
3406
+ return this.postMessage(r), await i;
3407
+ }, this.onMessage = async (r) => new Promise((i, a) => {
3408
+ const l = (u) => {
3409
+ if (u.origin !== this.url.origin)
3410
+ return;
3411
+ const d = u.data;
3412
+ r(d) && (i(d), window.removeEventListener("message", l), this.listeners.delete(l));
3413
+ };
3414
+ window.addEventListener("message", l), this.listeners.set(l, { reject: a });
3415
+ }), this.disconnect = () => {
3416
+ fi(this.popup), this.popup = null, this.listeners.forEach(({ reject: r }, i) => {
3417
+ r(L.provider.userRejectedRequest("Request rejected")), window.removeEventListener("message", i);
3418
+ }), this.listeners.clear();
3419
+ }, this.waitForPopupLoaded = async () => this.popup && !this.popup.closed ? (this.popup.focus(), this.popup) : (this.popup = await hi(this.url), this.onMessage(({ event: r }) => r === "PopupUnload").then(this.disconnect).catch(() => {
3420
+ }), this.onMessage(({ event: r }) => r === "PopupLoaded").then((r) => {
3421
+ this.postMessage({
3422
+ requestId: r.id,
3423
+ data: {
3424
+ version: me,
3425
+ metadata: this.metadata,
3426
+ preference: this.preference,
3427
+ location: window.location.toString()
3428
+ }
3429
+ });
3430
+ }).then(() => {
3431
+ if (!this.popup)
3432
+ throw L.rpc.internal();
3433
+ return this.popup;
3434
+ })), this.url = new URL(e), this.metadata = n, this.preference = s;
3435
+ }
3436
+ }
3437
+ function mi(t) {
3438
+ const e = Zn(yi(t), {
3439
+ shouldIncludeStack: !0
3440
+ }), n = new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");
3441
+ return n.searchParams.set("version", me), n.searchParams.set("code", e.code.toString()), n.searchParams.set("message", e.message), Object.assign(Object.assign({}, e), { docUrl: n.href });
3442
+ }
3443
+ function yi(t) {
3444
+ var e;
3445
+ if (typeof t == "string")
3446
+ return {
3447
+ message: t,
3448
+ code: U.rpc.internal
3449
+ };
3450
+ if (K(t)) {
3451
+ const n = t.errorMessage, s = (e = t.errorCode) !== null && e !== void 0 ? e : n.match(/(denied|rejected)/i) ? U.provider.userRejectedRequest : void 0;
3452
+ return Object.assign(Object.assign({}, t), {
3453
+ message: n,
3454
+ code: s,
3455
+ data: { method: t.method }
3456
+ });
3457
+ }
3458
+ return t;
3459
+ }
3460
+ class wi extends Vn {
3461
+ }
3462
+ var bi = function(t, e) {
3463
+ var n = {};
3464
+ for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && e.indexOf(s) < 0 && (n[s] = t[s]);
3465
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
3466
+ for (var r = 0, s = Object.getOwnPropertySymbols(t); r < s.length; r++)
3467
+ e.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, s[r]) && (n[s[r]] = t[s[r]]);
3468
+ return n;
3469
+ };
3470
+ class vi extends wi {
3471
+ constructor(e) {
3472
+ var { metadata: n } = e, s = e.preference, { keysUrl: r } = s, i = bi(s, ["keysUrl"]);
3473
+ super(), this.signer = null, this.isCoinbaseWallet = !0, this.metadata = n, this.preference = i, this.communicator = new _i({
3474
+ url: r,
3475
+ metadata: n,
3476
+ preference: i
3477
+ });
3478
+ const a = ti();
3479
+ a && (this.signer = this.initSigner(a));
3480
+ }
3481
+ async request(e) {
3482
+ try {
3483
+ if (fs(e), !this.signer)
3484
+ switch (e.method) {
3485
+ case "eth_requestAccounts": {
3486
+ const n = await this.requestSignerSelection(e), s = this.initSigner(n);
3487
+ await s.handshake(e), this.signer = s, ni(n);
3488
+ break;
3489
+ }
3490
+ case "wallet_sendCalls": {
3491
+ const n = this.initSigner("scw");
3492
+ await n.handshake({ method: "handshake" });
3493
+ const s = await n.request(e);
3494
+ return await n.cleanup(), s;
3495
+ }
3496
+ case "wallet_getCallsStatus":
3497
+ return at(e, Xs);
3498
+ case "net_version":
3499
+ return 1;
3500
+ // default value
3501
+ case "eth_chainId":
3502
+ return ne(1);
3503
+ // default value
3504
+ default:
3505
+ throw L.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");
3506
+ }
3507
+ return await this.signer.request(e);
3508
+ } catch (n) {
3509
+ const { code: s } = n;
3510
+ return s === U.provider.unauthorized && this.disconnect(), Promise.reject(mi(n));
3511
+ }
3512
+ }
3513
+ /** @deprecated Use `.request({ method: 'eth_requestAccounts' })` instead. */
3514
+ async enable() {
3515
+ return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'), await this.request({
3516
+ method: "eth_requestAccounts"
3517
+ });
3518
+ }
3519
+ async disconnect() {
3520
+ var e;
3521
+ await ((e = this.signer) === null || e === void 0 ? void 0 : e.cleanup()), this.signer = null, Y.clearAll(), this.emit("disconnect", L.provider.disconnected("User initiated disconnection"));
3522
+ }
3523
+ requestSignerSelection(e) {
3524
+ return si({
3525
+ communicator: this.communicator,
3526
+ preference: this.preference,
3527
+ metadata: this.metadata,
3528
+ handshakeRequest: e,
3529
+ callback: this.emit.bind(this)
3530
+ });
3531
+ }
3532
+ initSigner(e) {
3533
+ return ii({
3534
+ signerType: e,
3535
+ metadata: this.metadata,
3536
+ communicator: this.communicator,
3537
+ callback: this.emit.bind(this)
3538
+ });
3539
+ }
3540
+ }
3541
+ function ki(t) {
3542
+ if (t) {
3543
+ if (!["all", "smartWalletOnly", "eoaOnly"].includes(t.options))
3544
+ throw new Error(`Invalid options: ${t.options}`);
3545
+ if (t.attribution && t.attribution.auto !== void 0 && t.attribution.dataSuffix !== void 0)
3546
+ throw new Error("Attribution cannot contain both auto and dataSuffix properties");
3547
+ }
3548
+ }
3549
+ class Ii {
3550
+ constructor(e) {
3551
+ this.metadata = {
3552
+ appName: e.appName || "Dapp",
3553
+ appLogoUrl: e.appLogoUrl || ts(),
3554
+ appChainIds: e.appChainIds || []
3555
+ }, this.storeLatestVersion(), ci();
3556
+ }
3557
+ makeWeb3Provider(e = { options: "all" }) {
3558
+ var n;
3559
+ ki(e);
3560
+ const s = { metadata: this.metadata, preference: e };
3561
+ return (n = hs(s)) !== null && n !== void 0 ? n : new vi(s);
3562
+ }
3563
+ /**
3564
+ * Official Coinbase Wallet logo for developers to use on their frontend
3565
+ * @param type Type of wallet logo: "standard" | "circle" | "text" | "textWithLogo" | "textLight" | "textWithLogoLight"
3566
+ * @param width Width of the logo (Optional)
3567
+ * @returns SVG Data URI
3568
+ */
3569
+ getCoinbaseWalletLogo(e, n = 240) {
3570
+ return Fn(e, n);
3571
+ }
3572
+ storeLatestVersion() {
3573
+ new Y("CBWSDK").setItem("VERSION", me);
3574
+ }
3575
+ }
3576
+ export {
3577
+ Ii as CoinbaseWalletSDK,
3578
+ Ii as default
3579
+ };