import { S as SvelteComponent, i as init, s as safe_not_equal, k as element, l as claim_element, m as children, h as detach, n as attr, b as insert_hydration, f as transition_in, g as group_outros, d as check_outros, t as transition_out, K as destroy_each, a as space, q as text, c as claim_space, r as claim_text, E as src_url_equal, F as append_hydration, G as listen, u as set_data, x as create_component, y as claim_component, z as mount_component, A as destroy_component, L as run_all, X as component_subscribe, Y as is_function, C as noop, e as empty, Z as head_selector, p as set_style } from "./index-2a025a89.js"; import { a as animateText, S as SvelteMarkdown, b as animateSection } from "./helpers-88229792.js"; import { l as client$1, w as writable } from "./singletons-286ffebd.js"; import { _ as __vitePreload } from "./preload-helper-f8376bb0.js"; var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; } function getAugmentedNamespace(n2) { if (n2.__esModule) return n2; var f2 = n2.default; if (typeof f2 == "function") { var a2 = function a3() { if (this instanceof a3) { var args = [null]; args.push.apply(args, arguments); var Ctor = Function.bind.apply(f2, args); return new Ctor(); } return f2.apply(this, arguments); }; a2.prototype = f2.prototype; } else a2 = {}; Object.defineProperty(a2, "__esModule", { value: true }); Object.keys(n2).forEach(function(k2) { var d2 = Object.getOwnPropertyDescriptor(n2, k2); Object.defineProperty(a2, k2, d2.get ? d2 : { enumerable: true, get: function() { return n2[k2]; } }); }); return a2; } function get_each_context$2(ctx, list, i2) { const child_ctx = ctx.slice(); child_ctx[5] = list[i2]; return child_ctx; } function create_if_block_2$2(ctx) { let a2; let t_value = ( /*item*/ (ctx[5].linkText || "link") + "" ); let t2; let a_href_value; return { c() { a2 = element("a"); t2 = text(t_value); this.h(); }, l(nodes) { a2 = claim_element(nodes, "A", { href: true, class: true, target: true }); var a_nodes = children(a2); t2 = claim_text(a_nodes, t_value); a_nodes.forEach(detach); this.h(); }, h() { attr(a2, "href", a_href_value = /*item*/ ctx[5].link); attr(a2, "class", "hover:underline animate-speaker"); attr(a2, "target", "_blank"); }, m(target, anchor) { insert_hydration(target, a2, anchor); append_hydration(a2, t2); }, p(ctx2, dirty) { if (dirty & /*items*/ 1 && t_value !== (t_value = /*item*/ (ctx2[5].linkText || "link") + "")) set_data(t2, t_value); if (dirty & /*items*/ 1 && a_href_value !== (a_href_value = /*item*/ ctx2[5].link)) { attr(a2, "href", a_href_value); } }, d(detaching) { if (detaching) detach(a2); } }; } function create_if_block_1$2(ctx) { let a2; let t0; let t1_value = ( /*item*/ ctx[5].twitter + "" ); let t1; let a_href_value; return { c() { a2 = element("a"); t0 = text("@"); t1 = text(t1_value); this.h(); }, l(nodes) { a2 = claim_element(nodes, "A", { href: true, class: true, target: true }); var a_nodes = children(a2); t0 = claim_text(a_nodes, "@"); t1 = claim_text(a_nodes, t1_value); a_nodes.forEach(detach); this.h(); }, h() { attr(a2, "href", a_href_value = twitterLink( /*item*/ ctx[5].twitter )); attr(a2, "class", "hover:underline animate-speaker"); attr(a2, "target", "_blank"); }, m(target, anchor) { insert_hydration(target, a2, anchor); append_hydration(a2, t0); append_hydration(a2, t1); }, p(ctx2, dirty) { if (dirty & /*items*/ 1 && t1_value !== (t1_value = /*item*/ ctx2[5].twitter + "")) set_data(t1, t1_value); if (dirty & /*items*/ 1 && a_href_value !== (a_href_value = twitterLink( /*item*/ ctx2[5].twitter ))) { attr(a2, "href", a_href_value); } }, d(detaching) { if (detaching) detach(a2); } }; } function create_if_block$2(ctx) { let div; let sveltemarkdown; let current; sveltemarkdown = new SvelteMarkdown({ props: { source: ( /*item*/ ctx[5].caption ) } }); return { c() { div = element("div"); create_component(sveltemarkdown.$$.fragment); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); claim_component(sveltemarkdown.$$.fragment, div_nodes); div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "mt-2 text-sm text-supermild markdown-basic"); }, m(target, anchor) { insert_hydration(target, div, anchor); mount_component(sveltemarkdown, div, null); current = true; }, p(ctx2, dirty) { const sveltemarkdown_changes = {}; if (dirty & /*items*/ 1) sveltemarkdown_changes.source = /*item*/ ctx2[5].caption; sveltemarkdown.$set(sveltemarkdown_changes); }, i(local) { if (current) return; transition_in(sveltemarkdown.$$.fragment, local); current = true; }, o(local) { transition_out(sveltemarkdown.$$.fragment, local); current = false; }, d(detaching) { if (detaching) detach(div); destroy_component(sveltemarkdown); } }; } function create_each_block$2(ctx) { let div4; let div0; let img; let img_src_value; let t0; let div3; let div1; let t1_value = ( /*item*/ ctx[5].name.toUpperCase() + "" ); let t1; let t2; let div2; let t3; let t4; let current; let mounted; let dispose; function select_block_type(ctx2, dirty) { if ( /*item*/ ctx2[5].twitter ) return create_if_block_1$2; if ( /*item*/ ctx2[5].link ) return create_if_block_2$2; } let current_block_type = select_block_type(ctx); let if_block0 = current_block_type && current_block_type(ctx); let if_block1 = ( /*item*/ ctx[5].caption && create_if_block$2(ctx) ); return { c() { div4 = element("div"); div0 = element("div"); img = element("img"); t0 = space(); div3 = element("div"); div1 = element("div"); t1 = text(t1_value); t2 = space(); div2 = element("div"); if (if_block0) if_block0.c(); t3 = space(); if (if_block1) if_block1.c(); t4 = space(); this.h(); }, l(nodes) { div4 = claim_element(nodes, "DIV", { class: true }); var div4_nodes = children(div4); div0 = claim_element(div4_nodes, "DIV", {}); var div0_nodes = children(div0); img = claim_element(div0_nodes, "IMG", { src: true, class: true }); div0_nodes.forEach(detach); t0 = claim_space(div4_nodes); div3 = claim_element(div4_nodes, "DIV", { class: true }); var div3_nodes = children(div3); div1 = claim_element(div3_nodes, "DIV", { class: true }); var div1_nodes = children(div1); t1 = claim_text(div1_nodes, t1_value); div1_nodes.forEach(detach); t2 = claim_space(div3_nodes); div2 = claim_element(div3_nodes, "DIV", { class: true }); var div2_nodes = children(div2); if (if_block0) if_block0.l(div2_nodes); div2_nodes.forEach(detach); t3 = claim_space(div3_nodes); if (if_block1) if_block1.l(div3_nodes); div3_nodes.forEach(detach); t4 = claim_space(div4_nodes); div4_nodes.forEach(detach); this.h(); }, h() { if (!src_url_equal(img.src, img_src_value = "/people/" + /*item*/ ctx[5].img)) attr(img, "src", img_src_value); attr(img, "class", "grayscale invert aspect-square object-cover w-full"); attr(div1, "class", "mt-4 speaker-name animate-speaker font-mono2"); attr(div2, "class", "text-mild"); attr(div3, "class", "pb-4 px-4"); attr(div4, "class", "hover:bg-white hover:text-black person-item border border-white/30"); }, m(target, anchor) { insert_hydration(target, div4, anchor); append_hydration(div4, div0); append_hydration(div0, img); append_hydration(div4, t0); append_hydration(div4, div3); append_hydration(div3, div1); append_hydration(div1, t1); append_hydration(div3, t2); append_hydration(div3, div2); if (if_block0) if_block0.m(div2, null); append_hydration(div3, t3); if (if_block1) if_block1.m(div3, null); append_hydration(div4, t4); current = true; if (!mounted) { dispose = listen( div4, "mouseenter", /*animateSpeaker*/ ctx[2] ); mounted = true; } }, p(ctx2, dirty) { if (!current || dirty & /*items*/ 1 && !src_url_equal(img.src, img_src_value = "/people/" + /*item*/ ctx2[5].img)) { attr(img, "src", img_src_value); } if ((!current || dirty & /*items*/ 1) && t1_value !== (t1_value = /*item*/ ctx2[5].name.toUpperCase() + "")) set_data(t1, t1_value); if (current_block_type === (current_block_type = select_block_type(ctx2)) && if_block0) { if_block0.p(ctx2, dirty); } else { if (if_block0) if_block0.d(1); if_block0 = current_block_type && current_block_type(ctx2); if (if_block0) { if_block0.c(); if_block0.m(div2, null); } } if ( /*item*/ ctx2[5].caption ) { if (if_block1) { if_block1.p(ctx2, dirty); if (dirty & /*items*/ 1) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$2(ctx2); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div3, null); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block1); current = true; }, o(local) { transition_out(if_block1); current = false; }, d(detaching) { if (detaching) detach(div4); if (if_block0) { if_block0.d(); } if (if_block1) if_block1.d(); mounted = false; dispose(); } }; } function create_fragment$2(ctx) { let div; let current; let each_value = ( /*items*/ ctx[0].map( /*getPerson*/ ctx[1] ) ); let each_blocks = []; for (let i2 = 0; i2 < each_value.length; i2 += 1) { each_blocks[i2] = create_each_block$2(get_each_context$2(ctx, each_value, i2)); } const out = (i2) => transition_out(each_blocks[i2], 1, 1, () => { each_blocks[i2] = null; }); return { c() { div = element("div"); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].c(); } this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].l(div_nodes); } div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "grid gap-4 grid-cols-2 md:grid-cols-3 lg:grid-cols-5"); }, m(target, anchor) { insert_hydration(target, div, anchor); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].m(div, null); } current = true; }, p(ctx2, [dirty]) { if (dirty & /*animateSpeaker, items, getPerson, twitterLink*/ 7) { each_value = /*items*/ ctx2[0].map( /*getPerson*/ ctx2[1] ); let i2; for (i2 = 0; i2 < each_value.length; i2 += 1) { const child_ctx = get_each_context$2(ctx2, each_value, i2); if (each_blocks[i2]) { each_blocks[i2].p(child_ctx, dirty); transition_in(each_blocks[i2], 1); } else { each_blocks[i2] = create_each_block$2(child_ctx); each_blocks[i2].c(); transition_in(each_blocks[i2], 1); each_blocks[i2].m(div, null); } } group_outros(); for (i2 = each_value.length; i2 < each_blocks.length; i2 += 1) { out(i2); } check_outros(); } }, i(local) { if (current) return; for (let i2 = 0; i2 < each_value.length; i2 += 1) { transition_in(each_blocks[i2]); } current = true; }, o(local) { each_blocks = each_blocks.filter(Boolean); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { transition_out(each_blocks[i2]); } current = false; }, d(detaching) { if (detaching) detach(div); destroy_each(each_blocks, detaching); } }; } function twitterLink(handle) { return `https://twitter.com/${handle}`; } function instance$2($$self, $$props, $$invalidate) { let { items } = $$props; let { people } = $$props; let { size = "normal" } = $$props; function getPerson(id2) { return people.find((p2) => p2.id === id2); } function animateSpeaker(el) { for (const e of el.target.getElementsByClassName("animate-speaker")) { animateText({ target: e }); } } $$self.$$set = ($$props2) => { if ("items" in $$props2) $$invalidate(0, items = $$props2.items); if ("people" in $$props2) $$invalidate(3, people = $$props2.people); if ("size" in $$props2) $$invalidate(4, size = $$props2.size); }; return [items, getPerson, animateSpeaker, people, size]; } class PeopleList extends SvelteComponent { constructor(options) { super(); init(this, options, instance$2, create_fragment$2, safe_not_equal, { items: 0, people: 3, size: 4 }); } } client$1.disable_scroll_handling; const goto = client$1.goto; client$1.invalidate; client$1.invalidateAll; client$1.preload_data; client$1.preload_code; client$1.before_navigate; client$1.after_navigate; var arbitrum = { id: 42161, name: "Arbitrum One", network: "arbitrum", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { alchemy: { http: ["https://arb-mainnet.g.alchemy.com/v2"], webSocket: ["wss://arb-mainnet.g.alchemy.com/v2"] }, infura: { http: ["https://arbitrum-mainnet.infura.io/v3"], webSocket: ["wss://arbitrum-mainnet.infura.io/ws/v3"] }, default: { http: ["https://arb1.arbitrum.io/rpc"] }, public: { http: ["https://arb1.arbitrum.io/rpc"] } }, blockExplorers: { etherscan: { name: "Arbiscan", url: "https://arbiscan.io" }, default: { name: "Arbiscan", url: "https://arbiscan.io" } }, contracts: { multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11", blockCreated: 7654707 } } }; var goerli = { id: 5, network: "goerli", name: "Goerli", nativeCurrency: { name: "Goerli Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { alchemy: { http: ["https://eth-goerli.g.alchemy.com/v2"], webSocket: ["wss://eth-goerli.g.alchemy.com/v2"] }, infura: { http: ["https://goerli.infura.io/v3"], webSocket: ["wss://goerli.infura.io/ws/v3"] }, default: { http: ["https://rpc.ankr.com/eth_goerli"] }, public: { http: ["https://rpc.ankr.com/eth_goerli"] } }, blockExplorers: { etherscan: { name: "Etherscan", url: "https://goerli.etherscan.io" }, default: { name: "Etherscan", url: "https://goerli.etherscan.io" } }, contracts: { ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" }, ensUniversalResolver: { address: "0x687c30Cc44bFA39A1449e86E172BF002E7b3f0b0", blockCreated: 7725078 }, multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11", blockCreated: 6507670 } }, testnet: true }; var gnosis = { id: 100, name: "Gnosis", network: "gnosis", nativeCurrency: { decimals: 18, name: "Gnosis", symbol: "xDAI" }, rpcUrls: { default: { http: ["https://rpc.gnosischain.com"] }, public: { http: ["https://rpc.gnosischain.com"] } }, blockExplorers: { etherscan: { name: "Gnosisscan", url: "https://gnosisscan.io/" }, default: { name: "Gnosis Chain Explorer", url: "https://blockscout.com/xdai/mainnet/" } } }; var mainnet = { id: 1, network: "homestead", name: "Ethereum", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { alchemy: { http: ["https://eth-mainnet.g.alchemy.com/v2"], webSocket: ["wss://eth-mainnet.g.alchemy.com/v2"] }, infura: { http: ["https://mainnet.infura.io/v3"], webSocket: ["wss://mainnet.infura.io/ws/v3"] }, default: { http: ["https://cloudflare-eth.com"] }, public: { http: ["https://cloudflare-eth.com"] } }, blockExplorers: { etherscan: { name: "Etherscan", url: "https://etherscan.io" }, default: { name: "Etherscan", url: "https://etherscan.io" } }, contracts: { ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" }, ensUniversalResolver: { address: "0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376", blockCreated: 16172161 }, multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11", blockCreated: 14353601 } } }; var optimism = { id: 10, name: "Optimism", network: "optimism", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { alchemy: { http: ["https://opt-mainnet.g.alchemy.com/v2"], webSocket: ["wss://opt-mainnet.g.alchemy.com/v2"] }, infura: { http: ["https://optimism-mainnet.infura.io/v3"], webSocket: ["wss://optimism-mainnet.infura.io/ws/v3"] }, default: { http: ["https://mainnet.optimism.io"] }, public: { http: ["https://mainnet.optimism.io"] } }, blockExplorers: { etherscan: { name: "Etherscan", url: "https://optimistic.etherscan.io" }, default: { name: "Optimism Explorer", url: "https://explorer.optimism.io" } }, contracts: { multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11", blockCreated: 4286263 } } }; var polygon = { id: 137, name: "Polygon", network: "matic", nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18 }, rpcUrls: { alchemy: { http: ["https://polygon-mainnet.g.alchemy.com/v2"], webSocket: ["wss://polygon-mainnet.g.alchemy.com/v2"] }, infura: { http: ["https://polygon-mainnet.infura.io/v3"], webSocket: ["wss://polygon-mainnet.infura.io/ws/v3"] }, default: { http: ["https://polygon-rpc.com"] }, public: { http: ["https://polygon-rpc.com"] } }, blockExplorers: { etherscan: { name: "PolygonScan", url: "https://polygonscan.com" }, default: { name: "PolygonScan", url: "https://polygonscan.com" } }, contracts: { multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11", blockCreated: 25770160 } } }; var __accessCheck$1 = (obj, member, msg) => { if (!member.has(obj)) throw TypeError("Cannot " + msg); }; var __privateGet$1 = (obj, member, getter) => { __accessCheck$1(obj, member, "read from private field"); return getter ? getter.call(obj) : member.get(obj); }; var __privateAdd$1 = (obj, member, value) => { if (member.has(obj)) throw TypeError("Cannot add the same private member more than once"); member instanceof WeakSet ? member.add(obj) : member.set(obj, value); }; var __privateSet$1 = (obj, member, value, setter) => { __accessCheck$1(obj, member, "write to private field"); setter ? setter.call(obj, value) : member.set(obj, value); return value; }; var __privateMethod$1 = (obj, member, method) => { __accessCheck$1(obj, member, "access private method"); return method; }; var eventemitter3Exports = {}; var eventemitter3 = { get exports() { return eventemitter3Exports; }, set exports(v2) { eventemitter3Exports = v2; } }; (function(module) { var has = Object.prototype.hasOwnProperty, prefix = "~"; function Events() { } if (Object.create) { Events.prototype = /* @__PURE__ */ Object.create(null); if (!new Events().__proto__) prefix = false; } function EE(fn, context, once) { this.fn = fn; this.context = context; this.once = once || false; } function addListener(emitter, event, fn, context, once) { if (typeof fn !== "function") { throw new TypeError("The listener must be a function"); } var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event; if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); else emitter._events[evt] = [emitter._events[evt], listener]; return emitter; } function clearEvent(emitter, evt) { if (--emitter._eventsCount === 0) emitter._events = new Events(); else delete emitter._events[evt]; } function EventEmitter2() { this._events = new Events(); this._eventsCount = 0; } EventEmitter2.prototype.eventNames = function eventNames() { var names2 = [], events, name; if (this._eventsCount === 0) return names2; for (name in events = this._events) { if (has.call(events, name)) names2.push(prefix ? name.slice(1) : name); } if (Object.getOwnPropertySymbols) { return names2.concat(Object.getOwnPropertySymbols(events)); } return names2; }; EventEmitter2.prototype.listeners = function listeners(event) { var evt = prefix ? prefix + event : event, handlers = this._events[evt]; if (!handlers) return []; if (handlers.fn) return [handlers.fn]; for (var i2 = 0, l2 = handlers.length, ee = new Array(l2); i2 < l2; i2++) { ee[i2] = handlers[i2].fn; } return ee; }; EventEmitter2.prototype.listenerCount = function listenerCount(event) { var evt = prefix ? prefix + event : event, listeners = this._events[evt]; if (!listeners) return 0; if (listeners.fn) return 1; return listeners.length; }; EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { var evt = prefix ? prefix + event : event; if (!this._events[evt]) return false; var listeners = this._events[evt], len = arguments.length, args, i2; if (listeners.fn) { if (listeners.once) this.removeListener(event, listeners.fn, void 0, true); switch (len) { case 1: return listeners.fn.call(listeners.context), true; case 2: return listeners.fn.call(listeners.context, a1), true; case 3: return listeners.fn.call(listeners.context, a1, a2), true; case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; } for (i2 = 1, args = new Array(len - 1); i2 < len; i2++) { args[i2 - 1] = arguments[i2]; } listeners.fn.apply(listeners.context, args); } else { var length = listeners.length, j2; for (i2 = 0; i2 < length; i2++) { if (listeners[i2].once) this.removeListener(event, listeners[i2].fn, void 0, true); switch (len) { case 1: listeners[i2].fn.call(listeners[i2].context); break; case 2: listeners[i2].fn.call(listeners[i2].context, a1); break; case 3: listeners[i2].fn.call(listeners[i2].context, a1, a2); break; case 4: listeners[i2].fn.call(listeners[i2].context, a1, a2, a3); break; default: if (!args) for (j2 = 1, args = new Array(len - 1); j2 < len; j2++) { args[j2 - 1] = arguments[j2]; } listeners[i2].fn.apply(listeners[i2].context, args); } } } return true; }; EventEmitter2.prototype.on = function on(event, fn, context) { return addListener(this, event, fn, context, false); }; EventEmitter2.prototype.once = function once(event, fn, context) { return addListener(this, event, fn, context, true); }; EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) { var evt = prefix ? prefix + event : event; if (!this._events[evt]) return this; if (!fn) { clearEvent(this, evt); return this; } var listeners = this._events[evt]; if (listeners.fn) { if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) { clearEvent(this, evt); } } else { for (var i2 = 0, events = [], length = listeners.length; i2 < length; i2++) { if (listeners[i2].fn !== fn || once && !listeners[i2].once || context && listeners[i2].context !== context) { events.push(listeners[i2]); } } if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; else clearEvent(this, evt); } return this; }; EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) { var evt; if (event) { evt = prefix ? prefix + event : event; if (this._events[evt]) clearEvent(this, evt); } else { this._events = new Events(); this._eventsCount = 0; } return this; }; EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener; EventEmitter2.prototype.addListener = EventEmitter2.prototype.on; EventEmitter2.prefixed = prefix; EventEmitter2.EventEmitter = EventEmitter2; { module.exports = EventEmitter2; } })(eventemitter3); const EventEmitter = eventemitter3Exports; var __defProp = Object.defineProperty; var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value; var __publicField = (obj, key2, value) => { __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value); return value; }; var __accessCheck = (obj, member, msg) => { if (!member.has(obj)) throw TypeError("Cannot " + msg); }; var __privateGet = (obj, member, getter) => { __accessCheck(obj, member, "read from private field"); return getter ? getter.call(obj) : member.get(obj); }; var __privateAdd = (obj, member, value) => { if (member.has(obj)) throw TypeError("Cannot add the same private member more than once"); member instanceof WeakSet ? member.add(obj) : member.set(obj, value); }; var __privateSet = (obj, member, value, setter) => { __accessCheck(obj, member, "write to private field"); setter ? setter.call(obj, value) : member.set(obj, value); return value; }; var __privateMethod = (obj, member, method) => { __accessCheck(obj, member, "access private method"); return method; }; var Connector = class extends EventEmitter { constructor({ chains = [mainnet, goerli], options }) { super(); __publicField(this, "chains"); __publicField(this, "options"); this.chains = chains; this.options = options; } getBlockExplorerUrls(chain) { const { default: blockExplorer, ...blockExplorers } = chain.blockExplorers ?? {}; if (blockExplorer) return [ blockExplorer.url, ...Object.values(blockExplorers).map((x) => x.url) ]; } isChainUnsupported(chainId) { return !this.chains.some((x) => x.id === chainId); } }; var bnExports = {}; var bn = { get exports() { return bnExports; }, set exports(v2) { bnExports = v2; } }; const __viteBrowserExternal = {}; const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: __viteBrowserExternal }, Symbol.toStringTag, { value: "Module" })); const require$$1$1 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1); (function(module) { (function(module2, exports) { function assert2(val, msg) { if (!val) throw new Error(msg || "Assertion failed"); } function inherits2(ctor, superCtor) { ctor.super_ = superCtor; var TempCtor = function() { }; TempCtor.prototype = superCtor.prototype; ctor.prototype = new TempCtor(); ctor.prototype.constructor = ctor; } function BN2(number, base2, endian) { if (BN2.isBN(number)) { return number; } this.negative = 0; this.words = null; this.length = 0; this.red = null; if (number !== null) { if (base2 === "le" || base2 === "be") { endian = base2; base2 = 10; } this._init(number || 0, base2 || 10, endian || "be"); } } if (typeof module2 === "object") { module2.exports = BN2; } else { exports.BN = BN2; } BN2.BN = BN2; BN2.wordSize = 26; var Buffer; try { if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { Buffer = window.Buffer; } else { Buffer = require$$1$1.Buffer; } } catch (e) { } BN2.isBN = function isBN(num) { if (num instanceof BN2) { return true; } return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words); }; BN2.max = function max(left, right) { if (left.cmp(right) > 0) return left; return right; }; BN2.min = function min(left, right) { if (left.cmp(right) < 0) return left; return right; }; BN2.prototype._init = function init4(number, base2, endian) { if (typeof number === "number") { return this._initNumber(number, base2, endian); } if (typeof number === "object") { return this._initArray(number, base2, endian); } if (base2 === "hex") { base2 = 16; } assert2(base2 === (base2 | 0) && base2 >= 2 && base2 <= 36); number = number.toString().replace(/\s+/g, ""); var start = 0; if (number[0] === "-") { start++; this.negative = 1; } if (start < number.length) { if (base2 === 16) { this._parseHex(number, start, endian); } else { this._parseBase(number, base2, start); if (endian === "le") { this._initArray(this.toArray(), base2, endian); } } } }; BN2.prototype._initNumber = function _initNumber(number, base2, endian) { if (number < 0) { this.negative = 1; number = -number; } if (number < 67108864) { this.words = [number & 67108863]; this.length = 1; } else if (number < 4503599627370496) { this.words = [ number & 67108863, number / 67108864 & 67108863 ]; this.length = 2; } else { assert2(number < 9007199254740992); this.words = [ number & 67108863, number / 67108864 & 67108863, 1 ]; this.length = 3; } if (endian !== "le") return; this._initArray(this.toArray(), base2, endian); }; BN2.prototype._initArray = function _initArray(number, base2, endian) { assert2(typeof number.length === "number"); if (number.length <= 0) { this.words = [0]; this.length = 1; return this; } this.length = Math.ceil(number.length / 3); this.words = new Array(this.length); for (var i2 = 0; i2 < this.length; i2++) { this.words[i2] = 0; } var j2, w; var off = 0; if (endian === "be") { for (i2 = number.length - 1, j2 = 0; i2 >= 0; i2 -= 3) { w = number[i2] | number[i2 - 1] << 8 | number[i2 - 2] << 16; this.words[j2] |= w << off & 67108863; this.words[j2 + 1] = w >>> 26 - off & 67108863; off += 24; if (off >= 26) { off -= 26; j2++; } } } else if (endian === "le") { for (i2 = 0, j2 = 0; i2 < number.length; i2 += 3) { w = number[i2] | number[i2 + 1] << 8 | number[i2 + 2] << 16; this.words[j2] |= w << off & 67108863; this.words[j2 + 1] = w >>> 26 - off & 67108863; off += 24; if (off >= 26) { off -= 26; j2++; } } } return this._strip(); }; function parseHex4Bits(string, index) { var c2 = string.charCodeAt(index); if (c2 >= 48 && c2 <= 57) { return c2 - 48; } else if (c2 >= 65 && c2 <= 70) { return c2 - 55; } else if (c2 >= 97 && c2 <= 102) { return c2 - 87; } else { assert2(false, "Invalid character in " + string); } } function parseHexByte(string, lowerBound, index) { var r2 = parseHex4Bits(string, index); if (index - 1 >= lowerBound) { r2 |= parseHex4Bits(string, index - 1) << 4; } return r2; } BN2.prototype._parseHex = function _parseHex(number, start, endian) { this.length = Math.ceil((number.length - start) / 6); this.words = new Array(this.length); for (var i2 = 0; i2 < this.length; i2++) { this.words[i2] = 0; } var off = 0; var j2 = 0; var w; if (endian === "be") { for (i2 = number.length - 1; i2 >= start; i2 -= 2) { w = parseHexByte(number, start, i2) << off; this.words[j2] |= w & 67108863; if (off >= 18) { off -= 18; j2 += 1; this.words[j2] |= w >>> 26; } else { off += 8; } } } else { var parseLength = number.length - start; for (i2 = parseLength % 2 === 0 ? start + 1 : start; i2 < number.length; i2 += 2) { w = parseHexByte(number, start, i2) << off; this.words[j2] |= w & 67108863; if (off >= 18) { off -= 18; j2 += 1; this.words[j2] |= w >>> 26; } else { off += 8; } } } this._strip(); }; function parseBase(str, start, end, mul3) { var r2 = 0; var b2 = 0; var len = Math.min(str.length, end); for (var i2 = start; i2 < len; i2++) { var c2 = str.charCodeAt(i2) - 48; r2 *= mul3; if (c2 >= 49) { b2 = c2 - 49 + 10; } else if (c2 >= 17) { b2 = c2 - 17 + 10; } else { b2 = c2; } assert2(c2 >= 0 && b2 < mul3, "Invalid character"); r2 += b2; } return r2; } BN2.prototype._parseBase = function _parseBase(number, base2, start) { this.words = [0]; this.length = 1; for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base2) { limbLen++; } limbLen--; limbPow = limbPow / base2 | 0; var total = number.length - start; var mod = total % limbLen; var end = Math.min(total, total - mod) + start; var word = 0; for (var i2 = start; i2 < end; i2 += limbLen) { word = parseBase(number, i2, i2 + limbLen, base2); this.imuln(limbPow); if (this.words[0] + word < 67108864) { this.words[0] += word; } else { this._iaddn(word); } } if (mod !== 0) { var pow = 1; word = parseBase(number, i2, number.length, base2); for (i2 = 0; i2 < mod; i2++) { pow *= base2; } this.imuln(pow); if (this.words[0] + word < 67108864) { this.words[0] += word; } else { this._iaddn(word); } } this._strip(); }; BN2.prototype.copy = function copy(dest) { dest.words = new Array(this.length); for (var i2 = 0; i2 < this.length; i2++) { dest.words[i2] = this.words[i2]; } dest.length = this.length; dest.negative = this.negative; dest.red = this.red; }; function move(dest, src) { dest.words = src.words; dest.length = src.length; dest.negative = src.negative; dest.red = src.red; } BN2.prototype._move = function _move(dest) { move(dest, this); }; BN2.prototype.clone = function clone() { var r2 = new BN2(null); this.copy(r2); return r2; }; BN2.prototype._expand = function _expand(size) { while (this.length < size) { this.words[this.length++] = 0; } return this; }; BN2.prototype._strip = function strip() { while (this.length > 1 && this.words[this.length - 1] === 0) { this.length--; } return this._normSign(); }; BN2.prototype._normSign = function _normSign() { if (this.length === 1 && this.words[0] === 0) { this.negative = 0; } return this; }; if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") { try { BN2.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect4; } catch (e) { BN2.prototype.inspect = inspect4; } } else { BN2.prototype.inspect = inspect4; } function inspect4() { return (this.red ? ""; } var zeros2 = [ "", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000" ]; var groupSizes = [ 0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ]; var groupBases = [ 0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 ]; BN2.prototype.toString = function toString(base2, padding2) { base2 = base2 || 10; padding2 = padding2 | 0 || 1; var out; if (base2 === 16 || base2 === "hex") { out = ""; var off = 0; var carry = 0; for (var i2 = 0; i2 < this.length; i2++) { var w = this.words[i2]; var word = ((w << off | carry) & 16777215).toString(16); carry = w >>> 24 - off & 16777215; off += 2; if (off >= 26) { off -= 26; i2--; } if (carry !== 0 || i2 !== this.length - 1) { out = zeros2[6 - word.length] + word + out; } else { out = word + out; } } if (carry !== 0) { out = carry.toString(16) + out; } while (out.length % padding2 !== 0) { out = "0" + out; } if (this.negative !== 0) { out = "-" + out; } return out; } if (base2 === (base2 | 0) && base2 >= 2 && base2 <= 36) { var groupSize = groupSizes[base2]; var groupBase = groupBases[base2]; out = ""; var c2 = this.clone(); c2.negative = 0; while (!c2.isZero()) { var r2 = c2.modrn(groupBase).toString(base2); c2 = c2.idivn(groupBase); if (!c2.isZero()) { out = zeros2[groupSize - r2.length] + r2 + out; } else { out = r2 + out; } } if (this.isZero()) { out = "0" + out; } while (out.length % padding2 !== 0) { out = "0" + out; } if (this.negative !== 0) { out = "-" + out; } return out; } assert2(false, "Base should be between 2 and 36"); }; BN2.prototype.toNumber = function toNumber() { var ret = this.words[0]; if (this.length === 2) { ret += this.words[1] * 67108864; } else if (this.length === 3 && this.words[2] === 1) { ret += 4503599627370496 + this.words[1] * 67108864; } else if (this.length > 2) { assert2(false, "Number can only safely store up to 53 bits"); } return this.negative !== 0 ? -ret : ret; }; BN2.prototype.toJSON = function toJSON2() { return this.toString(16, 2); }; if (Buffer) { BN2.prototype.toBuffer = function toBuffer(endian, length) { return this.toArrayLike(Buffer, endian, length); }; } BN2.prototype.toArray = function toArray2(endian, length) { return this.toArrayLike(Array, endian, length); }; var allocate = function allocate2(ArrayType, size) { if (ArrayType.allocUnsafe) { return ArrayType.allocUnsafe(size); } return new ArrayType(size); }; BN2.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) { this._strip(); var byteLength2 = this.byteLength(); var reqLength = length || Math.max(1, byteLength2); assert2(byteLength2 <= reqLength, "byte array longer than desired length"); assert2(reqLength > 0, "Requested array length <= 0"); var res = allocate(ArrayType, reqLength); var postfix = endian === "le" ? "LE" : "BE"; this["_toArrayLike" + postfix](res, byteLength2); return res; }; BN2.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength2) { var position = 0; var carry = 0; for (var i2 = 0, shift = 0; i2 < this.length; i2++) { var word = this.words[i2] << shift | carry; res[position++] = word & 255; if (position < res.length) { res[position++] = word >> 8 & 255; } if (position < res.length) { res[position++] = word >> 16 & 255; } if (shift === 6) { if (position < res.length) { res[position++] = word >> 24 & 255; } carry = 0; shift = 0; } else { carry = word >>> 24; shift += 2; } } if (position < res.length) { res[position++] = carry; while (position < res.length) { res[position++] = 0; } } }; BN2.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength2) { var position = res.length - 1; var carry = 0; for (var i2 = 0, shift = 0; i2 < this.length; i2++) { var word = this.words[i2] << shift | carry; res[position--] = word & 255; if (position >= 0) { res[position--] = word >> 8 & 255; } if (position >= 0) { res[position--] = word >> 16 & 255; } if (shift === 6) { if (position >= 0) { res[position--] = word >> 24 & 255; } carry = 0; shift = 0; } else { carry = word >>> 24; shift += 2; } } if (position >= 0) { res[position--] = carry; while (position >= 0) { res[position--] = 0; } } }; if (Math.clz32) { BN2.prototype._countBits = function _countBits(w) { return 32 - Math.clz32(w); }; } else { BN2.prototype._countBits = function _countBits(w) { var t2 = w; var r2 = 0; if (t2 >= 4096) { r2 += 13; t2 >>>= 13; } if (t2 >= 64) { r2 += 7; t2 >>>= 7; } if (t2 >= 8) { r2 += 4; t2 >>>= 4; } if (t2 >= 2) { r2 += 2; t2 >>>= 2; } return r2 + t2; }; } BN2.prototype._zeroBits = function _zeroBits(w) { if (w === 0) return 26; var t2 = w; var r2 = 0; if ((t2 & 8191) === 0) { r2 += 13; t2 >>>= 13; } if ((t2 & 127) === 0) { r2 += 7; t2 >>>= 7; } if ((t2 & 15) === 0) { r2 += 4; t2 >>>= 4; } if ((t2 & 3) === 0) { r2 += 2; t2 >>>= 2; } if ((t2 & 1) === 0) { r2++; } return r2; }; BN2.prototype.bitLength = function bitLength() { var w = this.words[this.length - 1]; var hi = this._countBits(w); return (this.length - 1) * 26 + hi; }; function toBitArray(num) { var w = new Array(num.bitLength()); for (var bit = 0; bit < w.length; bit++) { var off = bit / 26 | 0; var wbit = bit % 26; w[bit] = num.words[off] >>> wbit & 1; } return w; } BN2.prototype.zeroBits = function zeroBits() { if (this.isZero()) return 0; var r2 = 0; for (var i2 = 0; i2 < this.length; i2++) { var b2 = this._zeroBits(this.words[i2]); r2 += b2; if (b2 !== 26) break; } return r2; }; BN2.prototype.byteLength = function byteLength2() { return Math.ceil(this.bitLength() / 8); }; BN2.prototype.toTwos = function toTwos(width) { if (this.negative !== 0) { return this.abs().inotn(width).iaddn(1); } return this.clone(); }; BN2.prototype.fromTwos = function fromTwos(width) { if (this.testn(width - 1)) { return this.notn(width).iaddn(1).ineg(); } return this.clone(); }; BN2.prototype.isNeg = function isNeg() { return this.negative !== 0; }; BN2.prototype.neg = function neg3() { return this.clone().ineg(); }; BN2.prototype.ineg = function ineg() { if (!this.isZero()) { this.negative ^= 1; } return this; }; BN2.prototype.iuor = function iuor(num) { while (this.length < num.length) { this.words[this.length++] = 0; } for (var i2 = 0; i2 < num.length; i2++) { this.words[i2] = this.words[i2] | num.words[i2]; } return this._strip(); }; BN2.prototype.ior = function ior(num) { assert2((this.negative | num.negative) === 0); return this.iuor(num); }; BN2.prototype.or = function or(num) { if (this.length > num.length) return this.clone().ior(num); return num.clone().ior(this); }; BN2.prototype.uor = function uor(num) { if (this.length > num.length) return this.clone().iuor(num); return num.clone().iuor(this); }; BN2.prototype.iuand = function iuand(num) { var b2; if (this.length > num.length) { b2 = num; } else { b2 = this; } for (var i2 = 0; i2 < b2.length; i2++) { this.words[i2] = this.words[i2] & num.words[i2]; } this.length = b2.length; return this._strip(); }; BN2.prototype.iand = function iand(num) { assert2((this.negative | num.negative) === 0); return this.iuand(num); }; BN2.prototype.and = function and(num) { if (this.length > num.length) return this.clone().iand(num); return num.clone().iand(this); }; BN2.prototype.uand = function uand(num) { if (this.length > num.length) return this.clone().iuand(num); return num.clone().iuand(this); }; BN2.prototype.iuxor = function iuxor(num) { var a2; var b2; if (this.length > num.length) { a2 = this; b2 = num; } else { a2 = num; b2 = this; } for (var i2 = 0; i2 < b2.length; i2++) { this.words[i2] = a2.words[i2] ^ b2.words[i2]; } if (this !== a2) { for (; i2 < a2.length; i2++) { this.words[i2] = a2.words[i2]; } } this.length = a2.length; return this._strip(); }; BN2.prototype.ixor = function ixor(num) { assert2((this.negative | num.negative) === 0); return this.iuxor(num); }; BN2.prototype.xor = function xor(num) { if (this.length > num.length) return this.clone().ixor(num); return num.clone().ixor(this); }; BN2.prototype.uxor = function uxor(num) { if (this.length > num.length) return this.clone().iuxor(num); return num.clone().iuxor(this); }; BN2.prototype.inotn = function inotn(width) { assert2(typeof width === "number" && width >= 0); var bytesNeeded = Math.ceil(width / 26) | 0; var bitsLeft = width % 26; this._expand(bytesNeeded); if (bitsLeft > 0) { bytesNeeded--; } for (var i2 = 0; i2 < bytesNeeded; i2++) { this.words[i2] = ~this.words[i2] & 67108863; } if (bitsLeft > 0) { this.words[i2] = ~this.words[i2] & 67108863 >> 26 - bitsLeft; } return this._strip(); }; BN2.prototype.notn = function notn(width) { return this.clone().inotn(width); }; BN2.prototype.setn = function setn(bit, val) { assert2(typeof bit === "number" && bit >= 0); var off = bit / 26 | 0; var wbit = bit % 26; this._expand(off + 1); if (val) { this.words[off] = this.words[off] | 1 << wbit; } else { this.words[off] = this.words[off] & ~(1 << wbit); } return this._strip(); }; BN2.prototype.iadd = function iadd(num) { var r2; if (this.negative !== 0 && num.negative === 0) { this.negative = 0; r2 = this.isub(num); this.negative ^= 1; return this._normSign(); } else if (this.negative === 0 && num.negative !== 0) { num.negative = 0; r2 = this.isub(num); num.negative = 1; return r2._normSign(); } var a2, b2; if (this.length > num.length) { a2 = this; b2 = num; } else { a2 = num; b2 = this; } var carry = 0; for (var i2 = 0; i2 < b2.length; i2++) { r2 = (a2.words[i2] | 0) + (b2.words[i2] | 0) + carry; this.words[i2] = r2 & 67108863; carry = r2 >>> 26; } for (; carry !== 0 && i2 < a2.length; i2++) { r2 = (a2.words[i2] | 0) + carry; this.words[i2] = r2 & 67108863; carry = r2 >>> 26; } this.length = a2.length; if (carry !== 0) { this.words[this.length] = carry; this.length++; } else if (a2 !== this) { for (; i2 < a2.length; i2++) { this.words[i2] = a2.words[i2]; } } return this; }; BN2.prototype.add = function add3(num) { var res; if (num.negative !== 0 && this.negative === 0) { num.negative = 0; res = this.sub(num); num.negative ^= 1; return res; } else if (num.negative === 0 && this.negative !== 0) { this.negative = 0; res = num.sub(this); this.negative = 1; return res; } if (this.length > num.length) return this.clone().iadd(num); return num.clone().iadd(this); }; BN2.prototype.isub = function isub(num) { if (num.negative !== 0) { num.negative = 0; var r2 = this.iadd(num); num.negative = 1; return r2._normSign(); } else if (this.negative !== 0) { this.negative = 0; this.iadd(num); this.negative = 1; return this._normSign(); } var cmp = this.cmp(num); if (cmp === 0) { this.negative = 0; this.length = 1; this.words[0] = 0; return this; } var a2, b2; if (cmp > 0) { a2 = this; b2 = num; } else { a2 = num; b2 = this; } var carry = 0; for (var i2 = 0; i2 < b2.length; i2++) { r2 = (a2.words[i2] | 0) - (b2.words[i2] | 0) + carry; carry = r2 >> 26; this.words[i2] = r2 & 67108863; } for (; carry !== 0 && i2 < a2.length; i2++) { r2 = (a2.words[i2] | 0) + carry; carry = r2 >> 26; this.words[i2] = r2 & 67108863; } if (carry === 0 && i2 < a2.length && a2 !== this) { for (; i2 < a2.length; i2++) { this.words[i2] = a2.words[i2]; } } this.length = Math.max(this.length, i2); if (a2 !== this) { this.negative = 1; } return this._strip(); }; BN2.prototype.sub = function sub(num) { return this.clone().isub(num); }; function smallMulTo(self2, num, out) { out.negative = num.negative ^ self2.negative; var len = self2.length + num.length | 0; out.length = len; len = len - 1 | 0; var a2 = self2.words[0] | 0; var b2 = num.words[0] | 0; var r2 = a2 * b2; var lo = r2 & 67108863; var carry = r2 / 67108864 | 0; out.words[0] = lo; for (var k2 = 1; k2 < len; k2++) { var ncarry = carry >>> 26; var rword = carry & 67108863; var maxJ = Math.min(k2, num.length - 1); for (var j2 = Math.max(0, k2 - self2.length + 1); j2 <= maxJ; j2++) { var i2 = k2 - j2 | 0; a2 = self2.words[i2] | 0; b2 = num.words[j2] | 0; r2 = a2 * b2 + rword; ncarry += r2 / 67108864 | 0; rword = r2 & 67108863; } out.words[k2] = rword | 0; carry = ncarry | 0; } if (carry !== 0) { out.words[k2] = carry | 0; } else { out.length--; } return out._strip(); } var comb10MulTo = function comb10MulTo2(self2, num, out) { var a2 = self2.words; var b2 = num.words; var o = out.words; var c2 = 0; var lo; var mid; var hi; var a0 = a2[0] | 0; var al0 = a0 & 8191; var ah0 = a0 >>> 13; var a1 = a2[1] | 0; var al1 = a1 & 8191; var ah1 = a1 >>> 13; var a22 = a2[2] | 0; var al2 = a22 & 8191; var ah2 = a22 >>> 13; var a3 = a2[3] | 0; var al3 = a3 & 8191; var ah3 = a3 >>> 13; var a4 = a2[4] | 0; var al4 = a4 & 8191; var ah4 = a4 >>> 13; var a5 = a2[5] | 0; var al5 = a5 & 8191; var ah5 = a5 >>> 13; var a6 = a2[6] | 0; var al6 = a6 & 8191; var ah6 = a6 >>> 13; var a7 = a2[7] | 0; var al7 = a7 & 8191; var ah7 = a7 >>> 13; var a8 = a2[8] | 0; var al8 = a8 & 8191; var ah8 = a8 >>> 13; var a9 = a2[9] | 0; var al9 = a9 & 8191; var ah9 = a9 >>> 13; var b0 = b2[0] | 0; var bl0 = b0 & 8191; var bh0 = b0 >>> 13; var b1 = b2[1] | 0; var bl1 = b1 & 8191; var bh1 = b1 >>> 13; var b22 = b2[2] | 0; var bl2 = b22 & 8191; var bh2 = b22 >>> 13; var b3 = b2[3] | 0; var bl3 = b3 & 8191; var bh3 = b3 >>> 13; var b4 = b2[4] | 0; var bl4 = b4 & 8191; var bh4 = b4 >>> 13; var b5 = b2[5] | 0; var bl5 = b5 & 8191; var bh5 = b5 >>> 13; var b6 = b2[6] | 0; var bl6 = b6 & 8191; var bh6 = b6 >>> 13; var b7 = b2[7] | 0; var bl7 = b7 & 8191; var bh7 = b7 >>> 13; var b8 = b2[8] | 0; var bl8 = b8 & 8191; var bh8 = b8 >>> 13; var b9 = b2[9] | 0; var bl9 = b9 & 8191; var bh9 = b9 >>> 13; out.negative = self2.negative ^ num.negative; out.length = 19; lo = Math.imul(al0, bl0); mid = Math.imul(al0, bh0); mid = mid + Math.imul(ah0, bl0) | 0; hi = Math.imul(ah0, bh0); var w0 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; w0 &= 67108863; lo = Math.imul(al1, bl0); mid = Math.imul(al1, bh0); mid = mid + Math.imul(ah1, bl0) | 0; hi = Math.imul(ah1, bh0); lo = lo + Math.imul(al0, bl1) | 0; mid = mid + Math.imul(al0, bh1) | 0; mid = mid + Math.imul(ah0, bl1) | 0; hi = hi + Math.imul(ah0, bh1) | 0; var w1 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; w1 &= 67108863; lo = Math.imul(al2, bl0); mid = Math.imul(al2, bh0); mid = mid + Math.imul(ah2, bl0) | 0; hi = Math.imul(ah2, bh0); lo = lo + Math.imul(al1, bl1) | 0; mid = mid + Math.imul(al1, bh1) | 0; mid = mid + Math.imul(ah1, bl1) | 0; hi = hi + Math.imul(ah1, bh1) | 0; lo = lo + Math.imul(al0, bl2) | 0; mid = mid + Math.imul(al0, bh2) | 0; mid = mid + Math.imul(ah0, bl2) | 0; hi = hi + Math.imul(ah0, bh2) | 0; var w2 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w2 >>> 26) | 0; w2 &= 67108863; lo = Math.imul(al3, bl0); mid = Math.imul(al3, bh0); mid = mid + Math.imul(ah3, bl0) | 0; hi = Math.imul(ah3, bh0); lo = lo + Math.imul(al2, bl1) | 0; mid = mid + Math.imul(al2, bh1) | 0; mid = mid + Math.imul(ah2, bl1) | 0; hi = hi + Math.imul(ah2, bh1) | 0; lo = lo + Math.imul(al1, bl2) | 0; mid = mid + Math.imul(al1, bh2) | 0; mid = mid + Math.imul(ah1, bl2) | 0; hi = hi + Math.imul(ah1, bh2) | 0; lo = lo + Math.imul(al0, bl3) | 0; mid = mid + Math.imul(al0, bh3) | 0; mid = mid + Math.imul(ah0, bl3) | 0; hi = hi + Math.imul(ah0, bh3) | 0; var w3 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w3 >>> 26) | 0; w3 &= 67108863; lo = Math.imul(al4, bl0); mid = Math.imul(al4, bh0); mid = mid + Math.imul(ah4, bl0) | 0; hi = Math.imul(ah4, bh0); lo = lo + Math.imul(al3, bl1) | 0; mid = mid + Math.imul(al3, bh1) | 0; mid = mid + Math.imul(ah3, bl1) | 0; hi = hi + Math.imul(ah3, bh1) | 0; lo = lo + Math.imul(al2, bl2) | 0; mid = mid + Math.imul(al2, bh2) | 0; mid = mid + Math.imul(ah2, bl2) | 0; hi = hi + Math.imul(ah2, bh2) | 0; lo = lo + Math.imul(al1, bl3) | 0; mid = mid + Math.imul(al1, bh3) | 0; mid = mid + Math.imul(ah1, bl3) | 0; hi = hi + Math.imul(ah1, bh3) | 0; lo = lo + Math.imul(al0, bl4) | 0; mid = mid + Math.imul(al0, bh4) | 0; mid = mid + Math.imul(ah0, bl4) | 0; hi = hi + Math.imul(ah0, bh4) | 0; var w4 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w4 >>> 26) | 0; w4 &= 67108863; lo = Math.imul(al5, bl0); mid = Math.imul(al5, bh0); mid = mid + Math.imul(ah5, bl0) | 0; hi = Math.imul(ah5, bh0); lo = lo + Math.imul(al4, bl1) | 0; mid = mid + Math.imul(al4, bh1) | 0; mid = mid + Math.imul(ah4, bl1) | 0; hi = hi + Math.imul(ah4, bh1) | 0; lo = lo + Math.imul(al3, bl2) | 0; mid = mid + Math.imul(al3, bh2) | 0; mid = mid + Math.imul(ah3, bl2) | 0; hi = hi + Math.imul(ah3, bh2) | 0; lo = lo + Math.imul(al2, bl3) | 0; mid = mid + Math.imul(al2, bh3) | 0; mid = mid + Math.imul(ah2, bl3) | 0; hi = hi + Math.imul(ah2, bh3) | 0; lo = lo + Math.imul(al1, bl4) | 0; mid = mid + Math.imul(al1, bh4) | 0; mid = mid + Math.imul(ah1, bl4) | 0; hi = hi + Math.imul(ah1, bh4) | 0; lo = lo + Math.imul(al0, bl5) | 0; mid = mid + Math.imul(al0, bh5) | 0; mid = mid + Math.imul(ah0, bl5) | 0; hi = hi + Math.imul(ah0, bh5) | 0; var w5 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; w5 &= 67108863; lo = Math.imul(al6, bl0); mid = Math.imul(al6, bh0); mid = mid + Math.imul(ah6, bl0) | 0; hi = Math.imul(ah6, bh0); lo = lo + Math.imul(al5, bl1) | 0; mid = mid + Math.imul(al5, bh1) | 0; mid = mid + Math.imul(ah5, bl1) | 0; hi = hi + Math.imul(ah5, bh1) | 0; lo = lo + Math.imul(al4, bl2) | 0; mid = mid + Math.imul(al4, bh2) | 0; mid = mid + Math.imul(ah4, bl2) | 0; hi = hi + Math.imul(ah4, bh2) | 0; lo = lo + Math.imul(al3, bl3) | 0; mid = mid + Math.imul(al3, bh3) | 0; mid = mid + Math.imul(ah3, bl3) | 0; hi = hi + Math.imul(ah3, bh3) | 0; lo = lo + Math.imul(al2, bl4) | 0; mid = mid + Math.imul(al2, bh4) | 0; mid = mid + Math.imul(ah2, bl4) | 0; hi = hi + Math.imul(ah2, bh4) | 0; lo = lo + Math.imul(al1, bl5) | 0; mid = mid + Math.imul(al1, bh5) | 0; mid = mid + Math.imul(ah1, bl5) | 0; hi = hi + Math.imul(ah1, bh5) | 0; lo = lo + Math.imul(al0, bl6) | 0; mid = mid + Math.imul(al0, bh6) | 0; mid = mid + Math.imul(ah0, bl6) | 0; hi = hi + Math.imul(ah0, bh6) | 0; var w6 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; w6 &= 67108863; lo = Math.imul(al7, bl0); mid = Math.imul(al7, bh0); mid = mid + Math.imul(ah7, bl0) | 0; hi = Math.imul(ah7, bh0); lo = lo + Math.imul(al6, bl1) | 0; mid = mid + Math.imul(al6, bh1) | 0; mid = mid + Math.imul(ah6, bl1) | 0; hi = hi + Math.imul(ah6, bh1) | 0; lo = lo + Math.imul(al5, bl2) | 0; mid = mid + Math.imul(al5, bh2) | 0; mid = mid + Math.imul(ah5, bl2) | 0; hi = hi + Math.imul(ah5, bh2) | 0; lo = lo + Math.imul(al4, bl3) | 0; mid = mid + Math.imul(al4, bh3) | 0; mid = mid + Math.imul(ah4, bl3) | 0; hi = hi + Math.imul(ah4, bh3) | 0; lo = lo + Math.imul(al3, bl4) | 0; mid = mid + Math.imul(al3, bh4) | 0; mid = mid + Math.imul(ah3, bl4) | 0; hi = hi + Math.imul(ah3, bh4) | 0; lo = lo + Math.imul(al2, bl5) | 0; mid = mid + Math.imul(al2, bh5) | 0; mid = mid + Math.imul(ah2, bl5) | 0; hi = hi + Math.imul(ah2, bh5) | 0; lo = lo + Math.imul(al1, bl6) | 0; mid = mid + Math.imul(al1, bh6) | 0; mid = mid + Math.imul(ah1, bl6) | 0; hi = hi + Math.imul(ah1, bh6) | 0; lo = lo + Math.imul(al0, bl7) | 0; mid = mid + Math.imul(al0, bh7) | 0; mid = mid + Math.imul(ah0, bl7) | 0; hi = hi + Math.imul(ah0, bh7) | 0; var w7 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; w7 &= 67108863; lo = Math.imul(al8, bl0); mid = Math.imul(al8, bh0); mid = mid + Math.imul(ah8, bl0) | 0; hi = Math.imul(ah8, bh0); lo = lo + Math.imul(al7, bl1) | 0; mid = mid + Math.imul(al7, bh1) | 0; mid = mid + Math.imul(ah7, bl1) | 0; hi = hi + Math.imul(ah7, bh1) | 0; lo = lo + Math.imul(al6, bl2) | 0; mid = mid + Math.imul(al6, bh2) | 0; mid = mid + Math.imul(ah6, bl2) | 0; hi = hi + Math.imul(ah6, bh2) | 0; lo = lo + Math.imul(al5, bl3) | 0; mid = mid + Math.imul(al5, bh3) | 0; mid = mid + Math.imul(ah5, bl3) | 0; hi = hi + Math.imul(ah5, bh3) | 0; lo = lo + Math.imul(al4, bl4) | 0; mid = mid + Math.imul(al4, bh4) | 0; mid = mid + Math.imul(ah4, bl4) | 0; hi = hi + Math.imul(ah4, bh4) | 0; lo = lo + Math.imul(al3, bl5) | 0; mid = mid + Math.imul(al3, bh5) | 0; mid = mid + Math.imul(ah3, bl5) | 0; hi = hi + Math.imul(ah3, bh5) | 0; lo = lo + Math.imul(al2, bl6) | 0; mid = mid + Math.imul(al2, bh6) | 0; mid = mid + Math.imul(ah2, bl6) | 0; hi = hi + Math.imul(ah2, bh6) | 0; lo = lo + Math.imul(al1, bl7) | 0; mid = mid + Math.imul(al1, bh7) | 0; mid = mid + Math.imul(ah1, bl7) | 0; hi = hi + Math.imul(ah1, bh7) | 0; lo = lo + Math.imul(al0, bl8) | 0; mid = mid + Math.imul(al0, bh8) | 0; mid = mid + Math.imul(ah0, bl8) | 0; hi = hi + Math.imul(ah0, bh8) | 0; var w8 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; w8 &= 67108863; lo = Math.imul(al9, bl0); mid = Math.imul(al9, bh0); mid = mid + Math.imul(ah9, bl0) | 0; hi = Math.imul(ah9, bh0); lo = lo + Math.imul(al8, bl1) | 0; mid = mid + Math.imul(al8, bh1) | 0; mid = mid + Math.imul(ah8, bl1) | 0; hi = hi + Math.imul(ah8, bh1) | 0; lo = lo + Math.imul(al7, bl2) | 0; mid = mid + Math.imul(al7, bh2) | 0; mid = mid + Math.imul(ah7, bl2) | 0; hi = hi + Math.imul(ah7, bh2) | 0; lo = lo + Math.imul(al6, bl3) | 0; mid = mid + Math.imul(al6, bh3) | 0; mid = mid + Math.imul(ah6, bl3) | 0; hi = hi + Math.imul(ah6, bh3) | 0; lo = lo + Math.imul(al5, bl4) | 0; mid = mid + Math.imul(al5, bh4) | 0; mid = mid + Math.imul(ah5, bl4) | 0; hi = hi + Math.imul(ah5, bh4) | 0; lo = lo + Math.imul(al4, bl5) | 0; mid = mid + Math.imul(al4, bh5) | 0; mid = mid + Math.imul(ah4, bl5) | 0; hi = hi + Math.imul(ah4, bh5) | 0; lo = lo + Math.imul(al3, bl6) | 0; mid = mid + Math.imul(al3, bh6) | 0; mid = mid + Math.imul(ah3, bl6) | 0; hi = hi + Math.imul(ah3, bh6) | 0; lo = lo + Math.imul(al2, bl7) | 0; mid = mid + Math.imul(al2, bh7) | 0; mid = mid + Math.imul(ah2, bl7) | 0; hi = hi + Math.imul(ah2, bh7) | 0; lo = lo + Math.imul(al1, bl8) | 0; mid = mid + Math.imul(al1, bh8) | 0; mid = mid + Math.imul(ah1, bl8) | 0; hi = hi + Math.imul(ah1, bh8) | 0; lo = lo + Math.imul(al0, bl9) | 0; mid = mid + Math.imul(al0, bh9) | 0; mid = mid + Math.imul(ah0, bl9) | 0; hi = hi + Math.imul(ah0, bh9) | 0; var w9 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; w9 &= 67108863; lo = Math.imul(al9, bl1); mid = Math.imul(al9, bh1); mid = mid + Math.imul(ah9, bl1) | 0; hi = Math.imul(ah9, bh1); lo = lo + Math.imul(al8, bl2) | 0; mid = mid + Math.imul(al8, bh2) | 0; mid = mid + Math.imul(ah8, bl2) | 0; hi = hi + Math.imul(ah8, bh2) | 0; lo = lo + Math.imul(al7, bl3) | 0; mid = mid + Math.imul(al7, bh3) | 0; mid = mid + Math.imul(ah7, bl3) | 0; hi = hi + Math.imul(ah7, bh3) | 0; lo = lo + Math.imul(al6, bl4) | 0; mid = mid + Math.imul(al6, bh4) | 0; mid = mid + Math.imul(ah6, bl4) | 0; hi = hi + Math.imul(ah6, bh4) | 0; lo = lo + Math.imul(al5, bl5) | 0; mid = mid + Math.imul(al5, bh5) | 0; mid = mid + Math.imul(ah5, bl5) | 0; hi = hi + Math.imul(ah5, bh5) | 0; lo = lo + Math.imul(al4, bl6) | 0; mid = mid + Math.imul(al4, bh6) | 0; mid = mid + Math.imul(ah4, bl6) | 0; hi = hi + Math.imul(ah4, bh6) | 0; lo = lo + Math.imul(al3, bl7) | 0; mid = mid + Math.imul(al3, bh7) | 0; mid = mid + Math.imul(ah3, bl7) | 0; hi = hi + Math.imul(ah3, bh7) | 0; lo = lo + Math.imul(al2, bl8) | 0; mid = mid + Math.imul(al2, bh8) | 0; mid = mid + Math.imul(ah2, bl8) | 0; hi = hi + Math.imul(ah2, bh8) | 0; lo = lo + Math.imul(al1, bl9) | 0; mid = mid + Math.imul(al1, bh9) | 0; mid = mid + Math.imul(ah1, bl9) | 0; hi = hi + Math.imul(ah1, bh9) | 0; var w10 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; w10 &= 67108863; lo = Math.imul(al9, bl2); mid = Math.imul(al9, bh2); mid = mid + Math.imul(ah9, bl2) | 0; hi = Math.imul(ah9, bh2); lo = lo + Math.imul(al8, bl3) | 0; mid = mid + Math.imul(al8, bh3) | 0; mid = mid + Math.imul(ah8, bl3) | 0; hi = hi + Math.imul(ah8, bh3) | 0; lo = lo + Math.imul(al7, bl4) | 0; mid = mid + Math.imul(al7, bh4) | 0; mid = mid + Math.imul(ah7, bl4) | 0; hi = hi + Math.imul(ah7, bh4) | 0; lo = lo + Math.imul(al6, bl5) | 0; mid = mid + Math.imul(al6, bh5) | 0; mid = mid + Math.imul(ah6, bl5) | 0; hi = hi + Math.imul(ah6, bh5) | 0; lo = lo + Math.imul(al5, bl6) | 0; mid = mid + Math.imul(al5, bh6) | 0; mid = mid + Math.imul(ah5, bl6) | 0; hi = hi + Math.imul(ah5, bh6) | 0; lo = lo + Math.imul(al4, bl7) | 0; mid = mid + Math.imul(al4, bh7) | 0; mid = mid + Math.imul(ah4, bl7) | 0; hi = hi + Math.imul(ah4, bh7) | 0; lo = lo + Math.imul(al3, bl8) | 0; mid = mid + Math.imul(al3, bh8) | 0; mid = mid + Math.imul(ah3, bl8) | 0; hi = hi + Math.imul(ah3, bh8) | 0; lo = lo + Math.imul(al2, bl9) | 0; mid = mid + Math.imul(al2, bh9) | 0; mid = mid + Math.imul(ah2, bl9) | 0; hi = hi + Math.imul(ah2, bh9) | 0; var w11 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; w11 &= 67108863; lo = Math.imul(al9, bl3); mid = Math.imul(al9, bh3); mid = mid + Math.imul(ah9, bl3) | 0; hi = Math.imul(ah9, bh3); lo = lo + Math.imul(al8, bl4) | 0; mid = mid + Math.imul(al8, bh4) | 0; mid = mid + Math.imul(ah8, bl4) | 0; hi = hi + Math.imul(ah8, bh4) | 0; lo = lo + Math.imul(al7, bl5) | 0; mid = mid + Math.imul(al7, bh5) | 0; mid = mid + Math.imul(ah7, bl5) | 0; hi = hi + Math.imul(ah7, bh5) | 0; lo = lo + Math.imul(al6, bl6) | 0; mid = mid + Math.imul(al6, bh6) | 0; mid = mid + Math.imul(ah6, bl6) | 0; hi = hi + Math.imul(ah6, bh6) | 0; lo = lo + Math.imul(al5, bl7) | 0; mid = mid + Math.imul(al5, bh7) | 0; mid = mid + Math.imul(ah5, bl7) | 0; hi = hi + Math.imul(ah5, bh7) | 0; lo = lo + Math.imul(al4, bl8) | 0; mid = mid + Math.imul(al4, bh8) | 0; mid = mid + Math.imul(ah4, bl8) | 0; hi = hi + Math.imul(ah4, bh8) | 0; lo = lo + Math.imul(al3, bl9) | 0; mid = mid + Math.imul(al3, bh9) | 0; mid = mid + Math.imul(ah3, bl9) | 0; hi = hi + Math.imul(ah3, bh9) | 0; var w12 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; w12 &= 67108863; lo = Math.imul(al9, bl4); mid = Math.imul(al9, bh4); mid = mid + Math.imul(ah9, bl4) | 0; hi = Math.imul(ah9, bh4); lo = lo + Math.imul(al8, bl5) | 0; mid = mid + Math.imul(al8, bh5) | 0; mid = mid + Math.imul(ah8, bl5) | 0; hi = hi + Math.imul(ah8, bh5) | 0; lo = lo + Math.imul(al7, bl6) | 0; mid = mid + Math.imul(al7, bh6) | 0; mid = mid + Math.imul(ah7, bl6) | 0; hi = hi + Math.imul(ah7, bh6) | 0; lo = lo + Math.imul(al6, bl7) | 0; mid = mid + Math.imul(al6, bh7) | 0; mid = mid + Math.imul(ah6, bl7) | 0; hi = hi + Math.imul(ah6, bh7) | 0; lo = lo + Math.imul(al5, bl8) | 0; mid = mid + Math.imul(al5, bh8) | 0; mid = mid + Math.imul(ah5, bl8) | 0; hi = hi + Math.imul(ah5, bh8) | 0; lo = lo + Math.imul(al4, bl9) | 0; mid = mid + Math.imul(al4, bh9) | 0; mid = mid + Math.imul(ah4, bl9) | 0; hi = hi + Math.imul(ah4, bh9) | 0; var w13 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; w13 &= 67108863; lo = Math.imul(al9, bl5); mid = Math.imul(al9, bh5); mid = mid + Math.imul(ah9, bl5) | 0; hi = Math.imul(ah9, bh5); lo = lo + Math.imul(al8, bl6) | 0; mid = mid + Math.imul(al8, bh6) | 0; mid = mid + Math.imul(ah8, bl6) | 0; hi = hi + Math.imul(ah8, bh6) | 0; lo = lo + Math.imul(al7, bl7) | 0; mid = mid + Math.imul(al7, bh7) | 0; mid = mid + Math.imul(ah7, bl7) | 0; hi = hi + Math.imul(ah7, bh7) | 0; lo = lo + Math.imul(al6, bl8) | 0; mid = mid + Math.imul(al6, bh8) | 0; mid = mid + Math.imul(ah6, bl8) | 0; hi = hi + Math.imul(ah6, bh8) | 0; lo = lo + Math.imul(al5, bl9) | 0; mid = mid + Math.imul(al5, bh9) | 0; mid = mid + Math.imul(ah5, bl9) | 0; hi = hi + Math.imul(ah5, bh9) | 0; var w14 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; w14 &= 67108863; lo = Math.imul(al9, bl6); mid = Math.imul(al9, bh6); mid = mid + Math.imul(ah9, bl6) | 0; hi = Math.imul(ah9, bh6); lo = lo + Math.imul(al8, bl7) | 0; mid = mid + Math.imul(al8, bh7) | 0; mid = mid + Math.imul(ah8, bl7) | 0; hi = hi + Math.imul(ah8, bh7) | 0; lo = lo + Math.imul(al7, bl8) | 0; mid = mid + Math.imul(al7, bh8) | 0; mid = mid + Math.imul(ah7, bl8) | 0; hi = hi + Math.imul(ah7, bh8) | 0; lo = lo + Math.imul(al6, bl9) | 0; mid = mid + Math.imul(al6, bh9) | 0; mid = mid + Math.imul(ah6, bl9) | 0; hi = hi + Math.imul(ah6, bh9) | 0; var w15 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; w15 &= 67108863; lo = Math.imul(al9, bl7); mid = Math.imul(al9, bh7); mid = mid + Math.imul(ah9, bl7) | 0; hi = Math.imul(ah9, bh7); lo = lo + Math.imul(al8, bl8) | 0; mid = mid + Math.imul(al8, bh8) | 0; mid = mid + Math.imul(ah8, bl8) | 0; hi = hi + Math.imul(ah8, bh8) | 0; lo = lo + Math.imul(al7, bl9) | 0; mid = mid + Math.imul(al7, bh9) | 0; mid = mid + Math.imul(ah7, bl9) | 0; hi = hi + Math.imul(ah7, bh9) | 0; var w16 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; w16 &= 67108863; lo = Math.imul(al9, bl8); mid = Math.imul(al9, bh8); mid = mid + Math.imul(ah9, bl8) | 0; hi = Math.imul(ah9, bh8); lo = lo + Math.imul(al8, bl9) | 0; mid = mid + Math.imul(al8, bh9) | 0; mid = mid + Math.imul(ah8, bl9) | 0; hi = hi + Math.imul(ah8, bh9) | 0; var w17 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; w17 &= 67108863; lo = Math.imul(al9, bl9); mid = Math.imul(al9, bh9); mid = mid + Math.imul(ah9, bl9) | 0; hi = Math.imul(ah9, bh9); var w18 = (c2 + lo | 0) + ((mid & 8191) << 13) | 0; c2 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; w18 &= 67108863; o[0] = w0; o[1] = w1; o[2] = w2; o[3] = w3; o[4] = w4; o[5] = w5; o[6] = w6; o[7] = w7; o[8] = w8; o[9] = w9; o[10] = w10; o[11] = w11; o[12] = w12; o[13] = w13; o[14] = w14; o[15] = w15; o[16] = w16; o[17] = w17; o[18] = w18; if (c2 !== 0) { o[19] = c2; out.length++; } return out; }; if (!Math.imul) { comb10MulTo = smallMulTo; } function bigMulTo(self2, num, out) { out.negative = num.negative ^ self2.negative; out.length = self2.length + num.length; var carry = 0; var hncarry = 0; for (var k2 = 0; k2 < out.length - 1; k2++) { var ncarry = hncarry; hncarry = 0; var rword = carry & 67108863; var maxJ = Math.min(k2, num.length - 1); for (var j2 = Math.max(0, k2 - self2.length + 1); j2 <= maxJ; j2++) { var i2 = k2 - j2; var a2 = self2.words[i2] | 0; var b2 = num.words[j2] | 0; var r2 = a2 * b2; var lo = r2 & 67108863; ncarry = ncarry + (r2 / 67108864 | 0) | 0; lo = lo + rword | 0; rword = lo & 67108863; ncarry = ncarry + (lo >>> 26) | 0; hncarry += ncarry >>> 26; ncarry &= 67108863; } out.words[k2] = rword; carry = ncarry; ncarry = hncarry; } if (carry !== 0) { out.words[k2] = carry; } else { out.length--; } return out._strip(); } function jumboMulTo(self2, num, out) { return bigMulTo(self2, num, out); } BN2.prototype.mulTo = function mulTo(num, out) { var res; var len = this.length + num.length; if (this.length === 10 && num.length === 10) { res = comb10MulTo(this, num, out); } else if (len < 63) { res = smallMulTo(this, num, out); } else if (len < 1024) { res = bigMulTo(this, num, out); } else { res = jumboMulTo(this, num, out); } return res; }; BN2.prototype.mul = function mul3(num) { var out = new BN2(null); out.words = new Array(this.length + num.length); return this.mulTo(num, out); }; BN2.prototype.mulf = function mulf(num) { var out = new BN2(null); out.words = new Array(this.length + num.length); return jumboMulTo(this, num, out); }; BN2.prototype.imul = function imul(num) { return this.clone().mulTo(num, this); }; BN2.prototype.imuln = function imuln(num) { var isNegNum = num < 0; if (isNegNum) num = -num; assert2(typeof num === "number"); assert2(num < 67108864); var carry = 0; for (var i2 = 0; i2 < this.length; i2++) { var w = (this.words[i2] | 0) * num; var lo = (w & 67108863) + (carry & 67108863); carry >>= 26; carry += w / 67108864 | 0; carry += lo >>> 26; this.words[i2] = lo & 67108863; } if (carry !== 0) { this.words[i2] = carry; this.length++; } return isNegNum ? this.ineg() : this; }; BN2.prototype.muln = function muln(num) { return this.clone().imuln(num); }; BN2.prototype.sqr = function sqr() { return this.mul(this); }; BN2.prototype.isqr = function isqr() { return this.imul(this.clone()); }; BN2.prototype.pow = function pow(num) { var w = toBitArray(num); if (w.length === 0) return new BN2(1); var res = this; for (var i2 = 0; i2 < w.length; i2++, res = res.sqr()) { if (w[i2] !== 0) break; } if (++i2 < w.length) { for (var q = res.sqr(); i2 < w.length; i2++, q = q.sqr()) { if (w[i2] === 0) continue; res = res.mul(q); } } return res; }; BN2.prototype.iushln = function iushln(bits) { assert2(typeof bits === "number" && bits >= 0); var r2 = bits % 26; var s2 = (bits - r2) / 26; var carryMask = 67108863 >>> 26 - r2 << 26 - r2; var i2; if (r2 !== 0) { var carry = 0; for (i2 = 0; i2 < this.length; i2++) { var newCarry = this.words[i2] & carryMask; var c2 = (this.words[i2] | 0) - newCarry << r2; this.words[i2] = c2 | carry; carry = newCarry >>> 26 - r2; } if (carry) { this.words[i2] = carry; this.length++; } } if (s2 !== 0) { for (i2 = this.length - 1; i2 >= 0; i2--) { this.words[i2 + s2] = this.words[i2]; } for (i2 = 0; i2 < s2; i2++) { this.words[i2] = 0; } this.length += s2; } return this._strip(); }; BN2.prototype.ishln = function ishln(bits) { assert2(this.negative === 0); return this.iushln(bits); }; BN2.prototype.iushrn = function iushrn(bits, hint, extended) { assert2(typeof bits === "number" && bits >= 0); var h2; if (hint) { h2 = (hint - hint % 26) / 26; } else { h2 = 0; } var r2 = bits % 26; var s2 = Math.min((bits - r2) / 26, this.length); var mask = 67108863 ^ 67108863 >>> r2 << r2; var maskedWords = extended; h2 -= s2; h2 = Math.max(0, h2); if (maskedWords) { for (var i2 = 0; i2 < s2; i2++) { maskedWords.words[i2] = this.words[i2]; } maskedWords.length = s2; } if (s2 === 0) ; else if (this.length > s2) { this.length -= s2; for (i2 = 0; i2 < this.length; i2++) { this.words[i2] = this.words[i2 + s2]; } } else { this.words[0] = 0; this.length = 1; } var carry = 0; for (i2 = this.length - 1; i2 >= 0 && (carry !== 0 || i2 >= h2); i2--) { var word = this.words[i2] | 0; this.words[i2] = carry << 26 - r2 | word >>> r2; carry = word & mask; } if (maskedWords && carry !== 0) { maskedWords.words[maskedWords.length++] = carry; } if (this.length === 0) { this.words[0] = 0; this.length = 1; } return this._strip(); }; BN2.prototype.ishrn = function ishrn(bits, hint, extended) { assert2(this.negative === 0); return this.iushrn(bits, hint, extended); }; BN2.prototype.shln = function shln(bits) { return this.clone().ishln(bits); }; BN2.prototype.ushln = function ushln(bits) { return this.clone().iushln(bits); }; BN2.prototype.shrn = function shrn(bits) { return this.clone().ishrn(bits); }; BN2.prototype.ushrn = function ushrn(bits) { return this.clone().iushrn(bits); }; BN2.prototype.testn = function testn(bit) { assert2(typeof bit === "number" && bit >= 0); var r2 = bit % 26; var s2 = (bit - r2) / 26; var q = 1 << r2; if (this.length <= s2) return false; var w = this.words[s2]; return !!(w & q); }; BN2.prototype.imaskn = function imaskn(bits) { assert2(typeof bits === "number" && bits >= 0); var r2 = bits % 26; var s2 = (bits - r2) / 26; assert2(this.negative === 0, "imaskn works only with positive numbers"); if (this.length <= s2) { return this; } if (r2 !== 0) { s2++; } this.length = Math.min(s2, this.length); if (r2 !== 0) { var mask = 67108863 ^ 67108863 >>> r2 << r2; this.words[this.length - 1] &= mask; } return this._strip(); }; BN2.prototype.maskn = function maskn(bits) { return this.clone().imaskn(bits); }; BN2.prototype.iaddn = function iaddn(num) { assert2(typeof num === "number"); assert2(num < 67108864); if (num < 0) return this.isubn(-num); if (this.negative !== 0) { if (this.length === 1 && (this.words[0] | 0) <= num) { this.words[0] = num - (this.words[0] | 0); this.negative = 0; return this; } this.negative = 0; this.isubn(num); this.negative = 1; return this; } return this._iaddn(num); }; BN2.prototype._iaddn = function _iaddn(num) { this.words[0] += num; for (var i2 = 0; i2 < this.length && this.words[i2] >= 67108864; i2++) { this.words[i2] -= 67108864; if (i2 === this.length - 1) { this.words[i2 + 1] = 1; } else { this.words[i2 + 1]++; } } this.length = Math.max(this.length, i2 + 1); return this; }; BN2.prototype.isubn = function isubn(num) { assert2(typeof num === "number"); assert2(num < 67108864); if (num < 0) return this.iaddn(-num); if (this.negative !== 0) { this.negative = 0; this.iaddn(num); this.negative = 1; return this; } this.words[0] -= num; if (this.length === 1 && this.words[0] < 0) { this.words[0] = -this.words[0]; this.negative = 1; } else { for (var i2 = 0; i2 < this.length && this.words[i2] < 0; i2++) { this.words[i2] += 67108864; this.words[i2 + 1] -= 1; } } return this._strip(); }; BN2.prototype.addn = function addn(num) { return this.clone().iaddn(num); }; BN2.prototype.subn = function subn(num) { return this.clone().isubn(num); }; BN2.prototype.iabs = function iabs() { this.negative = 0; return this; }; BN2.prototype.abs = function abs() { return this.clone().iabs(); }; BN2.prototype._ishlnsubmul = function _ishlnsubmul(num, mul3, shift) { var len = num.length + shift; var i2; this._expand(len); var w; var carry = 0; for (i2 = 0; i2 < num.length; i2++) { w = (this.words[i2 + shift] | 0) + carry; var right = (num.words[i2] | 0) * mul3; w -= right & 67108863; carry = (w >> 26) - (right / 67108864 | 0); this.words[i2 + shift] = w & 67108863; } for (; i2 < this.length - shift; i2++) { w = (this.words[i2 + shift] | 0) + carry; carry = w >> 26; this.words[i2 + shift] = w & 67108863; } if (carry === 0) return this._strip(); assert2(carry === -1); carry = 0; for (i2 = 0; i2 < this.length; i2++) { w = -(this.words[i2] | 0) + carry; carry = w >> 26; this.words[i2] = w & 67108863; } this.negative = 1; return this._strip(); }; BN2.prototype._wordDiv = function _wordDiv(num, mode) { var shift = this.length - num.length; var a2 = this.clone(); var b2 = num; var bhi = b2.words[b2.length - 1] | 0; var bhiBits = this._countBits(bhi); shift = 26 - bhiBits; if (shift !== 0) { b2 = b2.ushln(shift); a2.iushln(shift); bhi = b2.words[b2.length - 1] | 0; } var m2 = a2.length - b2.length; var q; if (mode !== "mod") { q = new BN2(null); q.length = m2 + 1; q.words = new Array(q.length); for (var i2 = 0; i2 < q.length; i2++) { q.words[i2] = 0; } } var diff = a2.clone()._ishlnsubmul(b2, 1, m2); if (diff.negative === 0) { a2 = diff; if (q) { q.words[m2] = 1; } } for (var j2 = m2 - 1; j2 >= 0; j2--) { var qj = (a2.words[b2.length + j2] | 0) * 67108864 + (a2.words[b2.length + j2 - 1] | 0); qj = Math.min(qj / bhi | 0, 67108863); a2._ishlnsubmul(b2, qj, j2); while (a2.negative !== 0) { qj--; a2.negative = 0; a2._ishlnsubmul(b2, 1, j2); if (!a2.isZero()) { a2.negative ^= 1; } } if (q) { q.words[j2] = qj; } } if (q) { q._strip(); } a2._strip(); if (mode !== "div" && shift !== 0) { a2.iushrn(shift); } return { div: q || null, mod: a2 }; }; BN2.prototype.divmod = function divmod(num, mode, positive) { assert2(!num.isZero()); if (this.isZero()) { return { div: new BN2(0), mod: new BN2(0) }; } var div, mod, res; if (this.negative !== 0 && num.negative === 0) { res = this.neg().divmod(num, mode); if (mode !== "mod") { div = res.div.neg(); } if (mode !== "div") { mod = res.mod.neg(); if (positive && mod.negative !== 0) { mod.iadd(num); } } return { div, mod }; } if (this.negative === 0 && num.negative !== 0) { res = this.divmod(num.neg(), mode); if (mode !== "mod") { div = res.div.neg(); } return { div, mod: res.mod }; } if ((this.negative & num.negative) !== 0) { res = this.neg().divmod(num.neg(), mode); if (mode !== "div") { mod = res.mod.neg(); if (positive && mod.negative !== 0) { mod.isub(num); } } return { div: res.div, mod }; } if (num.length > this.length || this.cmp(num) < 0) { return { div: new BN2(0), mod: this }; } if (num.length === 1) { if (mode === "div") { return { div: this.divn(num.words[0]), mod: null }; } if (mode === "mod") { return { div: null, mod: new BN2(this.modrn(num.words[0])) }; } return { div: this.divn(num.words[0]), mod: new BN2(this.modrn(num.words[0])) }; } return this._wordDiv(num, mode); }; BN2.prototype.div = function div(num) { return this.divmod(num, "div", false).div; }; BN2.prototype.mod = function mod(num) { return this.divmod(num, "mod", false).mod; }; BN2.prototype.umod = function umod(num) { return this.divmod(num, "mod", true).mod; }; BN2.prototype.divRound = function divRound(num) { var dm = this.divmod(num); if (dm.mod.isZero()) return dm.div; var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; var half = num.ushrn(1); var r2 = num.andln(1); var cmp = mod.cmp(half); if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); }; BN2.prototype.modrn = function modrn(num) { var isNegNum = num < 0; if (isNegNum) num = -num; assert2(num <= 67108863); var p2 = (1 << 26) % num; var acc = 0; for (var i2 = this.length - 1; i2 >= 0; i2--) { acc = (p2 * acc + (this.words[i2] | 0)) % num; } return isNegNum ? -acc : acc; }; BN2.prototype.modn = function modn(num) { return this.modrn(num); }; BN2.prototype.idivn = function idivn(num) { var isNegNum = num < 0; if (isNegNum) num = -num; assert2(num <= 67108863); var carry = 0; for (var i2 = this.length - 1; i2 >= 0; i2--) { var w = (this.words[i2] | 0) + carry * 67108864; this.words[i2] = w / num | 0; carry = w % num; } this._strip(); return isNegNum ? this.ineg() : this; }; BN2.prototype.divn = function divn(num) { return this.clone().idivn(num); }; BN2.prototype.egcd = function egcd(p2) { assert2(p2.negative === 0); assert2(!p2.isZero()); var x = this; var y2 = p2.clone(); if (x.negative !== 0) { x = x.umod(p2); } else { x = x.clone(); } var A2 = new BN2(1); var B = new BN2(0); var C2 = new BN2(0); var D = new BN2(1); var g2 = 0; while (x.isEven() && y2.isEven()) { x.iushrn(1); y2.iushrn(1); ++g2; } var yp = y2.clone(); var xp = x.clone(); while (!x.isZero()) { for (var i2 = 0, im = 1; (x.words[0] & im) === 0 && i2 < 26; ++i2, im <<= 1) ; if (i2 > 0) { x.iushrn(i2); while (i2-- > 0) { if (A2.isOdd() || B.isOdd()) { A2.iadd(yp); B.isub(xp); } A2.iushrn(1); B.iushrn(1); } } for (var j2 = 0, jm = 1; (y2.words[0] & jm) === 0 && j2 < 26; ++j2, jm <<= 1) ; if (j2 > 0) { y2.iushrn(j2); while (j2-- > 0) { if (C2.isOdd() || D.isOdd()) { C2.iadd(yp); D.isub(xp); } C2.iushrn(1); D.iushrn(1); } } if (x.cmp(y2) >= 0) { x.isub(y2); A2.isub(C2); B.isub(D); } else { y2.isub(x); C2.isub(A2); D.isub(B); } } return { a: C2, b: D, gcd: y2.iushln(g2) }; }; BN2.prototype._invmp = function _invmp(p2) { assert2(p2.negative === 0); assert2(!p2.isZero()); var a2 = this; var b2 = p2.clone(); if (a2.negative !== 0) { a2 = a2.umod(p2); } else { a2 = a2.clone(); } var x1 = new BN2(1); var x2 = new BN2(0); var delta = b2.clone(); while (a2.cmpn(1) > 0 && b2.cmpn(1) > 0) { for (var i2 = 0, im = 1; (a2.words[0] & im) === 0 && i2 < 26; ++i2, im <<= 1) ; if (i2 > 0) { a2.iushrn(i2); while (i2-- > 0) { if (x1.isOdd()) { x1.iadd(delta); } x1.iushrn(1); } } for (var j2 = 0, jm = 1; (b2.words[0] & jm) === 0 && j2 < 26; ++j2, jm <<= 1) ; if (j2 > 0) { b2.iushrn(j2); while (j2-- > 0) { if (x2.isOdd()) { x2.iadd(delta); } x2.iushrn(1); } } if (a2.cmp(b2) >= 0) { a2.isub(b2); x1.isub(x2); } else { b2.isub(a2); x2.isub(x1); } } var res; if (a2.cmpn(1) === 0) { res = x1; } else { res = x2; } if (res.cmpn(0) < 0) { res.iadd(p2); } return res; }; BN2.prototype.gcd = function gcd(num) { if (this.isZero()) return num.abs(); if (num.isZero()) return this.abs(); var a2 = this.clone(); var b2 = num.clone(); a2.negative = 0; b2.negative = 0; for (var shift = 0; a2.isEven() && b2.isEven(); shift++) { a2.iushrn(1); b2.iushrn(1); } do { while (a2.isEven()) { a2.iushrn(1); } while (b2.isEven()) { b2.iushrn(1); } var r2 = a2.cmp(b2); if (r2 < 0) { var t2 = a2; a2 = b2; b2 = t2; } else if (r2 === 0 || b2.cmpn(1) === 0) { break; } a2.isub(b2); } while (true); return b2.iushln(shift); }; BN2.prototype.invm = function invm(num) { return this.egcd(num).a.umod(num); }; BN2.prototype.isEven = function isEven() { return (this.words[0] & 1) === 0; }; BN2.prototype.isOdd = function isOdd() { return (this.words[0] & 1) === 1; }; BN2.prototype.andln = function andln(num) { return this.words[0] & num; }; BN2.prototype.bincn = function bincn(bit) { assert2(typeof bit === "number"); var r2 = bit % 26; var s2 = (bit - r2) / 26; var q = 1 << r2; if (this.length <= s2) { this._expand(s2 + 1); this.words[s2] |= q; return this; } var carry = q; for (var i2 = s2; carry !== 0 && i2 < this.length; i2++) { var w = this.words[i2] | 0; w += carry; carry = w >>> 26; w &= 67108863; this.words[i2] = w; } if (carry !== 0) { this.words[i2] = carry; this.length++; } return this; }; BN2.prototype.isZero = function isZero() { return this.length === 1 && this.words[0] === 0; }; BN2.prototype.cmpn = function cmpn(num) { var negative = num < 0; if (this.negative !== 0 && !negative) return -1; if (this.negative === 0 && negative) return 1; this._strip(); var res; if (this.length > 1) { res = 1; } else { if (negative) { num = -num; } assert2(num <= 67108863, "Number is too big"); var w = this.words[0] | 0; res = w === num ? 0 : w < num ? -1 : 1; } if (this.negative !== 0) return -res | 0; return res; }; BN2.prototype.cmp = function cmp(num) { if (this.negative !== 0 && num.negative === 0) return -1; if (this.negative === 0 && num.negative !== 0) return 1; var res = this.ucmp(num); if (this.negative !== 0) return -res | 0; return res; }; BN2.prototype.ucmp = function ucmp(num) { if (this.length > num.length) return 1; if (this.length < num.length) return -1; var res = 0; for (var i2 = this.length - 1; i2 >= 0; i2--) { var a2 = this.words[i2] | 0; var b2 = num.words[i2] | 0; if (a2 === b2) continue; if (a2 < b2) { res = -1; } else if (a2 > b2) { res = 1; } break; } return res; }; BN2.prototype.gtn = function gtn(num) { return this.cmpn(num) === 1; }; BN2.prototype.gt = function gt(num) { return this.cmp(num) === 1; }; BN2.prototype.gten = function gten(num) { return this.cmpn(num) >= 0; }; BN2.prototype.gte = function gte(num) { return this.cmp(num) >= 0; }; BN2.prototype.ltn = function ltn(num) { return this.cmpn(num) === -1; }; BN2.prototype.lt = function lt(num) { return this.cmp(num) === -1; }; BN2.prototype.lten = function lten(num) { return this.cmpn(num) <= 0; }; BN2.prototype.lte = function lte(num) { return this.cmp(num) <= 0; }; BN2.prototype.eqn = function eqn(num) { return this.cmpn(num) === 0; }; BN2.prototype.eq = function eq4(num) { return this.cmp(num) === 0; }; BN2.red = function red(num) { return new Red(num); }; BN2.prototype.toRed = function toRed(ctx) { assert2(!this.red, "Already a number in reduction context"); assert2(this.negative === 0, "red works only with positives"); return ctx.convertTo(this)._forceRed(ctx); }; BN2.prototype.fromRed = function fromRed() { assert2(this.red, "fromRed works only with numbers in reduction context"); return this.red.convertFrom(this); }; BN2.prototype._forceRed = function _forceRed(ctx) { this.red = ctx; return this; }; BN2.prototype.forceRed = function forceRed(ctx) { assert2(!this.red, "Already a number in reduction context"); return this._forceRed(ctx); }; BN2.prototype.redAdd = function redAdd(num) { assert2(this.red, "redAdd works only with red numbers"); return this.red.add(this, num); }; BN2.prototype.redIAdd = function redIAdd(num) { assert2(this.red, "redIAdd works only with red numbers"); return this.red.iadd(this, num); }; BN2.prototype.redSub = function redSub(num) { assert2(this.red, "redSub works only with red numbers"); return this.red.sub(this, num); }; BN2.prototype.redISub = function redISub(num) { assert2(this.red, "redISub works only with red numbers"); return this.red.isub(this, num); }; BN2.prototype.redShl = function redShl(num) { assert2(this.red, "redShl works only with red numbers"); return this.red.shl(this, num); }; BN2.prototype.redMul = function redMul(num) { assert2(this.red, "redMul works only with red numbers"); this.red._verify2(this, num); return this.red.mul(this, num); }; BN2.prototype.redIMul = function redIMul(num) { assert2(this.red, "redMul works only with red numbers"); this.red._verify2(this, num); return this.red.imul(this, num); }; BN2.prototype.redSqr = function redSqr() { assert2(this.red, "redSqr works only with red numbers"); this.red._verify1(this); return this.red.sqr(this); }; BN2.prototype.redISqr = function redISqr() { assert2(this.red, "redISqr works only with red numbers"); this.red._verify1(this); return this.red.isqr(this); }; BN2.prototype.redSqrt = function redSqrt() { assert2(this.red, "redSqrt works only with red numbers"); this.red._verify1(this); return this.red.sqrt(this); }; BN2.prototype.redInvm = function redInvm() { assert2(this.red, "redInvm works only with red numbers"); this.red._verify1(this); return this.red.invm(this); }; BN2.prototype.redNeg = function redNeg() { assert2(this.red, "redNeg works only with red numbers"); this.red._verify1(this); return this.red.neg(this); }; BN2.prototype.redPow = function redPow(num) { assert2(this.red && !num.red, "redPow(normalNum)"); this.red._verify1(this); return this.red.pow(this, num); }; var primes = { k256: null, p224: null, p192: null, p25519: null }; function MPrime(name, p2) { this.name = name; this.p = new BN2(p2, 16); this.n = this.p.bitLength(); this.k = new BN2(1).iushln(this.n).isub(this.p); this.tmp = this._tmp(); } MPrime.prototype._tmp = function _tmp() { var tmp = new BN2(null); tmp.words = new Array(Math.ceil(this.n / 13)); return tmp; }; MPrime.prototype.ireduce = function ireduce(num) { var r2 = num; var rlen; do { this.split(r2, this.tmp); r2 = this.imulK(r2); r2 = r2.iadd(this.tmp); rlen = r2.bitLength(); } while (rlen > this.n); var cmp = rlen < this.n ? -1 : r2.ucmp(this.p); if (cmp === 0) { r2.words[0] = 0; r2.length = 1; } else if (cmp > 0) { r2.isub(this.p); } else { if (r2.strip !== void 0) { r2.strip(); } else { r2._strip(); } } return r2; }; MPrime.prototype.split = function split(input, out) { input.iushrn(this.n, 0, out); }; MPrime.prototype.imulK = function imulK(num) { return num.imul(this.k); }; function K256() { MPrime.call( this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f" ); } inherits2(K256, MPrime); K256.prototype.split = function split(input, output) { var mask = 4194303; var outLen = Math.min(input.length, 9); for (var i2 = 0; i2 < outLen; i2++) { output.words[i2] = input.words[i2]; } output.length = outLen; if (input.length <= 9) { input.words[0] = 0; input.length = 1; return; } var prev = input.words[9]; output.words[output.length++] = prev & mask; for (i2 = 10; i2 < input.length; i2++) { var next = input.words[i2] | 0; input.words[i2 - 10] = (next & mask) << 4 | prev >>> 22; prev = next; } prev >>>= 22; input.words[i2 - 10] = prev; if (prev === 0 && input.length > 10) { input.length -= 10; } else { input.length -= 9; } }; K256.prototype.imulK = function imulK(num) { num.words[num.length] = 0; num.words[num.length + 1] = 0; num.length += 2; var lo = 0; for (var i2 = 0; i2 < num.length; i2++) { var w = num.words[i2] | 0; lo += w * 977; num.words[i2] = lo & 67108863; lo = w * 64 + (lo / 67108864 | 0); } if (num.words[num.length - 1] === 0) { num.length--; if (num.words[num.length - 1] === 0) { num.length--; } } return num; }; function P224() { MPrime.call( this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001" ); } inherits2(P224, MPrime); function P192() { MPrime.call( this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff" ); } inherits2(P192, MPrime); function P25519() { MPrime.call( this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed" ); } inherits2(P25519, MPrime); P25519.prototype.imulK = function imulK(num) { var carry = 0; for (var i2 = 0; i2 < num.length; i2++) { var hi = (num.words[i2] | 0) * 19 + carry; var lo = hi & 67108863; hi >>>= 26; num.words[i2] = lo; carry = hi; } if (carry !== 0) { num.words[num.length++] = carry; } return num; }; BN2._prime = function prime(name) { if (primes[name]) return primes[name]; var prime2; if (name === "k256") { prime2 = new K256(); } else if (name === "p224") { prime2 = new P224(); } else if (name === "p192") { prime2 = new P192(); } else if (name === "p25519") { prime2 = new P25519(); } else { throw new Error("Unknown prime " + name); } primes[name] = prime2; return prime2; }; function Red(m2) { if (typeof m2 === "string") { var prime = BN2._prime(m2); this.m = prime.p; this.prime = prime; } else { assert2(m2.gtn(1), "modulus must be greater than 1"); this.m = m2; this.prime = null; } } Red.prototype._verify1 = function _verify1(a2) { assert2(a2.negative === 0, "red works only with positives"); assert2(a2.red, "red works only with red numbers"); }; Red.prototype._verify2 = function _verify2(a2, b2) { assert2((a2.negative | b2.negative) === 0, "red works only with positives"); assert2( a2.red && a2.red === b2.red, "red works only with red numbers" ); }; Red.prototype.imod = function imod(a2) { if (this.prime) return this.prime.ireduce(a2)._forceRed(this); move(a2, a2.umod(this.m)._forceRed(this)); return a2; }; Red.prototype.neg = function neg3(a2) { if (a2.isZero()) { return a2.clone(); } return this.m.sub(a2)._forceRed(this); }; Red.prototype.add = function add3(a2, b2) { this._verify2(a2, b2); var res = a2.add(b2); if (res.cmp(this.m) >= 0) { res.isub(this.m); } return res._forceRed(this); }; Red.prototype.iadd = function iadd(a2, b2) { this._verify2(a2, b2); var res = a2.iadd(b2); if (res.cmp(this.m) >= 0) { res.isub(this.m); } return res; }; Red.prototype.sub = function sub(a2, b2) { this._verify2(a2, b2); var res = a2.sub(b2); if (res.cmpn(0) < 0) { res.iadd(this.m); } return res._forceRed(this); }; Red.prototype.isub = function isub(a2, b2) { this._verify2(a2, b2); var res = a2.isub(b2); if (res.cmpn(0) < 0) { res.iadd(this.m); } return res; }; Red.prototype.shl = function shl(a2, num) { this._verify1(a2); return this.imod(a2.ushln(num)); }; Red.prototype.imul = function imul(a2, b2) { this._verify2(a2, b2); return this.imod(a2.imul(b2)); }; Red.prototype.mul = function mul3(a2, b2) { this._verify2(a2, b2); return this.imod(a2.mul(b2)); }; Red.prototype.isqr = function isqr(a2) { return this.imul(a2, a2.clone()); }; Red.prototype.sqr = function sqr(a2) { return this.mul(a2, a2); }; Red.prototype.sqrt = function sqrt(a2) { if (a2.isZero()) return a2.clone(); var mod3 = this.m.andln(3); assert2(mod3 % 2 === 1); if (mod3 === 3) { var pow = this.m.add(new BN2(1)).iushrn(2); return this.pow(a2, pow); } var q = this.m.subn(1); var s2 = 0; while (!q.isZero() && q.andln(1) === 0) { s2++; q.iushrn(1); } assert2(!q.isZero()); var one = new BN2(1).toRed(this); var nOne = one.redNeg(); var lpow = this.m.subn(1).iushrn(1); var z = this.m.bitLength(); z = new BN2(2 * z * z).toRed(this); while (this.pow(z, lpow).cmp(nOne) !== 0) { z.redIAdd(nOne); } var c2 = this.pow(z, q); var r2 = this.pow(a2, q.addn(1).iushrn(1)); var t2 = this.pow(a2, q); var m2 = s2; while (t2.cmp(one) !== 0) { var tmp = t2; for (var i2 = 0; tmp.cmp(one) !== 0; i2++) { tmp = tmp.redSqr(); } assert2(i2 < m2); var b2 = this.pow(c2, new BN2(1).iushln(m2 - i2 - 1)); r2 = r2.redMul(b2); c2 = b2.redSqr(); t2 = t2.redMul(c2); m2 = i2; } return r2; }; Red.prototype.invm = function invm(a2) { var inv = a2._invmp(this.m); if (inv.negative !== 0) { inv.negative = 0; return this.imod(inv).redNeg(); } else { return this.imod(inv); } }; Red.prototype.pow = function pow(a2, num) { if (num.isZero()) return new BN2(1).toRed(this); if (num.cmpn(1) === 0) return a2.clone(); var windowSize = 4; var wnd = new Array(1 << windowSize); wnd[0] = new BN2(1).toRed(this); wnd[1] = a2; for (var i2 = 2; i2 < wnd.length; i2++) { wnd[i2] = this.mul(wnd[i2 - 1], a2); } var res = wnd[0]; var current = 0; var currentLen = 0; var start = num.bitLength() % 26; if (start === 0) { start = 26; } for (i2 = num.length - 1; i2 >= 0; i2--) { var word = num.words[i2]; for (var j2 = start - 1; j2 >= 0; j2--) { var bit = word >> j2 & 1; if (res !== wnd[0]) { res = this.sqr(res); } if (bit === 0 && current === 0) { currentLen = 0; continue; } current <<= 1; current |= bit; currentLen++; if (currentLen !== windowSize && (i2 !== 0 || j2 !== 0)) continue; res = this.mul(res, wnd[current]); currentLen = 0; current = 0; } start = 26; } return res; }; Red.prototype.convertTo = function convertTo(num) { var r2 = num.umod(this.m); return r2 === num ? r2.clone() : r2; }; Red.prototype.convertFrom = function convertFrom(num) { var res = num.clone(); res.red = null; return res; }; BN2.mont = function mont(num) { return new Mont(num); }; function Mont(m2) { Red.call(this, m2); this.shift = this.m.bitLength(); if (this.shift % 26 !== 0) { this.shift += 26 - this.shift % 26; } this.r = new BN2(1).iushln(this.shift); this.r2 = this.imod(this.r.sqr()); this.rinv = this.r._invmp(this.m); this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); this.minv = this.minv.umod(this.r); this.minv = this.r.sub(this.minv); } inherits2(Mont, Red); Mont.prototype.convertTo = function convertTo(num) { return this.imod(num.ushln(this.shift)); }; Mont.prototype.convertFrom = function convertFrom(num) { var r2 = this.imod(num.mul(this.rinv)); r2.red = null; return r2; }; Mont.prototype.imul = function imul(a2, b2) { if (a2.isZero() || b2.isZero()) { a2.words[0] = 0; a2.length = 1; return a2; } var t2 = a2.imul(b2); var c2 = t2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); var u = t2.isub(c2).iushrn(this.shift); var res = u; if (u.cmp(this.m) >= 0) { res = u.isub(this.m); } else if (u.cmpn(0) < 0) { res = u.iadd(this.m); } return res._forceRed(this); }; Mont.prototype.mul = function mul3(a2, b2) { if (a2.isZero() || b2.isZero()) return new BN2(0)._forceRed(this); var t2 = a2.mul(b2); var c2 = t2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); var u = t2.isub(c2).iushrn(this.shift); var res = u; if (u.cmp(this.m) >= 0) { res = u.isub(this.m); } else if (u.cmpn(0) < 0) { res = u.iadd(this.m); } return res._forceRed(this); }; Mont.prototype.invm = function invm(a2) { var res = this.imod(a2._invmp(this.m).mul(this.r2)); return res._forceRed(this); }; })(module, commonjsGlobal); })(bn); const BN$1 = bnExports; const version$p = "logger/5.7.0"; let _permanentCensorErrors = false; let _censorErrors = false; const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 }; let _logLevel = LogLevels["default"]; let _globalLogger = null; function _checkNormalize() { try { const missing = []; ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => { try { if ("test".normalize(form) !== "test") { throw new Error("bad normalize"); } ; } catch (error) { missing.push(form); } }); if (missing.length) { throw new Error("missing " + missing.join(", ")); } if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) { throw new Error("broken implementation"); } } catch (error) { return error.message; } return null; } const _normalizeError = _checkNormalize(); var LogLevel; (function(LogLevel2) { LogLevel2["DEBUG"] = "DEBUG"; LogLevel2["INFO"] = "INFO"; LogLevel2["WARNING"] = "WARNING"; LogLevel2["ERROR"] = "ERROR"; LogLevel2["OFF"] = "OFF"; })(LogLevel || (LogLevel = {})); var ErrorCode; (function(ErrorCode2) { ErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR"; ErrorCode2["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED"; ErrorCode2["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION"; ErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR"; ErrorCode2["SERVER_ERROR"] = "SERVER_ERROR"; ErrorCode2["TIMEOUT"] = "TIMEOUT"; ErrorCode2["BUFFER_OVERRUN"] = "BUFFER_OVERRUN"; ErrorCode2["NUMERIC_FAULT"] = "NUMERIC_FAULT"; ErrorCode2["MISSING_NEW"] = "MISSING_NEW"; ErrorCode2["INVALID_ARGUMENT"] = "INVALID_ARGUMENT"; ErrorCode2["MISSING_ARGUMENT"] = "MISSING_ARGUMENT"; ErrorCode2["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT"; ErrorCode2["CALL_EXCEPTION"] = "CALL_EXCEPTION"; ErrorCode2["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS"; ErrorCode2["NONCE_EXPIRED"] = "NONCE_EXPIRED"; ErrorCode2["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED"; ErrorCode2["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT"; ErrorCode2["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED"; ErrorCode2["ACTION_REJECTED"] = "ACTION_REJECTED"; })(ErrorCode || (ErrorCode = {})); const HEX = "0123456789abcdef"; class Logger { constructor(version2) { Object.defineProperty(this, "version", { enumerable: true, value: version2, writable: false }); } _log(logLevel, args) { const level = logLevel.toLowerCase(); if (LogLevels[level] == null) { this.throwArgumentError("invalid log level name", "logLevel", logLevel); } if (_logLevel > LogLevels[level]) { return; } console.log.apply(console, args); } debug(...args) { this._log(Logger.levels.DEBUG, args); } info(...args) { this._log(Logger.levels.INFO, args); } warn(...args) { this._log(Logger.levels.WARNING, args); } makeError(message, code2, params) { if (_censorErrors) { return this.makeError("censored error", code2, {}); } if (!code2) { code2 = Logger.errors.UNKNOWN_ERROR; } if (!params) { params = {}; } const messageDetails = []; Object.keys(params).forEach((key2) => { const value = params[key2]; try { if (value instanceof Uint8Array) { let hex = ""; for (let i2 = 0; i2 < value.length; i2++) { hex += HEX[value[i2] >> 4]; hex += HEX[value[i2] & 15]; } messageDetails.push(key2 + "=Uint8Array(0x" + hex + ")"); } else { messageDetails.push(key2 + "=" + JSON.stringify(value)); } } catch (error2) { messageDetails.push(key2 + "=" + JSON.stringify(params[key2].toString())); } }); messageDetails.push(`code=${code2}`); messageDetails.push(`version=${this.version}`); const reason = message; let url = ""; switch (code2) { case ErrorCode.NUMERIC_FAULT: { url = "NUMERIC_FAULT"; const fault = message; switch (fault) { case "overflow": case "underflow": case "division-by-zero": url += "-" + fault; break; case "negative-power": case "negative-width": url += "-unsupported"; break; case "unbound-bitwise-result": url += "-unbound-result"; break; } break; } case ErrorCode.CALL_EXCEPTION: case ErrorCode.INSUFFICIENT_FUNDS: case ErrorCode.MISSING_NEW: case ErrorCode.NONCE_EXPIRED: case ErrorCode.REPLACEMENT_UNDERPRICED: case ErrorCode.TRANSACTION_REPLACED: case ErrorCode.UNPREDICTABLE_GAS_LIMIT: url = code2; break; } if (url) { message += " [ See: https://links.ethers.org/v5-errors-" + url + " ]"; } if (messageDetails.length) { message += " (" + messageDetails.join(", ") + ")"; } const error = new Error(message); error.reason = reason; error.code = code2; Object.keys(params).forEach(function(key2) { error[key2] = params[key2]; }); return error; } throwError(message, code2, params) { throw this.makeError(message, code2, params); } throwArgumentError(message, name, value) { return this.throwError(message, Logger.errors.INVALID_ARGUMENT, { argument: name, value }); } assert(condition, message, code2, params) { if (!!condition) { return; } this.throwError(message, code2, params); } assertArgument(condition, message, name, value) { if (!!condition) { return; } this.throwArgumentError(message, name, value); } checkNormalize(message) { if (_normalizeError) { this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: _normalizeError }); } } checkSafeUint53(value, message) { if (typeof value !== "number") { return; } if (message == null) { message = "value not safe"; } if (value < 0 || value >= 9007199254740991) { this.throwError(message, Logger.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value }); } if (value % 1) { this.throwError(message, Logger.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value }); } } checkArgumentCount(count, expectedCount, message) { if (message) { message = ": " + message; } else { message = ""; } if (count < expectedCount) { this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, { count, expectedCount }); } if (count > expectedCount) { this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, { count, expectedCount }); } } checkNew(target, kind) { if (target === Object || target == null) { this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); } } checkAbstract(target, kind) { if (target === kind) { this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); } else if (target === Object || target == null) { this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); } } static globalLogger() { if (!_globalLogger) { _globalLogger = new Logger(version$p); } return _globalLogger; } static setCensorship(censorship, permanent) { if (!censorship && permanent) { this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } if (_permanentCensorErrors) { if (!censorship) { return; } this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } _censorErrors = !!censorship; _permanentCensorErrors = !!permanent; } static setLogLevel(logLevel) { const level = LogLevels[logLevel.toLowerCase()]; if (level == null) { Logger.globalLogger().warn("invalid log level - " + logLevel); return; } _logLevel = level; } static from(version2) { return new Logger(version2); } } Logger.errors = ErrorCode; Logger.levels = LogLevel; const lib_esm$k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, get ErrorCode() { return ErrorCode; }, get LogLevel() { return LogLevel; }, Logger }, Symbol.toStringTag, { value: "Module" })); const version$o = "bytes/5.7.0"; const logger$A = new Logger(version$o); function isHexable(value) { return !!value.toHexString; } function addSlice(array) { if (array.slice) { return array; } array.slice = function() { const args = Array.prototype.slice.call(arguments); return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); }; return array; } function isBytesLike(value) { return isHexString(value) && !(value.length % 2) || isBytes(value); } function isInteger(value) { return typeof value === "number" && value == value && value % 1 === 0; } function isBytes(value) { if (value == null) { return false; } if (value.constructor === Uint8Array) { return true; } if (typeof value === "string") { return false; } if (!isInteger(value.length) || value.length < 0) { return false; } for (let i2 = 0; i2 < value.length; i2++) { const v2 = value[i2]; if (!isInteger(v2) || v2 < 0 || v2 >= 256) { return false; } } return true; } function arrayify(value, options) { if (!options) { options = {}; } if (typeof value === "number") { logger$A.checkSafeUint53(value, "invalid arrayify value"); const result = []; while (value) { result.unshift(value & 255); value = parseInt(String(value / 256)); } if (result.length === 0) { result.push(0); } return addSlice(new Uint8Array(result)); } if (options.allowMissingPrefix && typeof value === "string" && value.substring(0, 2) !== "0x") { value = "0x" + value; } if (isHexable(value)) { value = value.toHexString(); } if (isHexString(value)) { let hex = value.substring(2); if (hex.length % 2) { if (options.hexPad === "left") { hex = "0" + hex; } else if (options.hexPad === "right") { hex += "0"; } else { logger$A.throwArgumentError("hex data is odd-length", "value", value); } } const result = []; for (let i2 = 0; i2 < hex.length; i2 += 2) { result.push(parseInt(hex.substring(i2, i2 + 2), 16)); } return addSlice(new Uint8Array(result)); } if (isBytes(value)) { return addSlice(new Uint8Array(value)); } return logger$A.throwArgumentError("invalid arrayify value", "value", value); } function concat(items) { const objects = items.map((item) => arrayify(item)); const length = objects.reduce((accum, item) => accum + item.length, 0); const result = new Uint8Array(length); objects.reduce((offset, object) => { result.set(object, offset); return offset + object.length; }, 0); return addSlice(result); } function stripZeros(value) { let result = arrayify(value); if (result.length === 0) { return result; } let start = 0; while (start < result.length && result[start] === 0) { start++; } if (start) { result = result.slice(start); } return result; } function zeroPad(value, length) { value = arrayify(value); if (value.length > length) { logger$A.throwArgumentError("value out of range", "value", arguments[0]); } const result = new Uint8Array(length); result.set(value, length - value.length); return addSlice(result); } function isHexString(value, length) { if (typeof value !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { return false; } if (length && value.length !== 2 + 2 * length) { return false; } return true; } const HexCharacters = "0123456789abcdef"; function hexlify(value, options) { if (!options) { options = {}; } if (typeof value === "number") { logger$A.checkSafeUint53(value, "invalid hexlify value"); let hex = ""; while (value) { hex = HexCharacters[value & 15] + hex; value = Math.floor(value / 16); } if (hex.length) { if (hex.length % 2) { hex = "0" + hex; } return "0x" + hex; } return "0x00"; } if (typeof value === "bigint") { value = value.toString(16); if (value.length % 2) { return "0x0" + value; } return "0x" + value; } if (options.allowMissingPrefix && typeof value === "string" && value.substring(0, 2) !== "0x") { value = "0x" + value; } if (isHexable(value)) { return value.toHexString(); } if (isHexString(value)) { if (value.length % 2) { if (options.hexPad === "left") { value = "0x0" + value.substring(2); } else if (options.hexPad === "right") { value += "0"; } else { logger$A.throwArgumentError("hex data is odd-length", "value", value); } } return value.toLowerCase(); } if (isBytes(value)) { let result = "0x"; for (let i2 = 0; i2 < value.length; i2++) { let v2 = value[i2]; result += HexCharacters[(v2 & 240) >> 4] + HexCharacters[v2 & 15]; } return result; } return logger$A.throwArgumentError("invalid hexlify value", "value", value); } function hexDataLength(data) { if (typeof data !== "string") { data = hexlify(data); } else if (!isHexString(data) || data.length % 2) { return null; } return (data.length - 2) / 2; } function hexDataSlice(data, offset, endOffset) { if (typeof data !== "string") { data = hexlify(data); } else if (!isHexString(data) || data.length % 2) { logger$A.throwArgumentError("invalid hexData", "value", data); } offset = 2 + 2 * offset; if (endOffset != null) { return "0x" + data.substring(offset, 2 + 2 * endOffset); } return "0x" + data.substring(offset); } function hexConcat(items) { let result = "0x"; items.forEach((item) => { result += hexlify(item).substring(2); }); return result; } function hexValue(value) { const trimmed = hexStripZeros(hexlify(value, { hexPad: "left" })); if (trimmed === "0x") { return "0x0"; } return trimmed; } function hexStripZeros(value) { if (typeof value !== "string") { value = hexlify(value); } if (!isHexString(value)) { logger$A.throwArgumentError("invalid hex string", "value", value); } value = value.substring(2); let offset = 0; while (offset < value.length && value[offset] === "0") { offset++; } return "0x" + value.substring(offset); } function hexZeroPad(value, length) { if (typeof value !== "string") { value = hexlify(value); } else if (!isHexString(value)) { logger$A.throwArgumentError("invalid hex string", "value", value); } if (value.length > 2 * length + 2) { logger$A.throwArgumentError("value out of range", "value", arguments[1]); } while (value.length < 2 * length + 2) { value = "0x0" + value.substring(2); } return value; } function splitSignature(signature2) { const result = { r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0, yParityAndS: "0x", compact: "0x" }; if (isBytesLike(signature2)) { let bytes = arrayify(signature2); if (bytes.length === 64) { result.v = 27 + (bytes[32] >> 7); bytes[32] &= 127; result.r = hexlify(bytes.slice(0, 32)); result.s = hexlify(bytes.slice(32, 64)); } else if (bytes.length === 65) { result.r = hexlify(bytes.slice(0, 32)); result.s = hexlify(bytes.slice(32, 64)); result.v = bytes[64]; } else { logger$A.throwArgumentError("invalid signature string", "signature", signature2); } if (result.v < 27) { if (result.v === 0 || result.v === 1) { result.v += 27; } else { logger$A.throwArgumentError("signature invalid v byte", "signature", signature2); } } result.recoveryParam = 1 - result.v % 2; if (result.recoveryParam) { bytes[32] |= 128; } result._vs = hexlify(bytes.slice(32, 64)); } else { result.r = signature2.r; result.s = signature2.s; result.v = signature2.v; result.recoveryParam = signature2.recoveryParam; result._vs = signature2._vs; if (result._vs != null) { const vs2 = zeroPad(arrayify(result._vs), 32); result._vs = hexlify(vs2); const recoveryParam = vs2[0] >= 128 ? 1 : 0; if (result.recoveryParam == null) { result.recoveryParam = recoveryParam; } else if (result.recoveryParam !== recoveryParam) { logger$A.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature2); } vs2[0] &= 127; const s2 = hexlify(vs2); if (result.s == null) { result.s = s2; } else if (result.s !== s2) { logger$A.throwArgumentError("signature v mismatch _vs", "signature", signature2); } } if (result.recoveryParam == null) { if (result.v == null) { logger$A.throwArgumentError("signature missing v and recoveryParam", "signature", signature2); } else if (result.v === 0 || result.v === 1) { result.recoveryParam = result.v; } else { result.recoveryParam = 1 - result.v % 2; } } else { if (result.v == null) { result.v = 27 + result.recoveryParam; } else { const recId = result.v === 0 || result.v === 1 ? result.v : 1 - result.v % 2; if (result.recoveryParam !== recId) { logger$A.throwArgumentError("signature recoveryParam mismatch v", "signature", signature2); } } } if (result.r == null || !isHexString(result.r)) { logger$A.throwArgumentError("signature missing or invalid r", "signature", signature2); } else { result.r = hexZeroPad(result.r, 32); } if (result.s == null || !isHexString(result.s)) { logger$A.throwArgumentError("signature missing or invalid s", "signature", signature2); } else { result.s = hexZeroPad(result.s, 32); } const vs = arrayify(result.s); if (vs[0] >= 128) { logger$A.throwArgumentError("signature s out of range", "signature", signature2); } if (result.recoveryParam) { vs[0] |= 128; } const _vs = hexlify(vs); if (result._vs) { if (!isHexString(result._vs)) { logger$A.throwArgumentError("signature invalid _vs", "signature", signature2); } result._vs = hexZeroPad(result._vs, 32); } if (result._vs == null) { result._vs = _vs; } else if (result._vs !== _vs) { logger$A.throwArgumentError("signature _vs mismatch v and s", "signature", signature2); } } result.yParityAndS = result._vs; result.compact = result.r + result.yParityAndS.substring(2); return result; } function joinSignature(signature2) { signature2 = splitSignature(signature2); return hexlify(concat([ signature2.r, signature2.s, signature2.recoveryParam ? "0x1c" : "0x1b" ])); } const lib_esm$j = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, arrayify, concat, hexConcat, hexDataLength, hexDataSlice, hexStripZeros, hexValue, hexZeroPad, hexlify, isBytes, isBytesLike, isHexString, joinSignature, splitSignature, stripZeros, zeroPad }, Symbol.toStringTag, { value: "Module" })); const version$n = "bignumber/5.7.0"; var BN = BN$1.BN; const logger$z = new Logger(version$n); const _constructorGuard$4 = {}; const MAX_SAFE = 9007199254740991; function isBigNumberish(value) { return value != null && (BigNumber.isBigNumber(value) || typeof value === "number" && value % 1 === 0 || typeof value === "string" && !!value.match(/^-?[0-9]+$/) || isHexString(value) || typeof value === "bigint" || isBytes(value)); } let _warnedToStringRadix = false; class BigNumber { constructor(constructorGuard, hex) { if (constructorGuard !== _constructorGuard$4) { logger$z.throwError("cannot call constructor directly; use BigNumber.from", Logger.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }); } this._hex = hex; this._isBigNumber = true; Object.freeze(this); } fromTwos(value) { return toBigNumber(toBN(this).fromTwos(value)); } toTwos(value) { return toBigNumber(toBN(this).toTwos(value)); } abs() { if (this._hex[0] === "-") { return BigNumber.from(this._hex.substring(1)); } return this; } add(other) { return toBigNumber(toBN(this).add(toBN(other))); } sub(other) { return toBigNumber(toBN(this).sub(toBN(other))); } div(other) { const o = BigNumber.from(other); if (o.isZero()) { throwFault$1("division-by-zero", "div"); } return toBigNumber(toBN(this).div(toBN(other))); } mul(other) { return toBigNumber(toBN(this).mul(toBN(other))); } mod(other) { const value = toBN(other); if (value.isNeg()) { throwFault$1("division-by-zero", "mod"); } return toBigNumber(toBN(this).umod(value)); } pow(other) { const value = toBN(other); if (value.isNeg()) { throwFault$1("negative-power", "pow"); } return toBigNumber(toBN(this).pow(value)); } and(other) { const value = toBN(other); if (this.isNegative() || value.isNeg()) { throwFault$1("unbound-bitwise-result", "and"); } return toBigNumber(toBN(this).and(value)); } or(other) { const value = toBN(other); if (this.isNegative() || value.isNeg()) { throwFault$1("unbound-bitwise-result", "or"); } return toBigNumber(toBN(this).or(value)); } xor(other) { const value = toBN(other); if (this.isNegative() || value.isNeg()) { throwFault$1("unbound-bitwise-result", "xor"); } return toBigNumber(toBN(this).xor(value)); } mask(value) { if (this.isNegative() || value < 0) { throwFault$1("negative-width", "mask"); } return toBigNumber(toBN(this).maskn(value)); } shl(value) { if (this.isNegative() || value < 0) { throwFault$1("negative-width", "shl"); } return toBigNumber(toBN(this).shln(value)); } shr(value) { if (this.isNegative() || value < 0) { throwFault$1("negative-width", "shr"); } return toBigNumber(toBN(this).shrn(value)); } eq(other) { return toBN(this).eq(toBN(other)); } lt(other) { return toBN(this).lt(toBN(other)); } lte(other) { return toBN(this).lte(toBN(other)); } gt(other) { return toBN(this).gt(toBN(other)); } gte(other) { return toBN(this).gte(toBN(other)); } isNegative() { return this._hex[0] === "-"; } isZero() { return toBN(this).isZero(); } toNumber() { try { return toBN(this).toNumber(); } catch (error) { throwFault$1("overflow", "toNumber", this.toString()); } return null; } toBigInt() { try { return BigInt(this.toString()); } catch (e) { } return logger$z.throwError("this platform does not support BigInt", Logger.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); } toString() { if (arguments.length > 0) { if (arguments[0] === 10) { if (!_warnedToStringRadix) { _warnedToStringRadix = true; logger$z.warn("BigNumber.toString does not accept any parameters; base-10 is assumed"); } } else if (arguments[0] === 16) { logger$z.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", Logger.errors.UNEXPECTED_ARGUMENT, {}); } else { logger$z.throwError("BigNumber.toString does not accept parameters", Logger.errors.UNEXPECTED_ARGUMENT, {}); } } return toBN(this).toString(10); } toHexString() { return this._hex; } toJSON(key2) { return { type: "BigNumber", hex: this.toHexString() }; } static from(value) { if (value instanceof BigNumber) { return value; } if (typeof value === "string") { if (value.match(/^-?0x[0-9a-f]+$/i)) { return new BigNumber(_constructorGuard$4, toHex$1(value)); } if (value.match(/^-?[0-9]+$/)) { return new BigNumber(_constructorGuard$4, toHex$1(new BN(value))); } return logger$z.throwArgumentError("invalid BigNumber string", "value", value); } if (typeof value === "number") { if (value % 1) { throwFault$1("underflow", "BigNumber.from", value); } if (value >= MAX_SAFE || value <= -MAX_SAFE) { throwFault$1("overflow", "BigNumber.from", value); } return BigNumber.from(String(value)); } const anyValue = value; if (typeof anyValue === "bigint") { return BigNumber.from(anyValue.toString()); } if (isBytes(anyValue)) { return BigNumber.from(hexlify(anyValue)); } if (anyValue) { if (anyValue.toHexString) { const hex = anyValue.toHexString(); if (typeof hex === "string") { return BigNumber.from(hex); } } else { let hex = anyValue._hex; if (hex == null && anyValue.type === "BigNumber") { hex = anyValue.hex; } if (typeof hex === "string") { if (isHexString(hex) || hex[0] === "-" && isHexString(hex.substring(1))) { return BigNumber.from(hex); } } } } return logger$z.throwArgumentError("invalid BigNumber value", "value", value); } static isBigNumber(value) { return !!(value && value._isBigNumber); } } function toHex$1(value) { if (typeof value !== "string") { return toHex$1(value.toString(16)); } if (value[0] === "-") { value = value.substring(1); if (value[0] === "-") { logger$z.throwArgumentError("invalid hex", "value", value); } value = toHex$1(value); if (value === "0x00") { return value; } return "-" + value; } if (value.substring(0, 2) !== "0x") { value = "0x" + value; } if (value === "0x") { return "0x00"; } if (value.length % 2) { value = "0x0" + value.substring(2); } while (value.length > 4 && value.substring(0, 4) === "0x00") { value = "0x" + value.substring(4); } return value; } function toBigNumber(value) { return BigNumber.from(toHex$1(value)); } function toBN(value) { const hex = BigNumber.from(value).toHexString(); if (hex[0] === "-") { return new BN("-" + hex.substring(3), 16); } return new BN(hex.substring(2), 16); } function throwFault$1(fault, operation, value) { const params = { fault, operation }; if (value != null) { params.value = value; } return logger$z.throwError(fault, Logger.errors.NUMERIC_FAULT, params); } function _base36To16(value) { return new BN(value, 36).toString(16); } function _base16To36(value) { return new BN(value, 16).toString(36); } const logger$y = new Logger(version$n); const _constructorGuard$3 = {}; const Zero$2 = BigNumber.from(0); const NegativeOne$2 = BigNumber.from(-1); function throwFault(message, fault, operation, value) { const params = { fault, operation }; if (value !== void 0) { params.value = value; } return logger$y.throwError(message, Logger.errors.NUMERIC_FAULT, params); } let zeros = "0"; while (zeros.length < 256) { zeros += zeros; } function getMultiplier(decimals) { if (typeof decimals !== "number") { try { decimals = BigNumber.from(decimals).toNumber(); } catch (e) { } } if (typeof decimals === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { return "1" + zeros.substring(0, decimals); } return logger$y.throwArgumentError("invalid decimal size", "decimals", decimals); } function formatFixed(value, decimals) { if (decimals == null) { decimals = 0; } const multiplier = getMultiplier(decimals); value = BigNumber.from(value); const negative = value.lt(Zero$2); if (negative) { value = value.mul(NegativeOne$2); } let fraction = value.mod(multiplier).toString(); while (fraction.length < multiplier.length - 1) { fraction = "0" + fraction; } fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; const whole = value.div(multiplier).toString(); if (multiplier.length === 1) { value = whole; } else { value = whole + "." + fraction; } if (negative) { value = "-" + value; } return value; } function parseFixed(value, decimals) { if (decimals == null) { decimals = 0; } const multiplier = getMultiplier(decimals); if (typeof value !== "string" || !value.match(/^-?[0-9.]+$/)) { logger$y.throwArgumentError("invalid decimal value", "value", value); } const negative = value.substring(0, 1) === "-"; if (negative) { value = value.substring(1); } if (value === ".") { logger$y.throwArgumentError("missing value", "value", value); } const comps = value.split("."); if (comps.length > 2) { logger$y.throwArgumentError("too many decimal points", "value", value); } let whole = comps[0], fraction = comps[1]; if (!whole) { whole = "0"; } if (!fraction) { fraction = "0"; } while (fraction[fraction.length - 1] === "0") { fraction = fraction.substring(0, fraction.length - 1); } if (fraction.length > multiplier.length - 1) { throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); } if (fraction === "") { fraction = "0"; } while (fraction.length < multiplier.length - 1) { fraction += "0"; } const wholeValue = BigNumber.from(whole); const fractionValue = BigNumber.from(fraction); let wei = wholeValue.mul(multiplier).add(fractionValue); if (negative) { wei = wei.mul(NegativeOne$2); } return wei; } class FixedFormat { constructor(constructorGuard, signed2, width, decimals) { if (constructorGuard !== _constructorGuard$3) { logger$y.throwError("cannot use FixedFormat constructor; use FixedFormat.from", Logger.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }); } this.signed = signed2; this.width = width; this.decimals = decimals; this.name = (signed2 ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); this._multiplier = getMultiplier(decimals); Object.freeze(this); } static from(value) { if (value instanceof FixedFormat) { return value; } if (typeof value === "number") { value = `fixed128x${value}`; } let signed2 = true; let width = 128; let decimals = 18; if (typeof value === "string") { if (value === "fixed") ; else if (value === "ufixed") { signed2 = false; } else { const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); if (!match) { logger$y.throwArgumentError("invalid fixed format", "format", value); } signed2 = match[1] !== "u"; width = parseInt(match[2]); decimals = parseInt(match[3]); } } else if (value) { const check = (key2, type, defaultValue) => { if (value[key2] == null) { return defaultValue; } if (typeof value[key2] !== type) { logger$y.throwArgumentError("invalid fixed format (" + key2 + " not " + type + ")", "format." + key2, value[key2]); } return value[key2]; }; signed2 = check("signed", "boolean", signed2); width = check("width", "number", width); decimals = check("decimals", "number", decimals); } if (width % 8) { logger$y.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); } if (decimals > 80) { logger$y.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); } return new FixedFormat(_constructorGuard$3, signed2, width, decimals); } } class FixedNumber { constructor(constructorGuard, hex, value, format) { if (constructorGuard !== _constructorGuard$3) { logger$y.throwError("cannot use FixedNumber constructor; use FixedNumber.from", Logger.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }); } this.format = format; this._hex = hex; this._value = value; this._isFixedNumber = true; Object.freeze(this); } _checkFormat(other) { if (this.format.name !== other.format.name) { logger$y.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); } } addUnsafe(other) { this._checkFormat(other); const a2 = parseFixed(this._value, this.format.decimals); const b2 = parseFixed(other._value, other.format.decimals); return FixedNumber.fromValue(a2.add(b2), this.format.decimals, this.format); } subUnsafe(other) { this._checkFormat(other); const a2 = parseFixed(this._value, this.format.decimals); const b2 = parseFixed(other._value, other.format.decimals); return FixedNumber.fromValue(a2.sub(b2), this.format.decimals, this.format); } mulUnsafe(other) { this._checkFormat(other); const a2 = parseFixed(this._value, this.format.decimals); const b2 = parseFixed(other._value, other.format.decimals); return FixedNumber.fromValue(a2.mul(b2).div(this.format._multiplier), this.format.decimals, this.format); } divUnsafe(other) { this._checkFormat(other); const a2 = parseFixed(this._value, this.format.decimals); const b2 = parseFixed(other._value, other.format.decimals); return FixedNumber.fromValue(a2.mul(this.format._multiplier).div(b2), this.format.decimals, this.format); } floor() { const comps = this.toString().split("."); if (comps.length === 1) { comps.push("0"); } let result = FixedNumber.from(comps[0], this.format); const hasFraction = !comps[1].match(/^(0*)$/); if (this.isNegative() && hasFraction) { result = result.subUnsafe(ONE.toFormat(result.format)); } return result; } ceiling() { const comps = this.toString().split("."); if (comps.length === 1) { comps.push("0"); } let result = FixedNumber.from(comps[0], this.format); const hasFraction = !comps[1].match(/^(0*)$/); if (!this.isNegative() && hasFraction) { result = result.addUnsafe(ONE.toFormat(result.format)); } return result; } // @TODO: Support other rounding algorithms round(decimals) { if (decimals == null) { decimals = 0; } const comps = this.toString().split("."); if (comps.length === 1) { comps.push("0"); } if (decimals < 0 || decimals > 80 || decimals % 1) { logger$y.throwArgumentError("invalid decimal count", "decimals", decimals); } if (comps[1].length <= decimals) { return this; } const factor = FixedNumber.from("1" + zeros.substring(0, decimals), this.format); const bump = BUMP.toFormat(this.format); return this.mulUnsafe(factor).addUnsafe(bump).floor().divUnsafe(factor); } isZero() { return this._value === "0.0" || this._value === "0"; } isNegative() { return this._value[0] === "-"; } toString() { return this._value; } toHexString(width) { if (width == null) { return this._hex; } if (width % 8) { logger$y.throwArgumentError("invalid byte width", "width", width); } const hex = BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); return hexZeroPad(hex, width / 8); } toUnsafeFloat() { return parseFloat(this.toString()); } toFormat(format) { return FixedNumber.fromString(this._value, format); } static fromValue(value, decimals, format) { if (format == null && decimals != null && !isBigNumberish(decimals)) { format = decimals; decimals = null; } if (decimals == null) { decimals = 0; } if (format == null) { format = "fixed"; } return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); } static fromString(value, format) { if (format == null) { format = "fixed"; } const fixedFormat = FixedFormat.from(format); const numeric = parseFixed(value, fixedFormat.decimals); if (!fixedFormat.signed && numeric.lt(Zero$2)) { throwFault("unsigned value cannot be negative", "overflow", "value", value); } let hex = null; if (fixedFormat.signed) { hex = numeric.toTwos(fixedFormat.width).toHexString(); } else { hex = numeric.toHexString(); hex = hexZeroPad(hex, fixedFormat.width / 8); } const decimal = formatFixed(numeric, fixedFormat.decimals); return new FixedNumber(_constructorGuard$3, hex, decimal, fixedFormat); } static fromBytes(value, format) { if (format == null) { format = "fixed"; } const fixedFormat = FixedFormat.from(format); if (arrayify(value).length > fixedFormat.width / 8) { throw new Error("overflow"); } let numeric = BigNumber.from(value); if (fixedFormat.signed) { numeric = numeric.fromTwos(fixedFormat.width); } const hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); const decimal = formatFixed(numeric, fixedFormat.decimals); return new FixedNumber(_constructorGuard$3, hex, decimal, fixedFormat); } static from(value, format) { if (typeof value === "string") { return FixedNumber.fromString(value, format); } if (isBytes(value)) { return FixedNumber.fromBytes(value, format); } try { return FixedNumber.fromValue(value, 0, format); } catch (error) { if (error.code !== Logger.errors.INVALID_ARGUMENT) { throw error; } } return logger$y.throwArgumentError("invalid FixedNumber value", "value", value); } static isFixedNumber(value) { return !!(value && value._isFixedNumber); } } const ONE = FixedNumber.from(1); const BUMP = FixedNumber.from("0.5"); const version$m = "properties/5.7.0"; var __awaiter$d = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$x = new Logger(version$m); function defineReadOnly(object, name, value) { Object.defineProperty(object, name, { enumerable: true, value, writable: false }); } function getStatic(ctor, key2) { for (let i2 = 0; i2 < 32; i2++) { if (ctor[key2]) { return ctor[key2]; } if (!ctor.prototype || typeof ctor.prototype !== "object") { break; } ctor = Object.getPrototypeOf(ctor.prototype).constructor; } return null; } function resolveProperties(object) { return __awaiter$d(this, void 0, void 0, function* () { const promises = Object.keys(object).map((key2) => { const value = object[key2]; return Promise.resolve(value).then((v2) => ({ key: key2, value: v2 })); }); const results = yield Promise.all(promises); return results.reduce((accum, result) => { accum[result.key] = result.value; return accum; }, {}); }); } function checkProperties(object, properties) { if (!object || typeof object !== "object") { logger$x.throwArgumentError("invalid object", "object", object); } Object.keys(object).forEach((key2) => { if (!properties[key2]) { logger$x.throwArgumentError("invalid object key - " + key2, "transaction:" + key2, object); } }); } function shallowCopy(object) { const result = {}; for (const key2 in object) { result[key2] = object[key2]; } return result; } const opaque = { bigint: true, boolean: true, "function": true, number: true, string: true }; function _isFrozen(object) { if (object === void 0 || object === null || opaque[typeof object]) { return true; } if (Array.isArray(object) || typeof object === "object") { if (!Object.isFrozen(object)) { return false; } const keys = Object.keys(object); for (let i2 = 0; i2 < keys.length; i2++) { let value = null; try { value = object[keys[i2]]; } catch (error) { continue; } if (!_isFrozen(value)) { return false; } } return true; } return logger$x.throwArgumentError(`Cannot deepCopy ${typeof object}`, "object", object); } function _deepCopy(object) { if (_isFrozen(object)) { return object; } if (Array.isArray(object)) { return Object.freeze(object.map((item) => deepCopy(item))); } if (typeof object === "object") { const result = {}; for (const key2 in object) { const value = object[key2]; if (value === void 0) { continue; } defineReadOnly(result, key2, deepCopy(value)); } return result; } return logger$x.throwArgumentError(`Cannot deepCopy ${typeof object}`, "object", object); } function deepCopy(object) { return _deepCopy(object); } class Description { constructor(info) { for (const key2 in info) { this[key2] = deepCopy(info[key2]); } } } const lib_esm$i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, Description, checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy }, Symbol.toStringTag, { value: "Module" })); const version$l = "abi/5.7.0"; const logger$w = new Logger(version$l); const _constructorGuard$2 = {}; let ModifiersBytes = { calldata: true, memory: true, storage: true }; let ModifiersNest = { calldata: true, memory: true }; function checkModifier(type, name) { if (type === "bytes" || type === "string") { if (ModifiersBytes[name]) { return true; } } else if (type === "address") { if (name === "payable") { return true; } } else if (type.indexOf("[") >= 0 || type === "tuple") { if (ModifiersNest[name]) { return true; } } if (ModifiersBytes[name] || name === "payable") { logger$w.throwArgumentError("invalid modifier", "name", name); } return false; } function parseParamType(param, allowIndexed) { let originalParam = param; function throwError(i2) { logger$w.throwArgumentError(`unexpected character at position ${i2}`, "param", param); } param = param.replace(/\s/g, " "); function newNode(parent2) { let node2 = { type: "", name: "", parent: parent2, state: { allowType: true } }; if (allowIndexed) { node2.indexed = false; } return node2; } let parent = { type: "", name: "", state: { allowType: true } }; let node = parent; for (let i2 = 0; i2 < param.length; i2++) { let c2 = param[i2]; switch (c2) { case "(": if (node.state.allowType && node.type === "") { node.type = "tuple"; } else if (!node.state.allowParams) { throwError(i2); } node.state.allowType = false; node.type = verifyType(node.type); node.components = [newNode(node)]; node = node.components[0]; break; case ")": delete node.state; if (node.name === "indexed") { if (!allowIndexed) { throwError(i2); } node.indexed = true; node.name = ""; } if (checkModifier(node.type, node.name)) { node.name = ""; } node.type = verifyType(node.type); let child = node; node = node.parent; if (!node) { throwError(i2); } delete child.parent; node.state.allowParams = false; node.state.allowName = true; node.state.allowArray = true; break; case ",": delete node.state; if (node.name === "indexed") { if (!allowIndexed) { throwError(i2); } node.indexed = true; node.name = ""; } if (checkModifier(node.type, node.name)) { node.name = ""; } node.type = verifyType(node.type); let sibling = newNode(node.parent); node.parent.components.push(sibling); delete node.parent; node = sibling; break; case " ": if (node.state.allowType) { if (node.type !== "") { node.type = verifyType(node.type); delete node.state.allowType; node.state.allowName = true; node.state.allowParams = true; } } if (node.state.allowName) { if (node.name !== "") { if (node.name === "indexed") { if (!allowIndexed) { throwError(i2); } if (node.indexed) { throwError(i2); } node.indexed = true; node.name = ""; } else if (checkModifier(node.type, node.name)) { node.name = ""; } else { node.state.allowName = false; } } } break; case "[": if (!node.state.allowArray) { throwError(i2); } node.type += c2; node.state.allowArray = false; node.state.allowName = false; node.state.readArray = true; break; case "]": if (!node.state.readArray) { throwError(i2); } node.type += c2; node.state.readArray = false; node.state.allowArray = true; node.state.allowName = true; break; default: if (node.state.allowType) { node.type += c2; node.state.allowParams = true; node.state.allowArray = true; } else if (node.state.allowName) { node.name += c2; delete node.state.allowArray; } else if (node.state.readArray) { node.type += c2; } else { throwError(i2); } } } if (node.parent) { logger$w.throwArgumentError("unexpected eof", "param", param); } delete parent.state; if (node.name === "indexed") { if (!allowIndexed) { throwError(originalParam.length - 7); } if (node.indexed) { throwError(originalParam.length - 7); } node.indexed = true; node.name = ""; } else if (checkModifier(node.type, node.name)) { node.name = ""; } parent.type = verifyType(parent.type); return parent; } function populate(object, params) { for (let key2 in params) { defineReadOnly(object, key2, params[key2]); } } const FormatTypes = Object.freeze({ // Bare formatting, as is needed for computing a sighash of an event or function sighash: "sighash", // Human-Readable with Minimal spacing and without names (compact human-readable) minimal: "minimal", // Human-Readable with nice spacing, including all names full: "full", // JSON-format a la Solidity json: "json" }); const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); class ParamType { constructor(constructorGuard, params) { if (constructorGuard !== _constructorGuard$2) { logger$w.throwError("use fromString", Logger.errors.UNSUPPORTED_OPERATION, { operation: "new ParamType()" }); } populate(this, params); let match = this.type.match(paramTypeArray); if (match) { populate(this, { arrayLength: parseInt(match[2] || "-1"), arrayChildren: ParamType.fromObject({ type: match[1], components: this.components }), baseType: "array" }); } else { populate(this, { arrayLength: null, arrayChildren: null, baseType: this.components != null ? "tuple" : this.type }); } this._isParamType = true; Object.freeze(this); } // Format the parameter fragment // - sighash: "(uint256,address)" // - minimal: "tuple(uint256,address) indexed" // - full: "tuple(uint256 foo, address bar) indexed baz" format(format) { if (!format) { format = FormatTypes.sighash; } if (!FormatTypes[format]) { logger$w.throwArgumentError("invalid format type", "format", format); } if (format === FormatTypes.json) { let result2 = { type: this.baseType === "tuple" ? "tuple" : this.type, name: this.name || void 0 }; if (typeof this.indexed === "boolean") { result2.indexed = this.indexed; } if (this.components) { result2.components = this.components.map((comp) => JSON.parse(comp.format(format))); } return JSON.stringify(result2); } let result = ""; if (this.baseType === "array") { result += this.arrayChildren.format(format); result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]"; } else { if (this.baseType === "tuple") { if (format !== FormatTypes.sighash) { result += this.type; } result += "(" + this.components.map((comp) => comp.format(format)).join(format === FormatTypes.full ? ", " : ",") + ")"; } else { result += this.type; } } if (format !== FormatTypes.sighash) { if (this.indexed === true) { result += " indexed"; } if (format === FormatTypes.full && this.name) { result += " " + this.name; } } return result; } static from(value, allowIndexed) { if (typeof value === "string") { return ParamType.fromString(value, allowIndexed); } return ParamType.fromObject(value); } static fromObject(value) { if (ParamType.isParamType(value)) { return value; } return new ParamType(_constructorGuard$2, { name: value.name || null, type: verifyType(value.type), indexed: value.indexed == null ? null : !!value.indexed, components: value.components ? value.components.map(ParamType.fromObject) : null }); } static fromString(value, allowIndexed) { function ParamTypify(node) { return ParamType.fromObject({ name: node.name, type: node.type, indexed: node.indexed, components: node.components }); } return ParamTypify(parseParamType(value, !!allowIndexed)); } static isParamType(value) { return !!(value != null && value._isParamType); } } function parseParams(value, allowIndex) { return splitNesting(value).map((param) => ParamType.fromString(param, allowIndex)); } class Fragment { constructor(constructorGuard, params) { if (constructorGuard !== _constructorGuard$2) { logger$w.throwError("use a static from method", Logger.errors.UNSUPPORTED_OPERATION, { operation: "new Fragment()" }); } populate(this, params); this._isFragment = true; Object.freeze(this); } static from(value) { if (Fragment.isFragment(value)) { return value; } if (typeof value === "string") { return Fragment.fromString(value); } return Fragment.fromObject(value); } static fromObject(value) { if (Fragment.isFragment(value)) { return value; } switch (value.type) { case "function": return FunctionFragment.fromObject(value); case "event": return EventFragment.fromObject(value); case "constructor": return ConstructorFragment.fromObject(value); case "error": return ErrorFragment.fromObject(value); case "fallback": case "receive": return null; } return logger$w.throwArgumentError("invalid fragment object", "value", value); } static fromString(value) { value = value.replace(/\s/g, " "); value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); value = value.trim(); if (value.split(" ")[0] === "event") { return EventFragment.fromString(value.substring(5).trim()); } else if (value.split(" ")[0] === "function") { return FunctionFragment.fromString(value.substring(8).trim()); } else if (value.split("(")[0].trim() === "constructor") { return ConstructorFragment.fromString(value.trim()); } else if (value.split(" ")[0] === "error") { return ErrorFragment.fromString(value.substring(5).trim()); } return logger$w.throwArgumentError("unsupported fragment", "value", value); } static isFragment(value) { return !!(value && value._isFragment); } } class EventFragment extends Fragment { format(format) { if (!format) { format = FormatTypes.sighash; } if (!FormatTypes[format]) { logger$w.throwArgumentError("invalid format type", "format", format); } if (format === FormatTypes.json) { return JSON.stringify({ type: "event", anonymous: this.anonymous, name: this.name, inputs: this.inputs.map((input) => JSON.parse(input.format(format))) }); } let result = ""; if (format !== FormatTypes.sighash) { result += "event "; } result += this.name + "(" + this.inputs.map((input) => input.format(format)).join(format === FormatTypes.full ? ", " : ",") + ") "; if (format !== FormatTypes.sighash) { if (this.anonymous) { result += "anonymous "; } } return result.trim(); } static from(value) { if (typeof value === "string") { return EventFragment.fromString(value); } return EventFragment.fromObject(value); } static fromObject(value) { if (EventFragment.isEventFragment(value)) { return value; } if (value.type !== "event") { logger$w.throwArgumentError("invalid event object", "value", value); } const params = { name: verifyIdentifier(value.name), anonymous: value.anonymous, inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], type: "event" }; return new EventFragment(_constructorGuard$2, params); } static fromString(value) { let match = value.match(regexParen); if (!match) { logger$w.throwArgumentError("invalid event string", "value", value); } let anonymous = false; match[3].split(" ").forEach((modifier) => { switch (modifier.trim()) { case "anonymous": anonymous = true; break; case "": break; default: logger$w.warn("unknown modifier: " + modifier); } }); return EventFragment.fromObject({ name: match[1].trim(), anonymous, inputs: parseParams(match[2], true), type: "event" }); } static isEventFragment(value) { return value && value._isFragment && value.type === "event"; } } function parseGas(value, params) { params.gas = null; let comps = value.split("@"); if (comps.length !== 1) { if (comps.length > 2) { logger$w.throwArgumentError("invalid human-readable ABI signature", "value", value); } if (!comps[1].match(/^[0-9]+$/)) { logger$w.throwArgumentError("invalid human-readable ABI signature gas", "value", value); } params.gas = BigNumber.from(comps[1]); return comps[0]; } return value; } function parseModifiers(value, params) { params.constant = false; params.payable = false; params.stateMutability = "nonpayable"; value.split(" ").forEach((modifier) => { switch (modifier.trim()) { case "constant": params.constant = true; break; case "payable": params.payable = true; params.stateMutability = "payable"; break; case "nonpayable": params.payable = false; params.stateMutability = "nonpayable"; break; case "pure": params.constant = true; params.stateMutability = "pure"; break; case "view": params.constant = true; params.stateMutability = "view"; break; case "external": case "public": case "": break; default: console.log("unknown modifier: " + modifier); } }); } function verifyState(value) { let result = { constant: false, payable: true, stateMutability: "payable" }; if (value.stateMutability != null) { result.stateMutability = value.stateMutability; result.constant = result.stateMutability === "view" || result.stateMutability === "pure"; if (value.constant != null) { if (!!value.constant !== result.constant) { logger$w.throwArgumentError("cannot have constant function with mutability " + result.stateMutability, "value", value); } } result.payable = result.stateMutability === "payable"; if (value.payable != null) { if (!!value.payable !== result.payable) { logger$w.throwArgumentError("cannot have payable function with mutability " + result.stateMutability, "value", value); } } } else if (value.payable != null) { result.payable = !!value.payable; if (value.constant == null && !result.payable && value.type !== "constructor") { logger$w.throwArgumentError("unable to determine stateMutability", "value", value); } result.constant = !!value.constant; if (result.constant) { result.stateMutability = "view"; } else { result.stateMutability = result.payable ? "payable" : "nonpayable"; } if (result.payable && result.constant) { logger$w.throwArgumentError("cannot have constant payable function", "value", value); } } else if (value.constant != null) { result.constant = !!value.constant; result.payable = !result.constant; result.stateMutability = result.constant ? "view" : "payable"; } else if (value.type !== "constructor") { logger$w.throwArgumentError("unable to determine stateMutability", "value", value); } return result; } class ConstructorFragment extends Fragment { format(format) { if (!format) { format = FormatTypes.sighash; } if (!FormatTypes[format]) { logger$w.throwArgumentError("invalid format type", "format", format); } if (format === FormatTypes.json) { return JSON.stringify({ type: "constructor", stateMutability: this.stateMutability !== "nonpayable" ? this.stateMutability : void 0, payable: this.payable, gas: this.gas ? this.gas.toNumber() : void 0, inputs: this.inputs.map((input) => JSON.parse(input.format(format))) }); } if (format === FormatTypes.sighash) { logger$w.throwError("cannot format a constructor for sighash", Logger.errors.UNSUPPORTED_OPERATION, { operation: "format(sighash)" }); } let result = "constructor(" + this.inputs.map((input) => input.format(format)).join(format === FormatTypes.full ? ", " : ",") + ") "; if (this.stateMutability && this.stateMutability !== "nonpayable") { result += this.stateMutability + " "; } return result.trim(); } static from(value) { if (typeof value === "string") { return ConstructorFragment.fromString(value); } return ConstructorFragment.fromObject(value); } static fromObject(value) { if (ConstructorFragment.isConstructorFragment(value)) { return value; } if (value.type !== "constructor") { logger$w.throwArgumentError("invalid constructor object", "value", value); } let state = verifyState(value); if (state.constant) { logger$w.throwArgumentError("constructor cannot be constant", "value", value); } const params = { name: null, type: value.type, inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], payable: state.payable, stateMutability: state.stateMutability, gas: value.gas ? BigNumber.from(value.gas) : null }; return new ConstructorFragment(_constructorGuard$2, params); } static fromString(value) { let params = { type: "constructor" }; value = parseGas(value, params); let parens = value.match(regexParen); if (!parens || parens[1].trim() !== "constructor") { logger$w.throwArgumentError("invalid constructor string", "value", value); } params.inputs = parseParams(parens[2].trim(), false); parseModifiers(parens[3].trim(), params); return ConstructorFragment.fromObject(params); } static isConstructorFragment(value) { return value && value._isFragment && value.type === "constructor"; } } class FunctionFragment extends ConstructorFragment { format(format) { if (!format) { format = FormatTypes.sighash; } if (!FormatTypes[format]) { logger$w.throwArgumentError("invalid format type", "format", format); } if (format === FormatTypes.json) { return JSON.stringify({ type: "function", name: this.name, constant: this.constant, stateMutability: this.stateMutability !== "nonpayable" ? this.stateMutability : void 0, payable: this.payable, gas: this.gas ? this.gas.toNumber() : void 0, inputs: this.inputs.map((input) => JSON.parse(input.format(format))), outputs: this.outputs.map((output) => JSON.parse(output.format(format))) }); } let result = ""; if (format !== FormatTypes.sighash) { result += "function "; } result += this.name + "(" + this.inputs.map((input) => input.format(format)).join(format === FormatTypes.full ? ", " : ",") + ") "; if (format !== FormatTypes.sighash) { if (this.stateMutability) { if (this.stateMutability !== "nonpayable") { result += this.stateMutability + " "; } } else if (this.constant) { result += "view "; } if (this.outputs && this.outputs.length) { result += "returns (" + this.outputs.map((output) => output.format(format)).join(", ") + ") "; } if (this.gas != null) { result += "@" + this.gas.toString() + " "; } } return result.trim(); } static from(value) { if (typeof value === "string") { return FunctionFragment.fromString(value); } return FunctionFragment.fromObject(value); } static fromObject(value) { if (FunctionFragment.isFunctionFragment(value)) { return value; } if (value.type !== "function") { logger$w.throwArgumentError("invalid function object", "value", value); } let state = verifyState(value); const params = { type: value.type, name: verifyIdentifier(value.name), constant: state.constant, inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], outputs: value.outputs ? value.outputs.map(ParamType.fromObject) : [], payable: state.payable, stateMutability: state.stateMutability, gas: value.gas ? BigNumber.from(value.gas) : null }; return new FunctionFragment(_constructorGuard$2, params); } static fromString(value) { let params = { type: "function" }; value = parseGas(value, params); let comps = value.split(" returns "); if (comps.length > 2) { logger$w.throwArgumentError("invalid function string", "value", value); } let parens = comps[0].match(regexParen); if (!parens) { logger$w.throwArgumentError("invalid function signature", "value", value); } params.name = parens[1].trim(); if (params.name) { verifyIdentifier(params.name); } params.inputs = parseParams(parens[2], false); parseModifiers(parens[3].trim(), params); if (comps.length > 1) { let returns = comps[1].match(regexParen); if (returns[1].trim() != "" || returns[3].trim() != "") { logger$w.throwArgumentError("unexpected tokens", "value", value); } params.outputs = parseParams(returns[2], false); } else { params.outputs = []; } return FunctionFragment.fromObject(params); } static isFunctionFragment(value) { return value && value._isFragment && value.type === "function"; } } function checkForbidden(fragment) { const sig = fragment.format(); if (sig === "Error(string)" || sig === "Panic(uint256)") { logger$w.throwArgumentError(`cannot specify user defined ${sig} error`, "fragment", fragment); } return fragment; } class ErrorFragment extends Fragment { format(format) { if (!format) { format = FormatTypes.sighash; } if (!FormatTypes[format]) { logger$w.throwArgumentError("invalid format type", "format", format); } if (format === FormatTypes.json) { return JSON.stringify({ type: "error", name: this.name, inputs: this.inputs.map((input) => JSON.parse(input.format(format))) }); } let result = ""; if (format !== FormatTypes.sighash) { result += "error "; } result += this.name + "(" + this.inputs.map((input) => input.format(format)).join(format === FormatTypes.full ? ", " : ",") + ") "; return result.trim(); } static from(value) { if (typeof value === "string") { return ErrorFragment.fromString(value); } return ErrorFragment.fromObject(value); } static fromObject(value) { if (ErrorFragment.isErrorFragment(value)) { return value; } if (value.type !== "error") { logger$w.throwArgumentError("invalid error object", "value", value); } const params = { type: value.type, name: verifyIdentifier(value.name), inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [] }; return checkForbidden(new ErrorFragment(_constructorGuard$2, params)); } static fromString(value) { let params = { type: "error" }; let parens = value.match(regexParen); if (!parens) { logger$w.throwArgumentError("invalid error signature", "value", value); } params.name = parens[1].trim(); if (params.name) { verifyIdentifier(params.name); } params.inputs = parseParams(parens[2], false); return checkForbidden(ErrorFragment.fromObject(params)); } static isErrorFragment(value) { return value && value._isFragment && value.type === "error"; } } function verifyType(type) { if (type.match(/^uint($|[^1-9])/)) { type = "uint256" + type.substring(4); } else if (type.match(/^int($|[^1-9])/)) { type = "int256" + type.substring(3); } return type; } const regexIdentifier = new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$"); function verifyIdentifier(value) { if (!value || !value.match(regexIdentifier)) { logger$w.throwArgumentError(`invalid identifier "${value}"`, "value", value); } return value; } const regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"); function splitNesting(value) { value = value.trim(); let result = []; let accum = ""; let depth = 0; for (let offset = 0; offset < value.length; offset++) { let c2 = value[offset]; if (c2 === "," && depth === 0) { result.push(accum); accum = ""; } else { accum += c2; if (c2 === "(") { depth++; } else if (c2 === ")") { depth--; if (depth === -1) { logger$w.throwArgumentError("unbalanced parenthesis", "value", value); } } } } if (accum) { result.push(accum); } return result; } const logger$v = new Logger(version$l); function checkResultErrors(result) { const errors = []; const checkErrors = function(path, object) { if (!Array.isArray(object)) { return; } for (let key2 in object) { const childPath = path.slice(); childPath.push(key2); try { checkErrors(childPath, object[key2]); } catch (error) { errors.push({ path: childPath, error }); } } }; checkErrors([], result); return errors; } class Coder { constructor(name, type, localName, dynamic) { this.name = name; this.type = type; this.localName = localName; this.dynamic = dynamic; } _throwError(message, value) { logger$v.throwArgumentError(message, this.localName, value); } } class Writer { constructor(wordSize) { defineReadOnly(this, "wordSize", wordSize || 32); this._data = []; this._dataLength = 0; this._padding = new Uint8Array(wordSize); } get data() { return hexConcat(this._data); } get length() { return this._dataLength; } _writeData(data) { this._data.push(data); this._dataLength += data.length; return data.length; } appendWriter(writer) { return this._writeData(concat(writer._data)); } // Arrayish items; padded on the right to wordSize writeBytes(value) { let bytes = arrayify(value); const paddingOffset = bytes.length % this.wordSize; if (paddingOffset) { bytes = concat([bytes, this._padding.slice(paddingOffset)]); } return this._writeData(bytes); } _getValue(value) { let bytes = arrayify(BigNumber.from(value)); if (bytes.length > this.wordSize) { logger$v.throwError("value out-of-bounds", Logger.errors.BUFFER_OVERRUN, { length: this.wordSize, offset: bytes.length }); } if (bytes.length % this.wordSize) { bytes = concat([this._padding.slice(bytes.length % this.wordSize), bytes]); } return bytes; } // BigNumberish items; padded on the left to wordSize writeValue(value) { return this._writeData(this._getValue(value)); } writeUpdatableValue() { const offset = this._data.length; this._data.push(this._padding); this._dataLength += this.wordSize; return (value) => { this._data[offset] = this._getValue(value); }; } } class Reader { constructor(data, wordSize, coerceFunc, allowLoose) { defineReadOnly(this, "_data", arrayify(data)); defineReadOnly(this, "wordSize", wordSize || 32); defineReadOnly(this, "_coerceFunc", coerceFunc); defineReadOnly(this, "allowLoose", allowLoose); this._offset = 0; } get data() { return hexlify(this._data); } get consumed() { return this._offset; } // The default Coerce function static coerce(name, value) { let match = name.match("^u?int([0-9]+)$"); if (match && parseInt(match[1]) <= 48) { value = value.toNumber(); } return value; } coerce(name, value) { if (this._coerceFunc) { return this._coerceFunc(name, value); } return Reader.coerce(name, value); } _peekBytes(offset, length, loose) { let alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; if (this._offset + alignedLength > this._data.length) { if (this.allowLoose && loose && this._offset + length <= this._data.length) { alignedLength = length; } else { logger$v.throwError("data out-of-bounds", Logger.errors.BUFFER_OVERRUN, { length: this._data.length, offset: this._offset + alignedLength }); } } return this._data.slice(this._offset, this._offset + alignedLength); } subReader(offset) { return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc, this.allowLoose); } readBytes(length, loose) { let bytes = this._peekBytes(0, length, !!loose); this._offset += bytes.length; return bytes.slice(0, length); } readValue() { return BigNumber.from(this.readBytes(this.wordSize)); } } var sha3Exports = {}; var sha3$1 = { get exports() { return sha3Exports; }, set exports(v2) { sha3Exports = v2; } }; /** * [js-sha3]{@link https://github.com/emn178/js-sha3} * * @version 0.8.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2015-2018 * @license MIT */ (function(module) { (function() { var INPUT_ERROR = "input is invalid type"; var FINALIZE_ERROR = "finalize already called"; var WINDOW = typeof window === "object"; var root = WINDOW ? window : {}; if (root.JS_SHA3_NO_WINDOW) { WINDOW = false; } var WEB_WORKER = !WINDOW && typeof self === "object"; var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node; if (NODE_JS) { root = commonjsGlobal; } else if (WEB_WORKER) { root = self; } var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && true && module.exports; var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined"; var HEX_CHARS = "0123456789abcdef".split(""); var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; var KECCAK_PADDING = [1, 256, 65536, 16777216]; var PADDING = [6, 1536, 393216, 100663296]; var SHIFT = [0, 8, 16, 24]; var RC = [ 1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648 ]; var BITS = [224, 256, 384, 512]; var SHAKE_BITS = [128, 256]; var OUTPUT_TYPES = ["hex", "buffer", "arrayBuffer", "array", "digest"]; var CSHAKE_BYTEPAD = { "128": 168, "256": 136 }; if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { Array.isArray = function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; }; } if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { ArrayBuffer.isView = function(obj) { return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer; }; } var createOutputMethod = function(bits2, padding2, outputType) { return function(message) { return new Keccak(bits2, padding2, bits2).update(message)[outputType](); }; }; var createShakeOutputMethod = function(bits2, padding2, outputType) { return function(message, outputBits) { return new Keccak(bits2, padding2, outputBits).update(message)[outputType](); }; }; var createCshakeOutputMethod = function(bits2, padding2, outputType) { return function(message, outputBits, n2, s2) { return methods["cshake" + bits2].update(message, outputBits, n2, s2)[outputType](); }; }; var createKmacOutputMethod = function(bits2, padding2, outputType) { return function(key2, message, outputBits, s2) { return methods["kmac" + bits2].update(key2, message, outputBits, s2)[outputType](); }; }; var createOutputMethods = function(method, createMethod2, bits2, padding2) { for (var i3 = 0; i3 < OUTPUT_TYPES.length; ++i3) { var type = OUTPUT_TYPES[i3]; method[type] = createMethod2(bits2, padding2, type); } return method; }; var createMethod = function(bits2, padding2) { var method = createOutputMethod(bits2, padding2, "hex"); method.create = function() { return new Keccak(bits2, padding2, bits2); }; method.update = function(message) { return method.create().update(message); }; return createOutputMethods(method, createOutputMethod, bits2, padding2); }; var createShakeMethod = function(bits2, padding2) { var method = createShakeOutputMethod(bits2, padding2, "hex"); method.create = function(outputBits) { return new Keccak(bits2, padding2, outputBits); }; method.update = function(message, outputBits) { return method.create(outputBits).update(message); }; return createOutputMethods(method, createShakeOutputMethod, bits2, padding2); }; var createCshakeMethod = function(bits2, padding2) { var w = CSHAKE_BYTEPAD[bits2]; var method = createCshakeOutputMethod(bits2, padding2, "hex"); method.create = function(outputBits, n2, s2) { if (!n2 && !s2) { return methods["shake" + bits2].create(outputBits); } else { return new Keccak(bits2, padding2, outputBits).bytepad([n2, s2], w); } }; method.update = function(message, outputBits, n2, s2) { return method.create(outputBits, n2, s2).update(message); }; return createOutputMethods(method, createCshakeOutputMethod, bits2, padding2); }; var createKmacMethod = function(bits2, padding2) { var w = CSHAKE_BYTEPAD[bits2]; var method = createKmacOutputMethod(bits2, padding2, "hex"); method.create = function(key2, outputBits, s2) { return new Kmac(bits2, padding2, outputBits).bytepad(["KMAC", s2], w).bytepad([key2], w); }; method.update = function(key2, message, outputBits, s2) { return method.create(key2, outputBits, s2).update(message); }; return createOutputMethods(method, createKmacOutputMethod, bits2, padding2); }; var algorithms = [ { name: "keccak", padding: KECCAK_PADDING, bits: BITS, createMethod }, { name: "sha3", padding: PADDING, bits: BITS, createMethod }, { name: "shake", padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, { name: "cshake", padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, { name: "kmac", padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } ]; var methods = {}, methodNames = []; for (var i2 = 0; i2 < algorithms.length; ++i2) { var algorithm = algorithms[i2]; var bits = algorithm.bits; for (var j2 = 0; j2 < bits.length; ++j2) { var methodName = algorithm.name + "_" + bits[j2]; methodNames.push(methodName); methods[methodName] = algorithm.createMethod(bits[j2], algorithm.padding); if (algorithm.name !== "sha3") { var newMethodName = algorithm.name + bits[j2]; methodNames.push(newMethodName); methods[newMethodName] = methods[methodName]; } } } function Keccak(bits2, padding2, outputBits) { this.blocks = []; this.s = []; this.padding = padding2; this.outputBits = outputBits; this.reset = true; this.finalized = false; this.block = 0; this.start = 0; this.blockCount = 1600 - (bits2 << 1) >> 5; this.byteCount = this.blockCount << 2; this.outputBlocks = outputBits >> 5; this.extraBytes = (outputBits & 31) >> 3; for (var i3 = 0; i3 < 50; ++i3) { this.s[i3] = 0; } } Keccak.prototype.update = function(message) { if (this.finalized) { throw new Error(FINALIZE_ERROR); } var notString, type = typeof message; if (type !== "string") { if (type === "object") { if (message === null) { throw new Error(INPUT_ERROR); } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { message = new Uint8Array(message); } else if (!Array.isArray(message)) { if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { throw new Error(INPUT_ERROR); } } } else { throw new Error(INPUT_ERROR); } notString = true; } var blocks = this.blocks, byteCount = this.byteCount, length = message.length, blockCount = this.blockCount, index = 0, s2 = this.s, i3, code2; while (index < length) { if (this.reset) { this.reset = false; blocks[0] = this.block; for (i3 = 1; i3 < blockCount + 1; ++i3) { blocks[i3] = 0; } } if (notString) { for (i3 = this.start; index < length && i3 < byteCount; ++index) { blocks[i3 >> 2] |= message[index] << SHIFT[i3++ & 3]; } } else { for (i3 = this.start; index < length && i3 < byteCount; ++index) { code2 = message.charCodeAt(index); if (code2 < 128) { blocks[i3 >> 2] |= code2 << SHIFT[i3++ & 3]; } else if (code2 < 2048) { blocks[i3 >> 2] |= (192 | code2 >> 6) << SHIFT[i3++ & 3]; blocks[i3 >> 2] |= (128 | code2 & 63) << SHIFT[i3++ & 3]; } else if (code2 < 55296 || code2 >= 57344) { blocks[i3 >> 2] |= (224 | code2 >> 12) << SHIFT[i3++ & 3]; blocks[i3 >> 2] |= (128 | code2 >> 6 & 63) << SHIFT[i3++ & 3]; blocks[i3 >> 2] |= (128 | code2 & 63) << SHIFT[i3++ & 3]; } else { code2 = 65536 + ((code2 & 1023) << 10 | message.charCodeAt(++index) & 1023); blocks[i3 >> 2] |= (240 | code2 >> 18) << SHIFT[i3++ & 3]; blocks[i3 >> 2] |= (128 | code2 >> 12 & 63) << SHIFT[i3++ & 3]; blocks[i3 >> 2] |= (128 | code2 >> 6 & 63) << SHIFT[i3++ & 3]; blocks[i3 >> 2] |= (128 | code2 & 63) << SHIFT[i3++ & 3]; } } } this.lastByteIndex = i3; if (i3 >= byteCount) { this.start = i3 - byteCount; this.block = blocks[blockCount]; for (i3 = 0; i3 < blockCount; ++i3) { s2[i3] ^= blocks[i3]; } f2(s2); this.reset = true; } else { this.start = i3; } } return this; }; Keccak.prototype.encode = function(x, right) { var o = x & 255, n2 = 1; var bytes = [o]; x = x >> 8; o = x & 255; while (o > 0) { bytes.unshift(o); x = x >> 8; o = x & 255; ++n2; } if (right) { bytes.push(n2); } else { bytes.unshift(n2); } this.update(bytes); return bytes.length; }; Keccak.prototype.encodeString = function(str) { var notString, type = typeof str; if (type !== "string") { if (type === "object") { if (str === null) { throw new Error(INPUT_ERROR); } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { str = new Uint8Array(str); } else if (!Array.isArray(str)) { if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { throw new Error(INPUT_ERROR); } } } else { throw new Error(INPUT_ERROR); } notString = true; } var bytes = 0, length = str.length; if (notString) { bytes = length; } else { for (var i3 = 0; i3 < str.length; ++i3) { var code2 = str.charCodeAt(i3); if (code2 < 128) { bytes += 1; } else if (code2 < 2048) { bytes += 2; } else if (code2 < 55296 || code2 >= 57344) { bytes += 3; } else { code2 = 65536 + ((code2 & 1023) << 10 | str.charCodeAt(++i3) & 1023); bytes += 4; } } } bytes += this.encode(bytes * 8); this.update(str); return bytes; }; Keccak.prototype.bytepad = function(strs, w) { var bytes = this.encode(w); for (var i3 = 0; i3 < strs.length; ++i3) { bytes += this.encodeString(strs[i3]); } var paddingBytes = w - bytes % w; var zeros2 = []; zeros2.length = paddingBytes; this.update(zeros2); return this; }; Keccak.prototype.finalize = function() { if (this.finalized) { return; } this.finalized = true; var blocks = this.blocks, i3 = this.lastByteIndex, blockCount = this.blockCount, s2 = this.s; blocks[i3 >> 2] |= this.padding[i3 & 3]; if (this.lastByteIndex === this.byteCount) { blocks[0] = blocks[blockCount]; for (i3 = 1; i3 < blockCount + 1; ++i3) { blocks[i3] = 0; } } blocks[blockCount - 1] |= 2147483648; for (i3 = 0; i3 < blockCount; ++i3) { s2[i3] ^= blocks[i3]; } f2(s2); }; Keccak.prototype.toString = Keccak.prototype.hex = function() { this.finalize(); var blockCount = this.blockCount, s2 = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i3 = 0, j3 = 0; var hex = "", block; while (j3 < outputBlocks) { for (i3 = 0; i3 < blockCount && j3 < outputBlocks; ++i3, ++j3) { block = s2[i3]; hex += HEX_CHARS[block >> 4 & 15] + HEX_CHARS[block & 15] + HEX_CHARS[block >> 12 & 15] + HEX_CHARS[block >> 8 & 15] + HEX_CHARS[block >> 20 & 15] + HEX_CHARS[block >> 16 & 15] + HEX_CHARS[block >> 28 & 15] + HEX_CHARS[block >> 24 & 15]; } if (j3 % blockCount === 0) { f2(s2); i3 = 0; } } if (extraBytes) { block = s2[i3]; hex += HEX_CHARS[block >> 4 & 15] + HEX_CHARS[block & 15]; if (extraBytes > 1) { hex += HEX_CHARS[block >> 12 & 15] + HEX_CHARS[block >> 8 & 15]; } if (extraBytes > 2) { hex += HEX_CHARS[block >> 20 & 15] + HEX_CHARS[block >> 16 & 15]; } } return hex; }; Keccak.prototype.arrayBuffer = function() { this.finalize(); var blockCount = this.blockCount, s2 = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i3 = 0, j3 = 0; var bytes = this.outputBits >> 3; var buffer2; if (extraBytes) { buffer2 = new ArrayBuffer(outputBlocks + 1 << 2); } else { buffer2 = new ArrayBuffer(bytes); } var array = new Uint32Array(buffer2); while (j3 < outputBlocks) { for (i3 = 0; i3 < blockCount && j3 < outputBlocks; ++i3, ++j3) { array[j3] = s2[i3]; } if (j3 % blockCount === 0) { f2(s2); } } if (extraBytes) { array[i3] = s2[i3]; buffer2 = buffer2.slice(0, bytes); } return buffer2; }; Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; Keccak.prototype.digest = Keccak.prototype.array = function() { this.finalize(); var blockCount = this.blockCount, s2 = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i3 = 0, j3 = 0; var array = [], offset, block; while (j3 < outputBlocks) { for (i3 = 0; i3 < blockCount && j3 < outputBlocks; ++i3, ++j3) { offset = j3 << 2; block = s2[i3]; array[offset] = block & 255; array[offset + 1] = block >> 8 & 255; array[offset + 2] = block >> 16 & 255; array[offset + 3] = block >> 24 & 255; } if (j3 % blockCount === 0) { f2(s2); } } if (extraBytes) { offset = j3 << 2; block = s2[i3]; array[offset] = block & 255; if (extraBytes > 1) { array[offset + 1] = block >> 8 & 255; } if (extraBytes > 2) { array[offset + 2] = block >> 16 & 255; } } return array; }; function Kmac(bits2, padding2, outputBits) { Keccak.call(this, bits2, padding2, outputBits); } Kmac.prototype = new Keccak(); Kmac.prototype.finalize = function() { this.encode(this.outputBits, true); return Keccak.prototype.finalize.call(this); }; var f2 = function(s2) { var h2, l2, n2, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; for (n2 = 0; n2 < 48; n2 += 2) { c0 = s2[0] ^ s2[10] ^ s2[20] ^ s2[30] ^ s2[40]; c1 = s2[1] ^ s2[11] ^ s2[21] ^ s2[31] ^ s2[41]; c2 = s2[2] ^ s2[12] ^ s2[22] ^ s2[32] ^ s2[42]; c3 = s2[3] ^ s2[13] ^ s2[23] ^ s2[33] ^ s2[43]; c4 = s2[4] ^ s2[14] ^ s2[24] ^ s2[34] ^ s2[44]; c5 = s2[5] ^ s2[15] ^ s2[25] ^ s2[35] ^ s2[45]; c6 = s2[6] ^ s2[16] ^ s2[26] ^ s2[36] ^ s2[46]; c7 = s2[7] ^ s2[17] ^ s2[27] ^ s2[37] ^ s2[47]; c8 = s2[8] ^ s2[18] ^ s2[28] ^ s2[38] ^ s2[48]; c9 = s2[9] ^ s2[19] ^ s2[29] ^ s2[39] ^ s2[49]; h2 = c8 ^ (c2 << 1 | c3 >>> 31); l2 = c9 ^ (c3 << 1 | c2 >>> 31); s2[0] ^= h2; s2[1] ^= l2; s2[10] ^= h2; s2[11] ^= l2; s2[20] ^= h2; s2[21] ^= l2; s2[30] ^= h2; s2[31] ^= l2; s2[40] ^= h2; s2[41] ^= l2; h2 = c0 ^ (c4 << 1 | c5 >>> 31); l2 = c1 ^ (c5 << 1 | c4 >>> 31); s2[2] ^= h2; s2[3] ^= l2; s2[12] ^= h2; s2[13] ^= l2; s2[22] ^= h2; s2[23] ^= l2; s2[32] ^= h2; s2[33] ^= l2; s2[42] ^= h2; s2[43] ^= l2; h2 = c2 ^ (c6 << 1 | c7 >>> 31); l2 = c3 ^ (c7 << 1 | c6 >>> 31); s2[4] ^= h2; s2[5] ^= l2; s2[14] ^= h2; s2[15] ^= l2; s2[24] ^= h2; s2[25] ^= l2; s2[34] ^= h2; s2[35] ^= l2; s2[44] ^= h2; s2[45] ^= l2; h2 = c4 ^ (c8 << 1 | c9 >>> 31); l2 = c5 ^ (c9 << 1 | c8 >>> 31); s2[6] ^= h2; s2[7] ^= l2; s2[16] ^= h2; s2[17] ^= l2; s2[26] ^= h2; s2[27] ^= l2; s2[36] ^= h2; s2[37] ^= l2; s2[46] ^= h2; s2[47] ^= l2; h2 = c6 ^ (c0 << 1 | c1 >>> 31); l2 = c7 ^ (c1 << 1 | c0 >>> 31); s2[8] ^= h2; s2[9] ^= l2; s2[18] ^= h2; s2[19] ^= l2; s2[28] ^= h2; s2[29] ^= l2; s2[38] ^= h2; s2[39] ^= l2; s2[48] ^= h2; s2[49] ^= l2; b0 = s2[0]; b1 = s2[1]; b32 = s2[11] << 4 | s2[10] >>> 28; b33 = s2[10] << 4 | s2[11] >>> 28; b14 = s2[20] << 3 | s2[21] >>> 29; b15 = s2[21] << 3 | s2[20] >>> 29; b46 = s2[31] << 9 | s2[30] >>> 23; b47 = s2[30] << 9 | s2[31] >>> 23; b28 = s2[40] << 18 | s2[41] >>> 14; b29 = s2[41] << 18 | s2[40] >>> 14; b20 = s2[2] << 1 | s2[3] >>> 31; b21 = s2[3] << 1 | s2[2] >>> 31; b2 = s2[13] << 12 | s2[12] >>> 20; b3 = s2[12] << 12 | s2[13] >>> 20; b34 = s2[22] << 10 | s2[23] >>> 22; b35 = s2[23] << 10 | s2[22] >>> 22; b16 = s2[33] << 13 | s2[32] >>> 19; b17 = s2[32] << 13 | s2[33] >>> 19; b48 = s2[42] << 2 | s2[43] >>> 30; b49 = s2[43] << 2 | s2[42] >>> 30; b40 = s2[5] << 30 | s2[4] >>> 2; b41 = s2[4] << 30 | s2[5] >>> 2; b22 = s2[14] << 6 | s2[15] >>> 26; b23 = s2[15] << 6 | s2[14] >>> 26; b4 = s2[25] << 11 | s2[24] >>> 21; b5 = s2[24] << 11 | s2[25] >>> 21; b36 = s2[34] << 15 | s2[35] >>> 17; b37 = s2[35] << 15 | s2[34] >>> 17; b18 = s2[45] << 29 | s2[44] >>> 3; b19 = s2[44] << 29 | s2[45] >>> 3; b10 = s2[6] << 28 | s2[7] >>> 4; b11 = s2[7] << 28 | s2[6] >>> 4; b42 = s2[17] << 23 | s2[16] >>> 9; b43 = s2[16] << 23 | s2[17] >>> 9; b24 = s2[26] << 25 | s2[27] >>> 7; b25 = s2[27] << 25 | s2[26] >>> 7; b6 = s2[36] << 21 | s2[37] >>> 11; b7 = s2[37] << 21 | s2[36] >>> 11; b38 = s2[47] << 24 | s2[46] >>> 8; b39 = s2[46] << 24 | s2[47] >>> 8; b30 = s2[8] << 27 | s2[9] >>> 5; b31 = s2[9] << 27 | s2[8] >>> 5; b12 = s2[18] << 20 | s2[19] >>> 12; b13 = s2[19] << 20 | s2[18] >>> 12; b44 = s2[29] << 7 | s2[28] >>> 25; b45 = s2[28] << 7 | s2[29] >>> 25; b26 = s2[38] << 8 | s2[39] >>> 24; b27 = s2[39] << 8 | s2[38] >>> 24; b8 = s2[48] << 14 | s2[49] >>> 18; b9 = s2[49] << 14 | s2[48] >>> 18; s2[0] = b0 ^ ~b2 & b4; s2[1] = b1 ^ ~b3 & b5; s2[10] = b10 ^ ~b12 & b14; s2[11] = b11 ^ ~b13 & b15; s2[20] = b20 ^ ~b22 & b24; s2[21] = b21 ^ ~b23 & b25; s2[30] = b30 ^ ~b32 & b34; s2[31] = b31 ^ ~b33 & b35; s2[40] = b40 ^ ~b42 & b44; s2[41] = b41 ^ ~b43 & b45; s2[2] = b2 ^ ~b4 & b6; s2[3] = b3 ^ ~b5 & b7; s2[12] = b12 ^ ~b14 & b16; s2[13] = b13 ^ ~b15 & b17; s2[22] = b22 ^ ~b24 & b26; s2[23] = b23 ^ ~b25 & b27; s2[32] = b32 ^ ~b34 & b36; s2[33] = b33 ^ ~b35 & b37; s2[42] = b42 ^ ~b44 & b46; s2[43] = b43 ^ ~b45 & b47; s2[4] = b4 ^ ~b6 & b8; s2[5] = b5 ^ ~b7 & b9; s2[14] = b14 ^ ~b16 & b18; s2[15] = b15 ^ ~b17 & b19; s2[24] = b24 ^ ~b26 & b28; s2[25] = b25 ^ ~b27 & b29; s2[34] = b34 ^ ~b36 & b38; s2[35] = b35 ^ ~b37 & b39; s2[44] = b44 ^ ~b46 & b48; s2[45] = b45 ^ ~b47 & b49; s2[6] = b6 ^ ~b8 & b0; s2[7] = b7 ^ ~b9 & b1; s2[16] = b16 ^ ~b18 & b10; s2[17] = b17 ^ ~b19 & b11; s2[26] = b26 ^ ~b28 & b20; s2[27] = b27 ^ ~b29 & b21; s2[36] = b36 ^ ~b38 & b30; s2[37] = b37 ^ ~b39 & b31; s2[46] = b46 ^ ~b48 & b40; s2[47] = b47 ^ ~b49 & b41; s2[8] = b8 ^ ~b0 & b2; s2[9] = b9 ^ ~b1 & b3; s2[18] = b18 ^ ~b10 & b12; s2[19] = b19 ^ ~b11 & b13; s2[28] = b28 ^ ~b20 & b22; s2[29] = b29 ^ ~b21 & b23; s2[38] = b38 ^ ~b30 & b32; s2[39] = b39 ^ ~b31 & b33; s2[48] = b48 ^ ~b40 & b42; s2[49] = b49 ^ ~b41 & b43; s2[0] ^= RC[n2]; s2[1] ^= RC[n2 + 1]; } }; if (COMMON_JS) { module.exports = methods; } else { for (i2 = 0; i2 < methodNames.length; ++i2) { root[methodNames[i2]] = methods[methodNames[i2]]; } } })(); })(sha3$1); const sha3 = sha3Exports; function keccak256$1(data) { return "0x" + sha3.keccak_256(arrayify(data)); } const lib_esm$h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, keccak256: keccak256$1 }, Symbol.toStringTag, { value: "Module" })); const version$k = "rlp/5.7.0"; const logger$u = new Logger(version$k); function arrayifyInteger(value) { const result = []; while (value) { result.unshift(value & 255); value >>= 8; } return result; } function unarrayifyInteger(data, offset, length) { let result = 0; for (let i2 = 0; i2 < length; i2++) { result = result * 256 + data[offset + i2]; } return result; } function _encode(object) { if (Array.isArray(object)) { let payload = []; object.forEach(function(child) { payload = payload.concat(_encode(child)); }); if (payload.length <= 55) { payload.unshift(192 + payload.length); return payload; } const length2 = arrayifyInteger(payload.length); length2.unshift(247 + length2.length); return length2.concat(payload); } if (!isBytesLike(object)) { logger$u.throwArgumentError("RLP object must be BytesLike", "object", object); } const data = Array.prototype.slice.call(arrayify(object)); if (data.length === 1 && data[0] <= 127) { return data; } else if (data.length <= 55) { data.unshift(128 + data.length); return data; } const length = arrayifyInteger(data.length); length.unshift(183 + length.length); return length.concat(data); } function encode$2(object) { return hexlify(_encode(object)); } function _decodeChildren(data, offset, childOffset, length) { const result = []; while (childOffset < offset + 1 + length) { const decoded = _decode(data, childOffset); result.push(decoded.result); childOffset += decoded.consumed; if (childOffset > offset + 1 + length) { logger$u.throwError("child data too short", Logger.errors.BUFFER_OVERRUN, {}); } } return { consumed: 1 + length, result }; } function _decode(data, offset) { if (data.length === 0) { logger$u.throwError("data too short", Logger.errors.BUFFER_OVERRUN, {}); } if (data[offset] >= 248) { const lengthLength = data[offset] - 247; if (offset + 1 + lengthLength > data.length) { logger$u.throwError("data short segment too short", Logger.errors.BUFFER_OVERRUN, {}); } const length = unarrayifyInteger(data, offset + 1, lengthLength); if (offset + 1 + lengthLength + length > data.length) { logger$u.throwError("data long segment too short", Logger.errors.BUFFER_OVERRUN, {}); } return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length); } else if (data[offset] >= 192) { const length = data[offset] - 192; if (offset + 1 + length > data.length) { logger$u.throwError("data array too short", Logger.errors.BUFFER_OVERRUN, {}); } return _decodeChildren(data, offset, offset + 1, length); } else if (data[offset] >= 184) { const lengthLength = data[offset] - 183; if (offset + 1 + lengthLength > data.length) { logger$u.throwError("data array too short", Logger.errors.BUFFER_OVERRUN, {}); } const length = unarrayifyInteger(data, offset + 1, lengthLength); if (offset + 1 + lengthLength + length > data.length) { logger$u.throwError("data array too short", Logger.errors.BUFFER_OVERRUN, {}); } const result = hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length)); return { consumed: 1 + lengthLength + length, result }; } else if (data[offset] >= 128) { const length = data[offset] - 128; if (offset + 1 + length > data.length) { logger$u.throwError("data too short", Logger.errors.BUFFER_OVERRUN, {}); } const result = hexlify(data.slice(offset + 1, offset + 1 + length)); return { consumed: 1 + length, result }; } return { consumed: 1, result: hexlify(data[offset]) }; } function decode$2(data) { const bytes = arrayify(data); const decoded = _decode(bytes, 0); if (decoded.consumed !== bytes.length) { logger$u.throwArgumentError("invalid rlp data", "data", data); } return decoded.result; } const lib_esm$g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, decode: decode$2, encode: encode$2 }, Symbol.toStringTag, { value: "Module" })); const version$j = "address/5.7.0"; const logger$t = new Logger(version$j); function getChecksumAddress(address) { if (!isHexString(address, 20)) { logger$t.throwArgumentError("invalid address", "address", address); } address = address.toLowerCase(); const chars = address.substring(2).split(""); const expanded = new Uint8Array(40); for (let i2 = 0; i2 < 40; i2++) { expanded[i2] = chars[i2].charCodeAt(0); } const hashed = arrayify(keccak256$1(expanded)); for (let i2 = 0; i2 < 40; i2 += 2) { if (hashed[i2 >> 1] >> 4 >= 8) { chars[i2] = chars[i2].toUpperCase(); } if ((hashed[i2 >> 1] & 15) >= 8) { chars[i2 + 1] = chars[i2 + 1].toUpperCase(); } } return "0x" + chars.join(""); } const MAX_SAFE_INTEGER = 9007199254740991; function log10(x) { if (Math.log10) { return Math.log10(x); } return Math.log(x) / Math.LN10; } const ibanLookup = {}; for (let i2 = 0; i2 < 10; i2++) { ibanLookup[String(i2)] = String(i2); } for (let i2 = 0; i2 < 26; i2++) { ibanLookup[String.fromCharCode(65 + i2)] = String(10 + i2); } const safeDigits = Math.floor(log10(MAX_SAFE_INTEGER)); function ibanChecksum(address) { address = address.toUpperCase(); address = address.substring(4) + address.substring(0, 2) + "00"; let expanded = address.split("").map((c2) => { return ibanLookup[c2]; }).join(""); while (expanded.length >= safeDigits) { let block = expanded.substring(0, safeDigits); expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); } let checksum = String(98 - parseInt(expanded, 10) % 97); while (checksum.length < 2) { checksum = "0" + checksum; } return checksum; } function getAddress(address) { let result = null; if (typeof address !== "string") { logger$t.throwArgumentError("invalid address", "address", address); } if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { if (address.substring(0, 2) !== "0x") { address = "0x" + address; } result = getChecksumAddress(address); if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { logger$t.throwArgumentError("bad address checksum", "address", address); } } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { if (address.substring(2, 4) !== ibanChecksum(address)) { logger$t.throwArgumentError("bad icap checksum", "address", address); } result = _base36To16(address.substring(4)); while (result.length < 40) { result = "0" + result; } result = getChecksumAddress("0x" + result); } else { logger$t.throwArgumentError("invalid address", "address", address); } return result; } function isAddress(address) { try { getAddress(address); return true; } catch (error) { } return false; } function getIcapAddress(address) { let base36 = _base16To36(getAddress(address).substring(2)).toUpperCase(); while (base36.length < 30) { base36 = "0" + base36; } return "XE" + ibanChecksum("XE00" + base36) + base36; } function getContractAddress(transaction) { let from = null; try { from = getAddress(transaction.from); } catch (error) { logger$t.throwArgumentError("missing from address", "transaction", transaction); } const nonce = stripZeros(arrayify(BigNumber.from(transaction.nonce).toHexString())); return getAddress(hexDataSlice(keccak256$1(encode$2([from, nonce])), 12)); } function getCreate2Address(from, salt, initCodeHash) { if (hexDataLength(salt) !== 32) { logger$t.throwArgumentError("salt must be 32 bytes", "salt", salt); } if (hexDataLength(initCodeHash) !== 32) { logger$t.throwArgumentError("initCodeHash must be 32 bytes", "initCodeHash", initCodeHash); } return getAddress(hexDataSlice(keccak256$1(concat(["0xff", getAddress(from), salt, initCodeHash])), 12)); } const lib_esm$f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, getAddress, getContractAddress, getCreate2Address, getIcapAddress, isAddress }, Symbol.toStringTag, { value: "Module" })); class AddressCoder extends Coder { constructor(localName) { super("address", "address", localName, false); } defaultValue() { return "0x0000000000000000000000000000000000000000"; } encode(writer, value) { try { value = getAddress(value); } catch (error) { this._throwError(error.message, value); } return writer.writeValue(value); } decode(reader) { return getAddress(hexZeroPad(reader.readValue().toHexString(), 20)); } } class AnonymousCoder extends Coder { constructor(coder) { super(coder.name, coder.type, void 0, coder.dynamic); this.coder = coder; } defaultValue() { return this.coder.defaultValue(); } encode(writer, value) { return this.coder.encode(writer, value); } decode(reader) { return this.coder.decode(reader); } } const logger$s = new Logger(version$l); function pack$1(writer, coders, values) { let arrayValues = null; if (Array.isArray(values)) { arrayValues = values; } else if (values && typeof values === "object") { let unique = {}; arrayValues = coders.map((coder) => { const name = coder.localName; if (!name) { logger$s.throwError("cannot encode object for signature with missing names", Logger.errors.INVALID_ARGUMENT, { argument: "values", coder, value: values }); } if (unique[name]) { logger$s.throwError("cannot encode object for signature with duplicate names", Logger.errors.INVALID_ARGUMENT, { argument: "values", coder, value: values }); } unique[name] = true; return values[name]; }); } else { logger$s.throwArgumentError("invalid tuple value", "tuple", values); } if (coders.length !== arrayValues.length) { logger$s.throwArgumentError("types/value length mismatch", "tuple", values); } let staticWriter = new Writer(writer.wordSize); let dynamicWriter = new Writer(writer.wordSize); let updateFuncs = []; coders.forEach((coder, index) => { let value = arrayValues[index]; if (coder.dynamic) { let dynamicOffset = dynamicWriter.length; coder.encode(dynamicWriter, value); let updateFunc = staticWriter.writeUpdatableValue(); updateFuncs.push((baseOffset) => { updateFunc(baseOffset + dynamicOffset); }); } else { coder.encode(staticWriter, value); } }); updateFuncs.forEach((func) => { func(staticWriter.length); }); let length = writer.appendWriter(staticWriter); length += writer.appendWriter(dynamicWriter); return length; } function unpack(reader, coders) { let values = []; let baseReader = reader.subReader(0); coders.forEach((coder) => { let value = null; if (coder.dynamic) { let offset = reader.readValue(); let offsetReader = baseReader.subReader(offset.toNumber()); try { value = coder.decode(offsetReader); } catch (error) { if (error.code === Logger.errors.BUFFER_OVERRUN) { throw error; } value = error; value.baseType = coder.name; value.name = coder.localName; value.type = coder.type; } } else { try { value = coder.decode(reader); } catch (error) { if (error.code === Logger.errors.BUFFER_OVERRUN) { throw error; } value = error; value.baseType = coder.name; value.name = coder.localName; value.type = coder.type; } } if (value != void 0) { values.push(value); } }); const uniqueNames = coders.reduce((accum, coder) => { const name = coder.localName; if (name) { if (!accum[name]) { accum[name] = 0; } accum[name]++; } return accum; }, {}); coders.forEach((coder, index) => { let name = coder.localName; if (!name || uniqueNames[name] !== 1) { return; } if (name === "length") { name = "_length"; } if (values[name] != null) { return; } const value = values[index]; if (value instanceof Error) { Object.defineProperty(values, name, { enumerable: true, get: () => { throw value; } }); } else { values[name] = value; } }); for (let i2 = 0; i2 < values.length; i2++) { const value = values[i2]; if (value instanceof Error) { Object.defineProperty(values, i2, { enumerable: true, get: () => { throw value; } }); } } return Object.freeze(values); } class ArrayCoder extends Coder { constructor(coder, length, localName) { const type = coder.type + "[" + (length >= 0 ? length : "") + "]"; const dynamic = length === -1 || coder.dynamic; super("array", type, localName, dynamic); this.coder = coder; this.length = length; } defaultValue() { const defaultChild = this.coder.defaultValue(); const result = []; for (let i2 = 0; i2 < this.length; i2++) { result.push(defaultChild); } return result; } encode(writer, value) { if (!Array.isArray(value)) { this._throwError("expected array value", value); } let count = this.length; if (count === -1) { count = value.length; writer.writeValue(value.length); } logger$s.checkArgumentCount(value.length, count, "coder array" + (this.localName ? " " + this.localName : "")); let coders = []; for (let i2 = 0; i2 < value.length; i2++) { coders.push(this.coder); } return pack$1(writer, coders, value); } decode(reader) { let count = this.length; if (count === -1) { count = reader.readValue().toNumber(); if (count * 32 > reader._data.length) { logger$s.throwError("insufficient data length", Logger.errors.BUFFER_OVERRUN, { length: reader._data.length, count }); } } let coders = []; for (let i2 = 0; i2 < count; i2++) { coders.push(new AnonymousCoder(this.coder)); } return reader.coerce(this.name, unpack(reader, coders)); } } class BooleanCoder extends Coder { constructor(localName) { super("bool", "bool", localName, false); } defaultValue() { return false; } encode(writer, value) { return writer.writeValue(value ? 1 : 0); } decode(reader) { return reader.coerce(this.type, !reader.readValue().isZero()); } } class DynamicBytesCoder extends Coder { constructor(type, localName) { super(type, type, localName, true); } defaultValue() { return "0x"; } encode(writer, value) { value = arrayify(value); let length = writer.writeValue(value.length); length += writer.writeBytes(value); return length; } decode(reader) { return reader.readBytes(reader.readValue().toNumber(), true); } } class BytesCoder extends DynamicBytesCoder { constructor(localName) { super("bytes", localName); } decode(reader) { return reader.coerce(this.name, hexlify(super.decode(reader))); } } class FixedBytesCoder extends Coder { constructor(size, localName) { let name = "bytes" + String(size); super(name, name, localName, false); this.size = size; } defaultValue() { return "0x0000000000000000000000000000000000000000000000000000000000000000".substring(0, 2 + this.size * 2); } encode(writer, value) { let data = arrayify(value); if (data.length !== this.size) { this._throwError("incorrect data length", value); } return writer.writeBytes(data); } decode(reader) { return reader.coerce(this.name, hexlify(reader.readBytes(this.size))); } } class NullCoder extends Coder { constructor(localName) { super("null", "", localName, false); } defaultValue() { return null; } encode(writer, value) { if (value != null) { this._throwError("not null", value); } return writer.writeBytes([]); } decode(reader) { reader.readBytes(0); return reader.coerce(this.name, null); } } const AddressZero = "0x0000000000000000000000000000000000000000"; const NegativeOne$1 = /* @__PURE__ */ BigNumber.from(-1); const Zero$1 = /* @__PURE__ */ BigNumber.from(0); const One$1 = /* @__PURE__ */ BigNumber.from(1); const MaxUint256$1 = /* @__PURE__ */ BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; class NumberCoder extends Coder { constructor(size, signed2, localName) { const name = (signed2 ? "int" : "uint") + size * 8; super(name, name, localName, false); this.size = size; this.signed = signed2; } defaultValue() { return 0; } encode(writer, value) { let v2 = BigNumber.from(value); let maxUintValue = MaxUint256$1.mask(writer.wordSize * 8); if (this.signed) { let bounds = maxUintValue.mask(this.size * 8 - 1); if (v2.gt(bounds) || v2.lt(bounds.add(One$1).mul(NegativeOne$1))) { this._throwError("value out-of-bounds", value); } } else if (v2.lt(Zero$1) || v2.gt(maxUintValue.mask(this.size * 8))) { this._throwError("value out-of-bounds", value); } v2 = v2.toTwos(this.size * 8).mask(this.size * 8); if (this.signed) { v2 = v2.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); } return writer.writeValue(v2); } decode(reader) { let value = reader.readValue().mask(this.size * 8); if (this.signed) { value = value.fromTwos(this.size * 8); } return reader.coerce(this.name, value); } } const version$i = "strings/5.7.0"; const logger$r = new Logger(version$i); var UnicodeNormalizationForm; (function(UnicodeNormalizationForm2) { UnicodeNormalizationForm2["current"] = ""; UnicodeNormalizationForm2["NFC"] = "NFC"; UnicodeNormalizationForm2["NFD"] = "NFD"; UnicodeNormalizationForm2["NFKC"] = "NFKC"; UnicodeNormalizationForm2["NFKD"] = "NFKD"; })(UnicodeNormalizationForm || (UnicodeNormalizationForm = {})); var Utf8ErrorReason; (function(Utf8ErrorReason2) { Utf8ErrorReason2["UNEXPECTED_CONTINUE"] = "unexpected continuation byte"; Utf8ErrorReason2["BAD_PREFIX"] = "bad codepoint prefix"; Utf8ErrorReason2["OVERRUN"] = "string overrun"; Utf8ErrorReason2["MISSING_CONTINUE"] = "missing continuation byte"; Utf8ErrorReason2["OUT_OF_RANGE"] = "out of UTF-8 range"; Utf8ErrorReason2["UTF16_SURROGATE"] = "UTF-16 surrogate"; Utf8ErrorReason2["OVERLONG"] = "overlong representation"; })(Utf8ErrorReason || (Utf8ErrorReason = {})); function errorFunc(reason, offset, bytes, output, badCodepoint) { return logger$r.throwArgumentError(`invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes); } function ignoreFunc(reason, offset, bytes, output, badCodepoint) { if (reason === Utf8ErrorReason.BAD_PREFIX || reason === Utf8ErrorReason.UNEXPECTED_CONTINUE) { let i2 = 0; for (let o = offset + 1; o < bytes.length; o++) { if (bytes[o] >> 6 !== 2) { break; } i2++; } return i2; } if (reason === Utf8ErrorReason.OVERRUN) { return bytes.length - offset - 1; } return 0; } function replaceFunc(reason, offset, bytes, output, badCodepoint) { if (reason === Utf8ErrorReason.OVERLONG) { output.push(badCodepoint); return 0; } output.push(65533); return ignoreFunc(reason, offset, bytes); } const Utf8ErrorFuncs = Object.freeze({ error: errorFunc, ignore: ignoreFunc, replace: replaceFunc }); function getUtf8CodePoints(bytes, onError) { if (onError == null) { onError = Utf8ErrorFuncs.error; } bytes = arrayify(bytes); const result = []; let i2 = 0; while (i2 < bytes.length) { const c2 = bytes[i2++]; if (c2 >> 7 === 0) { result.push(c2); continue; } let extraLength = null; let overlongMask = null; if ((c2 & 224) === 192) { extraLength = 1; overlongMask = 127; } else if ((c2 & 240) === 224) { extraLength = 2; overlongMask = 2047; } else if ((c2 & 248) === 240) { extraLength = 3; overlongMask = 65535; } else { if ((c2 & 192) === 128) { i2 += onError(Utf8ErrorReason.UNEXPECTED_CONTINUE, i2 - 1, bytes, result); } else { i2 += onError(Utf8ErrorReason.BAD_PREFIX, i2 - 1, bytes, result); } continue; } if (i2 - 1 + extraLength >= bytes.length) { i2 += onError(Utf8ErrorReason.OVERRUN, i2 - 1, bytes, result); continue; } let res = c2 & (1 << 8 - extraLength - 1) - 1; for (let j2 = 0; j2 < extraLength; j2++) { let nextChar = bytes[i2]; if ((nextChar & 192) != 128) { i2 += onError(Utf8ErrorReason.MISSING_CONTINUE, i2, bytes, result); res = null; break; } res = res << 6 | nextChar & 63; i2++; } if (res === null) { continue; } if (res > 1114111) { i2 += onError(Utf8ErrorReason.OUT_OF_RANGE, i2 - 1 - extraLength, bytes, result, res); continue; } if (res >= 55296 && res <= 57343) { i2 += onError(Utf8ErrorReason.UTF16_SURROGATE, i2 - 1 - extraLength, bytes, result, res); continue; } if (res <= overlongMask) { i2 += onError(Utf8ErrorReason.OVERLONG, i2 - 1 - extraLength, bytes, result, res); continue; } result.push(res); } return result; } function toUtf8Bytes(str, form = UnicodeNormalizationForm.current) { if (form != UnicodeNormalizationForm.current) { logger$r.checkNormalize(); str = str.normalize(form); } let result = []; for (let i2 = 0; i2 < str.length; i2++) { const c2 = str.charCodeAt(i2); if (c2 < 128) { result.push(c2); } else if (c2 < 2048) { result.push(c2 >> 6 | 192); result.push(c2 & 63 | 128); } else if ((c2 & 64512) == 55296) { i2++; const c22 = str.charCodeAt(i2); if (i2 >= str.length || (c22 & 64512) !== 56320) { throw new Error("invalid utf-8 string"); } const pair = 65536 + ((c2 & 1023) << 10) + (c22 & 1023); result.push(pair >> 18 | 240); result.push(pair >> 12 & 63 | 128); result.push(pair >> 6 & 63 | 128); result.push(pair & 63 | 128); } else { result.push(c2 >> 12 | 224); result.push(c2 >> 6 & 63 | 128); result.push(c2 & 63 | 128); } } return arrayify(result); } function escapeChar(value) { const hex = "0000" + value.toString(16); return "\\u" + hex.substring(hex.length - 4); } function _toEscapedUtf8String(bytes, onError) { return '"' + getUtf8CodePoints(bytes, onError).map((codePoint) => { if (codePoint < 256) { switch (codePoint) { case 8: return "\\b"; case 9: return "\\t"; case 10: return "\\n"; case 13: return "\\r"; case 34: return '\\"'; case 92: return "\\\\"; } if (codePoint >= 32 && codePoint < 127) { return String.fromCharCode(codePoint); } } if (codePoint <= 65535) { return escapeChar(codePoint); } codePoint -= 65536; return escapeChar((codePoint >> 10 & 1023) + 55296) + escapeChar((codePoint & 1023) + 56320); }).join("") + '"'; } function _toUtf8String(codePoints) { return codePoints.map((codePoint) => { if (codePoint <= 65535) { return String.fromCharCode(codePoint); } codePoint -= 65536; return String.fromCharCode((codePoint >> 10 & 1023) + 55296, (codePoint & 1023) + 56320); }).join(""); } function toUtf8String(bytes, onError) { return _toUtf8String(getUtf8CodePoints(bytes, onError)); } function toUtf8CodePoints(str, form = UnicodeNormalizationForm.current) { return getUtf8CodePoints(toUtf8Bytes(str, form)); } function formatBytes32String(text2) { const bytes = toUtf8Bytes(text2); if (bytes.length > 31) { throw new Error("bytes32 string must be less than 32 bytes"); } return hexlify(concat([bytes, HashZero]).slice(0, 32)); } function parseBytes32String(bytes) { const data = arrayify(bytes); if (data.length !== 32) { throw new Error("invalid bytes32 - not 32 bytes long"); } if (data[31] !== 0) { throw new Error("invalid bytes32 string - no null terminator"); } let length = 31; while (data[length - 1] === 0) { length--; } return toUtf8String(data.slice(0, length)); } function bytes2(data) { if (data.length % 4 !== 0) { throw new Error("bad data"); } let result = []; for (let i2 = 0; i2 < data.length; i2 += 4) { result.push(parseInt(data.substring(i2, i2 + 4), 16)); } return result; } function createTable(data, func) { if (!func) { func = function(value) { return [parseInt(value, 16)]; }; } let lo = 0; let result = {}; data.split(",").forEach((pair) => { let comps = pair.split(":"); lo += parseInt(comps[0], 16); result[lo] = func(comps[1]); }); return result; } function createRangeTable(data) { let hi = 0; return data.split(",").map((v2) => { let comps = v2.split("-"); if (comps.length === 1) { comps[1] = "0"; } else if (comps[1] === "") { comps[1] = "1"; } let lo = hi + parseInt(comps[0], 16); hi = parseInt(comps[1], 16); return { l: lo, h: hi }; }); } function matchMap(value, ranges) { let lo = 0; for (let i2 = 0; i2 < ranges.length; i2++) { let range = ranges[i2]; lo += range.l; if (value >= lo && value <= lo + range.h && (value - lo) % (range.d || 1) === 0) { if (range.e && range.e.indexOf(value - lo) !== -1) { continue; } return range; } } return null; } const Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"); const Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((v2) => parseInt(v2, 16)); const Table_B_2_ranges = [ { h: 25, s: 32, l: 65 }, { h: 30, s: 32, e: [23], l: 127 }, { h: 54, s: 1, e: [48], l: 64, d: 2 }, { h: 14, s: 1, l: 57, d: 2 }, { h: 44, s: 1, l: 17, d: 2 }, { h: 10, s: 1, e: [2, 6, 8], l: 61, d: 2 }, { h: 16, s: 1, l: 68, d: 2 }, { h: 84, s: 1, e: [18, 24, 66], l: 19, d: 2 }, { h: 26, s: 32, e: [17], l: 435 }, { h: 22, s: 1, l: 71, d: 2 }, { h: 15, s: 80, l: 40 }, { h: 31, s: 32, l: 16 }, { h: 32, s: 1, l: 80, d: 2 }, { h: 52, s: 1, l: 42, d: 2 }, { h: 12, s: 1, l: 55, d: 2 }, { h: 40, s: 1, e: [38], l: 15, d: 2 }, { h: 14, s: 1, l: 48, d: 2 }, { h: 37, s: 48, l: 49 }, { h: 148, s: 1, l: 6351, d: 2 }, { h: 88, s: 1, l: 160, d: 2 }, { h: 15, s: 16, l: 704 }, { h: 25, s: 26, l: 854 }, { h: 25, s: 32, l: 55915 }, { h: 37, s: 40, l: 1247 }, { h: 25, s: -119711, l: 53248 }, { h: 25, s: -119763, l: 52 }, { h: 25, s: -119815, l: 52 }, { h: 25, s: -119867, e: [1, 4, 5, 7, 8, 11, 12, 17], l: 52 }, { h: 25, s: -119919, l: 52 }, { h: 24, s: -119971, e: [2, 7, 8, 17], l: 52 }, { h: 24, s: -120023, e: [2, 7, 13, 15, 16, 17], l: 52 }, { h: 25, s: -120075, l: 52 }, { h: 25, s: -120127, l: 52 }, { h: 25, s: -120179, l: 52 }, { h: 25, s: -120231, l: 52 }, { h: 25, s: -120283, l: 52 }, { h: 25, s: -120335, l: 52 }, { h: 24, s: -119543, e: [17], l: 56 }, { h: 24, s: -119601, e: [17], l: 58 }, { h: 24, s: -119659, e: [17], l: 58 }, { h: 24, s: -119717, e: [17], l: 58 }, { h: 24, s: -119775, e: [17], l: 58 } ]; const Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"); const Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"); const Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2); const Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); function flatten(values) { return values.reduce((accum, value) => { value.forEach((value2) => { accum.push(value2); }); return accum; }, []); } function _nameprepTableA1(codepoint) { return !!matchMap(codepoint, Table_A_1_ranges); } function _nameprepTableB2(codepoint) { let range = matchMap(codepoint, Table_B_2_ranges); if (range) { return [codepoint + range.s]; } let codes = Table_B_2_lut_abs[codepoint]; if (codes) { return codes; } let shift = Table_B_2_lut_rel[codepoint]; if (shift) { return [codepoint + shift[0]]; } let complex = Table_B_2_complex[codepoint]; if (complex) { return complex; } return null; } function _nameprepTableC(codepoint) { return !!matchMap(codepoint, Table_C_ranges); } function nameprep(value) { if (value.match(/^[a-z0-9-]*$/i) && value.length <= 59) { return value.toLowerCase(); } let codes = toUtf8CodePoints(value); codes = flatten(codes.map((code2) => { if (Table_B_1_flags.indexOf(code2) >= 0) { return []; } if (code2 >= 65024 && code2 <= 65039) { return []; } let codesTableB2 = _nameprepTableB2(code2); if (codesTableB2) { return codesTableB2; } return [code2]; })); codes = toUtf8CodePoints(_toUtf8String(codes), UnicodeNormalizationForm.NFKC); codes.forEach((code2) => { if (_nameprepTableC(code2)) { throw new Error("STRINGPREP_CONTAINS_PROHIBITED"); } }); codes.forEach((code2) => { if (_nameprepTableA1(code2)) { throw new Error("STRINGPREP_CONTAINS_UNASSIGNED"); } }); let name = _toUtf8String(codes); if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") { throw new Error("invalid hyphen"); } return name; } const lib_esm$e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, get UnicodeNormalizationForm() { return UnicodeNormalizationForm; }, Utf8ErrorFuncs, get Utf8ErrorReason() { return Utf8ErrorReason; }, _toEscapedUtf8String, formatBytes32String, nameprep, parseBytes32String, toUtf8Bytes, toUtf8CodePoints, toUtf8String }, Symbol.toStringTag, { value: "Module" })); class StringCoder extends DynamicBytesCoder { constructor(localName) { super("string", localName); } defaultValue() { return ""; } encode(writer, value) { return super.encode(writer, toUtf8Bytes(value)); } decode(reader) { return toUtf8String(super.decode(reader)); } } class TupleCoder extends Coder { constructor(coders, localName) { let dynamic = false; const types = []; coders.forEach((coder) => { if (coder.dynamic) { dynamic = true; } types.push(coder.type); }); const type = "tuple(" + types.join(",") + ")"; super("tuple", type, localName, dynamic); this.coders = coders; } defaultValue() { const values = []; this.coders.forEach((coder) => { values.push(coder.defaultValue()); }); const uniqueNames = this.coders.reduce((accum, coder) => { const name = coder.localName; if (name) { if (!accum[name]) { accum[name] = 0; } accum[name]++; } return accum; }, {}); this.coders.forEach((coder, index) => { let name = coder.localName; if (!name || uniqueNames[name] !== 1) { return; } if (name === "length") { name = "_length"; } if (values[name] != null) { return; } values[name] = values[index]; }); return Object.freeze(values); } encode(writer, value) { return pack$1(writer, this.coders, value); } decode(reader) { return reader.coerce(this.name, unpack(reader, this.coders)); } } const logger$q = new Logger(version$l); const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); class AbiCoder { constructor(coerceFunc) { defineReadOnly(this, "coerceFunc", coerceFunc || null); } _getCoder(param) { switch (param.baseType) { case "address": return new AddressCoder(param.name); case "bool": return new BooleanCoder(param.name); case "string": return new StringCoder(param.name); case "bytes": return new BytesCoder(param.name); case "array": return new ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); case "tuple": return new TupleCoder((param.components || []).map((component) => { return this._getCoder(component); }), param.name); case "": return new NullCoder(param.name); } let match = param.type.match(paramTypeNumber); if (match) { let size = parseInt(match[2] || "256"); if (size === 0 || size > 256 || size % 8 !== 0) { logger$q.throwArgumentError("invalid " + match[1] + " bit length", "param", param); } return new NumberCoder(size / 8, match[1] === "int", param.name); } match = param.type.match(paramTypeBytes); if (match) { let size = parseInt(match[1]); if (size === 0 || size > 32) { logger$q.throwArgumentError("invalid bytes length", "param", param); } return new FixedBytesCoder(size, param.name); } return logger$q.throwArgumentError("invalid type", "type", param.type); } _getWordSize() { return 32; } _getReader(data, allowLoose) { return new Reader(data, this._getWordSize(), this.coerceFunc, allowLoose); } _getWriter() { return new Writer(this._getWordSize()); } getDefaultValue(types) { const coders = types.map((type) => this._getCoder(ParamType.from(type))); const coder = new TupleCoder(coders, "_"); return coder.defaultValue(); } encode(types, values) { if (types.length !== values.length) { logger$q.throwError("types/values length mismatch", Logger.errors.INVALID_ARGUMENT, { count: { types: types.length, values: values.length }, value: { types, values } }); } const coders = types.map((type) => this._getCoder(ParamType.from(type))); const coder = new TupleCoder(coders, "_"); const writer = this._getWriter(); coder.encode(writer, values); return writer.data; } decode(types, data, loose) { const coders = types.map((type) => this._getCoder(ParamType.from(type))); const coder = new TupleCoder(coders, "_"); return coder.decode(this._getReader(arrayify(data), loose)); } } const defaultAbiCoder = new AbiCoder(); function id(text2) { return keccak256$1(toUtf8Bytes(text2)); } const version$h = "hash/5.7.0"; function decode$1(textData) { textData = atob(textData); const data = []; for (let i2 = 0; i2 < textData.length; i2++) { data.push(textData.charCodeAt(i2)); } return arrayify(data); } function encode$1(data) { data = arrayify(data); let textData = ""; for (let i2 = 0; i2 < data.length; i2++) { textData += String.fromCharCode(data[i2]); } return btoa(textData); } const lib_esm$d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, decode: decode$1, encode: encode$1 }, Symbol.toStringTag, { value: "Module" })); function flat(array, depth) { if (depth == null) { depth = 1; } const result = []; const forEach = result.forEach; const flatDeep = function(arr, depth2) { forEach.call(arr, function(val) { if (depth2 > 0 && Array.isArray(val)) { flatDeep(val, depth2 - 1); } else { result.push(val); } }); }; flatDeep(array, depth); return result; } function fromEntries(array) { const result = {}; for (let i2 = 0; i2 < array.length; i2++) { const value = array[i2]; result[value[0]] = value[1]; } return result; } function decode_arithmetic(bytes) { let pos = 0; function u16() { return bytes[pos++] << 8 | bytes[pos++]; } let symbol_count = u16(); let total = 1; let acc = [0, 1]; for (let i2 = 1; i2 < symbol_count; i2++) { acc.push(total += u16()); } let skip = u16(); let pos_payload = pos; pos += skip; let read_width = 0; let read_buffer = 0; function read_bit() { if (read_width == 0) { read_buffer = read_buffer << 8 | bytes[pos++]; read_width = 8; } return read_buffer >> --read_width & 1; } const N2 = 31; const FULL = Math.pow(2, N2); const HALF = FULL >>> 1; const QRTR = HALF >> 1; const MASK = FULL - 1; let register = 0; for (let i2 = 0; i2 < N2; i2++) register = register << 1 | read_bit(); let symbols = []; let low = 0; let range = FULL; while (true) { let value = Math.floor(((register - low + 1) * total - 1) / range); let start = 0; let end = symbol_count; while (end - start > 1) { let mid = start + end >>> 1; if (value < acc[mid]) { end = mid; } else { start = mid; } } if (start == 0) break; symbols.push(start); let a2 = low + Math.floor(range * acc[start] / total); let b2 = low + Math.floor(range * acc[start + 1] / total) - 1; while (((a2 ^ b2) & HALF) == 0) { register = register << 1 & MASK | read_bit(); a2 = a2 << 1 & MASK; b2 = b2 << 1 & MASK | 1; } while (a2 & ~b2 & QRTR) { register = register & HALF | register << 1 & MASK >>> 1 | read_bit(); a2 = a2 << 1 ^ HALF; b2 = (b2 ^ HALF) << 1 | HALF | 1; } low = a2; range = 1 + b2 - a2; } let offset = symbol_count - 4; return symbols.map((x) => { switch (x - offset) { case 3: return offset + 65792 + (bytes[pos_payload++] << 16 | bytes[pos_payload++] << 8 | bytes[pos_payload++]); case 2: return offset + 256 + (bytes[pos_payload++] << 8 | bytes[pos_payload++]); case 1: return offset + bytes[pos_payload++]; default: return x - 1; } }); } function read_payload(v2) { let pos = 0; return () => v2[pos++]; } function read_compressed_payload(bytes) { return read_payload(decode_arithmetic(bytes)); } function signed(i2) { return i2 & 1 ? ~i2 >> 1 : i2 >> 1; } function read_counts(n2, next) { let v2 = Array(n2); for (let i2 = 0; i2 < n2; i2++) v2[i2] = 1 + next(); return v2; } function read_ascending(n2, next) { let v2 = Array(n2); for (let i2 = 0, x = -1; i2 < n2; i2++) v2[i2] = x += 1 + next(); return v2; } function read_deltas(n2, next) { let v2 = Array(n2); for (let i2 = 0, x = 0; i2 < n2; i2++) v2[i2] = x += signed(next()); return v2; } function read_member_array(next, lookup2) { let v2 = read_ascending(next(), next); let n2 = next(); let vX = read_ascending(n2, next); let vN = read_counts(n2, next); for (let i2 = 0; i2 < n2; i2++) { for (let j2 = 0; j2 < vN[i2]; j2++) { v2.push(vX[i2] + j2); } } return lookup2 ? v2.map((x) => lookup2[x]) : v2; } function read_mapped_map(next) { let ret = []; while (true) { let w = next(); if (w == 0) break; ret.push(read_linear_table(w, next)); } while (true) { let w = next() - 1; if (w < 0) break; ret.push(read_replacement_table(w, next)); } return fromEntries(flat(ret)); } function read_zero_terminated_array(next) { let v2 = []; while (true) { let i2 = next(); if (i2 == 0) break; v2.push(i2); } return v2; } function read_transposed(n2, w, next) { let m2 = Array(n2).fill(void 0).map(() => []); for (let i2 = 0; i2 < w; i2++) { read_deltas(n2, next).forEach((x, j2) => m2[j2].push(x)); } return m2; } function read_linear_table(w, next) { let dx = 1 + next(); let dy = next(); let vN = read_zero_terminated_array(next); let m2 = read_transposed(vN.length, 1 + w, next); return flat(m2.map((v2, i2) => { const x = v2[0], ys = v2.slice(1); return Array(vN[i2]).fill(void 0).map((_, j2) => { let j_dy = j2 * dy; return [x + j2 * dx, ys.map((y2) => y2 + j_dy)]; }); })); } function read_replacement_table(w, next) { let n2 = 1 + next(); let m2 = read_transposed(n2, 1 + w, next); return m2.map((v2) => [v2[0], v2.slice(1)]); } function read_emoji_trie(next) { let sorted = read_member_array(next).sort((a2, b2) => a2 - b2); return read(); function read() { let branches = []; while (true) { let keys = read_member_array(next, sorted); if (keys.length == 0) break; branches.push({ set: new Set(keys), node: read() }); } branches.sort((a2, b2) => b2.set.size - a2.set.size); let temp = next(); let valid = temp % 3; temp = temp / 3 | 0; let fe0f = !!(temp & 1); temp >>= 1; let save = temp == 1; let check = temp == 2; return { branches, valid, fe0f, save, check }; } } function getData() { return read_compressed_payload(decode$1("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); } const r$2 = getData(); const VALID = new Set(read_member_array(r$2)); const IGNORED = new Set(read_member_array(r$2)); const MAPPED = read_mapped_map(r$2); const EMOJI_ROOT = read_emoji_trie(r$2); const HYPHEN = 45; const UNDERSCORE = 95; function explode_cp(name) { return toUtf8CodePoints(name); } function filter_fe0f(cps) { return cps.filter((cp) => cp != 65039); } function ens_normalize_post_check(name) { for (let label of name.split(".")) { let cps = explode_cp(label); try { for (let i2 = cps.lastIndexOf(UNDERSCORE) - 1; i2 >= 0; i2--) { if (cps[i2] !== UNDERSCORE) { throw new Error(`underscore only allowed at start`); } } if (cps.length >= 4 && cps.every((cp) => cp < 128) && cps[2] === HYPHEN && cps[3] === HYPHEN) { throw new Error(`invalid label extension`); } } catch (err) { throw new Error(`Invalid label "${label}": ${err.message}`); } } return name; } function ens_normalize(name) { return ens_normalize_post_check(normalize(name, filter_fe0f)); } function normalize(name, emoji_filter) { let input = explode_cp(name).reverse(); let output = []; while (input.length) { let emoji = consume_emoji_reversed(input); if (emoji) { output.push(...emoji_filter(emoji)); continue; } let cp = input.pop(); if (VALID.has(cp)) { output.push(cp); continue; } if (IGNORED.has(cp)) { continue; } let cps = MAPPED[cp]; if (cps) { output.push(...cps); continue; } throw new Error(`Disallowed codepoint: 0x${cp.toString(16).toUpperCase()}`); } return ens_normalize_post_check(nfc(String.fromCodePoint(...output))); } function nfc(s2) { return s2.normalize("NFC"); } function consume_emoji_reversed(cps, eaten) { var _a; let node = EMOJI_ROOT; let emoji; let saved; let stack = []; let pos = cps.length; if (eaten) eaten.length = 0; while (pos) { let cp = cps[--pos]; node = (_a = node.branches.find((x) => x.set.has(cp))) === null || _a === void 0 ? void 0 : _a.node; if (!node) break; if (node.save) { saved = cp; } else if (node.check) { if (cp === saved) break; } stack.push(cp); if (node.fe0f) { stack.push(65039); if (pos > 0 && cps[pos - 1] == 65039) pos--; } if (node.valid) { emoji = stack.slice(); if (node.valid == 2) emoji.splice(1, 1); if (eaten) eaten.push(...cps.slice(pos).reverse()); cps.length = pos; } } return emoji; } const logger$p = new Logger(version$h); const Zeros$1 = new Uint8Array(32); Zeros$1.fill(0); function checkComponent(comp) { if (comp.length === 0) { throw new Error("invalid ENS name; empty component"); } return comp; } function ensNameSplit(name) { const bytes = toUtf8Bytes(ens_normalize(name)); const comps = []; if (name.length === 0) { return comps; } let last = 0; for (let i2 = 0; i2 < bytes.length; i2++) { const d2 = bytes[i2]; if (d2 === 46) { comps.push(checkComponent(bytes.slice(last, i2))); last = i2 + 1; } } if (last >= bytes.length) { throw new Error("invalid ENS name; empty component"); } comps.push(checkComponent(bytes.slice(last))); return comps; } function ensNormalize(name) { return ensNameSplit(name).map((comp) => toUtf8String(comp)).join("."); } function isValidName(name) { try { return ensNameSplit(name).length !== 0; } catch (error) { } return false; } function namehash(name) { if (typeof name !== "string") { logger$p.throwArgumentError("invalid ENS name; not a string", "name", name); } let result = Zeros$1; const comps = ensNameSplit(name); while (comps.length) { result = keccak256$1(concat([result, keccak256$1(comps.pop())])); } return hexlify(result); } function dnsEncode(name) { return hexlify(concat(ensNameSplit(name).map((comp) => { if (comp.length > 63) { throw new Error("invalid DNS encoded entry; length exceeds 63 bytes"); } const bytes = new Uint8Array(comp.length + 1); bytes.set(comp, 1); bytes[0] = bytes.length - 1; return bytes; }))) + "00"; } const messagePrefix = "Ethereum Signed Message:\n"; function hashMessage(message) { if (typeof message === "string") { message = toUtf8Bytes(message); } return keccak256$1(concat([ toUtf8Bytes(messagePrefix), toUtf8Bytes(String(message.length)), message ])); } var __awaiter$c = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$o = new Logger(version$h); const padding = new Uint8Array(32); padding.fill(0); const NegativeOne = BigNumber.from(-1); const Zero = BigNumber.from(0); const One = BigNumber.from(1); const MaxUint256 = BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); function hexPadRight(value) { const bytes = arrayify(value); const padOffset = bytes.length % 32; if (padOffset) { return hexConcat([bytes, padding.slice(padOffset)]); } return hexlify(bytes); } const hexTrue = hexZeroPad(One.toHexString(), 32); const hexFalse = hexZeroPad(Zero.toHexString(), 32); const domainFieldTypes = { name: "string", version: "string", chainId: "uint256", verifyingContract: "address", salt: "bytes32" }; const domainFieldNames = [ "name", "version", "chainId", "verifyingContract", "salt" ]; function checkString(key2) { return function(value) { if (typeof value !== "string") { logger$o.throwArgumentError(`invalid domain value for ${JSON.stringify(key2)}`, `domain.${key2}`, value); } return value; }; } const domainChecks = { name: checkString("name"), version: checkString("version"), chainId: function(value) { try { return BigNumber.from(value).toString(); } catch (error) { } return logger$o.throwArgumentError(`invalid domain value for "chainId"`, "domain.chainId", value); }, verifyingContract: function(value) { try { return getAddress(value).toLowerCase(); } catch (error) { } return logger$o.throwArgumentError(`invalid domain value "verifyingContract"`, "domain.verifyingContract", value); }, salt: function(value) { try { const bytes = arrayify(value); if (bytes.length !== 32) { throw new Error("bad length"); } return hexlify(bytes); } catch (error) { } return logger$o.throwArgumentError(`invalid domain value "salt"`, "domain.salt", value); } }; function getBaseEncoder(type) { { const match = type.match(/^(u?)int(\d*)$/); if (match) { const signed2 = match[1] === ""; const width = parseInt(match[2] || "256"); if (width % 8 !== 0 || width > 256 || match[2] && match[2] !== String(width)) { logger$o.throwArgumentError("invalid numeric width", "type", type); } const boundsUpper = MaxUint256.mask(signed2 ? width - 1 : width); const boundsLower = signed2 ? boundsUpper.add(One).mul(NegativeOne) : Zero; return function(value) { const v2 = BigNumber.from(value); if (v2.lt(boundsLower) || v2.gt(boundsUpper)) { logger$o.throwArgumentError(`value out-of-bounds for ${type}`, "value", value); } return hexZeroPad(v2.toTwos(256).toHexString(), 32); }; } } { const match = type.match(/^bytes(\d+)$/); if (match) { const width = parseInt(match[1]); if (width === 0 || width > 32 || match[1] !== String(width)) { logger$o.throwArgumentError("invalid bytes width", "type", type); } return function(value) { const bytes = arrayify(value); if (bytes.length !== width) { logger$o.throwArgumentError(`invalid length for ${type}`, "value", value); } return hexPadRight(value); }; } } switch (type) { case "address": return function(value) { return hexZeroPad(getAddress(value), 32); }; case "bool": return function(value) { return !value ? hexFalse : hexTrue; }; case "bytes": return function(value) { return keccak256$1(value); }; case "string": return function(value) { return id(value); }; } return null; } function encodeType(name, fields) { return `${name}(${fields.map(({ name: name2, type }) => type + " " + name2).join(",")})`; } class TypedDataEncoder { constructor(types) { defineReadOnly(this, "types", Object.freeze(deepCopy(types))); defineReadOnly(this, "_encoderCache", {}); defineReadOnly(this, "_types", {}); const links = {}; const parents = {}; const subtypes = {}; Object.keys(types).forEach((type) => { links[type] = {}; parents[type] = []; subtypes[type] = {}; }); for (const name in types) { const uniqueNames = {}; types[name].forEach((field) => { if (uniqueNames[field.name]) { logger$o.throwArgumentError(`duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, "types", types); } uniqueNames[field.name] = true; const baseType = field.type.match(/^([^\x5b]*)(\x5b|$)/)[1]; if (baseType === name) { logger$o.throwArgumentError(`circular type reference to ${JSON.stringify(baseType)}`, "types", types); } const encoder = getBaseEncoder(baseType); if (encoder) { return; } if (!parents[baseType]) { logger$o.throwArgumentError(`unknown type ${JSON.stringify(baseType)}`, "types", types); } parents[baseType].push(name); links[name][baseType] = true; }); } const primaryTypes = Object.keys(parents).filter((n2) => parents[n2].length === 0); if (primaryTypes.length === 0) { logger$o.throwArgumentError("missing primary type", "types", types); } else if (primaryTypes.length > 1) { logger$o.throwArgumentError(`ambiguous primary types or unused types: ${primaryTypes.map((t2) => JSON.stringify(t2)).join(", ")}`, "types", types); } defineReadOnly(this, "primaryType", primaryTypes[0]); function checkCircular(type, found) { if (found[type]) { logger$o.throwArgumentError(`circular type reference to ${JSON.stringify(type)}`, "types", types); } found[type] = true; Object.keys(links[type]).forEach((child) => { if (!parents[child]) { return; } checkCircular(child, found); Object.keys(found).forEach((subtype) => { subtypes[subtype][child] = true; }); }); delete found[type]; } checkCircular(this.primaryType, {}); for (const name in subtypes) { const st = Object.keys(subtypes[name]); st.sort(); this._types[name] = encodeType(name, types[name]) + st.map((t2) => encodeType(t2, types[t2])).join(""); } } getEncoder(type) { let encoder = this._encoderCache[type]; if (!encoder) { encoder = this._encoderCache[type] = this._getEncoder(type); } return encoder; } _getEncoder(type) { { const encoder = getBaseEncoder(type); if (encoder) { return encoder; } } const match = type.match(/^(.*)(\x5b(\d*)\x5d)$/); if (match) { const subtype = match[1]; const subEncoder = this.getEncoder(subtype); const length = parseInt(match[3]); return (value) => { if (length >= 0 && value.length !== length) { logger$o.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value); } let result = value.map(subEncoder); if (this._types[subtype]) { result = result.map(keccak256$1); } return keccak256$1(hexConcat(result)); }; } const fields = this.types[type]; if (fields) { const encodedType = id(this._types[type]); return (value) => { const values = fields.map(({ name, type: type2 }) => { const result = this.getEncoder(type2)(value[name]); if (this._types[type2]) { return keccak256$1(result); } return result; }); values.unshift(encodedType); return hexConcat(values); }; } return logger$o.throwArgumentError(`unknown type: ${type}`, "type", type); } encodeType(name) { const result = this._types[name]; if (!result) { logger$o.throwArgumentError(`unknown type: ${JSON.stringify(name)}`, "name", name); } return result; } encodeData(type, value) { return this.getEncoder(type)(value); } hashStruct(name, value) { return keccak256$1(this.encodeData(name, value)); } encode(value) { return this.encodeData(this.primaryType, value); } hash(value) { return this.hashStruct(this.primaryType, value); } _visit(type, value, callback) { { const encoder = getBaseEncoder(type); if (encoder) { return callback(type, value); } } const match = type.match(/^(.*)(\x5b(\d*)\x5d)$/); if (match) { const subtype = match[1]; const length = parseInt(match[3]); if (length >= 0 && value.length !== length) { logger$o.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value); } return value.map((v2) => this._visit(subtype, v2, callback)); } const fields = this.types[type]; if (fields) { return fields.reduce((accum, { name, type: type2 }) => { accum[name] = this._visit(type2, value[name], callback); return accum; }, {}); } return logger$o.throwArgumentError(`unknown type: ${type}`, "type", type); } visit(value, callback) { return this._visit(this.primaryType, value, callback); } static from(types) { return new TypedDataEncoder(types); } static getPrimaryType(types) { return TypedDataEncoder.from(types).primaryType; } static hashStruct(name, types, value) { return TypedDataEncoder.from(types).hashStruct(name, value); } static hashDomain(domain) { const domainFields = []; for (const name in domain) { const type = domainFieldTypes[name]; if (!type) { logger$o.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(name)}`, "domain", domain); } domainFields.push({ name, type }); } domainFields.sort((a2, b2) => { return domainFieldNames.indexOf(a2.name) - domainFieldNames.indexOf(b2.name); }); return TypedDataEncoder.hashStruct("EIP712Domain", { EIP712Domain: domainFields }, domain); } static encode(domain, types, value) { return hexConcat([ "0x1901", TypedDataEncoder.hashDomain(domain), TypedDataEncoder.from(types).hash(value) ]); } static hash(domain, types, value) { return keccak256$1(TypedDataEncoder.encode(domain, types, value)); } // Replaces all address types with ENS names with their looked up address static resolveNames(domain, types, value, resolveName2) { return __awaiter$c(this, void 0, void 0, function* () { domain = shallowCopy(domain); const ensCache = {}; if (domain.verifyingContract && !isHexString(domain.verifyingContract, 20)) { ensCache[domain.verifyingContract] = "0x"; } const encoder = TypedDataEncoder.from(types); encoder.visit(value, (type, value2) => { if (type === "address" && !isHexString(value2, 20)) { ensCache[value2] = "0x"; } return value2; }); for (const name in ensCache) { ensCache[name] = yield resolveName2(name); } if (domain.verifyingContract && ensCache[domain.verifyingContract]) { domain.verifyingContract = ensCache[domain.verifyingContract]; } value = encoder.visit(value, (type, value2) => { if (type === "address" && ensCache[value2]) { return ensCache[value2]; } return value2; }); return { domain, value }; }); } static getPayload(domain, types, value) { TypedDataEncoder.hashDomain(domain); const domainValues = {}; const domainTypes = []; domainFieldNames.forEach((name) => { const value2 = domain[name]; if (value2 == null) { return; } domainValues[name] = domainChecks[name](value2); domainTypes.push({ name, type: domainFieldTypes[name] }); }); const encoder = TypedDataEncoder.from(types); const typesWithDomain = shallowCopy(types); if (typesWithDomain.EIP712Domain) { logger$o.throwArgumentError("types must not contain EIP712Domain type", "types.EIP712Domain", types); } else { typesWithDomain.EIP712Domain = domainTypes; } encoder.encode(value); return { types: typesWithDomain, domain: domainValues, primaryType: encoder.primaryType, message: encoder.visit(value, (type, value2) => { if (type.match(/^bytes(\d*)/)) { return hexlify(arrayify(value2)); } if (type.match(/^u?int/)) { return BigNumber.from(value2).toString(); } switch (type) { case "address": return value2.toLowerCase(); case "bool": return !!value2; case "string": if (typeof value2 !== "string") { logger$o.throwArgumentError(`invalid string`, "value", value2); } return value2; } return logger$o.throwArgumentError("unsupported type", "type", type); }) }; } } const lib_esm$c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, _TypedDataEncoder: TypedDataEncoder, dnsEncode, ensNormalize, hashMessage, id, isValidName, messagePrefix, namehash }, Symbol.toStringTag, { value: "Module" })); const logger$n = new Logger(version$l); class LogDescription extends Description { } class TransactionDescription extends Description { } class ErrorDescription extends Description { } class Indexed extends Description { static isIndexed(value) { return !!(value && value._isIndexed); } } const BuiltinErrors = { "0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true }, "0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] } }; function wrapAccessError(property, error) { const wrap = new Error(`deferred error during ABI decoding triggered accessing ${property}`); wrap.error = error; return wrap; } class Interface { constructor(fragments) { let abi = []; if (typeof fragments === "string") { abi = JSON.parse(fragments); } else { abi = fragments; } defineReadOnly(this, "fragments", abi.map((fragment) => { return Fragment.from(fragment); }).filter((fragment) => fragment != null)); defineReadOnly(this, "_abiCoder", getStatic(new.target, "getAbiCoder")()); defineReadOnly(this, "functions", {}); defineReadOnly(this, "errors", {}); defineReadOnly(this, "events", {}); defineReadOnly(this, "structs", {}); this.fragments.forEach((fragment) => { let bucket = null; switch (fragment.type) { case "constructor": if (this.deploy) { logger$n.warn("duplicate definition - constructor"); return; } defineReadOnly(this, "deploy", fragment); return; case "function": bucket = this.functions; break; case "event": bucket = this.events; break; case "error": bucket = this.errors; break; default: return; } let signature2 = fragment.format(); if (bucket[signature2]) { logger$n.warn("duplicate definition - " + signature2); return; } bucket[signature2] = fragment; }); if (!this.deploy) { defineReadOnly(this, "deploy", ConstructorFragment.from({ payable: false, type: "constructor" })); } defineReadOnly(this, "_isInterface", true); } format(format) { if (!format) { format = FormatTypes.full; } if (format === FormatTypes.sighash) { logger$n.throwArgumentError("interface does not support formatting sighash", "format", format); } const abi = this.fragments.map((fragment) => fragment.format(format)); if (format === FormatTypes.json) { return JSON.stringify(abi.map((j2) => JSON.parse(j2))); } return abi; } // Sub-classes can override these to handle other blockchains static getAbiCoder() { return defaultAbiCoder; } static getAddress(address) { return getAddress(address); } static getSighash(fragment) { return hexDataSlice(id(fragment.format()), 0, 4); } static getEventTopic(eventFragment) { return id(eventFragment.format()); } // Find a function definition by any means necessary (unless it is ambiguous) getFunction(nameOrSignatureOrSighash) { if (isHexString(nameOrSignatureOrSighash)) { for (const name in this.functions) { if (nameOrSignatureOrSighash === this.getSighash(name)) { return this.functions[name]; } } logger$n.throwArgumentError("no matching function", "sighash", nameOrSignatureOrSighash); } if (nameOrSignatureOrSighash.indexOf("(") === -1) { const name = nameOrSignatureOrSighash.trim(); const matching = Object.keys(this.functions).filter((f2) => f2.split( "(" /* fix:) */ )[0] === name); if (matching.length === 0) { logger$n.throwArgumentError("no matching function", "name", name); } else if (matching.length > 1) { logger$n.throwArgumentError("multiple matching functions", "name", name); } return this.functions[matching[0]]; } const result = this.functions[FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; if (!result) { logger$n.throwArgumentError("no matching function", "signature", nameOrSignatureOrSighash); } return result; } // Find an event definition by any means necessary (unless it is ambiguous) getEvent(nameOrSignatureOrTopic) { if (isHexString(nameOrSignatureOrTopic)) { const topichash = nameOrSignatureOrTopic.toLowerCase(); for (const name in this.events) { if (topichash === this.getEventTopic(name)) { return this.events[name]; } } logger$n.throwArgumentError("no matching event", "topichash", topichash); } if (nameOrSignatureOrTopic.indexOf("(") === -1) { const name = nameOrSignatureOrTopic.trim(); const matching = Object.keys(this.events).filter((f2) => f2.split( "(" /* fix:) */ )[0] === name); if (matching.length === 0) { logger$n.throwArgumentError("no matching event", "name", name); } else if (matching.length > 1) { logger$n.throwArgumentError("multiple matching events", "name", name); } return this.events[matching[0]]; } const result = this.events[EventFragment.fromString(nameOrSignatureOrTopic).format()]; if (!result) { logger$n.throwArgumentError("no matching event", "signature", nameOrSignatureOrTopic); } return result; } // Find a function definition by any means necessary (unless it is ambiguous) getError(nameOrSignatureOrSighash) { if (isHexString(nameOrSignatureOrSighash)) { const getSighash = getStatic(this.constructor, "getSighash"); for (const name in this.errors) { const error = this.errors[name]; if (nameOrSignatureOrSighash === getSighash(error)) { return this.errors[name]; } } logger$n.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash); } if (nameOrSignatureOrSighash.indexOf("(") === -1) { const name = nameOrSignatureOrSighash.trim(); const matching = Object.keys(this.errors).filter((f2) => f2.split( "(" /* fix:) */ )[0] === name); if (matching.length === 0) { logger$n.throwArgumentError("no matching error", "name", name); } else if (matching.length > 1) { logger$n.throwArgumentError("multiple matching errors", "name", name); } return this.errors[matching[0]]; } const result = this.errors[FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; if (!result) { logger$n.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash); } return result; } // Get the sighash (the bytes4 selector) used by Solidity to identify a function getSighash(fragment) { if (typeof fragment === "string") { try { fragment = this.getFunction(fragment); } catch (error) { try { fragment = this.getError(fragment); } catch (_) { throw error; } } } return getStatic(this.constructor, "getSighash")(fragment); } // Get the topic (the bytes32 hash) used by Solidity to identify an event getEventTopic(eventFragment) { if (typeof eventFragment === "string") { eventFragment = this.getEvent(eventFragment); } return getStatic(this.constructor, "getEventTopic")(eventFragment); } _decodeParams(params, data) { return this._abiCoder.decode(params, data); } _encodeParams(params, values) { return this._abiCoder.encode(params, values); } encodeDeploy(values) { return this._encodeParams(this.deploy.inputs, values || []); } decodeErrorResult(fragment, data) { if (typeof fragment === "string") { fragment = this.getError(fragment); } const bytes = arrayify(data); if (hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) { logger$n.throwArgumentError(`data signature does not match error ${fragment.name}.`, "data", hexlify(bytes)); } return this._decodeParams(fragment.inputs, bytes.slice(4)); } encodeErrorResult(fragment, values) { if (typeof fragment === "string") { fragment = this.getError(fragment); } return hexlify(concat([ this.getSighash(fragment), this._encodeParams(fragment.inputs, values || []) ])); } // Decode the data for a function call (e.g. tx.data) decodeFunctionData(functionFragment, data) { if (typeof functionFragment === "string") { functionFragment = this.getFunction(functionFragment); } const bytes = arrayify(data); if (hexlify(bytes.slice(0, 4)) !== this.getSighash(functionFragment)) { logger$n.throwArgumentError(`data signature does not match function ${functionFragment.name}.`, "data", hexlify(bytes)); } return this._decodeParams(functionFragment.inputs, bytes.slice(4)); } // Encode the data for a function call (e.g. tx.data) encodeFunctionData(functionFragment, values) { if (typeof functionFragment === "string") { functionFragment = this.getFunction(functionFragment); } return hexlify(concat([ this.getSighash(functionFragment), this._encodeParams(functionFragment.inputs, values || []) ])); } // Decode the result from a function call (e.g. from eth_call) decodeFunctionResult(functionFragment, data) { if (typeof functionFragment === "string") { functionFragment = this.getFunction(functionFragment); } let bytes = arrayify(data); let reason = null; let message = ""; let errorArgs = null; let errorName = null; let errorSignature = null; switch (bytes.length % this._abiCoder._getWordSize()) { case 0: try { return this._abiCoder.decode(functionFragment.outputs, bytes); } catch (error) { } break; case 4: { const selector = hexlify(bytes.slice(0, 4)); const builtin = BuiltinErrors[selector]; if (builtin) { errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4)); errorName = builtin.name; errorSignature = builtin.signature; if (builtin.reason) { reason = errorArgs[0]; } if (errorName === "Error") { message = `; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(errorArgs[0])}`; } else if (errorName === "Panic") { message = `; VM Exception while processing transaction: reverted with panic code ${errorArgs[0]}`; } } else { try { const error = this.getError(selector); errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4)); errorName = error.name; errorSignature = error.format(); } catch (error) { } } break; } } return logger$n.throwError("call revert exception" + message, Logger.errors.CALL_EXCEPTION, { method: functionFragment.format(), data: hexlify(data), errorArgs, errorName, errorSignature, reason }); } // Encode the result for a function call (e.g. for eth_call) encodeFunctionResult(functionFragment, values) { if (typeof functionFragment === "string") { functionFragment = this.getFunction(functionFragment); } return hexlify(this._abiCoder.encode(functionFragment.outputs, values || [])); } // Create the filter for the event with search criteria (e.g. for eth_filterLog) encodeFilterTopics(eventFragment, values) { if (typeof eventFragment === "string") { eventFragment = this.getEvent(eventFragment); } if (values.length > eventFragment.inputs.length) { logger$n.throwError("too many arguments for " + eventFragment.format(), Logger.errors.UNEXPECTED_ARGUMENT, { argument: "values", value: values }); } let topics = []; if (!eventFragment.anonymous) { topics.push(this.getEventTopic(eventFragment)); } const encodeTopic = (param, value) => { if (param.type === "string") { return id(value); } else if (param.type === "bytes") { return keccak256$1(hexlify(value)); } if (param.type === "bool" && typeof value === "boolean") { value = value ? "0x01" : "0x00"; } if (param.type.match(/^u?int/)) { value = BigNumber.from(value).toHexString(); } if (param.type === "address") { this._abiCoder.encode(["address"], [value]); } return hexZeroPad(hexlify(value), 32); }; values.forEach((value, index) => { let param = eventFragment.inputs[index]; if (!param.indexed) { if (value != null) { logger$n.throwArgumentError("cannot filter non-indexed parameters; must be null", "contract." + param.name, value); } return; } if (value == null) { topics.push(null); } else if (param.baseType === "array" || param.baseType === "tuple") { logger$n.throwArgumentError("filtering with tuples or arrays not supported", "contract." + param.name, value); } else if (Array.isArray(value)) { topics.push(value.map((value2) => encodeTopic(param, value2))); } else { topics.push(encodeTopic(param, value)); } }); while (topics.length && topics[topics.length - 1] === null) { topics.pop(); } return topics; } encodeEventLog(eventFragment, values) { if (typeof eventFragment === "string") { eventFragment = this.getEvent(eventFragment); } const topics = []; const dataTypes = []; const dataValues = []; if (!eventFragment.anonymous) { topics.push(this.getEventTopic(eventFragment)); } if (values.length !== eventFragment.inputs.length) { logger$n.throwArgumentError("event arguments/values mismatch", "values", values); } eventFragment.inputs.forEach((param, index) => { const value = values[index]; if (param.indexed) { if (param.type === "string") { topics.push(id(value)); } else if (param.type === "bytes") { topics.push(keccak256$1(value)); } else if (param.baseType === "tuple" || param.baseType === "array") { throw new Error("not implemented"); } else { topics.push(this._abiCoder.encode([param.type], [value])); } } else { dataTypes.push(param); dataValues.push(value); } }); return { data: this._abiCoder.encode(dataTypes, dataValues), topics }; } // Decode a filter for the event and the search criteria decodeEventLog(eventFragment, data, topics) { if (typeof eventFragment === "string") { eventFragment = this.getEvent(eventFragment); } if (topics != null && !eventFragment.anonymous) { let topicHash = this.getEventTopic(eventFragment); if (!isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { logger$n.throwError("fragment/topic mismatch", Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); } topics = topics.slice(1); } let indexed = []; let nonIndexed = []; let dynamic = []; eventFragment.inputs.forEach((param, index) => { if (param.indexed) { if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { indexed.push(ParamType.fromObject({ type: "bytes32", name: param.name })); dynamic.push(true); } else { indexed.push(param); dynamic.push(false); } } else { nonIndexed.push(param); dynamic.push(false); } }); let resultIndexed = topics != null ? this._abiCoder.decode(indexed, concat(topics)) : null; let resultNonIndexed = this._abiCoder.decode(nonIndexed, data, true); let result = []; let nonIndexedIndex = 0, indexedIndex = 0; eventFragment.inputs.forEach((param, index) => { if (param.indexed) { if (resultIndexed == null) { result[index] = new Indexed({ _isIndexed: true, hash: null }); } else if (dynamic[index]) { result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] }); } else { try { result[index] = resultIndexed[indexedIndex++]; } catch (error) { result[index] = error; } } } else { try { result[index] = resultNonIndexed[nonIndexedIndex++]; } catch (error) { result[index] = error; } } if (param.name && result[param.name] == null) { const value = result[index]; if (value instanceof Error) { Object.defineProperty(result, param.name, { enumerable: true, get: () => { throw wrapAccessError(`property ${JSON.stringify(param.name)}`, value); } }); } else { result[param.name] = value; } } }); for (let i2 = 0; i2 < result.length; i2++) { const value = result[i2]; if (value instanceof Error) { Object.defineProperty(result, i2, { enumerable: true, get: () => { throw wrapAccessError(`index ${i2}`, value); } }); } } return Object.freeze(result); } // Given a transaction, find the matching function fragment (if any) and // determine all its properties and call parameters parseTransaction(tx) { let fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()); if (!fragment) { return null; } return new TransactionDescription({ args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), functionFragment: fragment, name: fragment.name, signature: fragment.format(), sighash: this.getSighash(fragment), value: BigNumber.from(tx.value || "0") }); } // @TODO //parseCallResult(data: BytesLike): ?? // Given an event log, find the matching event fragment (if any) and // determine all its properties and values parseLog(log) { let fragment = this.getEvent(log.topics[0]); if (!fragment || fragment.anonymous) { return null; } return new LogDescription({ eventFragment: fragment, name: fragment.name, signature: fragment.format(), topic: this.getEventTopic(fragment), args: this.decodeEventLog(fragment, log.data, log.topics) }); } parseError(data) { const hexData = hexlify(data); let fragment = this.getError(hexData.substring(0, 10).toLowerCase()); if (!fragment) { return null; } return new ErrorDescription({ args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)), errorFragment: fragment, name: fragment.name, signature: fragment.format(), sighash: this.getSighash(fragment) }); } /* static from(value: Array | string | Interface) { if (Interface.isInterface(value)) { return value; } if (typeof(value) === "string") { return new Interface(JSON.parse(value)); } return new Interface(value); } */ static isInterface(value) { return !!(value && value._isInterface); } } const lib_esm$b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, AbiCoder, ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, Indexed, Interface, LogDescription, ParamType, TransactionDescription, checkResultErrors, defaultAbiCoder }, Symbol.toStringTag, { value: "Module" })); const version$g = "abstract-provider/5.7.0"; var __awaiter$b = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$m = new Logger(version$g); class ForkEvent extends Description { static isForkEvent(value) { return !!(value && value._isForkEvent); } } class Provider { constructor() { logger$m.checkAbstract(new.target, Provider); defineReadOnly(this, "_isProvider", true); } getFeeData() { return __awaiter$b(this, void 0, void 0, function* () { const { block, gasPrice } = yield resolveProperties({ block: this.getBlock("latest"), gasPrice: this.getGasPrice().catch((error) => { return null; }) }); let lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null; if (block && block.baseFeePerGas) { lastBaseFeePerGas = block.baseFeePerGas; maxPriorityFeePerGas = BigNumber.from("1500000000"); maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas); } return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice }; }); } // Alias for "on" addListener(eventName, listener) { return this.on(eventName, listener); } // Alias for "off" removeListener(eventName, listener) { return this.off(eventName, listener); } static isProvider(value) { return !!(value && value._isProvider); } } const version$f = "abstract-signer/5.7.0"; var __awaiter$a = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$l = new Logger(version$f); const allowedTransactionKeys$2 = [ "accessList", "ccipReadEnabled", "chainId", "customData", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value" ]; const forwardErrors = [ Logger.errors.INSUFFICIENT_FUNDS, Logger.errors.NONCE_EXPIRED, Logger.errors.REPLACEMENT_UNDERPRICED ]; class Signer { /////////////////// // Sub-classes MUST call super constructor() { logger$l.checkAbstract(new.target, Signer); defineReadOnly(this, "_isSigner", true); } /////////////////// // Sub-classes MAY override these getBalance(blockTag) { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("getBalance"); return yield this.provider.getBalance(this.getAddress(), blockTag); }); } getTransactionCount(blockTag) { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("getTransactionCount"); return yield this.provider.getTransactionCount(this.getAddress(), blockTag); }); } // Populates "from" if unspecified, and estimates the gas for the transaction estimateGas(transaction) { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("estimateGas"); const tx = yield resolveProperties(this.checkTransaction(transaction)); return yield this.provider.estimateGas(tx); }); } // Populates "from" if unspecified, and calls with the transaction call(transaction, blockTag) { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("call"); const tx = yield resolveProperties(this.checkTransaction(transaction)); return yield this.provider.call(tx, blockTag); }); } // Populates all fields in a transaction, signs it and sends it to the network sendTransaction(transaction) { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("sendTransaction"); const tx = yield this.populateTransaction(transaction); const signedTx = yield this.signTransaction(tx); return yield this.provider.sendTransaction(signedTx); }); } getChainId() { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("getChainId"); const network = yield this.provider.getNetwork(); return network.chainId; }); } getGasPrice() { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("getGasPrice"); return yield this.provider.getGasPrice(); }); } getFeeData() { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("getFeeData"); return yield this.provider.getFeeData(); }); } resolveName(name) { return __awaiter$a(this, void 0, void 0, function* () { this._checkProvider("resolveName"); return yield this.provider.resolveName(name); }); } // Checks a transaction does not contain invalid keys and if // no "from" is provided, populates it. // - does NOT require a provider // - adds "from" is not present // - returns a COPY (safe to mutate the result) // By default called from: (overriding these prevents it) // - call // - estimateGas // - populateTransaction (and therefor sendTransaction) checkTransaction(transaction) { for (const key2 in transaction) { if (allowedTransactionKeys$2.indexOf(key2) === -1) { logger$l.throwArgumentError("invalid transaction key: " + key2, "transaction", transaction); } } const tx = shallowCopy(transaction); if (tx.from == null) { tx.from = this.getAddress(); } else { tx.from = Promise.all([ Promise.resolve(tx.from), this.getAddress() ]).then((result) => { if (result[0].toLowerCase() !== result[1].toLowerCase()) { logger$l.throwArgumentError("from address mismatch", "transaction", transaction); } return result[0]; }); } return tx; } // Populates ALL keys for a transaction and checks that "from" matches // this Signer. Should be used by sendTransaction but NOT by signTransaction. // By default called from: (overriding these prevents it) // - sendTransaction // // Notes: // - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas populateTransaction(transaction) { return __awaiter$a(this, void 0, void 0, function* () { const tx = yield resolveProperties(this.checkTransaction(transaction)); if (tx.to != null) { tx.to = Promise.resolve(tx.to).then((to) => __awaiter$a(this, void 0, void 0, function* () { if (to == null) { return null; } const address = yield this.resolveName(to); if (address == null) { logger$l.throwArgumentError("provided ENS name resolves to null", "tx.to", to); } return address; })); tx.to.catch((error) => { }); } const hasEip1559 = tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null; if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) { logger$l.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction); } else if ((tx.type === 0 || tx.type === 1) && hasEip1559) { logger$l.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction); } if ((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null)) { tx.type = 2; } else if (tx.type === 0 || tx.type === 1) { if (tx.gasPrice == null) { tx.gasPrice = this.getGasPrice(); } } else { const feeData = yield this.getFeeData(); if (tx.type == null) { if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) { tx.type = 2; if (tx.gasPrice != null) { const gasPrice = tx.gasPrice; delete tx.gasPrice; tx.maxFeePerGas = gasPrice; tx.maxPriorityFeePerGas = gasPrice; } else { if (tx.maxFeePerGas == null) { tx.maxFeePerGas = feeData.maxFeePerGas; } if (tx.maxPriorityFeePerGas == null) { tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; } } } else if (feeData.gasPrice != null) { if (hasEip1559) { logger$l.throwError("network does not support EIP-1559", Logger.errors.UNSUPPORTED_OPERATION, { operation: "populateTransaction" }); } if (tx.gasPrice == null) { tx.gasPrice = feeData.gasPrice; } tx.type = 0; } else { logger$l.throwError("failed to get consistent fee data", Logger.errors.UNSUPPORTED_OPERATION, { operation: "signer.getFeeData" }); } } else if (tx.type === 2) { if (tx.maxFeePerGas == null) { tx.maxFeePerGas = feeData.maxFeePerGas; } if (tx.maxPriorityFeePerGas == null) { tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; } } } if (tx.nonce == null) { tx.nonce = this.getTransactionCount("pending"); } if (tx.gasLimit == null) { tx.gasLimit = this.estimateGas(tx).catch((error) => { if (forwardErrors.indexOf(error.code) >= 0) { throw error; } return logger$l.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { error, tx }); }); } if (tx.chainId == null) { tx.chainId = this.getChainId(); } else { tx.chainId = Promise.all([ Promise.resolve(tx.chainId), this.getChainId() ]).then((results) => { if (results[1] !== 0 && results[0] !== results[1]) { logger$l.throwArgumentError("chainId address mismatch", "transaction", transaction); } return results[0]; }); } return yield resolveProperties(tx); }); } /////////////////// // Sub-classes SHOULD leave these alone _checkProvider(operation) { if (!this.provider) { logger$l.throwError("missing provider", Logger.errors.UNSUPPORTED_OPERATION, { operation: operation || "_checkProvider" }); } } static isSigner(value) { return !!(value && value._isSigner); } } class VoidSigner extends Signer { constructor(address, provider) { super(); defineReadOnly(this, "address", address); defineReadOnly(this, "provider", provider || null); } getAddress() { return Promise.resolve(this.address); } _fail(message, operation) { return Promise.resolve().then(() => { logger$l.throwError(message, Logger.errors.UNSUPPORTED_OPERATION, { operation }); }); } signMessage(message) { return this._fail("VoidSigner cannot sign messages", "signMessage"); } signTransaction(transaction) { return this._fail("VoidSigner cannot sign transactions", "signTransaction"); } _signTypedData(domain, types, value) { return this._fail("VoidSigner cannot sign typed data", "signTypedData"); } connect(provider) { return new VoidSigner(this.address, provider); } } var hash = {}; var utils$a = {}; var minimalisticAssert$1 = assert$b; function assert$b(val, msg) { if (!val) throw new Error(msg || "Assertion failed"); } assert$b.equal = function assertEqual(l2, r2, msg) { if (l2 != r2) throw new Error(msg || "Assertion failed: " + l2 + " != " + r2); }; var inherits_browserExports = {}; var inherits_browser$1 = { get exports() { return inherits_browserExports; }, set exports(v2) { inherits_browserExports = v2; } }; if (typeof Object.create === "function") { inherits_browser$1.exports = function inherits2(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } }); } }; } else { inherits_browser$1.exports = function inherits2(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; var TempCtor = function() { }; TempCtor.prototype = superCtor.prototype; ctor.prototype = new TempCtor(); ctor.prototype.constructor = ctor; } }; } var assert$a = minimalisticAssert$1; var inherits = inherits_browserExports; utils$a.inherits = inherits; function isSurrogatePair(msg, i2) { if ((msg.charCodeAt(i2) & 64512) !== 55296) { return false; } if (i2 < 0 || i2 + 1 >= msg.length) { return false; } return (msg.charCodeAt(i2 + 1) & 64512) === 56320; } function toArray(msg, enc) { if (Array.isArray(msg)) return msg.slice(); if (!msg) return []; var res = []; if (typeof msg === "string") { if (!enc) { var p2 = 0; for (var i2 = 0; i2 < msg.length; i2++) { var c2 = msg.charCodeAt(i2); if (c2 < 128) { res[p2++] = c2; } else if (c2 < 2048) { res[p2++] = c2 >> 6 | 192; res[p2++] = c2 & 63 | 128; } else if (isSurrogatePair(msg, i2)) { c2 = 65536 + ((c2 & 1023) << 10) + (msg.charCodeAt(++i2) & 1023); res[p2++] = c2 >> 18 | 240; res[p2++] = c2 >> 12 & 63 | 128; res[p2++] = c2 >> 6 & 63 | 128; res[p2++] = c2 & 63 | 128; } else { res[p2++] = c2 >> 12 | 224; res[p2++] = c2 >> 6 & 63 | 128; res[p2++] = c2 & 63 | 128; } } } else if (enc === "hex") { msg = msg.replace(/[^a-z0-9]+/ig, ""); if (msg.length % 2 !== 0) msg = "0" + msg; for (i2 = 0; i2 < msg.length; i2 += 2) res.push(parseInt(msg[i2] + msg[i2 + 1], 16)); } } else { for (i2 = 0; i2 < msg.length; i2++) res[i2] = msg[i2] | 0; } return res; } utils$a.toArray = toArray; function toHex(msg) { var res = ""; for (var i2 = 0; i2 < msg.length; i2++) res += zero2(msg[i2].toString(16)); return res; } utils$a.toHex = toHex; function htonl(w) { var res = w >>> 24 | w >>> 8 & 65280 | w << 8 & 16711680 | (w & 255) << 24; return res >>> 0; } utils$a.htonl = htonl; function toHex32(msg, endian) { var res = ""; for (var i2 = 0; i2 < msg.length; i2++) { var w = msg[i2]; if (endian === "little") w = htonl(w); res += zero8(w.toString(16)); } return res; } utils$a.toHex32 = toHex32; function zero2(word) { if (word.length === 1) return "0" + word; else return word; } utils$a.zero2 = zero2; function zero8(word) { if (word.length === 7) return "0" + word; else if (word.length === 6) return "00" + word; else if (word.length === 5) return "000" + word; else if (word.length === 4) return "0000" + word; else if (word.length === 3) return "00000" + word; else if (word.length === 2) return "000000" + word; else if (word.length === 1) return "0000000" + word; else return word; } utils$a.zero8 = zero8; function join32(msg, start, end, endian) { var len = end - start; assert$a(len % 4 === 0); var res = new Array(len / 4); for (var i2 = 0, k2 = start; i2 < res.length; i2++, k2 += 4) { var w; if (endian === "big") w = msg[k2] << 24 | msg[k2 + 1] << 16 | msg[k2 + 2] << 8 | msg[k2 + 3]; else w = msg[k2 + 3] << 24 | msg[k2 + 2] << 16 | msg[k2 + 1] << 8 | msg[k2]; res[i2] = w >>> 0; } return res; } utils$a.join32 = join32; function split32(msg, endian) { var res = new Array(msg.length * 4); for (var i2 = 0, k2 = 0; i2 < msg.length; i2++, k2 += 4) { var m2 = msg[i2]; if (endian === "big") { res[k2] = m2 >>> 24; res[k2 + 1] = m2 >>> 16 & 255; res[k2 + 2] = m2 >>> 8 & 255; res[k2 + 3] = m2 & 255; } else { res[k2 + 3] = m2 >>> 24; res[k2 + 2] = m2 >>> 16 & 255; res[k2 + 1] = m2 >>> 8 & 255; res[k2] = m2 & 255; } } return res; } utils$a.split32 = split32; function rotr32$1(w, b2) { return w >>> b2 | w << 32 - b2; } utils$a.rotr32 = rotr32$1; function rotl32$2(w, b2) { return w << b2 | w >>> 32 - b2; } utils$a.rotl32 = rotl32$2; function sum32$3(a2, b2) { return a2 + b2 >>> 0; } utils$a.sum32 = sum32$3; function sum32_3$1(a2, b2, c2) { return a2 + b2 + c2 >>> 0; } utils$a.sum32_3 = sum32_3$1; function sum32_4$2(a2, b2, c2, d2) { return a2 + b2 + c2 + d2 >>> 0; } utils$a.sum32_4 = sum32_4$2; function sum32_5$2(a2, b2, c2, d2, e) { return a2 + b2 + c2 + d2 + e >>> 0; } utils$a.sum32_5 = sum32_5$2; function sum64$1(buf, pos, ah, al) { var bh = buf[pos]; var bl = buf[pos + 1]; var lo = al + bl >>> 0; var hi = (lo < al ? 1 : 0) + ah + bh; buf[pos] = hi >>> 0; buf[pos + 1] = lo; } utils$a.sum64 = sum64$1; function sum64_hi$1(ah, al, bh, bl) { var lo = al + bl >>> 0; var hi = (lo < al ? 1 : 0) + ah + bh; return hi >>> 0; } utils$a.sum64_hi = sum64_hi$1; function sum64_lo$1(ah, al, bh, bl) { var lo = al + bl; return lo >>> 0; } utils$a.sum64_lo = sum64_lo$1; function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) { var carry = 0; var lo = al; lo = lo + bl >>> 0; carry += lo < al ? 1 : 0; lo = lo + cl >>> 0; carry += lo < cl ? 1 : 0; lo = lo + dl >>> 0; carry += lo < dl ? 1 : 0; var hi = ah + bh + ch + dh + carry; return hi >>> 0; } utils$a.sum64_4_hi = sum64_4_hi$1; function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) { var lo = al + bl + cl + dl; return lo >>> 0; } utils$a.sum64_4_lo = sum64_4_lo$1; function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { var carry = 0; var lo = al; lo = lo + bl >>> 0; carry += lo < al ? 1 : 0; lo = lo + cl >>> 0; carry += lo < cl ? 1 : 0; lo = lo + dl >>> 0; carry += lo < dl ? 1 : 0; lo = lo + el >>> 0; carry += lo < el ? 1 : 0; var hi = ah + bh + ch + dh + eh + carry; return hi >>> 0; } utils$a.sum64_5_hi = sum64_5_hi$1; function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { var lo = al + bl + cl + dl + el; return lo >>> 0; } utils$a.sum64_5_lo = sum64_5_lo$1; function rotr64_hi$1(ah, al, num) { var r2 = al << 32 - num | ah >>> num; return r2 >>> 0; } utils$a.rotr64_hi = rotr64_hi$1; function rotr64_lo$1(ah, al, num) { var r2 = ah << 32 - num | al >>> num; return r2 >>> 0; } utils$a.rotr64_lo = rotr64_lo$1; function shr64_hi$1(ah, al, num) { return ah >>> num; } utils$a.shr64_hi = shr64_hi$1; function shr64_lo$1(ah, al, num) { var r2 = ah << 32 - num | al >>> num; return r2 >>> 0; } utils$a.shr64_lo = shr64_lo$1; var common$5 = {}; var utils$9 = utils$a; var assert$9 = minimalisticAssert$1; function BlockHash$4() { this.pending = null; this.pendingTotal = 0; this.blockSize = this.constructor.blockSize; this.outSize = this.constructor.outSize; this.hmacStrength = this.constructor.hmacStrength; this.padLength = this.constructor.padLength / 8; this.endian = "big"; this._delta8 = this.blockSize / 8; this._delta32 = this.blockSize / 32; } common$5.BlockHash = BlockHash$4; BlockHash$4.prototype.update = function update(msg, enc) { msg = utils$9.toArray(msg, enc); if (!this.pending) this.pending = msg; else this.pending = this.pending.concat(msg); this.pendingTotal += msg.length; if (this.pending.length >= this._delta8) { msg = this.pending; var r2 = msg.length % this._delta8; this.pending = msg.slice(msg.length - r2, msg.length); if (this.pending.length === 0) this.pending = null; msg = utils$9.join32(msg, 0, msg.length - r2, this.endian); for (var i2 = 0; i2 < msg.length; i2 += this._delta32) this._update(msg, i2, i2 + this._delta32); } return this; }; BlockHash$4.prototype.digest = function digest(enc) { this.update(this._pad()); assert$9(this.pending === null); return this._digest(enc); }; BlockHash$4.prototype._pad = function pad() { var len = this.pendingTotal; var bytes = this._delta8; var k2 = bytes - (len + this.padLength) % bytes; var res = new Array(k2 + this.padLength); res[0] = 128; for (var i2 = 1; i2 < k2; i2++) res[i2] = 0; len <<= 3; if (this.endian === "big") { for (var t2 = 8; t2 < this.padLength; t2++) res[i2++] = 0; res[i2++] = 0; res[i2++] = 0; res[i2++] = 0; res[i2++] = 0; res[i2++] = len >>> 24 & 255; res[i2++] = len >>> 16 & 255; res[i2++] = len >>> 8 & 255; res[i2++] = len & 255; } else { res[i2++] = len & 255; res[i2++] = len >>> 8 & 255; res[i2++] = len >>> 16 & 255; res[i2++] = len >>> 24 & 255; res[i2++] = 0; res[i2++] = 0; res[i2++] = 0; res[i2++] = 0; for (t2 = 8; t2 < this.padLength; t2++) res[i2++] = 0; } return res; }; var sha = {}; var common$4 = {}; var utils$8 = utils$a; var rotr32 = utils$8.rotr32; function ft_1$1(s2, x, y2, z) { if (s2 === 0) return ch32$1(x, y2, z); if (s2 === 1 || s2 === 3) return p32(x, y2, z); if (s2 === 2) return maj32$1(x, y2, z); } common$4.ft_1 = ft_1$1; function ch32$1(x, y2, z) { return x & y2 ^ ~x & z; } common$4.ch32 = ch32$1; function maj32$1(x, y2, z) { return x & y2 ^ x & z ^ y2 & z; } common$4.maj32 = maj32$1; function p32(x, y2, z) { return x ^ y2 ^ z; } common$4.p32 = p32; function s0_256$1(x) { return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22); } common$4.s0_256 = s0_256$1; function s1_256$1(x) { return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25); } common$4.s1_256 = s1_256$1; function g0_256$1(x) { return rotr32(x, 7) ^ rotr32(x, 18) ^ x >>> 3; } common$4.g0_256 = g0_256$1; function g1_256$1(x) { return rotr32(x, 17) ^ rotr32(x, 19) ^ x >>> 10; } common$4.g1_256 = g1_256$1; var utils$7 = utils$a; var common$3 = common$5; var shaCommon$1 = common$4; var rotl32$1 = utils$7.rotl32; var sum32$2 = utils$7.sum32; var sum32_5$1 = utils$7.sum32_5; var ft_1 = shaCommon$1.ft_1; var BlockHash$3 = common$3.BlockHash; var sha1_K = [ 1518500249, 1859775393, 2400959708, 3395469782 ]; function SHA1() { if (!(this instanceof SHA1)) return new SHA1(); BlockHash$3.call(this); this.h = [ 1732584193, 4023233417, 2562383102, 271733878, 3285377520 ]; this.W = new Array(80); } utils$7.inherits(SHA1, BlockHash$3); var _1 = SHA1; SHA1.blockSize = 512; SHA1.outSize = 160; SHA1.hmacStrength = 80; SHA1.padLength = 64; SHA1.prototype._update = function _update(msg, start) { var W2 = this.W; for (var i2 = 0; i2 < 16; i2++) W2[i2] = msg[start + i2]; for (; i2 < W2.length; i2++) W2[i2] = rotl32$1(W2[i2 - 3] ^ W2[i2 - 8] ^ W2[i2 - 14] ^ W2[i2 - 16], 1); var a2 = this.h[0]; var b2 = this.h[1]; var c2 = this.h[2]; var d2 = this.h[3]; var e = this.h[4]; for (i2 = 0; i2 < W2.length; i2++) { var s2 = ~~(i2 / 20); var t2 = sum32_5$1(rotl32$1(a2, 5), ft_1(s2, b2, c2, d2), e, W2[i2], sha1_K[s2]); e = d2; d2 = c2; c2 = rotl32$1(b2, 30); b2 = a2; a2 = t2; } this.h[0] = sum32$2(this.h[0], a2); this.h[1] = sum32$2(this.h[1], b2); this.h[2] = sum32$2(this.h[2], c2); this.h[3] = sum32$2(this.h[3], d2); this.h[4] = sum32$2(this.h[4], e); }; SHA1.prototype._digest = function digest2(enc) { if (enc === "hex") return utils$7.toHex32(this.h, "big"); else return utils$7.split32(this.h, "big"); }; var utils$6 = utils$a; var common$2 = common$5; var shaCommon = common$4; var assert$8 = minimalisticAssert$1; var sum32$1 = utils$6.sum32; var sum32_4$1 = utils$6.sum32_4; var sum32_5 = utils$6.sum32_5; var ch32 = shaCommon.ch32; var maj32 = shaCommon.maj32; var s0_256 = shaCommon.s0_256; var s1_256 = shaCommon.s1_256; var g0_256 = shaCommon.g0_256; var g1_256 = shaCommon.g1_256; var BlockHash$2 = common$2.BlockHash; var sha256_K = [ 1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298 ]; function SHA256$1() { if (!(this instanceof SHA256$1)) return new SHA256$1(); BlockHash$2.call(this); this.h = [ 1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225 ]; this.k = sha256_K; this.W = new Array(64); } utils$6.inherits(SHA256$1, BlockHash$2); var _256 = SHA256$1; SHA256$1.blockSize = 512; SHA256$1.outSize = 256; SHA256$1.hmacStrength = 192; SHA256$1.padLength = 64; SHA256$1.prototype._update = function _update2(msg, start) { var W2 = this.W; for (var i2 = 0; i2 < 16; i2++) W2[i2] = msg[start + i2]; for (; i2 < W2.length; i2++) W2[i2] = sum32_4$1(g1_256(W2[i2 - 2]), W2[i2 - 7], g0_256(W2[i2 - 15]), W2[i2 - 16]); var a2 = this.h[0]; var b2 = this.h[1]; var c2 = this.h[2]; var d2 = this.h[3]; var e = this.h[4]; var f2 = this.h[5]; var g2 = this.h[6]; var h2 = this.h[7]; assert$8(this.k.length === W2.length); for (i2 = 0; i2 < W2.length; i2++) { var T1 = sum32_5(h2, s1_256(e), ch32(e, f2, g2), this.k[i2], W2[i2]); var T2 = sum32$1(s0_256(a2), maj32(a2, b2, c2)); h2 = g2; g2 = f2; f2 = e; e = sum32$1(d2, T1); d2 = c2; c2 = b2; b2 = a2; a2 = sum32$1(T1, T2); } this.h[0] = sum32$1(this.h[0], a2); this.h[1] = sum32$1(this.h[1], b2); this.h[2] = sum32$1(this.h[2], c2); this.h[3] = sum32$1(this.h[3], d2); this.h[4] = sum32$1(this.h[4], e); this.h[5] = sum32$1(this.h[5], f2); this.h[6] = sum32$1(this.h[6], g2); this.h[7] = sum32$1(this.h[7], h2); }; SHA256$1.prototype._digest = function digest3(enc) { if (enc === "hex") return utils$6.toHex32(this.h, "big"); else return utils$6.split32(this.h, "big"); }; var utils$5 = utils$a; var SHA256 = _256; function SHA224() { if (!(this instanceof SHA224)) return new SHA224(); SHA256.call(this); this.h = [ 3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428 ]; } utils$5.inherits(SHA224, SHA256); var _224 = SHA224; SHA224.blockSize = 512; SHA224.outSize = 224; SHA224.hmacStrength = 192; SHA224.padLength = 64; SHA224.prototype._digest = function digest4(enc) { if (enc === "hex") return utils$5.toHex32(this.h.slice(0, 7), "big"); else return utils$5.split32(this.h.slice(0, 7), "big"); }; var utils$4 = utils$a; var common$1 = common$5; var assert$7 = minimalisticAssert$1; var rotr64_hi = utils$4.rotr64_hi; var rotr64_lo = utils$4.rotr64_lo; var shr64_hi = utils$4.shr64_hi; var shr64_lo = utils$4.shr64_lo; var sum64 = utils$4.sum64; var sum64_hi = utils$4.sum64_hi; var sum64_lo = utils$4.sum64_lo; var sum64_4_hi = utils$4.sum64_4_hi; var sum64_4_lo = utils$4.sum64_4_lo; var sum64_5_hi = utils$4.sum64_5_hi; var sum64_5_lo = utils$4.sum64_5_lo; var BlockHash$1 = common$1.BlockHash; var sha512_K = [ 1116352408, 3609767458, 1899447441, 602891725, 3049323471, 3964484399, 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591 ]; function SHA512$1() { if (!(this instanceof SHA512$1)) return new SHA512$1(); BlockHash$1.call(this); this.h = [ 1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209 ]; this.k = sha512_K; this.W = new Array(160); } utils$4.inherits(SHA512$1, BlockHash$1); var _512 = SHA512$1; SHA512$1.blockSize = 1024; SHA512$1.outSize = 512; SHA512$1.hmacStrength = 192; SHA512$1.padLength = 128; SHA512$1.prototype._prepareBlock = function _prepareBlock(msg, start) { var W2 = this.W; for (var i2 = 0; i2 < 32; i2++) W2[i2] = msg[start + i2]; for (; i2 < W2.length; i2 += 2) { var c0_hi = g1_512_hi(W2[i2 - 4], W2[i2 - 3]); var c0_lo = g1_512_lo(W2[i2 - 4], W2[i2 - 3]); var c1_hi = W2[i2 - 14]; var c1_lo = W2[i2 - 13]; var c2_hi = g0_512_hi(W2[i2 - 30], W2[i2 - 29]); var c2_lo = g0_512_lo(W2[i2 - 30], W2[i2 - 29]); var c3_hi = W2[i2 - 32]; var c3_lo = W2[i2 - 31]; W2[i2] = sum64_4_hi( c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo ); W2[i2 + 1] = sum64_4_lo( c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo ); } }; SHA512$1.prototype._update = function _update3(msg, start) { this._prepareBlock(msg, start); var W2 = this.W; var ah = this.h[0]; var al = this.h[1]; var bh = this.h[2]; var bl = this.h[3]; var ch = this.h[4]; var cl = this.h[5]; var dh = this.h[6]; var dl = this.h[7]; var eh = this.h[8]; var el = this.h[9]; var fh = this.h[10]; var fl = this.h[11]; var gh = this.h[12]; var gl = this.h[13]; var hh = this.h[14]; var hl = this.h[15]; assert$7(this.k.length === W2.length); for (var i2 = 0; i2 < W2.length; i2 += 2) { var c0_hi = hh; var c0_lo = hl; var c1_hi = s1_512_hi(eh, el); var c1_lo = s1_512_lo(eh, el); var c2_hi = ch64_hi(eh, el, fh, fl, gh); var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); var c3_hi = this.k[i2]; var c3_lo = this.k[i2 + 1]; var c4_hi = W2[i2]; var c4_lo = W2[i2 + 1]; var T1_hi = sum64_5_hi( c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo ); var T1_lo = sum64_5_lo( c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo ); c0_hi = s0_512_hi(ah, al); c0_lo = s0_512_lo(ah, al); c1_hi = maj64_hi(ah, al, bh, bl, ch); c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo); var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo); hh = gh; hl = gl; gh = fh; gl = fl; fh = eh; fl = el; eh = sum64_hi(dh, dl, T1_hi, T1_lo); el = sum64_lo(dl, dl, T1_hi, T1_lo); dh = ch; dl = cl; ch = bh; cl = bl; bh = ah; bl = al; ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo); al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo); } sum64(this.h, 0, ah, al); sum64(this.h, 2, bh, bl); sum64(this.h, 4, ch, cl); sum64(this.h, 6, dh, dl); sum64(this.h, 8, eh, el); sum64(this.h, 10, fh, fl); sum64(this.h, 12, gh, gl); sum64(this.h, 14, hh, hl); }; SHA512$1.prototype._digest = function digest5(enc) { if (enc === "hex") return utils$4.toHex32(this.h, "big"); else return utils$4.split32(this.h, "big"); }; function ch64_hi(xh, xl, yh, yl, zh) { var r2 = xh & yh ^ ~xh & zh; if (r2 < 0) r2 += 4294967296; return r2; } function ch64_lo(xh, xl, yh, yl, zh, zl) { var r2 = xl & yl ^ ~xl & zl; if (r2 < 0) r2 += 4294967296; return r2; } function maj64_hi(xh, xl, yh, yl, zh) { var r2 = xh & yh ^ xh & zh ^ yh & zh; if (r2 < 0) r2 += 4294967296; return r2; } function maj64_lo(xh, xl, yh, yl, zh, zl) { var r2 = xl & yl ^ xl & zl ^ yl & zl; if (r2 < 0) r2 += 4294967296; return r2; } function s0_512_hi(xh, xl) { var c0_hi = rotr64_hi(xh, xl, 28); var c1_hi = rotr64_hi(xl, xh, 2); var c2_hi = rotr64_hi(xl, xh, 7); var r2 = c0_hi ^ c1_hi ^ c2_hi; if (r2 < 0) r2 += 4294967296; return r2; } function s0_512_lo(xh, xl) { var c0_lo = rotr64_lo(xh, xl, 28); var c1_lo = rotr64_lo(xl, xh, 2); var c2_lo = rotr64_lo(xl, xh, 7); var r2 = c0_lo ^ c1_lo ^ c2_lo; if (r2 < 0) r2 += 4294967296; return r2; } function s1_512_hi(xh, xl) { var c0_hi = rotr64_hi(xh, xl, 14); var c1_hi = rotr64_hi(xh, xl, 18); var c2_hi = rotr64_hi(xl, xh, 9); var r2 = c0_hi ^ c1_hi ^ c2_hi; if (r2 < 0) r2 += 4294967296; return r2; } function s1_512_lo(xh, xl) { var c0_lo = rotr64_lo(xh, xl, 14); var c1_lo = rotr64_lo(xh, xl, 18); var c2_lo = rotr64_lo(xl, xh, 9); var r2 = c0_lo ^ c1_lo ^ c2_lo; if (r2 < 0) r2 += 4294967296; return r2; } function g0_512_hi(xh, xl) { var c0_hi = rotr64_hi(xh, xl, 1); var c1_hi = rotr64_hi(xh, xl, 8); var c2_hi = shr64_hi(xh, xl, 7); var r2 = c0_hi ^ c1_hi ^ c2_hi; if (r2 < 0) r2 += 4294967296; return r2; } function g0_512_lo(xh, xl) { var c0_lo = rotr64_lo(xh, xl, 1); var c1_lo = rotr64_lo(xh, xl, 8); var c2_lo = shr64_lo(xh, xl, 7); var r2 = c0_lo ^ c1_lo ^ c2_lo; if (r2 < 0) r2 += 4294967296; return r2; } function g1_512_hi(xh, xl) { var c0_hi = rotr64_hi(xh, xl, 19); var c1_hi = rotr64_hi(xl, xh, 29); var c2_hi = shr64_hi(xh, xl, 6); var r2 = c0_hi ^ c1_hi ^ c2_hi; if (r2 < 0) r2 += 4294967296; return r2; } function g1_512_lo(xh, xl) { var c0_lo = rotr64_lo(xh, xl, 19); var c1_lo = rotr64_lo(xl, xh, 29); var c2_lo = shr64_lo(xh, xl, 6); var r2 = c0_lo ^ c1_lo ^ c2_lo; if (r2 < 0) r2 += 4294967296; return r2; } var utils$3 = utils$a; var SHA512 = _512; function SHA384() { if (!(this instanceof SHA384)) return new SHA384(); SHA512.call(this); this.h = [ 3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428 ]; } utils$3.inherits(SHA384, SHA512); var _384 = SHA384; SHA384.blockSize = 1024; SHA384.outSize = 384; SHA384.hmacStrength = 192; SHA384.padLength = 128; SHA384.prototype._digest = function digest6(enc) { if (enc === "hex") return utils$3.toHex32(this.h.slice(0, 12), "big"); else return utils$3.split32(this.h.slice(0, 12), "big"); }; sha.sha1 = _1; sha.sha224 = _224; sha.sha256 = _256; sha.sha384 = _384; sha.sha512 = _512; var ripemd = {}; var utils$2 = utils$a; var common = common$5; var rotl32 = utils$2.rotl32; var sum32 = utils$2.sum32; var sum32_3 = utils$2.sum32_3; var sum32_4 = utils$2.sum32_4; var BlockHash = common.BlockHash; function RIPEMD160() { if (!(this instanceof RIPEMD160)) return new RIPEMD160(); BlockHash.call(this); this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520]; this.endian = "little"; } utils$2.inherits(RIPEMD160, BlockHash); ripemd.ripemd160 = RIPEMD160; RIPEMD160.blockSize = 512; RIPEMD160.outSize = 160; RIPEMD160.hmacStrength = 192; RIPEMD160.padLength = 64; RIPEMD160.prototype._update = function update2(msg, start) { var A2 = this.h[0]; var B = this.h[1]; var C2 = this.h[2]; var D = this.h[3]; var E2 = this.h[4]; var Ah = A2; var Bh = B; var Ch = C2; var Dh = D; var Eh = E2; for (var j2 = 0; j2 < 80; j2++) { var T = sum32( rotl32( sum32_4(A2, f$2(j2, B, C2, D), msg[r$1[j2] + start], K(j2)), s$2[j2] ), E2 ); A2 = E2; E2 = D; D = rotl32(C2, 10); C2 = B; B = T; T = sum32( rotl32( sum32_4(Ah, f$2(79 - j2, Bh, Ch, Dh), msg[rh[j2] + start], Kh(j2)), sh[j2] ), Eh ); Ah = Eh; Eh = Dh; Dh = rotl32(Ch, 10); Ch = Bh; Bh = T; } T = sum32_3(this.h[1], C2, Dh); this.h[1] = sum32_3(this.h[2], D, Eh); this.h[2] = sum32_3(this.h[3], E2, Ah); this.h[3] = sum32_3(this.h[4], A2, Bh); this.h[4] = sum32_3(this.h[0], B, Ch); this.h[0] = T; }; RIPEMD160.prototype._digest = function digest7(enc) { if (enc === "hex") return utils$2.toHex32(this.h, "little"); else return utils$2.split32(this.h, "little"); }; function f$2(j2, x, y2, z) { if (j2 <= 15) return x ^ y2 ^ z; else if (j2 <= 31) return x & y2 | ~x & z; else if (j2 <= 47) return (x | ~y2) ^ z; else if (j2 <= 63) return x & z | y2 & ~z; else return x ^ (y2 | ~z); } function K(j2) { if (j2 <= 15) return 0; else if (j2 <= 31) return 1518500249; else if (j2 <= 47) return 1859775393; else if (j2 <= 63) return 2400959708; else return 2840853838; } function Kh(j2) { if (j2 <= 15) return 1352829926; else if (j2 <= 31) return 1548603684; else if (j2 <= 47) return 1836072691; else if (j2 <= 63) return 2053994217; else return 0; } var r$1 = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 ]; var rh = [ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 ]; var s$2 = [ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]; var sh = [ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; var utils$1 = utils$a; var assert$6 = minimalisticAssert$1; function Hmac(hash2, key2, enc) { if (!(this instanceof Hmac)) return new Hmac(hash2, key2, enc); this.Hash = hash2; this.blockSize = hash2.blockSize / 8; this.outSize = hash2.outSize / 8; this.inner = null; this.outer = null; this._init(utils$1.toArray(key2, enc)); } var hmac = Hmac; Hmac.prototype._init = function init2(key2) { if (key2.length > this.blockSize) key2 = new this.Hash().update(key2).digest(); assert$6(key2.length <= this.blockSize); for (var i2 = key2.length; i2 < this.blockSize; i2++) key2.push(0); for (i2 = 0; i2 < key2.length; i2++) key2[i2] ^= 54; this.inner = new this.Hash().update(key2); for (i2 = 0; i2 < key2.length; i2++) key2[i2] ^= 106; this.outer = new this.Hash().update(key2); }; Hmac.prototype.update = function update3(msg, enc) { this.inner.update(msg, enc); return this; }; Hmac.prototype.digest = function digest8(enc) { this.outer.update(this.inner.digest()); return this.outer.digest(enc); }; (function(exports) { var hash2 = exports; hash2.utils = utils$a; hash2.common = common$5; hash2.sha = sha; hash2.ripemd = ripemd; hash2.hmac = hmac; hash2.sha1 = hash2.sha.sha1; hash2.sha256 = hash2.sha.sha256; hash2.sha224 = hash2.sha.sha224; hash2.sha384 = hash2.sha.sha384; hash2.sha512 = hash2.sha.sha512; hash2.ripemd160 = hash2.ripemd.ripemd160; })(hash); function createCommonjsModule(fn, basedir, module) { return module = { path: basedir, exports: {}, require: function(path, base2) { return commonjsRequire(path, base2 === void 0 || base2 === null ? module.path : base2); } }, fn(module, module.exports), module.exports; } function commonjsRequire() { throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); } var minimalisticAssert = assert; function assert(val, msg) { if (!val) throw new Error(msg || "Assertion failed"); } assert.equal = function assertEqual2(l2, r2, msg) { if (l2 != r2) throw new Error(msg || "Assertion failed: " + l2 + " != " + r2); }; var utils_1 = createCommonjsModule(function(module, exports) { var utils2 = exports; function toArray2(msg, enc) { if (Array.isArray(msg)) return msg.slice(); if (!msg) return []; var res = []; if (typeof msg !== "string") { for (var i2 = 0; i2 < msg.length; i2++) res[i2] = msg[i2] | 0; return res; } if (enc === "hex") { msg = msg.replace(/[^a-z0-9]+/ig, ""); if (msg.length % 2 !== 0) msg = "0" + msg; for (var i2 = 0; i2 < msg.length; i2 += 2) res.push(parseInt(msg[i2] + msg[i2 + 1], 16)); } else { for (var i2 = 0; i2 < msg.length; i2++) { var c2 = msg.charCodeAt(i2); var hi = c2 >> 8; var lo = c2 & 255; if (hi) res.push(hi, lo); else res.push(lo); } } return res; } utils2.toArray = toArray2; function zero22(word) { if (word.length === 1) return "0" + word; else return word; } utils2.zero2 = zero22; function toHex2(msg) { var res = ""; for (var i2 = 0; i2 < msg.length; i2++) res += zero22(msg[i2].toString(16)); return res; } utils2.toHex = toHex2; utils2.encode = function encode3(arr, enc) { if (enc === "hex") return toHex2(arr); else return arr; }; }); var utils_1$1 = createCommonjsModule(function(module, exports) { var utils2 = exports; utils2.assert = minimalisticAssert; utils2.toArray = utils_1.toArray; utils2.zero2 = utils_1.zero2; utils2.toHex = utils_1.toHex; utils2.encode = utils_1.encode; function getNAF2(num, w, bits) { var naf = new Array(Math.max(num.bitLength(), bits) + 1); naf.fill(0); var ws = 1 << w + 1; var k2 = num.clone(); for (var i2 = 0; i2 < naf.length; i2++) { var z; var mod = k2.andln(ws - 1); if (k2.isOdd()) { if (mod > (ws >> 1) - 1) z = (ws >> 1) - mod; else z = mod; k2.isubn(z); } else { z = 0; } naf[i2] = z; k2.iushrn(1); } return naf; } utils2.getNAF = getNAF2; function getJSF2(k1, k2) { var jsf = [ [], [] ]; k1 = k1.clone(); k2 = k2.clone(); var d1 = 0; var d2 = 0; var m8; while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { var m14 = k1.andln(3) + d1 & 3; var m24 = k2.andln(3) + d2 & 3; if (m14 === 3) m14 = -1; if (m24 === 3) m24 = -1; var u1; if ((m14 & 1) === 0) { u1 = 0; } else { m8 = k1.andln(7) + d1 & 7; if ((m8 === 3 || m8 === 5) && m24 === 2) u1 = -m14; else u1 = m14; } jsf[0].push(u1); var u2; if ((m24 & 1) === 0) { u2 = 0; } else { m8 = k2.andln(7) + d2 & 7; if ((m8 === 3 || m8 === 5) && m14 === 2) u2 = -m24; else u2 = m24; } jsf[1].push(u2); if (2 * d1 === u1 + 1) d1 = 1 - d1; if (2 * d2 === u2 + 1) d2 = 1 - d2; k1.iushrn(1); k2.iushrn(1); } return jsf; } utils2.getJSF = getJSF2; function cachedProperty(obj, name, computer) { var key2 = "_" + name; obj.prototype[name] = function cachedProperty2() { return this[key2] !== void 0 ? this[key2] : this[key2] = computer.call(this); }; } utils2.cachedProperty = cachedProperty; function parseBytes(bytes) { return typeof bytes === "string" ? utils2.toArray(bytes, "hex") : bytes; } utils2.parseBytes = parseBytes; function intFromLE(bytes) { return new BN$1(bytes, "hex", "le"); } utils2.intFromLE = intFromLE; }); var getNAF = utils_1$1.getNAF; var getJSF = utils_1$1.getJSF; var assert$1 = utils_1$1.assert; function BaseCurve(type, conf) { this.type = type; this.p = new BN$1(conf.p, 16); this.red = conf.prime ? BN$1.red(conf.prime) : BN$1.mont(this.p); this.zero = new BN$1(0).toRed(this.red); this.one = new BN$1(1).toRed(this.red); this.two = new BN$1(2).toRed(this.red); this.n = conf.n && new BN$1(conf.n, 16); this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); this._wnafT1 = new Array(4); this._wnafT2 = new Array(4); this._wnafT3 = new Array(4); this._wnafT4 = new Array(4); this._bitLength = this.n ? this.n.bitLength() : 0; var adjustCount = this.n && this.p.div(this.n); if (!adjustCount || adjustCount.cmpn(100) > 0) { this.redN = null; } else { this._maxwellTrick = true; this.redN = this.n.toRed(this.red); } } var base = BaseCurve; BaseCurve.prototype.point = function point() { throw new Error("Not implemented"); }; BaseCurve.prototype.validate = function validate() { throw new Error("Not implemented"); }; BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p2, k2) { assert$1(p2.precomputed); var doubles = p2._getDoubles(); var naf = getNAF(k2, 1, this._bitLength); var I2 = (1 << doubles.step + 1) - (doubles.step % 2 === 0 ? 2 : 1); I2 /= 3; var repr = []; var j2; var nafW; for (j2 = 0; j2 < naf.length; j2 += doubles.step) { nafW = 0; for (var l2 = j2 + doubles.step - 1; l2 >= j2; l2--) nafW = (nafW << 1) + naf[l2]; repr.push(nafW); } var a2 = this.jpoint(null, null, null); var b2 = this.jpoint(null, null, null); for (var i2 = I2; i2 > 0; i2--) { for (j2 = 0; j2 < repr.length; j2++) { nafW = repr[j2]; if (nafW === i2) b2 = b2.mixedAdd(doubles.points[j2]); else if (nafW === -i2) b2 = b2.mixedAdd(doubles.points[j2].neg()); } a2 = a2.add(b2); } return a2.toP(); }; BaseCurve.prototype._wnafMul = function _wnafMul(p2, k2) { var w = 4; var nafPoints = p2._getNAFPoints(w); w = nafPoints.wnd; var wnd = nafPoints.points; var naf = getNAF(k2, w, this._bitLength); var acc = this.jpoint(null, null, null); for (var i2 = naf.length - 1; i2 >= 0; i2--) { for (var l2 = 0; i2 >= 0 && naf[i2] === 0; i2--) l2++; if (i2 >= 0) l2++; acc = acc.dblp(l2); if (i2 < 0) break; var z = naf[i2]; assert$1(z !== 0); if (p2.type === "affine") { if (z > 0) acc = acc.mixedAdd(wnd[z - 1 >> 1]); else acc = acc.mixedAdd(wnd[-z - 1 >> 1].neg()); } else { if (z > 0) acc = acc.add(wnd[z - 1 >> 1]); else acc = acc.add(wnd[-z - 1 >> 1].neg()); } } return p2.type === "affine" ? acc.toP() : acc; }; BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, points, coeffs, len, jacobianResult) { var wndWidth = this._wnafT1; var wnd = this._wnafT2; var naf = this._wnafT3; var max = 0; var i2; var j2; var p2; for (i2 = 0; i2 < len; i2++) { p2 = points[i2]; var nafPoints = p2._getNAFPoints(defW); wndWidth[i2] = nafPoints.wnd; wnd[i2] = nafPoints.points; } for (i2 = len - 1; i2 >= 1; i2 -= 2) { var a2 = i2 - 1; var b2 = i2; if (wndWidth[a2] !== 1 || wndWidth[b2] !== 1) { naf[a2] = getNAF(coeffs[a2], wndWidth[a2], this._bitLength); naf[b2] = getNAF(coeffs[b2], wndWidth[b2], this._bitLength); max = Math.max(naf[a2].length, max); max = Math.max(naf[b2].length, max); continue; } var comb = [ points[a2], /* 1 */ null, /* 3 */ null, /* 5 */ points[b2] /* 7 */ ]; if (points[a2].y.cmp(points[b2].y) === 0) { comb[1] = points[a2].add(points[b2]); comb[2] = points[a2].toJ().mixedAdd(points[b2].neg()); } else if (points[a2].y.cmp(points[b2].y.redNeg()) === 0) { comb[1] = points[a2].toJ().mixedAdd(points[b2]); comb[2] = points[a2].add(points[b2].neg()); } else { comb[1] = points[a2].toJ().mixedAdd(points[b2]); comb[2] = points[a2].toJ().mixedAdd(points[b2].neg()); } var index = [ -3, /* -1 -1 */ -1, /* -1 0 */ -5, /* -1 1 */ -7, /* 0 -1 */ 0, /* 0 0 */ 7, /* 0 1 */ 5, /* 1 -1 */ 1, /* 1 0 */ 3 /* 1 1 */ ]; var jsf = getJSF(coeffs[a2], coeffs[b2]); max = Math.max(jsf[0].length, max); naf[a2] = new Array(max); naf[b2] = new Array(max); for (j2 = 0; j2 < max; j2++) { var ja = jsf[0][j2] | 0; var jb = jsf[1][j2] | 0; naf[a2][j2] = index[(ja + 1) * 3 + (jb + 1)]; naf[b2][j2] = 0; wnd[a2] = comb; } } var acc = this.jpoint(null, null, null); var tmp = this._wnafT4; for (i2 = max; i2 >= 0; i2--) { var k2 = 0; while (i2 >= 0) { var zero = true; for (j2 = 0; j2 < len; j2++) { tmp[j2] = naf[j2][i2] | 0; if (tmp[j2] !== 0) zero = false; } if (!zero) break; k2++; i2--; } if (i2 >= 0) k2++; acc = acc.dblp(k2); if (i2 < 0) break; for (j2 = 0; j2 < len; j2++) { var z = tmp[j2]; if (z === 0) continue; else if (z > 0) p2 = wnd[j2][z - 1 >> 1]; else if (z < 0) p2 = wnd[j2][-z - 1 >> 1].neg(); if (p2.type === "affine") acc = acc.mixedAdd(p2); else acc = acc.add(p2); } } for (i2 = 0; i2 < len; i2++) wnd[i2] = null; if (jacobianResult) return acc; else return acc.toP(); }; function BasePoint(curve, type) { this.curve = curve; this.type = type; this.precomputed = null; } BaseCurve.BasePoint = BasePoint; BasePoint.prototype.eq = function eq() { throw new Error("Not implemented"); }; BasePoint.prototype.validate = function validate2() { return this.curve.validate(this); }; BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { bytes = utils_1$1.toArray(bytes, enc); var len = this.p.byteLength(); if ((bytes[0] === 4 || bytes[0] === 6 || bytes[0] === 7) && bytes.length - 1 === 2 * len) { if (bytes[0] === 6) assert$1(bytes[bytes.length - 1] % 2 === 0); else if (bytes[0] === 7) assert$1(bytes[bytes.length - 1] % 2 === 1); var res = this.point( bytes.slice(1, 1 + len), bytes.slice(1 + len, 1 + 2 * len) ); return res; } else if ((bytes[0] === 2 || bytes[0] === 3) && bytes.length - 1 === len) { return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 3); } throw new Error("Unknown point format"); }; BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { return this.encode(enc, true); }; BasePoint.prototype._encode = function _encode2(compact) { var len = this.curve.p.byteLength(); var x = this.getX().toArray("be", len); if (compact) return [this.getY().isEven() ? 2 : 3].concat(x); return [4].concat(x, this.getY().toArray("be", len)); }; BasePoint.prototype.encode = function encode(enc, compact) { return utils_1$1.encode(this._encode(compact), enc); }; BasePoint.prototype.precompute = function precompute(power) { if (this.precomputed) return this; var precomputed = { doubles: null, naf: null, beta: null }; precomputed.naf = this._getNAFPoints(8); precomputed.doubles = this._getDoubles(4, power); precomputed.beta = this._getBeta(); this.precomputed = precomputed; return this; }; BasePoint.prototype._hasDoubles = function _hasDoubles(k2) { if (!this.precomputed) return false; var doubles = this.precomputed.doubles; if (!doubles) return false; return doubles.points.length >= Math.ceil((k2.bitLength() + 1) / doubles.step); }; BasePoint.prototype._getDoubles = function _getDoubles(step, power) { if (this.precomputed && this.precomputed.doubles) return this.precomputed.doubles; var doubles = [this]; var acc = this; for (var i2 = 0; i2 < power; i2 += step) { for (var j2 = 0; j2 < step; j2++) acc = acc.dbl(); doubles.push(acc); } return { step, points: doubles }; }; BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { if (this.precomputed && this.precomputed.naf) return this.precomputed.naf; var res = [this]; var max = (1 << wnd) - 1; var dbl3 = max === 1 ? null : this.dbl(); for (var i2 = 1; i2 < max; i2++) res[i2] = res[i2 - 1].add(dbl3); return { wnd, points: res }; }; BasePoint.prototype._getBeta = function _getBeta() { return null; }; BasePoint.prototype.dblp = function dblp(k2) { var r2 = this; for (var i2 = 0; i2 < k2; i2++) r2 = r2.dbl(); return r2; }; var inherits_browser = createCommonjsModule(function(module) { if (typeof Object.create === "function") { module.exports = function inherits2(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } }); } }; } else { module.exports = function inherits2(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; var TempCtor = function() { }; TempCtor.prototype = superCtor.prototype; ctor.prototype = new TempCtor(); ctor.prototype.constructor = ctor; } }; } }); var assert$2 = utils_1$1.assert; function ShortCurve(conf) { base.call(this, "short", conf); this.a = new BN$1(conf.a, 16).toRed(this.red); this.b = new BN$1(conf.b, 16).toRed(this.red); this.tinv = this.two.redInvm(); this.zeroA = this.a.fromRed().cmpn(0) === 0; this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; this.endo = this._getEndomorphism(conf); this._endoWnafT1 = new Array(4); this._endoWnafT2 = new Array(4); } inherits_browser(ShortCurve, base); var short_1 = ShortCurve; ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) return; var beta; var lambda; if (conf.beta) { beta = new BN$1(conf.beta, 16).toRed(this.red); } else { var betas = this._getEndoRoots(this.p); beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; beta = beta.toRed(this.red); } if (conf.lambda) { lambda = new BN$1(conf.lambda, 16); } else { var lambdas = this._getEndoRoots(this.n); if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { lambda = lambdas[0]; } else { lambda = lambdas[1]; assert$2(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); } } var basis; if (conf.basis) { basis = conf.basis.map(function(vec) { return { a: new BN$1(vec.a, 16), b: new BN$1(vec.b, 16) }; }); } else { basis = this._getEndoBasis(lambda); } return { beta, lambda, basis }; }; ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { var red = num === this.p ? this.red : BN$1.mont(num); var tinv = new BN$1(2).toRed(red).redInvm(); var ntinv = tinv.redNeg(); var s2 = new BN$1(3).toRed(red).redNeg().redSqrt().redMul(tinv); var l1 = ntinv.redAdd(s2).fromRed(); var l2 = ntinv.redSub(s2).fromRed(); return [l1, l2]; }; ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); var u = lambda; var v2 = this.n.clone(); var x1 = new BN$1(1); var y1 = new BN$1(0); var x2 = new BN$1(0); var y2 = new BN$1(1); var a0; var b0; var a1; var b1; var a2; var b2; var prevR; var i2 = 0; var r2; var x; while (u.cmpn(0) !== 0) { var q = v2.div(u); r2 = v2.sub(q.mul(u)); x = x2.sub(q.mul(x1)); var y3 = y2.sub(q.mul(y1)); if (!a1 && r2.cmp(aprxSqrt) < 0) { a0 = prevR.neg(); b0 = x1; a1 = r2.neg(); b1 = x; } else if (a1 && ++i2 === 2) { break; } prevR = r2; v2 = u; u = r2; x2 = x1; x1 = x; y2 = y1; y1 = y3; } a2 = r2.neg(); b2 = x; var len1 = a1.sqr().add(b1.sqr()); var len2 = a2.sqr().add(b2.sqr()); if (len2.cmp(len1) >= 0) { a2 = a0; b2 = b0; } if (a1.negative) { a1 = a1.neg(); b1 = b1.neg(); } if (a2.negative) { a2 = a2.neg(); b2 = b2.neg(); } return [ { a: a1, b: b1 }, { a: a2, b: b2 } ]; }; ShortCurve.prototype._endoSplit = function _endoSplit(k2) { var basis = this.endo.basis; var v1 = basis[0]; var v2 = basis[1]; var c1 = v2.b.mul(k2).divRound(this.n); var c2 = v1.b.neg().mul(k2).divRound(this.n); var p1 = c1.mul(v1.a); var p2 = c2.mul(v2.a); var q1 = c1.mul(v1.b); var q2 = c2.mul(v2.b); var k1 = k2.sub(p1).sub(p2); var k22 = q1.add(q2).neg(); return { k1, k2: k22 }; }; ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { x = new BN$1(x, 16); if (!x.red) x = x.toRed(this.red); var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); var y3 = y2.redSqrt(); if (y3.redSqr().redSub(y2).cmp(this.zero) !== 0) throw new Error("invalid point"); var isOdd = y3.fromRed().isOdd(); if (odd && !isOdd || !odd && isOdd) y3 = y3.redNeg(); return this.point(x, y3); }; ShortCurve.prototype.validate = function validate3(point3) { if (point3.inf) return true; var x = point3.x; var y2 = point3.y; var ax = this.a.redMul(x); var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); return y2.redSqr().redISub(rhs).cmpn(0) === 0; }; ShortCurve.prototype._endoWnafMulAdd = function _endoWnafMulAdd(points, coeffs, jacobianResult) { var npoints = this._endoWnafT1; var ncoeffs = this._endoWnafT2; for (var i2 = 0; i2 < points.length; i2++) { var split = this._endoSplit(coeffs[i2]); var p2 = points[i2]; var beta = p2._getBeta(); if (split.k1.negative) { split.k1.ineg(); p2 = p2.neg(true); } if (split.k2.negative) { split.k2.ineg(); beta = beta.neg(true); } npoints[i2 * 2] = p2; npoints[i2 * 2 + 1] = beta; ncoeffs[i2 * 2] = split.k1; ncoeffs[i2 * 2 + 1] = split.k2; } var res = this._wnafMulAdd(1, npoints, ncoeffs, i2 * 2, jacobianResult); for (var j2 = 0; j2 < i2 * 2; j2++) { npoints[j2] = null; ncoeffs[j2] = null; } return res; }; function Point(curve, x, y2, isRed) { base.BasePoint.call(this, curve, "affine"); if (x === null && y2 === null) { this.x = null; this.y = null; this.inf = true; } else { this.x = new BN$1(x, 16); this.y = new BN$1(y2, 16); if (isRed) { this.x.forceRed(this.curve.red); this.y.forceRed(this.curve.red); } if (!this.x.red) this.x = this.x.toRed(this.curve.red); if (!this.y.red) this.y = this.y.toRed(this.curve.red); this.inf = false; } } inherits_browser(Point, base.BasePoint); ShortCurve.prototype.point = function point2(x, y2, isRed) { return new Point(this, x, y2, isRed); }; ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { return Point.fromJSON(this, obj, red); }; Point.prototype._getBeta = function _getBeta2() { if (!this.curve.endo) return; var pre = this.precomputed; if (pre && pre.beta) return pre.beta; var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); if (pre) { var curve = this.curve; var endoMul = function(p2) { return curve.point(p2.x.redMul(curve.endo.beta), p2.y); }; pre.beta = beta; beta.precomputed = { beta: null, naf: pre.naf && { wnd: pre.naf.wnd, points: pre.naf.points.map(endoMul) }, doubles: pre.doubles && { step: pre.doubles.step, points: pre.doubles.points.map(endoMul) } }; } return beta; }; Point.prototype.toJSON = function toJSON() { if (!this.precomputed) return [this.x, this.y]; return [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }]; }; Point.fromJSON = function fromJSON(curve, obj, red) { if (typeof obj === "string") obj = JSON.parse(obj); var res = curve.point(obj[0], obj[1], red); if (!obj[2]) return res; function obj2point(obj2) { return curve.point(obj2[0], obj2[1], red); } var pre = obj[2]; res.precomputed = { beta: null, doubles: pre.doubles && { step: pre.doubles.step, points: [res].concat(pre.doubles.points.map(obj2point)) }, naf: pre.naf && { wnd: pre.naf.wnd, points: [res].concat(pre.naf.points.map(obj2point)) } }; return res; }; Point.prototype.inspect = function inspect() { if (this.isInfinity()) return ""; return ""; }; Point.prototype.isInfinity = function isInfinity() { return this.inf; }; Point.prototype.add = function add(p2) { if (this.inf) return p2; if (p2.inf) return this; if (this.eq(p2)) return this.dbl(); if (this.neg().eq(p2)) return this.curve.point(null, null); if (this.x.cmp(p2.x) === 0) return this.curve.point(null, null); var c2 = this.y.redSub(p2.y); if (c2.cmpn(0) !== 0) c2 = c2.redMul(this.x.redSub(p2.x).redInvm()); var nx = c2.redSqr().redISub(this.x).redISub(p2.x); var ny = c2.redMul(this.x.redSub(nx)).redISub(this.y); return this.curve.point(nx, ny); }; Point.prototype.dbl = function dbl() { if (this.inf) return this; var ys1 = this.y.redAdd(this.y); if (ys1.cmpn(0) === 0) return this.curve.point(null, null); var a2 = this.curve.a; var x2 = this.x.redSqr(); var dyinv = ys1.redInvm(); var c2 = x2.redAdd(x2).redIAdd(x2).redIAdd(a2).redMul(dyinv); var nx = c2.redSqr().redISub(this.x.redAdd(this.x)); var ny = c2.redMul(this.x.redSub(nx)).redISub(this.y); return this.curve.point(nx, ny); }; Point.prototype.getX = function getX() { return this.x.fromRed(); }; Point.prototype.getY = function getY() { return this.y.fromRed(); }; Point.prototype.mul = function mul(k2) { k2 = new BN$1(k2, 16); if (this.isInfinity()) return this; else if (this._hasDoubles(k2)) return this.curve._fixedNafMul(this, k2); else if (this.curve.endo) return this.curve._endoWnafMulAdd([this], [k2]); else return this.curve._wnafMul(this, k2); }; Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { var points = [this, p2]; var coeffs = [k1, k2]; if (this.curve.endo) return this.curve._endoWnafMulAdd(points, coeffs); else return this.curve._wnafMulAdd(1, points, coeffs, 2); }; Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { var points = [this, p2]; var coeffs = [k1, k2]; if (this.curve.endo) return this.curve._endoWnafMulAdd(points, coeffs, true); else return this.curve._wnafMulAdd(1, points, coeffs, 2, true); }; Point.prototype.eq = function eq2(p2) { return this === p2 || this.inf === p2.inf && (this.inf || this.x.cmp(p2.x) === 0 && this.y.cmp(p2.y) === 0); }; Point.prototype.neg = function neg(_precompute) { if (this.inf) return this; var res = this.curve.point(this.x, this.y.redNeg()); if (_precompute && this.precomputed) { var pre = this.precomputed; var negate = function(p2) { return p2.neg(); }; res.precomputed = { naf: pre.naf && { wnd: pre.naf.wnd, points: pre.naf.points.map(negate) }, doubles: pre.doubles && { step: pre.doubles.step, points: pre.doubles.points.map(negate) } }; } return res; }; Point.prototype.toJ = function toJ() { if (this.inf) return this.curve.jpoint(null, null, null); var res = this.curve.jpoint(this.x, this.y, this.curve.one); return res; }; function JPoint(curve, x, y2, z) { base.BasePoint.call(this, curve, "jacobian"); if (x === null && y2 === null && z === null) { this.x = this.curve.one; this.y = this.curve.one; this.z = new BN$1(0); } else { this.x = new BN$1(x, 16); this.y = new BN$1(y2, 16); this.z = new BN$1(z, 16); } if (!this.x.red) this.x = this.x.toRed(this.curve.red); if (!this.y.red) this.y = this.y.toRed(this.curve.red); if (!this.z.red) this.z = this.z.toRed(this.curve.red); this.zOne = this.z === this.curve.one; } inherits_browser(JPoint, base.BasePoint); ShortCurve.prototype.jpoint = function jpoint(x, y2, z) { return new JPoint(this, x, y2, z); }; JPoint.prototype.toP = function toP() { if (this.isInfinity()) return this.curve.point(null, null); var zinv = this.z.redInvm(); var zinv2 = zinv.redSqr(); var ax = this.x.redMul(zinv2); var ay = this.y.redMul(zinv2).redMul(zinv); return this.curve.point(ax, ay); }; JPoint.prototype.neg = function neg2() { return this.curve.jpoint(this.x, this.y.redNeg(), this.z); }; JPoint.prototype.add = function add2(p2) { if (this.isInfinity()) return p2; if (p2.isInfinity()) return this; var pz2 = p2.z.redSqr(); var z2 = this.z.redSqr(); var u1 = this.x.redMul(pz2); var u2 = p2.x.redMul(z2); var s1 = this.y.redMul(pz2.redMul(p2.z)); var s2 = p2.y.redMul(z2.redMul(this.z)); var h2 = u1.redSub(u2); var r2 = s1.redSub(s2); if (h2.cmpn(0) === 0) { if (r2.cmpn(0) !== 0) return this.curve.jpoint(null, null, null); else return this.dbl(); } var h22 = h2.redSqr(); var h3 = h22.redMul(h2); var v2 = u1.redMul(h22); var nx = r2.redSqr().redIAdd(h3).redISub(v2).redISub(v2); var ny = r2.redMul(v2.redISub(nx)).redISub(s1.redMul(h3)); var nz = this.z.redMul(p2.z).redMul(h2); return this.curve.jpoint(nx, ny, nz); }; JPoint.prototype.mixedAdd = function mixedAdd(p2) { if (this.isInfinity()) return p2.toJ(); if (p2.isInfinity()) return this; var z2 = this.z.redSqr(); var u1 = this.x; var u2 = p2.x.redMul(z2); var s1 = this.y; var s2 = p2.y.redMul(z2).redMul(this.z); var h2 = u1.redSub(u2); var r2 = s1.redSub(s2); if (h2.cmpn(0) === 0) { if (r2.cmpn(0) !== 0) return this.curve.jpoint(null, null, null); else return this.dbl(); } var h22 = h2.redSqr(); var h3 = h22.redMul(h2); var v2 = u1.redMul(h22); var nx = r2.redSqr().redIAdd(h3).redISub(v2).redISub(v2); var ny = r2.redMul(v2.redISub(nx)).redISub(s1.redMul(h3)); var nz = this.z.redMul(h2); return this.curve.jpoint(nx, ny, nz); }; JPoint.prototype.dblp = function dblp2(pow) { if (pow === 0) return this; if (this.isInfinity()) return this; if (!pow) return this.dbl(); var i2; if (this.curve.zeroA || this.curve.threeA) { var r2 = this; for (i2 = 0; i2 < pow; i2++) r2 = r2.dbl(); return r2; } var a2 = this.curve.a; var tinv = this.curve.tinv; var jx = this.x; var jy = this.y; var jz = this.z; var jz4 = jz.redSqr().redSqr(); var jyd = jy.redAdd(jy); for (i2 = 0; i2 < pow; i2++) { var jx2 = jx.redSqr(); var jyd2 = jyd.redSqr(); var jyd4 = jyd2.redSqr(); var c2 = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a2.redMul(jz4)); var t1 = jx.redMul(jyd2); var nx = c2.redSqr().redISub(t1.redAdd(t1)); var t2 = t1.redISub(nx); var dny = c2.redMul(t2); dny = dny.redIAdd(dny).redISub(jyd4); var nz = jyd.redMul(jz); if (i2 + 1 < pow) jz4 = jz4.redMul(jyd4); jx = nx; jz = nz; jyd = dny; } return this.curve.jpoint(jx, jyd.redMul(tinv), jz); }; JPoint.prototype.dbl = function dbl2() { if (this.isInfinity()) return this; if (this.curve.zeroA) return this._zeroDbl(); else if (this.curve.threeA) return this._threeDbl(); else return this._dbl(); }; JPoint.prototype._zeroDbl = function _zeroDbl() { var nx; var ny; var nz; if (this.zOne) { var xx = this.x.redSqr(); var yy = this.y.redSqr(); var yyyy = yy.redSqr(); var s2 = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); s2 = s2.redIAdd(s2); var m2 = xx.redAdd(xx).redIAdd(xx); var t2 = m2.redSqr().redISub(s2).redISub(s2); var yyyy8 = yyyy.redIAdd(yyyy); yyyy8 = yyyy8.redIAdd(yyyy8); yyyy8 = yyyy8.redIAdd(yyyy8); nx = t2; ny = m2.redMul(s2.redISub(t2)).redISub(yyyy8); nz = this.y.redAdd(this.y); } else { var a2 = this.x.redSqr(); var b2 = this.y.redSqr(); var c2 = b2.redSqr(); var d2 = this.x.redAdd(b2).redSqr().redISub(a2).redISub(c2); d2 = d2.redIAdd(d2); var e = a2.redAdd(a2).redIAdd(a2); var f2 = e.redSqr(); var c8 = c2.redIAdd(c2); c8 = c8.redIAdd(c8); c8 = c8.redIAdd(c8); nx = f2.redISub(d2).redISub(d2); ny = e.redMul(d2.redISub(nx)).redISub(c8); nz = this.y.redMul(this.z); nz = nz.redIAdd(nz); } return this.curve.jpoint(nx, ny, nz); }; JPoint.prototype._threeDbl = function _threeDbl() { var nx; var ny; var nz; if (this.zOne) { var xx = this.x.redSqr(); var yy = this.y.redSqr(); var yyyy = yy.redSqr(); var s2 = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); s2 = s2.redIAdd(s2); var m2 = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); var t2 = m2.redSqr().redISub(s2).redISub(s2); nx = t2; var yyyy8 = yyyy.redIAdd(yyyy); yyyy8 = yyyy8.redIAdd(yyyy8); yyyy8 = yyyy8.redIAdd(yyyy8); ny = m2.redMul(s2.redISub(t2)).redISub(yyyy8); nz = this.y.redAdd(this.y); } else { var delta = this.z.redSqr(); var gamma = this.y.redSqr(); var beta = this.x.redMul(gamma); var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); alpha = alpha.redAdd(alpha).redIAdd(alpha); var beta4 = beta.redIAdd(beta); beta4 = beta4.redIAdd(beta4); var beta8 = beta4.redAdd(beta4); nx = alpha.redSqr().redISub(beta8); nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); var ggamma8 = gamma.redSqr(); ggamma8 = ggamma8.redIAdd(ggamma8); ggamma8 = ggamma8.redIAdd(ggamma8); ggamma8 = ggamma8.redIAdd(ggamma8); ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); } return this.curve.jpoint(nx, ny, nz); }; JPoint.prototype._dbl = function _dbl() { var a2 = this.curve.a; var jx = this.x; var jy = this.y; var jz = this.z; var jz4 = jz.redSqr().redSqr(); var jx2 = jx.redSqr(); var jy2 = jy.redSqr(); var c2 = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a2.redMul(jz4)); var jxd4 = jx.redAdd(jx); jxd4 = jxd4.redIAdd(jxd4); var t1 = jxd4.redMul(jy2); var nx = c2.redSqr().redISub(t1.redAdd(t1)); var t2 = t1.redISub(nx); var jyd8 = jy2.redSqr(); jyd8 = jyd8.redIAdd(jyd8); jyd8 = jyd8.redIAdd(jyd8); jyd8 = jyd8.redIAdd(jyd8); var ny = c2.redMul(t2).redISub(jyd8); var nz = jy.redAdd(jy).redMul(jz); return this.curve.jpoint(nx, ny, nz); }; JPoint.prototype.trpl = function trpl() { if (!this.curve.zeroA) return this.dbl().add(this); var xx = this.x.redSqr(); var yy = this.y.redSqr(); var zz = this.z.redSqr(); var yyyy = yy.redSqr(); var m2 = xx.redAdd(xx).redIAdd(xx); var mm = m2.redSqr(); var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); e = e.redIAdd(e); e = e.redAdd(e).redIAdd(e); e = e.redISub(mm); var ee = e.redSqr(); var t2 = yyyy.redIAdd(yyyy); t2 = t2.redIAdd(t2); t2 = t2.redIAdd(t2); t2 = t2.redIAdd(t2); var u = m2.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t2); var yyu4 = yy.redMul(u); yyu4 = yyu4.redIAdd(yyu4); yyu4 = yyu4.redIAdd(yyu4); var nx = this.x.redMul(ee).redISub(yyu4); nx = nx.redIAdd(nx); nx = nx.redIAdd(nx); var ny = this.y.redMul(u.redMul(t2.redISub(u)).redISub(e.redMul(ee))); ny = ny.redIAdd(ny); ny = ny.redIAdd(ny); ny = ny.redIAdd(ny); var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); return this.curve.jpoint(nx, ny, nz); }; JPoint.prototype.mul = function mul2(k2, kbase) { k2 = new BN$1(k2, kbase); return this.curve._wnafMul(this, k2); }; JPoint.prototype.eq = function eq3(p2) { if (p2.type === "affine") return this.eq(p2.toJ()); if (this === p2) return true; var z2 = this.z.redSqr(); var pz2 = p2.z.redSqr(); if (this.x.redMul(pz2).redISub(p2.x.redMul(z2)).cmpn(0) !== 0) return false; var z3 = z2.redMul(this.z); var pz3 = pz2.redMul(p2.z); return this.y.redMul(pz3).redISub(p2.y.redMul(z3)).cmpn(0) === 0; }; JPoint.prototype.eqXToP = function eqXToP(x) { var zs = this.z.redSqr(); var rx = x.toRed(this.curve.red).redMul(zs); if (this.x.cmp(rx) === 0) return true; var xc = x.clone(); var t2 = this.curve.redN.redMul(zs); for (; ; ) { xc.iadd(this.curve.n); if (xc.cmp(this.curve.p) >= 0) return false; rx.redIAdd(t2); if (this.x.cmp(rx) === 0) return true; } }; JPoint.prototype.inspect = function inspect2() { if (this.isInfinity()) return ""; return ""; }; JPoint.prototype.isInfinity = function isInfinity2() { return this.z.cmpn(0) === 0; }; var curve_1 = createCommonjsModule(function(module, exports) { var curve = exports; curve.base = base; curve.short = short_1; curve.mont = /*RicMoo:ethers:require(./mont)*/ null; curve.edwards = /*RicMoo:ethers:require(./edwards)*/ null; }); var curves_1 = createCommonjsModule(function(module, exports) { var curves = exports; var assert2 = utils_1$1.assert; function PresetCurve(options) { if (options.type === "short") this.curve = new curve_1.short(options); else if (options.type === "edwards") this.curve = new curve_1.edwards(options); else this.curve = new curve_1.mont(options); this.g = this.curve.g; this.n = this.curve.n; this.hash = options.hash; assert2(this.g.validate(), "Invalid curve"); assert2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); } curves.PresetCurve = PresetCurve; function defineCurve(name, options) { Object.defineProperty(curves, name, { configurable: true, enumerable: true, get: function() { var curve = new PresetCurve(options); Object.defineProperty(curves, name, { configurable: true, enumerable: true, value: curve }); return curve; } }); } defineCurve("p192", { type: "short", prime: "p192", p: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff", a: "ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc", b: "64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1", n: "ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831", hash: hash.sha256, gRed: false, g: [ "188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811" ] }); defineCurve("p224", { type: "short", prime: "p224", p: "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001", a: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe", b: "b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4", n: "ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d", hash: hash.sha256, gRed: false, g: [ "b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34" ] }); defineCurve("p256", { type: "short", prime: null, p: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff", a: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc", b: "5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b", n: "ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551", hash: hash.sha256, gRed: false, g: [ "6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5" ] }); defineCurve("p384", { type: "short", prime: null, p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff", a: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc", b: "b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef", n: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973", hash: hash.sha384, gRed: false, g: [ "aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7", "3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f" ] }); defineCurve("p521", { type: "short", prime: null, p: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff", a: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc", b: "00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00", n: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409", hash: hash.sha512, gRed: false, g: [ "000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66", "00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650" ] }); defineCurve("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: hash.sha256, gRed: false, g: [ "9" ] }); defineCurve("ed25519", { type: "edwards", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "-1", c: "1", // -121665 * (121666^(-1)) (mod P) d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: hash.sha256, gRed: false, g: [ "216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", // 4/5 "6666666666666666666666666666666666666666666666666666666666666658" ] }); var pre; try { pre = /*RicMoo:ethers:require(./precomputed/secp256k1)*/ null.crash(); } catch (e) { pre = void 0; } defineCurve("secp256k1", { type: "short", prime: "k256", p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f", a: "0", b: "7", n: "ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141", h: "1", hash: hash.sha256, // Precomputed endomorphism beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [ { a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" } ], gRed: false, g: [ "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", pre ] }); }); function HmacDRBG(options) { if (!(this instanceof HmacDRBG)) return new HmacDRBG(options); this.hash = options.hash; this.predResist = !!options.predResist; this.outLen = this.hash.outSize; this.minEntropy = options.minEntropy || this.hash.hmacStrength; this._reseed = null; this.reseedInterval = null; this.K = null; this.V = null; var entropy = utils_1.toArray(options.entropy, options.entropyEnc || "hex"); var nonce = utils_1.toArray(options.nonce, options.nonceEnc || "hex"); var pers = utils_1.toArray(options.pers, options.persEnc || "hex"); minimalisticAssert( entropy.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits" ); this._init(entropy, nonce, pers); } var hmacDrbg = HmacDRBG; HmacDRBG.prototype._init = function init3(entropy, nonce, pers) { var seed = entropy.concat(nonce).concat(pers); this.K = new Array(this.outLen / 8); this.V = new Array(this.outLen / 8); for (var i2 = 0; i2 < this.V.length; i2++) { this.K[i2] = 0; this.V[i2] = 1; } this._update(seed); this._reseed = 1; this.reseedInterval = 281474976710656; }; HmacDRBG.prototype._hmac = function hmac2() { return new hash.hmac(this.hash, this.K); }; HmacDRBG.prototype._update = function update4(seed) { var kmac = this._hmac().update(this.V).update([0]); if (seed) kmac = kmac.update(seed); this.K = kmac.digest(); this.V = this._hmac().update(this.V).digest(); if (!seed) return; this.K = this._hmac().update(this.V).update([1]).update(seed).digest(); this.V = this._hmac().update(this.V).digest(); }; HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add3, addEnc) { if (typeof entropyEnc !== "string") { addEnc = add3; add3 = entropyEnc; entropyEnc = null; } entropy = utils_1.toArray(entropy, entropyEnc); add3 = utils_1.toArray(add3, addEnc); minimalisticAssert( entropy.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits" ); this._update(entropy.concat(add3 || [])); this._reseed = 1; }; HmacDRBG.prototype.generate = function generate(len, enc, add3, addEnc) { if (this._reseed > this.reseedInterval) throw new Error("Reseed is required"); if (typeof enc !== "string") { addEnc = add3; add3 = enc; enc = null; } if (add3) { add3 = utils_1.toArray(add3, addEnc || "hex"); this._update(add3); } var temp = []; while (temp.length < len) { this.V = this._hmac().update(this.V).digest(); temp = temp.concat(this.V); } var res = temp.slice(0, len); this._update(add3); this._reseed++; return utils_1.encode(res, enc); }; var assert$3 = utils_1$1.assert; function KeyPair(ec2, options) { this.ec = ec2; this.priv = null; this.pub = null; if (options.priv) this._importPrivate(options.priv, options.privEnc); if (options.pub) this._importPublic(options.pub, options.pubEnc); } var key = KeyPair; KeyPair.fromPublic = function fromPublic(ec2, pub, enc) { if (pub instanceof KeyPair) return pub; return new KeyPair(ec2, { pub, pubEnc: enc }); }; KeyPair.fromPrivate = function fromPrivate(ec2, priv, enc) { if (priv instanceof KeyPair) return priv; return new KeyPair(ec2, { priv, privEnc: enc }); }; KeyPair.prototype.validate = function validate4() { var pub = this.getPublic(); if (pub.isInfinity()) return { result: false, reason: "Invalid public key" }; if (!pub.validate()) return { result: false, reason: "Public key is not a point" }; if (!pub.mul(this.ec.curve.n).isInfinity()) return { result: false, reason: "Public key * N != O" }; return { result: true, reason: null }; }; KeyPair.prototype.getPublic = function getPublic(compact, enc) { if (typeof compact === "string") { enc = compact; compact = null; } if (!this.pub) this.pub = this.ec.g.mul(this.priv); if (!enc) return this.pub; return this.pub.encode(enc, compact); }; KeyPair.prototype.getPrivate = function getPrivate(enc) { if (enc === "hex") return this.priv.toString(16, 2); else return this.priv; }; KeyPair.prototype._importPrivate = function _importPrivate(key2, enc) { this.priv = new BN$1(key2, enc || 16); this.priv = this.priv.umod(this.ec.curve.n); }; KeyPair.prototype._importPublic = function _importPublic(key2, enc) { if (key2.x || key2.y) { if (this.ec.curve.type === "mont") { assert$3(key2.x, "Need x coordinate"); } else if (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") { assert$3(key2.x && key2.y, "Need both x and y coordinate"); } this.pub = this.ec.curve.point(key2.x, key2.y); return; } this.pub = this.ec.curve.decodePoint(key2, enc); }; KeyPair.prototype.derive = function derive(pub) { if (!pub.validate()) { assert$3(pub.validate(), "public point not validated"); } return pub.mul(this.priv).getX(); }; KeyPair.prototype.sign = function sign(msg, enc, options) { return this.ec.sign(msg, this, enc, options); }; KeyPair.prototype.verify = function verify(msg, signature2) { return this.ec.verify(msg, signature2, this); }; KeyPair.prototype.inspect = function inspect3() { return ""; }; var assert$4 = utils_1$1.assert; function Signature(options, enc) { if (options instanceof Signature) return options; if (this._importDER(options, enc)) return; assert$4(options.r && options.s, "Signature without r or s"); this.r = new BN$1(options.r, 16); this.s = new BN$1(options.s, 16); if (options.recoveryParam === void 0) this.recoveryParam = null; else this.recoveryParam = options.recoveryParam; } var signature = Signature; function Position() { this.place = 0; } function getLength(buf, p2) { var initial = buf[p2.place++]; if (!(initial & 128)) { return initial; } var octetLen = initial & 15; if (octetLen === 0 || octetLen > 4) { return false; } var val = 0; for (var i2 = 0, off = p2.place; i2 < octetLen; i2++, off++) { val <<= 8; val |= buf[off]; val >>>= 0; } if (val <= 127) { return false; } p2.place = off; return val; } function rmPadding(buf) { var i2 = 0; var len = buf.length - 1; while (!buf[i2] && !(buf[i2 + 1] & 128) && i2 < len) { i2++; } if (i2 === 0) { return buf; } return buf.slice(i2); } Signature.prototype._importDER = function _importDER(data, enc) { data = utils_1$1.toArray(data, enc); var p2 = new Position(); if (data[p2.place++] !== 48) { return false; } var len = getLength(data, p2); if (len === false) { return false; } if (len + p2.place !== data.length) { return false; } if (data[p2.place++] !== 2) { return false; } var rlen = getLength(data, p2); if (rlen === false) { return false; } var r2 = data.slice(p2.place, rlen + p2.place); p2.place += rlen; if (data[p2.place++] !== 2) { return false; } var slen = getLength(data, p2); if (slen === false) { return false; } if (data.length !== slen + p2.place) { return false; } var s2 = data.slice(p2.place, slen + p2.place); if (r2[0] === 0) { if (r2[1] & 128) { r2 = r2.slice(1); } else { return false; } } if (s2[0] === 0) { if (s2[1] & 128) { s2 = s2.slice(1); } else { return false; } } this.r = new BN$1(r2); this.s = new BN$1(s2); this.recoveryParam = null; return true; }; function constructLength(arr, len) { if (len < 128) { arr.push(len); return; } var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); arr.push(octets | 128); while (--octets) { arr.push(len >>> (octets << 3) & 255); } arr.push(len); } Signature.prototype.toDER = function toDER(enc) { var r2 = this.r.toArray(); var s2 = this.s.toArray(); if (r2[0] & 128) r2 = [0].concat(r2); if (s2[0] & 128) s2 = [0].concat(s2); r2 = rmPadding(r2); s2 = rmPadding(s2); while (!s2[0] && !(s2[1] & 128)) { s2 = s2.slice(1); } var arr = [2]; constructLength(arr, r2.length); arr = arr.concat(r2); arr.push(2); constructLength(arr, s2.length); var backHalf = arr.concat(s2); var res = [48]; constructLength(res, backHalf.length); res = res.concat(backHalf); return utils_1$1.encode(res, enc); }; var rand = ( /*RicMoo:ethers:require(brorand)*/ function() { throw new Error("unsupported"); } ); var assert$5 = utils_1$1.assert; function EC(options) { if (!(this instanceof EC)) return new EC(options); if (typeof options === "string") { assert$5( Object.prototype.hasOwnProperty.call(curves_1, options), "Unknown curve " + options ); options = curves_1[options]; } if (options instanceof curves_1.PresetCurve) options = { curve: options }; this.curve = options.curve.curve; this.n = this.curve.n; this.nh = this.n.ushrn(1); this.g = this.curve.g; this.g = options.curve.g; this.g.precompute(options.curve.n.bitLength() + 1); this.hash = options.hash || options.curve.hash; } var ec = EC; EC.prototype.keyPair = function keyPair(options) { return new key(this, options); }; EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { return key.fromPrivate(this, priv, enc); }; EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { return key.fromPublic(this, pub, enc); }; EC.prototype.genKeyPair = function genKeyPair(options) { if (!options) options = {}; var drbg = new hmacDrbg({ hash: this.hash, pers: options.pers, persEnc: options.persEnc || "utf8", entropy: options.entropy || rand(this.hash.hmacStrength), entropyEnc: options.entropy && options.entropyEnc || "utf8", nonce: this.n.toArray() }); var bytes = this.n.byteLength(); var ns2 = this.n.sub(new BN$1(2)); for (; ; ) { var priv = new BN$1(drbg.generate(bytes)); if (priv.cmp(ns2) > 0) continue; priv.iaddn(1); return this.keyFromPrivate(priv); } }; EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { var delta = msg.byteLength() * 8 - this.n.bitLength(); if (delta > 0) msg = msg.ushrn(delta); if (!truncOnly && msg.cmp(this.n) >= 0) return msg.sub(this.n); else return msg; }; EC.prototype.sign = function sign2(msg, key2, enc, options) { if (typeof enc === "object") { options = enc; enc = null; } if (!options) options = {}; key2 = this.keyFromPrivate(key2, enc); msg = this._truncateToN(new BN$1(msg, 16)); var bytes = this.n.byteLength(); var bkey = key2.getPrivate().toArray("be", bytes); var nonce = msg.toArray("be", bytes); var drbg = new hmacDrbg({ hash: this.hash, entropy: bkey, nonce, pers: options.pers, persEnc: options.persEnc || "utf8" }); var ns1 = this.n.sub(new BN$1(1)); for (var iter = 0; ; iter++) { var k2 = options.k ? options.k(iter) : new BN$1(drbg.generate(this.n.byteLength())); k2 = this._truncateToN(k2, true); if (k2.cmpn(1) <= 0 || k2.cmp(ns1) >= 0) continue; var kp = this.g.mul(k2); if (kp.isInfinity()) continue; var kpX = kp.getX(); var r2 = kpX.umod(this.n); if (r2.cmpn(0) === 0) continue; var s2 = k2.invm(this.n).mul(r2.mul(key2.getPrivate()).iadd(msg)); s2 = s2.umod(this.n); if (s2.cmpn(0) === 0) continue; var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | (kpX.cmp(r2) !== 0 ? 2 : 0); if (options.canonical && s2.cmp(this.nh) > 0) { s2 = this.n.sub(s2); recoveryParam ^= 1; } return new signature({ r: r2, s: s2, recoveryParam }); } }; EC.prototype.verify = function verify2(msg, signature$1, key2, enc) { msg = this._truncateToN(new BN$1(msg, 16)); key2 = this.keyFromPublic(key2, enc); signature$1 = new signature(signature$1, "hex"); var r2 = signature$1.r; var s2 = signature$1.s; if (r2.cmpn(1) < 0 || r2.cmp(this.n) >= 0) return false; if (s2.cmpn(1) < 0 || s2.cmp(this.n) >= 0) return false; var sinv = s2.invm(this.n); var u1 = sinv.mul(msg).umod(this.n); var u2 = sinv.mul(r2).umod(this.n); var p2; if (!this.curve._maxwellTrick) { p2 = this.g.mulAdd(u1, key2.getPublic(), u2); if (p2.isInfinity()) return false; return p2.getX().umod(this.n).cmp(r2) === 0; } p2 = this.g.jmulAdd(u1, key2.getPublic(), u2); if (p2.isInfinity()) return false; return p2.eqXToP(r2); }; EC.prototype.recoverPubKey = function(msg, signature$1, j2, enc) { assert$5((3 & j2) === j2, "The recovery param is more than two bits"); signature$1 = new signature(signature$1, enc); var n2 = this.n; var e = new BN$1(msg); var r2 = signature$1.r; var s2 = signature$1.s; var isYOdd = j2 & 1; var isSecondKey = j2 >> 1; if (r2.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) throw new Error("Unable to find sencond key candinate"); if (isSecondKey) r2 = this.curve.pointFromX(r2.add(this.curve.n), isYOdd); else r2 = this.curve.pointFromX(r2, isYOdd); var rInv = signature$1.r.invm(n2); var s1 = n2.sub(e).mul(rInv).umod(n2); var s22 = s2.mul(rInv).umod(n2); return this.g.mulAdd(s1, r2, s22); }; EC.prototype.getKeyRecoveryParam = function(e, signature$1, Q, enc) { signature$1 = new signature(signature$1, enc); if (signature$1.recoveryParam !== null) return signature$1.recoveryParam; for (var i2 = 0; i2 < 4; i2++) { var Qprime; try { Qprime = this.recoverPubKey(e, signature$1, i2); } catch (e2) { continue; } if (Qprime.eq(Q)) return i2; } throw new Error("Unable to find valid recovery factor"); }; var elliptic_1 = createCommonjsModule(function(module, exports) { var elliptic = exports; elliptic.version = /*RicMoo:ethers*/ { version: "6.5.4" }.version; elliptic.utils = utils_1$1; elliptic.rand = /*RicMoo:ethers:require(brorand)*/ function() { throw new Error("unsupported"); }; elliptic.curve = curve_1; elliptic.curves = curves_1; elliptic.ec = ec; elliptic.eddsa = /*RicMoo:ethers:require(./elliptic/eddsa)*/ null; }); var EC$1 = elliptic_1.ec; const version$e = "signing-key/5.7.0"; const logger$k = new Logger(version$e); let _curve = null; function getCurve() { if (!_curve) { _curve = new EC$1("secp256k1"); } return _curve; } class SigningKey { constructor(privateKey) { defineReadOnly(this, "curve", "secp256k1"); defineReadOnly(this, "privateKey", hexlify(privateKey)); if (hexDataLength(this.privateKey) !== 32) { logger$k.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); } const keyPair2 = getCurve().keyFromPrivate(arrayify(this.privateKey)); defineReadOnly(this, "publicKey", "0x" + keyPair2.getPublic(false, "hex")); defineReadOnly(this, "compressedPublicKey", "0x" + keyPair2.getPublic(true, "hex")); defineReadOnly(this, "_isSigningKey", true); } _addPoint(other) { const p0 = getCurve().keyFromPublic(arrayify(this.publicKey)); const p1 = getCurve().keyFromPublic(arrayify(other)); return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); } signDigest(digest9) { const keyPair2 = getCurve().keyFromPrivate(arrayify(this.privateKey)); const digestBytes = arrayify(digest9); if (digestBytes.length !== 32) { logger$k.throwArgumentError("bad digest length", "digest", digest9); } const signature2 = keyPair2.sign(digestBytes, { canonical: true }); return splitSignature({ recoveryParam: signature2.recoveryParam, r: hexZeroPad("0x" + signature2.r.toString(16), 32), s: hexZeroPad("0x" + signature2.s.toString(16), 32) }); } computeSharedSecret(otherKey) { const keyPair2 = getCurve().keyFromPrivate(arrayify(this.privateKey)); const otherKeyPair = getCurve().keyFromPublic(arrayify(computePublicKey(otherKey))); return hexZeroPad("0x" + keyPair2.derive(otherKeyPair.getPublic()).toString(16), 32); } static isSigningKey(value) { return !!(value && value._isSigningKey); } } function recoverPublicKey(digest9, signature2) { const sig = splitSignature(signature2); const rs = { r: arrayify(sig.r), s: arrayify(sig.s) }; return "0x" + getCurve().recoverPubKey(arrayify(digest9), rs, sig.recoveryParam).encode("hex", false); } function computePublicKey(key2, compressed) { const bytes = arrayify(key2); if (bytes.length === 32) { const signingKey = new SigningKey(bytes); if (compressed) { return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex"); } return signingKey.publicKey; } else if (bytes.length === 33) { if (compressed) { return hexlify(bytes); } return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex"); } else if (bytes.length === 65) { if (!compressed) { return hexlify(bytes); } return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex"); } return logger$k.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); } const lib_esm$a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, SigningKey, computePublicKey, recoverPublicKey }, Symbol.toStringTag, { value: "Module" })); const version$d = "transactions/5.7.0"; const logger$j = new Logger(version$d); var TransactionTypes; (function(TransactionTypes2) { TransactionTypes2[TransactionTypes2["legacy"] = 0] = "legacy"; TransactionTypes2[TransactionTypes2["eip2930"] = 1] = "eip2930"; TransactionTypes2[TransactionTypes2["eip1559"] = 2] = "eip1559"; })(TransactionTypes || (TransactionTypes = {})); function handleAddress(value) { if (value === "0x") { return null; } return getAddress(value); } function handleNumber(value) { if (value === "0x") { return Zero$1; } return BigNumber.from(value); } const transactionFields = [ { name: "nonce", maxLength: 32, numeric: true }, { name: "gasPrice", maxLength: 32, numeric: true }, { name: "gasLimit", maxLength: 32, numeric: true }, { name: "to", length: 20 }, { name: "value", maxLength: 32, numeric: true }, { name: "data" } ]; const allowedTransactionKeys$1 = { chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, type: true, value: true }; function computeAddress(key2) { const publicKey = computePublicKey(key2); return getAddress(hexDataSlice(keccak256$1(hexDataSlice(publicKey, 1)), 12)); } function recoverAddress(digest9, signature2) { return computeAddress(recoverPublicKey(arrayify(digest9), signature2)); } function formatNumber(value, name) { const result = stripZeros(BigNumber.from(value).toHexString()); if (result.length > 32) { logger$j.throwArgumentError("invalid length for " + name, "transaction:" + name, value); } return result; } function accessSetify(addr, storageKeys) { return { address: getAddress(addr), storageKeys: (storageKeys || []).map((storageKey, index) => { if (hexDataLength(storageKey) !== 32) { logger$j.throwArgumentError("invalid access list storageKey", `accessList[${addr}:${index}]`, storageKey); } return storageKey.toLowerCase(); }) }; } function accessListify(value) { if (Array.isArray(value)) { return value.map((set, index) => { if (Array.isArray(set)) { if (set.length > 2) { logger$j.throwArgumentError("access list expected to be [ address, storageKeys[] ]", `value[${index}]`, set); } return accessSetify(set[0], set[1]); } return accessSetify(set.address, set.storageKeys); }); } const result = Object.keys(value).map((addr) => { const storageKeys = value[addr].reduce((accum, storageKey) => { accum[storageKey] = true; return accum; }, {}); return accessSetify(addr, Object.keys(storageKeys).sort()); }); result.sort((a2, b2) => a2.address.localeCompare(b2.address)); return result; } function formatAccessList(value) { return accessListify(value).map((set) => [set.address, set.storageKeys]); } function _serializeEip1559(transaction, signature2) { if (transaction.gasPrice != null) { const gasPrice = BigNumber.from(transaction.gasPrice); const maxFeePerGas = BigNumber.from(transaction.maxFeePerGas || 0); if (!gasPrice.eq(maxFeePerGas)) { logger$j.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas", "tx", { gasPrice, maxFeePerGas }); } } const fields = [ formatNumber(transaction.chainId || 0, "chainId"), formatNumber(transaction.nonce || 0, "nonce"), formatNumber(transaction.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"), formatNumber(transaction.maxFeePerGas || 0, "maxFeePerGas"), formatNumber(transaction.gasLimit || 0, "gasLimit"), transaction.to != null ? getAddress(transaction.to) : "0x", formatNumber(transaction.value || 0, "value"), transaction.data || "0x", formatAccessList(transaction.accessList || []) ]; if (signature2) { const sig = splitSignature(signature2); fields.push(formatNumber(sig.recoveryParam, "recoveryParam")); fields.push(stripZeros(sig.r)); fields.push(stripZeros(sig.s)); } return hexConcat(["0x02", encode$2(fields)]); } function _serializeEip2930(transaction, signature2) { const fields = [ formatNumber(transaction.chainId || 0, "chainId"), formatNumber(transaction.nonce || 0, "nonce"), formatNumber(transaction.gasPrice || 0, "gasPrice"), formatNumber(transaction.gasLimit || 0, "gasLimit"), transaction.to != null ? getAddress(transaction.to) : "0x", formatNumber(transaction.value || 0, "value"), transaction.data || "0x", formatAccessList(transaction.accessList || []) ]; if (signature2) { const sig = splitSignature(signature2); fields.push(formatNumber(sig.recoveryParam, "recoveryParam")); fields.push(stripZeros(sig.r)); fields.push(stripZeros(sig.s)); } return hexConcat(["0x01", encode$2(fields)]); } function _serialize(transaction, signature2) { checkProperties(transaction, allowedTransactionKeys$1); const raw = []; transactionFields.forEach(function(fieldInfo) { let value = transaction[fieldInfo.name] || []; const options = {}; if (fieldInfo.numeric) { options.hexPad = "left"; } value = arrayify(hexlify(value, options)); if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { logger$j.throwArgumentError("invalid length for " + fieldInfo.name, "transaction:" + fieldInfo.name, value); } if (fieldInfo.maxLength) { value = stripZeros(value); if (value.length > fieldInfo.maxLength) { logger$j.throwArgumentError("invalid length for " + fieldInfo.name, "transaction:" + fieldInfo.name, value); } } raw.push(hexlify(value)); }); let chainId = 0; if (transaction.chainId != null) { chainId = transaction.chainId; if (typeof chainId !== "number") { logger$j.throwArgumentError("invalid transaction.chainId", "transaction", transaction); } } else if (signature2 && !isBytesLike(signature2) && signature2.v > 28) { chainId = Math.floor((signature2.v - 35) / 2); } if (chainId !== 0) { raw.push(hexlify(chainId)); raw.push("0x"); raw.push("0x"); } if (!signature2) { return encode$2(raw); } const sig = splitSignature(signature2); let v2 = 27 + sig.recoveryParam; if (chainId !== 0) { raw.pop(); raw.pop(); raw.pop(); v2 += chainId * 2 + 8; if (sig.v > 28 && sig.v !== v2) { logger$j.throwArgumentError("transaction.chainId/signature.v mismatch", "signature", signature2); } } else if (sig.v !== v2) { logger$j.throwArgumentError("transaction.chainId/signature.v mismatch", "signature", signature2); } raw.push(hexlify(v2)); raw.push(stripZeros(arrayify(sig.r))); raw.push(stripZeros(arrayify(sig.s))); return encode$2(raw); } function serialize$2(transaction, signature2) { if (transaction.type == null || transaction.type === 0) { if (transaction.accessList != null) { logger$j.throwArgumentError("untyped transactions do not support accessList; include type: 1", "transaction", transaction); } return _serialize(transaction, signature2); } switch (transaction.type) { case 1: return _serializeEip2930(transaction, signature2); case 2: return _serializeEip1559(transaction, signature2); } return logger$j.throwError(`unsupported transaction type: ${transaction.type}`, Logger.errors.UNSUPPORTED_OPERATION, { operation: "serializeTransaction", transactionType: transaction.type }); } function _parseEipSignature(tx, fields, serialize2) { try { const recid = handleNumber(fields[0]).toNumber(); if (recid !== 0 && recid !== 1) { throw new Error("bad recid"); } tx.v = recid; } catch (error) { logger$j.throwArgumentError("invalid v for transaction type: 1", "v", fields[0]); } tx.r = hexZeroPad(fields[1], 32); tx.s = hexZeroPad(fields[2], 32); try { const digest9 = keccak256$1(serialize2(tx)); tx.from = recoverAddress(digest9, { r: tx.r, s: tx.s, recoveryParam: tx.v }); } catch (error) { } } function _parseEip1559(payload) { const transaction = decode$2(payload.slice(1)); if (transaction.length !== 9 && transaction.length !== 12) { logger$j.throwArgumentError("invalid component count for transaction type: 2", "payload", hexlify(payload)); } const maxPriorityFeePerGas = handleNumber(transaction[2]); const maxFeePerGas = handleNumber(transaction[3]); const tx = { type: 2, chainId: handleNumber(transaction[0]).toNumber(), nonce: handleNumber(transaction[1]).toNumber(), maxPriorityFeePerGas, maxFeePerGas, gasPrice: null, gasLimit: handleNumber(transaction[4]), to: handleAddress(transaction[5]), value: handleNumber(transaction[6]), data: transaction[7], accessList: accessListify(transaction[8]) }; if (transaction.length === 9) { return tx; } tx.hash = keccak256$1(payload); _parseEipSignature(tx, transaction.slice(9), _serializeEip1559); return tx; } function _parseEip2930(payload) { const transaction = decode$2(payload.slice(1)); if (transaction.length !== 8 && transaction.length !== 11) { logger$j.throwArgumentError("invalid component count for transaction type: 1", "payload", hexlify(payload)); } const tx = { type: 1, chainId: handleNumber(transaction[0]).toNumber(), nonce: handleNumber(transaction[1]).toNumber(), gasPrice: handleNumber(transaction[2]), gasLimit: handleNumber(transaction[3]), to: handleAddress(transaction[4]), value: handleNumber(transaction[5]), data: transaction[6], accessList: accessListify(transaction[7]) }; if (transaction.length === 8) { return tx; } tx.hash = keccak256$1(payload); _parseEipSignature(tx, transaction.slice(8), _serializeEip2930); return tx; } function _parse(rawTransaction) { const transaction = decode$2(rawTransaction); if (transaction.length !== 9 && transaction.length !== 6) { logger$j.throwArgumentError("invalid raw transaction", "rawTransaction", rawTransaction); } const tx = { nonce: handleNumber(transaction[0]).toNumber(), gasPrice: handleNumber(transaction[1]), gasLimit: handleNumber(transaction[2]), to: handleAddress(transaction[3]), value: handleNumber(transaction[4]), data: transaction[5], chainId: 0 }; if (transaction.length === 6) { return tx; } try { tx.v = BigNumber.from(transaction[6]).toNumber(); } catch (error) { return tx; } tx.r = hexZeroPad(transaction[7], 32); tx.s = hexZeroPad(transaction[8], 32); if (BigNumber.from(tx.r).isZero() && BigNumber.from(tx.s).isZero()) { tx.chainId = tx.v; tx.v = 0; } else { tx.chainId = Math.floor((tx.v - 35) / 2); if (tx.chainId < 0) { tx.chainId = 0; } let recoveryParam = tx.v - 27; const raw = transaction.slice(0, 6); if (tx.chainId !== 0) { raw.push(hexlify(tx.chainId)); raw.push("0x"); raw.push("0x"); recoveryParam -= tx.chainId * 2 + 8; } const digest9 = keccak256$1(encode$2(raw)); try { tx.from = recoverAddress(digest9, { r: hexlify(tx.r), s: hexlify(tx.s), recoveryParam }); } catch (error) { } tx.hash = keccak256$1(rawTransaction); } tx.type = null; return tx; } function parse(rawTransaction) { const payload = arrayify(rawTransaction); if (payload[0] > 127) { return _parse(payload); } switch (payload[0]) { case 1: return _parseEip2930(payload); case 2: return _parseEip1559(payload); } return logger$j.throwError(`unsupported transaction type: ${payload[0]}`, Logger.errors.UNSUPPORTED_OPERATION, { operation: "parseTransaction", transactionType: payload[0] }); } const lib_esm$9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, get TransactionTypes() { return TransactionTypes; }, accessListify, computeAddress, parse, recoverAddress, serialize: serialize$2 }, Symbol.toStringTag, { value: "Module" })); const version$c = "contracts/5.7.0"; var __awaiter$9 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$i = new Logger(version$c); function resolveName(resolver, nameOrPromise) { return __awaiter$9(this, void 0, void 0, function* () { const name = yield nameOrPromise; if (typeof name !== "string") { logger$i.throwArgumentError("invalid address or ENS name", "name", name); } try { return getAddress(name); } catch (error) { } if (!resolver) { logger$i.throwError("a provider or signer is needed to resolve ENS names", Logger.errors.UNSUPPORTED_OPERATION, { operation: "resolveName" }); } const address = yield resolver.resolveName(name); if (address == null) { logger$i.throwArgumentError("resolver or addr is not configured for ENS name", "name", name); } return address; }); } function resolveAddresses(resolver, value, paramType) { return __awaiter$9(this, void 0, void 0, function* () { if (Array.isArray(paramType)) { return yield Promise.all(paramType.map((paramType2, index) => { return resolveAddresses(resolver, Array.isArray(value) ? value[index] : value[paramType2.name], paramType2); })); } if (paramType.type === "address") { return yield resolveName(resolver, value); } if (paramType.type === "tuple") { return yield resolveAddresses(resolver, value, paramType.components); } if (paramType.baseType === "array") { if (!Array.isArray(value)) { return Promise.reject(logger$i.makeError("invalid value for array", Logger.errors.INVALID_ARGUMENT, { argument: "value", value })); } return yield Promise.all(value.map((v2) => resolveAddresses(resolver, v2, paramType.arrayChildren))); } return value; }); } function populateTransaction(contract, fragment, args) { return __awaiter$9(this, void 0, void 0, function* () { let overrides = {}; if (args.length === fragment.inputs.length + 1 && typeof args[args.length - 1] === "object") { overrides = shallowCopy(args.pop()); } logger$i.checkArgumentCount(args.length, fragment.inputs.length, "passed to contract"); if (contract.signer) { if (overrides.from) { overrides.from = resolveProperties({ override: resolveName(contract.signer, overrides.from), signer: contract.signer.getAddress() }).then((check) => __awaiter$9(this, void 0, void 0, function* () { if (getAddress(check.signer) !== check.override) { logger$i.throwError("Contract with a Signer cannot override from", Logger.errors.UNSUPPORTED_OPERATION, { operation: "overrides.from" }); } return check.override; })); } else { overrides.from = contract.signer.getAddress(); } } else if (overrides.from) { overrides.from = resolveName(contract.provider, overrides.from); } const resolved = yield resolveProperties({ args: resolveAddresses(contract.signer || contract.provider, args, fragment.inputs), address: contract.resolvedAddress, overrides: resolveProperties(overrides) || {} }); const data = contract.interface.encodeFunctionData(fragment, resolved.args); const tx = { data, to: resolved.address }; const ro = resolved.overrides; if (ro.nonce != null) { tx.nonce = BigNumber.from(ro.nonce).toNumber(); } if (ro.gasLimit != null) { tx.gasLimit = BigNumber.from(ro.gasLimit); } if (ro.gasPrice != null) { tx.gasPrice = BigNumber.from(ro.gasPrice); } if (ro.maxFeePerGas != null) { tx.maxFeePerGas = BigNumber.from(ro.maxFeePerGas); } if (ro.maxPriorityFeePerGas != null) { tx.maxPriorityFeePerGas = BigNumber.from(ro.maxPriorityFeePerGas); } if (ro.from != null) { tx.from = ro.from; } if (ro.type != null) { tx.type = ro.type; } if (ro.accessList != null) { tx.accessList = accessListify(ro.accessList); } if (tx.gasLimit == null && fragment.gas != null) { let intrinsic = 21e3; const bytes = arrayify(data); for (let i2 = 0; i2 < bytes.length; i2++) { intrinsic += 4; if (bytes[i2]) { intrinsic += 64; } } tx.gasLimit = BigNumber.from(fragment.gas).add(intrinsic); } if (ro.value) { const roValue = BigNumber.from(ro.value); if (!roValue.isZero() && !fragment.payable) { logger$i.throwError("non-payable method cannot override value", Logger.errors.UNSUPPORTED_OPERATION, { operation: "overrides.value", value: overrides.value }); } tx.value = roValue; } if (ro.customData) { tx.customData = shallowCopy(ro.customData); } if (ro.ccipReadEnabled) { tx.ccipReadEnabled = !!ro.ccipReadEnabled; } delete overrides.nonce; delete overrides.gasLimit; delete overrides.gasPrice; delete overrides.from; delete overrides.value; delete overrides.type; delete overrides.accessList; delete overrides.maxFeePerGas; delete overrides.maxPriorityFeePerGas; delete overrides.customData; delete overrides.ccipReadEnabled; const leftovers = Object.keys(overrides).filter((key2) => overrides[key2] != null); if (leftovers.length) { logger$i.throwError(`cannot override ${leftovers.map((l2) => JSON.stringify(l2)).join(",")}`, Logger.errors.UNSUPPORTED_OPERATION, { operation: "overrides", overrides: leftovers }); } return tx; }); } function buildPopulate(contract, fragment) { return function(...args) { return populateTransaction(contract, fragment, args); }; } function buildEstimate(contract, fragment) { const signerOrProvider = contract.signer || contract.provider; return function(...args) { return __awaiter$9(this, void 0, void 0, function* () { if (!signerOrProvider) { logger$i.throwError("estimate require a provider or signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); } const tx = yield populateTransaction(contract, fragment, args); return yield signerOrProvider.estimateGas(tx); }); }; } function addContractWait(contract, tx) { const wait = tx.wait.bind(tx); tx.wait = (confirmations) => { return wait(confirmations).then((receipt) => { receipt.events = receipt.logs.map((log) => { let event = deepCopy(log); let parsed = null; try { parsed = contract.interface.parseLog(log); } catch (e) { } if (parsed) { event.args = parsed.args; event.decode = (data, topics) => { return contract.interface.decodeEventLog(parsed.eventFragment, data, topics); }; event.event = parsed.name; event.eventSignature = parsed.signature; } event.removeListener = () => { return contract.provider; }; event.getBlock = () => { return contract.provider.getBlock(receipt.blockHash); }; event.getTransaction = () => { return contract.provider.getTransaction(receipt.transactionHash); }; event.getTransactionReceipt = () => { return Promise.resolve(receipt); }; return event; }); return receipt; }); }; } function buildCall(contract, fragment, collapseSimple) { const signerOrProvider = contract.signer || contract.provider; return function(...args) { return __awaiter$9(this, void 0, void 0, function* () { let blockTag = void 0; if (args.length === fragment.inputs.length + 1 && typeof args[args.length - 1] === "object") { const overrides = shallowCopy(args.pop()); if (overrides.blockTag != null) { blockTag = yield overrides.blockTag; } delete overrides.blockTag; args.push(overrides); } if (contract.deployTransaction != null) { yield contract._deployed(blockTag); } const tx = yield populateTransaction(contract, fragment, args); const result = yield signerOrProvider.call(tx, blockTag); try { let value = contract.interface.decodeFunctionResult(fragment, result); if (collapseSimple && fragment.outputs.length === 1) { value = value[0]; } return value; } catch (error) { if (error.code === Logger.errors.CALL_EXCEPTION) { error.address = contract.address; error.args = args; error.transaction = tx; } throw error; } }); }; } function buildSend(contract, fragment) { return function(...args) { return __awaiter$9(this, void 0, void 0, function* () { if (!contract.signer) { logger$i.throwError("sending a transaction requires a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); } if (contract.deployTransaction != null) { yield contract._deployed(); } const txRequest = yield populateTransaction(contract, fragment, args); const tx = yield contract.signer.sendTransaction(txRequest); addContractWait(contract, tx); return tx; }); }; } function buildDefault(contract, fragment, collapseSimple) { if (fragment.constant) { return buildCall(contract, fragment, collapseSimple); } return buildSend(contract, fragment); } function getEventTag$1(filter) { if (filter.address && (filter.topics == null || filter.topics.length === 0)) { return "*"; } return (filter.address || "*") + "@" + (filter.topics ? filter.topics.map((topic) => { if (Array.isArray(topic)) { return topic.join("|"); } return topic; }).join(":") : ""); } class RunningEvent { constructor(tag, filter) { defineReadOnly(this, "tag", tag); defineReadOnly(this, "filter", filter); this._listeners = []; } addListener(listener, once) { this._listeners.push({ listener, once }); } removeListener(listener) { let done = false; this._listeners = this._listeners.filter((item) => { if (done || item.listener !== listener) { return true; } done = true; return false; }); } removeAllListeners() { this._listeners = []; } listeners() { return this._listeners.map((i2) => i2.listener); } listenerCount() { return this._listeners.length; } run(args) { const listenerCount = this.listenerCount(); this._listeners = this._listeners.filter((item) => { const argsCopy = args.slice(); setTimeout(() => { item.listener.apply(this, argsCopy); }, 0); return !item.once; }); return listenerCount; } prepareEvent(event) { } // Returns the array that will be applied to an emit getEmit(event) { return [event]; } } class ErrorRunningEvent extends RunningEvent { constructor() { super("error", null); } } class FragmentRunningEvent extends RunningEvent { constructor(address, contractInterface, fragment, topics) { const filter = { address }; let topic = contractInterface.getEventTopic(fragment); if (topics) { if (topic !== topics[0]) { logger$i.throwArgumentError("topic mismatch", "topics", topics); } filter.topics = topics.slice(); } else { filter.topics = [topic]; } super(getEventTag$1(filter), filter); defineReadOnly(this, "address", address); defineReadOnly(this, "interface", contractInterface); defineReadOnly(this, "fragment", fragment); } prepareEvent(event) { super.prepareEvent(event); event.event = this.fragment.name; event.eventSignature = this.fragment.format(); event.decode = (data, topics) => { return this.interface.decodeEventLog(this.fragment, data, topics); }; try { event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics); } catch (error) { event.args = null; event.decodeError = error; } } getEmit(event) { const errors = checkResultErrors(event.args); if (errors.length) { throw errors[0].error; } const args = (event.args || []).slice(); args.push(event); return args; } } class WildcardRunningEvent extends RunningEvent { constructor(address, contractInterface) { super("*", { address }); defineReadOnly(this, "address", address); defineReadOnly(this, "interface", contractInterface); } prepareEvent(event) { super.prepareEvent(event); try { const parsed = this.interface.parseLog(event); event.event = parsed.name; event.eventSignature = parsed.signature; event.decode = (data, topics) => { return this.interface.decodeEventLog(parsed.eventFragment, data, topics); }; event.args = parsed.args; } catch (error) { } } } class BaseContract { constructor(addressOrName, contractInterface, signerOrProvider) { defineReadOnly(this, "interface", getStatic(new.target, "getInterface")(contractInterface)); if (signerOrProvider == null) { defineReadOnly(this, "provider", null); defineReadOnly(this, "signer", null); } else if (Signer.isSigner(signerOrProvider)) { defineReadOnly(this, "provider", signerOrProvider.provider || null); defineReadOnly(this, "signer", signerOrProvider); } else if (Provider.isProvider(signerOrProvider)) { defineReadOnly(this, "provider", signerOrProvider); defineReadOnly(this, "signer", null); } else { logger$i.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); } defineReadOnly(this, "callStatic", {}); defineReadOnly(this, "estimateGas", {}); defineReadOnly(this, "functions", {}); defineReadOnly(this, "populateTransaction", {}); defineReadOnly(this, "filters", {}); { const uniqueFilters = {}; Object.keys(this.interface.events).forEach((eventSignature) => { const event = this.interface.events[eventSignature]; defineReadOnly(this.filters, eventSignature, (...args) => { return { address: this.address, topics: this.interface.encodeFilterTopics(event, args) }; }); if (!uniqueFilters[event.name]) { uniqueFilters[event.name] = []; } uniqueFilters[event.name].push(eventSignature); }); Object.keys(uniqueFilters).forEach((name) => { const filters = uniqueFilters[name]; if (filters.length === 1) { defineReadOnly(this.filters, name, this.filters[filters[0]]); } else { logger$i.warn(`Duplicate definition of ${name} (${filters.join(", ")})`); } }); } defineReadOnly(this, "_runningEvents", {}); defineReadOnly(this, "_wrappedEmits", {}); if (addressOrName == null) { logger$i.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName); } defineReadOnly(this, "address", addressOrName); if (this.provider) { defineReadOnly(this, "resolvedAddress", resolveName(this.provider, addressOrName)); } else { try { defineReadOnly(this, "resolvedAddress", Promise.resolve(getAddress(addressOrName))); } catch (error) { logger$i.throwError("provider is required to use ENS name as contract address", Logger.errors.UNSUPPORTED_OPERATION, { operation: "new Contract" }); } } this.resolvedAddress.catch((e) => { }); const uniqueNames = {}; const uniqueSignatures = {}; Object.keys(this.interface.functions).forEach((signature2) => { const fragment = this.interface.functions[signature2]; if (uniqueSignatures[signature2]) { logger$i.warn(`Duplicate ABI entry for ${JSON.stringify(signature2)}`); return; } uniqueSignatures[signature2] = true; { const name = fragment.name; if (!uniqueNames[`%${name}`]) { uniqueNames[`%${name}`] = []; } uniqueNames[`%${name}`].push(signature2); } if (this[signature2] == null) { defineReadOnly(this, signature2, buildDefault(this, fragment, true)); } if (this.functions[signature2] == null) { defineReadOnly(this.functions, signature2, buildDefault(this, fragment, false)); } if (this.callStatic[signature2] == null) { defineReadOnly(this.callStatic, signature2, buildCall(this, fragment, true)); } if (this.populateTransaction[signature2] == null) { defineReadOnly(this.populateTransaction, signature2, buildPopulate(this, fragment)); } if (this.estimateGas[signature2] == null) { defineReadOnly(this.estimateGas, signature2, buildEstimate(this, fragment)); } }); Object.keys(uniqueNames).forEach((name) => { const signatures = uniqueNames[name]; if (signatures.length > 1) { return; } name = name.substring(1); const signature2 = signatures[0]; try { if (this[name] == null) { defineReadOnly(this, name, this[signature2]); } } catch (e) { } if (this.functions[name] == null) { defineReadOnly(this.functions, name, this.functions[signature2]); } if (this.callStatic[name] == null) { defineReadOnly(this.callStatic, name, this.callStatic[signature2]); } if (this.populateTransaction[name] == null) { defineReadOnly(this.populateTransaction, name, this.populateTransaction[signature2]); } if (this.estimateGas[name] == null) { defineReadOnly(this.estimateGas, name, this.estimateGas[signature2]); } }); } static getContractAddress(transaction) { return getContractAddress(transaction); } static getInterface(contractInterface) { if (Interface.isInterface(contractInterface)) { return contractInterface; } return new Interface(contractInterface); } // @TODO: Allow timeout? deployed() { return this._deployed(); } _deployed(blockTag) { if (!this._deployedPromise) { if (this.deployTransaction) { this._deployedPromise = this.deployTransaction.wait().then(() => { return this; }); } else { this._deployedPromise = this.provider.getCode(this.address, blockTag).then((code2) => { if (code2 === "0x") { logger$i.throwError("contract not deployed", Logger.errors.UNSUPPORTED_OPERATION, { contractAddress: this.address, operation: "getDeployed" }); } return this; }); } } return this._deployedPromise; } // @TODO: // estimateFallback(overrides?: TransactionRequest): Promise // @TODO: // estimateDeploy(bytecode: string, ...args): Promise fallback(overrides) { if (!this.signer) { logger$i.throwError("sending a transactions require a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); } const tx = shallowCopy(overrides || {}); ["from", "to"].forEach(function(key2) { if (tx[key2] == null) { return; } logger$i.throwError("cannot override " + key2, Logger.errors.UNSUPPORTED_OPERATION, { operation: key2 }); }); tx.to = this.resolvedAddress; return this.deployed().then(() => { return this.signer.sendTransaction(tx); }); } // Reconnect to a different signer or provider connect(signerOrProvider) { if (typeof signerOrProvider === "string") { signerOrProvider = new VoidSigner(signerOrProvider, this.provider); } const contract = new this.constructor(this.address, this.interface, signerOrProvider); if (this.deployTransaction) { defineReadOnly(contract, "deployTransaction", this.deployTransaction); } return contract; } // Re-attach to a different on-chain instance of this contract attach(addressOrName) { return new this.constructor(addressOrName, this.interface, this.signer || this.provider); } static isIndexed(value) { return Indexed.isIndexed(value); } _normalizeRunningEvent(runningEvent) { if (this._runningEvents[runningEvent.tag]) { return this._runningEvents[runningEvent.tag]; } return runningEvent; } _getRunningEvent(eventName) { if (typeof eventName === "string") { if (eventName === "error") { return this._normalizeRunningEvent(new ErrorRunningEvent()); } if (eventName === "event") { return this._normalizeRunningEvent(new RunningEvent("event", null)); } if (eventName === "*") { return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); } const fragment = this.interface.getEvent(eventName); return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment)); } if (eventName.topics && eventName.topics.length > 0) { try { const topic = eventName.topics[0]; if (typeof topic !== "string") { throw new Error("invalid topic"); } const fragment = this.interface.getEvent(topic); return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics)); } catch (error) { } const filter = { address: this.address, topics: eventName.topics }; return this._normalizeRunningEvent(new RunningEvent(getEventTag$1(filter), filter)); } return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); } _checkRunningEvents(runningEvent) { if (runningEvent.listenerCount() === 0) { delete this._runningEvents[runningEvent.tag]; const emit = this._wrappedEmits[runningEvent.tag]; if (emit && runningEvent.filter) { this.provider.off(runningEvent.filter, emit); delete this._wrappedEmits[runningEvent.tag]; } } } // Subclasses can override this to gracefully recover // from parse errors if they wish _wrapEvent(runningEvent, log, listener) { const event = deepCopy(log); event.removeListener = () => { if (!listener) { return; } runningEvent.removeListener(listener); this._checkRunningEvents(runningEvent); }; event.getBlock = () => { return this.provider.getBlock(log.blockHash); }; event.getTransaction = () => { return this.provider.getTransaction(log.transactionHash); }; event.getTransactionReceipt = () => { return this.provider.getTransactionReceipt(log.transactionHash); }; runningEvent.prepareEvent(event); return event; } _addEventListener(runningEvent, listener, once) { if (!this.provider) { logger$i.throwError("events require a provider or a signer with a provider", Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); } runningEvent.addListener(listener, once); this._runningEvents[runningEvent.tag] = runningEvent; if (!this._wrappedEmits[runningEvent.tag]) { const wrappedEmit = (log) => { let event = this._wrapEvent(runningEvent, log, listener); if (event.decodeError == null) { try { const args = runningEvent.getEmit(event); this.emit(runningEvent.filter, ...args); } catch (error) { event.decodeError = error.error; } } if (runningEvent.filter != null) { this.emit("event", event); } if (event.decodeError != null) { this.emit("error", event.decodeError, event); } }; this._wrappedEmits[runningEvent.tag] = wrappedEmit; if (runningEvent.filter != null) { this.provider.on(runningEvent.filter, wrappedEmit); } } } queryFilter(event, fromBlockOrBlockhash, toBlock) { const runningEvent = this._getRunningEvent(event); const filter = shallowCopy(runningEvent.filter); if (typeof fromBlockOrBlockhash === "string" && isHexString(fromBlockOrBlockhash, 32)) { if (toBlock != null) { logger$i.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); } filter.blockHash = fromBlockOrBlockhash; } else { filter.fromBlock = fromBlockOrBlockhash != null ? fromBlockOrBlockhash : 0; filter.toBlock = toBlock != null ? toBlock : "latest"; } return this.provider.getLogs(filter).then((logs) => { return logs.map((log) => this._wrapEvent(runningEvent, log, null)); }); } on(event, listener) { this._addEventListener(this._getRunningEvent(event), listener, false); return this; } once(event, listener) { this._addEventListener(this._getRunningEvent(event), listener, true); return this; } emit(eventName, ...args) { if (!this.provider) { return false; } const runningEvent = this._getRunningEvent(eventName); const result = runningEvent.run(args) > 0; this._checkRunningEvents(runningEvent); return result; } listenerCount(eventName) { if (!this.provider) { return 0; } if (eventName == null) { return Object.keys(this._runningEvents).reduce((accum, key2) => { return accum + this._runningEvents[key2].listenerCount(); }, 0); } return this._getRunningEvent(eventName).listenerCount(); } listeners(eventName) { if (!this.provider) { return []; } if (eventName == null) { const result = []; for (let tag in this._runningEvents) { this._runningEvents[tag].listeners().forEach((listener) => { result.push(listener); }); } return result; } return this._getRunningEvent(eventName).listeners(); } removeAllListeners(eventName) { if (!this.provider) { return this; } if (eventName == null) { for (const tag in this._runningEvents) { const runningEvent2 = this._runningEvents[tag]; runningEvent2.removeAllListeners(); this._checkRunningEvents(runningEvent2); } return this; } const runningEvent = this._getRunningEvent(eventName); runningEvent.removeAllListeners(); this._checkRunningEvents(runningEvent); return this; } off(eventName, listener) { if (!this.provider) { return this; } const runningEvent = this._getRunningEvent(eventName); runningEvent.removeListener(listener); this._checkRunningEvents(runningEvent); return this; } removeListener(eventName, listener) { return this.off(eventName, listener); } } class Contract extends BaseContract { } class BaseX { constructor(alphabet) { defineReadOnly(this, "alphabet", alphabet); defineReadOnly(this, "base", alphabet.length); defineReadOnly(this, "_alphabetMap", {}); defineReadOnly(this, "_leader", alphabet.charAt(0)); for (let i2 = 0; i2 < alphabet.length; i2++) { this._alphabetMap[alphabet.charAt(i2)] = i2; } } encode(value) { let source = arrayify(value); if (source.length === 0) { return ""; } let digits = [0]; for (let i2 = 0; i2 < source.length; ++i2) { let carry = source[i2]; for (let j2 = 0; j2 < digits.length; ++j2) { carry += digits[j2] << 8; digits[j2] = carry % this.base; carry = carry / this.base | 0; } while (carry > 0) { digits.push(carry % this.base); carry = carry / this.base | 0; } } let string = ""; for (let k2 = 0; source[k2] === 0 && k2 < source.length - 1; ++k2) { string += this._leader; } for (let q = digits.length - 1; q >= 0; --q) { string += this.alphabet[digits[q]]; } return string; } decode(value) { if (typeof value !== "string") { throw new TypeError("Expected String"); } let bytes = []; if (value.length === 0) { return new Uint8Array(bytes); } bytes.push(0); for (let i2 = 0; i2 < value.length; i2++) { let byte = this._alphabetMap[value[i2]]; if (byte === void 0) { throw new Error("Non-base" + this.base + " character"); } let carry = byte; for (let j2 = 0; j2 < bytes.length; ++j2) { carry += bytes[j2] * this.base; bytes[j2] = carry & 255; carry >>= 8; } while (carry > 0) { bytes.push(carry & 255); carry >>= 8; } } for (let k2 = 0; value[k2] === this._leader && k2 < value.length - 1; ++k2) { bytes.push(0); } return arrayify(new Uint8Array(bytes.reverse())); } } const Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); const Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); const lib_esm$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, Base32, Base58, BaseX }, Symbol.toStringTag, { value: "Module" })); var SupportedAlgorithm; (function(SupportedAlgorithm2) { SupportedAlgorithm2["sha256"] = "sha256"; SupportedAlgorithm2["sha512"] = "sha512"; })(SupportedAlgorithm || (SupportedAlgorithm = {})); const version$b = "sha2/5.7.0"; const logger$h = new Logger(version$b); function ripemd160(data) { return "0x" + hash.ripemd160().update(arrayify(data)).digest("hex"); } function sha256$1(data) { return "0x" + hash.sha256().update(arrayify(data)).digest("hex"); } function sha512(data) { return "0x" + hash.sha512().update(arrayify(data)).digest("hex"); } function computeHmac(algorithm, key2, data) { if (!SupportedAlgorithm[algorithm]) { logger$h.throwError("unsupported algorithm " + algorithm, Logger.errors.UNSUPPORTED_OPERATION, { operation: "hmac", algorithm }); } return "0x" + hash.hmac(hash[algorithm], arrayify(key2)).update(arrayify(data)).digest("hex"); } const lib_esm$7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, get SupportedAlgorithm() { return SupportedAlgorithm; }, computeHmac, ripemd160, sha256: sha256$1, sha512 }, Symbol.toStringTag, { value: "Module" })); function pbkdf2$1(password, salt, iterations, keylen, hashAlgorithm) { password = arrayify(password); salt = arrayify(salt); let hLen; let l2 = 1; const DK = new Uint8Array(keylen); const block1 = new Uint8Array(salt.length + 4); block1.set(salt); let r2; let T; for (let i2 = 1; i2 <= l2; i2++) { block1[salt.length] = i2 >> 24 & 255; block1[salt.length + 1] = i2 >> 16 & 255; block1[salt.length + 2] = i2 >> 8 & 255; block1[salt.length + 3] = i2 & 255; let U = arrayify(computeHmac(hashAlgorithm, password, block1)); if (!hLen) { hLen = U.length; T = new Uint8Array(hLen); l2 = Math.ceil(keylen / hLen); r2 = keylen - (l2 - 1) * hLen; } T.set(U); for (let j2 = 1; j2 < iterations; j2++) { U = arrayify(computeHmac(hashAlgorithm, password, U)); for (let k2 = 0; k2 < hLen; k2++) T[k2] ^= U[k2]; } const destPos = (i2 - 1) * hLen; const len = i2 === l2 ? r2 : hLen; DK.set(arrayify(T).slice(0, len), destPos); } return hexlify(DK); } const version$a = "wordlists/5.7.0"; const logger$g = new Logger(version$a); class Wordlist { constructor(locale) { logger$g.checkAbstract(new.target, Wordlist); defineReadOnly(this, "locale", locale); } // Subclasses may override this split(mnemonic) { return mnemonic.toLowerCase().split(/ +/g); } // Subclasses may override this join(words2) { return words2.join(" "); } static check(wordlist2) { const words2 = []; for (let i2 = 0; i2 < 2048; i2++) { const word = wordlist2.getWord(i2); if (i2 !== wordlist2.getWordIndex(word)) { return "0x"; } words2.push(word); } return id(words2.join("\n") + "\n"); } static register(lang, name) { if (!name) { name = lang.locale; } } } const words = "AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo"; let wordlist = null; function loadWords(lang) { if (wordlist != null) { return; } wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" "); if (Wordlist.check(lang) !== "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60") { wordlist = null; throw new Error("BIP39 Wordlist for en (English) FAILED"); } } class LangEn extends Wordlist { constructor() { super("en"); } getWord(index) { loadWords(this); return wordlist[index]; } getWordIndex(word) { loadWords(this); return wordlist.indexOf(word); } } const langEn = new LangEn(); Wordlist.register(langEn); const wordlists = { en: langEn }; const version$9 = "hdnode/5.7.0"; const logger$f = new Logger(version$9); const N = BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); const MasterSecret = toUtf8Bytes("Bitcoin seed"); const HardenedBit = 2147483648; function getUpperMask(bits) { return (1 << bits) - 1 << 8 - bits; } function getLowerMask(bits) { return (1 << bits) - 1; } function bytes32(value) { return hexZeroPad(hexlify(value), 32); } function base58check(data) { return Base58.encode(concat([data, hexDataSlice(sha256$1(sha256$1(data)), 0, 4)])); } function getWordlist(wordlist2) { if (wordlist2 == null) { return wordlists["en"]; } if (typeof wordlist2 === "string") { const words2 = wordlists[wordlist2]; if (words2 == null) { logger$f.throwArgumentError("unknown locale", "wordlist", wordlist2); } return words2; } return wordlist2; } const _constructorGuard$1 = {}; const defaultPath = "m/44'/60'/0'/0/0"; class HDNode { /** * This constructor should not be called directly. * * Please use: * - fromMnemonic * - fromSeed */ constructor(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonicOrPath) { if (constructorGuard !== _constructorGuard$1) { throw new Error("HDNode constructor cannot be called directly"); } if (privateKey) { const signingKey = new SigningKey(privateKey); defineReadOnly(this, "privateKey", signingKey.privateKey); defineReadOnly(this, "publicKey", signingKey.compressedPublicKey); } else { defineReadOnly(this, "privateKey", null); defineReadOnly(this, "publicKey", hexlify(publicKey)); } defineReadOnly(this, "parentFingerprint", parentFingerprint); defineReadOnly(this, "fingerprint", hexDataSlice(ripemd160(sha256$1(this.publicKey)), 0, 4)); defineReadOnly(this, "address", computeAddress(this.publicKey)); defineReadOnly(this, "chainCode", chainCode); defineReadOnly(this, "index", index); defineReadOnly(this, "depth", depth); if (mnemonicOrPath == null) { defineReadOnly(this, "mnemonic", null); defineReadOnly(this, "path", null); } else if (typeof mnemonicOrPath === "string") { defineReadOnly(this, "mnemonic", null); defineReadOnly(this, "path", mnemonicOrPath); } else { defineReadOnly(this, "mnemonic", mnemonicOrPath); defineReadOnly(this, "path", mnemonicOrPath.path); } } get extendedKey() { if (this.depth >= 256) { throw new Error("Depth too large!"); } return base58check(concat([ this.privateKey != null ? "0x0488ADE4" : "0x0488B21E", hexlify(this.depth), this.parentFingerprint, hexZeroPad(hexlify(this.index), 4), this.chainCode, this.privateKey != null ? concat(["0x00", this.privateKey]) : this.publicKey ])); } neuter() { return new HDNode(_constructorGuard$1, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, this.path); } _derive(index) { if (index > 4294967295) { throw new Error("invalid index - " + String(index)); } let path = this.path; if (path) { path += "/" + (index & ~HardenedBit); } const data = new Uint8Array(37); if (index & HardenedBit) { if (!this.privateKey) { throw new Error("cannot derive child of neutered node"); } data.set(arrayify(this.privateKey), 1); if (path) { path += "'"; } } else { data.set(arrayify(this.publicKey)); } for (let i2 = 24; i2 >= 0; i2 -= 8) { data[33 + (i2 >> 3)] = index >> 24 - i2 & 255; } const I2 = arrayify(computeHmac(SupportedAlgorithm.sha512, this.chainCode, data)); const IL = I2.slice(0, 32); const IR = I2.slice(32); let ki = null; let Ki = null; if (this.privateKey) { ki = bytes32(BigNumber.from(IL).add(this.privateKey).mod(N)); } else { const ek = new SigningKey(hexlify(IL)); Ki = ek._addPoint(this.publicKey); } let mnemonicOrPath = path; const srcMnemonic = this.mnemonic; if (srcMnemonic) { mnemonicOrPath = Object.freeze({ phrase: srcMnemonic.phrase, path, locale: srcMnemonic.locale || "en" }); } return new HDNode(_constructorGuard$1, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, mnemonicOrPath); } derivePath(path) { const components = path.split("/"); if (components.length === 0 || components[0] === "m" && this.depth !== 0) { throw new Error("invalid path - " + path); } if (components[0] === "m") { components.shift(); } let result = this; for (let i2 = 0; i2 < components.length; i2++) { const component = components[i2]; if (component.match(/^[0-9]+'$/)) { const index = parseInt(component.substring(0, component.length - 1)); if (index >= HardenedBit) { throw new Error("invalid path index - " + component); } result = result._derive(HardenedBit + index); } else if (component.match(/^[0-9]+$/)) { const index = parseInt(component); if (index >= HardenedBit) { throw new Error("invalid path index - " + component); } result = result._derive(index); } else { throw new Error("invalid path component - " + component); } } return result; } static _fromSeed(seed, mnemonic) { const seedArray = arrayify(seed); if (seedArray.length < 16 || seedArray.length > 64) { throw new Error("invalid seed"); } const I2 = arrayify(computeHmac(SupportedAlgorithm.sha512, MasterSecret, seedArray)); return new HDNode(_constructorGuard$1, bytes32(I2.slice(0, 32)), null, "0x00000000", bytes32(I2.slice(32)), 0, 0, mnemonic); } static fromMnemonic(mnemonic, password, wordlist2) { wordlist2 = getWordlist(wordlist2); mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist2), wordlist2); return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), { phrase: mnemonic, path: "m", locale: wordlist2.locale }); } static fromSeed(seed) { return HDNode._fromSeed(seed, null); } static fromExtendedKey(extendedKey) { const bytes = Base58.decode(extendedKey); if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { logger$f.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); } const depth = bytes[4]; const parentFingerprint = hexlify(bytes.slice(5, 9)); const index = parseInt(hexlify(bytes.slice(9, 13)).substring(2), 16); const chainCode = hexlify(bytes.slice(13, 45)); const key2 = bytes.slice(45, 78); switch (hexlify(bytes.slice(0, 4))) { case "0x0488b21e": case "0x043587cf": return new HDNode(_constructorGuard$1, null, hexlify(key2), parentFingerprint, chainCode, index, depth, null); case "0x0488ade4": case "0x04358394 ": if (key2[0] !== 0) { break; } return new HDNode(_constructorGuard$1, hexlify(key2.slice(1)), null, parentFingerprint, chainCode, index, depth, null); } return logger$f.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); } } function mnemonicToSeed(mnemonic, password) { if (!password) { password = ""; } const salt = toUtf8Bytes("mnemonic" + password, UnicodeNormalizationForm.NFKD); return pbkdf2$1(toUtf8Bytes(mnemonic, UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); } function mnemonicToEntropy(mnemonic, wordlist2) { wordlist2 = getWordlist(wordlist2); logger$f.checkNormalize(); const words2 = wordlist2.split(mnemonic); if (words2.length % 3 !== 0) { throw new Error("invalid mnemonic"); } const entropy = arrayify(new Uint8Array(Math.ceil(11 * words2.length / 8))); let offset = 0; for (let i2 = 0; i2 < words2.length; i2++) { let index = wordlist2.getWordIndex(words2[i2].normalize("NFKD")); if (index === -1) { throw new Error("invalid mnemonic"); } for (let bit = 0; bit < 11; bit++) { if (index & 1 << 10 - bit) { entropy[offset >> 3] |= 1 << 7 - offset % 8; } offset++; } } const entropyBits = 32 * words2.length / 3; const checksumBits = words2.length / 3; const checksumMask = getUpperMask(checksumBits); const checksum = arrayify(sha256$1(entropy.slice(0, entropyBits / 8)))[0] & checksumMask; if (checksum !== (entropy[entropy.length - 1] & checksumMask)) { throw new Error("invalid checksum"); } return hexlify(entropy.slice(0, entropyBits / 8)); } function entropyToMnemonic(entropy, wordlist2) { wordlist2 = getWordlist(wordlist2); entropy = arrayify(entropy); if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) { throw new Error("invalid entropy"); } const indices = [0]; let remainingBits = 11; for (let i2 = 0; i2 < entropy.length; i2++) { if (remainingBits > 8) { indices[indices.length - 1] <<= 8; indices[indices.length - 1] |= entropy[i2]; remainingBits -= 8; } else { indices[indices.length - 1] <<= remainingBits; indices[indices.length - 1] |= entropy[i2] >> 8 - remainingBits; indices.push(entropy[i2] & getLowerMask(8 - remainingBits)); remainingBits += 3; } } const checksumBits = entropy.length / 4; const checksum = arrayify(sha256$1(entropy))[0] & getUpperMask(checksumBits); indices[indices.length - 1] <<= checksumBits; indices[indices.length - 1] |= checksum >> 8 - checksumBits; return wordlist2.join(indices.map((index) => wordlist2.getWord(index))); } function isValidMnemonic(mnemonic, wordlist2) { try { mnemonicToEntropy(mnemonic, wordlist2); return true; } catch (error) { } return false; } function getAccountPath(index) { if (typeof index !== "number" || index < 0 || index >= HardenedBit || index % 1) { logger$f.throwArgumentError("invalid account index", "index", index); } return `m/44'/60'/${index}'/0/0`; } const lib_esm$6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, HDNode, defaultPath, entropyToMnemonic, getAccountPath, isValidMnemonic, mnemonicToEntropy, mnemonicToSeed }, Symbol.toStringTag, { value: "Module" })); const version$8 = "random/5.7.0"; const logger$e = new Logger(version$8); function getGlobal() { if (typeof self !== "undefined") { return self; } if (typeof window !== "undefined") { return window; } if (typeof global !== "undefined") { return global; } throw new Error("unable to locate global object"); } const anyGlobal = getGlobal(); let crypto = anyGlobal.crypto || anyGlobal.msCrypto; if (!crypto || !crypto.getRandomValues) { logger$e.warn("WARNING: Missing strong random number source"); crypto = { getRandomValues: function(buffer2) { return logger$e.throwError("no secure random source avaialble", Logger.errors.UNSUPPORTED_OPERATION, { operation: "crypto.getRandomValues" }); } }; } function randomBytes(length) { if (length <= 0 || length > 1024 || length % 1 || length != length) { logger$e.throwArgumentError("invalid length", "length", length); } const result = new Uint8Array(length); crypto.getRandomValues(result); return arrayify(result); } function shuffled(array) { array = array.slice(); for (let i2 = array.length - 1; i2 > 0; i2--) { const j2 = Math.floor(Math.random() * (i2 + 1)); const tmp = array[i2]; array[i2] = array[j2]; array[j2] = tmp; } return array; } const lib_esm$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, randomBytes, shuffled }, Symbol.toStringTag, { value: "Module" })); var aesJsExports = {}; var aesJs = { get exports() { return aesJsExports; }, set exports(v2) { aesJsExports = v2; } }; (function(module, exports) { (function(root) { function checkInt(value) { return parseInt(value) === value; } function checkInts(arrayish) { if (!checkInt(arrayish.length)) { return false; } for (var i2 = 0; i2 < arrayish.length; i2++) { if (!checkInt(arrayish[i2]) || arrayish[i2] < 0 || arrayish[i2] > 255) { return false; } } return true; } function coerceArray(arg, copy) { if (arg.buffer && ArrayBuffer.isView(arg) && arg.name === "Uint8Array") { if (copy) { if (arg.slice) { arg = arg.slice(); } else { arg = Array.prototype.slice.call(arg); } } return arg; } if (Array.isArray(arg)) { if (!checkInts(arg)) { throw new Error("Array contains invalid value: " + arg); } return new Uint8Array(arg); } if (checkInt(arg.length) && checkInts(arg)) { return new Uint8Array(arg); } throw new Error("unsupported array-like object"); } function createArray(length) { return new Uint8Array(length); } function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) { if (sourceStart != null || sourceEnd != null) { if (sourceArray.slice) { sourceArray = sourceArray.slice(sourceStart, sourceEnd); } else { sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd); } } targetArray.set(sourceArray, targetStart); } var convertUtf8 = function() { function toBytes(text2) { var result = [], i2 = 0; text2 = encodeURI(text2); while (i2 < text2.length) { var c2 = text2.charCodeAt(i2++); if (c2 === 37) { result.push(parseInt(text2.substr(i2, 2), 16)); i2 += 2; } else { result.push(c2); } } return coerceArray(result); } function fromBytes(bytes) { var result = [], i2 = 0; while (i2 < bytes.length) { var c2 = bytes[i2]; if (c2 < 128) { result.push(String.fromCharCode(c2)); i2++; } else if (c2 > 191 && c2 < 224) { result.push(String.fromCharCode((c2 & 31) << 6 | bytes[i2 + 1] & 63)); i2 += 2; } else { result.push(String.fromCharCode((c2 & 15) << 12 | (bytes[i2 + 1] & 63) << 6 | bytes[i2 + 2] & 63)); i2 += 3; } } return result.join(""); } return { toBytes, fromBytes }; }(); var convertHex = function() { function toBytes(text2) { var result = []; for (var i2 = 0; i2 < text2.length; i2 += 2) { result.push(parseInt(text2.substr(i2, 2), 16)); } return result; } var Hex = "0123456789abcdef"; function fromBytes(bytes) { var result = []; for (var i2 = 0; i2 < bytes.length; i2++) { var v2 = bytes[i2]; result.push(Hex[(v2 & 240) >> 4] + Hex[v2 & 15]); } return result.join(""); } return { toBytes, fromBytes }; }(); var numberOfRounds = { 16: 10, 24: 12, 32: 14 }; var rcon = [1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145]; var S2 = [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22]; var Si = [82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125]; var T1 = [3328402341, 4168907908, 4000806809, 4135287693, 4294111757, 3597364157, 3731845041, 2445657428, 1613770832, 33620227, 3462883241, 1445669757, 3892248089, 3050821474, 1303096294, 3967186586, 2412431941, 528646813, 2311702848, 4202528135, 4026202645, 2992200171, 2387036105, 4226871307, 1101901292, 3017069671, 1604494077, 1169141738, 597466303, 1403299063, 3832705686, 2613100635, 1974974402, 3791519004, 1033081774, 1277568618, 1815492186, 2118074177, 4126668546, 2211236943, 1748251740, 1369810420, 3521504564, 4193382664, 3799085459, 2883115123, 1647391059, 706024767, 134480908, 2512897874, 1176707941, 2646852446, 806885416, 932615841, 168101135, 798661301, 235341577, 605164086, 461406363, 3756188221, 3454790438, 1311188841, 2142417613, 3933566367, 302582043, 495158174, 1479289972, 874125870, 907746093, 3698224818, 3025820398, 1537253627, 2756858614, 1983593293, 3084310113, 2108928974, 1378429307, 3722699582, 1580150641, 327451799, 2790478837, 3117535592, 0, 3253595436, 1075847264, 3825007647, 2041688520, 3059440621, 3563743934, 2378943302, 1740553945, 1916352843, 2487896798, 2555137236, 2958579944, 2244988746, 3151024235, 3320835882, 1336584933, 3992714006, 2252555205, 2588757463, 1714631509, 293963156, 2319795663, 3925473552, 67240454, 4269768577, 2689618160, 2017213508, 631218106, 1269344483, 2723238387, 1571005438, 2151694528, 93294474, 1066570413, 563977660, 1882732616, 4059428100, 1673313503, 2008463041, 2950355573, 1109467491, 537923632, 3858759450, 4260623118, 3218264685, 2177748300, 403442708, 638784309, 3287084079, 3193921505, 899127202, 2286175436, 773265209, 2479146071, 1437050866, 4236148354, 2050833735, 3362022572, 3126681063, 840505643, 3866325909, 3227541664, 427917720, 2655997905, 2749160575, 1143087718, 1412049534, 999329963, 193497219, 2353415882, 3354324521, 1807268051, 672404540, 2816401017, 3160301282, 369822493, 2916866934, 3688947771, 1681011286, 1949973070, 336202270, 2454276571, 201721354, 1210328172, 3093060836, 2680341085, 3184776046, 1135389935, 3294782118, 965841320, 831886756, 3554993207, 4068047243, 3588745010, 2345191491, 1849112409, 3664604599, 26054028, 2983581028, 2622377682, 1235855840, 3630984372, 2891339514, 4092916743, 3488279077, 3395642799, 4101667470, 1202630377, 268961816, 1874508501, 4034427016, 1243948399, 1546530418, 941366308, 1470539505, 1941222599, 2546386513, 3421038627, 2715671932, 3899946140, 1042226977, 2521517021, 1639824860, 227249030, 260737669, 3765465232, 2084453954, 1907733956, 3429263018, 2420656344, 100860677, 4160157185, 470683154, 3261161891, 1781871967, 2924959737, 1773779408, 394692241, 2579611992, 974986535, 664706745, 3655459128, 3958962195, 731420851, 571543859, 3530123707, 2849626480, 126783113, 865375399, 765172662, 1008606754, 361203602, 3387549984, 2278477385, 2857719295, 1344809080, 2782912378, 59542671, 1503764984, 160008576, 437062935, 1707065306, 3622233649, 2218934982, 3496503480, 2185314755, 697932208, 1512910199, 504303377, 2075177163, 2824099068, 1841019862, 739644986]; var T2 = [2781242211, 2230877308, 2582542199, 2381740923, 234877682, 3184946027, 2984144751, 1418839493, 1348481072, 50462977, 2848876391, 2102799147, 434634494, 1656084439, 3863849899, 2599188086, 1167051466, 2636087938, 1082771913, 2281340285, 368048890, 3954334041, 3381544775, 201060592, 3963727277, 1739838676, 4250903202, 3930435503, 3206782108, 4149453988, 2531553906, 1536934080, 3262494647, 484572669, 2923271059, 1783375398, 1517041206, 1098792767, 49674231, 1334037708, 1550332980, 4098991525, 886171109, 150598129, 2481090929, 1940642008, 1398944049, 1059722517, 201851908, 1385547719, 1699095331, 1587397571, 674240536, 2704774806, 252314885, 3039795866, 151914247, 908333586, 2602270848, 1038082786, 651029483, 1766729511, 3447698098, 2682942837, 454166793, 2652734339, 1951935532, 775166490, 758520603, 3000790638, 4004797018, 4217086112, 4137964114, 1299594043, 1639438038, 3464344499, 2068982057, 1054729187, 1901997871, 2534638724, 4121318227, 1757008337, 0, 750906861, 1614815264, 535035132, 3363418545, 3988151131, 3201591914, 1183697867, 3647454910, 1265776953, 3734260298, 3566750796, 3903871064, 1250283471, 1807470800, 717615087, 3847203498, 384695291, 3313910595, 3617213773, 1432761139, 2484176261, 3481945413, 283769337, 100925954, 2180939647, 4037038160, 1148730428, 3123027871, 3813386408, 4087501137, 4267549603, 3229630528, 2315620239, 2906624658, 3156319645, 1215313976, 82966005, 3747855548, 3245848246, 1974459098, 1665278241, 807407632, 451280895, 251524083, 1841287890, 1283575245, 337120268, 891687699, 801369324, 3787349855, 2721421207, 3431482436, 959321879, 1469301956, 4065699751, 2197585534, 1199193405, 2898814052, 3887750493, 724703513, 2514908019, 2696962144, 2551808385, 3516813135, 2141445340, 1715741218, 2119445034, 2872807568, 2198571144, 3398190662, 700968686, 3547052216, 1009259540, 2041044702, 3803995742, 487983883, 1991105499, 1004265696, 1449407026, 1316239930, 504629770, 3683797321, 168560134, 1816667172, 3837287516, 1570751170, 1857934291, 4014189740, 2797888098, 2822345105, 2754712981, 936633572, 2347923833, 852879335, 1133234376, 1500395319, 3084545389, 2348912013, 1689376213, 3533459022, 3762923945, 3034082412, 4205598294, 133428468, 634383082, 2949277029, 2398386810, 3913789102, 403703816, 3580869306, 2297460856, 1867130149, 1918643758, 607656988, 4049053350, 3346248884, 1368901318, 600565992, 2090982877, 2632479860, 557719327, 3717614411, 3697393085, 2249034635, 2232388234, 2430627952, 1115438654, 3295786421, 2865522278, 3633334344, 84280067, 33027830, 303828494, 2747425121, 1600795957, 4188952407, 3496589753, 2434238086, 1486471617, 658119965, 3106381470, 953803233, 334231800, 3005978776, 857870609, 3151128937, 1890179545, 2298973838, 2805175444, 3056442267, 574365214, 2450884487, 550103529, 1233637070, 4289353045, 2018519080, 2057691103, 2399374476, 4166623649, 2148108681, 387583245, 3664101311, 836232934, 3330556482, 3100665960, 3280093505, 2955516313, 2002398509, 287182607, 3413881008, 4238890068, 3597515707, 975967766]; var T3 = [1671808611, 2089089148, 2006576759, 2072901243, 4061003762, 1807603307, 1873927791, 3310653893, 810573872, 16974337, 1739181671, 729634347, 4263110654, 3613570519, 2883997099, 1989864566, 3393556426, 2191335298, 3376449993, 2106063485, 4195741690, 1508618841, 1204391495, 4027317232, 2917941677, 3563566036, 2734514082, 2951366063, 2629772188, 2767672228, 1922491506, 3227229120, 3082974647, 4246528509, 2477669779, 644500518, 911895606, 1061256767, 4144166391, 3427763148, 878471220, 2784252325, 3845444069, 4043897329, 1905517169, 3631459288, 827548209, 356461077, 67897348, 3344078279, 593839651, 3277757891, 405286936, 2527147926, 84871685, 2595565466, 118033927, 305538066, 2157648768, 3795705826, 3945188843, 661212711, 2999812018, 1973414517, 152769033, 2208177539, 745822252, 439235610, 455947803, 1857215598, 1525593178, 2700827552, 1391895634, 994932283, 3596728278, 3016654259, 695947817, 3812548067, 795958831, 2224493444, 1408607827, 3513301457, 0, 3979133421, 543178784, 4229948412, 2982705585, 1542305371, 1790891114, 3410398667, 3201918910, 961245753, 1256100938, 1289001036, 1491644504, 3477767631, 3496721360, 4012557807, 2867154858, 4212583931, 1137018435, 1305975373, 861234739, 2241073541, 1171229253, 4178635257, 33948674, 2139225727, 1357946960, 1011120188, 2679776671, 2833468328, 1374921297, 2751356323, 1086357568, 2408187279, 2460827538, 2646352285, 944271416, 4110742005, 3168756668, 3066132406, 3665145818, 560153121, 271589392, 4279952895, 4077846003, 3530407890, 3444343245, 202643468, 322250259, 3962553324, 1608629855, 2543990167, 1154254916, 389623319, 3294073796, 2817676711, 2122513534, 1028094525, 1689045092, 1575467613, 422261273, 1939203699, 1621147744, 2174228865, 1339137615, 3699352540, 577127458, 712922154, 2427141008, 2290289544, 1187679302, 3995715566, 3100863416, 339486740, 3732514782, 1591917662, 186455563, 3681988059, 3762019296, 844522546, 978220090, 169743370, 1239126601, 101321734, 611076132, 1558493276, 3260915650, 3547250131, 2901361580, 1655096418, 2443721105, 2510565781, 3828863972, 2039214713, 3878868455, 3359869896, 928607799, 1840765549, 2374762893, 3580146133, 1322425422, 2850048425, 1823791212, 1459268694, 4094161908, 3928346602, 1706019429, 2056189050, 2934523822, 135794696, 3134549946, 2022240376, 628050469, 779246638, 472135708, 2800834470, 3032970164, 3327236038, 3894660072, 3715932637, 1956440180, 522272287, 1272813131, 3185336765, 2340818315, 2323976074, 1888542832, 1044544574, 3049550261, 1722469478, 1222152264, 50660867, 4127324150, 236067854, 1638122081, 895445557, 1475980887, 3117443513, 2257655686, 3243809217, 489110045, 2662934430, 3778599393, 4162055160, 2561878936, 288563729, 1773916777, 3648039385, 2391345038, 2493985684, 2612407707, 505560094, 2274497927, 3911240169, 3460925390, 1442818645, 678973480, 3749357023, 2358182796, 2717407649, 2306869641, 219617805, 3218761151, 3862026214, 1120306242, 1756942440, 1103331905, 2578459033, 762796589, 252780047, 2966125488, 1425844308, 3151392187, 372911126]; var T4 = [1667474886, 2088535288, 2004326894, 2071694838, 4075949567, 1802223062, 1869591006, 3318043793, 808472672, 16843522, 1734846926, 724270422, 4278065639, 3621216949, 2880169549, 1987484396, 3402253711, 2189597983, 3385409673, 2105378810, 4210693615, 1499065266, 1195886990, 4042263547, 2913856577, 3570689971, 2728590687, 2947541573, 2627518243, 2762274643, 1920112356, 3233831835, 3082273397, 4261223649, 2475929149, 640051788, 909531756, 1061110142, 4160160501, 3435941763, 875846760, 2779116625, 3857003729, 4059105529, 1903268834, 3638064043, 825316194, 353713962, 67374088, 3351728789, 589522246, 3284360861, 404236336, 2526454071, 84217610, 2593830191, 117901582, 303183396, 2155911963, 3806477791, 3958056653, 656894286, 2998062463, 1970642922, 151591698, 2206440989, 741110872, 437923380, 454765878, 1852748508, 1515908788, 2694904667, 1381168804, 993742198, 3604373943, 3014905469, 690584402, 3823320797, 791638366, 2223281939, 1398011302, 3520161977, 0, 3991743681, 538992704, 4244381667, 2981218425, 1532751286, 1785380564, 3419096717, 3200178535, 960056178, 1246420628, 1280103576, 1482221744, 3486468741, 3503319995, 4025428677, 2863326543, 4227536621, 1128514950, 1296947098, 859002214, 2240123921, 1162203018, 4193849577, 33687044, 2139062782, 1347481760, 1010582648, 2678045221, 2829640523, 1364325282, 2745433693, 1077985408, 2408548869, 2459086143, 2644360225, 943212656, 4126475505, 3166494563, 3065430391, 3671750063, 555836226, 269496352, 4294908645, 4092792573, 3537006015, 3452783745, 202118168, 320025894, 3974901699, 1600119230, 2543297077, 1145359496, 387397934, 3301201811, 2812801621, 2122220284, 1027426170, 1684319432, 1566435258, 421079858, 1936954854, 1616945344, 2172753945, 1330631070, 3705438115, 572679748, 707427924, 2425400123, 2290647819, 1179044492, 4008585671, 3099120491, 336870440, 3739122087, 1583276732, 185277718, 3688593069, 3772791771, 842159716, 976899700, 168435220, 1229577106, 101059084, 606366792, 1549591736, 3267517855, 3553849021, 2897014595, 1650632388, 2442242105, 2509612081, 3840161747, 2038008818, 3890688725, 3368567691, 926374254, 1835907034, 2374863873, 3587531953, 1313788572, 2846482505, 1819063512, 1448540844, 4109633523, 3941213647, 1701162954, 2054852340, 2930698567, 134748176, 3132806511, 2021165296, 623210314, 774795868, 471606328, 2795958615, 3031746419, 3334885783, 3907527627, 3722280097, 1953799400, 522133822, 1263263126, 3183336545, 2341176845, 2324333839, 1886425312, 1044267644, 3048588401, 1718004428, 1212733584, 50529542, 4143317495, 235803164, 1633788866, 892690282, 1465383342, 3115962473, 2256965911, 3250673817, 488449850, 2661202215, 3789633753, 4177007595, 2560144171, 286339874, 1768537042, 3654906025, 2391705863, 2492770099, 2610673197, 505291324, 2273808917, 3924369609, 3469625735, 1431699370, 673740880, 3755965093, 2358021891, 2711746649, 2307489801, 218961690, 3217021541, 3873845719, 1111672452, 1751693520, 1094828930, 2576986153, 757954394, 252645662, 2964376443, 1414855848, 3149649517, 370555436]; var T5 = [1374988112, 2118214995, 437757123, 975658646, 1001089995, 530400753, 2902087851, 1273168787, 540080725, 2910219766, 2295101073, 4110568485, 1340463100, 3307916247, 641025152, 3043140495, 3736164937, 632953703, 1172967064, 1576976609, 3274667266, 2169303058, 2370213795, 1809054150, 59727847, 361929877, 3211623147, 2505202138, 3569255213, 1484005843, 1239443753, 2395588676, 1975683434, 4102977912, 2572697195, 666464733, 3202437046, 4035489047, 3374361702, 2110667444, 1675577880, 3843699074, 2538681184, 1649639237, 2976151520, 3144396420, 4269907996, 4178062228, 1883793496, 2403728665, 2497604743, 1383856311, 2876494627, 1917518562, 3810496343, 1716890410, 3001755655, 800440835, 2261089178, 3543599269, 807962610, 599762354, 33778362, 3977675356, 2328828971, 2809771154, 4077384432, 1315562145, 1708848333, 101039829, 3509871135, 3299278474, 875451293, 2733856160, 92987698, 2767645557, 193195065, 1080094634, 1584504582, 3178106961, 1042385657, 2531067453, 3711829422, 1306967366, 2438237621, 1908694277, 67556463, 1615861247, 429456164, 3602770327, 2302690252, 1742315127, 2968011453, 126454664, 3877198648, 2043211483, 2709260871, 2084704233, 4169408201, 0, 159417987, 841739592, 504459436, 1817866830, 4245618683, 260388950, 1034867998, 908933415, 168810852, 1750902305, 2606453969, 607530554, 202008497, 2472011535, 3035535058, 463180190, 2160117071, 1641816226, 1517767529, 470948374, 3801332234, 3231722213, 1008918595, 303765277, 235474187, 4069246893, 766945465, 337553864, 1475418501, 2943682380, 4003061179, 2743034109, 4144047775, 1551037884, 1147550661, 1543208500, 2336434550, 3408119516, 3069049960, 3102011747, 3610369226, 1113818384, 328671808, 2227573024, 2236228733, 3535486456, 2935566865, 3341394285, 496906059, 3702665459, 226906860, 2009195472, 733156972, 2842737049, 294930682, 1206477858, 2835123396, 2700099354, 1451044056, 573804783, 2269728455, 3644379585, 2362090238, 2564033334, 2801107407, 2776292904, 3669462566, 1068351396, 742039012, 1350078989, 1784663195, 1417561698, 4136440770, 2430122216, 775550814, 2193862645, 2673705150, 1775276924, 1876241833, 3475313331, 3366754619, 270040487, 3902563182, 3678124923, 3441850377, 1851332852, 3969562369, 2203032232, 3868552805, 2868897406, 566021896, 4011190502, 3135740889, 1248802510, 3936291284, 699432150, 832877231, 708780849, 3332740144, 899835584, 1951317047, 4236429990, 3767586992, 866637845, 4043610186, 1106041591, 2144161806, 395441711, 1984812685, 1139781709, 3433712980, 3835036895, 2664543715, 1282050075, 3240894392, 1181045119, 2640243204, 25965917, 4203181171, 4211818798, 3009879386, 2463879762, 3910161971, 1842759443, 2597806476, 933301370, 1509430414, 3943906441, 3467192302, 3076639029, 3776767469, 2051518780, 2631065433, 1441952575, 404016761, 1942435775, 1408749034, 1610459739, 3745345300, 2017778566, 3400528769, 3110650942, 941896748, 3265478751, 371049330, 3168937228, 675039627, 4279080257, 967311729, 135050206, 3635733660, 1683407248, 2076935265, 3576870512, 1215061108, 3501741890]; var T6 = [1347548327, 1400783205, 3273267108, 2520393566, 3409685355, 4045380933, 2880240216, 2471224067, 1428173050, 4138563181, 2441661558, 636813900, 4233094615, 3620022987, 2149987652, 2411029155, 1239331162, 1730525723, 2554718734, 3781033664, 46346101, 310463728, 2743944855, 3328955385, 3875770207, 2501218972, 3955191162, 3667219033, 768917123, 3545789473, 692707433, 1150208456, 1786102409, 2029293177, 1805211710, 3710368113, 3065962831, 401639597, 1724457132, 3028143674, 409198410, 2196052529, 1620529459, 1164071807, 3769721975, 2226875310, 486441376, 2499348523, 1483753576, 428819965, 2274680428, 3075636216, 598438867, 3799141122, 1474502543, 711349675, 129166120, 53458370, 2592523643, 2782082824, 4063242375, 2988687269, 3120694122, 1559041666, 730517276, 2460449204, 4042459122, 2706270690, 3446004468, 3573941694, 533804130, 2328143614, 2637442643, 2695033685, 839224033, 1973745387, 957055980, 2856345839, 106852767, 1371368976, 4181598602, 1033297158, 2933734917, 1179510461, 3046200461, 91341917, 1862534868, 4284502037, 605657339, 2547432937, 3431546947, 2003294622, 3182487618, 2282195339, 954669403, 3682191598, 1201765386, 3917234703, 3388507166, 0, 2198438022, 1211247597, 2887651696, 1315723890, 4227665663, 1443857720, 507358933, 657861945, 1678381017, 560487590, 3516619604, 975451694, 2970356327, 261314535, 3535072918, 2652609425, 1333838021, 2724322336, 1767536459, 370938394, 182621114, 3854606378, 1128014560, 487725847, 185469197, 2918353863, 3106780840, 3356761769, 2237133081, 1286567175, 3152976349, 4255350624, 2683765030, 3160175349, 3309594171, 878443390, 1988838185, 3704300486, 1756818940, 1673061617, 3403100636, 272786309, 1075025698, 545572369, 2105887268, 4174560061, 296679730, 1841768865, 1260232239, 4091327024, 3960309330, 3497509347, 1814803222, 2578018489, 4195456072, 575138148, 3299409036, 446754879, 3629546796, 4011996048, 3347532110, 3252238545, 4270639778, 915985419, 3483825537, 681933534, 651868046, 2755636671, 3828103837, 223377554, 2607439820, 1649704518, 3270937875, 3901806776, 1580087799, 4118987695, 3198115200, 2087309459, 2842678573, 3016697106, 1003007129, 2802849917, 1860738147, 2077965243, 164439672, 4100872472, 32283319, 2827177882, 1709610350, 2125135846, 136428751, 3874428392, 3652904859, 3460984630, 3572145929, 3593056380, 2939266226, 824852259, 818324884, 3224740454, 930369212, 2801566410, 2967507152, 355706840, 1257309336, 4148292826, 243256656, 790073846, 2373340630, 1296297904, 1422699085, 3756299780, 3818836405, 457992840, 3099667487, 2135319889, 77422314, 1560382517, 1945798516, 788204353, 1521706781, 1385356242, 870912086, 325965383, 2358957921, 2050466060, 2388260884, 2313884476, 4006521127, 901210569, 3990953189, 1014646705, 1503449823, 1062597235, 2031621326, 3212035895, 3931371469, 1533017514, 350174575, 2256028891, 2177544179, 1052338372, 741876788, 1606591296, 1914052035, 213705253, 2334669897, 1107234197, 1899603969, 3725069491, 2631447780, 2422494913, 1635502980, 1893020342, 1950903388, 1120974935]; var T7 = [2807058932, 1699970625, 2764249623, 1586903591, 1808481195, 1173430173, 1487645946, 59984867, 4199882800, 1844882806, 1989249228, 1277555970, 3623636965, 3419915562, 1149249077, 2744104290, 1514790577, 459744698, 244860394, 3235995134, 1963115311, 4027744588, 2544078150, 4190530515, 1608975247, 2627016082, 2062270317, 1507497298, 2200818878, 567498868, 1764313568, 3359936201, 2305455554, 2037970062, 1047239e3, 1910319033, 1337376481, 2904027272, 2892417312, 984907214, 1243112415, 830661914, 861968209, 2135253587, 2011214180, 2927934315, 2686254721, 731183368, 1750626376, 4246310725, 1820824798, 4172763771, 3542330227, 48394827, 2404901663, 2871682645, 671593195, 3254988725, 2073724613, 145085239, 2280796200, 2779915199, 1790575107, 2187128086, 472615631, 3029510009, 4075877127, 3802222185, 4107101658, 3201631749, 1646252340, 4270507174, 1402811438, 1436590835, 3778151818, 3950355702, 3963161475, 4020912224, 2667994737, 273792366, 2331590177, 104699613, 95345982, 3175501286, 2377486676, 1560637892, 3564045318, 369057872, 4213447064, 3919042237, 1137477952, 2658625497, 1119727848, 2340947849, 1530455833, 4007360968, 172466556, 266959938, 516552836, 0, 2256734592, 3980931627, 1890328081, 1917742170, 4294704398, 945164165, 3575528878, 958871085, 3647212047, 2787207260, 1423022939, 775562294, 1739656202, 3876557655, 2530391278, 2443058075, 3310321856, 547512796, 1265195639, 437656594, 3121275539, 719700128, 3762502690, 387781147, 218828297, 3350065803, 2830708150, 2848461854, 428169201, 122466165, 3720081049, 1627235199, 648017665, 4122762354, 1002783846, 2117360635, 695634755, 3336358691, 4234721005, 4049844452, 3704280881, 2232435299, 574624663, 287343814, 612205898, 1039717051, 840019705, 2708326185, 793451934, 821288114, 1391201670, 3822090177, 376187827, 3113855344, 1224348052, 1679968233, 2361698556, 1058709744, 752375421, 2431590963, 1321699145, 3519142200, 2734591178, 188127444, 2177869557, 3727205754, 2384911031, 3215212461, 2648976442, 2450346104, 3432737375, 1180849278, 331544205, 3102249176, 4150144569, 2952102595, 2159976285, 2474404304, 766078933, 313773861, 2570832044, 2108100632, 1668212892, 3145456443, 2013908262, 418672217, 3070356634, 2594734927, 1852171925, 3867060991, 3473416636, 3907448597, 2614737639, 919489135, 164948639, 2094410160, 2997825956, 590424639, 2486224549, 1723872674, 3157750862, 3399941250, 3501252752, 3625268135, 2555048196, 3673637356, 1343127501, 4130281361, 3599595085, 2957853679, 1297403050, 81781910, 3051593425, 2283490410, 532201772, 1367295589, 3926170974, 895287692, 1953757831, 1093597963, 492483431, 3528626907, 1446242576, 1192455638, 1636604631, 209336225, 344873464, 1015671571, 669961897, 3375740769, 3857572124, 2973530695, 3747192018, 1933530610, 3464042516, 935293895, 3454686199, 2858115069, 1863638845, 3683022916, 4085369519, 3292445032, 875313188, 1080017571, 3279033885, 621591778, 1233856572, 2504130317, 24197544, 3017672716, 3835484340, 3247465558, 2220981195, 3060847922, 1551124588, 1463996600]; var T8 = [4104605777, 1097159550, 396673818, 660510266, 2875968315, 2638606623, 4200115116, 3808662347, 821712160, 1986918061, 3430322568, 38544885, 3856137295, 718002117, 893681702, 1654886325, 2975484382, 3122358053, 3926825029, 4274053469, 796197571, 1290801793, 1184342925, 3556361835, 2405426947, 2459735317, 1836772287, 1381620373, 3196267988, 1948373848, 3764988233, 3385345166, 3263785589, 2390325492, 1480485785, 3111247143, 3780097726, 2293045232, 548169417, 3459953789, 3746175075, 439452389, 1362321559, 1400849762, 1685577905, 1806599355, 2174754046, 137073913, 1214797936, 1174215055, 3731654548, 2079897426, 1943217067, 1258480242, 529487843, 1437280870, 3945269170, 3049390895, 3313212038, 923313619, 679998e3, 3215307299, 57326082, 377642221, 3474729866, 2041877159, 133361907, 1776460110, 3673476453, 96392454, 878845905, 2801699524, 777231668, 4082475170, 2330014213, 4142626212, 2213296395, 1626319424, 1906247262, 1846563261, 562755902, 3708173718, 1040559837, 3871163981, 1418573201, 3294430577, 114585348, 1343618912, 2566595609, 3186202582, 1078185097, 3651041127, 3896688048, 2307622919, 425408743, 3371096953, 2081048481, 1108339068, 2216610296, 0, 2156299017, 736970802, 292596766, 1517440620, 251657213, 2235061775, 2933202493, 758720310, 265905162, 1554391400, 1532285339, 908999204, 174567692, 1474760595, 4002861748, 2610011675, 3234156416, 3693126241, 2001430874, 303699484, 2478443234, 2687165888, 585122620, 454499602, 151849742, 2345119218, 3064510765, 514443284, 4044981591, 1963412655, 2581445614, 2137062819, 19308535, 1928707164, 1715193156, 4219352155, 1126790795, 600235211, 3992742070, 3841024952, 836553431, 1669664834, 2535604243, 3323011204, 1243905413, 3141400786, 4180808110, 698445255, 2653899549, 2989552604, 2253581325, 3252932727, 3004591147, 1891211689, 2487810577, 3915653703, 4237083816, 4030667424, 2100090966, 865136418, 1229899655, 953270745, 3399679628, 3557504664, 4118925222, 2061379749, 3079546586, 2915017791, 983426092, 2022837584, 1607244650, 2118541908, 2366882550, 3635996816, 972512814, 3283088770, 1568718495, 3499326569, 3576539503, 621982671, 2895723464, 410887952, 2623762152, 1002142683, 645401037, 1494807662, 2595684844, 1335535747, 2507040230, 4293295786, 3167684641, 367585007, 3885750714, 1865862730, 2668221674, 2960971305, 2763173681, 1059270954, 2777952454, 2724642869, 1320957812, 2194319100, 2429595872, 2815956275, 77089521, 3973773121, 3444575871, 2448830231, 1305906550, 4021308739, 2857194700, 2516901860, 3518358430, 1787304780, 740276417, 1699839814, 1592394909, 2352307457, 2272556026, 188821243, 1729977011, 3687994002, 274084841, 3594982253, 3613494426, 2701949495, 4162096729, 322734571, 2837966542, 1640576439, 484830689, 1202797690, 3537852828, 4067639125, 349075736, 3342319475, 4157467219, 4255800159, 1030690015, 1155237496, 2951971274, 1757691577, 607398968, 2738905026, 499347990, 3794078908, 1011452712, 227885567, 2818666809, 213114376, 3034881240, 1455525988, 3414450555, 850817237, 1817998408, 3092726480]; var U1 = [0, 235474187, 470948374, 303765277, 941896748, 908933415, 607530554, 708780849, 1883793496, 2118214995, 1817866830, 1649639237, 1215061108, 1181045119, 1417561698, 1517767529, 3767586992, 4003061179, 4236429990, 4069246893, 3635733660, 3602770327, 3299278474, 3400528769, 2430122216, 2664543715, 2362090238, 2193862645, 2835123396, 2801107407, 3035535058, 3135740889, 3678124923, 3576870512, 3341394285, 3374361702, 3810496343, 3977675356, 4279080257, 4043610186, 2876494627, 2776292904, 3076639029, 3110650942, 2472011535, 2640243204, 2403728665, 2169303058, 1001089995, 899835584, 666464733, 699432150, 59727847, 226906860, 530400753, 294930682, 1273168787, 1172967064, 1475418501, 1509430414, 1942435775, 2110667444, 1876241833, 1641816226, 2910219766, 2743034109, 2976151520, 3211623147, 2505202138, 2606453969, 2302690252, 2269728455, 3711829422, 3543599269, 3240894392, 3475313331, 3843699074, 3943906441, 4178062228, 4144047775, 1306967366, 1139781709, 1374988112, 1610459739, 1975683434, 2076935265, 1775276924, 1742315127, 1034867998, 866637845, 566021896, 800440835, 92987698, 193195065, 429456164, 395441711, 1984812685, 2017778566, 1784663195, 1683407248, 1315562145, 1080094634, 1383856311, 1551037884, 101039829, 135050206, 437757123, 337553864, 1042385657, 807962610, 573804783, 742039012, 2531067453, 2564033334, 2328828971, 2227573024, 2935566865, 2700099354, 3001755655, 3168937228, 3868552805, 3902563182, 4203181171, 4102977912, 3736164937, 3501741890, 3265478751, 3433712980, 1106041591, 1340463100, 1576976609, 1408749034, 2043211483, 2009195472, 1708848333, 1809054150, 832877231, 1068351396, 766945465, 599762354, 159417987, 126454664, 361929877, 463180190, 2709260871, 2943682380, 3178106961, 3009879386, 2572697195, 2538681184, 2236228733, 2336434550, 3509871135, 3745345300, 3441850377, 3274667266, 3910161971, 3877198648, 4110568485, 4211818798, 2597806476, 2497604743, 2261089178, 2295101073, 2733856160, 2902087851, 3202437046, 2968011453, 3936291284, 3835036895, 4136440770, 4169408201, 3535486456, 3702665459, 3467192302, 3231722213, 2051518780, 1951317047, 1716890410, 1750902305, 1113818384, 1282050075, 1584504582, 1350078989, 168810852, 67556463, 371049330, 404016761, 841739592, 1008918595, 775550814, 540080725, 3969562369, 3801332234, 4035489047, 4269907996, 3569255213, 3669462566, 3366754619, 3332740144, 2631065433, 2463879762, 2160117071, 2395588676, 2767645557, 2868897406, 3102011747, 3069049960, 202008497, 33778362, 270040487, 504459436, 875451293, 975658646, 675039627, 641025152, 2084704233, 1917518562, 1615861247, 1851332852, 1147550661, 1248802510, 1484005843, 1451044056, 933301370, 967311729, 733156972, 632953703, 260388950, 25965917, 328671808, 496906059, 1206477858, 1239443753, 1543208500, 1441952575, 2144161806, 1908694277, 1675577880, 1842759443, 3610369226, 3644379585, 3408119516, 3307916247, 4011190502, 3776767469, 4077384432, 4245618683, 2809771154, 2842737049, 3144396420, 3043140495, 2673705150, 2438237621, 2203032232, 2370213795]; var U2 = [0, 185469197, 370938394, 487725847, 741876788, 657861945, 975451694, 824852259, 1483753576, 1400783205, 1315723890, 1164071807, 1950903388, 2135319889, 1649704518, 1767536459, 2967507152, 3152976349, 2801566410, 2918353863, 2631447780, 2547432937, 2328143614, 2177544179, 3901806776, 3818836405, 4270639778, 4118987695, 3299409036, 3483825537, 3535072918, 3652904859, 2077965243, 1893020342, 1841768865, 1724457132, 1474502543, 1559041666, 1107234197, 1257309336, 598438867, 681933534, 901210569, 1052338372, 261314535, 77422314, 428819965, 310463728, 3409685355, 3224740454, 3710368113, 3593056380, 3875770207, 3960309330, 4045380933, 4195456072, 2471224067, 2554718734, 2237133081, 2388260884, 3212035895, 3028143674, 2842678573, 2724322336, 4138563181, 4255350624, 3769721975, 3955191162, 3667219033, 3516619604, 3431546947, 3347532110, 2933734917, 2782082824, 3099667487, 3016697106, 2196052529, 2313884476, 2499348523, 2683765030, 1179510461, 1296297904, 1347548327, 1533017514, 1786102409, 1635502980, 2087309459, 2003294622, 507358933, 355706840, 136428751, 53458370, 839224033, 957055980, 605657339, 790073846, 2373340630, 2256028891, 2607439820, 2422494913, 2706270690, 2856345839, 3075636216, 3160175349, 3573941694, 3725069491, 3273267108, 3356761769, 4181598602, 4063242375, 4011996048, 3828103837, 1033297158, 915985419, 730517276, 545572369, 296679730, 446754879, 129166120, 213705253, 1709610350, 1860738147, 1945798516, 2029293177, 1239331162, 1120974935, 1606591296, 1422699085, 4148292826, 4233094615, 3781033664, 3931371469, 3682191598, 3497509347, 3446004468, 3328955385, 2939266226, 2755636671, 3106780840, 2988687269, 2198438022, 2282195339, 2501218972, 2652609425, 1201765386, 1286567175, 1371368976, 1521706781, 1805211710, 1620529459, 2105887268, 1988838185, 533804130, 350174575, 164439672, 46346101, 870912086, 954669403, 636813900, 788204353, 2358957921, 2274680428, 2592523643, 2441661558, 2695033685, 2880240216, 3065962831, 3182487618, 3572145929, 3756299780, 3270937875, 3388507166, 4174560061, 4091327024, 4006521127, 3854606378, 1014646705, 930369212, 711349675, 560487590, 272786309, 457992840, 106852767, 223377554, 1678381017, 1862534868, 1914052035, 2031621326, 1211247597, 1128014560, 1580087799, 1428173050, 32283319, 182621114, 401639597, 486441376, 768917123, 651868046, 1003007129, 818324884, 1503449823, 1385356242, 1333838021, 1150208456, 1973745387, 2125135846, 1673061617, 1756818940, 2970356327, 3120694122, 2802849917, 2887651696, 2637442643, 2520393566, 2334669897, 2149987652, 3917234703, 3799141122, 4284502037, 4100872472, 3309594171, 3460984630, 3545789473, 3629546796, 2050466060, 1899603969, 1814803222, 1730525723, 1443857720, 1560382517, 1075025698, 1260232239, 575138148, 692707433, 878443390, 1062597235, 243256656, 91341917, 409198410, 325965383, 3403100636, 3252238545, 3704300486, 3620022987, 3874428392, 3990953189, 4042459122, 4227665663, 2460449204, 2578018489, 2226875310, 2411029155, 3198115200, 3046200461, 2827177882, 2743944855]; var U3 = [0, 218828297, 437656594, 387781147, 875313188, 958871085, 775562294, 590424639, 1750626376, 1699970625, 1917742170, 2135253587, 1551124588, 1367295589, 1180849278, 1265195639, 3501252752, 3720081049, 3399941250, 3350065803, 3835484340, 3919042237, 4270507174, 4085369519, 3102249176, 3051593425, 2734591178, 2952102595, 2361698556, 2177869557, 2530391278, 2614737639, 3145456443, 3060847922, 2708326185, 2892417312, 2404901663, 2187128086, 2504130317, 2555048196, 3542330227, 3727205754, 3375740769, 3292445032, 3876557655, 3926170974, 4246310725, 4027744588, 1808481195, 1723872674, 1910319033, 2094410160, 1608975247, 1391201670, 1173430173, 1224348052, 59984867, 244860394, 428169201, 344873464, 935293895, 984907214, 766078933, 547512796, 1844882806, 1627235199, 2011214180, 2062270317, 1507497298, 1423022939, 1137477952, 1321699145, 95345982, 145085239, 532201772, 313773861, 830661914, 1015671571, 731183368, 648017665, 3175501286, 2957853679, 2807058932, 2858115069, 2305455554, 2220981195, 2474404304, 2658625497, 3575528878, 3625268135, 3473416636, 3254988725, 3778151818, 3963161475, 4213447064, 4130281361, 3599595085, 3683022916, 3432737375, 3247465558, 3802222185, 4020912224, 4172763771, 4122762354, 3201631749, 3017672716, 2764249623, 2848461854, 2331590177, 2280796200, 2431590963, 2648976442, 104699613, 188127444, 472615631, 287343814, 840019705, 1058709744, 671593195, 621591778, 1852171925, 1668212892, 1953757831, 2037970062, 1514790577, 1463996600, 1080017571, 1297403050, 3673637356, 3623636965, 3235995134, 3454686199, 4007360968, 3822090177, 4107101658, 4190530515, 2997825956, 3215212461, 2830708150, 2779915199, 2256734592, 2340947849, 2627016082, 2443058075, 172466556, 122466165, 273792366, 492483431, 1047239e3, 861968209, 612205898, 695634755, 1646252340, 1863638845, 2013908262, 1963115311, 1446242576, 1530455833, 1277555970, 1093597963, 1636604631, 1820824798, 2073724613, 1989249228, 1436590835, 1487645946, 1337376481, 1119727848, 164948639, 81781910, 331544205, 516552836, 1039717051, 821288114, 669961897, 719700128, 2973530695, 3157750862, 2871682645, 2787207260, 2232435299, 2283490410, 2667994737, 2450346104, 3647212047, 3564045318, 3279033885, 3464042516, 3980931627, 3762502690, 4150144569, 4199882800, 3070356634, 3121275539, 2904027272, 2686254721, 2200818878, 2384911031, 2570832044, 2486224549, 3747192018, 3528626907, 3310321856, 3359936201, 3950355702, 3867060991, 4049844452, 4234721005, 1739656202, 1790575107, 2108100632, 1890328081, 1402811438, 1586903591, 1233856572, 1149249077, 266959938, 48394827, 369057872, 418672217, 1002783846, 919489135, 567498868, 752375421, 209336225, 24197544, 376187827, 459744698, 945164165, 895287692, 574624663, 793451934, 1679968233, 1764313568, 2117360635, 1933530610, 1343127501, 1560637892, 1243112415, 1192455638, 3704280881, 3519142200, 3336358691, 3419915562, 3907448597, 3857572124, 4075877127, 4294704398, 3029510009, 3113855344, 2927934315, 2744104290, 2159976285, 2377486676, 2594734927, 2544078150]; var U4 = [0, 151849742, 303699484, 454499602, 607398968, 758720310, 908999204, 1059270954, 1214797936, 1097159550, 1517440620, 1400849762, 1817998408, 1699839814, 2118541908, 2001430874, 2429595872, 2581445614, 2194319100, 2345119218, 3034881240, 3186202582, 2801699524, 2951971274, 3635996816, 3518358430, 3399679628, 3283088770, 4237083816, 4118925222, 4002861748, 3885750714, 1002142683, 850817237, 698445255, 548169417, 529487843, 377642221, 227885567, 77089521, 1943217067, 2061379749, 1640576439, 1757691577, 1474760595, 1592394909, 1174215055, 1290801793, 2875968315, 2724642869, 3111247143, 2960971305, 2405426947, 2253581325, 2638606623, 2487810577, 3808662347, 3926825029, 4044981591, 4162096729, 3342319475, 3459953789, 3576539503, 3693126241, 1986918061, 2137062819, 1685577905, 1836772287, 1381620373, 1532285339, 1078185097, 1229899655, 1040559837, 923313619, 740276417, 621982671, 439452389, 322734571, 137073913, 19308535, 3871163981, 4021308739, 4104605777, 4255800159, 3263785589, 3414450555, 3499326569, 3651041127, 2933202493, 2815956275, 3167684641, 3049390895, 2330014213, 2213296395, 2566595609, 2448830231, 1305906550, 1155237496, 1607244650, 1455525988, 1776460110, 1626319424, 2079897426, 1928707164, 96392454, 213114376, 396673818, 514443284, 562755902, 679998e3, 865136418, 983426092, 3708173718, 3557504664, 3474729866, 3323011204, 4180808110, 4030667424, 3945269170, 3794078908, 2507040230, 2623762152, 2272556026, 2390325492, 2975484382, 3092726480, 2738905026, 2857194700, 3973773121, 3856137295, 4274053469, 4157467219, 3371096953, 3252932727, 3673476453, 3556361835, 2763173681, 2915017791, 3064510765, 3215307299, 2156299017, 2307622919, 2459735317, 2610011675, 2081048481, 1963412655, 1846563261, 1729977011, 1480485785, 1362321559, 1243905413, 1126790795, 878845905, 1030690015, 645401037, 796197571, 274084841, 425408743, 38544885, 188821243, 3613494426, 3731654548, 3313212038, 3430322568, 4082475170, 4200115116, 3780097726, 3896688048, 2668221674, 2516901860, 2366882550, 2216610296, 3141400786, 2989552604, 2837966542, 2687165888, 1202797690, 1320957812, 1437280870, 1554391400, 1669664834, 1787304780, 1906247262, 2022837584, 265905162, 114585348, 499347990, 349075736, 736970802, 585122620, 972512814, 821712160, 2595684844, 2478443234, 2293045232, 2174754046, 3196267988, 3079546586, 2895723464, 2777952454, 3537852828, 3687994002, 3234156416, 3385345166, 4142626212, 4293295786, 3841024952, 3992742070, 174567692, 57326082, 410887952, 292596766, 777231668, 660510266, 1011452712, 893681702, 1108339068, 1258480242, 1343618912, 1494807662, 1715193156, 1865862730, 1948373848, 2100090966, 2701949495, 2818666809, 3004591147, 3122358053, 2235061775, 2352307457, 2535604243, 2653899549, 3915653703, 3764988233, 4219352155, 4067639125, 3444575871, 3294430577, 3746175075, 3594982253, 836553431, 953270745, 600235211, 718002117, 367585007, 484830689, 133361907, 251657213, 2041877159, 1891211689, 1806599355, 1654886325, 1568718495, 1418573201, 1335535747, 1184342925]; function convertToInt32(bytes) { var result = []; for (var i2 = 0; i2 < bytes.length; i2 += 4) { result.push( bytes[i2] << 24 | bytes[i2 + 1] << 16 | bytes[i2 + 2] << 8 | bytes[i2 + 3] ); } return result; } var AES = function(key2) { if (!(this instanceof AES)) { throw Error("AES must be instanitated with `new`"); } Object.defineProperty(this, "key", { value: coerceArray(key2, true) }); this._prepare(); }; AES.prototype._prepare = function() { var rounds = numberOfRounds[this.key.length]; if (rounds == null) { throw new Error("invalid key size (must be 16, 24 or 32 bytes)"); } this._Ke = []; this._Kd = []; for (var i2 = 0; i2 <= rounds; i2++) { this._Ke.push([0, 0, 0, 0]); this._Kd.push([0, 0, 0, 0]); } var roundKeyCount = (rounds + 1) * 4; var KC = this.key.length / 4; var tk = convertToInt32(this.key); var index; for (var i2 = 0; i2 < KC; i2++) { index = i2 >> 2; this._Ke[index][i2 % 4] = tk[i2]; this._Kd[rounds - index][i2 % 4] = tk[i2]; } var rconpointer = 0; var t2 = KC, tt; while (t2 < roundKeyCount) { tt = tk[KC - 1]; tk[0] ^= S2[tt >> 16 & 255] << 24 ^ S2[tt >> 8 & 255] << 16 ^ S2[tt & 255] << 8 ^ S2[tt >> 24 & 255] ^ rcon[rconpointer] << 24; rconpointer += 1; if (KC != 8) { for (var i2 = 1; i2 < KC; i2++) { tk[i2] ^= tk[i2 - 1]; } } else { for (var i2 = 1; i2 < KC / 2; i2++) { tk[i2] ^= tk[i2 - 1]; } tt = tk[KC / 2 - 1]; tk[KC / 2] ^= S2[tt & 255] ^ S2[tt >> 8 & 255] << 8 ^ S2[tt >> 16 & 255] << 16 ^ S2[tt >> 24 & 255] << 24; for (var i2 = KC / 2 + 1; i2 < KC; i2++) { tk[i2] ^= tk[i2 - 1]; } } var i2 = 0, r2, c2; while (i2 < KC && t2 < roundKeyCount) { r2 = t2 >> 2; c2 = t2 % 4; this._Ke[r2][c2] = tk[i2]; this._Kd[rounds - r2][c2] = tk[i2++]; t2++; } } for (var r2 = 1; r2 < rounds; r2++) { for (var c2 = 0; c2 < 4; c2++) { tt = this._Kd[r2][c2]; this._Kd[r2][c2] = U1[tt >> 24 & 255] ^ U2[tt >> 16 & 255] ^ U3[tt >> 8 & 255] ^ U4[tt & 255]; } } }; AES.prototype.encrypt = function(plaintext) { if (plaintext.length != 16) { throw new Error("invalid plaintext size (must be 16 bytes)"); } var rounds = this._Ke.length - 1; var a2 = [0, 0, 0, 0]; var t2 = convertToInt32(plaintext); for (var i2 = 0; i2 < 4; i2++) { t2[i2] ^= this._Ke[0][i2]; } for (var r2 = 1; r2 < rounds; r2++) { for (var i2 = 0; i2 < 4; i2++) { a2[i2] = T1[t2[i2] >> 24 & 255] ^ T2[t2[(i2 + 1) % 4] >> 16 & 255] ^ T3[t2[(i2 + 2) % 4] >> 8 & 255] ^ T4[t2[(i2 + 3) % 4] & 255] ^ this._Ke[r2][i2]; } t2 = a2.slice(); } var result = createArray(16), tt; for (var i2 = 0; i2 < 4; i2++) { tt = this._Ke[rounds][i2]; result[4 * i2] = (S2[t2[i2] >> 24 & 255] ^ tt >> 24) & 255; result[4 * i2 + 1] = (S2[t2[(i2 + 1) % 4] >> 16 & 255] ^ tt >> 16) & 255; result[4 * i2 + 2] = (S2[t2[(i2 + 2) % 4] >> 8 & 255] ^ tt >> 8) & 255; result[4 * i2 + 3] = (S2[t2[(i2 + 3) % 4] & 255] ^ tt) & 255; } return result; }; AES.prototype.decrypt = function(ciphertext) { if (ciphertext.length != 16) { throw new Error("invalid ciphertext size (must be 16 bytes)"); } var rounds = this._Kd.length - 1; var a2 = [0, 0, 0, 0]; var t2 = convertToInt32(ciphertext); for (var i2 = 0; i2 < 4; i2++) { t2[i2] ^= this._Kd[0][i2]; } for (var r2 = 1; r2 < rounds; r2++) { for (var i2 = 0; i2 < 4; i2++) { a2[i2] = T5[t2[i2] >> 24 & 255] ^ T6[t2[(i2 + 3) % 4] >> 16 & 255] ^ T7[t2[(i2 + 2) % 4] >> 8 & 255] ^ T8[t2[(i2 + 1) % 4] & 255] ^ this._Kd[r2][i2]; } t2 = a2.slice(); } var result = createArray(16), tt; for (var i2 = 0; i2 < 4; i2++) { tt = this._Kd[rounds][i2]; result[4 * i2] = (Si[t2[i2] >> 24 & 255] ^ tt >> 24) & 255; result[4 * i2 + 1] = (Si[t2[(i2 + 3) % 4] >> 16 & 255] ^ tt >> 16) & 255; result[4 * i2 + 2] = (Si[t2[(i2 + 2) % 4] >> 8 & 255] ^ tt >> 8) & 255; result[4 * i2 + 3] = (Si[t2[(i2 + 1) % 4] & 255] ^ tt) & 255; } return result; }; var ModeOfOperationECB = function(key2) { if (!(this instanceof ModeOfOperationECB)) { throw Error("AES must be instanitated with `new`"); } this.description = "Electronic Code Block"; this.name = "ecb"; this._aes = new AES(key2); }; ModeOfOperationECB.prototype.encrypt = function(plaintext) { plaintext = coerceArray(plaintext); if (plaintext.length % 16 !== 0) { throw new Error("invalid plaintext size (must be multiple of 16 bytes)"); } var ciphertext = createArray(plaintext.length); var block = createArray(16); for (var i2 = 0; i2 < plaintext.length; i2 += 16) { copyArray(plaintext, block, 0, i2, i2 + 16); block = this._aes.encrypt(block); copyArray(block, ciphertext, i2); } return ciphertext; }; ModeOfOperationECB.prototype.decrypt = function(ciphertext) { ciphertext = coerceArray(ciphertext); if (ciphertext.length % 16 !== 0) { throw new Error("invalid ciphertext size (must be multiple of 16 bytes)"); } var plaintext = createArray(ciphertext.length); var block = createArray(16); for (var i2 = 0; i2 < ciphertext.length; i2 += 16) { copyArray(ciphertext, block, 0, i2, i2 + 16); block = this._aes.decrypt(block); copyArray(block, plaintext, i2); } return plaintext; }; var ModeOfOperationCBC = function(key2, iv) { if (!(this instanceof ModeOfOperationCBC)) { throw Error("AES must be instanitated with `new`"); } this.description = "Cipher Block Chaining"; this.name = "cbc"; if (!iv) { iv = createArray(16); } else if (iv.length != 16) { throw new Error("invalid initialation vector size (must be 16 bytes)"); } this._lastCipherblock = coerceArray(iv, true); this._aes = new AES(key2); }; ModeOfOperationCBC.prototype.encrypt = function(plaintext) { plaintext = coerceArray(plaintext); if (plaintext.length % 16 !== 0) { throw new Error("invalid plaintext size (must be multiple of 16 bytes)"); } var ciphertext = createArray(plaintext.length); var block = createArray(16); for (var i2 = 0; i2 < plaintext.length; i2 += 16) { copyArray(plaintext, block, 0, i2, i2 + 16); for (var j2 = 0; j2 < 16; j2++) { block[j2] ^= this._lastCipherblock[j2]; } this._lastCipherblock = this._aes.encrypt(block); copyArray(this._lastCipherblock, ciphertext, i2); } return ciphertext; }; ModeOfOperationCBC.prototype.decrypt = function(ciphertext) { ciphertext = coerceArray(ciphertext); if (ciphertext.length % 16 !== 0) { throw new Error("invalid ciphertext size (must be multiple of 16 bytes)"); } var plaintext = createArray(ciphertext.length); var block = createArray(16); for (var i2 = 0; i2 < ciphertext.length; i2 += 16) { copyArray(ciphertext, block, 0, i2, i2 + 16); block = this._aes.decrypt(block); for (var j2 = 0; j2 < 16; j2++) { plaintext[i2 + j2] = block[j2] ^ this._lastCipherblock[j2]; } copyArray(ciphertext, this._lastCipherblock, 0, i2, i2 + 16); } return plaintext; }; var ModeOfOperationCFB = function(key2, iv, segmentSize) { if (!(this instanceof ModeOfOperationCFB)) { throw Error("AES must be instanitated with `new`"); } this.description = "Cipher Feedback"; this.name = "cfb"; if (!iv) { iv = createArray(16); } else if (iv.length != 16) { throw new Error("invalid initialation vector size (must be 16 size)"); } if (!segmentSize) { segmentSize = 1; } this.segmentSize = segmentSize; this._shiftRegister = coerceArray(iv, true); this._aes = new AES(key2); }; ModeOfOperationCFB.prototype.encrypt = function(plaintext) { if (plaintext.length % this.segmentSize != 0) { throw new Error("invalid plaintext size (must be segmentSize bytes)"); } var encrypted = coerceArray(plaintext, true); var xorSegment; for (var i2 = 0; i2 < encrypted.length; i2 += this.segmentSize) { xorSegment = this._aes.encrypt(this._shiftRegister); for (var j2 = 0; j2 < this.segmentSize; j2++) { encrypted[i2 + j2] ^= xorSegment[j2]; } copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i2, i2 + this.segmentSize); } return encrypted; }; ModeOfOperationCFB.prototype.decrypt = function(ciphertext) { if (ciphertext.length % this.segmentSize != 0) { throw new Error("invalid ciphertext size (must be segmentSize bytes)"); } var plaintext = coerceArray(ciphertext, true); var xorSegment; for (var i2 = 0; i2 < plaintext.length; i2 += this.segmentSize) { xorSegment = this._aes.encrypt(this._shiftRegister); for (var j2 = 0; j2 < this.segmentSize; j2++) { plaintext[i2 + j2] ^= xorSegment[j2]; } copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i2, i2 + this.segmentSize); } return plaintext; }; var ModeOfOperationOFB = function(key2, iv) { if (!(this instanceof ModeOfOperationOFB)) { throw Error("AES must be instanitated with `new`"); } this.description = "Output Feedback"; this.name = "ofb"; if (!iv) { iv = createArray(16); } else if (iv.length != 16) { throw new Error("invalid initialation vector size (must be 16 bytes)"); } this._lastPrecipher = coerceArray(iv, true); this._lastPrecipherIndex = 16; this._aes = new AES(key2); }; ModeOfOperationOFB.prototype.encrypt = function(plaintext) { var encrypted = coerceArray(plaintext, true); for (var i2 = 0; i2 < encrypted.length; i2++) { if (this._lastPrecipherIndex === 16) { this._lastPrecipher = this._aes.encrypt(this._lastPrecipher); this._lastPrecipherIndex = 0; } encrypted[i2] ^= this._lastPrecipher[this._lastPrecipherIndex++]; } return encrypted; }; ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt; var Counter = function(initialValue) { if (!(this instanceof Counter)) { throw Error("Counter must be instanitated with `new`"); } if (initialValue !== 0 && !initialValue) { initialValue = 1; } if (typeof initialValue === "number") { this._counter = createArray(16); this.setValue(initialValue); } else { this.setBytes(initialValue); } }; Counter.prototype.setValue = function(value) { if (typeof value !== "number" || parseInt(value) != value) { throw new Error("invalid counter value (must be an integer)"); } for (var index = 15; index >= 0; --index) { this._counter[index] = value % 256; value = value >> 8; } }; Counter.prototype.setBytes = function(bytes) { bytes = coerceArray(bytes, true); if (bytes.length != 16) { throw new Error("invalid counter bytes size (must be 16 bytes)"); } this._counter = bytes; }; Counter.prototype.increment = function() { for (var i2 = 15; i2 >= 0; i2--) { if (this._counter[i2] === 255) { this._counter[i2] = 0; } else { this._counter[i2]++; break; } } }; var ModeOfOperationCTR = function(key2, counter) { if (!(this instanceof ModeOfOperationCTR)) { throw Error("AES must be instanitated with `new`"); } this.description = "Counter"; this.name = "ctr"; if (!(counter instanceof Counter)) { counter = new Counter(counter); } this._counter = counter; this._remainingCounter = null; this._remainingCounterIndex = 16; this._aes = new AES(key2); }; ModeOfOperationCTR.prototype.encrypt = function(plaintext) { var encrypted = coerceArray(plaintext, true); for (var i2 = 0; i2 < encrypted.length; i2++) { if (this._remainingCounterIndex === 16) { this._remainingCounter = this._aes.encrypt(this._counter._counter); this._remainingCounterIndex = 0; this._counter.increment(); } encrypted[i2] ^= this._remainingCounter[this._remainingCounterIndex++]; } return encrypted; }; ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt; function pkcs7pad(data) { data = coerceArray(data, true); var padder = 16 - data.length % 16; var result = createArray(data.length + padder); copyArray(data, result); for (var i2 = data.length; i2 < result.length; i2++) { result[i2] = padder; } return result; } function pkcs7strip(data) { data = coerceArray(data, true); if (data.length < 16) { throw new Error("PKCS#7 invalid length"); } var padder = data[data.length - 1]; if (padder > 16) { throw new Error("PKCS#7 padding byte out of range"); } var length = data.length - padder; for (var i2 = 0; i2 < padder; i2++) { if (data[length + i2] !== padder) { throw new Error("PKCS#7 invalid padding byte"); } } var result = createArray(length); copyArray(data, result, 0, 0, length); return result; } var aesjs = { AES, Counter, ModeOfOperation: { ecb: ModeOfOperationECB, cbc: ModeOfOperationCBC, cfb: ModeOfOperationCFB, ofb: ModeOfOperationOFB, ctr: ModeOfOperationCTR }, utils: { hex: convertHex, utf8: convertUtf8 }, padding: { pkcs7: { pad: pkcs7pad, strip: pkcs7strip } }, _arrayTest: { coerceArray, createArray, copyArray } }; { module.exports = aesjs; } })(); })(aesJs); const aes = aesJsExports; const version$7 = "json-wallets/5.7.0"; function looseArrayify(hexString) { if (typeof hexString === "string" && hexString.substring(0, 2) !== "0x") { hexString = "0x" + hexString; } return arrayify(hexString); } function zpad(value, length) { value = String(value); while (value.length < length) { value = "0" + value; } return value; } function getPassword(password) { if (typeof password === "string") { return toUtf8Bytes(password, UnicodeNormalizationForm.NFKC); } return arrayify(password); } function searchPath(object, path) { let currentChild = object; const comps = path.toLowerCase().split("/"); for (let i2 = 0; i2 < comps.length; i2++) { let matchingChild = null; for (const key2 in currentChild) { if (key2.toLowerCase() === comps[i2]) { matchingChild = currentChild[key2]; break; } } if (matchingChild === null) { return null; } currentChild = matchingChild; } return currentChild; } function uuidV4(randomBytes2) { const bytes = arrayify(randomBytes2); bytes[6] = bytes[6] & 15 | 64; bytes[8] = bytes[8] & 63 | 128; const value = hexlify(bytes); return [ value.substring(2, 10), value.substring(10, 14), value.substring(14, 18), value.substring(18, 22), value.substring(22, 34) ].join("-"); } const logger$d = new Logger(version$7); class CrowdsaleAccount extends Description { isCrowdsaleAccount(value) { return !!(value && value._isCrowdsaleAccount); } } function decrypt$1(json, password) { const data = JSON.parse(json); password = getPassword(password); const ethaddr = getAddress(searchPath(data, "ethaddr")); const encseed = looseArrayify(searchPath(data, "encseed")); if (!encseed || encseed.length % 16 !== 0) { logger$d.throwArgumentError("invalid encseed", "json", json); } const key2 = arrayify(pbkdf2$1(password, password, 2e3, 32, "sha256")).slice(0, 16); const iv = encseed.slice(0, 16); const encryptedSeed = encseed.slice(16); const aesCbc = new aes.ModeOfOperation.cbc(key2, iv); const seed = aes.padding.pkcs7.strip(arrayify(aesCbc.decrypt(encryptedSeed))); let seedHex = ""; for (let i2 = 0; i2 < seed.length; i2++) { seedHex += String.fromCharCode(seed[i2]); } const seedHexBytes = toUtf8Bytes(seedHex); const privateKey = keccak256$1(seedHexBytes); return new CrowdsaleAccount({ _isCrowdsaleAccount: true, address: ethaddr, privateKey }); } function isCrowdsaleWallet(json) { let data = null; try { data = JSON.parse(json); } catch (error) { return false; } return data.encseed && data.ethaddr; } function isKeystoreWallet(json) { let data = null; try { data = JSON.parse(json); } catch (error) { return false; } if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) { return false; } return true; } function getJsonWalletAddress(json) { if (isCrowdsaleWallet(json)) { try { return getAddress(JSON.parse(json).ethaddr); } catch (error) { return null; } } if (isKeystoreWallet(json)) { try { return getAddress(JSON.parse(json).address); } catch (error) { return null; } } return null; } var scryptExports = {}; var scrypt$1 = { get exports() { return scryptExports; }, set exports(v2) { scryptExports = v2; } }; (function(module, exports) { (function(root) { const MAX_VALUE = 2147483647; function SHA2562(m2) { const K2 = new Uint32Array([ 1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298 ]); let h0 = 1779033703, h1 = 3144134277, h2 = 1013904242, h3 = 2773480762; let h4 = 1359893119, h5 = 2600822924, h6 = 528734635, h7 = 1541459225; const w = new Uint32Array(64); function blocks(p3) { let off = 0, len = p3.length; while (len >= 64) { let a2 = h0, b2 = h1, c2 = h2, d2 = h3, e = h4, f2 = h5, g2 = h6, h8 = h7, u, i3, j2, t1, t2; for (i3 = 0; i3 < 16; i3++) { j2 = off + i3 * 4; w[i3] = (p3[j2] & 255) << 24 | (p3[j2 + 1] & 255) << 16 | (p3[j2 + 2] & 255) << 8 | p3[j2 + 3] & 255; } for (i3 = 16; i3 < 64; i3++) { u = w[i3 - 2]; t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10; u = w[i3 - 15]; t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3; w[i3] = (t1 + w[i3 - 7] | 0) + (t2 + w[i3 - 16] | 0) | 0; } for (i3 = 0; i3 < 64; i3++) { t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f2 ^ ~e & g2) | 0) + (h8 + (K2[i3] + w[i3] | 0) | 0) | 0; t2 = ((a2 >>> 2 | a2 << 32 - 2) ^ (a2 >>> 13 | a2 << 32 - 13) ^ (a2 >>> 22 | a2 << 32 - 22)) + (a2 & b2 ^ a2 & c2 ^ b2 & c2) | 0; h8 = g2; g2 = f2; f2 = e; e = d2 + t1 | 0; d2 = c2; c2 = b2; b2 = a2; a2 = t1 + t2 | 0; } h0 = h0 + a2 | 0; h1 = h1 + b2 | 0; h2 = h2 + c2 | 0; h3 = h3 + d2 | 0; h4 = h4 + e | 0; h5 = h5 + f2 | 0; h6 = h6 + g2 | 0; h7 = h7 + h8 | 0; off += 64; len -= 64; } } blocks(m2); let i2, bytesLeft = m2.length % 64, bitLenHi = m2.length / 536870912 | 0, bitLenLo = m2.length << 3, numZeros = bytesLeft < 56 ? 56 : 120, p2 = m2.slice(m2.length - bytesLeft, m2.length); p2.push(128); for (i2 = bytesLeft + 1; i2 < numZeros; i2++) { p2.push(0); } p2.push(bitLenHi >>> 24 & 255); p2.push(bitLenHi >>> 16 & 255); p2.push(bitLenHi >>> 8 & 255); p2.push(bitLenHi >>> 0 & 255); p2.push(bitLenLo >>> 24 & 255); p2.push(bitLenLo >>> 16 & 255); p2.push(bitLenLo >>> 8 & 255); p2.push(bitLenLo >>> 0 & 255); blocks(p2); return [ h0 >>> 24 & 255, h0 >>> 16 & 255, h0 >>> 8 & 255, h0 >>> 0 & 255, h1 >>> 24 & 255, h1 >>> 16 & 255, h1 >>> 8 & 255, h1 >>> 0 & 255, h2 >>> 24 & 255, h2 >>> 16 & 255, h2 >>> 8 & 255, h2 >>> 0 & 255, h3 >>> 24 & 255, h3 >>> 16 & 255, h3 >>> 8 & 255, h3 >>> 0 & 255, h4 >>> 24 & 255, h4 >>> 16 & 255, h4 >>> 8 & 255, h4 >>> 0 & 255, h5 >>> 24 & 255, h5 >>> 16 & 255, h5 >>> 8 & 255, h5 >>> 0 & 255, h6 >>> 24 & 255, h6 >>> 16 & 255, h6 >>> 8 & 255, h6 >>> 0 & 255, h7 >>> 24 & 255, h7 >>> 16 & 255, h7 >>> 8 & 255, h7 >>> 0 & 255 ]; } function PBKDF2_HMAC_SHA256_OneIter(password, salt, dkLen) { password = password.length <= 64 ? password : SHA2562(password); const innerLen = 64 + salt.length + 4; const inner = new Array(innerLen); const outerKey = new Array(64); let i2; let dk = []; for (i2 = 0; i2 < 64; i2++) { inner[i2] = 54; } for (i2 = 0; i2 < password.length; i2++) { inner[i2] ^= password[i2]; } for (i2 = 0; i2 < salt.length; i2++) { inner[64 + i2] = salt[i2]; } for (i2 = innerLen - 4; i2 < innerLen; i2++) { inner[i2] = 0; } for (i2 = 0; i2 < 64; i2++) outerKey[i2] = 92; for (i2 = 0; i2 < password.length; i2++) outerKey[i2] ^= password[i2]; function incrementCounter() { for (let i3 = innerLen - 1; i3 >= innerLen - 4; i3--) { inner[i3]++; if (inner[i3] <= 255) return; inner[i3] = 0; } } while (dkLen >= 32) { incrementCounter(); dk = dk.concat(SHA2562(outerKey.concat(SHA2562(inner)))); dkLen -= 32; } if (dkLen > 0) { incrementCounter(); dk = dk.concat(SHA2562(outerKey.concat(SHA2562(inner))).slice(0, dkLen)); } return dk; } function blockmix_salsa8(BY, Yi, r2, x, _X) { let i2; arraycopy(BY, (2 * r2 - 1) * 16, _X, 0, 16); for (i2 = 0; i2 < 2 * r2; i2++) { blockxor(BY, i2 * 16, _X, 16); salsa20_8(_X, x); arraycopy(_X, 0, BY, Yi + i2 * 16, 16); } for (i2 = 0; i2 < r2; i2++) { arraycopy(BY, Yi + i2 * 2 * 16, BY, i2 * 16, 16); } for (i2 = 0; i2 < r2; i2++) { arraycopy(BY, Yi + (i2 * 2 + 1) * 16, BY, (i2 + r2) * 16, 16); } } function R(a2, b2) { return a2 << b2 | a2 >>> 32 - b2; } function salsa20_8(B, x) { arraycopy(B, 0, x, 0, 16); for (let i2 = 8; i2 > 0; i2 -= 2) { x[4] ^= R(x[0] + x[12], 7); x[8] ^= R(x[4] + x[0], 9); x[12] ^= R(x[8] + x[4], 13); x[0] ^= R(x[12] + x[8], 18); x[9] ^= R(x[5] + x[1], 7); x[13] ^= R(x[9] + x[5], 9); x[1] ^= R(x[13] + x[9], 13); x[5] ^= R(x[1] + x[13], 18); x[14] ^= R(x[10] + x[6], 7); x[2] ^= R(x[14] + x[10], 9); x[6] ^= R(x[2] + x[14], 13); x[10] ^= R(x[6] + x[2], 18); x[3] ^= R(x[15] + x[11], 7); x[7] ^= R(x[3] + x[15], 9); x[11] ^= R(x[7] + x[3], 13); x[15] ^= R(x[11] + x[7], 18); x[1] ^= R(x[0] + x[3], 7); x[2] ^= R(x[1] + x[0], 9); x[3] ^= R(x[2] + x[1], 13); x[0] ^= R(x[3] + x[2], 18); x[6] ^= R(x[5] + x[4], 7); x[7] ^= R(x[6] + x[5], 9); x[4] ^= R(x[7] + x[6], 13); x[5] ^= R(x[4] + x[7], 18); x[11] ^= R(x[10] + x[9], 7); x[8] ^= R(x[11] + x[10], 9); x[9] ^= R(x[8] + x[11], 13); x[10] ^= R(x[9] + x[8], 18); x[12] ^= R(x[15] + x[14], 7); x[13] ^= R(x[12] + x[15], 9); x[14] ^= R(x[13] + x[12], 13); x[15] ^= R(x[14] + x[13], 18); } for (let i2 = 0; i2 < 16; ++i2) { B[i2] += x[i2]; } } function blockxor(S2, Si, D, len) { for (let i2 = 0; i2 < len; i2++) { D[i2] ^= S2[Si + i2]; } } function arraycopy(src, srcPos, dest, destPos, length) { while (length--) { dest[destPos++] = src[srcPos++]; } } function checkBufferish(o) { if (!o || typeof o.length !== "number") { return false; } for (let i2 = 0; i2 < o.length; i2++) { const v2 = o[i2]; if (typeof v2 !== "number" || v2 % 1 || v2 < 0 || v2 >= 256) { return false; } } return true; } function ensureInteger(value, name) { if (typeof value !== "number" || value % 1) { throw new Error("invalid " + name); } return value; } function _scrypt(password, salt, N2, r2, p2, dkLen, callback) { N2 = ensureInteger(N2, "N"); r2 = ensureInteger(r2, "r"); p2 = ensureInteger(p2, "p"); dkLen = ensureInteger(dkLen, "dkLen"); if (N2 === 0 || (N2 & N2 - 1) !== 0) { throw new Error("N must be power of 2"); } if (N2 > MAX_VALUE / 128 / r2) { throw new Error("N too large"); } if (r2 > MAX_VALUE / 128 / p2) { throw new Error("r too large"); } if (!checkBufferish(password)) { throw new Error("password must be an array or buffer"); } password = Array.prototype.slice.call(password); if (!checkBufferish(salt)) { throw new Error("salt must be an array or buffer"); } salt = Array.prototype.slice.call(salt); let b2 = PBKDF2_HMAC_SHA256_OneIter(password, salt, p2 * 128 * r2); const B = new Uint32Array(p2 * 32 * r2); for (let i2 = 0; i2 < B.length; i2++) { const j2 = i2 * 4; B[i2] = (b2[j2 + 3] & 255) << 24 | (b2[j2 + 2] & 255) << 16 | (b2[j2 + 1] & 255) << 8 | (b2[j2 + 0] & 255) << 0; } const XY = new Uint32Array(64 * r2); const V2 = new Uint32Array(32 * r2 * N2); const Yi = 32 * r2; const x = new Uint32Array(16); const _X = new Uint32Array(16); const totalOps = p2 * N2 * 2; let currentOp = 0; let lastPercent10 = null; let stop = false; let state = 0; let i0 = 0, i1; let Bi; const limit = callback ? parseInt(1e3 / r2) : 4294967295; const nextTick = typeof setImmediate !== "undefined" ? setImmediate : setTimeout; const incrementalSMix = function() { if (stop) { return callback(new Error("cancelled"), currentOp / totalOps); } let steps; switch (state) { case 0: Bi = i0 * 32 * r2; arraycopy(B, Bi, XY, 0, Yi); state = 1; i1 = 0; case 1: steps = N2 - i1; if (steps > limit) { steps = limit; } for (let i2 = 0; i2 < steps; i2++) { arraycopy(XY, 0, V2, (i1 + i2) * Yi, Yi); blockmix_salsa8(XY, Yi, r2, x, _X); } i1 += steps; currentOp += steps; if (callback) { const percent10 = parseInt(1e3 * currentOp / totalOps); if (percent10 !== lastPercent10) { stop = callback(null, currentOp / totalOps); if (stop) { break; } lastPercent10 = percent10; } } if (i1 < N2) { break; } i1 = 0; state = 2; case 2: steps = N2 - i1; if (steps > limit) { steps = limit; } for (let i2 = 0; i2 < steps; i2++) { const offset = (2 * r2 - 1) * 16; const j2 = XY[offset] & N2 - 1; blockxor(V2, j2 * Yi, XY, Yi); blockmix_salsa8(XY, Yi, r2, x, _X); } i1 += steps; currentOp += steps; if (callback) { const percent10 = parseInt(1e3 * currentOp / totalOps); if (percent10 !== lastPercent10) { stop = callback(null, currentOp / totalOps); if (stop) { break; } lastPercent10 = percent10; } } if (i1 < N2) { break; } arraycopy(XY, 0, B, Bi, Yi); i0++; if (i0 < p2) { state = 0; break; } b2 = []; for (let i2 = 0; i2 < B.length; i2++) { b2.push(B[i2] >> 0 & 255); b2.push(B[i2] >> 8 & 255); b2.push(B[i2] >> 16 & 255); b2.push(B[i2] >> 24 & 255); } const derivedKey = PBKDF2_HMAC_SHA256_OneIter(password, b2, dkLen); if (callback) { callback(null, 1, derivedKey); } return derivedKey; } if (callback) { nextTick(incrementalSMix); } }; if (!callback) { while (true) { const derivedKey = incrementalSMix(); if (derivedKey != void 0) { return derivedKey; } } } incrementalSMix(); } const lib = { scrypt: function(password, salt, N2, r2, p2, dkLen, progressCallback) { return new Promise(function(resolve, reject) { let lastProgress = 0; if (progressCallback) { progressCallback(0); } _scrypt(password, salt, N2, r2, p2, dkLen, function(error, progress, key2) { if (error) { reject(error); } else if (key2) { if (progressCallback && lastProgress !== 1) { progressCallback(1); } resolve(new Uint8Array(key2)); } else if (progressCallback && progress !== lastProgress) { lastProgress = progress; return progressCallback(progress); } }); }); }, syncScrypt: function(password, salt, N2, r2, p2, dkLen) { return new Uint8Array(_scrypt(password, salt, N2, r2, p2, dkLen)); } }; { module.exports = lib; } })(); })(scrypt$1); const scrypt = scryptExports; var __awaiter$8 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$c = new Logger(version$7); function hasMnemonic$1(value) { return value != null && value.mnemonic && value.mnemonic.phrase; } class KeystoreAccount extends Description { isKeystoreAccount(value) { return !!(value && value._isKeystoreAccount); } } function _decrypt(data, key2, ciphertext) { const cipher = searchPath(data, "crypto/cipher"); if (cipher === "aes-128-ctr") { const iv = looseArrayify(searchPath(data, "crypto/cipherparams/iv")); const counter = new aes.Counter(iv); const aesCtr = new aes.ModeOfOperation.ctr(key2, counter); return arrayify(aesCtr.decrypt(ciphertext)); } return null; } function _getAccount(data, key2) { const ciphertext = looseArrayify(searchPath(data, "crypto/ciphertext")); const computedMAC = hexlify(keccak256$1(concat([key2.slice(16, 32), ciphertext]))).substring(2); if (computedMAC !== searchPath(data, "crypto/mac").toLowerCase()) { throw new Error("invalid password"); } const privateKey = _decrypt(data, key2.slice(0, 16), ciphertext); if (!privateKey) { logger$c.throwError("unsupported cipher", Logger.errors.UNSUPPORTED_OPERATION, { operation: "decrypt" }); } const mnemonicKey = key2.slice(32, 64); const address = computeAddress(privateKey); if (data.address) { let check = data.address.toLowerCase(); if (check.substring(0, 2) !== "0x") { check = "0x" + check; } if (getAddress(check) !== address) { throw new Error("address mismatch"); } } const account = { _isKeystoreAccount: true, address, privateKey: hexlify(privateKey) }; if (searchPath(data, "x-ethers/version") === "0.1") { const mnemonicCiphertext = looseArrayify(searchPath(data, "x-ethers/mnemonicCiphertext")); const mnemonicIv = looseArrayify(searchPath(data, "x-ethers/mnemonicCounter")); const mnemonicCounter = new aes.Counter(mnemonicIv); const mnemonicAesCtr = new aes.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); const path = searchPath(data, "x-ethers/path") || defaultPath; const locale = searchPath(data, "x-ethers/locale") || "en"; const entropy = arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); try { const mnemonic = entropyToMnemonic(entropy, locale); const node = HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path); if (node.privateKey != account.privateKey) { throw new Error("mnemonic mismatch"); } account.mnemonic = node.mnemonic; } catch (error) { if (error.code !== Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") { throw error; } } } return new KeystoreAccount(account); } function pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc) { return arrayify(pbkdf2$1(passwordBytes, salt, count, dkLen, prfFunc)); } function pbkdf2(passwordBytes, salt, count, dkLen, prfFunc) { return Promise.resolve(pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc)); } function _computeKdfKey(data, password, pbkdf2Func, scryptFunc, progressCallback) { const passwordBytes = getPassword(password); const kdf = searchPath(data, "crypto/kdf"); if (kdf && typeof kdf === "string") { const throwError = function(name, value) { return logger$c.throwArgumentError("invalid key-derivation function parameters", name, value); }; if (kdf.toLowerCase() === "scrypt") { const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt")); const N2 = parseInt(searchPath(data, "crypto/kdfparams/n")); const r2 = parseInt(searchPath(data, "crypto/kdfparams/r")); const p2 = parseInt(searchPath(data, "crypto/kdfparams/p")); if (!N2 || !r2 || !p2) { throwError("kdf", kdf); } if ((N2 & N2 - 1) !== 0) { throwError("N", N2); } const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen")); if (dkLen !== 32) { throwError("dklen", dkLen); } return scryptFunc(passwordBytes, salt, N2, r2, p2, 64, progressCallback); } else if (kdf.toLowerCase() === "pbkdf2") { const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt")); let prfFunc = null; const prf = searchPath(data, "crypto/kdfparams/prf"); if (prf === "hmac-sha256") { prfFunc = "sha256"; } else if (prf === "hmac-sha512") { prfFunc = "sha512"; } else { throwError("prf", prf); } const count = parseInt(searchPath(data, "crypto/kdfparams/c")); const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen")); if (dkLen !== 32) { throwError("dklen", dkLen); } return pbkdf2Func(passwordBytes, salt, count, dkLen, prfFunc); } } return logger$c.throwArgumentError("unsupported key-derivation function", "kdf", kdf); } function decryptSync(json, password) { const data = JSON.parse(json); const key2 = _computeKdfKey(data, password, pbkdf2Sync, scrypt.syncScrypt); return _getAccount(data, key2); } function decrypt(json, password, progressCallback) { return __awaiter$8(this, void 0, void 0, function* () { const data = JSON.parse(json); const key2 = yield _computeKdfKey(data, password, pbkdf2, scrypt.scrypt, progressCallback); return _getAccount(data, key2); }); } function encrypt(account, password, options, progressCallback) { try { if (getAddress(account.address) !== computeAddress(account.privateKey)) { throw new Error("address/privateKey mismatch"); } if (hasMnemonic$1(account)) { const mnemonic = account.mnemonic; const node = HDNode.fromMnemonic(mnemonic.phrase, null, mnemonic.locale).derivePath(mnemonic.path || defaultPath); if (node.privateKey != account.privateKey) { throw new Error("mnemonic mismatch"); } } } catch (e) { return Promise.reject(e); } if (typeof options === "function" && !progressCallback) { progressCallback = options; options = {}; } if (!options) { options = {}; } const privateKey = arrayify(account.privateKey); const passwordBytes = getPassword(password); let entropy = null; let path = null; let locale = null; if (hasMnemonic$1(account)) { const srcMnemonic = account.mnemonic; entropy = arrayify(mnemonicToEntropy(srcMnemonic.phrase, srcMnemonic.locale || "en")); path = srcMnemonic.path || defaultPath; locale = srcMnemonic.locale || "en"; } let client2 = options.client; if (!client2) { client2 = "ethers.js"; } let salt = null; if (options.salt) { salt = arrayify(options.salt); } else { salt = randomBytes(32); } let iv = null; if (options.iv) { iv = arrayify(options.iv); if (iv.length !== 16) { throw new Error("invalid iv"); } } else { iv = randomBytes(16); } let uuidRandom = null; if (options.uuid) { uuidRandom = arrayify(options.uuid); if (uuidRandom.length !== 16) { throw new Error("invalid uuid"); } } else { uuidRandom = randomBytes(16); } let N2 = 1 << 17, r2 = 8, p2 = 1; if (options.scrypt) { if (options.scrypt.N) { N2 = options.scrypt.N; } if (options.scrypt.r) { r2 = options.scrypt.r; } if (options.scrypt.p) { p2 = options.scrypt.p; } } return scrypt.scrypt(passwordBytes, salt, N2, r2, p2, 64, progressCallback).then((key2) => { key2 = arrayify(key2); const derivedKey = key2.slice(0, 16); const macPrefix = key2.slice(16, 32); const mnemonicKey = key2.slice(32, 64); const counter = new aes.Counter(iv); const aesCtr = new aes.ModeOfOperation.ctr(derivedKey, counter); const ciphertext = arrayify(aesCtr.encrypt(privateKey)); const mac = keccak256$1(concat([macPrefix, ciphertext])); const data = { address: account.address.substring(2).toLowerCase(), id: uuidV4(uuidRandom), version: 3, crypto: { cipher: "aes-128-ctr", cipherparams: { iv: hexlify(iv).substring(2) }, ciphertext: hexlify(ciphertext).substring(2), kdf: "scrypt", kdfparams: { salt: hexlify(salt).substring(2), n: N2, dklen: 32, p: p2, r: r2 }, mac: mac.substring(2) } }; if (entropy) { const mnemonicIv = randomBytes(16); const mnemonicCounter = new aes.Counter(mnemonicIv); const mnemonicAesCtr = new aes.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); const mnemonicCiphertext = arrayify(mnemonicAesCtr.encrypt(entropy)); const now2 = new Date(); const timestamp = now2.getUTCFullYear() + "-" + zpad(now2.getUTCMonth() + 1, 2) + "-" + zpad(now2.getUTCDate(), 2) + "T" + zpad(now2.getUTCHours(), 2) + "-" + zpad(now2.getUTCMinutes(), 2) + "-" + zpad(now2.getUTCSeconds(), 2) + ".0Z"; data["x-ethers"] = { client: client2, gethFilename: "UTC--" + timestamp + "--" + data.address, mnemonicCounter: hexlify(mnemonicIv).substring(2), mnemonicCiphertext: hexlify(mnemonicCiphertext).substring(2), path, locale, version: "0.1" }; } return JSON.stringify(data); }); } function decryptJsonWallet(json, password, progressCallback) { if (isCrowdsaleWallet(json)) { if (progressCallback) { progressCallback(0); } const account = decrypt$1(json, password); if (progressCallback) { progressCallback(1); } return Promise.resolve(account); } if (isKeystoreWallet(json)) { return decrypt(json, password, progressCallback); } return Promise.reject(new Error("invalid JSON wallet")); } function decryptJsonWalletSync(json, password) { if (isCrowdsaleWallet(json)) { return decrypt$1(json, password); } if (isKeystoreWallet(json)) { return decryptSync(json, password); } throw new Error("invalid JSON wallet"); } const lib_esm$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, decryptCrowdsale: decrypt$1, decryptJsonWallet, decryptJsonWalletSync, decryptKeystore: decrypt, decryptKeystoreSync: decryptSync, encryptKeystore: encrypt, getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet }, Symbol.toStringTag, { value: "Module" })); const version$6 = "wallet/5.7.0"; var __awaiter$7 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$b = new Logger(version$6); function isAccount(value) { return value != null && isHexString(value.privateKey, 32) && value.address != null; } function hasMnemonic(value) { const mnemonic = value.mnemonic; return mnemonic && mnemonic.phrase; } class Wallet extends Signer { constructor(privateKey, provider) { super(); if (isAccount(privateKey)) { const signingKey = new SigningKey(privateKey.privateKey); defineReadOnly(this, "_signingKey", () => signingKey); defineReadOnly(this, "address", computeAddress(this.publicKey)); if (this.address !== getAddress(privateKey.address)) { logger$b.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDACTED]"); } if (hasMnemonic(privateKey)) { const srcMnemonic = privateKey.mnemonic; defineReadOnly(this, "_mnemonic", () => ({ phrase: srcMnemonic.phrase, path: srcMnemonic.path || defaultPath, locale: srcMnemonic.locale || "en" })); const mnemonic = this.mnemonic; const node = HDNode.fromMnemonic(mnemonic.phrase, null, mnemonic.locale).derivePath(mnemonic.path); if (computeAddress(node.privateKey) !== this.address) { logger$b.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDACTED]"); } } else { defineReadOnly(this, "_mnemonic", () => null); } } else { if (SigningKey.isSigningKey(privateKey)) { if (privateKey.curve !== "secp256k1") { logger$b.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); } defineReadOnly(this, "_signingKey", () => privateKey); } else { if (typeof privateKey === "string") { if (privateKey.match(/^[0-9a-f]*$/i) && privateKey.length === 64) { privateKey = "0x" + privateKey; } } const signingKey = new SigningKey(privateKey); defineReadOnly(this, "_signingKey", () => signingKey); } defineReadOnly(this, "_mnemonic", () => null); defineReadOnly(this, "address", computeAddress(this.publicKey)); } if (provider && !Provider.isProvider(provider)) { logger$b.throwArgumentError("invalid provider", "provider", provider); } defineReadOnly(this, "provider", provider || null); } get mnemonic() { return this._mnemonic(); } get privateKey() { return this._signingKey().privateKey; } get publicKey() { return this._signingKey().publicKey; } getAddress() { return Promise.resolve(this.address); } connect(provider) { return new Wallet(this, provider); } signTransaction(transaction) { return resolveProperties(transaction).then((tx) => { if (tx.from != null) { if (getAddress(tx.from) !== this.address) { logger$b.throwArgumentError("transaction from address mismatch", "transaction.from", transaction.from); } delete tx.from; } const signature2 = this._signingKey().signDigest(keccak256$1(serialize$2(tx))); return serialize$2(tx, signature2); }); } signMessage(message) { return __awaiter$7(this, void 0, void 0, function* () { return joinSignature(this._signingKey().signDigest(hashMessage(message))); }); } _signTypedData(domain, types, value) { return __awaiter$7(this, void 0, void 0, function* () { const populated = yield TypedDataEncoder.resolveNames(domain, types, value, (name) => { if (this.provider == null) { logger$b.throwError("cannot resolve ENS names without a provider", Logger.errors.UNSUPPORTED_OPERATION, { operation: "resolveName", value: name }); } return this.provider.resolveName(name); }); return joinSignature(this._signingKey().signDigest(TypedDataEncoder.hash(populated.domain, types, populated.value))); }); } encrypt(password, options, progressCallback) { if (typeof options === "function" && !progressCallback) { progressCallback = options; options = {}; } if (progressCallback && typeof progressCallback !== "function") { throw new Error("invalid callback"); } if (!options) { options = {}; } return encrypt(this, password, options, progressCallback); } /** * Static methods to create Wallet instances. */ static createRandom(options) { let entropy = randomBytes(16); if (!options) { options = {}; } if (options.extraEntropy) { entropy = arrayify(hexDataSlice(keccak256$1(concat([entropy, options.extraEntropy])), 0, 16)); } const mnemonic = entropyToMnemonic(entropy, options.locale); return Wallet.fromMnemonic(mnemonic, options.path, options.locale); } static fromEncryptedJson(json, password, progressCallback) { return decryptJsonWallet(json, password, progressCallback).then((account) => { return new Wallet(account); }); } static fromEncryptedJsonSync(json, password) { return new Wallet(decryptJsonWalletSync(json, password)); } static fromMnemonic(mnemonic, path, wordlist2) { if (!path) { path = defaultPath; } return new Wallet(HDNode.fromMnemonic(mnemonic, null, wordlist2).derivePath(path)); } } function verifyMessage(message, signature2) { return recoverAddress(hashMessage(message), signature2); } function verifyTypedData(domain, types, value, signature2) { return recoverAddress(TypedDataEncoder.hash(domain, types, value), signature2); } const lib_esm$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, Wallet, verifyMessage, verifyTypedData }, Symbol.toStringTag, { value: "Module" })); const version$5 = "networks/5.7.1"; const logger$a = new Logger(version$5); function isRenetworkable(value) { return value && typeof value.renetwork === "function"; } function ethDefaultProvider(network) { const func = function(providers, options) { if (options == null) { options = {}; } const providerList = []; if (providers.InfuraProvider && options.infura !== "-") { try { providerList.push(new providers.InfuraProvider(network, options.infura)); } catch (error) { } } if (providers.EtherscanProvider && options.etherscan !== "-") { try { providerList.push(new providers.EtherscanProvider(network, options.etherscan)); } catch (error) { } } if (providers.AlchemyProvider && options.alchemy !== "-") { try { providerList.push(new providers.AlchemyProvider(network, options.alchemy)); } catch (error) { } } if (providers.PocketProvider && options.pocket !== "-") { const skip = ["goerli", "ropsten", "rinkeby", "sepolia"]; try { const provider = new providers.PocketProvider(network, options.pocket); if (provider.network && skip.indexOf(provider.network.name) === -1) { providerList.push(provider); } } catch (error) { } } if (providers.CloudflareProvider && options.cloudflare !== "-") { try { providerList.push(new providers.CloudflareProvider(network)); } catch (error) { } } if (providers.AnkrProvider && options.ankr !== "-") { try { const skip = ["ropsten"]; const provider = new providers.AnkrProvider(network, options.ankr); if (provider.network && skip.indexOf(provider.network.name) === -1) { providerList.push(provider); } } catch (error) { } } if (providerList.length === 0) { return null; } if (providers.FallbackProvider) { let quorum = 1; if (options.quorum != null) { quorum = options.quorum; } else if (network === "homestead") { quorum = 2; } return new providers.FallbackProvider(providerList, quorum); } return providerList[0]; }; func.renetwork = function(network2) { return ethDefaultProvider(network2); }; return func; } function etcDefaultProvider(url, network) { const func = function(providers, options) { if (providers.JsonRpcProvider) { return new providers.JsonRpcProvider(url, network); } return null; }; func.renetwork = function(network2) { return etcDefaultProvider(url, network2); }; return func; } const homestead = { chainId: 1, ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", name: "homestead", _defaultProvider: ethDefaultProvider("homestead") }; const ropsten = { chainId: 3, ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", name: "ropsten", _defaultProvider: ethDefaultProvider("ropsten") }; const classicMordor = { chainId: 63, name: "classicMordor", _defaultProvider: etcDefaultProvider("https://www.ethercluster.com/mordor", "classicMordor") }; const networks = { unspecified: { chainId: 0, name: "unspecified" }, homestead, mainnet: homestead, morden: { chainId: 2, name: "morden" }, ropsten, testnet: ropsten, rinkeby: { chainId: 4, ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", name: "rinkeby", _defaultProvider: ethDefaultProvider("rinkeby") }, kovan: { chainId: 42, name: "kovan", _defaultProvider: ethDefaultProvider("kovan") }, goerli: { chainId: 5, ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", name: "goerli", _defaultProvider: ethDefaultProvider("goerli") }, kintsugi: { chainId: 1337702, name: "kintsugi" }, sepolia: { chainId: 11155111, name: "sepolia", _defaultProvider: ethDefaultProvider("sepolia") }, // ETC (See: #351) classic: { chainId: 61, name: "classic", _defaultProvider: etcDefaultProvider("https://www.ethercluster.com/etc", "classic") }, classicMorden: { chainId: 62, name: "classicMorden" }, classicMordor, classicTestnet: classicMordor, classicKotti: { chainId: 6, name: "classicKotti", _defaultProvider: etcDefaultProvider("https://www.ethercluster.com/kotti", "classicKotti") }, xdai: { chainId: 100, name: "xdai" }, matic: { chainId: 137, name: "matic", _defaultProvider: ethDefaultProvider("matic") }, maticmum: { chainId: 80001, name: "maticmum" }, optimism: { chainId: 10, name: "optimism", _defaultProvider: ethDefaultProvider("optimism") }, "optimism-kovan": { chainId: 69, name: "optimism-kovan" }, "optimism-goerli": { chainId: 420, name: "optimism-goerli" }, arbitrum: { chainId: 42161, name: "arbitrum" }, "arbitrum-rinkeby": { chainId: 421611, name: "arbitrum-rinkeby" }, "arbitrum-goerli": { chainId: 421613, name: "arbitrum-goerli" }, bnb: { chainId: 56, name: "bnb" }, bnbt: { chainId: 97, name: "bnbt" } }; function getNetwork$1(network) { if (network == null) { return null; } if (typeof network === "number") { for (const name in networks) { const standard2 = networks[name]; if (standard2.chainId === network) { return { name: standard2.name, chainId: standard2.chainId, ensAddress: standard2.ensAddress || null, _defaultProvider: standard2._defaultProvider || null }; } } return { chainId: network, name: "unknown" }; } if (typeof network === "string") { const standard2 = networks[network]; if (standard2 == null) { return null; } return { name: standard2.name, chainId: standard2.chainId, ensAddress: standard2.ensAddress, _defaultProvider: standard2._defaultProvider || null }; } const standard = networks[network.name]; if (!standard) { if (typeof network.chainId !== "number") { logger$a.throwArgumentError("invalid network chainId", "network", network); } return network; } if (network.chainId !== 0 && network.chainId !== standard.chainId) { logger$a.throwArgumentError("network chainId mismatch", "network", network); } let defaultProvider = network._defaultProvider || null; if (defaultProvider == null && standard._defaultProvider) { if (isRenetworkable(standard._defaultProvider)) { defaultProvider = standard._defaultProvider.renetwork(network); } else { defaultProvider = standard._defaultProvider; } } return { name: network.name, chainId: standard.chainId, ensAddress: network.ensAddress || standard.ensAddress || null, _defaultProvider: defaultProvider }; } const version$4 = "web/5.7.1"; var __awaiter$6 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; function getUrl(href, options) { return __awaiter$6(this, void 0, void 0, function* () { if (options == null) { options = {}; } const request = { method: options.method || "GET", headers: options.headers || {}, body: options.body || void 0 }; if (options.skipFetchSetup !== true) { request.mode = "cors"; request.cache = "no-cache"; request.credentials = "same-origin"; request.redirect = "follow"; request.referrer = "client"; } if (options.fetchOptions != null) { const opts = options.fetchOptions; if (opts.mode) { request.mode = opts.mode; } if (opts.cache) { request.cache = opts.cache; } if (opts.credentials) { request.credentials = opts.credentials; } if (opts.redirect) { request.redirect = opts.redirect; } if (opts.referrer) { request.referrer = opts.referrer; } } const response = yield fetch(href, request); const body = yield response.arrayBuffer(); const headers = {}; if (response.headers.forEach) { response.headers.forEach((value, key2) => { headers[key2.toLowerCase()] = value; }); } else { response.headers.keys().forEach((key2) => { headers[key2.toLowerCase()] = response.headers.get(key2); }); } return { headers, statusCode: response.status, statusMessage: response.statusText, body: arrayify(new Uint8Array(body)) }; }); } var __awaiter$5 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$9 = new Logger(version$4); function staller(duration) { return new Promise((resolve) => { setTimeout(resolve, duration); }); } function bodyify(value, type) { if (value == null) { return null; } if (typeof value === "string") { return value; } if (isBytesLike(value)) { if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) { try { return toUtf8String(value); } catch (error) { } } return hexlify(value); } return value; } function unpercent(value) { return toUtf8Bytes(value.replace(/%([0-9a-f][0-9a-f])/gi, (all, code2) => { return String.fromCharCode(parseInt(code2, 16)); })); } function _fetchData(connection, body, processFunc) { const attemptLimit = typeof connection === "object" && connection.throttleLimit != null ? connection.throttleLimit : 12; logger$9.assertArgument(attemptLimit > 0 && attemptLimit % 1 === 0, "invalid connection throttle limit", "connection.throttleLimit", attemptLimit); const throttleCallback = typeof connection === "object" ? connection.throttleCallback : null; const throttleSlotInterval = typeof connection === "object" && typeof connection.throttleSlotInterval === "number" ? connection.throttleSlotInterval : 100; logger$9.assertArgument(throttleSlotInterval > 0 && throttleSlotInterval % 1 === 0, "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval); const errorPassThrough = typeof connection === "object" ? !!connection.errorPassThrough : false; const headers = {}; let url = null; const options = { method: "GET" }; let allow304 = false; let timeout = 2 * 60 * 1e3; if (typeof connection === "string") { url = connection; } else if (typeof connection === "object") { if (connection == null || connection.url == null) { logger$9.throwArgumentError("missing URL", "connection.url", connection); } url = connection.url; if (typeof connection.timeout === "number" && connection.timeout > 0) { timeout = connection.timeout; } if (connection.headers) { for (const key2 in connection.headers) { headers[key2.toLowerCase()] = { key: key2, value: String(connection.headers[key2]) }; if (["if-none-match", "if-modified-since"].indexOf(key2.toLowerCase()) >= 0) { allow304 = true; } } } options.allowGzip = !!connection.allowGzip; if (connection.user != null && connection.password != null) { if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) { logger$9.throwError("basic authentication requires a secure https url", Logger.errors.INVALID_ARGUMENT, { argument: "url", url, user: connection.user, password: "[REDACTED]" }); } const authorization = connection.user + ":" + connection.password; headers["authorization"] = { key: "Authorization", value: "Basic " + encode$1(toUtf8Bytes(authorization)) }; } if (connection.skipFetchSetup != null) { options.skipFetchSetup = !!connection.skipFetchSetup; } if (connection.fetchOptions != null) { options.fetchOptions = shallowCopy(connection.fetchOptions); } } const reData = new RegExp("^data:([^;:]*)?(;base64)?,(.*)$", "i"); const dataMatch = url ? url.match(reData) : null; if (dataMatch) { try { const response = { statusCode: 200, statusMessage: "OK", headers: { "content-type": dataMatch[1] || "text/plain" }, body: dataMatch[2] ? decode$1(dataMatch[3]) : unpercent(dataMatch[3]) }; let result = response.body; if (processFunc) { result = processFunc(response.body, response); } return Promise.resolve(result); } catch (error) { logger$9.throwError("processing response error", Logger.errors.SERVER_ERROR, { body: bodyify(dataMatch[1], dataMatch[2]), error, requestBody: null, requestMethod: "GET", url }); } } if (body) { options.method = "POST"; options.body = body; if (headers["content-type"] == null) { headers["content-type"] = { key: "Content-Type", value: "application/octet-stream" }; } if (headers["content-length"] == null) { headers["content-length"] = { key: "Content-Length", value: String(body.length) }; } } const flatHeaders = {}; Object.keys(headers).forEach((key2) => { const header = headers[key2]; flatHeaders[header.key] = header.value; }); options.headers = flatHeaders; const runningTimeout = function() { let timer2 = null; const promise = new Promise(function(resolve, reject) { if (timeout) { timer2 = setTimeout(() => { if (timer2 == null) { return; } timer2 = null; reject(logger$9.makeError("timeout", Logger.errors.TIMEOUT, { requestBody: bodyify(options.body, flatHeaders["content-type"]), requestMethod: options.method, timeout, url })); }, timeout); } }); const cancel = function() { if (timer2 == null) { return; } clearTimeout(timer2); timer2 = null; }; return { promise, cancel }; }(); const runningFetch = function() { return __awaiter$5(this, void 0, void 0, function* () { for (let attempt = 0; attempt < attemptLimit; attempt++) { let response = null; try { response = yield getUrl(url, options); if (attempt < attemptLimit) { if (response.statusCode === 301 || response.statusCode === 302) { const location = response.headers.location || ""; if (options.method === "GET" && location.match(/^https:/)) { url = response.headers.location; continue; } } else if (response.statusCode === 429) { let tryAgain = true; if (throttleCallback) { tryAgain = yield throttleCallback(attempt, url); } if (tryAgain) { let stall2 = 0; const retryAfter = response.headers["retry-after"]; if (typeof retryAfter === "string" && retryAfter.match(/^[1-9][0-9]*$/)) { stall2 = parseInt(retryAfter) * 1e3; } else { stall2 = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt))); } yield staller(stall2); continue; } } } } catch (error) { response = error.response; if (response == null) { runningTimeout.cancel(); logger$9.throwError("missing response", Logger.errors.SERVER_ERROR, { requestBody: bodyify(options.body, flatHeaders["content-type"]), requestMethod: options.method, serverError: error, url }); } } let body2 = response.body; if (allow304 && response.statusCode === 304) { body2 = null; } else if (!errorPassThrough && (response.statusCode < 200 || response.statusCode >= 300)) { runningTimeout.cancel(); logger$9.throwError("bad response", Logger.errors.SERVER_ERROR, { status: response.statusCode, headers: response.headers, body: bodyify(body2, response.headers ? response.headers["content-type"] : null), requestBody: bodyify(options.body, flatHeaders["content-type"]), requestMethod: options.method, url }); } if (processFunc) { try { const result = yield processFunc(body2, response); runningTimeout.cancel(); return result; } catch (error) { if (error.throttleRetry && attempt < attemptLimit) { let tryAgain = true; if (throttleCallback) { tryAgain = yield throttleCallback(attempt, url); } if (tryAgain) { const timeout2 = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt))); yield staller(timeout2); continue; } } runningTimeout.cancel(); logger$9.throwError("processing response error", Logger.errors.SERVER_ERROR, { body: bodyify(body2, response.headers ? response.headers["content-type"] : null), error, requestBody: bodyify(options.body, flatHeaders["content-type"]), requestMethod: options.method, url }); } } runningTimeout.cancel(); return body2; } return logger$9.throwError("failed response", Logger.errors.SERVER_ERROR, { requestBody: bodyify(options.body, flatHeaders["content-type"]), requestMethod: options.method, url }); }); }(); return Promise.race([runningTimeout.promise, runningFetch]); } function fetchJson(connection, json, processFunc) { let processJsonFunc = (value, response) => { let result = null; if (value != null) { try { result = JSON.parse(toUtf8String(value)); } catch (error) { logger$9.throwError("invalid JSON", Logger.errors.SERVER_ERROR, { body: value, error }); } } if (processFunc) { result = processFunc(result, response); } return result; }; let body = null; if (json != null) { body = toUtf8Bytes(json); const updated = typeof connection === "string" ? { url: connection } : shallowCopy(connection); if (updated.headers) { const hasContentType = Object.keys(updated.headers).filter((k2) => k2.toLowerCase() === "content-type").length !== 0; if (!hasContentType) { updated.headers = shallowCopy(updated.headers); updated.headers["content-type"] = "application/json"; } } else { updated.headers = { "content-type": "application/json" }; } connection = updated; } return _fetchData(connection, body, processJsonFunc); } function poll(func, options) { if (!options) { options = {}; } options = shallowCopy(options); if (options.floor == null) { options.floor = 0; } if (options.ceiling == null) { options.ceiling = 1e4; } if (options.interval == null) { options.interval = 250; } return new Promise(function(resolve, reject) { let timer2 = null; let done = false; const cancel = () => { if (done) { return false; } done = true; if (timer2) { clearTimeout(timer2); } return true; }; if (options.timeout) { timer2 = setTimeout(() => { if (cancel()) { reject(new Error("timeout")); } }, options.timeout); } const retryLimit = options.retryLimit; let attempt = 0; function check() { return func().then(function(result) { if (result !== void 0) { if (cancel()) { resolve(result); } } else if (options.oncePoll) { options.oncePoll.once("poll", check); } else if (options.onceBlock) { options.onceBlock.once("block", check); } else if (!done) { attempt++; if (attempt > retryLimit) { if (cancel()) { reject(new Error("retry limit reached")); } return; } let timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt))); if (timeout < options.floor) { timeout = options.floor; } if (timeout > options.ceiling) { timeout = options.ceiling; } setTimeout(check, timeout); } return null; }, function(error) { if (cancel()) { reject(error); } }); } check(); }); } const lib_esm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, _fetchData, fetchJson, poll }, Symbol.toStringTag, { value: "Module" })); var ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; var ALPHABET_MAP = {}; for (var z = 0; z < ALPHABET.length; z++) { var x = ALPHABET.charAt(z); if (ALPHABET_MAP[x] !== void 0) throw new TypeError(x + " is ambiguous"); ALPHABET_MAP[x] = z; } function polymodStep(pre) { var b2 = pre >> 25; return (pre & 33554431) << 5 ^ -(b2 >> 0 & 1) & 996825010 ^ -(b2 >> 1 & 1) & 642813549 ^ -(b2 >> 2 & 1) & 513874426 ^ -(b2 >> 3 & 1) & 1027748829 ^ -(b2 >> 4 & 1) & 705979059; } function prefixChk(prefix) { var chk = 1; for (var i2 = 0; i2 < prefix.length; ++i2) { var c2 = prefix.charCodeAt(i2); if (c2 < 33 || c2 > 126) return "Invalid prefix (" + prefix + ")"; chk = polymodStep(chk) ^ c2 >> 5; } chk = polymodStep(chk); for (i2 = 0; i2 < prefix.length; ++i2) { var v2 = prefix.charCodeAt(i2); chk = polymodStep(chk) ^ v2 & 31; } return chk; } function encode2(prefix, words2, LIMIT) { LIMIT = LIMIT || 90; if (prefix.length + 7 + words2.length > LIMIT) throw new TypeError("Exceeds length limit"); prefix = prefix.toLowerCase(); var chk = prefixChk(prefix); if (typeof chk === "string") throw new Error(chk); var result = prefix + "1"; for (var i2 = 0; i2 < words2.length; ++i2) { var x = words2[i2]; if (x >> 5 !== 0) throw new Error("Non 5-bit word"); chk = polymodStep(chk) ^ x; result += ALPHABET.charAt(x); } for (i2 = 0; i2 < 6; ++i2) { chk = polymodStep(chk); } chk ^= 1; for (i2 = 0; i2 < 6; ++i2) { var v2 = chk >> (5 - i2) * 5 & 31; result += ALPHABET.charAt(v2); } return result; } function __decode(str, LIMIT) { LIMIT = LIMIT || 90; if (str.length < 8) return str + " too short"; if (str.length > LIMIT) return "Exceeds length limit"; var lowered = str.toLowerCase(); var uppered = str.toUpperCase(); if (str !== lowered && str !== uppered) return "Mixed-case string " + str; str = lowered; var split = str.lastIndexOf("1"); if (split === -1) return "No separator character for " + str; if (split === 0) return "Missing prefix for " + str; var prefix = str.slice(0, split); var wordChars = str.slice(split + 1); if (wordChars.length < 6) return "Data too short"; var chk = prefixChk(prefix); if (typeof chk === "string") return chk; var words2 = []; for (var i2 = 0; i2 < wordChars.length; ++i2) { var c2 = wordChars.charAt(i2); var v2 = ALPHABET_MAP[c2]; if (v2 === void 0) return "Unknown character " + c2; chk = polymodStep(chk) ^ v2; if (i2 + 6 >= wordChars.length) continue; words2.push(v2); } if (chk !== 1) return "Invalid checksum for " + str; return { prefix, words: words2 }; } function decodeUnsafe() { var res = __decode.apply(null, arguments); if (typeof res === "object") return res; } function decode(str) { var res = __decode.apply(null, arguments); if (typeof res === "object") return res; throw new Error(res); } function convert(data, inBits, outBits, pad2) { var value = 0; var bits = 0; var maxV = (1 << outBits) - 1; var result = []; for (var i2 = 0; i2 < data.length; ++i2) { value = value << inBits | data[i2]; bits += inBits; while (bits >= outBits) { bits -= outBits; result.push(value >> bits & maxV); } } if (pad2) { if (bits > 0) { result.push(value << outBits - bits & maxV); } } else { if (bits >= inBits) return "Excess padding"; if (value << outBits - bits & maxV) return "Non-zero padding"; } return result; } function toWordsUnsafe(bytes) { var res = convert(bytes, 8, 5, true); if (Array.isArray(res)) return res; } function toWords(bytes) { var res = convert(bytes, 8, 5, true); if (Array.isArray(res)) return res; throw new Error(res); } function fromWordsUnsafe(words2) { var res = convert(words2, 5, 8, false); if (Array.isArray(res)) return res; } function fromWords(words2) { var res = convert(words2, 5, 8, false); if (Array.isArray(res)) return res; throw new Error(res); } var bech32 = { decodeUnsafe, decode, encode: encode2, toWordsUnsafe, toWords, fromWordsUnsafe, fromWords }; const version$3 = "providers/5.7.2"; const logger$8 = new Logger(version$3); class Formatter { constructor() { this.formats = this.getDefaultFormats(); } getDefaultFormats() { const formats = {}; const address = this.address.bind(this); const bigNumber = this.bigNumber.bind(this); const blockTag = this.blockTag.bind(this); const data = this.data.bind(this); const hash2 = this.hash.bind(this); const hex = this.hex.bind(this); const number = this.number.bind(this); const type = this.type.bind(this); const strictData = (v2) => { return this.data(v2, true); }; formats.transaction = { hash: hash2, type, accessList: Formatter.allowNull(this.accessList.bind(this), null), blockHash: Formatter.allowNull(hash2, null), blockNumber: Formatter.allowNull(number, null), transactionIndex: Formatter.allowNull(number, null), confirmations: Formatter.allowNull(number, null), from: address, // either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) // must be set gasPrice: Formatter.allowNull(bigNumber), maxPriorityFeePerGas: Formatter.allowNull(bigNumber), maxFeePerGas: Formatter.allowNull(bigNumber), gasLimit: bigNumber, to: Formatter.allowNull(address, null), value: bigNumber, nonce: number, data, r: Formatter.allowNull(this.uint256), s: Formatter.allowNull(this.uint256), v: Formatter.allowNull(number), creates: Formatter.allowNull(address, null), raw: Formatter.allowNull(data) }; formats.transactionRequest = { from: Formatter.allowNull(address), nonce: Formatter.allowNull(number), gasLimit: Formatter.allowNull(bigNumber), gasPrice: Formatter.allowNull(bigNumber), maxPriorityFeePerGas: Formatter.allowNull(bigNumber), maxFeePerGas: Formatter.allowNull(bigNumber), to: Formatter.allowNull(address), value: Formatter.allowNull(bigNumber), data: Formatter.allowNull(strictData), type: Formatter.allowNull(number), accessList: Formatter.allowNull(this.accessList.bind(this), null) }; formats.receiptLog = { transactionIndex: number, blockNumber: number, transactionHash: hash2, address, topics: Formatter.arrayOf(hash2), data, logIndex: number, blockHash: hash2 }; formats.receipt = { to: Formatter.allowNull(this.address, null), from: Formatter.allowNull(this.address, null), contractAddress: Formatter.allowNull(address, null), transactionIndex: number, // should be allowNull(hash), but broken-EIP-658 support is handled in receipt root: Formatter.allowNull(hex), gasUsed: bigNumber, logsBloom: Formatter.allowNull(data), blockHash: hash2, transactionHash: hash2, logs: Formatter.arrayOf(this.receiptLog.bind(this)), blockNumber: number, confirmations: Formatter.allowNull(number, null), cumulativeGasUsed: bigNumber, effectiveGasPrice: Formatter.allowNull(bigNumber), status: Formatter.allowNull(number), type }; formats.block = { hash: Formatter.allowNull(hash2), parentHash: hash2, number, timestamp: number, nonce: Formatter.allowNull(hex), difficulty: this.difficulty.bind(this), gasLimit: bigNumber, gasUsed: bigNumber, miner: Formatter.allowNull(address), extraData: data, transactions: Formatter.allowNull(Formatter.arrayOf(hash2)), baseFeePerGas: Formatter.allowNull(bigNumber) }; formats.blockWithTransactions = shallowCopy(formats.block); formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))); formats.filter = { fromBlock: Formatter.allowNull(blockTag, void 0), toBlock: Formatter.allowNull(blockTag, void 0), blockHash: Formatter.allowNull(hash2, void 0), address: Formatter.allowNull(address, void 0), topics: Formatter.allowNull(this.topics.bind(this), void 0) }; formats.filterLog = { blockNumber: Formatter.allowNull(number), blockHash: Formatter.allowNull(hash2), transactionIndex: number, removed: Formatter.allowNull(this.boolean.bind(this)), address, data: Formatter.allowFalsish(data, "0x"), topics: Formatter.arrayOf(hash2), transactionHash: hash2, logIndex: number }; return formats; } accessList(accessList) { return accessListify(accessList || []); } // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number // Strict! Used on input. number(number) { if (number === "0x") { return 0; } return BigNumber.from(number).toNumber(); } type(number) { if (number === "0x" || number == null) { return 0; } return BigNumber.from(number).toNumber(); } // Strict! Used on input. bigNumber(value) { return BigNumber.from(value); } // Requires a boolean, "true" or "false"; returns a boolean boolean(value) { if (typeof value === "boolean") { return value; } if (typeof value === "string") { value = value.toLowerCase(); if (value === "true") { return true; } if (value === "false") { return false; } } throw new Error("invalid boolean - " + value); } hex(value, strict) { if (typeof value === "string") { if (!strict && value.substring(0, 2) !== "0x") { value = "0x" + value; } if (isHexString(value)) { return value.toLowerCase(); } } return logger$8.throwArgumentError("invalid hash", "value", value); } data(value, strict) { const result = this.hex(value, strict); if (result.length % 2 !== 0) { throw new Error("invalid data; odd-length - " + value); } return result; } // Requires an address // Strict! Used on input. address(value) { return getAddress(value); } callAddress(value) { if (!isHexString(value, 32)) { return null; } const address = getAddress(hexDataSlice(value, 12)); return address === AddressZero ? null : address; } contractAddress(value) { return getContractAddress(value); } // Strict! Used on input. blockTag(blockTag) { if (blockTag == null) { return "latest"; } if (blockTag === "earliest") { return "0x0"; } switch (blockTag) { case "earliest": return "0x0"; case "latest": case "pending": case "safe": case "finalized": return blockTag; } if (typeof blockTag === "number" || isHexString(blockTag)) { return hexValue(blockTag); } throw new Error("invalid blockTag"); } // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash. hash(value, strict) { const result = this.hex(value, strict); if (hexDataLength(result) !== 32) { return logger$8.throwArgumentError("invalid hash", "value", value); } return result; } // Returns the difficulty as a number, or if too large (i.e. PoA network) null difficulty(value) { if (value == null) { return null; } const v2 = BigNumber.from(value); try { return v2.toNumber(); } catch (error) { } return null; } uint256(value) { if (!isHexString(value)) { throw new Error("invalid uint256"); } return hexZeroPad(value, 32); } _block(value, format) { if (value.author != null && value.miner == null) { value.miner = value.author; } const difficulty = value._difficulty != null ? value._difficulty : value.difficulty; const result = Formatter.check(format, value); result._difficulty = difficulty == null ? null : BigNumber.from(difficulty); return result; } block(value) { return this._block(value, this.formats.block); } blockWithTransactions(value) { return this._block(value, this.formats.blockWithTransactions); } // Strict! Used on input. transactionRequest(value) { return Formatter.check(this.formats.transactionRequest, value); } transactionResponse(transaction) { if (transaction.gas != null && transaction.gasLimit == null) { transaction.gasLimit = transaction.gas; } if (transaction.to && BigNumber.from(transaction.to).isZero()) { transaction.to = "0x0000000000000000000000000000000000000000"; } if (transaction.input != null && transaction.data == null) { transaction.data = transaction.input; } if (transaction.to == null && transaction.creates == null) { transaction.creates = this.contractAddress(transaction); } if ((transaction.type === 1 || transaction.type === 2) && transaction.accessList == null) { transaction.accessList = []; } const result = Formatter.check(this.formats.transaction, transaction); if (transaction.chainId != null) { let chainId = transaction.chainId; if (isHexString(chainId)) { chainId = BigNumber.from(chainId).toNumber(); } result.chainId = chainId; } else { let chainId = transaction.networkId; if (chainId == null && result.v == null) { chainId = transaction.chainId; } if (isHexString(chainId)) { chainId = BigNumber.from(chainId).toNumber(); } if (typeof chainId !== "number" && result.v != null) { chainId = (result.v - 35) / 2; if (chainId < 0) { chainId = 0; } chainId = parseInt(chainId); } if (typeof chainId !== "number") { chainId = 0; } result.chainId = chainId; } if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { result.blockHash = null; } return result; } transaction(value) { return parse(value); } receiptLog(value) { return Formatter.check(this.formats.receiptLog, value); } receipt(value) { const result = Formatter.check(this.formats.receipt, value); if (result.root != null) { if (result.root.length <= 4) { const value2 = BigNumber.from(result.root).toNumber(); if (value2 === 0 || value2 === 1) { if (result.status != null && result.status !== value2) { logger$8.throwArgumentError("alt-root-status/status mismatch", "value", { root: result.root, status: result.status }); } result.status = value2; delete result.root; } else { logger$8.throwArgumentError("invalid alt-root-status", "value.root", result.root); } } else if (result.root.length !== 66) { logger$8.throwArgumentError("invalid root hash", "value.root", result.root); } } if (result.status != null) { result.byzantium = true; } return result; } topics(value) { if (Array.isArray(value)) { return value.map((v2) => this.topics(v2)); } else if (value != null) { return this.hash(value, true); } return null; } filter(value) { return Formatter.check(this.formats.filter, value); } filterLog(value) { return Formatter.check(this.formats.filterLog, value); } static check(format, object) { const result = {}; for (const key2 in format) { try { const value = format[key2](object[key2]); if (value !== void 0) { result[key2] = value; } } catch (error) { error.checkKey = key2; error.checkValue = object[key2]; throw error; } } return result; } // if value is null-ish, nullValue is returned static allowNull(format, nullValue) { return function(value) { if (value == null) { return nullValue; } return format(value); }; } // If value is false-ish, replaceValue is returned static allowFalsish(format, replaceValue) { return function(value) { if (!value) { return replaceValue; } return format(value); }; } // Requires an Array satisfying check static arrayOf(format) { return function(array) { if (!Array.isArray(array)) { throw new Error("not an array"); } const result = []; array.forEach(function(value) { result.push(format(value)); }); return result; }; } } function isCommunityResourcable(value) { return value && typeof value.isCommunityResource === "function"; } function isCommunityResource(value) { return isCommunityResourcable(value) && value.isCommunityResource(); } var __awaiter$4 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$7 = new Logger(version$3); const MAX_CCIP_REDIRECTS = 10; function checkTopic(topic) { if (topic == null) { return "null"; } if (hexDataLength(topic) !== 32) { logger$7.throwArgumentError("invalid topic", "topic", topic); } return topic.toLowerCase(); } function serializeTopics(topics) { topics = topics.slice(); while (topics.length > 0 && topics[topics.length - 1] == null) { topics.pop(); } return topics.map((topic) => { if (Array.isArray(topic)) { const unique = {}; topic.forEach((topic2) => { unique[checkTopic(topic2)] = true; }); const sorted = Object.keys(unique); sorted.sort(); return sorted.join("|"); } else { return checkTopic(topic); } }).join("&"); } function deserializeTopics(data) { if (data === "") { return []; } return data.split(/&/g).map((topic) => { if (topic === "") { return []; } const comps = topic.split("|").map((topic2) => { return topic2 === "null" ? null : topic2; }); return comps.length === 1 ? comps[0] : comps; }); } function getEventTag(eventName) { if (typeof eventName === "string") { eventName = eventName.toLowerCase(); if (hexDataLength(eventName) === 32) { return "tx:" + eventName; } if (eventName.indexOf(":") === -1) { return eventName; } } else if (Array.isArray(eventName)) { return "filter:*:" + serializeTopics(eventName); } else if (ForkEvent.isForkEvent(eventName)) { logger$7.warn("not implemented"); throw new Error("not implemented"); } else if (eventName && typeof eventName === "object") { return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []); } throw new Error("invalid event - " + eventName); } function getTime() { return new Date().getTime(); } function stall$1(duration) { return new Promise((resolve) => { setTimeout(resolve, duration); }); } const PollableEvents = ["block", "network", "pending", "poll"]; class Event { constructor(tag, listener, once) { defineReadOnly(this, "tag", tag); defineReadOnly(this, "listener", listener); defineReadOnly(this, "once", once); this._lastBlockNumber = -2; this._inflight = false; } get event() { switch (this.type) { case "tx": return this.hash; case "filter": return this.filter; } return this.tag; } get type() { return this.tag.split(":")[0]; } get hash() { const comps = this.tag.split(":"); if (comps[0] !== "tx") { return null; } return comps[1]; } get filter() { const comps = this.tag.split(":"); if (comps[0] !== "filter") { return null; } const address = comps[1]; const topics = deserializeTopics(comps[2]); const filter = {}; if (topics.length > 0) { filter.topics = topics; } if (address && address !== "*") { filter.address = address; } return filter; } pollable() { return this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0; } } const coinInfos = { "0": { symbol: "btc", p2pkh: 0, p2sh: 5, prefix: "bc" }, "2": { symbol: "ltc", p2pkh: 48, p2sh: 50, prefix: "ltc" }, "3": { symbol: "doge", p2pkh: 30, p2sh: 22 }, "60": { symbol: "eth", ilk: "eth" }, "61": { symbol: "etc", ilk: "eth" }, "700": { symbol: "xdai", ilk: "eth" } }; function bytes32ify(value) { return hexZeroPad(BigNumber.from(value).toHexString(), 32); } function base58Encode(data) { return Base58.encode(concat([data, hexDataSlice(sha256$1(sha256$1(data)), 0, 4)])); } const matcherIpfs = new RegExp("^(ipfs)://(.*)$", "i"); const matchers = [ new RegExp("^(https)://(.*)$", "i"), new RegExp("^(data):(.*)$", "i"), matcherIpfs, new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$", "i") ]; function _parseString(result, start) { try { return toUtf8String(_parseBytes(result, start)); } catch (error) { } return null; } function _parseBytes(result, start) { if (result === "0x") { return null; } const offset = BigNumber.from(hexDataSlice(result, start, start + 32)).toNumber(); const length = BigNumber.from(hexDataSlice(result, offset, offset + 32)).toNumber(); return hexDataSlice(result, offset + 32, offset + 32 + length); } function getIpfsLink(link) { if (link.match(/^ipfs:\/\/ipfs\//i)) { link = link.substring(12); } else if (link.match(/^ipfs:\/\//i)) { link = link.substring(7); } else { logger$7.throwArgumentError("unsupported IPFS format", "link", link); } return `https://gateway.ipfs.io/ipfs/${link}`; } function numPad(value) { const result = arrayify(value); if (result.length > 32) { throw new Error("internal; should not happen"); } const padded = new Uint8Array(32); padded.set(result, 32 - result.length); return padded; } function bytesPad(value) { if (value.length % 32 === 0) { return value; } const result = new Uint8Array(Math.ceil(value.length / 32) * 32); result.set(value); return result; } function encodeBytes(datas) { const result = []; let byteCount = 0; for (let i2 = 0; i2 < datas.length; i2++) { result.push(null); byteCount += 32; } for (let i2 = 0; i2 < datas.length; i2++) { const data = arrayify(datas[i2]); result[i2] = numPad(byteCount); result.push(numPad(data.length)); result.push(bytesPad(data)); byteCount += 32 + Math.ceil(data.length / 32) * 32; } return hexConcat(result); } class Resolver { // The resolvedAddress is only for creating a ReverseLookup resolver constructor(provider, address, name, resolvedAddress) { defineReadOnly(this, "provider", provider); defineReadOnly(this, "name", name); defineReadOnly(this, "address", provider.formatter.address(address)); defineReadOnly(this, "_resolvedAddress", resolvedAddress); } supportsWildcard() { if (!this._supportsEip2544) { this._supportsEip2544 = this.provider.call({ to: this.address, data: "0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000" }).then((result) => { return BigNumber.from(result).eq(1); }).catch((error) => { if (error.code === Logger.errors.CALL_EXCEPTION) { return false; } this._supportsEip2544 = null; throw error; }); } return this._supportsEip2544; } _fetch(selector, parameters) { return __awaiter$4(this, void 0, void 0, function* () { const tx = { to: this.address, ccipReadEnabled: true, data: hexConcat([selector, namehash(this.name), parameters || "0x"]) }; let parseBytes = false; if (yield this.supportsWildcard()) { parseBytes = true; tx.data = hexConcat(["0x9061b923", encodeBytes([dnsEncode(this.name), tx.data])]); } try { let result = yield this.provider.call(tx); if (arrayify(result).length % 32 === 4) { logger$7.throwError("resolver threw error", Logger.errors.CALL_EXCEPTION, { transaction: tx, data: result }); } if (parseBytes) { result = _parseBytes(result, 0); } return result; } catch (error) { if (error.code === Logger.errors.CALL_EXCEPTION) { return null; } throw error; } }); } _fetchBytes(selector, parameters) { return __awaiter$4(this, void 0, void 0, function* () { const result = yield this._fetch(selector, parameters); if (result != null) { return _parseBytes(result, 0); } return null; }); } _getAddress(coinType, hexBytes) { const coinInfo = coinInfos[String(coinType)]; if (coinInfo == null) { logger$7.throwError(`unsupported coin type: ${coinType}`, Logger.errors.UNSUPPORTED_OPERATION, { operation: `getAddress(${coinType})` }); } if (coinInfo.ilk === "eth") { return this.provider.formatter.address(hexBytes); } const bytes = arrayify(hexBytes); if (coinInfo.p2pkh != null) { const p2pkh = hexBytes.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/); if (p2pkh) { const length = parseInt(p2pkh[1], 16); if (p2pkh[2].length === length * 2 && length >= 1 && length <= 75) { return base58Encode(concat([[coinInfo.p2pkh], "0x" + p2pkh[2]])); } } } if (coinInfo.p2sh != null) { const p2sh = hexBytes.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/); if (p2sh) { const length = parseInt(p2sh[1], 16); if (p2sh[2].length === length * 2 && length >= 1 && length <= 75) { return base58Encode(concat([[coinInfo.p2sh], "0x" + p2sh[2]])); } } } if (coinInfo.prefix != null) { const length = bytes[1]; let version2 = bytes[0]; if (version2 === 0) { if (length !== 20 && length !== 32) { version2 = -1; } } else { version2 = -1; } if (version2 >= 0 && bytes.length === 2 + length && length >= 1 && length <= 75) { const words2 = bech32.toWords(bytes.slice(2)); words2.unshift(version2); return bech32.encode(coinInfo.prefix, words2); } } return null; } getAddress(coinType) { return __awaiter$4(this, void 0, void 0, function* () { if (coinType == null) { coinType = 60; } if (coinType === 60) { try { const result = yield this._fetch("0x3b3b57de"); if (result === "0x" || result === HashZero) { return null; } return this.provider.formatter.callAddress(result); } catch (error) { if (error.code === Logger.errors.CALL_EXCEPTION) { return null; } throw error; } } const hexBytes = yield this._fetchBytes("0xf1cb7e06", bytes32ify(coinType)); if (hexBytes == null || hexBytes === "0x") { return null; } const address = this._getAddress(coinType, hexBytes); if (address == null) { logger$7.throwError(`invalid or unsupported coin data`, Logger.errors.UNSUPPORTED_OPERATION, { operation: `getAddress(${coinType})`, coinType, data: hexBytes }); } return address; }); } getAvatar() { return __awaiter$4(this, void 0, void 0, function* () { const linkage = [{ type: "name", content: this.name }]; try { const avatar = yield this.getText("avatar"); if (avatar == null) { return null; } for (let i2 = 0; i2 < matchers.length; i2++) { const match = avatar.match(matchers[i2]); if (match == null) { continue; } const scheme = match[1].toLowerCase(); switch (scheme) { case "https": linkage.push({ type: "url", content: avatar }); return { linkage, url: avatar }; case "data": linkage.push({ type: "data", content: avatar }); return { linkage, url: avatar }; case "ipfs": linkage.push({ type: "ipfs", content: avatar }); return { linkage, url: getIpfsLink(avatar) }; case "erc721": case "erc1155": { const selector = scheme === "erc721" ? "0xc87b56dd" : "0x0e89341c"; linkage.push({ type: scheme, content: avatar }); const owner = this._resolvedAddress || (yield this.getAddress()); const comps = (match[2] || "").split("/"); if (comps.length !== 2) { return null; } const addr = yield this.provider.formatter.address(comps[0]); const tokenId = hexZeroPad(BigNumber.from(comps[1]).toHexString(), 32); if (scheme === "erc721") { const tokenOwner = this.provider.formatter.callAddress(yield this.provider.call({ to: addr, data: hexConcat(["0x6352211e", tokenId]) })); if (owner !== tokenOwner) { return null; } linkage.push({ type: "owner", content: tokenOwner }); } else if (scheme === "erc1155") { const balance = BigNumber.from(yield this.provider.call({ to: addr, data: hexConcat(["0x00fdd58e", hexZeroPad(owner, 32), tokenId]) })); if (balance.isZero()) { return null; } linkage.push({ type: "balance", content: balance.toString() }); } const tx = { to: this.provider.formatter.address(comps[0]), data: hexConcat([selector, tokenId]) }; let metadataUrl = _parseString(yield this.provider.call(tx), 0); if (metadataUrl == null) { return null; } linkage.push({ type: "metadata-url-base", content: metadataUrl }); if (scheme === "erc1155") { metadataUrl = metadataUrl.replace("{id}", tokenId.substring(2)); linkage.push({ type: "metadata-url-expanded", content: metadataUrl }); } if (metadataUrl.match(/^ipfs:/i)) { metadataUrl = getIpfsLink(metadataUrl); } linkage.push({ type: "metadata-url", content: metadataUrl }); const metadata = yield fetchJson(metadataUrl); if (!metadata) { return null; } linkage.push({ type: "metadata", content: JSON.stringify(metadata) }); let imageUrl = metadata.image; if (typeof imageUrl !== "string") { return null; } if (imageUrl.match(/^(https:\/\/|data:)/i)) { } else { const ipfs = imageUrl.match(matcherIpfs); if (ipfs == null) { return null; } linkage.push({ type: "url-ipfs", content: imageUrl }); imageUrl = getIpfsLink(imageUrl); } linkage.push({ type: "url", content: imageUrl }); return { linkage, url: imageUrl }; } } } } catch (error) { } return null; }); } getContentHash() { return __awaiter$4(this, void 0, void 0, function* () { const hexBytes = yield this._fetchBytes("0xbc1c58d1"); if (hexBytes == null || hexBytes === "0x") { return null; } const ipfs = hexBytes.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/); if (ipfs) { const length = parseInt(ipfs[3], 16); if (ipfs[4].length === length * 2) { return "ipfs://" + Base58.encode("0x" + ipfs[1]); } } const ipns = hexBytes.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/); if (ipns) { const length = parseInt(ipns[3], 16); if (ipns[4].length === length * 2) { return "ipns://" + Base58.encode("0x" + ipns[1]); } } const swarm = hexBytes.match(/^0xe40101fa011b20([0-9a-f]*)$/); if (swarm) { if (swarm[1].length === 32 * 2) { return "bzz://" + swarm[1]; } } const skynet = hexBytes.match(/^0x90b2c605([0-9a-f]*)$/); if (skynet) { if (skynet[1].length === 34 * 2) { const urlSafe = { "=": "", "+": "-", "/": "_" }; const hash2 = encode$1("0x" + skynet[1]).replace(/[=+\/]/g, (a2) => urlSafe[a2]); return "sia://" + hash2; } } return logger$7.throwError(`invalid or unsupported content hash data`, Logger.errors.UNSUPPORTED_OPERATION, { operation: "getContentHash()", data: hexBytes }); }); } getText(key2) { return __awaiter$4(this, void 0, void 0, function* () { let keyBytes = toUtf8Bytes(key2); keyBytes = concat([bytes32ify(64), bytes32ify(keyBytes.length), keyBytes]); if (keyBytes.length % 32 !== 0) { keyBytes = concat([keyBytes, hexZeroPad("0x", 32 - key2.length % 32)]); } const hexBytes = yield this._fetchBytes("0x59d1d43c", hexlify(keyBytes)); if (hexBytes == null || hexBytes === "0x") { return null; } return toUtf8String(hexBytes); }); } } let defaultFormatter = null; let nextPollId = 1; class BaseProvider extends Provider { /** * ready * * A Promise that resolves only once the provider is ready. * * Sub-classes that call the super with a network without a chainId * MUST set this. Standard named networks have a known chainId. * */ constructor(network) { super(); this._events = []; this._emitted = { block: -2 }; this.disableCcipRead = false; this.formatter = new.target.getFormatter(); defineReadOnly(this, "anyNetwork", network === "any"); if (this.anyNetwork) { network = this.detectNetwork(); } if (network instanceof Promise) { this._networkPromise = network; network.catch((error) => { }); this._ready().catch((error) => { }); } else { const knownNetwork = getStatic(new.target, "getNetwork")(network); if (knownNetwork) { defineReadOnly(this, "_network", knownNetwork); this.emit("network", knownNetwork, null); } else { logger$7.throwArgumentError("invalid network", "network", network); } } this._maxInternalBlockNumber = -1024; this._lastBlockNumber = -2; this._maxFilterBlockRange = 10; this._pollingInterval = 4e3; this._fastQueryDate = 0; } _ready() { return __awaiter$4(this, void 0, void 0, function* () { if (this._network == null) { let network = null; if (this._networkPromise) { try { network = yield this._networkPromise; } catch (error) { } } if (network == null) { network = yield this.detectNetwork(); } if (!network) { logger$7.throwError("no network detected", Logger.errors.UNKNOWN_ERROR, {}); } if (this._network == null) { if (this.anyNetwork) { this._network = network; } else { defineReadOnly(this, "_network", network); } this.emit("network", network, null); } } return this._network; }); } // This will always return the most recently established network. // For "any", this can change (a "network" event is emitted before // any change is reflected); otherwise this cannot change get ready() { return poll(() => { return this._ready().then((network) => { return network; }, (error) => { if (error.code === Logger.errors.NETWORK_ERROR && error.event === "noNetwork") { return void 0; } throw error; }); }); } // @TODO: Remove this and just create a singleton formatter static getFormatter() { if (defaultFormatter == null) { defaultFormatter = new Formatter(); } return defaultFormatter; } // @TODO: Remove this and just use getNetwork static getNetwork(network) { return getNetwork$1(network == null ? "homestead" : network); } ccipReadFetch(tx, calldata, urls) { return __awaiter$4(this, void 0, void 0, function* () { if (this.disableCcipRead || urls.length === 0) { return null; } const sender = tx.to.toLowerCase(); const data = calldata.toLowerCase(); const errorMessages = []; for (let i2 = 0; i2 < urls.length; i2++) { const url = urls[i2]; const href = url.replace("{sender}", sender).replace("{data}", data); const json = url.indexOf("{data}") >= 0 ? null : JSON.stringify({ data, sender }); const result = yield fetchJson({ url: href, errorPassThrough: true }, json, (value, response) => { value.status = response.statusCode; return value; }); if (result.data) { return result.data; } const errorMessage = result.message || "unknown error"; if (result.status >= 400 && result.status < 500) { return logger$7.throwError(`response not found during CCIP fetch: ${errorMessage}`, Logger.errors.SERVER_ERROR, { url, errorMessage }); } errorMessages.push(errorMessage); } return logger$7.throwError(`error encountered during CCIP fetch: ${errorMessages.map((m2) => JSON.stringify(m2)).join(", ")}`, Logger.errors.SERVER_ERROR, { urls, errorMessages }); }); } // Fetches the blockNumber, but will reuse any result that is less // than maxAge old or has been requested since the last request _getInternalBlockNumber(maxAge) { return __awaiter$4(this, void 0, void 0, function* () { yield this._ready(); if (maxAge > 0) { while (this._internalBlockNumber) { const internalBlockNumber = this._internalBlockNumber; try { const result = yield internalBlockNumber; if (getTime() - result.respTime <= maxAge) { return result.blockNumber; } break; } catch (error) { if (this._internalBlockNumber === internalBlockNumber) { break; } } } } const reqTime = getTime(); const checkInternalBlockNumber = resolveProperties({ blockNumber: this.perform("getBlockNumber", {}), networkError: this.getNetwork().then((network) => null, (error) => error) }).then(({ blockNumber, networkError }) => { if (networkError) { if (this._internalBlockNumber === checkInternalBlockNumber) { this._internalBlockNumber = null; } throw networkError; } const respTime = getTime(); blockNumber = BigNumber.from(blockNumber).toNumber(); if (blockNumber < this._maxInternalBlockNumber) { blockNumber = this._maxInternalBlockNumber; } this._maxInternalBlockNumber = blockNumber; this._setFastBlockNumber(blockNumber); return { blockNumber, reqTime, respTime }; }); this._internalBlockNumber = checkInternalBlockNumber; checkInternalBlockNumber.catch((error) => { if (this._internalBlockNumber === checkInternalBlockNumber) { this._internalBlockNumber = null; } }); return (yield checkInternalBlockNumber).blockNumber; }); } poll() { return __awaiter$4(this, void 0, void 0, function* () { const pollId = nextPollId++; const runners = []; let blockNumber = null; try { blockNumber = yield this._getInternalBlockNumber(100 + this.pollingInterval / 2); } catch (error) { this.emit("error", error); return; } this._setFastBlockNumber(blockNumber); this.emit("poll", pollId, blockNumber); if (blockNumber === this._lastBlockNumber) { this.emit("didPoll", pollId); return; } if (this._emitted.block === -2) { this._emitted.block = blockNumber - 1; } if (Math.abs(this._emitted.block - blockNumber) > 1e3) { logger$7.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${blockNumber})`); this.emit("error", logger$7.makeError("network block skew detected", Logger.errors.NETWORK_ERROR, { blockNumber, event: "blockSkew", previousBlockNumber: this._emitted.block })); this.emit("block", blockNumber); } else { for (let i2 = this._emitted.block + 1; i2 <= blockNumber; i2++) { this.emit("block", i2); } } if (this._emitted.block !== blockNumber) { this._emitted.block = blockNumber; Object.keys(this._emitted).forEach((key2) => { if (key2 === "block") { return; } const eventBlockNumber = this._emitted[key2]; if (eventBlockNumber === "pending") { return; } if (blockNumber - eventBlockNumber > 12) { delete this._emitted[key2]; } }); } if (this._lastBlockNumber === -2) { this._lastBlockNumber = blockNumber - 1; } this._events.forEach((event) => { switch (event.type) { case "tx": { const hash2 = event.hash; let runner = this.getTransactionReceipt(hash2).then((receipt) => { if (!receipt || receipt.blockNumber == null) { return null; } this._emitted["t:" + hash2] = receipt.blockNumber; this.emit(hash2, receipt); return null; }).catch((error) => { this.emit("error", error); }); runners.push(runner); break; } case "filter": { if (!event._inflight) { event._inflight = true; if (event._lastBlockNumber === -2) { event._lastBlockNumber = blockNumber - 1; } const filter = event.filter; filter.fromBlock = event._lastBlockNumber + 1; filter.toBlock = blockNumber; const minFromBlock = filter.toBlock - this._maxFilterBlockRange; if (minFromBlock > filter.fromBlock) { filter.fromBlock = minFromBlock; } if (filter.fromBlock < 0) { filter.fromBlock = 0; } const runner = this.getLogs(filter).then((logs) => { event._inflight = false; if (logs.length === 0) { return; } logs.forEach((log) => { if (log.blockNumber > event._lastBlockNumber) { event._lastBlockNumber = log.blockNumber; } this._emitted["b:" + log.blockHash] = log.blockNumber; this._emitted["t:" + log.transactionHash] = log.blockNumber; this.emit(filter, log); }); }).catch((error) => { this.emit("error", error); event._inflight = false; }); runners.push(runner); } break; } } }); this._lastBlockNumber = blockNumber; Promise.all(runners).then(() => { this.emit("didPoll", pollId); }).catch((error) => { this.emit("error", error); }); return; }); } // Deprecated; do not use this resetEventsBlock(blockNumber) { this._lastBlockNumber = blockNumber - 1; if (this.polling) { this.poll(); } } get network() { return this._network; } // This method should query the network if the underlying network // can change, such as when connected to a JSON-RPC backend detectNetwork() { return __awaiter$4(this, void 0, void 0, function* () { return logger$7.throwError("provider does not support network detection", Logger.errors.UNSUPPORTED_OPERATION, { operation: "provider.detectNetwork" }); }); } getNetwork() { return __awaiter$4(this, void 0, void 0, function* () { const network = yield this._ready(); const currentNetwork = yield this.detectNetwork(); if (network.chainId !== currentNetwork.chainId) { if (this.anyNetwork) { this._network = currentNetwork; this._lastBlockNumber = -2; this._fastBlockNumber = null; this._fastBlockNumberPromise = null; this._fastQueryDate = 0; this._emitted.block = -2; this._maxInternalBlockNumber = -1024; this._internalBlockNumber = null; this.emit("network", currentNetwork, network); yield stall$1(0); return this._network; } const error = logger$7.makeError("underlying network changed", Logger.errors.NETWORK_ERROR, { event: "changed", network, detectedNetwork: currentNetwork }); this.emit("error", error); throw error; } return network; }); } get blockNumber() { this._getInternalBlockNumber(100 + this.pollingInterval / 2).then((blockNumber) => { this._setFastBlockNumber(blockNumber); }, (error) => { }); return this._fastBlockNumber != null ? this._fastBlockNumber : -1; } get polling() { return this._poller != null; } set polling(value) { if (value && !this._poller) { this._poller = setInterval(() => { this.poll(); }, this.pollingInterval); if (!this._bootstrapPoll) { this._bootstrapPoll = setTimeout(() => { this.poll(); this._bootstrapPoll = setTimeout(() => { if (!this._poller) { this.poll(); } this._bootstrapPoll = null; }, this.pollingInterval); }, 0); } } else if (!value && this._poller) { clearInterval(this._poller); this._poller = null; } } get pollingInterval() { return this._pollingInterval; } set pollingInterval(value) { if (typeof value !== "number" || value <= 0 || parseInt(String(value)) != value) { throw new Error("invalid polling interval"); } this._pollingInterval = value; if (this._poller) { clearInterval(this._poller); this._poller = setInterval(() => { this.poll(); }, this._pollingInterval); } } _getFastBlockNumber() { const now2 = getTime(); if (now2 - this._fastQueryDate > 2 * this._pollingInterval) { this._fastQueryDate = now2; this._fastBlockNumberPromise = this.getBlockNumber().then((blockNumber) => { if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { this._fastBlockNumber = blockNumber; } return this._fastBlockNumber; }); } return this._fastBlockNumberPromise; } _setFastBlockNumber(blockNumber) { if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { return; } this._fastQueryDate = getTime(); if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { this._fastBlockNumber = blockNumber; this._fastBlockNumberPromise = Promise.resolve(blockNumber); } } waitForTransaction(transactionHash, confirmations, timeout) { return __awaiter$4(this, void 0, void 0, function* () { return this._waitForTransaction(transactionHash, confirmations == null ? 1 : confirmations, timeout || 0, null); }); } _waitForTransaction(transactionHash, confirmations, timeout, replaceable) { return __awaiter$4(this, void 0, void 0, function* () { const receipt = yield this.getTransactionReceipt(transactionHash); if ((receipt ? receipt.confirmations : 0) >= confirmations) { return receipt; } return new Promise((resolve, reject) => { const cancelFuncs = []; let done = false; const alreadyDone = function() { if (done) { return true; } done = true; cancelFuncs.forEach((func) => { func(); }); return false; }; const minedHandler = (receipt2) => { if (receipt2.confirmations < confirmations) { return; } if (alreadyDone()) { return; } resolve(receipt2); }; this.on(transactionHash, minedHandler); cancelFuncs.push(() => { this.removeListener(transactionHash, minedHandler); }); if (replaceable) { let lastBlockNumber = replaceable.startBlock; let scannedBlock = null; const replaceHandler = (blockNumber) => __awaiter$4(this, void 0, void 0, function* () { if (done) { return; } yield stall$1(1e3); this.getTransactionCount(replaceable.from).then((nonce) => __awaiter$4(this, void 0, void 0, function* () { if (done) { return; } if (nonce <= replaceable.nonce) { lastBlockNumber = blockNumber; } else { { const mined = yield this.getTransaction(transactionHash); if (mined && mined.blockNumber != null) { return; } } if (scannedBlock == null) { scannedBlock = lastBlockNumber - 3; if (scannedBlock < replaceable.startBlock) { scannedBlock = replaceable.startBlock; } } while (scannedBlock <= blockNumber) { if (done) { return; } const block = yield this.getBlockWithTransactions(scannedBlock); for (let ti = 0; ti < block.transactions.length; ti++) { const tx = block.transactions[ti]; if (tx.hash === transactionHash) { return; } if (tx.from === replaceable.from && tx.nonce === replaceable.nonce) { if (done) { return; } const receipt2 = yield this.waitForTransaction(tx.hash, confirmations); if (alreadyDone()) { return; } let reason = "replaced"; if (tx.data === replaceable.data && tx.to === replaceable.to && tx.value.eq(replaceable.value)) { reason = "repriced"; } else if (tx.data === "0x" && tx.from === tx.to && tx.value.isZero()) { reason = "cancelled"; } reject(logger$7.makeError("transaction was replaced", Logger.errors.TRANSACTION_REPLACED, { cancelled: reason === "replaced" || reason === "cancelled", reason, replacement: this._wrapTransaction(tx), hash: transactionHash, receipt: receipt2 })); return; } } scannedBlock++; } } if (done) { return; } this.once("block", replaceHandler); }), (error) => { if (done) { return; } this.once("block", replaceHandler); }); }); if (done) { return; } this.once("block", replaceHandler); cancelFuncs.push(() => { this.removeListener("block", replaceHandler); }); } if (typeof timeout === "number" && timeout > 0) { const timer2 = setTimeout(() => { if (alreadyDone()) { return; } reject(logger$7.makeError("timeout exceeded", Logger.errors.TIMEOUT, { timeout })); }, timeout); if (timer2.unref) { timer2.unref(); } cancelFuncs.push(() => { clearTimeout(timer2); }); } }); }); } getBlockNumber() { return __awaiter$4(this, void 0, void 0, function* () { return this._getInternalBlockNumber(0); }); } getGasPrice() { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const result = yield this.perform("getGasPrice", {}); try { return BigNumber.from(result); } catch (error) { return logger$7.throwError("bad result from backend", Logger.errors.SERVER_ERROR, { method: "getGasPrice", result, error }); } }); } getBalance(addressOrName, blockTag) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const params = yield resolveProperties({ address: this._getAddress(addressOrName), blockTag: this._getBlockTag(blockTag) }); const result = yield this.perform("getBalance", params); try { return BigNumber.from(result); } catch (error) { return logger$7.throwError("bad result from backend", Logger.errors.SERVER_ERROR, { method: "getBalance", params, result, error }); } }); } getTransactionCount(addressOrName, blockTag) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const params = yield resolveProperties({ address: this._getAddress(addressOrName), blockTag: this._getBlockTag(blockTag) }); const result = yield this.perform("getTransactionCount", params); try { return BigNumber.from(result).toNumber(); } catch (error) { return logger$7.throwError("bad result from backend", Logger.errors.SERVER_ERROR, { method: "getTransactionCount", params, result, error }); } }); } getCode(addressOrName, blockTag) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const params = yield resolveProperties({ address: this._getAddress(addressOrName), blockTag: this._getBlockTag(blockTag) }); const result = yield this.perform("getCode", params); try { return hexlify(result); } catch (error) { return logger$7.throwError("bad result from backend", Logger.errors.SERVER_ERROR, { method: "getCode", params, result, error }); } }); } getStorageAt(addressOrName, position, blockTag) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const params = yield resolveProperties({ address: this._getAddress(addressOrName), blockTag: this._getBlockTag(blockTag), position: Promise.resolve(position).then((p2) => hexValue(p2)) }); const result = yield this.perform("getStorageAt", params); try { return hexlify(result); } catch (error) { return logger$7.throwError("bad result from backend", Logger.errors.SERVER_ERROR, { method: "getStorageAt", params, result, error }); } }); } // This should be called by any subclass wrapping a TransactionResponse _wrapTransaction(tx, hash2, startBlock) { if (hash2 != null && hexDataLength(hash2) !== 32) { throw new Error("invalid response - sendTransaction"); } const result = tx; if (hash2 != null && tx.hash !== hash2) { logger$7.throwError("Transaction hash mismatch from Provider.sendTransaction.", Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash2 }); } result.wait = (confirms, timeout) => __awaiter$4(this, void 0, void 0, function* () { if (confirms == null) { confirms = 1; } if (timeout == null) { timeout = 0; } let replacement = void 0; if (confirms !== 0 && startBlock != null) { replacement = { data: tx.data, from: tx.from, nonce: tx.nonce, to: tx.to, value: tx.value, startBlock }; } const receipt = yield this._waitForTransaction(tx.hash, confirms, timeout, replacement); if (receipt == null && confirms === 0) { return null; } this._emitted["t:" + tx.hash] = receipt.blockNumber; if (receipt.status === 0) { logger$7.throwError("transaction failed", Logger.errors.CALL_EXCEPTION, { transactionHash: tx.hash, transaction: tx, receipt }); } return receipt; }); return result; } sendTransaction(signedTransaction) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const hexTx = yield Promise.resolve(signedTransaction).then((t2) => hexlify(t2)); const tx = this.formatter.transaction(signedTransaction); if (tx.confirmations == null) { tx.confirmations = 0; } const blockNumber = yield this._getInternalBlockNumber(100 + 2 * this.pollingInterval); try { const hash2 = yield this.perform("sendTransaction", { signedTransaction: hexTx }); return this._wrapTransaction(tx, hash2, blockNumber); } catch (error) { error.transaction = tx; error.transactionHash = tx.hash; throw error; } }); } _getTransactionRequest(transaction) { return __awaiter$4(this, void 0, void 0, function* () { const values = yield transaction; const tx = {}; ["from", "to"].forEach((key2) => { if (values[key2] == null) { return; } tx[key2] = Promise.resolve(values[key2]).then((v2) => v2 ? this._getAddress(v2) : null); }); ["gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "value"].forEach((key2) => { if (values[key2] == null) { return; } tx[key2] = Promise.resolve(values[key2]).then((v2) => v2 ? BigNumber.from(v2) : null); }); ["type"].forEach((key2) => { if (values[key2] == null) { return; } tx[key2] = Promise.resolve(values[key2]).then((v2) => v2 != null ? v2 : null); }); if (values.accessList) { tx.accessList = this.formatter.accessList(values.accessList); } ["data"].forEach((key2) => { if (values[key2] == null) { return; } tx[key2] = Promise.resolve(values[key2]).then((v2) => v2 ? hexlify(v2) : null); }); return this.formatter.transactionRequest(yield resolveProperties(tx)); }); } _getFilter(filter) { return __awaiter$4(this, void 0, void 0, function* () { filter = yield filter; const result = {}; if (filter.address != null) { result.address = this._getAddress(filter.address); } ["blockHash", "topics"].forEach((key2) => { if (filter[key2] == null) { return; } result[key2] = filter[key2]; }); ["fromBlock", "toBlock"].forEach((key2) => { if (filter[key2] == null) { return; } result[key2] = this._getBlockTag(filter[key2]); }); return this.formatter.filter(yield resolveProperties(result)); }); } _call(transaction, blockTag, attempt) { return __awaiter$4(this, void 0, void 0, function* () { if (attempt >= MAX_CCIP_REDIRECTS) { logger$7.throwError("CCIP read exceeded maximum redirections", Logger.errors.SERVER_ERROR, { redirects: attempt, transaction }); } const txSender = transaction.to; const result = yield this.perform("call", { transaction, blockTag }); if (attempt >= 0 && blockTag === "latest" && txSender != null && result.substring(0, 10) === "0x556f1830" && hexDataLength(result) % 32 === 4) { try { const data = hexDataSlice(result, 4); const sender = hexDataSlice(data, 0, 32); if (!BigNumber.from(sender).eq(txSender)) { logger$7.throwError("CCIP Read sender did not match", Logger.errors.CALL_EXCEPTION, { name: "OffchainLookup", signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)", transaction, data: result }); } const urls = []; const urlsOffset = BigNumber.from(hexDataSlice(data, 32, 64)).toNumber(); const urlsLength = BigNumber.from(hexDataSlice(data, urlsOffset, urlsOffset + 32)).toNumber(); const urlsData = hexDataSlice(data, urlsOffset + 32); for (let u = 0; u < urlsLength; u++) { const url = _parseString(urlsData, u * 32); if (url == null) { logger$7.throwError("CCIP Read contained corrupt URL string", Logger.errors.CALL_EXCEPTION, { name: "OffchainLookup", signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)", transaction, data: result }); } urls.push(url); } const calldata = _parseBytes(data, 64); if (!BigNumber.from(hexDataSlice(data, 100, 128)).isZero()) { logger$7.throwError("CCIP Read callback selector included junk", Logger.errors.CALL_EXCEPTION, { name: "OffchainLookup", signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)", transaction, data: result }); } const callbackSelector = hexDataSlice(data, 96, 100); const extraData = _parseBytes(data, 128); const ccipResult = yield this.ccipReadFetch(transaction, calldata, urls); if (ccipResult == null) { logger$7.throwError("CCIP Read disabled or provided no URLs", Logger.errors.CALL_EXCEPTION, { name: "OffchainLookup", signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)", transaction, data: result }); } const tx = { to: txSender, data: hexConcat([callbackSelector, encodeBytes([ccipResult, extraData])]) }; return this._call(tx, blockTag, attempt + 1); } catch (error) { if (error.code === Logger.errors.SERVER_ERROR) { throw error; } } } try { return hexlify(result); } catch (error) { return logger$7.throwError("bad result from backend", Logger.errors.SERVER_ERROR, { method: "call", params: { transaction, blockTag }, result, error }); } }); } call(transaction, blockTag) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const resolved = yield resolveProperties({ transaction: this._getTransactionRequest(transaction), blockTag: this._getBlockTag(blockTag), ccipReadEnabled: Promise.resolve(transaction.ccipReadEnabled) }); return this._call(resolved.transaction, resolved.blockTag, resolved.ccipReadEnabled ? 0 : -1); }); } estimateGas(transaction) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const params = yield resolveProperties({ transaction: this._getTransactionRequest(transaction) }); const result = yield this.perform("estimateGas", params); try { return BigNumber.from(result); } catch (error) { return logger$7.throwError("bad result from backend", Logger.errors.SERVER_ERROR, { method: "estimateGas", params, result, error }); } }); } _getAddress(addressOrName) { return __awaiter$4(this, void 0, void 0, function* () { addressOrName = yield addressOrName; if (typeof addressOrName !== "string") { logger$7.throwArgumentError("invalid address or ENS name", "name", addressOrName); } const address = yield this.resolveName(addressOrName); if (address == null) { logger$7.throwError("ENS name not configured", Logger.errors.UNSUPPORTED_OPERATION, { operation: `resolveName(${JSON.stringify(addressOrName)})` }); } return address; }); } _getBlock(blockHashOrBlockTag, includeTransactions) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); blockHashOrBlockTag = yield blockHashOrBlockTag; let blockNumber = -128; const params = { includeTransactions: !!includeTransactions }; if (isHexString(blockHashOrBlockTag, 32)) { params.blockHash = blockHashOrBlockTag; } else { try { params.blockTag = yield this._getBlockTag(blockHashOrBlockTag); if (isHexString(params.blockTag)) { blockNumber = parseInt(params.blockTag.substring(2), 16); } } catch (error) { logger$7.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); } } return poll(() => __awaiter$4(this, void 0, void 0, function* () { const block = yield this.perform("getBlock", params); if (block == null) { if (params.blockHash != null) { if (this._emitted["b:" + params.blockHash] == null) { return null; } } if (params.blockTag != null) { if (blockNumber > this._emitted.block) { return null; } } return void 0; } if (includeTransactions) { let blockNumber2 = null; for (let i2 = 0; i2 < block.transactions.length; i2++) { const tx = block.transactions[i2]; if (tx.blockNumber == null) { tx.confirmations = 0; } else if (tx.confirmations == null) { if (blockNumber2 == null) { blockNumber2 = yield this._getInternalBlockNumber(100 + 2 * this.pollingInterval); } let confirmations = blockNumber2 - tx.blockNumber + 1; if (confirmations <= 0) { confirmations = 1; } tx.confirmations = confirmations; } } const blockWithTxs = this.formatter.blockWithTransactions(block); blockWithTxs.transactions = blockWithTxs.transactions.map((tx) => this._wrapTransaction(tx)); return blockWithTxs; } return this.formatter.block(block); }), { oncePoll: this }); }); } getBlock(blockHashOrBlockTag) { return this._getBlock(blockHashOrBlockTag, false); } getBlockWithTransactions(blockHashOrBlockTag) { return this._getBlock(blockHashOrBlockTag, true); } getTransaction(transactionHash) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); transactionHash = yield transactionHash; const params = { transactionHash: this.formatter.hash(transactionHash, true) }; return poll(() => __awaiter$4(this, void 0, void 0, function* () { const result = yield this.perform("getTransaction", params); if (result == null) { if (this._emitted["t:" + transactionHash] == null) { return null; } return void 0; } const tx = this.formatter.transactionResponse(result); if (tx.blockNumber == null) { tx.confirmations = 0; } else if (tx.confirmations == null) { const blockNumber = yield this._getInternalBlockNumber(100 + 2 * this.pollingInterval); let confirmations = blockNumber - tx.blockNumber + 1; if (confirmations <= 0) { confirmations = 1; } tx.confirmations = confirmations; } return this._wrapTransaction(tx); }), { oncePoll: this }); }); } getTransactionReceipt(transactionHash) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); transactionHash = yield transactionHash; const params = { transactionHash: this.formatter.hash(transactionHash, true) }; return poll(() => __awaiter$4(this, void 0, void 0, function* () { const result = yield this.perform("getTransactionReceipt", params); if (result == null) { if (this._emitted["t:" + transactionHash] == null) { return null; } return void 0; } if (result.blockHash == null) { return void 0; } const receipt = this.formatter.receipt(result); if (receipt.blockNumber == null) { receipt.confirmations = 0; } else if (receipt.confirmations == null) { const blockNumber = yield this._getInternalBlockNumber(100 + 2 * this.pollingInterval); let confirmations = blockNumber - receipt.blockNumber + 1; if (confirmations <= 0) { confirmations = 1; } receipt.confirmations = confirmations; } return receipt; }), { oncePoll: this }); }); } getLogs(filter) { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); const params = yield resolveProperties({ filter: this._getFilter(filter) }); const logs = yield this.perform("getLogs", params); logs.forEach((log) => { if (log.removed == null) { log.removed = false; } }); return Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(logs); }); } getEtherPrice() { return __awaiter$4(this, void 0, void 0, function* () { yield this.getNetwork(); return this.perform("getEtherPrice", {}); }); } _getBlockTag(blockTag) { return __awaiter$4(this, void 0, void 0, function* () { blockTag = yield blockTag; if (typeof blockTag === "number" && blockTag < 0) { if (blockTag % 1) { logger$7.throwArgumentError("invalid BlockTag", "blockTag", blockTag); } let blockNumber = yield this._getInternalBlockNumber(100 + 2 * this.pollingInterval); blockNumber += blockTag; if (blockNumber < 0) { blockNumber = 0; } return this.formatter.blockTag(blockNumber); } return this.formatter.blockTag(blockTag); }); } getResolver(name) { return __awaiter$4(this, void 0, void 0, function* () { let currentName = name; while (true) { if (currentName === "" || currentName === ".") { return null; } if (name !== "eth" && currentName === "eth") { return null; } const addr = yield this._getResolver(currentName, "getResolver"); if (addr != null) { const resolver = new Resolver(this, addr, name); if (currentName !== name && !(yield resolver.supportsWildcard())) { return null; } return resolver; } currentName = currentName.split(".").slice(1).join("."); } }); } _getResolver(name, operation) { return __awaiter$4(this, void 0, void 0, function* () { if (operation == null) { operation = "ENS"; } const network = yield this.getNetwork(); if (!network.ensAddress) { logger$7.throwError("network does not support ENS", Logger.errors.UNSUPPORTED_OPERATION, { operation, network: network.name }); } try { const addrData = yield this.call({ to: network.ensAddress, data: "0x0178b8bf" + namehash(name).substring(2) }); return this.formatter.callAddress(addrData); } catch (error) { } return null; }); } resolveName(name) { return __awaiter$4(this, void 0, void 0, function* () { name = yield name; try { return Promise.resolve(this.formatter.address(name)); } catch (error) { if (isHexString(name)) { throw error; } } if (typeof name !== "string") { logger$7.throwArgumentError("invalid ENS name", "name", name); } const resolver = yield this.getResolver(name); if (!resolver) { return null; } return yield resolver.getAddress(); }); } lookupAddress(address) { return __awaiter$4(this, void 0, void 0, function* () { address = yield address; address = this.formatter.address(address); const node = address.substring(2).toLowerCase() + ".addr.reverse"; const resolverAddr = yield this._getResolver(node, "lookupAddress"); if (resolverAddr == null) { return null; } const name = _parseString(yield this.call({ to: resolverAddr, data: "0x691f3431" + namehash(node).substring(2) }), 0); const addr = yield this.resolveName(name); if (addr != address) { return null; } return name; }); } getAvatar(nameOrAddress) { return __awaiter$4(this, void 0, void 0, function* () { let resolver = null; if (isHexString(nameOrAddress)) { const address = this.formatter.address(nameOrAddress); const node = address.substring(2).toLowerCase() + ".addr.reverse"; const resolverAddress = yield this._getResolver(node, "getAvatar"); if (!resolverAddress) { return null; } resolver = new Resolver(this, resolverAddress, node); try { const avatar2 = yield resolver.getAvatar(); if (avatar2) { return avatar2.url; } } catch (error) { if (error.code !== Logger.errors.CALL_EXCEPTION) { throw error; } } try { const name = _parseString(yield this.call({ to: resolverAddress, data: "0x691f3431" + namehash(node).substring(2) }), 0); resolver = yield this.getResolver(name); } catch (error) { if (error.code !== Logger.errors.CALL_EXCEPTION) { throw error; } return null; } } else { resolver = yield this.getResolver(nameOrAddress); if (!resolver) { return null; } } const avatar = yield resolver.getAvatar(); if (avatar == null) { return null; } return avatar.url; }); } perform(method, params) { return logger$7.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method }); } _startEvent(event) { this.polling = this._events.filter((e) => e.pollable()).length > 0; } _stopEvent(event) { this.polling = this._events.filter((e) => e.pollable()).length > 0; } _addEventListener(eventName, listener, once) { const event = new Event(getEventTag(eventName), listener, once); this._events.push(event); this._startEvent(event); return this; } on(eventName, listener) { return this._addEventListener(eventName, listener, false); } once(eventName, listener) { return this._addEventListener(eventName, listener, true); } emit(eventName, ...args) { let result = false; let stopped = []; let eventTag = getEventTag(eventName); this._events = this._events.filter((event) => { if (event.tag !== eventTag) { return true; } setTimeout(() => { event.listener.apply(this, args); }, 0); result = true; if (event.once) { stopped.push(event); return false; } return true; }); stopped.forEach((event) => { this._stopEvent(event); }); return result; } listenerCount(eventName) { if (!eventName) { return this._events.length; } let eventTag = getEventTag(eventName); return this._events.filter((event) => { return event.tag === eventTag; }).length; } listeners(eventName) { if (eventName == null) { return this._events.map((event) => event.listener); } let eventTag = getEventTag(eventName); return this._events.filter((event) => event.tag === eventTag).map((event) => event.listener); } off(eventName, listener) { if (listener == null) { return this.removeAllListeners(eventName); } const stopped = []; let found = false; let eventTag = getEventTag(eventName); this._events = this._events.filter((event) => { if (event.tag !== eventTag || event.listener != listener) { return true; } if (found) { return true; } found = true; stopped.push(event); return false; }); stopped.forEach((event) => { this._stopEvent(event); }); return this; } removeAllListeners(eventName) { let stopped = []; if (eventName == null) { stopped = this._events; this._events = []; } else { const eventTag = getEventTag(eventName); this._events = this._events.filter((event) => { if (event.tag !== eventTag) { return true; } stopped.push(event); return false; }); } stopped.forEach((event) => { this._stopEvent(event); }); return this; } } var __awaiter$3 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$6 = new Logger(version$3); const errorGas = ["call", "estimateGas"]; function spelunk(value, requireData) { if (value == null) { return null; } if (typeof value.message === "string" && value.message.match("reverted")) { const data = isHexString(value.data) ? value.data : null; if (!requireData || data) { return { message: value.message, data }; } } if (typeof value === "object") { for (const key2 in value) { const result = spelunk(value[key2], requireData); if (result) { return result; } } return null; } if (typeof value === "string") { try { return spelunk(JSON.parse(value), requireData); } catch (error) { } } return null; } function checkError(method, error, params) { const transaction = params.transaction || params.signedTransaction; if (method === "call") { const result = spelunk(error, true); if (result) { return result.data; } logger$6.throwError("missing revert data in call exception; Transaction reverted without a reason string", Logger.errors.CALL_EXCEPTION, { data: "0x", transaction, error }); } if (method === "estimateGas") { let result = spelunk(error.body, false); if (result == null) { result = spelunk(error, false); } if (result) { logger$6.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { reason: result.message, method, transaction, error }); } } let message = error.message; if (error.code === Logger.errors.SERVER_ERROR && error.error && typeof error.error.message === "string") { message = error.error.message; } else if (typeof error.body === "string") { message = error.body; } else if (typeof error.responseText === "string") { message = error.responseText; } message = (message || "").toLowerCase(); if (message.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)) { logger$6.throwError("insufficient funds for intrinsic transaction cost", Logger.errors.INSUFFICIENT_FUNDS, { error, method, transaction }); } if (message.match(/nonce (is )?too low/i)) { logger$6.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, { error, method, transaction }); } if (message.match(/replacement transaction underpriced|transaction gas price.*too low/i)) { logger$6.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, { error, method, transaction }); } if (message.match(/only replay-protected/i)) { logger$6.throwError("legacy pre-eip-155 transactions not supported", Logger.errors.UNSUPPORTED_OPERATION, { error, method, transaction }); } if (errorGas.indexOf(method) >= 0 && message.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)) { logger$6.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { error, method, transaction }); } throw error; } function timer(timeout) { return new Promise(function(resolve) { setTimeout(resolve, timeout); }); } function getResult(payload) { if (payload.error) { const error = new Error(payload.error.message); error.code = payload.error.code; error.data = payload.error.data; throw error; } return payload.result; } function getLowerCase(value) { if (value) { return value.toLowerCase(); } return value; } const _constructorGuard = {}; class JsonRpcSigner extends Signer { constructor(constructorGuard, provider, addressOrIndex) { super(); if (constructorGuard !== _constructorGuard) { throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); } defineReadOnly(this, "provider", provider); if (addressOrIndex == null) { addressOrIndex = 0; } if (typeof addressOrIndex === "string") { defineReadOnly(this, "_address", this.provider.formatter.address(addressOrIndex)); defineReadOnly(this, "_index", null); } else if (typeof addressOrIndex === "number") { defineReadOnly(this, "_index", addressOrIndex); defineReadOnly(this, "_address", null); } else { logger$6.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); } } connect(provider) { return logger$6.throwError("cannot alter JSON-RPC Signer connection", Logger.errors.UNSUPPORTED_OPERATION, { operation: "connect" }); } connectUnchecked() { return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index); } getAddress() { if (this._address) { return Promise.resolve(this._address); } return this.provider.send("eth_accounts", []).then((accounts) => { if (accounts.length <= this._index) { logger$6.throwError("unknown account #" + this._index, Logger.errors.UNSUPPORTED_OPERATION, { operation: "getAddress" }); } return this.provider.formatter.address(accounts[this._index]); }); } sendUncheckedTransaction(transaction) { transaction = shallowCopy(transaction); const fromAddress = this.getAddress().then((address) => { if (address) { address = address.toLowerCase(); } return address; }); if (transaction.gasLimit == null) { const estimate = shallowCopy(transaction); estimate.from = fromAddress; transaction.gasLimit = this.provider.estimateGas(estimate); } if (transaction.to != null) { transaction.to = Promise.resolve(transaction.to).then((to) => __awaiter$3(this, void 0, void 0, function* () { if (to == null) { return null; } const address = yield this.provider.resolveName(to); if (address == null) { logger$6.throwArgumentError("provided ENS name resolves to null", "tx.to", to); } return address; })); } return resolveProperties({ tx: resolveProperties(transaction), sender: fromAddress }).then(({ tx, sender }) => { if (tx.from != null) { if (tx.from.toLowerCase() !== sender) { logger$6.throwArgumentError("from address mismatch", "transaction", transaction); } } else { tx.from = sender; } const hexTx = this.provider.constructor.hexlifyTransaction(tx, { from: true }); return this.provider.send("eth_sendTransaction", [hexTx]).then((hash2) => { return hash2; }, (error) => { if (typeof error.message === "string" && error.message.match(/user denied/i)) { logger$6.throwError("user rejected transaction", Logger.errors.ACTION_REJECTED, { action: "sendTransaction", transaction: tx }); } return checkError("sendTransaction", error, hexTx); }); }); } signTransaction(transaction) { return logger$6.throwError("signing transactions is unsupported", Logger.errors.UNSUPPORTED_OPERATION, { operation: "signTransaction" }); } sendTransaction(transaction) { return __awaiter$3(this, void 0, void 0, function* () { const blockNumber = yield this.provider._getInternalBlockNumber(100 + 2 * this.provider.pollingInterval); const hash2 = yield this.sendUncheckedTransaction(transaction); try { return yield poll(() => __awaiter$3(this, void 0, void 0, function* () { const tx = yield this.provider.getTransaction(hash2); if (tx === null) { return void 0; } return this.provider._wrapTransaction(tx, hash2, blockNumber); }), { oncePoll: this.provider }); } catch (error) { error.transactionHash = hash2; throw error; } }); } signMessage(message) { return __awaiter$3(this, void 0, void 0, function* () { const data = typeof message === "string" ? toUtf8Bytes(message) : message; const address = yield this.getAddress(); try { return yield this.provider.send("personal_sign", [hexlify(data), address.toLowerCase()]); } catch (error) { if (typeof error.message === "string" && error.message.match(/user denied/i)) { logger$6.throwError("user rejected signing", Logger.errors.ACTION_REJECTED, { action: "signMessage", from: address, messageData: message }); } throw error; } }); } _legacySignMessage(message) { return __awaiter$3(this, void 0, void 0, function* () { const data = typeof message === "string" ? toUtf8Bytes(message) : message; const address = yield this.getAddress(); try { return yield this.provider.send("eth_sign", [address.toLowerCase(), hexlify(data)]); } catch (error) { if (typeof error.message === "string" && error.message.match(/user denied/i)) { logger$6.throwError("user rejected signing", Logger.errors.ACTION_REJECTED, { action: "_legacySignMessage", from: address, messageData: message }); } throw error; } }); } _signTypedData(domain, types, value) { return __awaiter$3(this, void 0, void 0, function* () { const populated = yield TypedDataEncoder.resolveNames(domain, types, value, (name) => { return this.provider.resolveName(name); }); const address = yield this.getAddress(); try { return yield this.provider.send("eth_signTypedData_v4", [ address.toLowerCase(), JSON.stringify(TypedDataEncoder.getPayload(populated.domain, types, populated.value)) ]); } catch (error) { if (typeof error.message === "string" && error.message.match(/user denied/i)) { logger$6.throwError("user rejected signing", Logger.errors.ACTION_REJECTED, { action: "_signTypedData", from: address, messageData: { domain: populated.domain, types, value: populated.value } }); } throw error; } }); } unlock(password) { return __awaiter$3(this, void 0, void 0, function* () { const provider = this.provider; const address = yield this.getAddress(); return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]); }); } } class UncheckedJsonRpcSigner extends JsonRpcSigner { sendTransaction(transaction) { return this.sendUncheckedTransaction(transaction).then((hash2) => { return { hash: hash2, nonce: null, gasLimit: null, gasPrice: null, data: null, value: null, chainId: null, confirmations: 0, from: null, wait: (confirmations) => { return this.provider.waitForTransaction(hash2, confirmations); } }; }); } } const allowedTransactionKeys = { chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true, type: true, accessList: true, maxFeePerGas: true, maxPriorityFeePerGas: true }; class JsonRpcProvider extends BaseProvider { constructor(url, network) { let networkOrReady = network; if (networkOrReady == null) { networkOrReady = new Promise((resolve, reject) => { setTimeout(() => { this.detectNetwork().then((network2) => { resolve(network2); }, (error) => { reject(error); }); }, 0); }); } super(networkOrReady); if (!url) { url = getStatic(this.constructor, "defaultUrl")(); } if (typeof url === "string") { defineReadOnly(this, "connection", Object.freeze({ url })); } else { defineReadOnly(this, "connection", Object.freeze(shallowCopy(url))); } this._nextId = 42; } get _cache() { if (this._eventLoopCache == null) { this._eventLoopCache = {}; } return this._eventLoopCache; } static defaultUrl() { return "http://localhost:8545"; } detectNetwork() { if (!this._cache["detectNetwork"]) { this._cache["detectNetwork"] = this._uncachedDetectNetwork(); setTimeout(() => { this._cache["detectNetwork"] = null; }, 0); } return this._cache["detectNetwork"]; } _uncachedDetectNetwork() { return __awaiter$3(this, void 0, void 0, function* () { yield timer(0); let chainId = null; try { chainId = yield this.send("eth_chainId", []); } catch (error) { try { chainId = yield this.send("net_version", []); } catch (error2) { } } if (chainId != null) { const getNetwork2 = getStatic(this.constructor, "getNetwork"); try { return getNetwork2(BigNumber.from(chainId).toNumber()); } catch (error) { return logger$6.throwError("could not detect network", Logger.errors.NETWORK_ERROR, { chainId, event: "invalidNetwork", serverError: error }); } } return logger$6.throwError("could not detect network", Logger.errors.NETWORK_ERROR, { event: "noNetwork" }); }); } getSigner(addressOrIndex) { return new JsonRpcSigner(_constructorGuard, this, addressOrIndex); } getUncheckedSigner(addressOrIndex) { return this.getSigner(addressOrIndex).connectUnchecked(); } listAccounts() { return this.send("eth_accounts", []).then((accounts) => { return accounts.map((a2) => this.formatter.address(a2)); }); } send(method, params) { const request = { method, params, id: this._nextId++, jsonrpc: "2.0" }; this.emit("debug", { action: "request", request: deepCopy(request), provider: this }); const cache = ["eth_chainId", "eth_blockNumber"].indexOf(method) >= 0; if (cache && this._cache[method]) { return this._cache[method]; } const result = fetchJson(this.connection, JSON.stringify(request), getResult).then((result2) => { this.emit("debug", { action: "response", request, response: result2, provider: this }); return result2; }, (error) => { this.emit("debug", { action: "response", error, request, provider: this }); throw error; }); if (cache) { this._cache[method] = result; setTimeout(() => { this._cache[method] = null; }, 0); } return result; } prepareRequest(method, params) { switch (method) { case "getBlockNumber": return ["eth_blockNumber", []]; case "getGasPrice": return ["eth_gasPrice", []]; case "getBalance": return ["eth_getBalance", [getLowerCase(params.address), params.blockTag]]; case "getTransactionCount": return ["eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]]; case "getCode": return ["eth_getCode", [getLowerCase(params.address), params.blockTag]]; case "getStorageAt": return ["eth_getStorageAt", [getLowerCase(params.address), hexZeroPad(params.position, 32), params.blockTag]]; case "sendTransaction": return ["eth_sendRawTransaction", [params.signedTransaction]]; case "getBlock": if (params.blockTag) { return ["eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]]; } else if (params.blockHash) { return ["eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]]; } return null; case "getTransaction": return ["eth_getTransactionByHash", [params.transactionHash]]; case "getTransactionReceipt": return ["eth_getTransactionReceipt", [params.transactionHash]]; case "call": { const hexlifyTransaction = getStatic(this.constructor, "hexlifyTransaction"); return ["eth_call", [hexlifyTransaction(params.transaction, { from: true }), params.blockTag]]; } case "estimateGas": { const hexlifyTransaction = getStatic(this.constructor, "hexlifyTransaction"); return ["eth_estimateGas", [hexlifyTransaction(params.transaction, { from: true })]]; } case "getLogs": if (params.filter && params.filter.address != null) { params.filter.address = getLowerCase(params.filter.address); } return ["eth_getLogs", [params.filter]]; } return null; } perform(method, params) { return __awaiter$3(this, void 0, void 0, function* () { if (method === "call" || method === "estimateGas") { const tx = params.transaction; if (tx && tx.type != null && BigNumber.from(tx.type).isZero()) { if (tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null) { const feeData = yield this.getFeeData(); if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) { params = shallowCopy(params); params.transaction = shallowCopy(tx); delete params.transaction.type; } } } } const args = this.prepareRequest(method, params); if (args == null) { logger$6.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method }); } try { return yield this.send(args[0], args[1]); } catch (error) { return checkError(method, error, params); } }); } _startEvent(event) { if (event.tag === "pending") { this._startPending(); } super._startEvent(event); } _startPending() { if (this._pendingFilter != null) { return; } const self2 = this; const pendingFilter = this.send("eth_newPendingTransactionFilter", []); this._pendingFilter = pendingFilter; pendingFilter.then(function(filterId) { function poll2() { self2.send("eth_getFilterChanges", [filterId]).then(function(hashes) { if (self2._pendingFilter != pendingFilter) { return null; } let seq = Promise.resolve(); hashes.forEach(function(hash2) { self2._emitted["t:" + hash2.toLowerCase()] = "pending"; seq = seq.then(function() { return self2.getTransaction(hash2).then(function(tx) { self2.emit("pending", tx); return null; }); }); }); return seq.then(function() { return timer(1e3); }); }).then(function() { if (self2._pendingFilter != pendingFilter) { self2.send("eth_uninstallFilter", [filterId]); return; } setTimeout(function() { poll2(); }, 0); return null; }).catch((error) => { }); } poll2(); return filterId; }).catch((error) => { }); } _stopEvent(event) { if (event.tag === "pending" && this.listenerCount("pending") === 0) { this._pendingFilter = null; } super._stopEvent(event); } // Convert an ethers.js transaction into a JSON-RPC transaction // - gasLimit => gas // - All values hexlified // - All numeric values zero-striped // - All addresses are lowercased // NOTE: This allows a TransactionRequest, but all values should be resolved // before this is called // @TODO: This will likely be removed in future versions and prepareRequest // will be the preferred method for this. static hexlifyTransaction(transaction, allowExtra) { const allowed = shallowCopy(allowedTransactionKeys); if (allowExtra) { for (const key2 in allowExtra) { if (allowExtra[key2]) { allowed[key2] = true; } } } checkProperties(transaction, allowed); const result = {}; ["chainId", "gasLimit", "gasPrice", "type", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "value"].forEach(function(key2) { if (transaction[key2] == null) { return; } const value = hexValue(BigNumber.from(transaction[key2])); if (key2 === "gasLimit") { key2 = "gas"; } result[key2] = value; }); ["from", "to", "data"].forEach(function(key2) { if (transaction[key2] == null) { return; } result[key2] = hexlify(transaction[key2]); }); if (transaction.accessList) { result["accessList"] = accessListify(transaction.accessList); } return result; } } let WS = null; try { WS = WebSocket; if (WS == null) { throw new Error("inject please"); } } catch (error) { const logger2 = new Logger(version$3); WS = function() { logger2.throwError("WebSockets not supported in this environment", Logger.errors.UNSUPPORTED_OPERATION, { operation: "new WebSocket()" }); }; } var __awaiter$2 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$5 = new Logger(version$3); let NextId = 1; class WebSocketProvider extends JsonRpcProvider { constructor(url, network) { if (network === "any") { logger$5.throwError("WebSocketProvider does not support 'any' network yet", Logger.errors.UNSUPPORTED_OPERATION, { operation: "network:any" }); } if (typeof url === "string") { super(url, network); } else { super("_websocket", network); } this._pollingInterval = -1; this._wsReady = false; if (typeof url === "string") { defineReadOnly(this, "_websocket", new WS(this.connection.url)); } else { defineReadOnly(this, "_websocket", url); } defineReadOnly(this, "_requests", {}); defineReadOnly(this, "_subs", {}); defineReadOnly(this, "_subIds", {}); defineReadOnly(this, "_detectNetwork", super.detectNetwork()); this.websocket.onopen = () => { this._wsReady = true; Object.keys(this._requests).forEach((id2) => { this.websocket.send(this._requests[id2].payload); }); }; this.websocket.onmessage = (messageEvent) => { const data = messageEvent.data; const result = JSON.parse(data); if (result.id != null) { const id2 = String(result.id); const request = this._requests[id2]; delete this._requests[id2]; if (result.result !== void 0) { request.callback(null, result.result); this.emit("debug", { action: "response", request: JSON.parse(request.payload), response: result.result, provider: this }); } else { let error = null; if (result.error) { error = new Error(result.error.message || "unknown error"); defineReadOnly(error, "code", result.error.code || null); defineReadOnly(error, "response", data); } else { error = new Error("unknown error"); } request.callback(error, void 0); this.emit("debug", { action: "response", error, request: JSON.parse(request.payload), provider: this }); } } else if (result.method === "eth_subscription") { const sub = this._subs[result.params.subscription]; if (sub) { sub.processFunc(result.params.result); } } else { console.warn("this should not happen"); } }; const fauxPoll = setInterval(() => { this.emit("poll"); }, 1e3); if (fauxPoll.unref) { fauxPoll.unref(); } } // Cannot narrow the type of _websocket, as that is not backwards compatible // so we add a getter and let the WebSocket be a public API. get websocket() { return this._websocket; } detectNetwork() { return this._detectNetwork; } get pollingInterval() { return 0; } resetEventsBlock(blockNumber) { logger$5.throwError("cannot reset events block on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, { operation: "resetEventBlock" }); } set pollingInterval(value) { logger$5.throwError("cannot set polling interval on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, { operation: "setPollingInterval" }); } poll() { return __awaiter$2(this, void 0, void 0, function* () { return null; }); } set polling(value) { if (!value) { return; } logger$5.throwError("cannot set polling on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, { operation: "setPolling" }); } send(method, params) { const rid = NextId++; return new Promise((resolve, reject) => { function callback(error, result) { if (error) { return reject(error); } return resolve(result); } const payload = JSON.stringify({ method, params, id: rid, jsonrpc: "2.0" }); this.emit("debug", { action: "request", request: JSON.parse(payload), provider: this }); this._requests[String(rid)] = { callback, payload }; if (this._wsReady) { this.websocket.send(payload); } }); } static defaultUrl() { return "ws://localhost:8546"; } _subscribe(tag, param, processFunc) { return __awaiter$2(this, void 0, void 0, function* () { let subIdPromise = this._subIds[tag]; if (subIdPromise == null) { subIdPromise = Promise.all(param).then((param2) => { return this.send("eth_subscribe", param2); }); this._subIds[tag] = subIdPromise; } const subId = yield subIdPromise; this._subs[subId] = { tag, processFunc }; }); } _startEvent(event) { switch (event.type) { case "block": this._subscribe("block", ["newHeads"], (result) => { const blockNumber = BigNumber.from(result.number).toNumber(); this._emitted.block = blockNumber; this.emit("block", blockNumber); }); break; case "pending": this._subscribe("pending", ["newPendingTransactions"], (result) => { this.emit("pending", result); }); break; case "filter": this._subscribe(event.tag, ["logs", this._getFilter(event.filter)], (result) => { if (result.removed == null) { result.removed = false; } this.emit(event.filter, this.formatter.filterLog(result)); }); break; case "tx": { const emitReceipt = (event2) => { const hash2 = event2.hash; this.getTransactionReceipt(hash2).then((receipt) => { if (!receipt) { return; } this.emit(hash2, receipt); }); }; emitReceipt(event); this._subscribe("tx", ["newHeads"], (result) => { this._events.filter((e) => e.type === "tx").forEach(emitReceipt); }); break; } case "debug": case "poll": case "willPoll": case "didPoll": case "error": break; default: console.log("unhandled:", event); break; } } _stopEvent(event) { let tag = event.tag; if (event.type === "tx") { if (this._events.filter((e) => e.type === "tx").length) { return; } tag = "tx"; } else if (this.listenerCount(event.event)) { return; } const subId = this._subIds[tag]; if (!subId) { return; } delete this._subIds[tag]; subId.then((subId2) => { if (!this._subs[subId2]) { return; } delete this._subs[subId2]; this.send("eth_unsubscribe", [subId2]); }); } destroy() { return __awaiter$2(this, void 0, void 0, function* () { if (this.websocket.readyState === WS.CONNECTING) { yield new Promise((resolve) => { this.websocket.onopen = function() { resolve(true); }; this.websocket.onerror = function() { resolve(false); }; }); } this.websocket.close(1e3); }); } } var __awaiter$1 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$4 = new Logger(version$3); class StaticJsonRpcProvider extends JsonRpcProvider { detectNetwork() { const _super = Object.create(null, { detectNetwork: { get: () => super.detectNetwork } }); return __awaiter$1(this, void 0, void 0, function* () { let network = this.network; if (network == null) { network = yield _super.detectNetwork.call(this); if (!network) { logger$4.throwError("no network detected", Logger.errors.UNKNOWN_ERROR, {}); } if (this._network == null) { defineReadOnly(this, "_network", network); this.emit("network", network, null); } } return network; }); } } var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger$3 = new Logger(version$3); function now() { return new Date().getTime(); } function checkNetworks(networks2) { let result = null; for (let i2 = 0; i2 < networks2.length; i2++) { const network = networks2[i2]; if (network == null) { return null; } if (result) { if (!(result.name === network.name && result.chainId === network.chainId && (result.ensAddress === network.ensAddress || result.ensAddress == null && network.ensAddress == null))) { logger$3.throwArgumentError("provider mismatch", "networks", networks2); } } else { result = network; } } return result; } function median(values, maxDelta) { values = values.slice().sort(); const middle = Math.floor(values.length / 2); if (values.length % 2) { return values[middle]; } const a2 = values[middle - 1], b2 = values[middle]; if (maxDelta != null && Math.abs(a2 - b2) > maxDelta) { return null; } return (a2 + b2) / 2; } function serialize$1(value) { if (value === null) { return "null"; } else if (typeof value === "number" || typeof value === "boolean") { return JSON.stringify(value); } else if (typeof value === "string") { return value; } else if (BigNumber.isBigNumber(value)) { return value.toString(); } else if (Array.isArray(value)) { return JSON.stringify(value.map((i2) => serialize$1(i2))); } else if (typeof value === "object") { const keys = Object.keys(value); keys.sort(); return "{" + keys.map((key2) => { let v2 = value[key2]; if (typeof v2 === "function") { v2 = "[function]"; } else { v2 = serialize$1(v2); } return JSON.stringify(key2) + ":" + v2; }).join(",") + "}"; } throw new Error("unknown value type: " + typeof value); } let nextRid = 1; function stall(duration) { let cancel = null; let timer2 = null; let promise = new Promise((resolve) => { cancel = function() { if (timer2) { clearTimeout(timer2); timer2 = null; } resolve(); }; timer2 = setTimeout(cancel, duration); }); const wait = (func) => { promise = promise.then(func); return promise; }; function getPromise() { return promise; } return { cancel, getPromise, wait }; } const ForwardErrors = [ Logger.errors.CALL_EXCEPTION, Logger.errors.INSUFFICIENT_FUNDS, Logger.errors.NONCE_EXPIRED, Logger.errors.REPLACEMENT_UNDERPRICED, Logger.errors.UNPREDICTABLE_GAS_LIMIT ]; const ForwardProperties = [ "address", "args", "errorArgs", "errorSignature", "method", "transaction" ]; function exposeDebugConfig(config, now2) { const result = { weight: config.weight }; Object.defineProperty(result, "provider", { get: () => config.provider }); if (config.start) { result.start = config.start; } if (now2) { result.duration = now2 - config.start; } if (config.done) { if (config.error) { result.error = config.error; } else { result.result = config.result || null; } } return result; } function normalizedTally(normalize2, quorum) { return function(configs) { const tally = {}; configs.forEach((c2) => { const value = normalize2(c2.result); if (!tally[value]) { tally[value] = { count: 0, result: c2.result }; } tally[value].count++; }); const keys = Object.keys(tally); for (let i2 = 0; i2 < keys.length; i2++) { const check = tally[keys[i2]]; if (check.count >= quorum) { return check.result; } } return void 0; }; } function getProcessFunc(provider, method, params) { let normalize2 = serialize$1; switch (method) { case "getBlockNumber": return function(configs) { const values = configs.map((c2) => c2.result); let blockNumber = median(configs.map((c2) => c2.result), 2); if (blockNumber == null) { return void 0; } blockNumber = Math.ceil(blockNumber); if (values.indexOf(blockNumber + 1) >= 0) { blockNumber++; } if (blockNumber >= provider._highestBlockNumber) { provider._highestBlockNumber = blockNumber; } return provider._highestBlockNumber; }; case "getGasPrice": return function(configs) { const values = configs.map((c2) => c2.result); values.sort(); return values[Math.floor(values.length / 2)]; }; case "getEtherPrice": return function(configs) { return median(configs.map((c2) => c2.result)); }; case "getBalance": case "getTransactionCount": case "getCode": case "getStorageAt": case "call": case "estimateGas": case "getLogs": break; case "getTransaction": case "getTransactionReceipt": normalize2 = function(tx) { if (tx == null) { return null; } tx = shallowCopy(tx); tx.confirmations = -1; return serialize$1(tx); }; break; case "getBlock": if (params.includeTransactions) { normalize2 = function(block) { if (block == null) { return null; } block = shallowCopy(block); block.transactions = block.transactions.map((tx) => { tx = shallowCopy(tx); tx.confirmations = -1; return tx; }); return serialize$1(block); }; } else { normalize2 = function(block) { if (block == null) { return null; } return serialize$1(block); }; } break; default: throw new Error("unknown method: " + method); } return normalizedTally(normalize2, provider.quorum); } function waitForSync(config, blockNumber) { return __awaiter(this, void 0, void 0, function* () { const provider = config.provider; if (provider.blockNumber != null && provider.blockNumber >= blockNumber || blockNumber === -1) { return provider; } return poll(() => { return new Promise((resolve, reject) => { setTimeout(function() { if (provider.blockNumber >= blockNumber) { return resolve(provider); } if (config.cancelled) { return resolve(null); } return resolve(void 0); }, 0); }); }, { oncePoll: provider }); }); } function getRunner(config, currentBlockNumber, method, params) { return __awaiter(this, void 0, void 0, function* () { let provider = config.provider; switch (method) { case "getBlockNumber": case "getGasPrice": return provider[method](); case "getEtherPrice": if (provider.getEtherPrice) { return provider.getEtherPrice(); } break; case "getBalance": case "getTransactionCount": case "getCode": if (params.blockTag && isHexString(params.blockTag)) { provider = yield waitForSync(config, currentBlockNumber); } return provider[method](params.address, params.blockTag || "latest"); case "getStorageAt": if (params.blockTag && isHexString(params.blockTag)) { provider = yield waitForSync(config, currentBlockNumber); } return provider.getStorageAt(params.address, params.position, params.blockTag || "latest"); case "getBlock": if (params.blockTag && isHexString(params.blockTag)) { provider = yield waitForSync(config, currentBlockNumber); } return provider[params.includeTransactions ? "getBlockWithTransactions" : "getBlock"](params.blockTag || params.blockHash); case "call": case "estimateGas": if (params.blockTag && isHexString(params.blockTag)) { provider = yield waitForSync(config, currentBlockNumber); } if (method === "call" && params.blockTag) { return provider[method](params.transaction, params.blockTag); } return provider[method](params.transaction); case "getTransaction": case "getTransactionReceipt": return provider[method](params.transactionHash); case "getLogs": { let filter = params.filter; if (filter.fromBlock && isHexString(filter.fromBlock) || filter.toBlock && isHexString(filter.toBlock)) { provider = yield waitForSync(config, currentBlockNumber); } return provider.getLogs(filter); } } return logger$3.throwError("unknown method error", Logger.errors.UNKNOWN_ERROR, { method, params }); }); } class FallbackProvider extends BaseProvider { constructor(providers, quorum) { if (providers.length === 0) { logger$3.throwArgumentError("missing providers", "providers", providers); } const providerConfigs = providers.map((configOrProvider, index) => { if (Provider.isProvider(configOrProvider)) { const stallTimeout = isCommunityResource(configOrProvider) ? 2e3 : 750; const priority = 1; return Object.freeze({ provider: configOrProvider, weight: 1, stallTimeout, priority }); } const config = shallowCopy(configOrProvider); if (config.priority == null) { config.priority = 1; } if (config.stallTimeout == null) { config.stallTimeout = isCommunityResource(configOrProvider) ? 2e3 : 750; } if (config.weight == null) { config.weight = 1; } const weight = config.weight; if (weight % 1 || weight > 512 || weight < 1) { logger$3.throwArgumentError("invalid weight; must be integer in [1, 512]", `providers[${index}].weight`, weight); } return Object.freeze(config); }); const total = providerConfigs.reduce((accum, c2) => accum + c2.weight, 0); if (quorum == null) { quorum = total / 2; } else if (quorum > total) { logger$3.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); } let networkOrReady = checkNetworks(providerConfigs.map((c2) => c2.provider.network)); if (networkOrReady == null) { networkOrReady = new Promise((resolve, reject) => { setTimeout(() => { this.detectNetwork().then(resolve, reject); }, 0); }); } super(networkOrReady); defineReadOnly(this, "providerConfigs", Object.freeze(providerConfigs)); defineReadOnly(this, "quorum", quorum); this._highestBlockNumber = -1; } detectNetwork() { return __awaiter(this, void 0, void 0, function* () { const networks2 = yield Promise.all(this.providerConfigs.map((c2) => c2.provider.getNetwork())); return checkNetworks(networks2); }); } perform(method, params) { return __awaiter(this, void 0, void 0, function* () { if (method === "sendTransaction") { const results = yield Promise.all(this.providerConfigs.map((c2) => { return c2.provider.sendTransaction(params.signedTransaction).then((result) => { return result.hash; }, (error) => { return error; }); })); for (let i3 = 0; i3 < results.length; i3++) { const result = results[i3]; if (typeof result === "string") { return result; } } throw results[0]; } if (this._highestBlockNumber === -1 && method !== "getBlockNumber") { yield this.getBlockNumber(); } const processFunc = getProcessFunc(this, method, params); const configs = shuffled(this.providerConfigs.map(shallowCopy)); configs.sort((a2, b2) => a2.priority - b2.priority); const currentBlockNumber = this._highestBlockNumber; let i2 = 0; let first = true; while (true) { const t0 = now(); let inflightWeight = configs.filter((c2) => c2.runner && t0 - c2.start < c2.stallTimeout).reduce((accum, c2) => accum + c2.weight, 0); while (inflightWeight < this.quorum && i2 < configs.length) { const config = configs[i2++]; const rid = nextRid++; config.start = now(); config.staller = stall(config.stallTimeout); config.staller.wait(() => { config.staller = null; }); config.runner = getRunner(config, currentBlockNumber, method, params).then((result) => { config.done = true; config.result = result; if (this.listenerCount("debug")) { this.emit("debug", { action: "request", rid, backend: exposeDebugConfig(config, now()), request: { method, params: deepCopy(params) }, provider: this }); } }, (error) => { config.done = true; config.error = error; if (this.listenerCount("debug")) { this.emit("debug", { action: "request", rid, backend: exposeDebugConfig(config, now()), request: { method, params: deepCopy(params) }, provider: this }); } }); if (this.listenerCount("debug")) { this.emit("debug", { action: "request", rid, backend: exposeDebugConfig(config, null), request: { method, params: deepCopy(params) }, provider: this }); } inflightWeight += config.weight; } const waiting = []; configs.forEach((c2) => { if (c2.done || !c2.runner) { return; } waiting.push(c2.runner); if (c2.staller) { waiting.push(c2.staller.getPromise()); } }); if (waiting.length) { yield Promise.race(waiting); } const results = configs.filter((c2) => c2.done && c2.error == null); if (results.length >= this.quorum) { const result = processFunc(results); if (result !== void 0) { configs.forEach((c2) => { if (c2.staller) { c2.staller.cancel(); } c2.cancelled = true; }); return result; } if (!first) { yield stall(100).getPromise(); } first = false; } const errors = configs.reduce((accum, c2) => { if (!c2.done || c2.error == null) { return accum; } const code2 = c2.error.code; if (ForwardErrors.indexOf(code2) >= 0) { if (!accum[code2]) { accum[code2] = { error: c2.error, weight: 0 }; } accum[code2].weight += c2.weight; } return accum; }, {}); Object.keys(errors).forEach((errorCode) => { const tally = errors[errorCode]; if (tally.weight < this.quorum) { return; } configs.forEach((c2) => { if (c2.staller) { c2.staller.cancel(); } c2.cancelled = true; }); const e = tally.error; const props = {}; ForwardProperties.forEach((name) => { if (e[name] == null) { return; } props[name] = e[name]; }); logger$3.throwError(e.reason || e.message, errorCode, props); }); if (configs.filter((c2) => !c2.done).length === 0) { break; } } configs.forEach((c2) => { if (c2.staller) { c2.staller.cancel(); } c2.cancelled = true; }); return logger$3.throwError("failed to meet quorum", Logger.errors.SERVER_ERROR, { method, params, //results: configs.map((c) => c.result), //errors: configs.map((c) => c.error), results: configs.map((c2) => exposeDebugConfig(c2)), provider: this }); }); } } const logger$2 = new Logger(version$3); let _nextId = 1; function buildWeb3LegacyFetcher(provider, sendFunc) { const fetcher = "Web3LegacyFetcher"; return function(method, params) { const request = { method, params, id: _nextId++, jsonrpc: "2.0" }; return new Promise((resolve, reject) => { this.emit("debug", { action: "request", fetcher, request: deepCopy(request), provider: this }); sendFunc(request, (error, response) => { if (error) { this.emit("debug", { action: "response", fetcher, error, request, provider: this }); return reject(error); } this.emit("debug", { action: "response", fetcher, request, response, provider: this }); if (response.error) { const error2 = new Error(response.error.message); error2.code = response.error.code; error2.data = response.error.data; return reject(error2); } resolve(response.result); }); }); }; } function buildEip1193Fetcher(provider) { return function(method, params) { if (params == null) { params = []; } const request = { method, params }; this.emit("debug", { action: "request", fetcher: "Eip1193Fetcher", request: deepCopy(request), provider: this }); return provider.request(request).then((response) => { this.emit("debug", { action: "response", fetcher: "Eip1193Fetcher", request, response, provider: this }); return response; }, (error) => { this.emit("debug", { action: "response", fetcher: "Eip1193Fetcher", request, error, provider: this }); throw error; }); }; } class Web3Provider extends JsonRpcProvider { constructor(provider, network) { if (provider == null) { logger$2.throwArgumentError("missing provider", "provider", provider); } let path = null; let jsonRpcFetchFunc = null; let subprovider = null; if (typeof provider === "function") { path = "unknown:"; jsonRpcFetchFunc = provider; } else { path = provider.host || provider.path || ""; if (!path && provider.isMetaMask) { path = "metamask"; } subprovider = provider; if (provider.request) { if (path === "") { path = "eip-1193:"; } jsonRpcFetchFunc = buildEip1193Fetcher(provider); } else if (provider.sendAsync) { jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.sendAsync.bind(provider)); } else if (provider.send) { jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.send.bind(provider)); } else { logger$2.throwArgumentError("unsupported provider", "provider", provider); } if (!path) { path = "unknown:"; } } super(path, network); defineReadOnly(this, "jsonRpcFetchFunc", jsonRpcFetchFunc); defineReadOnly(this, "provider", subprovider); } send(method, params) { return this.jsonRpcFetchFunc(method, params); } } const version$2 = "solidity/5.7.0"; const regexBytes = new RegExp("^bytes([0-9]+)$"); const regexNumber = new RegExp("^(u?int)([0-9]*)$"); const regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$"); const Zeros = "0000000000000000000000000000000000000000000000000000000000000000"; const logger$1 = new Logger(version$2); function _pack(type, value, isArray) { switch (type) { case "address": if (isArray) { return zeroPad(value, 32); } return arrayify(value); case "string": return toUtf8Bytes(value); case "bytes": return arrayify(value); case "bool": value = value ? "0x01" : "0x00"; if (isArray) { return zeroPad(value, 32); } return arrayify(value); } let match = type.match(regexNumber); if (match) { let size = parseInt(match[2] || "256"); if (match[2] && String(size) !== match[2] || size % 8 !== 0 || size === 0 || size > 256) { logger$1.throwArgumentError("invalid number type", "type", type); } if (isArray) { size = 256; } value = BigNumber.from(value).toTwos(size); return zeroPad(value, size / 8); } match = type.match(regexBytes); if (match) { const size = parseInt(match[1]); if (String(size) !== match[1] || size === 0 || size > 32) { logger$1.throwArgumentError("invalid bytes type", "type", type); } if (arrayify(value).byteLength !== size) { logger$1.throwArgumentError(`invalid value for ${type}`, "value", value); } if (isArray) { return arrayify((value + Zeros).substring(0, 66)); } return value; } match = type.match(regexArray); if (match && Array.isArray(value)) { const baseType = match[1]; const count = parseInt(match[2] || String(value.length)); if (count != value.length) { logger$1.throwArgumentError(`invalid array length for ${type}`, "value", value); } const result = []; value.forEach(function(value2) { result.push(_pack(baseType, value2, true)); }); return concat(result); } return logger$1.throwArgumentError("invalid type", "type", type); } function pack(types, values) { if (types.length != values.length) { logger$1.throwArgumentError("wrong number of values; expected ${ types.length }", "values", values); } const tight = []; types.forEach(function(type, index) { tight.push(_pack(type, values[index])); }); return hexlify(concat(tight)); } function keccak256(types, values) { return keccak256$1(pack(types, values)); } function sha256(types, values) { return sha256$1(pack(types, values)); } const lib_esm$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, keccak256, pack, sha256 }, Symbol.toStringTag, { value: "Module" })); const version$1 = "units/5.7.0"; const logger = new Logger(version$1); const names = [ "wei", "kwei", "mwei", "gwei", "szabo", "finney", "ether" ]; function commify(value) { const comps = String(value).split("."); if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || comps[1] && !comps[1].match(/^[0-9]*$/) || value === "." || value === "-.") { logger.throwArgumentError("invalid value", "value", value); } let whole = comps[0]; let negative = ""; if (whole.substring(0, 1) === "-") { negative = "-"; whole = whole.substring(1); } while (whole.substring(0, 1) === "0") { whole = whole.substring(1); } if (whole === "") { whole = "0"; } let suffix = ""; if (comps.length === 2) { suffix = "." + (comps[1] || "0"); } while (suffix.length > 2 && suffix[suffix.length - 1] === "0") { suffix = suffix.substring(0, suffix.length - 1); } const formatted = []; while (whole.length) { if (whole.length <= 3) { formatted.unshift(whole); break; } else { const index = whole.length - 3; formatted.unshift(whole.substring(index)); whole = whole.substring(0, index); } } return negative + formatted.join(",") + suffix; } function formatUnits(value, unitName) { if (typeof unitName === "string") { const index = names.indexOf(unitName); if (index !== -1) { unitName = 3 * index; } } return formatFixed(value, unitName != null ? unitName : 18); } function parseUnits(value, unitName) { if (typeof value !== "string") { logger.throwArgumentError("value must be a string", "value", value); } if (typeof unitName === "string") { const index = names.indexOf(unitName); if (index !== -1) { unitName = 3 * index; } } return parseFixed(value, unitName != null ? unitName : 18); } function formatEther(wei) { return formatUnits(wei, 18); } function parseEther(ether) { return parseUnits(ether, 18); } const lib_esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, commify, formatEther, formatUnits, parseEther, parseUnits }, Symbol.toStringTag, { value: "Module" })); const version = "ethers/5.7.2"; new Logger(version); var utils = {}; const require$$0 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$b); const require$$1 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$f); const require$$2 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$d); const require$$3 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$8); const require$$4 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$j); const require$$5 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$c); const require$$6 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$6); const require$$7 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$4); const require$$8 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$h); const require$$9 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$k); const require$$10 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$7); const require$$11 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$1); const require$$12 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$5); const require$$13 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$i); const require$$14 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$g); const require$$15 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$a); const require$$16 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$e); const require$$17 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$9); const require$$18 = /* @__PURE__ */ getAugmentedNamespace(lib_esm); const require$$19 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$3); const require$$20 = /* @__PURE__ */ getAugmentedNamespace(lib_esm$2); (function(exports) { var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function(o, m2, k2, k22) { if (k22 === void 0) k22 = k2; Object.defineProperty(o, k22, { enumerable: true, get: function() { return m2[k2]; } }); } : function(o, m2, k2, k22) { if (k22 === void 0) k22 = k2; o[k22] = m2[k2]; }); var __setModuleDefault = commonjsGlobal && commonjsGlobal.__setModuleDefault || (Object.create ? function(o, v2) { Object.defineProperty(o, "default", { enumerable: true, value: v2 }); } : function(o, v2) { o["default"] = v2; }); var __importStar = commonjsGlobal && commonjsGlobal.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k2 in mod) if (k2 !== "default" && Object.prototype.hasOwnProperty.call(mod, k2)) __createBinding(result, mod, k2); } __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatBytes32String = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports._toEscapedUtf8String = exports.nameprep = exports.hexDataSlice = exports.hexDataLength = exports.hexZeroPad = exports.hexValue = exports.hexStripZeros = exports.hexConcat = exports.isHexString = exports.hexlify = exports.base64 = exports.base58 = exports.TransactionDescription = exports.LogDescription = exports.Interface = exports.SigningKey = exports.HDNode = exports.defaultPath = exports.isBytesLike = exports.isBytes = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.shallowCopy = exports.resolveProperties = exports.getStatic = exports.defineReadOnly = exports.deepCopy = exports.checkProperties = exports.poll = exports.fetchJson = exports._fetchData = exports.RLP = exports.Logger = exports.checkResultErrors = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.Fragment = exports.defaultAbiCoder = exports.AbiCoder = void 0; exports.Indexed = exports.Utf8ErrorReason = exports.UnicodeNormalizationForm = exports.SupportedAlgorithm = exports.mnemonicToSeed = exports.isValidMnemonic = exports.entropyToMnemonic = exports.mnemonicToEntropy = exports.getAccountPath = exports.verifyTypedData = exports.verifyMessage = exports.recoverPublicKey = exports.computePublicKey = exports.recoverAddress = exports.computeAddress = exports.getJsonWalletAddress = exports.TransactionTypes = exports.serializeTransaction = exports.parseTransaction = exports.accessListify = exports.joinSignature = exports.splitSignature = exports.soliditySha256 = exports.solidityKeccak256 = exports.solidityPack = exports.shuffled = exports.randomBytes = exports.sha512 = exports.sha256 = exports.ripemd160 = exports.keccak256 = exports.computeHmac = exports.commify = exports.parseUnits = exports.formatUnits = exports.parseEther = exports.formatEther = exports.isAddress = exports.getCreate2Address = exports.getContractAddress = exports.getIcapAddress = exports.getAddress = exports._TypedDataEncoder = exports.id = exports.isValidName = exports.namehash = exports.hashMessage = exports.dnsEncode = exports.parseBytes32String = void 0; var abi_1 = require$$0; Object.defineProperty(exports, "AbiCoder", { enumerable: true, get: function() { return abi_1.AbiCoder; } }); Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function() { return abi_1.checkResultErrors; } }); Object.defineProperty(exports, "ConstructorFragment", { enumerable: true, get: function() { return abi_1.ConstructorFragment; } }); Object.defineProperty(exports, "defaultAbiCoder", { enumerable: true, get: function() { return abi_1.defaultAbiCoder; } }); Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: function() { return abi_1.ErrorFragment; } }); Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function() { return abi_1.EventFragment; } }); Object.defineProperty(exports, "FormatTypes", { enumerable: true, get: function() { return abi_1.FormatTypes; } }); Object.defineProperty(exports, "Fragment", { enumerable: true, get: function() { return abi_1.Fragment; } }); Object.defineProperty(exports, "FunctionFragment", { enumerable: true, get: function() { return abi_1.FunctionFragment; } }); Object.defineProperty(exports, "Indexed", { enumerable: true, get: function() { return abi_1.Indexed; } }); Object.defineProperty(exports, "Interface", { enumerable: true, get: function() { return abi_1.Interface; } }); Object.defineProperty(exports, "LogDescription", { enumerable: true, get: function() { return abi_1.LogDescription; } }); Object.defineProperty(exports, "ParamType", { enumerable: true, get: function() { return abi_1.ParamType; } }); Object.defineProperty(exports, "TransactionDescription", { enumerable: true, get: function() { return abi_1.TransactionDescription; } }); var address_1 = require$$1; Object.defineProperty(exports, "getAddress", { enumerable: true, get: function() { return address_1.getAddress; } }); Object.defineProperty(exports, "getCreate2Address", { enumerable: true, get: function() { return address_1.getCreate2Address; } }); Object.defineProperty(exports, "getContractAddress", { enumerable: true, get: function() { return address_1.getContractAddress; } }); Object.defineProperty(exports, "getIcapAddress", { enumerable: true, get: function() { return address_1.getIcapAddress; } }); Object.defineProperty(exports, "isAddress", { enumerable: true, get: function() { return address_1.isAddress; } }); var base64 = __importStar(require$$2); exports.base64 = base64; var basex_1 = require$$3; Object.defineProperty(exports, "base58", { enumerable: true, get: function() { return basex_1.Base58; } }); var bytes_1 = require$$4; Object.defineProperty(exports, "arrayify", { enumerable: true, get: function() { return bytes_1.arrayify; } }); Object.defineProperty(exports, "concat", { enumerable: true, get: function() { return bytes_1.concat; } }); Object.defineProperty(exports, "hexConcat", { enumerable: true, get: function() { return bytes_1.hexConcat; } }); Object.defineProperty(exports, "hexDataSlice", { enumerable: true, get: function() { return bytes_1.hexDataSlice; } }); Object.defineProperty(exports, "hexDataLength", { enumerable: true, get: function() { return bytes_1.hexDataLength; } }); Object.defineProperty(exports, "hexlify", { enumerable: true, get: function() { return bytes_1.hexlify; } }); Object.defineProperty(exports, "hexStripZeros", { enumerable: true, get: function() { return bytes_1.hexStripZeros; } }); Object.defineProperty(exports, "hexValue", { enumerable: true, get: function() { return bytes_1.hexValue; } }); Object.defineProperty(exports, "hexZeroPad", { enumerable: true, get: function() { return bytes_1.hexZeroPad; } }); Object.defineProperty(exports, "isBytes", { enumerable: true, get: function() { return bytes_1.isBytes; } }); Object.defineProperty(exports, "isBytesLike", { enumerable: true, get: function() { return bytes_1.isBytesLike; } }); Object.defineProperty(exports, "isHexString", { enumerable: true, get: function() { return bytes_1.isHexString; } }); Object.defineProperty(exports, "joinSignature", { enumerable: true, get: function() { return bytes_1.joinSignature; } }); Object.defineProperty(exports, "zeroPad", { enumerable: true, get: function() { return bytes_1.zeroPad; } }); Object.defineProperty(exports, "splitSignature", { enumerable: true, get: function() { return bytes_1.splitSignature; } }); Object.defineProperty(exports, "stripZeros", { enumerable: true, get: function() { return bytes_1.stripZeros; } }); var hash_1 = require$$5; Object.defineProperty(exports, "_TypedDataEncoder", { enumerable: true, get: function() { return hash_1._TypedDataEncoder; } }); Object.defineProperty(exports, "dnsEncode", { enumerable: true, get: function() { return hash_1.dnsEncode; } }); Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function() { return hash_1.hashMessage; } }); Object.defineProperty(exports, "id", { enumerable: true, get: function() { return hash_1.id; } }); Object.defineProperty(exports, "isValidName", { enumerable: true, get: function() { return hash_1.isValidName; } }); Object.defineProperty(exports, "namehash", { enumerable: true, get: function() { return hash_1.namehash; } }); var hdnode_1 = require$$6; Object.defineProperty(exports, "defaultPath", { enumerable: true, get: function() { return hdnode_1.defaultPath; } }); Object.defineProperty(exports, "entropyToMnemonic", { enumerable: true, get: function() { return hdnode_1.entropyToMnemonic; } }); Object.defineProperty(exports, "getAccountPath", { enumerable: true, get: function() { return hdnode_1.getAccountPath; } }); Object.defineProperty(exports, "HDNode", { enumerable: true, get: function() { return hdnode_1.HDNode; } }); Object.defineProperty(exports, "isValidMnemonic", { enumerable: true, get: function() { return hdnode_1.isValidMnemonic; } }); Object.defineProperty(exports, "mnemonicToEntropy", { enumerable: true, get: function() { return hdnode_1.mnemonicToEntropy; } }); Object.defineProperty(exports, "mnemonicToSeed", { enumerable: true, get: function() { return hdnode_1.mnemonicToSeed; } }); var json_wallets_1 = require$$7; Object.defineProperty(exports, "getJsonWalletAddress", { enumerable: true, get: function() { return json_wallets_1.getJsonWalletAddress; } }); var keccak256_1 = require$$8; Object.defineProperty(exports, "keccak256", { enumerable: true, get: function() { return keccak256_1.keccak256; } }); var logger_1 = require$$9; Object.defineProperty(exports, "Logger", { enumerable: true, get: function() { return logger_1.Logger; } }); var sha2_1 = require$$10; Object.defineProperty(exports, "computeHmac", { enumerable: true, get: function() { return sha2_1.computeHmac; } }); Object.defineProperty(exports, "ripemd160", { enumerable: true, get: function() { return sha2_1.ripemd160; } }); Object.defineProperty(exports, "sha256", { enumerable: true, get: function() { return sha2_1.sha256; } }); Object.defineProperty(exports, "sha512", { enumerable: true, get: function() { return sha2_1.sha512; } }); var solidity_1 = require$$11; Object.defineProperty(exports, "solidityKeccak256", { enumerable: true, get: function() { return solidity_1.keccak256; } }); Object.defineProperty(exports, "solidityPack", { enumerable: true, get: function() { return solidity_1.pack; } }); Object.defineProperty(exports, "soliditySha256", { enumerable: true, get: function() { return solidity_1.sha256; } }); var random_1 = require$$12; Object.defineProperty(exports, "randomBytes", { enumerable: true, get: function() { return random_1.randomBytes; } }); Object.defineProperty(exports, "shuffled", { enumerable: true, get: function() { return random_1.shuffled; } }); var properties_1 = require$$13; Object.defineProperty(exports, "checkProperties", { enumerable: true, get: function() { return properties_1.checkProperties; } }); Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function() { return properties_1.deepCopy; } }); Object.defineProperty(exports, "defineReadOnly", { enumerable: true, get: function() { return properties_1.defineReadOnly; } }); Object.defineProperty(exports, "getStatic", { enumerable: true, get: function() { return properties_1.getStatic; } }); Object.defineProperty(exports, "resolveProperties", { enumerable: true, get: function() { return properties_1.resolveProperties; } }); Object.defineProperty(exports, "shallowCopy", { enumerable: true, get: function() { return properties_1.shallowCopy; } }); var RLP = __importStar(require$$14); exports.RLP = RLP; var signing_key_1 = require$$15; Object.defineProperty(exports, "computePublicKey", { enumerable: true, get: function() { return signing_key_1.computePublicKey; } }); Object.defineProperty(exports, "recoverPublicKey", { enumerable: true, get: function() { return signing_key_1.recoverPublicKey; } }); Object.defineProperty(exports, "SigningKey", { enumerable: true, get: function() { return signing_key_1.SigningKey; } }); var strings_1 = require$$16; Object.defineProperty(exports, "formatBytes32String", { enumerable: true, get: function() { return strings_1.formatBytes32String; } }); Object.defineProperty(exports, "nameprep", { enumerable: true, get: function() { return strings_1.nameprep; } }); Object.defineProperty(exports, "parseBytes32String", { enumerable: true, get: function() { return strings_1.parseBytes32String; } }); Object.defineProperty(exports, "_toEscapedUtf8String", { enumerable: true, get: function() { return strings_1._toEscapedUtf8String; } }); Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function() { return strings_1.toUtf8Bytes; } }); Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function() { return strings_1.toUtf8CodePoints; } }); Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function() { return strings_1.toUtf8String; } }); Object.defineProperty(exports, "Utf8ErrorFuncs", { enumerable: true, get: function() { return strings_1.Utf8ErrorFuncs; } }); var transactions_1 = require$$17; Object.defineProperty(exports, "accessListify", { enumerable: true, get: function() { return transactions_1.accessListify; } }); Object.defineProperty(exports, "computeAddress", { enumerable: true, get: function() { return transactions_1.computeAddress; } }); Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function() { return transactions_1.parse; } }); Object.defineProperty(exports, "recoverAddress", { enumerable: true, get: function() { return transactions_1.recoverAddress; } }); Object.defineProperty(exports, "serializeTransaction", { enumerable: true, get: function() { return transactions_1.serialize; } }); Object.defineProperty(exports, "TransactionTypes", { enumerable: true, get: function() { return transactions_1.TransactionTypes; } }); var units_1 = require$$18; Object.defineProperty(exports, "commify", { enumerable: true, get: function() { return units_1.commify; } }); Object.defineProperty(exports, "formatEther", { enumerable: true, get: function() { return units_1.formatEther; } }); Object.defineProperty(exports, "parseEther", { enumerable: true, get: function() { return units_1.parseEther; } }); Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function() { return units_1.formatUnits; } }); Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function() { return units_1.parseUnits; } }); var wallet_1 = require$$19; Object.defineProperty(exports, "verifyMessage", { enumerable: true, get: function() { return wallet_1.verifyMessage; } }); Object.defineProperty(exports, "verifyTypedData", { enumerable: true, get: function() { return wallet_1.verifyTypedData; } }); var web_1 = require$$20; Object.defineProperty(exports, "_fetchData", { enumerable: true, get: function() { return web_1._fetchData; } }); Object.defineProperty(exports, "fetchJson", { enumerable: true, get: function() { return web_1.fetchJson; } }); Object.defineProperty(exports, "poll", { enumerable: true, get: function() { return web_1.poll; } }); var sha2_2 = require$$10; Object.defineProperty(exports, "SupportedAlgorithm", { enumerable: true, get: function() { return sha2_2.SupportedAlgorithm; } }); var strings_2 = require$$16; Object.defineProperty(exports, "UnicodeNormalizationForm", { enumerable: true, get: function() { return strings_2.UnicodeNormalizationForm; } }); Object.defineProperty(exports, "Utf8ErrorReason", { enumerable: true, get: function() { return strings_2.Utf8ErrorReason; } }); })(utils); function getInjectedName(ethereum) { var _a; if (!ethereum) return "Injected"; const getName = (provider) => { if (provider.isApexWallet) return "Apex Wallet"; if (provider.isAvalanche) return "Core Wallet"; if (provider.isBitKeep) return "BitKeep"; if (provider.isBitski) return "Bitski"; if (provider.isBraveWallet) return "Brave Wallet"; if (provider.isCoinbaseWallet) return "Coinbase Wallet"; if (provider.isExodus) return "Exodus"; if (provider.isFrame) return "Frame"; if (provider.isKuCoinWallet) return "KuCoin Wallet"; if (provider.isMathWallet) return "MathWallet"; if (provider.isOneInchIOSWallet || provider.isOneInchAndroidWallet) return "1inch Wallet"; if (provider.isOpera) return "Opera"; if (provider.isPortal) return "Ripio Portal"; if (provider.isRainbow) return "Rainbow"; if (provider.isTally) return "Tally"; if (provider.isTokenPocket) return "TokenPocket"; if (provider.isTokenary) return "Tokenary"; if (provider.isTrust || provider.isTrustWallet) return "Trust Wallet"; if (provider.isMetaMask) return "MetaMask"; if (provider.isXDEFI) return "XDEFI Wallet"; }; if ((_a = ethereum.providers) == null ? void 0 : _a.length) { const nameSet = /* @__PURE__ */ new Set(); let unknownCount = 1; for (const provider of ethereum.providers) { let name = getName(provider); if (!name) { name = `Unknown Wallet #${unknownCount}`; unknownCount += 1; } nameSet.add(name); } const names2 = [...nameSet]; if (names2.length) return names2; return names2[0] ?? "Injected"; } return getName(ethereum) ?? "Injected"; } var _provider$2, _switchingChains; var InjectedConnector = class extends Connector { constructor({ chains, options: options_ } = {}) { const options = { shimDisconnect: true, shimChainChangedDisconnect: true, getProvider: () => typeof window !== "undefined" ? window.ethereum : void 0, ...options_ }; super({ chains, options }); __publicField(this, "id", "injected"); __publicField(this, "name"); __publicField(this, "ready"); __privateAdd(this, _provider$2, void 0); __privateAdd(this, _switchingChains, void 0); __publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`); __publicField(this, "onAccountsChanged", (accounts) => { if (accounts.length === 0) this.emit("disconnect"); else this.emit("change", { account: utils.getAddress(accounts[0]) }); }); __publicField(this, "onChainChanged", (chainId) => { const id2 = normalizeChainId(chainId); const unsupported = this.isChainUnsupported(id2); this.emit("change", { chain: { id: id2, unsupported } }); }); __publicField(this, "onDisconnect", () => { var _a; if (this.options.shimChainChangedDisconnect && __privateGet(this, _switchingChains)) { __privateSet(this, _switchingChains, false); return; } this.emit("disconnect"); if (this.options.shimDisconnect) (_a = getClient().storage) == null ? void 0 : _a.removeItem(this.shimDisconnectKey); }); const provider = options.getProvider(); if (typeof options.name === "string") this.name = options.name; else if (provider) { const detectedName = getInjectedName(provider); if (options.name) this.name = options.name(detectedName); else { if (typeof detectedName === "string") this.name = detectedName; else this.name = detectedName[0]; } } else this.name = "Injected"; this.ready = !!provider; } async connect({ chainId } = {}) { var _a; try { const provider = await this.getProvider(); if (!provider) throw new ConnectorNotFoundError(); if (provider.on) { provider.on("accountsChanged", this.onAccountsChanged); provider.on("chainChanged", this.onChainChanged); provider.on("disconnect", this.onDisconnect); } this.emit("message", { type: "connecting" }); const accounts = await provider.request({ method: "eth_requestAccounts" }); const account = utils.getAddress(accounts[0]); let id2 = await this.getChainId(); let unsupported = this.isChainUnsupported(id2); if (chainId && id2 !== chainId) { const chain = await this.switchChain(chainId); id2 = chain.id; unsupported = this.isChainUnsupported(id2); } if (this.options.shimDisconnect) (_a = getClient().storage) == null ? void 0 : _a.setItem(this.shimDisconnectKey, true); return { account, chain: { id: id2, unsupported }, provider }; } catch (error) { if (this.isUserRejectedRequestError(error)) throw new UserRejectedRequestError(error); if (error.code === -32002) throw new ResourceUnavailableError(error); throw error; } } async disconnect() { var _a; const provider = await this.getProvider(); if (!(provider == null ? void 0 : provider.removeListener)) return; provider.removeListener("accountsChanged", this.onAccountsChanged); provider.removeListener("chainChanged", this.onChainChanged); provider.removeListener("disconnect", this.onDisconnect); if (this.options.shimDisconnect) (_a = getClient().storage) == null ? void 0 : _a.removeItem(this.shimDisconnectKey); } async getAccount() { const provider = await this.getProvider(); if (!provider) throw new ConnectorNotFoundError(); const accounts = await provider.request({ method: "eth_accounts" }); return utils.getAddress(accounts[0]); } async getChainId() { const provider = await this.getProvider(); if (!provider) throw new ConnectorNotFoundError(); return provider.request({ method: "eth_chainId" }).then(normalizeChainId); } async getProvider() { const provider = this.options.getProvider(); if (provider) __privateSet(this, _provider$2, provider); return __privateGet(this, _provider$2); } async getSigner({ chainId } = {}) { const [provider, account] = await Promise.all([ this.getProvider(), this.getAccount() ]); return new Web3Provider( provider, chainId ).getSigner(account); } async isAuthorized() { var _a; try { if (this.options.shimDisconnect && !((_a = getClient().storage) == null ? void 0 : _a.getItem(this.shimDisconnectKey))) return false; const provider = await this.getProvider(); if (!provider) throw new ConnectorNotFoundError(); const account = await this.getAccount(); return !!account; } catch { return false; } } async switchChain(chainId) { var _a, _b, _c; if (this.options.shimChainChangedDisconnect) __privateSet(this, _switchingChains, true); const provider = await this.getProvider(); if (!provider) throw new ConnectorNotFoundError(); const id2 = utils.hexValue(chainId); try { await Promise.all([ provider.request({ method: "wallet_switchEthereumChain", params: [{ chainId: id2 }] }), new Promise( (res) => this.on("change", ({ chain }) => { if ((chain == null ? void 0 : chain.id) === chainId) res(); }) ) ]); return this.chains.find((x) => x.id === chainId) ?? { id: chainId, name: `Chain ${id2}`, network: `${id2}`, nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" }, rpcUrls: { default: { http: [""] }, public: { http: [""] } } }; } catch (error) { const chain = this.chains.find((x) => x.id === chainId); if (!chain) throw new ChainNotConfiguredError({ chainId, connectorId: this.id }); if (error.code === 4902 || ((_b = (_a = error == null ? void 0 : error.data) == null ? void 0 : _a.originalError) == null ? void 0 : _b.code) === 4902) { try { await provider.request({ method: "wallet_addEthereumChain", params: [ { chainId: id2, chainName: chain.name, nativeCurrency: chain.nativeCurrency, rpcUrls: [((_c = chain.rpcUrls.public) == null ? void 0 : _c.http[0]) ?? ""], blockExplorerUrls: this.getBlockExplorerUrls(chain) } ] }); return chain; } catch (addError) { if (this.isUserRejectedRequestError(addError)) throw new UserRejectedRequestError(error); throw new AddChainError(); } } if (this.isUserRejectedRequestError(error)) throw new UserRejectedRequestError(error); throw new SwitchChainError(error); } } async watchAsset({ address, decimals = 18, image, symbol }) { const provider = await this.getProvider(); if (!provider) throw new ConnectorNotFoundError(); return provider.request({ method: "wallet_watchAsset", params: { type: "ERC20", options: { address, decimals, image, symbol } } }); } isUserRejectedRequestError(error) { return error.code === 4001; } }; _provider$2 = /* @__PURE__ */ new WeakMap(); _switchingChains = /* @__PURE__ */ new WeakMap(); const subscribeWithSelectorImpl = (fn) => (set, get, api) => { const origSubscribe = api.subscribe; api.subscribe = (selector, optListener, options) => { let listener = selector; if (optListener) { const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is; let currentSlice = selector(api.getState()); listener = (state) => { const nextSlice = selector(state); if (!equalityFn(currentSlice, nextSlice)) { const previousSlice = currentSlice; optListener(currentSlice = nextSlice, previousSlice); } }; if (options == null ? void 0 : options.fireImmediately) { optListener(currentSlice, currentSlice); } } return origSubscribe(listener); }; const initialState = fn(set, get, api); return initialState; }; const subscribeWithSelector = subscribeWithSelectorImpl; function createJSONStorage(getStorage) { let storage; try { storage = getStorage(); } catch (e) { return; } const persistStorage = { getItem: (name) => { var _a; const parse2 = (str2) => { if (str2 === null) { return null; } return JSON.parse(str2); }; const str = (_a = storage.getItem(name)) != null ? _a : null; if (str instanceof Promise) { return str.then(parse2); } return parse2(str); }, setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue)), removeItem: (name) => storage.removeItem(name) }; return persistStorage; } const toThenable = (fn) => (input) => { try { const result = fn(input); if (result instanceof Promise) { return result; } return { then(onFulfilled) { return toThenable(onFulfilled)(result); }, catch(_onRejected) { return this; } }; } catch (e) { return { then(_onFulfilled) { return this; }, catch(onRejected) { return toThenable(onRejected)(e); } }; } }; const oldImpl = (config, baseOptions) => (set, get, api) => { let options = { getStorage: () => localStorage, serialize: JSON.stringify, deserialize: JSON.parse, partialize: (state) => state, version: 0, merge: (persistedState, currentState) => ({ ...currentState, ...persistedState }), ...baseOptions }; let hasHydrated = false; const hydrationListeners = /* @__PURE__ */ new Set(); const finishHydrationListeners = /* @__PURE__ */ new Set(); let storage; try { storage = options.getStorage(); } catch (e) { } if (!storage) { return config( (...args) => { console.warn( `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.` ); set(...args); }, get, api ); } const thenableSerialize = toThenable(options.serialize); const setItem = () => { const state = options.partialize({ ...get() }); let errorInSync; const thenable = thenableSerialize({ state, version: options.version }).then( (serializedValue) => storage.setItem(options.name, serializedValue) ).catch((e) => { errorInSync = e; }); if (errorInSync) { throw errorInSync; } return thenable; }; const savedSetState = api.setState; api.setState = (state, replace) => { savedSetState(state, replace); void setItem(); }; const configResult = config( (...args) => { set(...args); void setItem(); }, get, api ); let stateFromStorage; const hydrate = () => { var _a; if (!storage) return; hasHydrated = false; hydrationListeners.forEach((cb) => cb(get())); const postRehydrationCallback = ((_a = options.onRehydrateStorage) == null ? void 0 : _a.call(options, get())) || void 0; return toThenable(storage.getItem.bind(storage))(options.name).then((storageValue) => { if (storageValue) { return options.deserialize(storageValue); } }).then((deserializedStorageValue) => { if (deserializedStorageValue) { if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) { if (options.migrate) { return options.migrate( deserializedStorageValue.state, deserializedStorageValue.version ); } console.error( `State loaded from storage couldn't be migrated since no migrate function was provided` ); } else { return deserializedStorageValue.state; } } }).then((migratedState) => { var _a2; stateFromStorage = options.merge( migratedState, (_a2 = get()) != null ? _a2 : configResult ); set(stateFromStorage, true); return setItem(); }).then(() => { postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0); hasHydrated = true; finishHydrationListeners.forEach((cb) => cb(stateFromStorage)); }).catch((e) => { postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e); }); }; api.persist = { setOptions: (newOptions) => { options = { ...options, ...newOptions }; if (newOptions.getStorage) { storage = newOptions.getStorage(); } }, clearStorage: () => { storage == null ? void 0 : storage.removeItem(options.name); }, getOptions: () => options, rehydrate: () => hydrate(), hasHydrated: () => hasHydrated, onHydrate: (cb) => { hydrationListeners.add(cb); return () => { hydrationListeners.delete(cb); }; }, onFinishHydration: (cb) => { finishHydrationListeners.add(cb); return () => { finishHydrationListeners.delete(cb); }; } }; hydrate(); return stateFromStorage || configResult; }; const newImpl = (config, baseOptions) => (set, get, api) => { let options = { storage: createJSONStorage(() => localStorage), partialize: (state) => state, version: 0, merge: (persistedState, currentState) => ({ ...currentState, ...persistedState }), ...baseOptions }; let hasHydrated = false; const hydrationListeners = /* @__PURE__ */ new Set(); const finishHydrationListeners = /* @__PURE__ */ new Set(); let storage = options.storage; if (!storage) { return config( (...args) => { console.warn( `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.` ); set(...args); }, get, api ); } const setItem = () => { const state = options.partialize({ ...get() }); return storage.setItem(options.name, { state, version: options.version }); }; const savedSetState = api.setState; api.setState = (state, replace) => { savedSetState(state, replace); void setItem(); }; const configResult = config( (...args) => { set(...args); void setItem(); }, get, api ); let stateFromStorage; const hydrate = () => { var _a; if (!storage) return; hasHydrated = false; hydrationListeners.forEach((cb) => cb(get())); const postRehydrationCallback = ((_a = options.onRehydrateStorage) == null ? void 0 : _a.call(options, get())) || void 0; return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => { if (deserializedStorageValue) { if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) { if (options.migrate) { return options.migrate( deserializedStorageValue.state, deserializedStorageValue.version ); } console.error( `State loaded from storage couldn't be migrated since no migrate function was provided` ); } else { return deserializedStorageValue.state; } } }).then((migratedState) => { var _a2; stateFromStorage = options.merge( migratedState, (_a2 = get()) != null ? _a2 : configResult ); set(stateFromStorage, true); return setItem(); }).then(() => { postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0); hasHydrated = true; finishHydrationListeners.forEach((cb) => cb(stateFromStorage)); }).catch((e) => { postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e); }); }; api.persist = { setOptions: (newOptions) => { options = { ...options, ...newOptions }; if (newOptions.storage) { storage = newOptions.storage; } }, clearStorage: () => { storage == null ? void 0 : storage.removeItem(options.name); }, getOptions: () => options, rehydrate: () => hydrate(), hasHydrated: () => hasHydrated, onHydrate: (cb) => { hydrationListeners.add(cb); return () => { hydrationListeners.delete(cb); }; }, onFinishHydration: (cb) => { finishHydrationListeners.add(cb); return () => { finishHydrationListeners.delete(cb); }; } }; hydrate(); return stateFromStorage || configResult; }; const persistImpl = (config, baseOptions) => { var _a; if ("getStorage" in baseOptions || "serialize" in baseOptions || "deserialize" in baseOptions) { if (((_a = { "BASE_URL": "./", "MODE": "production", "DEV": false, "PROD": true }) == null ? void 0 : _a.MODE) !== "production") { console.warn( "[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead." ); } return oldImpl(config, baseOptions); } return newImpl(config, baseOptions); }; const persist = persistImpl; const createStoreImpl = (createState) => { let state; const listeners = /* @__PURE__ */ new Set(); const setState = (partial, replace) => { const nextState = typeof partial === "function" ? partial(state) : partial; if (!Object.is(nextState, state)) { const previousState = state; state = (replace != null ? replace : typeof nextState !== "object") ? nextState : Object.assign({}, state, nextState); listeners.forEach((listener) => listener(state, previousState)); } }; const getState = () => state; const subscribe2 = (listener) => { listeners.add(listener); return () => listeners.delete(listener); }; const destroy = () => { var _a; if (((_a = { "BASE_URL": "./", "MODE": "production", "DEV": false, "PROD": true }) == null ? void 0 : _a.MODE) !== "production") { console.warn( "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected." ); } listeners.clear(); }; const api = { setState, getState, subscribe: subscribe2, destroy }; state = createState(setState, getState, api); return api; }; const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl; function shallow(objA, objB) { if (Object.is(objA, objB)) { return true; } if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) { return false; } if (objA instanceof Map && objB instanceof Map) { if (objA.size !== objB.size) return false; for (const [key2, value] of objA) { if (!Object.is(value, objB.get(key2))) { return false; } } return true; } if (objA instanceof Set && objB instanceof Set) { if (objA.size !== objB.size) return false; for (const value of objA) { if (!objB.has(value)) { return false; } } return true; } const keysA = Object.keys(objA); if (keysA.length !== Object.keys(objB).length) { return false; } for (let i2 = 0; i2 < keysA.length; i2++) { if (!Object.prototype.hasOwnProperty.call(objB, keysA[i2]) || !Object.is(objA[keysA[i2]], objB[keysA[i2]])) { return false; } } return true; } function configureChains(defaultChains, providers2, { minQuorum = 1, pollingInterval = 4e3, targetQuorum = 1, stallTimeout } = {}) { if (!defaultChains.length) throw new Error("must have at least one chain"); if (targetQuorum < minQuorum) throw new Error("quorum cannot be lower than minQuorum"); let chains = []; const providers_ = {}; const webSocketProviders_ = {}; for (const chain of defaultChains) { let configExists = false; for (const provider of providers2) { const apiConfig = provider(chain); if (!apiConfig) continue; configExists = true; if (!chains.some(({ id: id2 }) => id2 === chain.id)) { chains = [...chains, apiConfig.chain]; } providers_[chain.id] = [ ...providers_[chain.id] || [], apiConfig.provider ]; if (apiConfig.webSocketProvider) { webSocketProviders_[chain.id] = [ ...webSocketProviders_[chain.id] || [], apiConfig.webSocketProvider ]; } } if (!configExists) { throw new Error( [ `Could not find valid provider configuration for chain "${chain.name}". `, "You may need to add `jsonRpcProvider` to `configureChains` with the chain's RPC URLs.", "Read more: https://wagmi.sh/core/providers/jsonRpc" ].join("\n") ); } } return { chains, provider: ({ chainId }) => { const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0]; const chainProviders = providers_[activeChain.id]; if (!chainProviders || !chainProviders[0]) throw new Error(`No providers configured for chain "${activeChain.id}"`); let provider; if (chainProviders.length === 1) { provider = chainProviders[0](); } else { provider = fallbackProvider(targetQuorum, minQuorum, chainProviders, { stallTimeout }); } if (activeChain.id === 42220) { provider.formatter.formats.block = { ...provider.formatter.formats.block, difficulty: () => 0, gasLimit: () => 0 }; } return Object.assign(provider, { chains, pollingInterval }); }, webSocketProvider: ({ chainId }) => { var _a; const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0]; const chainWebSocketProviders = webSocketProviders_[activeChain.id]; if (!chainWebSocketProviders) return void 0; const provider = (_a = chainWebSocketProviders[0]) == null ? void 0 : _a.call(chainWebSocketProviders); if (provider && activeChain.id === 42220) { provider.formatter.formats.block = { ...provider.formatter.formats.block, difficulty: () => 0, gasLimit: () => 0 }; } return Object.assign(provider || {}, { chains }); } }; } function fallbackProvider(targetQuorum, minQuorum, providers_, { stallTimeout }) { var _a; try { return new FallbackProvider( providers_.map((chainProvider, index) => { const provider = chainProvider(); return { provider, priority: provider.priority ?? index, stallTimeout: provider.stallTimeout ?? stallTimeout, weight: provider.weight }; }), targetQuorum ); } catch (error) { if ((_a = error == null ? void 0 : error.message) == null ? void 0 : _a.includes( "quorum will always fail; larger than total weight" )) { if (targetQuorum === minQuorum) throw error; return fallbackProvider(targetQuorum - 1, minQuorum, providers_, { stallTimeout }); } throw error; } } var findAndReplace = (cacheRef, { find, replace }) => { if (cacheRef && find(cacheRef)) { return replace(cacheRef); } if (typeof cacheRef !== "object") { return cacheRef; } if (Array.isArray(cacheRef)) { return cacheRef.map((item) => findAndReplace(item, { find, replace })); } if (cacheRef instanceof Object) { return Object.entries(cacheRef).reduce( (curr, [key2, value]) => ({ ...curr, [key2]: findAndReplace(value, { find, replace }) }), {} ); } return cacheRef; }; function deserialize(cachedString) { const cache = JSON.parse(cachedString); const deserializedCacheWithBigNumbers = findAndReplace(cache, { find: (data) => data.type === "BigNumber", replace: (data) => BigNumber.from(data.hex) }); return deserializedCacheWithBigNumbers; } function normalizeFunctionName({ contract, functionName, args = [] }) { if (functionName in contract.functions) return functionName; const argsLength = (args == null ? void 0 : args.length) ?? 0; const overloadFunctions = Object.keys(contract.functions).filter((x) => x.startsWith(`${functionName}(`)).map((x) => ({ name: x, fragment: utils.FunctionFragment.fromString(x) })).filter((x) => argsLength === x.fragment.inputs.length); for (const overloadFunction of overloadFunctions) { const matched = args.every((arg, index) => { const abiParameter = overloadFunction.fragment.inputs[index]; return isArgOfType(arg, abiParameter); }); if (matched) return overloadFunction.name; } return functionName; } function isArgOfType(arg, abiParameter) { const argType = typeof arg; const abiParameterType = abiParameter.type; switch (abiParameterType) { case "address": return utils.isAddress(arg); case "bool": return argType === "boolean"; case "function": return argType === "string"; case "string": return argType === "string"; default: { if (abiParameterType === "tuple" && "components" in abiParameter) return Object.values(abiParameter.components).every( (component, index) => { return isArgOfType( Object.values(arg)[index], component ); } ); if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test( abiParameterType )) return argType === "number" || argType === "bigint" || BigNumber.isBigNumber(arg); if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType)) return argType === "string" || arg instanceof Uint8Array; if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) { return Array.isArray(arg) && arg.every( (x) => isArgOfType(x, { ...abiParameter, type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, "") }) ); } return false; } } } function logWarn(message) { var _a, _b, _c; (_c = (_b = (_a = getClient()) == null ? void 0 : _a.config.logger) == null ? void 0 : _b.warn) == null ? void 0 : _c.call(_b, message); } function normalizeChainId(chainId) { if (typeof chainId === "string") return Number.parseInt( chainId, chainId.trim().substring(0, 2) === "0x" ? 16 : 10 ); if (typeof chainId === "bigint") return Number(chainId); return chainId; } function getReferenceKey(keys, cutoff) { return keys.slice(0, cutoff).join(".") || "."; } function getCutoff(array, value) { const { length } = array; for (let index = 0; index < length; ++index) { if (array[index] === value) { return index + 1; } } return 0; } function createReplacer(replacer, circularReplacer) { const hasReplacer = typeof replacer === "function"; const hasCircularReplacer = typeof circularReplacer === "function"; const cache = []; const keys = []; return function replace(key2, value) { if (typeof value === "object") { if (cache.length) { const thisCutoff = getCutoff(cache, this); if (thisCutoff === 0) { cache[cache.length] = this; } else { cache.splice(thisCutoff); keys.splice(thisCutoff); } keys[keys.length] = key2; const valueCutoff = getCutoff(cache, value); if (valueCutoff !== 0) { return hasCircularReplacer ? circularReplacer.call( this, key2, value, getReferenceKey(keys, valueCutoff) ) : `[ref=${getReferenceKey(keys, valueCutoff)}]`; } } else { cache[0] = value; keys[0] = key2; } } return hasReplacer ? replacer.call(this, key2, value) : value; }; } function serialize(value, replacer, indent, circularReplacer) { return JSON.stringify( value, createReplacer(replacer, circularReplacer), indent ?? void 0 ); } var noopStorage = { getItem: (_key) => "", setItem: (_key, _value) => null, removeItem: (_key) => null }; function createStorage({ deserialize: deserialize2 = deserialize, key: prefix = "wagmi", serialize: serialize2 = serialize, storage }) { return { ...storage, getItem: (key2, defaultState = null) => { const value = storage.getItem(`${prefix}.${key2}`); try { return value ? deserialize2(value) : defaultState; } catch (error) { console.warn(error); return defaultState; } }, setItem: (key2, value) => { if (value === null) { storage.removeItem(`${prefix}.${key2}`); } else { try { storage.setItem(`${prefix}.${key2}`, serialize2(value)); } catch (err) { console.error(err); } } }, removeItem: (key2) => storage.removeItem(`${prefix}.${key2}`) }; } var storeKey = "store"; var _isAutoConnecting, _lastUsedConnector, _addEffects, addEffects_fn; var Client = class { constructor({ autoConnect = false, connectors = [new InjectedConnector()], provider, storage = createStorage({ storage: typeof window !== "undefined" ? window.localStorage : noopStorage }), logger: logger2 = { warn: console.warn }, webSocketProvider }) { var _a, _b; __privateAdd$1(this, _addEffects); this.providers = /* @__PURE__ */ new Map(); this.webSocketProviders = /* @__PURE__ */ new Map(); __privateAdd$1(this, _isAutoConnecting, void 0); __privateAdd$1(this, _lastUsedConnector, void 0); this.config = { autoConnect, connectors, logger: logger2, provider, storage, webSocketProvider }; let status = "disconnected"; let chainId; if (autoConnect) { try { const rawState = storage.getItem(storeKey); const data = (_a = rawState == null ? void 0 : rawState.state) == null ? void 0 : _a.data; status = (data == null ? void 0 : data.account) ? "reconnecting" : "connecting"; chainId = (_b = data == null ? void 0 : data.chain) == null ? void 0 : _b.id; } catch (_error) { } } this.store = createStore( subscribeWithSelector( persist( () => ({ connectors: typeof connectors === "function" ? connectors() : connectors, provider: this.getProvider({ chainId }), status, webSocketProvider: this.getWebSocketProvider({ chainId }) }), { name: storeKey, storage, partialize: (state) => { var _a2, _b2; return { ...autoConnect && { data: { account: (_a2 = state == null ? void 0 : state.data) == null ? void 0 : _a2.account, chain: (_b2 = state == null ? void 0 : state.data) == null ? void 0 : _b2.chain } }, chains: state == null ? void 0 : state.chains }; }, version: 2 } ) ) ); this.storage = storage; __privateSet$1(this, _lastUsedConnector, storage == null ? void 0 : storage.getItem("wallet")); __privateMethod$1(this, _addEffects, addEffects_fn).call(this); if (autoConnect && typeof window !== "undefined") setTimeout(async () => await this.autoConnect(), 0); } get chains() { return this.store.getState().chains; } get connectors() { return this.store.getState().connectors; } get connector() { return this.store.getState().connector; } get data() { return this.store.getState().data; } get error() { return this.store.getState().error; } get lastUsedChainId() { var _a, _b; return (_b = (_a = this.data) == null ? void 0 : _a.chain) == null ? void 0 : _b.id; } get provider() { return this.store.getState().provider; } get status() { return this.store.getState().status; } get subscribe() { return this.store.subscribe; } get webSocketProvider() { return this.store.getState().webSocketProvider; } setState(updater) { const newState = typeof updater === "function" ? updater(this.store.getState()) : updater; this.store.setState(newState, true); } clearState() { this.setState((x) => ({ ...x, chains: void 0, connector: void 0, data: void 0, error: void 0, status: "disconnected" })); } async destroy() { var _a, _b; if (this.connector) await ((_b = (_a = this.connector).disconnect) == null ? void 0 : _b.call(_a)); __privateSet$1(this, _isAutoConnecting, false); this.clearState(); this.store.destroy(); } async autoConnect() { if (__privateGet$1(this, _isAutoConnecting)) return; __privateSet$1(this, _isAutoConnecting, true); this.setState((x) => { var _a; return { ...x, status: ((_a = x.data) == null ? void 0 : _a.account) ? "reconnecting" : "connecting" }; }); const sorted = __privateGet$1(this, _lastUsedConnector) ? [...this.connectors].sort( (x) => x.id === __privateGet$1(this, _lastUsedConnector) ? -1 : 1 ) : this.connectors; let connected = false; for (const connector of sorted) { if (!connector.ready || !connector.isAuthorized) continue; const isAuthorized = await connector.isAuthorized(); if (!isAuthorized) continue; const data = await connector.connect(); this.setState((x) => ({ ...x, connector, chains: connector == null ? void 0 : connector.chains, data, status: "connected" })); connected = true; break; } if (!connected) this.setState((x) => ({ ...x, data: void 0, status: "disconnected" })); __privateSet$1(this, _isAutoConnecting, false); return this.data; } getProvider({ bust, chainId } = {}) { let provider_ = this.providers.get(chainId ?? -1); if (provider_ && !bust) return provider_; const { provider } = this.config; provider_ = typeof provider === "function" ? provider({ chainId }) : provider; this.providers.set(chainId ?? -1, provider_); return provider_; } getWebSocketProvider({ bust, chainId } = {}) { let webSocketProvider_ = this.webSocketProviders.get(chainId ?? -1); if (webSocketProvider_ && !bust) return webSocketProvider_; const { webSocketProvider } = this.config; webSocketProvider_ = typeof webSocketProvider === "function" ? webSocketProvider({ chainId }) : webSocketProvider; if (webSocketProvider_) this.webSocketProviders.set(chainId ?? -1, webSocketProvider_); return webSocketProvider_; } setLastUsedConnector(lastUsedConnector = null) { var _a; (_a = this.storage) == null ? void 0 : _a.setItem("wallet", lastUsedConnector); } }; _isAutoConnecting = /* @__PURE__ */ new WeakMap(); _lastUsedConnector = /* @__PURE__ */ new WeakMap(); _addEffects = /* @__PURE__ */ new WeakSet(); addEffects_fn = function() { const onChange = (data) => { this.setState((x) => ({ ...x, data: { ...x.data, ...data } })); }; const onDisconnect = () => { this.clearState(); }; const onError = (error) => { this.setState((x) => ({ ...x, error })); }; this.store.subscribe( ({ connector }) => connector, (connector, prevConnector) => { var _a, _b, _c, _d, _e, _f; (_a = prevConnector == null ? void 0 : prevConnector.off) == null ? void 0 : _a.call(prevConnector, "change", onChange); (_b = prevConnector == null ? void 0 : prevConnector.off) == null ? void 0 : _b.call(prevConnector, "disconnect", onDisconnect); (_c = prevConnector == null ? void 0 : prevConnector.off) == null ? void 0 : _c.call(prevConnector, "error", onError); if (!connector) return; (_d = connector.on) == null ? void 0 : _d.call(connector, "change", onChange); (_e = connector.on) == null ? void 0 : _e.call(connector, "disconnect", onDisconnect); (_f = connector.on) == null ? void 0 : _f.call(connector, "error", onError); } ); const { provider, webSocketProvider } = this.config; const subscribeProvider = typeof provider === "function"; const subscribeWebSocketProvider = typeof webSocketProvider === "function"; if (subscribeProvider || subscribeWebSocketProvider) this.store.subscribe( ({ data }) => { var _a; return (_a = data == null ? void 0 : data.chain) == null ? void 0 : _a.id; }, (chainId) => { this.setState((x) => ({ ...x, provider: this.getProvider({ bust: true, chainId }), webSocketProvider: this.getWebSocketProvider({ bust: true, chainId }) })); } ); }; var client; function createClient(config) { const client_ = new Client(config); client = client_; return client_; } function getClient() { if (!client) { throw new Error( "No wagmi client found. Ensure you have set up a client: https://wagmi.sh/react/client" ); } return client; } async function connect({ chainId, connector }) { const client2 = getClient(); const activeConnector = client2.connector; if (activeConnector && connector.id === activeConnector.id) throw new ConnectorAlreadyConnectedError(); try { client2.setState((x) => ({ ...x, status: "connecting" })); const data = await connector.connect({ chainId }); client2.setLastUsedConnector(connector.id); client2.setState((x) => ({ ...x, connector, chains: connector == null ? void 0 : connector.chains, data, status: "connected" })); client2.storage.setItem("connected", true); return { ...data, connector }; } catch (err) { client2.setState((x) => { return { ...x, status: x.connector ? "connected" : "disconnected" }; }); throw err; } } async function disconnect() { const client2 = getClient(); if (client2.connector) await client2.connector.disconnect(); client2.clearState(); client2.storage.removeItem("connected"); } var erc20ABI = [ { type: "event", name: "Approval", inputs: [ { indexed: true, name: "owner", type: "address" }, { indexed: true, name: "spender", type: "address" }, { indexed: false, name: "value", type: "uint256" } ] }, { type: "event", name: "Transfer", inputs: [ { indexed: true, name: "from", type: "address" }, { indexed: true, name: "to", type: "address" }, { indexed: false, name: "value", type: "uint256" } ] }, { type: "function", name: "allowance", stateMutability: "view", inputs: [ { name: "owner", type: "address" }, { name: "spender", type: "address" } ], outputs: [ { name: "", type: "uint256" } ] }, { type: "function", name: "approve", stateMutability: "nonpayable", inputs: [ { name: "spender", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] }, { type: "function", name: "balanceOf", stateMutability: "view", inputs: [ { name: "account", type: "address" } ], outputs: [ { name: "", type: "uint256" } ] }, { type: "function", name: "decimals", stateMutability: "view", inputs: [], outputs: [ { name: "", type: "uint8" } ] }, { type: "function", name: "name", stateMutability: "view", inputs: [], outputs: [ { name: "", type: "string" } ] }, { type: "function", name: "symbol", stateMutability: "view", inputs: [], outputs: [ { name: "", type: "string" } ] }, { type: "function", name: "totalSupply", stateMutability: "view", inputs: [], outputs: [ { name: "", type: "uint256" } ] }, { type: "function", name: "transfer", stateMutability: "nonpayable", inputs: [ { name: "recipient", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] }, { type: "function", name: "transferFrom", stateMutability: "nonpayable", inputs: [ { name: "sender", type: "address" }, { name: "recipient", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] } ]; var erc20ABI_bytes32 = [ { type: "event", name: "Approval", inputs: [ { indexed: true, name: "owner", type: "address" }, { indexed: true, name: "spender", type: "address" }, { indexed: false, name: "value", type: "uint256" } ] }, { type: "event", name: "Transfer", inputs: [ { indexed: true, name: "from", type: "address" }, { indexed: true, name: "to", type: "address" }, { indexed: false, name: "value", type: "uint256" } ] }, { type: "function", name: "allowance", stateMutability: "view", inputs: [ { name: "owner", type: "address" }, { name: "spender", type: "address" } ], outputs: [ { name: "", type: "uint256" } ] }, { type: "function", name: "approve", stateMutability: "nonpayable", inputs: [ { name: "spender", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] }, { type: "function", name: "balanceOf", stateMutability: "view", inputs: [ { name: "account", type: "address" } ], outputs: [ { name: "", type: "uint256" } ] }, { type: "function", name: "decimals", stateMutability: "view", inputs: [], outputs: [ { name: "", type: "uint8" } ] }, { type: "function", name: "name", stateMutability: "view", inputs: [], outputs: [ { name: "", type: "bytes32" } ] }, { type: "function", name: "symbol", stateMutability: "view", inputs: [], outputs: [ { name: "", type: "bytes32" } ] }, { type: "function", name: "totalSupply", stateMutability: "view", inputs: [], outputs: [ { name: "", type: "uint256" } ] }, { type: "function", name: "transfer", stateMutability: "nonpayable", inputs: [ { name: "recipient", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] }, { type: "function", name: "transferFrom", stateMutability: "nonpayable", inputs: [ { name: "sender", type: "address" }, { name: "recipient", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] } ]; var multicallABI = [ { inputs: [ { components: [ { name: "target", type: "address" }, { name: "allowFailure", type: "bool" }, { name: "callData", type: "bytes" } ], name: "calls", type: "tuple[]" } ], name: "aggregate3", outputs: [ { components: [ { name: "success", type: "bool" }, { name: "returnData", type: "bytes" } ], name: "returnData", type: "tuple[]" } ], stateMutability: "view", type: "function" } ]; function getContract({ address, abi, signerOrProvider }) { return new Contract( address, abi, signerOrProvider ); } function getProvider({ chainId } = {}) { const client2 = getClient(); if (chainId) return client2.getProvider({ chainId }) || client2.provider; return client2.provider; } async function multicall({ allowFailure = true, chainId, contracts, overrides }) { var _a; const provider = getProvider({ chainId }); if (!provider.chains) throw new ProviderChainsNotFound(); const chain = provider.chains.find((chain2) => chain2.id === chainId) || provider.chains[0]; if (!chain) throw new ProviderChainsNotFound(); if (!((_a = chain == null ? void 0 : chain.contracts) == null ? void 0 : _a.multicall3)) throw new ChainDoesNotSupportMulticallError({ chain }); if (typeof (overrides == null ? void 0 : overrides.blockTag) === "number" && (overrides == null ? void 0 : overrides.blockTag) < (chain.contracts.multicall3.blockCreated ?? 0)) throw new ChainDoesNotSupportMulticallError({ blockNumber: overrides == null ? void 0 : overrides.blockTag, chain }); const multicallContract = getContract({ address: chain.contracts.multicall3.address, abi: multicallABI, signerOrProvider: provider }); const calls = contracts.map( ({ address, abi, functionName, ...config }) => { const { args } = config || {}; const contract = getContract({ address, abi }); const params2 = args ?? []; const normalizedFunctionName = normalizeFunctionName({ contract, functionName, args }); try { const contractFunction = contract[normalizedFunctionName]; if (!contractFunction) logWarn( `"${normalizedFunctionName}" is not in the interface for contract "${address}"` ); const callData = contract.interface.encodeFunctionData( normalizedFunctionName, params2 ); return { target: address, allowFailure, callData }; } catch (err) { if (!allowFailure) throw err; return { target: address, allowFailure, callData: "0x" }; } } ); const params = [...[calls], ...overrides ? [overrides] : []]; const results = await multicallContract.aggregate3( ...params ); return results.map(({ returnData, success }, i2) => { const { address, abi, functionName, ...rest } = contracts[i2]; const contract = getContract({ address, abi }); const args = rest.args; const normalizedFunctionName = normalizeFunctionName({ contract, functionName, args }); if (!success) { let error; try { contract.interface.decodeFunctionResult( normalizedFunctionName, returnData ); } catch (err) { error = new ContractMethodRevertedError({ address, args, chainId: chain.id, functionName: normalizedFunctionName, errorMessage: err.message }); if (!allowFailure) throw error; logWarn(error.message); } return null; } if (returnData === "0x") { const error = new ContractMethodNoResultError({ address, args, chainId: chain.id, functionName: normalizedFunctionName }); if (!allowFailure) throw error; logWarn(error.message); return null; } try { const result = contract.interface.decodeFunctionResult( normalizedFunctionName, returnData ); return Array.isArray(result) && result.length === 1 ? result[0] : result; } catch (err) { const error = new ContractResultDecodeError({ address, args, chainId: chain.id, functionName: normalizedFunctionName, errorMessage: err.message }); if (!allowFailure) throw error; logWarn(error.message); return null; } }); } async function readContract({ address, chainId, abi, functionName, overrides, ...config }) { const provider = getProvider({ chainId }); const contract = getContract({ address, abi, signerOrProvider: provider }); const args = config.args; const normalizedFunctionName = normalizeFunctionName({ contract, functionName, args }); const contractFunction = contract[normalizedFunctionName]; if (!contractFunction) throw new ContractMethodDoesNotExistError({ address, functionName: normalizedFunctionName }); const params = [...args ?? [], ...overrides ? [overrides] : []]; return contractFunction == null ? void 0 : contractFunction(...params); } async function readContracts({ allowFailure = true, contracts, overrides }) { try { const provider = getProvider(); const contractsByChainId = contracts.reduce((contracts2, contract, index) => { const chainId = contract.chainId ?? provider.network.chainId; return { ...contracts2, [chainId]: [...contracts2[chainId] || [], { contract, index }] }; }, {}); const promises = () => Object.entries(contractsByChainId).map( ([chainId, contracts2]) => multicall({ allowFailure, chainId: parseInt(chainId), contracts: contracts2.map(({ contract }) => contract), overrides }) ); let multicallResults; if (allowFailure) { multicallResults = (await Promise.allSettled(promises())).map((result) => { if (result.status === "fulfilled") return result.value; if (result.reason instanceof ChainDoesNotSupportMulticallError) { logWarn(result.reason.message); throw result.reason; } return null; }).flat(); } else { multicallResults = (await Promise.all(promises())).flat(); } const resultIndexes = Object.values(contractsByChainId).map((contracts2) => contracts2.map(({ index }) => index)).flat(); return multicallResults.reduce((results, result, index) => { if (results) results[resultIndexes[index]] = result; return results; }, []); } catch (err) { if (err instanceof ContractResultDecodeError) throw err; if (err instanceof ContractMethodNoResultError) throw err; if (err instanceof ContractMethodRevertedError) throw err; const promises = () => contracts.map( (contract) => readContract({ ...contract, overrides }) ); if (allowFailure) return (await Promise.allSettled(promises())).map((result, i2) => { if (result.status === "fulfilled") return result.value; const { address, args, chainId, functionName } = contracts[i2]; const error = new ContractMethodRevertedError({ address, functionName, chainId: chainId ?? 1, args, errorMessage: result.reason }); logWarn(error.message); return null; }); return await Promise.all(promises()); } } async function fetchEnsAvatar({ address, chainId }) { const provider = getProvider({ chainId }); const avatar = await provider.getAvatar(address); return avatar; } async function fetchEnsName({ address, chainId }) { const provider = getProvider({ chainId }); return provider.lookupAddress(utils.getAddress(address)); } async function fetchBalance({ address, chainId, formatUnits: unit, token }) { const client2 = getClient(); const provider = getProvider({ chainId }); if (token) { const fetchContractBalance = async ({ abi }) => { const erc20Config = { abi, address: token, chainId }; const [value2, decimals, symbol] = await readContracts({ allowFailure: false, contracts: [ { ...erc20Config, functionName: "balanceOf", args: [address] }, { ...erc20Config, functionName: "decimals" }, { ...erc20Config, functionName: "symbol" } ] }); return { decimals, formatted: utils.formatUnits(value2 ?? "0", unit ?? decimals), symbol, value: value2 }; }; try { return await fetchContractBalance({ abi: erc20ABI }); } catch (err) { if (err instanceof ContractResultDecodeError) { const { symbol, ...rest } = await fetchContractBalance({ abi: erc20ABI_bytes32 }); return { symbol: utils.parseBytes32String(symbol), ...rest }; } throw err; } } const chains = [...client2.provider.chains || [], ...client2.chains ?? []]; const value = await provider.getBalance(address); const chain = chains.find((x) => x.id === provider.network.chainId); return { decimals: (chain == null ? void 0 : chain.nativeCurrency.decimals) ?? 18, formatted: utils.formatUnits(value ?? "0", unit ?? "ether"), symbol: (chain == null ? void 0 : chain.nativeCurrency.symbol) ?? "ETH", value }; } async function fetchSigner({ chainId } = {}) { var _a, _b; const client2 = getClient(); const signer = await ((_b = (_a = client2.connector) == null ? void 0 : _a.getSigner) == null ? void 0 : _b.call(_a, { chainId })) || null; return signer; } function getAccount() { const { data, connector, status } = getClient(); switch (status) { case "connected": return { address: data == null ? void 0 : data.account, connector, isConnected: true, isConnecting: false, isDisconnected: false, isReconnecting: false, status }; case "reconnecting": return { address: data == null ? void 0 : data.account, connector, isConnected: !!(data == null ? void 0 : data.account), isConnecting: false, isDisconnected: false, isReconnecting: true, status }; case "connecting": return { address: data == null ? void 0 : data.account, connector, isConnected: false, isConnecting: true, isDisconnected: false, isReconnecting: false, status }; case "disconnected": return { address: void 0, connector: void 0, isConnected: false, isConnecting: false, isDisconnected: true, isReconnecting: false, status }; } } function getNetwork() { var _a, _b, _c; const client2 = getClient(); const chainId = (_b = (_a = client2.data) == null ? void 0 : _a.chain) == null ? void 0 : _b.id; const activeChains = client2.chains ?? []; const activeChain = [...client2.provider.chains || [], ...activeChains].find( (x) => x.id === chainId ) ?? { id: chainId, name: `Chain ${chainId}`, network: `${chainId}`, nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" }, rpcUrls: { default: { http: [""] }, public: { http: [""] } } }; return { chain: chainId ? { ...activeChain, ...(_c = client2.data) == null ? void 0 : _c.chain, id: chainId } : void 0, chains: activeChains }; } async function signMessage(args) { try { const signer = await fetchSigner(); if (!signer) throw new ConnectorNotFoundError(); return await signer.signMessage( args.message ); } catch (error) { if (error.code === 4001 || error.code === "ACTION_REJECTED") throw new UserRejectedRequestError(error); throw error; } } async function switchNetwork({ chainId }) { const { connector } = getClient(); if (!connector) throw new ConnectorNotFoundError(); if (!connector.switchChain) throw new SwitchChainNotSupportedError({ connector }); return connector.switchChain(chainId); } function watchAccount(callback, { selector = (x) => x } = {}) { const client2 = getClient(); const handleChange = () => callback(getAccount()); const unsubscribe = client2.subscribe( ({ data, connector, status }) => selector({ address: data == null ? void 0 : data.account, connector, status }), handleChange, { equalityFn: shallow } ); return unsubscribe; } function watchNetwork(callback, { selector = (x) => x } = {}) { const client2 = getClient(); const handleChange = () => callback(getNetwork()); const unsubscribe = client2.subscribe( ({ data, chains }) => { var _a; return selector({ chainId: (_a = data == null ? void 0 : data.chain) == null ? void 0 : _a.id, chains }); }, handleChange, { equalityFn: shallow } ); return unsubscribe; } var RpcError = class extends Error { constructor(message, options) { const { cause, code: code2, data } = options; if (!Number.isInteger(code2)) throw new Error('"code" must be an integer.'); if (!message || typeof message !== "string") throw new Error('"message" must be a nonempty string.'); super(message); this.cause = cause; this.code = code2; this.data = data; } }; var ProviderRpcError = class extends RpcError { constructor(message, options) { const { cause, code: code2, data } = options; if (!(Number.isInteger(code2) && code2 >= 1e3 && code2 <= 4999)) throw new Error( '"code" must be an integer such that: 1000 <= code <= 4999' ); super(message, { cause, code: code2, data }); } }; var AddChainError = class extends Error { constructor() { super(...arguments); this.name = "AddChainError"; this.message = "Error adding chain"; } }; var ChainDoesNotSupportMulticallError = class extends Error { constructor({ blockNumber, chain }) { super( `Chain "${chain.name}" does not support multicall${blockNumber ? ` on block ${blockNumber}` : ""}.` ); this.name = "ChainDoesNotSupportMulticall"; } }; var ChainNotConfiguredError = class extends Error { constructor({ chainId, connectorId }) { super(`Chain "${chainId}" not configured for connector "${connectorId}".`); this.name = "ChainNotConfigured"; } }; var ConnectorAlreadyConnectedError = class extends Error { constructor() { super(...arguments); this.name = "ConnectorAlreadyConnectedError"; this.message = "Connector already connected"; } }; var ConnectorNotFoundError = class extends Error { constructor() { super(...arguments); this.name = "ConnectorNotFoundError"; this.message = "Connector not found"; } }; var ContractMethodDoesNotExistError = class extends Error { constructor({ address, chainId, functionName }) { var _a; const { chains, network } = getProvider(); const chain = chains == null ? void 0 : chains.find(({ id: id2 }) => id2 === (chainId || network.chainId)); const blockExplorer = (_a = chain == null ? void 0 : chain.blockExplorers) == null ? void 0 : _a.default; super( [ `Function "${functionName}" on contract "${address}" does not exist.`, ...blockExplorer ? [ "", `${blockExplorer == null ? void 0 : blockExplorer.name}: ${blockExplorer == null ? void 0 : blockExplorer.url}/address/${address}#readContract` ] : [] ].join("\n") ); this.name = "ContractMethodDoesNotExistError"; } }; var ContractMethodNoResultError = class extends Error { constructor({ address, args, chainId, functionName }) { super( [ "Contract read returned an empty response. This could be due to any of the following:", `- The contract does not have the function "${functionName}",`, "- The parameters passed to the contract function may be invalid, or", "- The address is not a contract.", "", `Config:`, JSON.stringify( { address, abi: "...", functionName, chainId, args }, null, 2 ) ].join("\n") ); this.name = "ContractMethodNoResultError"; } }; var ContractMethodRevertedError = class extends Error { constructor({ address, args, chainId, functionName, errorMessage }) { super( [ "Contract method reverted with an error.", "", `Config:`, JSON.stringify( { address, abi: "...", functionName, chainId, args }, null, 2 ), "", `Details: ${errorMessage}` ].join("\n") ); this.name = "ContractMethodRevertedError"; } }; var ContractResultDecodeError = class extends Error { constructor({ address, args, chainId, functionName, errorMessage }) { super( [ "Failed to decode contract function result.", "", `Config:`, JSON.stringify( { address, abi: "...", functionName, chainId, args }, null, 2 ), "", `Details: ${errorMessage}` ].join("\n") ); this.name = "ContractResultDecodeError"; } }; var ProviderChainsNotFound = class extends Error { constructor() { super(...arguments); this.name = "ProviderChainsNotFound"; this.message = [ "No chains were found on the wagmi provider. Some functions that require a chain may not work.", "", "It is recommended to add a list of chains to the provider in `createClient`.", "", "Example:", "", "```", "import { getDefaultProvider } from 'ethers'", "import { chain, createClient } from 'wagmi'", "", "createClient({", " provider: Object.assign(getDefaultProvider(), { chains: [chain.mainnet] })", "})", "```" ].join("\n"); } }; var ResourceUnavailableError = class extends RpcError { constructor(cause) { super("Resource unavailable", { cause, code: -32002 }); this.name = "ResourceUnavailable"; } }; var SwitchChainError = class extends ProviderRpcError { constructor(cause) { super("Error switching chain", { cause, code: 4902 }); this.name = "SwitchChainError"; } }; var SwitchChainNotSupportedError = class extends Error { constructor({ connector }) { super(`"${connector.name}" does not support programmatic chain switching.`); this.name = "SwitchChainNotSupportedError"; } }; var UserRejectedRequestError = class extends ProviderRpcError { constructor(cause) { super("User rejected request", { cause, code: 4001 }); this.name = "UserRejectedRequestError"; } }; var _client, _provider$1, _isUserRejectedRequestError, isUserRejectedRequestError_fn; var CoinbaseWalletConnector = class extends Connector { constructor({ chains, options }) { super({ chains, options: { reloadOnDisconnect: false, ...options } }); __privateAdd(this, _isUserRejectedRequestError); __publicField(this, "id", "coinbaseWallet"); __publicField(this, "name", "Coinbase Wallet"); __publicField(this, "ready", true); __privateAdd(this, _client, void 0); __privateAdd(this, _provider$1, void 0); __publicField(this, "onAccountsChanged", (accounts) => { if (accounts.length === 0) this.emit("disconnect"); else this.emit("change", { account: utils.getAddress(accounts[0]) }); }); __publicField(this, "onChainChanged", (chainId) => { const id2 = normalizeChainId(chainId); const unsupported = this.isChainUnsupported(id2); this.emit("change", { chain: { id: id2, unsupported } }); }); __publicField(this, "onDisconnect", () => { this.emit("disconnect"); }); } async connect({ chainId } = {}) { try { const provider = await this.getProvider(); provider.on("accountsChanged", this.onAccountsChanged); provider.on("chainChanged", this.onChainChanged); provider.on("disconnect", this.onDisconnect); this.emit("message", { type: "connecting" }); const accounts = await provider.enable(); const account = utils.getAddress(accounts[0]); let id2 = await this.getChainId(); let unsupported = this.isChainUnsupported(id2); if (chainId && id2 !== chainId) { const chain = await this.switchChain(chainId); id2 = chain.id; unsupported = this.isChainUnsupported(id2); } return { account, chain: { id: id2, unsupported }, provider: new Web3Provider( provider ) }; } catch (error) { if (/(user closed modal|accounts received is empty)/i.test( error.message )) throw new UserRejectedRequestError(error); throw error; } } async disconnect() { if (!__privateGet(this, _provider$1)) return; const provider = await this.getProvider(); provider.removeListener("accountsChanged", this.onAccountsChanged); provider.removeListener("chainChanged", this.onChainChanged); provider.removeListener("disconnect", this.onDisconnect); provider.disconnect(); provider.close(); } async getAccount() { const provider = await this.getProvider(); const accounts = await provider.request({ method: "eth_accounts" }); return utils.getAddress(accounts[0]); } async getChainId() { const provider = await this.getProvider(); const chainId = normalizeChainId(provider.chainId); return chainId; } async getProvider() { var _a; if (!__privateGet(this, _provider$1)) { let CoinbaseWalletSDK = (await __vitePreload(() => import("./index-2bdcf748.js").then((n2) => n2.i), true ? ["./index-2bdcf748.js","./tslib-bb523be7.js"] : void 0, import.meta.url)).default; if (typeof CoinbaseWalletSDK !== "function" && typeof CoinbaseWalletSDK.default === "function") CoinbaseWalletSDK = CoinbaseWalletSDK.default; __privateSet(this, _client, new CoinbaseWalletSDK(this.options)); const walletExtensionChainId = (_a = __privateGet(this, _client).walletExtension) == null ? void 0 : _a.getChainId(); const chain = this.chains.find( (chain2) => this.options.chainId ? chain2.id === this.options.chainId : chain2.id === walletExtensionChainId ) || this.chains[0]; const chainId = this.options.chainId || (chain == null ? void 0 : chain.id); const jsonRpcUrl = this.options.jsonRpcUrl || (chain == null ? void 0 : chain.rpcUrls.default.http[0]); __privateSet(this, _provider$1, __privateGet(this, _client).makeWeb3Provider(jsonRpcUrl, chainId)); } return __privateGet(this, _provider$1); } async getSigner({ chainId } = {}) { const [provider, account] = await Promise.all([ this.getProvider(), this.getAccount() ]); return new Web3Provider( provider, chainId ).getSigner(account); } async isAuthorized() { try { const account = await this.getAccount(); return !!account; } catch { return false; } } async switchChain(chainId) { var _a; const provider = await this.getProvider(); const id2 = utils.hexValue(chainId); try { await provider.request({ method: "wallet_switchEthereumChain", params: [{ chainId: id2 }] }); return this.chains.find((x) => x.id === chainId) ?? { id: chainId, name: `Chain ${id2}`, network: `${id2}`, nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" }, rpcUrls: { default: { http: [""] }, public: { http: [""] } } }; } catch (error) { const chain = this.chains.find((x) => x.id === chainId); if (!chain) throw new ChainNotConfiguredError({ chainId, connectorId: this.id }); if (error.code === 4902) { try { await provider.request({ method: "wallet_addEthereumChain", params: [ { chainId: id2, chainName: chain.name, nativeCurrency: chain.nativeCurrency, rpcUrls: [((_a = chain.rpcUrls.public) == null ? void 0 : _a.http[0]) ?? ""], blockExplorerUrls: this.getBlockExplorerUrls(chain) } ] }); return chain; } catch (addError) { if (__privateMethod(this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, addError)) throw new UserRejectedRequestError(addError); throw new AddChainError(); } } if (__privateMethod(this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, error)) throw new UserRejectedRequestError(error); throw new SwitchChainError(error); } } async watchAsset({ address, decimals = 18, image, symbol }) { const provider = await this.getProvider(); return provider.request({ method: "wallet_watchAsset", params: { type: "ERC20", options: { address, decimals, image, symbol } } }); } }; _client = /* @__PURE__ */ new WeakMap(); _provider$1 = /* @__PURE__ */ new WeakMap(); _isUserRejectedRequestError = /* @__PURE__ */ new WeakSet(); isUserRejectedRequestError_fn = function(error) { return /(user rejected)/i.test(error.message); }; var defaultV2Config = { namespace: "eip155", methods: [ "eth_sendTransaction", "eth_sendRawTransaction", "eth_sign", "eth_signTransaction", "eth_signTypedData", "eth_signTypedData_v3", "eth_signTypedData_v4", "personal_sign", "wallet_switchEthereumChain", "wallet_addEthereumChain" ], events: ["accountsChanged", "chainChanged"] }; var _provider, _initUniversalProviderPromise, _web3Modal, _createWeb3Modal, createWeb3Modal_fn, _initUniversalProvider, initUniversalProvider_fn, _createUniversalProvider, createUniversalProvider_fn, _isChainsAuthorized, isChainsAuthorized_fn, _switchChain, switchChain_fn; var WalletConnectConnector = class extends Connector { constructor(config) { super(config); __privateAdd(this, _createWeb3Modal); __privateAdd(this, _initUniversalProvider); __privateAdd(this, _createUniversalProvider); __privateAdd(this, _isChainsAuthorized); __privateAdd(this, _switchChain); __publicField(this, "id", "walletConnect"); __publicField(this, "name", "WalletConnect"); __publicField(this, "ready", true); __privateAdd(this, _provider, void 0); __privateAdd(this, _initUniversalProviderPromise, void 0); __privateAdd(this, _web3Modal, void 0); __publicField(this, "onAccountsChanged", (accounts) => { if (accounts.length === 0) this.emit("disconnect"); else this.emit("change", { account: utils.getAddress(accounts[0]) }); }); __publicField(this, "onChainChanged", (chainId) => { const id2 = normalizeChainId(chainId); const unsupported = this.isChainUnsupported(id2); this.emit("change", { chain: { id: id2, unsupported } }); }); __publicField(this, "onDisconnect", () => { this.emit("disconnect"); }); __publicField(this, "onDisplayUri", (uri) => { this.emit("message", { type: "display_uri", data: uri }); }); if (this.version === "2") { __privateMethod(this, _createUniversalProvider, createUniversalProvider_fn).call(this); if (this.isQrCode) __privateMethod(this, _createWeb3Modal, createWeb3Modal_fn).call(this); } } get isQrCode() { return this.options.qrcode !== false; } get namespacedChains() { return this.chains.map( (chain) => `${defaultV2Config.namespace}:${chain.id}` ); } get version() { if ("version" in this.options) return this.options.version; return "1"; } async connect({ chainId } = {}) { var _a, _b, _c, _d; const isV1 = this.version === "1"; const isV2 = this.version === "2"; try { let targetChainId = chainId; if (!targetChainId) { const lastUsedChainId = getClient().lastUsedChainId; if (lastUsedChainId && !this.isChainUnsupported(lastUsedChainId)) targetChainId = lastUsedChainId; } const provider = await this.getProvider({ chainId: targetChainId, create: isV1 }); provider.on("accountsChanged", this.onAccountsChanged); provider.on("chainChanged", this.onChainChanged); provider.on("disconnect", this.onDisconnect); if (isV2) { provider.on("session_delete", this.onDisconnect); provider.on("display_uri", this.onDisplayUri); const isChainsAuthorized = await __privateMethod(this, _isChainsAuthorized, isChainsAuthorized_fn).call(this); if (provider.session && !isChainsAuthorized) await provider.disconnect(); if (!provider.session || provider.session && !isChainsAuthorized) { await Promise.race([ provider.connect({ namespaces: { [defaultV2Config.namespace]: { methods: defaultV2Config.methods, events: defaultV2Config.events, chains: this.namespacedChains, rpcMap: this.chains.reduce( (rpc, chain) => ({ ...rpc, [chain.id]: chain.rpcUrls.default.http[0] }), {} ) } } }), ...this.isQrCode ? [ new Promise( (_resolve, reject) => provider.on("display_uri", async (uri) => { var _a2, _b2; await ((_a2 = __privateGet(this, _web3Modal)) == null ? void 0 : _a2.openModal({ uri })); (_b2 = __privateGet(this, _web3Modal)) == null ? void 0 : _b2.subscribeModal(({ open }) => { if (!open) reject(new Error("user rejected")); }); }) ) ] : [] ]); if (this.isQrCode) (_a = __privateGet(this, _web3Modal)) == null ? void 0 : _a.closeModal(); } } setTimeout(() => this.emit("message", { type: "connecting" }), 0); const accounts = await Promise.race([ provider.enable(), ...isV1 && this.isQrCode ? [ new Promise( (_res, reject) => provider.connector.on( "disconnect", () => reject(new Error("user rejected")) ) ) ] : [] ]); const account = utils.getAddress(accounts[0]); const id2 = await this.getChainId(); const unsupported = this.isChainUnsupported(id2); if (isV1) { const walletName = ((_c = (_b = provider.connector) == null ? void 0 : _b.peerMeta) == null ? void 0 : _c.name) ?? ""; const switchChainAllowedRegex = /(imtoken|metamask|omni|rainbow|trust wallet)/i; if (switchChainAllowedRegex.test(walletName)) this.switchChain = __privateMethod(this, _switchChain, switchChain_fn); } else this.switchChain = __privateMethod(this, _switchChain, switchChain_fn); return { account, chain: { id: id2, unsupported }, provider: new Web3Provider( provider ) }; } catch (error) { if (isV2 && this.isQrCode) (_d = __privateGet(this, _web3Modal)) == null ? void 0 : _d.closeModal(); if (/user closed modal|user rejected/i.test( error == null ? void 0 : error.message )) { throw new UserRejectedRequestError(error); } throw error; } } async disconnect() { const provider = await this.getProvider(); try { await provider.disconnect(); } catch (error) { if (!/No matching key/i.test(error.message)) throw error; } provider.removeListener("accountsChanged", this.onAccountsChanged); provider.removeListener("chainChanged", this.onChainChanged); provider.removeListener("disconnect", this.onDisconnect); if (this.version === "1" && typeof localStorage !== "undefined") localStorage.removeItem("walletconnect"); else { provider.removeListener("session_delete", this.onDisconnect); provider.removeListener("display_uri", this.onDisplayUri); } } async getAccount() { const provider = await this.getProvider(); let accounts; if (this.version === "1") accounts = provider.accounts; else accounts = await provider.request({ method: "eth_accounts" }); return utils.getAddress(accounts[0]); } async getChainId() { var _a, _b; const provider = await this.getProvider(); if (this.version === "1") return normalizeChainId(provider.chainId); return ((_b = (_a = getClient().data) == null ? void 0 : _a.chain) == null ? void 0 : _b.id) ?? normalizeChainId(await provider.request({ method: "eth_chainId" })); } async getProvider({ chainId, create } = {}) { var _a, _b; if (this.options.version === "2") { if (!__privateGet(this, _provider)) await __privateMethod(this, _createUniversalProvider, createUniversalProvider_fn).call(this); if (chainId) __privateGet(this, _provider).setDefaultChain( `${defaultV2Config.namespace}:${chainId}` ); return __privateGet(this, _provider); } else if (!__privateGet(this, _provider) || chainId || create) { const rpc = !((_a = this.options) == null ? void 0 : _a.infuraId) ? this.chains.reduce( (rpc2, chain) => ({ ...rpc2, [chain.id]: chain.rpcUrls.default.http[0] }), {} ) : {}; const WalletConnectProvider = (await __vitePreload(() => import("./index-a0bc99f6.js"), true ? ["./index-a0bc99f6.js","./index-fbf1926a.js","./tslib-bb523be7.js","./dijkstra-cb1f074b.js"] : void 0, import.meta.url)).default; __privateSet(this, _provider, new WalletConnectProvider({ ...this.options, chainId, rpc: { ...rpc, ...(_b = this.options) == null ? void 0 : _b.rpc } })); return __privateGet(this, _provider); } return __privateGet(this, _provider); } async getSigner({ chainId } = {}) { const [provider, account] = await Promise.all([ this.getProvider({ chainId }), this.getAccount() ]); let provider_ = provider; if (this.version === "2") { const chainId_ = await this.getChainId(); provider_ = { ...provider, async request(args) { return await provider.request( args, `${defaultV2Config.namespace}:${chainId ?? chainId_}` ); } }; } return new Web3Provider(provider_, chainId).getSigner(account); } async isAuthorized() { try { const [account, isChainsAuthorized] = await Promise.all([ this.getAccount(), __privateMethod(this, _isChainsAuthorized, isChainsAuthorized_fn).call(this) ]); return !!account && isChainsAuthorized; } catch { return false; } } }; _provider = /* @__PURE__ */ new WeakMap(); _initUniversalProviderPromise = /* @__PURE__ */ new WeakMap(); _web3Modal = /* @__PURE__ */ new WeakMap(); _createWeb3Modal = /* @__PURE__ */ new WeakSet(); createWeb3Modal_fn = async function() { const { Web3Modal } = await __vitePreload(() => import("./index-87de7c9c.js"), true ? ["./index-87de7c9c.js","./preload-helper-f8376bb0.js"] : void 0, import.meta.url); const { version: version2 } = this.options; __privateSet(this, _web3Modal, new Web3Modal({ walletConnectVersion: version2 === "2" ? 2 : 1, projectId: version2 === "2" ? this.options.projectId : "", standaloneChains: this.namespacedChains })); }; _initUniversalProvider = /* @__PURE__ */ new WeakSet(); initUniversalProvider_fn = async function() { const WalletConnectProvider = (await __vitePreload(() => import("./index.es-0ba1da57.js"), true ? ["./index.es-0ba1da57.js","./tslib-bb523be7.js","./index-fbf1926a.js"] : void 0, import.meta.url)).default; if (typeof (WalletConnectProvider == null ? void 0 : WalletConnectProvider.init) === "function") { __privateSet(this, _provider, await WalletConnectProvider.init( this.options )); } }; _createUniversalProvider = /* @__PURE__ */ new WeakSet(); createUniversalProvider_fn = async function() { if (!__privateGet(this, _initUniversalProviderPromise)) { __privateSet(this, _initUniversalProviderPromise, __privateMethod(this, _initUniversalProvider, initUniversalProvider_fn).call(this)); } return __privateGet(this, _initUniversalProviderPromise); }; _isChainsAuthorized = /* @__PURE__ */ new WeakSet(); isChainsAuthorized_fn = async function() { var _a, _b; const provider = await this.getProvider(); if (this.version === "1") return true; const providerChains = ((_b = (_a = provider.namespaces) == null ? void 0 : _a[defaultV2Config.namespace]) == null ? void 0 : _b.chains) || []; const authorizedChainIds = providerChains.map( (chain) => parseInt(chain.split(":")[1] || "") ); return !this.chains.some(({ id: id2 }) => !authorizedChainIds.includes(id2)); }; _switchChain = /* @__PURE__ */ new WeakSet(); switchChain_fn = async function(chainId) { const provider = await this.getProvider(); const id2 = utils.hexValue(chainId); try { await Promise.race([ provider.request({ method: "wallet_switchEthereumChain", params: [{ chainId: id2 }] }), new Promise( (res) => this.on("change", ({ chain }) => { if ((chain == null ? void 0 : chain.id) === chainId) res(chainId); }) ) ]); if (this.version === "2") { ; provider.setDefaultChain( `${defaultV2Config.namespace}:${chainId}` ); this.onChainChanged(chainId); } return this.chains.find((x) => x.id === chainId) ?? { id: chainId, name: `Chain ${id2}`, network: `${id2}`, nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" }, rpcUrls: { default: { http: [""] }, public: { http: [""] } } }; } catch (error) { const message = typeof error === "string" ? error : error == null ? void 0 : error.message; if (/user rejected request/i.test(message)) throw new UserRejectedRequestError(error); throw new SwitchChainError(error); } }; function jsonRpcProvider({ priority, rpc, stallTimeout, static: static_ = true, weight }) { return function(chain) { const rpcConfig = rpc(chain); if (!rpcConfig || rpcConfig.http === "") return null; return { chain: { ...chain, rpcUrls: { ...chain.rpcUrls, default: { http: [rpcConfig.http] } } }, provider: () => { var _a, _b; const RpcProvider = static_ ? StaticJsonRpcProvider : JsonRpcProvider; const provider = new RpcProvider(rpcConfig.http, { ensAddress: (_b = (_a = chain.contracts) == null ? void 0 : _a.ensRegistry) == null ? void 0 : _b.address, chainId: chain.id, name: chain.network }); return Object.assign(provider, { priority, stallTimeout, weight }); }, ...rpcConfig.webSocket && { webSocketProvider: () => new WebSocketProvider( rpcConfig.webSocket, chain.id ) } }; }; } let P$1 = class P { constructor(n2, t2) { this.wagmi = {}, this.walletConnectUri = "", this.walletConnectVersion = 1, this.chains = [], this.namespace = "eip155", this.disconnect = disconnect, this.getAccount = getAccount, this.watchAccount = watchAccount, this.fetchBalance = fetchBalance, this.getNetwork = getNetwork, this.watchNetwork = watchNetwork, this.switchNetwork = switchNetwork, this.fetchEnsName = fetchEnsName, this.fetchEnsAvatar = fetchEnsAvatar; var e; const o = n2.connectors.find((i2) => i2.id === "walletConnect"); if (!o) throw new Error("WalletConnectConnector is required"); this.wagmi = n2, this.chains = t2, this.walletConnectVersion = Number((e = o.options.version) != null ? e : "1"); } getDefaultConnectorChainId(n2) { return n2.chains[0].id; } async connectWalletConnectV1(n2, t2) { return new Promise((e, o) => { n2.once("message", async ({ type: i2 }) => { if (i2 === "connecting") { const c2 = (await n2.getProvider()).connector; this.walletConnectUri = c2.uri, t2(c2.uri), c2.on("disconnect", () => { o(Error()); }), c2.on("connect", () => { e(); }); } }); }); } async connectWalletConnectV2(n2, t2) { const e = await n2.getProvider(); let o = ""; return new Promise((i2) => { e.once("display_uri", (c2) => { this.walletConnectUri = c2, o = c2, t2(c2); }), e.once("connect", () => { o === this.walletConnectUri && i2(); }); }); } getDefaultChain() { const n2 = this.chains.find((t2) => t2.id === 1); return n2 ?? this.chains[0]; } getConnectorById(n2) { const t2 = this.wagmi.connectors.find((e) => e.id === n2); if (!t2) throw new Error(`Connector for id ${n2} was not found`); return t2; } getConnectors() { return this.wagmi.connectors.filter((n2) => n2.id !== "walletConnect"); } async connectWalletConnect(n2, t2) { const e = this.getConnectorById("walletConnect"), o = this.walletConnectVersion === 1, i2 = t2 ?? this.getDefaultConnectorChainId(e), c2 = o ? this.connectWalletConnectV1.bind(this) : this.connectWalletConnectV2.bind(this), [a2] = await Promise.all([connect({ connector: e, chainId: i2 }), c2(e, n2)]); return a2; } async connectConnector(n2, t2) { const e = this.getConnectorById(n2), o = t2 ?? this.getDefaultConnectorChainId(e); return await connect({ connector: e, chainId: o }); } }; const E = "eip155"; function j({ projectId: r2 }) { return jsonRpcProvider({ rpc: (n2) => { var t2; return [1, 3, 4, 5, 10, 42, 56, 69, 97, 100, 137, 420, 42161, 42220, 43114, 80001, 421611, 421613, 1313161554, 11297108109].includes(n2.id) ? { http: `https://rpc.walletconnect.com/v1/?chainId=${E}:${n2.id}&projectId=${r2}` } : { http: n2.rpcUrls.default.http[0], webSocket: (t2 = n2.rpcUrls.default.webSocket) == null ? void 0 : t2[0] }; } }); } function V({ appName: r2, chains: n2, version: t2, projectId: e }) { const o = t2 ?? "1"; if (o === "2" && !e) throw new Error("modalConnectors() requires projectId for WalletConnect version 2"); return [new WalletConnectConnector({ chains: n2, options: { qrcode: false, version: o, projectId: e } }), new InjectedConnector({ chains: n2, options: { shimDisconnect: true, shimChainChangedDisconnect: true } }), new CoinbaseWalletConnector({ chains: n2, options: { appName: r2 } })]; } const t = Symbol(); const s$1 = Object.getPrototypeOf, c$2 = /* @__PURE__ */ new WeakMap(), l = (e) => e && (c$2.has(e) ? c$2.get(e) : s$1(e) === Object.prototype || s$1(e) === Array.prototype), g$1 = (e) => l(e) && e[t] || null, h$2 = (e, t2 = true) => { c$2.set(e, t2); }; const isObject = (x) => typeof x === "object" && x !== null; const proxyStateMap = /* @__PURE__ */ new WeakMap(); const refSet = /* @__PURE__ */ new WeakSet(); const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), defaultHandlePromise = (promise) => { switch (promise.status) { case "fulfilled": return promise.value; case "rejected": throw promise.reason; default: throw promise; } }, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version2, handlePromise = defaultHandlePromise) => { const cache = snapCache.get(target); if ((cache == null ? void 0 : cache[0]) === version2) { return cache[1]; } const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); h$2(snap, true); snapCache.set(target, [version2, snap]); Reflect.ownKeys(target).forEach((key2) => { const value = Reflect.get(target, key2); if (refSet.has(value)) { h$2(value, false); snap[key2] = value; } else if (value instanceof Promise) { Object.defineProperty(snap, key2, { get() { return handlePromise(value); } }); } else if (proxyStateMap.has(value)) { snap[key2] = snapshot(value, handlePromise); } else { snap[key2] = value; } }); return Object.freeze(snap); }, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = (initialObject) => { if (!isObject(initialObject)) { throw new Error("object required"); } const found = proxyCache.get(initialObject); if (found) { return found; } let version2 = versionHolder[0]; const listeners = /* @__PURE__ */ new Set(); const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => { if (version2 !== nextVersion) { version2 = nextVersion; listeners.forEach((listener) => listener(op, nextVersion)); } }; let checkVersion = versionHolder[1]; const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => { if (checkVersion !== nextCheckVersion && !listeners.size) { checkVersion = nextCheckVersion; propProxyStates.forEach(([propProxyState]) => { const propVersion = propProxyState[1](nextCheckVersion); if (propVersion > version2) { version2 = propVersion; } }); } return version2; }; const createPropListener = (prop) => (op, nextVersion) => { const newOp = [...op]; newOp[1] = [prop, ...newOp[1]]; notifyUpdate(newOp, nextVersion); }; const propProxyStates = /* @__PURE__ */ new Map(); const addPropListener = (prop, propProxyState) => { if (({ "BASE_URL": "./", "MODE": "production", "DEV": false, "PROD": true } && "production") !== "production" && propProxyStates.has(prop)) { throw new Error("prop listener already exists"); } if (listeners.size) { const remove = propProxyState[3](createPropListener(prop)); propProxyStates.set(prop, [propProxyState, remove]); } else { propProxyStates.set(prop, [propProxyState]); } }; const removePropListener = (prop) => { var _a; const entry = propProxyStates.get(prop); if (entry) { propProxyStates.delete(prop); (_a = entry[1]) == null ? void 0 : _a.call(entry); } }; const addListener = (listener) => { listeners.add(listener); if (listeners.size === 1) { propProxyStates.forEach(([propProxyState, prevRemove], prop) => { if (({ "BASE_URL": "./", "MODE": "production", "DEV": false, "PROD": true } && "production") !== "production" && prevRemove) { throw new Error("remove already exists"); } const remove = propProxyState[3](createPropListener(prop)); propProxyStates.set(prop, [propProxyState, remove]); }); } const removeListener = () => { listeners.delete(listener); if (listeners.size === 0) { propProxyStates.forEach(([propProxyState, remove], prop) => { if (remove) { remove(); propProxyStates.set(prop, [propProxyState]); } }); } }; return removeListener; }; const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); const handler = { deleteProperty(target, prop) { const prevValue = Reflect.get(target, prop); removePropListener(prop); const deleted = Reflect.deleteProperty(target, prop); if (deleted) { notifyUpdate(["delete", [prop], prevValue]); } return deleted; }, set(target, prop, value, receiver) { var _a; const hasPrevValue = Reflect.has(target, prop); const prevValue = Reflect.get(target, prop, receiver); if (hasPrevValue && objectIs(prevValue, value)) { return true; } removePropListener(prop); if (isObject(value)) { value = g$1(value) || value; } let nextValue = value; if ((_a = Object.getOwnPropertyDescriptor(target, prop)) == null ? void 0 : _a.set) ; else if (value instanceof Promise) { value.then((v2) => { value.status = "fulfilled"; value.value = v2; notifyUpdate(["resolve", [prop], v2]); }).catch((e) => { value.status = "rejected"; value.reason = e; notifyUpdate(["reject", [prop], e]); }); } else { if (!proxyStateMap.has(value) && canProxy(value)) { nextValue = proxy(value); } const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); if (childProxyState) { addPropListener(prop, childProxyState); } } Reflect.set(target, prop, nextValue, receiver); notifyUpdate(["set", [prop], value, prevValue]); return true; } }; const proxyObject = newProxy(baseObject, handler); proxyCache.set(initialObject, proxyObject); const proxyState = [ baseObject, ensureVersion, createSnapshot, addListener ]; proxyStateMap.set(proxyObject, proxyState); Reflect.ownKeys(initialObject).forEach((key2) => { const desc = Object.getOwnPropertyDescriptor( initialObject, key2 ); if (desc.get || desc.set) { Object.defineProperty(baseObject, key2, desc); } else { proxyObject[key2] = initialObject[key2]; } }); return proxyObject; }) => [ // public functions proxyFunction2, // shared state proxyStateMap, refSet, // internal things objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder ]; const [proxyFunction] = buildProxyFunction(); function proxy(initialObject = {}) { return proxyFunction(initialObject); } function subscribe(proxyObject, callback, notifyInSync) { const proxyState = proxyStateMap.get(proxyObject); if (({ "BASE_URL": "./", "MODE": "production", "DEV": false, "PROD": true } && "production") !== "production" && !proxyState) { console.warn("Please use proxy object"); } let promise; const ops = []; const addListener = proxyState[3]; let isListenerActive = false; const listener = (op) => { ops.push(op); if (notifyInSync) { callback(ops.splice(0)); return; } if (!promise) { promise = Promise.resolve().then(() => { promise = void 0; if (isListenerActive) { callback(ops.splice(0)); } }); } }; const removeListener = addListener(listener); isListenerActive = true; return () => { isListenerActive = false; removeListener(); }; } function snapshot(proxyObject, handlePromise) { const proxyState = proxyStateMap.get(proxyObject); if (({ "BASE_URL": "./", "MODE": "production", "DEV": false, "PROD": true } && "production") !== "production" && !proxyState) { console.warn("Please use proxy object"); } const [target, ensureVersion, createSnapshot] = proxyState; return createSnapshot(target, ensureVersion(), handlePromise); } var buffer = {}; var base64Js = {}; base64Js.byteLength = byteLength; base64Js.toByteArray = toByteArray; base64Js.fromByteArray = fromByteArray; var lookup = []; var revLookup = []; var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array; var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for (var i$1 = 0, len = code.length; i$1 < len; ++i$1) { lookup[i$1] = code[i$1]; revLookup[code.charCodeAt(i$1)] = i$1; } revLookup["-".charCodeAt(0)] = 62; revLookup["_".charCodeAt(0)] = 63; function getLens(b64) { var len = b64.length; if (len % 4 > 0) { throw new Error("Invalid string. Length must be a multiple of 4"); } var validLen = b64.indexOf("="); if (validLen === -1) validLen = len; var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; return [validLen, placeHoldersLen]; } function byteLength(b64) { var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; } function _byteLength(b64, validLen, placeHoldersLen) { return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; } function toByteArray(b64) { var tmp; var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); var curByte = 0; var len = placeHoldersLen > 0 ? validLen - 4 : validLen; var i2; for (i2 = 0; i2 < len; i2 += 4) { tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)]; arr[curByte++] = tmp >> 16 & 255; arr[curByte++] = tmp >> 8 & 255; arr[curByte++] = tmp & 255; } if (placeHoldersLen === 2) { tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4; arr[curByte++] = tmp & 255; } if (placeHoldersLen === 1) { tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2; arr[curByte++] = tmp >> 8 & 255; arr[curByte++] = tmp & 255; } return arr; } function tripletToBase64(num) { return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63]; } function encodeChunk(uint8, start, end) { var tmp; var output = []; for (var i2 = start; i2 < end; i2 += 3) { tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255); output.push(tripletToBase64(tmp)); } return output.join(""); } function fromByteArray(uint8) { var tmp; var len = uint8.length; var extraBytes = len % 3; var parts = []; var maxChunkLength = 16383; for (var i2 = 0, len2 = len - extraBytes; i2 < len2; i2 += maxChunkLength) { parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len2 ? len2 : i2 + maxChunkLength)); } if (extraBytes === 1) { tmp = uint8[len - 1]; parts.push( lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==" ); } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1]; parts.push( lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=" ); } return parts.join(""); } var ieee754 = {}; /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ ieee754.read = function(buffer2, offset, isLE, mLen, nBytes) { var e, m2; var eLen = nBytes * 8 - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var nBits = -7; var i2 = isLE ? nBytes - 1 : 0; var d2 = isLE ? -1 : 1; var s2 = buffer2[offset + i2]; i2 += d2; e = s2 & (1 << -nBits) - 1; s2 >>= -nBits; nBits += eLen; for (; nBits > 0; e = e * 256 + buffer2[offset + i2], i2 += d2, nBits -= 8) { } m2 = e & (1 << -nBits) - 1; e >>= -nBits; nBits += mLen; for (; nBits > 0; m2 = m2 * 256 + buffer2[offset + i2], i2 += d2, nBits -= 8) { } if (e === 0) { e = 1 - eBias; } else if (e === eMax) { return m2 ? NaN : (s2 ? -1 : 1) * Infinity; } else { m2 = m2 + Math.pow(2, mLen); e = e - eBias; } return (s2 ? -1 : 1) * m2 * Math.pow(2, e - mLen); }; ieee754.write = function(buffer2, value, offset, isLE, mLen, nBytes) { var e, m2, c2; var eLen = nBytes * 8 - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; var i2 = isLE ? 0 : nBytes - 1; var d2 = isLE ? 1 : -1; var s2 = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; value = Math.abs(value); if (isNaN(value) || value === Infinity) { m2 = isNaN(value) ? 1 : 0; e = eMax; } else { e = Math.floor(Math.log(value) / Math.LN2); if (value * (c2 = Math.pow(2, -e)) < 1) { e--; c2 *= 2; } if (e + eBias >= 1) { value += rt / c2; } else { value += rt * Math.pow(2, 1 - eBias); } if (value * c2 >= 2) { e++; c2 /= 2; } if (e + eBias >= eMax) { m2 = 0; e = eMax; } else if (e + eBias >= 1) { m2 = (value * c2 - 1) * Math.pow(2, mLen); e = e + eBias; } else { m2 = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); e = 0; } } for (; mLen >= 8; buffer2[offset + i2] = m2 & 255, i2 += d2, m2 /= 256, mLen -= 8) { } e = e << mLen | m2; eLen += mLen; for (; eLen > 0; buffer2[offset + i2] = e & 255, i2 += d2, e /= 256, eLen -= 8) { } buffer2[offset + i2 - d2] |= s2 * 128; }; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ (function(exports) { const base64 = base64Js; const ieee754$1 = ieee754; const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null; exports.Buffer = Buffer; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; const K_MAX_LENGTH = 2147483647; exports.kMaxLength = K_MAX_LENGTH; Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { console.error( "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support." ); } function typedArraySupport() { try { const arr = new Uint8Array(1); const proto = { foo: function() { return 42; } }; Object.setPrototypeOf(proto, Uint8Array.prototype); Object.setPrototypeOf(arr, proto); return arr.foo() === 42; } catch (e) { return false; } } Object.defineProperty(Buffer.prototype, "parent", { enumerable: true, get: function() { if (!Buffer.isBuffer(this)) return void 0; return this.buffer; } }); Object.defineProperty(Buffer.prototype, "offset", { enumerable: true, get: function() { if (!Buffer.isBuffer(this)) return void 0; return this.byteOffset; } }); function createBuffer(length) { if (length > K_MAX_LENGTH) { throw new RangeError('The value "' + length + '" is invalid for option "size"'); } const buf = new Uint8Array(length); Object.setPrototypeOf(buf, Buffer.prototype); return buf; } function Buffer(arg, encodingOrOffset, length) { if (typeof arg === "number") { if (typeof encodingOrOffset === "string") { throw new TypeError( 'The "string" argument must be of type string. Received type number' ); } return allocUnsafe(arg); } return from(arg, encodingOrOffset, length); } Buffer.poolSize = 8192; function from(value, encodingOrOffset, length) { if (typeof value === "string") { return fromString(value, encodingOrOffset); } if (ArrayBuffer.isView(value)) { return fromArrayView(value); } if (value == null) { throw new TypeError( "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value ); } if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { return fromArrayBuffer(value, encodingOrOffset, length); } if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { return fromArrayBuffer(value, encodingOrOffset, length); } if (typeof value === "number") { throw new TypeError( 'The "value" argument must not be of type number. Received type number' ); } const valueOf = value.valueOf && value.valueOf(); if (valueOf != null && valueOf !== value) { return Buffer.from(valueOf, encodingOrOffset, length); } const b2 = fromObject(value); if (b2) return b2; if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") { return Buffer.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); } throw new TypeError( "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value ); } Buffer.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); Object.setPrototypeOf(Buffer, Uint8Array); function assertSize(size) { if (typeof size !== "number") { throw new TypeError('"size" argument must be of type number'); } else if (size < 0) { throw new RangeError('The value "' + size + '" is invalid for option "size"'); } } function alloc(size, fill, encoding) { assertSize(size); if (size <= 0) { return createBuffer(size); } if (fill !== void 0) { return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill); } return createBuffer(size); } Buffer.alloc = function(size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } Buffer.allocUnsafe = function(size) { return allocUnsafe(size); }; Buffer.allocUnsafeSlow = function(size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") { encoding = "utf8"; } if (!Buffer.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } const length = byteLength2(string, encoding) | 0; let buf = createBuffer(length); const actual = buf.write(string, encoding); if (actual !== length) { buf = buf.slice(0, actual); } return buf; } function fromArrayLike(array) { const length = array.length < 0 ? 0 : checked(array.length) | 0; const buf = createBuffer(length); for (let i2 = 0; i2 < length; i2 += 1) { buf[i2] = array[i2] & 255; } return buf; } function fromArrayView(arrayView) { if (isInstance(arrayView, Uint8Array)) { const copy = new Uint8Array(arrayView); return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength); } return fromArrayLike(arrayView); } function fromArrayBuffer(array, byteOffset, length) { if (byteOffset < 0 || array.byteLength < byteOffset) { throw new RangeError('"offset" is outside of buffer bounds'); } if (array.byteLength < byteOffset + (length || 0)) { throw new RangeError('"length" is outside of buffer bounds'); } let buf; if (byteOffset === void 0 && length === void 0) { buf = new Uint8Array(array); } else if (length === void 0) { buf = new Uint8Array(array, byteOffset); } else { buf = new Uint8Array(array, byteOffset, length); } Object.setPrototypeOf(buf, Buffer.prototype); return buf; } function fromObject(obj) { if (Buffer.isBuffer(obj)) { const len = checked(obj.length) | 0; const buf = createBuffer(len); if (buf.length === 0) { return buf; } obj.copy(buf, 0, 0, len); return buf; } if (obj.length !== void 0) { if (typeof obj.length !== "number" || numberIsNaN(obj.length)) { return createBuffer(0); } return fromArrayLike(obj); } if (obj.type === "Buffer" && Array.isArray(obj.data)) { return fromArrayLike(obj.data); } } function checked(length) { if (length >= K_MAX_LENGTH) { throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes"); } return length | 0; } function SlowBuffer(length) { if (+length != length) { length = 0; } return Buffer.alloc(+length); } Buffer.isBuffer = function isBuffer(b2) { return b2 != null && b2._isBuffer === true && b2 !== Buffer.prototype; }; Buffer.compare = function compare(a2, b2) { if (isInstance(a2, Uint8Array)) a2 = Buffer.from(a2, a2.offset, a2.byteLength); if (isInstance(b2, Uint8Array)) b2 = Buffer.from(b2, b2.offset, b2.byteLength); if (!Buffer.isBuffer(a2) || !Buffer.isBuffer(b2)) { throw new TypeError( 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' ); } if (a2 === b2) return 0; let x = a2.length; let y2 = b2.length; for (let i2 = 0, len = Math.min(x, y2); i2 < len; ++i2) { if (a2[i2] !== b2[i2]) { x = a2[i2]; y2 = b2[i2]; break; } } if (x < y2) return -1; if (y2 < x) return 1; return 0; }; Buffer.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": case "utf-8": case "ascii": case "latin1": case "binary": case "base64": case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return true; default: return false; } }; Buffer.concat = function concat2(list, length) { if (!Array.isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers'); } if (list.length === 0) { return Buffer.alloc(0); } let i2; if (length === void 0) { length = 0; for (i2 = 0; i2 < list.length; ++i2) { length += list[i2].length; } } const buffer2 = Buffer.allocUnsafe(length); let pos = 0; for (i2 = 0; i2 < list.length; ++i2) { let buf = list[i2]; if (isInstance(buf, Uint8Array)) { if (pos + buf.length > buffer2.length) { if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf); buf.copy(buffer2, pos); } else { Uint8Array.prototype.set.call( buffer2, buf, pos ); } } else if (!Buffer.isBuffer(buf)) { throw new TypeError('"list" argument must be an Array of Buffers'); } else { buf.copy(buffer2, pos); } pos += buf.length; } return buffer2; }; function byteLength2(string, encoding) { if (Buffer.isBuffer(string)) { return string.length; } if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { return string.byteLength; } if (typeof string !== "string") { throw new TypeError( 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string ); } const len = string.length; const mustMatch = arguments.length > 2 && arguments[2] === true; if (!mustMatch && len === 0) return 0; let loweredCase = false; for (; ; ) { switch (encoding) { case "ascii": case "latin1": case "binary": return len; case "utf8": case "utf-8": return utf8ToBytes(string).length; case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return len * 2; case "hex": return len >>> 1; case "base64": return base64ToBytes(string).length; default: if (loweredCase) { return mustMatch ? -1 : utf8ToBytes(string).length; } encoding = ("" + encoding).toLowerCase(); loweredCase = true; } } } Buffer.byteLength = byteLength2; function slowToString(encoding, start, end) { let loweredCase = false; if (start === void 0 || start < 0) { start = 0; } if (start > this.length) { return ""; } if (end === void 0 || end > this.length) { end = this.length; } if (end <= 0) { return ""; } end >>>= 0; start >>>= 0; if (end <= start) { return ""; } if (!encoding) encoding = "utf8"; while (true) { switch (encoding) { case "hex": return hexSlice(this, start, end); case "utf8": case "utf-8": return utf8Slice(this, start, end); case "ascii": return asciiSlice(this, start, end); case "latin1": case "binary": return latin1Slice(this, start, end); case "base64": return base64Slice(this, start, end); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return utf16leSlice(this, start, end); default: if (loweredCase) throw new TypeError("Unknown encoding: " + encoding); encoding = (encoding + "").toLowerCase(); loweredCase = true; } } } Buffer.prototype._isBuffer = true; function swap(b2, n2, m2) { const i2 = b2[n2]; b2[n2] = b2[m2]; b2[m2] = i2; } Buffer.prototype.swap16 = function swap16() { const len = this.length; if (len % 2 !== 0) { throw new RangeError("Buffer size must be a multiple of 16-bits"); } for (let i2 = 0; i2 < len; i2 += 2) { swap(this, i2, i2 + 1); } return this; }; Buffer.prototype.swap32 = function swap32() { const len = this.length; if (len % 4 !== 0) { throw new RangeError("Buffer size must be a multiple of 32-bits"); } for (let i2 = 0; i2 < len; i2 += 4) { swap(this, i2, i2 + 3); swap(this, i2 + 1, i2 + 2); } return this; }; Buffer.prototype.swap64 = function swap64() { const len = this.length; if (len % 8 !== 0) { throw new RangeError("Buffer size must be a multiple of 64-bits"); } for (let i2 = 0; i2 < len; i2 += 8) { swap(this, i2, i2 + 7); swap(this, i2 + 1, i2 + 6); swap(this, i2 + 2, i2 + 5); swap(this, i2 + 3, i2 + 4); } return this; }; Buffer.prototype.toString = function toString() { const length = this.length; if (length === 0) return ""; if (arguments.length === 0) return utf8Slice(this, 0, length); return slowToString.apply(this, arguments); }; Buffer.prototype.toLocaleString = Buffer.prototype.toString; Buffer.prototype.equals = function equals(b2) { if (!Buffer.isBuffer(b2)) throw new TypeError("Argument must be a Buffer"); if (this === b2) return true; return Buffer.compare(this, b2) === 0; }; Buffer.prototype.inspect = function inspect4() { let str = ""; const max = exports.INSPECT_MAX_BYTES; str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); if (this.length > max) str += " ... "; return ""; }; if (customInspectSymbol) { Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; } Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { target = Buffer.from(target, target.offset, target.byteLength); } if (!Buffer.isBuffer(target)) { throw new TypeError( 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target ); } if (start === void 0) { start = 0; } if (end === void 0) { end = target ? target.length : 0; } if (thisStart === void 0) { thisStart = 0; } if (thisEnd === void 0) { thisEnd = this.length; } if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { throw new RangeError("out of range index"); } if (thisStart >= thisEnd && start >= end) { return 0; } if (thisStart >= thisEnd) { return -1; } if (start >= end) { return 1; } start >>>= 0; end >>>= 0; thisStart >>>= 0; thisEnd >>>= 0; if (this === target) return 0; let x = thisEnd - thisStart; let y2 = end - start; const len = Math.min(x, y2); const thisCopy = this.slice(thisStart, thisEnd); const targetCopy = target.slice(start, end); for (let i2 = 0; i2 < len; ++i2) { if (thisCopy[i2] !== targetCopy[i2]) { x = thisCopy[i2]; y2 = targetCopy[i2]; break; } } if (x < y2) return -1; if (y2 < x) return 1; return 0; }; function bidirectionalIndexOf(buffer2, val, byteOffset, encoding, dir) { if (buffer2.length === 0) return -1; if (typeof byteOffset === "string") { encoding = byteOffset; byteOffset = 0; } else if (byteOffset > 2147483647) { byteOffset = 2147483647; } else if (byteOffset < -2147483648) { byteOffset = -2147483648; } byteOffset = +byteOffset; if (numberIsNaN(byteOffset)) { byteOffset = dir ? 0 : buffer2.length - 1; } if (byteOffset < 0) byteOffset = buffer2.length + byteOffset; if (byteOffset >= buffer2.length) { if (dir) return -1; else byteOffset = buffer2.length - 1; } else if (byteOffset < 0) { if (dir) byteOffset = 0; else return -1; } if (typeof val === "string") { val = Buffer.from(val, encoding); } if (Buffer.isBuffer(val)) { if (val.length === 0) { return -1; } return arrayIndexOf(buffer2, val, byteOffset, encoding, dir); } else if (typeof val === "number") { val = val & 255; if (typeof Uint8Array.prototype.indexOf === "function") { if (dir) { return Uint8Array.prototype.indexOf.call(buffer2, val, byteOffset); } else { return Uint8Array.prototype.lastIndexOf.call(buffer2, val, byteOffset); } } return arrayIndexOf(buffer2, [val], byteOffset, encoding, dir); } throw new TypeError("val must be string, number or Buffer"); } function arrayIndexOf(arr, val, byteOffset, encoding, dir) { let indexSize = 1; let arrLength = arr.length; let valLength = val.length; if (encoding !== void 0) { encoding = String(encoding).toLowerCase(); if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") { if (arr.length < 2 || val.length < 2) { return -1; } indexSize = 2; arrLength /= 2; valLength /= 2; byteOffset /= 2; } } function read(buf, i3) { if (indexSize === 1) { return buf[i3]; } else { return buf.readUInt16BE(i3 * indexSize); } } let i2; if (dir) { let foundIndex = -1; for (i2 = byteOffset; i2 < arrLength; i2++) { if (read(arr, i2) === read(val, foundIndex === -1 ? 0 : i2 - foundIndex)) { if (foundIndex === -1) foundIndex = i2; if (i2 - foundIndex + 1 === valLength) return foundIndex * indexSize; } else { if (foundIndex !== -1) i2 -= i2 - foundIndex; foundIndex = -1; } } } else { if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; for (i2 = byteOffset; i2 >= 0; i2--) { let found = true; for (let j2 = 0; j2 < valLength; j2++) { if (read(arr, i2 + j2) !== read(val, j2)) { found = false; break; } } if (found) return i2; } } return -1; } Buffer.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false); }; function hexWrite(buf, string, offset, length) { offset = Number(offset) || 0; const remaining = buf.length - offset; if (!length) { length = remaining; } else { length = Number(length); if (length > remaining) { length = remaining; } } const strLen = string.length; if (length > strLen / 2) { length = strLen / 2; } let i2; for (i2 = 0; i2 < length; ++i2) { const parsed = parseInt(string.substr(i2 * 2, 2), 16); if (numberIsNaN(parsed)) return i2; buf[offset + i2] = parsed; } return i2; } function utf8Write(buf, string, offset, length) { return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); } function asciiWrite(buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length); } function base64Write(buf, string, offset, length) { return blitBuffer(base64ToBytes(string), buf, offset, length); } function ucs2Write(buf, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); } Buffer.prototype.write = function write(string, offset, length, encoding) { if (offset === void 0) { encoding = "utf8"; length = this.length; offset = 0; } else if (length === void 0 && typeof offset === "string") { encoding = offset; length = this.length; offset = 0; } else if (isFinite(offset)) { offset = offset >>> 0; if (isFinite(length)) { length = length >>> 0; if (encoding === void 0) encoding = "utf8"; } else { encoding = length; length = void 0; } } else { throw new Error( "Buffer.write(string, encoding, offset[, length]) is no longer supported" ); } const remaining = this.length - offset; if (length === void 0 || length > remaining) length = remaining; if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { throw new RangeError("Attempt to write outside buffer bounds"); } if (!encoding) encoding = "utf8"; let loweredCase = false; for (; ; ) { switch (encoding) { case "hex": return hexWrite(this, string, offset, length); case "utf8": case "utf-8": return utf8Write(this, string, offset, length); case "ascii": case "latin1": case "binary": return asciiWrite(this, string, offset, length); case "base64": return base64Write(this, string, offset, length); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return ucs2Write(this, string, offset, length); default: if (loweredCase) throw new TypeError("Unknown encoding: " + encoding); encoding = ("" + encoding).toLowerCase(); loweredCase = true; } } }; Buffer.prototype.toJSON = function toJSON2() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) }; }; function base64Slice(buf, start, end) { if (start === 0 && end === buf.length) { return base64.fromByteArray(buf); } else { return base64.fromByteArray(buf.slice(start, end)); } } function utf8Slice(buf, start, end) { end = Math.min(buf.length, end); const res = []; let i2 = start; while (i2 < end) { const firstByte = buf[i2]; let codePoint = null; let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; if (i2 + bytesPerSequence <= end) { let secondByte, thirdByte, fourthByte, tempCodePoint; switch (bytesPerSequence) { case 1: if (firstByte < 128) { codePoint = firstByte; } break; case 2: secondByte = buf[i2 + 1]; if ((secondByte & 192) === 128) { tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; if (tempCodePoint > 127) { codePoint = tempCodePoint; } } break; case 3: secondByte = buf[i2 + 1]; thirdByte = buf[i2 + 2]; if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) { codePoint = tempCodePoint; } } break; case 4: secondByte = buf[i2 + 1]; thirdByte = buf[i2 + 2]; fourthByte = buf[i2 + 3]; if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; if (tempCodePoint > 65535 && tempCodePoint < 1114112) { codePoint = tempCodePoint; } } } } if (codePoint === null) { codePoint = 65533; bytesPerSequence = 1; } else if (codePoint > 65535) { codePoint -= 65536; res.push(codePoint >>> 10 & 1023 | 55296); codePoint = 56320 | codePoint & 1023; } res.push(codePoint); i2 += bytesPerSequence; } return decodeCodePointsArray(res); } const MAX_ARGUMENTS_LENGTH = 4096; function decodeCodePointsArray(codePoints) { const len = codePoints.length; if (len <= MAX_ARGUMENTS_LENGTH) { return String.fromCharCode.apply(String, codePoints); } let res = ""; let i2 = 0; while (i2 < len) { res += String.fromCharCode.apply( String, codePoints.slice(i2, i2 += MAX_ARGUMENTS_LENGTH) ); } return res; } function asciiSlice(buf, start, end) { let ret = ""; end = Math.min(buf.length, end); for (let i2 = start; i2 < end; ++i2) { ret += String.fromCharCode(buf[i2] & 127); } return ret; } function latin1Slice(buf, start, end) { let ret = ""; end = Math.min(buf.length, end); for (let i2 = start; i2 < end; ++i2) { ret += String.fromCharCode(buf[i2]); } return ret; } function hexSlice(buf, start, end) { const len = buf.length; if (!start || start < 0) start = 0; if (!end || end < 0 || end > len) end = len; let out = ""; for (let i2 = start; i2 < end; ++i2) { out += hexSliceLookupTable[buf[i2]]; } return out; } function utf16leSlice(buf, start, end) { const bytes = buf.slice(start, end); let res = ""; for (let i2 = 0; i2 < bytes.length - 1; i2 += 2) { res += String.fromCharCode(bytes[i2] + bytes[i2 + 1] * 256); } return res; } Buffer.prototype.slice = function slice(start, end) { const len = this.length; start = ~~start; end = end === void 0 ? len : ~~end; if (start < 0) { start += len; if (start < 0) start = 0; } else if (start > len) { start = len; } if (end < 0) { end += len; if (end < 0) end = 0; } else if (end > len) { end = len; } if (end < start) end = start; const newBuf = this.subarray(start, end); Object.setPrototypeOf(newBuf, Buffer.prototype); return newBuf; }; function checkOffset(offset, ext, length) { if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint"); if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length"); } Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength3, noAssert) { offset = offset >>> 0; byteLength3 = byteLength3 >>> 0; if (!noAssert) checkOffset(offset, byteLength3, this.length); let val = this[offset]; let mul3 = 1; let i2 = 0; while (++i2 < byteLength3 && (mul3 *= 256)) { val += this[offset + i2] * mul3; } return val; }; Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength3, noAssert) { offset = offset >>> 0; byteLength3 = byteLength3 >>> 0; if (!noAssert) { checkOffset(offset, byteLength3, this.length); } let val = this[offset + --byteLength3]; let mul3 = 1; while (byteLength3 > 0 && (mul3 *= 256)) { val += this[offset + --byteLength3] * mul3; } return val; }; Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216; }; Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); }; Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; const last = this[offset + 7]; if (first === void 0 || last === void 0) { boundsError(offset, this.length - 8); } const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24; const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24; return BigInt(lo) + (BigInt(hi) << BigInt(32)); }); Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; const last = this[offset + 7]; if (first === void 0 || last === void 0) { boundsError(offset, this.length - 8); } const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last; return (BigInt(hi) << BigInt(32)) + BigInt(lo); }); Buffer.prototype.readIntLE = function readIntLE(offset, byteLength3, noAssert) { offset = offset >>> 0; byteLength3 = byteLength3 >>> 0; if (!noAssert) checkOffset(offset, byteLength3, this.length); let val = this[offset]; let mul3 = 1; let i2 = 0; while (++i2 < byteLength3 && (mul3 *= 256)) { val += this[offset + i2] * mul3; } mul3 *= 128; if (val >= mul3) val -= Math.pow(2, 8 * byteLength3); return val; }; Buffer.prototype.readIntBE = function readIntBE(offset, byteLength3, noAssert) { offset = offset >>> 0; byteLength3 = byteLength3 >>> 0; if (!noAssert) checkOffset(offset, byteLength3, this.length); let i2 = byteLength3; let mul3 = 1; let val = this[offset + --i2]; while (i2 > 0 && (mul3 *= 256)) { val += this[offset + --i2] * mul3; } mul3 *= 128; if (val >= mul3) val -= Math.pow(2, 8 * byteLength3); return val; }; Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); if (!(this[offset] & 128)) return this[offset]; return (255 - this[offset] + 1) * -1; }; Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); const val = this[offset] | this[offset + 1] << 8; return val & 32768 ? val | 4294901760 : val; }; Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); const val = this[offset + 1] | this[offset] << 8; return val & 32768 ? val | 4294901760 : val; }; Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; }; Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; }; Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; const last = this[offset + 7]; if (first === void 0 || last === void 0) { boundsError(offset, this.length - 8); } const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24); return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24); }); Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; const last = this[offset + 7]; if (first === void 0 || last === void 0) { boundsError(offset, this.length - 8); } const val = (first << 24) + // Overflow this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last); }); Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee754$1.read(this, offset, true, 23, 4); }; Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee754$1.read(this, offset, false, 23, 4); }; Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee754$1.read(this, offset, true, 52, 8); }; Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee754$1.read(this, offset, false, 52, 8); }; function checkInt(buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); if (offset + ext > buf.length) throw new RangeError("Index out of range"); } Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength3, noAssert) { value = +value; offset = offset >>> 0; byteLength3 = byteLength3 >>> 0; if (!noAssert) { const maxBytes = Math.pow(2, 8 * byteLength3) - 1; checkInt(this, value, offset, byteLength3, maxBytes, 0); } let mul3 = 1; let i2 = 0; this[offset] = value & 255; while (++i2 < byteLength3 && (mul3 *= 256)) { this[offset + i2] = value / mul3 & 255; } return offset + byteLength3; }; Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength3, noAssert) { value = +value; offset = offset >>> 0; byteLength3 = byteLength3 >>> 0; if (!noAssert) { const maxBytes = Math.pow(2, 8 * byteLength3) - 1; checkInt(this, value, offset, byteLength3, maxBytes, 0); } let i2 = byteLength3 - 1; let mul3 = 1; this[offset + i2] = value & 255; while (--i2 >= 0 && (mul3 *= 256)) { this[offset + i2] = value / mul3 & 255; } return offset + byteLength3; }; Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 255, 0); this[offset] = value & 255; return offset + 1; }; Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 65535, 0); this[offset] = value & 255; this[offset + 1] = value >>> 8; return offset + 2; }; Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 65535, 0); this[offset] = value >>> 8; this[offset + 1] = value & 255; return offset + 2; }; Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0); this[offset + 3] = value >>> 24; this[offset + 2] = value >>> 16; this[offset + 1] = value >>> 8; this[offset] = value & 255; return offset + 4; }; Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0); this[offset] = value >>> 24; this[offset + 1] = value >>> 16; this[offset + 2] = value >>> 8; this[offset + 3] = value & 255; return offset + 4; }; function wrtBigUInt64LE(buf, value, offset, min, max) { checkIntBI(value, min, max, buf, offset, 7); let lo = Number(value & BigInt(4294967295)); buf[offset++] = lo; lo = lo >> 8; buf[offset++] = lo; lo = lo >> 8; buf[offset++] = lo; lo = lo >> 8; buf[offset++] = lo; let hi = Number(value >> BigInt(32) & BigInt(4294967295)); buf[offset++] = hi; hi = hi >> 8; buf[offset++] = hi; hi = hi >> 8; buf[offset++] = hi; hi = hi >> 8; buf[offset++] = hi; return offset; } function wrtBigUInt64BE(buf, value, offset, min, max) { checkIntBI(value, min, max, buf, offset, 7); let lo = Number(value & BigInt(4294967295)); buf[offset + 7] = lo; lo = lo >> 8; buf[offset + 6] = lo; lo = lo >> 8; buf[offset + 5] = lo; lo = lo >> 8; buf[offset + 4] = lo; let hi = Number(value >> BigInt(32) & BigInt(4294967295)); buf[offset + 3] = hi; hi = hi >> 8; buf[offset + 2] = hi; hi = hi >> 8; buf[offset + 1] = hi; hi = hi >> 8; buf[offset] = hi; return offset + 8; } Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength3, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { const limit = Math.pow(2, 8 * byteLength3 - 1); checkInt(this, value, offset, byteLength3, limit - 1, -limit); } let i2 = 0; let mul3 = 1; let sub = 0; this[offset] = value & 255; while (++i2 < byteLength3 && (mul3 *= 256)) { if (value < 0 && sub === 0 && this[offset + i2 - 1] !== 0) { sub = 1; } this[offset + i2] = (value / mul3 >> 0) - sub & 255; } return offset + byteLength3; }; Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength3, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { const limit = Math.pow(2, 8 * byteLength3 - 1); checkInt(this, value, offset, byteLength3, limit - 1, -limit); } let i2 = byteLength3 - 1; let mul3 = 1; let sub = 0; this[offset + i2] = value & 255; while (--i2 >= 0 && (mul3 *= 256)) { if (value < 0 && sub === 0 && this[offset + i2 + 1] !== 0) { sub = 1; } this[offset + i2] = (value / mul3 >> 0) - sub & 255; } return offset + byteLength3; }; Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 127, -128); if (value < 0) value = 255 + value + 1; this[offset] = value & 255; return offset + 1; }; Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768); this[offset] = value & 255; this[offset + 1] = value >>> 8; return offset + 2; }; Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768); this[offset] = value >>> 8; this[offset + 1] = value & 255; return offset + 2; }; Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648); this[offset] = value & 255; this[offset + 1] = value >>> 8; this[offset + 2] = value >>> 16; this[offset + 3] = value >>> 24; return offset + 4; }; Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648); if (value < 0) value = 4294967295 + value + 1; this[offset] = value >>> 24; this[offset + 1] = value >>> 16; this[offset + 2] = value >>> 8; this[offset + 3] = value & 255; return offset + 4; }; Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); }); Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); }); function checkIEEE754(buf, value, offset, ext, max, min) { if (offset + ext > buf.length) throw new RangeError("Index out of range"); if (offset < 0) throw new RangeError("Index out of range"); } function writeFloat(buf, value, offset, littleEndian, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { checkIEEE754(buf, value, offset, 4); } ieee754$1.write(buf, value, offset, littleEndian, 23, 4); return offset + 4; } Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert); }; function writeDouble(buf, value, offset, littleEndian, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { checkIEEE754(buf, value, offset, 8); } ieee754$1.write(buf, value, offset, littleEndian, 52, 8); return offset + 8; } Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; Buffer.prototype.copy = function copy(target, targetStart, start, end) { if (!Buffer.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; if (!end && end !== 0) end = this.length; if (targetStart >= target.length) targetStart = target.length; if (!targetStart) targetStart = 0; if (end > 0 && end < start) end = start; if (end === start) return 0; if (target.length === 0 || this.length === 0) return 0; if (targetStart < 0) { throw new RangeError("targetStart out of bounds"); } if (start < 0 || start >= this.length) throw new RangeError("Index out of range"); if (end < 0) throw new RangeError("sourceEnd out of bounds"); if (end > this.length) end = this.length; if (target.length - targetStart < end - start) { end = target.length - targetStart + start; } const len = end - start; if (this === target && typeof Uint8Array.prototype.copyWithin === "function") { this.copyWithin(targetStart, start, end); } else { Uint8Array.prototype.set.call( target, this.subarray(start, end), targetStart ); } return len; }; Buffer.prototype.fill = function fill(val, start, end, encoding) { if (typeof val === "string") { if (typeof start === "string") { encoding = start; start = 0; end = this.length; } else if (typeof end === "string") { encoding = end; end = this.length; } if (encoding !== void 0 && typeof encoding !== "string") { throw new TypeError("encoding must be a string"); } if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } if (val.length === 1) { const code2 = val.charCodeAt(0); if (encoding === "utf8" && code2 < 128 || encoding === "latin1") { val = code2; } } } else if (typeof val === "number") { val = val & 255; } else if (typeof val === "boolean") { val = Number(val); } if (start < 0 || this.length < start || this.length < end) { throw new RangeError("Out of range index"); } if (end <= start) { return this; } start = start >>> 0; end = end === void 0 ? this.length : end >>> 0; if (!val) val = 0; let i2; if (typeof val === "number") { for (i2 = start; i2 < end; ++i2) { this[i2] = val; } } else { const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); const len = bytes.length; if (len === 0) { throw new TypeError('The value "' + val + '" is invalid for argument "value"'); } for (i2 = 0; i2 < end - start; ++i2) { this[i2 + start] = bytes[i2 % len]; } } return this; }; const errors = {}; function E2(sym, getMessage, Base) { errors[sym] = class NodeError extends Base { constructor() { super(); Object.defineProperty(this, "message", { value: getMessage.apply(this, arguments), writable: true, configurable: true }); this.name = `${this.name} [${sym}]`; this.stack; delete this.name; } get code() { return sym; } set code(value) { Object.defineProperty(this, "code", { configurable: true, enumerable: true, value, writable: true }); } toString() { return `${this.name} [${sym}]: ${this.message}`; } }; } E2( "ERR_BUFFER_OUT_OF_BOUNDS", function(name) { if (name) { return `${name} is outside of buffer bounds`; } return "Attempt to access memory outside buffer bounds"; }, RangeError ); E2( "ERR_INVALID_ARG_TYPE", function(name, actual) { return `The "${name}" argument must be of type number. Received type ${typeof actual}`; }, TypeError ); E2( "ERR_OUT_OF_RANGE", function(str, range, input) { let msg = `The value of "${str}" is out of range.`; let received = input; if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { received = addNumericalSeparator(String(input)); } else if (typeof input === "bigint") { received = String(input); if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) { received = addNumericalSeparator(received); } received += "n"; } msg += ` It must be ${range}. Received ${received}`; return msg; }, RangeError ); function addNumericalSeparator(val) { let res = ""; let i2 = val.length; const start = val[0] === "-" ? 1 : 0; for (; i2 >= start + 4; i2 -= 3) { res = `_${val.slice(i2 - 3, i2)}${res}`; } return `${val.slice(0, i2)}${res}`; } function checkBounds(buf, offset, byteLength3) { validateNumber(offset, "offset"); if (buf[offset] === void 0 || buf[offset + byteLength3] === void 0) { boundsError(offset, buf.length - (byteLength3 + 1)); } } function checkIntBI(value, min, max, buf, offset, byteLength3) { if (value > max || value < min) { const n2 = typeof min === "bigint" ? "n" : ""; let range; if (byteLength3 > 3) { if (min === 0 || min === BigInt(0)) { range = `>= 0${n2} and < 2${n2} ** ${(byteLength3 + 1) * 8}${n2}`; } else { range = `>= -(2${n2} ** ${(byteLength3 + 1) * 8 - 1}${n2}) and < 2 ** ${(byteLength3 + 1) * 8 - 1}${n2}`; } } else { range = `>= ${min}${n2} and <= ${max}${n2}`; } throw new errors.ERR_OUT_OF_RANGE("value", range, value); } checkBounds(buf, offset, byteLength3); } function validateNumber(value, name) { if (typeof value !== "number") { throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value); } } function boundsError(value, length, type) { if (Math.floor(value) !== value) { validateNumber(value, type); throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value); } if (length < 0) { throw new errors.ERR_BUFFER_OUT_OF_BOUNDS(); } throw new errors.ERR_OUT_OF_RANGE( type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value ); } const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; function base64clean(str) { str = str.split("=")[0]; str = str.trim().replace(INVALID_BASE64_RE, ""); if (str.length < 2) return ""; while (str.length % 4 !== 0) { str = str + "="; } return str; } function utf8ToBytes(string, units) { units = units || Infinity; let codePoint; const length = string.length; let leadSurrogate = null; const bytes = []; for (let i2 = 0; i2 < length; ++i2) { codePoint = string.charCodeAt(i2); if (codePoint > 55295 && codePoint < 57344) { if (!leadSurrogate) { if (codePoint > 56319) { if ((units -= 3) > -1) bytes.push(239, 191, 189); continue; } else if (i2 + 1 === length) { if ((units -= 3) > -1) bytes.push(239, 191, 189); continue; } leadSurrogate = codePoint; continue; } if (codePoint < 56320) { if ((units -= 3) > -1) bytes.push(239, 191, 189); leadSurrogate = codePoint; continue; } codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536; } else if (leadSurrogate) { if ((units -= 3) > -1) bytes.push(239, 191, 189); } leadSurrogate = null; if (codePoint < 128) { if ((units -= 1) < 0) break; bytes.push(codePoint); } else if (codePoint < 2048) { if ((units -= 2) < 0) break; bytes.push( codePoint >> 6 | 192, codePoint & 63 | 128 ); } else if (codePoint < 65536) { if ((units -= 3) < 0) break; bytes.push( codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128 ); } else if (codePoint < 1114112) { if ((units -= 4) < 0) break; bytes.push( codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128 ); } else { throw new Error("Invalid code point"); } } return bytes; } function asciiToBytes(str) { const byteArray = []; for (let i2 = 0; i2 < str.length; ++i2) { byteArray.push(str.charCodeAt(i2) & 255); } return byteArray; } function utf16leToBytes(str, units) { let c2, hi, lo; const byteArray = []; for (let i2 = 0; i2 < str.length; ++i2) { if ((units -= 2) < 0) break; c2 = str.charCodeAt(i2); hi = c2 >> 8; lo = c2 % 256; byteArray.push(lo); byteArray.push(hi); } return byteArray; } function base64ToBytes(str) { return base64.toByteArray(base64clean(str)); } function blitBuffer(src, dst, offset, length) { let i2; for (i2 = 0; i2 < length; ++i2) { if (i2 + offset >= dst.length || i2 >= src.length) break; dst[i2 + offset] = src[i2]; } return i2; } function isInstance(obj, type) { return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name; } function numberIsNaN(obj) { return obj !== obj; } const hexSliceLookupTable = function() { const alphabet = "0123456789abcdef"; const table = new Array(256); for (let i2 = 0; i2 < 16; ++i2) { const i16 = i2 * 16; for (let j2 = 0; j2 < 16; ++j2) { table[i16 + j2] = alphabet[i2] + alphabet[j2]; } } return table; }(); function defineBigIntMethod(fn) { return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn; } function BufferBigIntNotDefined() { throw new Error("BigInt not supported"); } })(buffer); const n = proxy({ selectedChain: void 0, chains: void 0, standaloneChains: void 0, standaloneUri: void 0, address: void 0, profileName: void 0, profileAvatar: void 0, profileLoading: false, balanceLoading: false, balance: void 0, isConnected: false, isStandalone: false, isCustomDesktop: false, isCustomMobile: false, isDataLoaded: false, isUiLoaded: false, walletConnectVersion: 1 }), a$1 = { state: n, subscribe(e) { return subscribe(n, () => e(n)); }, setChains(e) { n.chains = e; }, setStandaloneChains(e) { n.standaloneChains = e; }, setStandaloneUri(e) { n.standaloneUri = e; }, getSelectedChain() { const e = L.client().getNetwork().chain; return e && (n.selectedChain = e), n.selectedChain; }, setSelectedChain(e) { n.selectedChain = e; }, setIsStandalone(e) { n.isStandalone = e; }, setIsCustomDesktop(e) { n.isCustomDesktop = e; }, setIsCustomMobile(e) { n.isCustomMobile = e; }, getAccount() { const e = L.client().getAccount(); n.address = e.address, n.isConnected = e.isConnected; }, setAddress(e) { n.address = e; }, setIsConnected(e) { n.isConnected = e; }, setProfileName(e) { n.profileName = e; }, setProfileAvatar(e) { n.profileAvatar = e; }, setProfileLoading(e) { n.profileLoading = e; }, setBalanceLoading(e) { n.balanceLoading = e; }, setBalance(e) { n.balance = e; }, setIsDataLoaded(e) { n.isDataLoaded = e; }, setIsUiLoaded(e) { n.isUiLoaded = e; }, setWalletConnectVersion(e) { n.walletConnectVersion = e; }, resetEnsProfile() { n.profileName = void 0, n.profileAvatar = void 0; }, resetBalance() { n.balance = void 0; }, resetAccount() { n.address = void 0, n.isConnected = false, a$1.resetEnsProfile(), a$1.resetBalance(); } }, h$1 = proxy({ initialized: false, ethereumClient: void 0 }), L = { setEthereumClient(e) { !h$1.initialized && e && (h$1.ethereumClient = e, a$1.setChains(e.chains), h$1.initialized = true); }, client() { if (h$1.ethereumClient) return h$1.ethereumClient; throw new Error("ClientCtrl has no client set"); } }, d$1 = { WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", isMobile() { return typeof window < "u" ? Boolean(window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : false; }, isAndroid() { return d$1.isMobile() && navigator.userAgent.toLowerCase().includes("android"); }, isEmptyObject(e) { return Object.getPrototypeOf(e) === Object.prototype && Object.getOwnPropertyNames(e).length === 0 && Object.getOwnPropertySymbols(e).length === 0; }, isHttpUrl(e) { return e.startsWith("http://") || e.startsWith("https://"); }, formatNativeUrl(e, t2, s2) { if (d$1.isHttpUrl(e)) return this.formatUniversalUrl(e, t2, s2); let o = e; o.includes("://") || (o = e.replaceAll("/", "").replaceAll(":", ""), o = `${o}://`), this.setWalletConnectDeepLink(o, s2); const l2 = encodeURIComponent(t2); return `${o}wc?uri=${l2}`; }, formatUniversalUrl(e, t2, s2) { if (!d$1.isHttpUrl(e)) return this.formatNativeUrl(e, t2, s2); let o = e; e.endsWith("/") && (o = e.slice(0, -1)), this.setWalletConnectDeepLink(o, s2); const l2 = encodeURIComponent(t2); return `${o}/wc?uri=${l2}`; }, async wait(e) { return new Promise((t2) => { setTimeout(t2, e); }); }, openHref(e, t2 = "_self") { window.open(e, t2, "noreferrer noopener"); }, setWalletConnectDeepLink(e, t2) { localStorage.setItem(d$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: e, name: t2 })); }, setWalletConnectAndroidDeepLink(e) { const [t2] = e.split("?"); localStorage.setItem(d$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: t2, name: "Android" })); }, removeWalletConnectDeepLink() { localStorage.removeItem(d$1.WALLETCONNECT_DEEPLINK_CHOICE); }, isNull(e) { return e === null; } }; function S() { return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; } const f$1 = proxy({ projectId: "", themeMode: S() ? "dark" : "light", themeColor: "default", themeBackground: d$1.isMobile() ? "themeColor" : "gradient", themeZIndex: 89, mobileWallets: void 0, desktopWallets: void 0, walletImages: void 0, chainImages: void 0, tokenImages: void 0, standaloneChains: void 0, enableStandaloneMode: false, enableNetworkView: false, enableAccountView: true, defaultChain: void 0, explorerAllowList: void 0, explorerDenyList: void 0, termsOfServiceUrl: void 0, privacyPolicyUrl: void 0 }), W = { state: f$1, subscribe(e) { return subscribe(f$1, () => e(f$1)); }, setConfig(e) { var t2, s2, o, l2; if (a$1.setStandaloneChains(e.standaloneChains), a$1.setIsStandalone(Boolean((t2 = e.standaloneChains) == null ? void 0 : t2.length) || Boolean(e.enableStandaloneMode)), a$1.setIsCustomMobile(Boolean((s2 = e.mobileWallets) == null ? void 0 : s2.length)), a$1.setIsCustomDesktop(Boolean((o = e.desktopWallets) == null ? void 0 : o.length)), a$1.setWalletConnectVersion((l2 = e.walletConnectVersion) != null ? l2 : 1), e.defaultChain) a$1.setSelectedChain(e.defaultChain); else if (!a$1.state.isStandalone) { const u = L.client().getDefaultChain(); a$1.setSelectedChain(u); } Object.assign(f$1, e); }, setThemeConfig(e) { Object.assign(f$1, e); } }, I = "https://explorer-api.walletconnect.com"; function y(e) { const t2 = Object.fromEntries(Object.entries(e).filter(([s2, o]) => typeof o < "u" && o !== null && o !== "").map(([s2, o]) => [s2, o.toString()])); return new URLSearchParams(t2).toString(); } const v = { async fetchWallets(e, t2) { const s2 = y(t2), o = `${I}/v3/wallets?projectId=${e}&${s2}`; return (await fetch(o)).json(); }, formatImageUrl(e, t2) { return `${I}/v3/logo/lg/${t2}?projectId=${e}`; } }, r = proxy({ wallets: { listings: [], total: 0, page: 1 }, search: { listings: [], total: 0, page: 1 }, previewWallets: [], recomendedWallets: [] }); function b$1() { const { projectId: e } = W.state; if (!e) throw new Error("projectId is required to work with explorer api"); return e; } const A = { state: r, async getPreviewWallets(e) { const { listings: t2 } = await v.fetchWallets(b$1(), e); return r.previewWallets = Object.values(t2), r.previewWallets; }, async getRecomendedWallets() { const { listings: e } = await v.fetchWallets(b$1(), { page: 1, entries: 6 }); r.recomendedWallets = Object.values(e); }, async getPaginatedWallets(e) { const { page: t2, search: s2 } = e, { listings: o, total: l2 } = await v.fetchWallets(b$1(), e), u = Object.values(o), w = s2 ? "search" : "wallets"; return r[w] = { listings: [...r[w].listings, ...u], total: l2, page: t2 ?? 1 }, { listings: u, total: l2 }; }, getImageUrl(e) { return v.formatImageUrl(b$1(), e); }, resetSearch() { r.search = { listings: [], total: 0, page: 1 }; } }, i = proxy({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), g = { state: i, subscribe(e) { return subscribe(i, () => e(i)); }, push(e, t2) { e !== i.view && (i.view = e, t2 && (i.data = t2), i.history.push(e)); }, replace(e) { i.view = e, i.history = [e]; }, goBack() { if (i.history.length > 1) { i.history.pop(); const [e] = i.history.slice(-1); i.view = e; } } }, C$1 = proxy({ open: false }), k = { state: C$1, subscribe(e) { return subscribe(C$1, () => e(C$1)); }, async open(e) { return new Promise((t2) => { const { isConnected: s2, isStandalone: o, isUiLoaded: l2, isDataLoaded: u } = a$1.state, { enableNetworkView: w } = W.state; if (o ? (a$1.setStandaloneUri(e == null ? void 0 : e.uri), a$1.setStandaloneChains(e == null ? void 0 : e.standaloneChains), g.replace("ConnectWallet")) : e != null && e.route ? g.replace(e.route) : s2 ? g.replace("Account") : w ? g.replace("SelectNetwork") : g.replace("ConnectWallet"), l2 && u) C$1.open = true, t2(); else { const E2 = setInterval(() => { a$1.state.isUiLoaded && a$1.state.isDataLoaded && (clearInterval(E2), C$1.open = true, t2()); }, 200); } }); }, close() { C$1.open = false; } }, c$1 = proxy({ open: false, message: "", variant: "success" }), P2 = { state: c$1, subscribe(e) { return subscribe(c$1, () => e(c$1)); }, openToast(e, t2) { c$1.open = true, c$1.message = e, c$1.variant = t2; }, closeToast() { c$1.open = false; } }; typeof window < "u" && (window.Buffer || (window.Buffer = buffer.Buffer), window.global || (window.global = window), window.process || (window.process = { env: {} })); var c = Object.defineProperty, p = Object.defineProperties, b = Object.getOwnPropertyDescriptors, s = Object.getOwnPropertySymbols, d = Object.prototype.hasOwnProperty, f = Object.prototype.propertyIsEnumerable, a = (r2, e, t2) => e in r2 ? c(r2, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : r2[e] = t2, m = (r2, e) => { for (var t2 in e || (e = {})) d.call(e, t2) && a(r2, t2, e[t2]); if (s) for (var t2 of s(e)) f.call(e, t2) && a(r2, t2, e[t2]); return r2; }, C = (r2, e) => p(r2, b(e)); class h { constructor(e, t2) { this.openModal = k.open, this.closeModal = k.close, this.subscribeModal = k.subscribe, this.setTheme = W.setThemeConfig, this.setDefaultChain = a$1.setSelectedChain, L.setEthereumClient(t2), W.setConfig(C(m({}, e), { walletConnectVersion: t2.walletConnectVersion })), this.initUi(); } async initUi() { if (typeof window < "u") { await __vitePreload(() => import("./index-65007766.js"), true ? ["./index-65007766.js","./dijkstra-cb1f074b.js"] : void 0, import.meta.url); const e = document.createElement("w3m-modal"); document.body.insertAdjacentElement("beforeend", e), a$1.setIsUiLoaded(true); } } } function get_each_context$1(ctx, list, i2) { const child_ctx = ctx.slice(); child_ctx[18] = list[i2]; return child_ctx; } function create_if_block_8(ctx) { let div0; let button; let t0; let t1; let div1; let t2; let mounted; let dispose; return { c() { div0 = element("div"); button = element("button"); t0 = text("Connect using Web3 wallet"); t1 = space(); div1 = element("div"); t2 = text("Once connected, you will see what discount you are entitled to - based on ownership of the\n specific ZK Badges or SBT tokens."); this.h(); }, l(nodes) { div0 = claim_element(nodes, "DIV", { class: true }); var div0_nodes = children(div0); button = claim_element(div0_nodes, "BUTTON", { class: true }); var button_nodes = children(button); t0 = claim_text(button_nodes, "Connect using Web3 wallet"); button_nodes.forEach(detach); div0_nodes.forEach(detach); t1 = claim_space(nodes); div1 = claim_element(nodes, "DIV", { class: true }); var div1_nodes = children(div1); t2 = claim_text(div1_nodes, "Once connected, you will see what discount you are entitled to - based on ownership of the\n specific ZK Badges or SBT tokens."); div1_nodes.forEach(detach); this.h(); }, h() { attr(button, "class", "button is-link is-light"); attr(div0, "class", "buttons"); attr(div1, "class", "text-supermild mt-4 text-base"); }, m(target, anchor) { insert_hydration(target, div0, anchor); append_hydration(div0, button); append_hydration(button, t0); insert_hydration(target, t1, anchor); insert_hydration(target, div1, anchor); append_hydration(div1, t2); if (!mounted) { dispose = [ listen(button, "click", function() { if (is_function( /*enable*/ ctx[1] )) ctx[1].apply(this, arguments); }), listen( button, "mouseenter", /*mouseenter_handler*/ ctx[11] ) ]; mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; }, d(detaching) { if (detaching) detach(div0); if (detaching) detach(t1); if (detaching) detach(div1); mounted = false; run_all(dispose); } }; } function create_if_block_7(ctx) { let div; let t0; let span; let t1; let t2; let button; let t3; let mounted; let dispose; return { c() { div = element("div"); t0 = text("Connected as: "); span = element("span"); t1 = text( /*selectedAccount*/ ctx[5] ); t2 = space(); button = element("button"); t3 = text("disconnect"); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", {}); var div_nodes = children(div); t0 = claim_text(div_nodes, "Connected as: "); span = claim_element(div_nodes, "SPAN", { class: true }); var span_nodes = children(span); t1 = claim_text( span_nodes, /*selectedAccount*/ ctx[5] ); span_nodes.forEach(detach); t2 = claim_space(div_nodes); button = claim_element(div_nodes, "BUTTON", { class: true }); var button_nodes = children(button); t3 = claim_text(button_nodes, "disconnect"); button_nodes.forEach(detach); div_nodes.forEach(detach); this.h(); }, h() { attr(span, "class", "font-bold"); attr(button, "class", "button is-link is-light inline-block cursor-pointer"); }, m(target, anchor) { insert_hydration(target, div, anchor); append_hydration(div, t0); append_hydration(div, span); append_hydration(span, t1); append_hydration(div, t2); append_hydration(div, button); append_hydration(button, t3); if (!mounted) { dispose = [ listen(button, "click", function() { if (is_function( /*disable*/ ctx[2] )) ctx[2].apply(this, arguments); }), listen(button, "mouseenter", animateText) ]; mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; if (dirty & /*selectedAccount*/ 32) set_data( t1, /*selectedAccount*/ ctx[5] ); }, d(detaching) { if (detaching) detach(div); mounted = false; run_all(dispose); } }; } function create_else_block(ctx) { let div; let each_value = ( /*badges*/ ctx[7] ); let each_blocks = []; for (let i2 = 0; i2 < each_value.length; i2 += 1) { each_blocks[i2] = create_each_block$1(get_each_context$1(ctx, each_value, i2)); } return { c() { div = element("div"); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].c(); } this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].l(div_nodes); } div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 lg:gap-6"); }, m(target, anchor) { insert_hydration(target, div, anchor); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].m(div, null); } }, p(ctx2, dirty) { if (dirty & /*userBadges, badges, animateSection, redeemUrl, claimed, animateText, claimHandler, connected, data*/ 729) { each_value = /*badges*/ ctx2[7]; let i2; for (i2 = 0; i2 < each_value.length; i2 += 1) { const child_ctx = get_each_context$1(ctx2, each_value, i2); if (each_blocks[i2]) { each_blocks[i2].p(child_ctx, dirty); } else { each_blocks[i2] = create_each_block$1(child_ctx); each_blocks[i2].c(); each_blocks[i2].m(div, null); } } for (; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].d(1); } each_blocks.length = each_value.length; } }, d(detaching) { if (detaching) detach(div); destroy_each(each_blocks, detaching); } }; } function create_if_block$1(ctx) { let div; let t0; let br0; let br1; let t1; return { c() { div = element("div"); t0 = text("Loading ..."); br0 = element("br"); br1 = element("br"); t1 = text("If you have any problems, please contact us in the public Signal\n group"); }, l(nodes) { div = claim_element(nodes, "DIV", {}); var div_nodes = children(div); t0 = claim_text(div_nodes, "Loading ..."); br0 = claim_element(div_nodes, "BR", {}); br1 = claim_element(div_nodes, "BR", {}); t1 = claim_text(div_nodes, "If you have any problems, please contact us in the public Signal\n group"); div_nodes.forEach(detach); }, m(target, anchor) { insert_hydration(target, div, anchor); append_hydration(div, t0); append_hydration(div, br0); append_hydration(div, br1); append_hydration(div, t1); }, p: noop, d(detaching) { if (detaching) detach(div); } }; } function create_if_block_6(ctx) { let div; let t_value = ( /*badge*/ ctx[18].shortname + "" ); let t2; return { c() { div = element("div"); t2 = text(t_value); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); t2 = claim_text(div_nodes, t_value); div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "uppercase font-bold"); }, m(target, anchor) { insert_hydration(target, div, anchor); append_hydration(div, t2); }, p: noop, d(detaching) { if (detaching) detach(div); } }; } function create_if_block_2$1(ctx) { let div; function select_block_type_1(ctx2, dirty) { var _a; if ( /*claimed*/ ctx2[4][ /*badge*/ ctx2[18].id ] ) return create_if_block_3$1; if ( /*userBadges*/ (_a = ctx2[3].badges[ /*badge*/ ctx2[18].id ]) == null ? void 0 : _a.eligible ) return create_if_block_5; return create_else_block_2; } let current_block_type = select_block_type_1(ctx); let if_block = current_block_type(ctx); return { c() { div = element("div"); if_block.c(); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); if_block.l(div_nodes); div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "pt-2"); }, m(target, anchor) { insert_hydration(target, div, anchor); if_block.m(div, null); }, p(ctx2, dirty) { if (current_block_type === (current_block_type = select_block_type_1(ctx2)) && if_block) { if_block.p(ctx2, dirty); } else { if_block.d(1); if_block = current_block_type(ctx2); if (if_block) { if_block.c(); if_block.m(div, null); } } }, d(detaching) { if (detaching) detach(div); if_block.d(); } }; } function create_else_block_2(ctx) { let button; let t2; return { c() { button = element("button"); t2 = text("Not eligible"); this.h(); }, l(nodes) { button = claim_element(nodes, "BUTTON", { class: true }); var button_nodes = children(button); t2 = claim_text(button_nodes, "Not eligible"); button_nodes.forEach(detach); this.h(); }, h() { attr(button, "class", "button button-inactive text-gray-600 border-gray-600"); }, m(target, anchor) { insert_hydration(target, button, anchor); append_hydration(button, t2); }, p: noop, d(detaching) { if (detaching) detach(button); } }; } function create_if_block_5(ctx) { let button; let t2; let mounted; let dispose; return { c() { button = element("button"); t2 = text("Eligible! Get discount!"); this.h(); }, l(nodes) { button = claim_element(nodes, "BUTTON", { class: true }); var button_nodes = children(button); t2 = claim_text(button_nodes, "Eligible! Get discount!"); button_nodes.forEach(detach); this.h(); }, h() { attr(button, "class", "button-inverse"); }, m(target, anchor) { insert_hydration(target, button, anchor); append_hydration(button, t2); if (!mounted) { dispose = [ listen( button, "click", /*claimHandler*/ ctx[9]( /*badge*/ ctx[18].id ) ), listen( button, "mouseenter", /*mouseenter_handler_2*/ ctx[13] ) ]; mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; }, d(detaching) { if (detaching) detach(button); mounted = false; run_all(dispose); } }; } function create_if_block_3$1(ctx) { let if_block_anchor; function select_block_type_2(ctx2, dirty) { if ( /*claimed*/ ctx2[4][ /*badge*/ ctx2[18].id ].voucher ) return create_if_block_4$1; return create_else_block_1; } let current_block_type = select_block_type_2(ctx); let if_block = current_block_type(ctx); return { c() { if_block.c(); if_block_anchor = empty(); }, l(nodes) { if_block.l(nodes); if_block_anchor = empty(); }, m(target, anchor) { if_block.m(target, anchor); insert_hydration(target, if_block_anchor, anchor); }, p(ctx2, dirty) { if (current_block_type === (current_block_type = select_block_type_2(ctx2)) && if_block) { if_block.p(ctx2, dirty); } else { if_block.d(1); if_block = current_block_type(ctx2); if (if_block) { if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } }, d(detaching) { if_block.d(detaching); if (detaching) detach(if_block_anchor); } }; } function create_else_block_1(ctx) { let t_value = ( /*claimed*/ (ctx[4][ /*badge*/ ctx[18].id ].text || "Please sign message in your wallet ..") + "" ); let t2; return { c() { t2 = text(t_value); }, l(nodes) { t2 = claim_text(nodes, t_value); }, m(target, anchor) { insert_hydration(target, t2, anchor); }, p(ctx2, dirty) { if (dirty & /*claimed*/ 16 && t_value !== (t_value = /*claimed*/ (ctx2[4][ /*badge*/ ctx2[18].id ].text || "Please sign message in your wallet ..") + "")) set_data(t2, t_value); }, d(detaching) { if (detaching) detach(t2); } }; } function create_if_block_4$1(ctx) { let t0; let a0; let t1_value = ( /*claimed*/ ctx[4][ /*badge*/ ctx[18].id ].voucher + "" ); let t1; let a0_href_value; let t2; let div; let a1; let button; let t3; let a1_href_value; let mounted; let dispose; return { c() { t0 = text("Your personal voucher: "); a0 = element("a"); t1 = text(t1_value); t2 = space(); div = element("div"); a1 = element("a"); button = element("button"); t3 = text("Buy ticket using voucher"); this.h(); }, l(nodes) { t0 = claim_text(nodes, "Your personal voucher: "); a0 = claim_element(nodes, "A", { href: true, target: true, class: true }); var a0_nodes = children(a0); t1 = claim_text(a0_nodes, t1_value); a0_nodes.forEach(detach); t2 = claim_space(nodes); div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); a1 = claim_element(div_nodes, "A", { href: true, target: true }); var a1_nodes = children(a1); button = claim_element(a1_nodes, "BUTTON", { class: true }); var button_nodes = children(button); t3 = claim_text(button_nodes, "Buy ticket using voucher"); button_nodes.forEach(detach); a1_nodes.forEach(detach); div_nodes.forEach(detach); this.h(); }, h() { attr(a0, "href", a0_href_value = redeemUrl + /*claimed*/ ctx[4][ /*badge*/ ctx[18].id ].voucher); attr(a0, "target", "_blank"); attr(a0, "class", "underline hover:no-underline external"); attr(button, "class", "button-inverse"); attr(a1, "href", a1_href_value = redeemUrl + /*claimed*/ ctx[4][ /*badge*/ ctx[18].id ].voucher); attr(a1, "target", "_blank"); attr(div, "class", "pt-2"); }, m(target, anchor) { insert_hydration(target, t0, anchor); insert_hydration(target, a0, anchor); append_hydration(a0, t1); insert_hydration(target, t2, anchor); insert_hydration(target, div, anchor); append_hydration(div, a1); append_hydration(a1, button); append_hydration(button, t3); if (!mounted) { dispose = listen( button, "mouseenter", /*mouseenter_handler_1*/ ctx[12] ); mounted = true; } }, p(ctx2, dirty) { if (dirty & /*claimed*/ 16 && t1_value !== (t1_value = /*claimed*/ ctx2[4][ /*badge*/ ctx2[18].id ].voucher + "")) set_data(t1, t1_value); if (dirty & /*claimed*/ 16 && a0_href_value !== (a0_href_value = redeemUrl + /*claimed*/ ctx2[4][ /*badge*/ ctx2[18].id ].voucher)) { attr(a0, "href", a0_href_value); } if (dirty & /*claimed*/ 16 && a1_href_value !== (a1_href_value = redeemUrl + /*claimed*/ ctx2[4][ /*badge*/ ctx2[18].id ].voucher)) { attr(a1, "href", a1_href_value); } }, d(detaching) { if (detaching) detach(t0); if (detaching) detach(a0); if (detaching) detach(t2); if (detaching) detach(div); mounted = false; dispose(); } }; } function create_if_block_1$1(ctx) { let div; let t_value = ( /*badge*/ ctx[18].text + "" ); let t2; return { c() { div = element("div"); t2 = text(t_value); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); t2 = claim_text(div_nodes, t_value); div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "text-xs leading-6 pt-4 text-mild"); }, m(target, anchor) { insert_hydration(target, div, anchor); append_hydration(div, t2); }, p: noop, d(detaching) { if (detaching) detach(div); } }; } function create_each_block$1(ctx) { let div4; let div0; let img; let img_src_value; let img_class_value; let t0; let div3; let t1; let div1; let a2; let t2_value = ( /*badge*/ ctx[18].name + "" ); let t2; let t3; let div2; let t4; let span; let t5; let t6_value = ( /*data*/ ctx[0].config.ticketBasePrice - /*data*/ ctx[0].config.ticketBasePrice * /*badge*/ (ctx[18].discount / 100) + "" ); let t6; let t7; let t8_value = ( /*badge*/ ctx[18].discount + "" ); let t8; let t9; let t10; let t11; let t12; let div4_class_value; let mounted; let dispose; let if_block0 = ( /*badge*/ ctx[18].shortname && create_if_block_6(ctx) ); let if_block1 = ( /*connected*/ ctx[6] && /*userBadges*/ ctx[3] && create_if_block_2$1(ctx) ); let if_block2 = ( /*badge*/ ctx[18].text && create_if_block_1$1(ctx) ); return { c() { div4 = element("div"); div0 = element("div"); img = element("img"); t0 = space(); div3 = element("div"); if (if_block0) if_block0.c(); t1 = space(); div1 = element("div"); a2 = element("a"); t2 = text(t2_value); t3 = space(); div2 = element("div"); t4 = text("Ticket: "); span = element("span"); t5 = text("€"); t6 = text(t6_value); t7 = text("\n ("); t8 = text(t8_value); t9 = text("% discount)"); t10 = space(); if (if_block1) if_block1.c(); t11 = space(); if (if_block2) if_block2.c(); t12 = space(); this.h(); }, l(nodes) { div4 = claim_element(nodes, "DIV", { class: true }); var div4_nodes = children(div4); div0 = claim_element(div4_nodes, "DIV", { class: true }); var div0_nodes = children(div0); img = claim_element(div0_nodes, "IMG", { src: true, class: true }); div0_nodes.forEach(detach); t0 = claim_space(div4_nodes); div3 = claim_element(div4_nodes, "DIV", { class: true }); var div3_nodes = children(div3); if (if_block0) if_block0.l(div3_nodes); t1 = claim_space(div3_nodes); div1 = claim_element(div3_nodes, "DIV", { class: true }); var div1_nodes = children(div1); a2 = claim_element(div1_nodes, "A", { href: true, target: true, class: true }); var a_nodes = children(a2); t2 = claim_text(a_nodes, t2_value); a_nodes.forEach(detach); div1_nodes.forEach(detach); t3 = claim_space(div3_nodes); div2 = claim_element(div3_nodes, "DIV", { class: true }); var div2_nodes = children(div2); t4 = claim_text(div2_nodes, "Ticket: "); span = claim_element(div2_nodes, "SPAN", { class: true }); var span_nodes = children(span); t5 = claim_text(span_nodes, "€"); t6 = claim_text(span_nodes, t6_value); span_nodes.forEach(detach); t7 = claim_text(div2_nodes, "\n ("); t8 = claim_text(div2_nodes, t8_value); t9 = claim_text(div2_nodes, "% discount)"); div2_nodes.forEach(detach); t10 = claim_space(div3_nodes); if (if_block1) if_block1.l(div3_nodes); t11 = claim_space(div3_nodes); if (if_block2) if_block2.l(div3_nodes); div3_nodes.forEach(detach); t12 = claim_space(div4_nodes); div4_nodes.forEach(detach); this.h(); }, h() { var _a, _b, _c, _d, _e; if (!src_url_equal(img.src, img_src_value = /*badge*/ ctx[18].img)) attr(img, "src", img_src_value); attr(img, "class", img_class_value = "w-2/5 aspect-square " + /*connected*/ (ctx[6] && /*userBadges*/ ctx[3] && /*userBadges*/ ((_a = ctx[3].badges[ /*badge*/ ctx[18].id ]) == null ? void 0 : _a.eligible) ? "" : "grayscale") + " badge-image inline-block object-contain"); attr(div0, "class", "mb-6 text-center"); attr( a2, "href", /*badge*/ ctx[18].url ); attr(a2, "target", "_blank"); attr(a2, "class", "external animate-section font-mono2 lowercase"); attr( div1, "class", /*badge*/ ctx[18].shortname ? "" : "font-bold" ); attr(span, "class", "font-bold"); attr(div2, "class", "mt-4"); attr(div3, "class", "w-full"); attr(div4, "class", div4_class_value = "justify-center text-center badge p-4 border border-white/30 hover:border-white border-dashed " + /*userBadges*/ (((_b = ctx[3]) == null ? void 0 : _b.badges) && /*userBadges*/ ((_e = (_d = ctx[3]) == null ? void 0 : _d.badges[ /*badge*/ (_c = ctx[18]) == null ? void 0 : _c.id ]) == null ? void 0 : _e.eligible) ? "bg-white text-black eligible" : "")); }, m(target, anchor) { insert_hydration(target, div4, anchor); append_hydration(div4, div0); append_hydration(div0, img); append_hydration(div4, t0); append_hydration(div4, div3); if (if_block0) if_block0.m(div3, null); append_hydration(div3, t1); append_hydration(div3, div1); append_hydration(div1, a2); append_hydration(a2, t2); append_hydration(div3, t3); append_hydration(div3, div2); append_hydration(div2, t4); append_hydration(div2, span); append_hydration(span, t5); append_hydration(span, t6); append_hydration(div2, t7); append_hydration(div2, t8); append_hydration(div2, t9); append_hydration(div3, t10); if (if_block1) if_block1.m(div3, null); append_hydration(div3, t11); if (if_block2) if_block2.m(div3, null); append_hydration(div4, t12); if (!mounted) { dispose = listen(div4, "mouseenter", animateSection(30)); mounted = true; } }, p(ctx2, dirty) { var _a, _b, _c, _d, _e; if (dirty & /*connected, userBadges*/ 72 && img_class_value !== (img_class_value = "w-2/5 aspect-square " + /*connected*/ (ctx2[6] && /*userBadges*/ ctx2[3] && /*userBadges*/ ((_a = ctx2[3].badges[ /*badge*/ ctx2[18].id ]) == null ? void 0 : _a.eligible) ? "" : "grayscale") + " badge-image inline-block object-contain")) { attr(img, "class", img_class_value); } if ( /*badge*/ ctx2[18].shortname ) if_block0.p(ctx2, dirty); if (dirty & /*data*/ 1 && t6_value !== (t6_value = /*data*/ ctx2[0].config.ticketBasePrice - /*data*/ ctx2[0].config.ticketBasePrice * /*badge*/ (ctx2[18].discount / 100) + "")) set_data(t6, t6_value); if ( /*connected*/ ctx2[6] && /*userBadges*/ ctx2[3] ) { if (if_block1) { if_block1.p(ctx2, dirty); } else { if_block1 = create_if_block_2$1(ctx2); if_block1.c(); if_block1.m(div3, t11); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if ( /*badge*/ ctx2[18].text ) if_block2.p(ctx2, dirty); if (dirty & /*userBadges*/ 8 && div4_class_value !== (div4_class_value = "justify-center text-center badge p-4 border border-white/30 hover:border-white border-dashed " + /*userBadges*/ (((_b = ctx2[3]) == null ? void 0 : _b.badges) && /*userBadges*/ ((_e = (_d = ctx2[3]) == null ? void 0 : _d.badges[ /*badge*/ (_c = ctx2[18]) == null ? void 0 : _c.id ]) == null ? void 0 : _e.eligible) ? "bg-white text-black eligible" : ""))) { attr(div4, "class", div4_class_value); } }, d(detaching) { if (detaching) detach(div4); if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); mounted = false; dispose(); } }; } function create_fragment$1(ctx) { let t0; let t1; let div6; let div5; let div0; let t2; let t3; let div1; let t4; let div2; let t5; let t6; let div3; let sveltemarkdown; let t7; let div4; let a2; let button; let t8; let a_href_value; let current; let mounted; let dispose; let if_block0 = !/*connected*/ ctx[6] && create_if_block_8(ctx); let if_block1 = ( /*connected*/ ctx[6] && create_if_block_7(ctx) ); function select_block_type(ctx2, dirty) { if ( /*connected*/ ctx2[6] && /*userBadges*/ ctx2[3] === null ) return create_if_block$1; return create_else_block; } let current_block_type = select_block_type(ctx); let if_block2 = current_block_type(ctx); sveltemarkdown = new SvelteMarkdown({ props: { source: ( /*data*/ ctx[0].config.ticketsDiscounts ) } }); return { c() { if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); div6 = element("div"); div5 = element("div"); div0 = element("div"); t2 = text("Eligible ZK Badges / SBTs"); t3 = space(); div1 = element("div"); if_block2.c(); t4 = space(); div2 = element("div"); t5 = text("Other discounts (via form)"); t6 = space(); div3 = element("div"); create_component(sveltemarkdown.$$.fragment); t7 = space(); div4 = element("div"); a2 = element("a"); button = element("button"); t8 = text("Apply for a discount"); this.h(); }, l(nodes) { if (if_block0) if_block0.l(nodes); t0 = claim_space(nodes); if (if_block1) if_block1.l(nodes); t1 = claim_space(nodes); div6 = claim_element(nodes, "DIV", { class: true }); var div6_nodes = children(div6); div5 = claim_element(div6_nodes, "DIV", { class: true }); var div5_nodes = children(div5); div0 = claim_element(div5_nodes, "DIV", { class: true }); var div0_nodes = children(div0); t2 = claim_text(div0_nodes, "Eligible ZK Badges / SBTs"); div0_nodes.forEach(detach); t3 = claim_space(div5_nodes); div1 = claim_element(div5_nodes, "DIV", { class: true }); var div1_nodes = children(div1); if_block2.l(div1_nodes); div1_nodes.forEach(detach); t4 = claim_space(div5_nodes); div2 = claim_element(div5_nodes, "DIV", { class: true }); var div2_nodes = children(div2); t5 = claim_text(div2_nodes, "Other discounts (via form)"); div2_nodes.forEach(detach); t6 = claim_space(div5_nodes); div3 = claim_element(div5_nodes, "DIV", { class: true }); var div3_nodes = children(div3); claim_component(sveltemarkdown.$$.fragment, div3_nodes); div3_nodes.forEach(detach); t7 = claim_space(div5_nodes); div4 = claim_element(div5_nodes, "DIV", { class: true }); var div4_nodes = children(div4); a2 = claim_element(div4_nodes, "A", { href: true }); var a_nodes = children(a2); button = claim_element(a_nodes, "BUTTON", { class: true }); var button_nodes = children(button); t8 = claim_text(button_nodes, "Apply for a discount"); button_nodes.forEach(detach); a_nodes.forEach(detach); div4_nodes.forEach(detach); div5_nodes.forEach(detach); div6_nodes.forEach(detach); this.h(); }, h() { attr(div0, "class", "text-xl font-mono2 lowercase mb-10"); attr(div1, "class", "pb-8"); attr(div2, "class", "text-xl font-mono2 lowercase mt-12 mb-8"); attr(div3, "class", "text-mild"); attr(button, "class", "button"); attr(a2, "href", a_href_value = /*data*/ ctx[0].config.ticketsDiscountForm); attr(div4, "class", "mt-8 mb-8"); attr(div5, "class", "m-auto"); attr(div6, "class", "w-full mt-16"); }, m(target, anchor) { if (if_block0) if_block0.m(target, anchor); insert_hydration(target, t0, anchor); if (if_block1) if_block1.m(target, anchor); insert_hydration(target, t1, anchor); insert_hydration(target, div6, anchor); append_hydration(div6, div5); append_hydration(div5, div0); append_hydration(div0, t2); append_hydration(div5, t3); append_hydration(div5, div1); if_block2.m(div1, null); append_hydration(div5, t4); append_hydration(div5, div2); append_hydration(div2, t5); append_hydration(div5, t6); append_hydration(div5, div3); mount_component(sveltemarkdown, div3, null); append_hydration(div5, t7); append_hydration(div5, div4); append_hydration(div4, a2); append_hydration(a2, button); append_hydration(button, t8); current = true; if (!mounted) { dispose = [ listen(div0, "mouseenter", animateText), listen(div2, "mouseenter", animateText), listen(button, "mouseenter", animateText) ]; mounted = true; } }, p(ctx2, [dirty]) { if (!/*connected*/ ctx2[6]) { if (if_block0) { if_block0.p(ctx2, dirty); } else { if_block0 = create_if_block_8(ctx2); if_block0.c(); if_block0.m(t0.parentNode, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if ( /*connected*/ ctx2[6] ) { if (if_block1) { if_block1.p(ctx2, dirty); } else { if_block1 = create_if_block_7(ctx2); if_block1.c(); if_block1.m(t1.parentNode, t1); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (current_block_type === (current_block_type = select_block_type(ctx2)) && if_block2) { if_block2.p(ctx2, dirty); } else { if_block2.d(1); if_block2 = current_block_type(ctx2); if (if_block2) { if_block2.c(); if_block2.m(div1, null); } } const sveltemarkdown_changes = {}; if (dirty & /*data*/ 1) sveltemarkdown_changes.source = /*data*/ ctx2[0].config.ticketsDiscounts; sveltemarkdown.$set(sveltemarkdown_changes); if (!current || dirty & /*data*/ 1 && a_href_value !== (a_href_value = /*data*/ ctx2[0].config.ticketsDiscountForm)) { attr(a2, "href", a_href_value); } }, i(local) { if (current) return; transition_in(sveltemarkdown.$$.fragment, local); current = true; }, o(local) { transition_out(sveltemarkdown.$$.fragment, local); current = false; }, d(detaching) { if (if_block0) if_block0.d(detaching); if (detaching) detach(t0); if (if_block1) if_block1.d(detaching); if (detaching) detach(t1); if (detaching) detach(div6); if_block2.d(); destroy_component(sveltemarkdown); mounted = false; run_all(dispose); } }; } const projectId = "43a2f1e1b1753e7d4e628b5a1827d319"; const redeemUrl = "https://tickets.web3privacy.info/w3ps1/redeem?voucher="; function instance$1($$self, $$props, $$invalidate) { let connected; let selectedAccount; let $web3store; let { data } = $$props; const chains = [mainnet, arbitrum, optimism, polygon, gnosis]; const badges = data.badges; let web3Modal; let enable = () => init4(); let disable; let userBadges = null; let claimed = {}; const web3store = writable({}); component_subscribe($$self, web3store, (value) => $$invalidate(10, $web3store = value)); async function checkBadges(addr) { const resp = await fetch(`${data.config.badgesApiUrl}/account/${addr}`); return resp.json(); } async function init4() { const { provider } = configureChains(chains, [j({ projectId })]); const wagmiClient = createClient({ autoConnect: false, connectors: [...V({ appName: "web3Modal", chains })], provider }); const ethereumClient = new P$1(wagmiClient, chains); $$invalidate(2, disable = async () => { await disconnect(); $$invalidate(3, userBadges = {}); web3store.set({}); }); $$invalidate(1, enable = async () => { await web3Modal.openModal(); }); web3Modal = new h({ projectId }, ethereumClient); await web3Modal.openModal(); web3Modal.subscribeModal(async (newState) => { const account = getAccount(); web3store.set(account); $$invalidate(4, claimed = {}); $$invalidate(3, userBadges = await checkBadges(account.address)); }); } function claimHandler(badgeId) { return async () => { const badge = badges.find((b2) => b2.id === badgeId); const addr = selectedAccount; $$invalidate(4, claimed[badgeId] = {}, claimed); const msg = `I want to get a discount on a ticket to Web3Privacy Prague 2023. My address is "${addr}" and I own "${badge.name}". ${new Date().toISOString()}`; let signature2; try { signature2 = await signMessage({ message: msg }); } catch (e) { $$invalidate(4, claimed[badgeId] = null, claimed); return; } if (!signature2) { return null; } $$invalidate( 4, claimed[badgeId] = { text: "Wait for the voucher to be generated from our ticketing system .." }, claimed ); const query = { addr, badgeId, msg, signature: signature2 }; console.log(query); const resp = await fetch(`${data.config.badgesApiUrl}/claim`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(query) }); const res = await resp.json(); $$invalidate(4, claimed[badgeId] = { claimed: true, voucher: res.voucher, res }, claimed); }; } const mouseenter_handler = (ev) => animateText(ev, 15); const mouseenter_handler_1 = (ev) => animateText(ev, 15); const mouseenter_handler_2 = (ev) => animateText(ev, 15); $$self.$$set = ($$props2) => { if ("data" in $$props2) $$invalidate(0, data = $$props2.data); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*$web3store*/ 1024) { $$invalidate(6, connected = $web3store.isConnected); } if ($$self.$$.dirty & /*$web3store*/ 1024) { $$invalidate(5, selectedAccount = $web3store.address); } }; return [ data, enable, disable, userBadges, claimed, selectedAccount, connected, badges, web3store, claimHandler, $web3store, mouseenter_handler, mouseenter_handler_1, mouseenter_handler_2 ]; } class Web3Dialog extends SvelteComponent { constructor(options) { super(); init(this, options, instance$1, create_fragment$1, safe_not_equal, { data: 0 }); } } function get_each_context(ctx, list, i2) { const child_ctx = ctx.slice(); child_ctx[3] = list[i2]; return child_ctx; } function get_each_context_1(ctx, list, i2) { const child_ctx = ctx.slice(); child_ctx[6] = list[i2]; return child_ctx; } function get_each_context_2(ctx, list, i2) { const child_ctx = ctx.slice(); child_ctx[9] = list[i2]; return child_ctx; } function get_each_context_3(ctx, list, i2) { const child_ctx = ctx.slice(); child_ctx[12] = list[i2]; return child_ctx; } function get_each_context_4(ctx, list, i2) { const child_ctx = ctx.slice(); child_ctx[15] = list[i2]; return child_ctx; } function get_each_context_5(ctx, list, i2) { const child_ctx = ctx.slice(); child_ctx[9] = list[i2]; return child_ctx; } function create_each_block_5(ctx) { let div2; let img; let img_src_value; let t0; let div0; let t1_value = ( /*ti*/ ctx[9].title.toUpperCase() + "" ); let t1; let t2; let div1; let sveltemarkdown; let t3; let current; let mounted; let dispose; sveltemarkdown = new SvelteMarkdown({ props: { source: ( /*ti*/ ctx[9].desc ) } }); return { c() { div2 = element("div"); img = element("img"); t0 = space(); div0 = element("div"); t1 = text(t1_value); t2 = space(); div1 = element("div"); create_component(sveltemarkdown.$$.fragment); t3 = space(); this.h(); }, l(nodes) { div2 = claim_element(nodes, "DIV", { class: true }); var div2_nodes = children(div2); img = claim_element(div2_nodes, "IMG", { class: true, src: true }); t0 = claim_space(div2_nodes); div0 = claim_element(div2_nodes, "DIV", { class: true }); var div0_nodes = children(div0); t1 = claim_text(div0_nodes, t1_value); div0_nodes.forEach(detach); t2 = claim_space(div2_nodes); div1 = claim_element(div2_nodes, "DIV", { class: true }); var div1_nodes = children(div1); claim_component(sveltemarkdown.$$.fragment, div1_nodes); div1_nodes.forEach(detach); t3 = claim_space(div2_nodes); div2_nodes.forEach(detach); this.h(); }, h() { attr(img, "class", "topic-img"); if (!src_url_equal(img.src, img_src_value = "/topics/" + /*ti*/ ctx[9].img + ".webp")) attr(img, "src", img_src_value); attr(div0, "class", "topic-header inline-block px-3 py-1.5 text-lg"); attr(div1, "class", "mt-6 text-mild markdown animate-section text-sm leading-6"); attr(div2, "class", "topic-item text-center mb-6"); }, m(target, anchor) { insert_hydration(target, div2, anchor); append_hydration(div2, img); append_hydration(div2, t0); append_hydration(div2, div0); append_hydration(div0, t1); append_hydration(div2, t2); append_hydration(div2, div1); mount_component(sveltemarkdown, div1, null); append_hydration(div2, t3); current = true; if (!mounted) { dispose = listen(div2, "mouseenter", animateSection(5)); mounted = true; } }, p(ctx2, dirty) { if (!current || dirty & /*data*/ 1 && !src_url_equal(img.src, img_src_value = "/topics/" + /*ti*/ ctx2[9].img + ".webp")) { attr(img, "src", img_src_value); } if ((!current || dirty & /*data*/ 1) && t1_value !== (t1_value = /*ti*/ ctx2[9].title.toUpperCase() + "")) set_data(t1, t1_value); const sveltemarkdown_changes = {}; if (dirty & /*data*/ 1) sveltemarkdown_changes.source = /*ti*/ ctx2[9].desc; sveltemarkdown.$set(sveltemarkdown_changes); }, i(local) { if (current) return; transition_in(sveltemarkdown.$$.fragment, local); current = true; }, o(local) { transition_out(sveltemarkdown.$$.fragment, local); current = false; }, d(detaching) { if (detaching) detach(div2); destroy_component(sveltemarkdown); mounted = false; dispose(); } }; } function create_if_block_4(ctx) { let div; let t_value = ( /*data*/ ctx[0].config.speakersNote + "" ); let t2; return { c() { div = element("div"); t2 = text(t_value); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); t2 = claim_text(div_nodes, t_value); div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "text-supermild mt-6"); }, m(target, anchor) { insert_hydration(target, div, anchor); append_hydration(div, t2); }, p(ctx2, dirty) { if (dirty & /*data*/ 1 && t_value !== (t_value = /*data*/ ctx2[0].config.speakersNote + "")) set_data(t2, t_value); }, d(detaching) { if (detaching) detach(div); } }; } function create_each_block_4(ctx) { let div4; let div0; let a0; let img; let img_src_value; let img_class_value; let a0_href_value; let t0; let div3; let div1; let a1; let t1_value = ( /*partner*/ ctx[15].name + "" ); let t1; let a1_href_value; let t2; let div2; let a2; let t3; let t4_value = ( /*partner*/ ctx[15].twitter + "" ); let t4; let a2_href_value; let mounted; let dispose; return { c() { div4 = element("div"); div0 = element("div"); a0 = element("a"); img = element("img"); t0 = space(); div3 = element("div"); div1 = element("div"); a1 = element("a"); t1 = text(t1_value); t2 = space(); div2 = element("div"); a2 = element("a"); t3 = text("@"); t4 = text(t4_value); this.h(); }, l(nodes) { div4 = claim_element(nodes, "DIV", { class: true }); var div4_nodes = children(div4); div0 = claim_element(div4_nodes, "DIV", {}); var div0_nodes = children(div0); a0 = claim_element(div0_nodes, "A", { href: true }); var a0_nodes = children(a0); img = claim_element(a0_nodes, "IMG", { src: true, class: true }); a0_nodes.forEach(detach); div0_nodes.forEach(detach); t0 = claim_space(div4_nodes); div3 = claim_element(div4_nodes, "DIV", { class: true }); var div3_nodes = children(div3); div1 = claim_element(div3_nodes, "DIV", {}); var div1_nodes = children(div1); a1 = claim_element(div1_nodes, "A", { href: true, class: true }); var a1_nodes = children(a1); t1 = claim_text(a1_nodes, t1_value); a1_nodes.forEach(detach); div1_nodes.forEach(detach); t2 = claim_space(div3_nodes); div2 = claim_element(div3_nodes, "DIV", {}); var div2_nodes = children(div2); a2 = claim_element(div2_nodes, "A", { href: true, class: true }); var a2_nodes = children(a2); t3 = claim_text(a2_nodes, "@"); t4 = claim_text(a2_nodes, t4_value); a2_nodes.forEach(detach); div2_nodes.forEach(detach); div3_nodes.forEach(detach); div4_nodes.forEach(detach); this.h(); }, h() { if (!src_url_equal(img.src, img_src_value = "/partners/" + /*partner*/ ctx[15].img)) attr(img, "src", img_src_value); attr(img, "class", img_class_value = "partner-img aspect-[16/11] w-full h-full object-contain " + /*partner*/ ctx[15].class + " " + /*partner*/ (ctx[15].padding ? `p-${/*partner*/ ctx[15].padding}` : "")); attr(a0, "href", a0_href_value = /*partner*/ ctx[15].web); attr(a1, "href", a1_href_value = /*partner*/ ctx[15].web); attr(a1, "class", "font-mono2 animate-section lowercase"); attr(a2, "href", a2_href_value = "https://twitter.com/" + /*partner*/ ctx[15].twitter); attr(a2, "class", "text-sm text-mild"); attr(div3, "class", "p-2 partner-text"); attr(div4, "class", "partner-item text-center items-center p-2"); }, m(target, anchor) { insert_hydration(target, div4, anchor); append_hydration(div4, div0); append_hydration(div0, a0); append_hydration(a0, img); append_hydration(div4, t0); append_hydration(div4, div3); append_hydration(div3, div1); append_hydration(div1, a1); append_hydration(a1, t1); append_hydration(div3, t2); append_hydration(div3, div2); append_hydration(div2, a2); append_hydration(a2, t3); append_hydration(a2, t4); if (!mounted) { dispose = listen(div4, "mouseenter", animateSection(40)); mounted = true; } }, p(ctx2, dirty) { if (dirty & /*data*/ 1 && !src_url_equal(img.src, img_src_value = "/partners/" + /*partner*/ ctx2[15].img)) { attr(img, "src", img_src_value); } if (dirty & /*data*/ 1 && img_class_value !== (img_class_value = "partner-img aspect-[16/11] w-full h-full object-contain " + /*partner*/ ctx2[15].class + " " + /*partner*/ (ctx2[15].padding ? `p-${/*partner*/ ctx2[15].padding}` : ""))) { attr(img, "class", img_class_value); } if (dirty & /*data*/ 1 && a0_href_value !== (a0_href_value = /*partner*/ ctx2[15].web)) { attr(a0, "href", a0_href_value); } if (dirty & /*data*/ 1 && t1_value !== (t1_value = /*partner*/ ctx2[15].name + "")) set_data(t1, t1_value); if (dirty & /*data*/ 1 && a1_href_value !== (a1_href_value = /*partner*/ ctx2[15].web)) { attr(a1, "href", a1_href_value); } if (dirty & /*data*/ 1 && t4_value !== (t4_value = /*partner*/ ctx2[15].twitter + "")) set_data(t4, t4_value); if (dirty & /*data*/ 1 && a2_href_value !== (a2_href_value = "https://twitter.com/" + /*partner*/ ctx2[15].twitter)) { attr(a2, "href", a2_href_value); } }, d(detaching) { if (detaching) detach(div4); mounted = false; dispose(); } }; } function create_each_block_3(ctx) { let div0; let t0_value = ( /*level*/ ctx[12].name + "" ); let t0; let t1; let div1; function func(...args) { return ( /*func*/ ctx[1]( /*level*/ ctx[12], ...args ) ); } let each_value_4 = ( /*data*/ ctx[0].config.partners.filter(func) ); let each_blocks = []; for (let i2 = 0; i2 < each_value_4.length; i2 += 1) { each_blocks[i2] = create_each_block_4(get_each_context_4(ctx, each_value_4, i2)); } return { c() { div0 = element("div"); t0 = text(t0_value); t1 = space(); div1 = element("div"); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].c(); } this.h(); }, l(nodes) { div0 = claim_element(nodes, "DIV", { class: true }); var div0_nodes = children(div0); t0 = claim_text(div0_nodes, t0_value); div0_nodes.forEach(detach); t1 = claim_space(nodes); div1 = claim_element(nodes, "DIV", { class: true }); var div1_nodes = children(div1); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].l(div1_nodes); } div1_nodes.forEach(detach); this.h(); }, h() { attr(div0, "class", "lowercase pb-6 text-xl font-mono2"); attr(div1, "class", "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-2 mb-6"); }, m(target, anchor) { insert_hydration(target, div0, anchor); append_hydration(div0, t0); insert_hydration(target, t1, anchor); insert_hydration(target, div1, anchor); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].m(div1, null); } }, p(new_ctx, dirty) { ctx = new_ctx; if (dirty & /*data*/ 1 && t0_value !== (t0_value = /*level*/ ctx[12].name + "")) set_data(t0, t0_value); if (dirty & /*animateSection, data*/ 1) { each_value_4 = /*data*/ ctx[0].config.partners.filter(func); let i2; for (i2 = 0; i2 < each_value_4.length; i2 += 1) { const child_ctx = get_each_context_4(ctx, each_value_4, i2); if (each_blocks[i2]) { each_blocks[i2].p(child_ctx, dirty); } else { each_blocks[i2] = create_each_block_4(child_ctx); each_blocks[i2].c(); each_blocks[i2].m(div1, null); } } for (; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].d(1); } each_blocks.length = each_value_4.length; } }, d(detaching) { if (detaching) detach(div0); if (detaching) detach(t1); if (detaching) detach(div1); destroy_each(each_blocks, detaching); } }; } function create_each_block_2(ctx) { let li; let raw_value = ( /*ti*/ ctx[9] + "" ); return { c() { li = element("li"); this.h(); }, l(nodes) { li = claim_element(nodes, "LI", { class: true }); var li_nodes = children(li); li_nodes.forEach(detach); this.h(); }, h() { attr(li, "class", "mb-2 pl-2 text-sm"); }, m(target, anchor) { insert_hydration(target, li, anchor); li.innerHTML = raw_value; }, p(ctx2, dirty) { if (dirty & /*data*/ 1 && raw_value !== (raw_value = /*ti*/ ctx2[9] + "")) li.innerHTML = raw_value; }, d(detaching) { if (detaching) detach(li); } }; } function create_if_block_3(ctx) { let div; let t_value = ( /*tt*/ ctx[6].note + "" ); let t2; return { c() { div = element("div"); t2 = text(t_value); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); t2 = claim_text(div_nodes, t_value); div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "mt-10 text-sm"); }, m(target, anchor) { insert_hydration(target, div, anchor); append_hydration(div, t2); }, p(ctx2, dirty) { if (dirty & /*data*/ 1 && t_value !== (t_value = /*tt*/ ctx2[6].note + "")) set_data(t2, t_value); }, d(detaching) { if (detaching) detach(div); } }; } function create_if_block_2(ctx) { let div; let sveltemarkdown; let current; sveltemarkdown = new SvelteMarkdown({ props: { source: ( /*tt*/ ctx[6].hint ) } }); return { c() { div = element("div"); create_component(sveltemarkdown.$$.fragment); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); claim_component(sveltemarkdown.$$.fragment, div_nodes); div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "mt-10 markdown text-sm"); }, m(target, anchor) { insert_hydration(target, div, anchor); mount_component(sveltemarkdown, div, null); current = true; }, p(ctx2, dirty) { const sveltemarkdown_changes = {}; if (dirty & /*data*/ 1) sveltemarkdown_changes.source = /*tt*/ ctx2[6].hint; sveltemarkdown.$set(sveltemarkdown_changes); }, i(local) { if (current) return; transition_in(sveltemarkdown.$$.fragment, local); current = true; }, o(local) { transition_out(sveltemarkdown.$$.fragment, local); current = false; }, d(detaching) { if (detaching) detach(div); destroy_component(sveltemarkdown); } }; } function create_each_block_1(ctx) { let div5; let div0; let t0; let div1; let t1; let div4; let div2; let a0; let t2_value = ( /*tt*/ ctx[6].title + "" ); let t2; let a0_href_value; let t3; let div3; let a1; let t4_value = ( /*tt*/ ctx[6].price + "" ); let t4; let a1_href_value; let t5; let ul; let t6; let t7; let t8; let div5_class_value; let current; let mounted; let dispose; let each_value_2 = ( /*tt*/ ctx[6].includes ); let each_blocks = []; for (let i2 = 0; i2 < each_value_2.length; i2 += 1) { each_blocks[i2] = create_each_block_2(get_each_context_2(ctx, each_value_2, i2)); } let if_block0 = ( /*tt*/ ctx[6].note && create_if_block_3(ctx) ); let if_block1 = ( /*tt*/ ctx[6].hint && create_if_block_2(ctx) ); return { c() { div5 = element("div"); div0 = element("div"); t0 = space(); div1 = element("div"); t1 = space(); div4 = element("div"); div2 = element("div"); a0 = element("a"); t2 = text(t2_value); t3 = space(); div3 = element("div"); a1 = element("a"); t4 = text(t4_value); t5 = space(); ul = element("ul"); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].c(); } t6 = space(); if (if_block0) if_block0.c(); t7 = space(); if (if_block1) if_block1.c(); t8 = space(); this.h(); }, l(nodes) { div5 = claim_element(nodes, "DIV", { class: true }); var div5_nodes = children(div5); div0 = claim_element(div5_nodes, "DIV", { class: true }); children(div0).forEach(detach); t0 = claim_space(div5_nodes); div1 = claim_element(div5_nodes, "DIV", { class: true }); children(div1).forEach(detach); t1 = claim_space(div5_nodes); div4 = claim_element(div5_nodes, "DIV", { style: true }); var div4_nodes = children(div4); div2 = claim_element(div4_nodes, "DIV", { class: true }); var div2_nodes = children(div2); a0 = claim_element(div2_nodes, "A", { href: true, class: true }); var a0_nodes = children(a0); t2 = claim_text(a0_nodes, t2_value); a0_nodes.forEach(detach); div2_nodes.forEach(detach); t3 = claim_space(div4_nodes); div3 = claim_element(div4_nodes, "DIV", { class: true }); var div3_nodes = children(div3); a1 = claim_element(div3_nodes, "A", { href: true }); var a1_nodes = children(a1); t4 = claim_text(a1_nodes, t4_value); a1_nodes.forEach(detach); div3_nodes.forEach(detach); t5 = claim_space(div4_nodes); ul = claim_element(div4_nodes, "UL", { class: true }); var ul_nodes = children(ul); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].l(ul_nodes); } ul_nodes.forEach(detach); t6 = claim_space(div4_nodes); if (if_block0) if_block0.l(div4_nodes); t7 = claim_space(div4_nodes); if (if_block1) if_block1.l(div4_nodes); div4_nodes.forEach(detach); t8 = claim_space(div5_nodes); div5_nodes.forEach(detach); this.h(); }, h() { attr(div0, "class", "ticket-bg"); attr(div1, "class", "ticket-img"); attr(a0, "href", a0_href_value = /*data*/ ctx[0].config.ticketingUrl); attr(a0, "class", "animate-section font-mono2"); attr(div2, "class", "text-2xl uppercase ticket-title"); attr(a1, "href", a1_href_value = /*data*/ ctx[0].config.ticketingUrl); attr(div3, "class", "text-2xl mt-5 font-bold"); attr(ul, "class", "mt-8 text-left list-disc px-6"); set_style(div4, "z-index", "1"); attr(div5, "class", div5_class_value = "ticket-item " + /*tt*/ ctx[6].ticketTypeClass + " border py-10 px-10 hover:text-black " + /*data*/ (ctx[0].config.ticketing ? "cursor-pointer" : "")); }, m(target, anchor) { insert_hydration(target, div5, anchor); append_hydration(div5, div0); append_hydration(div5, t0); append_hydration(div5, div1); append_hydration(div5, t1); append_hydration(div5, div4); append_hydration(div4, div2); append_hydration(div2, a0); append_hydration(a0, t2); append_hydration(div4, t3); append_hydration(div4, div3); append_hydration(div3, a1); append_hydration(a1, t4); append_hydration(div4, t5); append_hydration(div4, ul); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].m(ul, null); } append_hydration(div4, t6); if (if_block0) if_block0.m(div4, null); append_hydration(div4, t7); if (if_block1) if_block1.m(div4, null); append_hydration(div5, t8); current = true; if (!mounted) { dispose = [ listen(div5, "mouseenter", animateSection(40)), listen( div5, "click", /*click_handler*/ ctx[2] ) ]; mounted = true; } }, p(ctx2, dirty) { if ((!current || dirty & /*data*/ 1) && t2_value !== (t2_value = /*tt*/ ctx2[6].title + "")) set_data(t2, t2_value); if (!current || dirty & /*data*/ 1 && a0_href_value !== (a0_href_value = /*data*/ ctx2[0].config.ticketingUrl)) { attr(a0, "href", a0_href_value); } if ((!current || dirty & /*data*/ 1) && t4_value !== (t4_value = /*tt*/ ctx2[6].price + "")) set_data(t4, t4_value); if (!current || dirty & /*data*/ 1 && a1_href_value !== (a1_href_value = /*data*/ ctx2[0].config.ticketingUrl)) { attr(a1, "href", a1_href_value); } if (dirty & /*data*/ 1) { each_value_2 = /*tt*/ ctx2[6].includes; let i2; for (i2 = 0; i2 < each_value_2.length; i2 += 1) { const child_ctx = get_each_context_2(ctx2, each_value_2, i2); if (each_blocks[i2]) { each_blocks[i2].p(child_ctx, dirty); } else { each_blocks[i2] = create_each_block_2(child_ctx); each_blocks[i2].c(); each_blocks[i2].m(ul, null); } } for (; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].d(1); } each_blocks.length = each_value_2.length; } if ( /*tt*/ ctx2[6].note ) { if (if_block0) { if_block0.p(ctx2, dirty); } else { if_block0 = create_if_block_3(ctx2); if_block0.c(); if_block0.m(div4, t7); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if ( /*tt*/ ctx2[6].hint ) { if (if_block1) { if_block1.p(ctx2, dirty); if (dirty & /*data*/ 1) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block_2(ctx2); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div4, null); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (!current || dirty & /*data*/ 1 && div5_class_value !== (div5_class_value = "ticket-item " + /*tt*/ ctx2[6].ticketTypeClass + " border py-10 px-10 hover:text-black " + /*data*/ (ctx2[0].config.ticketing ? "cursor-pointer" : ""))) { attr(div5, "class", div5_class_value); } }, i(local) { if (current) return; transition_in(if_block1); current = true; }, o(local) { transition_out(if_block1); current = false; }, d(detaching) { if (detaching) detach(div5); destroy_each(each_blocks, detaching); if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); mounted = false; run_all(dispose); } }; } function create_if_block_1(ctx) { let div; let a2; let button; let t2; let a_href_value; let mounted; let dispose; return { c() { div = element("div"); a2 = element("a"); button = element("button"); t2 = text("Buy a ticket"); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); a2 = claim_element(div_nodes, "A", { href: true }); var a_nodes = children(a2); button = claim_element(a_nodes, "BUTTON", { class: true }); var button_nodes = children(button); t2 = claim_text(button_nodes, "Buy a ticket"); button_nodes.forEach(detach); a_nodes.forEach(detach); div_nodes.forEach(detach); this.h(); }, h() { attr(button, "class", "button"); attr(a2, "href", a_href_value = /*data*/ ctx[0].config.ticketingUrl); attr(div, "class", "mt-10 text-xl"); }, m(target, anchor) { insert_hydration(target, div, anchor); append_hydration(div, a2); append_hydration(a2, button); append_hydration(button, t2); if (!mounted) { dispose = listen(button, "mouseenter", animateText); mounted = true; } }, p(ctx2, dirty) { if (dirty & /*data*/ 1 && a_href_value !== (a_href_value = /*data*/ ctx2[0].config.ticketingUrl)) { attr(a2, "href", a_href_value); } }, d(detaching) { if (detaching) detach(div); mounted = false; dispose(); } }; } function create_if_block(ctx) { let div; let t_value = ( /*data*/ ctx[0].config.ticketsNote + "" ); let t2; return { c() { div = element("div"); t2 = text(t_value); this.h(); }, l(nodes) { div = claim_element(nodes, "DIV", { class: true }); var div_nodes = children(div); t2 = claim_text(div_nodes, t_value); div_nodes.forEach(detach); this.h(); }, h() { attr(div, "class", "mt-8 text-xl"); }, m(target, anchor) { insert_hydration(target, div, anchor); append_hydration(div, t2); }, p(ctx2, dirty) { if (dirty & /*data*/ 1 && t_value !== (t_value = /*data*/ ctx2[0].config.ticketsNote + "")) set_data(t2, t_value); }, d(detaching) { if (detaching) detach(div); } }; } function create_each_block(ctx) { let div2; let div0; let t0_value = ( /*fi*/ ctx[3].title + "" ); let t0; let t1; let div1; let sveltemarkdown; let t2; let current; let mounted; let dispose; sveltemarkdown = new SvelteMarkdown({ props: { source: ( /*fi*/ ctx[3].text ) } }); return { c() { div2 = element("div"); div0 = element("div"); t0 = text(t0_value); t1 = space(); div1 = element("div"); create_component(sveltemarkdown.$$.fragment); t2 = space(); this.h(); }, l(nodes) { div2 = claim_element(nodes, "DIV", { class: true }); var div2_nodes = children(div2); div0 = claim_element(div2_nodes, "DIV", { class: true }); var div0_nodes = children(div0); t0 = claim_text(div0_nodes, t0_value); div0_nodes.forEach(detach); t1 = claim_space(div2_nodes); div1 = claim_element(div2_nodes, "DIV", { class: true }); var div1_nodes = children(div1); claim_component(sveltemarkdown.$$.fragment, div1_nodes); div1_nodes.forEach(detach); t2 = claim_space(div2_nodes); div2_nodes.forEach(detach); this.h(); }, h() { attr(div0, "class", "text-xl mb-6 animate-section"); attr(div1, "class", "markdown text-sm text-mild desc leading-6"); attr(div2, "class", "faq-item cursor-help"); }, m(target, anchor) { insert_hydration(target, div2, anchor); append_hydration(div2, div0); append_hydration(div0, t0); append_hydration(div2, t1); append_hydration(div2, div1); mount_component(sveltemarkdown, div1, null); append_hydration(div2, t2); current = true; if (!mounted) { dispose = listen(div2, "mouseenter", animateSection(15)); mounted = true; } }, p(ctx2, dirty) { if ((!current || dirty & /*data*/ 1) && t0_value !== (t0_value = /*fi*/ ctx2[3].title + "")) set_data(t0, t0_value); const sveltemarkdown_changes = {}; if (dirty & /*data*/ 1) sveltemarkdown_changes.source = /*fi*/ ctx2[3].text; sveltemarkdown.$set(sveltemarkdown_changes); }, i(local) { if (current) return; transition_in(sveltemarkdown.$$.fragment, local); current = true; }, o(local) { transition_out(sveltemarkdown.$$.fragment, local); current = false; }, d(detaching) { if (detaching) detach(div2); destroy_component(sveltemarkdown); mounted = false; dispose(); } }; } function create_fragment(ctx) { let title_value; let meta0; let meta0_content_value; let meta1; let meta2; let meta2_content_value; let meta3; let meta3_content_value; let meta4; let meta4_content_value; let meta5; let meta5_content_value; let meta6; let meta6_content_value; let meta7; let meta7_content_value; let meta8; let meta8_content_value; let meta9; let meta9_content_value; let t0; let div5; let div4; let div1; let p2; let t1_value = ( /*data*/ ctx[0].config.intro_first + "" ); let t1; let t2; let div0; let sveltemarkdown; let t3; let div2; let t4; let t5; let div3; let t6; let div9; let div8; let div6; let t7; let t8; let div7; let peoplelist0; let t9; let t10; let div13; let div12; let div10; let t11; let t12; let div11; let peoplelist1; let t13; let div17; let div16; let div14; let t14; let t15; let t16; let div15; let a2; let button; let t17; let a_href_value; let t18; let div25; let div21; let div18; let t19; let t20; let div19; let t21_value = ( /*data*/ ctx[0].config.ticketsIntro + "" ); let t21; let t22; let div20; let t23; let t24; let t25; let div24; let div22; let t26; let t27; let div23; let web3dialog; let t28; let div29; let div28; let div26; let t29; let t30; let div27; let current; let mounted; let dispose; document.title = title_value = /*data*/ ctx[0].config.title + " | " + /*data*/ ctx[0].config.date; sveltemarkdown = new SvelteMarkdown({ props: { source: ( /*data*/ ctx[0].config.intro ) } }); let each_value_5 = ( /*data*/ ctx[0].config.themes ); let each_blocks_3 = []; for (let i2 = 0; i2 < each_value_5.length; i2 += 1) { each_blocks_3[i2] = create_each_block_5(get_each_context_5(ctx, each_value_5, i2)); } const out = (i2) => transition_out(each_blocks_3[i2], 1, 1, () => { each_blocks_3[i2] = null; }); peoplelist0 = new PeopleList({ props: { items: ( /*data*/ ctx[0].config.speakers ), people: ( /*data*/ ctx[0].config.people ) } }); let if_block0 = ( /*data*/ ctx[0].config.speakersNote && create_if_block_4(ctx) ); peoplelist1 = new PeopleList({ props: { items: ( /*data*/ ctx[0].config.hosts ), people: ( /*data*/ ctx[0].config.people ), size: "small" } }); let each_value_3 = ( /*data*/ ctx[0].config.partnerLevels ); let each_blocks_2 = []; for (let i2 = 0; i2 < each_value_3.length; i2 += 1) { each_blocks_2[i2] = create_each_block_3(get_each_context_3(ctx, each_value_3, i2)); } let each_value_1 = ( /*data*/ ctx[0].config.tickets ); let each_blocks_1 = []; for (let i2 = 0; i2 < each_value_1.length; i2 += 1) { each_blocks_1[i2] = create_each_block_1(get_each_context_1(ctx, each_value_1, i2)); } const out_1 = (i2) => transition_out(each_blocks_1[i2], 1, 1, () => { each_blocks_1[i2] = null; }); let if_block1 = ( /*data*/ ctx[0].config.ticketing && create_if_block_1(ctx) ); let if_block2 = ( /*data*/ ctx[0].config.ticketsNote && create_if_block(ctx) ); web3dialog = new Web3Dialog({ props: { data: ( /*data*/ ctx[0] ) } }); let each_value = ( /*data*/ ctx[0].config.faq ); let each_blocks = []; for (let i2 = 0; i2 < each_value.length; i2 += 1) { each_blocks[i2] = create_each_block(get_each_context(ctx, each_value, i2)); } const out_2 = (i2) => transition_out(each_blocks[i2], 1, 1, () => { each_blocks[i2] = null; }); return { c() { meta0 = element("meta"); meta1 = element("meta"); meta2 = element("meta"); meta3 = element("meta"); meta4 = element("meta"); meta5 = element("meta"); meta6 = element("meta"); meta7 = element("meta"); meta8 = element("meta"); meta9 = element("meta"); t0 = space(); div5 = element("div"); div4 = element("div"); div1 = element("div"); p2 = element("p"); t1 = text(t1_value); t2 = space(); div0 = element("div"); create_component(sveltemarkdown.$$.fragment); t3 = space(); div2 = element("div"); t4 = text("Main topics"); t5 = space(); div3 = element("div"); for (let i2 = 0; i2 < each_blocks_3.length; i2 += 1) { each_blocks_3[i2].c(); } t6 = space(); div9 = element("div"); div8 = element("div"); div6 = element("div"); t7 = text("Speakers"); t8 = space(); div7 = element("div"); create_component(peoplelist0.$$.fragment); t9 = space(); if (if_block0) if_block0.c(); t10 = space(); div13 = element("div"); div12 = element("div"); div10 = element("div"); t11 = text("Hosts"); t12 = space(); div11 = element("div"); create_component(peoplelist1.$$.fragment); t13 = space(); div17 = element("div"); div16 = element("div"); div14 = element("div"); t14 = text("Partners"); t15 = space(); for (let i2 = 0; i2 < each_blocks_2.length; i2 += 1) { each_blocks_2[i2].c(); } t16 = space(); div15 = element("div"); a2 = element("a"); button = element("button"); t17 = text("Become a partner"); t18 = space(); div25 = element("div"); div21 = element("div"); div18 = element("div"); t19 = text("Ticket"); t20 = space(); div19 = element("div"); t21 = text(t21_value); t22 = space(); div20 = element("div"); for (let i2 = 0; i2 < each_blocks_1.length; i2 += 1) { each_blocks_1[i2].c(); } t23 = space(); if (if_block1) if_block1.c(); t24 = space(); if (if_block2) if_block2.c(); t25 = space(); div24 = element("div"); div22 = element("div"); t26 = text("Get your discount"); t27 = space(); div23 = element("div"); create_component(web3dialog.$$.fragment); t28 = space(); div29 = element("div"); div28 = element("div"); div26 = element("div"); t29 = text("FAQ"); t30 = space(); div27 = element("div"); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].c(); } this.h(); }, l(nodes) { const head_nodes = head_selector("svelte-z1gllm", document.head); meta0 = claim_element(head_nodes, "META", { name: true, content: true }); meta1 = claim_element(head_nodes, "META", { name: true, content: true }); meta2 = claim_element(head_nodes, "META", { name: true, content: true }); meta3 = claim_element(head_nodes, "META", { name: true, content: true }); meta4 = claim_element(head_nodes, "META", { name: true, content: true }); meta5 = claim_element(head_nodes, "META", { name: true, content: true }); meta6 = claim_element(head_nodes, "META", { name: true, content: true }); meta7 = claim_element(head_nodes, "META", { name: true, content: true }); meta8 = claim_element(head_nodes, "META", { name: true, content: true }); meta9 = claim_element(head_nodes, "META", { name: true, content: true }); head_nodes.forEach(detach); t0 = claim_space(nodes); div5 = claim_element(nodes, "DIV", { class: true, id: true }); var div5_nodes = children(div5); div4 = claim_element(div5_nodes, "DIV", { class: true }); var div4_nodes = children(div4); div1 = claim_element(div4_nodes, "DIV", { class: true }); var div1_nodes = children(div1); p2 = claim_element(div1_nodes, "P", { class: true }); var p_nodes = children(p2); t1 = claim_text(p_nodes, t1_value); p_nodes.forEach(detach); t2 = claim_space(div1_nodes); div0 = claim_element(div1_nodes, "DIV", { class: true }); var div0_nodes = children(div0); claim_component(sveltemarkdown.$$.fragment, div0_nodes); div0_nodes.forEach(detach); div1_nodes.forEach(detach); t3 = claim_space(div4_nodes); div2 = claim_element(div4_nodes, "DIV", { class: true }); var div2_nodes = children(div2); t4 = claim_text(div2_nodes, "Main topics"); div2_nodes.forEach(detach); t5 = claim_space(div4_nodes); div3 = claim_element(div4_nodes, "DIV", { class: true }); var div3_nodes = children(div3); for (let i2 = 0; i2 < each_blocks_3.length; i2 += 1) { each_blocks_3[i2].l(div3_nodes); } div3_nodes.forEach(detach); div4_nodes.forEach(detach); div5_nodes.forEach(detach); t6 = claim_space(nodes); div9 = claim_element(nodes, "DIV", { class: true, id: true }); var div9_nodes = children(div9); div8 = claim_element(div9_nodes, "DIV", { class: true }); var div8_nodes = children(div8); div6 = claim_element(div8_nodes, "DIV", { class: true }); var div6_nodes = children(div6); t7 = claim_text(div6_nodes, "Speakers"); div6_nodes.forEach(detach); t8 = claim_space(div8_nodes); div7 = claim_element(div8_nodes, "DIV", { class: true }); var div7_nodes = children(div7); claim_component(peoplelist0.$$.fragment, div7_nodes); div7_nodes.forEach(detach); t9 = claim_space(div8_nodes); if (if_block0) if_block0.l(div8_nodes); div8_nodes.forEach(detach); div9_nodes.forEach(detach); t10 = claim_space(nodes); div13 = claim_element(nodes, "DIV", { id: true }); var div13_nodes = children(div13); div12 = claim_element(div13_nodes, "DIV", { class: true }); var div12_nodes = children(div12); div10 = claim_element(div12_nodes, "DIV", { class: true }); var div10_nodes = children(div10); t11 = claim_text(div10_nodes, "Hosts"); div10_nodes.forEach(detach); t12 = claim_space(div12_nodes); div11 = claim_element(div12_nodes, "DIV", { class: true }); var div11_nodes = children(div11); claim_component(peoplelist1.$$.fragment, div11_nodes); div11_nodes.forEach(detach); div12_nodes.forEach(detach); div13_nodes.forEach(detach); t13 = claim_space(nodes); div17 = claim_element(nodes, "DIV", { class: true, id: true }); var div17_nodes = children(div17); div16 = claim_element(div17_nodes, "DIV", { class: true }); var div16_nodes = children(div16); div14 = claim_element(div16_nodes, "DIV", { class: true }); var div14_nodes = children(div14); t14 = claim_text(div14_nodes, "Partners"); div14_nodes.forEach(detach); t15 = claim_space(div16_nodes); for (let i2 = 0; i2 < each_blocks_2.length; i2 += 1) { each_blocks_2[i2].l(div16_nodes); } t16 = claim_space(div16_nodes); div15 = claim_element(div16_nodes, "DIV", { class: true }); var div15_nodes = children(div15); a2 = claim_element(div15_nodes, "A", { href: true }); var a_nodes = children(a2); button = claim_element(a_nodes, "BUTTON", { class: true }); var button_nodes = children(button); t17 = claim_text(button_nodes, "Become a partner"); button_nodes.forEach(detach); a_nodes.forEach(detach); div15_nodes.forEach(detach); div16_nodes.forEach(detach); div17_nodes.forEach(detach); t18 = claim_space(nodes); div25 = claim_element(nodes, "DIV", { class: true, id: true }); var div25_nodes = children(div25); div21 = claim_element(div25_nodes, "DIV", { class: true }); var div21_nodes = children(div21); div18 = claim_element(div21_nodes, "DIV", { class: true }); var div18_nodes = children(div18); t19 = claim_text(div18_nodes, "Ticket"); div18_nodes.forEach(detach); t20 = claim_space(div21_nodes); div19 = claim_element(div21_nodes, "DIV", { class: true }); var div19_nodes = children(div19); t21 = claim_text(div19_nodes, t21_value); div19_nodes.forEach(detach); t22 = claim_space(div21_nodes); div20 = claim_element(div21_nodes, "DIV", { class: true }); var div20_nodes = children(div20); for (let i2 = 0; i2 < each_blocks_1.length; i2 += 1) { each_blocks_1[i2].l(div20_nodes); } div20_nodes.forEach(detach); t23 = claim_space(div21_nodes); if (if_block1) if_block1.l(div21_nodes); t24 = claim_space(div21_nodes); if (if_block2) if_block2.l(div21_nodes); div21_nodes.forEach(detach); t25 = claim_space(div25_nodes); div24 = claim_element(div25_nodes, "DIV", { class: true }); var div24_nodes = children(div24); div22 = claim_element(div24_nodes, "DIV", { class: true }); var div22_nodes = children(div22); t26 = claim_text(div22_nodes, "Get your discount"); div22_nodes.forEach(detach); t27 = claim_space(div24_nodes); div23 = claim_element(div24_nodes, "DIV", {}); var div23_nodes = children(div23); claim_component(web3dialog.$$.fragment, div23_nodes); div23_nodes.forEach(detach); div24_nodes.forEach(detach); div25_nodes.forEach(detach); t28 = claim_space(nodes); div29 = claim_element(nodes, "DIV", { class: true, id: true }); var div29_nodes = children(div29); div28 = claim_element(div29_nodes, "DIV", { class: true }); var div28_nodes = children(div28); div26 = claim_element(div28_nodes, "DIV", { class: true }); var div26_nodes = children(div26); t29 = claim_text(div26_nodes, "FAQ"); div26_nodes.forEach(detach); t30 = claim_space(div28_nodes); div27 = claim_element(div28_nodes, "DIV", { class: true }); var div27_nodes = children(div27); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].l(div27_nodes); } div27_nodes.forEach(detach); div28_nodes.forEach(detach); div29_nodes.forEach(detach); this.h(); }, h() { attr(meta0, "name", "description"); attr(meta0, "content", meta0_content_value = /*data*/ ctx[0].config.desc); attr(meta1, "name", "twitter:card"); attr(meta1, "content", "summary"); attr(meta2, "name", "twitter:site"); attr(meta2, "content", meta2_content_value = "@" + /*data*/ ctx[0].config.twitter); attr(meta3, "name", "twitter:title"); attr(meta3, "content", meta3_content_value = /*data*/ ctx[0].config.title); attr(meta4, "name", "twitter:description"); attr(meta4, "content", meta4_content_value = /*data*/ ctx[0].config.desc); attr(meta5, "name", "twitter:image"); attr(meta5, "content", meta5_content_value = "https://" + /*data*/ ctx[0].config.domain + /*data*/ ctx[0].config.image); attr(meta6, "name", "og:url"); attr(meta6, "content", meta6_content_value = "https://" + /*data*/ ctx[0].config.domain); attr(meta7, "name", "og:title"); attr(meta7, "content", meta7_content_value = /*data*/ ctx[0].config.title); attr(meta8, "name", "og:description"); attr(meta8, "content", meta8_content_value = /*data*/ ctx[0].config.desc); attr(meta9, "name", "og:image"); attr(meta9, "content", meta9_content_value = "https://" + /*data*/ ctx[0].config.domain + /*data*/ ctx[0].config.image); attr(p2, "class", "animate-section text-white font-mono2 lowercase"); attr(div0, "class", "markdown multiline pt-10"); attr(div1, "class", "py-16 md:py-32 md:w-5/6 mx-auto text-mild"); attr(div2, "class", "section-header"); attr(div3, "class", "grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-4 md:gap-6"); attr(div4, "class", "middle-pane-medium pb-16 mx-auto"); attr(div5, "class", "bg-black"); attr(div5, "id", "about"); attr(div6, "class", "section-header"); attr(div7, "class", "mx-auto"); attr(div8, "class", "middle-pane-medium pt-16 mx-auto mb-8"); attr(div9, "class", "bg-black"); attr(div9, "id", "speakers"); attr(div10, "class", "section-header"); attr(div11, "class", "mx-auto"); attr(div12, "class", "middle-pane-medium pt-0 mx-auto pb-32"); attr(div13, "id", "hosts"); attr(div14, "class", "section-header"); attr(button, "class", "button text-lg"); attr(a2, "href", a_href_value = /*data*/ ctx[0].config.sponsorUrl); attr(div15, "class", "mt-10"); attr(div16, "class", "middle-pane-medium pt-16 mx-auto pb-24"); attr(div17, "class", ""); attr(div17, "id", "sponsors"); attr(div18, "class", "section-header"); attr(div19, "class", "mb-8 text-mild"); attr(div20, "class", "grid lg:grid-cols-2 gap-10 mx-auto"); attr(div21, "class", "middle-pane-medium pt-16 mx-auto"); attr(div22, "class", "section-subheader"); attr(div24, "class", "middle-pane-medium mx-auto pt-20 pb-32"); attr(div25, "class", ""); attr(div25, "id", "ticket"); attr(div26, "class", "section-header"); attr(div27, "class", "grid md:grid-cols-2 gap-8 md:gap-16"); attr(div28, "class", "middle-pane-medium pt-20 mx-auto"); attr(div29, "class", "pb-36 bg-[#0e0e0e]"); attr(div29, "id", "faq"); }, m(target, anchor) { append_hydration(document.head, meta0); append_hydration(document.head, meta1); append_hydration(document.head, meta2); append_hydration(document.head, meta3); append_hydration(document.head, meta4); append_hydration(document.head, meta5); append_hydration(document.head, meta6); append_hydration(document.head, meta7); append_hydration(document.head, meta8); append_hydration(document.head, meta9); insert_hydration(target, t0, anchor); insert_hydration(target, div5, anchor); append_hydration(div5, div4); append_hydration(div4, div1); append_hydration(div1, p2); append_hydration(p2, t1); append_hydration(div1, t2); append_hydration(div1, div0); mount_component(sveltemarkdown, div0, null); append_hydration(div4, t3); append_hydration(div4, div2); append_hydration(div2, t4); append_hydration(div4, t5); append_hydration(div4, div3); for (let i2 = 0; i2 < each_blocks_3.length; i2 += 1) { each_blocks_3[i2].m(div3, null); } insert_hydration(target, t6, anchor); insert_hydration(target, div9, anchor); append_hydration(div9, div8); append_hydration(div8, div6); append_hydration(div6, t7); append_hydration(div8, t8); append_hydration(div8, div7); mount_component(peoplelist0, div7, null); append_hydration(div8, t9); if (if_block0) if_block0.m(div8, null); insert_hydration(target, t10, anchor); insert_hydration(target, div13, anchor); append_hydration(div13, div12); append_hydration(div12, div10); append_hydration(div10, t11); append_hydration(div12, t12); append_hydration(div12, div11); mount_component(peoplelist1, div11, null); insert_hydration(target, t13, anchor); insert_hydration(target, div17, anchor); append_hydration(div17, div16); append_hydration(div16, div14); append_hydration(div14, t14); append_hydration(div16, t15); for (let i2 = 0; i2 < each_blocks_2.length; i2 += 1) { each_blocks_2[i2].m(div16, null); } append_hydration(div16, t16); append_hydration(div16, div15); append_hydration(div15, a2); append_hydration(a2, button); append_hydration(button, t17); insert_hydration(target, t18, anchor); insert_hydration(target, div25, anchor); append_hydration(div25, div21); append_hydration(div21, div18); append_hydration(div18, t19); append_hydration(div21, t20); append_hydration(div21, div19); append_hydration(div19, t21); append_hydration(div21, t22); append_hydration(div21, div20); for (let i2 = 0; i2 < each_blocks_1.length; i2 += 1) { each_blocks_1[i2].m(div20, null); } append_hydration(div21, t23); if (if_block1) if_block1.m(div21, null); append_hydration(div21, t24); if (if_block2) if_block2.m(div21, null); append_hydration(div25, t25); append_hydration(div25, div24); append_hydration(div24, div22); append_hydration(div22, t26); append_hydration(div24, t27); append_hydration(div24, div23); mount_component(web3dialog, div23, null); insert_hydration(target, t28, anchor); insert_hydration(target, div29, anchor); append_hydration(div29, div28); append_hydration(div28, div26); append_hydration(div26, t29); append_hydration(div28, t30); append_hydration(div28, div27); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { each_blocks[i2].m(div27, null); } current = true; if (!mounted) { dispose = [ listen(div1, "mouseenter", animateSection(15)), listen(div2, "mouseenter", animateText), listen(div6, "mouseenter", animateText), listen(div10, "mouseenter", animateText), listen(div14, "mouseenter", animateText), listen(button, "mouseenter", animateText), listen(div18, "mouseenter", animateText), listen(div22, "mouseenter", animateText), listen(div26, "mouseenter", animateText) ]; mounted = true; } }, p(ctx2, [dirty]) { if ((!current || dirty & /*data*/ 1) && title_value !== (title_value = /*data*/ ctx2[0].config.title + " | " + /*data*/ ctx2[0].config.date)) { document.title = title_value; } if (!current || dirty & /*data*/ 1 && meta0_content_value !== (meta0_content_value = /*data*/ ctx2[0].config.desc)) { attr(meta0, "content", meta0_content_value); } if (!current || dirty & /*data*/ 1 && meta2_content_value !== (meta2_content_value = "@" + /*data*/ ctx2[0].config.twitter)) { attr(meta2, "content", meta2_content_value); } if (!current || dirty & /*data*/ 1 && meta3_content_value !== (meta3_content_value = /*data*/ ctx2[0].config.title)) { attr(meta3, "content", meta3_content_value); } if (!current || dirty & /*data*/ 1 && meta4_content_value !== (meta4_content_value = /*data*/ ctx2[0].config.desc)) { attr(meta4, "content", meta4_content_value); } if (!current || dirty & /*data*/ 1 && meta5_content_value !== (meta5_content_value = "https://" + /*data*/ ctx2[0].config.domain + /*data*/ ctx2[0].config.image)) { attr(meta5, "content", meta5_content_value); } if (!current || dirty & /*data*/ 1 && meta6_content_value !== (meta6_content_value = "https://" + /*data*/ ctx2[0].config.domain)) { attr(meta6, "content", meta6_content_value); } if (!current || dirty & /*data*/ 1 && meta7_content_value !== (meta7_content_value = /*data*/ ctx2[0].config.title)) { attr(meta7, "content", meta7_content_value); } if (!current || dirty & /*data*/ 1 && meta8_content_value !== (meta8_content_value = /*data*/ ctx2[0].config.desc)) { attr(meta8, "content", meta8_content_value); } if (!current || dirty & /*data*/ 1 && meta9_content_value !== (meta9_content_value = "https://" + /*data*/ ctx2[0].config.domain + /*data*/ ctx2[0].config.image)) { attr(meta9, "content", meta9_content_value); } if ((!current || dirty & /*data*/ 1) && t1_value !== (t1_value = /*data*/ ctx2[0].config.intro_first + "")) set_data(t1, t1_value); const sveltemarkdown_changes = {}; if (dirty & /*data*/ 1) sveltemarkdown_changes.source = /*data*/ ctx2[0].config.intro; sveltemarkdown.$set(sveltemarkdown_changes); if (dirty & /*animateSection, data*/ 1) { each_value_5 = /*data*/ ctx2[0].config.themes; let i2; for (i2 = 0; i2 < each_value_5.length; i2 += 1) { const child_ctx = get_each_context_5(ctx2, each_value_5, i2); if (each_blocks_3[i2]) { each_blocks_3[i2].p(child_ctx, dirty); transition_in(each_blocks_3[i2], 1); } else { each_blocks_3[i2] = create_each_block_5(child_ctx); each_blocks_3[i2].c(); transition_in(each_blocks_3[i2], 1); each_blocks_3[i2].m(div3, null); } } group_outros(); for (i2 = each_value_5.length; i2 < each_blocks_3.length; i2 += 1) { out(i2); } check_outros(); } const peoplelist0_changes = {}; if (dirty & /*data*/ 1) peoplelist0_changes.items = /*data*/ ctx2[0].config.speakers; if (dirty & /*data*/ 1) peoplelist0_changes.people = /*data*/ ctx2[0].config.people; peoplelist0.$set(peoplelist0_changes); if ( /*data*/ ctx2[0].config.speakersNote ) { if (if_block0) { if_block0.p(ctx2, dirty); } else { if_block0 = create_if_block_4(ctx2); if_block0.c(); if_block0.m(div8, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } const peoplelist1_changes = {}; if (dirty & /*data*/ 1) peoplelist1_changes.items = /*data*/ ctx2[0].config.hosts; if (dirty & /*data*/ 1) peoplelist1_changes.people = /*data*/ ctx2[0].config.people; peoplelist1.$set(peoplelist1_changes); if (dirty & /*data, animateSection*/ 1) { each_value_3 = /*data*/ ctx2[0].config.partnerLevels; let i2; for (i2 = 0; i2 < each_value_3.length; i2 += 1) { const child_ctx = get_each_context_3(ctx2, each_value_3, i2); if (each_blocks_2[i2]) { each_blocks_2[i2].p(child_ctx, dirty); } else { each_blocks_2[i2] = create_each_block_3(child_ctx); each_blocks_2[i2].c(); each_blocks_2[i2].m(div16, t16); } } for (; i2 < each_blocks_2.length; i2 += 1) { each_blocks_2[i2].d(1); } each_blocks_2.length = each_value_3.length; } if (!current || dirty & /*data*/ 1 && a_href_value !== (a_href_value = /*data*/ ctx2[0].config.sponsorUrl)) { attr(a2, "href", a_href_value); } if ((!current || dirty & /*data*/ 1) && t21_value !== (t21_value = /*data*/ ctx2[0].config.ticketsIntro + "")) set_data(t21, t21_value); if (dirty & /*data, animateSection, goto*/ 1) { each_value_1 = /*data*/ ctx2[0].config.tickets; let i2; for (i2 = 0; i2 < each_value_1.length; i2 += 1) { const child_ctx = get_each_context_1(ctx2, each_value_1, i2); if (each_blocks_1[i2]) { each_blocks_1[i2].p(child_ctx, dirty); transition_in(each_blocks_1[i2], 1); } else { each_blocks_1[i2] = create_each_block_1(child_ctx); each_blocks_1[i2].c(); transition_in(each_blocks_1[i2], 1); each_blocks_1[i2].m(div20, null); } } group_outros(); for (i2 = each_value_1.length; i2 < each_blocks_1.length; i2 += 1) { out_1(i2); } check_outros(); } if ( /*data*/ ctx2[0].config.ticketing ) { if (if_block1) { if_block1.p(ctx2, dirty); } else { if_block1 = create_if_block_1(ctx2); if_block1.c(); if_block1.m(div21, t24); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if ( /*data*/ ctx2[0].config.ticketsNote ) { if (if_block2) { if_block2.p(ctx2, dirty); } else { if_block2 = create_if_block(ctx2); if_block2.c(); if_block2.m(div21, null); } } else if (if_block2) { if_block2.d(1); if_block2 = null; } const web3dialog_changes = {}; if (dirty & /*data*/ 1) web3dialog_changes.data = /*data*/ ctx2[0]; web3dialog.$set(web3dialog_changes); if (dirty & /*animateSection, data*/ 1) { each_value = /*data*/ ctx2[0].config.faq; let i2; for (i2 = 0; i2 < each_value.length; i2 += 1) { const child_ctx = get_each_context(ctx2, each_value, i2); if (each_blocks[i2]) { each_blocks[i2].p(child_ctx, dirty); transition_in(each_blocks[i2], 1); } else { each_blocks[i2] = create_each_block(child_ctx); each_blocks[i2].c(); transition_in(each_blocks[i2], 1); each_blocks[i2].m(div27, null); } } group_outros(); for (i2 = each_value.length; i2 < each_blocks.length; i2 += 1) { out_2(i2); } check_outros(); } }, i(local) { if (current) return; transition_in(sveltemarkdown.$$.fragment, local); for (let i2 = 0; i2 < each_value_5.length; i2 += 1) { transition_in(each_blocks_3[i2]); } transition_in(peoplelist0.$$.fragment, local); transition_in(peoplelist1.$$.fragment, local); for (let i2 = 0; i2 < each_value_1.length; i2 += 1) { transition_in(each_blocks_1[i2]); } transition_in(web3dialog.$$.fragment, local); for (let i2 = 0; i2 < each_value.length; i2 += 1) { transition_in(each_blocks[i2]); } current = true; }, o(local) { transition_out(sveltemarkdown.$$.fragment, local); each_blocks_3 = each_blocks_3.filter(Boolean); for (let i2 = 0; i2 < each_blocks_3.length; i2 += 1) { transition_out(each_blocks_3[i2]); } transition_out(peoplelist0.$$.fragment, local); transition_out(peoplelist1.$$.fragment, local); each_blocks_1 = each_blocks_1.filter(Boolean); for (let i2 = 0; i2 < each_blocks_1.length; i2 += 1) { transition_out(each_blocks_1[i2]); } transition_out(web3dialog.$$.fragment, local); each_blocks = each_blocks.filter(Boolean); for (let i2 = 0; i2 < each_blocks.length; i2 += 1) { transition_out(each_blocks[i2]); } current = false; }, d(detaching) { detach(meta0); detach(meta1); detach(meta2); detach(meta3); detach(meta4); detach(meta5); detach(meta6); detach(meta7); detach(meta8); detach(meta9); if (detaching) detach(t0); if (detaching) detach(div5); destroy_component(sveltemarkdown); destroy_each(each_blocks_3, detaching); if (detaching) detach(t6); if (detaching) detach(div9); destroy_component(peoplelist0); if (if_block0) if_block0.d(); if (detaching) detach(t10); if (detaching) detach(div13); destroy_component(peoplelist1); if (detaching) detach(t13); if (detaching) detach(div17); destroy_each(each_blocks_2, detaching); if (detaching) detach(t18); if (detaching) detach(div25); destroy_each(each_blocks_1, detaching); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); destroy_component(web3dialog); if (detaching) detach(t28); if (detaching) detach(div29); destroy_each(each_blocks, detaching); mounted = false; run_all(dispose); } }; } function instance($$self, $$props, $$invalidate) { let { data } = $$props; const func = (level, p2) => p2.level == level.key; const click_handler = () => data.config.ticketing ? goto(data.config.ticketingUrl) : false; $$self.$$set = ($$props2) => { if ("data" in $$props2) $$invalidate(0, data = $$props2.data); }; return [data, func, click_handler]; } class Page extends SvelteComponent { constructor(options) { super(); init(this, options, instance, create_fragment, safe_not_equal, { data: 0 }); } } export { A, EventEmitter as E, L, Page as P, W, a$1 as a, P2 as b, buffer as c, d$1 as d, commonjsGlobal as e, bnExports as f, g, getAugmentedNamespace as h, inherits_browserExports as i, getDefaultExportFromCjs as j, k, base64Js as l, ieee754 as m, require$$1$1 as r, sha3Exports as s };